summaryrefslogtreecommitdiffstats
path: root/src/com/android/wallpaper/util/ActivityUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/wallpaper/util/ActivityUtils.java')
-rwxr-xr-xsrc/com/android/wallpaper/util/ActivityUtils.java60
1 files changed, 59 insertions, 1 deletions
diff --git a/src/com/android/wallpaper/util/ActivityUtils.java b/src/com/android/wallpaper/util/ActivityUtils.java
index cc1912d..1fccd2f 100755
--- a/src/com/android/wallpaper/util/ActivityUtils.java
+++ b/src/com/android/wallpaper/util/ActivityUtils.java
@@ -15,9 +15,16 @@
*/
package com.android.wallpaper.util;
+import static com.android.wallpaper.util.LaunchSourceUtils.LAUNCH_SETTINGS_SEARCH;
+import static com.android.wallpaper.util.LaunchSourceUtils.LAUNCH_SOURCE_SETTINGS;
+import static com.android.wallpaper.util.LaunchSourceUtils.WALLPAPER_LAUNCH_SOURCE;
+
import android.app.Activity;
import android.content.ActivityNotFoundException;
+import android.content.Context;
import android.content.Intent;
+import android.provider.Settings;
+import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
@@ -27,6 +34,8 @@ import com.android.wallpaper.R;
* Various utilities pertaining to activities.
*/
public final class ActivityUtils {
+ private static final int SUW_NOT_YET = 0;
+ private static final int SUW_COMPLETE = 1;
/**
* Starts an activity with the given intent "safely" - i.e., catches exceptions that may occur
@@ -49,4 +58,53 @@ public final class ActivityUtils {
+ "or use the exported attribute for this activity.", e);
}
}
-}
+
+ /**
+ * Returns true if wallpaper launch source is from Settings related.
+ *
+ * @param intent activity intent.
+ */
+ public static boolean isLaunchedFromSettingsRelated(Intent intent) {
+ return isLaunchedFromSettings(intent) || isLaunchedFromSettingsSearch(intent);
+ }
+
+ /**
+ * Returns true if wallpaper launch source is from Settings.
+ *
+ * @param intent activity intent.
+ */
+ private static boolean isLaunchedFromSettings(Intent intent) {
+ return (intent != null && TextUtils.equals(LAUNCH_SOURCE_SETTINGS,
+ intent.getStringExtra(WALLPAPER_LAUNCH_SOURCE)));
+ }
+
+ /**
+ * Returns true if wallpaper launch source is from Settings Search.
+ *
+ * @param intent activity intent.
+ */
+ public static boolean isLaunchedFromSettingsSearch(Intent intent) {
+ return (intent != null && intent.hasExtra(LAUNCH_SETTINGS_SEARCH));
+ }
+
+ /**
+ * Returns true if wallpaper is in SUW mode.
+ *
+ * @param context activity's context.
+ */
+ public static boolean isSUWMode(Context context) {
+ return (Settings.Secure.getInt(
+ context.getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, SUW_COMPLETE)
+ == SUW_NOT_YET);
+ }
+
+ /**
+ * Returns true if it's wallpaper only mode.
+ *
+ * @param intent activity intent.
+ */
+ public static boolean isWallpaperOnlyMode(Intent intent) {
+ return "wallpaper_only".equals(
+ intent.getStringExtra("com.android.launcher3.WALLPAPER_FLAVOR"));
+ }
+} \ No newline at end of file