Skip to content

Commit

Permalink
Firebase+Pusher to allow remote control
Browse files Browse the repository at this point in the history
  • Loading branch information
obbimi committed Feb 7, 2022
1 parent b6e2f2f commit fefdc8e
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 39 deletions.
9 changes: 9 additions & 0 deletions AndroidManifestBadminton.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,14 @@
<!--<meta-data android:name="android.support.PARENT_ACTIVITY" android:value="com.doubleyellow.scoreboard.main.ScoreBoard" />-->
</activity>

<!--
If using pusher, and notifications even need to be received if app is in the background, we need a service
-->
<service android:name="com.doubleyellow.scoreboard.firebase.PusherMessagingService" android:enabled="true"
android:description="@string/FCM_Info">
<intent-filter android:priority="1">
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>
</manifest>
9 changes: 9 additions & 0 deletions AndroidManifestRacketlon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -189,5 +189,14 @@
<!--<meta-data android:name="android.support.PARENT_ACTIVITY" android:value="com.doubleyellow.scoreboard.main.ScoreBoard" />-->
</activity>

<!--
If using pusher, and notifications even need to be received if app is in the background, we need a service
-->
<service android:name="com.doubleyellow.scoreboard.firebase.PusherMessagingService" android:enabled="true"
android:description="@string/FCM_Info">
<intent-filter android:priority="1">
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>
</manifest>
9 changes: 9 additions & 0 deletions AndroidManifestSquore.xml
Original file line number Diff line number Diff line change
Expand Up @@ -286,5 +286,14 @@
<!--<meta-data android:name="android.support.PARENT_ACTIVITY" android:value="com.doubleyellow.scoreboard.main.ScoreBoard" />-->
</activity>

<!--
If using pusher, and notifications even need to be received if app is in the background, we need a service
-->
<service android:name="com.doubleyellow.scoreboard.firebase.PusherMessagingService" android:enabled="true"
android:description="@string/FCM_Info">
<intent-filter android:priority="1">
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>
</manifest>
9 changes: 9 additions & 0 deletions AndroidManifestTabletennis.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,14 @@
<!--<meta-data android:name="android.support.PARENT_ACTIVITY" android:value="com.doubleyellow.scoreboard.main.ScoreBoard" />-->
</activity>

<!--
If using pusher, and notifications even need to be received if app is in the background, we need a service
-->
<service android:name="com.doubleyellow.scoreboard.firebase.PusherMessagingService" android:enabled="true"
android:description="@string/FCM_Info">
<intent-filter android:priority="1">
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>
</manifest>
9 changes: 9 additions & 0 deletions AndroidManifestTennisPadel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,14 @@
<!--<meta-data android:name="android.support.PARENT_ACTIVITY" android:value="com.doubleyellow.scoreboard.main.ScoreBoard" />-->
</activity>

<!--
If using pusher, and notifications even need to be received if app is in the background, we need a service
-->
<service android:name="com.doubleyellow.scoreboard.firebase.PusherMessagingService" android:enabled="true"
android:description="@string/FCM_Info">
<intent-filter android:priority="1">
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>
</manifest>
16 changes: 9 additions & 7 deletions src/com/doubleyellow/scoreboard/Brand.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@

