mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 06:28:00 +01:00
reuse the same activity at photo and video view intents
This commit is contained in:
parent
9ebdffdda0
commit
e4bbe31276
4 changed files with 101 additions and 162 deletions
|
@ -49,6 +49,9 @@
|
||||||
android:label="@string/third_party_licences"
|
android:label="@string/third_party_licences"
|
||||||
android:screenOrientation="portrait"/>
|
android:screenOrientation="portrait"/>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".activities.PhotoVideoActivity"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.PhotoActivity"
|
android:name=".activities.PhotoActivity"
|
||||||
android:theme="@style/FullScreenTheme">
|
android:theme="@style/FullScreenTheme">
|
||||||
|
|
|
@ -1,91 +1,12 @@
|
||||||
package com.simplemobiletools.gallery.activities;
|
package com.simplemobiletools.gallery.activities;
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
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;
|
public class PhotoActivity extends PhotoVideoActivity {
|
||||||
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;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
mIsVideo = false;
|
||||||
super.onCreate(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(), 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());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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());
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,91 +1,12 @@
|
||||||
package com.simplemobiletools.gallery.activities;
|
package com.simplemobiletools.gallery.activities;
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
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;
|
public class VideoActivity extends PhotoVideoActivity {
|
||||||
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;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
mIsVideo = true;
|
||||||
super.onCreate(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(), 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());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue