Example #1
0
 public static String m1122b(Activity activity) {
   try {
     return m1123b((Context) activity, activity.getComponentName());
   } catch (Throwable e) {
     throw new IllegalArgumentException(e);
   }
 }
Example #2
0
  // Change theme to dark if dark mode is set
  public static void initDarkMode(Activity activity) {
    if (isDarkMode(activity)) {
      int theme = 0;

      try {
        theme = activity.getPackageManager().getActivityInfo(activity.getComponentName(), 0).theme;
      } catch (NameNotFoundException e) {
        return;
      }

      // Convert to dark theme
      if (theme == R.style.BL_Theme_Light) {
        theme = R.style.BL_Theme_Dark;
      } else if (theme == R.style.BL_Theme_Light_Translucent) {
        theme = R.style.BL_Theme_Dark_Translucent;
      } else if (theme == R.style.BL_Theme_Light_TranslucentActionBar_NoTranslucent) {
        theme = R.style.BL_Theme_Dark_TranslucentActionBar_NoTranslucent;
      } else if (theme == R.style.BL_Theme_Light_TranslucentActionBar) {
        theme = R.style.BL_Theme_Dark_TranslucentActionBar;
      } else if (theme == R.style.BL_Theme_Light_GradientActionBar) {
        theme = R.style.BL_Theme_Dark_GradientActionBar;
      } else if (theme == R.style.BL_Theme_Light_WithNav) {
        theme = R.style.BL_Theme_Dark_WithNav;
      }

      activity.setTheme(theme);
    }
  }
Example #3
0
 public static String b(Activity paramActivity) {
   try {
     paramActivity = b(paramActivity, paramActivity.getComponentName());
     return paramActivity;
   } catch (PackageManager.NameNotFoundException paramActivity) {
     throw new IllegalArgumentException(paramActivity);
   }
 }
Example #4
0
 public static String getParentActivityName(Activity paramActivity) {
   try {
     String str = getParentActivityName(paramActivity, paramActivity.getComponentName());
     return str;
   } catch (PackageManager.NameNotFoundException localNameNotFoundException) {
     throw new IllegalArgumentException(localNameNotFoundException);
   }
 }
 public void addActivity(Activity activity) {
   for (int i = 0; i < activityList.size(); i++) {
     if (activity
         .getComponentName()
         .getClassName()
         .equals(((Activity) activityList.get(i)).getComponentName().getClassName())) {
       ((Activity) activityList.get(i)).finish();
       activityList.remove(i);
     }
   }
   activityList.add(activity);
 }
Example #6
0
 /**
  * 得到某activity的元数据
  *
  * @param activity
  * @param key
  * @return
  */
 public static String getActivityMetaData(Activity activity, String key) {
   String data = null;
   ActivityInfo info = null;
   try {
     info =
         activity
             .getPackageManager()
             .getActivityInfo(activity.getComponentName(), PackageManager.GET_META_DATA);
   } catch (NameNotFoundException e) {
     e.printStackTrace();
   }
   if (info != null) {
     data = info.metaData.get(key).toString();
   }
   return data;
 }
 /**
  * @return The activity associated with this dialog, or null if there is no associated activity.
  */
 private ComponentName getAssociatedActivity() {
   Activity activity = mOwnerActivity;
   Context context = getContext();
   while (activity == null && context != null) {
     if (context instanceof Activity) {
       activity = (Activity) context; // found it!
     } else {
       context =
           (context instanceof ContextWrapper)
               ? ((ContextWrapper) context).getBaseContext()
               : // unwrap one level
               null; // done
     }
   }
   return activity == null ? null : activity.getComponentName();
 }
Example #8
0
  /**
   * Displays the download manager UI. Note the UI is different on tablets and on phones.
   *
   * @return Whether the UI was shown.
   */
  public static boolean showDownloadManager(@Nullable Activity activity, @Nullable Tab tab) {
    if (!isDownloadHomeEnabled()) return false;

    // Figure out what tab was last being viewed by the user.
    if (activity == null) activity = ApplicationStatus.getLastTrackedFocusedActivity();
    if (tab == null && activity instanceof ChromeTabbedActivity) {
      tab = ((ChromeTabbedActivity) activity).getActivityTab();
    }

    Context appContext = ContextUtils.getApplicationContext();
    if (DeviceFormFactor.isTablet(appContext)) {
      // Download Home shows up as a tab on tablets.
      LoadUrlParams params = new LoadUrlParams(UrlConstants.DOWNLOADS_URL);
      if (tab == null || !tab.isInitialized()) {
        // Open a new tab, which pops Chrome into the foreground.
        TabDelegate delegate = new TabDelegate(false);
        delegate.createNewTab(params, TabLaunchType.FROM_CHROME_UI, null);
      } else {
        // Download Home shows up inside an existing tab, but only if the last Activity was
        // the ChromeTabbedActivity.
        tab.loadUrl(params);

        // Bring Chrome to the foreground, if possible.
        Intent intent = Tab.createBringTabToFrontIntent(tab.getId());
        if (intent != null) {
          intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          IntentUtils.safeStartActivity(appContext, intent);
        }
      }
    } else {
      // Download Home shows up as a new Activity on phones.
      Intent intent = new Intent();
      intent.setClass(appContext, DownloadActivity.class);
      if (tab != null) intent.putExtra(EXTRA_IS_OFF_THE_RECORD, tab.isIncognito());
      if (activity == null) {
        // Stands alone in its own task.
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        appContext.startActivity(intent);
      } else {
        // Sits on top of another Activity.
        intent.putExtra(IntentHandler.EXTRA_PARENT_COMPONENT, activity.getComponentName());
        activity.startActivity(intent);
      }
    }

    return true;
  }