public enum Brand
{
Squore (SportType.Squash , R.string.app_name_short_brand__Squash , 0, 0/*R.drawable.brand_squore*/ , R.id.sb_branded_logo_ar150, R.color.brand_squore_bg_color , R.string.CUSTOM_RECEIVER_APP_ID_squore_fancy , R.array.colorSchema__Squash , 3000, "https://squore.double-yellow.be" , "8da78f9d-f7dd-437c-8b7d-d5bc231f92ec", R.raw.changelog),
//Tabletennis (SportType.Tabletennis, R.string.app_name_short_brand__Tabletennis , 0, 0/*R.drawable.brand_squore*/ , R.id.sb_branded_logo_ar150, R.color.brand_tabletennis_bg_color , R.string.CUSTOM_RECEIVER_APP_ID_tabletennis_fancy , R.array.colorSchema__Tabletennis , 3000, "https://tabletennis.double-yellow.be", "e35d8fcb-a7c0-4c2a-9c74-cc3f6e1e6a41", R.raw.changelog_tabletennis),
//Badminton (SportType.Badminton , R.string.app_name_short_brand__Badminton , 0, 0/*R.drawable.brand_squore*/ , R.id.sb_branded_logo_ar150, R.color.brand_badminton_bg_color , R.string.CUSTOM_RECEIVER_APP_ID_badminton_fancy , R.array.colorSchema__Badminton , 3000, "https://badminton.double-yellow.be", "18be497c-ddfa-4851-9b43-0a5866605252", R.raw.changelog_badminton),
//Racketlon (SportType.Racketlon , R.string.app_name_short_brand__Racketlon , 0, 0/*R.drawable.brand_squore*/ , R.id.sb_branded_logo_ar150, R.color.brand_racketlon_bg_color , R.string.CUSTOM_RECEIVER_APP_ID_racketlon_fancy , R.array.colorSchema__Racketlon , 3000, "https://racketlon.double-yellow.be", "6ffc7128-6fd5-46d1-b79c-46e4c613cba5", R.raw.changelog_racketlon),
//TennisPadel (SportType.TennisPadel, R.string.app_name_short_brand__TennisPadel , 0, R.drawable.logo_brand_tennispadel , R.id.sb_branded_logo_ar400, R.color.brand_padel_bg_color , R.string.CUSTOM_RECEIVER_APP_ID_tennispadel_fancy , R.array.colorSchema__TennisPadel , 4000, "https://tennispadel.double-yellow.be", "239ad8ef-0cdd-490c-8f01-4d50dd4e7c6b", R.raw.changelog_tennispadel),
//Racquetball (SportType.Racquetball, R.string.app_name_short_brand__Racquetball , 0, 0/*R.drawable.brand_squore*/ , R.id.sb_branded_logo_ar150, 0 , R.string.CUSTOM_RECEIVER_APP_ID_brand_shared , R.array.colorSchema__Racquetball , 3000, "https://racquetball.double-yellow.be", R.raw.changelog),
Squore (SportType.Squash , R.string.app_name_short_brand__Squash , 0, 0/*R.drawable.brand_squore*/ , R.id.sb_branded_logo_ar150, R.color.brand_squore_bg_color , R.string.CUSTOM_RECEIVER_APP_ID_squore_fancy , R.array.colorSchema__Squash , 3000, "https://squore.double-yellow.be" , "8da78f9d-f7dd-437c-8b7d-d5bc231f92ec", R.raw.changelog),
//Tabletennis (SportType.Tabletennis, R.string.app_name_short_brand__Tabletennis , 0, 0/*R.drawable.brand_squore*/ , R.id.sb_branded_logo_ar150, R.color.brand_tabletennis_bg_color , R.string.CUSTOM_RECEIVER_APP_ID_tabletennis_fancy , R.array.colorSchema__Tabletennis , 3000, "https://tabletennis.double-yellow.be", "e35d8fcb-a7c0-4c2a-9c74-cc3f6e1e6a41", R.raw.changelog_tabletennis),
//Badminton (SportType.Badminton , R.string.app_name_short_brand__Badminton , 0, 0/*R.drawable.brand_squore*/ , R.id.sb_branded_logo_ar150, R.color.brand_badminton_bg_color , R.string.CUSTOM_RECEIVER_APP_ID_badminton_fancy , R.array.colorSchema__Badminton , 3000, "https://badminton.double-yellow.be" , "18be497c-ddfa-4851-9b43-0a5866605252", R.raw.changelog_badminton),
//Racketlon (SportType.Racketlon , R.string.app_name_short_brand__Racketlon , 0, 0/*R.drawable.brand_squore*/ , R.id.sb_branded_logo_ar150, R.color.brand_racketlon_bg_color , R.string.CUSTOM_RECEIVER_APP_ID_racketlon_fancy , R.array.colorSchema__Racketlon , 3000, "https://racketlon.double-yellow.be" , "6ffc7128-6fd5-46d1-b79c-46e4c613cba5", R.raw.changelog_racketlon),
//TennisPadel (SportType.TennisPadel, R.string.app_name_short_brand__TennisPadel , 0, R.drawable.logo_brand_tennispadel , R.id.sb_branded_logo_ar400, R.color.brand_padel_bg_color , R.string.CUSTOM_RECEIVER_APP_ID_tennispadel_fancy , R.array.colorSchema__TennisPadel , 4000, "https://tennispadel.double-yellow.be", "239ad8ef-0cdd-490c-8f01-4d50dd4e7c6b", R.raw.changelog_tennispadel),
//Racquetball (SportType.Racquetball, R.string.app_name_short_brand__Racquetball , 0, 0/*R.drawable.brand_squore*/ , R.id.sb_branded_logo_ar150, 0 , R.string.CUSTOM_RECEIVER_APP_ID_brand_shared , R.array.colorSchema__Racquetball , 3000, "https://racquetball.double-yellow.be", null , R.raw.changelog),

;
Brand( SportType sport
Expand Down Expand Up @@ -82,7 +82,7 @@ public enum Brand
};

public static/*final*/Brand brand = Brand.Squore;

private static final String sSharedPusherId = "964ea544-59d3-4698-a5dd-2bcdb8b7f93d";
private SportType eSport;
private int iShortNameResId;
private int iSplashDuration;
Expand Down Expand Up @@ -394,6 +394,8 @@ private static boolean trueUnlessFlagIsOn(int iFlag) {
public static String getBaseURL() { return brand.sBaseURL;}
/** Only used for BlueTooth connections for now */
public static UUID getUUID() { return brand.uuid;}
/** uuid of pusher beam https://dashboard.pusher.com/beams/instances */
public static UUID getUUIDPusher() { return UUID.fromString(Brand.sSharedPusherId);}

public static int getImageViewResId() { return brand.imageViewResId;}
public static int getLogoResId() { return brand.iLogoResId;}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,44 +42,38 @@ public class PusherMessagingService extends MessagingService
}
}

