diff options
-rw-r--r-- | res/layout/app_ops_details_item.xml | 13 | ||||
-rw-r--r-- | src/com/android/settings/applications/AppOpsDetails.java | 30 |
2 files changed, 40 insertions, 3 deletions
diff --git a/res/layout/app_ops_details_item.xml b/res/layout/app_ops_details_item.xml index 8b62d65..1124ec7 100644 --- a/res/layout/app_ops_details_item.xml +++ b/res/layout/app_ops_details_item.xml @@ -70,4 +70,17 @@ android:focusable="false" android:entries="@+array/app_ops_permissions" /> + <Switch + android:id="@+id/switchWidget" + 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="1" + android:padding="8dip" + android:focusable="false" + android:clickable="true" /> + + </GridLayout> diff --git a/src/com/android/settings/applications/AppOpsDetails.java b/src/com/android/settings/applications/AppOpsDetails.java index 1078eff..13e4831 100644 --- a/src/com/android/settings/applications/AppOpsDetails.java +++ b/src/com/android/settings/applications/AppOpsDetails.java @@ -38,6 +38,7 @@ import android.widget.CompoundButton; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.Spinner; +import android.widget.Switch; import android.widget.TextView; import com.android.internal.logging.MetricsLogger; @@ -173,12 +174,17 @@ public class AppOpsDetails extends InstrumentedFragment { entry.getSwitchText(mState)); ((TextView)view.findViewById(R.id.op_time)).setText( entry.getTimeText(res, true)); - Spinner sw = (Spinner)view.findViewById(R.id.spinnerWidget); + + Spinner sp = (Spinner) view.findViewById(R.id.spinnerWidget); + sp.setVisibility(View.INVISIBLE); + Switch sw = (Switch) view.findViewById(R.id.switchWidget); + sw.setVisibility(View.INVISIBLE); + final int switchOp = AppOpsManager.opToSwitch(firstOp.getOp()); int mode = mAppOps.checkOp(switchOp, entry.getPackageOps().getUid(), entry.getPackageOps().getPackageName()); - sw.setSelection(modeToPosition(mode)); - sw.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() { + sp.setSelection(modeToPosition(mode)); + sp.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() { boolean firstMode = true; @Override @@ -197,6 +203,24 @@ public class AppOpsDetails extends InstrumentedFragment { // Do nothing } }); + + sw.setChecked(mAppOps.checkOp(switchOp, entry.getPackageOps() + .getUid(), entry.getPackageOps().getPackageName()) == AppOpsManager.MODE_ALLOWED); + sw.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener() { + public void onCheckedChanged(CompoundButton buttonView, + boolean isChecked) { + mAppOps.setMode(switchOp, entry.getPackageOps() + .getUid(), entry.getPackageOps() + .getPackageName(), + isChecked ? AppOpsManager.MODE_ALLOWED + : AppOpsManager.MODE_IGNORED); + } + }); + if (AppOpsManager.isStrictOp(switchOp)) { + sp.setVisibility(View.VISIBLE); + } else { + sw.setVisibility(View.VISIBLE); + } } } |