From: Nathaniel Wesley Filardo Date: Sat, 28 Sep 2019 13:26:54 +0000 (+0100) Subject: Refactor MainService to service directory X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=0b1970143c4033851ef8771a101e76cc1c3ee6cd;p=acmetensortoys-ctfws-android Refactor MainService to service directory --- diff --git a/mobile/src/main/AndroidManifest.xml b/mobile/src/main/AndroidManifest.xml index 65c708f..6ec4315 100644 --- a/mobile/src/main/AndroidManifest.xml +++ b/mobile/src/main/AndroidManifest.xml @@ -39,7 +39,7 @@ diff --git a/mobile/src/main/java/com/acmetensortoys/ctfwstimer/CtFwSCallbacksMQTT.java b/mobile/src/main/java/com/acmetensortoys/ctfwstimer/service/CtFwSCallbacksMQTT.java similarity index 98% rename from mobile/src/main/java/com/acmetensortoys/ctfwstimer/CtFwSCallbacksMQTT.java rename to mobile/src/main/java/com/acmetensortoys/ctfwstimer/service/CtFwSCallbacksMQTT.java index ed53b71..2575199 100644 --- a/mobile/src/main/java/com/acmetensortoys/ctfwstimer/CtFwSCallbacksMQTT.java +++ b/mobile/src/main/java/com/acmetensortoys/ctfwstimer/service/CtFwSCallbacksMQTT.java @@ -1,4 +1,4 @@ -package com.acmetensortoys.ctfwstimer; +package com.acmetensortoys.ctfwstimer.service; import android.util.Log; diff --git a/mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainService.java b/mobile/src/main/java/com/acmetensortoys/ctfwstimer/service/MainService.java 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 6f0e614..a8f67a8 100644 --- a/mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainService.java +++ b/mobile/src/main/java/com/acmetensortoys/ctfwstimer/service/MainService.java @@ -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; } diff --git a/mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainServiceNotification.java b/mobile/src/main/java/com/acmetensortoys/ctfwstimer/service/MainServiceNotification.java 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 be9c038..5fbe85a 100644 --- a/mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainServiceNotification.java +++ b/mobile/src/main/java/com/acmetensortoys/ctfwstimer/service/MainServiceNotification.java @@ -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;