Search in sources :

Example 6 with Builder

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);
}
Also used : RemoteViews(android.widget.RemoteViews) NotificationCompat(android.support.v4.app.NotificationCompat) Resources(android.content.res.Resources) Notification(android.app.Notification)

Example 7 with Builder

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();
}
Also used : AlertDialog(android.app.AlertDialog) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) DialogInterface(android.content.DialogInterface) Bundle(android.os.Bundle) Paint(android.graphics.Paint) FragmentTransaction(android.support.v4.app.FragmentTransaction) OnClickListener(android.content.DialogInterface.OnClickListener) CompoundButton(android.widget.CompoundButton)

Example 8 with Builder

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();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) DialogFragment(android.support.v4.app.DialogFragment) OnClickListener(android.content.DialogInterface.OnClickListener)

Example 9 with Builder

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());
    }
}
Also used : NotificationManager(android.app.NotificationManager) DialogInterface(android.content.DialogInterface) OAuthActivity(org.qii.weiciyuan.ui.login.OAuthActivity) SSOActivity(org.qii.weiciyuan.ui.login.SSOActivity) AccountActivity(org.qii.weiciyuan.ui.login.AccountActivity) FragmentActivity(android.support.v4.app.FragmentActivity) BlackMagicActivity(org.qii.weiciyuan.ui.blackmagic.BlackMagicActivity) Activity(android.app.Activity) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) Notification(android.app.Notification) PendingIntent(android.app.PendingIntent) AccountBean(org.qii.weiciyuan.bean.AccountBean)

Example 10 with Builder

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());
}
Also used : NotificationManager(android.app.NotificationManager) TaskStackBuilder(android.support.v4.app.TaskStackBuilder) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Aggregations

NotificationCompat (android.support.v4.app.NotificationCompat)109 PendingIntent (android.app.PendingIntent)89 Intent (android.content.Intent)82 NotificationManager (android.app.NotificationManager)36 Notification (android.app.Notification)31 Builder (android.support.v4.app.NotificationCompat.Builder)19 Context (android.content.Context)18 TaskStackBuilder (android.support.v4.app.TaskStackBuilder)15 Uri (android.net.Uri)14 Bundle (android.os.Bundle)13 View (android.view.View)13 TextView (android.widget.TextView)11 Bitmap (android.graphics.Bitmap)10 IOException (java.io.IOException)10 RemoteViews (android.widget.RemoteViews)9 ArrayList (java.util.ArrayList)9 AlertDialog (android.app.AlertDialog)8 DialogInterface (android.content.DialogInterface)7 Dialog (android.app.Dialog)6 Paint (android.graphics.Paint)6