Skip to content

Commit

Permalink
BLE initial: 523
Browse files Browse the repository at this point in the history
  • Loading branch information
hoeveid committed Jul 13, 2024
1 parent c6fad98 commit afadc5a
Show file tree
Hide file tree
Showing 15 changed files with 72 additions and 49 deletions.
6 changes: 6 additions & 0 deletions AndroidManifestBadminton.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
android:smallScreens="true" />
-->

<queries>
<intent>
<action android:name="android.intent.action.TTS_SERVICE" />
</intent>
</queries>

<application
android:theme="@style/Theme.App.Starting_Badminton"
android:allowBackup="true"
Expand Down
6 changes: 6 additions & 0 deletions AndroidManifestRacketlon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
android:smallScreens="true" />
-->

<queries>
<intent>
<action android:name="android.intent.action.TTS_SERVICE" />
</intent>
</queries>

<application
android:theme="@style/Theme.App.Starting_Racketlon"
android:allowBackup="true"
Expand Down
6 changes: 6 additions & 0 deletions AndroidManifestTabletennis.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
android:smallScreens="true" />
-->

<queries>
<intent>
<action android:name="android.intent.action.TTS_SERVICE" />
</intent>
</queries>

<application
android:theme="@style/Theme.App.Starting_Tabletennis"
android:allowBackup="true"
Expand Down
7 changes: 1 addition & 6 deletions AndroidManifestTennisPadel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@

<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
<!-- mimetype must match the mimetype as passed from com.doubleyellow.scoreboard.main.ScoreBoard.createNdefMessage() -->
<!--
<data android:mimeType="application/com.doubleyellow.scoreboard"/>
Expand Down Expand Up @@ -178,10 +179,4 @@
</intent-filter>
</service>
</application>

<queries>
<intent>
<action android:name="android.intent.action.TTS_SERVICE" />
</intent>
</queries>
</manifest>
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,21 @@ android {
minSdkVersion 21 // increased to 21 for WearOS splashscreen dependency
targetSdkVersion 34
multiDexEnabled true // required since using firebase
versionCode 1915 * 10000 + 522
versionCode 1915 * 10000 + 523
versionName "4.54"
}
phoneTabletPost23 {
dimension "devicetype"
minSdkVersion 23
targetSdkVersion 34
versionCode 2315 * 10000 + 522
versionCode 2315 * 10000 + 523
versionName "4.54"
}
wearOs {
dimension "devicetype"
minSdkVersion 25 // 25 for Wear2.0 (23 would suffice for Wear1.0)
targetSdkVersion 34
versionCode 2501 * 10000 + 522
versionCode 2501 * 10000 + 523
versionName "4.54"
}
}
Expand Down
2 changes: 1 addition & 1 deletion res/layout-land/match.xml
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="@fraction/matchformat_label_width" />

