mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-29 20:37:12 +01:00
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.
This commit is contained in:
parent
ca957e8904
commit
e5d9f93e96
@ -79,6 +79,7 @@ dependencies {
|
|||||||
implementation 'com.atlassian.commonmark:commonmark:0.13.1'
|
implementation 'com.atlassian.commonmark:commonmark:0.13.1'
|
||||||
implementation 'com.google.code.gson:gson:2.8.6'
|
implementation 'com.google.code.gson:gson:2.8.6'
|
||||||
implementation 'me.zhanghai.android.fastscroll:library:1.1.2'
|
implementation 'me.zhanghai.android.fastscroll:library:1.1.2'
|
||||||
|
implementation("com.thefuntasty.hauler:core:3.1.0")
|
||||||
|
|
||||||
def toroVersion = '3.7.0.2010003'
|
def toroVersion = '3.7.0.2010003'
|
||||||
implementation "im.ene.toro3:toro:$toroVersion"
|
implementation "im.ene.toro3:toro:$toroVersion"
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
android:name=".Activity.ViewImgurMediaActivity"
|
android:name=".Activity.ViewImgurMediaActivity"
|
||||||
android:configChanges="orientation|screenSize|layoutDirection"
|
android:configChanges="orientation|screenSize|layoutDirection"
|
||||||
android:parentActivityName=".Activity.MainActivity"
|
android:parentActivityName=".Activity.MainActivity"
|
||||||
android:theme="@style/AppTheme.ActionBar.Transparent" />
|
android:theme="@style/AppTheme.Draggable" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".Activity.ReportActivity"
|
android:name=".Activity.ReportActivity"
|
||||||
android:label="@string/report_activity_label"
|
android:label="@string/report_activity_label"
|
||||||
@ -83,7 +83,7 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".Activity.ViewGIFActivity"
|
android:name=".Activity.ViewGIFActivity"
|
||||||
android:parentActivityName=".Activity.MainActivity"
|
android:parentActivityName=".Activity.MainActivity"
|
||||||
android:theme="@style/AppTheme.ActionBar.Transparent" />
|
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"
|
||||||
@ -289,12 +289,12 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".Activity.ViewImageActivity"
|
android:name=".Activity.ViewImageActivity"
|
||||||
android:parentActivityName=".Activity.MainActivity"
|
android:parentActivityName=".Activity.MainActivity"
|
||||||
android:theme="@style/AppTheme.ActionBar.Transparent" />
|
android:theme="@style/AppTheme.Draggable" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".Activity.ViewVideoActivity"
|
android:name=".Activity.ViewVideoActivity"
|
||||||
android:configChanges="orientation|screenSize|layoutDirection"
|
android:configChanges="orientation|screenSize|layoutDirection"
|
||||||
android:parentActivityName=".Activity.MainActivity"
|
android:parentActivityName=".Activity.MainActivity"
|
||||||
android:theme="@style/AppTheme.ActionBar.Transparent" />
|
android:theme="@style/AppTheme.Draggable" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".Activity.ViewPostDetailActivity"
|
android:name=".Activity.ViewPostDetailActivity"
|
||||||
android:parentActivityName=".Activity.MainActivity"
|
android:parentActivityName=".Activity.MainActivity"
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
package ml.docilealligator.infinityforreddit.Activity;
|
package ml.docilealligator.infinityforreddit.Activity;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.animation.Animator;
|
|
||||||
import android.animation.ArgbEvaluator;
|
|
||||||
import android.animation.ValueAnimator;
|
|
||||||
import android.app.DownloadManager;
|
import android.app.DownloadManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.PorterDuff;
|
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@ -19,11 +15,9 @@ import android.os.Environment;
|
|||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
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.RequestListener;
|
||||||
import com.bumptech.glide.request.RequestOptions;
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
import com.bumptech.glide.request.target.Target;
|
import com.bumptech.glide.request.target.Target;
|
||||||
import com.github.pwittchen.swipe.library.rx2.SimpleSwipeListener;
|
import com.thefuntasty.hauler.HaulerView;
|
||||||
import com.github.pwittchen.swipe.library.rx2.Swipe;
|
|
||||||
|
|
||||||
import java.io.File;
|
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 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.parent_relative_layout_view_gif_activity)
|
@BindView(R.id.hauler_view_view_gif_activity)
|
||||||
RelativeLayout mRelativeLayout;
|
HaulerView mHaulerView;
|
||||||
@BindView(R.id.progress_bar_view_gif_activity)
|
@BindView(R.id.progress_bar_view_gif_activity)
|
||||||
ProgressBar mProgressBar;
|
ProgressBar mProgressBar;
|
||||||
@BindView(R.id.image_view_view_gif_activity)
|
@BindView(R.id.image_view_view_gif_activity)
|
||||||
@ -81,14 +74,9 @@ public class ViewGIFActivity extends AppCompatActivity {
|
|||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
private boolean isActionBarHidden = false;
|
private boolean isActionBarHidden = false;
|
||||||
private boolean isDownloading = false;
|
private boolean isDownloading = false;
|
||||||
private Menu mMenu;
|
|
||||||
private Swipe swipe;
|
|
||||||
private RequestManager glide;
|
private RequestManager glide;
|
||||||
private String mImageUrl;
|
private String mImageUrl;
|
||||||
private String mImageFileName;
|
private String mImageFileName;
|
||||||
private float totalLengthY = 0.0f;
|
|
||||||
private float touchY = -1.0f;
|
|
||||||
private float zoom = 1.0f;
|
|
||||||
private boolean isSwiping = false;
|
private boolean isSwiping = false;
|
||||||
private String postTitle;
|
private String postTitle;
|
||||||
|
|
||||||
@ -117,6 +105,8 @@ public class ViewGIFActivity extends AppCompatActivity {
|
|||||||
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();
|
||||||
@ -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();
|
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 -> {
|
mImageView.setOnClickListener(view -> {
|
||||||
if (isActionBarHidden) {
|
if (isActionBarHidden) {
|
||||||
getWindow().getDecorView().setSystemUiVisibility(
|
getWindow().getDecorView().setSystemUiVisibility(
|
||||||
@ -353,7 +169,6 @@ public class ViewGIFActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
mMenu = menu;
|
|
||||||
getMenuInflater().inflate(R.menu.view_gif_activity, menu);
|
getMenuInflater().inflate(R.menu.view_gif_activity, menu);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -434,14 +249,6 @@ public class ViewGIFActivity extends AppCompatActivity {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean dispatchTouchEvent(MotionEvent ev) {
|
|
||||||
if (zoom == 1.0) {
|
|
||||||
swipe.dispatchTouchEvent(ev);
|
|
||||||
}
|
|
||||||
return super.dispatchTouchEvent(ev);
|
|
||||||
}
|
|
||||||
|
|
||||||
@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) {
|
||||||
@ -497,10 +304,4 @@ public class ViewGIFActivity extends AppCompatActivity {
|
|||||||
manager.enqueue(request);
|
manager.enqueue(request);
|
||||||
Toast.makeText(this, R.string.download_started, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.download_started, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
overridePendingTransition(0, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,12 @@
|
|||||||
package ml.docilealligator.infinityforreddit.Activity;
|
package ml.docilealligator.infinityforreddit.Activity;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.animation.Animator;
|
|
||||||
import android.animation.ArgbEvaluator;
|
|
||||||
import android.animation.ValueAnimator;
|
|
||||||
import android.app.DownloadManager;
|
import android.app.DownloadManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.PorterDuff;
|
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@ -20,11 +16,9 @@ import android.os.Environment;
|
|||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -35,8 +29,6 @@ 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.GestureController;
|
|
||||||
import com.alexvasilkov.gestures.State;
|
|
||||||
import com.alexvasilkov.gestures.views.GestureImageView;
|
import com.alexvasilkov.gestures.views.GestureImageView;
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.RequestManager;
|
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.CustomTarget;
|
||||||
import com.bumptech.glide.request.target.Target;
|
import com.bumptech.glide.request.target.Target;
|
||||||
import com.bumptech.glide.request.transition.Transition;
|
import com.bumptech.glide.request.transition.Transition;
|
||||||
import com.github.pwittchen.swipe.library.rx2.SimpleSwipeListener;
|
import com.thefuntasty.hauler.HaulerView;
|
||||||
import com.github.pwittchen.swipe.library.rx2.Swipe;
|
|
||||||
|
|
||||||
import java.io.File;
|
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 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.parent_relative_layout_view_image_activity)
|
@BindView(R.id.hauler_view_view_image_activity)
|
||||||
RelativeLayout mRelativeLayout;
|
HaulerView mHaulerView;
|
||||||
@BindView(R.id.progress_bar_view_image_activity)
|
@BindView(R.id.progress_bar_view_image_activity)
|
||||||
ProgressBar mProgressBar;
|
ProgressBar mProgressBar;
|
||||||
@BindView(R.id.image_view_view_image_activity)
|
@BindView(R.id.image_view_view_image_activity)
|
||||||
@ -84,15 +75,8 @@ public class ViewImageActivity extends AppCompatActivity {
|
|||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
private boolean isActionBarHidden = false;
|
private boolean isActionBarHidden = false;
|
||||||
private boolean isDownloading = false;
|
private boolean isDownloading = false;
|
||||||
private Menu mMenu;
|
|
||||||
private Swipe swipe;
|
|
||||||
private String mImageUrl;
|
private String mImageUrl;
|
||||||
private String mImageFileName;
|
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 RequestManager glide;
|
||||||
private String postTitle;
|
private String postTitle;
|
||||||
|
|
||||||
@ -135,202 +119,16 @@ public class ViewImageActivity extends AppCompatActivity {
|
|||||||
setTitle("");
|
setTitle("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mHaulerView.setOnDragDismissedListener(dragDirection -> finish());
|
||||||
|
|
||||||
mLoadErrorLinearLayout.setOnClickListener(view -> {
|
mLoadErrorLinearLayout.setOnClickListener(view -> {
|
||||||
if (!isSwiping) {
|
|
||||||
mProgressBar.setVisibility(View.VISIBLE);
|
mProgressBar.setVisibility(View.VISIBLE);
|
||||||
mLoadErrorLinearLayout.setVisibility(View.GONE);
|
mLoadErrorLinearLayout.setVisibility(View.GONE);
|
||||||
loadImage();
|
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);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
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.getController().getSettings().setMaxZoom(10f).setDoubleTapZoom(2f).setPanEnabled(true);
|
||||||
|
|
||||||
mImageView.setOnClickListener(view -> {
|
mImageView.setOnClickListener(view -> {
|
||||||
@ -372,7 +170,6 @@ public class ViewImageActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
mMenu = menu;
|
|
||||||
getMenuInflater().inflate(R.menu.view_image_activity, menu);
|
getMenuInflater().inflate(R.menu.view_image_activity, menu);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -453,14 +250,6 @@ public class ViewImageActivity extends AppCompatActivity {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean dispatchTouchEvent(MotionEvent ev) {
|
|
||||||
if (Math.abs(zoom - initialZoom) <= 0.000001) {
|
|
||||||
swipe.dispatchTouchEvent(ev);
|
|
||||||
}
|
|
||||||
return super.dispatchTouchEvent(ev);
|
|
||||||
}
|
|
||||||
|
|
||||||
@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) {
|
||||||
@ -516,10 +305,4 @@ public class ViewImageActivity extends AppCompatActivity {
|
|||||||
manager.enqueue(request);
|
manager.enqueue(request);
|
||||||
Toast.makeText(this, R.string.download_started, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.download_started, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
overridePendingTransition(0, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ import androidx.fragment.app.FragmentManager;
|
|||||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||||
import androidx.viewpager.widget.ViewPager;
|
import androidx.viewpager.widget.ViewPager;
|
||||||
|
|
||||||
|
import com.thefuntasty.hauler.HaulerView;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@ -56,6 +58,8 @@ public class ViewImgurMediaActivity extends AppCompatActivity {
|
|||||||
public static final int IMGUR_TYPE_IMAGE = 2;
|
public static final int IMGUR_TYPE_IMAGE = 2;
|
||||||
private static final String IMGUR_IMAGES_STATE = "IIS";
|
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)
|
@BindView(R.id.progress_bar_view_imgur_media_activity)
|
||||||
ProgressBar progressBar;
|
ProgressBar progressBar;
|
||||||
@BindView(R.id.view_pager_view_imgur_media_activity)
|
@BindView(R.id.view_pager_view_imgur_media_activity)
|
||||||
@ -109,6 +113,8 @@ public class ViewImgurMediaActivity extends AppCompatActivity {
|
|||||||
images = savedInstanceState.getParcelableArrayList(IMGUR_IMAGES_STATE);
|
images = savedInstanceState.getParcelableArrayList(IMGUR_IMAGES_STATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
haulerView.setOnDragDismissedListener(dragDirection -> finish());
|
||||||
|
|
||||||
if (images == null) {
|
if (images == null) {
|
||||||
fetchImgurMedia(imgurId);
|
fetchImgurMedia(imgurId);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,16 +1,12 @@
|
|||||||
package ml.docilealligator.infinityforreddit.Activity;
|
package ml.docilealligator.infinityforreddit.Activity;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.animation.Animator;
|
|
||||||
import android.animation.ArgbEvaluator;
|
|
||||||
import android.animation.ValueAnimator;
|
|
||||||
import android.app.DownloadManager;
|
import android.app.DownloadManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.PorterDuff;
|
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
@ -21,13 +17,11 @@ import android.os.Environment;
|
|||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -36,8 +30,6 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
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.ExoPlayerFactory;
|
||||||
import com.google.android.exoplayer2.Player;
|
import com.google.android.exoplayer2.Player;
|
||||||
import com.google.android.exoplayer2.SimpleExoPlayer;
|
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.DefaultDataSourceFactory;
|
||||||
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;
|
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
|
import com.thefuntasty.hauler.HaulerView;
|
||||||
|
|
||||||
import java.io.File;
|
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 IS_MUTE_STATE = "IMS";
|
||||||
private static final String VIDEO_DOWNLOAD_URL_STATE = "VDUS";
|
private static final String VIDEO_DOWNLOAD_URL_STATE = "VDUS";
|
||||||
private static final String VIDEO_URI_STATE = "VUS";
|
private static final String VIDEO_URI_STATE = "VUS";
|
||||||
@BindView(R.id.relative_layout_view_video_activity)
|
@BindView(R.id.hauler_view_view_video_activity)
|
||||||
RelativeLayout relativeLayout;
|
HaulerView haulerView;
|
||||||
@BindView(R.id.progress_bar_view_video_activity)
|
@BindView(R.id.progress_bar_view_video_activity)
|
||||||
ProgressBar progressBar;
|
ProgressBar progressBar;
|
||||||
@BindView(R.id.player_view_view_video_activity)
|
@BindView(R.id.player_view_view_video_activity)
|
||||||
@ -99,16 +92,11 @@ public class ViewVideoActivity extends AppCompatActivity {
|
|||||||
private SimpleExoPlayer player;
|
private SimpleExoPlayer player;
|
||||||
private DataSource.Factory dataSourceFactory;
|
private DataSource.Factory dataSourceFactory;
|
||||||
|
|
||||||
private Menu mMenu;
|
|
||||||
private Swipe swipe;
|
|
||||||
|
|
||||||
private String videoDownloadUrl;
|
private String videoDownloadUrl;
|
||||||
private String videoFileName;
|
private String videoFileName;
|
||||||
private boolean wasPlaying;
|
private boolean wasPlaying;
|
||||||
private boolean isDownloading = false;
|
private boolean isDownloading = false;
|
||||||
private boolean isMute = false;
|
private boolean isMute = false;
|
||||||
private float totalLengthY = 0.0f;
|
|
||||||
private float touchY = -1.0f;
|
|
||||||
private String postTitle;
|
private String postTitle;
|
||||||
private long resumePosition = -1;
|
private long resumePosition = -1;
|
||||||
|
|
||||||
@ -155,6 +143,8 @@ public class ViewVideoActivity extends AppCompatActivity {
|
|||||||
params.rightMargin = getResources().getDimensionPixelSize(resourceId);
|
params.rightMargin = getResources().getDimensionPixelSize(resourceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
haulerView.setOnDragDismissedListener(dragDirection -> finish());
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
mVideoUri = intent.getData();
|
mVideoUri = intent.getData();
|
||||||
postTitle = intent.getStringExtra(EXTRA_POST_TITLE);
|
postTitle = intent.getStringExtra(EXTRA_POST_TITLE);
|
||||||
@ -168,156 +158,6 @@ public class ViewVideoActivity extends AppCompatActivity {
|
|||||||
setTitle("");
|
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 -> {
|
videoPlayerView.setControllerVisibilityListener(visibility -> {
|
||||||
switch (visibility) {
|
switch (visibility) {
|
||||||
case View.GONE:
|
case View.GONE:
|
||||||
@ -394,8 +234,6 @@ public class ViewVideoActivity extends AppCompatActivity {
|
|||||||
player.prepare(new DashMediaSource.Factory(dataSourceFactory).createMediaSource(mVideoUri));
|
player.prepare(new DashMediaSource.Factory(dataSourceFactory).createMediaSource(mVideoUri));
|
||||||
preparePlayer(savedInstanceState);
|
preparePlayer(savedInstanceState);
|
||||||
}
|
}
|
||||||
} if (videoType == VIDEO_TYPE_REDGIFS) {
|
|
||||||
|
|
||||||
} else if (videoType == VIDEO_TYPE_DIRECT) {
|
} else if (videoType == VIDEO_TYPE_DIRECT) {
|
||||||
videoDownloadUrl = mVideoUri.toString();
|
videoDownloadUrl = mVideoUri.toString();
|
||||||
videoFileName = videoDownloadUrl.substring(videoDownloadUrl.lastIndexOf('/') + 1);
|
videoFileName = videoDownloadUrl.substring(videoDownloadUrl.lastIndexOf('/') + 1);
|
||||||
@ -474,16 +312,9 @@ public class ViewVideoActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.view_video, menu);
|
getMenuInflater().inflate(R.menu.view_video, menu);
|
||||||
mMenu = menu;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean dispatchTouchEvent(MotionEvent ev) {
|
|
||||||
swipe.dispatchTouchEvent(ev);
|
|
||||||
return super.dispatchTouchEvent(ev);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
@ -599,12 +430,6 @@ public class ViewVideoActivity extends AppCompatActivity {
|
|||||||
Toast.makeText(this, R.string.download_started, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.download_started, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
overridePendingTransition(0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
|
@ -2122,7 +2122,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
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, ViewGIFActivity.class);
|
||||||
intent.setData(Uri.parse(post.getVideoUrl()));
|
|
||||||
intent.putExtra(ViewGIFActivity.FILE_NAME_KEY, post.getSubredditName()
|
intent.putExtra(ViewGIFActivity.FILE_NAME_KEY, post.getSubredditName()
|
||||||
+ "-" + post.getId() + ".gif");
|
+ "-" + post.getId() + ".gif");
|
||||||
intent.putExtra(ViewGIFActivity.GIF_URL_KEY, post.getVideoUrl());
|
intent.putExtra(ViewGIFActivity.GIF_URL_KEY, post.getVideoUrl());
|
||||||
@ -2220,12 +2219,21 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
imageView.setOnClickListener(view -> {
|
imageView.setOnClickListener(view -> {
|
||||||
Post post = getItem(getAdapterPosition());
|
Post post = getItem(getAdapterPosition());
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
|
if (post.getPostType() == Post.IMAGE_TYPE) {
|
||||||
Intent intent = new Intent(mActivity, ViewImageActivity.class);
|
Intent intent = new Intent(mActivity, ViewImageActivity.class);
|
||||||
intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, post.getUrl());
|
intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, post.getUrl());
|
||||||
intent.putExtra(ViewImageActivity.FILE_NAME_KEY, post.getSubredditName()
|
intent.putExtra(ViewImageActivity.FILE_NAME_KEY, post.getSubredditName()
|
||||||
+ "-" + post.getId() + ".jpg");
|
+ "-" + post.getId() + ".jpg");
|
||||||
intent.putExtra(ViewImageActivity.POST_TITLE_KEY, post.getTitle());
|
intent.putExtra(ViewImageActivity.POST_TITLE_KEY, post.getTitle());
|
||||||
mActivity.startActivity(intent);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,6 @@ public class ViewImgurImageFragment extends Fragment {
|
|||||||
private Activity activity;
|
private Activity activity;
|
||||||
private RequestManager glide;
|
private RequestManager glide;
|
||||||
private ImgurMedia imgurMedia;
|
private ImgurMedia imgurMedia;
|
||||||
private boolean isActionBarHidden = false;
|
|
||||||
private boolean isDownloading = false;
|
private boolean isDownloading = false;
|
||||||
|
|
||||||
public ViewImgurImageFragment() {
|
public ViewImgurImageFragment() {
|
||||||
|
@ -1,14 +1,24 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?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: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_gif_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:id="@+id/parent_relative_layout_view_gif_activity"
|
|
||||||
android:background="#000000"
|
|
||||||
android:keepScreenOn="true"
|
android:keepScreenOn="true"
|
||||||
|
app:dragUpEnabled="true"
|
||||||
tools:application="ml.docilealligator.infinityforreddit.Activity.ViewGIFActivity">
|
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
|
<ProgressBar
|
||||||
android:id="@+id/progress_bar_view_gif_activity"
|
android:id="@+id/progress_bar_view_gif_activity"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -39,4 +49,8 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
|
</com.thefuntasty.hauler.HaulerView>
|
@ -1,13 +1,23 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?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: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:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:id="@+id/parent_relative_layout_view_image_activity"
|
app:dragUpEnabled="true"
|
||||||
android:background="@android:color/black"
|
|
||||||
tools:application="ml.docilealligator.infinityforreddit.Activity.ViewImageActivity">
|
tools:application="ml.docilealligator.infinityforreddit.Activity.ViewImageActivity">
|
||||||
|
|
||||||
|
<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
|
<ProgressBar
|
||||||
android:id="@+id/progress_bar_view_image_activity"
|
android:id="@+id/progress_bar_view_image_activity"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -38,4 +48,8 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
|
</com.thefuntasty.hauler.HaulerView>
|
@ -1,6 +1,19 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?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"
|
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"
|
||||||
|
app:dragUpEnabled="true"
|
||||||
|
tools:context=".Activity.ViewImgurMediaActivity">
|
||||||
|
|
||||||
|
<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_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
@ -13,8 +26,7 @@
|
|||||||
<androidx.viewpager.widget.ViewPager
|
<androidx.viewpager.widget.ViewPager
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:id="@+id/view_pager_view_imgur_media_activity"
|
android:id="@+id/view_pager_view_imgur_media_activity" />
|
||||||
tools:context=".Activity.ViewImgurMediaActivity" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/load_image_error_linear_layout_view_imgur_media_activity"
|
android:id="@+id/load_image_error_linear_layout_view_imgur_media_activity"
|
||||||
@ -34,4 +46,8 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
|
</com.thefuntasty.hauler.HaulerView>
|
@ -1,14 +1,24 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?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: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_video_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="#000000"
|
|
||||||
android:id="@+id/relative_layout_view_video_activity"
|
|
||||||
android:keepScreenOn="true"
|
android:keepScreenOn="true"
|
||||||
|
app:dragUpEnabled="true"
|
||||||
tools:application="ml.docilealligator.infinityforreddit.Activity.ViewVideoActivity">
|
tools:application="ml.docilealligator.infinityforreddit.Activity.ViewVideoActivity">
|
||||||
|
|
||||||
|
<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">
|
||||||
|
|
||||||
<com.google.android.exoplayer2.ui.PlayerView
|
<com.google.android.exoplayer2.ui.PlayerView
|
||||||
android:id="@+id/player_view_view_video_activity"
|
android:id="@+id/player_view_view_video_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -22,4 +32,8 @@
|
|||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
|
</com.thefuntasty.hauler.HaulerView>
|
@ -32,10 +32,13 @@
|
|||||||
<item name="android:windowBackground">@android:color/transparent</item>
|
<item name="android:windowBackground">@android:color/transparent</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="AppTheme.ActionBar.Transparent" parent="AppTheme">
|
<style name="AppTheme.Draggable" parent="AppTheme">
|
||||||
<item name="android:windowBackground">@android:color/black</item>
|
<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:windowTranslucentStatus">true</item>
|
||||||
<item name="android:windowTranslucentNavigation">true</item>
|
<item name="android:windowBackground">@android:color/black</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.DayNight.ActionBar" />
|
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.DayNight.ActionBar" />
|
||||||
|
Loading…
Reference in New Issue
Block a user