From a5fe3b11a69ba34c112526bd03c6ea90784cd55a Mon Sep 17 00:00:00 2001 From: Arian Date: Wed, 14 Oct 2020 17:45:23 +0200 Subject: [PATCH] davinci: parts: Always show the warning dialog Change-Id: I979cc479ee928edf0e203489264df340326fbf5b --- .../res/layout/popup_calibration_warning.xml | 28 ------------------ parts/res/values/strings.xml | 1 - .../PopupCameraSettingsFragment.java | 29 ++----------------- 3 files changed, 2 insertions(+), 56 deletions(-) delete mode 100644 parts/res/layout/popup_calibration_warning.xml diff --git a/parts/res/layout/popup_calibration_warning.xml b/parts/res/layout/popup_calibration_warning.xml deleted file mode 100644 index c807d60..0000000 --- a/parts/res/layout/popup_calibration_warning.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - diff --git a/parts/res/values/strings.xml b/parts/res/values/strings.xml index e2f017b..8a3843b 100644 --- a/parts/res/values/strings.xml +++ b/parts/res/values/strings.xml @@ -30,7 +30,6 @@ Calibrate the popup camera motor Motor calibration Unnecessary use of calibration may cause permanent damage. It is recommended to calibrate the popup camera motor only in case of it not moving properly or it being in incorrect position! - Do not show again Warning diff --git a/parts/src/org/lineageos/settings/popupcamera/PopupCameraSettingsFragment.java b/parts/src/org/lineageos/settings/popupcamera/PopupCameraSettingsFragment.java index 12dca95..797ce7e 100644 --- a/parts/src/org/lineageos/settings/popupcamera/PopupCameraSettingsFragment.java +++ b/parts/src/org/lineageos/settings/popupcamera/PopupCameraSettingsFragment.java @@ -23,9 +23,6 @@ import android.app.DialogFragment; import android.content.SharedPreferences; import android.os.Bundle; import android.view.MenuItem; -import android.view.View; -import android.widget.CompoundButton; -import android.widget.CheckBox; import androidx.preference.Preference; import androidx.preference.Preference.OnPreferenceChangeListener; @@ -67,14 +64,8 @@ public class PopupCameraSettingsFragment extends PreferenceFragment @Override public boolean onPreferenceClick(Preference preference) { if (MOTOR_CALIBRATION_KEY.equals(preference.getKey())) { - SharedPreferences prefs = getActivity().getSharedPreferences( - MOTOR_CALIBRATION_KEY, Activity.MODE_PRIVATE); - if (!prefs.getBoolean("popup_calibration_warning_hidden", false)) { - MotorCalibrationWarningDialog fragment = new MotorCalibrationWarningDialog(); - fragment.show(getFragmentManager(), "motor_calibration_warning_dialog"); - } else { - mPopupCameraService.calibrateMotor(); - } + MotorCalibrationWarningDialog fragment = new MotorCalibrationWarningDialog(); + fragment.show(getFragmentManager(), "motor_calibration_warning_dialog"); return true; } return false; @@ -83,25 +74,9 @@ public class PopupCameraSettingsFragment extends PreferenceFragment private class MotorCalibrationWarningDialog extends DialogFragment { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { - View view = getActivity().getLayoutInflater().inflate( - R.layout.popup_calibration_warning, null); - CheckBox hideDialog = (CheckBox) view.findViewById(R.id.popup_calibration_warning_hide); - - hideDialog.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { - getActivity() - .getSharedPreferences(MOTOR_CALIBRATION_KEY, Activity.MODE_PRIVATE) - .edit() - .putBoolean("popup_calibration_warning_hidden", isChecked) - .commit(); - } - }); - return new AlertDialog.Builder(getActivity()) .setTitle(R.string.popup_calibration_warning_title) .setMessage(R.string.popup_calibration_warning_text) - .setView(view) .setPositiveButton(R.string.popup_camera_calibrate_now, (dialog, which) -> { mPopupCameraService.calibrateMotor();