tidy up once more
authortobiasKaminsky <tobias@kaminsky.me>
Sun, 1 Nov 2015 07:52:04 +0000 (08:52 +0100)
committertobiasKaminsky <tobias@kaminsky.me>
Sun, 1 Nov 2015 07:52:04 +0000 (08:52 +0100)
res/values/strings.xml
src/com/owncloud/android/media/MediaService.java
src/com/owncloud/android/ui/fragment/OCFileListFragment.java
src/com/owncloud/android/ui/preview/PreviewMediaFragment.java
src/com/owncloud/android/ui/preview/PreviewVideoActivity.java

index 340468f..cbf2097 100644 (file)
     <string name="file_list__footer__files_and_folder">%1$d files, 1 folder</string>
     <string name="file_list__footer__files_and_folders">%1$d files, %2$d folders</string>
     <string name="action_stream_file">Stream file with external player</string>
     <string name="file_list__footer__files_and_folder">%1$d files, 1 folder</string>
     <string name="file_list__footer__files_and_folders">%1$d files, %2$d folders</string>
     <string name="action_stream_file">Stream file with external player</string>
-    <string name="stream_expose_password">May expose password?</string>
+    <string name="stream_expose_password">Do you want to stream this file with an external app?\n\nCAUTION: This may expose your password!</string>
 
 </resources>
 
 </resources>
index 15fad66..7bd9c0c 100644 (file)
@@ -454,11 +454,6 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
         releaseResources(false); // release everything except MediaPlayer
 
         try {
         releaseResources(false); // release everything except MediaPlayer
 
         try {
-//            if (mFile == null) {
-//                Toast.makeText(this, R.string.media_err_nothing_to_play, Toast.LENGTH_LONG).show();
-//                processStopRequest(true);
-//                return;
-                
             if (mAccount == null) {
                 Toast.makeText(this, R.string.media_err_not_in_owncloud, Toast.LENGTH_LONG).show();
                 processStopRequest(true);
             if (mAccount == null) {
                 Toast.makeText(this, R.string.media_err_not_in_owncloud, Toast.LENGTH_LONG).show();
                 processStopRequest(true);
@@ -468,7 +463,7 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
             createMediaPlayerIfNeeded();
             mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
             String url = mFile.getStoragePath();
             createMediaPlayerIfNeeded();
             mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
             String url = mFile.getStoragePath();
-            // Streaming is not possible right now
+
             if (url == null || url.length() <= 0) {
                 url = AccountUtils.constructFullURLForAccount(this, mAccount) + mFile.getRemotePath();
             }
             if (url == null || url.length() <= 0) {
                 url = AccountUtils.constructFullURLForAccount(this, mAccount) + mFile.getRemotePath();
             }
index feabc5b..fe3200b 100644 (file)
@@ -48,6 +48,7 @@ import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.files.FileMenuFilter;
 import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.lib.resources.status.OwnCloudVersion;
 import com.owncloud.android.files.FileMenuFilter;
 import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.lib.resources.status.OwnCloudVersion;
+import com.owncloud.android.media.MediaService;
 import com.owncloud.android.ui.activity.FileActivity;
 import com.owncloud.android.ui.activity.FileDisplayActivity;
 import com.owncloud.android.ui.activity.FolderPickerActivity;
 import com.owncloud.android.ui.activity.FileActivity;
 import com.owncloud.android.ui.activity.FileDisplayActivity;
 import com.owncloud.android.ui.activity.FolderPickerActivity;
@@ -392,30 +393,10 @@ public class OCFileListFragment extends ExtendedListFragment implements FileActi
                 return true;
             }
             case R.id.action_stream_file: {
                 return true;
             }
             case R.id.action_stream_file: {
-                AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
-                builder.setMessage("May expose password?")
-                        .setPositiveButton("Stream", new DialogInterface.OnClickListener() {
-                            public void onClick(DialogInterface dialog, int id) {
-                                Account account = ((FileActivity)mContainerActivity).getAccount();
-                                Context context = MainApp.getAppContext();
-                                String uri = PreviewMediaFragment.generateUrlWithCredentials(account, context, mTargetFile);
-
-                                Intent i = new Intent(android.content.Intent.ACTION_VIEW);
-                                i.setData(Uri.parse(uri));
-                                startActivity(i);
-
-//                    Intent i = new Intent(Intent.ACTION_VIEW);
-//                    i.setComponent(new ComponentName("org.videolan.vlc", "org.videolan.vlc.gui.video.VideoPlayerActivity"));
-//                    i.setData(Uri.parse(uri));
-//                    startActivity(i);
-                            }
-                        })
-                        .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
-                            public void onClick(DialogInterface dialog, int id) {
-                                // User cancelled the dialog
-                            }
-                        });
-                builder.show();
+                Account account = ((FileActivity)mContainerActivity).getAccount();
+                Context context = MainApp.getAppContext();
+                String uri = PreviewMediaFragment.generateUrlWithCredentials(account, context, mTargetFile);
+                MediaService.streamWithExternalApp(uri, getActivity()).show();
 
                 return true;
             }
 
                 return true;
             }
