From 3afcbcf7153e554f09657845aaa2f8164d13d7e7 Mon Sep 17 00:00:00 2001 From: Adrian DC Date: Sat, 6 Aug 2016 00:18:09 +0200 Subject: [PATCH] Settings: Show only one tab on PrivacyGuard direct access * 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 --- .../android/settings/applications/AppOpsSummary.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/com/android/settings/applications/AppOpsSummary.java b/src/com/android/settings/applications/AppOpsSummary.java index 31641e285f..faefb65fee 100644 --- a/src/com/android/settings/applications/AppOpsSummary.java +++ b/src/com/android/settings/applications/AppOpsSummary.java @@ -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); -- 2.11.0