From f76b09e5d5664b56d748968cdbcca1fd6c71f9b3 Mon Sep 17 00:00:00 2001 From: Lars Date: Mon, 30 Dec 2019 19:17:09 +0100 Subject: [PATCH 01/39] Twelveish-10 Wrong capitalization in the German prefixes Fixed wrong capitalization by calpilatizing the words in strings.xml and adding toLowerCase on capitalise2's output. --- .../layoutxml/twelveish/WordClockTask.java | 2 +- app/src/main/res/values/strings.xml | 48 +++++++++---------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/com/layoutxml/twelveish/WordClockTask.java b/app/src/main/java/com/layoutxml/twelveish/WordClockTask.java index 274da72..eacd581 100644 --- a/app/src/main/java/com/layoutxml/twelveish/WordClockTask.java +++ b/app/src/main/java/com/layoutxml/twelveish/WordClockTask.java @@ -478,7 +478,7 @@ private String capitalise2(int hours, int minutes, int index) { + middle + ((minutes > 0) ? (SuffixNewLine[index] ? " " : "") : "") + ((showSuffixes) ? ((minutes > 0) ? Suffixes[index] : "") : ""); - return arrangeWords(text); + return arrangeWords(text).toLowerCase(); } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 651eeb5..e516c1a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -305,30 +305,30 @@ - zwölf - eins - zwei - drei - vier - fünf - sechs - sieben - acht - neun - zehn - elf - zwölf - dreizehn - vierzehn - fünfzehn - sechzehn - siebzehn - achtzehn - neunzehn - zwanzig - einundzwanzig - zweiundzwanzig - dreiundzwanzig + Zwölf + Eins + Zwei + Drei + Vier + Fünf + Sechs + Sieben + Acht + Neun + Zehn + Elf + Zwölf + Dreizehn + Vierzehn + Fünfzehn + Sechzehn + Siebzehn + Achtzehn + Neunzehn + Zwanzig + Einundzwanzig + Zweiundzwanzig + Dreiundzwanzig kurz nach From 768a2426ee28324445bfcc363d598db9a2f5ab91 Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Sun, 3 Jan 2021 22:05:38 +0100 Subject: [PATCH 02/39] Capitalized Viertel in the german translation and de-capitalized hours. --- app/src/main/res/values/strings.xml | 60 ++++++++++++++--------------- build.gradle | 2 +- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e516c1a..6815408 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -305,42 +305,42 @@ - Zwölf - Eins - Zwei - Drei - Vier - Fünf - Sechs - Sieben - Acht - Neun - Zehn - Elf - Zwölf - Dreizehn - Vierzehn - Fünfzehn - Sechzehn - Siebzehn - Achtzehn - Neunzehn - Zwanzig - Einundzwanzig - Zweiundzwanzig - Dreiundzwanzig + zwölf + eins + zwei + drei + vier + fünf + sechs + sieben + acht + neun + zehn + elf + zwölf + dreizehn + vierzehn + fünfzehn + sechzehn + siebzehn + achtzehn + neunzehn + zwanzig + einundzwanzig + zweiundzwanzig + dreiundzwanzig kurz nach - bald viertel\u00A0nach - fast viertel\u00A0nach - viertel\u00A0nach + bald Viertel\u00A0nach + fast Viertel\u00A0nach + Viertel\u00A0nach bald halb kurz vor halb kurz nach halb - bald viertel\u00A0vor - fast viertel\u00A0vor - viertel\u00A0vor + bald Viertel\u00A0vor + fast Viertel\u00A0vor + Viertel\u00A0vor bald fast diff --git a/build.gradle b/build.gradle index eca7d40..2426268 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.4.1' + classpath 'com.android.tools.build:gradle:4.1.1' // NOTE: Do not place your application dependencies here; they belong From d96de1c6eb0eed0829da0d60b754547bcc9cc623 Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Sun, 3 Jan 2021 22:14:59 +0100 Subject: [PATCH 03/39] Fixes #10 --- .gitignore | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/.gitignore b/.gitignore index f03203d..131d80e 100644 --- a/.gitignore +++ b/.gitignore @@ -66,3 +66,92 @@ fastlane/readme.md .idea/workspace.xml___jb_old___ .idea/misc.xml .idea/misc.xml + +# Built application files +*.apk +*.aar +*.ap_ +*.aab + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ +# Uncomment the following line in case you need and you don't have the release build type files in your app +# release/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +# Android Studio 3 in .gitignore file. +.idea/caches +.idea/modules.xml +# Comment next line if keeping position of elements in Navigation Editor is relevant for you +.idea/navEditor.xml + +# Keystore files +# Uncomment the following lines if you do not want to check your keystore files in. +#*.jks +#*.keystore + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild +.cxx/ + +# Google Services (e.g. APIs or Firebase) +# google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md + +# Version control +vcs.xml + +# lint +lint/intermediates/ +lint/generated/ +lint/outputs/ +lint/tmp/ +# lint/reports/ + +# Android Profiling +*.hprof From 6aca461f6995b7b7aaa8dcfe99d26fcfbb6f3fc3 Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Sun, 3 Jan 2021 22:35:42 +0100 Subject: [PATCH 04/39] Reverted gitignore to LayoutXML version --- .gitignore | 91 +----------------------------------------------------- 1 file changed, 1 insertion(+), 90 deletions(-) diff --git a/.gitignore b/.gitignore index 131d80e..67ec355 100644 --- a/.gitignore +++ b/.gitignore @@ -65,93 +65,4 @@ fastlane/test_output fastlane/readme.md .idea/workspace.xml___jb_old___ .idea/misc.xml -.idea/misc.xml - -# Built application files -*.apk -*.aar -*.ap_ -*.aab - -# Files for the ART/Dalvik VM -*.dex - -# Java class files -*.class - -# Generated files -bin/ -gen/ -out/ -# Uncomment the following line in case you need and you don't have the release build type files in your app -# release/ - -# Gradle files -.gradle/ -build/ - -# Local configuration file (sdk path, etc) -local.properties - -# Proguard folder generated by Eclipse -proguard/ - -# Log Files -*.log - -# Android Studio Navigation editor temp files -.navigation/ - -# Android Studio captures folder -captures/ - -# IntelliJ -*.iml -.idea/workspace.xml -.idea/tasks.xml -.idea/gradle.xml -.idea/assetWizardSettings.xml -.idea/dictionaries -.idea/libraries -# Android Studio 3 in .gitignore file. -.idea/caches -.idea/modules.xml -# Comment next line if keeping position of elements in Navigation Editor is relevant for you -.idea/navEditor.xml - -# Keystore files -# Uncomment the following lines if you do not want to check your keystore files in. -#*.jks -#*.keystore - -# External native build folder generated in Android Studio 2.2 and later -.externalNativeBuild -.cxx/ - -# Google Services (e.g. APIs or Firebase) -# google-services.json - -# Freeline -freeline.py -freeline/ -freeline_project_description.json - -# fastlane -fastlane/report.xml -fastlane/Preview.html -fastlane/screenshots -fastlane/test_output -fastlane/readme.md - -# Version control -vcs.xml - -# lint -lint/intermediates/ -lint/generated/ -lint/outputs/ -lint/tmp/ -# lint/reports/ - -# Android Profiling -*.hprof +.idea/misc.xml \ No newline at end of file From 7c3e750b66669528caefe9c7258475cd6e593c1a Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Sun, 3 Jan 2021 22:36:27 +0100 Subject: [PATCH 05/39] Reverted gitignore to LayoutXML version --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 67ec355..f03203d 100644 --- a/.gitignore +++ b/.gitignore @@ -65,4 +65,4 @@ fastlane/test_output fastlane/readme.md .idea/workspace.xml___jb_old___ .idea/misc.xml -.idea/misc.xml \ No newline at end of file +.idea/misc.xml From dfb4c8a7fc08a20a71f15ff35a99bc49bf4bb37a Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Mon, 4 Jan 2021 22:34:07 +0100 Subject: [PATCH 06/39] Fixes issue where some words weren't properly capitalized in Title Case. --- .../com/layoutxml/twelveish/WordClockTask.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/layoutxml/twelveish/WordClockTask.java b/app/src/main/java/com/layoutxml/twelveish/WordClockTask.java index eacd581..392348f 100644 --- a/app/src/main/java/com/layoutxml/twelveish/WordClockTask.java +++ b/app/src/main/java/com/layoutxml/twelveish/WordClockTask.java @@ -369,7 +369,19 @@ private String capitalise0(int hours, int minutes, int index) { String mainPrefix = ""; StringBuilder prefix; if ((minutes > 0) && (!Prefixes[index].equals("")) && (Prefixes[index] != null)) { - String[] prefixArray = Prefixes[index].split(" "); + + //We first need to replace unicode spaces with regular spaces + StringBuilder preString = new StringBuilder(); + String[] preArray = Prefixes[index].split("\\u00A0"); + + for (int i = 0; i < preArray.length; i++){ + preString.append(preArray[i]); + preString.append(" "); + } + + // Then we'll separate out the first letter of each word and capitalize it + + String[] prefixArray = preString.toString().split(" "); prefix = new StringBuilder(); for (String word : prefixArray) { if (prefix.length() != 0) From 27e1b856d76a375cb0fd64cb3ce605bcad9a5671 Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Tue, 5 Jan 2021 13:28:31 +0100 Subject: [PATCH 07/39] -Fixed: an issue with word alignment caused by the previous commit. -Fixed: capitalisation for suffixes with non-break spaces --- .../layoutxml/twelveish/WordClockTask.java | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/layoutxml/twelveish/WordClockTask.java b/app/src/main/java/com/layoutxml/twelveish/WordClockTask.java index 392348f..976594b 100644 --- a/app/src/main/java/com/layoutxml/twelveish/WordClockTask.java +++ b/app/src/main/java/com/layoutxml/twelveish/WordClockTask.java @@ -370,16 +370,19 @@ private String capitalise0(int hours, int minutes, int index) { StringBuilder prefix; if ((minutes > 0) && (!Prefixes[index].equals("")) && (Prefixes[index] != null)) { - //We first need to replace unicode spaces with regular spaces + //Split the prefix with non-break spaces and capitalise each word StringBuilder preString = new StringBuilder(); String[] preArray = Prefixes[index].split("\\u00A0"); - for (int i = 0; i < preArray.length; i++){ - preString.append(preArray[i]); - preString.append(" "); + for (String word : preArray){ + if(preString.length() != 0) + preString.append("\u00A0"); + + String capitalised = word.substring(0, 1).toUpperCase() + word.substring(1); + preString.append(capitalised); } - // Then we'll separate out the first letter of each word and capitalize it + // Do the same with spaces String[] prefixArray = preString.toString().split(" "); prefix = new StringBuilder(); @@ -415,8 +418,21 @@ private String capitalise0(int hours, int minutes, int index) { if (showSuffixes) { StringBuilder suffix; if ((minutes > 0) && (!Suffixes[index].equals("")) && (Suffixes[index] != null)) { + + //We first need to replace non-break spaces with regular spaces + StringBuilder suffString = new StringBuilder(); + String[] suffArray = Suffixes[index].split("\\u00A0"); + + for (String word : suffArray){ + if(suffString.length() != 0) + suffString.append("\u00A0"); + + String capitalised = word.substring(0, 1).toUpperCase() + word.substring(1); + suffString.append(capitalised); + } + if (SuffixNewLine[index]) { - String[] suffixArray = Suffixes[index].split(" "); + String[] suffixArray = suffString.toString().split(" "); suffix = new StringBuilder(); for (String word : suffixArray) { if (suffix.length() != 0) @@ -426,7 +442,7 @@ private String capitalise0(int hours, int minutes, int index) { } mainSuffix = suffix.toString(); } else { - mainSuffix = Suffixes[index].toLowerCase(); + mainSuffix = suffString.toString().toLowerCase(); } } } From 81d59388db6a849a7fed17796a0936019d3a733e Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Tue, 5 Jan 2021 22:58:38 +0100 Subject: [PATCH 08/39] Sorted issues with Dagger that stopped the companion app from functioning. --- .../java/com/layoutxml/twelveish/CustomizationScreen.java | 6 +++++- phone/src/main/java/com/layoutxml/twelveish/dagger/App.java | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/phone/src/main/java/com/layoutxml/twelveish/CustomizationScreen.java b/phone/src/main/java/com/layoutxml/twelveish/CustomizationScreen.java index f580e80..2ceaa48 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/CustomizationScreen.java +++ b/phone/src/main/java/com/layoutxml/twelveish/CustomizationScreen.java @@ -20,9 +20,13 @@ import com.layoutxml.twelveish.dagger.SettingsManagerComponent; import com.layoutxml.twelveish.fragments.PreviewFragment; +import javax.inject.Inject; + + public class CustomizationScreen extends AppCompatActivity { - private SettingsManagerComponent settingsManagerComponent; + @Inject + SettingsManagerComponent settingsManagerComponent; private Communicator communicator; private static final String TAG = "CustomizationScreen"; private boolean isInAmoledMode = false; diff --git a/phone/src/main/java/com/layoutxml/twelveish/dagger/App.java b/phone/src/main/java/com/layoutxml/twelveish/dagger/App.java index ffe4b09..dc30b27 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/dagger/App.java +++ b/phone/src/main/java/com/layoutxml/twelveish/dagger/App.java @@ -2,9 +2,12 @@ import android.app.Application; +import javax.inject.Inject; + public class App extends Application { - private CommunicatorComponent component; + @Inject + CommunicatorComponent component; @Override public void onCreate() { From 34c988abece2a73130d792ceb88a4b36b8d1d125 Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Tue, 12 Jan 2021 16:23:11 +0100 Subject: [PATCH 09/39] Updated ViewAdapters to use getBindingAdapterPosition() instead of deprecated getAdapterPosition() - This seems to have fixed a bug with onItemClickSwitch not being fired in MainTextSettingsFragment Updated capitalisation of a key string. --- .../twelveish/adapters/ImageRecyclerViewAdapter.java | 2 +- .../twelveish/adapters/SwitchRecyclerViewAdapter.java | 6 +++--- .../twelveish/adapters/TextviewRecyclerViewAdapter.java | 2 +- phone/src/main/res/values/strings.xml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/phone/src/main/java/com/layoutxml/twelveish/adapters/ImageRecyclerViewAdapter.java b/phone/src/main/java/com/layoutxml/twelveish/adapters/ImageRecyclerViewAdapter.java index 27e987e..45847ad 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/adapters/ImageRecyclerViewAdapter.java +++ b/phone/src/main/java/com/layoutxml/twelveish/adapters/ImageRecyclerViewAdapter.java @@ -64,7 +64,7 @@ public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickL @Override public void onClick(View view) { if (mClickListener != null) { - mClickListener.onItemClickImage(view, getAdapterPosition(), mData.get(getAdapterPosition()).second, name); + mClickListener.onItemClickImage(view, getBindingAdapterPosition(), mData.get(getBindingAdapterPosition()).second, name); } } } diff --git a/phone/src/main/java/com/layoutxml/twelveish/adapters/SwitchRecyclerViewAdapter.java b/phone/src/main/java/com/layoutxml/twelveish/adapters/SwitchRecyclerViewAdapter.java index 56319b8..af49a16 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/adapters/SwitchRecyclerViewAdapter.java +++ b/phone/src/main/java/com/layoutxml/twelveish/adapters/SwitchRecyclerViewAdapter.java @@ -65,14 +65,14 @@ public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickL @Override public void onClick(View view) { if (mClickListener != null) { - String key = mData.get(getAdapterPosition()).second; - if (key.equals("showDay") || key.equals("showDayAmbient") || key.equals("showSecondaryCalendarActive") || key.equals("showSecondaryCalendar") || key.equals("militarytextTime")) { + String key = mData.get(getBindingAdapterPosition()).second; + if (key.equals("showDay") || key.equals("showDayAmbient") || key.equals("showSecondaryCalendarActive") || key.equals("showSecondaryCalendar") || key.equals("militaryTextTime")) { settingsManager.significantTimeChange = true; } boolean newValue = !settingsManager.booleanHashmap.get(key); settingsManager.booleanHashmap.put(key,newValue); mySwtich.setChecked(newValue); - mClickListener.onItemClickSwitch(view, getAdapterPosition(), newValue, name); + mClickListener.onItemClickSwitch(view, getBindingAdapterPosition(), newValue, name); } } } diff --git a/phone/src/main/java/com/layoutxml/twelveish/adapters/TextviewRecyclerViewAdapter.java b/phone/src/main/java/com/layoutxml/twelveish/adapters/TextviewRecyclerViewAdapter.java index 1e2f61b..f29ded0 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/adapters/TextviewRecyclerViewAdapter.java +++ b/phone/src/main/java/com/layoutxml/twelveish/adapters/TextviewRecyclerViewAdapter.java @@ -59,7 +59,7 @@ public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickL @Override public void onClick(View view) { - if (mClickListener != null) mClickListener.onItemClick(view, getAdapterPosition(), name); + if (mClickListener != null) mClickListener.onItemClick(view, getBindingAdapterPosition(), name); } } diff --git a/phone/src/main/res/values/strings.xml b/phone/src/main/res/values/strings.xml index e34a1ff..dc9e3a5 100644 --- a/phone/src/main/res/values/strings.xml +++ b/phone/src/main/res/values/strings.xml @@ -12,7 +12,7 @@ secondaryColorActive secondaryColor militaryTime - militarytextTime + militaryTextTime dateOrder stringOption capitalisation From fceaf04d8081908831ad712051cb39694de65e2f Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Wed, 13 Jan 2021 13:23:39 +0100 Subject: [PATCH 10/39] Added activity to choose the watch face language Fixed a bug where invalidating the preview wouldn't update the prefixes and suffixes --- phone/src/main/AndroidManifest.xml | 10 +--- .../activities/LanguageSelectionActivity.java | 54 +++++++++++++++++ .../fragments/SharedSettingsFragment.java | 37 ++++++++++-- .../twelveish/objects/WatchPreviewView.java | 60 ++++++++++++------- phone/src/main/res/values/strings.xml | 43 +++++++++---- 5 files changed, 155 insertions(+), 49 deletions(-) create mode 100644 phone/src/main/java/com/layoutxml/twelveish/activities/LanguageSelectionActivity.java diff --git a/phone/src/main/AndroidManifest.xml b/phone/src/main/AndroidManifest.xml index 70f3335..ce5d528 100644 --- a/phone/src/main/AndroidManifest.xml +++ b/phone/src/main/AndroidManifest.xml @@ -1,14 +1,7 @@ - - - @@ -30,13 +23,14 @@ - + + \ No newline at end of file diff --git a/phone/src/main/java/com/layoutxml/twelveish/activities/LanguageSelectionActivity.java b/phone/src/main/java/com/layoutxml/twelveish/activities/LanguageSelectionActivity.java new file mode 100644 index 0000000..1449331 --- /dev/null +++ b/phone/src/main/java/com/layoutxml/twelveish/activities/LanguageSelectionActivity.java @@ -0,0 +1,54 @@ +package com.layoutxml.twelveish.activities; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.util.Pair; +import android.view.View; + +import com.layoutxml.twelveish.R; +import com.layoutxml.twelveish.adapters.TextviewRecyclerViewAdapter; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +public class LanguageSelectionActivity extends AppCompatActivity implements TextviewRecyclerViewAdapter.ItemClickListener { + + private TextviewRecyclerViewAdapter adapter; + private List> languageOptions; + private String settingsName = "languageSelectionList"; + private String[] availableLanguages; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.color_selection_activity); + + availableLanguages = getResources().getStringArray(R.array.AvailableLanguages); + languageOptions = new ArrayList<>(); + for(String lang : availableLanguages){ + Locale mLocale = new Locale(lang); + languageOptions.add(new Pair(mLocale.getDisplayLanguage(mLocale), mLocale.getDisplayLanguage(new Locale ("en")))); + } + + RecyclerView recyclerView = findViewById(R.id.colorList); + recyclerView.setLayoutManager(new LinearLayoutManager(this)); + adapter = new TextviewRecyclerViewAdapter(this, languageOptions, settingsName); + adapter.setClickListener(this); + recyclerView.setAdapter(adapter); + } + + @Override + public void onItemClick(View view, int position, String name) { + Intent returnIntent = new Intent(); + String newLanguage = availableLanguages[position]; + returnIntent.putExtra("newLanguage", newLanguage); + setResult(Activity.RESULT_OK, returnIntent); + finish(); + } +} \ No newline at end of file diff --git a/phone/src/main/java/com/layoutxml/twelveish/fragments/SharedSettingsFragment.java b/phone/src/main/java/com/layoutxml/twelveish/fragments/SharedSettingsFragment.java index ff52057..edd087d 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/fragments/SharedSettingsFragment.java +++ b/phone/src/main/java/com/layoutxml/twelveish/fragments/SharedSettingsFragment.java @@ -19,12 +19,14 @@ import com.layoutxml.twelveish.R; import com.layoutxml.twelveish.SettingsManager; import com.layoutxml.twelveish.activities.ColorSelectionActivity; +import com.layoutxml.twelveish.activities.LanguageSelectionActivity; import com.layoutxml.twelveish.adapters.ImageRecyclerViewAdapter; import com.layoutxml.twelveish.adapters.SwitchRecyclerViewAdapter; import com.layoutxml.twelveish.adapters.TextviewRecyclerViewAdapter; import java.util.ArrayList; import java.util.List; +import java.util.Locale; public class SharedSettingsFragment extends Fragment implements ImageRecyclerViewAdapter.ItemClickImageListener, TextviewRecyclerViewAdapter.ItemClickListener{ @@ -35,6 +37,10 @@ public class SharedSettingsFragment extends Fragment implements ImageRecyclerVie private SettingsManager settingsManager; private CustomizationScreen activity; private List> optionsTI; + private List> optionsTT; + private int colorSelectionRequestCode = 0; + private int languageSelectionRequestCode = 1; + RecyclerView recyclerViewTT; @Nullable @Override @@ -47,8 +53,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c optionsTI = new ArrayList<>(); generateColorOptions(); - List> optionsTT = new ArrayList<>(); - optionsTT.add(new Pair("Language","Currently set "+settingsManager.stringHashmap.get(getResources().getString(R.string.preference_language)))); + optionsTT = new ArrayList<>(); + generateLanguageOptions(); RecyclerView recyclerViewTI = view.findViewById(R.id.topImageRV); recyclerViewTI.setLayoutManager(new LinearLayoutManager(getContext())); @@ -56,7 +62,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c adapterMI.setClickListener(this); recyclerViewTI.setAdapter(adapterMI); - RecyclerView recyclerViewTT = view.findViewById(R.id.topTextRV); + recyclerViewTT = view.findViewById(R.id.topTextRV); recyclerViewTT.setLayoutManager(new LinearLayoutManager(getContext())); adapterMT = new TextviewRecyclerViewAdapter(getContext(),optionsTT, settingsMTName); adapterMT.setClickListener(this); @@ -70,14 +76,25 @@ private void generateColorOptions() { optionsTI.add(new Pair("Background Color",settingsManager.integerHashmap.get(getResources().getString(R.string.preference_background_color)))); } + private void generateLanguageOptions(){ + optionsTT.clear(); + String chosenLanguage = new Locale(settingsManager.stringHashmap.get(getString(R.string.preference_language))) + .getDisplayLanguage(new Locale("en")); // return the name of the chosen language in English + optionsTT.add(new Pair("Language","Currently set "+chosenLanguage)); + + } + @Override public void onItemClickImage(View view, int position, Integer currentColor, String name) { Intent intent = new Intent(getContext(), ColorSelectionActivity.class); - startActivityForResult(intent, position); + startActivityForResult(intent, colorSelectionRequestCode); } @Override - public void onItemClick(View view, int position, String name){} + public void onItemClick(View view, int position, String name){ + Intent intent = new Intent(getContext(), LanguageSelectionActivity.class); + startActivityForResult(intent, languageSelectionRequestCode); + } @Override @@ -89,6 +106,16 @@ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent d generateColorOptions(); adapterMI.notifyDataSetChanged(); break; + case 1: + settingsManager.stringHashmap.put(getResources().getString(R.string.preference_language), data.getStringExtra("newLanguage")); + + settingsManager.significantTimeChange = true; + activity.invalidatePreview(); + + optionsTT.clear(); + generateLanguageOptions(); + adapterMT.notifyDataSetChanged(); + break; default: break; } diff --git a/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java b/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java index a9f70e6..32ffe6f 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java +++ b/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java @@ -71,11 +71,15 @@ public class WatchPreviewView extends View implements WordClockListener { private int secondaryTextSizeDP = 14; private int batteryLevel = 100; private int previousHight = 0; + private Context activity; + private String oldLanguage = ""; public WatchPreviewView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); paint = new Paint(); paintFrame = new Paint(); + activity = context; + try { CustomizationScreen activity = (CustomizationScreen) getContext(); settingsManager = activity.getSettingsManagerComponent().getSettingsManager(); @@ -157,7 +161,34 @@ public WatchPreviewView(Context context, @Nullable AttributeSet attrs) { break; } - switch (settingsManager.stringHashmap.get(context.getString(R.string.preference_language))) { + generateAffixes(); // Fetch the prefixes and suffixes for the chosen language + + final Handler handler = new Handler(Looper.getMainLooper()); + Runnable reDrawer = new Runnable(){ + public void run(){ + invalidate(); + handler.postDelayed(this,1000); + } + }; + reDrawer.run(); + + getContext().registerReceiver(new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + batteryLevel = (int) (100 * intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1) / ((float) (intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1)))); + text1 = (batteryLevel + "%"); + } + }, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + height = MeasureSpec.getSize(heightMeasureSpec); + } + + private void generateAffixes(){ + switch (settingsManager.stringHashmap.get(activity.getString(R.string.preference_language))) { case "nl": Prefixes = getResources().getStringArray(R.array.PrefixesNL); Suffixes = getResources().getStringArray(R.array.SuffixesNL); @@ -280,28 +311,7 @@ public WatchPreviewView(Context context, @Nullable AttributeSet attrs) { break; } - final Handler handler = new Handler(Looper.getMainLooper()); - Runnable reDrawer = new Runnable(){ - public void run(){ - invalidate(); - handler.postDelayed(this,1000); - } - }; - reDrawer.run(); - - getContext().registerReceiver(new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - batteryLevel = (int) (100 * intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1) / ((float) (intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1)))); - text1 = (batteryLevel + "%"); - } - }, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - height = MeasureSpec.getSize(heightMeasureSpec); + oldLanguage = settingsManager.stringHashmap.get(activity.getString(R.string.preference_language)); } @Override @@ -311,6 +321,10 @@ protected void onDraw(Canvas canvas) { int y = getHeight()/2; paint.setColor(Color.parseColor("#000000")); + if(!oldLanguage.equals(settingsManager.stringHashmap.get(activity.getString(R.string.preference_language)))) // The language has been changed, update our prefixes and suffixes + generateAffixes(); + + if (mAmbient) paintFrame.setColor(Color.parseColor("#333333")); else diff --git a/phone/src/main/res/values/strings.xml b/phone/src/main/res/values/strings.xml index dc9e3a5..0fd644c 100644 --- a/phone/src/main/res/values/strings.xml +++ b/phone/src/main/res/values/strings.xml @@ -46,6 +46,23 @@ secondaryTextSizeOffset mainTextSizeReal + + nl + en + fi + fr + de + el + hu + it + lt + no + pt + ru + es + sv + + twelve one @@ -466,7 +483,7 @@ circa poco più\u00A0che quasi - + quasi pressapoco @@ -481,8 +498,8 @@ e mezza meno un quarto meno qualcosa - - + + Do @@ -521,21 +538,21 @@ las once - - + + casi - - + + casi - - - - - + + + + + casi - + y cinco y cuarto y cuarto From e04ef53251b7d9ea10efdefeeb21a61088d480f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Hel=C3=B8?= Date: Mon, 18 Jan 2021 12:43:41 +0100 Subject: [PATCH 11/39] Added TextSelectionActivity to replace LanguageSelectionActivity, while adding options for other types of setting selection with only text. Refactored MainTextSettingsFragment.onActivityResult to be more readable. Started implementing handling for font and capitalization settings - Not yet functional. --- phone/src/main/AndroidManifest.xml | 1 + .../activities/LanguageSelectionActivity.java | 21 ++-- .../activities/TextSelectionActivity.java | 115 ++++++++++++++++++ .../fragments/MainTextSettingsFragment.java | 59 ++++++++- .../fragments/SharedSettingsFragment.java | 2 + 5 files changed, 184 insertions(+), 14 deletions(-) create mode 100644 phone/src/main/java/com/layoutxml/twelveish/activities/TextSelectionActivity.java diff --git a/phone/src/main/AndroidManifest.xml b/phone/src/main/AndroidManifest.xml index ce5d528..497975f 100644 --- a/phone/src/main/AndroidManifest.xml +++ b/phone/src/main/AndroidManifest.xml @@ -31,6 +31,7 @@ + \ No newline at end of file diff --git a/phone/src/main/java/com/layoutxml/twelveish/activities/LanguageSelectionActivity.java b/phone/src/main/java/com/layoutxml/twelveish/activities/LanguageSelectionActivity.java index 1449331..dac6ad1 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/activities/LanguageSelectionActivity.java +++ b/phone/src/main/java/com/layoutxml/twelveish/activities/LanguageSelectionActivity.java @@ -20,7 +20,7 @@ public class LanguageSelectionActivity extends AppCompatActivity implements TextviewRecyclerViewAdapter.ItemClickListener { private TextviewRecyclerViewAdapter adapter; - private List> languageOptions; + private List> settingOptions; private String settingsName = "languageSelectionList"; private String[] availableLanguages; @@ -29,20 +29,25 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.color_selection_activity); - availableLanguages = getResources().getStringArray(R.array.AvailableLanguages); - languageOptions = new ArrayList<>(); - for(String lang : availableLanguages){ - Locale mLocale = new Locale(lang); - languageOptions.add(new Pair(mLocale.getDisplayLanguage(mLocale), mLocale.getDisplayLanguage(new Locale ("en")))); - } + generateLanguageList(); + RecyclerView recyclerView = findViewById(R.id.colorList); recyclerView.setLayoutManager(new LinearLayoutManager(this)); - adapter = new TextviewRecyclerViewAdapter(this, languageOptions, settingsName); + adapter = new TextviewRecyclerViewAdapter(this, settingOptions, settingsName); adapter.setClickListener(this); recyclerView.setAdapter(adapter); } + private void generateLanguageList(){ + availableLanguages = getResources().getStringArray(R.array.AvailableLanguages); + settingOptions = new ArrayList<>(); + for(String lang : availableLanguages){ + Locale mLocale = new Locale(lang); + settingOptions.add(new Pair(mLocale.getDisplayLanguage(mLocale), mLocale.getDisplayLanguage(new Locale("en")))); + } + } + @Override public void onItemClick(View view, int position, String name) { Intent returnIntent = new Intent(); diff --git a/phone/src/main/java/com/layoutxml/twelveish/activities/TextSelectionActivity.java b/phone/src/main/java/com/layoutxml/twelveish/activities/TextSelectionActivity.java new file mode 100644 index 0000000..5eb7fcb --- /dev/null +++ b/phone/src/main/java/com/layoutxml/twelveish/activities/TextSelectionActivity.java @@ -0,0 +1,115 @@ +package com.layoutxml.twelveish.activities; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.util.Pair; +import android.view.View; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.layoutxml.twelveish.R; +import com.layoutxml.twelveish.adapters.TextviewRecyclerViewAdapter; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +public class TextSelectionActivity extends AppCompatActivity implements TextviewRecyclerViewAdapter.ItemClickListener { + + private TextviewRecyclerViewAdapter adapter; + private List> settingOptions; + private String settingsName = "languageSelectionList"; + private String[] availableLanguages; + private String settingType = ""; + + public static String LANGUAGE_SELECTION = "SELECT_LANGUAGE"; + public static String FONT_SELECTION = "SELECT_FONT"; + public static String SEPARATOR_SYMBOL = "SELECT_SEPARATOR"; + public static String CAPITALIZATION = "CAPITALIZATION"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.color_selection_activity); + + settingType = getIntent().getStringExtra("SETTING_TYPE"); + + if(settingType.equals(LANGUAGE_SELECTION)){ + generateLanguageList(); + } else if(settingType.equals(FONT_SELECTION)){ + generateFontList(); + } else if(settingType.equals(SEPARATOR_SYMBOL)){ + generateSeparatorList(); + } else if(settingType.equals(CAPITALIZATION)){ + generateCapitalizationList(); + } + + RecyclerView recyclerView = findViewById(R.id.colorList); + recyclerView.setLayoutManager(new LinearLayoutManager(this)); + adapter = new TextviewRecyclerViewAdapter(this, settingOptions, settingsName); + adapter.setClickListener(this); + recyclerView.setAdapter(adapter); + } + + private void generateFontList() { + settingOptions = new ArrayList<>(); + settingOptions.add(new Pair("Roboto Light", "robotolight")); + settingOptions.add(new Pair("Alegreya", "alegreya")); + settingOptions.add(new Pair("Cabin", "cabin")); + settingOptions.add(new Pair("IBMplex Sans", "ibmplexsans")); + settingOptions.add(new Pair("Inconsolata", "inconsolata")); + settingOptions.add(new Pair("Merriweather", "merriweather")); + settingOptions.add(new Pair("Nunito", "nunito")); + settingOptions.add(new Pair("Pacifico", "pacifico")); + settingOptions.add(new Pair("Quattro Cento", "quattrocento")); + + } + + private void generateSeparatorList() { + settingOptions = new ArrayList<>(); + settingOptions.add(new Pair("Slash", "/")); + settingOptions.add(new Pair("Period", ".")); + settingOptions.add(new Pair("Hyphen", "-")); + settingOptions.add(new Pair("Space", " ")); + } + + private void generateCapitalizationList(){ + settingOptions = new ArrayList<>(); + settingOptions.add(new Pair("All words title case", "The Quick Brown Fox Jumped Over The Lazy Dog")); + settingOptions.add(new Pair("All uppercase","THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG")); + settingOptions.add(new Pair("All lowercase","the quick brown fox jumped over the lazy dog")); + settingOptions.add(new Pair("First word title case","The quick brown fox jumped over the lazy dog")); + settingOptions.add(new Pair("First word in every line title case","The quick brown fox jumped over the lazy dog")); + } + + private void generateLanguageList(){ + availableLanguages = getResources().getStringArray(R.array.AvailableLanguages); + settingOptions = new ArrayList<>(); + for(String lang : availableLanguages){ + Locale mLocale = new Locale(lang); + settingOptions.add(new Pair(mLocale.getDisplayLanguage(mLocale), mLocale.getDisplayLanguage(new Locale("en")))); + } + } + + @Override + public void onItemClick(View view, int position, String name) { + Intent returnIntent = new Intent(); + + if(settingType.equals(LANGUAGE_SELECTION)){ + String newLanguage = availableLanguages[position]; + returnIntent.putExtra("newLanguage", newLanguage); + } else if(settingType.equals(FONT_SELECTION)){ + returnIntent.putExtra("newFont", settingOptions.get(position).second); + } else if(settingType.equals(SEPARATOR_SYMBOL)){ + returnIntent.putExtra("newSeparator", settingOptions.get(position).second); + } else if(settingType.equals(CAPITALIZATION)){ + returnIntent.putExtra("newCapitalization", position); + } + + setResult(Activity.RESULT_OK, returnIntent); + finish(); + } +} \ No newline at end of file diff --git a/phone/src/main/java/com/layoutxml/twelveish/fragments/MainTextSettingsFragment.java b/phone/src/main/java/com/layoutxml/twelveish/fragments/MainTextSettingsFragment.java index b27c9f7..6103988 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/fragments/MainTextSettingsFragment.java +++ b/phone/src/main/java/com/layoutxml/twelveish/fragments/MainTextSettingsFragment.java @@ -21,6 +21,7 @@ import com.layoutxml.twelveish.SettingsManager; import com.layoutxml.twelveish.activities.AboutActivityP; import com.layoutxml.twelveish.activities.ColorSelectionActivity; +import com.layoutxml.twelveish.activities.TextSelectionActivity; import com.layoutxml.twelveish.adapters.ImageRecyclerViewAdapter; import com.layoutxml.twelveish.adapters.SwitchRecyclerViewAdapter; import com.layoutxml.twelveish.adapters.TextviewRecyclerViewAdapter; @@ -40,6 +41,15 @@ public class MainTextSettingsFragment extends Fragment implements ImageRecyclerV private CustomizationScreen activity; private List> optionsTI; private static final String TAG = "MainTextSettingsFragmen"; + private List> optionsTT; + + + // Set up request codes for option picker activities + private final int reqColorActive = 0; + private final int reqColorAmbient = 1; + private final int reqFont = 2; + private final int reqCapitalization = 3; + private final int reqTextOffset = 4; @Nullable @Override @@ -52,10 +62,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c optionsTI = new ArrayList<>(); generateColorOptions(); - List> optionsTT = new ArrayList<>(); - optionsTT.add(new Pair("Font","Currently set "+settingsManager.stringHashmap.get(getResources().getString(R.string.preference_font)))); - optionsTT.add(new Pair("Capitalization","Currently set "+settingsManager.integerHashmap.get(getResources().getString(R.string.preference_capitalisation)))); - optionsTT.add(new Pair("Text Size Offset","Currently set "+settingsManager.integerHashmap.get(getResources().getString(R.string.main_text_size_offset)))); + generateTextOptions(); + List> optionsTS = new ArrayList<>(); optionsTS.add(new Pair("24h Format",getResources().getString(R.string.preference_military_text_time))); @@ -87,6 +95,13 @@ private void generateColorOptions() { optionsTI.add(new Pair("Text Color in Ambient",settingsManager.integerHashmap.get(getResources().getString(R.string.preference_main_text_color_ambient)))); } + private void generateTextOptions(){ + optionsTT = new ArrayList<>(); + optionsTT.add(new Pair("Font","Currently set "+settingsManager.stringHashmap.get(getResources().getString(R.string.preference_font)))); + optionsTT.add(new Pair("Capitalization","Currently set "+settingsManager.integerHashmap.get(getResources().getString(R.string.preference_capitalisation)))); + optionsTT.add(new Pair("Text Size Offset","Currently set "+settingsManager.integerHashmap.get(getResources().getString(R.string.main_text_size_offset)))); + } + @Override public void onItemClickSwitch(View view, int position, boolean newValue, String name) { if (name.equals(settingsMSName)) { @@ -102,6 +117,21 @@ public void onItemClickImage(View view, int position, Integer currentColor, Stri @Override public void onItemClick(View view, int position, String name){ + if(name.equals(settingsMTName)){ + Intent intent; + switch (position){ + case 0: + intent = new Intent(getContext(), TextSelectionActivity.class); + intent.putExtra("SETTING_TYPE", TextSelectionActivity.FONT_SELECTION); + startActivityForResult(intent, reqFont); + break; + /*case 1: + intent = new Intent(getContext(), TextSelectionActivity.class); + intent.putExtra("SETTING_TYPE", TextSelectionActivity.CAPITALIZATION); + startActivityForResult(intent, reqCapitalization); + break;*/ + } + } } @Override @@ -110,16 +140,33 @@ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent d if (resultCode==Activity.RESULT_OK) { Log.d(TAG, "onActivityResult: result is for "+requestCode); switch (requestCode) { - case 0: + case reqColorActive: settingsManager.integerHashmap.put(getResources().getString(R.string.preference_main_text_color), data.getIntExtra("newColor", Color.parseColor("#000000"))); generateColorOptions(); adapterMI.notifyDataSetChanged(); break; - case 1: + case reqColorAmbient: settingsManager.integerHashmap.put(getResources().getString(R.string.preference_main_text_color_ambient), data.getIntExtra("newColor", Color.parseColor("#000000"))); generateColorOptions(); adapterMI.notifyDataSetChanged(); break; + case reqFont: + // TODO: Handle new Font setting + settingsManager.stringHashmap.put(getResources().getString(R.string.preference_font), data.getStringExtra("newFont")); + generateTextOptions(); + adapterMT.notifyDataSetChanged(); + activity.invalidatePreview(); + break; + case reqCapitalization: + // TODO: Handle new capitalization setting + settingsManager.integerHashmap.put(getResources().getString(R.string.preference_capitalisation), data.getIntExtra("newCapitalization", 0)); + generateTextOptions(); + adapterMT.notifyDataSetChanged(); + activity.invalidatePreview(); + break; + case reqTextOffset: + // TODO: Handle new text offset setting + break; default: break; } diff --git a/phone/src/main/java/com/layoutxml/twelveish/fragments/SharedSettingsFragment.java b/phone/src/main/java/com/layoutxml/twelveish/fragments/SharedSettingsFragment.java index edd087d..5846c09 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/fragments/SharedSettingsFragment.java +++ b/phone/src/main/java/com/layoutxml/twelveish/fragments/SharedSettingsFragment.java @@ -20,6 +20,7 @@ import com.layoutxml.twelveish.SettingsManager; import com.layoutxml.twelveish.activities.ColorSelectionActivity; import com.layoutxml.twelveish.activities.LanguageSelectionActivity; +import com.layoutxml.twelveish.activities.TextSelectionActivity; import com.layoutxml.twelveish.adapters.ImageRecyclerViewAdapter; import com.layoutxml.twelveish.adapters.SwitchRecyclerViewAdapter; import com.layoutxml.twelveish.adapters.TextviewRecyclerViewAdapter; @@ -93,6 +94,7 @@ public void onItemClickImage(View view, int position, Integer currentColor, Stri @Override public void onItemClick(View view, int position, String name){ Intent intent = new Intent(getContext(), LanguageSelectionActivity.class); + intent.putExtra("SETTING_TYPE", TextSelectionActivity.LANGUAGE_SELECTION); startActivityForResult(intent, languageSelectionRequestCode); } From 49c4e1cbe1e814ebd7a662dbe6b1f35a7e6ad45e Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Mon, 18 Jan 2021 20:51:13 +0100 Subject: [PATCH 12/39] Added setting for main and most top text settings. - Text offset remains. Changed the text of some options to look better. Added helping text to replace integer options (e.g. date order, capitalization) Refactored TextSelectionActivity slightly to fit with TopSettingsFragment.onItemClick --- .../activities/TextSelectionActivity.java | 59 +++++++--- .../fragments/MainTextSettingsFragment.java | 26 +++-- .../fragments/TopSettingsFragment.java | 62 ++++++++-- .../twelveish/objects/WatchPreviewView.java | 107 +++++++++--------- 4 files changed, 172 insertions(+), 82 deletions(-) diff --git a/phone/src/main/java/com/layoutxml/twelveish/activities/TextSelectionActivity.java b/phone/src/main/java/com/layoutxml/twelveish/activities/TextSelectionActivity.java index 5eb7fcb..37e3659 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/activities/TextSelectionActivity.java +++ b/phone/src/main/java/com/layoutxml/twelveish/activities/TextSelectionActivity.java @@ -11,9 +11,11 @@ import androidx.recyclerview.widget.RecyclerView; import com.layoutxml.twelveish.R; +import com.layoutxml.twelveish.SettingsManager; import com.layoutxml.twelveish.adapters.TextviewRecyclerViewAdapter; import java.util.ArrayList; +import java.util.Calendar; import java.util.List; import java.util.Locale; @@ -23,28 +25,34 @@ public class TextSelectionActivity extends AppCompatActivity implements Textview private List> settingOptions; private String settingsName = "languageSelectionList"; private String[] availableLanguages; - private String settingType = ""; + private int settingType; + private SettingsManager settingsManager; + + public static int LANGUAGE_SELECTION = 0; + public static int CAPITALIZATION = 1; + public static int FONT_SELECTION = 2; + public static int DATE_ORDER = 3; + public static int SEPARATOR_SYMBOL = 4; + public static int TEXT_OFFSET = 5; - public static String LANGUAGE_SELECTION = "SELECT_LANGUAGE"; - public static String FONT_SELECTION = "SELECT_FONT"; - public static String SEPARATOR_SYMBOL = "SELECT_SEPARATOR"; - public static String CAPITALIZATION = "CAPITALIZATION"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.color_selection_activity); - settingType = getIntent().getStringExtra("SETTING_TYPE"); + settingType = getIntent().getIntExtra("SETTING_TYPE", 0); - if(settingType.equals(LANGUAGE_SELECTION)){ + if(settingType == LANGUAGE_SELECTION){ generateLanguageList(); - } else if(settingType.equals(FONT_SELECTION)){ + } else if(settingType == FONT_SELECTION){ generateFontList(); - } else if(settingType.equals(SEPARATOR_SYMBOL)){ + } else if(settingType == SEPARATOR_SYMBOL){ generateSeparatorList(); - } else if(settingType.equals(CAPITALIZATION)){ + } else if(settingType == CAPITALIZATION){ generateCapitalizationList(); + } else if(settingType == DATE_ORDER){ + generateDateOrderList(); } RecyclerView recyclerView = findViewById(R.id.colorList); @@ -94,19 +102,42 @@ private void generateLanguageList(){ } } + private void generateDateOrderList(){ + Calendar mCalendar = Calendar.getInstance(); + settingOptions = new ArrayList<>(); + + int day = mCalendar.get(Calendar.DAY_OF_MONTH); + int month = mCalendar.get(Calendar.MONTH) + 1; + int year = mCalendar.get(Calendar.YEAR); + + String dateStrings[] = new String[4]; + dateStrings[0] = String.format(Locale.UK, "%02d" + "-" + "%02d" + "-" + "%04d", month, day, year); + dateStrings[1] = String.format(Locale.UK, "%02d" + "-" + "%02d" + "-" + "%04d", day, month, year); + dateStrings[2] = String.format(Locale.UK, "%04d" + "-" + "%02d" + "-" + "%02d", year, month, day); + dateStrings[3] = String.format(Locale.UK, "%04d" + "-" + "%02d" + "-" + "%02d", year, day, month); + + settingOptions.add(new Pair("Month-Day-Year", dateStrings[0])); + settingOptions.add(new Pair("Day-Month-Year", dateStrings[1])); + settingOptions.add(new Pair("Year-Month-Day", dateStrings[2])); + settingOptions.add(new Pair("Year-Day-Month", dateStrings[3])); + } + @Override public void onItemClick(View view, int position, String name) { Intent returnIntent = new Intent(); - if(settingType.equals(LANGUAGE_SELECTION)){ + if(settingType == LANGUAGE_SELECTION){ String newLanguage = availableLanguages[position]; returnIntent.putExtra("newLanguage", newLanguage); - } else if(settingType.equals(FONT_SELECTION)){ + + } else if(settingType == FONT_SELECTION){ returnIntent.putExtra("newFont", settingOptions.get(position).second); - } else if(settingType.equals(SEPARATOR_SYMBOL)){ + } else if(settingType == SEPARATOR_SYMBOL){ returnIntent.putExtra("newSeparator", settingOptions.get(position).second); - } else if(settingType.equals(CAPITALIZATION)){ + } else if(settingType == CAPITALIZATION){ returnIntent.putExtra("newCapitalization", position); + } else if(settingType == DATE_ORDER){ + returnIntent.putExtra("newDateOrder", position); } setResult(Activity.RESULT_OK, returnIntent); diff --git a/phone/src/main/java/com/layoutxml/twelveish/fragments/MainTextSettingsFragment.java b/phone/src/main/java/com/layoutxml/twelveish/fragments/MainTextSettingsFragment.java index 6103988..e3dc457 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/fragments/MainTextSettingsFragment.java +++ b/phone/src/main/java/com/layoutxml/twelveish/fragments/MainTextSettingsFragment.java @@ -62,6 +62,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c optionsTI = new ArrayList<>(); generateColorOptions(); + optionsTT = new ArrayList<>(); generateTextOptions(); @@ -96,10 +97,13 @@ private void generateColorOptions() { } private void generateTextOptions(){ - optionsTT = new ArrayList<>(); - optionsTT.add(new Pair("Font","Currently set "+settingsManager.stringHashmap.get(getResources().getString(R.string.preference_font)))); - optionsTT.add(new Pair("Capitalization","Currently set "+settingsManager.integerHashmap.get(getResources().getString(R.string.preference_capitalisation)))); - optionsTT.add(new Pair("Text Size Offset","Currently set "+settingsManager.integerHashmap.get(getResources().getString(R.string.main_text_size_offset)))); + optionsTT.clear(); + + int capitalization = settingsManager.integerHashmap.get(getResources().getString(R.string.preference_capitalisation)); + String[] capitalizationString = {"all words title case", "all uppercase", "all lowercase", "first world title case", "first word in every line title case"}; + optionsTT.add(new Pair("Font","Currently set to "+settingsManager.stringHashmap.get(getResources().getString(R.string.preference_font)))); + optionsTT.add(new Pair("Capitalization","Currently set to "+capitalizationString[capitalization])); + optionsTT.add(new Pair("Text Size Offset","Currently set to "+settingsManager.integerHashmap.get(getResources().getString(R.string.main_text_size_offset)))); } @Override @@ -125,11 +129,11 @@ public void onItemClick(View view, int position, String name){ intent.putExtra("SETTING_TYPE", TextSelectionActivity.FONT_SELECTION); startActivityForResult(intent, reqFont); break; - /*case 1: + case 1: intent = new Intent(getContext(), TextSelectionActivity.class); intent.putExtra("SETTING_TYPE", TextSelectionActivity.CAPITALIZATION); startActivityForResult(intent, reqCapitalization); - break;*/ + break; } } } @@ -151,15 +155,19 @@ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent d adapterMI.notifyDataSetChanged(); break; case reqFont: - // TODO: Handle new Font setting settingsManager.stringHashmap.put(getResources().getString(R.string.preference_font), data.getStringExtra("newFont")); + + settingsManager.significantTimeChange = true; + + optionsTT.clear(); generateTextOptions(); adapterMT.notifyDataSetChanged(); - activity.invalidatePreview(); break; case reqCapitalization: - // TODO: Handle new capitalization setting settingsManager.integerHashmap.put(getResources().getString(R.string.preference_capitalisation), data.getIntExtra("newCapitalization", 0)); + + settingsManager.significantTimeChange = true; + generateTextOptions(); adapterMT.notifyDataSetChanged(); activity.invalidatePreview(); diff --git a/phone/src/main/java/com/layoutxml/twelveish/fragments/TopSettingsFragment.java b/phone/src/main/java/com/layoutxml/twelveish/fragments/TopSettingsFragment.java index f75f9d0..4f4e7c8 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/fragments/TopSettingsFragment.java +++ b/phone/src/main/java/com/layoutxml/twelveish/fragments/TopSettingsFragment.java @@ -20,6 +20,7 @@ import com.layoutxml.twelveish.R; import com.layoutxml.twelveish.SettingsManager; import com.layoutxml.twelveish.activities.ColorSelectionActivity; +import com.layoutxml.twelveish.activities.TextSelectionActivity; import com.layoutxml.twelveish.adapters.ImageRecyclerViewAdapter; import com.layoutxml.twelveish.adapters.SwitchRecyclerViewAdapter; import com.layoutxml.twelveish.adapters.TextviewRecyclerViewAdapter; @@ -38,6 +39,14 @@ public class TopSettingsFragment extends Fragment implements ImageRecyclerViewAd private SettingsManager settingsManager; private CustomizationScreen activity; private List> optionsTI; + private List> optionsTT; + + private final int reqSecColorActive = 0; + private final int reqSecColorAmbient = 1; + private final int reqFont = 2; + private final int reqDateOrder = 3; + private final int reqDateSymbol = 4; + private final int reqTextOffset = 5; @Nullable @Override @@ -50,11 +59,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c optionsTI = new ArrayList<>(); generateColorOptions(); - List> optionsTT = new ArrayList<>(); - optionsTT.add(new Pair("Font","Currently set "+settingsManager.stringHashmap.get(getResources().getString(R.string.preference_font_secondary)))); //TODO - optionsTT.add(new Pair("Date Order","Currently set "+settingsManager.integerHashmap.get(getResources().getString(R.string.preference_date_order)))); - optionsTT.add(new Pair("Date Separator Symbol","Currently set "+settingsManager.stringHashmap.get(getResources().getString(R.string.preference_date_separator)))); - optionsTT.add(new Pair("Text Size Offset","Currently set "+settingsManager.integerHashmap.get(getResources().getString(R.string.secondary_text_size_offset)))); + optionsTT = new ArrayList<>(); + generateTextOptions(); List> optionsTS = new ArrayList<>(); optionsTS.add(new Pair("Digital Clock",getString(R.string.preference_show_digital_clock))); @@ -95,6 +101,18 @@ private void generateColorOptions() { optionsTI.add(new Pair("Text Color in Ambient",settingsManager.integerHashmap.get(getResources().getString(R.string.preference_secondary_text_color_ambient)))); } + private void generateTextOptions(){ + optionsTT.clear(); + + int dateOrder = settingsManager.integerHashmap.get(getResources().getString(R.string.preference_date_order)); + String[] dateOrderString = {"Month-Day-Year", "Day-Month-Year", "Year-Month-Day", "Year-Day-Month"}; + + optionsTT.add(new Pair("Font","Currently set to "+settingsManager.stringHashmap.get(getResources().getString(R.string.preference_font_secondary)))); + optionsTT.add(new Pair("Date Order","Currently set to "+dateOrderString[dateOrder])); + optionsTT.add(new Pair("Date Separator Symbol","Currently set to "+settingsManager.stringHashmap.get(getResources().getString(R.string.preference_date_separator)))); + optionsTT.add(new Pair("Text Size Offset","Currently set to "+settingsManager.integerHashmap.get(getResources().getString(R.string.secondary_text_size_offset)))); + } + @Override public void onItemClickSwitch(View view, int position, boolean newValue, String name) { if (name.equals(settingsTSName)) { @@ -109,22 +127,50 @@ public void onItemClickImage(View view, int position, Integer currentColor, Stri } @Override - public void onItemClick(View view, int position, String name){} + public void onItemClick(View view, int position, String name){ + if(name.equals(settingsTTName)){ + Intent intent; + + intent = new Intent(getContext(), TextSelectionActivity.class); + intent.putExtra("SETTING_TYPE", position + 2); + startActivityForResult(intent,position + 2); + } + } @Override public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { if (resultCode== Activity.RESULT_OK) { switch (requestCode) { - case 0: + case reqSecColorActive: settingsManager.integerHashmap.put(getResources().getString(R.string.preference_secondary_text_color), data.getIntExtra("newColor", Color.parseColor("#000000"))); generateColorOptions(); adapterTI.notifyDataSetChanged(); break; - case 1: + case reqSecColorAmbient: settingsManager.integerHashmap.put(getResources().getString(R.string.preference_secondary_text_color_ambient), data.getIntExtra("newColor", Color.parseColor("#000000"))); generateColorOptions(); adapterTI.notifyDataSetChanged(); break; + case reqFont: + settingsManager.stringHashmap.put(activity.getString(R.string.preference_font_secondary), data.getStringExtra("newFont")); + + settingsManager.significantTimeChange = true; + generateTextOptions(); + adapterTT.notifyDataSetChanged(); + break; + case reqDateOrder: + settingsManager.integerHashmap.put(activity.getString(R.string.preference_date_order), data.getIntExtra("newDateOrder", 0)); + + generateTextOptions(); + settingsManager.significantTimeChange = true; + + adapterTT.notifyDataSetChanged(); + activity.invalidatePreview(); + break; + case reqDateSymbol: + break; + case reqTextOffset: + break; default: break; } diff --git a/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java b/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java index 32ffe6f..da4f648 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java +++ b/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java @@ -109,57 +109,7 @@ public WatchPreviewView(Context context, @Nullable AttributeSet attrs) { mTextPaint.setTextSize(22 + secondaryTextOffset); //secondary text mTextPaint2.setTextSize(24 + mainTextOffset); - Typeface NORMAL_TYPEFACE2; - switch (settingsManager.stringHashmap.get(context.getString(R.string.preference_font))) { - case "robotolight": - NORMAL_TYPEFACE2 = Typeface.create("sans-serif-light", Typeface.NORMAL); - mTextPaint2.setTypeface(NORMAL_TYPEFACE2); - break; - case "alegreya": - NORMAL_TYPEFACE2 = ResourcesCompat.getFont(context, R.font.alegreya); - mTextPaint2.setTypeface(NORMAL_TYPEFACE2); - break; - case "cabin": - NORMAL_TYPEFACE2 = ResourcesCompat.getFont(context, R.font.cabin); - mTextPaint2.setTypeface(NORMAL_TYPEFACE2); - break; - case "ibmplexsans": - NORMAL_TYPEFACE2 = ResourcesCompat.getFont(context, R.font.ibmplexsans); - mTextPaint2.setTypeface(NORMAL_TYPEFACE2); - break; - case "inconsolata": - NORMAL_TYPEFACE2 = ResourcesCompat.getFont(context, R.font.inconsolata); - mTextPaint2.setTypeface(NORMAL_TYPEFACE2); - break; - case "merriweather": - NORMAL_TYPEFACE2 = ResourcesCompat.getFont(context, R.font.merriweather); - mTextPaint2.setTypeface(NORMAL_TYPEFACE2); - break; - case "nunito": - NORMAL_TYPEFACE2 = ResourcesCompat.getFont(context, R.font.nunito); - mTextPaint2.setTypeface(NORMAL_TYPEFACE2); - break; - case "pacifico": - NORMAL_TYPEFACE2 = ResourcesCompat.getFont(context, R.font.pacifico); - mTextPaint2.setTypeface(NORMAL_TYPEFACE2); - break; - case "quattrocento": - NORMAL_TYPEFACE2 = ResourcesCompat.getFont(context, R.font.quattrocento); - mTextPaint2.setTypeface(NORMAL_TYPEFACE2); - break; - case "quicksand": - NORMAL_TYPEFACE2 = ResourcesCompat.getFont(context, R.font.quicksand); - mTextPaint2.setTypeface(NORMAL_TYPEFACE2); - break; - case "rubik": - NORMAL_TYPEFACE2 = ResourcesCompat.getFont(context, R.font.rubik); - mTextPaint2.setTypeface(NORMAL_TYPEFACE2); - break; - default: - NORMAL_TYPEFACE2 = Typeface.create("sans-serif-light", Typeface.NORMAL); - mTextPaint2.setTypeface(NORMAL_TYPEFACE2); - break; - } + getFont(); generateAffixes(); // Fetch the prefixes and suffixes for the chosen language @@ -324,6 +274,7 @@ protected void onDraw(Canvas canvas) { if(!oldLanguage.equals(settingsManager.stringHashmap.get(activity.getString(R.string.preference_language)))) // The language has been changed, update our prefixes and suffixes generateAffixes(); + getFont(); if (mAmbient) paintFrame.setColor(Color.parseColor("#333333")); @@ -467,6 +418,60 @@ else if (hourText > 12 && !settingsManager.booleanHashmap.get(getContext().getSt //TODO placeholder } + private void getFont(){ + Typeface NORMAL_TYPEFACE2; + switch (settingsManager.stringHashmap.get(activity.getString(R.string.preference_font))) { + case "robotolight": + NORMAL_TYPEFACE2 = Typeface.create("sans-serif-light", Typeface.NORMAL); + mTextPaint2.setTypeface(NORMAL_TYPEFACE2); + break; + case "alegreya": + NORMAL_TYPEFACE2 = ResourcesCompat.getFont(activity, R.font.alegreya); + mTextPaint2.setTypeface(NORMAL_TYPEFACE2); + break; + case "cabin": + NORMAL_TYPEFACE2 = ResourcesCompat.getFont(activity, R.font.cabin); + mTextPaint2.setTypeface(NORMAL_TYPEFACE2); + break; + case "ibmplexsans": + NORMAL_TYPEFACE2 = ResourcesCompat.getFont(activity, R.font.ibmplexsans); + mTextPaint2.setTypeface(NORMAL_TYPEFACE2); + break; + case "inconsolata": + NORMAL_TYPEFACE2 = ResourcesCompat.getFont(activity, R.font.inconsolata); + mTextPaint2.setTypeface(NORMAL_TYPEFACE2); + break; + case "merriweather": + NORMAL_TYPEFACE2 = ResourcesCompat.getFont(activity, R.font.merriweather); + mTextPaint2.setTypeface(NORMAL_TYPEFACE2); + break; + case "nunito": + NORMAL_TYPEFACE2 = ResourcesCompat.getFont(activity, R.font.nunito); + mTextPaint2.setTypeface(NORMAL_TYPEFACE2); + break; + case "pacifico": + NORMAL_TYPEFACE2 = ResourcesCompat.getFont(activity, R.font.pacifico); + mTextPaint2.setTypeface(NORMAL_TYPEFACE2); + break; + case "quattrocento": + NORMAL_TYPEFACE2 = ResourcesCompat.getFont(activity, R.font.quattrocento); + mTextPaint2.setTypeface(NORMAL_TYPEFACE2); + break; + case "quicksand": + NORMAL_TYPEFACE2 = ResourcesCompat.getFont(activity, R.font.quicksand); + mTextPaint2.setTypeface(NORMAL_TYPEFACE2); + break; + case "rubik": + NORMAL_TYPEFACE2 = ResourcesCompat.getFont(activity, R.font.rubik); + mTextPaint2.setTypeface(NORMAL_TYPEFACE2); + break; + default: + NORMAL_TYPEFACE2 = Typeface.create("sans-serif-light", Typeface.NORMAL); + mTextPaint2.setTypeface(NORMAL_TYPEFACE2); + break; + } + } + private void getDate() { //Get date int first, second, third; From 29186d1388aca364ae1f662030fd2ca313999b42 Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Mon, 18 Jan 2021 23:08:53 +0100 Subject: [PATCH 13/39] Added Seekbars for Text size offset for the main and secondary texts - needs tuning. --- .../adapters/SeekerRecyclerViewAdapter.java | 102 ++++++++++++++++++ .../fragments/MainTextSettingsFragment.java | 41 +++++-- .../fragments/TopSettingsFragment.java | 43 ++++++-- .../layoutxml/twelveish/objects/Triple.java | 14 +++ .../twelveish/objects/WatchPreviewView.java | 9 +- phone/src/main/res/layout/slider_item.xml | 33 ++++++ .../main/res/layout/top_settings_fragment.xml | 7 ++ 7 files changed, 234 insertions(+), 15 deletions(-) create mode 100644 phone/src/main/java/com/layoutxml/twelveish/adapters/SeekerRecyclerViewAdapter.java create mode 100644 phone/src/main/java/com/layoutxml/twelveish/objects/Triple.java create mode 100644 phone/src/main/res/layout/slider_item.xml diff --git a/phone/src/main/java/com/layoutxml/twelveish/adapters/SeekerRecyclerViewAdapter.java b/phone/src/main/java/com/layoutxml/twelveish/adapters/SeekerRecyclerViewAdapter.java new file mode 100644 index 0000000..64ce2ad --- /dev/null +++ b/phone/src/main/java/com/layoutxml/twelveish/adapters/SeekerRecyclerViewAdapter.java @@ -0,0 +1,102 @@ +package com.layoutxml.twelveish.adapters; + +import android.content.Context; +import android.os.Build; +import android.util.Pair; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.SeekBar; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.layoutxml.twelveish.R; +import com.layoutxml.twelveish.objects.Triple; + +import java.util.List; + +public class SeekerRecyclerViewAdapter extends RecyclerView.Adapter { + + private List> mData; + private LayoutInflater mInflater; + private ItemClickListener mClickListener; + private SeekBar.OnSeekBarChangeListener mSeekBarListener; + private String name=""; //adapter name + + public SeekerRecyclerViewAdapter(Context context, List> data, String name) { + this.mInflater = LayoutInflater.from(context); + this.mData = data; + this.name = name; + } + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = mInflater.inflate(R.layout.slider_item, parent, false); + return new ViewHolder(view); + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + String title = mData.get(position).first; + int value = mData.get(position).second; + int maxValue = mData.get(position).third; + holder.myTextView.setText(title); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + holder.mySeekBar.setMin(0); + } + holder.mySeekBar.setMax(maxValue); + holder.mySeekBar.setProgress(value); + } + + @Override + public int getItemCount() { + return mData.size(); + } + + public class ViewHolder extends RecyclerView.ViewHolder implements SeekBar.OnSeekBarChangeListener { + TextView myTextView; + SeekBar mySeekBar; + + ViewHolder(View itemView) { + super(itemView); + myTextView = itemView.findViewById(R.id.titleTextView); + mySeekBar = itemView.findViewById(R.id.seekBar); + mySeekBar.setOnSeekBarChangeListener(this); + } + + + @Override + public void onProgressChanged(SeekBar seekBar, int value, boolean fromUser) { + if(mSeekBarListener != null) + mSeekBarListener.onProgressChanged(seekBar, value, fromUser); + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + if(mSeekBarListener != null) + mSeekBarListener.onStartTrackingTouch(seekBar); + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + if(mSeekBarListener != null) + mSeekBarListener.onStopTrackingTouch(seekBar); + } + } + + String getItem(int id) { + return mData.get(id).first; + } + + public void setOnSeekBarChangeListener(SeekBar.OnSeekBarChangeListener listener){ + this.mSeekBarListener = listener; + } + + public interface ItemClickListener { + void onItemClick(View view, int position, String name); + } +} \ No newline at end of file diff --git a/phone/src/main/java/com/layoutxml/twelveish/fragments/MainTextSettingsFragment.java b/phone/src/main/java/com/layoutxml/twelveish/fragments/MainTextSettingsFragment.java index e3dc457..6b683a2 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/fragments/MainTextSettingsFragment.java +++ b/phone/src/main/java/com/layoutxml/twelveish/fragments/MainTextSettingsFragment.java @@ -9,6 +9,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.SeekBar; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -23,20 +24,24 @@ import com.layoutxml.twelveish.activities.ColorSelectionActivity; import com.layoutxml.twelveish.activities.TextSelectionActivity; import com.layoutxml.twelveish.adapters.ImageRecyclerViewAdapter; +import com.layoutxml.twelveish.adapters.SeekerRecyclerViewAdapter; import com.layoutxml.twelveish.adapters.SwitchRecyclerViewAdapter; import com.layoutxml.twelveish.adapters.TextviewRecyclerViewAdapter; +import com.layoutxml.twelveish.objects.Triple; import java.util.ArrayList; import java.util.List; -public class MainTextSettingsFragment extends Fragment implements ImageRecyclerViewAdapter.ItemClickImageListener, TextviewRecyclerViewAdapter.ItemClickListener, SwitchRecyclerViewAdapter.ItemClickSwitchListener{ +public class MainTextSettingsFragment extends Fragment implements ImageRecyclerViewAdapter.ItemClickImageListener, TextviewRecyclerViewAdapter.ItemClickListener, SwitchRecyclerViewAdapter.ItemClickSwitchListener, SeekBar.OnSeekBarChangeListener { private ImageRecyclerViewAdapter adapterMI; private TextviewRecyclerViewAdapter adapterMT; private SwitchRecyclerViewAdapter adapterMS; + private SeekerRecyclerViewAdapter adapterMSB; private final String settingsMIName = "settingsMI"; private final String settingsMTName = "settingsMT"; private final String settingsMSName = "settingsMS"; + private final String settingsMSBName = "settingsMSB"; private SettingsManager settingsManager; private CustomizationScreen activity; private List> optionsTI; @@ -49,7 +54,7 @@ public class MainTextSettingsFragment extends Fragment implements ImageRecyclerV private final int reqColorAmbient = 1; private final int reqFont = 2; private final int reqCapitalization = 3; - private final int reqTextOffset = 4; + @Nullable @Override @@ -69,6 +74,9 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c List> optionsTS = new ArrayList<>(); optionsTS.add(new Pair("24h Format",getResources().getString(R.string.preference_military_text_time))); + List> optionsTSB = new ArrayList<>(); + optionsTSB.add(new Triple("Text Size Offset", settingsManager.integerHashmap.get(getString(R.string.secondary_text_size_offset)), 5)); + RecyclerView recyclerViewTI = view.findViewById(R.id.topImageRV); recyclerViewTI.setLayoutManager(new LinearLayoutManager(getContext())); adapterMI = new ImageRecyclerViewAdapter(getContext(),optionsTI, settingsMIName); @@ -81,6 +89,12 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c adapterMT.setClickListener(this); recyclerViewTT.setAdapter(adapterMT); + RecyclerView recyclerViewMSB = view.findViewById(R.id.topSeekRV); + recyclerViewMSB.setLayoutManager(new LinearLayoutManager(getContext())); + adapterMSB = new SeekerRecyclerViewAdapter(getContext(), optionsTSB, settingsMSBName); + adapterMSB.setOnSeekBarChangeListener(this); + recyclerViewMSB.setAdapter(adapterMSB); + RecyclerView recyclerViewTS = view.findViewById(R.id.topSwitchRV); recyclerViewTS.setLayoutManager(new LinearLayoutManager(getContext())); adapterMS = new SwitchRecyclerViewAdapter(getContext(),optionsTS, settingsMSName, settingsManager); @@ -103,7 +117,6 @@ private void generateTextOptions(){ String[] capitalizationString = {"all words title case", "all uppercase", "all lowercase", "first world title case", "first word in every line title case"}; optionsTT.add(new Pair("Font","Currently set to "+settingsManager.stringHashmap.get(getResources().getString(R.string.preference_font)))); optionsTT.add(new Pair("Capitalization","Currently set to "+capitalizationString[capitalization])); - optionsTT.add(new Pair("Text Size Offset","Currently set to "+settingsManager.integerHashmap.get(getResources().getString(R.string.main_text_size_offset)))); } @Override @@ -172,13 +185,29 @@ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent d adapterMT.notifyDataSetChanged(); activity.invalidatePreview(); break; - case reqTextOffset: - // TODO: Handle new text offset setting - break; default: break; } } } + + @Override + public void onProgressChanged(SeekBar seekBar, int newValue, boolean fromUser) { + if(fromUser){ + settingsManager.integerHashmap.put(getString(R.string.main_text_size_offset), newValue); + settingsManager.significantTimeChange = true; + activity.invalidatePreview(); + } + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + + } } diff --git a/phone/src/main/java/com/layoutxml/twelveish/fragments/TopSettingsFragment.java b/phone/src/main/java/com/layoutxml/twelveish/fragments/TopSettingsFragment.java index 4f4e7c8..75ddd30 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/fragments/TopSettingsFragment.java +++ b/phone/src/main/java/com/layoutxml/twelveish/fragments/TopSettingsFragment.java @@ -9,6 +9,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.SeekBar; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -22,20 +23,24 @@ import com.layoutxml.twelveish.activities.ColorSelectionActivity; import com.layoutxml.twelveish.activities.TextSelectionActivity; import com.layoutxml.twelveish.adapters.ImageRecyclerViewAdapter; +import com.layoutxml.twelveish.adapters.SeekerRecyclerViewAdapter; import com.layoutxml.twelveish.adapters.SwitchRecyclerViewAdapter; import com.layoutxml.twelveish.adapters.TextviewRecyclerViewAdapter; +import com.layoutxml.twelveish.objects.Triple; import java.util.ArrayList; import java.util.List; -public class TopSettingsFragment extends Fragment implements ImageRecyclerViewAdapter.ItemClickImageListener, TextviewRecyclerViewAdapter.ItemClickListener, SwitchRecyclerViewAdapter.ItemClickSwitchListener{ +public class TopSettingsFragment extends Fragment implements ImageRecyclerViewAdapter.ItemClickImageListener, TextviewRecyclerViewAdapter.ItemClickListener, SwitchRecyclerViewAdapter.ItemClickSwitchListener, SeekBar.OnSeekBarChangeListener { private ImageRecyclerViewAdapter adapterTI; private TextviewRecyclerViewAdapter adapterTT; private SwitchRecyclerViewAdapter adapterTS; + private SeekerRecyclerViewAdapter adapterTSB; private final String settingsTIName = "settingsTI"; private final String settingsTTName = "settingsTT"; private final String settingsTSName = "settingsTS"; + private final String settingsTSBName = "settingsTSB"; private SettingsManager settingsManager; private CustomizationScreen activity; private List> optionsTI; @@ -74,6 +79,9 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c optionsTS.add(new Pair("24h Format",getResources().getString(R.string.preference_military_time))); optionsTS.add(new Pair("Show Seconds in Active",getResources().getString(R.string.preference_show_seconds))); + List> optionsTSB = new ArrayList<>(); + optionsTSB.add(new Triple("Text Size Offset", settingsManager.integerHashmap.get(getString(R.string.secondary_text_size_offset)), 5)); + RecyclerView recyclerViewTI = view.findViewById(R.id.topImageRV); recyclerViewTI.setLayoutManager(new LinearLayoutManager(getContext())); adapterTI = new ImageRecyclerViewAdapter(getContext(),optionsTI,settingsTIName); @@ -86,6 +94,13 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c adapterTT.setClickListener(this); recyclerViewTT.setAdapter(adapterTT); + RecyclerView recyclerViewTSB = view.findViewById(R.id.topSeekRV); + recyclerViewTSB.setLayoutManager(new LinearLayoutManager(getContext())); + adapterTSB = new SeekerRecyclerViewAdapter(getContext(), optionsTSB, settingsTSBName); + adapterTSB.setOnSeekBarChangeListener(this); + recyclerViewTSB.setAdapter(adapterTSB); + + RecyclerView recyclerViewTS = view.findViewById(R.id.topSwitchRV); recyclerViewTS.setLayoutManager(new LinearLayoutManager(getContext())); adapterTS = new SwitchRecyclerViewAdapter(getContext(),optionsTS,settingsTSName, settingsManager); @@ -110,7 +125,6 @@ private void generateTextOptions(){ optionsTT.add(new Pair("Font","Currently set to "+settingsManager.stringHashmap.get(getResources().getString(R.string.preference_font_secondary)))); optionsTT.add(new Pair("Date Order","Currently set to "+dateOrderString[dateOrder])); optionsTT.add(new Pair("Date Separator Symbol","Currently set to "+settingsManager.stringHashmap.get(getResources().getString(R.string.preference_date_separator)))); - optionsTT.add(new Pair("Text Size Offset","Currently set to "+settingsManager.integerHashmap.get(getResources().getString(R.string.secondary_text_size_offset)))); } @Override @@ -129,9 +143,7 @@ public void onItemClickImage(View view, int position, Integer currentColor, Stri @Override public void onItemClick(View view, int position, String name){ if(name.equals(settingsTTName)){ - Intent intent; - - intent = new Intent(getContext(), TextSelectionActivity.class); + Intent intent = new Intent(getContext(), TextSelectionActivity.class); intent.putExtra("SETTING_TYPE", position + 2); startActivityForResult(intent,position + 2); } @@ -169,11 +181,28 @@ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent d break; case reqDateSymbol: break; - case reqTextOffset: - break; default: break; } } } + + @Override + public void onProgressChanged(SeekBar seekBar, int newValue, boolean fromUser) { + if(fromUser){ + settingsManager.integerHashmap.put(getString(R.string.secondary_text_size_offset), newValue); + settingsManager.significantTimeChange = true; + activity.invalidatePreview(); + } + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + + } } diff --git a/phone/src/main/java/com/layoutxml/twelveish/objects/Triple.java b/phone/src/main/java/com/layoutxml/twelveish/objects/Triple.java new file mode 100644 index 0000000..f3235cd --- /dev/null +++ b/phone/src/main/java/com/layoutxml/twelveish/objects/Triple.java @@ -0,0 +1,14 @@ +package com.layoutxml.twelveish.objects; + +public class Triple { + + public final T first; + public final T1 second; + public final T2 third; + + public Triple(T first, T1 second, T2 third) { + this.first = first; + this.second = second; + this.third = third; + } +} diff --git a/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java b/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java index da4f648..5625304 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java +++ b/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java @@ -35,8 +35,8 @@ public class WatchPreviewView extends View implements WordClockListener { - private final int secondaryTextOffset = 0; //TODO - private final int mainTextOffset = 0; //TODO + private int secondaryTextOffset = 0; + private int mainTextOffset = 0; private int height = 0; private Paint paint; private Paint paintFrame; @@ -276,6 +276,11 @@ protected void onDraw(Canvas canvas) { getFont(); + // Update the size offsets + mainTextOffset = settingsManager.integerHashmap.get(getResources().getString(R.string.main_text_size_offset)); + secondaryTextOffset = settingsManager.integerHashmap.get(getResources().getString(R.string.secondary_text_size_offset)); + + if (mAmbient) paintFrame.setColor(Color.parseColor("#333333")); else diff --git a/phone/src/main/res/layout/slider_item.xml b/phone/src/main/res/layout/slider_item.xml new file mode 100644 index 0000000..93572c5 --- /dev/null +++ b/phone/src/main/res/layout/slider_item.xml @@ -0,0 +1,33 @@ + + + + + + + + + + \ No newline at end of file diff --git a/phone/src/main/res/layout/top_settings_fragment.xml b/phone/src/main/res/layout/top_settings_fragment.xml index 096fc15..cdc2520 100644 --- a/phone/src/main/res/layout/top_settings_fragment.xml +++ b/phone/src/main/res/layout/top_settings_fragment.xml @@ -23,8 +23,15 @@ android:id="@+id/topTextRV" android:layout_width="match_parent" android:layout_height="wrap_content"> + + + Date: Tue, 19 Jan 2021 17:45:22 +0100 Subject: [PATCH 14/39] Moved some code around and tweaked the text size offset. --- .../fragments/MainTextSettingsFragment.java | 18 +++++++------ .../fragments/SharedSettingsFragment.java | 2 +- .../fragments/TopSettingsFragment.java | 25 +++++++++++++------ 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/phone/src/main/java/com/layoutxml/twelveish/fragments/MainTextSettingsFragment.java b/phone/src/main/java/com/layoutxml/twelveish/fragments/MainTextSettingsFragment.java index 6b683a2..1ac8bbc 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/fragments/MainTextSettingsFragment.java +++ b/phone/src/main/java/com/layoutxml/twelveish/fragments/MainTextSettingsFragment.java @@ -151,6 +151,15 @@ public void onItemClick(View view, int position, String name){ } } + @Override + public void onProgressChanged(SeekBar seekBar, int newValue, boolean fromUser) { + if(fromUser){ + settingsManager.integerHashmap.put(getString(R.string.main_text_size_offset), newValue * 7); + settingsManager.significantTimeChange = true; + activity.invalidatePreview(); + } + } + @Override public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { Log.d(TAG, "onActivityResult: result received"); @@ -191,14 +200,7 @@ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent d } } - @Override - public void onProgressChanged(SeekBar seekBar, int newValue, boolean fromUser) { - if(fromUser){ - settingsManager.integerHashmap.put(getString(R.string.main_text_size_offset), newValue); - settingsManager.significantTimeChange = true; - activity.invalidatePreview(); - } - } + @Override public void onStartTrackingTouch(SeekBar seekBar) { diff --git a/phone/src/main/java/com/layoutxml/twelveish/fragments/SharedSettingsFragment.java b/phone/src/main/java/com/layoutxml/twelveish/fragments/SharedSettingsFragment.java index 5846c09..ef19f5d 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/fragments/SharedSettingsFragment.java +++ b/phone/src/main/java/com/layoutxml/twelveish/fragments/SharedSettingsFragment.java @@ -81,7 +81,7 @@ private void generateLanguageOptions(){ optionsTT.clear(); String chosenLanguage = new Locale(settingsManager.stringHashmap.get(getString(R.string.preference_language))) .getDisplayLanguage(new Locale("en")); // return the name of the chosen language in English - optionsTT.add(new Pair("Language","Currently set "+chosenLanguage)); + optionsTT.add(new Pair("Language","Currently set to "+chosenLanguage)); } diff --git a/phone/src/main/java/com/layoutxml/twelveish/fragments/TopSettingsFragment.java b/phone/src/main/java/com/layoutxml/twelveish/fragments/TopSettingsFragment.java index 75ddd30..125f9ec 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/fragments/TopSettingsFragment.java +++ b/phone/src/main/java/com/layoutxml/twelveish/fragments/TopSettingsFragment.java @@ -149,6 +149,15 @@ public void onItemClick(View view, int position, String name){ } } + @Override + public void onProgressChanged(SeekBar seekBar, int newValue, boolean fromUser) { + if(fromUser){ + settingsManager.integerHashmap.put(getString(R.string.secondary_text_size_offset), newValue * 3); + settingsManager.significantTimeChange = true; + activity.invalidatePreview(); + } + } + @Override public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { if (resultCode== Activity.RESULT_OK) { @@ -180,6 +189,13 @@ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent d activity.invalidatePreview(); break; case reqDateSymbol: + settingsManager.stringHashmap.put(getString(R.string.preference_date_separator), data.getStringExtra("newSeparator")); + + generateTextOptions(); + settingsManager.significantTimeChange = true; + + adapterTT.notifyDataSetChanged(); + activity.invalidatePreview(); break; default: break; @@ -187,14 +203,7 @@ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent d } } - @Override - public void onProgressChanged(SeekBar seekBar, int newValue, boolean fromUser) { - if(fromUser){ - settingsManager.integerHashmap.put(getString(R.string.secondary_text_size_offset), newValue); - settingsManager.significantTimeChange = true; - activity.invalidatePreview(); - } - } + @Override public void onStartTrackingTouch(SeekBar seekBar) { From a8c0aeb753837213d5f6c9a842a8823e17e588a6 Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Tue, 19 Jan 2021 20:04:22 +0100 Subject: [PATCH 15/39] Updated dependencies for wearable support.wearable libraries - This fixed broken imports in ComplicationConfigActivity --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ae625a5..1cec47b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -20,12 +20,12 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.google.android.support:wearable:2.7.0' + implementation 'com.google.android.support:wearable:2.8.1' implementation 'com.google.android.gms:play-services-wearable:17.0.0' implementation 'androidx.percentlayout:percentlayout:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha03' implementation 'androidx.wear:wear:1.0.0' - compileOnly 'com.google.android.wearable:wearable:2.7.0' + compileOnly 'com.google.android.wearable:wearable:2.8.1' implementation "androidx.constraintlayout:constraintlayout:1.1.3" } From 7af79d1071361788e8830175c6345f8644d7000d Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Wed, 20 Jan 2021 20:04:53 +0100 Subject: [PATCH 16/39] Added saving/loading of a single watch face configuration --- phone/build.gradle | 1 + .../twelveish/CustomizationScreen.java | 83 ++++++++++++- phone/src/main/res/values/strings.xml | 116 +++++++++--------- 3 files changed, 141 insertions(+), 59 deletions(-) diff --git a/phone/build.gradle b/phone/build.gradle index 77ff4f0..ac4b8d6 100644 --- a/phone/build.gradle +++ b/phone/build.gradle @@ -33,6 +33,7 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.appcompat:appcompat:1.3.0-alpha01' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + implementation 'com.google.code.gson:gson:2.8.5' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' diff --git a/phone/src/main/java/com/layoutxml/twelveish/CustomizationScreen.java b/phone/src/main/java/com/layoutxml/twelveish/CustomizationScreen.java index 2ceaa48..bf8405e 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/CustomizationScreen.java +++ b/phone/src/main/java/com/layoutxml/twelveish/CustomizationScreen.java @@ -1,6 +1,8 @@ package com.layoutxml.twelveish; import android.os.Bundle; +import android.provider.Settings; +import android.util.JsonReader; import android.util.Log; import android.view.View; import android.widget.ImageButton; @@ -14,16 +16,26 @@ import com.google.android.gms.wearable.Wearable; import com.google.android.material.tabs.TabLayout; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.layoutxml.twelveish.adapters.OptionsPagerAdapter; import com.layoutxml.twelveish.dagger.App; import com.layoutxml.twelveish.dagger.DaggerSettingsManagerComponent; import com.layoutxml.twelveish.dagger.SettingsManagerComponent; import com.layoutxml.twelveish.fragments.PreviewFragment; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.List; + import javax.inject.Inject; -public class CustomizationScreen extends AppCompatActivity { +public class CustomizationScreen extends AppCompatActivity implements View.OnClickListener { @Inject SettingsManagerComponent settingsManagerComponent; @@ -41,8 +53,50 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { communicator.initiateHandshake(); Log.d(TAG, "communicatorID" + communicator); + //private static final Type REVIEW_TYPE = new TypeToken>() + settingsManagerComponent = DaggerSettingsManagerComponent.factory().create(getApplicationContext()); + SettingsManager testSettings = settingsManagerComponent.getSettingsManager(); + Gson gson = new Gson(); + try { + JsonReader reader = new JsonReader(new FileReader(this.getFilesDir().toString() + "/test.json")); + reader.beginObject(); + while(reader.hasNext()){ + String nameToRead = reader.nextName(); + if(nameToRead.equals("stringHashMap")){ + reader.beginObject(); + while(reader.hasNext()){ + String firstString = reader.nextName(); + String secondString = reader.nextString(); + testSettings.stringHashmap.put(firstString, secondString); + } + reader.endObject(); + } else if (nameToRead.equals("booleanHashMap")){ + reader.beginObject(); + while (reader.hasNext()){ + testSettings.booleanHashmap.put(reader.nextName(), reader.nextBoolean()); + } + reader.endObject(); + } else if(nameToRead.equals("integerHashMap")){ + reader.beginObject(); + while(reader.hasNext()){ + testSettings.integerHashmap.put(reader.nextName(), reader.nextInt()); + } + reader.endObject(); + } + } + + reader.endObject(); + + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + + FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); @@ -74,6 +128,9 @@ public void onClick(View v) { invalidatePreview(); } }); + + ImageButton saveButton = findViewById(R.id.saveButton); + saveButton.setOnClickListener(this); } @Override @@ -94,6 +151,30 @@ public SettingsManagerComponent getSettingsManagerComponent() { return settingsManagerComponent; } + @Override + public void onClick(View view) { + SettingsManager settingsManager = settingsManagerComponent.getSettingsManager(); + Gson gson = new Gson(); + HashMap settingMap = new HashMap<>(); + settingMap.put("stringHashMap", settingsManager.stringHashmap); + settingMap.put("booleanHashMap", settingsManager.booleanHashmap); + settingMap.put("integerHashMap", settingsManager.integerHashmap); + + String mapString = gson.toJson(settingMap); + + try { + String fileName = this.getFilesDir().toString() + "/test.json"; + FileWriter writer = new FileWriter(fileName); + gson.toJson(settingMap, writer); + writer.close(); + } catch (IOException e) { + e.printStackTrace(); + } + if(!mapString.equals("")){ + mapString = ""; + } + } + public interface AmoledChange { public void ambientModeChange(boolean value); } diff --git a/phone/src/main/res/values/strings.xml b/phone/src/main/res/values/strings.xml index 0fd644c..b2d9be7 100644 --- a/phone/src/main/res/values/strings.xml +++ b/phone/src/main/res/values/strings.xml @@ -90,8 +90,8 @@ twenty three - - + + a\u00A0quarter past a quarter past almost\u00A0half past @@ -106,16 +106,16 @@ ish or\u00A0so - + or\u00A0so - - + + ish or\u00A0so - + or\u00A0so - - + + Su @@ -168,18 +168,18 @@ apie - - + + su\u00A0ketvirčiu su\u00A0ketvirčiu su\u00A0puse su\u00A0puse su\u00A0puse su\u00A0puse - - - - + + + + Se @@ -232,18 +232,18 @@ lähes - - - - - - - - - - - - + + + + + + + + + + + + Su @@ -282,21 +282,21 @@ двадцать три - - + + почти - + почти - - - + + + почти\u00A0без четверти без четверти почти - + - + или\u00A0около того с\u00A0четвертью с\u00A0четвертью @@ -304,10 +304,10 @@ с\u00A0половиной с\u00A0половиной с\u00A0половиной - - - - + + + + Вс @@ -360,18 +360,18 @@ fast - - - + + + oder\u00A0so - - - - - + + + + + oder\u00A0so - - + + So @@ -410,8 +410,8 @@ huszonhárom - - + + negyed negyed lassan fél @@ -420,22 +420,22 @@ fél háromnegyed háromnegyed - + mindjárt múlt körül lesz - - + + lesz - + múlt - + múlt lesz - + Va @@ -474,8 +474,8 @@ le undici - - + + quasi circa quasi From 34b310e68414ec61ee8f4cb122a0bb6d724bbb85 Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Fri, 22 Jan 2021 11:57:58 +0100 Subject: [PATCH 17/39] Added feature to transfer all preferences to the wearable. - Still needs implementing getting preferences from the wearable to handheld. Refactored MyWatchFace.Engine.onDataChanged to accept more than one incoming preference at a time. Changed how the wearable fetches preferences to send to handheld. --- .../com/layoutxml/twelveish/MyWatchFace.java | 81 ++++++------ phone/src/main/AndroidManifest.xml | 7 +- .../com/layoutxml/twelveish/Communicator.java | 120 +++++++++++++++--- .../twelveish/CustomizationScreen.java | 55 +++++--- 4 files changed, 185 insertions(+), 78 deletions(-) diff --git a/app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java b/app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java index 7107e1b..8d34ae2 100644 --- a/app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java +++ b/app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java @@ -59,6 +59,7 @@ import java.lang.ref.WeakReference; import java.util.Calendar; import java.util.Locale; +import java.util.Map; import java.util.TimeZone; import java.util.concurrent.TimeUnit; @@ -1184,6 +1185,35 @@ private void processData(DataItem dataItem) { getDate(); //forces date refresh in case it is changed significantTimeChange = true; } + if (array!=null && array.length > 3){ // We're receiving multiple preferences at once + int index = 0; + for(int i = 0; i < array.length; i+=3){ + switch(array[i + 2]){ + case "String": + prefs.edit().putString(array[i], array[i+1]).apply(); + break; + case "Integer": + int newPref = Integer.parseInt(array[i+1]); + prefs.edit().putInt(array[i], newPref).apply(); + break; + case "Boolean": + if (array[i + 1].equalsIgnoreCase("true") || array[i+1].equalsIgnoreCase("false")){ + boolean newPref2 = Boolean.parseBoolean(array[i+1]); + prefs.edit().putBoolean(array[i], newPref2).apply(); + } else { + Toast.makeText(getApplicationContext(), "Preference error", Toast.LENGTH_SHORT).show(); + } + break; + default: + Log.d(TAG, "Unkown type in processData. Index: " + i); + } + } + + loadPreferences(); + getDate(); //forces date refresh in case it is changed + significantTimeChange = true; + + } boolean handshake = mDataMapItem.getDataMap().getBoolean(HANDSHAKE_KEY); if (!handshake) { final PutDataMapRequest mPutDataMapRequest = PutDataMapRequest.create(path); @@ -1202,45 +1232,18 @@ public void run() { } boolean preferences = mDataMapItem.getDataMap().getBoolean(DATA_REQUEST_KEY); if (preferences) { - String[] preferencesToSend = new String[38]; - preferencesToSend[0] = "militaryTime"; - preferencesToSend[1] = militaryTime ? "true" : "false"; - preferencesToSend[2] = "militaryTextTime"; - preferencesToSend[3] = militaryTextTime ? "true" : "false"; - preferencesToSend[4] = "ampm"; - preferencesToSend[5] = "false"; //TODO: remove - preferencesToSend[6] = "showSecondary"; - preferencesToSend[7] = showSecondary ? "true" : "false"; - preferencesToSend[8] = "showSecondaryActive"; - preferencesToSend[9] = showSecondaryActive ? "true" : "false"; - preferencesToSend[10] = "showSecondaryCalendar"; - preferencesToSend[11] = showSecondaryCalendar ? "true" : "false"; - preferencesToSend[12] = "showSecondaryCalendarActive"; - preferencesToSend[13] = showSecondaryCalendarActive ? "true" : "false"; - preferencesToSend[14] = "showSuffixes"; - preferencesToSend[15] = "true"; - preferencesToSend[16] = "showBattery"; - preferencesToSend[17] = showBattery ? "true" : "false"; - preferencesToSend[18] = "showBatteryAmbient"; - preferencesToSend[19] = showBatteryAmbient ? "true" : "false"; - preferencesToSend[20] = "showWords"; - preferencesToSend[21] = "true"; - preferencesToSend[22] = "showWordsAmbient"; - preferencesToSend[23] = "true"; - preferencesToSend[24] = "showSeconds"; - preferencesToSend[25] = showSeconds ? "true" : "false"; - preferencesToSend[26] = "showComplication"; - preferencesToSend[27] = showComplication ? "true" : "false"; - preferencesToSend[28] = "showComplicationAmbient"; - preferencesToSend[29] = showComplicationAmbient ? "true" : "false"; - preferencesToSend[30] = "showDay"; - preferencesToSend[31] = showDay ? "true" : "false"; - preferencesToSend[32] = "showDayAmbient"; - preferencesToSend[33] = showDayAmbient ? "true" : "false"; - preferencesToSend[34] = "disableComplicationTap"; - preferencesToSend[35] = disableComplicationTap ? "true" : "false"; - preferencesToSend[36] = "legacyWords"; - preferencesToSend[37] = "false"; + Map prefMap = prefs.getAll(); + int index = 0; + String[] preferencesToSend = new String[prefMap.size() * 2]; + + for(Map.Entry entry : prefMap.entrySet()){ + String key = entry.getKey(); + String value = entry.getValue().toString(); + + preferencesToSend[index] = key; + preferencesToSend[index+1] = value; + index += 2; + } final PutDataMapRequest mPutDataMapRequest = PutDataMapRequest.create(path); mPutDataMapRequest.getDataMap().putLong("Timestamp", System.currentTimeMillis()); diff --git a/phone/src/main/AndroidManifest.xml b/phone/src/main/AndroidManifest.xml index 497975f..1a307b5 100644 --- a/phone/src/main/AndroidManifest.xml +++ b/phone/src/main/AndroidManifest.xml @@ -15,12 +15,15 @@ android:supportsRtl="true" android:theme="@style/AppTheme" tools:ignore="GoogleAppIndexingWarning"> - + + @@ -30,7 +33,7 @@ - + diff --git a/phone/src/main/java/com/layoutxml/twelveish/Communicator.java b/phone/src/main/java/com/layoutxml/twelveish/Communicator.java index dcfb428..8a3cd9b 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/Communicator.java +++ b/phone/src/main/java/com/layoutxml/twelveish/Communicator.java @@ -20,6 +20,7 @@ import java.lang.ref.WeakReference; import java.util.ArrayList; +import java.util.Map; import javax.inject.Inject; import javax.inject.Singleton; @@ -56,7 +57,7 @@ public void initiateHandshake() { setCurrentStatus(false); mPutDataMapRequest.getDataMap().putLong("Timestamp", System.currentTimeMillis()); - mPutDataMapRequest.getDataMap().putBoolean(HANDSHAKE_KEY, false); + mPutDataMapRequest.getDataMap().putBoolean(HANDSHAKE_KEY, true); mPutDataMapRequest.setUrgent(); PutDataRequest mPutDataRequest = mPutDataMapRequest.asPutDataRequest(); Wearable.getDataClient(applicationContext).putDataItem(mPutDataRequest); @@ -120,21 +121,83 @@ public void run() { }, 5000); //deleting as described in google's documentation does not actually work, so I have to resolve to clearing with delay } -// public void requestBooleanPreferences(Context context, WeakReference listenerActivity) { -// mPutDataMapRequest.getDataMap().putLong("Timestamp", System.currentTimeMillis()); -// mPutDataMapRequest.getDataMap().putBoolean(DATA_REQUEST_KEY, true); -// mPutDataMapRequest.setUrgent(); -// PutDataRequest mPutDataRequest = mPutDataMapRequest.asPutDataRequest(); -// Wearable.getDataClient(context).putDataItem(mPutDataRequest); -// booleanActivity = listenerActivity; -// final Handler handler = new Handler(); -// handler.postDelayed(new Runnable() { -// @Override -// public void run() { -// mPutDataMapRequest.getDataMap().clear(); -// } -// }, 5000); -// } + public void sendWatchFace(SettingsManager settingsManager, Context context){ + String[] preferencesToSend = new String[(settingsManager.booleanHashmap.size() + settingsManager.integerHashmap.size() + settingsManager.stringHashmap.size())*3]; + + int index = 0; + for(Map.Entry preference : settingsManager.stringHashmap.entrySet()){ + String key = preference.getKey(); + String value = preference.getValue(); + String type = "String"; + + preferencesToSend[index] = key; + preferencesToSend[index + 1] = value; + preferencesToSend[index + 2] = type; + index += 3; + } + + for(Map.Entry preference : settingsManager.integerHashmap.entrySet()){ + String key = preference.getKey(); + int value = preference.getValue(); + String type = "Integer"; + + preferencesToSend[index] = key; + preferencesToSend[index + 1] = String.valueOf(value); + preferencesToSend[index + 2] = type; + index += 3; + } + + for(Map.Entry preference : settingsManager.booleanHashmap.entrySet()){ + String key = preference.getKey(); + boolean value = preference.getValue(); + String type = "Boolean"; + + preferencesToSend[index] = key; + preferencesToSend[index + 1] = value ? "true" : "false"; + preferencesToSend[index + 2] = type; + index += 3; + } + + + if(preferencesToSend != null){ + Log.d(TAG, "Preferences found"); + } + + mPutDataMapRequest.getDataMap().putLong("Timestamp", System.currentTimeMillis()); + mPutDataMapRequest.getDataMap().putStringArray(DATA_KEY, preferencesToSend); + mPutDataMapRequest.setUrgent(); + PutDataRequest mPutDataRequest = mPutDataMapRequest.asPutDataRequest(); + Wearable.getDataClient(context).putDataItem(mPutDataRequest); + final Handler handler = new Handler(); + handler.postDelayed(new Runnable() { + @Override + public void run() { + mPutDataMapRequest.getDataMap().clear(); + } + }, 5000); //deleting as described in google's documentation does not actually work, so I have to resolve to clearing with delay + + } + + /* public void requestBooleanPreferences(Context context, WeakReference listenerActivity) { + mPutDataMapRequest.getDataMap().putLong("Timestamp", System.currentTimeMillis()); + mPutDataMapRequest.getDataMap().putBoolean(DATA_REQUEST_KEY, true); + mPutDataMapRequest.setUrgent(); + PutDataRequest mPutDataRequest = mPutDataMapRequest.asPutDataRequest(); + Wearable.getDataClient(context).putDataItem(mPutDataRequest); + customizationListener = listenerActivity; + final Handler handler = new Handler(); + handler.postDelayed(new Runnable() { + @Override + public void run() { + mPutDataMapRequest.getDataMap().clear(); + } + }, 5000); + }*/ + + /* public void requestPreferences(Context context, WeakReference listenerActivity){ + mPutDataMapRequest.getDataMap().putLong("Timestamp", System.currentTimeMillis()); + mPutDataMapRequest.getDataMap().putBoolean(); + }*/ public void requestConfig(Context context, WeakReference listenerActivity) { Log.d(TAG, "requestConfig"); @@ -162,6 +225,7 @@ public void onDataChanged(@NonNull DataEventBuffer dataEventBuffer) { boolean handshake = mDataMapItem.getDataMap().getBoolean(HANDSHAKE_KEY); boolean goodbye = mDataMapItem.getDataMap().getBoolean(GOODBYE_KEY); boolean config = mDataMapItem.getDataMap().getBoolean(CONFIG_REQUEST_KEY2); + boolean preferences = mDataMapItem.getDataMap().getBoolean(DATA_REQUEST_KEY2); if (handshake) { Log.d(TAG,"handshake received"); setCurrentStatus(true); @@ -175,6 +239,30 @@ public void onDataChanged(@NonNull DataEventBuffer dataEventBuffer) { isWatchConnected=false; initiateHandshake(); } + + /* if(preferences){ + Log.d(TAG, "onDataChanged: preferences"); + String[] newPreferences = mDataMapItem.getDataMap().getStringArray(PREFERENCES_KEY); + HomeScreen customizationScreen = customizationListener.get(); + SettingsManager settingsManager = ((App) customizationScreen.getApplication()).getSettingsManagerComponent().getSettingsManager(); + if(newPreferences != null){ + for(int i = 0; i < newPreferences.length; i+=2){ + if(settingsManager.stringHashmap.containsKey(newPreferences[i])){ + settingsManager.stringHashmap.put(newPreferences[i], newPreferences[i+1]); + } else if(settingsManager.integerHashmap.containsKey(newPreferences[i])){ + settingsManager.integerHashmap.put(newPreferences[i], Integer.valueOf(newPreferences[i+1])); + } else if(settingsManager.booleanHashmap.containsKey(newPreferences[i])){ + settingsManager.booleanHashmap.put(newPreferences[i], Boolean.valueOf(newPreferences[i+1])); + } else { + Log.d(TAG, "Unknown preference key: " + newPreferences[i]); + } + } + + settingsManager.significantTimeChange=true; + customizationScreen.invalidatePreview(); + }* + }*/ + if (config) { Log.d(TAG, "onDataChanged: config"); String[] booleanPreferencesTemp = mDataMapItem.getDataMap().getStringArray(PREFERENCES_KEY); diff --git a/phone/src/main/java/com/layoutxml/twelveish/CustomizationScreen.java b/phone/src/main/java/com/layoutxml/twelveish/CustomizationScreen.java index bf8405e..dd1a57d 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/CustomizationScreen.java +++ b/phone/src/main/java/com/layoutxml/twelveish/CustomizationScreen.java @@ -6,6 +6,7 @@ import android.util.Log; import android.view.View; import android.widget.ImageButton; +import android.widget.Toast; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; @@ -57,7 +58,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { settingsManagerComponent = DaggerSettingsManagerComponent.factory().create(getApplicationContext()); - SettingsManager testSettings = settingsManagerComponent.getSettingsManager(); + + final SettingsManager testSettings = settingsManagerComponent.getSettingsManager(); Gson gson = new Gson(); try { JsonReader reader = new JsonReader(new FileReader(this.getFilesDir().toString() + "/test.json")); @@ -96,7 +98,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { } - FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); @@ -131,6 +132,9 @@ public void onClick(View v) { ImageButton saveButton = findViewById(R.id.saveButton); saveButton.setOnClickListener(this); + + ImageButton sendButton = findViewById(R.id.sendButton); + sendButton.setOnClickListener(this); } @Override @@ -154,29 +158,38 @@ public SettingsManagerComponent getSettingsManagerComponent() { @Override public void onClick(View view) { SettingsManager settingsManager = settingsManagerComponent.getSettingsManager(); - Gson gson = new Gson(); - HashMap settingMap = new HashMap<>(); - settingMap.put("stringHashMap", settingsManager.stringHashmap); - settingMap.put("booleanHashMap", settingsManager.booleanHashmap); - settingMap.put("integerHashMap", settingsManager.integerHashmap); - - String mapString = gson.toJson(settingMap); - - try { - String fileName = this.getFilesDir().toString() + "/test.json"; - FileWriter writer = new FileWriter(fileName); - gson.toJson(settingMap, writer); - writer.close(); - } catch (IOException e) { - e.printStackTrace(); - } - if(!mapString.equals("")){ - mapString = ""; + switch (view.getId()){ + case R.id.saveButton: + + Gson gson = new Gson(); + HashMap settingMap = new HashMap<>(); + settingMap.put("stringHashMap", settingsManager.stringHashmap); + settingMap.put("booleanHashMap", settingsManager.booleanHashmap); + settingMap.put("integerHashMap", settingsManager.integerHashmap); + + String mapString = gson.toJson(settingMap); + + try { + String fileName = this.getFilesDir().toString() + "/test.json"; + FileWriter writer = new FileWriter(fileName); + gson.toJson(settingMap, writer); + writer.close(); + } catch (IOException e) { + e.printStackTrace(); + } + break; + case R.id.sendButton: + Toast.makeText(getApplicationContext(), "Applying watchface", Toast.LENGTH_LONG).show(); + communicator.sendWatchFace(settingsManager, getApplicationContext()); + break; + default: + throw new IllegalStateException("Unexpected value: " + view.getId()); } + } public interface AmoledChange { - public void ambientModeChange(boolean value); + void ambientModeChange(boolean value); } public void invalidatePreview() { From ae215281550618501ce63b29c553f3718670a398 Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Fri, 22 Jan 2021 15:45:02 +0100 Subject: [PATCH 18/39] Modified .gitignore - removes .idea/misc.xml and .idea/modules.xml --- .gitignore | 3 +++ .idea/misc.xml | 48 ----------------------------------------------- .idea/modules.xml | 10 ---------- 3 files changed, 3 insertions(+), 58 deletions(-) delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml diff --git a/.gitignore b/.gitignore index f03203d..d4fc6a9 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,9 @@ captures/ .idea/dictionaries .idea/libraries .idea/caches +.idea/modules.xml +.idea/compiler.xml +.idea/misc.xml # Keystore files # Uncomment the following line if you do not want to check your keystore files in. diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index af360d1..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index fe37581..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file From a5327010f0b0cb6c81d315cf175ad1cb6ae03532 Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Fri, 22 Jan 2021 15:57:55 +0100 Subject: [PATCH 19/39] Updated .gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d4fc6a9..3ef9291 100644 --- a/.gitignore +++ b/.gitignore @@ -44,6 +44,7 @@ captures/ .idea/modules.xml .idea/compiler.xml .idea/misc.xml +.idea/**/shelf # Keystore files # Uncomment the following line if you do not want to check your keystore files in. @@ -68,4 +69,3 @@ fastlane/test_output fastlane/readme.md .idea/workspace.xml___jb_old___ .idea/misc.xml -.idea/misc.xml From c89cd189cc5d7835cbb632a752b7f42ee0bd27e5 Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Sun, 24 Jan 2021 23:31:18 +0100 Subject: [PATCH 20/39] Add loading watch preferences on startup --- phone/src/main/AndroidManifest.xml | 1 - .../com/layoutxml/twelveish/Communicator.java | 44 +++++++++++++------ .../twelveish/CustomizationScreen.java | 6 --- .../twelveish/objects/WatchPreviewView.java | 32 +++++++++++++- 4 files changed, 62 insertions(+), 21 deletions(-) diff --git a/phone/src/main/AndroidManifest.xml b/phone/src/main/AndroidManifest.xml index 1a307b5..c2a3a85 100644 --- a/phone/src/main/AndroidManifest.xml +++ b/phone/src/main/AndroidManifest.xml @@ -15,7 +15,6 @@ android:supportsRtl="true" android:theme="@style/AppTheme" tools:ignore="GoogleAppIndexingWarning"> - previewListener; + private WeakReference preferenceListener; @Inject public Communicator(Context context) { @@ -178,13 +180,13 @@ public void run() { } - /* public void requestBooleanPreferences(Context context, WeakReference listenerActivity) { + public void requestBooleanPreferences(Context context, WeakReference listenerActivity) { mPutDataMapRequest.getDataMap().putLong("Timestamp", System.currentTimeMillis()); mPutDataMapRequest.getDataMap().putBoolean(DATA_REQUEST_KEY, true); mPutDataMapRequest.setUrgent(); PutDataRequest mPutDataRequest = mPutDataMapRequest.asPutDataRequest(); Wearable.getDataClient(context).putDataItem(mPutDataRequest); - customizationListener = listenerActivity; + preferenceListener = listenerActivity; final Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override @@ -192,7 +194,7 @@ public void run() { mPutDataMapRequest.getDataMap().clear(); } }, 5000); - }*/ + } /* public void requestPreferences(Context context, WeakReference listenerActivity){ mPutDataMapRequest.getDataMap().putLong("Timestamp", System.currentTimeMillis()); @@ -240,11 +242,13 @@ public void onDataChanged(@NonNull DataEventBuffer dataEventBuffer) { initiateHandshake(); } - /* if(preferences){ + if(preferences){ Log.d(TAG, "onDataChanged: preferences"); String[] newPreferences = mDataMapItem.getDataMap().getStringArray(PREFERENCES_KEY); - HomeScreen customizationScreen = customizationListener.get(); - SettingsManager settingsManager = ((App) customizationScreen.getApplication()).getSettingsManagerComponent().getSettingsManager(); + SettingsManager settingsManager = new SettingsManager(applicationContext); + settingsManager.initializeDefaultBooleans(); + settingsManager.initializeDefaultIntegers(); + settingsManager.initializeDefaultStrings(); if(newPreferences != null){ for(int i = 0; i < newPreferences.length; i+=2){ if(settingsManager.stringHashmap.containsKey(newPreferences[i])){ @@ -258,10 +262,24 @@ public void onDataChanged(@NonNull DataEventBuffer dataEventBuffer) { } } - settingsManager.significantTimeChange=true; - customizationScreen.invalidatePreview(); - }* - }*/ + WatchPreviewView previewView = preferenceListener.get(); + Gson gson = new Gson(); + HashMap settingMap = new HashMap<>(); + settingMap.put("stringHashMap", settingsManager.stringHashmap); + settingMap.put("booleanHashMap", settingsManager.booleanHashmap); + settingMap.put("integerHashMap", settingsManager.integerHashmap); + + try { + String fileName = previewView.getContext().getFilesDir().toString() + "/test.json"; + FileWriter writer = new FileWriter(fileName); + gson.toJson(settingMap, writer); + writer.close(); + } catch (IOException e) { + e.printStackTrace(); + } + previewView.loadSettings(settingsManager); + } + } if (config) { Log.d(TAG, "onDataChanged: config"); diff --git a/phone/src/main/java/com/layoutxml/twelveish/CustomizationScreen.java b/phone/src/main/java/com/layoutxml/twelveish/CustomizationScreen.java index dd1a57d..e947440 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/CustomizationScreen.java +++ b/phone/src/main/java/com/layoutxml/twelveish/CustomizationScreen.java @@ -54,13 +54,10 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { communicator.initiateHandshake(); Log.d(TAG, "communicatorID" + communicator); - //private static final Type REVIEW_TYPE = new TypeToken>() - settingsManagerComponent = DaggerSettingsManagerComponent.factory().create(getApplicationContext()); final SettingsManager testSettings = settingsManagerComponent.getSettingsManager(); - Gson gson = new Gson(); try { JsonReader reader = new JsonReader(new FileReader(this.getFilesDir().toString() + "/test.json")); reader.beginObject(); @@ -97,7 +94,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { e.printStackTrace(); } - FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); @@ -167,8 +163,6 @@ public void onClick(View view) { settingMap.put("booleanHashMap", settingsManager.booleanHashmap); settingMap.put("integerHashMap", settingsManager.integerHashmap); - String mapString = gson.toJson(settingMap); - try { String fileName = this.getFilesDir().toString() + "/test.json"; FileWriter writer = new FileWriter(fileName); diff --git a/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java b/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java index 5625304..c13e4ca 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java +++ b/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java @@ -32,6 +32,7 @@ import java.lang.ref.WeakReference; import java.util.Calendar; import java.util.Locale; +import java.util.Map; public class WatchPreviewView extends View implements WordClockListener { @@ -88,9 +89,13 @@ public WatchPreviewView(Context context, @Nullable AttributeSet attrs) { Log.d(TAG, "communicatorID" + communicator); Log.d(TAG, "WatchPreviewView: from customization"); } catch (Exception e) { - Log.d(TAG, "WatchPreviewView: from home screen"); SettingsManagerComponent settingsManagerComponent = DaggerSettingsManagerComponent.factory().create(getContext()); settingsManager = settingsManagerComponent.getSettingsManager(); + HomeScreen activity = (HomeScreen) getContext(); + communicator = ((App) activity.getApplication()).getCommunicatorComponent().getCommunicator(); + communicator.requestBooleanPreferences(getContext(), new WeakReference(this)); + Log.d(TAG, "WatchPreviewView: from home screen"); + Log.d(TAG, "communicatorID: " + communicator); } mTextPaint = new Paint(); @@ -548,4 +553,29 @@ public void changeAmbientMode(boolean value) { significantTimeChange = true; Log.d(TAG, "changeAmbientMode: "+value); } + + public void loadSettings(SettingsManager newSettings){ + for(Map.Entry preference : newSettings.stringHashmap.entrySet()){ + String key = preference.getKey(); + String value = preference.getValue(); + if(value != null) + this.settingsManager.stringHashmap.put(key, value); + } + + for(Map.Entry preference : newSettings.booleanHashmap.entrySet()){ + String key = preference.getKey(); + boolean value = preference.getValue(); + this.settingsManager.booleanHashmap.put(key, value); + } + + for(Map.Entry preference : newSettings.integerHashmap.entrySet()){ + String key = preference.getKey(); + int value = preference.getValue(); + + this.settingsManager.integerHashmap.put(key, value); + } + + settingsManager.significantTimeChange = true; + invalidate(); + } } From 9d683758f98c5a8c9ee7d7348b3d1ae293b58e01 Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Tue, 26 Jan 2021 21:59:33 +0100 Subject: [PATCH 21/39] Fix a bug where 24h text format wouldn't update from handheld --- app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java | 2 +- app/src/main/res/values/strings.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java b/app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java index 8d34ae2..a50db87 100644 --- a/app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java +++ b/app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java @@ -1186,7 +1186,6 @@ private void processData(DataItem dataItem) { significantTimeChange = true; } if (array!=null && array.length > 3){ // We're receiving multiple preferences at once - int index = 0; for(int i = 0; i < array.length; i+=3){ switch(array[i + 2]){ case "String": @@ -1202,6 +1201,7 @@ private void processData(DataItem dataItem) { prefs.edit().putBoolean(array[i], newPref2).apply(); } else { Toast.makeText(getApplicationContext(), "Preference error", Toast.LENGTH_SHORT).show(); + Log.d(TAG, "processData: Boolean was neither true nor false! Key: " + array[i]); } break; default: diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6815408..b9d4fb6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -15,7 +15,7 @@ secondaryColorActive secondaryColor militaryTime - militarytextTime + militaryTextTime dateOrder stringOption capitalisation From fde7977ad9c22bf0c264b0dbf55fbe85cc1f556f Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Wed, 27 Jan 2021 18:54:05 +0100 Subject: [PATCH 22/39] Fix a bug where the watch would show as connected even if it wasn't --- .../java/com/layoutxml/twelveish/MyWatchFace.java | 12 +++++++----- .../java/com/layoutxml/twelveish/Communicator.java | 7 ++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java b/app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java index 8d34ae2..80c4423 100644 --- a/app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java +++ b/app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java @@ -71,7 +71,9 @@ public class MyWatchFace extends CanvasWatchFaceService { private static final String TAG = "MyWatchFace"; private final String path = "/twelveish"; private final String DATA_KEY = "rokas-twelveish"; - private final String HANDSHAKE_KEY = "rokas-twelveish-hs"; + // private final String HANDSHAKE_KEY = "rokas-twelveish-hs"; + private final String HANDSHAKE_REQUEST = "rokas-twelveish-hs-req"; + private final String HANDSHAKE_RESPONSE = "rokas-twelveish-hs-res"; private final String GOODBYE_KEY = "rokas-twelveish-gb"; private final String DATA_REQUEST_KEY = "rokas-twelveish-dr"; private final String DATA_REQUEST_KEY2 = "rokas-twelveish-dr2"; @@ -757,7 +759,7 @@ public void onVisibilityChanged(boolean visible) { final PutDataMapRequest mPutDataMapRequest = PutDataMapRequest.create(path); mPutDataMapRequest.getDataMap().putLong("Timestamp", System.currentTimeMillis()); - mPutDataMapRequest.getDataMap().putBoolean(HANDSHAKE_KEY, true); + mPutDataMapRequest.getDataMap().putBoolean(HANDSHAKE_REQUEST, true); mPutDataMapRequest.setUrgent(); PutDataRequest mPutDataRequest = mPutDataMapRequest.asPutDataRequest(); Wearable.getDataClient(getApplicationContext()).putDataItem(mPutDataRequest); @@ -1214,11 +1216,11 @@ private void processData(DataItem dataItem) { significantTimeChange = true; } - boolean handshake = mDataMapItem.getDataMap().getBoolean(HANDSHAKE_KEY); - if (!handshake) { + boolean handshake = mDataMapItem.getDataMap().getBoolean(HANDSHAKE_REQUEST); + if (handshake) { final PutDataMapRequest mPutDataMapRequest = PutDataMapRequest.create(path); mPutDataMapRequest.getDataMap().putLong("Timestamp", System.currentTimeMillis()); - mPutDataMapRequest.getDataMap().putBoolean(HANDSHAKE_KEY, true); + mPutDataMapRequest.getDataMap().putBoolean(HANDSHAKE_RESPONSE, true); mPutDataMapRequest.setUrgent(); PutDataRequest mPutDataRequest = mPutDataMapRequest.asPutDataRequest(); Wearable.getDataClient(getApplicationContext()).putDataItem(mPutDataRequest); diff --git a/phone/src/main/java/com/layoutxml/twelveish/Communicator.java b/phone/src/main/java/com/layoutxml/twelveish/Communicator.java index 266751e..e197cf9 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/Communicator.java +++ b/phone/src/main/java/com/layoutxml/twelveish/Communicator.java @@ -31,7 +31,8 @@ public class Communicator implements DataClient.OnDataChangedListener { private final String path = "/twelveish"; private final String DATA_KEY = "rokas-twelveish"; - private final String HANDSHAKE_KEY = "rokas-twelveish-hs"; + private final String HANDSHAKE_REQUEST = "rokas-twelveish-hs-req"; + private final String HANDSHAKE_RESPONSE = "rokas-twelveish-hs-res"; private final String GOODBYE_KEY = "rokas-twelveish-gb"; private final String DATA_REQUEST_KEY = "rokas-twelveish-dr"; private final String DATA_REQUEST_KEY2 = "rokas-twelveish-dr2"; @@ -59,7 +60,7 @@ public void initiateHandshake() { setCurrentStatus(false); mPutDataMapRequest.getDataMap().putLong("Timestamp", System.currentTimeMillis()); - mPutDataMapRequest.getDataMap().putBoolean(HANDSHAKE_KEY, true); + mPutDataMapRequest.getDataMap().putBoolean(HANDSHAKE_REQUEST, true); mPutDataMapRequest.setUrgent(); PutDataRequest mPutDataRequest = mPutDataMapRequest.asPutDataRequest(); Wearable.getDataClient(applicationContext).putDataItem(mPutDataRequest); @@ -224,7 +225,7 @@ public void onDataChanged(@NonNull DataEventBuffer dataEventBuffer) { if (event.getType()==DataEvent.TYPE_CHANGED && event.getDataItem().getUri().getPath()!=null && event.getDataItem().getUri().getPath().equals(path)) { Log.d(TAG, "onDataChanged: received something"); DataMapItem mDataMapItem = DataMapItem.fromDataItem(event.getDataItem()); - boolean handshake = mDataMapItem.getDataMap().getBoolean(HANDSHAKE_KEY); + boolean handshake = mDataMapItem.getDataMap().getBoolean(HANDSHAKE_RESPONSE); boolean goodbye = mDataMapItem.getDataMap().getBoolean(GOODBYE_KEY); boolean config = mDataMapItem.getDataMap().getBoolean(CONFIG_REQUEST_KEY2); boolean preferences = mDataMapItem.getDataMap().getBoolean(DATA_REQUEST_KEY2); From 648389991580c8fbbf4dbf380f748af1fa5f2b5c Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Wed, 27 Jan 2021 18:57:28 +0100 Subject: [PATCH 23/39] Add checking if the watch has suddenly disconnected --- .../com/layoutxml/twelveish/MyWatchFace.java | 26 +++++++++- .../com/layoutxml/twelveish/Communicator.java | 47 +++++++++++++++++++ 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java b/app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java index 80c4423..6df09fe 100644 --- a/app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java +++ b/app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java @@ -80,6 +80,11 @@ public class MyWatchFace extends CanvasWatchFaceService { private final String CONFIG_REQUEST_KEY = "rokas-twelveish-cr"; private final String CONFIG_REQUEST_KEY2 = "rokas-twelveish-cr2"; private final String PREFERENCES_KEY = "rokas-twelveish-pr"; + + private final String PING_FIRE = "rokas-twelveish-fire"; // Request ping + private final String PING_ICE = "rokas-twelveish-ice"; // Ping response + private final String TIMESTAMP = "rokas-twelveish-timestamp"; + private static Typeface NORMAL_TYPEFACE = Typeface.create("sans-serif-light", Typeface.NORMAL); private static final long INTERACTIVE_UPDATE_RATE_MS = TimeUnit.SECONDS.toMillis(1); private static final int MSG_UPDATE_TIME = 0; @@ -1248,7 +1253,7 @@ public void run() { } final PutDataMapRequest mPutDataMapRequest = PutDataMapRequest.create(path); - mPutDataMapRequest.getDataMap().putLong("Timestamp", System.currentTimeMillis()); + mPutDataMapRequest.getDataMap().putLong(TIMESTAMP, System.currentTimeMillis()); mPutDataMapRequest.getDataMap().putStringArray(PREFERENCES_KEY, preferencesToSend); mPutDataMapRequest.getDataMap().putBoolean(DATA_REQUEST_KEY, false); mPutDataMapRequest.getDataMap().putBoolean(DATA_REQUEST_KEY2, true); @@ -1272,7 +1277,7 @@ public void run() { configToSend[2] = complicationRightSet ? "true" : "false"; final PutDataMapRequest mPutDataMapRequest = PutDataMapRequest.create(path); - mPutDataMapRequest.getDataMap().putLong("Timestamp", System.currentTimeMillis()); + mPutDataMapRequest.getDataMap().putLong(TIMESTAMP, System.currentTimeMillis()); mPutDataMapRequest.getDataMap().putStringArray(PREFERENCES_KEY, configToSend); mPutDataMapRequest.getDataMap().putBoolean(CONFIG_REQUEST_KEY, false); mPutDataMapRequest.getDataMap().putBoolean(CONFIG_REQUEST_KEY2, true); @@ -1287,6 +1292,23 @@ public void run() { } }, 5000); } + boolean ping = mDataMapItem.getDataMap().getBoolean(PING_FIRE); + if(ping){ + final PutDataMapRequest mPutDataMapRequest = PutDataMapRequest.create(path); + mPutDataMapRequest.getDataMap().putLong(TIMESTAMP, System.currentTimeMillis()); + mPutDataMapRequest.getDataMap().putBoolean(PING_FIRE, false); + mPutDataMapRequest.getDataMap().putBoolean(PING_ICE, true); + mPutDataMapRequest.setUrgent(); + PutDataRequest mPutDataRequest = mPutDataMapRequest.asPutDataRequest(); + Wearable.getDataClient(getApplicationContext()).putDataItem(mPutDataRequest); + final Handler handler = new Handler(); + handler.postDelayed(new Runnable() { + @Override + public void run() { + mPutDataMapRequest.getDataMap().clear(); + } + }, 5000); + } } } } diff --git a/phone/src/main/java/com/layoutxml/twelveish/Communicator.java b/phone/src/main/java/com/layoutxml/twelveish/Communicator.java index e197cf9..de4c452 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/Communicator.java +++ b/phone/src/main/java/com/layoutxml/twelveish/Communicator.java @@ -39,6 +39,11 @@ public class Communicator implements DataClient.OnDataChangedListener { private final String PREFERENCES_KEY = "rokas-twelveish-pr"; private final String CONFIG_REQUEST_KEY = "rokas-twelveish-cr"; private final String CONFIG_REQUEST_KEY2 = "rokas-twelveish-cr2"; + + private final String PING_FIRE = "rokas-twelveish-fire"; // Request ping + private final String PING_ICE = "rokas-twelveish-ice"; // Ping response + private final String TIMESTAMP = "rokas-twelveish-timestamp"; + private PutDataMapRequest mPutDataMapRequest; private Context applicationContext; private boolean currentStatus = true; //temporary value for waiting period if watch not found to not create false negatives @@ -47,6 +52,8 @@ public class Communicator implements DataClient.OnDataChangedListener { private static final String TAG = "Communicator"; private WeakReference previewListener; private WeakReference preferenceListener; + private long lastPing = 0; + @Inject public Communicator(Context context) { @@ -105,6 +112,21 @@ public void run() { } } + public void ping(){ + mPutDataMapRequest.getDataMap().putBoolean(PING_FIRE, true); + mPutDataMapRequest.getDataMap().putLong(TIMESTAMP, System.currentTimeMillis()); + mPutDataMapRequest.setUrgent(); + final PutDataRequest mPutDataRequest = mPutDataMapRequest.asPutDataRequest(); + Wearable.getDataClient(applicationContext).putDataItem(mPutDataRequest); + final Handler handler = new Handler(); + handler.postDelayed(new Runnable() { + @Override + public void run() { + mPutDataMapRequest.getDataMap().clear(); + } + }, 5000); + } + public void sendPreference(String key, String value, String type, Context context) { String[] array = new String[3]; array[0] = key; @@ -229,11 +251,31 @@ public void onDataChanged(@NonNull DataEventBuffer dataEventBuffer) { boolean goodbye = mDataMapItem.getDataMap().getBoolean(GOODBYE_KEY); boolean config = mDataMapItem.getDataMap().getBoolean(CONFIG_REQUEST_KEY2); boolean preferences = mDataMapItem.getDataMap().getBoolean(DATA_REQUEST_KEY2); + boolean ping = mDataMapItem.getDataMap().getBoolean(PING_ICE); if (handshake) { Log.d(TAG,"handshake received"); setCurrentStatus(true); if (!isWatchConnected) { Toast.makeText(applicationContext, "Watch connected", Toast.LENGTH_SHORT).show(); + lastPing = mDataMapItem.getDataMap().getLong(TIMESTAMP); + final Handler pingHandler = new Handler(){}; + pingHandler.postDelayed(new Runnable() { + @Override + public void run() { + if(isWatchConnected) { + ping(); + Long timeSincePing = System.currentTimeMillis() - lastPing; + if(timeSincePing > 15000){ + Toast.makeText(applicationContext, "Watch disconnected, retrying", Toast.LENGTH_SHORT).show(); + isWatchConnected = false; + initiateHandshake(); + lastPing = 0; + } + pingHandler.postDelayed(this, 5000); + } + + } + }, 5000); } isWatchConnected = true; } @@ -241,6 +283,7 @@ public void onDataChanged(@NonNull DataEventBuffer dataEventBuffer) { Toast.makeText(applicationContext, "Watch disconnected", Toast.LENGTH_SHORT).show(); isWatchConnected=false; initiateHandshake(); + lastPing = 0; } if(preferences){ @@ -298,6 +341,10 @@ public void onDataChanged(@NonNull DataEventBuffer dataEventBuffer) { } } } + + if(ping){ + lastPing = mPutDataMapRequest.getDataMap().getLong(TIMESTAMP); + } } } } From b39206f24f3bc0943c7364a820ad31dc23bc2d84 Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Wed, 27 Jan 2021 19:02:39 +0100 Subject: [PATCH 24/39] Fix Communicator.requestBooleanPreferences to Communicator.requestPreferences --- phone/src/main/java/com/layoutxml/twelveish/Communicator.java | 2 +- .../java/com/layoutxml/twelveish/objects/WatchPreviewView.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phone/src/main/java/com/layoutxml/twelveish/Communicator.java b/phone/src/main/java/com/layoutxml/twelveish/Communicator.java index de4c452..0f4611b 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/Communicator.java +++ b/phone/src/main/java/com/layoutxml/twelveish/Communicator.java @@ -203,7 +203,7 @@ public void run() { } - public void requestBooleanPreferences(Context context, WeakReference listenerActivity) { + public void requestPreferences(Context context, WeakReference listenerActivity) { mPutDataMapRequest.getDataMap().putLong("Timestamp", System.currentTimeMillis()); mPutDataMapRequest.getDataMap().putBoolean(DATA_REQUEST_KEY, true); mPutDataMapRequest.setUrgent(); diff --git a/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java b/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java index c13e4ca..91af707 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java +++ b/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java @@ -93,7 +93,7 @@ public WatchPreviewView(Context context, @Nullable AttributeSet attrs) { settingsManager = settingsManagerComponent.getSettingsManager(); HomeScreen activity = (HomeScreen) getContext(); communicator = ((App) activity.getApplication()).getCommunicatorComponent().getCommunicator(); - communicator.requestBooleanPreferences(getContext(), new WeakReference(this)); + communicator.requestPreferences(getContext(), new WeakReference(this)); Log.d(TAG, "WatchPreviewView: from home screen"); Log.d(TAG, "communicatorID: " + communicator); } From 827e45dff00cb82491240a3b05236d3c203abdaf Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Sat, 30 Jan 2021 14:30:17 +0100 Subject: [PATCH 25/39] Add switches for toggling showing complications --- .../twelveish/fragments/ComplicationSettingsFragment.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phone/src/main/java/com/layoutxml/twelveish/fragments/ComplicationSettingsFragment.java b/phone/src/main/java/com/layoutxml/twelveish/fragments/ComplicationSettingsFragment.java index 6110d4b..4bae069 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/fragments/ComplicationSettingsFragment.java +++ b/phone/src/main/java/com/layoutxml/twelveish/fragments/ComplicationSettingsFragment.java @@ -46,6 +46,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c List> optionsBO = new ArrayList<>(); optionsBO.add(new Pair("Disable complication tap actions",getString(R.string.preference_tap_complications))); + optionsBO.add(new Pair("Show complications", getResources().getString(R.string.preference_show_complications))); + optionsBO.add(new Pair("Show complications in ambient", getResources().getString(R.string.preference_show_complications_ambient))); RecyclerView recyclerViewSC = view.findViewById(R.id.setComplicationsRV); recyclerViewSC.setLayoutManager(new LinearLayoutManager(getContext())); From 72d67f16215aa530b83a6fc738fc9e30d5dff028 Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Sun, 31 Jan 2021 14:20:46 +0100 Subject: [PATCH 26/39] Implement picking font for secondary text --- .../twelveish/objects/WatchPreviewView.java | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java b/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java index 91af707..9cdd8bb 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java +++ b/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java @@ -114,7 +114,7 @@ public WatchPreviewView(Context context, @Nullable AttributeSet attrs) { mTextPaint.setTextSize(22 + secondaryTextOffset); //secondary text mTextPaint2.setTextSize(24 + mainTextOffset); - getFont(); + mTextPaint2.setTypeface(getFont(settingsManager.stringHashmap.get(getResources().getString(R.string.preference_font)))); generateAffixes(); // Fetch the prefixes and suffixes for the chosen language @@ -279,7 +279,7 @@ protected void onDraw(Canvas canvas) { if(!oldLanguage.equals(settingsManager.stringHashmap.get(activity.getString(R.string.preference_language)))) // The language has been changed, update our prefixes and suffixes generateAffixes(); - getFont(); + mTextPaint.setTypeface(getFont(settingsManager.stringHashmap.get(getResources().getString(R.string.preference_font_secondary)))); // Update the size offsets mainTextOffset = settingsManager.integerHashmap.get(getResources().getString(R.string.main_text_size_offset)); @@ -325,6 +325,8 @@ protected void onDraw(Canvas canvas) { : String.format(Locale.UK, "%d:%02d:%02d" + ampmSymbols, hourDigital, minutes, seconds); //Draw digital clock, date, battery percentage and day of the week + + mTextPaint.setTypeface(getFont(settingsManager.stringHashmap.get(getResources().getString(R.string.preference_font_secondary)))); // Set the font for our digital clock. float firstSeparator = 60.0f; if ((mAmbient && !settingsManager.booleanHashmap.get(getContext().getString(R.string.preference_show_digital_clock_ambient))) || (!mAmbient && !settingsManager.booleanHashmap.get(getContext().getString(R.string.preference_show_digital_clock)))) { text = ""; @@ -383,6 +385,7 @@ protected void onDraw(Canvas canvas) { //Draw text clock if (significantTimeChange) { + mTextPaint2.setTypeface(getFont(settingsManager.stringHashmap.get(getResources().getString(R.string.preference_font)))); mTextPaint.setTextSize(getHeight() * 0.06f + secondaryTextOffset); //secondary text getDate(); lastSignificantMinutes = minutes; @@ -428,58 +431,60 @@ else if (hourText > 12 && !settingsManager.booleanHashmap.get(getContext().getSt //TODO placeholder } - private void getFont(){ + private Typeface getFont(String newFont){ Typeface NORMAL_TYPEFACE2; - switch (settingsManager.stringHashmap.get(activity.getString(R.string.preference_font))) { + switch (newFont) { case "robotolight": NORMAL_TYPEFACE2 = Typeface.create("sans-serif-light", Typeface.NORMAL); - mTextPaint2.setTypeface(NORMAL_TYPEFACE2); + // mTextPaint2.setTypeface(NORMAL_TYPEFACE2); break; case "alegreya": NORMAL_TYPEFACE2 = ResourcesCompat.getFont(activity, R.font.alegreya); - mTextPaint2.setTypeface(NORMAL_TYPEFACE2); + // mTextPaint2.setTypeface(NORMAL_TYPEFACE2); break; case "cabin": NORMAL_TYPEFACE2 = ResourcesCompat.getFont(activity, R.font.cabin); - mTextPaint2.setTypeface(NORMAL_TYPEFACE2); + // mTextPaint2.setTypeface(NORMAL_TYPEFACE2); break; case "ibmplexsans": NORMAL_TYPEFACE2 = ResourcesCompat.getFont(activity, R.font.ibmplexsans); - mTextPaint2.setTypeface(NORMAL_TYPEFACE2); + // mTextPaint2.setTypeface(NORMAL_TYPEFACE2); break; case "inconsolata": NORMAL_TYPEFACE2 = ResourcesCompat.getFont(activity, R.font.inconsolata); - mTextPaint2.setTypeface(NORMAL_TYPEFACE2); + // mTextPaint2.setTypeface(NORMAL_TYPEFACE2); break; case "merriweather": NORMAL_TYPEFACE2 = ResourcesCompat.getFont(activity, R.font.merriweather); - mTextPaint2.setTypeface(NORMAL_TYPEFACE2); + // mTextPaint2.setTypeface(NORMAL_TYPEFACE2); break; case "nunito": NORMAL_TYPEFACE2 = ResourcesCompat.getFont(activity, R.font.nunito); - mTextPaint2.setTypeface(NORMAL_TYPEFACE2); + // mTextPaint2.setTypeface(NORMAL_TYPEFACE2); break; case "pacifico": NORMAL_TYPEFACE2 = ResourcesCompat.getFont(activity, R.font.pacifico); - mTextPaint2.setTypeface(NORMAL_TYPEFACE2); + // mTextPaint2.setTypeface(NORMAL_TYPEFACE2); break; case "quattrocento": NORMAL_TYPEFACE2 = ResourcesCompat.getFont(activity, R.font.quattrocento); - mTextPaint2.setTypeface(NORMAL_TYPEFACE2); + // mTextPaint2.setTypeface(NORMAL_TYPEFACE2); break; case "quicksand": NORMAL_TYPEFACE2 = ResourcesCompat.getFont(activity, R.font.quicksand); - mTextPaint2.setTypeface(NORMAL_TYPEFACE2); + // mTextPaint2.setTypeface(NORMAL_TYPEFACE2); break; case "rubik": NORMAL_TYPEFACE2 = ResourcesCompat.getFont(activity, R.font.rubik); - mTextPaint2.setTypeface(NORMAL_TYPEFACE2); + // mTextPaint2.setTypeface(NORMAL_TYPEFACE2); break; default: NORMAL_TYPEFACE2 = Typeface.create("sans-serif-light", Typeface.NORMAL); - mTextPaint2.setTypeface(NORMAL_TYPEFACE2); + // mTextPaint2.setTypeface(NORMAL_TYPEFACE2); break; } + + return NORMAL_TYPEFACE2; } private void getDate() { From da2559b509fdd134df9a607581553a9263937f75 Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Sun, 31 Jan 2021 14:21:08 +0100 Subject: [PATCH 27/39] Fix tablayout centering --- phone/src/main/res/layout/customize_screen.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phone/src/main/res/layout/customize_screen.xml b/phone/src/main/res/layout/customize_screen.xml index a910206..03238fb 100644 --- a/phone/src/main/res/layout/customize_screen.xml +++ b/phone/src/main/res/layout/customize_screen.xml @@ -72,12 +72,13 @@ From 4b1864eb76871ead70d3da84e435d44f4e002c10 Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Mon, 1 Feb 2021 00:13:39 +0100 Subject: [PATCH 28/39] Cleanup setting typeface of watch preview --- .../com/layoutxml/twelveish/objects/WatchPreviewView.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java b/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java index 9cdd8bb..82226e6 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java +++ b/phone/src/main/java/com/layoutxml/twelveish/objects/WatchPreviewView.java @@ -99,12 +99,12 @@ public WatchPreviewView(Context context, @Nullable AttributeSet attrs) { } mTextPaint = new Paint(); - mTextPaint.setTypeface(NORMAL_TYPEFACE); + mTextPaint.setTypeface(getFont(settingsManager.stringHashmap.get(getResources().getString(R.string.preference_font_secondary)))); mTextPaint.setAntiAlias(true); mTextPaint.setTextAlign(Paint.Align.CENTER); mTextPaint2 = new Paint(); - mTextPaint2.setTypeface(NORMAL_TYPEFACE); + mTextPaint2.setTypeface(getFont(settingsManager.stringHashmap.get(getResources().getString(R.string.preference_font)))); mTextPaint2.setAntiAlias(true); mTextPaint2.setTextAlign(Paint.Align.CENTER); @@ -114,7 +114,7 @@ public WatchPreviewView(Context context, @Nullable AttributeSet attrs) { mTextPaint.setTextSize(22 + secondaryTextOffset); //secondary text mTextPaint2.setTextSize(24 + mainTextOffset); - mTextPaint2.setTypeface(getFont(settingsManager.stringHashmap.get(getResources().getString(R.string.preference_font)))); + generateAffixes(); // Fetch the prefixes and suffixes for the chosen language From 9dac74cc807facd8294c6f146f7162730d8feec3 Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Mon, 1 Feb 2021 00:14:07 +0100 Subject: [PATCH 29/39] Cleanup some XML tags --- app/src/main/res/layout/about_screen.xml | 2 +- app/src/main/res/layout/font_size_info_activity.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/layout/about_screen.xml b/app/src/main/res/layout/about_screen.xml index 7375976..4eca984 100644 --- a/app/src/main/res/layout/about_screen.xml +++ b/app/src/main/res/layout/about_screen.xml @@ -8,7 +8,7 @@ + android:boxedEdges="all"> + android:boxedEdges="all"> Date: Mon, 1 Feb 2021 00:45:48 +0100 Subject: [PATCH 30/39] Remove options to start complication config activities (temporary) --- .../fragments/ComplicationSettingsFragment.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/phone/src/main/java/com/layoutxml/twelveish/fragments/ComplicationSettingsFragment.java b/phone/src/main/java/com/layoutxml/twelveish/fragments/ComplicationSettingsFragment.java index 4bae069..d2618f1 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/fragments/ComplicationSettingsFragment.java +++ b/phone/src/main/java/com/layoutxml/twelveish/fragments/ComplicationSettingsFragment.java @@ -39,21 +39,22 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c activity = (CustomizationScreen) getContext(); settingsManager = activity.getSettingsManagerComponent().getSettingsManager(); - List> optionsSC = new ArrayList>(); + // Commented out until implemented + /*List> optionsSC = new ArrayList>(); optionsSC.add(new Pair("Left Complication","Click to launch menu on your watch")); optionsSC.add(new Pair("Right Complication","Click to launch menu on your watch")); - optionsSC.add(new Pair("Bottom Complication","Click to launch menu on your watch")); + optionsSC.add(new Pair("Bottom Complication","Click to launch menu on your watch"));*/ List> optionsBO = new ArrayList<>(); optionsBO.add(new Pair("Disable complication tap actions",getString(R.string.preference_tap_complications))); optionsBO.add(new Pair("Show complications", getResources().getString(R.string.preference_show_complications))); optionsBO.add(new Pair("Show complications in ambient", getResources().getString(R.string.preference_show_complications_ambient))); - RecyclerView recyclerViewSC = view.findViewById(R.id.setComplicationsRV); + /*RecyclerView recyclerViewSC = view.findViewById(R.id.setComplicationsRV); recyclerViewSC.setLayoutManager(new LinearLayoutManager(getContext())); adapterSC = new TextviewRecyclerViewAdapter(getContext(),optionsSC, complicationSCName); adapterSC.setClickListener(this); - recyclerViewSC.setAdapter(adapterSC); + recyclerViewSC.setAdapter(adapterSC);*/ RecyclerView recyclerViewBO = view.findViewById(R.id.complicationsSwitchRV); recyclerViewBO.setLayoutManager(new LinearLayoutManager(getContext())); From 6c7f9c1a4d227b289d656bcdc7deacb4e00e719c Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Sun, 7 Feb 2021 21:03:02 +0100 Subject: [PATCH 31/39] Remove unused variables in TextSelectionActivity --- .../layoutxml/twelveish/activities/TextSelectionActivity.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/phone/src/main/java/com/layoutxml/twelveish/activities/TextSelectionActivity.java b/phone/src/main/java/com/layoutxml/twelveish/activities/TextSelectionActivity.java index 37e3659..17bfffc 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/activities/TextSelectionActivity.java +++ b/phone/src/main/java/com/layoutxml/twelveish/activities/TextSelectionActivity.java @@ -26,14 +26,12 @@ public class TextSelectionActivity extends AppCompatActivity implements Textview private String settingsName = "languageSelectionList"; private String[] availableLanguages; private int settingType; - private SettingsManager settingsManager; public static int LANGUAGE_SELECTION = 0; public static int CAPITALIZATION = 1; public static int FONT_SELECTION = 2; public static int DATE_ORDER = 3; public static int SEPARATOR_SYMBOL = 4; - public static int TEXT_OFFSET = 5; @Override From 2bbb3030364b2f7688322ef228ef78a97f12fddc Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Sun, 7 Feb 2021 21:05:53 +0100 Subject: [PATCH 32/39] Remove option to choose font for top text, awaiting implementation on watch --- .../twelveish/fragments/TopSettingsFragment.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phone/src/main/java/com/layoutxml/twelveish/fragments/TopSettingsFragment.java b/phone/src/main/java/com/layoutxml/twelveish/fragments/TopSettingsFragment.java index 125f9ec..a23aba0 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/fragments/TopSettingsFragment.java +++ b/phone/src/main/java/com/layoutxml/twelveish/fragments/TopSettingsFragment.java @@ -51,7 +51,6 @@ public class TopSettingsFragment extends Fragment implements ImageRecyclerViewAd private final int reqFont = 2; private final int reqDateOrder = 3; private final int reqDateSymbol = 4; - private final int reqTextOffset = 5; @Nullable @Override @@ -122,7 +121,8 @@ private void generateTextOptions(){ int dateOrder = settingsManager.integerHashmap.get(getResources().getString(R.string.preference_date_order)); String[] dateOrderString = {"Month-Day-Year", "Day-Month-Year", "Year-Month-Day", "Year-Day-Month"}; - optionsTT.add(new Pair("Font","Currently set to "+settingsManager.stringHashmap.get(getResources().getString(R.string.preference_font_secondary)))); + // TODO: Implement font selection for the top text on the watch. + // optionsTT.add(new Pair("Font","Currently set to "+settingsManager.stringHashmap.get(getResources().getString(R.string.preference_font_secondary)))); optionsTT.add(new Pair("Date Order","Currently set to "+dateOrderString[dateOrder])); optionsTT.add(new Pair("Date Separator Symbol","Currently set to "+settingsManager.stringHashmap.get(getResources().getString(R.string.preference_date_separator)))); } @@ -144,8 +144,8 @@ public void onItemClickImage(View view, int position, Integer currentColor, Stri public void onItemClick(View view, int position, String name){ if(name.equals(settingsTTName)){ Intent intent = new Intent(getContext(), TextSelectionActivity.class); - intent.putExtra("SETTING_TYPE", position + 2); - startActivityForResult(intent,position + 2); + intent.putExtra("SETTING_TYPE", position + 3); + startActivityForResult(intent,position + 3); } } From 8319da83c25736f6192cc43c32ff61b131634acf Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Sun, 7 Feb 2021 21:20:05 +0100 Subject: [PATCH 33/39] Fix phone app thinking the watch is disconnected when it isn't --- app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java b/app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java index a4ef43b..64d6eee 100644 --- a/app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java +++ b/app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java @@ -763,7 +763,7 @@ public void onVisibilityChanged(boolean visible) { Wearable.getDataClient(getApplicationContext()).addListener(this); final PutDataMapRequest mPutDataMapRequest = PutDataMapRequest.create(path); - mPutDataMapRequest.getDataMap().putLong("Timestamp", System.currentTimeMillis()); + mPutDataMapRequest.getDataMap().putLong(TIMESTAMP, System.currentTimeMillis()); mPutDataMapRequest.getDataMap().putBoolean(HANDSHAKE_REQUEST, true); mPutDataMapRequest.setUrgent(); PutDataRequest mPutDataRequest = mPutDataMapRequest.asPutDataRequest(); @@ -1224,7 +1224,7 @@ private void processData(DataItem dataItem) { boolean handshake = mDataMapItem.getDataMap().getBoolean(HANDSHAKE_REQUEST); if (handshake) { final PutDataMapRequest mPutDataMapRequest = PutDataMapRequest.create(path); - mPutDataMapRequest.getDataMap().putLong("Timestamp", System.currentTimeMillis()); + mPutDataMapRequest.getDataMap().putLong(TIMESTAMP, System.currentTimeMillis()); mPutDataMapRequest.getDataMap().putBoolean(HANDSHAKE_RESPONSE, true); mPutDataMapRequest.setUrgent(); PutDataRequest mPutDataRequest = mPutDataMapRequest.asPutDataRequest(); From 813e8e5b7f06ce0c4988f79a71723f9460fc737e Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Sun, 7 Feb 2021 21:26:22 +0100 Subject: [PATCH 34/39] Fix wrong namespace in layout files. Undoes 9dac74cc807facd8294c6f146f7162730d8feec3 --- app/src/main/res/layout/about_screen.xml | 2 +- app/src/main/res/layout/font_size_info_activity.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/layout/about_screen.xml b/app/src/main/res/layout/about_screen.xml index 4eca984..7375976 100644 --- a/app/src/main/res/layout/about_screen.xml +++ b/app/src/main/res/layout/about_screen.xml @@ -8,7 +8,7 @@ + app:boxedEdges="all"> + app:boxedEdges="all"> Date: Sun, 7 Feb 2021 21:48:56 +0100 Subject: [PATCH 35/39] Change text on home screen button to better reflect what it does --- phone/src/main/res/layout/home_screen.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phone/src/main/res/layout/home_screen.xml b/phone/src/main/res/layout/home_screen.xml index 597eea9..4a14dd0 100644 --- a/phone/src/main/res/layout/home_screen.xml +++ b/phone/src/main/res/layout/home_screen.xml @@ -28,7 +28,7 @@ android:layout_marginStart="16dp" android:layout_marginEnd="16dp" android:layout_marginBottom="32dp" - android:text="New" + android:text="Edit" app:layout_constraintBottom_toTopOf="@+id/buttonInstall" app:layout_constraintEnd_toStartOf="@+id/guideline" app:layout_constraintStart_toStartOf="parent" From a538fc21123309e445ee1c4483f2364437c23d71 Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Sun, 7 Feb 2021 22:41:19 +0100 Subject: [PATCH 36/39] Add try/catch around Integer parsing when receiving preferences from companion app --- .../main/java/com/layoutxml/twelveish/MyWatchFace.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java b/app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java index 64d6eee..fd881b0 100644 --- a/app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java +++ b/app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java @@ -1199,8 +1199,12 @@ private void processData(DataItem dataItem) { prefs.edit().putString(array[i], array[i+1]).apply(); break; case "Integer": - int newPref = Integer.parseInt(array[i+1]); - prefs.edit().putInt(array[i], newPref).apply(); + try { + int newPref = Integer.parseInt(array[1]); + prefs.edit().putInt(array[i],newPref).apply(); + } catch (NumberFormatException e) { + Toast.makeText(getApplicationContext(), "Preference error", Toast.LENGTH_SHORT).show(); + } break; case "Boolean": if (array[i + 1].equalsIgnoreCase("true") || array[i+1].equalsIgnoreCase("false")){ From 083cf35a08d644b6740cc3dbfb559b674840cf07 Mon Sep 17 00:00:00 2001 From: Lars Erik Date: Wed, 10 Feb 2021 21:49:35 +0100 Subject: [PATCH 37/39] Fix german noun capitalisation not working with "First word title case" capitalisation --- app/src/main/java/com/layoutxml/twelveish/WordClockTask.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/layoutxml/twelveish/WordClockTask.java b/app/src/main/java/com/layoutxml/twelveish/WordClockTask.java index 976594b..49e224f 100644 --- a/app/src/main/java/com/layoutxml/twelveish/WordClockTask.java +++ b/app/src/main/java/com/layoutxml/twelveish/WordClockTask.java @@ -526,7 +526,7 @@ private String capitalise3(int hours, int minutes, int index) { + middle + ((minutes > 0) ? (SuffixNewLine[index] ? "\n" : "") : "") + ((showSuffixes) ? ((minutes > 0) ? Suffixes[index] : "") : ""); - return text20.substring(0, 1).toUpperCase() + text20.substring(1).toLowerCase(); + return text20.substring(0, 1).toUpperCase() + text20.substring(1); } else { String text20 = ((minutes > 0) ? Prefixes[index] : "") @@ -534,7 +534,7 @@ private String capitalise3(int hours, int minutes, int index) { + middle + ((minutes > 0) ? (SuffixNewLine[index] ? " " : "") : "") + ((showSuffixes) ? ((minutes > 0) ? Suffixes[index] : "") : ""); - return arrangeWords(text20.substring(0, 1).toUpperCase() + text20.substring(1).toLowerCase()); + return arrangeWords(text20.substring(0, 1).toUpperCase() + text20.substring(1)); } } From f955e03367c27f9808e53559c3eedc3260ce3703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Hel=C3=B8?= Date: Fri, 12 Feb 2021 23:26:19 +0100 Subject: [PATCH 38/39] Fix capitalisation of nouns in german prefixes in the phone app preview --- .../layoutxml/twelveish/WordClockTask.java | 40 ++++++++++++++++--- phone/src/main/res/values/strings.xml | 12 +++--- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/phone/src/main/java/com/layoutxml/twelveish/WordClockTask.java b/phone/src/main/java/com/layoutxml/twelveish/WordClockTask.java index a1cfe23..bb18cd7 100644 --- a/phone/src/main/java/com/layoutxml/twelveish/WordClockTask.java +++ b/phone/src/main/java/com/layoutxml/twelveish/WordClockTask.java @@ -368,7 +368,22 @@ private String capitalise0(int hours, int minutes, int index) { String mainPrefix = ""; StringBuilder prefix; if ((minutes > 0) && (!Prefixes[index].equals("")) && (Prefixes[index] != null)) { - String[] prefixArray = Prefixes[index].split(" "); + + // Split the prefix with non-break spaces and capitalise each word + StringBuilder preString = new StringBuilder(); + String[] preArray = Prefixes[index].split("\\u00A0"); + + for (String word : preArray){ + if(preString.length() != 0) + preString.append("\u00A0"); + + String capitalised = word.substring(0,1).toUpperCase() + word.substring(1); + preString.append(capitalised); + } + + // Do the same with spaces + + String[] prefixArray = preString.toString().split(" "); prefix = new StringBuilder(); for (String word : prefixArray) { if (prefix.length() != 0) @@ -402,8 +417,21 @@ private String capitalise0(int hours, int minutes, int index) { if (showSuffixes) { StringBuilder suffix; if ((minutes > 0) && (!Suffixes[index].equals("")) && (Suffixes[index] != null)) { + + // Split the prefix with non-break spaces and capitalise each word + StringBuilder suffString = new StringBuilder(); + String[] suffArray = Prefixes[index].split("\\u00A0"); + + for (String word : suffArray){ + if(suffString.length() != 0) // No suffix has more than two parts separated by a non-break space + suffString.append("\u00A0"); + + String capitalised = word.substring(0,1).toUpperCase() + word.substring(1); + suffString.append(capitalised); + } + if (SuffixNewLine[index]) { - String[] suffixArray = Suffixes[index].split(" "); + String[] suffixArray = suffString.toString().split(" "); suffix = new StringBuilder(); for (String word : suffixArray) { if (suffix.length() != 0) @@ -413,7 +441,7 @@ private String capitalise0(int hours, int minutes, int index) { } mainSuffix = suffix.toString(); } else { - mainSuffix = Suffixes[index].toLowerCase(); + mainSuffix = suffString.toString().toLowerCase(); } } } @@ -477,7 +505,7 @@ private String capitalise2(int hours, int minutes, int index) { + middle + ((minutes > 0) ? (SuffixNewLine[index] ? " " : "") : "") + ((showSuffixes) ? ((minutes > 0) ? Suffixes[index] : "") : ""); - return arrangeWords(text); + return arrangeWords(text).toLowerCase(); } } @@ -497,7 +525,7 @@ private String capitalise3(int hours, int minutes, int index) { + middle + ((minutes > 0) ? (SuffixNewLine[index] ? "\n" : "") : "") + ((showSuffixes) ? ((minutes > 0) ? Suffixes[index] : "") : ""); - return text20.substring(0, 1).toUpperCase() + text20.substring(1).toLowerCase(); + return text20.substring(0, 1).toUpperCase() + text20.substring(1); } else { String text20 = ((minutes > 0) ? Prefixes[index] : "") @@ -505,7 +533,7 @@ private String capitalise3(int hours, int minutes, int index) { + middle + ((minutes > 0) ? (SuffixNewLine[index] ? " " : "") : "") + ((showSuffixes) ? ((minutes > 0) ? Suffixes[index] : "") : ""); - return arrangeWords(text20.substring(0, 1).toUpperCase() + text20.substring(1).toLowerCase()); + return arrangeWords(text20.substring(0, 1).toUpperCase() + text20.substring(1)); } } diff --git a/phone/src/main/res/values/strings.xml b/phone/src/main/res/values/strings.xml index b2d9be7..0da488a 100644 --- a/phone/src/main/res/values/strings.xml +++ b/phone/src/main/res/values/strings.xml @@ -347,15 +347,15 @@ kurz nach - bald viertel\u00A0nach - fast viertel\u00A0nach - viertel\u00A0nach + bald Viertel\u00A0nach + fast Viertel\u00A0nach + Viertel\u00A0nach bald halb kurz vor halb kurz nach halb - bald viertel\u00A0vor - fast viertel\u00A0vor - viertel\u00A0vor + bald Viertel\u00A0vor + fast Viertel\u00A0vor + Viertel\u00A0vor bald fast From 8a9d1a8a07ffec1f3a99dc802d7a2c600b25d3e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Hel=C3=B8?= Date: Fri, 12 Feb 2021 23:29:49 +0100 Subject: [PATCH 39/39] Update version code and name to 358 and 2.4.0 --- app/build.gradle | 4 ++-- phone/build.gradle | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 1cec47b..47e1330 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,8 +6,8 @@ android { applicationId "com.layoutxml.twelveish" minSdkVersion 23 targetSdkVersion 29 - versionCode 267 - versionName "2.3.2" + versionCode 358 + versionName "2.4.0" multiDexEnabled true } buildTypes { diff --git a/phone/build.gradle b/phone/build.gradle index ac4b8d6..0a60234 100644 --- a/phone/build.gradle +++ b/phone/build.gradle @@ -13,8 +13,8 @@ android { applicationId "com.layoutxml.twelveish" minSdkVersion 21 targetSdkVersion 29 - versionCode 266 - versionName "2.3.2" + versionCode 357 + versionName "2.4.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"