diff --git a/app/build.gradle b/app/build.gradle
index 3437d5ad..fdac7e1d 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -79,6 +79,7 @@ dependencies {
implementation 'com.atlassian.commonmark:commonmark:0.13.1'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'me.zhanghai.android.fastscroll:library:1.1.2'
+ implementation("com.thefuntasty.hauler:core:3.1.0")
def toroVersion = '3.7.0.2010003'
implementation "im.ene.toro3:toro:$toroVersion"
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 40c18016..da3e366c 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -25,7 +25,7 @@
android:name=".Activity.ViewImgurMediaActivity"
android:configChanges="orientation|screenSize|layoutDirection"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.ActionBar.Transparent" />
+ android:theme="@style/AppTheme.Draggable" />
+ android:theme="@style/AppTheme.Draggable" />
+ android:theme="@style/AppTheme.Draggable" />
+ android:theme="@style/AppTheme.Draggable" />
finish());
+
glide = Glide.with(this);
Intent intent = getIntent();
@@ -138,182 +128,8 @@ public class ViewGIFActivity extends AppCompatActivity {
}
});
- float pxHeight = getResources().getDisplayMetrics().heightPixels;
-
- int activityColorFrom = getResources().getColor(android.R.color.black);
- int actionBarColorFrom = getResources().getColor(R.color.transparentActionBarAndExoPlayerControllerColor);
- int actionBarElementColorFrom = getResources().getColor(android.R.color.white);
- int colorTo = getResources().getColor(android.R.color.transparent);
-
- final ValueAnimator activityColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), activityColorFrom, colorTo);
- final ValueAnimator actionBarColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), actionBarColorFrom, colorTo);
- final ValueAnimator actionBarElementColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), actionBarElementColorFrom, colorTo);
-
- activityColorAnimation.setDuration(300); // milliseconds
- actionBarColorAnimation.setDuration(300);
- actionBarElementColorAnimation.setDuration(300);
-
- activityColorAnimation.addUpdateListener(valueAnimator -> mRelativeLayout.setBackgroundColor((int) valueAnimator.getAnimatedValue()));
-
- actionBarColorAnimation.addUpdateListener(valueAnimator -> actionBar.setBackgroundDrawable(new ColorDrawable((int) valueAnimator.getAnimatedValue())));
-
- actionBarElementColorAnimation.addUpdateListener(valueAnimator -> {
- upArrow.setColorFilter((int) valueAnimator.getAnimatedValue(), PorterDuff.Mode.SRC_IN);
- if (mMenu != null) {
- Drawable drawable = mMenu.getItem(0).getIcon();
- //drawable.mutate();
- drawable.setColorFilter((int) valueAnimator.getAnimatedValue(), PorterDuff.Mode.SRC_IN);
- }
- });
-
loadImage();
- swipe = new Swipe();
- swipe.setListener(new SimpleSwipeListener() {
- @Override
- public void onSwipingUp(final MotionEvent event) {
- isSwiping = true;
- float nowY = event.getY();
- float offset;
- if (touchY == -1.0f) {
- offset = 0.0f;
- } else {
- offset = nowY - touchY;
- }
- totalLengthY += offset;
- touchY = nowY;
- mImageView.animate()
- .y(totalLengthY)
- .setDuration(0)
- .start();
- mLoadErrorLinearLayout.animate()
- .y(totalLengthY)
- .setDuration(0)
- .start();
- }
-
- @Override
- public boolean onSwipedUp(final MotionEvent event) {
- if (totalLengthY < -pxHeight / 8) {
- mImageView.animate()
- .y(-pxHeight)
- .setDuration(300)
- .setListener(new Animator.AnimatorListener() {
- @Override
- public void onAnimationStart(Animator animator) {
- activityColorAnimation.start();
- actionBarColorAnimation.start();
- actionBarElementColorAnimation.start();
- }
-
- @Override
- public void onAnimationEnd(Animator animator) {
- finish();
- }
-
- @Override
- public void onAnimationCancel(Animator animator) {
- }
-
- @Override
- public void onAnimationRepeat(Animator animator) {
- }
- })
- .start();
- mLoadErrorLinearLayout.animate()
- .y(-pxHeight)
- .setDuration(300)
- .start();
- } else {
- isSwiping = false;
- mImageView.animate()
- .y(0)
- .setDuration(300)
- .start();
- mLoadErrorLinearLayout.animate()
- .y(0)
- .setDuration(300)
- .start();
- }
-
- totalLengthY = 0.0f;
- touchY = -1.0f;
- return false;
- }
-
- @Override
- public void onSwipingDown(final MotionEvent event) {
- isSwiping = true;
- float nowY = event.getY();
- float offset;
- if (touchY == -1.0f) {
- offset = 0.0f;
- } else {
- offset = nowY - touchY;
- }
- totalLengthY += offset;
- touchY = nowY;
- mImageView.animate()
- .y(totalLengthY)
- .setDuration(0)
- .start();
- mLoadErrorLinearLayout.animate()
- .y(totalLengthY)
- .setDuration(0)
- .start();
- }
-
- @Override
- public boolean onSwipedDown(final MotionEvent event) {
- if (totalLengthY > pxHeight / 8) {
- mImageView.animate()
- .y(pxHeight)
- .setDuration(300)
- .setListener(new Animator.AnimatorListener() {
- @Override
- public void onAnimationStart(Animator animator) {
- activityColorAnimation.start();
- actionBarColorAnimation.start();
- actionBarElementColorAnimation.start();
- }
-
- @Override
- public void onAnimationEnd(Animator animator) {
- finish();
- }
-
- @Override
- public void onAnimationCancel(Animator animator) {
- }
-
- @Override
- public void onAnimationRepeat(Animator animator) {
- }
- })
- .start();
- mLoadErrorLinearLayout.animate()
- .y(pxHeight)
- .setDuration(300)
- .start();
- } else {
- isSwiping = false;
- mImageView.animate()
- .y(0)
- .setDuration(300)
- .start();
- mLoadErrorLinearLayout.animate()
- .y(0)
- .setDuration(300)
- .start();
- }
-
- totalLengthY = 0.0f;
- touchY = -1.0f;
-
- return false;
- }
- });
-
mImageView.setOnClickListener(view -> {
if (isActionBarHidden) {
getWindow().getDecorView().setSystemUiVisibility(
@@ -353,7 +169,6 @@ public class ViewGIFActivity extends AppCompatActivity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- mMenu = menu;
getMenuInflater().inflate(R.menu.view_gif_activity, menu);
return true;
}
@@ -434,14 +249,6 @@ public class ViewGIFActivity extends AppCompatActivity {
return false;
}
- @Override
- public boolean dispatchTouchEvent(MotionEvent ev) {
- if (zoom == 1.0) {
- swipe.dispatchTouchEvent(ev);
- }
- return super.dispatchTouchEvent(ev);
- }
-
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (requestCode == PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE && grantResults.length > 0) {
@@ -497,10 +304,4 @@ public class ViewGIFActivity extends AppCompatActivity {
manager.enqueue(request);
Toast.makeText(this, R.string.download_started, Toast.LENGTH_SHORT).show();
}
-
- @Override
- protected void onPause() {
- super.onPause();
- overridePendingTransition(0, 0);
- }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java
index 68d65cb7..779d7fe7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java
@@ -1,16 +1,12 @@
package ml.docilealligator.infinityforreddit.Activity;
import android.Manifest;
-import android.animation.Animator;
-import android.animation.ArgbEvaluator;
-import android.animation.ValueAnimator;
import android.app.DownloadManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
-import android.graphics.PorterDuff;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
@@ -20,11 +16,9 @@ import android.os.Environment;
import android.text.Html;
import android.view.Menu;
import android.view.MenuItem;
-import android.view.MotionEvent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
-import android.widget.RelativeLayout;
import android.widget.Toast;
import androidx.annotation.NonNull;
@@ -35,8 +29,6 @@ import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
-import com.alexvasilkov.gestures.GestureController;
-import com.alexvasilkov.gestures.State;
import com.alexvasilkov.gestures.views.GestureImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
@@ -46,8 +38,7 @@ import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.target.Target;
import com.bumptech.glide.request.transition.Transition;
-import com.github.pwittchen.swipe.library.rx2.SimpleSwipeListener;
-import com.github.pwittchen.swipe.library.rx2.Swipe;
+import com.thefuntasty.hauler.HaulerView;
import java.io.File;
@@ -71,8 +62,8 @@ public class ViewImageActivity extends AppCompatActivity {
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.parent_relative_layout_view_image_activity)
- RelativeLayout mRelativeLayout;
+ @BindView(R.id.hauler_view_view_image_activity)
+ HaulerView mHaulerView;
@BindView(R.id.progress_bar_view_image_activity)
ProgressBar mProgressBar;
@BindView(R.id.image_view_view_image_activity)
@@ -84,15 +75,8 @@ public class ViewImageActivity extends AppCompatActivity {
SharedPreferences mSharedPreferences;
private boolean isActionBarHidden = false;
private boolean isDownloading = false;
- private Menu mMenu;
- private Swipe swipe;
private String mImageUrl;
private String mImageFileName;
- private float totalLengthY = 0.0f;
- private float touchY = -1.0f;
- private float initialZoom = 1.0f;
- private float zoom = 1.0f;
- private boolean isSwiping = false;
private RequestManager glide;
private String postTitle;
@@ -135,202 +119,16 @@ public class ViewImageActivity extends AppCompatActivity {
setTitle("");
}
+ mHaulerView.setOnDragDismissedListener(dragDirection -> finish());
+
mLoadErrorLinearLayout.setOnClickListener(view -> {
- if (!isSwiping) {
- mProgressBar.setVisibility(View.VISIBLE);
- mLoadErrorLinearLayout.setVisibility(View.GONE);
- loadImage();
- }
- });
-
- float pxHeight = getResources().getDisplayMetrics().heightPixels;
-
- int activityColorFrom = getResources().getColor(android.R.color.black);
- int actionBarColorFrom = getResources().getColor(R.color.transparentActionBarAndExoPlayerControllerColor);
- int actionBarElementColorFrom = getResources().getColor(android.R.color.white);
- int colorTo = getResources().getColor(android.R.color.transparent);
-
- final ValueAnimator activityColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), activityColorFrom, colorTo);
- final ValueAnimator actionBarColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), actionBarColorFrom, colorTo);
- final ValueAnimator actionBarElementColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), actionBarElementColorFrom, colorTo);
-
- activityColorAnimation.setDuration(300); // milliseconds
- actionBarColorAnimation.setDuration(300);
- actionBarElementColorAnimation.setDuration(300);
-
- activityColorAnimation.addUpdateListener(valueAnimator -> mRelativeLayout.setBackgroundColor((int) valueAnimator.getAnimatedValue()));
-
- actionBarColorAnimation.addUpdateListener(valueAnimator -> actionBar.setBackgroundDrawable(new ColorDrawable((int) valueAnimator.getAnimatedValue())));
-
- actionBarElementColorAnimation.addUpdateListener(valueAnimator -> {
- upArrow.setColorFilter((int) valueAnimator.getAnimatedValue(), PorterDuff.Mode.SRC_IN);
- if (mMenu != null) {
- Drawable drawable = mMenu.getItem(0).getIcon();
- //drawable.mutate();
- drawable.setColorFilter((int) valueAnimator.getAnimatedValue(), PorterDuff.Mode.SRC_IN);
- }
+ mProgressBar.setVisibility(View.VISIBLE);
+ mLoadErrorLinearLayout.setVisibility(View.GONE);
+ loadImage();
});
loadImage();
- swipe = new Swipe();
- swipe.setListener(new SimpleSwipeListener() {
- @Override
- public void onSwipingUp(final MotionEvent event) {
- isSwiping = true;
- float nowY = event.getY();
- float offset;
- if (touchY == -1.0f) {
- offset = 0.0f;
- } else {
- offset = nowY - touchY;
- }
- totalLengthY += offset;
- touchY = nowY;
- mImageView.animate()
- .y(totalLengthY)
- .setDuration(0)
- .start();
- mLoadErrorLinearLayout.animate()
- .y(totalLengthY)
- .setDuration(0)
- .start();
- }
-
- @Override
- public boolean onSwipedUp(final MotionEvent event) {
- if (totalLengthY < -pxHeight / 8) {
- mImageView.animate()
- .y(-pxHeight)
- .setDuration(300)
- .setListener(new Animator.AnimatorListener() {
- @Override
- public void onAnimationStart(Animator animator) {
- activityColorAnimation.start();
- actionBarColorAnimation.start();
- actionBarElementColorAnimation.start();
- }
-
- @Override
- public void onAnimationEnd(Animator animator) {
- finish();
- }
-
- @Override
- public void onAnimationCancel(Animator animator) {
- }
-
- @Override
- public void onAnimationRepeat(Animator animator) {
- }
- })
- .start();
- mLoadErrorLinearLayout.animate()
- .y(-pxHeight)
- .setDuration(300)
- .start();
- } else {
- isSwiping = false;
- mImageView.animate()
- .y(0)
- .setDuration(300)
- .start();
- mLoadErrorLinearLayout.animate()
- .y(0)
- .setDuration(300)
- .start();
- }
-
- totalLengthY = 0.0f;
- touchY = -1.0f;
- return false;
- }
-
- @Override
- public void onSwipingDown(final MotionEvent event) {
- isSwiping = true;
- float nowY = event.getY();
- float offset;
- if (touchY == -1.0f) {
- offset = 0.0f;
- } else {
- offset = nowY - touchY;
- }
- totalLengthY += offset;
- touchY = nowY;
- mImageView.animate()
- .y(totalLengthY)
- .setDuration(0)
- .start();
- mLoadErrorLinearLayout.animate()
- .y(totalLengthY)
- .setDuration(0)
- .start();
- }
-
- @Override
- public boolean onSwipedDown(final MotionEvent event) {
- if (totalLengthY > pxHeight / 8) {
- mImageView.animate()
- .y(pxHeight)
- .setDuration(300)
- .setListener(new Animator.AnimatorListener() {
- @Override
- public void onAnimationStart(Animator animator) {
- activityColorAnimation.start();
- actionBarColorAnimation.start();
- actionBarElementColorAnimation.start();
- }
-
- @Override
- public void onAnimationEnd(Animator animator) {
- finish();
- }
-
- @Override
- public void onAnimationCancel(Animator animator) {
- }
-
- @Override
- public void onAnimationRepeat(Animator animator) {
- }
- })
- .start();
- mLoadErrorLinearLayout.animate()
- .y(pxHeight)
- .setDuration(300)
- .start();
- } else {
- isSwiping = false;
- mImageView.animate()
- .y(0)
- .setDuration(300)
- .start();
- mLoadErrorLinearLayout.animate()
- .y(0)
- .setDuration(300)
- .start();
- }
-
- totalLengthY = 0.0f;
- touchY = -1.0f;
-
- return false;
- }
- });
-
- mImageView.getController().addOnStateChangeListener(new GestureController.OnStateChangeListener() {
- @Override
- public void onStateChanged(State state) {
- zoom = state.getZoom();
- }
-
- @Override
- public void onStateReset(State oldState, State newState) {
- initialZoom = newState.getZoom();
- }
- });
-
mImageView.getController().getSettings().setMaxZoom(10f).setDoubleTapZoom(2f).setPanEnabled(true);
mImageView.setOnClickListener(view -> {
@@ -372,7 +170,6 @@ public class ViewImageActivity extends AppCompatActivity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- mMenu = menu;
getMenuInflater().inflate(R.menu.view_image_activity, menu);
return true;
}
@@ -453,14 +250,6 @@ public class ViewImageActivity extends AppCompatActivity {
return false;
}
- @Override
- public boolean dispatchTouchEvent(MotionEvent ev) {
- if (Math.abs(zoom - initialZoom) <= 0.000001) {
- swipe.dispatchTouchEvent(ev);
- }
- return super.dispatchTouchEvent(ev);
- }
-
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (requestCode == PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE && grantResults.length > 0) {
@@ -516,10 +305,4 @@ public class ViewImageActivity extends AppCompatActivity {
manager.enqueue(request);
Toast.makeText(this, R.string.download_started, Toast.LENGTH_SHORT).show();
}
-
- @Override
- protected void onPause() {
- super.onPause();
- overridePendingTransition(0, 0);
- }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java
index e9040328..9e0b95e7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java
@@ -19,6 +19,8 @@ import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.ViewPager;
+import com.thefuntasty.hauler.HaulerView;
+
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -56,6 +58,8 @@ public class ViewImgurMediaActivity extends AppCompatActivity {
public static final int IMGUR_TYPE_IMAGE = 2;
private static final String IMGUR_IMAGES_STATE = "IIS";
+ @BindView(R.id.hauler_view_view_imgur_media_activity)
+ HaulerView haulerView;
@BindView(R.id.progress_bar_view_imgur_media_activity)
ProgressBar progressBar;
@BindView(R.id.view_pager_view_imgur_media_activity)
@@ -109,6 +113,8 @@ public class ViewImgurMediaActivity extends AppCompatActivity {
images = savedInstanceState.getParcelableArrayList(IMGUR_IMAGES_STATE);
}
+ haulerView.setOnDragDismissedListener(dragDirection -> finish());
+
if (images == null) {
fetchImgurMedia(imgurId);
} else {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java
index fdf5c7d2..29b78878 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java
@@ -1,16 +1,12 @@
package ml.docilealligator.infinityforreddit.Activity;
import android.Manifest;
-import android.animation.Animator;
-import android.animation.ArgbEvaluator;
-import android.animation.ValueAnimator;
import android.app.DownloadManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
-import android.graphics.PorterDuff;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.media.AudioManager;
@@ -21,13 +17,11 @@ import android.os.Environment;
import android.text.Html;
import android.view.Menu;
import android.view.MenuItem;
-import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
-import android.widget.RelativeLayout;
import android.widget.Toast;
import androidx.annotation.NonNull;
@@ -36,8 +30,6 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
-import com.github.pwittchen.swipe.library.rx2.SimpleSwipeListener;
-import com.github.pwittchen.swipe.library.rx2.Swipe;
import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.SimpleExoPlayer;
@@ -55,6 +47,7 @@ import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;
import com.google.android.exoplayer2.util.Util;
+import com.thefuntasty.hauler.HaulerView;
import java.io.File;
@@ -86,8 +79,8 @@ public class ViewVideoActivity extends AppCompatActivity {
private static final String IS_MUTE_STATE = "IMS";
private static final String VIDEO_DOWNLOAD_URL_STATE = "VDUS";
private static final String VIDEO_URI_STATE = "VUS";
- @BindView(R.id.relative_layout_view_video_activity)
- RelativeLayout relativeLayout;
+ @BindView(R.id.hauler_view_view_video_activity)
+ HaulerView haulerView;
@BindView(R.id.progress_bar_view_video_activity)
ProgressBar progressBar;
@BindView(R.id.player_view_view_video_activity)
@@ -99,16 +92,11 @@ public class ViewVideoActivity extends AppCompatActivity {
private SimpleExoPlayer player;
private DataSource.Factory dataSourceFactory;
- private Menu mMenu;
- private Swipe swipe;
-
private String videoDownloadUrl;
private String videoFileName;
private boolean wasPlaying;
private boolean isDownloading = false;
private boolean isMute = false;
- private float totalLengthY = 0.0f;
- private float touchY = -1.0f;
private String postTitle;
private long resumePosition = -1;
@@ -155,6 +143,8 @@ public class ViewVideoActivity extends AppCompatActivity {
params.rightMargin = getResources().getDimensionPixelSize(resourceId);
}
+ haulerView.setOnDragDismissedListener(dragDirection -> finish());
+
Intent intent = getIntent();
mVideoUri = intent.getData();
postTitle = intent.getStringExtra(EXTRA_POST_TITLE);
@@ -168,156 +158,6 @@ public class ViewVideoActivity extends AppCompatActivity {
setTitle("");
}
- final float pxHeight = getResources().getDisplayMetrics().heightPixels;
-
- int activityColorFrom = getResources().getColor(android.R.color.black);
- int actionBarColorFrom = getResources().getColor(R.color.transparentActionBarAndExoPlayerControllerColor);
- int actionBarElementColorFrom = getResources().getColor(android.R.color.white);
- int colorTo = getResources().getColor(android.R.color.transparent);
-
- final ValueAnimator activityColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), activityColorFrom, colorTo);
- final ValueAnimator actionBarColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), actionBarColorFrom, colorTo);
- final ValueAnimator actionBarElementColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), actionBarElementColorFrom, colorTo);
-
- activityColorAnimation.setDuration(300); // milliseconds
- actionBarColorAnimation.setDuration(300);
- actionBarElementColorAnimation.setDuration(300);
-
- activityColorAnimation.addUpdateListener(valueAnimator -> relativeLayout.setBackgroundColor((int) valueAnimator.getAnimatedValue()));
-
- actionBarColorAnimation.addUpdateListener(valueAnimator -> actionBar.setBackgroundDrawable(new ColorDrawable((int) valueAnimator.getAnimatedValue())));
-
- actionBarElementColorAnimation.addUpdateListener(valueAnimator -> {
- upArrow.setColorFilter((int) valueAnimator.getAnimatedValue(), PorterDuff.Mode.SRC_IN);
- if (mMenu != null) {
- Drawable drawable = mMenu.getItem(0).getIcon();
- drawable.setColorFilter((int) valueAnimator.getAnimatedValue(), PorterDuff.Mode.SRC_IN);
- }
- });
-
- swipe = new Swipe();
- swipe.setListener(new SimpleSwipeListener() {
- @Override
- public void onSwipingUp(final MotionEvent event) {
- float nowY = event.getY();
- float offset;
- if (touchY == -1.0f) {
- offset = 0.0f;
- } else {
- offset = nowY - touchY;
- }
- totalLengthY += offset;
- touchY = nowY;
- videoPlayerView.animate()
- .y(totalLengthY)
- .setDuration(0)
- .start();
- }
-
- @Override
- public boolean onSwipedUp(final MotionEvent event) {
- videoPlayerView.animate()
- .y(0)
- .setDuration(300)
- .start();
-
- if (totalLengthY < -pxHeight / 8) {
- videoPlayerView.animate()
- .y(-pxHeight)
- .setDuration(300)
- .setListener(new Animator.AnimatorListener() {
- @Override
- public void onAnimationStart(Animator animator) {
- activityColorAnimation.start();
- actionBarColorAnimation.start();
- actionBarElementColorAnimation.start();
- }
-
- @Override
- public void onAnimationEnd(Animator animator) {
- finish();
- }
-
- @Override
- public void onAnimationCancel(Animator animator) {
- }
-
- @Override
- public void onAnimationRepeat(Animator animator) {
- }
- })
- .start();
- } else {
- videoPlayerView.animate()
- .y(0)
- .setDuration(300)
- .start();
- }
-
- totalLengthY = 0.0f;
- touchY = -1.0f;
- return false;
- }
-
- @Override
- public void onSwipingDown(final MotionEvent event) {
- float nowY = event.getY();
- float offset;
- if (touchY == -1.0f) {
- offset = 0.0f;
- } else {
- offset = nowY - touchY;
- }
- totalLengthY += offset;
- touchY = nowY;
- videoPlayerView.animate()
- .y(totalLengthY)
- .setDuration(0)
- .start();
- }
-
- @Override
- public boolean onSwipedDown(final MotionEvent event) {
- if (totalLengthY > pxHeight / 8) {
- videoPlayerView.animate()
- .y(pxHeight)
- .setDuration(300)
- .setListener(new Animator.AnimatorListener() {
- @Override
- public void onAnimationStart(Animator animator) {
- activityColorAnimation.start();
- actionBarColorAnimation.start();
- actionBarElementColorAnimation.start();
- }
-
- @Override
- public void onAnimationEnd(Animator animator) {
- finish();
- }
-
- @Override
- public void onAnimationCancel(Animator animator) {
- }
-
- @Override
- public void onAnimationRepeat(Animator animator) {
- }
- })
- .start();
- } else {
- videoPlayerView.animate()
- .y(0)
- .setDuration(300)
- .start();
- }
-
- totalLengthY = 0.0f;
- touchY = -1.0f;
-
- return false;
- }
- });
-
videoPlayerView.setControllerVisibilityListener(visibility -> {
switch (visibility) {
case View.GONE:
@@ -394,8 +234,6 @@ public class ViewVideoActivity extends AppCompatActivity {
player.prepare(new DashMediaSource.Factory(dataSourceFactory).createMediaSource(mVideoUri));
preparePlayer(savedInstanceState);
}
- } if (videoType == VIDEO_TYPE_REDGIFS) {
-
} else if (videoType == VIDEO_TYPE_DIRECT) {
videoDownloadUrl = mVideoUri.toString();
videoFileName = videoDownloadUrl.substring(videoDownloadUrl.lastIndexOf('/') + 1);
@@ -474,16 +312,9 @@ public class ViewVideoActivity extends AppCompatActivity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.view_video, menu);
- mMenu = menu;
return true;
}
- @Override
- public boolean dispatchTouchEvent(MotionEvent ev) {
- swipe.dispatchTouchEvent(ev);
- return super.dispatchTouchEvent(ev);
- }
-
@Override
protected void onDestroy() {
super.onDestroy();
@@ -599,12 +430,6 @@ public class ViewVideoActivity extends AppCompatActivity {
Toast.makeText(this, R.string.download_started, Toast.LENGTH_SHORT).show();
}
- @Override
- protected void onPause() {
- super.onPause();
- overridePendingTransition(0, 0);
- }
-
@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
index 7a1b6a78..e335bfa0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
@@ -2122,7 +2122,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter {
Post post = getItem(getAdapterPosition());
if (post != null) {
- Intent intent = new Intent(mActivity, ViewImageActivity.class);
- intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, post.getUrl());
- intent.putExtra(ViewImageActivity.FILE_NAME_KEY, post.getSubredditName()
- + "-" + post.getId() + ".jpg");
- intent.putExtra(ViewImageActivity.POST_TITLE_KEY, post.getTitle());
- mActivity.startActivity(intent);
+ if (post.getPostType() == Post.IMAGE_TYPE) {
+ Intent intent = new Intent(mActivity, ViewImageActivity.class);
+ intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, post.getUrl());
+ intent.putExtra(ViewImageActivity.FILE_NAME_KEY, post.getSubredditName()
+ + "-" + post.getId() + ".jpg");
+ intent.putExtra(ViewImageActivity.POST_TITLE_KEY, post.getTitle());
+ mActivity.startActivity(intent);
+ } else if (post.getPostType() == Post.GIF_TYPE) {
+ Intent intent = new Intent(mActivity, ViewGIFActivity.class);
+ intent.putExtra(ViewGIFActivity.FILE_NAME_KEY, post.getSubredditName()
+ + "-" + post.getId() + ".gif");
+ intent.putExtra(ViewGIFActivity.GIF_URL_KEY, post.getVideoUrl());
+ intent.putExtra(ViewGIFActivity.POST_TITLE_KEY, post.getTitle());
+ mActivity.startActivity(intent);
+ }
}
});
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurImageFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurImageFragment.java
index 3c9b5b41..ae047287 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurImageFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurImageFragment.java
@@ -63,7 +63,6 @@ public class ViewImgurImageFragment extends Fragment {
private Activity activity;
private RequestManager glide;
private ImgurMedia imgurMedia;
- private boolean isActionBarHidden = false;
private boolean isDownloading = false;
public ViewImgurImageFragment() {
diff --git a/app/src/main/res/layout/activity_view_gif.xml b/app/src/main/res/layout/activity_view_gif.xml
index cce51370..695ebc95 100644
--- a/app/src/main/res/layout/activity_view_gif.xml
+++ b/app/src/main/res/layout/activity_view_gif.xml
@@ -1,42 +1,56 @@
-
-
-
-
+ android:fillViewport="true">
-
-
-
+ android:layout_height="match_parent">
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_view_image.xml b/app/src/main/res/layout/activity_view_image.xml
index 8486d543..3b1b2e8c 100644
--- a/app/src/main/res/layout/activity_view_image.xml
+++ b/app/src/main/res/layout/activity_view_image.xml
@@ -1,41 +1,55 @@
-
-
-
-
+ android:fillViewport="true">
-
-
-
+ android:layout_height="match_parent">
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_view_imgur_media.xml b/app/src/main/res/layout/activity_view_imgur_media.xml
index 96936001..e6d6e67c 100644
--- a/app/src/main/res/layout/activity_view_imgur_media.xml
+++ b/app/src/main/res/layout/activity_view_imgur_media.xml
@@ -1,37 +1,53 @@
-
+ android:layout_height="match_parent"
+ app:dragUpEnabled="true"
+ tools:context=".Activity.ViewImgurMediaActivity">
-
-
-
+ android:fillViewport="true">
-
-
-
+ android:layout_height="match_parent">
-
+
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_view_video.xml b/app/src/main/res/layout/activity_view_video.xml
index 7d94d800..2907fd4d 100644
--- a/app/src/main/res/layout/activity_view_video.xml
+++ b/app/src/main/res/layout/activity_view_video.xml
@@ -1,25 +1,39 @@
-
-
+ android:fillViewport="true">
-
+
-
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 5634d70e..a7e31f71 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -32,10 +32,13 @@
- @android:color/transparent
-