Skip to content

Commit

Permalink
Prevent su options from being deselected every time the fragment loads
Browse files Browse the repository at this point in the history
  • Loading branch information
ChainsDD committed Jul 7, 2012
1 parent 6298409 commit 1877610
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions src/com/noshufou/android/su/InfoFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public class InfoFragment extends SherlockFragment
private SharedPreferences mPrefs;

private Device mDevice = null;
private boolean mModal = false;

private boolean mDualPane = false;

Expand Down Expand Up @@ -86,9 +85,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
mOutdatedNotification.setOnCheckedChangeListener(this);
mSuOptionsRow = view.findViewById(R.id.su_options_row);
mTempUnroot = (CheckBox) view.findViewById(R.id.temp_unroot);
mTempUnroot.setOnCheckedChangeListener(this);
mTempUnroot.setOnClickListener(this);
mOtaSurvival = (CheckBox) view.findViewById(R.id.ota_survival);
mOtaSurvival.setOnCheckedChangeListener(this);
mOtaSurvival.setOnClickListener(this);

view.findViewById(R.id.display_changelog).setOnClickListener(this);
mGetElite = view.findViewById(R.id.get_elite);
Expand Down Expand Up @@ -145,23 +144,21 @@ public void onClick(View v) {
final Intent updaterIntent = new Intent(getSherlockActivity(), UpdaterActivity.class);
startActivity(updaterIntent);
break;
case R.id.temp_unroot:
new ToggleSuOption(Preferences.TEMP_UNROOT).execute();
break;
case R.id.ota_survival:
new ToggleSuOption(Preferences.OTA_SURVIVE).execute();
break;
}
}

@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (mModal) return;

switch (buttonView.getId()) {
case R.id.outdated_notification:
mPrefs.edit().putBoolean(Preferences.OUTDATED_NOTIFICATION, isChecked).commit();
break;
case R.id.temp_unroot:
new ToggleSuOption(Preferences.TEMP_UNROOT).execute();
break;
case R.id.ota_survival:
new ToggleSuOption(Preferences.OTA_SURVIVE).execute();
break;
}
}

Expand Down Expand Up @@ -277,12 +274,10 @@ protected void onProgressUpdate(Object... values) {
boolean rooted = (Boolean) values[1];
boolean backupAvailable = (Boolean) values[2];
mSuOptionsRow.setVisibility(View.VISIBLE);
mModal = true;
mTempUnroot.setChecked(!rooted && backupAvailable);
mTempUnroot.setEnabled(rooted || backupAvailable);
mOtaSurvival.setChecked(backupAvailable);
mOtaSurvival.setEnabled(rooted);
mModal = false;
}
}
}
Expand All @@ -305,8 +300,8 @@ protected void onPreExecute() {
getSherlockActivity().setSupportProgressBarIndeterminateVisibility(true);
mTempUnroot.setEnabled(false);
mOtaSurvival.setEnabled(false);
if (mKey.equals(Preferences.TEMP_UNROOT)) mTempUnroot.setText(R.string.updater_working);
else mOtaSurvival.setText(R.string.updater_working);
if (mKey.equals(Preferences.TEMP_UNROOT)) mTempUnroot.setText(R.string.info_working);
else mOtaSurvival.setText(R.string.info_working);
}

@Override
Expand Down

0 comments on commit 1877610

Please sign in to comment.