Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fade53d0 authored by Sam Mortimer's avatar Sam Mortimer
Browse files

[1/2] AppOps: Show allowed/ignored counts

Change-Id: Ia27737155c33e934df9a2a1fcff88379240fd096
parent 4344cdd5
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@
        android:textAlignment="viewStart" />

    <TextView
        android:id="@+id/op_time"
        android:id="@+id/op_counts"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toEndOf="@id/op_icon"
@@ -58,6 +58,16 @@
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textAlignment="viewStart" />

    <TextView
        android:id="@+id/op_time"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toEndOf="@id/op_icon"
        android:layout_toStartOf="@+id/spinnerWidget"
        android:layout_below="@id/op_counts"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textAlignment="viewStart" />

    <Spinner
        android:id="@+id/spinnerWidget"
        android:layout_width="wrap_content"
+2 −0
Original line number Diff line number Diff line
@@ -21,4 +21,6 @@
    <item android:id="@+id/show_system_apps"
          android:title="@string/app_ops_show_system_apps"
          android:checkable="true" />
    <item android:id="@+id/reset_counters"
          android:title="@string/app_ops_reset_counters" />
</menu>
+6 −0
Original line number Diff line number Diff line
@@ -124,6 +124,9 @@
    <string name="view_stats_title">View stats</string>
    <string name="anonymous_learn_more">Learn more</string>

    <string name="app_ops_allowed">Allowed</string>
    <string name="app_ops_ignored">Denied</string>

    <!-- Anonymous Statistics - Notification -->
    <string name="anonymous_notification_desc">Enable or Disable CyanogenMod Statistics</string>

@@ -1031,5 +1034,8 @@ two in order to insert additional control points. \'Remove\' deletes the selecte
    <!-- App ops menu options -->
    <string name="app_ops_show_user_apps">Show user apps</string>
    <string name="app_ops_show_system_apps">Show built-in apps</string>
    <string name="app_ops_reset_counters">Reset allow/deny counters</string>
    <string name="app_ops_reset_confirm_title">Confirm counters reset</string>
    <string name="app_ops_reset_confirm_mesg">Are you sure you wish to reset AppOps counters ?</string>

</resources>
+2 −0
Original line number Diff line number Diff line
@@ -183,6 +183,8 @@ public class AppOpsDetails extends Fragment {
                }
                ((TextView)view.findViewById(R.id.op_name)).setText(
                        entry.getSwitchText(mState));
                ((TextView)view.findViewById(R.id.op_counts)).setText(
                        entry.getCountsText(res));
                ((TextView)view.findViewById(R.id.op_time)).setText(
                        entry.getTimeText(res, true));
                Spinner sw = (Spinner)view.findViewById(R.id.spinnerWidget);
+22 −15
Original line number Diff line number Diff line
@@ -340,30 +340,37 @@ public class AppOpsState {
        }

        private CharSequence getCombinedText(ArrayList<AppOpsManager.OpEntry> ops,
                CharSequence[] items) {
            if (ops.size() == 1) {
                return items[ops.get(0).getOp()];
            } else {
                CharSequence[] items, boolean withTerseCounts) {
            StringBuilder builder = new StringBuilder();
            for (int i=0; i<ops.size(); i++) {
                if (i > 0) {
                    builder.append(", ");
                }
                builder.append(items[ops.get(i).getOp()]);
                if (withTerseCounts) {
                    builder.append(" (" + ops.get(i).getAllowedCount()
                            + "/" + ops.get(i).getIgnoredCount() + ")");
                }
            }
            return builder.toString();
        }

        public CharSequence getCountsText(Resources res) {
            return res.getText(R.string.app_ops_allowed)
                    + ": " + mOps.get(0).getAllowedCount()
                    + " " + res.getText(R.string.app_ops_ignored)
                    + ": " + mOps.get(0).getIgnoredCount();
        }

        public CharSequence getSummaryText(AppOpsState state) {
            return getCombinedText(mOps, state.mOpSummaries);
            return getCombinedText(mOps, state.mOpSummaries, true);
        }

        public CharSequence getSwitchText(AppOpsState state) {
            if (mSwitchOps.size() > 0) {
                return getCombinedText(mSwitchOps, state.mOpLabels);
                return getCombinedText(mSwitchOps, state.mOpLabels, false);
            } else {
                return getCombinedText(mOps, state.mOpLabels);
                return getCombinedText(mOps, state.mOpLabels, false);
            }
        }

@@ -580,7 +587,7 @@ public class AppOpsState {

                        }
                        AppOpsManager.OpEntry opEntry = new AppOpsManager.OpEntry(
                                permOps.get(k), AppOpsManager.MODE_ALLOWED, 0, 0, 0);
                                permOps.get(k), AppOpsManager.MODE_ALLOWED, 0, 0, 0, 0, 0);
                        dummyOps.add(opEntry);
                        addOp(entries, pkgOps, appEntry, opEntry, packageName == null,
                                packageName == null ? 0 : opToOrder[opEntry.getOp()]);
Loading