Merge "Should popup the confirmation toast after clicking the reset button." into tm-dev am: 8cb0439d9c am: cc4af05607

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/17822267

Change-Id: I74bb43797299b183a40f9050b6256e768361c7d5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
PETER LIANG
2022-04-20 13:20:24 +00:00
committed by Automerger Merge Worker
3 changed files with 21 additions and 0 deletions

View File

@@ -5300,6 +5300,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] -->

View File

@@ -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() {

View File

@@ -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));
}
}