davinci: parts: Always show the warning dialog

Change-Id: I979cc479ee928edf0e203489264df340326fbf5b
This commit is contained in:
Arian 2020-10-14 17:45:23 +02:00
parent d738bb5729
commit a5fe3b11a6
No known key found for this signature in database
GPG Key ID: 48029380598CE3B9
3 changed files with 2 additions and 56 deletions

View File

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2020 The LineageOS Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingTop="8dp">
<CheckBox
android:id="@+id/popup_calibration_warning_hide"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/popup_calibration_warning_hide" />
</LinearLayout>

View File

@ -30,7 +30,6 @@
<string name="popup_calibration_summary">Calibrate the popup camera motor</string> <string name="popup_calibration_summary">Calibrate the popup camera motor</string>
<string name="popup_calibration_warning_title">Motor calibration</string> <string name="popup_calibration_warning_title">Motor calibration</string>
<string name="popup_calibration_warning_text">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!</string> <string name="popup_calibration_warning_text">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!</string>
<string name="popup_calibration_warning_hide">Do not show again</string>
<!-- Popup camera strings --> <!-- Popup camera strings -->
<string name="popup_camera_tip">Warning</string> <string name="popup_camera_tip">Warning</string>

View File

@ -23,9 +23,6 @@ import android.app.DialogFragment;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.CheckBox;
import androidx.preference.Preference; import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener; import androidx.preference.Preference.OnPreferenceChangeListener;
@ -67,14 +64,8 @@ public class PopupCameraSettingsFragment extends PreferenceFragment
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
if (MOTOR_CALIBRATION_KEY.equals(preference.getKey())) { 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(); MotorCalibrationWarningDialog fragment = new MotorCalibrationWarningDialog();
fragment.show(getFragmentManager(), "motor_calibration_warning_dialog"); fragment.show(getFragmentManager(), "motor_calibration_warning_dialog");
} else {
mPopupCameraService.calibrateMotor();
}
return true; return true;
} }
return false; return false;
@ -83,25 +74,9 @@ public class PopupCameraSettingsFragment extends PreferenceFragment
private class MotorCalibrationWarningDialog extends DialogFragment { private class MotorCalibrationWarningDialog extends DialogFragment {
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { 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()) return new AlertDialog.Builder(getActivity())
.setTitle(R.string.popup_calibration_warning_title) .setTitle(R.string.popup_calibration_warning_title)
.setMessage(R.string.popup_calibration_warning_text) .setMessage(R.string.popup_calibration_warning_text)
.setView(view)
.setPositiveButton(R.string.popup_camera_calibrate_now, .setPositiveButton(R.string.popup_camera_calibrate_now,
(dialog, which) -> { (dialog, which) -> {
mPopupCameraService.calibrateMotor(); mPopupCameraService.calibrateMotor();