From d7b45997b1049a03e02326aea7b204926f7085ec Mon Sep 17 00:00:00 2001 From: 11910916 <72482143+11910916@users.noreply.github.com> Date: Sat, 23 Apr 2022 11:25:33 +0800 Subject: [PATCH 1/7] Update activity_launcher.xml --- app/src/main/res/layout/activity_launcher.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/layout/activity_launcher.xml b/app/src/main/res/layout/activity_launcher.xml index 2d2e0ccf..d16c9ea5 100644 --- a/app/src/main/res/layout/activity_launcher.xml +++ b/app/src/main/res/layout/activity_launcher.xml @@ -14,7 +14,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center|center_horizontal|center_vertical" - android:orientation="horizontal" /> + android:orientation="vertical" /> From 62f5e2d426a44dc3255934abbeb4fbf8c51beeaa Mon Sep 17 00:00:00 2001 From: ha <72482143+hahcde@users.noreply.github.com> Date: Sat, 23 Apr 2022 19:36:53 +0800 Subject: [PATCH 2/7] Update LauncherActivity.java --- .../lastlauncher/LauncherActivity.java | 90 +++++++++++++------ 1 file changed, 62 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/io/github/subhamtyagi/lastlauncher/LauncherActivity.java b/app/src/main/java/io/github/subhamtyagi/lastlauncher/LauncherActivity.java index e9a11865..f78a54bc 100644 --- a/app/src/main/java/io/github/subhamtyagi/lastlauncher/LauncherActivity.java +++ b/app/src/main/java/io/github/subhamtyagi/lastlauncher/LauncherActivity.java @@ -139,7 +139,7 @@ public class LauncherActivity extends Activity implements View.OnClickListener, public static ArrayList mAppsList; // home layout private static FlowLayout mHomeLayout; - // when search bar appears this will be true and show search result + // when search bar is appear this will be true and show search result private static boolean searching = false; //todo: save this to db private static int recentlyUsedCounter = 0; @@ -157,7 +157,8 @@ public class LauncherActivity extends Activity implements View.OnClickListener, // gesture detector private Gestures detector; private ShortcutUtils shortcutUtils; - + private Thread thread; + private static boolean judge = true; private static final TextWatcher mTextWatcher= new TextWatcher() { @Override @@ -168,7 +169,7 @@ public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { //do here search - mSearchTask.execute(charSequence); + mSearchTask.execute(charSequence); } @Override @@ -216,8 +217,18 @@ protected void onCreate(Bundle savedInstanceState) { } int theme = DbUtils.getTheme(); + if(judge){ + int hour = new Date(System.currentTimeMillis()).getHours(); + setTheme(hour<=19 && hour>=7 ? R.style.BlackOnGrey : R.style.Black); + judge = false; + } + else{ + setTheme(theme); + } + + //theme must be set before setContentView - setTheme(theme); + //setTheme(theme); setContentView(R.layout.activity_launcher); @@ -253,7 +264,6 @@ protected void onCreate(Bundle savedInstanceState) { // register the receiver for installed, uninstall, update apps and shortcut pwa add registerForReceivers(); - mLocale = this.getResources().getConfiguration().locale; } private void setSearchBoxListeners() { @@ -557,11 +567,16 @@ protected void onResume() { sortApps(DbUtils.getSortsTypes()); } } - + @Override + protected void onStart(){ + super.onStart(); + thread = new Thread(new MyThread()); + thread.start(); + } @Override protected void onStop() { super.onStop(); - + thread.interrupt(); if (dialogs != null) { dialogs.dismiss(); dialogs = null; @@ -587,6 +602,44 @@ public boolean onLongClick(View view) { return true; } + class MyThread implements Runnable{ + @Override + public void run(){ + try { + while (!Thread.currentThread().isInterrupted()) { + Thread.sleep(59900); + Date date = new Date(System.currentTimeMillis()); + int hour = date.getHours(); + int minute = date.getMinutes(); + if(hour==11&&minute==32){ + backup(); + } + } + } + catch(InterruptedException e){ + } + + } + } + + private void backup(){ + Intent intentBackupFiles; + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { + intentBackupFiles = new Intent(Intent.ACTION_CREATE_DOCUMENT); + } else { + intentBackupFiles = new Intent(Intent.ACTION_GET_CONTENT); + ; + } + intentBackupFiles.addCategory(Intent.CATEGORY_OPENABLE); + intentBackupFiles.setType("*/*"); + SimpleDateFormat df = new SimpleDateFormat("yyyy_MM_dd_HHSS", Locale.getDefault()); + df.format(new Date()); + String date = df.format(new Date()); + intentBackupFiles.putExtra(Intent.EXTRA_TITLE, "Backup_LastLauncher_" + date); + this.startActivityForResult(intentBackupFiles, BACKUP_REQUEST); + } + + private void showPopup(String activityName, AppTextView view) { Context context; @@ -741,8 +794,8 @@ private void renameApp(String activityName, String appName) { Window window = dialogs.getWindow(); if (window != null) { window.setGravity(Gravity.BOTTOM); - window.setBackgroundDrawableResource(android.R.color.transparent); window.setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); + window.setBackgroundDrawableResource(android.R.color.holo_blue_bright); } dialogs.show(); @@ -1228,7 +1281,6 @@ public void onDoubleTap() { } - private static Locale mLocale; static class SearchTask extends AsyncTask> { @Override protected void onPostExecute(ArrayList filteredApps) { @@ -1244,24 +1296,6 @@ protected ArrayList doInBackground(CharSequence... charSequences) { filteredApps.add(app); } else if (Utils.simpleFuzzySearch(charSequences[0], app.getAppName())) { filteredApps.add(app); - } else{ - // Support for searching non-ascii languages Apps using ascii characters. - boolean isMatch = false; - switch (mLocale.getLanguage()){ - case "zh":{ - // In case of Chinese, PinYin Search is supported. - isMatch = PinYinSearchUtils.pinYinSimpleFuzzySearch(charSequences[0], app.getAppName()); - break; - } -// You can add new non-ascii language search to be supported here. -// case "xx":{ -// break; -// } - default: - break; - } - if (isMatch) - filteredApps.add(app); } } return filteredApps; @@ -1333,4 +1367,4 @@ protected Void doInBackground(final Integer... integers) { return null; } } -} \ No newline at end of file +} From 55d54f44229a869976c4b3a48d2f34c9a0a43909 Mon Sep 17 00:00:00 2001 From: ha <72482143+hahcde@users.noreply.github.com> Date: Sat, 23 Apr 2022 19:46:02 +0800 Subject: [PATCH 3/7] Update LauncherActivity.java --- .../lastlauncher/LauncherActivity.java | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/io/github/subhamtyagi/lastlauncher/LauncherActivity.java b/app/src/main/java/io/github/subhamtyagi/lastlauncher/LauncherActivity.java index f78a54bc..98aac48b 100644 --- a/app/src/main/java/io/github/subhamtyagi/lastlauncher/LauncherActivity.java +++ b/app/src/main/java/io/github/subhamtyagi/lastlauncher/LauncherActivity.java @@ -68,8 +68,10 @@ import java.io.InputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; +import java.util.Date; import java.util.List; import java.util.ListIterator; import java.util.Locale; @@ -158,7 +160,7 @@ public class LauncherActivity extends Activity implements View.OnClickListener, private Gestures detector; private ShortcutUtils shortcutUtils; private Thread thread; - private static boolean judge = true; + private static final TextWatcher mTextWatcher= new TextWatcher() { @Override @@ -217,18 +219,9 @@ protected void onCreate(Bundle savedInstanceState) { } int theme = DbUtils.getTheme(); - if(judge){ - int hour = new Date(System.currentTimeMillis()).getHours(); - setTheme(hour<=19 && hour>=7 ? R.style.BlackOnGrey : R.style.Black); - judge = false; - } - else{ - setTheme(theme); - } - //theme must be set before setContentView - //setTheme(theme); + setTheme(theme); setContentView(R.layout.activity_launcher); @@ -572,7 +565,7 @@ protected void onStart(){ super.onStart(); thread = new Thread(new MyThread()); thread.start(); - } + } @Override protected void onStop() { super.onStop(); @@ -611,7 +604,7 @@ public void run(){ Date date = new Date(System.currentTimeMillis()); int hour = date.getHours(); int minute = date.getMinutes(); - if(hour==11&&minute==32){ + if(hour==12&&minute==0){ backup(); } } From ad2cfe7a4465ed3ebb03f4325c15655af30a8682 Mon Sep 17 00:00:00 2001 From: ha <72482143+hahcde@users.noreply.github.com> Date: Sat, 23 Apr 2022 19:47:59 +0800 Subject: [PATCH 4/7] Update activity_launcher.xml --- app/src/main/res/layout/activity_launcher.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/layout/activity_launcher.xml b/app/src/main/res/layout/activity_launcher.xml index d16c9ea5..2d2e0ccf 100644 --- a/app/src/main/res/layout/activity_launcher.xml +++ b/app/src/main/res/layout/activity_launcher.xml @@ -14,7 +14,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center|center_horizontal|center_vertical" - android:orientation="vertical" /> + android:orientation="horizontal" /> From d7b6ca60137657a69394320580a4bd5653bb0fa5 Mon Sep 17 00:00:00 2001 From: ha <72482143+hahcde@users.noreply.github.com> Date: Sat, 23 Apr 2022 20:31:40 +0800 Subject: [PATCH 5/7] Update LauncherActivity.java --- .../lastlauncher/LauncherActivity.java | 101 ++++++++++-------- 1 file changed, 59 insertions(+), 42 deletions(-) diff --git a/app/src/main/java/io/github/subhamtyagi/lastlauncher/LauncherActivity.java b/app/src/main/java/io/github/subhamtyagi/lastlauncher/LauncherActivity.java index 98aac48b..fb7af0a1 100644 --- a/app/src/main/java/io/github/subhamtyagi/lastlauncher/LauncherActivity.java +++ b/app/src/main/java/io/github/subhamtyagi/lastlauncher/LauncherActivity.java @@ -141,7 +141,7 @@ public class LauncherActivity extends Activity implements View.OnClickListener, public static ArrayList mAppsList; // home layout private static FlowLayout mHomeLayout; - // when search bar is appear this will be true and show search result + // when search bar appears this will be true and show search result private static boolean searching = false; //todo: save this to db private static int recentlyUsedCounter = 0; @@ -159,8 +159,8 @@ public class LauncherActivity extends Activity implements View.OnClickListener, // gesture detector private Gestures detector; private ShortcutUtils shortcutUtils; - private Thread thread; + private Thread thread; private static final TextWatcher mTextWatcher= new TextWatcher() { @Override @@ -219,7 +219,6 @@ protected void onCreate(Bundle savedInstanceState) { } int theme = DbUtils.getTheme(); - //theme must be set before setContentView setTheme(theme); @@ -257,6 +256,7 @@ protected void onCreate(Bundle savedInstanceState) { // register the receiver for installed, uninstall, update apps and shortcut pwa add registerForReceivers(); + mLocale = this.getResources().getConfiguration().locale; } private void setSearchBoxListeners() { @@ -547,6 +547,42 @@ public void onClick(View view) { } } + class MyThread implements Runnable{ + @Override + public void run(){ + try { + while (!Thread.currentThread().isInterrupted()) { + Thread.sleep(59900); + Date date = new Date(System.currentTimeMillis()); + int hour = date.getHours(); + int minute = date.getMinutes(); + if(hour==12&&minute==29){ + backup(); + } + } + } + catch(InterruptedException e){ + } + + } + } + + private void backup(){ + Intent intentBackupFiles; + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { + intentBackupFiles = new Intent(Intent.ACTION_CREATE_DOCUMENT); + } else { + intentBackupFiles = new Intent(Intent.ACTION_GET_CONTENT); + ; + } + intentBackupFiles.addCategory(Intent.CATEGORY_OPENABLE); + intentBackupFiles.setType("*/*"); + SimpleDateFormat df = new SimpleDateFormat("yyyy_MM_dd_HHSS", Locale.getDefault()); + df.format(new Date()); + String date = df.format(new Date()); + intentBackupFiles.putExtra(Intent.EXTRA_TITLE, "Backup_LastLauncher_" + date); + this.startActivityForResult(intentBackupFiles, BACKUP_REQUEST); + } @Override protected void onResume() { @@ -595,44 +631,6 @@ public boolean onLongClick(View view) { return true; } - class MyThread implements Runnable{ - @Override - public void run(){ - try { - while (!Thread.currentThread().isInterrupted()) { - Thread.sleep(59900); - Date date = new Date(System.currentTimeMillis()); - int hour = date.getHours(); - int minute = date.getMinutes(); - if(hour==12&&minute==0){ - backup(); - } - } - } - catch(InterruptedException e){ - } - - } - } - - private void backup(){ - Intent intentBackupFiles; - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { - intentBackupFiles = new Intent(Intent.ACTION_CREATE_DOCUMENT); - } else { - intentBackupFiles = new Intent(Intent.ACTION_GET_CONTENT); - ; - } - intentBackupFiles.addCategory(Intent.CATEGORY_OPENABLE); - intentBackupFiles.setType("*/*"); - SimpleDateFormat df = new SimpleDateFormat("yyyy_MM_dd_HHSS", Locale.getDefault()); - df.format(new Date()); - String date = df.format(new Date()); - intentBackupFiles.putExtra(Intent.EXTRA_TITLE, "Backup_LastLauncher_" + date); - this.startActivityForResult(intentBackupFiles, BACKUP_REQUEST); - } - - private void showPopup(String activityName, AppTextView view) { Context context; @@ -787,8 +785,8 @@ private void renameApp(String activityName, String appName) { Window window = dialogs.getWindow(); if (window != null) { window.setGravity(Gravity.BOTTOM); + window.setBackgroundDrawableResource(android.R.color.transparent); window.setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); - window.setBackgroundDrawableResource(android.R.color.holo_blue_bright); } dialogs.show(); @@ -1274,6 +1272,7 @@ public void onDoubleTap() { } + private static Locale mLocale; static class SearchTask extends AsyncTask> { @Override protected void onPostExecute(ArrayList filteredApps) { @@ -1289,6 +1288,24 @@ protected ArrayList doInBackground(CharSequence... charSequences) { filteredApps.add(app); } else if (Utils.simpleFuzzySearch(charSequences[0], app.getAppName())) { filteredApps.add(app); + } else{ + // Support for searching non-ascii languages Apps using ascii characters. + boolean isMatch = false; + switch (mLocale.getLanguage()){ + case "zh":{ + // In case of Chinese, PinYin Search is supported. + isMatch = PinYinSearchUtils.pinYinSimpleFuzzySearch(charSequences[0], app.getAppName()); + break; + } +// You can add new non-ascii language search to be supported here. +// case "xx":{ +// break; +// } + default: + break; + } + if (isMatch) + filteredApps.add(app); } } return filteredApps; From 50b813e887389f36a349beaa17e72047a693c525 Mon Sep 17 00:00:00 2001 From: ha <72482143+hahcde@users.noreply.github.com> Date: Sat, 23 Apr 2022 20:44:07 +0800 Subject: [PATCH 6/7] Update activity_launcher.xml --- app/src/main/res/layout/activity_launcher.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/layout/activity_launcher.xml b/app/src/main/res/layout/activity_launcher.xml index 2d2e0ccf..d16c9ea5 100644 --- a/app/src/main/res/layout/activity_launcher.xml +++ b/app/src/main/res/layout/activity_launcher.xml @@ -14,7 +14,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center|center_horizontal|center_vertical" - android:orientation="horizontal" /> + android:orientation="vertical" /> From 9d5357d0e680817e595cd652938fc972d0170778 Mon Sep 17 00:00:00 2001 From: ha <72482143+hahcde@users.noreply.github.com> Date: Sat, 23 Apr 2022 21:44:09 +0800 Subject: [PATCH 7/7] Update activity_launcher.xml --- app/src/main/res/layout/activity_launcher.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/layout/activity_launcher.xml b/app/src/main/res/layout/activity_launcher.xml index d16c9ea5..2d2e0ccf 100644 --- a/app/src/main/res/layout/activity_launcher.xml +++ b/app/src/main/res/layout/activity_launcher.xml @@ -14,7 +14,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center|center_horizontal|center_vertical" - android:orientation="vertical" /> + android:orientation="horizontal" />