Ejemplo n.º 1
0
  /**
   * Shows at most one dialog using the intent extras and the restored state of the activity.
   *
   * @param savedInstanceState restored state
   */
  private void showDialogIfNeeded(Bundle savedInstanceState) {
    // Check if the intent has the ICON_COLOR_CHANGED action; if so, show a new dialog.
    if (getIntent().getBooleanExtra(IconColorReceiver.EXTRA_ICON_COLOR_CHANGED, false)) {
      // Clear the flag in the intent so that the dialog doesn't show up anymore
      getIntent().putExtra(IconColorReceiver.EXTRA_ICON_COLOR_CHANGED, false);

      // Display a dialog showcasing the new icon!
      ImageView imageView = new ImageView(this);
      PackageManager manager = getPackageManager();
      try {
        ComponentInfo info = manager.getActivityInfo(getComponentName(), 0);
        imageView.setImageDrawable(
            ContextCompat.getDrawable(getBaseContext(), info.getIconResource()));
      } catch (PackageManager.NameNotFoundException ignored) {
      }

      new QKDialog()
          .setContext(this)
          .setTitle(getString(R.string.icon_ready))
          .setMessage(R.string.icon_ready_message)
          .setCustomView(imageView)
          .setPositiveButton(R.string.okay, null)
          .show();

      // Only show the MMS setup fragment if it hasn't already been dismissed
    } else if (!wasMmsSetupFragmentDismissed(savedInstanceState)) {
      beginMmsSetup();
    }
  }