Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Commit

Permalink
More background tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
M66B committed Mar 3, 2014
1 parent 716d7cd commit 06b4b8e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
28 changes: 20 additions & 8 deletions src/biz/bokhorst/xprivacy/ActivityApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -546,16 +546,28 @@ private void optionClear() {
alertDialogBuilder.setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
List<Boolean> oldState = PrivacyManager.getRestartStates(mAppInfo.getUid(), null);
PrivacyManager.deleteRestrictions(mAppInfo.getUid(), null, true);
new AsyncTask<Object, Object, Object>() {
private List<Boolean> oldState;

// Refresh display
if (mPrivacyListAdapter != null)
mPrivacyListAdapter.notifyDataSetChanged();
@Override
protected Object doInBackground(Object... arg0) {
oldState = PrivacyManager.getRestartStates(mAppInfo.getUid(), null);
PrivacyManager.deleteRestrictions(mAppInfo.getUid(), null, true);
return null;
}

@Override
protected void onPostExecute(Object result) {
// Refresh display
if (mPrivacyListAdapter != null)
mPrivacyListAdapter.notifyDataSetChanged();

// Notify restart
if (oldState.contains(true))
Toast.makeText(ActivityApp.this, getString(R.string.msg_restart), Toast.LENGTH_SHORT).show();
// Notify restart
if (oldState.contains(true))
Toast.makeText(ActivityApp.this, getString(R.string.msg_restart), Toast.LENGTH_SHORT)
.show();
}
}.executeOnExecutor(mExecutor);
}
});
alertDialogBuilder.setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() {
Expand Down
18 changes: 14 additions & 4 deletions src/biz/bokhorst/xprivacy/ActivityMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -605,10 +605,20 @@ private void optionClearDB() {
alertDialogBuilder.setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
PrivacyManager.clear();
spRestriction.setSelection(0);
((EditText) findViewById(R.id.etFilter)).setText("");
ActivityMain.this.recreate();
new AsyncTask<Object, Object, Object>() {
@Override
protected Object doInBackground(Object... arg0) {
PrivacyManager.clear();
return null;
}

@Override
protected void onPostExecute(Object result) {
spRestriction.setSelection(0);
((EditText) findViewById(R.id.etFilter)).setText("");
ActivityMain.this.recreate();
}
}.executeOnExecutor(mExecutor);
}
});
alertDialogBuilder.setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() {
Expand Down

0 comments on commit 06b4b8e

Please sign in to comment.