Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b833fe1b authored by Peter_Liang's avatar Peter_Liang
Browse files

Should popup the confirmation toast after clicking the reset button.

Goal: Users may not notice what the change after resetting all settings configs in the Text and reading options. So we will use the toast to give nice feedback for them.

Fix: 220126995
Test: make RunSettingsRoboTests  ROBOTEST_FILTER=TextReadingPreferenceFragmentTest
Change-Id: Ife42b0c9d8a0241d7b8c3e5dbe7f9f1e2a6d759a
parent 39e13577
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -5306,6 +5306,8 @@
    <string name="accessibility_text_reading_preview_mail_content">Good morning!\n\nI just wanted to check how the designs are coming. Will they be ready before we start building the new balloons?</string>
    <!-- Title for the reset button of the accessibility text reading page to reset all preferences state. [CHAR LIMIT=25] -->
    <string name="accessibility_text_reading_reset_button_title">Reset settings</string>
    <!-- Message for the toast after clicking the reset button of the dialog of the accessibility text reading page. [CHAR LIMIT=NONE] -->
    <string name="accessibility_text_reading_reset_message">Display size and text settings have been reset</string>
    <!-- Title for the confirm dialog of reset settings. [CHAR LIMIT=NONE] -->
    <string name="accessibility_text_reading_confirm_dialog_title">Reset display size and text?</string>
    <!-- Message for the confirm dialog of reset settings. [CHAR LIMIT=NONE] -->
+4 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.widget.Toast;

import androidx.appcompat.app.AlertDialog;

@@ -178,6 +179,9 @@ public class TextReadingPreferenceFragment extends DashboardFragment {
        } else {
            mResetStateListeners.forEach(ResetStateListener::resetState);
        }

        Toast.makeText(getPrefContext(), R.string.accessibility_text_reading_reset_message,
                Toast.LENGTH_SHORT).show();
    }

    private List<ResetStateListener> getResetStateListeners() {
+15 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.shadows.ShadowToast;

import java.util.ArrayList;
import java.util.Arrays;
@@ -104,4 +105,18 @@ public class TextReadingPreferenceFragmentTest {
        verify(listener1).resetState();
        verify(listener2).resetState();
    }

    @Test
    public void onDialogPositiveButtonClicked_boldTextEnabled_showToast() {
        Settings.Secure.putInt(mContext.getContentResolver(),
                Settings.Secure.FONT_WEIGHT_ADJUSTMENT, BOLD_TEXT_ADJUSTMENT);
        final AlertDialog dialog = (AlertDialog) mFragment.onCreateDialog(
                DialogEnums.DIALOG_RESET_SETTINGS);
        dialog.show();

        dialog.getButton(DialogInterface.BUTTON_POSITIVE).callOnClick();

        assertThat(ShadowToast.getTextOfLatestToast())
                .isEqualTo(mContext.getString(R.string.accessibility_text_reading_reset_message));
    }
}