From 882207682fe3e82cb15bb1f1db87565022d4826e Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 21 Jan 2024 18:56:15 +0900 Subject: [PATCH 01/17] =?UTF-8?q?FeatureSwitch=E3=82=AF=E3=83=A9=E3=82=B9?= =?UTF-8?q?=E4=BD=9C=E6=88=90=20WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/utils/FeatureSwitch.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java diff --git a/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java b/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java new file mode 100644 index 00000000..92b09262 --- /dev/null +++ b/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java @@ -0,0 +1,14 @@ +package one.nem.lacerta.utils; + +public class FeatureSwitch { + + public static class FeatureMaster { + public static boolean enableSearch = true; + } + + public static class Setting { + public static boolean showDisplayMenu = false; + public static boolean showDataMenu = false; + public static boolean showScanMenu = false; + } +} From 8f1849591dad900ce5ac34d9de49cb9f83dfc75e Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 21 Jan 2024 19:02:33 +0900 Subject: [PATCH 02/17] =?UTF-8?q?=E4=BE=9D=E5=AD=98=E9=96=A2=E4=BF=82?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utils/build.gradle b/utils/build.gradle index 1aab90c9..c98e08bb 100644 --- a/utils/build.gradle +++ b/utils/build.gradle @@ -39,4 +39,6 @@ dependencies { // model implementation project(':model') + + implementation project(':utils') } \ No newline at end of file From acea8ba27d6385b8422508afc50ad3b56e9609fe Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 21 Jan 2024 19:03:45 +0900 Subject: [PATCH 03/17] =?UTF-8?q?Revert=20"=E4=BE=9D=E5=AD=98=E9=96=A2?= =?UTF-8?q?=E4=BF=82=E8=BF=BD=E5=8A=A0"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 8f1849591dad900ce5ac34d9de49cb9f83dfc75e. --- utils/build.gradle | 2 -- 1 file changed, 2 deletions(-) diff --git a/utils/build.gradle b/utils/build.gradle index c98e08bb..1aab90c9 100644 --- a/utils/build.gradle +++ b/utils/build.gradle @@ -39,6 +39,4 @@ dependencies { // model implementation project(':model') - - implementation project(':utils') } \ No newline at end of file From af626f4dc0345803023ad595009131794399eebb Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 21 Jan 2024 19:04:01 +0900 Subject: [PATCH 04/17] =?UTF-8?q?=E4=BE=9D=E5=AD=98=E9=96=A2=E4=BF=82?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index 300174c9..7368eab2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -78,4 +78,6 @@ dependencies { implementation project(':data') implementation project(':shared:ui') + + implementation project(':utils') } \ No newline at end of file From ec7adbe33141577528f9960df26c483992fa515c Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 21 Jan 2024 19:07:33 +0900 Subject: [PATCH 05/17] =?UTF-8?q?SharedPrefUtils=E3=83=A1=E3=82=BD?= =?UTF-8?q?=E3=83=83=E3=83=89=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/utils/impl/SharedPrefUtilsImpl.java | 10 ++++++++++ .../nem/lacerta/utils/repository/SharedPrefUtils.java | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/utils/src/main/java/one/nem/lacerta/utils/impl/SharedPrefUtilsImpl.java b/utils/src/main/java/one/nem/lacerta/utils/impl/SharedPrefUtilsImpl.java index f976b46b..14f493a5 100644 --- a/utils/src/main/java/one/nem/lacerta/utils/impl/SharedPrefUtilsImpl.java +++ b/utils/src/main/java/one/nem/lacerta/utils/impl/SharedPrefUtilsImpl.java @@ -26,4 +26,14 @@ public class SharedPrefUtilsImpl implements SharedPrefUtils{ // Editorの取得 return applicationContext.getSharedPreferences(name, Context.MODE_PRIVATE).edit(); } + + @Override + public SharedPreferences getSharedPreferences(String name) { + return applicationContext.getSharedPreferences(name, Context.MODE_PRIVATE); + } + + @Override + public SharedPreferences getSharedPreferences() { + return applicationContext.getSharedPreferences("common", Context.MODE_PRIVATE); // TODO-rca: 決め打ちやめる? + } } diff --git a/utils/src/main/java/one/nem/lacerta/utils/repository/SharedPrefUtils.java b/utils/src/main/java/one/nem/lacerta/utils/repository/SharedPrefUtils.java index 68d21ae7..0be1859b 100644 --- a/utils/src/main/java/one/nem/lacerta/utils/repository/SharedPrefUtils.java +++ b/utils/src/main/java/one/nem/lacerta/utils/repository/SharedPrefUtils.java @@ -10,4 +10,8 @@ public interface SharedPrefUtils { // TODO-rca: 名称をenumで管理する? SharedPreferences.Editor getEditor(String name); + SharedPreferences getSharedPreferences(String name); + + SharedPreferences getSharedPreferences(); + } From 19ff8245914947c8fe2dc3103d15e82033c738d0 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 21 Jan 2024 19:09:37 +0900 Subject: [PATCH 06/17] =?UTF-8?q?Enum=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/pref/FeatureSwitchOverride.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 model/src/main/java/one/nem/lacerta/model/pref/FeatureSwitchOverride.java diff --git a/model/src/main/java/one/nem/lacerta/model/pref/FeatureSwitchOverride.java b/model/src/main/java/one/nem/lacerta/model/pref/FeatureSwitchOverride.java new file mode 100644 index 00000000..9a9a2497 --- /dev/null +++ b/model/src/main/java/one/nem/lacerta/model/pref/FeatureSwitchOverride.java @@ -0,0 +1,30 @@ +package one.nem.lacerta.model.pref; + +public enum FeatureSwitchOverride { + + ENABLE_DEBUG_MENU("enableDebugMenu"), + ENABLE_SEARCH("enableSearch"), + SHOW_DISPLAY_MENU("showDisplayMenu"), + SHOW_DATA_MENU("showDataMenu"), + SHOW_SCAN_MENU("showScanMenu"); + + private final String key; + + FeatureSwitchOverride(String key) { + this.key = key; + } + + public String getKey() { + return key; + } + + public static FeatureSwitchOverride fromKey(String key) { + for (FeatureSwitchOverride value : values()) { + if (value.getKey().equals(key)) { + return value; + } + } + return null; + } + +} From d40f61928c3c2644f9e4f0c94c6c75d9283119f1 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 21 Jan 2024 19:10:03 +0900 Subject: [PATCH 07/17] =?UTF-8?q?=E4=BE=9D=E5=AD=98=E9=96=A2=E4=BF=82?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index 7368eab2..ae313899 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -79,5 +79,7 @@ dependencies { implementation project(':data') implementation project(':shared:ui') + implementation project(':model') + implementation project(':utils') } \ No newline at end of file From 2dc3407217bf25659330794873abe9e9e12a79c9 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 21 Jan 2024 19:11:25 +0900 Subject: [PATCH 08/17] =?UTF-8?q?FeatureSwitch=E3=81=AEOverride=E3=81=8C?= =?UTF-8?q?=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/utils/impl/SharedPrefUtilsImpl.java | 11 +++++++++++ .../nem/lacerta/utils/repository/SharedPrefUtils.java | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/utils/src/main/java/one/nem/lacerta/utils/impl/SharedPrefUtilsImpl.java b/utils/src/main/java/one/nem/lacerta/utils/impl/SharedPrefUtilsImpl.java index 14f493a5..b991839e 100644 --- a/utils/src/main/java/one/nem/lacerta/utils/impl/SharedPrefUtilsImpl.java +++ b/utils/src/main/java/one/nem/lacerta/utils/impl/SharedPrefUtilsImpl.java @@ -5,6 +5,7 @@ import android.content.Context; import android.content.SharedPreferences; import dagger.hilt.android.qualifiers.ApplicationContext; +import one.nem.lacerta.model.pref.FeatureSwitchOverride; import one.nem.lacerta.utils.repository.SharedPrefUtils; public class SharedPrefUtilsImpl implements SharedPrefUtils{ @@ -36,4 +37,14 @@ public class SharedPrefUtilsImpl implements SharedPrefUtils{ public SharedPreferences getSharedPreferences() { return applicationContext.getSharedPreferences("common", Context.MODE_PRIVATE); // TODO-rca: 決め打ちやめる? } + + @Override + public boolean getFeatureSwitchOverride(FeatureSwitchOverride featureSwitchOverride) { + return getSharedPreferences().getBoolean(featureSwitchOverride.getKey(), false); + } + + @Override + public void setFeatureSwitchOverride(FeatureSwitchOverride featureSwitchOverride, boolean value) { + getEditor().putBoolean(featureSwitchOverride.getKey(), value).apply(); + } } diff --git a/utils/src/main/java/one/nem/lacerta/utils/repository/SharedPrefUtils.java b/utils/src/main/java/one/nem/lacerta/utils/repository/SharedPrefUtils.java index 0be1859b..36a0c49c 100644 --- a/utils/src/main/java/one/nem/lacerta/utils/repository/SharedPrefUtils.java +++ b/utils/src/main/java/one/nem/lacerta/utils/repository/SharedPrefUtils.java @@ -2,6 +2,8 @@ package one.nem.lacerta.utils.repository; import android.content.SharedPreferences; +import one.nem.lacerta.model.pref.FeatureSwitchOverride; + public interface SharedPrefUtils { // Shared preferences editorの取得 @@ -14,4 +16,7 @@ public interface SharedPrefUtils { SharedPreferences getSharedPreferences(); + boolean getFeatureSwitchOverride(FeatureSwitchOverride featureSwitchOverride); + + void setFeatureSwitchOverride(FeatureSwitchOverride featureSwitchOverride, boolean value); } From d9d22198d51389e71b302e8bde9857bbf0013200 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 21 Jan 2024 19:18:43 +0900 Subject: [PATCH 09/17] =?UTF-8?q?FeatureSwitch=E5=AE=9F=E8=A3=85WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/MainActivity.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/app/src/main/java/one/nem/lacerta/MainActivity.java b/app/src/main/java/one/nem/lacerta/MainActivity.java index 6dec2e80..397921c7 100644 --- a/app/src/main/java/one/nem/lacerta/MainActivity.java +++ b/app/src/main/java/one/nem/lacerta/MainActivity.java @@ -10,19 +10,27 @@ import androidx.navigation.ui.NavigationUI; import android.graphics.Color; import android.os.Bundle; import android.util.Log; +import android.view.Menu; import android.widget.Toast; +import one.nem.lacerta.utils.FeatureSwitch; + import com.google.android.material.bottomnavigation.BottomNavigationView; import dagger.hilt.android.AndroidEntryPoint; +import one.nem.lacerta.utils.repository.SharedPrefUtils; + import javax.inject.Inject; @AndroidEntryPoint public class MainActivity extends AppCompatActivity { + @Inject + SharedPrefUtils sharedPrefUtils; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -50,4 +58,28 @@ public class MainActivity extends AppCompatActivity { // Set status bar color getWindow().setStatusBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSurface)); } + + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + if (!FeatureSwitch.Meta.canOverrideSwitch) { + Log.d("FeatureSwitch", "Switch override is disabled"); + if (!FeatureSwitch.FeatureMaster.enableDebugMenu) { + menu.removeItem(one.nem.lacerta.feature.debug.R.id.feature_debug_navigation); + + } + if (!FeatureSwitch.FeatureMaster.enableSearch) { + menu.removeItem(one.nem.lacerta.feature.search.R.id.feature_search_navigation); + } + } else { + Log.d("FeatureSwitch", "Switch override is enabled"); + if (!FeatureSwitch.FeatureMaster.enableDebugMenu && !sharedPrefUtils.getFeatureSwitchOverride(one.nem.lacerta.model.pref.FeatureSwitchOverride.ENABLE_DEBUG_MENU)) { + menu.removeItem(one.nem.lacerta.feature.debug.R.id.feature_debug_navigation); + } + if (!FeatureSwitch.FeatureMaster.enableSearch && !sharedPrefUtils.getFeatureSwitchOverride(one.nem.lacerta.model.pref.FeatureSwitchOverride.ENABLE_SEARCH)) { + menu.removeItem(one.nem.lacerta.feature.search.R.id.feature_search_navigation); + } + } + + return super.onPrepareOptionsMenu(menu); + } } From 676a0e277231342d8708679ff8c5b53237fb51c9 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 21 Jan 2024 19:45:02 +0900 Subject: [PATCH 10/17] WIP --- .idea/misc.xml | 1 - .../java/one/nem/lacerta/MainActivity.java | 31 ++++--------------- app/src/main/res/layout/activity_main.xml | 5 ++- app/src/main/res/menu/bottom_nav_menu.xml | 2 +- app/src/main/res/navigation/main_nav.xml | 2 +- .../one/nem/lacerta/utils/FeatureSwitch.java | 5 +++ .../utils/impl/SharedPrefUtilsImpl.java | 3 ++ 7 files changed, 18 insertions(+), 31 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 0ad17cbd..8978d23d 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/app/src/main/java/one/nem/lacerta/MainActivity.java b/app/src/main/java/one/nem/lacerta/MainActivity.java index 397921c7..1d42d4b1 100644 --- a/app/src/main/java/one/nem/lacerta/MainActivity.java +++ b/app/src/main/java/one/nem/lacerta/MainActivity.java @@ -11,6 +11,7 @@ import android.graphics.Color; import android.os.Bundle; import android.util.Log; import android.view.Menu; +import android.view.MenuItem; import android.widget.Toast; import one.nem.lacerta.utils.FeatureSwitch; @@ -36,13 +37,14 @@ public class MainActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); + BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav); + // Init navigation try { FragmentManager supportFragmentManager = getSupportFragmentManager(); NavHostFragment navHostFragment = (NavHostFragment) supportFragmentManager.findFragmentById(R.id.nav_host_fragment); assert navHostFragment != null; NavController navController = navHostFragment.getNavController(); - BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav); NavigationUI.setupWithNavController(bottomNavigationView, navController); } catch (Exception e) { @@ -52,34 +54,13 @@ public class MainActivity extends AppCompatActivity { finish(); // Exit app } + // bottomNavigation FeatureSwitch + Menu menu = bottomNavigationView.getMenu(); + // Set navigation bar color getWindow().setNavigationBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer)); // Set status bar color getWindow().setStatusBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSurface)); } - - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - if (!FeatureSwitch.Meta.canOverrideSwitch) { - Log.d("FeatureSwitch", "Switch override is disabled"); - if (!FeatureSwitch.FeatureMaster.enableDebugMenu) { - menu.removeItem(one.nem.lacerta.feature.debug.R.id.feature_debug_navigation); - - } - if (!FeatureSwitch.FeatureMaster.enableSearch) { - menu.removeItem(one.nem.lacerta.feature.search.R.id.feature_search_navigation); - } - } else { - Log.d("FeatureSwitch", "Switch override is enabled"); - if (!FeatureSwitch.FeatureMaster.enableDebugMenu && !sharedPrefUtils.getFeatureSwitchOverride(one.nem.lacerta.model.pref.FeatureSwitchOverride.ENABLE_DEBUG_MENU)) { - menu.removeItem(one.nem.lacerta.feature.debug.R.id.feature_debug_navigation); - } - if (!FeatureSwitch.FeatureMaster.enableSearch && !sharedPrefUtils.getFeatureSwitchOverride(one.nem.lacerta.model.pref.FeatureSwitchOverride.ENABLE_SEARCH)) { - menu.removeItem(one.nem.lacerta.feature.search.R.id.feature_search_navigation); - } - } - - return super.onPrepareOptionsMenu(menu); - } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 3305b5e2..cc3f088c 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -18,7 +18,7 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:navGraph="@navigation/main_nav" - tools:layout="@layout/fragment_debug_menu_container" /> + tools:layout="@layout/fragment_home_top" /> + app:layout_constraintStart_toStartOf="parent" /> \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml index 87e98113..12a0311d 100644 --- a/app/src/main/res/menu/bottom_nav_menu.xml +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -19,7 +19,7 @@ + android:title="@string/debug_menu_title" /> + app:startDestination="@id/feature_home_navigation"> diff --git a/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java b/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java index 92b09262..9e53abfb 100644 --- a/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java +++ b/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java @@ -2,8 +2,13 @@ package one.nem.lacerta.utils; public class FeatureSwitch { + public static class Meta { + public static boolean canOverrideSwitch = true; + } + public static class FeatureMaster { public static boolean enableSearch = true; + public static boolean enableDebugMenu = true; } public static class Setting { diff --git a/utils/src/main/java/one/nem/lacerta/utils/impl/SharedPrefUtilsImpl.java b/utils/src/main/java/one/nem/lacerta/utils/impl/SharedPrefUtilsImpl.java index b991839e..82301a64 100644 --- a/utils/src/main/java/one/nem/lacerta/utils/impl/SharedPrefUtilsImpl.java +++ b/utils/src/main/java/one/nem/lacerta/utils/impl/SharedPrefUtilsImpl.java @@ -4,6 +4,8 @@ package one.nem.lacerta.utils.impl; import android.content.Context; import android.content.SharedPreferences; +import javax.inject.Inject; + import dagger.hilt.android.qualifiers.ApplicationContext; import one.nem.lacerta.model.pref.FeatureSwitchOverride; import one.nem.lacerta.utils.repository.SharedPrefUtils; @@ -12,6 +14,7 @@ public class SharedPrefUtilsImpl implements SharedPrefUtils{ private final Context applicationContext; + @Inject public SharedPrefUtilsImpl(@ApplicationContext Context applicationContext) { this.applicationContext = applicationContext; } From ec633a723890ce82659d60b0631f9856beaaae49 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 21 Jan 2024 20:16:38 +0900 Subject: [PATCH 11/17] =?UTF-8?q?FeatureSwitch=E5=AE=9F=E8=A3=85=E4=BB=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/MainActivity.java | 43 +++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/one/nem/lacerta/MainActivity.java b/app/src/main/java/one/nem/lacerta/MainActivity.java index 1d42d4b1..2ca5f720 100644 --- a/app/src/main/java/one/nem/lacerta/MainActivity.java +++ b/app/src/main/java/one/nem/lacerta/MainActivity.java @@ -14,12 +14,13 @@ import android.view.Menu; import android.view.MenuItem; import android.widget.Toast; +import one.nem.lacerta.model.pref.FeatureSwitchOverride; import one.nem.lacerta.utils.FeatureSwitch; import com.google.android.material.bottomnavigation.BottomNavigationView; - +import java.io.NotActiveException; import dagger.hilt.android.AndroidEntryPoint; import one.nem.lacerta.utils.repository.SharedPrefUtils; @@ -54,8 +55,44 @@ public class MainActivity extends AppCompatActivity { finish(); // Exit app } - // bottomNavigation FeatureSwitch - Menu menu = bottomNavigationView.getMenu(); + // Apply feature switch + if (FeatureSwitch.Meta.canOverrideSwitch) { + Log.d("FeatureSwitch", "Feature switch override is enabled"); + if (!FeatureSwitch.FeatureMaster.enableDebugMenu) { + if (sharedPrefUtils.getFeatureSwitchOverride(FeatureSwitchOverride.ENABLE_DEBUG_MENU)) { + Log.d("FeatureSwitch", "Debug menu is enabled"); + } else { + bottomNavigationView.getMenu().removeItem(one.nem.lacerta.feature.debug.R.id.feature_debug_navigation); + Log.d("FeatureSwitch", "Debug menu is disabled"); + } + } else { + Log.d("FeatureSwitch", "Debug menu is enabled"); + } + if (!FeatureSwitch.FeatureMaster.enableSearch) { + if (sharedPrefUtils.getFeatureSwitchOverride(FeatureSwitchOverride.ENABLE_SEARCH)) { + Log.d("FeatureSwitch", "Search is enabled"); + } else { + bottomNavigationView.getMenu().removeItem(one.nem.lacerta.feature.search.R.id.feature_search_navigation); + Log.d("FeatureSwitch", "Search is disabled"); + } + } else { + Log.d("FeatureSwitch", "Search is enabled"); + } + } else { + Log.d("FeatureSwitch", "Feature switch override is disabled"); + if (FeatureSwitch.FeatureMaster.enableDebugMenu) { + Log.d("FeatureSwitch", "Debug menu is enabled"); + } else { + Log.d("FeatureSwitch", "Debug menu is disabled"); + bottomNavigationView.getMenu().removeItem(one.nem.lacerta.feature.debug.R.id.feature_debug_navigation); + } + if (FeatureSwitch.FeatureMaster.enableSearch) { + Log.d("FeatureSwitch", "Search is enabled"); + } else { + Log.d("FeatureSwitch", "Search is disabled"); + bottomNavigationView.getMenu().removeItem(one.nem.lacerta.feature.search.R.id.feature_search_navigation); + } + } // Set navigation bar color getWindow().setNavigationBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer)); From fd850651b3108d23c8e94dfaad74277d540c632a Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 21 Jan 2024 20:28:33 +0900 Subject: [PATCH 12/17] =?UTF-8?q?=E5=AE=9F=E8=A3=85=E3=82=92=E5=8D=98?= =?UTF-8?q?=E7=B4=94=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/MainActivity.java | 45 ++++--------------- 1 file changed, 8 insertions(+), 37 deletions(-) diff --git a/app/src/main/java/one/nem/lacerta/MainActivity.java b/app/src/main/java/one/nem/lacerta/MainActivity.java index 2ca5f720..349e87c1 100644 --- a/app/src/main/java/one/nem/lacerta/MainActivity.java +++ b/app/src/main/java/one/nem/lacerta/MainActivity.java @@ -56,43 +56,9 @@ public class MainActivity extends AppCompatActivity { } // Apply feature switch - if (FeatureSwitch.Meta.canOverrideSwitch) { - Log.d("FeatureSwitch", "Feature switch override is enabled"); - if (!FeatureSwitch.FeatureMaster.enableDebugMenu) { - if (sharedPrefUtils.getFeatureSwitchOverride(FeatureSwitchOverride.ENABLE_DEBUG_MENU)) { - Log.d("FeatureSwitch", "Debug menu is enabled"); - } else { - bottomNavigationView.getMenu().removeItem(one.nem.lacerta.feature.debug.R.id.feature_debug_navigation); - Log.d("FeatureSwitch", "Debug menu is disabled"); - } - } else { - Log.d("FeatureSwitch", "Debug menu is enabled"); - } - if (!FeatureSwitch.FeatureMaster.enableSearch) { - if (sharedPrefUtils.getFeatureSwitchOverride(FeatureSwitchOverride.ENABLE_SEARCH)) { - Log.d("FeatureSwitch", "Search is enabled"); - } else { - bottomNavigationView.getMenu().removeItem(one.nem.lacerta.feature.search.R.id.feature_search_navigation); - Log.d("FeatureSwitch", "Search is disabled"); - } - } else { - Log.d("FeatureSwitch", "Search is enabled"); - } - } else { - Log.d("FeatureSwitch", "Feature switch override is disabled"); - if (FeatureSwitch.FeatureMaster.enableDebugMenu) { - Log.d("FeatureSwitch", "Debug menu is enabled"); - } else { - Log.d("FeatureSwitch", "Debug menu is disabled"); - bottomNavigationView.getMenu().removeItem(one.nem.lacerta.feature.debug.R.id.feature_debug_navigation); - } - if (FeatureSwitch.FeatureMaster.enableSearch) { - Log.d("FeatureSwitch", "Search is enabled"); - } else { - Log.d("FeatureSwitch", "Search is disabled"); - bottomNavigationView.getMenu().removeItem(one.nem.lacerta.feature.search.R.id.feature_search_navigation); - } - } + applyFeatureSwitch(bottomNavigationView, FeatureSwitchOverride.ENABLE_SEARCH, FeatureSwitch.FeatureMaster.enableSearch, one.nem.lacerta.feature.search.R.id.feature_search_navigation); + applyFeatureSwitch(bottomNavigationView, FeatureSwitchOverride.ENABLE_DEBUG_MENU, FeatureSwitch.FeatureMaster.enableDebugMenu, one.nem.lacerta.feature.debug.R.id.feature_debug_navigation); + // Set navigation bar color getWindow().setNavigationBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer)); @@ -100,4 +66,9 @@ public class MainActivity extends AppCompatActivity { // Set status bar color getWindow().setStatusBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSurface)); } + + private void applyFeatureSwitch(BottomNavigationView bottomNavigationView, FeatureSwitchOverride featureSwitchOverride, boolean defaultValue, int menuId) { + boolean isEnabled = FeatureSwitch.Meta.canOverrideSwitch ? sharedPrefUtils.getFeatureSwitchOverride(featureSwitchOverride) : defaultValue; + if (!isEnabled) bottomNavigationView.getMenu().removeItem(menuId); + } } From 40a0d08a1f59de9fa19d60f5aa7c4f85538ec860 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 21 Jan 2024 20:28:56 +0900 Subject: [PATCH 13/17] =?UTF-8?q?=E3=83=87=E3=83=90=E3=83=83=E3=82=B0?= =?UTF-8?q?=E3=83=A1=E3=83=8B=E3=83=A5=E3=83=BC=E3=82=92=E7=84=A1=E5=8A=B9?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java b/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java index 9e53abfb..1c198478 100644 --- a/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java +++ b/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java @@ -8,7 +8,7 @@ public class FeatureSwitch { public static class FeatureMaster { public static boolean enableSearch = true; - public static boolean enableDebugMenu = true; + public static boolean enableDebugMenu = false; } public static class Setting { From 4cfc87a40bc3d43417401c56d42834bfdfa1236d Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 21 Jan 2024 20:32:29 +0900 Subject: [PATCH 14/17] =?UTF-8?q?=E5=88=9D=E5=9B=9E=E8=B5=B7=E5=8B=95?= =?UTF-8?q?=E3=83=95=E3=83=A9=E3=82=B0=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/utils/impl/SharedPrefUtilsImpl.java | 10 ++++++++++ .../nem/lacerta/utils/repository/SharedPrefUtils.java | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/utils/src/main/java/one/nem/lacerta/utils/impl/SharedPrefUtilsImpl.java b/utils/src/main/java/one/nem/lacerta/utils/impl/SharedPrefUtilsImpl.java index 82301a64..07f3f012 100644 --- a/utils/src/main/java/one/nem/lacerta/utils/impl/SharedPrefUtilsImpl.java +++ b/utils/src/main/java/one/nem/lacerta/utils/impl/SharedPrefUtilsImpl.java @@ -50,4 +50,14 @@ public class SharedPrefUtilsImpl implements SharedPrefUtils{ public void setFeatureSwitchOverride(FeatureSwitchOverride featureSwitchOverride, boolean value) { getEditor().putBoolean(featureSwitchOverride.getKey(), value).apply(); } + + @Override + public boolean getIsFirstLaunch() { + return getSharedPreferences().getBoolean("isFirstLaunch", true); + } + + @Override + public void setIsFirstLaunch(boolean value) { + getEditor().putBoolean("isFirstLaunch", value).apply(); + } } diff --git a/utils/src/main/java/one/nem/lacerta/utils/repository/SharedPrefUtils.java b/utils/src/main/java/one/nem/lacerta/utils/repository/SharedPrefUtils.java index 36a0c49c..ac807157 100644 --- a/utils/src/main/java/one/nem/lacerta/utils/repository/SharedPrefUtils.java +++ b/utils/src/main/java/one/nem/lacerta/utils/repository/SharedPrefUtils.java @@ -19,4 +19,8 @@ public interface SharedPrefUtils { boolean getFeatureSwitchOverride(FeatureSwitchOverride featureSwitchOverride); void setFeatureSwitchOverride(FeatureSwitchOverride featureSwitchOverride, boolean value); + + boolean getIsFirstLaunch(); + + void setIsFirstLaunch(boolean value); } From ea0b1a76651b862acb119bd7d4a4f2c3baaa5d8c Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 21 Jan 2024 20:34:47 +0900 Subject: [PATCH 15/17] =?UTF-8?q?=E5=88=9D=E5=9B=9E=E8=B5=B7=E5=8B=95?= =?UTF-8?q?=E3=81=AE=E5=A0=B4=E5=90=88=E3=81=AB=E5=88=9D=E6=9C=9F=E5=8C=96?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=81=A8=E3=81=97=E3=81=A6=E3=83=87=E3=83=95?= =?UTF-8?q?=E3=82=A9=E3=83=AB=E3=83=88=E5=80=A4=E3=82=92=E6=9B=B8=E3=81=8D?= =?UTF-8?q?=E8=BE=BC=E3=82=80=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/one/nem/lacerta/MainActivity.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/src/main/java/one/nem/lacerta/MainActivity.java b/app/src/main/java/one/nem/lacerta/MainActivity.java index 349e87c1..9511079a 100644 --- a/app/src/main/java/one/nem/lacerta/MainActivity.java +++ b/app/src/main/java/one/nem/lacerta/MainActivity.java @@ -40,6 +40,10 @@ public class MainActivity extends AppCompatActivity { BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav); + if (sharedPrefUtils.getIsFirstLaunch()) { + initializeApp(); + } + // Init navigation try { FragmentManager supportFragmentManager = getSupportFragmentManager(); @@ -67,6 +71,15 @@ public class MainActivity extends AppCompatActivity { getWindow().setStatusBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSurface)); } + private void initializeApp() { + // Set feature switch override to default value + sharedPrefUtils.setFeatureSwitchOverride(FeatureSwitchOverride.ENABLE_SEARCH, FeatureSwitch.FeatureMaster.enableSearch); + sharedPrefUtils.setFeatureSwitchOverride(FeatureSwitchOverride.ENABLE_DEBUG_MENU, FeatureSwitch.FeatureMaster.enableDebugMenu); + + // Set isFirstLaunch to false + sharedPrefUtils.setIsFirstLaunch(false); + } + private void applyFeatureSwitch(BottomNavigationView bottomNavigationView, FeatureSwitchOverride featureSwitchOverride, boolean defaultValue, int menuId) { boolean isEnabled = FeatureSwitch.Meta.canOverrideSwitch ? sharedPrefUtils.getFeatureSwitchOverride(featureSwitchOverride) : defaultValue; if (!isEnabled) bottomNavigationView.getMenu().removeItem(menuId); From a62d748c72e3af881edda87c8d9071f31da71405 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 21 Jan 2024 20:35:20 +0900 Subject: [PATCH 16/17] =?UTF-8?q?=E3=83=AD=E3=82=B0=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/one/nem/lacerta/MainActivity.java | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/one/nem/lacerta/MainActivity.java b/app/src/main/java/one/nem/lacerta/MainActivity.java index 9511079a..f57efce9 100644 --- a/app/src/main/java/one/nem/lacerta/MainActivity.java +++ b/app/src/main/java/one/nem/lacerta/MainActivity.java @@ -72,6 +72,7 @@ public class MainActivity extends AppCompatActivity { } private void initializeApp() { + Log.d("Init", "Initializing app"); // Set feature switch override to default value sharedPrefUtils.setFeatureSwitchOverride(FeatureSwitchOverride.ENABLE_SEARCH, FeatureSwitch.FeatureMaster.enableSearch); sharedPrefUtils.setFeatureSwitchOverride(FeatureSwitchOverride.ENABLE_DEBUG_MENU, FeatureSwitch.FeatureMaster.enableDebugMenu); From b4135f9ec00846f23132c7466b1c7ca50a461f4e Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 21 Jan 2024 20:37:04 +0900 Subject: [PATCH 17/17] =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF?= =?UTF-8?q?=E3=82=BF=E3=83=AA=E3=83=B3=E3=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/one/nem/lacerta/MainActivity.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/one/nem/lacerta/MainActivity.java b/app/src/main/java/one/nem/lacerta/MainActivity.java index f57efce9..84d15b35 100644 --- a/app/src/main/java/one/nem/lacerta/MainActivity.java +++ b/app/src/main/java/one/nem/lacerta/MainActivity.java @@ -40,9 +40,8 @@ public class MainActivity extends AppCompatActivity { BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav); - if (sharedPrefUtils.getIsFirstLaunch()) { - initializeApp(); - } + // Initialize app + if (sharedPrefUtils.getIsFirstLaunch()) initializeApp(); // Init navigation try {