offer opening third party videos too with the gallery
This commit is contained in:
parent
d6a8683941
commit
74a4a5173c
5 changed files with 107 additions and 4 deletions
|
@ -50,5 +50,18 @@
|
|||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".activities.VideoActivity"
|
||||
android:theme="@style/FullScreenTheme">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
|
||||
<data android:mimeType="video/*"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
|
@ -23,7 +23,7 @@ public class PhotoActivity extends AppCompatActivity implements ViewPagerFragmen
|
|||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.photo_layout);
|
||||
setContentView(R.layout.fragment_holder);
|
||||
|
||||
uri = getIntent().getData();
|
||||
if (uri == null)
|
||||
|
@ -39,7 +39,7 @@ public class PhotoActivity extends AppCompatActivity implements ViewPagerFragmen
|
|||
final ViewPagerFragment fragment = new PhotoFragment();
|
||||
fragment.setListener(this);
|
||||
fragment.setArguments(bundle);
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.photo_holder, fragment).commit();
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_holder, fragment).commit();
|
||||
hideSystemUI();
|
||||
setTitle(Utils.getFilename(uri.toString()));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
package com.simplemobiletools.gallery.activities;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.simplemobiletools.gallery.Constants;
|
||||
import com.simplemobiletools.gallery.R;
|
||||
import com.simplemobiletools.gallery.Utils;
|
||||
import com.simplemobiletools.gallery.fragments.VideoFragment;
|
||||
import com.simplemobiletools.gallery.fragments.ViewPagerFragment;
|
||||
import com.simplemobiletools.gallery.models.Medium;
|
||||
|
||||
public class VideoActivity extends AppCompatActivity implements ViewPagerFragment.FragmentClickListener {
|
||||
private ActionBar actionbar;
|
||||
private boolean isFullScreen;
|
||||
private Uri uri;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.fragment_holder);
|
||||
|
||||
uri = getIntent().getData();
|
||||
if (uri == null)
|
||||
return;
|
||||
|
||||
actionbar = getSupportActionBar();
|
||||
isFullScreen = true;
|
||||
hideSystemUI();
|
||||
|
||||
final Bundle bundle = new Bundle();
|
||||
final Medium medium = new Medium(uri.toString(), true);
|
||||
bundle.putSerializable(Constants.MEDIUM, medium);
|
||||
final ViewPagerFragment fragment = new VideoFragment();
|
||||
fragment.setListener(this);
|
||||
fragment.setArguments(bundle);
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_holder, fragment).commit();
|
||||
hideSystemUI();
|
||||
setTitle(Utils.getFilename(uri.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.photo_video_menu, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_share:
|
||||
shareMedium();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void shareMedium() {
|
||||
final String shareTitle = getResources().getString(R.string.share_via);
|
||||
final Intent sendIntent = new Intent();
|
||||
sendIntent.setAction(Intent.ACTION_SEND);
|
||||
sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
|
||||
sendIntent.setType("video/*");
|
||||
startActivity(Intent.createChooser(sendIntent, shareTitle));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fragmentClicked() {
|
||||
isFullScreen = !isFullScreen;
|
||||
if (isFullScreen) {
|
||||
hideSystemUI();
|
||||
} else {
|
||||
showSystemUI();
|
||||
}
|
||||
}
|
||||
|
||||
private void hideSystemUI() {
|
||||
Utils.hideSystemUI(actionbar, getWindow());
|
||||
}
|
||||
|
||||
private void showSystemUI() {
|
||||
Utils.showSystemUI(actionbar, getWindow());
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
android:id="@+id/photo_holder"
|
||||
android:id="@+id/fragment_holder"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
android:id="@+id/photo_holder"
|
||||
android:id="@+id/fragment_holder"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
Loading…
Reference in a new issue