Skip to content

Commit

Permalink
Merge branch 'alpha' into beta
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
Ben Sandee committed Nov 22, 2022
2 parents 6ef7d1a + 80e9513 commit cc972f0
Show file tree
Hide file tree
Showing 15 changed files with 271 additions and 228 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ avoided for new code (e.g. the "m" member variable prefix).
It's possible that contributions may be folded into future releases of Orange Squeeze. If so, the
authors will be recognized in the release notes.

## Languages and Translations

Open Squeeze was developed by a native American English speaker. The German and French translations were
initially machine generated and then heavily modified by users and contributors.

Translations to new languages and modifications to existing translations should be done via
[Weblate](https://hosted.weblate.org/projects/open-squeeze/) which is freely provided for
Open Source projects. Thank you to them for providing this service!

## License

The license for the code is [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0).
Expand Down
24 changes: 12 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,15 @@ dependencies {
implementation "com.google.code.findbugs:jsr305:${obl_jsr305Version}"

// ReactiveX
implementation "io.reactivex.rxjava3:rxandroid:3.0.0"
implementation "io.reactivex.rxjava3:rxandroid:3.0.2"
implementation "io.reactivex.rxjava3:rxjava:3.1.5"
implementation "io.reactivex.rxjava3:rxkotlin:3.0.1"

// sqldelight
implementation "com.squareup.sqldelight:android-driver:${sqldelight_version}"
implementation "com.squareup.sqldelight:coroutines-extensions:${sqldelight_version}"

debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10'

implementation 'androidx.multidex:multidex:2.0.1'

Expand All @@ -211,17 +211,17 @@ dependencies {
testImplementation "io.mockk:mockk-android:1.13.2"
testImplementation "com.google.truth:truth:1.1.3"

androidTestImplementation "androidx.test:runner:1.4.0"
androidTestImplementation "androidx.test:rules:1.4.0"
androidTestImplementation "androidx.test:core:1.4.0"
androidTestImplementation "androidx.test:core-ktx:1.4.0"
androidTestImplementation "androidx.test.espresso:espresso-core:3.4.0"
androidTestImplementation "androidx.test.espresso:espresso-intents:3.4.0"
androidTestImplementation "androidx.test.ext:junit:1.1.3"
androidTestImplementation "androidx.test.ext:junit-ktx:1.1.3"
androidTestImplementation "androidx.test.ext:truth:1.4.0"
androidTestImplementation "androidx.test:runner:1.5.1"
androidTestImplementation "androidx.test:rules:1.5.0"
androidTestImplementation "androidx.test:core:1.5.0"
androidTestImplementation "androidx.test:core-ktx:1.5.0"
androidTestImplementation "androidx.test.espresso:espresso-core:3.5.0"
androidTestImplementation "androidx.test.espresso:espresso-intents:3.5.0"
androidTestImplementation "androidx.test.ext:junit:1.1.4"
androidTestImplementation "androidx.test.ext:junit-ktx:1.1.4"
androidTestImplementation "androidx.test.ext:truth:1.5.0"
androidTestImplementation "io.mockk:mockk-android:1.13.2"
androidTestUtil "androidx.test:orchestrator:1.4.1"
androidTestUtil "androidx.test:orchestrator:1.4.2"
}

tasks.withType(JavaCompile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.v4.media.session.MediaControllerCompat;

import androidx.appcompat.app.AppCompatActivity;
Expand Down Expand Up @@ -78,6 +80,8 @@ public static int getInstanceCount() {
return sInstanceCount;
}

final static private Handler sHandler = new Handler(Looper.getMainLooper());

static public boolean sShouldAutoStart = true;

static private int sInstanceCount = 0;
Expand Down Expand Up @@ -209,13 +213,15 @@ protected void onStart() {
}
setWindowFlags();

// show deferred player snackbar when the UI is ready
if (sDeferredPlayerSnackbar != null) {
PlayerStatus status = sDeferredPlayerSnackbar;
sDeferredPlayerSnackbar = null;
sHandler.postDelayed(() -> {
// show deferred player snackbar when the UI is ready
if (sDeferredPlayerSnackbar != null) {
PlayerStatus status = sDeferredPlayerSnackbar;
sDeferredPlayerSnackbar = null;

showPlayerSnackbar(status);
}
showPlayerSnackbar(status);
}
}, 250);
}

@Override
Expand Down Expand Up @@ -445,7 +451,8 @@ protected void setWindowFlags() {

protected void showPlayerSnackbar(PlayerStatus status) {
OSAssert.assertMainThread();
if (!mStarted || isFinishing() || !allowSnackbarDisplay() || getSnackbarView() == null) {
View snackbarView = getSnackbarView();
if (!mStarted || isFinishing() || !allowSnackbarDisplay() || snackbarView == null || snackbarView.getWidth() <= 0 || snackbarView.getHeight() <= 0) {
sDeferredPlayerSnackbar = status;
return;
}
Expand All @@ -454,7 +461,10 @@ protected void showPlayerSnackbar(PlayerStatus status) {
if (!status.getId().equals(mLastShownPlayerSnackbar)) {
mLastShownPlayerSnackbar = status.getId();
String text = getString(R.string.change_player_snackbar, status.getName());
Snackbar.make(getSnackbarView(), HtmlCompat.fromHtml(text, HtmlCompat.FROM_HTML_MODE_COMPACT), Snackbar.LENGTH_SHORT).show();
Snackbar
.make(snackbarView, HtmlCompat.fromHtml(text, HtmlCompat.FROM_HTML_MODE_COMPACT), Snackbar.LENGTH_SHORT)
.setAnchorView(snackbarView)
.show();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public void showSnackbar(CharSequence text, SnackbarLength length) {
} else {
translatedLength = Snackbar.LENGTH_SHORT;
}
mLastSnackbar = Snackbar.make(getSnackbarView(), text, translatedLength);
mLastSnackbar = Snackbar.make(getSnackbarView(), text, translatedLength).setAnchorView(getSnackbarView());
mLastSnackbar.show();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import com.orangebikelabs.orangesqueeze.BuildConfig;
import com.orangebikelabs.orangesqueeze.R;
Expand Down Expand Up @@ -191,6 +192,17 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
}

@Override
protected boolean allowSnackbarDisplay() {
return true;
}

@Nullable
@Override
protected View getSnackbarView() {
return findViewById(R.id.controls);
}

private void setHidePlaylistItemDrawable() {
if (mHidePlaylistItem == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package com.orangebikelabs.orangesqueeze.players;

import android.annotation.SuppressLint;
import android.content.Context;

import arrow.core.Option;
Expand Down Expand Up @@ -40,6 +39,7 @@

import java.net.URI;
import java.net.URISyntaxException;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
Expand Down Expand Up @@ -84,11 +84,13 @@ public interface OnPlayerCommandListener {
private SyncStatus mSyncStatus;
private boolean mDrawerMode;
private int mPlayerItemLayoutRid;
final private NumberFormat mNumberFormat;

public ManagePlayersAdapter(Context context) {
super(context, 0);

setDrawerMode(false);
mNumberFormat = NumberFormat.getInstance();
}

@Nonnull
Expand Down Expand Up @@ -291,15 +293,31 @@ public View getView(int pos, @Nullable View convertView, ViewGroup parent) {
return convertView;
}

@SuppressLint("SetTextI18n")
protected void setVolume(Slider sb, TextView playerVolumeLabel, int volume) {
/** called when volume is set by user */
protected void setVolumeFromUser(Slider sb, TextView playerVolumeLabel, int volume) {
View parentView = (View) sb.getTag(R.id.tag_containerview);
PlayerId pid = (PlayerId) parentView.getTag(R.id.tag_playerid);
playerVolumeLabel.setText(Integer.toString(volume));
updateVolumeText(playerVolumeLabel, volume);

mOnPlayerCommandListener.onPlayerCommand(pid, PlayerCommand.VOLUME, volume);
}

protected void hideVolumeText(@Nullable TextView playerVolumeLabel) {
if(playerVolumeLabel != null) {
playerVolumeLabel.setVisibility(View.INVISIBLE);
}
}

/** called to update the text field to a specific volume level */
protected void updateVolumeText(@Nullable TextView playerVolumeLabel, int volume) {
if(playerVolumeLabel != null) {
if(playerVolumeLabel.getVisibility() != View.VISIBLE) {
playerVolumeLabel.setVisibility(View.VISIBLE);
}
playerVolumeLabel.setText(mNumberFormat.format(volume));
}
}

/**
* tag should be the player status
*/
Expand Down Expand Up @@ -422,7 +440,7 @@ protected void updateView(View view) {
SwitchMaterial powerButton = view.findViewById(R.id.player_power_toggle);
Slider volumeBar = view.findViewById(R.id.volume_bar);
View actionButton = view.findViewById(R.id.action_button);
TextView playerStatusText = view.findViewById(R.id.player_status_label);
TextView playerStatusLabel = view.findViewById(R.id.player_status_label);
final TextView playerVolumeLabel = view.findViewById(R.id.player_volume_label);

if (powerButton != null) {
Expand All @@ -441,7 +459,7 @@ protected void updateView(View view) {
volumeBar.addOnChangeListener((slider, value, fromUser) -> {
if (fromUser) {
// only respond to user-generated events
setVolume(slider, playerVolumeLabel, (int) value);
setVolumeFromUser(slider, playerVolumeLabel, (int) value);
}
});
volumeBar.addOnSliderTouchListener(new Slider.OnSliderTouchListener() {
Expand All @@ -457,7 +475,7 @@ public void onStopTrackingTouch(Slider slider) {
playerVolumeLabel.setVisibility(View.VISIBLE);
// called at the end of a touch/drag cycle, call with update to make
// sure we are in sync with remote volume
setVolume(slider, playerVolumeLabel, (int) slider.getValue());
setVolumeFromUser(slider, playerVolumeLabel, (int) slider.getValue());
}
});
volumeBar.setLabelFormatter((value -> Integer.toString((int) value)));
Expand All @@ -475,10 +493,11 @@ public void onStopTrackingTouch(Slider slider) {
// when progress is visible, don't routinely update the volume,
// power buttons because they may lag

int clampedVolume = MoreMath.coerceIn(mPlayerStatus.getVolume(), 0, 100);
int playerStatusVisibility = View.GONE;
boolean progressVisible = false;
boolean statusInProgress = false;
if (!mPlayerStatus.isInitialized()) {
progressVisible = true;
statusInProgress = true;

if (volumeBar != null) {
volumeBar.setValue(0);
Expand All @@ -489,7 +508,7 @@ public void onStopTrackingTouch(Slider slider) {
powerButton.setChecked(false);
}
} else if (isWorkInProgress(mPlayerStatus.getId())) {
progressVisible = true;
statusInProgress = true;
} else {
if (powerButton != null) {
powerButton.setChecked(mPlayerStatus.isPowered());
Expand All @@ -502,28 +521,34 @@ public void onStopTrackingTouch(Slider slider) {
} else {
if (volumeBar != null) {
// ensure received values are within 0 <= value <= 100
int clampedVolume = MoreMath.coerceIn(mPlayerStatus.getVolume(), 0, 100);
volumeBar.setValue(clampedVolume);
}
}
updateVolumeText(playerVolumeLabel, clampedVolume);

// TODO add different text if mPlayerStatus.isVolumeLocked()
if (volumeBar != null) {
volumeBar.setEnabled(true);
}
if (mPlayerStatus.isPowered()) {
playerStatusVisibility = View.VISIBLE;
if (playerStatusText != null) {
if (playerStatusLabel != null) {
if (mPlayerStatus.isConnected()) {
playerStatusText.setText(mPlayerStatus.getMode().getRid());
playerStatusLabel.setText(mPlayerStatus.getMode().getRid());
} else {
playerStatusText.setText(getContext().getString(R.string.disconnected));
playerStatusLabel.setText(getContext().getString(R.string.disconnected));
}
}
}
}
if (playerStatusText != null) {
playerStatusText.setVisibility(playerStatusVisibility);

if(statusInProgress) {
hideVolumeText(playerVolumeLabel);
} else {
updateVolumeText(playerVolumeLabel, clampedVolume);
}
if (playerStatusLabel != null) {
playerStatusLabel.setVisibility(playerStatusVisibility);
}
if (mPlayerStatus.getId().equals(mSelectedPlayer)) {
view.setBackgroundResource(R.drawable.manageplayers_item_selected);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package com.orangebikelabs.orangesqueeze.ui
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.fragment.app.commitNow

import com.orangebikelabs.orangesqueeze.BuildConfig
Expand Down Expand Up @@ -105,6 +106,11 @@ class MainActivity : DrawerActivity() {
return true
}

override fun getSnackbarView(): View? {
val retval = findViewById<View>(R.id.tiny_nowplaying_container)
return retval
}

override fun applyDrawerState(drawerState: DrawerState) {
if (drawerState !== DrawerState.BROWSE) {
supportActionBar.title = title
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public View getView(int position, @Nullable View convertView, ViewGroup parent)
}
dialog.dismiss();
});
builder.setNegativeButton(R.string.close, (dialog, which) -> {
builder.setNegativeButton(R.string.dismiss_dialog, (dialog, which) -> {
// nothing to do
});
Dialog retval = builder.create();
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
<string name="nextbutton_label">Weiter</string>
<string name="cancel">Abbrechen</string>
<string name="ok">OK</string>
<string name="close">OK</string>
<string name="dismiss_dialog">OK</string>
<string name="permission_write_external_storage_rationale_title">Speicherberechtigung</string>
<string name="permission_write_external_storage_neverask">Die Berechtigung zu speichern wird nie wieder angefordert.</string>
<string name="permission_write_external_storage_denied">Die Berechtigung zu speichern wurde abgelehnt.</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<string name="pause_desc">Pause de la lecture</string>
<string name="error_invalid_credentials">Nom d\'utilisateur et/ou mot de passe incorrect</string>
<string name="no">Annuler</string>
<string name="close">OK</string>
<string name="dismiss_dialog">OK</string>
<string name="empty_downloads_text">Aucun téléchargement actif ou terminé</string>
<string name="empty_text">Pas d\'objet</string>
<string name="select_player_prompt">Sélectionner un platine:</string>
Expand Down
9 changes: 0 additions & 9 deletions app/src/main/res/values/about_strings.xml

This file was deleted.

11 changes: 0 additions & 11 deletions app/src/main/res/values/exception_strings.xml

This file was deleted.

Loading

0 comments on commit cc972f0

Please sign in to comment.