mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-12-01 16:58:00 +01:00
allow opening other photos with the Gallery
This commit is contained in:
parent
a6e4e949e0
commit
d6a8683941
6 changed files with 146 additions and 15 deletions
|
@ -36,5 +36,19 @@
|
||||||
android:name=".activities.LicenseActivity"
|
android:name=".activities.LicenseActivity"
|
||||||
android:label="@string/third_party_licences"
|
android:label="@string/third_party_licences"
|
||||||
android:screenOrientation="portrait"/>
|
android:screenOrientation="portrait"/>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".activities.PhotoActivity"
|
||||||
|
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="image/*"/>
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
|
@ -5,6 +5,9 @@ import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.support.v7.app.ActionBar;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
@ -28,4 +31,25 @@ public class Utils {
|
||||||
public static boolean hasStoragePermission(Context cxt) {
|
public static boolean hasStoragePermission(Context cxt) {
|
||||||
return ContextCompat.checkSelfPermission(cxt, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
|
return ContextCompat.checkSelfPermission(cxt, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void showSystemUI(ActionBar actionbar, Window window) {
|
||||||
|
if (actionbar != null)
|
||||||
|
actionbar.show();
|
||||||
|
|
||||||
|
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void hideSystemUI(ActionBar actionbar, Window window) {
|
||||||
|
if (actionbar != null)
|
||||||
|
actionbar.hide();
|
||||||
|
|
||||||
|
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
|
||||||
|
View.SYSTEM_UI_FLAG_LOW_PROFILE |
|
||||||
|
View.SYSTEM_UI_FLAG_FULLSCREEN |
|
||||||
|
View.SYSTEM_UI_FLAG_IMMERSIVE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.PhotoFragment;
|
||||||
|
import com.simplemobiletools.gallery.fragments.ViewPagerFragment;
|
||||||
|
import com.simplemobiletools.gallery.models.Medium;
|
||||||
|
|
||||||
|
public class PhotoActivity 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.photo_layout);
|
||||||
|
|
||||||
|
uri = getIntent().getData();
|
||||||
|
if (uri == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
actionbar = getSupportActionBar();
|
||||||
|
isFullScreen = true;
|
||||||
|
hideSystemUI();
|
||||||
|
|
||||||
|
final Bundle bundle = new Bundle();
|
||||||
|
final Medium medium = new Medium(uri.toString(), false);
|
||||||
|
bundle.putSerializable(Constants.MEDIUM, medium);
|
||||||
|
final ViewPagerFragment fragment = new PhotoFragment();
|
||||||
|
fragment.setListener(this);
|
||||||
|
fragment.setArguments(bundle);
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.photo_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("image/*");
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
|
@ -315,24 +315,11 @@ public class ViewPagerActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hideSystemUI() {
|
private void hideSystemUI() {
|
||||||
if (actionbar != null)
|
Utils.hideSystemUI(actionbar, getWindow());
|
||||||
actionbar.hide();
|
|
||||||
|
|
||||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
|
|
||||||
View.SYSTEM_UI_FLAG_LOW_PROFILE |
|
|
||||||
View.SYSTEM_UI_FLAG_FULLSCREEN |
|
|
||||||
View.SYSTEM_UI_FLAG_IMMERSIVE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showSystemUI() {
|
private void showSystemUI() {
|
||||||
if (actionbar != null)
|
Utils.showSystemUI(actionbar, getWindow());
|
||||||
actionbar.show();
|
|
||||||
|
|
||||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateActionbarTitle() {
|
private void updateActionbarTitle() {
|
||||||
|
|
7
app/src/main/res/layout/photo_layout.xml
Normal file
7
app/src/main/res/layout/photo_layout.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/photo_holder"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@android:color/black"/>
|
9
app/src/main/res/menu/photo_video_menu.xml
Normal file
9
app/src/main/res/menu/photo_video_menu.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_share"
|
||||||
|
android:icon="@mipmap/share"
|
||||||
|
android:title="@string/share"
|
||||||
|
app:showAsAction="ifRoom"/>
|
||||||
|
</menu>
|
Loading…
Reference in a new issue