diff options
author | Shashank Mittal <mittals@codeaurora.org> | 2014-03-06 17:16:49 -0800 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2016-01-03 14:43:32 -0800 |
commit | 090a9c69d8d1ccdc15bc78826a2ce443fc1f0d10 (patch) | |
tree | 7b373218e3d7cea9f337241354c9a9f83490ea3a | |
parent | b6b6082f7a260cf7442ee4291e7e9d73428bb2e1 (diff) | |
download | packages_apps_Settings-090a9c69d8d1ccdc15bc78826a2ce443fc1f0d10.zip packages_apps_Settings-090a9c69d8d1ccdc15bc78826a2ce443fc1f0d10.tar.gz packages_apps_Settings-090a9c69d8d1ccdc15bc78826a2ce443fc1f0d10.tar.bz2 |
AppOps: Add 'Always ask' option under appOps setting.
Add always ask option for each operation.
Change-Id: Ia4f331a5b7d0b1c8ae6946c55a4f78818fe0454f
-rw-r--r-- | res/layout/app_ops_details_item.xml | 9 | ||||
-rw-r--r-- | res/values/cm_arrays.xml | 1 | ||||
-rw-r--r-- | src/com/android/settings/applications/AppOpsDetails.java | 29 |
3 files changed, 26 insertions, 13 deletions
diff --git a/res/layout/app_ops_details_item.xml b/res/layout/app_ops_details_item.xml index c630ad6..8b62d65 100644 --- a/res/layout/app_ops_details_item.xml +++ b/res/layout/app_ops_details_item.xml @@ -42,6 +42,7 @@ android:id="@+id/op_name" android:layout_column="1" android:layout_row="0" + android:layout_columnSpan="2" android:layout_gravity="fill_horizontal" android:layout_marginTop="2dip" android:singleLine="true" @@ -57,16 +58,16 @@ 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_gravity="center_vertical" android:layout_marginStart="8dip" android:layout_column="2" - android:layout_row="0" - android:layout_rowSpan="2" + android:layout_row="1" android:padding="8dip" android:focusable="false" - android:clickable="true" /> + android:entries="@+array/app_ops_permissions" /> </GridLayout> diff --git a/res/values/cm_arrays.xml b/res/values/cm_arrays.xml index e61175d..c331a00 100644 --- a/res/values/cm_arrays.xml +++ b/res/values/cm_arrays.xml @@ -240,7 +240,6 @@ <item>@string/app_ops_permissions_always_ask</item> </string-array> - <string-array name="hardware_keys_action_values" translatable="false"> <item>0</item> <item>1</item> diff --git a/src/com/android/settings/applications/AppOpsDetails.java b/src/com/android/settings/applications/AppOpsDetails.java index d48af27..1078eff 100644 --- a/src/com/android/settings/applications/AppOpsDetails.java +++ b/src/com/android/settings/applications/AppOpsDetails.java @@ -33,10 +33,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.internal.logging.MetricsLogger; @@ -172,16 +173,28 @@ public class AppOpsDetails extends InstrumentedFragment { 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 } }); } |