Update LibPhoneNumberInfo

This commit is contained in:
xynngh 2021-06-01 12:26:00 +04:00
parent 2c2ce19146
commit 1f3b621450
6 changed files with 62 additions and 73 deletions

View File

@ -15,12 +15,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Changed
- The Lookup screen number field is prefilled from clipboard.
- The database update procedure is optimized to require less RAM.
- Updated French and Italian translations thanks to J. Lavoie ([@Edanas](https://hosted.weblate.org/user/Edanas/)).
- Updated Portuguese translation thanks to ssantos ([@ssantos](https://hosted.weblate.org/user/ssantos/)).
### Fixed
- Fix Hebrew translation not being used by Android.
- Fixed a rare bug where the app could stuck in an update loop.
- Fixed Hebrew translation not being used by Android.
## [0.5.14] - 2021-05-05

View File

@ -46,7 +46,7 @@ dependencies {
implementation 'org.conscrypt:conscrypt-android:2.5.2'
//noinspection GradleDependency: 3.12.* is the latest version compatible with Android <5
implementation 'com.squareup.okhttp3:okhttp:3.12.13'
implementation 'com.gitlab.xynngh:LibPhoneNumberInfo:5b0b9fcbee'
implementation 'com.gitlab.xynngh:LibPhoneNumberInfo:c77bdd2b69'
implementation 'org.apache.commons:commons-csv:1.8'
implementation 'androidx.appcompat:appcompat:1.2.0'

View File

@ -18,6 +18,7 @@ import dummydomain.yetanothercallblocker.sia.model.database.CommunityDatabase;
import dummydomain.yetanothercallblocker.sia.model.database.DbManager;
import dummydomain.yetanothercallblocker.sia.model.database.FeaturedDatabase;
import dummydomain.yetanothercallblocker.sia.network.DbDownloader;
import dummydomain.yetanothercallblocker.sia.network.DbUpdateRequester;
import dummydomain.yetanothercallblocker.sia.network.OkHttpClientFactory;
import dummydomain.yetanothercallblocker.sia.network.WebService;
import dummydomain.yetanothercallblocker.sia.utils.Utils;
@ -32,22 +33,17 @@ import static dummydomain.yetanothercallblocker.data.SiaConstants.SIA_SECONDARY_
public class Config {
private static class WSParameterProvider extends WebService.DefaultWSParameterProvider {
dummydomain.yetanothercallblocker.Settings settings;
SiaMetadata siaMetadata;
CommunityDatabase communityDatabase;
final dummydomain.yetanothercallblocker.Settings settings;
final SiaMetadata siaMetadata;
final CommunityDatabase communityDatabase;
volatile String appId;
volatile long appIdTimestamp;
void setSettings(dummydomain.yetanothercallblocker.Settings settings) {
WSParameterProvider(dummydomain.yetanothercallblocker.Settings settings,
SiaMetadata siaMetadata, CommunityDatabase communityDatabase) {
this.settings = settings;
}
void setSiaMetadata(SiaMetadata siaMetadata) {
this.siaMetadata = siaMetadata;
}
void setCommunityDatabase(CommunityDatabase communityDatabase) {
this.communityDatabase = communityDatabase;
}
@ -98,32 +94,29 @@ public class Config {
return new OkHttpClient();
};
WSParameterProvider wsParameterProvider = new WSParameterProvider();
wsParameterProvider.setSettings(settings);
WebService webService = new WebService(wsParameterProvider, okHttpClientFactory);
YacbHolder.setWebService(webService);
YacbHolder.setDbManager(new DbManager(storage, SIA_PATH_PREFIX,
new DbDownloader(okHttpClientFactory)));
CommunityDatabase communityDatabase = new CommunityDatabase(
storage, AbstractDatabase.Source.ANY, SIA_PATH_PREFIX,
SIA_SECONDARY_PATH_PREFIX, siaSettings, webService);
wsParameterProvider.setCommunityDatabase(communityDatabase);
SIA_SECONDARY_PATH_PREFIX, siaSettings);
YacbHolder.setCommunityDatabase(communityDatabase);
SiaMetadata siaMetadata = new SiaMetadata(storage, SIA_PATH_PREFIX,
communityDatabase::isUsingInternal);
wsParameterProvider.setSiaMetadata(siaMetadata);
YacbHolder.setSiaMetadata(siaMetadata);
FeaturedDatabase featuredDatabase = new FeaturedDatabase(
storage, AbstractDatabase.Source.ANY, SIA_PATH_PREFIX);
YacbHolder.setFeaturedDatabase(featuredDatabase);
WSParameterProvider wsParameterProvider = new WSParameterProvider(
settings, siaMetadata, communityDatabase);
WebService webService = new WebService(wsParameterProvider, okHttpClientFactory);
YacbHolder.setWebService(webService);
YacbHolder.setDbManager(new DbManager(storage, SIA_PATH_PREFIX,
new DbDownloader(okHttpClientFactory), new DbUpdateRequester(webService),
communityDatabase));
YacbHolder.setCommunityReviewsLoader(new CommunityReviewsLoader(webService));
YacbDaoSessionFactory daoSessionFactory = new YacbDaoSessionFactory(context, "YACB");

View File

@ -0,0 +1,37 @@
package dummydomain.yetanothercallblocker.work;
import dummydomain.yetanothercallblocker.App;
import dummydomain.yetanothercallblocker.Settings;
import dummydomain.yetanothercallblocker.data.YacbHolder;
import dummydomain.yetanothercallblocker.event.SecondaryDbUpdateFinished;
import dummydomain.yetanothercallblocker.event.SecondaryDbUpdatingEvent;
import dummydomain.yetanothercallblocker.sia.model.database.DbManager;
import static dummydomain.yetanothercallblocker.EventUtils.postEvent;
import static dummydomain.yetanothercallblocker.EventUtils.postStickyEvent;
import static dummydomain.yetanothercallblocker.EventUtils.removeStickyEvent;
public class DbUpdater {
public void update() {
Settings settings = App.getSettings();
boolean updated = false;
SecondaryDbUpdatingEvent sticky = new SecondaryDbUpdatingEvent();
postStickyEvent(sticky);
try {
DbManager.UpdateResult updateResult = YacbHolder.getDbManager().updateSecondaryDb();
if (updateResult.isUpdated()) {
settings.setLastUpdateTime(System.currentTimeMillis());
updated = true;
} // TODO: handle other results
settings.setLastUpdateCheckTime(System.currentTimeMillis());
} finally {
removeStickyEvent(sticky);
postEvent(new SecondaryDbUpdateFinished(updated));
}
}
}

View File

@ -16,12 +16,9 @@ import org.slf4j.LoggerFactory;
import dummydomain.yetanothercallblocker.App;
import dummydomain.yetanothercallblocker.NotificationHelper;
import dummydomain.yetanothercallblocker.R;
import dummydomain.yetanothercallblocker.Settings;
import dummydomain.yetanothercallblocker.data.YacbHolder;
import dummydomain.yetanothercallblocker.event.MainDbDownloadFinishedEvent;
import dummydomain.yetanothercallblocker.event.MainDbDownloadingEvent;
import dummydomain.yetanothercallblocker.event.SecondaryDbUpdateFinished;
import dummydomain.yetanothercallblocker.event.SecondaryDbUpdatingEvent;
import static dummydomain.yetanothercallblocker.EventUtils.postEvent;
import static dummydomain.yetanothercallblocker.EventUtils.postStickyEvent;
@ -102,24 +99,7 @@ public class TaskService extends IntentService {
}
private void updateSecondaryDb() {
Settings settings = App.getSettings();
boolean updated = false;
SecondaryDbUpdatingEvent sticky = new SecondaryDbUpdatingEvent();
postStickyEvent(sticky);
try {
if (YacbHolder.getCommunityDatabase().updateSecondaryDb()) {
settings.setLastUpdateTime(System.currentTimeMillis());
updated = true;
}
settings.setLastUpdateCheckTime(System.currentTimeMillis());
} finally {
removeStickyEvent(sticky);
}
postEvent(new SecondaryDbUpdateFinished(updated));
new DbUpdater().update();
}
}

View File

@ -9,16 +9,6 @@ import androidx.work.WorkerParameters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import dummydomain.yetanothercallblocker.App;
import dummydomain.yetanothercallblocker.Settings;
import dummydomain.yetanothercallblocker.data.YacbHolder;
import dummydomain.yetanothercallblocker.event.SecondaryDbUpdateFinished;
import dummydomain.yetanothercallblocker.event.SecondaryDbUpdatingEvent;
import static dummydomain.yetanothercallblocker.EventUtils.postEvent;
import static dummydomain.yetanothercallblocker.EventUtils.postStickyEvent;
import static dummydomain.yetanothercallblocker.EventUtils.removeStickyEvent;
public class UpdateWorker extends Worker {
private static final Logger LOG = LoggerFactory.getLogger(UpdateWorker.class);
@ -32,24 +22,11 @@ public class UpdateWorker extends Worker {
public Result doWork() {
LOG.info("doWork() started");
Settings settings = App.getSettings();
boolean updated = false;
SecondaryDbUpdatingEvent sticky = new SecondaryDbUpdatingEvent();
postStickyEvent(sticky);
try {
if (YacbHolder.getCommunityDatabase().updateSecondaryDb()) {
settings.setLastUpdateTime(System.currentTimeMillis());
updated = true;
new DbUpdater().update();
} catch (Exception e) {
LOG.error("doWork() error", e);
}
settings.setLastUpdateCheckTime(System.currentTimeMillis());
} finally {
removeStickyEvent(sticky);
}
postEvent(new SecondaryDbUpdateFinished(updated));
LOG.info("doWork() finished");
return Result.success();