Use custom request headers

This commit is contained in:
xynngh 2020-06-22 20:02:47 +04:00
parent a28878ba04
commit 69945a9ce9
5 changed files with 34 additions and 3 deletions

View File

@ -39,7 +39,7 @@ dependencies {
implementation 'org.conscrypt:conscrypt-android:2.4.0'
//noinspection GradleDependency: 3.12.* is the latest version compatible with Android <5
implementation 'com.squareup.okhttp3:okhttp:3.12.12'
implementation 'com.gitlab.xynngh:LibPhoneNumberInfo:2827d231b7'
implementation 'com.gitlab.xynngh:LibPhoneNumberInfo:551b0a2f6b'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'

View File

@ -19,6 +19,7 @@ import dummydomain.yetanothercallblocker.data.DatabaseSingleton;
import dummydomain.yetanothercallblocker.data.SiaNumberCategoryUtils;
import dummydomain.yetanothercallblocker.event.SecondaryDbUpdateFinished;
import dummydomain.yetanothercallblocker.sia.model.NumberCategory;
import dummydomain.yetanothercallblocker.sia.model.SiaMetadata;
import dummydomain.yetanothercallblocker.sia.model.database.CommunityDatabase;
import dummydomain.yetanothercallblocker.sia.model.database.CommunityDatabaseItem;
import dummydomain.yetanothercallblocker.sia.model.database.FeaturedDatabase;
@ -119,12 +120,13 @@ public class DebugActivity extends AppCompatActivity {
protected String doInBackground(Void... voids) {
StringBuilder sb = new StringBuilder();
SiaMetadata siaMetadata = DatabaseSingleton.getSiaMetadata();
CommunityDatabase communityDatabase = DatabaseSingleton.getCommunityDatabase();
sb.append("DB info:\n");
sb.append("Operational: ").append(communityDatabase.isOperational()).append('\n');
sb.append("Base version: ").append(communityDatabase.getBaseDbVersion());
sb.append(" (SIA: ").append(communityDatabase.getSiaAppVersion()).append(")\n");
sb.append(" (SIA: ").append(siaMetadata.getSiaAppVersion()).append(")\n");
sb.append("Effective version: ").append(communityDatabase.getEffectiveDbVersion()).append('\n');
sb.append("Last update time: ").append(dateOrNever(App.getSettings().getLastUpdateTime())).append('\n');
sb.append("Last update check time: ").append(dateOrNever(App.getSettings().getLastUpdateCheckTime())).append('\n');

View File

@ -8,6 +8,7 @@ import dummydomain.yetanothercallblocker.sia.Settings;
import dummydomain.yetanothercallblocker.sia.SettingsImpl;
import dummydomain.yetanothercallblocker.sia.Storage;
import dummydomain.yetanothercallblocker.sia.model.CommunityReviewsLoader;
import dummydomain.yetanothercallblocker.sia.model.SiaMetadata;
import dummydomain.yetanothercallblocker.sia.model.database.AbstractDatabase;
import dummydomain.yetanothercallblocker.sia.model.database.CommunityDatabase;
import dummydomain.yetanothercallblocker.sia.model.database.DbManager;
@ -21,8 +22,13 @@ import static dummydomain.yetanothercallblocker.data.SiaConstants.SIA_SECONDARY_
public class Config {
private static class WSParameterProvider extends WebService.DefaultWSParameterProvider {
SiaMetadata siaMetadata;
CommunityDatabase communityDatabase;
void setSiaMetadata(SiaMetadata siaMetadata) {
this.siaMetadata = siaMetadata;
}
void setCommunityDatabase(CommunityDatabase communityDatabase) {
this.communityDatabase = communityDatabase;
}
@ -34,7 +40,12 @@ public class Config {
@Override
public int getAppVersion() {
return communityDatabase.getSiaAppVersion();
return siaMetadata.getSiaAppVersion();
}
@Override
public String getOkHttpVersion() {
return siaMetadata.getSiaOkHttpVersion();
}
@Override
@ -60,6 +71,12 @@ public class Config {
wsParameterProvider.setCommunityDatabase(communityDatabase);
DatabaseSingleton.setCommunityDatabase(communityDatabase);
SiaMetadata siaMetadata = new SiaMetadata(storage, SIA_PATH_PREFIX,
communityDatabase::isUsingInternal);
wsParameterProvider.setSiaMetadata(siaMetadata);
DatabaseSingleton.setSiaMetadata(siaMetadata);
DatabaseSingleton.setFeaturedDatabase(new FeaturedDatabase(
storage, AbstractDatabase.Source.ANY, SIA_PATH_PREFIX));

View File

@ -6,6 +6,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import dummydomain.yetanothercallblocker.sia.model.CommunityReviewsLoader;
import dummydomain.yetanothercallblocker.sia.model.SiaMetadata;
import dummydomain.yetanothercallblocker.sia.model.database.CommunityDatabase;
import dummydomain.yetanothercallblocker.sia.model.database.CommunityDatabaseItem;
import dummydomain.yetanothercallblocker.sia.model.database.DbManager;
@ -18,6 +19,8 @@ public class DatabaseSingleton {
private static DbManager dbManager;
private static SiaMetadata siaMetadata;
private static CommunityDatabase communityDatabase;
private static FeaturedDatabase featuredDatabase;
@ -30,6 +33,10 @@ public class DatabaseSingleton {
DatabaseSingleton.dbManager = dbManager;
}
static void setSiaMetadata(SiaMetadata siaMetadata) {
DatabaseSingleton.siaMetadata = siaMetadata;
}
static void setCommunityDatabase(CommunityDatabase communityDatabase) {
DatabaseSingleton.communityDatabase = communityDatabase;
}
@ -50,6 +57,10 @@ public class DatabaseSingleton {
return dbManager;
}
public static SiaMetadata getSiaMetadata() {
return siaMetadata;
}
public static CommunityDatabase getCommunityDatabase() {
return communityDatabase;
}

View File

@ -91,6 +91,7 @@ public class TaskService extends IntentService {
DatabaseSingleton.getDbManager().downloadMainDb();
DatabaseSingleton.getCommunityDatabase().reload();
DatabaseSingleton.getFeaturedDatabase().reload();
DatabaseSingleton.getSiaMetadata().reload();
} finally {
removeStickyEvent(sticky);
}