]> hydra-www.ietfng.org Git - acmetensortoys-ctfws-android/commitdiff
Refactor MainService to service directory
authorNathaniel Wesley Filardo <nwfilardo@gmail.com>
Sat, 28 Sep 2019 13:26:54 +0000 (14:26 +0100)
committerNathaniel Wesley Filardo <nwfilardo@gmail.com>
Sat, 28 Sep 2019 13:26:54 +0000 (14:26 +0100)
mobile/src/main/AndroidManifest.xml
mobile/src/main/java/com/acmetensortoys/ctfwstimer/service/CtFwSCallbacksMQTT.java [moved from mobile/src/main/java/com/acmetensortoys/ctfwstimer/CtFwSCallbacksMQTT.java with 98% similarity]
mobile/src/main/java/com/acmetensortoys/ctfwstimer/service/MainService.java [moved from mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainService.java with 96% similarity]
mobile/src/main/java/com/acmetensortoys/ctfwstimer/service/MainServiceNotification.java [moved from mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainServiceNotification.java with 98% similarity]

index 65c708f7276660b5cce19858b52154893a3719a5..6ec43155a1af2d352c03de330843b178b3689c62 100644 (file)
@@ -39,7 +39,7 @@
         <activity android:name=".activity.SettingsActivity" />
 
         <service
-            android:name=".MainService"
+            android:name=".service.MainService"
             android:enabled="true"
             android:exported="false" />
 
similarity index 96%
rename from mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainService.java
rename to mobile/src/main/java/com/acmetensortoys/ctfwstimer/service/MainService.java
index 6f0e61450bb1dfae62c7d2f7e38ddfab1d8275bd..a8f67a85ad391194af312af5c20391141a29827a 100644 (file)
@@ -1,4 +1,4 @@
-package com.acmetensortoys.ctfwstimer;
+package com.acmetensortoys.ctfwstimer.service;
 
 import android.app.Service;
 import android.content.Intent;
@@ -14,6 +14,8 @@ import android.util.Log;
 
 import com.acmetensortoys.ctfwstimer.lib.CtFwSGameStateManager;
 import com.acmetensortoys.ctfwstimer.lib.TimerProvider;
+import com.acmetensortoys.ctfwstimer.utils.CheckedAsyncDownloader;
+import com.acmetensortoys.ctfwstimer.utils.HandbookDownloader;
 
 import org.eclipse.paho.android.service.MqttAndroidClient;
 import org.eclipse.paho.android.service.MqttTraceHandler;
@@ -359,15 +361,15 @@ public class MainService extends Service {
     }
 
     public class LocalBinder extends Binder {
-        CtFwSGameStateManager getGameState() {
+        public CtFwSGameStateManager getGameState() {
             return mCgs;
         }
-        long getLastServerTimeDeltaEstimate() { return lastServerTimeDeltaEstimate; }
+        public long getLastServerTimeDeltaEstimate() { return lastServerTimeDeltaEstimate; }
 
         // It should not be necessary to call this except at the beginning or to force a reconnect;
         // most everything else you might want in a connect method is handled by the
         // OnSharedPreferenceChangeListener listener above.
-        void connect(boolean force) {
+        public void connect(boolean force) {
             if (force || mMSE != MqttServerEvent.MSE_SUB) {
                 SharedPreferences sp = PreferenceManager
                         .getDefaultSharedPreferences(MainService.this);
@@ -375,7 +377,7 @@ public class MainService extends Service {
                 doMqtt(sp.getString("server", null));
             }
         }
-        void registerObserver(Observer o) {
+        public void registerObserver(Observer o) {
             synchronized(MainService.this) {
                 if (mObsvs.add(o)) {
                     // Fire off synthetic deltas to bring the observer up to date.
@@ -389,10 +391,10 @@ public class MainService extends Service {
                 }
             }
         }
-        void unregisterObserver(Observer o) {
+        public void unregisterObserver(Observer o) {
             synchronized(MainService.this) { mObsvs.remove(o); }
         }
-        void exit() {
+        public void exit() {
             mMsn.ensureNoNotification(true);
         }
     }
@@ -401,6 +403,7 @@ public class MainService extends Service {
     @Override
     public IBinder onBind(Intent intent) {
         Log.d("Service", "onBind: " + intent);
+        mBinder.connect(false);
         return mBinder;
     }
 
similarity index 98%
rename from mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainServiceNotification.java
rename to mobile/src/main/java/com/acmetensortoys/ctfwstimer/service/MainServiceNotification.java
index be9c038d3a70369dfcf915d4ea1a9db3dbfdacde..5fbe85ab0551dce24525216f30f4ca916cd70d57 100644 (file)
@@ -1,4 +1,4 @@
-package com.acmetensortoys.ctfwstimer;
+package com.acmetensortoys.ctfwstimer.service;
 
 import android.app.Notification;
 import android.app.NotificationChannel;
@@ -17,6 +17,8 @@ import android.preference.PreferenceManager;
 import android.support.v4.app.NotificationCompat;
 import android.util.Log;
 
+import com.acmetensortoys.ctfwstimer.activity.MainActivity;
+import com.acmetensortoys.ctfwstimer.R;
 import com.acmetensortoys.ctfwstimer.lib.CtFwSGameStateManager;
 
 import java.text.NumberFormat;