Loading res/layout/app_ops_details_item.xml +5 −4 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toEndOf="@id/op_icon" android:layout_toStartOf="@+id/switchWidget" android:layout_toStartOf="@+id/spinnerWidget" android:layout_marginTop="2dip" android:singleLine="true" android:ellipsize="marquee" Loading @@ -53,12 +53,13 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toEndOf="@id/op_icon" android:layout_toStartOf="@+id/switchWidget" android:layout_toStartOf="@+id/spinnerWidget" android:layout_below="@id/op_name" android:textAppearance="?android:attr/textAppearanceSmall" android:textAlignment="viewStart" /> <Switch android:id="@+id/switchWidget" <Spinner android:id="@+id/spinnerWidget" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentEnd="true" Loading @@ -66,6 +67,6 @@ android:layout_marginStart="8dip" android:padding="8dip" android:focusable="false" android:clickable="true" /> android:entries="@array/app_ops_permissions" /> </RelativeLayout> res/values/cm_arrays.xml +7 −0 Original line number Diff line number Diff line Loading @@ -703,4 +703,11 @@ <item>@string/app_ops_labels_bluetooth_change</item> <item>@string/app_ops_labels_data_change</item> </string-array> <!-- App ops permissions --> <string-array name="app_ops_permissions"> <item>Allowed</item> <item>Denied</item> <item>Always ask</item> </string-array> </resources> src/com/android/settings/applications/AppOpsDetails.java +50 −8 Original line number Diff line number Diff line Loading @@ -36,10 +36,11 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.CompoundButton; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.Switch; import android.widget.Spinner; import android.widget.TextView; import com.android.settings.R; Loading @@ -61,6 +62,36 @@ public class AppOpsDetails extends Fragment { private TextView mAppVersion; private LinearLayout mOperationsSection; private final int MODE_ALLOWED = 0; private final int MODE_IGNORED = 1; private final int MODE_ASK = 2; private int modeToPosition(int mode) { switch (mode) { case AppOpsManager.MODE_ALLOWED: return MODE_ALLOWED; case AppOpsManager.MODE_IGNORED: return MODE_IGNORED; case AppOpsManager.MODE_ASK: return MODE_ASK; }; return MODE_IGNORED; } private int positionToMode(int position) { switch (position) { case MODE_ALLOWED: return AppOpsManager.MODE_ALLOWED; case MODE_IGNORED: return AppOpsManager.MODE_IGNORED; case MODE_ASK: return AppOpsManager.MODE_ASK; }; return AppOpsManager.MODE_IGNORED; } // Utility method to set application label and icon. private void setAppLabelAndIcon(final PackageInfo pkgInfo) { final View appSnippet = mRootView.findViewById(R.id.app_snippet); Loading Loading @@ -154,16 +185,27 @@ public class AppOpsDetails extends Fragment { entry.getSwitchText(mState)); ((TextView)view.findViewById(R.id.op_time)).setText( entry.getTimeText(res, true)); Switch sw = (Switch)view.findViewById(R.id.switchWidget); Spinner sw = (Spinner)view.findViewById(R.id.spinnerWidget); final int switchOp = AppOpsManager.opToSwitch(firstOp.getOp()); sw.setChecked(mAppOps.checkOp(switchOp, entry.getPackageOps().getUid(), entry.getPackageOps().getPackageName()) == AppOpsManager.MODE_ALLOWED); sw.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener() { int mode = mAppOps.checkOp(switchOp, entry.getPackageOps().getUid(), entry.getPackageOps().getPackageName()); sw.setSelection(modeToPosition(mode)); sw.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() { boolean firstMode = true; @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { if(firstMode) { firstMode = false; return; } mAppOps.setMode(switchOp, entry.getPackageOps().getUid(), entry.getPackageOps().getPackageName(), isChecked ? AppOpsManager.MODE_ALLOWED : AppOpsManager.MODE_IGNORED); entry.getPackageOps().getPackageName(), positionToMode(position)); } @Override public void onNothingSelected(AdapterView<?> parentView) { // Do nothing } }); } Loading Loading
res/layout/app_ops_details_item.xml +5 −4 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toEndOf="@id/op_icon" android:layout_toStartOf="@+id/switchWidget" android:layout_toStartOf="@+id/spinnerWidget" android:layout_marginTop="2dip" android:singleLine="true" android:ellipsize="marquee" Loading @@ -53,12 +53,13 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toEndOf="@id/op_icon" android:layout_toStartOf="@+id/switchWidget" android:layout_toStartOf="@+id/spinnerWidget" android:layout_below="@id/op_name" android:textAppearance="?android:attr/textAppearanceSmall" android:textAlignment="viewStart" /> <Switch android:id="@+id/switchWidget" <Spinner android:id="@+id/spinnerWidget" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentEnd="true" Loading @@ -66,6 +67,6 @@ android:layout_marginStart="8dip" android:padding="8dip" android:focusable="false" android:clickable="true" /> android:entries="@array/app_ops_permissions" /> </RelativeLayout>
res/values/cm_arrays.xml +7 −0 Original line number Diff line number Diff line Loading @@ -703,4 +703,11 @@ <item>@string/app_ops_labels_bluetooth_change</item> <item>@string/app_ops_labels_data_change</item> </string-array> <!-- App ops permissions --> <string-array name="app_ops_permissions"> <item>Allowed</item> <item>Denied</item> <item>Always ask</item> </string-array> </resources>
src/com/android/settings/applications/AppOpsDetails.java +50 −8 Original line number Diff line number Diff line Loading @@ -36,10 +36,11 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.CompoundButton; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.Switch; import android.widget.Spinner; import android.widget.TextView; import com.android.settings.R; Loading @@ -61,6 +62,36 @@ public class AppOpsDetails extends Fragment { private TextView mAppVersion; private LinearLayout mOperationsSection; private final int MODE_ALLOWED = 0; private final int MODE_IGNORED = 1; private final int MODE_ASK = 2; private int modeToPosition(int mode) { switch (mode) { case AppOpsManager.MODE_ALLOWED: return MODE_ALLOWED; case AppOpsManager.MODE_IGNORED: return MODE_IGNORED; case AppOpsManager.MODE_ASK: return MODE_ASK; }; return MODE_IGNORED; } private int positionToMode(int position) { switch (position) { case MODE_ALLOWED: return AppOpsManager.MODE_ALLOWED; case MODE_IGNORED: return AppOpsManager.MODE_IGNORED; case MODE_ASK: return AppOpsManager.MODE_ASK; }; return AppOpsManager.MODE_IGNORED; } // Utility method to set application label and icon. private void setAppLabelAndIcon(final PackageInfo pkgInfo) { final View appSnippet = mRootView.findViewById(R.id.app_snippet); Loading Loading @@ -154,16 +185,27 @@ public class AppOpsDetails extends Fragment { entry.getSwitchText(mState)); ((TextView)view.findViewById(R.id.op_time)).setText( entry.getTimeText(res, true)); Switch sw = (Switch)view.findViewById(R.id.switchWidget); Spinner sw = (Spinner)view.findViewById(R.id.spinnerWidget); final int switchOp = AppOpsManager.opToSwitch(firstOp.getOp()); sw.setChecked(mAppOps.checkOp(switchOp, entry.getPackageOps().getUid(), entry.getPackageOps().getPackageName()) == AppOpsManager.MODE_ALLOWED); sw.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener() { int mode = mAppOps.checkOp(switchOp, entry.getPackageOps().getUid(), entry.getPackageOps().getPackageName()); sw.setSelection(modeToPosition(mode)); sw.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() { boolean firstMode = true; @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { if(firstMode) { firstMode = false; return; } mAppOps.setMode(switchOp, entry.getPackageOps().getUid(), entry.getPackageOps().getPackageName(), isChecked ? AppOpsManager.MODE_ALLOWED : AppOpsManager.MODE_IGNORED); entry.getPackageOps().getPackageName(), positionToMode(position)); } @Override public void onNothingSelected(AdapterView<?> parentView) { // Do nothing } }); } Loading