Search in sources :

Example 41 with Builder

use of android.support.v4.app.NotificationCompat.Builder in project mobile-android by photo.

the class NewPhotoObserver method showAutouploadIgnoredNotification.

/**
     * Show the autoupload ignored notification
     * 
     * @param file
     */
private void showAutouploadIgnoredNotification(File file) {
    NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    int icon = R.drawable.icon;
    long when = System.currentTimeMillis();
    String contentMessageTitle;
    contentMessageTitle = CommonUtils.getStringResource(R.string.upload_limit_reached_message);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext);
    Notification notification = builder.setContentTitle(CommonUtils.getStringResource(R.string.autoupload_ignored)).setContentText(contentMessageTitle).setWhen(when).setSmallIcon(icon).setAutoCancel(true).build();
    notificationManager.notify(file.hashCode(), notification);
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Notification(android.app.Notification)

Example 42 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 43 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 44 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 45 with Builder

use of android.support.v4.app.NotificationCompat.Builder in project XposedInstaller by rovo89.

the class NotificationUtil method showModulesUpdatedNotification.

@SuppressWarnings("deprecation")
public static void showModulesUpdatedNotification() {
    Intent intent = new Intent(sContext, WelcomeActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra("fragment", 0);
    PendingIntent pInstallTab = PendingIntent.getActivity(sContext, PENDING_INTENT_OPEN_INSTALL, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    String title = sContext.getString(R.string.xposed_module_updated_notification_title);
    String message = sContext.getString(R.string.xposed_module_updated_notification);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(sContext).setContentTitle(title).setContentText(message).setTicker(title).setContentIntent(pInstallTab).setVibrate(new long[] { 0 }).setAutoCancel(true).setSmallIcon(R.drawable.ic_notification).setColor(sContext.getResources().getColor(R.color.colorPrimary));
    if (Build.VERSION.SDK_INT >= 21)
        builder.setPriority(2);
    Intent iSoftReboot = new Intent(sContext, RebootReceiver.class);
    iSoftReboot.putExtra(RebootReceiver.EXTRA_SOFT_REBOOT, true);
    PendingIntent pSoftReboot = PendingIntent.getBroadcast(sContext, PENDING_INTENT_SOFT_REBOOT, iSoftReboot, PendingIntent.FLAG_UPDATE_CURRENT);
    Intent iReboot = new Intent(sContext, RebootReceiver.class);
    PendingIntent pReboot = PendingIntent.getBroadcast(sContext, PENDING_INTENT_REBOOT, iReboot, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.addAction(0, sContext.getString(R.string.reboot), pReboot);
    builder.addAction(0, sContext.getString(R.string.soft_reboot), pSoftReboot);
    sNotificationManager.notify(null, NOTIFICATION_MODULES_UPDATED, builder.build());
}
Also used : NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Aggregations

NotificationCompat (android.support.v4.app.NotificationCompat)105 PendingIntent (android.app.PendingIntent)86 Intent (android.content.Intent)76 NotificationManager (android.app.NotificationManager)35 Notification (android.app.Notification)29 Builder (android.support.v4.app.NotificationCompat.Builder)19 Context (android.content.Context)16 TaskStackBuilder (android.support.v4.app.TaskStackBuilder)14 Uri (android.net.Uri)11 Bundle (android.os.Bundle)10 Bitmap (android.graphics.Bitmap)9 View (android.view.View)9 RemoteViews (android.widget.RemoteViews)9 IOException (java.io.IOException)9 AlertDialog (android.app.AlertDialog)7 DialogInterface (android.content.DialogInterface)7 Paint (android.graphics.Paint)6 SpannableString (android.text.SpannableString)6 TypedValue (android.util.TypedValue)6 TextView (android.widget.TextView)6