From 8101d7468de000327525b187501f21319c53abbe Mon Sep 17 00:00:00 2001 From: TIANGeng708 <1012721175@qq.com> Date: Sat, 23 Apr 2022 16:31:58 +0800 Subject: [PATCH] bug --- .../dialogs/GlobalSettingsDialog.java | 13 +++- .../lastlauncher/utils/Constants.java | 6 +- app/src/main/res/menu/sort_apps_popups.xml | 8 ++- app/src/main/res/values-zh-rCN/strings.xml | 1 + app/src/main/res/values/strings.xml | 2 + .../lastlauncher/LauncherActivityTest.java | 68 +++++++++++++++++++ .../lastlauncher/utils/ConstantsTest.java | 23 +++++++ 7 files changed, 115 insertions(+), 6 deletions(-) create mode 100644 app/src/test/java/io/github/subhamtyagi/lastlauncher/LauncherActivityTest.java create mode 100644 app/src/test/java/io/github/subhamtyagi/lastlauncher/utils/ConstantsTest.java diff --git a/app/src/main/java/io/github/subhamtyagi/lastlauncher/dialogs/GlobalSettingsDialog.java b/app/src/main/java/io/github/subhamtyagi/lastlauncher/dialogs/GlobalSettingsDialog.java index d5af5435..3a3b0f9d 100644 --- a/app/src/main/java/io/github/subhamtyagi/lastlauncher/dialogs/GlobalSettingsDialog.java +++ b/app/src/main/java/io/github/subhamtyagi/lastlauncher/dialogs/GlobalSettingsDialog.java @@ -169,6 +169,11 @@ public void onClick(View view) { } } + /**This method is used to control the order of apps. + * The code block we added is to give the newly added buttons the ability to sort them by name. + * + * @param view + */ private void sortApps(View view) { Context context; // set theme @@ -184,8 +189,12 @@ private void sortApps(View view) { popupMenu.setOnMenuItemClickListener(menuItem -> { cancel(); switch (menuItem.getItemId()) { - case R.id.menu_sort_by_name: - launcherActivity.sortApps(Constants.SORT_BY_NAME); +// case R.id.menu_sort_by_name: +// launcherActivity.sortApps(Constants.SORT_BY_NAME); +// break; + //CS304 Issue link: https://github.com/SubhamTyagi/Last-Launcher/issues/165 + case R.id.menu_sort_by_name_modify: + launcherActivity.sortApps(Constants.SORT_BY_NAME_MODIFY); break; case R.id.menu_sort_by_opening_counts: launcherActivity.sortApps(Constants.SORT_BY_OPENING_COUNTS); diff --git a/app/src/main/java/io/github/subhamtyagi/lastlauncher/utils/Constants.java b/app/src/main/java/io/github/subhamtyagi/lastlauncher/utils/Constants.java index 23a4a47f..96c5bfe5 100644 --- a/app/src/main/java/io/github/subhamtyagi/lastlauncher/utils/Constants.java +++ b/app/src/main/java/io/github/subhamtyagi/lastlauncher/utils/Constants.java @@ -32,6 +32,8 @@ public class Constants { public static final int SORT_BY_CUSTOM = 5; public static final int SORT_BY_UPDATE_TIME = 6; public static final int SORT_BY_RECENT_OPEN = 7; + //CS304 Issue link: https://github.com/SubhamTyagi/Last-Launcher/issues/165 + public static final int SORT_BY_NAME_MODIFY = 1; public static final int RESTORE_REQUEST = 125; public static final int FONTS_REQUEST = 126; @@ -47,8 +49,8 @@ public class Constants { public static int dynamicHeight = 20; public static final int DEFAULT_TEXT_SIZE_NORMAL_APPS = dynamicHeight; public static final int DEFAULT_TEXT_SIZE_OFTEN_APPS = dynamicHeight * 9 / 5; - public static final int MAX_TEXT_SIZE_FOR_APPS=90; - public static final int MIN_TEXT_SIZE_FOR_APPS=14; + public static final int MAX_TEXT_SIZE_FOR_APPS = 90; + public static final int MIN_TEXT_SIZE_FOR_APPS = 14; } diff --git a/app/src/main/res/menu/sort_apps_popups.xml b/app/src/main/res/menu/sort_apps_popups.xml index dcb155c1..d5d95068 100644 --- a/app/src/main/res/menu/sort_apps_popups.xml +++ b/app/src/main/res/menu/sort_apps_popups.xml @@ -19,8 +19,12 @@ + android:id="@+id/menu_sort_by_name_modify" + android:title="@string/by_name_modify" /> + + + + 颜色 应用使用 明朝 + 名称 应用排序依据 选择字体 恢复默认字体 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7b7eda9a..33e64bc4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -77,6 +77,8 @@ Sort Apps By Name + + App Name App Usage diff --git a/app/src/test/java/io/github/subhamtyagi/lastlauncher/LauncherActivityTest.java b/app/src/test/java/io/github/subhamtyagi/lastlauncher/LauncherActivityTest.java new file mode 100644 index 00000000..5ca76527 --- /dev/null +++ b/app/src/test/java/io/github/subhamtyagi/lastlauncher/LauncherActivityTest.java @@ -0,0 +1,68 @@ +package io.github.subhamtyagi.lastlauncher; + +import android.view.View; +import io.github.subhamtyagi.lastlauncher.utils.Gestures; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertTrue; + +public class LauncherActivityTest { + + private LauncherActivity launcherActivityUnderTest; + + @Before + public void setUp() { + launcherActivityUnderTest = new LauncherActivity(); + } + + + @Test + //CS304 Issue link: https://github.com/SubhamTyagi/Last-Launcher/issues/165 + public void testOnClick() { + // Setup + final View view = new View(null); + + // Run the test + launcherActivityUnderTest.onClick(view); + + // Verify the results + } + + + @Test + //CS304 Issue link: https://github.com/SubhamTyagi/Last-Launcher/issues/165 + public void testOnLongClick() { + // Setup + final View view = new View(null); + + // Run the test + final boolean result = launcherActivityUnderTest.onLongClick(view); + + // Verify the results + assertTrue(result); + } + + + @Test + //CS304 Issue link: https://github.com/SubhamTyagi/Last-Launcher/issues/165 + public void testOnSwipe() { + // Setup + // Run the test + launcherActivityUnderTest.onSwipe(Gestures.Direction.SWIPE_UP); + + // Verify the results + } + + @Test + //CS304 Issue link: https://github.com/SubhamTyagi/Last-Launcher/issues/165 + public void testOnDoubleTap() { + // Setup + // Run the test + launcherActivityUnderTest.onDoubleTap(); + + // Verify the results + } + + +} diff --git a/app/src/test/java/io/github/subhamtyagi/lastlauncher/utils/ConstantsTest.java b/app/src/test/java/io/github/subhamtyagi/lastlauncher/utils/ConstantsTest.java new file mode 100644 index 00000000..751cf25d --- /dev/null +++ b/app/src/test/java/io/github/subhamtyagi/lastlauncher/utils/ConstantsTest.java @@ -0,0 +1,23 @@ +package io.github.subhamtyagi.lastlauncher.utils; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class ConstantsTest { + + private Constants constantsUnderTest; + + @Before + public void setUp() { + constantsUnderTest = new Constants(); + } + + + @Test + //CS304 Issue link: https://github.com/SubhamTyagi/Last-Launcher/issues/165 + public void testOnConstants() { + int a= Constants.SORT_BY_NAME_MODIFY; + Assert.assertEquals(1,a); + } +}