Update LibPhoneNumberInfo
This commit is contained in:
parent
2c2ce19146
commit
1f3b621450
|
@ -15,12 +15,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- The Lookup screen number field is prefilled from clipboard.
|
- 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 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/)).
|
- Updated Portuguese translation thanks to ssantos ([@ssantos](https://hosted.weblate.org/user/ssantos/)).
|
||||||
|
|
||||||
### Fixed
|
### 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
|
## [0.5.14] - 2021-05-05
|
||||||
|
|
|
@ -46,7 +46,7 @@ dependencies {
|
||||||
implementation 'org.conscrypt:conscrypt-android:2.5.2'
|
implementation 'org.conscrypt:conscrypt-android:2.5.2'
|
||||||
//noinspection GradleDependency: 3.12.* is the latest version compatible with Android <5
|
//noinspection GradleDependency: 3.12.* is the latest version compatible with Android <5
|
||||||
implementation 'com.squareup.okhttp3:okhttp:3.12.13'
|
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 'org.apache.commons:commons-csv:1.8'
|
||||||
|
|
||||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||||
|
|
|
@ -18,6 +18,7 @@ import dummydomain.yetanothercallblocker.sia.model.database.CommunityDatabase;
|
||||||
import dummydomain.yetanothercallblocker.sia.model.database.DbManager;
|
import dummydomain.yetanothercallblocker.sia.model.database.DbManager;
|
||||||
import dummydomain.yetanothercallblocker.sia.model.database.FeaturedDatabase;
|
import dummydomain.yetanothercallblocker.sia.model.database.FeaturedDatabase;
|
||||||
import dummydomain.yetanothercallblocker.sia.network.DbDownloader;
|
import dummydomain.yetanothercallblocker.sia.network.DbDownloader;
|
||||||
|
import dummydomain.yetanothercallblocker.sia.network.DbUpdateRequester;
|
||||||
import dummydomain.yetanothercallblocker.sia.network.OkHttpClientFactory;
|
import dummydomain.yetanothercallblocker.sia.network.OkHttpClientFactory;
|
||||||
import dummydomain.yetanothercallblocker.sia.network.WebService;
|
import dummydomain.yetanothercallblocker.sia.network.WebService;
|
||||||
import dummydomain.yetanothercallblocker.sia.utils.Utils;
|
import dummydomain.yetanothercallblocker.sia.utils.Utils;
|
||||||
|
@ -32,22 +33,17 @@ import static dummydomain.yetanothercallblocker.data.SiaConstants.SIA_SECONDARY_
|
||||||
public class Config {
|
public class Config {
|
||||||
|
|
||||||
private static class WSParameterProvider extends WebService.DefaultWSParameterProvider {
|
private static class WSParameterProvider extends WebService.DefaultWSParameterProvider {
|
||||||
dummydomain.yetanothercallblocker.Settings settings;
|
final dummydomain.yetanothercallblocker.Settings settings;
|
||||||
SiaMetadata siaMetadata;
|
final SiaMetadata siaMetadata;
|
||||||
CommunityDatabase communityDatabase;
|
final CommunityDatabase communityDatabase;
|
||||||
|
|
||||||
volatile String appId;
|
volatile String appId;
|
||||||
volatile long appIdTimestamp;
|
volatile long appIdTimestamp;
|
||||||
|
|
||||||
void setSettings(dummydomain.yetanothercallblocker.Settings settings) {
|
WSParameterProvider(dummydomain.yetanothercallblocker.Settings settings,
|
||||||
|
SiaMetadata siaMetadata, CommunityDatabase communityDatabase) {
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
}
|
|
||||||
|
|
||||||
void setSiaMetadata(SiaMetadata siaMetadata) {
|
|
||||||
this.siaMetadata = siaMetadata;
|
this.siaMetadata = siaMetadata;
|
||||||
}
|
|
||||||
|
|
||||||
void setCommunityDatabase(CommunityDatabase communityDatabase) {
|
|
||||||
this.communityDatabase = communityDatabase;
|
this.communityDatabase = communityDatabase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,32 +94,29 @@ public class Config {
|
||||||
return new OkHttpClient();
|
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(
|
CommunityDatabase communityDatabase = new CommunityDatabase(
|
||||||
storage, AbstractDatabase.Source.ANY, SIA_PATH_PREFIX,
|
storage, AbstractDatabase.Source.ANY, SIA_PATH_PREFIX,
|
||||||
SIA_SECONDARY_PATH_PREFIX, siaSettings, webService);
|
SIA_SECONDARY_PATH_PREFIX, siaSettings);
|
||||||
|
|
||||||
wsParameterProvider.setCommunityDatabase(communityDatabase);
|
|
||||||
YacbHolder.setCommunityDatabase(communityDatabase);
|
YacbHolder.setCommunityDatabase(communityDatabase);
|
||||||
|
|
||||||
SiaMetadata siaMetadata = new SiaMetadata(storage, SIA_PATH_PREFIX,
|
SiaMetadata siaMetadata = new SiaMetadata(storage, SIA_PATH_PREFIX,
|
||||||
communityDatabase::isUsingInternal);
|
communityDatabase::isUsingInternal);
|
||||||
|
|
||||||
wsParameterProvider.setSiaMetadata(siaMetadata);
|
|
||||||
YacbHolder.setSiaMetadata(siaMetadata);
|
YacbHolder.setSiaMetadata(siaMetadata);
|
||||||
|
|
||||||
FeaturedDatabase featuredDatabase = new FeaturedDatabase(
|
FeaturedDatabase featuredDatabase = new FeaturedDatabase(
|
||||||
storage, AbstractDatabase.Source.ANY, SIA_PATH_PREFIX);
|
storage, AbstractDatabase.Source.ANY, SIA_PATH_PREFIX);
|
||||||
YacbHolder.setFeaturedDatabase(featuredDatabase);
|
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));
|
YacbHolder.setCommunityReviewsLoader(new CommunityReviewsLoader(webService));
|
||||||
|
|
||||||
YacbDaoSessionFactory daoSessionFactory = new YacbDaoSessionFactory(context, "YACB");
|
YacbDaoSessionFactory daoSessionFactory = new YacbDaoSessionFactory(context, "YACB");
|
||||||
|
|
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -16,12 +16,9 @@ import org.slf4j.LoggerFactory;
|
||||||
import dummydomain.yetanothercallblocker.App;
|
import dummydomain.yetanothercallblocker.App;
|
||||||
import dummydomain.yetanothercallblocker.NotificationHelper;
|
import dummydomain.yetanothercallblocker.NotificationHelper;
|
||||||
import dummydomain.yetanothercallblocker.R;
|
import dummydomain.yetanothercallblocker.R;
|
||||||
import dummydomain.yetanothercallblocker.Settings;
|
|
||||||
import dummydomain.yetanothercallblocker.data.YacbHolder;
|
import dummydomain.yetanothercallblocker.data.YacbHolder;
|
||||||
import dummydomain.yetanothercallblocker.event.MainDbDownloadFinishedEvent;
|
import dummydomain.yetanothercallblocker.event.MainDbDownloadFinishedEvent;
|
||||||
import dummydomain.yetanothercallblocker.event.MainDbDownloadingEvent;
|
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.postEvent;
|
||||||
import static dummydomain.yetanothercallblocker.EventUtils.postStickyEvent;
|
import static dummydomain.yetanothercallblocker.EventUtils.postStickyEvent;
|
||||||
|
@ -102,24 +99,7 @@ public class TaskService extends IntentService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSecondaryDb() {
|
private void updateSecondaryDb() {
|
||||||
Settings settings = App.getSettings();
|
new DbUpdater().update();
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,16 +9,6 @@ import androidx.work.WorkerParameters;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
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 {
|
public class UpdateWorker extends Worker {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(UpdateWorker.class);
|
private static final Logger LOG = LoggerFactory.getLogger(UpdateWorker.class);
|
||||||
|
@ -32,25 +22,12 @@ public class UpdateWorker extends Worker {
|
||||||
public Result doWork() {
|
public Result doWork() {
|
||||||
LOG.info("doWork() started");
|
LOG.info("doWork() started");
|
||||||
|
|
||||||
Settings settings = App.getSettings();
|
|
||||||
|
|
||||||
boolean updated = false;
|
|
||||||
|
|
||||||
SecondaryDbUpdatingEvent sticky = new SecondaryDbUpdatingEvent();
|
|
||||||
|
|
||||||
postStickyEvent(sticky);
|
|
||||||
try {
|
try {
|
||||||
if (YacbHolder.getCommunityDatabase().updateSecondaryDb()) {
|
new DbUpdater().update();
|
||||||
settings.setLastUpdateTime(System.currentTimeMillis());
|
} catch (Exception e) {
|
||||||
updated = true;
|
LOG.error("doWork() error", e);
|
||||||
}
|
|
||||||
settings.setLastUpdateCheckTime(System.currentTimeMillis());
|
|
||||||
} finally {
|
|
||||||
removeStickyEvent(sticky);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
postEvent(new SecondaryDbUpdateFinished(updated));
|
|
||||||
|
|
||||||
LOG.info("doWork() finished");
|
LOG.info("doWork() finished");
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue