mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-30 21:07:11 +01:00
Refactor ViewImage and ViewGif activities. Allow zooming in gifs.
This commit is contained in:
parent
b57d381e94
commit
d428baaa7b
@ -87,10 +87,6 @@
|
|||||||
android:label="@string/multi_reddit_listing_activity_label"
|
android:label="@string/multi_reddit_listing_activity_label"
|
||||||
android:parentActivityName=".Activity.MainActivity"
|
android:parentActivityName=".Activity.MainActivity"
|
||||||
android:theme="@style/AppTheme.NoActionBar" />
|
android:theme="@style/AppTheme.NoActionBar" />
|
||||||
<activity
|
|
||||||
android:name=".Activity.ViewGIFActivity"
|
|
||||||
android:parentActivityName=".Activity.MainActivity"
|
|
||||||
android:theme="@style/AppTheme.Draggable" />
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".Activity.AccountSavedThingActivity"
|
android:name=".Activity.AccountSavedThingActivity"
|
||||||
android:label="@string/account_saved_thing_activity_label"
|
android:label="@string/account_saved_thing_activity_label"
|
||||||
@ -294,7 +290,7 @@
|
|||||||
android:parentActivityName=".Activity.MainActivity"
|
android:parentActivityName=".Activity.MainActivity"
|
||||||
android:theme="@style/AppTheme.NoActionBar" />
|
android:theme="@style/AppTheme.NoActionBar" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".Activity.ViewImageActivity"
|
android:name=".Activity.ViewImageOrGifActivity"
|
||||||
android:parentActivityName=".Activity.MainActivity"
|
android:parentActivityName=".Activity.MainActivity"
|
||||||
android:theme="@style/AppTheme.Draggable" />
|
android:theme="@style/AppTheme.Draggable" />
|
||||||
<activity
|
<activity
|
||||||
|
@ -79,20 +79,20 @@ public class LinkResolverActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (path.endsWith("jpg") || path.endsWith("png")) {
|
if (path.endsWith("jpg") || path.endsWith("png")) {
|
||||||
Intent intent = new Intent(this, ViewImageActivity.class);
|
Intent intent = new Intent(this, ViewImageOrGifActivity.class);
|
||||||
String url = uri.toString();
|
String url = uri.toString();
|
||||||
String fileName = url.substring(url.lastIndexOf('/') + 1);
|
String fileName = url.substring(url.lastIndexOf('/') + 1);
|
||||||
intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, url);
|
intent.putExtra(ViewImageOrGifActivity.IMAGE_URL_KEY, url);
|
||||||
intent.putExtra(ViewImageActivity.FILE_NAME_KEY, fileName);
|
intent.putExtra(ViewImageOrGifActivity.FILE_NAME_KEY, fileName);
|
||||||
intent.putExtra(ViewImageActivity.POST_TITLE_KEY, fileName);
|
intent.putExtra(ViewImageOrGifActivity.POST_TITLE_KEY, fileName);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else if (path.endsWith("gif")) {
|
} else if (path.endsWith("gif")) {
|
||||||
Intent intent = new Intent(this, ViewGIFActivity.class);
|
Intent intent = new Intent(this, ViewImageOrGifActivity.class);
|
||||||
String url = uri.toString();
|
String url = uri.toString();
|
||||||
String fileName = url.substring(url.lastIndexOf('/') + 1);
|
String fileName = url.substring(url.lastIndexOf('/') + 1);
|
||||||
intent.putExtra(ViewGIFActivity.GIF_URL_KEY, url);
|
intent.putExtra(ViewImageOrGifActivity.GIF_URL_KEY, url);
|
||||||
intent.putExtra(ViewGIFActivity.FILE_NAME_KEY, fileName);
|
intent.putExtra(ViewImageOrGifActivity.FILE_NAME_KEY, fileName);
|
||||||
intent.putExtra(ViewGIFActivity.POST_TITLE_KEY, fileName);
|
intent.putExtra(ViewImageOrGifActivity.POST_TITLE_KEY, fileName);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else if (path.endsWith("mp4")) {
|
} else if (path.endsWith("mp4")) {
|
||||||
Intent intent = new Intent(this, ViewVideoActivity.class);
|
Intent intent = new Intent(this, ViewVideoActivity.class);
|
||||||
|
@ -1,319 +0,0 @@
|
|||||||
package ml.docilealligator.infinityforreddit.Activity;
|
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.app.DownloadManager;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.graphics.drawable.ColorDrawable;
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Environment;
|
|
||||||
import android.text.Html;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.appcompat.app.ActionBar;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import androidx.core.app.ActivityCompat;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
import androidx.core.content.FileProvider;
|
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
|
||||||
import com.bumptech.glide.RequestManager;
|
|
||||||
import com.bumptech.glide.load.DataSource;
|
|
||||||
import com.bumptech.glide.load.engine.GlideException;
|
|
||||||
import com.bumptech.glide.load.resource.gif.GifDrawable;
|
|
||||||
import com.bumptech.glide.request.RequestListener;
|
|
||||||
import com.bumptech.glide.request.RequestOptions;
|
|
||||||
import com.bumptech.glide.request.target.Target;
|
|
||||||
import com.thefuntasty.hauler.HaulerView;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Named;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import ml.docilealligator.infinityforreddit.AsyncTask.SaveGIFToFileAsyncTask;
|
|
||||||
import ml.docilealligator.infinityforreddit.BuildConfig;
|
|
||||||
import ml.docilealligator.infinityforreddit.Font.ContentFontFamily;
|
|
||||||
import ml.docilealligator.infinityforreddit.Font.ContentFontStyle;
|
|
||||||
import ml.docilealligator.infinityforreddit.Font.FontFamily;
|
|
||||||
import ml.docilealligator.infinityforreddit.Font.FontStyle;
|
|
||||||
import ml.docilealligator.infinityforreddit.Font.TitleFontFamily;
|
|
||||||
import ml.docilealligator.infinityforreddit.Font.TitleFontStyle;
|
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
|
||||||
import pl.droidsonroids.gif.GifImageView;
|
|
||||||
|
|
||||||
public class ViewGIFActivity extends AppCompatActivity {
|
|
||||||
|
|
||||||
public static final String GIF_URL_KEY = "GUK";
|
|
||||||
public static final String FILE_NAME_KEY = "FNK";
|
|
||||||
public static final String POST_TITLE_KEY = "PTK";
|
|
||||||
private static final int PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE = 0;
|
|
||||||
@BindView(R.id.hauler_view_view_gif_activity)
|
|
||||||
HaulerView mHaulerView;
|
|
||||||
@BindView(R.id.progress_bar_view_gif_activity)
|
|
||||||
ProgressBar mProgressBar;
|
|
||||||
@BindView(R.id.image_view_view_gif_activity)
|
|
||||||
GifImageView mImageView;
|
|
||||||
@BindView(R.id.load_image_error_linear_layout_view_gif_activity)
|
|
||||||
LinearLayout mLoadErrorLinearLayout;
|
|
||||||
@Inject
|
|
||||||
@Named("default")
|
|
||||||
SharedPreferences mSharedPreferences;
|
|
||||||
private boolean isActionBarHidden = false;
|
|
||||||
private boolean isDownloading = false;
|
|
||||||
private RequestManager glide;
|
|
||||||
private String mImageUrl;
|
|
||||||
private String mImageFileName;
|
|
||||||
private boolean isSwiping = false;
|
|
||||||
private String postTitle;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
|
||||||
|
|
||||||
getTheme().applyStyle(R.style.Theme_Normal, true);
|
|
||||||
|
|
||||||
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences
|
|
||||||
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
|
|
||||||
|
|
||||||
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
|
|
||||||
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
|
|
||||||
|
|
||||||
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
|
|
||||||
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
|
|
||||||
|
|
||||||
getTheme().applyStyle(FontFamily.valueOf(mSharedPreferences
|
|
||||||
.getString(SharedPreferencesUtils.FONT_FAMILY_KEY, FontFamily.Default.name())).getResId(), true);
|
|
||||||
|
|
||||||
getTheme().applyStyle(TitleFontFamily.valueOf(mSharedPreferences
|
|
||||||
.getString(SharedPreferencesUtils.TITLE_FONT_FAMILY_KEY, TitleFontFamily.Default.name())).getResId(), true);
|
|
||||||
|
|
||||||
getTheme().applyStyle(ContentFontFamily.valueOf(mSharedPreferences
|
|
||||||
.getString(SharedPreferencesUtils.CONTENT_FONT_FAMILY_KEY, ContentFontFamily.Default.name())).getResId(), true);
|
|
||||||
|
|
||||||
setContentView(R.layout.activity_view_gif);
|
|
||||||
|
|
||||||
ButterKnife.bind(this);
|
|
||||||
|
|
||||||
ActionBar actionBar = getSupportActionBar();
|
|
||||||
Drawable upArrow = getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp);
|
|
||||||
actionBar.setHomeAsUpIndicator(upArrow);
|
|
||||||
actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparentActionBarAndExoPlayerControllerColor)));
|
|
||||||
|
|
||||||
mHaulerView.setOnDragDismissedListener(dragDirection -> finish());
|
|
||||||
|
|
||||||
glide = Glide.with(this);
|
|
||||||
|
|
||||||
Intent intent = getIntent();
|
|
||||||
mImageUrl = intent.getStringExtra(GIF_URL_KEY);
|
|
||||||
mImageFileName = intent.getStringExtra(FILE_NAME_KEY);
|
|
||||||
postTitle = intent.getStringExtra(POST_TITLE_KEY);
|
|
||||||
|
|
||||||
if (postTitle != null) {
|
|
||||||
setTitle(Html.fromHtml(String.format("<small>%s</small>", postTitle)));
|
|
||||||
} else {
|
|
||||||
setTitle("");
|
|
||||||
}
|
|
||||||
|
|
||||||
mLoadErrorLinearLayout.setOnClickListener(view -> {
|
|
||||||
if (!isSwiping) {
|
|
||||||
mProgressBar.setVisibility(View.VISIBLE);
|
|
||||||
mLoadErrorLinearLayout.setVisibility(View.GONE);
|
|
||||||
loadImage();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
loadImage();
|
|
||||||
|
|
||||||
mImageView.setOnClickListener(view -> {
|
|
||||||
if (isActionBarHidden) {
|
|
||||||
getWindow().getDecorView().setSystemUiVisibility(
|
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
|
||||||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
|
||||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
|
||||||
isActionBarHidden = false;
|
|
||||||
} else {
|
|
||||||
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_HIDE_NAVIGATION
|
|
||||||
| View.SYSTEM_UI_FLAG_FULLSCREEN
|
|
||||||
| View.SYSTEM_UI_FLAG_IMMERSIVE);
|
|
||||||
isActionBarHidden = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadImage() {
|
|
||||||
glide.load(mImageUrl).listener(new RequestListener<Drawable>() {
|
|
||||||
@Override
|
|
||||||
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
|
||||||
mProgressBar.setVisibility(View.GONE);
|
|
||||||
mLoadErrorLinearLayout.setVisibility(View.VISIBLE);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
|
|
||||||
mProgressBar.setVisibility(View.GONE);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}).apply(new RequestOptions().fitCenter()).into(mImageView);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
getMenuInflater().inflate(R.menu.view_gif_activity, menu);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case android.R.id.home:
|
|
||||||
finish();
|
|
||||||
return true;
|
|
||||||
case R.id.action_download_view_gif_activity:
|
|
||||||
if (isDownloading) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
isDownloading = true;
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 23) {
|
|
||||||
if (ContextCompat.checkSelfPermission(this,
|
|
||||||
Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
|
||||||
|
|
||||||
// Permission is not granted
|
|
||||||
// No explanation needed; request the permission
|
|
||||||
ActivityCompat.requestPermissions(this,
|
|
||||||
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
|
||||||
PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE);
|
|
||||||
} else {
|
|
||||||
// Permission has already been granted
|
|
||||||
download();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
download();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
case R.id.action_share_view_gif_activity:
|
|
||||||
Toast.makeText(ViewGIFActivity.this, R.string.save_gif_first, Toast.LENGTH_SHORT).show();
|
|
||||||
glide.asGif().load(mImageUrl).listener(new RequestListener<GifDrawable>() {
|
|
||||||
@Override
|
|
||||||
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<GifDrawable> target, boolean isFirstResource) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onResourceReady(GifDrawable resource, Object model, Target<GifDrawable> target, DataSource dataSource, boolean isFirstResource) {
|
|
||||||
if (getExternalCacheDir() != null) {
|
|
||||||
new SaveGIFToFileAsyncTask(resource, getExternalCacheDir().getPath(), mImageFileName,
|
|
||||||
new SaveGIFToFileAsyncTask.SaveGIFToFileAsyncTaskListener() {
|
|
||||||
@Override
|
|
||||||
public void saveSuccess(File imageFile) {
|
|
||||||
Uri uri = FileProvider.getUriForFile(ViewGIFActivity.this,
|
|
||||||
BuildConfig.APPLICATION_ID + ".provider", imageFile);
|
|
||||||
Intent shareIntent = new Intent();
|
|
||||||
shareIntent.setAction(Intent.ACTION_SEND);
|
|
||||||
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
|
|
||||||
shareIntent.setType("image/*");
|
|
||||||
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
||||||
startActivity(Intent.createChooser(shareIntent, getString(R.string.share)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveFailed() {
|
|
||||||
Toast.makeText(ViewGIFActivity.this,
|
|
||||||
R.string.cannot_save_gif, Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}).execute();
|
|
||||||
} else {
|
|
||||||
Toast.makeText(ViewGIFActivity.this,
|
|
||||||
R.string.cannot_get_storage, Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}).submit();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
|
||||||
if (requestCode == PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE && grantResults.length > 0) {
|
|
||||||
if (grantResults[0] == PackageManager.PERMISSION_DENIED) {
|
|
||||||
Toast.makeText(this, R.string.no_storage_permission, Toast.LENGTH_SHORT).show();
|
|
||||||
} else if (grantResults[0] == PackageManager.PERMISSION_GRANTED && isDownloading) {
|
|
||||||
download();
|
|
||||||
}
|
|
||||||
isDownloading = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void download() {
|
|
||||||
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(mImageUrl));
|
|
||||||
request.setTitle(mImageFileName);
|
|
||||||
|
|
||||||
request.allowScanningByMediaScanner();
|
|
||||||
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
|
|
||||||
|
|
||||||
//Android Q support
|
|
||||||
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
||||||
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_PICTURES, mImageFileName);
|
|
||||||
} else {
|
|
||||||
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString();
|
|
||||||
File directory = new File(path + "/Infinity/");
|
|
||||||
boolean saveToInfinityFolder = true;
|
|
||||||
if (!directory.exists()) {
|
|
||||||
if (!directory.mkdir()) {
|
|
||||||
saveToInfinityFolder = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (directory.isFile()) {
|
|
||||||
if (!(directory.delete() && directory.mkdir())) {
|
|
||||||
saveToInfinityFolder = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (saveToInfinityFolder) {
|
|
||||||
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_PICTURES + "/Infinity/", mImageFileName);
|
|
||||||
} else {
|
|
||||||
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_PICTURES, mImageFileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
|
|
||||||
|
|
||||||
if (manager == null) {
|
|
||||||
Toast.makeText(this, R.string.download_failed, Toast.LENGTH_SHORT).show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
manager.enqueue(request);
|
|
||||||
Toast.makeText(this, R.string.download_started, Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
@ -34,11 +34,12 @@ import androidx.core.app.ActivityCompat;
|
|||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.core.content.FileProvider;
|
import androidx.core.content.FileProvider;
|
||||||
|
|
||||||
import com.alexvasilkov.gestures.views.GestureImageView;
|
import com.alexvasilkov.gestures.views.GestureFrameLayout;
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.RequestManager;
|
import com.bumptech.glide.RequestManager;
|
||||||
import com.bumptech.glide.load.DataSource;
|
import com.bumptech.glide.load.DataSource;
|
||||||
import com.bumptech.glide.load.engine.GlideException;
|
import com.bumptech.glide.load.engine.GlideException;
|
||||||
|
import com.bumptech.glide.load.resource.gif.GifDrawable;
|
||||||
import com.bumptech.glide.request.RequestListener;
|
import com.bumptech.glide.request.RequestListener;
|
||||||
import com.bumptech.glide.request.target.CustomTarget;
|
import com.bumptech.glide.request.target.CustomTarget;
|
||||||
import com.bumptech.glide.request.target.Target;
|
import com.bumptech.glide.request.target.Target;
|
||||||
@ -53,6 +54,7 @@ import javax.inject.Named;
|
|||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
import ml.docilealligator.infinityforreddit.AsyncTask.SaveGIFToFileAsyncTask;
|
||||||
import ml.docilealligator.infinityforreddit.AsyncTask.SaveImageToFileAsyncTask;
|
import ml.docilealligator.infinityforreddit.AsyncTask.SaveImageToFileAsyncTask;
|
||||||
import ml.docilealligator.infinityforreddit.BottomSheetFragment.SetAsWallpaperBottomSheetFragment;
|
import ml.docilealligator.infinityforreddit.BottomSheetFragment.SetAsWallpaperBottomSheetFragment;
|
||||||
import ml.docilealligator.infinityforreddit.BuildConfig;
|
import ml.docilealligator.infinityforreddit.BuildConfig;
|
||||||
@ -66,29 +68,34 @@ import ml.docilealligator.infinityforreddit.Infinity;
|
|||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.SetAsWallpaperCallback;
|
import ml.docilealligator.infinityforreddit.SetAsWallpaperCallback;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
|
import pl.droidsonroids.gif.GifImageView;
|
||||||
|
|
||||||
public class ViewImageActivity extends AppCompatActivity implements SetAsWallpaperCallback {
|
public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWallpaperCallback {
|
||||||
|
|
||||||
public static final String IMAGE_URL_KEY = "IUK";
|
public static final String IMAGE_URL_KEY = "IUK";
|
||||||
|
public static final String GIF_URL_KEY = "GUK";
|
||||||
public static final String FILE_NAME_KEY = "FNK";
|
public static final String FILE_NAME_KEY = "FNK";
|
||||||
public static final String POST_TITLE_KEY = "PTK";
|
public static final String POST_TITLE_KEY = "PTK";
|
||||||
private static final int PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE = 0;
|
private static final int PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE = 0;
|
||||||
@BindView(R.id.hauler_view_view_image_activity)
|
@BindView(R.id.hauler_view_view_image_or_gif_activity)
|
||||||
HaulerView mHaulerView;
|
HaulerView mHaulerView;
|
||||||
@BindView(R.id.progress_bar_view_image_activity)
|
@BindView(R.id.progress_bar_view_image_or_gif_activity)
|
||||||
ProgressBar mProgressBar;
|
ProgressBar mProgressBar;
|
||||||
@BindView(R.id.image_view_view_image_activity)
|
@BindView(R.id.image_view_view_image_or_gif_activity)
|
||||||
GestureImageView mImageView;
|
GifImageView mImageView;
|
||||||
@BindView(R.id.load_image_error_linear_layout_view_image_activity)
|
@BindView(R.id.gesture_layout_view_image_or_gif_activity)
|
||||||
|
GestureFrameLayout gestureLayout;
|
||||||
|
@BindView(R.id.load_image_error_linear_layout_view_image_or_gif_activity)
|
||||||
LinearLayout mLoadErrorLinearLayout;
|
LinearLayout mLoadErrorLinearLayout;
|
||||||
@Inject
|
@Inject
|
||||||
@Named("default")
|
@Named("default")
|
||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
private boolean isActionBarHidden = false;
|
private boolean isActionBarHidden = false;
|
||||||
private boolean isDownloading = false;
|
private boolean isDownloading = false;
|
||||||
|
private RequestManager glide;
|
||||||
private String mImageUrl;
|
private String mImageUrl;
|
||||||
private String mImageFileName;
|
private String mImageFileName;
|
||||||
private RequestManager glide;
|
private boolean isGif = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -116,7 +123,7 @@ public class ViewImageActivity extends AppCompatActivity implements SetAsWallpap
|
|||||||
getTheme().applyStyle(ContentFontFamily.valueOf(mSharedPreferences
|
getTheme().applyStyle(ContentFontFamily.valueOf(mSharedPreferences
|
||||||
.getString(SharedPreferencesUtils.CONTENT_FONT_FAMILY_KEY, ContentFontFamily.Default.name())).getResId(), true);
|
.getString(SharedPreferencesUtils.CONTENT_FONT_FAMILY_KEY, ContentFontFamily.Default.name())).getResId(), true);
|
||||||
|
|
||||||
setContentView(R.layout.activity_view_image);
|
setContentView(R.layout.activity_view_image_or_gif);
|
||||||
|
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
@ -125,12 +132,18 @@ public class ViewImageActivity extends AppCompatActivity implements SetAsWallpap
|
|||||||
actionBar.setHomeAsUpIndicator(upArrow);
|
actionBar.setHomeAsUpIndicator(upArrow);
|
||||||
actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparentActionBarAndExoPlayerControllerColor)));
|
actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparentActionBarAndExoPlayerControllerColor)));
|
||||||
|
|
||||||
|
mHaulerView.setOnDragDismissedListener(dragDirection -> finish());
|
||||||
|
|
||||||
glide = Glide.with(this);
|
glide = Glide.with(this);
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
|
mImageUrl = intent.getStringExtra(GIF_URL_KEY);
|
||||||
|
if (mImageUrl == null) {
|
||||||
|
isGif = false;
|
||||||
mImageUrl = intent.getStringExtra(IMAGE_URL_KEY);
|
mImageUrl = intent.getStringExtra(IMAGE_URL_KEY);
|
||||||
|
}
|
||||||
mImageFileName = intent.getStringExtra(FILE_NAME_KEY);
|
mImageFileName = intent.getStringExtra(FILE_NAME_KEY);
|
||||||
String postTitle = intent.getStringExtra(POST_TITLE_KEY);
|
postTitle = intent.getStringExtra(POST_TITLE_KEY);
|
||||||
|
|
||||||
if (postTitle != null) {
|
if (postTitle != null) {
|
||||||
setTitle(Html.fromHtml(String.format("<small>%s</small>", postTitle)));
|
setTitle(Html.fromHtml(String.format("<small>%s</small>", postTitle)));
|
||||||
@ -138,8 +151,6 @@ public class ViewImageActivity extends AppCompatActivity implements SetAsWallpap
|
|||||||
setTitle("");
|
setTitle("");
|
||||||
}
|
}
|
||||||
|
|
||||||
mHaulerView.setOnDragDismissedListener(dragDirection -> finish());
|
|
||||||
|
|
||||||
mLoadErrorLinearLayout.setOnClickListener(view -> {
|
mLoadErrorLinearLayout.setOnClickListener(view -> {
|
||||||
mProgressBar.setVisibility(View.VISIBLE);
|
mProgressBar.setVisibility(View.VISIBLE);
|
||||||
mLoadErrorLinearLayout.setVisibility(View.GONE);
|
mLoadErrorLinearLayout.setVisibility(View.GONE);
|
||||||
@ -148,7 +159,7 @@ public class ViewImageActivity extends AppCompatActivity implements SetAsWallpap
|
|||||||
|
|
||||||
loadImage();
|
loadImage();
|
||||||
|
|
||||||
mImageView.getController().getSettings().setMaxZoom(10f).setDoubleTapZoom(2f).setPanEnabled(true);
|
gestureLayout.getController().getSettings().setMaxZoom(10f).setDoubleTapZoom(2f).setPanEnabled(true);
|
||||||
|
|
||||||
mImageView.setOnClickListener(view -> {
|
mImageView.setOnClickListener(view -> {
|
||||||
if (isActionBarHidden) {
|
if (isActionBarHidden) {
|
||||||
@ -189,7 +200,9 @@ public class ViewImageActivity extends AppCompatActivity implements SetAsWallpap
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.view_image_activity, menu);
|
getMenuInflater().inflate(R.menu.view_image_or_gif_activity, menu);
|
||||||
|
if (!isGif)
|
||||||
|
menu.findItem(R.id.action_set_wallpaper_view_image_or_gif_activity).setVisible(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +212,7 @@ public class ViewImageActivity extends AppCompatActivity implements SetAsWallpap
|
|||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
finish();
|
finish();
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_download_view_image_activity:
|
case R.id.action_download_view_image_or_gif_activity:
|
||||||
if (isDownloading) {
|
if (isDownloading) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -218,26 +231,47 @@ public class ViewImageActivity extends AppCompatActivity implements SetAsWallpap
|
|||||||
PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE);
|
PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE);
|
||||||
} else {
|
} else {
|
||||||
// Permission has already been granted
|
// Permission has already been granted
|
||||||
download();
|
download(mImageUrl, mImageFileName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
download();
|
download(mImageUrl, mImageFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_share_view_image_activity:
|
case R.id.action_share_view_image_or_gif_activity:
|
||||||
|
if (isGif)
|
||||||
|
shareGif();
|
||||||
|
else
|
||||||
|
shareImage();
|
||||||
|
return true;
|
||||||
|
case R.id.action_set_wallpaper_view_image_or_gif_activity:
|
||||||
|
if (!isGif) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
SetAsWallpaperBottomSheetFragment setAsWallpaperBottomSheetFragment = new SetAsWallpaperBottomSheetFragment();
|
||||||
|
setAsWallpaperBottomSheetFragment.show(getSupportFragmentManager(), setAsWallpaperBottomSheetFragment.getTag());
|
||||||
|
} else {
|
||||||
|
setAsWallpaper(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void shareImage() {
|
||||||
glide.asBitmap().load(mImageUrl).into(new CustomTarget<Bitmap>() {
|
glide.asBitmap().load(mImageUrl).into(new CustomTarget<Bitmap>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
||||||
if (getExternalCacheDir() != null) {
|
if (getExternalCacheDir() != null) {
|
||||||
Toast.makeText(ViewImageActivity.this, R.string.save_image_first, Toast.LENGTH_SHORT).show();
|
Toast.makeText(ViewImageOrGifActivity.this, R.string.save_image_first, Toast.LENGTH_SHORT).show();
|
||||||
new SaveImageToFileAsyncTask(resource, getExternalCacheDir().getPath(), mImageFileName,
|
new SaveImageToFileAsyncTask(resource, getExternalCacheDir().getPath(), mImageFileName,
|
||||||
new SaveImageToFileAsyncTask.SaveImageToFileAsyncTaskListener() {
|
new SaveImageToFileAsyncTask.SaveImageToFileAsyncTaskListener() {
|
||||||
@Override
|
@Override
|
||||||
public void saveSuccess(File imageFile) {
|
public void saveSuccess(File imageFile) {
|
||||||
Uri uri = FileProvider.getUriForFile(ViewImageActivity.this,
|
Uri uri = FileProvider.getUriForFile(ViewImageOrGifActivity.this,
|
||||||
BuildConfig.APPLICATION_ID + ".provider",imageFile);
|
BuildConfig.APPLICATION_ID + ".provider", imageFile);
|
||||||
Intent shareIntent = new Intent();
|
Intent shareIntent = new Intent();
|
||||||
shareIntent.setAction(Intent.ACTION_SEND);
|
shareIntent.setAction(Intent.ACTION_SEND);
|
||||||
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
|
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
|
||||||
@ -248,12 +282,12 @@ public class ViewImageActivity extends AppCompatActivity implements SetAsWallpap
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveFailed() {
|
public void saveFailed() {
|
||||||
Toast.makeText(ViewImageActivity.this,
|
Toast.makeText(ViewImageOrGifActivity.this,
|
||||||
R.string.cannot_save_image, Toast.LENGTH_SHORT).show();
|
R.string.cannot_save_image, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}).execute();
|
}).execute();
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(ViewImageActivity.this,
|
Toast.makeText(ViewImageOrGifActivity.this,
|
||||||
R.string.cannot_get_storage, Toast.LENGTH_SHORT).show();
|
R.string.cannot_get_storage, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -263,34 +297,61 @@ public class ViewImageActivity extends AppCompatActivity implements SetAsWallpap
|
|||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
|
||||||
|
|
||||||
case R.id.action_set_wallpaper_view_image_activity:
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
|
||||||
SetAsWallpaperBottomSheetFragment setAsWallpaperBottomSheetFragment = new SetAsWallpaperBottomSheetFragment();
|
|
||||||
setAsWallpaperBottomSheetFragment.show(getSupportFragmentManager(), setAsWallpaperBottomSheetFragment.getTag());
|
|
||||||
} else {
|
|
||||||
setAsWallpaper(2);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void shareGif() {
|
||||||
|
Toast.makeText(ViewImageOrGifActivity.this, R.string.save_gif_first, Toast.LENGTH_SHORT).show();
|
||||||
|
glide.asGif().load(mImageUrl).listener(new RequestListener<GifDrawable>() {
|
||||||
|
@Override
|
||||||
|
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<GifDrawable> target, boolean isFirstResource) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onResourceReady(GifDrawable resource, Object model, Target<GifDrawable> target, DataSource dataSource, boolean isFirstResource) {
|
||||||
|
if (getExternalCacheDir() != null) {
|
||||||
|
new SaveGIFToFileAsyncTask(resource, getExternalCacheDir().getPath(), mImageFileName,
|
||||||
|
new SaveGIFToFileAsyncTask.SaveGIFToFileAsyncTaskListener() {
|
||||||
|
@Override
|
||||||
|
public void saveSuccess(File imageFile) {
|
||||||
|
Uri uri = FileProvider.getUriForFile(ViewImageOrGifActivity.this,
|
||||||
|
BuildConfig.APPLICATION_ID + ".provider", imageFile);
|
||||||
|
Intent shareIntent = new Intent();
|
||||||
|
shareIntent.setAction(Intent.ACTION_SEND);
|
||||||
|
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
|
||||||
|
shareIntent.setType("image/*");
|
||||||
|
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
startActivity(Intent.createChooser(shareIntent, getString(R.string.share)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveFailed() {
|
||||||
|
Toast.makeText(ViewImageOrGifActivity.this,
|
||||||
|
R.string.cannot_save_gif, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}).execute();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(ViewImageOrGifActivity.this,
|
||||||
|
R.string.cannot_get_storage, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).submit();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||||
if (requestCode == PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE && grantResults.length > 0) {
|
if (requestCode == PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE && grantResults.length > 0) {
|
||||||
if (grantResults[0] == PackageManager.PERMISSION_DENIED) {
|
if (grantResults[0] == PackageManager.PERMISSION_DENIED) {
|
||||||
Toast.makeText(this, R.string.no_storage_permission, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.no_storage_permission, Toast.LENGTH_SHORT).show();
|
||||||
} else if (grantResults[0] == PackageManager.PERMISSION_GRANTED && isDownloading) {
|
} else if (grantResults[0] == PackageManager.PERMISSION_GRANTED && isDownloading) {
|
||||||
download();
|
download(mImageUrl, mImageFileName);
|
||||||
}
|
}
|
||||||
isDownloading = false;
|
isDownloading = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void download() {
|
void download(String mImageUrl, String mImageFileName) {
|
||||||
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(mImageUrl));
|
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(mImageUrl));
|
||||||
request.setTitle(mImageFileName);
|
request.setTitle(mImageFileName);
|
||||||
|
|
||||||
@ -335,11 +396,11 @@ public class ViewImageActivity extends AppCompatActivity implements SetAsWallpap
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setAsWallpaper(int setTo) {
|
private void setAsWallpaper(int setTo) {
|
||||||
Toast.makeText(ViewImageActivity.this, R.string.save_image_first, Toast.LENGTH_SHORT).show();
|
Toast.makeText(ViewImageOrGifActivity.this, R.string.save_image_first, Toast.LENGTH_SHORT).show();
|
||||||
glide.asBitmap().load(mImageUrl).into(new CustomTarget<Bitmap>() {
|
glide.asBitmap().load(mImageUrl).into(new CustomTarget<Bitmap>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
||||||
WallpaperManager manager = WallpaperManager.getInstance(ViewImageActivity.this);
|
WallpaperManager manager = WallpaperManager.getInstance(ViewImageOrGifActivity.this);
|
||||||
|
|
||||||
DisplayMetrics metrics = new DisplayMetrics();
|
DisplayMetrics metrics = new DisplayMetrics();
|
||||||
WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
|
WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
|
||||||
@ -386,9 +447,9 @@ public class ViewImageActivity extends AppCompatActivity implements SetAsWallpap
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Toast.makeText(ViewImageActivity.this, R.string.wallpaper_set, Toast.LENGTH_SHORT).show();
|
Toast.makeText(ViewImageOrGifActivity.this, R.string.wallpaper_set, Toast.LENGTH_SHORT).show();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Toast.makeText(ViewImageActivity.this, R.string.error_set_wallpaper, Toast.LENGTH_SHORT).show();
|
Toast.makeText(ViewImageOrGifActivity.this, R.string.error_set_wallpaper, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -348,9 +348,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
} else {
|
} else {
|
||||||
glide.load(subredditData.getBannerUrl()).into(bannerImageView);
|
glide.load(subredditData.getBannerUrl()).into(bannerImageView);
|
||||||
bannerImageView.setOnClickListener(view -> {
|
bannerImageView.setOnClickListener(view -> {
|
||||||
Intent intent = new Intent(ViewSubredditDetailActivity.this, ViewImageActivity.class);
|
Intent intent = new Intent(ViewSubredditDetailActivity.this, ViewImageOrGifActivity.class);
|
||||||
intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, subredditData.getBannerUrl());
|
intent.putExtra(ViewImageOrGifActivity.IMAGE_URL_KEY, subredditData.getBannerUrl());
|
||||||
intent.putExtra(ViewImageActivity.FILE_NAME_KEY, subredditName + "-banner.jpg");
|
intent.putExtra(ViewImageOrGifActivity.FILE_NAME_KEY, subredditName + "-banner.jpg");
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -369,9 +369,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(216, 0))))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(216, 0))))
|
||||||
.into(iconGifImageView);
|
.into(iconGifImageView);
|
||||||
iconGifImageView.setOnClickListener(view -> {
|
iconGifImageView.setOnClickListener(view -> {
|
||||||
Intent intent = new Intent(ViewSubredditDetailActivity.this, ViewImageActivity.class);
|
Intent intent = new Intent(ViewSubredditDetailActivity.this, ViewImageOrGifActivity.class);
|
||||||
intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, subredditData.getIconUrl());
|
intent.putExtra(ViewImageOrGifActivity.IMAGE_URL_KEY, subredditData.getIconUrl());
|
||||||
intent.putExtra(ViewImageActivity.FILE_NAME_KEY, subredditName + "-icon.jpg");
|
intent.putExtra(ViewImageOrGifActivity.FILE_NAME_KEY, subredditName + "-icon.jpg");
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -295,9 +295,9 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
} else {
|
} else {
|
||||||
glide.load(userData.getBanner()).into(bannerImageView);
|
glide.load(userData.getBanner()).into(bannerImageView);
|
||||||
bannerImageView.setOnClickListener(view -> {
|
bannerImageView.setOnClickListener(view -> {
|
||||||
Intent intent = new Intent(this, ViewImageActivity.class);
|
Intent intent = new Intent(this, ViewImageOrGifActivity.class);
|
||||||
intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, userData.getBanner());
|
intent.putExtra(ViewImageOrGifActivity.IMAGE_URL_KEY, userData.getBanner());
|
||||||
intent.putExtra(ViewImageActivity.FILE_NAME_KEY, username + "-banner.jpg");
|
intent.putExtra(ViewImageOrGifActivity.FILE_NAME_KEY, username + "-banner.jpg");
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -315,9 +315,9 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
.into(iconGifImageView);
|
.into(iconGifImageView);
|
||||||
|
|
||||||
iconGifImageView.setOnClickListener(view -> {
|
iconGifImageView.setOnClickListener(view -> {
|
||||||
Intent intent = new Intent(this, ViewImageActivity.class);
|
Intent intent = new Intent(this, ViewImageOrGifActivity.class);
|
||||||
intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, userData.getIconUrl());
|
intent.putExtra(ViewImageOrGifActivity.IMAGE_URL_KEY, userData.getIconUrl());
|
||||||
intent.putExtra(ViewImageActivity.FILE_NAME_KEY, username + "-icon.jpg");
|
intent.putExtra(ViewImageOrGifActivity.FILE_NAME_KEY, username + "-icon.jpg");
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -81,8 +81,7 @@ import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
|||||||
import ml.docilealligator.infinityforreddit.Activity.CommentActivity;
|
import ml.docilealligator.infinityforreddit.Activity.CommentActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.FilteredThingActivity;
|
import ml.docilealligator.infinityforreddit.Activity.FilteredThingActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity;
|
import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewGIFActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewImageOrGifActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewImageActivity;
|
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewPostDetailActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewPostDetailActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
|
||||||
@ -307,7 +306,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
mShowElapsedTime = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
|
mShowElapsedTime = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
|
||||||
mExpandChildren = !mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_TOP_LEVEL_COMMENTS_FIRST, false);
|
mExpandChildren = !mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_TOP_LEVEL_COMMENTS_FIRST, false);
|
||||||
mCommentToolbarHidden = mSharedPreferences.getBoolean(SharedPreferencesUtils.COMMENT_TOOLBAR_HIDDEN, false);
|
mCommentToolbarHidden = mSharedPreferences.getBoolean(SharedPreferencesUtils.COMMENT_TOOLBAR_HIDDEN, false);
|
||||||
mCommentToolbarHideOnClick= mSharedPreferences.getBoolean(SharedPreferencesUtils.COMMENT_TOOLBAR_HIDE_ON_CLICK, true);
|
mCommentToolbarHideOnClick = mSharedPreferences.getBoolean(SharedPreferencesUtils.COMMENT_TOOLBAR_HIDE_ON_CLICK, true);
|
||||||
mSwapTapAndLong = mSharedPreferences.getBoolean(SharedPreferencesUtils.SWAP_TAP_AND_LONG_COMMENTS, false);
|
mSwapTapAndLong = mSharedPreferences.getBoolean(SharedPreferencesUtils.SWAP_TAP_AND_LONG_COMMENTS, false);
|
||||||
mShowCommentDivider = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_COMMENT_DIVIDER, false);
|
mShowCommentDivider = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_COMMENT_DIVIDER, false);
|
||||||
mShowAbsoluteNumberOfVotes = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ABSOLUTE_NUMBER_OF_VOTES, true);
|
mShowAbsoluteNumberOfVotes = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ABSOLUTE_NUMBER_OF_VOTES, true);
|
||||||
@ -934,7 +933,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
((LoadMoreChildCommentsViewHolder) holder).placeholderTextView.setOnClickListener(view -> {
|
((LoadMoreChildCommentsViewHolder) holder).placeholderTextView.setOnClickListener(view -> {
|
||||||
int commentPosition = mIsSingleCommentThreadMode ? holder.getAdapterPosition() - 2 : holder.getAdapterPosition() - 1;
|
int commentPosition = mIsSingleCommentThreadMode ? holder.getAdapterPosition() - 2 : holder.getAdapterPosition() - 1;
|
||||||
int parentPosition = getParentPosition(commentPosition);
|
int parentPosition = getParentPosition(commentPosition);
|
||||||
if(parentPosition >= 0) {
|
if (parentPosition >= 0) {
|
||||||
CommentData parentComment = mVisibleComments.get(parentPosition);
|
CommentData parentComment = mVisibleComments.get(parentPosition);
|
||||||
|
|
||||||
mVisibleComments.get(commentPosition).setLoadingMoreChildren(true);
|
mVisibleComments.get(commentPosition).setLoadingMoreChildren(true);
|
||||||
@ -1172,7 +1171,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
} else {
|
} else {
|
||||||
imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView);
|
imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView);
|
||||||
}
|
}
|
||||||
} else if(holder instanceof PostDetailLinkViewHolder) {
|
} else if (holder instanceof PostDetailLinkViewHolder) {
|
||||||
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(mPost.getPreviewUrl())
|
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(mPost.getPreviewUrl())
|
||||||
.listener(new RequestListener<Drawable>() {
|
.listener(new RequestListener<Drawable>() {
|
||||||
@Override
|
@Override
|
||||||
@ -2255,11 +2254,11 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, mPost.getTitle());
|
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, mPost.getTitle());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
} else if (mPost.getPostType() == Post.GIF_TYPE) {
|
} else if (mPost.getPostType() == Post.GIF_TYPE) {
|
||||||
Intent intent = new Intent(mActivity, ViewGIFActivity.class);
|
Intent intent = new Intent(mActivity, ViewImageOrGifActivity.class);
|
||||||
intent.putExtra(ViewGIFActivity.FILE_NAME_KEY, mPost.getSubredditName()
|
intent.putExtra(ViewImageOrGifActivity.FILE_NAME_KEY, mPost.getSubredditName()
|
||||||
+ "-" + mPost.getId() + ".gif");
|
+ "-" + mPost.getId() + ".gif");
|
||||||
intent.putExtra(ViewGIFActivity.GIF_URL_KEY, mPost.getVideoUrl());
|
intent.putExtra(ViewImageOrGifActivity.GIF_URL_KEY, mPost.getVideoUrl());
|
||||||
intent.putExtra(ViewImageActivity.POST_TITLE_KEY, mPost.getTitle());
|
intent.putExtra(ViewImageOrGifActivity.POST_TITLE_KEY, mPost.getTitle());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -2350,18 +2349,18 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
|
|
||||||
mImageView.setOnClickListener(view -> {
|
mImageView.setOnClickListener(view -> {
|
||||||
if (mPost.getPostType() == Post.IMAGE_TYPE) {
|
if (mPost.getPostType() == Post.IMAGE_TYPE) {
|
||||||
Intent intent = new Intent(mActivity, ViewImageActivity.class);
|
Intent intent = new Intent(mActivity, ViewImageOrGifActivity.class);
|
||||||
intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, mPost.getUrl());
|
intent.putExtra(ViewImageOrGifActivity.IMAGE_URL_KEY, mPost.getUrl());
|
||||||
intent.putExtra(ViewImageActivity.FILE_NAME_KEY, mPost.getSubredditNamePrefixed().substring(2)
|
intent.putExtra(ViewImageOrGifActivity.FILE_NAME_KEY, mPost.getSubredditNamePrefixed().substring(2)
|
||||||
+ "-" + mPost.getId().substring(3) + ".jpg");
|
+ "-" + mPost.getId().substring(3) + ".jpg");
|
||||||
intent.putExtra(ViewImageActivity.POST_TITLE_KEY, mPost.getTitle());
|
intent.putExtra(ViewImageOrGifActivity.POST_TITLE_KEY, mPost.getTitle());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
} else if (mPost.getPostType() == Post.GIF_TYPE) {
|
} else if (mPost.getPostType() == Post.GIF_TYPE) {
|
||||||
Intent intent = new Intent(mActivity, ViewGIFActivity.class);
|
Intent intent = new Intent(mActivity, ViewImageOrGifActivity.class);
|
||||||
intent.putExtra(ViewGIFActivity.FILE_NAME_KEY, mPost.getSubredditName()
|
intent.putExtra(ViewImageOrGifActivity.FILE_NAME_KEY, mPost.getSubredditName()
|
||||||
+ "-" + mPost.getId() + ".gif");
|
+ "-" + mPost.getId() + ".gif");
|
||||||
intent.putExtra(ViewGIFActivity.GIF_URL_KEY, mPost.getVideoUrl());
|
intent.putExtra(ViewImageOrGifActivity.GIF_URL_KEY, mPost.getVideoUrl());
|
||||||
intent.putExtra(ViewImageActivity.POST_TITLE_KEY, mPost.getTitle());
|
intent.putExtra(ViewImageOrGifActivity.POST_TITLE_KEY, mPost.getTitle());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -2934,7 +2933,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
expandButton.setOnClickListener(view -> {
|
expandButton.setOnClickListener(view -> {
|
||||||
if (expandButton.getVisibility() == View.VISIBLE) {
|
if (expandButton.getVisibility() == View.VISIBLE) {
|
||||||
int commentPosition = mIsSingleCommentThreadMode ? getAdapterPosition() - 2 : getAdapterPosition() - 1;
|
int commentPosition = mIsSingleCommentThreadMode ? getAdapterPosition() - 2 : getAdapterPosition() - 1;
|
||||||
if(commentPosition >= 0 && commentPosition < mVisibleComments.size()) {
|
if (commentPosition >= 0 && commentPosition < mVisibleComments.size()) {
|
||||||
CommentData comment = getCurrentComment();
|
CommentData comment = getCurrentComment();
|
||||||
if (mVisibleComments.get(commentPosition).isExpanded()) {
|
if (mVisibleComments.get(commentPosition).isExpanded()) {
|
||||||
collapseChildren(commentPosition);
|
collapseChildren(commentPosition);
|
||||||
|
@ -65,8 +65,7 @@ import jp.wasabeef.glide.transformations.BlurTransformation;
|
|||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.FilteredThingActivity;
|
import ml.docilealligator.infinityforreddit.Activity.FilteredThingActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity;
|
import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewGIFActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewImageOrGifActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewImageActivity;
|
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewPostDetailActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewPostDetailActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
|
||||||
@ -836,9 +835,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
|
|
||||||
final String imageUrl = post.getUrl();
|
final String imageUrl = post.getUrl();
|
||||||
((PostCompactViewHolder) holder).imageView.setOnClickListener(view -> {
|
((PostCompactViewHolder) holder).imageView.setOnClickListener(view -> {
|
||||||
Intent intent = new Intent(mActivity, ViewImageActivity.class);
|
Intent intent = new Intent(mActivity, ViewImageOrGifActivity.class);
|
||||||
intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, imageUrl);
|
intent.putExtra(ViewImageOrGifActivity.IMAGE_URL_KEY, imageUrl);
|
||||||
intent.putExtra(ViewImageActivity.FILE_NAME_KEY, subredditName
|
intent.putExtra(ViewImageOrGifActivity.FILE_NAME_KEY, subredditName
|
||||||
+ "-" + id + ".jpg");
|
+ "-" + id + ".jpg");
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
});
|
});
|
||||||
@ -866,11 +865,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
|
|
||||||
final Uri gifVideoUri = Uri.parse(post.getVideoUrl());
|
final Uri gifVideoUri = Uri.parse(post.getVideoUrl());
|
||||||
((PostCompactViewHolder) holder).imageView.setOnClickListener(view -> {
|
((PostCompactViewHolder) holder).imageView.setOnClickListener(view -> {
|
||||||
Intent intent = new Intent(mActivity, ViewGIFActivity.class);
|
Intent intent = new Intent(mActivity, ViewImageOrGifActivity.class);
|
||||||
intent.setData(gifVideoUri);
|
intent.setData(gifVideoUri);
|
||||||
intent.putExtra(ViewGIFActivity.FILE_NAME_KEY, subredditName
|
intent.putExtra(ViewImageOrGifActivity.FILE_NAME_KEY, subredditName
|
||||||
+ "-" + id + ".gif");
|
+ "-" + id + ".gif");
|
||||||
intent.putExtra(ViewGIFActivity.GIF_URL_KEY, post.getVideoUrl());
|
intent.putExtra(ViewImageOrGifActivity.GIF_URL_KEY, post.getVideoUrl());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -2144,11 +2143,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, post.getTitle());
|
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, post.getTitle());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
} else if (post.getPostType() == Post.GIF_TYPE) {
|
} else if (post.getPostType() == Post.GIF_TYPE) {
|
||||||
Intent intent = new Intent(mActivity, ViewGIFActivity.class);
|
Intent intent = new Intent(mActivity, ViewImageOrGifActivity.class);
|
||||||
intent.putExtra(ViewGIFActivity.FILE_NAME_KEY, post.getSubredditName()
|
intent.putExtra(ViewImageOrGifActivity.FILE_NAME_KEY, post.getSubredditName()
|
||||||
+ "-" + post.getId() + ".gif");
|
+ "-" + post.getId() + ".gif");
|
||||||
intent.putExtra(ViewGIFActivity.GIF_URL_KEY, post.getVideoUrl());
|
intent.putExtra(ViewImageOrGifActivity.GIF_URL_KEY, post.getVideoUrl());
|
||||||
intent.putExtra(ViewGIFActivity.POST_TITLE_KEY, post.getTitle());
|
intent.putExtra(ViewImageOrGifActivity.POST_TITLE_KEY, post.getTitle());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2243,18 +2242,18 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
Post post = getItem(getAdapterPosition());
|
Post post = getItem(getAdapterPosition());
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
if (post.getPostType() == Post.IMAGE_TYPE) {
|
if (post.getPostType() == Post.IMAGE_TYPE) {
|
||||||
Intent intent = new Intent(mActivity, ViewImageActivity.class);
|
Intent intent = new Intent(mActivity, ViewImageOrGifActivity.class);
|
||||||
intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, post.getUrl());
|
intent.putExtra(ViewImageOrGifActivity.IMAGE_URL_KEY, post.getUrl());
|
||||||
intent.putExtra(ViewImageActivity.FILE_NAME_KEY, post.getSubredditName()
|
intent.putExtra(ViewImageOrGifActivity.FILE_NAME_KEY, post.getSubredditName()
|
||||||
+ "-" + post.getId() + ".jpg");
|
+ "-" + post.getId() + ".jpg");
|
||||||
intent.putExtra(ViewImageActivity.POST_TITLE_KEY, post.getTitle());
|
intent.putExtra(ViewImageOrGifActivity.POST_TITLE_KEY, post.getTitle());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
} else if (post.getPostType() == Post.GIF_TYPE) {
|
} else if (post.getPostType() == Post.GIF_TYPE) {
|
||||||
Intent intent = new Intent(mActivity, ViewGIFActivity.class);
|
Intent intent = new Intent(mActivity, ViewImageOrGifActivity.class);
|
||||||
intent.putExtra(ViewGIFActivity.FILE_NAME_KEY, post.getSubredditName()
|
intent.putExtra(ViewImageOrGifActivity.FILE_NAME_KEY, post.getSubredditName()
|
||||||
+ "-" + post.getId() + ".gif");
|
+ "-" + post.getId() + ".gif");
|
||||||
intent.putExtra(ViewGIFActivity.GIF_URL_KEY, post.getVideoUrl());
|
intent.putExtra(ViewImageOrGifActivity.GIF_URL_KEY, post.getVideoUrl());
|
||||||
intent.putExtra(ViewGIFActivity.POST_TITLE_KEY, post.getTitle());
|
intent.putExtra(ViewImageOrGifActivity.POST_TITLE_KEY, post.getTitle());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2507,7 +2506,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
@BindView(R.id.share_button_item_post_text_type)
|
@BindView(R.id.share_button_item_post_text_type)
|
||||||
ImageView shareButton;
|
ImageView shareButton;
|
||||||
|
|
||||||
PostTextTypeViewHolder (View itemView) {
|
PostTextTypeViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
ButterKnife.bind(this, itemView);
|
ButterKnife.bind(this, itemView);
|
||||||
setBaseView(cardView,
|
setBaseView(cardView,
|
||||||
|
@ -32,8 +32,7 @@ import ml.docilealligator.infinityforreddit.Activity.SubredditMultiselectionActi
|
|||||||
import ml.docilealligator.infinityforreddit.Activity.SubredditSelectionActivity;
|
import ml.docilealligator.infinityforreddit.Activity.SubredditSelectionActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.SubscribedThingListingActivity;
|
import ml.docilealligator.infinityforreddit.Activity.SubscribedThingListingActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ThemePreviewActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ThemePreviewActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewGIFActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewImageOrGifActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewImageActivity;
|
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewImgurMediaActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewImgurMediaActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewMessageActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewMessageActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewMultiRedditDetailActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewMultiRedditDetailActivity;
|
||||||
@ -134,9 +133,7 @@ public interface AppComponent {
|
|||||||
|
|
||||||
void inject(AccountSavedThingActivity accountSavedThingActivity);
|
void inject(AccountSavedThingActivity accountSavedThingActivity);
|
||||||
|
|
||||||
void inject(ViewImageActivity viewImageActivity);
|
void inject(ViewImageOrGifActivity viewGIFActivity);
|
||||||
|
|
||||||
void inject(ViewGIFActivity viewGIFActivity);
|
|
||||||
|
|
||||||
void inject(MultiRedditListingActivity multiRedditListingActivity);
|
void inject(MultiRedditListingActivity multiRedditListingActivity);
|
||||||
|
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<com.thefuntasty.hauler.HaulerView
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:id="@+id/hauler_view_view_gif_activity"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:keepScreenOn="true"
|
|
||||||
app:dragUpEnabled="true"
|
|
||||||
tools:application="ml.docilealligator.infinityforreddit.Activity.ViewGIFActivity">
|
|
||||||
|
|
||||||
<androidx.core.widget.NestedScrollView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:fillViewport="true">
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<ProgressBar
|
|
||||||
android:id="@+id/progress_bar_view_gif_activity"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_centerInParent="true" />
|
|
||||||
|
|
||||||
<pl.droidsonroids.gif.GifImageView
|
|
||||||
android:id="@+id/image_view_view_gif_activity"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
app:gest_fillViewport="true" />
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/load_image_error_linear_layout_view_gif_activity"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:visibility="gone">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:drawableTop="@drawable/ic_error_outline_white_24dp"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:gravity="center"
|
|
||||||
android:textColor="@android:color/white"
|
|
||||||
android:text="@string/error_loading_gif_tap_to_retry"
|
|
||||||
android:textSize="?attr/font_default"
|
|
||||||
android:fontFamily="?attr/font_family" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
</androidx.core.widget.NestedScrollView>
|
|
||||||
|
|
||||||
</com.thefuntasty.hauler.HaulerView>
|
|
@ -1,9 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<com.thefuntasty.hauler.HaulerView
|
<com.thefuntasty.hauler.HaulerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/hauler_view_view_image_activity"
|
android:id="@+id/hauler_view_view_image_or_gif_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:dragUpEnabled="true"
|
app:dragUpEnabled="true"
|
||||||
@ -19,21 +18,28 @@
|
|||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progress_bar_view_image_activity"
|
android:id="@+id/progress_bar_view_image_or_gif_activity"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerInParent="true" />
|
android:layout_centerInParent="true" />
|
||||||
|
|
||||||
<com.alexvasilkov.gestures.views.GestureImageView
|
<com.alexvasilkov.gestures.views.GestureFrameLayout
|
||||||
android:id="@+id/image_view_view_image_activity"
|
android:id="@+id/gesture_layout_view_image_or_gif_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
app:gest_fillViewport="true" />
|
app:gest_fillViewport="true" />
|
||||||
|
|
||||||
|
<pl.droidsonroids.gif.GifImageView
|
||||||
|
android:id="@+id/image_view_view_image_or_gif_activity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:gest_fillViewport="true" />
|
||||||
|
</com.alexvasilkov.gestures.views.GestureFrameLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/load_image_error_linear_layout_view_image_activity"
|
android:id="@+id/load_image_error_linear_layout_view_image_or_gif_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:visibility="gone">
|
android:visibility="gone">
|
||||||
@ -41,13 +47,13 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:drawableTop="@drawable/ic_error_outline_white_24dp"
|
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
android:drawableTop="@drawable/ic_error_outline_white_24dp"
|
||||||
|
android:fontFamily="?attr/font_family"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textColor="@android:color/white"
|
|
||||||
android:text="@string/error_loading_image_tap_to_retry"
|
android:text="@string/error_loading_image_tap_to_retry"
|
||||||
android:textSize="?attr/font_default"
|
android:textColor="@android:color/white"
|
||||||
android:fontFamily="?attr/font_family" />
|
android:textSize="?attr/font_default" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
@ -1,17 +0,0 @@
|
|||||||
<?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/action_download_view_gif_activity"
|
|
||||||
android:orderInCategory="1"
|
|
||||||
android:title="@string/action_download"
|
|
||||||
android:icon="@drawable/ic_file_download_toolbar_white_24dp"
|
|
||||||
app:showAsAction="ifRoom" />
|
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/action_share_view_gif_activity"
|
|
||||||
android:orderInCategory="2"
|
|
||||||
android:title="@string/action_share"
|
|
||||||
android:icon="@drawable/ic_share_toolbar_white_24dp"
|
|
||||||
app:showAsAction="ifRoom" />
|
|
||||||
</menu>
|
|
@ -2,22 +2,23 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_download_view_image_activity"
|
android:id="@+id/action_download_view_image_or_gif_activity"
|
||||||
|
android:icon="@drawable/ic_file_download_toolbar_white_24dp"
|
||||||
android:orderInCategory="1"
|
android:orderInCategory="1"
|
||||||
android:title="@string/action_download"
|
android:title="@string/action_download"
|
||||||
android:icon="@drawable/ic_file_download_toolbar_white_24dp"
|
|
||||||
app:showAsAction="ifRoom" />
|
app:showAsAction="ifRoom" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_share_view_image_activity"
|
android:id="@+id/action_share_view_image_or_gif_activity"
|
||||||
|
android:icon="@drawable/ic_share_toolbar_white_24dp"
|
||||||
android:orderInCategory="2"
|
android:orderInCategory="2"
|
||||||
android:title="@string/action_share"
|
android:title="@string/action_share"
|
||||||
android:icon="@drawable/ic_share_toolbar_white_24dp"
|
|
||||||
app:showAsAction="ifRoom" />
|
app:showAsAction="ifRoom" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_set_wallpaper_view_image_activity"
|
android:id="@+id/action_set_wallpaper_view_image_or_gif_activity"
|
||||||
android:orderInCategory="3"
|
android:orderInCategory="3"
|
||||||
android:title="@string/action_set_wallpaper"
|
android:title="@string/action_set_wallpaper"
|
||||||
|
android:visible="false"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
</menu>
|
</menu>
|
Loading…
Reference in New Issue
Block a user