diff options
Diffstat (limited to 'app')
6 files changed, 117 insertions, 13 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 7c20dc28..9eddbc89 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java @@ -400,11 +400,6 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { - DownloadService downloadService = getDownloadService(); - if (downloadService == null) { - return false; - } - float playbackSpeed = 1.0f; switch (menuItem.getItemId()) { case R.id.playback_speed_half: @@ -419,10 +414,12 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis case R.id.playback_speed_tripple: playbackSpeed = 3.0f; break; + case R.id.playback_speed_custom: + setPlaybackSpeed(); + return true; } - downloadService.setPlaybackSpeed(playbackSpeed); - updateTitle(); + setPlaybackSpeed(playbackSpeed); return true; } }); @@ -1485,8 +1482,15 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis stringRes = R.string.download_playback_speed_tripple; } + String playbackSpeedText = null; if(stringRes != -1) { - title += " (" + context.getResources().getString(stringRes) + ")"; + playbackSpeedText = context.getResources().getString(stringRes); + } else if(Math.abs(playbackSpeed - 1.0) > 0.01) { + playbackSpeedText = Float.toString(playbackSpeed) + "x"; + } + + if(playbackSpeedText != null) { + title += " (" + playbackSpeedText + ")"; } setTitle(title); } @@ -1504,4 +1508,64 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis return entries; } + + private void setPlaybackSpeed() { + View dialogView = context.getLayoutInflater().inflate(R.layout.set_playback_speed, null); + + // Setup playbackSpeed label + final TextView playbackSpeedBox = (TextView) dialogView.findViewById(R.id.playback_speed_label); + final SharedPreferences prefs = Util.getPreferences(context); + String playbackSpeedString = prefs.getString(Constants.PREFERENCES_KEY_CUSTOM_PLAYBACK_SPEED, "17"); + int playbackSpeed = Integer.parseInt(playbackSpeedString); + playbackSpeedBox.setText(new Float(playbackSpeed / 10.0).toString()); + + // Setup playbackSpeed slider + final SeekBar playbackSpeedBar = (SeekBar) dialogView.findViewById(R.id.playback_speed_bar); + playbackSpeedBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + if (fromUser) { + playbackSpeedBox.setText(new Float((progress + 5) / 10.0).toString()); + seekBar.setProgress(progress); + } + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + } + }); + playbackSpeedBar.setProgress(playbackSpeed - 5); + + AlertDialog.Builder builder = new AlertDialog.Builder(context); + builder.setTitle(R.string.download_playback_speed_custom) + .setView(dialogView) + .setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + int playbackSpeed = playbackSpeedBar.getProgress() + 5; + + SharedPreferences.Editor editor = prefs.edit(); + editor.putString(Constants.PREFERENCES_KEY_CUSTOM_PLAYBACK_SPEED, Integer.toString(playbackSpeed)); + editor.commit(); + + setPlaybackSpeed(new Float(playbackSpeed / 10.0)); + } + }) + .setNegativeButton(R.string.common_cancel, null); + AlertDialog dialog = builder.create(); + dialog.show(); + } + private void setPlaybackSpeed(float playbackSpeed) { + DownloadService downloadService = getDownloadService(); + if (downloadService == null) { + return; + } + + downloadService.setPlaybackSpeed(playbackSpeed); + updateTitle(); + } } diff --git a/app/src/main/java/github/daneren2005/dsub/util/Constants.java b/app/src/main/java/github/daneren2005/dsub/util/Constants.java index 4109ea67..b7a68962 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/Constants.java +++ b/app/src/main/java/github/daneren2005/dsub/util/Constants.java @@ -176,6 +176,7 @@ public final class Constants { public static final String PREFERENCES_KEY_HEADS_UP_NOTIFICATION = "headsUpNotification"; public static final String PREFERENCES_KEY_CAST_CACHE = "castCache"; public static final String PREFERENCES_KEY_PLAYBACK_SPEED = "playbackSpeed"; + public static final String PREFERENCES_KEY_CUSTOM_PLAYBACK_SPEED = "customPlaybackSpeed"; public static final String OFFLINE_SCROBBLE_COUNT = "scrobbleCount"; public static final String OFFLINE_SCROBBLE_ID = "scrobbleID"; diff --git a/app/src/main/res/layout/set_playback_speed.xml b/app/src/main/res/layout/set_playback_speed.xml new file mode 100644 index 00000000..42f23a35 --- /dev/null +++ b/app/src/main/res/layout/set_playback_speed.xml @@ -0,0 +1,22 @@ +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="horizontal" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_gravity="center"> + + <TextView + android:id="@+id/playback_speed_label" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="8dp" + android:textSize="20dp" + android:paddingRight="10px" + android:layout_gravity="center" + android:textColor="?android:textColorPrimary"/> + + <SeekBar + android:id="@+id/playback_speed_bar" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:max="25"/> +</LinearLayout>
\ No newline at end of file diff --git a/app/src/main/res/menu/playback_speed_options.xml b/app/src/main/res/menu/playback_speed_options.xml index e64ecd04..909d3b3c 100644 --- a/app/src/main/res/menu/playback_speed_options.xml +++ b/app/src/main/res/menu/playback_speed_options.xml @@ -19,4 +19,8 @@ <item android:id="@+id/playback_speed_tripple" android:title="@string/download.playback_speed_tripple"/> + + <item + android:id="@+id/playback_speed_custom" + android:title="@string/download.playback_speed_custom"/> </menu>
\ No newline at end of file diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 8ac830a7..a720b214 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -220,6 +220,11 @@ <string name="download.thumbs_up">Jó</string> <string name="download.thumbs_down">Nem jó</string> <string name="download.batch_mode">Kötegelt mód</string> + <string name="download.playback_speed_half">0.5x</string> + <string name="download.playback_speed_normal">1x</string> + <string name="download.playback_speed_one_half">1.5x</string> + <string name="download.playback_speed_double">2x</string> + <string name="download.playback_speed_tripple">3x</string> <string name="sync.new_podcasts">Új podcastok: \"%s\"</string> <string name="sync.new_playlists">Új lejátszási listák: \"%s\"</string> @@ -442,6 +447,11 @@ <string name="settings.override_system_language">A rendszer nyelvének felülbírálása</string> <string name="settings.override_system_language_summary">A Dsub megjelenítése angol nyelven abban az esetben is, ha rendelkezik fordítással. Az alkalmazást törölni kell a memóriából, mert a beállítás csak újraindítás után lép érvénybe!</string> <string name="settings.drawer_items_title">Oldalsáv elemei</string> + <string name="settings.song_press_action">Viselkedés dal megérintésekor</string> + <string name="settings.song_press_play_single">Dal lejátszása</string> + <string name="settings.song_press_play_all">A teljes album hozzáadása a várólistához</string> + <string name="settings.song_press_play_next">Dal sorba állítása következőnek</string> + <string name="settings.song_press_play_last">Dal sorba állítása utolsónak</string> <string name="settings.large_album_art">Nagyméretű albumborítók</string> <string name="settings.large_album_art_summary">Albumok megjelenítése rácsnézetben és nagyméretű albumborítóval a listanézet helyett.</string> <string name="settings.admin_enabled">Admin engedélyezése</string> @@ -530,7 +540,7 @@ <string name="admin.role.jukebox">Jukebox vezérlése</string> <string name="admin.role.share">Megosztások kezelése</string> <string name="admin.role.video_conversion">Videók konvertálása</string> - <string name="admin.role.lastfm">Last.fm funkció használata</string> + <string name="admin.role.lastfm">Last.fm szolgáltatás használata</string> <string name="music_service.retry">Hálózati hiba történt! Újrapróbálkozás %1$d/%2$d.</string> @@ -555,8 +565,8 @@ <string name="equalizer.label">Equalizer</string> <string name="equalizer.enabled">Engedélyezve</string> <string name="equalizer.preset">Profil kiválasztása</string> - <string name="equalizer.bass_booster">Basszus fokozás</string> - <string name="equalizer.voice_booster">Beszédhang fokozás</string> + <string name="equalizer.bass_booster">Basszus fokozása</string> + <string name="equalizer.voice_booster">Beszédhang fokozása</string> <string name="equalizer.db_size">%d dB</string> <string name="equalizer.bass_size">%d ezer</string> @@ -578,7 +588,9 @@ <string name="changelog_ok_button">OK</string> <string name="changelog_show_full">Továbbiak…</string> - <string name="chat.send_a_message">Üzenet küldése</string> + <string name="chat.send_a_message">Üzenet küldése</string> + + <string name="changelog_version_format">Verzió %s</string> <string name="tasker.start_playing">Lejátszás indítása</string> <string name="tasker.start_playing_shuffled">Lejátszás indítása kevert sorrendben</string> @@ -624,7 +636,7 @@ <string name="details.version">Verzió</string> <string name="details.files_cached">Gyorsítótárazott fájlok</string> <string name="details.files_permanent">Megőrzött fájlok</string> - <string name="details.used_space">Felhasznált tároló</string> + <string name="details.used_space">Felhasznált tárhely</string> <string name="details.available_space">Rendelkezésre álló hely</string> <string name="details.of">%1$s/%2$s</string> <string name="details.song">Dal</string> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d372940f..b987bad6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -225,6 +225,7 @@ <string name="download.playback_speed_one_half">1.5x</string> <string name="download.playback_speed_double">2x</string> <string name="download.playback_speed_tripple">3x</string> + <string name="download.playback_speed_custom">Custom</string> <string name="sync.new_podcasts">New podcasts available</string> <string name="sync.new_playlists">New songs in playlists</string> |