diff options
-rw-r--r-- | res/values/strings.xml | 1 | ||||
-rw-r--r-- | src/com/cyngn/theme/perapptheming/PerAppThemingWindow.java | 5 | ||||
-rw-r--r-- | src/com/cyngn/theme/util/Utils.java | 26 |
3 files changed, 32 insertions, 0 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index 26699b5..ad06862 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -87,5 +87,6 @@ </string> <string name="per_app_applied_theme_indicator" translatable="false">\u2022</string> <string name="per_app_theme_applying">Your theme is being applied</string> + <string name="per_app_theme_app_not_overlaid_warning">Theme does not support this app, some elements may not change.</string> </resources> diff --git a/src/com/cyngn/theme/perapptheming/PerAppThemingWindow.java b/src/com/cyngn/theme/perapptheming/PerAppThemingWindow.java index 7e3694a..1b2000a 100644 --- a/src/com/cyngn/theme/perapptheming/PerAppThemingWindow.java +++ b/src/com/cyngn/theme/perapptheming/PerAppThemingWindow.java @@ -39,6 +39,7 @@ import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; +import android.widget.Toast; import com.cyngn.theme.chooser.R; import com.cyngn.theme.util.Utils; @@ -737,6 +738,10 @@ public class PerAppThemingWindow extends Service implements OnTouchListener, final String themePkgName = (String) view.getTag(R.id.tag_key_name); final String appPkgName = Utils.getTopTaskPackageName(getContext()); if (!TextUtils.isEmpty(appPkgName) && !TextUtils.isEmpty(themePkgName)) { + if (!Utils.themeHasOverlayForApp(getContext(), appPkgName, themePkgName)) { + Toast.makeText(getContext(), R.string.per_app_theme_app_not_overlaid_warning, + Toast.LENGTH_LONG).show(); + } hideThemeList(true, new Runnable() { @Override public void run() { diff --git a/src/com/cyngn/theme/util/Utils.java b/src/com/cyngn/theme/util/Utils.java index 3fe8c63..6054bf8 100644 --- a/src/com/cyngn/theme/util/Utils.java +++ b/src/com/cyngn/theme/util/Utils.java @@ -43,6 +43,8 @@ public class Utils { private static final String TAG = Utils.class.getSimpleName(); private static final boolean DEBUG = false; + private static final String OVERLAY_BASE_PATH = "overlays" + File.separator; + public static Bitmap decodeFile(String path, int reqWidth, int reqHeight) { BitmapFactory.Options opts = new BitmapFactory.Options(); @@ -474,6 +476,30 @@ public class Utils { return false; } + /** + * Method to identify if a theme explicitly overlays a particular app. Explicit is defined + * as having files in overlays/appPkgName/ + * @param context + * @param appPkgNane + * @param themePkgName + * @return + */ + public static boolean themeHasOverlayForApp(Context context, String appPkgNane, + String themePkgName) { + boolean hasExplicitOverlay = false; + try { + Context themeContext = context.createPackageContext(themePkgName, 0); + if (themeContext != null) { + AssetManager assets = themeContext.getAssets(); + String[] files = assets.list(OVERLAY_BASE_PATH + appPkgNane); + if (files != null && files.length > 0) hasExplicitOverlay = true; + } + } catch (Exception e) { + // don't care, we'll return false and let the caller handle things + } + return hasExplicitOverlay; + } + private static boolean isCurrentHomeActivity(Context context, ComponentName component) { final PackageManager pm = context.getPackageManager(); |