// =============================================
// TEMP METHODS FOR LOGGING ONLY
// =============================================

/** invoked only if started with startService */
@Override public int onStartCommand(@Nullable Intent intent, int flags, int startId) {
Log.i(TAG, "onStartCommand. intent: " + intent);
return super.onStartCommand(intent, flags, startId);
}
/** called when service has been declared in the androidmanifest and used for the first time (e.g. first notification?! or when startService is called) */
/** called when service has been declared in the AndroidManifest and used for the first time (e.g. first notification?! or when startService is called), device wakeup with app in foreground */
@Override public void onCreate() {
Log.i(TAG, "Service created");
PusherHandler.getInstance().setInForegroundOnly(false);
super.onCreate();
}

/** when device goes to sleep */
@Override public void onDestroy() {
Log.i(TAG, "Service destroyed");
PusherHandler.getInstance().setInForegroundOnly(true);
super.onDestroy();
}
/** invoked on message received (first one only!) */
public IBinder onBind(Intent arg0) {
Log.i(TAG, "onBind()" );
return super.onBind(arg0);
}

/** ?? */
public boolean onUnbind(Intent arg0) {
Log.i(TAG, "onUnBind()");
return super.onUnbind(arg0);
/** invoked only if started with startService */
@Override public int onStartCommand(@Nullable Intent intent, int flags, int startId) {
Log.i(TAG, "onStartCommand. intent: " + intent);
return super.onStartCommand(intent, flags, startId);
}

/*
public void onStop() {
Log.i(TAG, "onStop()");
// =============================================
// TEMP METHODS FOR LOGGING ONLY
// =============================================

/** invoked on message received (first one only!) */
public IBinder onBind(Intent arg) {
Log.i(TAG, "onBind() : " + arg );
return super.onBind(arg);
}
public void onPause() {
Log.i(TAG, "onPause()");

/** ?? */
public boolean onUnbind(Intent arg) {
Log.i(TAG, "onUnBind() : " + arg);
return super.onUnbind(arg);
}
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@
package com.doubleyellow.scoreboard.prefs;

import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.preference.DialogPreference;
import android.preference.PreferenceManager;
import android.util.AttributeSet;
import com.doubleyellow.scoreboard.main.ScoreBoard;

import com.doubleyellow.scoreboard.Brand;
import com.doubleyellow.util.Feature;

import java.util.EnumSet;
Expand All @@ -35,7 +32,17 @@
public class AutomateWhatCanBeAutomatedPrefs extends MultiPrefsDialog
{
/** */
public static EnumSet<PreferenceKeys> dialog_AutomateOrSuggest_prefKeys = EnumSet.of(PreferenceKeys.useTossFeature, PreferenceKeys.useTimersFeature, PreferenceKeys.useOfficialAnnouncementsFeature, PreferenceKeys.endGameSuggestion);
public static EnumSet<PreferenceKeys> dialog_AutomateOrSuggest_prefKeys =
EnumSet.of( PreferenceKeys.useTossFeature
, PreferenceKeys.useTimersFeature
, PreferenceKeys.useOfficialAnnouncementsFeature
, PreferenceKeys.endGameSuggestion
);
static {
if ( Brand.isNotSquash() ) {
dialog_AutomateOrSuggest_prefKeys.add(PreferenceKeys.useChangeSidesFeature);
}
}

public AutomateWhatCanBeAutomatedPrefs(Context context, AttributeSet attrs) {
super(context, attrs);
Expand Down

0 comments on commit fefdc8e

Please sign in to comment.