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_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).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).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).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 k-9 by k9mail.
the class BaseNotificationsTest method createFakeController.
private NotificationController createFakeController() {
Builder builder = MockHelper.mockBuilder(Builder.class);
NotificationController controller = mock(NotificationController.class);
when(controller.createNotificationBuilder()).thenReturn(builder);
when(controller.getAccountName(any(Account.class))).thenReturn(ACCOUNT_NAME);
return controller;
}
use of android.support.v4.app.NotificationCompat.Builder in project k-9 by k9mail.
the class BaseNotificationsTest method testCreateBigTextStyleNotification.
@Test
public void testCreateBigTextStyleNotification() throws Exception {
Account account = createFakeAccount();
int notificationId = 23;
NotificationHolder holder = createNotificationHolder(notificationId);
Builder builder = notifications.createBigTextStyleNotification(account, holder, notificationId);
verify(builder).setTicker(NOTIFICATION_SUMMARY);
verify(builder).setGroup("newMailNotifications-" + ACCOUNT_NUMBER);
verify(builder).setContentTitle(SENDER);
verify(builder).setContentText(SUBJECT);
verify(builder).setSubText(ACCOUNT_NAME);
BigTextStyle bigTextStyle = notifications.bigTextStyle;
verify(bigTextStyle).bigText(NOTIFICATION_PREVIEW);
verify(builder).setStyle(bigTextStyle);
}
use of android.support.v4.app.NotificationCompat.Builder in project k-9 by k9mail.
the class DeviceNotificationsTest method createFakeNotificationBuilder.
private Builder createFakeNotificationBuilder() {
Builder builder = mockBuilder(Builder.class);
when(builder.build()).thenReturn(FAKE_NOTIFICATION);
return builder;
}
use of android.support.v4.app.NotificationCompat.Builder in project k-9 by k9mail.
the class WearNotifications method addSummaryActions.
public void addSummaryActions(Builder builder, NotificationData notificationData) {
NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender();
addMarkAllAsReadAction(wearableExtender, notificationData);
if (isDeleteActionAvailableForWear()) {
addDeleteAllAction(wearableExtender, notificationData);
}
Account account = notificationData.getAccount();
if (isArchiveActionAvailableForWear(account)) {
addArchiveAllAction(wearableExtender, notificationData);
}
builder.extend(wearableExtender);
}
Aggregations