aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/build.gradle32
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java35
-rw-r--r--app/src/main/res/drawable/ic_video_quality_24dp.xml15
-rw-r--r--app/src/main/res/layout/exo_playback_control_view.xml6
-rw-r--r--app/src/main/res/values/strings.xml2
5 files changed, 72 insertions, 18 deletions
diff --git a/app/build.gradle b/app/build.gradle
index 6cc9800d..ccb12c3b 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -38,7 +38,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.browser:browser:1.2.0'
implementation 'androidx.cardview:cardview:1.0.0'
- implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
+ implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
// Lifecycle components
def lifecycleVersion = '2.2.0'
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycleVersion"
@@ -62,22 +62,22 @@ dependencies {
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
- implementation 'io.reactivex.rxjava2:rxjava:2.2.19'
+ implementation 'io.reactivex.rxjava2:rxjava:2.2.20'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'
implementation 'jp.wasabeef:glide-transformations:4.1.0'
- implementation 'com.google.dagger:dagger:2.28.3'
- annotationProcessor 'com.google.dagger:dagger-compiler:2.28.1'
- implementation 'com.jakewharton:butterknife:10.2.1'
- annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
+ implementation 'com.google.dagger:dagger:2.29.1'
+ annotationProcessor 'com.google.dagger:dagger-compiler:2.29.1'
+ implementation 'com.jakewharton:butterknife:10.2.3'
+ annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
implementation 'com.github.santalu:aspect-ratio-imageview:1.0.9'
implementation 'com.lsjwzh:materialloadingprogressbar:0.5.8-RELEASE'
- implementation 'io.noties.markwon:core:4.5.0'
- implementation 'io.noties.markwon:linkify:4.5.0'
- implementation 'io.noties.markwon:ext-strikethrough:4.5.0'
- implementation 'io.noties.markwon:simple-ext:4.5.0'
- implementation 'io.noties.markwon:recycler-table:4.5.0'
- implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.20'
+ implementation 'io.noties.markwon:core:4.6.0'
+ implementation 'io.noties.markwon:linkify:4.6.0'
+ implementation 'io.noties.markwon:ext-strikethrough:4.6.0'
+ implementation 'io.noties.markwon:simple-ext:4.6.0'
+ implementation 'io.noties.markwon:recycler-table:4.6.0'
+ implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.21'
implementation 'com.github.Ferfalk:SimpleSearchView:0.1.4'
def eventbusVersion = '3.2.0'
@@ -90,7 +90,7 @@ dependencies {
annotationProcessor 'com.evernote:android-state-processor:1.4.1'
implementation 'com.nex3z:flow-layout:1.3.0'
implementation 'com.r0adkll:slidableactivity:2.1.0'
- implementation 'com.atlassian.commonmark:commonmark:0.14.0'
+ implementation 'com.atlassian.commonmark:commonmark:0.15.2'
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"
@@ -104,7 +104,7 @@ dependencies {
exclude module: 'extension-ima'
}
- testImplementation 'junit:junit:4.13'
- androidTestImplementation 'androidx.test:runner:1.2.0'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
+ testImplementation 'junit:junit:4.13.1'
+ androidTestImplementation 'androidx.test:runner:1.3.0'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
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 a8cefd9f..77cdc9e7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java
@@ -38,8 +38,8 @@ import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
-import com.google.android.exoplayer2.trackselection.TrackSelector;
import com.google.android.exoplayer2.ui.PlayerView;
+import com.google.android.exoplayer2.ui.TrackSelectionDialogBuilder;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;
@@ -62,6 +62,7 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Service.DownloadMediaService;
import ml.docilealligator.infinityforreddit.Service.DownloadRedditVideoService;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
+import ml.docilealligator.infinityforreddit.Utils.Utils;
import retrofit2.Retrofit;
public class ViewVideoActivity extends AppCompatActivity {
@@ -92,9 +93,12 @@ public class ViewVideoActivity extends AppCompatActivity {
PlayerView videoPlayerView;
@BindView(R.id.mute_exo_playback_control_view)
ImageButton muteButton;
+ @BindView(R.id.hd_exo_playback_control_view)
+ ImageButton hdButton;
private Uri mVideoUri;
private SimpleExoPlayer player;
+ private DefaultTrackSelector trackSelector;
private DataSource.Factory dataSourceFactory;
private String videoDownloadUrl;
@@ -108,6 +112,8 @@ public class ViewVideoActivity extends AppCompatActivity {
private boolean isNSFW;
private long resumePosition = -1;
private int videoType;
+ private boolean isDataSavingMode;
+ private boolean isHd;
@Inject
@Named("gfycat")
@@ -148,6 +154,15 @@ public class ViewVideoActivity extends AppCompatActivity {
actionBar.setHomeAsUpIndicator(upArrow);
actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparentActionBarAndExoPlayerControllerColor)));
+ String dataSavingModeString = mSharedPreferences.getString(SharedPreferencesUtils.DATA_SAVING_MODE, SharedPreferencesUtils.DATA_SAVING_MODE_OFF);
+ int networkType = Utils.getConnectedNetwork(this);
+ if (dataSavingModeString.equals(SharedPreferencesUtils.DATA_SAVING_MODE_ALWAYS)) {
+ isDataSavingMode = true;
+ } else if (dataSavingModeString.equals(SharedPreferencesUtils.DATA_SAVING_MODE_ONLY_ON_CELLULAR_DATA)) {
+ isDataSavingMode = networkType == Utils.NETWORK_TYPE_CELLULAR;
+ }
+ isHd = !isDataSavingMode;
+
if (!mSharedPreferences.getBoolean(SharedPreferencesUtils.VIDEO_PLAYER_IGNORE_NAV_BAR, false)) {
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || getResources().getBoolean(R.bool.isTablet)) {
//Set player controller bottom margin in order to display it above the navbar
@@ -205,7 +220,7 @@ public class ViewVideoActivity extends AppCompatActivity {
});
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory();
- TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
+ trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
videoPlayerView.setPlayer(player);
videoType = getIntent().getIntExtra(EXTRA_VIDEO_TYPE, VIDEO_TYPE_NORMAL);
@@ -296,6 +311,22 @@ public class ViewVideoActivity extends AppCompatActivity {
@Override
public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
if (!trackGroups.isEmpty()) {
+ if (videoType == VIDEO_TYPE_NORMAL) {
+ if (isDataSavingMode) {
+ trackSelector.setParameters(
+ trackSelector.buildUponParameters()
+ .setMaxVideoSize(720, 720));
+ }
+
+ hdButton.setVisibility(View.VISIBLE);
+ hdButton.setOnClickListener(view -> {
+ TrackSelectionDialogBuilder build = new TrackSelectionDialogBuilder(ViewVideoActivity.this, getString(R.string.select_video_quality), trackSelector, 0);
+ build.setShowDisableOption(true);
+ build.setAllowAdaptiveSelections(false);
+ build.build().show();
+ });
+ }
+
for (int i = 0; i < trackGroups.length; i++) {
String mimeType = trackGroups.get(i).getFormat(0).sampleMimeType;
if (mimeType != null && mimeType.contains("audio")) {
diff --git a/app/src/main/res/drawable/ic_video_quality_24dp.xml b/app/src/main/res/drawable/ic_video_quality_24dp.xml
new file mode 100644
index 00000000..68c1435d
--- /dev/null
+++ b/app/src/main/res/drawable/ic_video_quality_24dp.xml
@@ -0,0 +1,15 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:pathData="M3,6h18v5h2V6c0,-1.1 -0.9,-2 -2,-2H3C1.9,4 1,4.9 1,6v12c0,1.1 0.9,2 2,2h9v-2H3V6z"
+ android:fillColor="#ffffff"/>
+ <path
+ android:pathData="M15,12l-6,-4l0,8z"
+ android:fillColor="#ffffff"/>
+ <path
+ android:pathData="M22.71,18.43c0.03,-0.29 0.04,-0.58 0.01,-0.86l1.07,-0.85c0.1,-0.08 0.12,-0.21 0.06,-0.32l-1.03,-1.79c-0.06,-0.11 -0.19,-0.15 -0.31,-0.11L21.23,15c-0.23,-0.17 -0.48,-0.31 -0.75,-0.42l-0.2,-1.36C20.26,13.09 20.16,13 20.03,13h-2.07c-0.12,0 -0.23,0.09 -0.25,0.21l-0.2,1.36c-0.26,0.11 -0.51,0.26 -0.74,0.42l-1.28,-0.5c-0.12,-0.05 -0.25,0 -0.31,0.11l-1.03,1.79c-0.06,0.11 -0.04,0.24 0.06,0.32l1.07,0.86c-0.03,0.29 -0.04,0.58 -0.01,0.86l-1.07,0.85c-0.1,0.08 -0.12,0.21 -0.06,0.32l1.03,1.79c0.06,0.11 0.19,0.15 0.31,0.11l1.27,-0.5c0.23,0.17 0.48,0.31 0.75,0.42l0.2,1.36c0.02,0.12 0.12,0.21 0.25,0.21h2.07c0.12,0 0.23,-0.09 0.25,-0.21l0.2,-1.36c0.26,-0.11 0.51,-0.26 0.74,-0.42l1.28,0.5c0.12,0.05 0.25,0 0.31,-0.11l1.03,-1.79c0.06,-0.11 0.04,-0.24 -0.06,-0.32L22.71,18.43zM19,19.5c-0.83,0 -1.5,-0.67 -1.5,-1.5s0.67,-1.5 1.5,-1.5s1.5,0.67 1.5,1.5S19.83,19.5 19,19.5z"
+ android:fillColor="#ffffff"/>
+</vector>
diff --git a/app/src/main/res/layout/exo_playback_control_view.xml b/app/src/main/res/layout/exo_playback_control_view.xml
index 89749c08..611c5e06 100644
--- a/app/src/main/res/layout/exo_playback_control_view.xml
+++ b/app/src/main/res/layout/exo_playback_control_view.xml
@@ -34,6 +34,12 @@
style="@style/ExoMediaButton"
android:visibility="gone" />
+ <ImageButton
+ android:id="@+id/hd_exo_playback_control_view"
+ android:src="@drawable/ic_video_quality_24dp"
+ style="@style/ExoMediaButton"
+ android:visibility="gone" />
+
</LinearLayout>
<LinearLayout
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 886d65c0..21d7027d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -922,4 +922,6 @@
<string name="random_nsfw_post">Random NSFW post</string>
<string name="fetch_random_thing_failed">Try again later</string>
+ <string name="select_video_quality">Select Video Quality</string>
+
</resources>