davinci: parts: Always show the warning dialog
Change-Id: I979cc479ee928edf0e203489264df340326fbf5b
This commit is contained in:
parent
d738bb5729
commit
a5fe3b11a6
@ -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>
|
@ -30,7 +30,6 @@
|
||||
<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_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 -->
|
||||
<string name="popup_camera_tip">Warning</string>
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user