Skip to content
This repository has been archived by the owner on May 3, 2021. It is now read-only.

Functional phone app #23

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f76b09e
Twelveish-10 Wrong capitalization in the German prefixes
augustuen Dec 30, 2019
768a242
Capitalized Viertel in the german translation and de-capitalized hours.
augustuen Jan 3, 2021
d96de1c
Fixes #10
augustuen Jan 3, 2021
cfcfa86
Merge remote-tracking branch 'remotes/LayoutXML/master' into Twelveis…
augustuen Jan 3, 2021
6aca461
Reverted gitignore to LayoutXML version
augustuen Jan 3, 2021
7c3e750
Reverted gitignore to LayoutXML version
augustuen Jan 3, 2021
dfb4c8a
Fixes issue where some words weren't properly capitalized in Title Case.
augustuen Jan 4, 2021
27e1b85
-Fixed: an issue with word alignment caused by the previous commit.
augustuen Jan 5, 2021
81d5938
Sorted issues with Dagger that stopped the companion app from functio…
augustuen Jan 5, 2021
34c988a
Updated ViewAdapters to use getBindingAdapterPosition() instead of de…
augustuen Jan 12, 2021
fceaf04
Added activity to choose the watch face language
augustuen Jan 13, 2021
e04ef53
Added TextSelectionActivity to replace LanguageSelectionActivity, whi…
augustuen Jan 18, 2021
49c4e1c
Added setting for main and most top text settings. - Text offset rema…
augustuen Jan 18, 2021
29186d1
Added Seekbars for Text size offset for the main and secondary texts …
augustuen Jan 18, 2021
96075d2
Moved some code around and tweaked the text size offset.
augustuen Jan 19, 2021
a8c0aeb
Updated dependencies for wearable support.wearable libraries - This f…
augustuen Jan 19, 2021
7af79d1
Added saving/loading of a single watch face configuration
augustuen Jan 20, 2021
34b310e
Added feature to transfer all preferences to the wearable. - Still ne…
augustuen Jan 22, 2021
ae21528
Modified .gitignore - removes .idea/misc.xml and .idea/modules.xml
augustuen Jan 22, 2021
a532701
Updated .gitignore
augustuen Jan 22, 2021
c89cd18
Add loading watch preferences on startup
augustuen Jan 24, 2021
9d68375
Fix a bug where 24h text format wouldn't update from handheld
augustuen Jan 26, 2021
fde7977
Fix a bug where the watch would show as connected even if it wasn't
augustuen Jan 27, 2021
6483899
Add checking if the watch has suddenly disconnected
augustuen Jan 27, 2021
b39206f
Fix Communicator.requestBooleanPreferences to Communicator.requestPre…
augustuen Jan 27, 2021
827e45d
Add switches for toggling showing complications
augustuen Jan 30, 2021
72d67f1
Implement picking font for secondary text
augustuen Jan 31, 2021
da2559b
Fix tablayout centering
augustuen Jan 31, 2021
7223ebc
Merge branch 'communicatorTest' into Companion-app
augustuen Jan 31, 2021
4b1864e
Cleanup setting typeface of watch preview
augustuen Jan 31, 2021
9dac74c
Cleanup some XML tags
augustuen Jan 31, 2021
26a0c6a
Remove options to start complication config activities (temporary)
augustuen Jan 31, 2021
6c7f9c1
Remove unused variables in TextSelectionActivity
augustuen Feb 7, 2021
2bbb303
Remove option to choose font for top text, awaiting implementation on…
augustuen Feb 7, 2021
8319da8
Fix phone app thinking the watch is disconnected when it isn't
augustuen Feb 7, 2021
813e8e5
Fix wrong namespace in layout files. Undoes 9dac74cc807facd8294c6f146…
augustuen Feb 7, 2021
4d7f4d6
Change text on home screen button to better reflect what it does
augustuen Feb 7, 2021
a538fc2
Add try/catch around Integer parsing when receiving preferences from …
augustuen Feb 7, 2021
083cf35
Fix german noun capitalisation not working with "First word title cas…
augustuen Feb 10, 2021
7be9a65
Merge branch 'Twelveish-10' into Companion-app
augustuen Feb 10, 2021
f955e03
Fix capitalisation of nouns in german prefixes in the phone app preview
augustuen Feb 12, 2021
8a9d1a8
Update version code and name to 358 and 2.4.0
augustuen Feb 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ captures/
.idea/dictionaries
.idea/libraries
.idea/caches
.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.
Expand All @@ -65,4 +69,3 @@ fastlane/test_output
fastlane/readme.md
.idea/workspace.xml___jb_old___
.idea/misc.xml
.idea/misc.xml
48 changes: 0 additions & 48 deletions .idea/misc.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/modules.xml

