From 95ab204fc02573cf201fee907f7deaae6f7e06b0 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 23 Feb 2016 23:28:51 +0100 Subject: [PATCH] add a Share button to the menu --- app/src/main/AndroidManifest.xml | 3 +-- .../com/activities/ViewPagerActivity.java | 27 +++++++++++++++++++ app/src/main/res/menu/menu.xml | 10 +++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 app/src/main/res/menu/menu.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b77f34322..4c04053db 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -27,7 +27,6 @@ + android:screenOrientation="portrait"/> diff --git a/app/src/main/java/gallery/simplemobiletools/com/activities/ViewPagerActivity.java b/app/src/main/java/gallery/simplemobiletools/com/activities/ViewPagerActivity.java index 971f7d743..a6cc699c2 100644 --- a/app/src/main/java/gallery/simplemobiletools/com/activities/ViewPagerActivity.java +++ b/app/src/main/java/gallery/simplemobiletools/com/activities/ViewPagerActivity.java @@ -4,7 +4,10 @@ import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.provider.MediaStore; +import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; +import android.view.Menu; +import android.view.MenuItem; import android.view.View; import java.io.File; @@ -20,6 +23,7 @@ import gallery.simplemobiletools.com.adapters.MyPagerAdapter; public class ViewPagerActivity extends AppCompatActivity { private int pos; private boolean isFullScreen; + private ActionBar actionbar; @Override protected void onCreate(Bundle savedInstanceState) { @@ -27,6 +31,7 @@ public class ViewPagerActivity extends AppCompatActivity { setContentView(R.layout.activity_photo); pos = 0; + actionbar = getSupportActionBar(); isFullScreen = true; hideSystemUI(); @@ -46,6 +51,22 @@ public class ViewPagerActivity extends AppCompatActivity { }); } + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_share: + return true; + default: + return super.onOptionsItemSelected(item); + } + } + private List getPhotos() { final List photos = new ArrayList<>(); final String path = getIntent().getStringExtra(Constants.PHOTO); @@ -87,6 +108,9 @@ public class ViewPagerActivity extends AppCompatActivity { } private void hideSystemUI() { + if (actionbar != null) + actionbar.hide(); + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | @@ -96,6 +120,9 @@ public class ViewPagerActivity extends AppCompatActivity { } private void showSystemUI() { + if (actionbar != null) + actionbar.show(); + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); diff --git a/app/src/main/res/menu/menu.xml b/app/src/main/res/menu/menu.xml new file mode 100644 index 000000000..de87bba5e --- /dev/null +++ b/app/src/main/res/menu/menu.xml @@ -0,0 +1,10 @@ + + + + +