@@ -550,7 +531,7 @@ public class OCFileListFragment extends ExtendedListFragment implements FileActi
 
             // decide grid vs list view
             OwnCloudVersion version = AccountUtils.getServerVersion(
 
             // decide grid vs list view
             OwnCloudVersion version = AccountUtils.getServerVersion(
-                    ((FileActivity) mContainerActivity).getAccount());
+                    ((FileActivity)mContainerActivity).getAccount());
             if (version != null && version.supportsRemoteThumbnails() &&
                 imagesCount > 0 && imagesCount == filesCount) {
                 switchToGridView();
             if (version != null && version.supportsRemoteThumbnails() &&
                 imagesCount > 0 && imagesCount == filesCount) {
                 switchToGridView();
index 21be61d..3f0ffc5 100644 (file)
@@ -199,10 +199,6 @@ public class PreviewMediaFragment extends FileFragment implements
             if (mAccount == null) {
                 throw new IllegalStateException("Instanced with a NULL ownCloud Account");
             }
             if (mAccount == null) {
                 throw new IllegalStateException("Instanced with a NULL ownCloud Account");
             }
-//            if (!file.isDown()) {
-//                throw new IllegalStateException("There is no local file to preview");
-//            }
-
         }
         else {
             file = (OCFile) savedInstanceState.getParcelable(PreviewMediaFragment.EXTRA_FILE);
         }
         else {
             file = (OCFile) savedInstanceState.getParcelable(PreviewMediaFragment.EXTRA_FILE);
@@ -515,7 +511,7 @@ public class PreviewMediaFragment extends FileFragment implements
          * <p/>
          * Just starts the playback.
          *
          * <p/>
          * Just starts the playback.
          *
-         * @param vp {@link MediaPlayer} instance performing the playback.
+         * @param   vp    {@link MediaPlayer} instance performing the playback.
          */
         @Override
         public void onPrepared(MediaPlayer vp) {
          */
         @Override
         public void onPrepared(MediaPlayer vp) {
@@ -546,7 +542,8 @@ public class PreviewMediaFragment extends FileFragment implements
                 if (Build.VERSION.SDK_INT == Build.VERSION_CODES.GINGERBREAD) {
                     mVideoPreview.pause();
 
                 if (Build.VERSION.SDK_INT == Build.VERSION_CODES.GINGERBREAD) {
                     mVideoPreview.pause();
 
-                } else {
+                }
+                else {
                     if (Build.VERSION.SDK_INT == Build.VERSION_CODES.GINGERBREAD_MR1) {
                         // mVideePreview.pause() is not enough
 
                     if (Build.VERSION.SDK_INT == Build.VERSION_CODES.GINGERBREAD_MR1) {
                         // mVideePreview.pause() is not enough
 
@@ -571,37 +568,8 @@ public class PreviewMediaFragment extends FileFragment implements
          */
         @Override
         public boolean onError(MediaPlayer mp, int what, int extra) {
          */
         @Override
         public boolean onError(MediaPlayer mp, int what, int extra) {
-//            if (mVideoPreview.getWindowToken() != null) {
-                // try to open with another app
-//                try{
-//                    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
-//                    builder.setMessage("May expose password?")
-//                            .setPositiveButton("Stream", new DialogInterface.OnClickListener() {
-//                                public void onClick(DialogInterface dialog, int id) {
-//                                    Intent i = new Intent(android.content.Intent.ACTION_VIEW);
-//                                    i.setData(Uri.parse(mUri));
-//                                    startActivity(i);
-//                                }
-//                            })
-//                            .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
-//                                public void onClick(DialogInterface dialog, int id) {
-//                                    // User cancelled the dialog
-//                                }
-//                            });
-//                    builder.show();
-
-                MediaService.streamWithExternalApp(mUri, getActivity()).show();
-
-//                }
-//                catch (ActivityNotFoundException e){
-//                    Intent i = new Intent(android.content.Intent.ACTION_VIEW);
-//                    i.setData(Uri.parse(mUri));
-//                    startActivity(i);
-//                }
-//            }
-//            }
+            MediaService.streamWithExternalApp(mUri, getActivity()).show();
             return true;
             return true;
-
         }
     }
 
         }
     }
 
index 4ba5326..383b082 100644 (file)
@@ -207,15 +207,9 @@ public class PreviewVideoActivity extends FileActivity implements OnCompletionLi
                     mVideoPlayer.setVideoPath(file.getStoragePath());
                     
                 } else {
                     mVideoPlayer.setVideoPath(file.getStoragePath());
                     
                 } else {
-                    // not working yet
                     String url;
                     String url;
-//                    try {
-//                        url = AccountUtils.constructFullURLForAccount(this, getAccount()) + file.getRemotePath();
-                        url = PreviewMediaFragment.generateUrlWithCredentials(getAccount(), getApplicationContext(), getFile());
-                        mVideoPlayer.setVideoURI(Uri.parse(url));
-//                    } catch (AccountNotFoundException e) {
-//                        onError(null, MediaService.OC_MEDIA_ERROR, R.string.media_err_no_account);
-//                    }
+                    url = PreviewMediaFragment.generateUrlWithCredentials(getAccount(), getApplicationContext(), getFile());
+                    mVideoPlayer.setVideoURI(Uri.parse(url));
                 }
                 
                 // create and prepare control panel for the user
                 }
                 
                 // create and prepare control panel for the user