From 3c6513473a24fbce67d159c27c0087fac62de286 Mon Sep 17 00:00:00 2001 From: Arian Date: Tue, 7 Nov 2023 14:58:06 +0100 Subject: [PATCH] sm6150-common: parts: Get rid of HelpDialogFragment class As preparation to upgrade the sdk get rid of this private class. Fragments must be a public static class to be properly recreated from instance state. Also change the behaviour to only hide the dialog when confirmed instead of also when it is cancelled. Change-Id: I171aa2345058edae7520c37942c3c11b3cdfdfdc --- .../settings/doze/DozeSettingsFragment.java | 38 ++++++++----------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/parts/src/org/lineageos/settings/doze/DozeSettingsFragment.java b/parts/src/org/lineageos/settings/doze/DozeSettingsFragment.java index b845d6c..ef31c90 100644 --- a/parts/src/org/lineageos/settings/doze/DozeSettingsFragment.java +++ b/parts/src/org/lineageos/settings/doze/DozeSettingsFragment.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2015 The CyanogenMod Project - * 2017-2019 The LineageOS Project + * 2017-2023 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. @@ -178,28 +178,20 @@ public class DozeSettingsFragment extends PreferenceFragment mPocketPreference.setEnabled(isChecked); } - private static class HelpDialogFragment extends DialogFragment { - @Override - public Dialog onCreateDialog(Bundle savedInstanceState) { - return new AlertDialog.Builder(getActivity()) - .setTitle(R.string.doze_settings_help_title) - .setMessage(R.string.doze_settings_help_text) - .setNegativeButton(R.string.dialog_ok, (dialog, which) -> dialog.cancel()) - .create(); - } - - @Override - public void onCancel(DialogInterface dialog) { - getActivity() - .getSharedPreferences("doze_settings", Activity.MODE_PRIVATE) - .edit() - .putBoolean("first_help_shown", true) - .commit(); - } - } - private void showHelp() { - HelpDialogFragment fragment = new HelpDialogFragment(); - fragment.show(getFragmentManager(), "help_dialog"); + AlertDialog helpDialog = new AlertDialog.Builder(getActivity()) + .setTitle(R.string.doze_settings_help_title) + .setMessage(R.string.doze_settings_help_text) + .setPositiveButton(R.string.dialog_ok, + (dialog, which) -> { + getActivity() + .getSharedPreferences("doze_settings", Activity.MODE_PRIVATE) + .edit() + .putBoolean("first_help_shown", true) + .commit(); + dialog.cancel(); + }) + .create(); + helpDialog.show(); } }