mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 04:37:25 +01:00
Use an OkHttpClient with User-Agent when initializing BigImageViewer.
If not passed, BigImageViewer overrides the Glide OkHttp downloader upon initialization with an empty one:
https://github.com/Piasy/BigImageViewer/blob/067f8eb/GlideImageLoader/src/main/java/com/github/piasy/biv/loader/glide/GlideProgressSupport.java#L76
In that case, Glide creates a default User-Agent:
cbdc1e78b4/library/src/main/java/com/bumptech/glide/load/model/LazyHeaders.java (L103-L106)
Example User-Agent: Dalvik/2.1.0 (Linux; U; Android 11; sdk_gphone_x86 Build/RSR1.201013.001)
https://files.catbox.moe is filtering out that User-Agent. Using the App one fixes it.
This commit is contained in:
parent
0393ff6e77
commit
b626c5fb73
@ -10,9 +10,9 @@ import javax.inject.Singleton;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import eu.toldi.infinityforlemmy.apis.StreamableAPI;
|
||||
import eu.toldi.infinityforlemmy.privatemessage.LemmyPrivateMessageAPI;
|
||||
import eu.toldi.infinityforlemmy.comment.LemmyCommentAPI;
|
||||
import eu.toldi.infinityforlemmy.post.LemmyPostAPI;
|
||||
import eu.toldi.infinityforlemmy.privatemessage.LemmyPrivateMessageAPI;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import okhttp3.ConnectionPool;
|
||||
import okhttp3.Interceptor;
|
||||
@ -34,6 +34,19 @@ abstract class NetworkModule {
|
||||
.build();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Named("glide")
|
||||
@Singleton
|
||||
static OkHttpClient provideGlideOkHttp(@Named("base") OkHttpClient baseOkHttp) {
|
||||
return baseOkHttp.newBuilder()
|
||||
.addInterceptor(chain -> chain.proceed(
|
||||
chain.request()
|
||||
.newBuilder()
|
||||
.header("User-Agent", APIUtils.USER_AGENT)
|
||||
.build()
|
||||
))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Named("base")
|
||||
|
@ -78,6 +78,7 @@ import eu.toldi.infinityforlemmy.font.TitleFontStyle;
|
||||
import eu.toldi.infinityforlemmy.services.DownloadMediaService;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWallpaperCallback, CustomFontReceiver {
|
||||
|
||||
@ -108,6 +109,9 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
|
||||
@Named("default")
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
@Named("glide")
|
||||
OkHttpClient okHttpClient;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private boolean isActionBarHidden = false;
|
||||
private boolean isDownloading = false;
|
||||
@ -146,7 +150,7 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
|
||||
getTheme().applyStyle(ContentFontFamily.valueOf(mSharedPreferences
|
||||
.getString(SharedPreferencesUtils.CONTENT_FONT_FAMILY_KEY, ContentFontFamily.Default.name())).getResId(), true);
|
||||
|
||||
BigImageViewer.initialize(GlideImageLoader.with(this.getApplicationContext()));
|
||||
BigImageViewer.initialize(GlideImageLoader.with(this.getApplicationContext(), okHttpClient));
|
||||
|
||||
setContentView(R.layout.activity_view_image_or_gif);
|
||||
|
||||
|
@ -85,6 +85,7 @@ import eu.toldi.infinityforlemmy.postfilter.PostFilter;
|
||||
import eu.toldi.infinityforlemmy.readpost.ReadPost;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import okhttp3.OkHttpClient;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.Retrofit;
|
||||
@ -147,6 +148,9 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
@Inject
|
||||
@Named("glide")
|
||||
OkHttpClient okHttpClient;
|
||||
@State
|
||||
ArrayList<Post> posts;
|
||||
@State
|
||||
@ -195,7 +199,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
BigImageViewer.initialize(GlideImageLoader.with(this.getApplicationContext()));
|
||||
BigImageViewer.initialize(GlideImageLoader.with(this.getApplicationContext(), okHttpClient));
|
||||
|
||||
setContentView(R.layout.activity_view_post_detail);
|
||||
|
||||
|
@ -52,6 +52,7 @@ import java.io.File;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
@ -69,6 +70,7 @@ import eu.toldi.infinityforlemmy.bottomsheetfragments.UrlMenuBottomSheetFragment
|
||||
import eu.toldi.infinityforlemmy.post.Post;
|
||||
import eu.toldi.infinityforlemmy.services.DownloadMediaService;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
public class ViewRedditGalleryImageOrGifFragment extends Fragment {
|
||||
|
||||
@ -105,6 +107,9 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment {
|
||||
ImageView wallpaperImageView;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
@Inject
|
||||
@Named("glide")
|
||||
OkHttpClient okHttpClient;
|
||||
|
||||
private ViewRedditGalleryActivity activity;
|
||||
private RequestManager glide;
|
||||
@ -122,7 +127,7 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment {
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
BigImageViewer.initialize(GlideImageLoader.with(activity.getApplicationContext()));
|
||||
BigImageViewer.initialize(GlideImageLoader.with(activity.getApplicationContext(), okHttpClient));
|
||||
|
||||
View rootView = inflater.inflate(R.layout.fragment_view_reddit_gallery_image_or_gif, container, false);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user