summaryrefslogtreecommitdiff
path: root/org.fox.ttrss/src
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2015-07-10 09:47:35 +0300
committerAndrew Dolgov <[email protected]>2015-07-10 09:48:05 +0300
commit5e5c76c7e2043bc05bf70637ccc8eb4c27165c82 (patch)
tree8f09906e656ebb3c422a2055648cb687417bf074 /org.fox.ttrss/src
parent5c0768b40d305f6a93957d8e3426d2ae493a15bf (diff)
replace inline video player with a separate activity
Diffstat (limited to 'org.fox.ttrss/src')
-rwxr-xr-xorg.fox.ttrss/src/main/AndroidManifest.xml28
-rwxr-xr-xorg.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java77
-rw-r--r--org.fox.ttrss/src/main/java/org/fox/ttrss/VideoPlayerActivity.java146
-rw-r--r--org.fox.ttrss/src/main/res/layout/activity_video_player.xml30
-rw-r--r--org.fox.ttrss/src/main/res/menu/activity_video_player.xml15
-rwxr-xr-xorg.fox.ttrss/src/main/res/values/strings.xml4
6 files changed, 224 insertions, 76 deletions
diff --git a/org.fox.ttrss/src/main/AndroidManifest.xml b/org.fox.ttrss/src/main/AndroidManifest.xml
index 5c1c658d..73a7d9aa 100755
--- a/org.fox.ttrss/src/main/AndroidManifest.xml
+++ b/org.fox.ttrss/src/main/AndroidManifest.xml
@@ -21,9 +21,9 @@
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
- android:theme="@android:style/Theme.NoDisplay"
android:name=".LaunchActivity"
- android:label="@string/app_name" >
+ android:label="@string/app_name"
+ android:theme="@android:style/Theme.NoDisplay" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -40,7 +40,7 @@
</activity>
<activity
android:name=".MasterActivity"
- android:label="@string/app_name">
+ android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
@@ -48,7 +48,7 @@
<activity
android:name=".DetailActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
- android:label="@string/app_name">
+ android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
@@ -70,11 +70,11 @@
</activity>
<activity
android:name=".offline.OfflineMasterActivity"
- android:label="@string/app_name">
+ android:label="@string/app_name" >
</activity>
<activity
android:name=".offline.OfflineDetailActivity"
- android:label="@string/app_name">
+ android:label="@string/app_name" >
</activity>
<activity
android:name=".share.ShareActivity"
@@ -256,13 +256,17 @@
android:name=".ArticleImagesPagerActivity"
android:label="Article Images" >
</activity>
-
- <activity android:name="org.acra.CrashReportDialog"
- android:theme="@style/DarkDialogTheme"
- android:launchMode="singleInstance"
+ <activity
+ android:name="org.acra.CrashReportDialog"
android:excludeFromRecents="true"
- android:finishOnTaskLaunch="true" />
-
+ android:finishOnTaskLaunch="true"
+ android:launchMode="singleInstance"
+ android:theme="@style/DarkDialogTheme" />
+ <activity
+ android:name=".VideoPlayerActivity"
+ android:configChanges="keyboardHidden|orientation|screenSize"
+ android:label="@string/title_activity_video_player" >
+ </activity>
</application>
</manifest>
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java
index 1fcdd721..45fb5480 100755
--- a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java
+++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java
@@ -1037,7 +1037,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
try {
Element source = video.select("source").first();
- String streamUri = source.attr("src");
+ final String streamUri = source.attr("src");
String posterUri = video.attr("poster");
if (streamUri != null && posterUri != null) {
@@ -1056,11 +1056,22 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
holder.flavorImageView.setVisibility(View.VISIBLE);
holder.flavorVideoPlayView.setVisibility(View.VISIBLE);
+ ViewCompat.setTransitionName(holder.flavorImageView, "TRANSITION:ARTICLE_VIDEO_PLAYER");
+
holder.flavorImageView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
- //
+ Intent intent = new Intent(m_activity, VideoPlayerActivity.class);
+ intent.putExtra("streamUri", streamUri);
+ intent.putExtra("title", article.title);
+
+ ActivityOptionsCompat options =
+ ActivityOptionsCompat.makeSceneTransitionAnimation(m_activity,
+ holder.flavorImageView, // The view which starts the transition
+ "TRANSITION:ARTICLE_VIDEO_PLAYER" // The transitionName of the view we’re transitioning to
+ );
+ ActivityCompat.startActivity(m_activity, intent, options.toBundle());
}
});
@@ -1075,68 +1086,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
}
- /* if (m_prefs.getBoolean("enable_headlines_video", false) && article.articleDoc != null && holder.flavorVideoView != null) {
- Element source = article.articleDoc.select("video > source").first();
-
- if (source != null) {
- try {
- Uri streamUri = Uri.parse(source.attr("src"));
-
- if (streamUri != null) {
- videoFound = true;
-
- holder.flavorImageLoadingBar.setVisibility(View.GONE);
- holder.flavorVideoView.setVisibility(View.VISIBLE);
- holder.flavorImageView.setVisibility(View.GONE);
- holder.flavorVideoPlayView.setVisibility(View.VISIBLE);
-
- if (!streamUri.equals(holder.flavorVideoView.getTag())) {
- holder.flavorVideoView.setTag(streamUri);
-
- holder.flavorVideoView.setVideoURI(streamUri);
-
- holder.flavorVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
- @Override
- public void onPrepared(MediaPlayer mp) {
- //mp.setLooping(true);
- mp.seekTo(1000);
- }
- });
-
- holder.flavorVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
- @Override
- public void onCompletion(MediaPlayer mp) {
- mp.seekTo(0);
- }
- });
-
- holder.flavorVideoView.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- VideoView video = (VideoView) v;
-
- if (event.getAction() == MotionEvent.ACTION_DOWN) {
- if (video.isPlaying()) {
- video.pause();
- holder.flavorVideoPlayView.setVisibility(View.VISIBLE);
- } else {
- video.start();
- holder.flavorVideoPlayView.setVisibility(View.GONE);
- }
- }
-
- return true;
- }
- });
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- videoFound = false;
- }
- }
- } */
-
if (!videoFound && showFlavorImage && holder.flavorImageView != null) {
holder.flavorImageArrow.setVisibility(View.GONE);
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/VideoPlayerActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/VideoPlayerActivity.java
new file mode 100644
index 00000000..81aa09cc
--- /dev/null
+++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/VideoPlayerActivity.java
@@ -0,0 +1,146 @@
+package org.fox.ttrss;
+
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.media.MediaPlayer;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.v7.widget.Toolbar;
+import android.util.Log;
+import android.view.ContextMenu;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.MediaController;
+import android.widget.VideoView;
+
+
+public class VideoPlayerActivity extends CommonActivity {
+
+ private final String TAG = this.getClass().getSimpleName();
+ private String m_streamUri;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+
+ setTheme(R.style.DarkTheme);
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_video_player);
+
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+
+ if (!isPortrait())
+ getSupportActionBar().hide();
+
+ VideoView videoView = (VideoView) findViewById(R.id.video_player);
+ registerForContextMenu(videoView); // doesn't work :[
+
+ setTitle(getIntent().getStringExtra("title"));
+
+ if (savedInstanceState == null) {
+ m_streamUri = getIntent().getStringExtra("streamUri");
+ } else {
+ m_streamUri = savedInstanceState.getString("streamUri");
+ }
+
+ final MediaController mediaController = new MediaController(this);
+ mediaController.setAnchorView(videoView);
+ videoView.setMediaController(mediaController);
+ videoView.setVideoURI(Uri.parse(m_streamUri));
+
+ videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
+ @Override
+ public void onPrepared(MediaPlayer mp) {
+ mp.setLooping(true);
+ }
+ });
+
+ videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
+ @Override
+ public void onCompletion(MediaPlayer mp) {
+ mp.seekTo(0);
+ }
+ });
+
+ videoView.start();
+ }
+
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+
+ if (!isPortrait())
+ getSupportActionBar().hide();
+ else
+ getSupportActionBar().show();
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle out) {
+ super.onSaveInstanceState(out);
+
+ out.putString("streamUri", m_streamUri);
+ }
+
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.activity_video_player, menu);
+ return true;
+ }
+
+
+ @Override
+ public void onCreateContextMenu(ContextMenu menu, View v,
+ ContextMenu.ContextMenuInfo menuInfo) {
+
+ getMenuInflater().inflate(R.menu.activity_video_player, menu);
+
+ super.onCreateContextMenu(menu, v, menuInfo);
+ }
+
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ return onContextItemSelected(item); // this is really bad :()
+ }
+
+ @Override
+ public boolean onContextItemSelected(android.view.MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ case R.id.article_vid_open:
+ if (m_streamUri != null) {
+ try {
+ Intent intent = new Intent(Intent.ACTION_VIEW,
+ Uri.parse(m_streamUri));
+ startActivity(intent);
+ } catch (Exception e) {
+ e.printStackTrace();
+ toast(R.string.error_other_error);
+ }
+ }
+ return true;
+ case R.id.article_vid_share:
+ if (m_streamUri != null) {
+ Intent intent = new Intent(Intent.ACTION_SEND);
+
+ intent.setType("video/mp4");
+ intent.putExtra(Intent.EXTRA_SUBJECT, m_streamUri);
+ intent.putExtra(Intent.EXTRA_TEXT, m_streamUri);
+
+ startActivity(Intent.createChooser(intent, m_streamUri));
+ }
+ return true;
+ default:
+ Log.d(TAG, "onContextItemSelected, unhandled id=" + item.getItemId());
+ return super.onContextItemSelected(item);
+ }
+ }
+
+}
diff --git a/org.fox.ttrss/src/main/res/layout/activity_video_player.xml b/org.fox.ttrss/src/main/res/layout/activity_video_player.xml
new file mode 100644
index 00000000..4954ae01
--- /dev/null
+++ b/org.fox.ttrss/src/main/res/layout/activity_video_player.xml
@@ -0,0 +1,30 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:fitsSystemWindows="true"
+ android:background="?android:colorBackground"
+ tools:context="org.fox.ttrss.VideoPlayerActivity">
+
+ <!--
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ -->
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_below="@+id/toolbar">
+
+ <VideoView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_gravity="center"
+ android:id="@+id/video_player"
+ android:transitionName="TRANSITION:ARTICLE_VIDEO_PLAYER" />
+ </FrameLayout>
+
+ <include layout="@layout/toolbar" android:id="@+id/toolbar" />
+
+</RelativeLayout>
diff --git a/org.fox.ttrss/src/main/res/menu/activity_video_player.xml b/org.fox.ttrss/src/main/res/menu/activity_video_player.xml
new file mode 100644
index 00000000..fb4da795
--- /dev/null
+++ b/org.fox.ttrss/src/main/res/menu/activity_video_player.xml
@@ -0,0 +1,15 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ tools:context="org.fox.ttrss.VideoPlayerActivity">
+
+ <item
+ android:id="@+id/article_vid_open"
+ app:showAsAction=""
+ android:title="Open video"/>
+ <item
+ android:id="@+id/article_vid_share"
+ android:icon="@drawable/ic_share"
+ app:showAsAction="ifRoom"
+ android:title="Share video"/>
+</menu>
diff --git a/org.fox.ttrss/src/main/res/values/strings.xml b/org.fox.ttrss/src/main/res/values/strings.xml
index 746451f8..31de7124 100755
--- a/org.fox.ttrss/src/main/res/values/strings.xml
+++ b/org.fox.ttrss/src/main/res/values/strings.xml
@@ -224,4 +224,8 @@
<string name="prefs_widget_show_fresh">Show Fresh articles</string>
<string name="prefs_widget_show_fresh_summary">Instead of total unread display amount of Fresh articles</string>
<string name="prefs_widget">Widget</string>
+ <string name="title_activity_video_player">Video Player</string>
+
+ <string name="hello_world">Hello world!</string>
+ <string name="action_settings">Settings</string>
</resources>