From f53abe2b234624e9383239119b65f1bf6ee29394 Mon Sep 17 00:00:00 2001 From: jens Date: Thu, 8 Jul 2021 17:57:33 +0200 Subject: [PATCH] TabLayout --- .../automation2/ActivityMainTabLayout.java | 8 +++++- .../java/com/jens/automation2/Settings.java | 9 ++++++- app/src/main/res/layout/activity_settings.xml | 7 +++++ ...xml => main_tab_layout_tabs_at_bottom.xml} | 15 +++++++---- .../layout/main_tab_layout_tabs_at_top.xml | 27 +++++++++++++++++++ app/src/main/res/values/arrays.xml | 12 +++++++++ app/src/main/res/values/strings.xml | 4 +++ 7 files changed, 75 insertions(+), 7 deletions(-) rename app/src/main/res/layout/{main_tab_layout.xml => main_tab_layout_tabs_at_bottom.xml} (98%) create mode 100644 app/src/main/res/layout/main_tab_layout_tabs_at_top.xml diff --git a/app/src/main/java/com/jens/automation2/ActivityMainTabLayout.java b/app/src/main/java/com/jens/automation2/ActivityMainTabLayout.java index 975263eb..e8f815da 100644 --- a/app/src/main/java/com/jens/automation2/ActivityMainTabLayout.java +++ b/app/src/main/java/com/jens/automation2/ActivityMainTabLayout.java @@ -17,7 +17,13 @@ public class ActivityMainTabLayout extends TabActivity protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.main_tab_layout); + + Settings.readFromPersistentStorage(ActivityMainTabLayout.this); + + if(Settings.tabsPlacement == 1) + setContentView(R.layout.main_tab_layout_tabs_at_bottom); + else + setContentView(R.layout.main_tab_layout_tabs_at_top); TabHost tabHost = getTabHost(); diff --git a/app/src/main/java/com/jens/automation2/Settings.java b/app/src/main/java/com/jens/automation2/Settings.java index eb2fbbbb..32194328 100644 --- a/app/src/main/java/com/jens/automation2/Settings.java +++ b/app/src/main/java/com/jens/automation2/Settings.java @@ -60,6 +60,7 @@ public class Settings implements SharedPreferences public static int activityDetectionRequiredProbability; public static boolean privacyLocationing; public static int startScreen; + public static int tabsPlacement; public static boolean executeRulesAndProfilesWithSingleClick; public static boolean displayNewsOnMainScreen; public static boolean automaticUpdateCheck; @@ -116,6 +117,7 @@ public class Settings implements SharedPreferences protected static final int default_activityDetectionRequiredProbability = 75; protected static final boolean default_privacyLocationing = false; protected static final int default_startScreen = 0; + protected static final int default_tabsPlacement = 0; protected static final boolean default_executeRulesAndProfilesWithSingleClick = false; protected static final boolean default_displayNewsOnMainScreen = false; protected static final boolean default_automaticUpdateCheck = false; @@ -253,6 +255,7 @@ public class Settings implements SharedPreferences privacyLocationing = prefs.getBoolean("privacyLocationing", default_privacyLocationing); startScreen = Integer.parseInt(prefs.getString("startScreen", String.valueOf(default_startScreen))); + tabsPlacement = Integer.parseInt(prefs.getString("tabsPlacement", String.valueOf(default_tabsPlacement))); executeRulesAndProfilesWithSingleClick = prefs.getBoolean("executeRulesAndProfilesWithSingleClick", default_executeRulesAndProfilesWithSingleClick); automaticUpdateCheck = prefs.getBoolean("automaticUpdateCheck", default_automaticUpdateCheck); @@ -440,6 +443,9 @@ public class Settings implements SharedPreferences if(!prefs.contains("startScreen") | force) editor.putString("startScreen", String.valueOf(default_startScreen)); + if(!prefs.contains("tabsPlacement") | force) + editor.putString("tabsPlacement", String.valueOf(default_tabsPlacement)); + if(!prefs.contains("executeRulesAndProfilesWithSingleClick") | force) editor.putBoolean("executeRulesAndProfilesWithSingleClick", default_executeRulesAndProfilesWithSingleClick); @@ -524,6 +530,7 @@ public class Settings implements SharedPreferences editor.putString("activityDetectionRequiredProbability", String.valueOf(activityDetectionRequiredProbability)); editor.putBoolean("privacyLocationing", privacyLocationing); editor.putString("startScreen", String.valueOf(startScreen)); + editor.putString("tabsPlacement", String.valueOf(tabsPlacement)); editor.putBoolean("executeRulesAndProfilesWithSingleClick", executeRulesAndProfilesWithSingleClick); editor.putBoolean("automaticUpdateCheck", automaticUpdateCheck); editor.putBoolean("displayNewsOnMainScreen", displayNewsOnMainScreen); @@ -575,4 +582,4 @@ public class Settings implements SharedPreferences return null; } -} +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index a651c527..20f04cd0 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -52,6 +52,13 @@ android:entries="@array/startScreenOptions" android:entryValues="@array/startScreenOptionsValues" /> + + diff --git a/app/src/main/res/layout/main_tab_layout.xml b/app/src/main/res/layout/main_tab_layout_tabs_at_bottom.xml similarity index 98% rename from app/src/main/res/layout/main_tab_layout.xml rename to app/src/main/res/layout/main_tab_layout_tabs_at_bottom.xml index 6de81e82..e2025f2a 100644 --- a/app/src/main/res/layout/main_tab_layout.xml +++ b/app/src/main/res/layout/main_tab_layout_tabs_at_bottom.xml @@ -3,20 +3,25 @@ android:id="@android:id/tabhost" android:layout_width="match_parent" android:layout_height="match_parent"> + + + + - + + \ No newline at end of file diff --git a/app/src/main/res/layout/main_tab_layout_tabs_at_top.xml b/app/src/main/res/layout/main_tab_layout_tabs_at_top.xml new file mode 100644 index 00000000..779fbc37 --- /dev/null +++ b/app/src/main/res/layout/main_tab_layout_tabs_at_top.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index a6a34cd2..2fdce81c 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -21,4 +21,16 @@ 2 3 + + + @string/top + @string/bottom + + + 0 + 1 + 2 + 3 + + \ 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 c0a33b5d..1c6a1a4b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -686,4 +686,8 @@ Enter a vibration duration, followed by a comma, then a pause duration. You can concatenate as many vibrations as you like. Separate them by commas again.\nE.g. the pattern 100,500,500,1000,100 will vibrate 100, wait 500, vibrate 500, wait 1000, vibrate 100.\nIf you think a vibration is dropped try increasing the pause before them. Please enter a valid vibration pattern. Would you like to receive (only important) news about this app on the main screen? Those are downloaded from the developer\'s website. There will be no intrusive notification, just a text on the main screen when you open the app. + Top + Bottom + Position of tabs + Choose where the tabs bar should be placed. \ No newline at end of file