use of android.support.v4.app.NotificationCompat.Builder in project physical-web by google.
the class UrlDeviceDiscoveryService method updateSummaryNotification.
/**
* Create or update the a single notification that is a collapsed version
* of the top two beacon notifications.
*/
private void updateSummaryNotification(List<PwPair> pwPairs) {
int numNearbyBeacons = pwPairs.size();
String contentTitle = String.valueOf(numNearbyBeacons);
Resources resources = getResources();
contentTitle += " " + resources.getQuantityString(R.plurals.numFoundBeacons, numNearbyBeacons, numNearbyBeacons);
String contentText = getString(R.string.summary_notification_pull_down);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setSmallIcon(R.drawable.ic_notification).setContentTitle(contentTitle).setContentText(contentText).setSmallIcon(R.drawable.ic_notification).setGroup(NOTIFICATION_GROUP_KEY).setGroupSummary(true).setPriority(Utils.containsFavorite(pwPairs) ? NotificationCompat.PRIORITY_DEFAULT : NotificationCompat.PRIORITY_MIN).setContentIntent(createReturnToAppPendingIntent());
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder.setVisibility(NOTIFICATION_VISIBILITY);
}
Notification notification = builder.build();
// Create the big view for the notification (viewed by pulling down)
RemoteViews remoteViews = updateSummaryNotificationRemoteViews(pwPairs);
notification.bigContentView = remoteViews;
mNotificationManager.notify(SUMMARY_NOTIFICATION_ID, notification);
}
use of android.support.v4.app.NotificationCompat.Builder in project JamsMusicPlayer by psaravan.
the class CautionEditArtistsDialog method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
parentActivity = getActivity();
dialogFragment = this;
EDIT_TYPE = this.getArguments().getString("EDIT_TYPE");
ARTIST = this.getArguments().getString("ARTIST");
rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.fragment_caution_edit_artists, null);
cautionText = (TextView) rootView.findViewById(R.id.caution_text);
cautionText.setText(R.string.caution_artists_text);
cautionText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
cautionText.setPaintFlags(cautionText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
sharedPreferences = getActivity().getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE);
sharedPreferences.edit().putBoolean("SHOW_ARTIST_EDIT_CAUTION", false).commit();
dontShowAgainText = (TextView) rootView.findViewById(R.id.dont_show_again_text);
dontShowAgainText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
dontShowAgainText.setPaintFlags(dontShowAgainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
dontShowAgainCheckbox = (CheckBox) rootView.findViewById(R.id.dont_show_again_checkbox);
dontShowAgainCheckbox.setChecked(true);
dontShowAgainCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton arg0, boolean isChecked) {
if (isChecked == true) {
sharedPreferences.edit().putBoolean("SHOW_ARTIST_EDIT_CAUTION", false).commit();
} else {
sharedPreferences.edit().putBoolean("SHOW_ARTIST_EDIT_CAUTION", true).commit();
}
}
});
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
//Set the dialog title.
builder.setTitle(R.string.caution);
builder.setView(rootView);
builder.setNegativeButton(R.string.no, new OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
dialogFragment.dismiss();
}
});
builder.setPositiveButton(R.string.yes, new OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
dialogFragment.dismiss();
FragmentTransaction ft = getFragmentManager().beginTransaction();
Bundle bundle = new Bundle();
bundle.putString("EDIT_TYPE", EDIT_TYPE);
bundle.putString("ARTIST", ARTIST);
ID3sArtistEditorDialog dialog = new ID3sArtistEditorDialog();
dialog.setArguments(bundle);
dialog.show(ft, "id3ArtistEditorDialog");
}
});
return builder.create();
}
use of android.support.v4.app.NotificationCompat.Builder in project JamsMusicPlayer by psaravan.
the class EditGooglePlayMusicTagsDialog method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final DialogFragment dialog = this;
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
//Set the dialog title.
builder.setTitle(R.string.google_play_music_no_asterisk);
builder.setMessage(getResources().getString(R.string.edit_google_play_music_tags_unsupported));
builder.setNegativeButton(R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
dialog.dismiss();
}
});
return builder.create();
}
use of android.support.v4.app.NotificationCompat.Builder in project weiciyuan by qii.
the class Utility method showExpiredTokenDialogOrNotification.
public static void showExpiredTokenDialogOrNotification() {
final Activity activity = GlobalContext.getInstance().getCurrentRunningActivity();
boolean currentAccountTokenIsExpired = true;
AccountBean currentAccount = GlobalContext.getInstance().getAccountBean();
if (currentAccount != null) {
currentAccountTokenIsExpired = !Utility.isTokenValid(currentAccount);
}
if (currentAccountTokenIsExpired && activity != null && !GlobalContext.getInstance().tokenExpiredDialogIsShowing) {
if (activity.getClass() == AccountActivity.class) {
return;
}
if (activity.getClass() == OAuthActivity.class) {
return;
}
if (activity.getClass() == BlackMagicActivity.class) {
return;
}
if (activity.getClass() == SSOActivity.class) {
return;
}
final AccountBean needRefreshTokenAccount = currentAccount;
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
new AlertDialog.Builder(activity).setTitle(R.string.dialog_title_error).setMessage(R.string.your_token_is_expired).setPositiveButton(R.string.logout_to_login_again, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
activity.startActivity(AccountActivity.newIntent(needRefreshTokenAccount));
activity.finish();
GlobalContext.getInstance().tokenExpiredDialogIsShowing = false;
}
}).setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
//do nothing
}
}).show();
GlobalContext.getInstance().tokenExpiredDialogIsShowing = true;
}
});
} else if (!currentAccountTokenIsExpired || activity == null) {
Intent i = AccountActivity.newIntent();
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(GlobalContext.getInstance(), 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
Notification.Builder builder = new Notification.Builder(GlobalContext.getInstance()).setContentTitle(GlobalContext.getInstance().getString(R.string.login_again)).setContentText(GlobalContext.getInstance().getString(R.string.have_account_whose_token_is_expired)).setSmallIcon(R.drawable.ic_notification).setAutoCancel(true).setContentIntent(pendingIntent).setOnlyAlertOnce(true);
NotificationManager notificationManager = (NotificationManager) GlobalContext.getInstance().getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(NotificationServiceHelper.getTokenExpiredNotificationId(), builder.build());
} else if (GlobalContext.getInstance().tokenExpiredDialogIsShowing) {
NotificationManager notificationManager = (NotificationManager) GlobalContext.getInstance().getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(NotificationServiceHelper.getTokenExpiredNotificationId());
}
}
use of android.support.v4.app.NotificationCompat.Builder in project android-support-v4-googlemaps by petedoyle.
the class NotificationsActivity method onPostDirect.
public void onPostDirect(View v) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(this).setTicker("Direct Notification").setSmallIcon(android.R.drawable.stat_notify_chat).setContentTitle("Direct Notification").setContentText("This will open the content viewer").setAutoCancel(true).setContentIntent(TaskStackBuilder.from(this).addParentStack(ContentViewActivity.class).addNextIntent(new Intent(this, ContentViewActivity.class).putExtra(ContentViewActivity.EXTRA_TEXT, "From Notification")).getPendingIntent(0, 0));
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nm.notify("direct_tag", R.id.direct_notification, builder.getNotification());
}
Aggregations