[Android] Play last video feature

Geoffrey Métais git at videolan.org
Tue Mar 17 13:30:40 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Mar 17 11:46:27 2015 +0100| [daebce9d988306c09c083729a055fa295d73c106] | committer: Geoffrey Métais

Play last video feature

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=daebce9d988306c09c083729a055fa295d73c106
---

 .../src/org/videolan/vlc/gui/MainActivity.java     |   21 ++++++++++++++------
 .../org/videolan/vlc/gui/PreferencesActivity.java  |    1 +
 .../vlc/gui/video/VideoPlayerActivity.java         |    2 ++
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index e2ac940..09d90ca 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -29,6 +29,7 @@ import android.content.IntentFilter;
 import android.content.SharedPreferences;
 import android.content.SharedPreferences.Editor;
 import android.database.Cursor;
+import android.net.Uri;
 import android.os.Build;
 import android.os.Bundle;
 import android.os.Handler;
@@ -72,12 +73,14 @@ import org.videolan.vlc.audio.AudioService;
 import org.videolan.vlc.audio.AudioServiceController;
 import org.videolan.vlc.gui.SidebarAdapter.SidebarEntry;
 import org.videolan.vlc.gui.audio.AudioAlbumsSongsFragment;
+import org.videolan.vlc.gui.audio.AudioBrowserFragment;
 import org.videolan.vlc.gui.audio.AudioPlayer;
 import org.videolan.vlc.gui.audio.EqualizerFragment;
 import org.videolan.vlc.gui.network.NetworkFragment;
 import org.videolan.vlc.gui.video.MediaInfoFragment;
 import org.videolan.vlc.gui.video.VideoGridFragment;
 import org.videolan.vlc.gui.video.VideoListAdapter;
+import org.videolan.vlc.gui.video.VideoPlayerActivity;
 import org.videolan.vlc.interfaces.IRefreshable;
 import org.videolan.vlc.interfaces.ISortable;
 import org.videolan.vlc.util.AndroidDevices;
@@ -269,8 +272,7 @@ public class MainActivity extends ActionBarActivity implements OnItemClickListen
     }
 
     private void applyTheme() {
-        SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
-        boolean enableBlackTheme = pref.getBoolean("enable_black_theme", false);
+        boolean enableBlackTheme = mSettings.getBoolean("enable_black_theme", false);
         if (enableBlackTheme) {
             setTheme(R.style.Theme_VLC_Black);
         }
@@ -527,7 +529,8 @@ public class MainActivity extends ActionBarActivity implements OnItemClickListen
             menu.findItem(R.id.ml_menu_save).setVisible(false);
         if (current instanceof MRLPanelFragment)
             menu.findItem(R.id.ml_menu_clean).setVisible(!((MRLPanelFragment) current).isEmpty());
-        menu.findItem(R.id.ml_menu_last_playlist).setVisible(SidebarEntry.ID_AUDIO.equals(mCurrentFragment));
+        boolean showLast = current instanceof AudioBrowserFragment || (current instanceof VideoGridFragment && mSettings.getString(PreferencesActivity.VIDEO_LAST, null) != null);
+        menu.findItem(R.id.ml_menu_last_playlist).setVisible(showLast);
 
 
 
@@ -568,8 +571,14 @@ public class MainActivity extends ActionBarActivity implements OnItemClickListen
                 break;
             // Restore last playlist
             case R.id.ml_menu_last_playlist:
-                Intent i = new Intent(AudioService.ACTION_REMOTE_LAST_PLAYLIST);
-                sendBroadcast(i);
+                if (current instanceof AudioBrowserFragment) {
+                    Intent i = new Intent(AudioService.ACTION_REMOTE_LAST_PLAYLIST);
+                    sendBroadcast(i);
+                } else if (current instanceof VideoGridFragment) {
+                    String location = Uri.decode(mSettings.getString(PreferencesActivity.VIDEO_LAST, null));
+                    if (location != null)
+                        VideoPlayerActivity.start(this, location);
+                }
                 break;
             case android.R.id.home:
                 // Slide down the audio player.
@@ -935,7 +944,7 @@ public class MainActivity extends ActionBarActivity implements OnItemClickListen
                 @Override
                 public void onClick(View v) {
                     removeTipViewIfDisplayed();
-                    Editor editor = PreferenceManager.getDefaultSharedPreferences(MainActivity.this).edit();
+                    Editor editor = mSettings.edit();
                     editor.putBoolean(settingKey, true);
                     Util.commitPreferences(editor);
                 }
diff --git a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
index 8b3828c..a99689c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
@@ -71,6 +71,7 @@ public class PreferencesActivity extends PreferenceActivity implements OnSharedP
     public final static String VIDEO_RESUME_TIME = "VideoResumeTime";
     public final static String VIDEO_PAUSED = "VideoPaused";
     public final static String VIDEO_SUBTITLE_FILES = "VideoSubtitleFiles";
+    public final static String VIDEO_LAST = "VideoLastPlayed";
     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/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 2aba34f..4a84277 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -730,6 +730,8 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
         }
         editor.putString(PreferencesActivity.VIDEO_SUBTITLE_FILES, subtitleList_serialized);
 
+        editor.putString(PreferencesActivity.VIDEO_LAST, Uri.encode(mLocation));
+
         Util.commitPreferences(editor);
     }
 



More information about the Android mailing list