From: Nathaniel Wesley Filardo Date: Sat, 21 Oct 2017 04:48:31 +0000 (-0400) Subject: Tidying X-Git-Tag: release-1.2~31 X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=3b228767afbbf3334232b97999ee5be32ef8214e;p=acmetensortoys-ctfws-android Tidying --- diff --git a/lib/src/main/java/com/acmetensortoys/ctfwstimer/lib/CtFwSGameState.java b/lib/src/main/java/com/acmetensortoys/ctfwstimer/lib/CtFwSGameState.java index c83b38d..e052cb0 100644 --- a/lib/src/main/java/com/acmetensortoys/ctfwstimer/lib/CtFwSGameState.java +++ b/lib/src/main/java/com/acmetensortoys/ctfwstimer/lib/CtFwSGameState.java @@ -22,14 +22,13 @@ public class CtFwSGameState { } // Game time - private boolean configured = false; - private long startT; // NTP seconds for game start + private long startT; // POSIX seconds for game start private int setupD; private int rounds; private int roundD; private int gameIx; - private long endT = 0; // NTP seconds for game end (if >= startT) + private long endT = 0; // POSIX seconds for game end (if >= startT) public void fromMqttConfigMessage(String st) { String tm = st.trim(); @@ -131,12 +130,10 @@ public class CtFwSGameState { } // Game score - public int flagsTotal; public boolean flagsVisible = false; public int flagsRed = 0; public int flagsYel = 0; - public void fromMqttFlagsMessage(String st) { String tm = st.trim(); switch(tm) { @@ -166,7 +163,6 @@ public class CtFwSGameState { } // Informative messages handling - public class Msg { public final long when; public final String msg; @@ -178,7 +174,6 @@ public class CtFwSGameState { } private final List msgs = new ArrayList<>(); private long lastMsgTimestamp; - public void onNewMessage(String str) { Scanner s = new Scanner(str); long t; @@ -205,7 +200,6 @@ public class CtFwSGameState { } // Observer interface - public interface Observer { // Called when the game configuration parameters change void onCtFwSConfigure(CtFwSGameState game); diff --git a/mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainService.java b/mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainService.java index 970aab5..6252a24 100644 --- a/mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainService.java +++ b/mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainService.java @@ -96,17 +96,17 @@ public class MainService extends Service { @Override public void connectComplete(boolean reconnect, String serverURI) { Log.d("CtFwS", "Conn OK 2 srv=" + serverURI + " reconn=" + reconnect); + String p = "ctfws/game/"; try { - String p = "ctfws/game/"; - mMqc.subscribe(p+"config" , 2, null, subal, mCtfwscbs.onConfig); - mMqc.subscribe(p+"endtime" , 2, null, subal, mCtfwscbs.onEnd); - mMqc.subscribe(p+"flags" , 2, null, subal, mCtfwscbs.onFlags); - mMqc.subscribe(p+"message" , 2, null, subal, mCtfwscbs.onMessage); - mMqc.subscribe(p+"message/player", 2, null, subal, mCtfwscbs.onPlayerMessage); - setMSE(MqttServerEvent.MSE_SUB); + mMqc.subscribe(p + "config", 2, null, subal, mCtfwscbs.onConfig); + mMqc.subscribe(p + "endtime", 2, null, subal, mCtfwscbs.onEnd); + mMqc.subscribe(p + "flags", 2, null, subal, mCtfwscbs.onFlags); + mMqc.subscribe(p + "message", 2, null, subal, mCtfwscbs.onMessage); + mMqc.subscribe(p + "message/player", 2, null, subal, mCtfwscbs.onPlayerMessage); } catch (MqttException e) { Log.e("CtFwS", "Exn Sub", e); } + setMSE(MqttServerEvent.MSE_SUB); } @Override @@ -209,16 +209,16 @@ public class MainService extends Service { // Ahem. Now then. Connect with *more callbacks*, which will fire off our // subscription requests, which of course have *yet more* callbacks, which // react to messages sent to us. Have we lost the thread yet? + MqttConnectOptions mco = new MqttConnectOptions(); + mco.setCleanSession(true); + mco.setAutomaticReconnect(true); + mco.setKeepAliveInterval(180); // seconds try { - MqttConnectOptions mco = new MqttConnectOptions(); - mco.setCleanSession(true); - mco.setAutomaticReconnect(true); - mco.setKeepAliveInterval(180); // seconds mMqc.connect(mco, null, mqttal); - Log.d("Service", "Connect dispatched"); } catch (MqttException e) { Log.e("Service", "Conn Exn", e); } + Log.d("Service", "Connect dispatched"); } // Must hold strongly since Android only holds weakly once registered. diff --git a/mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainServiceNotification.java b/mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainServiceNotification.java index 047d6bb..c6a2872 100644 --- a/mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainServiceNotification.java +++ b/mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainServiceNotification.java @@ -5,7 +5,6 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; -import android.content.SharedPreferences; import android.content.res.Resources; import android.os.Build; import android.os.IBinder; diff --git a/wear/src/main/res/values/strings.xml b/wear/src/main/res/values/strings.xml index be6c0b7..e4eab0a 100644 --- a/wear/src/main/res/values/strings.xml +++ b/wear/src/main/res/values/strings.xml @@ -4,5 +4,4 @@ Game\nEnd Game\nStart Jailbreak\n%1$d of %2$d - %1$d Flags: