aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-04-30 18:26:54 -0700
committerScott Jackson <daneren2005@gmail.com>2015-04-30 18:26:54 -0700
commit8ba015a68370deab3458927bea7dadc7d23c1c29 (patch)
tree279df967bc5181b4ce7daa628aec74ce5cd96a25 /app/src
parent076d07c655656b6d8bc3e5e3f4e2f8aa3747dd2d (diff)
downloaddsub-8ba015a68370deab3458927bea7dadc7d23c1c29.tar.gz
dsub-8ba015a68370deab3458927bea7dadc7d23c1c29.tar.bz2
dsub-8ba015a68370deab3458927bea7dadc7d23c1c29.zip
Fixed #499: Warning when user is trying to download on mobile when Wifi only streaming is set
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java60
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/Util.java2
-rw-r--r--app/src/main/res/values/strings.xml1
3 files changed, 34 insertions, 29 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java
index fa7e3404..43d85cdd 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java
@@ -222,7 +222,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
albumArtImageView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent me) {
- if(me.getAction() == MotionEvent.ACTION_DOWN) {
+ if (me.getAction() == MotionEvent.ACTION_DOWN) {
lastY = (int) me.getRawY();
}
return gestureScanner.onTouchEvent(me);
@@ -268,7 +268,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
@Override
protected void done(Boolean result) {
- if(result) {
+ if (result) {
onCurrentChanged();
onProgressChanged();
}
@@ -462,7 +462,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
albumArtImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- if(overlayHeight == -1 || lastY < (view.getBottom() - overlayHeight)) {
+ if (overlayHeight == -1 || lastY < (view.getBottom() - overlayHeight)) {
toggleFullscreenAlbumArt();
setControlsVisible(true);
}
@@ -470,35 +470,35 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
});
progressBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
- @Override
- public void onStopTrackingTouch(final SeekBar seekBar) {
- new SilentBackgroundTask<Void>(context) {
- @Override
- protected Void doInBackground() throws Throwable {
- getDownloadService().seekTo(progressBar.getProgress());
- return null;
- }
-
- @Override
- protected void done(Void result) {
- seekInProgress = false;
- NowPlayingFragment.this.onProgressChanged();
- }
- }.execute();
- }
-
- @Override
- public void onStartTrackingTouch(final SeekBar seekBar) {
+ @Override
+ public void onStopTrackingTouch(final SeekBar seekBar) {
+ new SilentBackgroundTask<Void>(context) {
+ @Override
+ protected Void doInBackground() throws Throwable {
+ getDownloadService().seekTo(progressBar.getProgress());
+ return null;
+ }
+
+ @Override
+ protected void done(Void result) {
+ seekInProgress = false;
+ NowPlayingFragment.this.onProgressChanged();
+ }
+ }.execute();
+ }
+
+ @Override
+ public void onStartTrackingTouch(final SeekBar seekBar) {
seekInProgress = true;
- }
+ }
- @Override
- public void onProgressChanged(final SeekBar seekBar, final int position, final boolean fromUser) {
+ @Override
+ public void onProgressChanged(final SeekBar seekBar, final int position, final boolean fromUser) {
if (fromUser) {
Util.toast(context, Util.formatDuration(position / 1000), true);
setControlsVisible(true);
}
- }
+ }
});
playlistView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
@@ -1309,8 +1309,12 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
switch (playerState) {
case DOWNLOADING:
if(currentPlaying != null) {
- long bytes = currentPlaying.getPartialFile().length();
- statusTextView.setText(context.getResources().getString(R.string.download_playerstate_downloading, Util.formatLocalizedBytes(bytes, context)));
+ if(Util.isWifiRequiredForDownload(context)) {
+ statusTextView.setText(context.getResources().getString(R.string.download_playerstate_mobile_disabled));
+ } else {
+ long bytes = currentPlaying.getPartialFile().length();
+ statusTextView.setText(context.getResources().getString(R.string.download_playerstate_downloading, Util.formatLocalizedBytes(bytes, context)));
+ }
}
break;
case PREPARING:
diff --git a/app/src/main/java/github/daneren2005/dsub/util/Util.java b/app/src/main/java/github/daneren2005/dsub/util/Util.java
index 75d8d5dd..032facd6 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/Util.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/Util.java
@@ -1023,7 +1023,7 @@ public final class Util {
return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState());
}
- private static boolean isWifiRequiredForDownload(Context context) {
+ public static boolean isWifiRequiredForDownload(Context context) {
SharedPreferences prefs = getPreferences(context);
return prefs.getBoolean(Constants.PREFERENCES_KEY_WIFI_REQUIRED_FOR_DOWNLOAD, false);
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index b897cad6..8544c6e3 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -183,6 +183,7 @@
<string name="download.empty">Playlist is empty</string>
<string name="download.shuffle_loading">Shuffle list is loading...</string>
<string name="download.playerstate_downloading">Downloading - %s</string>
+ <string name="download.playerstate_mobile_disabled">Waiting for WiFi network to download</string>
<string name="download.playerstate_buffering">Buffering</string>
<string name="download.playerstate_playing_shuffle">Playing shuffle</string>
<string name="download.menu_show_album">Show Album</string>