diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 59a0a2ae8..27f95db18 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -49,6 +49,9 @@
android:label="@string/third_party_licences"
android:screenOrientation="portrait"/>
+
+
diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoActivity.java
index 3fd6a5bc0..91dcd54c5 100644
--- a/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoActivity.java
+++ b/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoActivity.java
@@ -1,91 +1,12 @@
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.PhotoFragment;
-import com.simplemobiletools.gallery.fragments.ViewPagerFragment;
-import com.simplemobiletools.gallery.models.Medium;
-
-public class PhotoActivity extends AppCompatActivity implements ViewPagerFragment.FragmentClickListener {
- private static ActionBar mActionbar;
- private static Uri mUri;
-
- private static boolean mIsFullScreen;
+public class PhotoActivity extends PhotoVideoActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
+ mIsVideo = false;
super.onCreate(savedInstanceState);
- setContentView(R.layout.fragment_holder);
-
- mUri = getIntent().getData();
- if (mUri == null)
- return;
-
- mActionbar = getSupportActionBar();
- mIsFullScreen = true;
- hideSystemUI();
-
- final Bundle bundle = new Bundle();
- final Medium medium = new Medium(mUri.toString(), false, 0);
- bundle.putSerializable(Constants.MEDIUM, medium);
- final ViewPagerFragment fragment = new PhotoFragment();
- fragment.setListener(this);
- fragment.setArguments(bundle);
- getSupportFragmentManager().beginTransaction().replace(R.id.fragment_holder, fragment).commit();
- hideSystemUI();
- setTitle(Utils.getFilename(mUri.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, mUri);
- sendIntent.setType("image/*");
- startActivity(Intent.createChooser(sendIntent, shareTitle));
- }
-
- @Override
- public void fragmentClicked() {
- mIsFullScreen = !mIsFullScreen;
- if (mIsFullScreen) {
- hideSystemUI();
- } else {
- showSystemUI();
- }
- }
-
- private void hideSystemUI() {
- Utils.hideSystemUI(mActionbar, getWindow());
- }
-
- private void showSystemUI() {
- Utils.showSystemUI(mActionbar, getWindow());
}
}
diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoVideoActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoVideoActivity.java
new file mode 100644
index 000000000..74c78a998
--- /dev/null
+++ b/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoVideoActivity.java
@@ -0,0 +1,94 @@
+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.PhotoFragment;
+import com.simplemobiletools.gallery.fragments.VideoFragment;
+import com.simplemobiletools.gallery.fragments.ViewPagerFragment;
+import com.simplemobiletools.gallery.models.Medium;
+
+public class PhotoVideoActivity extends AppCompatActivity implements ViewPagerFragment.FragmentClickListener {
+ private static ActionBar mActionbar;
+ private static Uri mUri;
+
+ private static boolean mIsFullScreen;
+
+ protected static boolean mIsVideo;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.fragment_holder);
+
+ mUri = getIntent().getData();
+ if (mUri == null)
+ return;
+
+ mActionbar = getSupportActionBar();
+ mIsFullScreen = true;
+ hideSystemUI();
+
+ final Bundle bundle = new Bundle();
+ final Medium medium = new Medium(mUri.toString(), mIsVideo, 0);
+ bundle.putSerializable(Constants.MEDIUM, medium);
+ final ViewPagerFragment fragment = (mIsVideo ? new VideoFragment() : new PhotoFragment());
+ fragment.setListener(this);
+ fragment.setArguments(bundle);
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_holder, fragment).commit();
+ hideSystemUI();
+ setTitle(Utils.getFilename(mUri.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, mUri);
+ sendIntent.setType(mIsVideo ? "video/*" : "image/*");
+ startActivity(Intent.createChooser(sendIntent, shareTitle));
+ }
+
+ @Override
+ public void fragmentClicked() {
+ mIsFullScreen = !mIsFullScreen;
+ if (mIsFullScreen) {
+ hideSystemUI();
+ } else {
+ showSystemUI();
+ }
+ }
+
+ private void hideSystemUI() {
+ Utils.hideSystemUI(mActionbar, getWindow());
+ }
+
+ private void showSystemUI() {
+ Utils.showSystemUI(mActionbar, getWindow());
+ }
+}
diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/VideoActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/VideoActivity.java
index e0297237f..bea0ab11f 100644
--- a/app/src/main/java/com/simplemobiletools/gallery/activities/VideoActivity.java
+++ b/app/src/main/java/com/simplemobiletools/gallery/activities/VideoActivity.java
@@ -1,91 +1,12 @@
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 static ActionBar mActionbar;
- private static Uri mUri;
-
- private static boolean mIsFullScreen;
+public class VideoActivity extends PhotoVideoActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
+ mIsVideo = true;
super.onCreate(savedInstanceState);
- setContentView(R.layout.fragment_holder);
-
- mUri = getIntent().getData();
- if (mUri == null)
- return;
-
- mActionbar = getSupportActionBar();
- mIsFullScreen = true;
- hideSystemUI();
-
- final Bundle bundle = new Bundle();
- final Medium medium = new Medium(mUri.toString(), true, 0);
- 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(mUri.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, mUri);
- sendIntent.setType("video/*");
- startActivity(Intent.createChooser(sendIntent, shareTitle));
- }
-
- @Override
- public void fragmentClicked() {
- mIsFullScreen = !mIsFullScreen;
- if (mIsFullScreen) {
- hideSystemUI();
- } else {
- showSystemUI();
- }
- }
-
- private void hideSystemUI() {
- Utils.hideSystemUI(mActionbar, getWindow());
- }
-
- private void showSystemUI() {
- Utils.showSystemUI(mActionbar, getWindow());
}
}