OSDN Git Service

Settings: Show only one tab on PrivacyGuard direct access
authorAdrian DC <radian.dc@gmail.com>
Fri, 5 Aug 2016 22:18:09 +0000 (00:18 +0200)
committerSteve Kondik <shade@chemlab.org>
Thu, 11 Aug 2016 17:26:54 +0000 (10:26 -0700)
 * Allow an intent request to a specific tab to be isolated,
    giving access only to the expected settings

 * "Apps started on boot" opens only Bootup
 * "Manage root accesses" opens only Root Access

 * Related to the following commits
    Ia5bc9d56fb11700b19d73336fad13c0a936091ff
    I79d963ecbadc624dc45a398387a348691318b6be

Change-Id: I5a720fe2a8abe5fdf1a1b91c054d8b3a57d6cc5d
Signed-off-by: Adrian DC <radian.dc@gmail.com>
src/com/android/settings/applications/AppOpsSummary.java

index 31641e2..faefb65 100644 (file)
@@ -65,6 +65,7 @@ public class AppOpsSummary extends InstrumentedFragment {
     CharSequence[] mPageNames;
 
     int mCurPos;
+    int mPositionOffset;
 
     @Override
     protected int getMetricsCategory() {
@@ -81,12 +82,12 @@ public class AppOpsSummary extends InstrumentedFragment {
 
         @Override
         public Fragment getItem(int position) {
-            return new AppOpsCategory(mPageTemplates[position]);
+            return new AppOpsCategory(mPageTemplates[mPositionOffset + position]);
         }
 
         @Override
         public int getCount() {
-            return mPageTemplates.length;
+            return mPageNames.length;
         }
 
         @Override
@@ -135,19 +136,22 @@ public class AppOpsSummary extends InstrumentedFragment {
 
         mPageNames = getResources().getTextArray(R.array.app_ops_categories_cm);
 
-        int defaultTab = -1;
+        mPositionOffset = 0;
+
+        int specificTab = -1;
         Bundle bundle = getArguments();
         if (bundle != null) {
-            defaultTab = Arrays.asList(mPageNames).indexOf(bundle.getString("appops_tab", ""));
+            specificTab = Arrays.asList(mPageNames).indexOf(bundle.getString("appops_tab", ""));
+            if (specificTab >= 0) {
+                mPageNames = Arrays.copyOfRange(mPageNames, specificTab, specificTab + 1);
+                mPositionOffset = specificTab;
+            }
         }
 
         mViewPager = (ViewPager) rootView.findViewById(R.id.pager);
         mAdapter = new MyPagerAdapter(getChildFragmentManager(),
                 filterTemplates(AppOpsState.ALL_TEMPLATES));
         mViewPager.setAdapter(mAdapter);
-        if (defaultTab >= 0) {
-            mViewPager.setCurrentItem(defaultTab);
-        }
         mViewPager.setOnPageChangeListener(mAdapter);
         PagerTabStrip tabs = (PagerTabStrip) rootView.findViewById(R.id.tabs);