use overflow for video player

This commit is contained in:
Andrew Dolgov 2015-12-02 16:12:43 +03:00
parent 863860201a
commit 13da30911a
4 changed files with 53 additions and 24 deletions

View File

@ -393,9 +393,6 @@ public class ArticleImagesPagerActivity extends CommonActivity implements Gestur
public boolean onImageMenuItemSelected(MenuItem item, String url) {
switch (item.getItemId()) {
/*case android.R.id.home:
onBackPressed();
return true;*/
case R.id.article_img_open:
if (url != null) {
try {
@ -416,15 +413,14 @@ public class ArticleImagesPagerActivity extends CommonActivity implements Gestur
shareText(url);
}
return true;
// TODO: this needs access to article text, I'm afraid
case R.id.article_img_view_caption:
if (url != null) {
displayImageCaption(url, m_content);
}
return true;
default:
Log.d(TAG, "onContextItemSelected, unhandled id=" + item.getItemId());
return super.onContextItemSelected(item);
Log.d(TAG, "onImageMenuItemSelected, unhandled id=" + item.getItemId());
return false;
}
}

View File

@ -11,12 +11,14 @@ import android.util.Log;
import android.view.ContextMenu;
import android.view.Display;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.MediaController;
import android.widget.PopupMenu;
import java.io.IOException;
@ -40,9 +42,7 @@ public class VideoPlayerActivity extends CommonActivity {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (!isPortrait())
getSupportActionBar().hide();
getSupportActionBar().hide();
surfaceView = (SurfaceView) findViewById(R.id.video_player);
registerForContextMenu(surfaceView);
@ -55,6 +55,25 @@ public class VideoPlayerActivity extends CommonActivity {
m_streamUri = savedInstanceState.getString("streamUri");
}
findViewById(R.id.video_player_overflow).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PopupMenu popup = new PopupMenu(VideoPlayerActivity.this, v);
MenuInflater inflater = popup.getMenuInflater();
inflater.inflate(R.menu.activity_video_player, popup.getMenu());
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
return onVideoMenuItemSelected(item);
}
});
popup.show();
}
});
final MediaController mediaController = new MediaController(this);
surfaceView.setOnClickListener(new View.OnClickListener() {
@ -182,11 +201,6 @@ public class VideoPlayerActivity extends CommonActivity {
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (!isPortrait())
getSupportActionBar().hide();
else
getSupportActionBar().show();
resizeSurface();
}
@ -198,7 +212,7 @@ public class VideoPlayerActivity extends CommonActivity {
}
@Override
/*@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_video_player, menu);
return true;
@ -218,14 +232,10 @@ public class VideoPlayerActivity extends CommonActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
return onContextItemSelected(item); // this is really bad :()
}
} */
@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
public boolean onVideoMenuItemSelected(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 {
@ -236,14 +246,19 @@ public class VideoPlayerActivity extends CommonActivity {
}
}
return true;
case R.id.article_vid_copy:
if (m_streamUri != null) {
copyToClipboard(m_streamUri);
}
return true;
case R.id.article_vid_share:
if (m_streamUri != null) {
shareText(m_streamUri);
}
return true;
default:
Log.d(TAG, "onContextItemSelected, unhandled id=" + item.getItemId());
return super.onContextItemSelected(item);
Log.d(TAG, "onVideoMenuItemSelected, unhandled id=" + item.getItemId());
return false;
}
}

View File

@ -23,6 +23,19 @@
android:id="@+id/video_loading"
android:layout_gravity="center"
android:indeterminate="true" />
<ImageView
android:id="@+id/video_player_overflow"
android:clickable="true"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:layout_weight="0"
android:background="@drawable/ripple"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:src="@drawable/ic_dots_vertical"
android:layout_gravity="right|bottom"
android:layout_marginBottom="8dp" />
</FrameLayout>
<include layout="@layout/toolbar" android:id="@+id/toolbar" />

View File

@ -6,7 +6,12 @@
<item
android:id="@+id/article_vid_open"
app:showAsAction=""
android:title="@string/video_player_open"/>
android:title="@string/open_with"/>
<item
android:id="@+id/article_vid_copy"
app:showAsAction=""
android:icon="@drawable/ic_content_copy"
android:title="@string/article_link_copy"/>
<item
android:id="@+id/article_vid_share"
android:icon="@drawable/ic_share"