Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution for issue #165 #166

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;


}
8 changes: 6 additions & 2 deletions app/src/main/res/menu/sort_apps_popups.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">

<item
android:id="@+id/menu_sort_by_name"
android:title="@string/by_name" />
android:id="@+id/menu_sort_by_name_modify"
android:title="@string/by_name_modify" />

<!-- <item-->
<!-- android:id="@+id/menu_sort_by_name"-->
<!-- android:title="@string/by_name" />-->

<item
android:id="@+id/menu_sort_by_opening_counts"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<string name="by_color">颜色</string>
<string name="by_opening_counts">应用使用</string>
<string name="by_name">明朝</string>
<string name="by_name_modify">名称</string>
<string name="sort_apps_by">应用排序依据</string>
<string name="select_fonts">选择字体</string>
<string name="restore_default_fonts">恢复默认字体</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@
<string name="sort_apps_by">Sort Apps By</string>
<!--Sort Apps By: NAME-->
<string name="by_name">Name</string>
<!--Sort Apps By: NAME-->
<string name="by_name_modify">App Name</string>
<!--Sort Apps By: APP USAGE TIME-->
<string name="by_opening_counts">App Usage</string>
<!--Sort Apps By: APP COLOR-->
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}


}
Original file line number Diff line number Diff line change
@@ -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);
}
}