This file was deleted.

8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"
}
127 changes: 79 additions & 48 deletions app/src/main/java/com/layoutxml/twelveish/MyWatchFace.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -70,13 +71,20 @@ 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";
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;
Expand Down Expand Up @@ -755,8 +763,8 @@ public void onVisibilityChanged(boolean visible) {
Wearable.getDataClient(getApplicationContext()).addListener(this);

final PutDataMapRequest mPutDataMapRequest = PutDataMapRequest.create(path);
mPutDataMapRequest.getDataMap().putLong("Timestamp", System.currentTimeMillis());
mPutDataMapRequest.getDataMap().putBoolean(HANDSHAKE_KEY, true);
mPutDataMapRequest.getDataMap().putLong(TIMESTAMP, System.currentTimeMillis());
mPutDataMapRequest.getDataMap().putBoolean(HANDSHAKE_REQUEST, true);
mPutDataMapRequest.setUrgent();
PutDataRequest mPutDataRequest = mPutDataMapRequest.asPutDataRequest();
Wearable.getDataClient(getApplicationContext()).putDataItem(mPutDataRequest);
Expand Down Expand Up @@ -1184,11 +1192,44 @@ private void processData(DataItem dataItem) {
getDate(); //forces date refresh in case it is changed
significantTimeChange = true;
}
boolean handshake = mDataMapItem.getDataMap().getBoolean(HANDSHAKE_KEY);
if (!handshake) {
if (array!=null && array.length > 3){ // We're receiving multiple preferences at once
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":
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")){
boolean newPref2 = Boolean.parseBoolean(array[i+1]);
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:
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_REQUEST);
if (handshake) {
final PutDataMapRequest mPutDataMapRequest = PutDataMapRequest.create(path);
mPutDataMapRequest.getDataMap().putLong("Timestamp", System.currentTimeMillis());
mPutDataMapRequest.getDataMap().putBoolean(HANDSHAKE_KEY, true);
mPutDataMapRequest.getDataMap().putLong(TIMESTAMP, System.currentTimeMillis());
mPutDataMapRequest.getDataMap().putBoolean(HANDSHAKE_RESPONSE, true);
mPutDataMapRequest.setUrgent();
PutDataRequest mPutDataRequest = mPutDataMapRequest.asPutDataRequest();
Wearable.getDataClient(getApplicationContext()).putDataItem(mPutDataRequest);
Expand All @@ -1202,48 +1243,21 @@ 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<String, ?> prefMap = prefs.getAll();
int index = 0;
String[] preferencesToSend = new String[prefMap.size() * 2];

for(Map.Entry<String, ?> 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());
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);
Expand All @@ -1267,7 +1281,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);
Expand All @@ -1282,6 +1296,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);
}
}
}
}
40 changes: 34 additions & 6 deletions app/src/main/java/com/layoutxml/twelveish/WordClockTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,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)
Expand Down Expand Up @@ -403,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)
Expand All @@ -414,7 +442,7 @@ private String capitalise0(int hours, int minutes, int index) {
}
mainSuffix = suffix.toString();
} else {
mainSuffix = Suffixes[index].toLowerCase();
mainSuffix = suffString.toString().toLowerCase();
}
}
}
Expand Down Expand Up @@ -478,7 +506,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();
}
}

Expand All @@ -498,15 +526,15 @@ 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] : "")
+ ((minutes > 0) ? (PrefixNewLine[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));
}
}

Expand Down
Loading