App ops: new labels, fix crash, fix updating list.

- Add new labels for media ops.
- Fix crash due to missing boolean entry for access notifications op.
- Fix updating op category lists to remain stable (not jump
  back to the top).

Change-Id: I505cfd91b1ff92587a627d33f3ac7a21145a9bbd
This commit is contained in:
Dianne Hackborn
2013-02-13 11:02:12 -08:00
parent 7bb10dbca5
commit 7ff56d331e
3 changed files with 33 additions and 20 deletions

View File

@@ -32,7 +32,7 @@ import android.preference.PreferenceActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
@@ -165,6 +165,10 @@ public class AppOpsCategory extends ListFragment implements
* Handles a request to start the Loader.
*/
@Override protected void onStartLoading() {
// We don't monitor changed when loading is stopped, so need
// to always reload at this point.
onContentChanged();
if (mApps != null) {
// If we currently have a result available, deliver it
// immediately.
@@ -239,33 +243,36 @@ public class AppOpsCategory extends ListFragment implements
}
}
public static class AppListAdapter extends ArrayAdapter<AppOpEntry> {
public static class AppListAdapter extends BaseAdapter {
private final Resources mResources;
private final LayoutInflater mInflater;
private final AppOpsState mState;
List<AppOpEntry> mList;
public AppListAdapter(Context context, AppOpsState state) {
super(context, android.R.layout.simple_list_item_2);
mResources = context.getResources();
mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mState = state;
}
public void setData(List<AppOpEntry> data) {
clear();
if (data != null) {
addAll(data);
}
mList = data;
notifyDataSetChanged();
}
@Override
public boolean hasStableIds() {
return true;
public int getCount() {
return mList != null ? mList.size() : 0;
}
@Override
public AppOpEntry getItem(int position) {
return mList.get(position);
}
@Override
public long getItemId(int position) {
// XXX need to generate real id.
return position;
}
@@ -315,16 +322,9 @@ public class AppOpsCategory extends ListFragment implements
// Start out with a progress indicator.
setListShown(false);
}
@Override
public void onStart() {
super.onStart();
// Prepare the loader. We don't monitor for changes while stopped,
// so want to re-start the loader (retrieving a new data set) each
// time we start.
getLoaderManager().restartLoader(0, null, this);
// Prepare the loader.
getLoaderManager().initLoader(0, null, this);
}
// utility method used to start sub activity

View File

@@ -151,11 +151,18 @@ public class AppOpsState {
AppOpsManager.OP_ACCESS_NOTIFICATIONS,
AppOpsManager.OP_CALL_PHONE,
AppOpsManager.OP_WRITE_SETTINGS,
AppOpsManager.OP_SYSTEM_ALERT_WINDOW },
AppOpsManager.OP_SYSTEM_ALERT_WINDOW,
AppOpsManager.OP_CAMERA,
AppOpsManager.OP_RECORD_AUDIO,
AppOpsManager.OP_PLAY_AUDIO },
new boolean[] { false,
false,
true,
true,
true,
true,
true,
true,
true }
);