[Android] Add an option to disable playback history
Geoffrey Métais
git at videolan.org
Wed Jan 6 11:15:48 CET 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jan 6 10:54:09 2016 +0100| [bbce0f84da0ece73389ab38666b77b423c8fc183] | committer: Geoffrey Métais
Add an option to disable playback history
> https://code.videolan.org/videolan/vlc-android/commit/bbce0f84da0ece73389ab38666b77b423c8fc183
---
.../videolan/vlc/gui/preferences/PreferencesActivity.java | 1 +
vlc-android/res/values/strings.xml | 4 ++++
vlc-android/res/xml/preferences.xml | 6 ++++++
vlc-android/src/org/videolan/vlc/PlaybackService.java | 13 +++++++------
vlc-android/src/org/videolan/vlc/gui/MainActivity.java | 3 +++
.../videolan/vlc/gui/preferences/PreferencesFragment.java | 3 +++
6 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/vlc-android/flavors/vanilla/src/org/videolan/vlc/gui/preferences/PreferencesActivity.java b/vlc-android/flavors/vanilla/src/org/videolan/vlc/gui/preferences/PreferencesActivity.java
index d0a7aec..73edb2f 100644
--- a/vlc-android/flavors/vanilla/src/org/videolan/vlc/gui/preferences/PreferencesActivity.java
+++ b/vlc-android/flavors/vanilla/src/org/videolan/vlc/gui/preferences/PreferencesActivity.java
@@ -45,6 +45,7 @@ public class PreferencesActivity extends AppCompatActivity implements PlaybackSe
public final static String VIDEO_BACKGROUND = "video_background";
public final static String VIDEO_RESTORE = "video_restore";
public final static String AUTO_RESCAN = "auto_rescan";
+ public final static String PLAYBACK_HISTORY = "playback_history";
public final static int RESULT_RESCAN = RESULT_FIRST_USER + 1;
public final static int RESULT_RESTART = RESULT_FIRST_USER + 2;
diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index c8d8194..a81453f 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -175,6 +175,10 @@
<string name="search">Search</string>
<string name="search_history">Search history</string>
+
+ <string name="playback_history_title">Playback history</string>
+ <string name="playback_history_summary">Save all media played in History section</string>
+
<!-- Tips -->
<string name="video_player_tips">Video player tips:</string>
<string name="seek">Seek</string>
diff --git a/vlc-android/res/xml/preferences.xml b/vlc-android/res/xml/preferences.xml
index 46a4931..fb2a06d 100644
--- a/vlc-android/res/xml/preferences.xml
+++ b/vlc-android/res/xml/preferences.xml
@@ -16,6 +16,12 @@
android:title="@string/hardware_acceleration" />
<CheckBoxPreference
+ android:defaultValue="true"
+ android:key="playback_history"
+ android:summary="@string/playback_history_summary"
+ android:title="@string/playback_history_title" />
+
+ <CheckBoxPreference
android:defaultValue="false"
android:key="video_background"
android:summary="@string/play_as_audio_background_summary"
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index cd9414b..f050a71 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -1655,12 +1655,13 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
notifyTrackChanged();
determinePrevAndNextIndices();
- VLCApplication.runBackground(new Runnable() {
- @Override
- public void run() {
- MediaDatabase.getInstance().addHistoryItem(mw);
- }
- });
+ if (mSettings.getBoolean(PreferencesActivity.PLAYBACK_HISTORY, true))
+ VLCApplication.runBackground(new Runnable() {
+ @Override
+ public void run() {
+ MediaDatabase.getInstance().addHistoryItem(mw);
+ }
+ });
} else {//Start VideoPlayer for first video, it will trigger playIndex when ready.
VideoPlayerActivity.startOpened(VLCApplication.getAppContext(),
getCurrentMediaWrapper().getUri(), mCurrentIndex);
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index a102d7a..6a1dc5f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -236,6 +236,9 @@ public class MainActivity extends AudioPlayerContainerActivity implements Search
mNavigationView.getMenu().findItem(R.id.nav_network).setVisible(true);
}
+ mNavigationView.getMenu().findItem(R.id.nav_history).setVisible(mSettings.getBoolean(PreferencesActivity.PLAYBACK_HISTORY, true));
+
+
if (AndroidUtil.isLolliPopOrLater())
mNavigationView.setPadding(0, mNavigationView.getPaddingTop()/2, 0, 0);
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesFragment.java b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesFragment.java
index 507a6ff..b7a6f2d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesFragment.java
@@ -112,6 +112,9 @@ public class PreferencesFragment extends BasePreferenceFragment implements Share
case "dev_category":
loadFragment(new Developer());
break;
+ case PreferencesActivity.PLAYBACK_HISTORY:
+ getActivity().setResult(PreferencesActivity.RESULT_RESTART);
+ return true;
default:
return super.onPreferenceTreeClick(preference);
}
More information about the Android
mailing list