<Spinner
<com.doubleyellow.android.view.EnumSpinner
android:id="@+id/spDoublesServeSequence"
android:layout_width="0dp"
android:layout_height="wrap_content"
Expand Down
2 changes: 1 addition & 1 deletion res/layout/editformat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
android:textSize="@dimen/txt_small"
android:layout_margin="2dp"
/>
<Spinner
<com.doubleyellow.android.view.EnumSpinner
android:id="@+id/spDoublesServeSequence"
app:enum_class="com.doubleyellow.scoreboard.model.DoublesServeSequence"
app:enum_display_values="@array/doublesServeSequence"
Expand Down
2 changes: 1 addition & 1 deletion res/values/defaults.xml
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ http://developer.android.com/guide/practices/screens_support.html
\nPostResult=demo/demo.post.matchresult.basic.auth.php?lang=en
\nAuthentication=Basic
]]></string>
<string name="OfficialRulesURLs_default__Squash"><![CDATA[https://worldsquashofficiating.com/rules/
<string name="OfficialRulesURLs_default__Squash"><![CDATA[https://worldsquashofficiating.com/home/rules-of-squash/
\n/help/rules.of.singles.squash.php
\nhttp://www.worldsquash.org/wp-content/uploads/2018/11/190101_Rules-of-Singles-Squash-2019-V1-1.pdf
\nhttp://www.worldsquash.org/ws/wp-content/uploads/2014/11/150101_Doubles-Rules-Final.pdf
Expand Down
2 changes: 1 addition & 1 deletion src/com/doubleyellow/scoreboard/demo/FullDemoThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private void completeSimulate() {
iStep++;
iMessage = 0;
}
if ( iStep > ListUtil.size(lView) ) {
if (iStep < 0 || iStep >= ListUtil.size(lView) ) {
return;
}
final ListenerAndView lv = lView.get(iStep);
Expand Down
44 changes: 28 additions & 16 deletions src/com/doubleyellow/scoreboard/main/ScoreBoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,11 @@ private class ScoreBoardTouchListener implements SimpleGestureListener.SwipeList
if ( Brand.isSquash() ) {
// TODO: for doubles, switch in/out in such a way that touched player becomes the server
Log.d(TAG, String.format("Two finger click on player %s", player));
showBrokenEquipment(player);
if ( matchModel.isDoubles() ) {
handleMenuItem(R.id.pl_show_conduct, player);
} else {
showBrokenEquipment(player);
}
break;
} else {
handleMenuItem(R.id.sb_change_sides);
Expand Down Expand Up @@ -714,7 +718,7 @@ private class PlayerNamesButtonListener implements View.OnLongClickListener, Vie

if ( matchModel.isDoubles() ) {
// toggle player names of the long clicked team
_swapDoublePlayers(pl);
handleMenuItem(R.id.sb_swap_double_players, pl);
} else {
if ( isWearable() && matchModel.hasStarted()==false ) {
if ( PreferenceValues.isBrandTesting(ScoreBoard.this) ) {
Expand Down Expand Up @@ -4209,7 +4213,11 @@ public boolean handleMenuItem(int id, Object... ctx) {
}
return true;
case R.id.sb_swap_double_players:
swapDoublePlayers();
if ( ctx != null && ctx.length==1 && ctx[0] instanceof Player) {
_swapDoublePlayers((Player) ctx[0]);
} else {
swapDoublePlayers();
}
return true;
case R.id.sb_lock:
lockMatch(ctx);
Expand Down Expand Up @@ -8223,19 +8231,23 @@ private boolean onResume_BluetoothMediaControlButtons() {
ms.setActive(true);
}

// play dummy audio: todo: redo this every x seconds?
AudioTrack at = new AudioTrack( AudioManager.STREAM_MUSIC
, 48000
, AudioFormat.CHANNEL_OUT_STEREO
, AudioFormat.ENCODING_PCM_16BIT
, AudioTrack.getMinBufferSize(48000, AudioFormat.CHANNEL_OUT_STEREO, AudioFormat.ENCODING_PCM_16BIT)
, AudioTrack.MODE_STREAM
);
at.play();

// a little sleep
at.stop();
at.release();
try {
// play dummy audio: todo: redo this every x seconds?
AudioTrack at = new AudioTrack( AudioManager.STREAM_MUSIC
, 48000
, AudioFormat.CHANNEL_OUT_STEREO
, AudioFormat.ENCODING_PCM_16BIT
, AudioTrack.getMinBufferSize(48000, AudioFormat.CHANNEL_OUT_STEREO, AudioFormat.ENCODING_PCM_16BIT)
, AudioTrack.MODE_STREAM
);
at.play();

// a little sleep
at.stop();
at.release();
} catch (Exception e) {
Log.e(TAG, "Why was this again?", e);
}

return true;
}
Expand Down
8 changes: 0 additions & 8 deletions src/com/doubleyellow/scoreboard/model/GSMModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -1283,14 +1283,6 @@ private Player[] calculateIsPossibleSetVictoryFor(Player[] playersWinningGame, W
int i = joFormat.optInt(JsonKey.lastBallChangeOccurredAtStartOfGame.toString(), 0);
setLastBallChangeOccurredAtStartOfGame(i);

if ( joFormat.has(PreferenceKeys.goldenPointToWinGame.toString()) ) {
// legacy
boolean b = joFormat.optBoolean(PreferenceKeys.goldenPointToWinGame.toString());
if ( b ) {
joFormat.put(PreferenceKeys.goldenPointFormat.toString(), GoldenPointFormat.OnFirstDeuce.toString());
}
joFormat.remove(PreferenceKeys.goldenPointToWinGame.toString());
}
String s3 = joFormat.optString(PreferenceKeys.goldenPointFormat.toString());
if (StringUtil.isNotEmpty(s3) ) {
setGoldenPointFormat(GoldenPointFormat.valueOf(s3));
Expand Down
2 changes: 0 additions & 2 deletions src/com/doubleyellow/scoreboard/prefs/PreferenceKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,6 @@ public enum PreferenceKeys {
finalSetFinish, // also used as JSONKey
newBalls, // also used as JSONKey
newBallsXGamesUpFront,
/** @deprecated */
goldenPointToWinGame, // also used as JSONKey
goldenPointFormat, // also used as JSONKey
StartTiebreakOneGameEarly, // also used as JSONKey
PowerPlay,
Expand Down
2 changes: 2 additions & 0 deletions src/com/doubleyellow/scoreboard/prefs/PreferenceValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -1067,9 +1067,11 @@ public static boolean useHandInHandOutScoring(Context context) {
return getBoolean(PreferenceKeys.useHandInHandOutScoring, context, R.bool.useEnglishScoring_default);
}
/** @deprecated */
/*
public static boolean useGoldenPoint(Context context) {
return getBoolean(PreferenceKeys.goldenPointToWinGame, context, false);
}
*/
public static GoldenPointFormat goldenPointFormat(Context context) {
// for backwards compatibility
GoldenPointFormat goldenPointFormatDefault = useGroupNameAsEventData(context) ? GoldenPointFormat.OnFirstDeuce : GoldenPointFormat.None;
Expand Down
2 changes: 1 addition & 1 deletion src/com/doubleyellow/scoreboard/prefs/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ Preference findPreference(ColorPrefs.ColorTarget key) {
hideRemovePreference(psgMF, PreferenceKeys.changeSidesWhen_GSM);
hideRemovePreference(psgMF, PreferenceKeys.finalSetFinish);
hideRemovePreference(psgMF, PreferenceKeys.newBalls);
hideRemovePreference(psgMF, PreferenceKeys.goldenPointToWinGame);
//hideRemovePreference(psgMF, PreferenceKeys.goldenPointToWinGame);
hideRemovePreference(psgBeh, PreferenceKeys.indicateGoldenPoint);
}
/*
Expand Down
24 changes: 15 additions & 9 deletions src/com/doubleyellow/scoreboard/vico/IBoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ public MatchGameScoresView.ScoresToShow updateSetScoresToShow(boolean bChange) {
, R.id.btn_gameset2_detail1, R.id.btn_gameset2_detail2, R.id.space_gameset2_detail
, R.id.btn_gameset1_detail1, R.id.btn_gameset1_detail2, R.id.space_gameset1_detail
};
List<TextView> lSetScoresViews = new ArrayList<>();
List<TextView> lSetScoresViews = new ArrayList<>();
List<Space> lSetScoresSpaces = new ArrayList<>();
for(int iViewId: iaSetScores) {
View vCheck = findViewById(iViewId);
Expand All @@ -760,20 +760,24 @@ public MatchGameScoresView.ScoresToShow updateSetScoresToShow(boolean bChange) {
if ( Brand.isGameSetMatch() ) {
GSMModel gsmModel = (GSMModel) matchModel;

TextView vSetsWon1 = (TextView) findViewById(R.id.btn_setswon1);
TextView vSetsWon2 = (TextView) findViewById(R.id.btn_setswon2);
final TextView vSetsWon1 = (TextView) findViewById(R.id.btn_setswon1);
final TextView vSetsWon2 = (TextView) findViewById(R.id.btn_setswon2);

Map<Player, Integer> setsWon = gsmModel.getSetsWon();
Integer iSetsFor1 = setsWon.get(m_firstPlayerOnScreen);
Integer iSetsFor2 = setsWon.get(m_firstPlayerOnScreen.getOther());
vSetsWon1.setText(String.valueOf(iSetsFor1));
vSetsWon2.setText(String.valueOf(iSetsFor2));
if ( vSetsWon1 != null ) {
vSetsWon1.setText(String.valueOf(iSetsFor1));
vSetsWon2.setText(String.valueOf(iSetsFor2));
}

if ( iSetsFor1 + iSetsFor2 <= iNrOfSetDetailsPossibleInLayout) {
// few enough sets played to show details score how the set ended, e.g. 6-4 or 7-6

vSetsWon1.setVisibility(iVisibilityIfNotUsed);
vSetsWon2.setVisibility(iVisibilityIfNotUsed);
if ( vSetsWon1 != null ) {
vSetsWon1.setVisibility(iVisibilityIfNotUsed);
vSetsWon2.setVisibility(iVisibilityIfNotUsed);
}

List<Map<Player, Integer>> gamesWonPerSet = GSMUtil.gsmGamesWonPerSet(gsmModel, true);

Expand Down Expand Up @@ -852,8 +856,10 @@ public MatchGameScoresView.ScoresToShow updateSetScoresToShow(boolean bChange) {
vSetScore1.setVisibility(iVisibilityIfNotUsed);
vSetScore2.setVisibility(iVisibilityIfNotUsed);
}
vSetsWon1.setVisibility(View.VISIBLE);
vSetsWon2.setVisibility(View.VISIBLE);
if ( vSetsWon1 != null ) {
vSetsWon1.setVisibility(View.VISIBLE);
vSetsWon2.setVisibility(View.VISIBLE);
}
}
} else {
Map<Player, Integer> gamesWon = matchModel.getGamesWon();
Expand Down

0 comments on commit afadc5a

Please sign in to comment.