aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml/docilealligator/infinityforreddit
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2022-09-06 15:01:45 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2022-09-06 15:01:45 +0000
commit84b5b1d95ddaa4701799ac369eef678f4d0794d7 (patch)
treead9eaa687dff67e1e0b6575d878093df1d532b80 /app/src/main/java/ml/docilealligator/infinityforreddit
parent6d224c307d105c9b1d2a46f0f81a11cabc4d32b1 (diff)
downloadinfinity-for-reddit-84b5b1d95ddaa4701799ac369eef678f4d0794d7.tar
infinity-for-reddit-84b5b1d95ddaa4701799ac369eef678f4d0794d7.tar.gz
infinity-for-reddit-84b5b1d95ddaa4701799ac369eef678f4d0794d7.tar.bz2
infinity-for-reddit-84b5b1d95ddaa4701799ac369eef678f4d0794d7.tar.lz
infinity-for-reddit-84b5b1d95ddaa4701799ac369eef678f4d0794d7.tar.xz
infinity-for-reddit-84b5b1d95ddaa4701799ac369eef678f4d0794d7.tar.zst
infinity-for-reddit-84b5b1d95ddaa4701799ac369eef678f4d0794d7.zip
Version 5.3.1.
Diffstat (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/SwitchToAnonymousMode.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/videoautoplay/AdsExoPlayerViewHelper.java188
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/videoautoplay/AdsPlayable.java119
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/videoautoplay/MediaSourceBuilder.java10
4 files changed, 9 insertions, 311 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/SwitchToAnonymousMode.java b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/SwitchToAnonymousMode.java
index c14b7131..d41d04bc 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/SwitchToAnonymousMode.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/SwitchToAnonymousMode.java
@@ -7,6 +7,7 @@ import java.util.concurrent.Executor;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.account.AccountDao;
+import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
public class SwitchToAnonymousMode {
public static void switchToAnonymousMode(RedditDataRoomDatabase redditDataRoomDatabase, SharedPreferences currentAccountSharedPreferences,
@@ -19,7 +20,9 @@ public class SwitchToAnonymousMode {
}
accountDao.markAllAccountsNonCurrent();
+ String redgifsAccessToken = currentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "");
currentAccountSharedPreferences.edit().clear().apply();
+ currentAccountSharedPreferences.edit().putString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, redgifsAccessToken).apply();
handler.post(switchToAnonymousAccountAsyncTaskListener::logoutSuccess);
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/videoautoplay/AdsExoPlayerViewHelper.java b/app/src/main/java/ml/docilealligator/infinityforreddit/videoautoplay/AdsExoPlayerViewHelper.java
deleted file mode 100644
index 22a63afc..00000000
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/videoautoplay/AdsExoPlayerViewHelper.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright (c) 2018 Nam Nguyen, nam@ene.im
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package ml.docilealligator.infinityforreddit.videoautoplay;
-
-import android.content.Context;
-import android.net.Uri;
-import android.view.View;
-import android.view.ViewGroup;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.google.android.exoplayer2.source.ads.AdsLoader;
-import com.google.android.exoplayer2.ui.PlayerView;
-
-import ml.docilealligator.infinityforreddit.videoautoplay.annotations.Beta;
-
-/**
- * A {@link ToroPlayerHelper} to integrate ExoPlayer IMA Extension. Work together with {@link
- * AdsPlayable}.
- *
- * @author eneim (2018/08/22).
- * @since 3.6.0.2802
- */
-@SuppressWarnings("unused") @Beta //
-public class AdsExoPlayerViewHelper extends ExoPlayerViewHelper {
-
- static class DefaultAdViewProvider implements AdsLoader.AdViewProvider {
-
- @NonNull final ViewGroup viewGroup;
-
- DefaultAdViewProvider(@NonNull ViewGroup viewGroup) {
- this.viewGroup = viewGroup;
- }
-
- @Override public ViewGroup getAdViewGroup() {
- return this.viewGroup;
- }
-
- @Override public View[] getAdOverlayViews() {
- return new View[0];
- }
- }
-
- private static AdsPlayable createPlayable( ///
- ToroPlayer player, //
- ExoCreator creator, //
- Uri contentUri, //
- String fileExt, //
- AdsLoader adsLoader, //
- AdsLoader.AdViewProvider adViewProvider //
- ) {
- return new AdsPlayable(creator, contentUri, fileExt, player, adsLoader, adViewProvider);
- }
-
- private static AdsPlayable createPlayable( //
- ToroPlayer player, //
- Config config, //
- Uri contentUri, //
- String fileExt, //
- AdsLoader adsLoader, //
- AdsLoader.AdViewProvider adViewProvider //
- ) {
- Context context = player.getPlayerView().getContext();
- return createPlayable(player, ToroExo.with(context).getCreator(config), contentUri, fileExt,
- adsLoader, adViewProvider);
- }
-
- private static AdsPlayable createPlayable( //
- ToroPlayer player, //
- Uri contentUri, //
- String fileExt, //
- AdsLoader adsLoader, //
- AdsLoader.AdViewProvider adViewProvider //
- ) {
- Context context = player.getPlayerView().getContext();
- return createPlayable(player, ToroExo.with(context).getDefaultCreator(), contentUri, fileExt,
- adsLoader, adViewProvider);
- }
-
- // Neither ExoCreator nor Config are provided.
-
- /**
- * Create new {@link AdsExoPlayerViewHelper} for a {@link ToroPlayer} and {@link AdsLoader}.
- *
- * @param adContainer if {@code null} then overlay of {@link PlayerView} will be used.
- */
- @Deprecated
- public AdsExoPlayerViewHelper( //
- @NonNull ToroPlayer player, //
- @NonNull Uri uri, //
- @Nullable String fileExt, //
- @NonNull AdsLoader adsLoader, //
- @Nullable ViewGroup adContainer //
- ) {
- super(player,
- createPlayable(player, uri, fileExt, adsLoader,
- adContainer != null ? new DefaultAdViewProvider(adContainer) : null));
- }
-
- public AdsExoPlayerViewHelper( //
- @NonNull ToroPlayer player, //
- @NonNull Uri uri, //
- @Nullable String fileExt, //
- @NonNull AdsLoader adsLoader, //
- @Nullable ViewGroup adContainer, // will be ignored
- @Nullable AdsLoader.AdViewProvider adViewProvider //
- ) {
- super(player, createPlayable(player, uri, fileExt, adsLoader, adViewProvider));
- }
-
- // ExoCreator is provided.
-
- /**
- * Create new {@link AdsExoPlayerViewHelper} for a {@link ToroPlayer} and {@link AdsLoader}.
- *
- * @param adContainer if {@code null} then overlay of {@link PlayerView} will be used.
- */
- @Deprecated
- public AdsExoPlayerViewHelper( //
- @NonNull ToroPlayer player, //
- @NonNull Uri uri, //
- @Nullable String fileExt, //
- @NonNull AdsLoader adsLoader, //
- @Nullable ViewGroup adContainer, //
- @NonNull ExoCreator creator //
- ) {
- super(player, createPlayable(player, creator, uri, fileExt, adsLoader,
- adContainer != null ? new DefaultAdViewProvider(adContainer) : null));
- }
-
- public AdsExoPlayerViewHelper( //
- @NonNull ToroPlayer player, //
- @NonNull Uri uri, //
- @Nullable String fileExt, //
- @NonNull AdsLoader adsLoader, //
- @Nullable ViewGroup adContainer, // will be ignored
- @Nullable AdsLoader.AdViewProvider adViewProvider, //
- @NonNull ExoCreator creator //
- ) {
- super(player, createPlayable(player, creator, uri, fileExt, adsLoader, adViewProvider));
- }
- // Config is provided.
-
- /**
- * Create new {@link AdsExoPlayerViewHelper} for a {@link ToroPlayer} and {@link AdsLoader}.
- *
- * @param adContainer if {@code null} then overlay of {@link PlayerView} will be used.
- */
- @Deprecated
- public AdsExoPlayerViewHelper( //
- @NonNull ToroPlayer player, //
- @NonNull Uri uri, //
- @Nullable String fileExt, //
- @NonNull AdsLoader adsLoader, //
- @Nullable ViewGroup adContainer, //
- @NonNull Config config //
- ) {
- super(player, createPlayable(player, config, uri, fileExt, adsLoader,
- adContainer != null ? new DefaultAdViewProvider(adContainer) : null));
- }
-
- public AdsExoPlayerViewHelper( //
- @NonNull ToroPlayer player, //
- @NonNull Uri uri, //
- @Nullable String fileExt, //
- @NonNull AdsLoader adsLoader, //
- @Nullable ViewGroup adContainer, // will be ignored
- @Nullable AdsLoader.AdViewProvider adViewProvider, //
- @NonNull Config config //
- ) {
- super(player, createPlayable(player, config, uri, fileExt, adsLoader, adViewProvider));
- }
-}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/videoautoplay/AdsPlayable.java b/app/src/main/java/ml/docilealligator/infinityforreddit/videoautoplay/AdsPlayable.java
deleted file mode 100644
index 666b3815..00000000
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/videoautoplay/AdsPlayable.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (c) 2018 Nam Nguyen, nam@ene.im
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package ml.docilealligator.infinityforreddit.videoautoplay;
-
-import android.net.Uri;
-import android.view.View;
-import android.view.ViewGroup;
-
-import androidx.annotation.CallSuper;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.google.android.exoplayer2.C;
-import com.google.android.exoplayer2.source.MediaSource;
-import com.google.android.exoplayer2.source.ads.AdsLoader;
-import com.google.android.exoplayer2.source.ads.AdsMediaSource;
-import com.google.android.exoplayer2.ui.PlayerView;
-
-import ml.docilealligator.infinityforreddit.videoautoplay.annotations.Beta;
-
-/**
- * A {@link Playable} that is able to integrate with {@link AdsLoader}.
- *
- * @author eneim (2018/08/22).
- * @since 3.6.0.2802
- */
-@Beta //
-public class AdsPlayable extends ExoPlayable {
-
- static class FactoryImpl implements AdsMediaSource.MediaSourceFactory {
-
- @NonNull final ExoCreator creator;
- @NonNull final ToroPlayer player;
-
- FactoryImpl(@NonNull ExoCreator creator, @NonNull ToroPlayer player) {
- this.creator = creator;
- this.player = player;
- }
-
- @Override public MediaSource createMediaSource(Uri uri) {
- return this.creator.createMediaSource(uri, null);
- }
-
- @Override public int[] getSupportedTypes() {
- // IMA does not support Smooth Streaming ads.
- return new int[] { C.TYPE_DASH, C.TYPE_HLS, C.TYPE_OTHER };
- }
- }
-
- @NonNull private final AdsLoader adsLoader;
- @NonNull private final FactoryImpl factory;
- @Nullable private final AdsLoader.AdViewProvider adViewProvider;
-
- /**
- * @deprecated Use the constructors that use {@link AdsLoader.AdViewProvider} instead.
- */
- @Deprecated
- public AdsPlayable(ExoCreator creator, Uri uri, String fileExt, ToroPlayer player,
- @NonNull AdsLoader adsLoader, @Nullable final ViewGroup adsContainer) {
- super(creator, uri, fileExt);
- this.adsLoader = adsLoader;
- this.adViewProvider = adsContainer == null ? null
- : new AdsExoPlayerViewHelper.DefaultAdViewProvider(adsContainer);
- this.factory = new FactoryImpl(this.creator, player);
- }
-
- @SuppressWarnings("WeakerAccess")
- public AdsPlayable(ExoCreator creator, Uri uri, String fileExt, ToroPlayer player,
- @NonNull AdsLoader adsLoader, @Nullable AdsLoader.AdViewProvider adViewProvider) {
- super(creator, uri, fileExt);
- this.adsLoader = adsLoader;
- this.adViewProvider = adViewProvider;
- this.factory = new FactoryImpl(this.creator, player);
- }
-
- @CallSuper
- @Override public void prepare(boolean prepareSource) {
- this.mediaSource = createAdsMediaSource(creator, mediaUri, fileExt, //
- factory.player, adsLoader, adViewProvider, factory);
- super.prepare(prepareSource);
- }
-
- @Override protected void beforePrepareMediaSource() {
- super.beforePrepareMediaSource();
- adsLoader.setPlayer(player);
- }
-
- @Override public void release() {
- adsLoader.setPlayer(null);
- super.release();
- }
-
- private static MediaSource createAdsMediaSource(ExoCreator creator, Uri uri, String fileExt,
- ToroPlayer player, AdsLoader adsLoader, AdsLoader.AdViewProvider adViewProvider,
- AdsMediaSource.MediaSourceFactory factory) {
- MediaSource original = creator.createMediaSource(uri, fileExt);
- View playerView = player.getPlayerView();
- if (!(playerView instanceof PlayerView)) {
- throw new IllegalArgumentException("Require PlayerView");
- }
-
- return new AdsMediaSource(original, factory, adsLoader,
- adViewProvider == null ? (PlayerView) playerView : adViewProvider);
- }
-}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/videoautoplay/MediaSourceBuilder.java b/app/src/main/java/ml/docilealligator/infinityforreddit/videoautoplay/MediaSourceBuilder.java
index 7daacc99..885319d0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/videoautoplay/MediaSourceBuilder.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/videoautoplay/MediaSourceBuilder.java
@@ -35,6 +35,8 @@ import com.google.android.exoplayer2.source.ProgressiveMediaSource;
import com.google.android.exoplayer2.source.dash.DashMediaSource;
import com.google.android.exoplayer2.source.dash.DefaultDashChunkSource;
import com.google.android.exoplayer2.source.hls.HlsMediaSource;
+import com.google.android.exoplayer2.source.smoothstreaming.DefaultSsChunkSource;
+import com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource;
import com.google.android.exoplayer2.upstream.DataSource;
/**
@@ -59,11 +61,11 @@ public interface MediaSourceBuilder {
@ContentType int type = isEmpty(ext) ? inferContentType(uri) : inferContentType("." + ext);
MediaSource result;
switch (type) {
- /*case C.TYPE_SS:
- result = new SsMediaSource.Factory( //
- new DefaultSsChunkSource.Factory(mediaDataSourceFactory), manifestDataSourceFactory)//
+ case C.TYPE_SS:
+ result = new SsMediaSource.Factory(
+ new DefaultSsChunkSource.Factory(mediaDataSourceFactory), manifestDataSourceFactory)
.createMediaSource(uri);
- break;*/
+ break;
case C.TYPE_DASH:
result = new DashMediaSource.Factory(
new DefaultDashChunkSource.Factory(mediaDataSourceFactory), manifestDataSourceFactory)