Commit | Line | Data |
---|---|---|
7a94b5bc | 1 | From 4776c9b9c278880d70581ad77c1f116eb76f459d Mon Sep 17 00:00:00 2001 |
6bcbafcd L |
2 | From: Ivan Iskandar <iiiiskandar14@gmail.com> |
3 | Date: Wed, 14 Dec 2016 14:58:54 +0100 | |
7653b73c | 4 | Subject: [PATCH 10/20] Hide the "show/hide overlays" when no overlay installed |
6bcbafcd L |
5 | |
6 | Change-Id: I54088d27c9492e0992992de59bf340fe2465260a | |
7 | --- | |
8 | .../settings/applications/ManageApplications.java | 38 +++++++++++++++++++--- | |
9 | 1 file changed, 34 insertions(+), 4 deletions(-) | |
10 | ||
11 | diff --git a/src/com/android/settings/applications/ManageApplications.java b/src/com/android/settings/applications/ManageApplications.java | |
7a94b5bc | 12 | index ed617814b3..c3bc4d4a94 100644 |
6bcbafcd L |
13 | --- a/src/com/android/settings/applications/ManageApplications.java |
14 | +++ b/src/com/android/settings/applications/ManageApplications.java | |
15 | @@ -195,6 +195,10 @@ public class ManageApplications extends InstrumentedFragment | |
16 | private boolean mShowSubstratum; | |
17 | private boolean mShowSubstratumIcons; | |
18 | ||
19 | + // if app and icon overlay installed | |
20 | + private boolean mAppOverlayInstalled; | |
21 | + private boolean mIconOverlayInstalled; | |
22 | + | |
23 | private ApplicationsState mApplicationsState; | |
24 | ||
25 | public int mListType; | |
26 | @@ -556,6 +560,9 @@ public class ManageApplications extends InstrumentedFragment | |
27 | } | |
28 | ||
29 | void updateOptionsMenu() { | |
30 | + mAppOverlayInstalled = isOverlayInstalled("app"); | |
31 | + mIconOverlayInstalled = isOverlayInstalled("icon"); | |
32 | + | |
33 | if (mOptionsMenu == null) { | |
34 | return; | |
35 | } | |
36 | @@ -573,13 +580,13 @@ public class ManageApplications extends InstrumentedFragment | |
37 | && mListType != LIST_TYPE_HIGH_POWER); | |
38 | ||
39 | mOptionsMenu.findItem(R.id.show_substratum).setVisible(!mShowSubstratum | |
40 | - && mListType != LIST_TYPE_HIGH_POWER); | |
41 | + && mListType != LIST_TYPE_HIGH_POWER && mAppOverlayInstalled); | |
42 | mOptionsMenu.findItem(R.id.hide_substratum).setVisible(mShowSubstratum | |
43 | - && mListType != LIST_TYPE_HIGH_POWER); | |
44 | + && mListType != LIST_TYPE_HIGH_POWER && mAppOverlayInstalled); | |
45 | mOptionsMenu.findItem(R.id.show_substratum_icons).setVisible(!mShowSubstratumIcons | |
46 | - && mListType != LIST_TYPE_HIGH_POWER); | |
47 | + && mListType != LIST_TYPE_HIGH_POWER && mIconOverlayInstalled); | |
48 | mOptionsMenu.findItem(R.id.hide_substratum_icons).setVisible(mShowSubstratumIcons | |
49 | - && mListType != LIST_TYPE_HIGH_POWER); | |
50 | + && mListType != LIST_TYPE_HIGH_POWER && mIconOverlayInstalled); | |
51 | } | |
52 | ||
53 | @Override | |
54 | @@ -668,6 +675,29 @@ public class ManageApplications extends InstrumentedFragment | |
55 | mFilterAdapter.setFilterEnabled(FILTER_APPS_DISABLED, hasDisabledApps); | |
56 | } | |
57 | ||
58 | + boolean isOverlayInstalled(String type) { | |
59 | + List<ApplicationInfo> packages = getActivity().getPackageManager() | |
60 | + .getInstalledApplications(PackageManager.GET_META_DATA); | |
61 | + | |
62 | + for (ApplicationInfo packageInfo : packages) { | |
63 | + if (packageInfo.metaData != null) { | |
64 | + if (type.equals("app")) { | |
65 | + if (packageInfo.metaData | |
66 | + .getString("Substratum_Parent") != null) { | |
67 | + return true; | |
68 | + } | |
69 | + } | |
70 | + if (type.equals("icon")) { | |
71 | + if (packageInfo.metaData | |
72 | + .getString("Substratum_IconPack") != null) { | |
73 | + return true; | |
74 | + } | |
75 | + } | |
76 | + } | |
77 | + } | |
78 | + return false; | |
79 | + } | |
80 | + | |
81 | static class FilterSpinnerAdapter extends ArrayAdapter<CharSequence> { | |
82 | ||
83 | private final ManageApplications mManageApplications; | |
84 | -- | |
7a94b5bc | 85 | 2.11.1 |
6bcbafcd | 86 |