aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-06-04 12:06:01 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-06-04 12:06:01 +0000
commite5d9f93e96a0876676a75e31ebea29e4071c580a (patch)
treededd62954c1ab39b5dceda0cc871e0700c0f2d60 /app
parentca957e890443452d2c543f567b53e94495dbf8e5 (diff)
downloadinfinity-for-reddit-e5d9f93e96a0876676a75e31ebea29e4071c580a.tar
infinity-for-reddit-e5d9f93e96a0876676a75e31ebea29e4071c580a.tar.gz
infinity-for-reddit-e5d9f93e96a0876676a75e31ebea29e4071c580a.tar.bz2
infinity-for-reddit-e5d9f93e96a0876676a75e31ebea29e4071c580a.tar.lz
infinity-for-reddit-e5d9f93e96a0876676a75e31ebea29e4071c580a.tar.xz
infinity-for-reddit-e5d9f93e96a0876676a75e31ebea29e4071c580a.tar.zst
infinity-for-reddit-e5d9f93e96a0876676a75e31ebea29e4071c580a.zip
Swipe up or down to finish ViewImgurMediaActivity. Using Hauler to do swipe up or down to finish ViewImageActivity, ViewGIFActivity and ViewVideoActivity. Fixed gifs downloaded as jpg.
Diffstat (limited to '')
-rw-r--r--app/build.gradle1
-rw-r--r--app/src/main/AndroidManifest.xml8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java209
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java233
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java185
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java22
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurImageFragment.java1
-rw-r--r--app/src/main/res/layout/activity_view_gif.xml70
-rw-r--r--app/src/main/res/layout/activity_view_image.xml70
-rw-r--r--app/src/main/res/layout/activity_view_imgur_media.xml70
-rw-r--r--app/src/main/res/layout/activity_view_video.xml40
-rw-r--r--app/src/main/res/values/styles.xml9
13 files changed, 204 insertions, 720 deletions
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" />
<activity
android:name=".Activity.ReportActivity"
android:label="@string/report_activity_label"
@@ -83,7 +83,7 @@
<activity
android:name=".Activity.ViewGIFActivity"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.ActionBar.Transparent" />
+ android:theme="@style/AppTheme.Draggable" />
<activity
android:name=".Activity.AccountSavedThingActivity"
android:label="@string/account_saved_thing_activity_label"
@@ -289,12 +289,12 @@
<activity
android:name=".Activity.ViewImageActivity"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.ActionBar.Transparent" />
+ android:theme="@style/AppTheme.Draggable" />
<activity
android:name=".Activity.ViewVideoActivity"
android:configChanges="orientation|screenSize|layoutDirection"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.ActionBar.Transparent" />
+ android:theme="@style/AppTheme.Draggable" />
<activity
android:name=".Activity.ViewPostDetailActivity"
android:parentActivityName=".Activity.MainActivity"
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java
index 3173c143..8bdc82fe 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java
@@ -1,15 +1,11 @@
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.PorterDuff;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
@@ -19,11 +15,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;
@@ -42,8 +36,7 @@ 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.github.pwittchen.swipe.library.rx2.SimpleSwipeListener;
-import com.github.pwittchen.swipe.library.rx2.Swipe;
+import com.thefuntasty.hauler.HaulerView;
import java.io.File;
@@ -68,8 +61,8 @@ public class ViewGIFActivity 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_gif_activity)
- RelativeLayout mRelativeLayout;
+ @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)
@@ -81,14 +74,9 @@ public class ViewGIFActivity extends AppCompatActivity {
SharedPreferences mSharedPreferences;
private boolean isActionBarHidden = false;
private boolean isDownloading = false;
- private Menu mMenu;
- private Swipe swipe;
private RequestManager glide;
private String mImageUrl;
private String mImageFileName;
- private float totalLengthY = 0.0f;
- private float touchY = -1.0f;
- private float zoom = 1.0f;
private boolean isSwiping = false;
private String postTitle;
@@ -117,6 +105,8 @@ public class ViewGIFActivity extends AppCompatActivity {
actionBar.setHomeAsUpIndicator(upArrow);
actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparentActionBarAndExoPlayerControllerColor)));
+ mHaulerView.setOnDragDismissedListener(dragDirection -> 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;
}
@@ -435,14 +250,6 @@ public class ViewGIFActivity extends AppCompatActivity {
}
@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) {
if (grantResults[0] == PackageManager.PERMISSION_DENIED) {
@@ -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("");
}
- 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);
+ mHaulerView.setOnDragDismissedListener(dragDirection -> finish());
- 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);
- }
+ mLoadErrorLinearLayout.setOnClickListener(view -> {
+ 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;
}
@@ -454,14 +251,6 @@ public class ViewImageActivity extends AppCompatActivity {
}
@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) {
if (grantResults[0] == PackageManager.PERMISSION_DENIED) {
@@ -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,17 +312,10 @@ 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();
player.release();
@@ -600,12 +431,6 @@ public class ViewVideoActivity extends AppCompatActivity {
}
@Override
- protected void onPause() {
- super.onPause();
- overridePendingTransition(0, 0);
- }
-
- @Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(IS_MUTE_STATE, isMute);
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, RecyclerView
mActivity.startActivity(intent);
} else if (post.getPostType() == Post.GIF_TYPE) {
Intent intent = new Intent(mActivity, ViewGIFActivity.class);
- intent.setData(Uri.parse(post.getVideoUrl()));
intent.putExtra(ViewGIFActivity.FILE_NAME_KEY, post.getSubredditName()
+ "-" + post.getId() + ".gif");
intent.putExtra(ViewGIFActivity.GIF_URL_KEY, post.getVideoUrl());
@@ -2220,12 +2219,21 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
imageView.setOnClickListener(view -> {
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 @@
<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<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:id="@+id/parent_relative_layout_view_gif_activity"
- android:background="#000000"
android:keepScreenOn="true"
+ app:dragUpEnabled="true"
tools:application="ml.docilealligator.infinityforreddit.Activity.ViewGIFActivity">
- <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"
+ <androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
- app:gest_fillViewport="true" />
+ android: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
+ <RelativeLayout
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: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" />
+
+ </LinearLayout>
+
+ </RelativeLayout>
- </LinearLayout>
+ </androidx.core.widget.NestedScrollView>
-</RelativeLayout>
+</com.thefuntasty.hauler.HaulerView> \ 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 @@
<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<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_image_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:id="@+id/parent_relative_layout_view_image_activity"
- android:background="@android:color/black"
+ app:dragUpEnabled="true"
tools:application="ml.docilealligator.infinityforreddit.Activity.ViewImageActivity">
- <ProgressBar
- android:id="@+id/progress_bar_view_image_activity"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true" />
-
- <com.alexvasilkov.gestures.views.GestureImageView
- android:id="@+id/image_view_view_image_activity"
+ <androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
- app:gest_fillViewport="true" />
+ android:fillViewport="true">
- <LinearLayout
- android:id="@+id/load_image_error_linear_layout_view_image_activity"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:visibility="gone">
-
- <TextView
+ <RelativeLayout
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_image_tap_to_retry"
- android:textSize="?attr/font_default" />
+ android:layout_height="match_parent">
+
+ <ProgressBar
+ android:id="@+id/progress_bar_view_image_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerInParent="true" />
+
+ <com.alexvasilkov.gestures.views.GestureImageView
+ android:id="@+id/image_view_view_image_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_image_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_image_tap_to_retry"
+ android:textSize="?attr/font_default" />
+
+ </LinearLayout>
+
+ </RelativeLayout>
- </LinearLayout>
+ </androidx.core.widget.NestedScrollView>
-</RelativeLayout>
+</com.thefuntasty.hauler.HaulerView> \ 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 @@
<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<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_imgur_media_activity"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ app:dragUpEnabled="true"
+ tools:context=".Activity.ViewImgurMediaActivity">
- <ProgressBar
- android:id="@+id/progress_bar_view_imgur_media_activity"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true" />
-
- <androidx.viewpager.widget.ViewPager
+ <androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:id="@+id/view_pager_view_imgur_media_activity"
- tools:context=".Activity.ViewImgurMediaActivity" />
+ android:fillViewport="true">
- <LinearLayout
- android:id="@+id/load_image_error_linear_layout_view_imgur_media_activity"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:visibility="gone">
-
- <TextView
+ <RelativeLayout
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_image_tap_to_retry"
- android:textSize="?attr/font_default" />
+ android:layout_height="match_parent">
+
+ <ProgressBar
+ android:id="@+id/progress_bar_view_imgur_media_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerInParent="true" />
+
+ <androidx.viewpager.widget.ViewPager
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:id="@+id/view_pager_view_imgur_media_activity" />
+
+ <LinearLayout
+ android:id="@+id/load_image_error_linear_layout_view_imgur_media_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_image_tap_to_retry"
+ android:textSize="?attr/font_default" />
+
+ </LinearLayout>
+
+ </RelativeLayout>
- </LinearLayout>
+ </androidx.core.widget.NestedScrollView>
-</RelativeLayout> \ No newline at end of file
+</com.thefuntasty.hauler.HaulerView> \ 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 @@
<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<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_video_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="#000000"
- android:id="@+id/relative_layout_view_video_activity"
android:keepScreenOn="true"
+ app:dragUpEnabled="true"
tools:application="ml.docilealligator.infinityforreddit.Activity.ViewVideoActivity">
- <com.google.android.exoplayer2.ui.PlayerView
- android:id="@+id/player_view_view_video_activity"
+ <androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
- app:controller_layout_id="@layout/exo_playback_control_view"/>
+ android:fillViewport="true">
- <ProgressBar
- android:id="@+id/progress_bar_view_video_activity"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true"
- android:visibility="gone" />
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
-</RelativeLayout>
+ <com.google.android.exoplayer2.ui.PlayerView
+ android:id="@+id/player_view_view_video_activity"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:controller_layout_id="@layout/exo_playback_control_view"/>
+
+ <ProgressBar
+ android:id="@+id/progress_bar_view_video_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerInParent="true"
+ android:visibility="gone" />
+
+ </RelativeLayout>
+
+ </androidx.core.widget.NestedScrollView>
+
+</com.thefuntasty.hauler.HaulerView> \ 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 @@
<item name="android:windowBackground">@android:color/transparent</item>
</style>
- <style name="AppTheme.ActionBar.Transparent" parent="AppTheme">
- <item name="android:windowBackground">@android:color/black</item>
+ <style name="AppTheme.Draggable" parent="AppTheme">
+ <item name="android:colorBackgroundCacheHint">@null</item>
+ <item name="android:windowContentOverlay">@null</item>
+ <item name="android:windowIsFloating">false</item>
+ <item name="android:windowIsTranslucent">true</item>
<item name="android:windowTranslucentStatus">true</item>
- <item name="android:windowTranslucentNavigation">true</item>
+ <item name="android:windowBackground">@android:color/black</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.DayNight.ActionBar" />