use of android.support.v4.app.NotificationCompat.Builder in project NetGuard by M66B.
the class ServiceSinkhole method showErrorNotification.
private void showErrorNotification(String message) {
Intent main = new Intent(this, ActivityMain.class);
PendingIntent pi = PendingIntent.getActivity(this, 0, main, PendingIntent.FLAG_UPDATE_CURRENT);
TypedValue tv = new TypedValue();
getTheme().resolveAttribute(R.attr.colorOff, tv, true);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_error_white_24dp).setContentTitle(getString(R.string.app_name)).setContentText(getString(R.string.msg_error, message)).setContentIntent(pi).setColor(tv.data).setOngoing(false).setAutoCancel(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder.setCategory(Notification.CATEGORY_STATUS).setVisibility(Notification.VISIBILITY_SECRET);
}
NotificationCompat.BigTextStyle notification = new NotificationCompat.BigTextStyle(builder);
notification.bigText(getString(R.string.msg_error, message));
notification.setSummaryText(message);
NotificationManagerCompat.from(this).notify(NOTIFY_ERROR, notification.build());
}
use of android.support.v4.app.NotificationCompat.Builder in project Talon-for-Twitter by klinker24.
the class TweetPager method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
case R.id.menu_save_tweet:
saveTweet();
return true;
case R.id.menu_remove_saved_tweet:
removeSavedTweet();
return true;
case R.id.menu_delete_tweet:
new DeleteTweet().execute();
getSharedPreferences("com.klinker.android.twitter_world_preferences", 0).edit().putBoolean("just_muted", true).commit();
return true;
case R.id.menu_share:
String text1 = tweet;
text1 = "@" + screenName + ": " + text1 + "\n\n" + "https://twitter.com/" + screenName + "/status/" + tweetId;
Log.v("my_text_on_share", text1);
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("text/plain");
share.putExtra(Intent.EXTRA_TEXT, text1);
startActivity(share);
return true;
case R.id.menu_copy_text:
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("tweet_text", tweet);
clipboard.setPrimaryClip(clip);
return true;
case R.id.menu_save_image:
new Thread(new Runnable() {
@Override
public void run() {
Looper.prepare();
try {
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context, TALON_SERVICE_CHANNEL_ID).setSmallIcon(R.drawable.ic_stat_icon).setTicker(getResources().getString(R.string.downloading) + "...").setContentTitle(getResources().getString(R.string.app_name)).setContentText(getResources().getString(R.string.saving_picture) + "...").setProgress(100, 100, true).setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_action_save));
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(6, mBuilder.build());
String url = webpage;
if (webpage.contains("insta")) {
url = url.substring(0, url.length() - 1) + "l";
}
URL mUrl = new URL(url);
Bitmap bitmap = BitmapFactory.decodeStream(mUrl.openConnection().getInputStream());
Random generator = new Random();
int n = 1000000;
n = generator.nextInt(n);
String fname = "Image-" + n;
Uri uri = IOUtils.saveImage(bitmap, fname, context);
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(uri, "image/*");
PendingIntent pending = PendingIntent.getActivity(context, 91, intent, 0);
mBuilder = new NotificationCompat.Builder(context, TALON_SERVICE_CHANNEL_ID).setContentIntent(pending).setSmallIcon(R.drawable.ic_stat_icon).setTicker(getResources().getString(R.string.saved_picture) + "...").setContentTitle(getResources().getString(R.string.app_name)).setContentText(getResources().getString(R.string.saved_picture) + "!").setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_action_save));
mNotificationManager.notify(6, mBuilder.build());
} catch (Exception e) {
e.printStackTrace();
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context, TALON_SERVICE_CHANNEL_ID).setSmallIcon(R.drawable.ic_stat_icon).setTicker(getResources().getString(R.string.error) + "...").setContentTitle(getResources().getString(R.string.app_name)).setContentText(getResources().getString(R.string.error) + "...").setProgress(100, 100, true).setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_action_save));
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(6, mBuilder.build());
}
}
}).start();
return true;
case R.id.menu_quote:
String text = tweet;
switch(settings.quoteStyle) {
case AppSettings.QUOTE_STYLE_TWITTER:
text = " " + "https://twitter.com/" + screenName + "/status/" + tweetId;
break;
case AppSettings.QUOTE_STYLE_TALON:
text = "\"@" + screenName + ": " + text + "\" ";
break;
case AppSettings.QUOTE_STYLE_RT:
text = " RT @" + screenName + ": " + text;
break;
}
Intent quote = new Intent(context, ComposeActivity.class);
quote.putExtra("user", text);
quote.putExtra("id", tweetId);
startActivity(quote);
return true;
case R.id.menu_spam:
new MarkSpam().execute();
getSharedPreferences("com.klinker.android.twitter_world_preferences", 0).edit().putBoolean("just_muted", true).commit();
return super.onOptionsItemSelected(item);
/*case R.id.menu_mute_hashtags:
if (!hashtags[0].equals("")) {
ArrayList<String> tags = new ArrayList<String>();
if (hashtags != null) {
for (String s : hashtags) {
if (!s.equals("")) {
tags.add("#" + s);
}
}
}
final CharSequence[] fItems = new CharSequence[tags.size()];
for (int i = 0; i < tags.size(); i++) {
fItems[i] = tags.get(i);
}
final SharedPreferences sharedPreferences = context.getSharedPreferences("com.klinker.android.twitter_world_preferences",
0);
if (fItems.length > 1) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setItems(fItems, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
String touched = fItems[item] + "";
Toast.makeText(context, getResources().getString(R.string.muted) + " " + touched, Toast.LENGTH_SHORT).show();
touched = touched.replace("#", "") + " ";
String current = sharedPreferences.getString("muted_hashtags", "");
sharedPreferences.edit().putString("muted_hashtags", current + touched).commit();
sharedPreferences.edit().putBoolean("refresh_me", true).commit();
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();
} else {
String touched = fItems[0] + "";
Toast.makeText(context, getResources().getString(R.string.muted) + " " + touched, Toast.LENGTH_SHORT).show();
touched = touched.replace("#", "") + " ";
String current = sharedPreferences.getString("muted_hashtags", "");
sharedPreferences.edit().putString("muted_hashtags", current + touched).commit();
sharedPreferences.edit().putBoolean("refresh_me", true).commit();
}
} else {
Toast.makeText(context, getResources().getString(R.string.no_hashtags), Toast.LENGTH_SHORT).show();
}
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("just_muted", true).commit();
return super.onOptionsItemSelected(item);
case R.id.menu_share_links:
if (!otherLinks[0].equals("")) {
ArrayList<String> urls = new ArrayList<String>();
if (otherLinks != null) {
for (String s : otherLinks) {
if (!s.equals("")) {
urls.add(s);
}
}
}
final CharSequence[] fItems = new CharSequence[urls.size()];
for (int i = 0; i < urls.size(); i++) {
fItems[i] = urls.get(i);
}
if (fItems.length > 1) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setItems(fItems, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
String touched = fItems[item] + "";
Intent intent=new Intent(android.content.Intent.ACTION_SEND);
intent.setType("text/plain");
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.putExtra(Intent.EXTRA_TEXT, touched);
context.startActivity(Intent.createChooser(intent, context.getResources().getString(R.string.menu_share)));
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();
} else {
String touched = fItems[0] + "";
Intent intent=new Intent(android.content.Intent.ACTION_SEND);
intent.setType("text/plain");
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.putExtra(Intent.EXTRA_TEXT, touched);
context.startActivity(Intent.createChooser(intent, context.getResources().getString(R.string.menu_share)));
}
} else {
Toast.makeText(context, getResources().getString(R.string.no_links), Toast.LENGTH_SHORT).show();
}
return super.onOptionsItemSelected(item);*/
case R.id.menu_translate:
try {
String url = settings.translateURL + tweet;
Uri uri = Uri.parse(url);
Intent browser = new Intent(Intent.ACTION_VIEW, uri);
browser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(browser);
} catch (Exception e) {
}
return true;
default:
return super.onOptionsItemSelected(item);
}
}
use of android.support.v4.app.NotificationCompat.Builder in project aware-client by denzilferreira.
the class ESM_DateTime method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
super.onCreateDialog(savedInstanceState);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
datePicked = Calendar.getInstance();
View ui = inflater.inflate(R.layout.esm_datetime, null);
builder.setView(ui);
esm_dialog = builder.create();
esm_dialog.setCanceledOnTouchOutside(false);
try {
TextView esm_title = (TextView) ui.findViewById(R.id.esm_title);
esm_title.setText(getTitle());
TextView esm_instructions = (TextView) ui.findViewById(R.id.esm_instructions);
esm_instructions.setText(getInstructions());
final ViewPager datetimePager = (ViewPager) ui.findViewById(R.id.datetimepager);
DateTimePagerAdapter dateTimePagerAdapter = new DateTimePagerAdapter(getContext());
datetimePager.setAdapter(dateTimePagerAdapter);
datetimePager.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
if (getExpirationThreshold() > 0 && expire_monitor != null)
expire_monitor.cancel(true);
} catch (JSONException e) {
e.printStackTrace();
}
}
});
Button cancel_text = (Button) ui.findViewById(R.id.esm_cancel);
cancel_text.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
esm_dialog.cancel();
}
});
Button submit_number = (Button) ui.findViewById(R.id.esm_submit);
submit_number.setText(getSubmitButton());
submit_number.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
if (getExpirationThreshold() > 0 && expire_monitor != null)
expire_monitor.cancel(true);
ContentValues rowData = new ContentValues();
rowData.put(ESM_Provider.ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis());
rowData.put(ESM_Provider.ESM_Data.ANSWER, datePicked.getTimeInMillis());
rowData.put(ESM_Provider.ESM_Data.STATUS, ESM.STATUS_ANSWERED);
getActivity().getContentResolver().update(ESM_Provider.ESM_Data.CONTENT_URI, rowData, ESM_Provider.ESM_Data._ID + "=" + getID(), null);
Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED);
answer.putExtra(ESM.EXTRA_ANSWER, rowData.getAsString(ESM_Provider.ESM_Data.ANSWER));
getActivity().sendBroadcast(answer);
if (Aware.DEBUG)
Log.d(Aware.TAG, "Answer:" + rowData.toString());
esm_dialog.dismiss();
} catch (JSONException e) {
e.printStackTrace();
}
}
});
} catch (JSONException e) {
e.printStackTrace();
}
return esm_dialog;
}
use of android.support.v4.app.NotificationCompat.Builder in project Shuttle by timusus.
the class PlaylistUtils method renamePlaylistDialog.
public static void renamePlaylistDialog(final Context context, final Playlist playlist) {
@SuppressLint("InflateParams") View customView = LayoutInflater.from(context).inflate(R.layout.dialog_playlist, null);
final EditText editText = customView.findViewById(R.id.editText);
editText.setText(playlist.name);
MaterialDialog.Builder builder = DialogUtils.getBuilder(context).title(R.string.create_playlist_create_text_prompt).customView(customView, false).positiveText(R.string.save).onPositive((materialDialog, dialogAction) -> {
String name = editText.getText().toString();
if (name.length() > 0) {
ContentResolver resolver = context.getContentResolver();
ContentValues values = new ContentValues(1);
values.put(MediaStore.Audio.Playlists.NAME, name);
resolver.update(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, values, MediaStore.Audio.Playlists._ID + "=?", new String[] { Long.valueOf(playlist.id).toString() });
playlist.name = name;
Toast.makeText(context, R.string.playlist_renamed_message, Toast.LENGTH_SHORT).show();
}
}).negativeText(R.string.cancel);
final MaterialDialog dialog = builder.build();
TextWatcher textWatcher = new TextWatcher() {
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
// check if playlist with current name exists already, and warn the user if so.
setSaveButton(dialog, playlist, editText.getText().toString());
}
public void afterTextChanged(Editable s) {
}
};
editText.addTextChangedListener(textWatcher);
dialog.show();
}
use of android.support.v4.app.NotificationCompat.Builder in project BottomNavigation by Ashok-Varma.
the class BadgeItem method hide.
/**
* @param animate whether to animate the change
* @return this, to allow builder pattern
*/
public T hide(boolean animate) {
mIsHidden = true;
if (isWeakReferenceValid()) {
TextView textView = mTextViewRef.get();
if (animate) {
ViewPropertyAnimatorCompat animatorCompat = ViewCompat.animate(textView);
animatorCompat.cancel();
animatorCompat.setDuration(mAnimationDuration);
animatorCompat.scaleX(0).scaleY(0);
animatorCompat.setListener(new ViewPropertyAnimatorListener() {
@Override
public void onAnimationStart(View view) {
// Empty body
}
@Override
public void onAnimationEnd(View view) {
view.setVisibility(View.GONE);
}
@Override
public void onAnimationCancel(View view) {
view.setVisibility(View.GONE);
}
});
animatorCompat.start();
} else {
textView.setVisibility(View.GONE);
}
}
return getSubInstance();
}
Aggregations