From 5ad9d71a7cc9107f9c0fb3fe03b049dcc8f949c0 Mon Sep 17 00:00:00 2001 From: e <11910117@mail.sustech.edu.cn> Date: Sun, 22 May 2022 17:25:24 +0800 Subject: [PATCH] Add two menu items for adding a new function that use can change spacing bewteen apps. --- .../lastlauncher/LauncherActivity.java | 8 ++++++++ .../dialogs/GlobalSettingsDialog.java | 18 ++++++++++++++++++ app/src/main/res/menu/font_selection_popup.xml | 6 ++++++ app/src/main/res/values-zh-rCN/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 2 ++ .../org/apmem/tools/layouts/FlowLayout.java | 14 +++++++++++++- 6 files changed, 49 insertions(+), 1 deletion(-) 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 eef5f096..a59d8a88 100644 --- a/app/src/main/java/io/github/subhamtyagi/lastlauncher/LauncherActivity.java +++ b/app/src/main/java/io/github/subhamtyagi/lastlauncher/LauncherActivity.java @@ -587,6 +587,14 @@ public boolean onLongClick(View view) { return true; } + public void addAppSpacing() { + mHomeLayout.addletterSpacingRate(); + } + + public void minusAppSpacint() { + mHomeLayout.minusletterSpacingRate(); + } + private void showPopup(String activityName, AppTextView view) { Context context; 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 2c2b114f..566d7e16 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 @@ -369,6 +369,16 @@ private void setFonts() { } + private void addAppSpacing() { + cancel(); + launcherActivity.addAppSpacing(); + } + + private void minuAppSpacing() { + cancel(); + launcherActivity.minusAppSpacint(); + } + private void fontSelection(View view) { Context context; @@ -384,6 +394,14 @@ private void fontSelection(View view) { popupMenu.setOnMenuItemClickListener(menuItem -> { switch (menuItem.getItemId()) { + case R.id.menu_add_spacing: + addAppSpacing(); + launcherActivity.loadApps(); + break; + case R.id.menu_minus_spacing: + minuAppSpacing(); + launcherActivity.loadApps(); + break; case R.id.menu_choose_fonts: setFonts(); break; diff --git a/app/src/main/res/menu/font_selection_popup.xml b/app/src/main/res/menu/font_selection_popup.xml index bcd37ccb..a9fc5c4e 100644 --- a/app/src/main/res/menu/font_selection_popup.xml +++ b/app/src/main/res/menu/font_selection_popup.xml @@ -25,4 +25,10 @@ + + \ No newline at end of file diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index e106508b..74a9cd87 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -56,4 +56,6 @@ 颜色&尺寸 设置 重启启动器 + 增大应用间距 + 减小应用间距 \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7b7eda9a..21217fe0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -90,4 +90,6 @@ Recently first Restart Launcher + Add app spacing + Minus app spacing \ No newline at end of file diff --git a/flowlayout/layouts/src/main/java/org/apmem/tools/layouts/FlowLayout.java b/flowlayout/layouts/src/main/java/org/apmem/tools/layouts/FlowLayout.java index 15492067..1dcc5646 100644 --- a/flowlayout/layouts/src/main/java/org/apmem/tools/layouts/FlowLayout.java +++ b/flowlayout/layouts/src/main/java/org/apmem/tools/layouts/FlowLayout.java @@ -26,6 +26,18 @@ public class FlowLayout extends ViewGroup { List lines = new ArrayList<>(); List views = new ArrayList<>(); + private double letterSpacingRate = 0; + + public void addletterSpacingRate() { + letterSpacingRate += 0.1; + } + + public void minusletterSpacingRate() { + if (letterSpacingRate>0) { + letterSpacingRate -= 0.1; + } + } + public FlowLayout(Context context) { super(context); this.config = new ConfigDefinition(); @@ -86,7 +98,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { ); ViewDefinition view = new ViewDefinition(this.config, child); - view.setWidth(child.getMeasuredWidth()); + view.setWidth((int)(child.getMeasuredWidth()*(1+letterSpacingRate))); view.setHeight(child.getMeasuredHeight()); view.setNewLine(lp.isNewLine()); view.setGravity(lp.getGravity());