mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-02-09 07:58:43 +01:00
Delete something related to downloading videos.
This commit is contained in:
parent
7866b1c92e
commit
cf84a6d431
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
BIN
.idea/caches/gradle_models.ser
generated
BIN
.idea/caches/gradle_models.ser
generated
Binary file not shown.
@ -6,8 +6,8 @@ android {
|
|||||||
applicationId "ml.docilealligator.infinityforreddit"
|
applicationId "ml.docilealligator.infinityforreddit"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 10
|
versionCode 11
|
||||||
versionName "1.0.9"
|
versionName "1.1.0"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
@ -33,16 +33,16 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
|
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||||
implementation 'com.google.android.material:material:1.1.0-alpha09'
|
implementation 'com.google.android.material:material:1.1.0-alpha10'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
|
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
androidTestImplementation 'androidx.test:runner:1.2.0'
|
androidTestImplementation 'androidx.test:runner:1.2.0'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||||
implementation 'com.google.android.exoplayer:exoplayer:2.9.6'
|
implementation 'com.google.android.exoplayer:exoplayer:2.10.4'
|
||||||
implementation 'com.google.android.exoplayer:exoplayer-dash:2.9.6'
|
implementation 'com.google.android.exoplayer:exoplayer-dash:2.10.4'
|
||||||
implementation 'androidx.browser:browser:1.0.0'
|
implementation 'androidx.browser:browser:1.0.0'
|
||||||
implementation 'com.alexvasilkov:gesture-views:2.5.2'
|
implementation 'com.alexvasilkov:gesture-views:2.5.2'
|
||||||
implementation 'androidx.cardview:cardview:1.0.0'
|
implementation 'androidx.cardview:cardview:1.0.0'
|
||||||
@ -79,6 +79,6 @@ dependencies {
|
|||||||
implementation 'com.evernote:android-state:1.4.1'
|
implementation 'com.evernote:android-state:1.4.1'
|
||||||
annotationProcessor 'com.evernote:android-state-processor:1.4.1'
|
annotationProcessor 'com.evernote:android-state-processor:1.4.1'
|
||||||
implementation 'androidx.work:work-runtime:2.2.0'
|
implementation 'androidx.work:work-runtime:2.2.0'
|
||||||
implementation 'androidx.preference:preference:1.1.0-rc01'
|
implementation 'androidx.preference:preference:1.1.0'
|
||||||
implementation 'org.sufficientlysecure:html-textview:3.6'
|
implementation 'org.sufficientlysecure:html-textview:3.6'
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,15 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="ml.docilealligator.infinityforreddit">
|
package="ml.docilealligator.infinityforreddit">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
|
<uses-permission
|
||||||
|
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||||
|
android:maxSdkVersion="22" />
|
||||||
|
|
||||||
|
<uses-permission-sdk-23 android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".Infinity"
|
android:name=".Infinity"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
@ -249,13 +258,5 @@
|
|||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
</application>
|
</application>
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
|
||||||
|
|
||||||
<uses-permission
|
|
||||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
|
||||||
android:maxSdkVersion="22" />
|
|
||||||
|
|
||||||
<uses-permission-sdk-23 android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
@ -431,13 +431,8 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
|
|||||||
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
|
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
|
||||||
intent.setData(gifVideoUri);
|
intent.setData(gifVideoUri);
|
||||||
intent.putExtra(ViewVideoActivity.TITLE_KEY, mPost.getTitle());
|
intent.putExtra(ViewVideoActivity.TITLE_KEY, mPost.getTitle());
|
||||||
intent.putExtra(ViewVideoActivity.IS_HLS_VIDEO_KEY, mPost.isHLSVideo());
|
intent.putExtra(ViewVideoActivity.SUBREDDIT_KEY, mPost.getSubredditName());
|
||||||
intent.putExtra(ViewVideoActivity.IS_DOWNLOADABLE_KEY, mPost.isDownloadableGifOrVideo());
|
intent.putExtra(ViewVideoActivity.ID_KEY, mPost.getId());
|
||||||
if(mPost.isDownloadableGifOrVideo()) {
|
|
||||||
intent.putExtra(ViewVideoActivity.DOWNLOAD_URL_KEY, mPost.getGifOrVideoDownloadUrl());
|
|
||||||
intent.putExtra(ViewVideoActivity.SUBREDDIT_KEY, mPost.getSubredditName());
|
|
||||||
intent.putExtra(ViewVideoActivity.ID_KEY, mPost.getId());
|
|
||||||
}
|
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@ -449,13 +444,8 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
|
|||||||
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
|
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
|
||||||
intent.setData(videoUri);
|
intent.setData(videoUri);
|
||||||
intent.putExtra(ViewVideoActivity.TITLE_KEY, mPost.getTitle());
|
intent.putExtra(ViewVideoActivity.TITLE_KEY, mPost.getTitle());
|
||||||
intent.putExtra(ViewVideoActivity.IS_HLS_VIDEO_KEY, mPost.isHLSVideo());
|
intent.putExtra(ViewVideoActivity.SUBREDDIT_KEY, mPost.getSubredditName());
|
||||||
intent.putExtra(ViewVideoActivity.IS_DOWNLOADABLE_KEY, mPost.isDownloadableGifOrVideo());
|
intent.putExtra(ViewVideoActivity.ID_KEY, mPost.getId());
|
||||||
if(mPost.isDownloadableGifOrVideo()) {
|
|
||||||
intent.putExtra(ViewVideoActivity.DOWNLOAD_URL_KEY, mPost.getGifOrVideoDownloadUrl());
|
|
||||||
intent.putExtra(ViewVideoActivity.SUBREDDIT_KEY, mPost.getSubredditName());
|
|
||||||
intent.putExtra(ViewVideoActivity.ID_KEY, mPost.getId());
|
|
||||||
}
|
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
@ -268,12 +268,11 @@ class ParsePost {
|
|||||||
|
|
||||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime,
|
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime,
|
||||||
title, previewUrl, permalink, score, postType, voteType, gilded, flair, hidden,
|
title, previewUrl, permalink, score, postType, voteType, gilded, flair, hidden,
|
||||||
spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, true);
|
spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
|
||||||
|
|
||||||
post.setPreviewWidth(previewWidth);
|
post.setPreviewWidth(previewWidth);
|
||||||
post.setPreviewHeight(previewHeight);
|
post.setPreviewHeight(previewHeight);
|
||||||
post.setVideoUrl(videoUrl);
|
post.setVideoUrl(videoUrl);
|
||||||
post.setDownloadableGifOrVideo(false);
|
|
||||||
} else if(data.has(JSONUtils.PREVIEW_KEY)){
|
} else if(data.has(JSONUtils.PREVIEW_KEY)){
|
||||||
if(data.getJSONObject(JSONUtils.PREVIEW_KEY).has(JSONUtils.REDDIT_VIDEO_PREVIEW_KEY)) {
|
if(data.getJSONObject(JSONUtils.PREVIEW_KEY).has(JSONUtils.REDDIT_VIDEO_PREVIEW_KEY)) {
|
||||||
//Gif video post (HLS)
|
//Gif video post (HLS)
|
||||||
@ -284,11 +283,10 @@ class ParsePost {
|
|||||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
||||||
formattedPostTime, title, previewUrl, permalink, score, postType, voteType,
|
formattedPostTime, title, previewUrl, permalink, score, postType, voteType,
|
||||||
gilded, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved,
|
gilded, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved,
|
||||||
isCrosspost, true);
|
isCrosspost);
|
||||||
post.setPreviewWidth(previewWidth);
|
post.setPreviewWidth(previewWidth);
|
||||||
post.setPreviewHeight(previewHeight);
|
post.setPreviewHeight(previewHeight);
|
||||||
post.setVideoUrl(videoUrl);
|
post.setVideoUrl(videoUrl);
|
||||||
post.setDownloadableGifOrVideo(false);
|
|
||||||
} else {
|
} else {
|
||||||
if (url.endsWith("jpg") || url.endsWith("png")) {
|
if (url.endsWith("jpg") || url.endsWith("png")) {
|
||||||
//Image post
|
//Image post
|
||||||
|
@ -30,7 +30,6 @@ class Post implements Parcelable {
|
|||||||
private String previewUrl;
|
private String previewUrl;
|
||||||
private String url;
|
private String url;
|
||||||
private String videoUrl;
|
private String videoUrl;
|
||||||
private String gifOrVideoDownloadUrl;
|
|
||||||
private String permalink;
|
private String permalink;
|
||||||
private String flair;
|
private String flair;
|
||||||
private int score;
|
private int score;
|
||||||
@ -47,15 +46,12 @@ class Post implements Parcelable {
|
|||||||
private boolean locked;
|
private boolean locked;
|
||||||
private boolean saved;
|
private boolean saved;
|
||||||
private boolean isCrosspost;
|
private boolean isCrosspost;
|
||||||
private boolean isHLSVideo;
|
|
||||||
private boolean isDownloadableGifOrVideo;
|
|
||||||
private String crosspostParentId;
|
private String crosspostParentId;
|
||||||
|
|
||||||
Post(String id, String fullName, String subredditName, String subredditNamePrefixed, String author,
|
Post(String id, String fullName, String subredditName, String subredditNamePrefixed, String author,
|
||||||
String postTime, String title, String previewUrl, String permalink, int score, int postType,
|
String postTime, String title, String previewUrl, String permalink, int score, int postType,
|
||||||
int voteType, int gilded, String flair, boolean hidden, boolean spoiler, boolean nsfw,
|
int voteType, int gilded, String flair, boolean hidden, boolean spoiler, boolean nsfw,
|
||||||
boolean stickied, boolean archived, boolean locked, boolean saved, boolean isCrosspost,
|
boolean stickied, boolean archived, boolean locked, boolean saved, boolean isCrosspost) {
|
||||||
boolean isHLSVideo) {
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.fullName = fullName;
|
this.fullName = fullName;
|
||||||
this.subredditName = subredditName;
|
this.subredditName = subredditName;
|
||||||
@ -79,7 +75,6 @@ class Post implements Parcelable {
|
|||||||
this.locked = locked;
|
this.locked = locked;
|
||||||
this.saved = saved;
|
this.saved = saved;
|
||||||
this.isCrosspost = isCrosspost;
|
this.isCrosspost = isCrosspost;
|
||||||
this.isHLSVideo = isHLSVideo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Post(String id, String fullName, String subredditName, String subredditNamePrefixed, String author,
|
Post(String id, String fullName, String subredditName, String subredditNamePrefixed, String author,
|
||||||
@ -155,7 +150,6 @@ class Post implements Parcelable {
|
|||||||
previewUrl = in.readString();
|
previewUrl = in.readString();
|
||||||
url = in.readString();
|
url = in.readString();
|
||||||
videoUrl = in.readString();
|
videoUrl = in.readString();
|
||||||
gifOrVideoDownloadUrl = in.readString();
|
|
||||||
permalink = in.readString();
|
permalink = in.readString();
|
||||||
flair = in.readString();
|
flair = in.readString();
|
||||||
score = in.readInt();
|
score = in.readInt();
|
||||||
@ -172,8 +166,6 @@ class Post implements Parcelable {
|
|||||||
locked = in.readByte() != 0;
|
locked = in.readByte() != 0;
|
||||||
saved = in.readByte() != 0;
|
saved = in.readByte() != 0;
|
||||||
isCrosspost = in.readByte() != 0;
|
isCrosspost = in.readByte() != 0;
|
||||||
isHLSVideo = in.readByte() != 0;
|
|
||||||
isDownloadableGifOrVideo = in.readByte() != 0;
|
|
||||||
crosspostParentId = in.readString();
|
crosspostParentId = in.readString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,14 +257,6 @@ class Post implements Parcelable {
|
|||||||
return videoUrl;
|
return videoUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getGifOrVideoDownloadUrl() {
|
|
||||||
return gifOrVideoDownloadUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setGifOrVideoDownloadUrl(String gifOrVideoDownloadUrl) {
|
|
||||||
this.gifOrVideoDownloadUrl = gifOrVideoDownloadUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
String getPermalink() {
|
String getPermalink() {
|
||||||
return permalink;
|
return permalink;
|
||||||
}
|
}
|
||||||
@ -354,18 +338,6 @@ class Post implements Parcelable {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isHLSVideo() {
|
|
||||||
return isHLSVideo;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setDownloadableGifOrVideo(boolean isDownloadableGifOrVideo) {
|
|
||||||
this.isDownloadableGifOrVideo = isDownloadableGifOrVideo;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isDownloadableGifOrVideo() {
|
|
||||||
return isDownloadableGifOrVideo;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isStickied() {
|
boolean isStickied() {
|
||||||
return stickied;
|
return stickied;
|
||||||
}
|
}
|
||||||
@ -414,7 +386,6 @@ class Post implements Parcelable {
|
|||||||
parcel.writeString(previewUrl);
|
parcel.writeString(previewUrl);
|
||||||
parcel.writeString(url);
|
parcel.writeString(url);
|
||||||
parcel.writeString(videoUrl);
|
parcel.writeString(videoUrl);
|
||||||
parcel.writeString(gifOrVideoDownloadUrl);
|
|
||||||
parcel.writeString(permalink);
|
parcel.writeString(permalink);
|
||||||
parcel.writeString(flair);
|
parcel.writeString(flair);
|
||||||
parcel.writeInt(score);
|
parcel.writeInt(score);
|
||||||
@ -431,8 +402,6 @@ class Post implements Parcelable {
|
|||||||
parcel.writeByte((byte) (locked ? 1 : 0));
|
parcel.writeByte((byte) (locked ? 1 : 0));
|
||||||
parcel.writeByte((byte) (saved ? 1 : 0));
|
parcel.writeByte((byte) (saved ? 1 : 0));
|
||||||
parcel.writeByte((byte) (isCrosspost ? 1 : 0));
|
parcel.writeByte((byte) (isCrosspost ? 1 : 0));
|
||||||
parcel.writeByte((byte) (isHLSVideo ? 1 : 0));
|
|
||||||
parcel.writeByte((byte) (isDownloadableGifOrVideo ? 1 : 0));
|
|
||||||
parcel.writeString(crosspostParentId);
|
parcel.writeString(crosspostParentId);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -420,13 +420,8 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
|
|||||||
Intent intent = new Intent(mContext, ViewVideoActivity.class);
|
Intent intent = new Intent(mContext, ViewVideoActivity.class);
|
||||||
intent.setData(gifVideoUri);
|
intent.setData(gifVideoUri);
|
||||||
intent.putExtra(ViewVideoActivity.TITLE_KEY, title);
|
intent.putExtra(ViewVideoActivity.TITLE_KEY, title);
|
||||||
intent.putExtra(ViewVideoActivity.IS_HLS_VIDEO_KEY, post.isHLSVideo());
|
intent.putExtra(ViewVideoActivity.SUBREDDIT_KEY, subredditName);
|
||||||
intent.putExtra(ViewVideoActivity.IS_DOWNLOADABLE_KEY, post.isDownloadableGifOrVideo());
|
intent.putExtra(ViewVideoActivity.ID_KEY, id);
|
||||||
if(post.isDownloadableGifOrVideo()) {
|
|
||||||
intent.putExtra(ViewVideoActivity.DOWNLOAD_URL_KEY, post.getGifOrVideoDownloadUrl());
|
|
||||||
intent.putExtra(ViewVideoActivity.SUBREDDIT_KEY, subredditName);
|
|
||||||
intent.putExtra(ViewVideoActivity.ID_KEY, id);
|
|
||||||
}
|
|
||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@ -438,13 +433,8 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
|
|||||||
Intent intent = new Intent(mContext, ViewVideoActivity.class);
|
Intent intent = new Intent(mContext, ViewVideoActivity.class);
|
||||||
intent.setData(videoUri);
|
intent.setData(videoUri);
|
||||||
intent.putExtra(ViewVideoActivity.TITLE_KEY, title);
|
intent.putExtra(ViewVideoActivity.TITLE_KEY, title);
|
||||||
intent.putExtra(ViewVideoActivity.IS_HLS_VIDEO_KEY, post.isHLSVideo());
|
intent.putExtra(ViewVideoActivity.SUBREDDIT_KEY, subredditName);
|
||||||
intent.putExtra(ViewVideoActivity.IS_DOWNLOADABLE_KEY, post.isDownloadableGifOrVideo());
|
intent.putExtra(ViewVideoActivity.ID_KEY, id);
|
||||||
if(post.isDownloadableGifOrVideo()) {
|
|
||||||
intent.putExtra(ViewVideoActivity.DOWNLOAD_URL_KEY, post.getGifOrVideoDownloadUrl());
|
|
||||||
intent.putExtra(ViewVideoActivity.SUBREDDIT_KEY, subredditName);
|
|
||||||
intent.putExtra(ViewVideoActivity.ID_KEY, id);
|
|
||||||
}
|
|
||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
@ -4,8 +4,6 @@ import android.Manifest;
|
|||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.ArgbEvaluator;
|
import android.animation.ArgbEvaluator;
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
import android.app.DownloadManager;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
@ -16,7 +14,6 @@ import android.media.AudioManager;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
@ -37,7 +34,6 @@ 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;
|
||||||
import com.google.android.exoplayer2.source.ExtractorMediaSource;
|
|
||||||
import com.google.android.exoplayer2.source.hls.HlsMediaSource;
|
import com.google.android.exoplayer2.source.hls.HlsMediaSource;
|
||||||
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
|
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
|
||||||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
||||||
@ -45,13 +41,9 @@ import com.google.android.exoplayer2.trackselection.TrackSelection;
|
|||||||
import com.google.android.exoplayer2.trackselection.TrackSelector;
|
import com.google.android.exoplayer2.trackselection.TrackSelector;
|
||||||
import com.google.android.exoplayer2.ui.PlayerView;
|
import com.google.android.exoplayer2.ui.PlayerView;
|
||||||
import com.google.android.exoplayer2.upstream.DataSource;
|
import com.google.android.exoplayer2.upstream.DataSource;
|
||||||
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
|
|
||||||
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 java.io.File;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
@ -60,9 +52,6 @@ public class ViewVideoActivity extends AppCompatActivity {
|
|||||||
private static final int PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE = 0;
|
private static final int PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE = 0;
|
||||||
|
|
||||||
static final String TITLE_KEY = "TK";
|
static final String TITLE_KEY = "TK";
|
||||||
static final String IS_HLS_VIDEO_KEY = "IHVK";
|
|
||||||
static final String IS_DOWNLOADABLE_KEY = "IDK";
|
|
||||||
static final String DOWNLOAD_URL_KEY = "DUK";
|
|
||||||
static final String SUBREDDIT_KEY = "SK";
|
static final String SUBREDDIT_KEY = "SK";
|
||||||
static final String ID_KEY = "IK";
|
static final String ID_KEY = "IK";
|
||||||
|
|
||||||
@ -71,13 +60,11 @@ public class ViewVideoActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private Uri mVideoUri;
|
private Uri mVideoUri;
|
||||||
private SimpleExoPlayer player;
|
private SimpleExoPlayer player;
|
||||||
|
private DataSource.Factory dataSourceFactory;
|
||||||
|
|
||||||
private Menu mMenu;
|
private Menu mMenu;
|
||||||
private Swipe swipe;
|
private Swipe swipe;
|
||||||
|
|
||||||
private String mGifOrVideoFileName;
|
|
||||||
private String mDownloadUrl;
|
|
||||||
private boolean mIsHLSVideo;
|
|
||||||
private boolean wasPlaying;
|
private boolean wasPlaying;
|
||||||
private boolean isDownloading = false;
|
private boolean isDownloading = false;
|
||||||
private float totalLengthY = 0.0f;
|
private float totalLengthY = 0.0f;
|
||||||
@ -112,13 +99,6 @@ public class ViewVideoActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
mVideoUri = intent.getData();
|
mVideoUri = intent.getData();
|
||||||
mIsHLSVideo = intent.getExtras().getBoolean(IS_HLS_VIDEO_KEY);
|
|
||||||
|
|
||||||
if(intent.getExtras().getBoolean(IS_DOWNLOADABLE_KEY)) {
|
|
||||||
mGifOrVideoFileName = intent.getStringExtra(SUBREDDIT_KEY)
|
|
||||||
+ "-" + intent.getStringExtra(ID_KEY).substring(3) + ".gif";
|
|
||||||
mDownloadUrl = intent.getStringExtra(DOWNLOAD_URL_KEY);
|
|
||||||
}
|
|
||||||
|
|
||||||
final float pxHeight = getResources().getDisplayMetrics().heightPixels;
|
final float pxHeight = getResources().getDisplayMetrics().heightPixels;
|
||||||
|
|
||||||
@ -285,39 +265,26 @@ public class ViewVideoActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
|
|
||||||
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory();
|
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory();
|
||||||
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
|
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
|
||||||
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
|
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
|
||||||
videoPlayerView.setPlayer(player);
|
videoPlayerView.setPlayer(player);
|
||||||
DataSource.Factory dataSourceFactory;
|
// Produces DataSource instances through which media data is loaded.
|
||||||
|
dataSourceFactory = new DefaultHttpDataSourceFactory(Util.getUserAgent(this, "Infinity"));
|
||||||
// Prepare the player with the source.
|
// Prepare the player with the source.
|
||||||
if(mIsHLSVideo) {
|
player.prepare(new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(mVideoUri));
|
||||||
// Produces DataSource instances through which media data is loaded.
|
|
||||||
dataSourceFactory = new DefaultHttpDataSourceFactory(
|
|
||||||
Util.getUserAgent(this, "Infinity"));
|
|
||||||
player.prepare(new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(mVideoUri));
|
|
||||||
} else {
|
|
||||||
// Produces DataSource instances through which media data is loaded.
|
|
||||||
dataSourceFactory = new DefaultDataSourceFactory(this,
|
|
||||||
Util.getUserAgent(this, "Infinity"), bandwidthMeter);
|
|
||||||
player.prepare(new ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(mVideoUri));
|
|
||||||
}
|
|
||||||
|
|
||||||
player.setRepeatMode(Player.REPEAT_MODE_ALL);
|
player.setRepeatMode(Player.REPEAT_MODE_ALL);
|
||||||
player.setPlayWhenReady(true);
|
player.setPlayWhenReady(true);
|
||||||
wasPlaying = true;
|
wasPlaying = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/*@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
if(!mIsHLSVideo) {
|
getMenuInflater().inflate(R.menu.view_video, menu);
|
||||||
getMenuInflater().inflate(R.menu.view_video, menu);
|
mMenu = menu;
|
||||||
mMenu = menu;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean dispatchTouchEvent(MotionEvent ev) {
|
public boolean dispatchTouchEvent(MotionEvent ev) {
|
||||||
@ -390,47 +357,7 @@ public class ViewVideoActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void download() {
|
private void download() {
|
||||||
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(mDownloadUrl));
|
isDownloading = false;
|
||||||
request.setTitle(mGifOrVideoFileName);
|
|
||||||
|
|
||||||
request.allowScanningByMediaScanner();
|
|
||||||
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
|
|
||||||
|
|
||||||
//Android Q support
|
|
||||||
if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
||||||
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_PICTURES, mGifOrVideoFileName);
|
|
||||||
} else {
|
|
||||||
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString();
|
|
||||||
File directory = new File(path + "/Infinity/");
|
|
||||||
boolean saveToInfinityFolder = true;
|
|
||||||
if(!directory.exists()) {
|
|
||||||
if(!directory.mkdir()) {
|
|
||||||
saveToInfinityFolder = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(directory.isFile()) {
|
|
||||||
if(!directory.delete() && !directory.mkdir()) {
|
|
||||||
saveToInfinityFolder = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(saveToInfinityFolder) {
|
|
||||||
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_PICTURES + "/Infinity/", mGifOrVideoFileName);
|
|
||||||
} else {
|
|
||||||
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_PICTURES, mGifOrVideoFileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
|
|
||||||
|
|
||||||
if(manager == null) {
|
|
||||||
Toast.makeText(this, R.string.download_failed, Toast.LENGTH_SHORT).show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
manager.enqueue(request);
|
|
||||||
Toast.makeText(this, R.string.download_started, Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -31,6 +31,6 @@ task clean(type: Delete) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
roomVersion = '2.2.0-beta01'
|
roomVersion = '2.2.0-rc01'
|
||||||
archLifecycleVersion = '2.2.0-alpha03'
|
archLifecycleVersion = '2.2.0-alpha04'
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user