Skip to content

Merge backend-overhaul to master #3198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 56 commits into from
Nov 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
bb273eb
Migrated logEvents to retrofit (#3087)
ilgazer Aug 11, 2019
728ead7
Update library for data client (#3131)
maskaravivek Aug 14, 2019
c6794f3
Backend overhaul fetch media by filename (#3081)
ilgazer Sep 4, 2019
90d4e49
Migrated isUserBlockedFromCommons to retrofit (#3085)
ilgazer Sep 12, 2019
4178998
* Login the login token way, handle LoginResult minutely, add account…
ashishkumar468 Sep 15, 2019
f13a4d4
Added progress updater in UploadService to show upload progress in no…
ashishkumar468 Sep 30, 2019
2e0281e
[Dependency: Quadtree] Remove unused code from cache controller (#3163)
Oct 5, 2019
13d847e
Basic logging with redacted sensitive headers (#3159)
Oct 5, 2019
ccd7b3d
As per #3026, removed the obsolete classes in package mwapi (#3150)
ilgazer Oct 5, 2019
dab46bf
fixed compile time error (#3165)
ashishkumar468 Oct 5, 2019
c55d363
[Dependency fluent]: Remove unused dependency fluent (#3164)
Oct 5, 2019
db6ffdd
Donot init quiz checker in onResume (#3167)
ashishkumar468 Oct 7, 2019
55edc34
clear image cache on logout (#3168)
ashishkumar468 Oct 7, 2019
533ba60
Fixed default locale and upload locales in descrptions (#3166)
ashishkumar468 Oct 9, 2019
4fd9374
Fix 2FA login (#3170)
Oct 12, 2019
d897cfe
Fix build (#3172)
Oct 13, 2019
5892229
Closes #3094 (#3095)
ashishkumar468 Jul 28, 2019
0376a21
Update changelog.md
misaochan Jul 29, 2019
bb9e157
Versioning for v2.11.0
misaochan Jul 29, 2019
af2a87b
Localisation updates from https://translatewiki.net.
translatewiki Jul 25, 2019
d7f6866
Localisation updates from https://translatewiki.net.
translatewiki Jul 29, 2019
e213d33
Localisation updates from https://translatewiki.net.
translatewiki Aug 1, 2019
b48c72f
Localisation updates from https://translatewiki.net.
translatewiki Aug 5, 2019
33cc08b
Center map on location clicked in nearby list and notification card(#…
cypherop Aug 5, 2019
3d6509c
removed swipe to delete (#2589)
vanshikaarora Aug 5, 2019
443517f
Localisation updates from https://translatewiki.net.
translatewiki Aug 8, 2019
a3fe511
Localisation updates from https://translatewiki.net.
translatewiki Aug 12, 2019
c7d7dea
Localisation updates from https://translatewiki.net.
translatewiki Aug 15, 2019
9124876
Localisation updates from https://translatewiki.net.
translatewiki Aug 19, 2019
e8551bb
Localisation updates from https://translatewiki.net.
translatewiki Aug 23, 2019
bebcb28
Localisation updates from https://translatewiki.net.
translatewiki Aug 26, 2019
47abe4f
edited CREDITS file (#3145)
vanshikaarora Aug 28, 2019
df26bf8
Unused dependencies are removed (#3141)
RozaliiaRusskikh Aug 28, 2019
1a29982
Localisation updates from https://translatewiki.net.
translatewiki Aug 29, 2019
aab692a
Localisation updates from https://translatewiki.net.
translatewiki Sep 3, 2019
d58e362
Localisation updates from https://translatewiki.net.
translatewiki Sep 6, 2019
cc0176a
Working with #3129 issue (#3146)
PavelAplevich Sep 9, 2019
95f1ce2
Localisation updates from https://translatewiki.net.
translatewiki Sep 9, 2019
4eb5470
Localisation updates from https://translatewiki.net.
translatewiki Sep 12, 2019
9d43181
Localisation updates from https://translatewiki.net.
translatewiki Sep 16, 2019
cc01bef
Localisation updates from https://translatewiki.net.
translatewiki Sep 19, 2019
cf12a31
delete res/values-en-gb (#3153)
neslihanturan Sep 23, 2019
ee1342d
Localisation updates from https://translatewiki.net.
translatewiki Sep 23, 2019
c557964
Localisation updates from https://translatewiki.net.
translatewiki Sep 26, 2019
528a307
First commit (#3093)
thetimeheist76 Sep 29, 2019
aae16e9
Solution #3126 (#3155)
PavelAplevich Sep 29, 2019
68e27d4
Bugfix/fix upload presenter tests (#3158)
ashishkumar468 Sep 29, 2019
6842bd8
Localisation updates from https://translatewiki.net.
translatewiki Oct 1, 2019
17a7980
Remove dependency on Exif parsing library. (#2947)
dbrant Oct 5, 2019
4ca7c82
Localisation updates from https://translatewiki.net.
translatewiki Oct 7, 2019
8a29312
Localisation updates from https://translatewiki.net.
translatewiki Oct 14, 2019
958bbbd
Refactor nearby classes mvp (#2969)
neslihanturan Oct 15, 2019
53d0d5e
On Logout, fetch the CSRF token and then make the post logout call (#…
ashishkumar468 Oct 30, 2019
5a2a06b
Correction is passed file name to checkPageExistsUsingTitle, function…
ashishkumar468 Nov 6, 2019
7e44da8
Merge master (#3196)
maskaravivek Nov 6, 2019
19f14c4
Merge branch 'master' into backend-overhaul
Nov 6, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
id 'com.github.triplet.play' version '2.2.1' apply false
}

apply from: '../gitutils.gradle'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
Expand All @@ -20,15 +19,18 @@ dependencies {
// Utils
implementation 'com.github.nicolas-raoul:Quadtree:ac16ea8035bf07'
implementation 'in.yuvi:http.fluent:1.3'
implementation 'com.squareup.okhttp3:okhttp:3.12.1'
implementation 'com.squareup.okio:okio:1.15.0'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.okhttp3:okhttp:4.2.0'
implementation 'com.squareup.okio:okio:2.2.2'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'io.reactivex.rxjava2:rxjava:2.2.3'
implementation 'com.jakewharton.rxbinding2:rxbinding:2.1.1'
implementation 'com.jakewharton.rxbinding2:rxbinding-support-v4:2.1.1'
implementation 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.1.1'
implementation 'com.jakewharton.rxbinding2:rxbinding-design:2.1.1'
implementation 'com.facebook.fresco:fresco:1.13.0'
implementation 'com.dmitrybrant:wikimedia-android-data-client:0.0.18'
implementation 'org.apache.commons:commons-lang3:3.8.1'
implementation 'com.github.maskaravivek:wikimedia-android-data-client:v0.0.28'

// UI
implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'
Expand All @@ -49,6 +51,7 @@ dependencies {
api('com.github.tony19:logback-android-classic:1.1.1-6') {
exclude group: 'com.google.android', module: 'android'
}
implementation "com.squareup.okhttp3:logging-interceptor:4.2.0"

// Dependency injector
implementation "com.google.dagger:dagger-android-support:$DAGGER_VERSION"
Expand All @@ -62,21 +65,21 @@ dependencies {
testImplementation 'org.robolectric:robolectric:4.3'
testImplementation 'androidx.test:core:1.2.0'
testImplementation 'com.nhaarman:mockito-kotlin:1.5.0'
testImplementation 'com.squareup.okhttp3:mockwebserver:3.10.0'
testImplementation 'com.squareup.okhttp3:mockwebserver:3.12.1'
testImplementation "org.powermock:powermock-module-junit4:2.0.0-beta.5"
testImplementation "org.powermock:powermock-api-mockito2:2.0.0-beta.5"

// Android testing
androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$KOTLIN_VERSION"
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.1'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test:rules:1.1.1'
androidTestImplementation 'androidx.annotation:annotation:1.0.2'
androidTestImplementation 'com.squareup.okhttp3:mockwebserver:3.10.0'
androidTestImplementation 'org.mockito:mockito-core:2.10.0'
androidTestUtil 'androidx.test:orchestrator:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.2.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation 'androidx.annotation:annotation:1.1.0'
androidTestImplementation 'com.squareup.okhttp3:mockwebserver:3.12.1'
androidTestImplementation 'org.mockito:mockito-core:2.13.0'
androidTestUtil 'androidx.test:orchestrator:1.2.0'

// Debugging
debugImplementation "com.squareup.leakcanary:leakcanary-android:$LEAK_CANARY_VERSION"
Expand Down Expand Up @@ -187,6 +190,7 @@ android {
buildConfigField "String", "IMAGE_URL_BASE", "\"https://upload.wikimedia.org/wikipedia/commons\""
buildConfigField "String", "HOME_URL", "\"https://commons.wikimedia.org/wiki/\""
buildConfigField "String", "COMMONS_URL", "\"https://commons.wikimedia.org\""
buildConfigField "String", "WIKIDATA_URL", "\"https://wikidata.org\""
buildConfigField "String", "MOBILE_HOME_URL", "\"https://commons.m.wikimedia.org/wiki/\""
buildConfigField "String", "SIGNUP_LANDING_URL", "\"https://commons.m.wikimedia.org/w/index.php?title=Special:CreateAccount&returnto=Main+Page&returntoquery=welcome%3Dyes\""
buildConfigField "String", "SIGNUP_SUCCESS_REDIRECTION_URL", "\"https://commons.m.wikimedia.org/w/index.php?title=Main_Page&welcome=yes\""
Expand Down Expand Up @@ -218,6 +222,7 @@ android {
buildConfigField "String", "IMAGE_URL_BASE", "\"https://upload.beta.wmflabs.org/wikipedia/commons\""
buildConfigField "String", "HOME_URL", "\"https://commons.wikimedia.beta.wmflabs.org/wiki/\""
buildConfigField "String", "COMMONS_URL", "\"https://commons.wikimedia.beta.wmflabs.org\""
buildConfigField "String", "WIKIDATA_URL", "\"https://wikidata.org\""
buildConfigField "String", "MOBILE_HOME_URL", "\"https://commons.m.wikimedia.beta.wmflabs.org/wiki/\""
buildConfigField "String", "SIGNUP_LANDING_URL", "\"https://commons.m.wikimedia.beta.wmflabs.org/w/index.php?title=Special:CreateAccount&returnto=Main+Page&returntoquery=welcome%3Dyes\""
buildConfigField "String", "SIGNUP_SUCCESS_REDIRECTION_URL", "\"https://commons.m.wikimedia.beta.wmflabs.org/w/index.php?title=Main_Page&welcome=yes\""
Expand Down
21 changes: 3 additions & 18 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@
</service>
<service
android:name=".contributions.ContributionsSyncService"
android:exported="true">
android:exported="true"
android:process=":sync">
<intent-filter>
<action android:name="android.content.SyncAdapter" />
</intent-filter>
Expand All @@ -161,17 +162,6 @@
android:name="android.content.SyncAdapter"
android:resource="@xml/contributions_sync_adapter" />
</service>
<service
android:name=".modifications.ModificationsSyncService"
android:exported="true">
<intent-filter>
<action android:name="android.content.SyncAdapter" />
</intent-filter>

<meta-data
android:name="android.content.SyncAdapter"
android:resource="@xml/modifications_sync_adapter" />
</service>

<service
android:name="org.acra.sender.SenderService"
Expand All @@ -193,12 +183,7 @@
android:exported="false"
android:label="@string/provider_contributions"
android:syncable="true" />
<provider
android:name=".modifications.ModificationsContentProvider"
android:authorities="${applicationId}.modifications.contentprovider"
android:exported="false"
android:label="@string/provider_modifications"
android:syncable="true" />

<provider
android:name=".category.CategoryContentProvider"
android:authorities="${applicationId}.categories.contentprovider"
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/fr/free/nrw/commons/CommonsAppAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,16 @@ public String getPassword() {

@Override
public void updateAccount(@NonNull LoginResult result) {
// TODO: sessionManager.updateAccount(result);
sessionManager.updateAccount(result);
}

@Override
public SharedPreferenceCookieManager getCookies() {
if (!preferences.contains(COOKIE_STORE_NAME)) {
return null;
}
return GsonUnmarshaller.unmarshal(SharedPreferenceCookieManager.class, preferences.getString(COOKIE_STORE_NAME, null));
return GsonUnmarshaller.unmarshal(SharedPreferenceCookieManager.class,
preferences.getString(COOKIE_STORE_NAME, null));
}

@Override
Expand Down
53 changes: 28 additions & 25 deletions app/src/main/java/fr/free/nrw/commons/CommonsApplication.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package fr.free.nrw.commons;

import static org.acra.ReportField.ANDROID_VERSION;
import static org.acra.ReportField.APP_VERSION_CODE;
import static org.acra.ReportField.APP_VERSION_NAME;
import static org.acra.ReportField.PHONE_MODEL;
import static org.acra.ReportField.STACK_TRACE;
import static org.acra.ReportField.USER_COMMENT;

import android.annotation.SuppressLint;
import android.app.Application;
import android.app.NotificationChannel;
Expand All @@ -9,26 +16,12 @@
import android.os.Build;
import android.os.Process;
import android.util.Log;

import androidx.annotation.NonNull;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.imagepipeline.core.ImagePipeline;
import com.facebook.imagepipeline.core.ImagePipelineConfig;
import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;

import org.acra.ACRA;
import org.acra.annotation.AcraCore;
import org.acra.annotation.AcraDialog;
import org.acra.annotation.AcraMailSender;
import org.acra.data.StringFormat;
import org.wikipedia.AppAdapter;
import org.wikipedia.language.AppLanguageLookUpTable;

import java.io.File;

import javax.inject.Inject;
import javax.inject.Named;

import androidx.annotation.NonNull;
import fr.free.nrw.commons.auth.SessionManager;
import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao;
import fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesDao;
Expand All @@ -41,22 +34,24 @@
import fr.free.nrw.commons.kvstore.JsonKvStore;
import fr.free.nrw.commons.logging.FileLoggingTree;
import fr.free.nrw.commons.logging.LogUtils;
import fr.free.nrw.commons.modifications.ModifierSequenceDao;
import fr.free.nrw.commons.upload.FileUtils;
import fr.free.nrw.commons.utils.ConfigUtils;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.internal.functions.Functions;
import io.reactivex.plugins.RxJavaPlugins;
import io.reactivex.schedulers.Schedulers;
import java.io.File;
import javax.inject.Inject;
import javax.inject.Named;
import org.acra.ACRA;
import org.acra.annotation.AcraCore;
import org.acra.annotation.AcraDialog;
import org.acra.annotation.AcraMailSender;
import org.acra.data.StringFormat;
import org.wikipedia.AppAdapter;
import org.wikipedia.language.AppLanguageLookUpTable;
import timber.log.Timber;

import static org.acra.ReportField.ANDROID_VERSION;
import static org.acra.ReportField.APP_VERSION_CODE;
import static org.acra.ReportField.APP_VERSION_NAME;
import static org.acra.ReportField.PHONE_MODEL;
import static org.acra.ReportField.STACK_TRACE;
import static org.acra.ReportField.USER_COMMENT;

@AcraCore(
buildConfigClass = BuildConfig.class,
resReportSendSuccessToast = R.string.crash_dialog_ok_toast,
Expand Down Expand Up @@ -250,6 +245,7 @@ public void clearApplicationData(Context context, LogoutListener logoutListener)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(() -> {
Timber.d("All accounts have been removed");
clearImageCache();
//TODO: fix preference manager
defaultPrefs.clearAll();
defaultPrefs.putBoolean("firstrun", false);
Expand All @@ -258,14 +254,21 @@ public void clearApplicationData(Context context, LogoutListener logoutListener)
});
}

/**
* Clear all images cache held by Fresco
*/
private void clearImageCache() {
ImagePipeline imagePipeline = Fresco.getImagePipeline();
imagePipeline.clearCaches();
}

/**
* Deletes all tables and re-creates them.
*/
private void updateAllDatabases() {
dbOpenHelper.getReadableDatabase().close();
SQLiteDatabase db = dbOpenHelper.getWritableDatabase();

ModifierSequenceDao.Table.onDelete(db);
CategoryDao.Table.onDelete(db);
ContributionDao.Table.onDelete(db);
BookmarkPicturesDao.Table.onDelete(db);
Expand Down
22 changes: 12 additions & 10 deletions app/src/main/java/fr/free/nrw/commons/Media.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import org.apache.commons.lang3.StringUtils;
import org.wikipedia.dataclient.mwapi.MwQueryPage;
import org.wikipedia.gallery.ExtMetadata;
Expand All @@ -20,14 +23,13 @@
import java.util.Locale;
import java.util.Map;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import fr.free.nrw.commons.location.LatLng;
import fr.free.nrw.commons.utils.CommonsDateUtil;
import fr.free.nrw.commons.utils.MediaDataExtractorUtil;

public class Media implements Parcelable {

public static final Media EMPTY = new Media("");
public static Creator<Media> CREATOR = new Creator<Media>() {
@Override
public Media createFromParcel(Parcel parcel) {
Expand Down Expand Up @@ -156,9 +158,9 @@ public static Media from(MwQueryPage page) {
page.title(),
"",
0,
safeParseDate(metadata.dateTimeOriginal().value()),
safeParseDate(metadata.dateTime().value()),
StringUtil.fromHtml(metadata.artist().value()).toString()
safeParseDate(metadata.dateTime()),
safeParseDate(metadata.dateTime()),
StringUtil.fromHtml(metadata.artist()).toString()
);

if (!StringUtils.isBlank(imageInfo.getThumbUrl())) {
Expand All @@ -170,17 +172,17 @@ public static Media from(MwQueryPage page) {
language = "default";
}

media.setDescriptions(Collections.singletonMap(language, metadata.imageDescription().value()));
media.setCategories(MediaDataExtractorUtil.extractCategoriesFromList(metadata.categories().value()));
String latitude = metadata.gpsLatitude().value();
String longitude = metadata.gpsLongitude().value();
media.setDescriptions(Collections.singletonMap(language, metadata.imageDescription()));
media.setCategories(MediaDataExtractorUtil.extractCategoriesFromList(metadata.getCategories()));
String latitude = metadata.getGpsLatitude();
String longitude = metadata.getGpsLongitude();

if (!StringUtils.isBlank(latitude) && !StringUtils.isBlank(longitude)) {
LatLng latLng = new LatLng(Double.parseDouble(latitude), Double.parseDouble(longitude), 0);
media.setCoordinates(latLng);
}

media.setLicenseInformation(metadata.licenseShortName().value(), metadata.licenseUrl().value());
media.setLicenseInformation(metadata.licenseShortName(), metadata.licenseUrl());
return media;
}

Expand Down
20 changes: 10 additions & 10 deletions app/src/main/java/fr/free/nrw/commons/MediaDataExtractor.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package fr.free.nrw.commons;

import androidx.core.text.HtmlCompat;

import javax.inject.Inject;
import javax.inject.Singleton;

import androidx.core.text.HtmlCompat;
import fr.free.nrw.commons.mwapi.MediaWikiApi;
import fr.free.nrw.commons.media.MediaClient;
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient;
import io.reactivex.Single;
import timber.log.Timber;
Expand All @@ -17,14 +18,14 @@
*/
@Singleton
public class MediaDataExtractor {
private final MediaWikiApi mediaWikiApi;
private final OkHttpJsonApiClient okHttpJsonApiClient;
private final MediaClient mediaClient;

@Inject
public MediaDataExtractor(MediaWikiApi mwApi,
OkHttpJsonApiClient okHttpJsonApiClient) {
public MediaDataExtractor(OkHttpJsonApiClient okHttpJsonApiClient,
MediaClient mediaClient) {
this.okHttpJsonApiClient = okHttpJsonApiClient;
this.mediaWikiApi = mwApi;
this.mediaClient = mediaClient;
}

/**
Expand All @@ -35,7 +36,7 @@ public MediaDataExtractor(MediaWikiApi mwApi,
*/
public Single<Media> fetchMediaDetails(String filename) {
Single<Media> mediaSingle = getMediaFromFileName(filename);
Single<Boolean> pageExistsSingle = mediaWikiApi.pageExists("Commons:Deletion_requests/" + filename);
Single<Boolean> pageExistsSingle = mediaClient.checkPageExistsUsingTitle("Commons:Deletion_requests/" + filename);
Single<String> discussionSingle = getDiscussion(filename);
return Single.zip(mediaSingle, pageExistsSingle, discussionSingle, (media, deletionStatus, discussion) -> {
media.setDiscussion(discussion);
Expand All @@ -52,7 +53,7 @@ public Single<Media> fetchMediaDetails(String filename) {
* @return return data rich Media object
*/
public Single<Media> getMediaFromFileName(String filename) {
return okHttpJsonApiClient.getMedia(filename, false);
return mediaClient.getMedia(filename);
}

/**
Expand All @@ -61,8 +62,7 @@ public Single<Media> getMediaFromFileName(String filename) {
* @return
*/
private Single<String> getDiscussion(String filename) {
return mediaWikiApi.fetchMediaByFilename(filename.replace("File", "File talk"))
.flatMap(mediaResult -> mediaWikiApi.parseWikicode(mediaResult.getWikiSource()))
return mediaClient.getPageHtml(filename.replace("File", "File talk"))
.map(discussion -> HtmlCompat.fromHtml(discussion, HtmlCompat.FROM_HTML_MODE_LEGACY).toString())
.onErrorReturn(throwable -> {
Timber.e(throwable, "Error occurred while fetching discussion");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,22 @@ private static OkHttpClient createClient() {
return new OkHttpClient.Builder()
.cookieJar(SharedPreferenceCookieManager.getInstance())
.cache(NET_CACHE)
.addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
.addInterceptor(getLoggingInterceptor())
.addInterceptor(new UnsuccessfulResponseInterceptor())
.addInterceptor(new CommonHeaderRequestInterceptor())
.build();
}

private static HttpLoggingInterceptor getLoggingInterceptor() {
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor()
.setLevel(HttpLoggingInterceptor.Level.BASIC);

httpLoggingInterceptor.redactHeader("Authorization");
httpLoggingInterceptor.redactHeader("Cookie");

return httpLoggingInterceptor;
}

private static class CommonHeaderRequestInterceptor implements Interceptor {
@Override @NonNull public Response intercept(@NonNull Chain chain) throws IOException {
Request request = chain.request().newBuilder()
Expand Down
Loading