diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8510884d0..b017bb86a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -50,5 +50,18 @@ + + + + + + + + + + + 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 3f5d3a849..31435c2cb 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoActivity.java @@ -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())); } diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/VideoActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/VideoActivity.java new file mode 100644 index 000000000..f1f53c02d --- /dev/null +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/VideoActivity.java @@ -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()); + } +} diff --git a/app/src/main/res/layout/activity_medium.xml b/app/src/main/res/layout/activity_medium.xml index 884715a3f..4edfd536b 100644 --- a/app/src/main/res/layout/activity_medium.xml +++ b/app/src/main/res/layout/activity_medium.xml @@ -1,6 +1,6 @@