Skip to content

Commit

Permalink
Merge pull request #10 from menekseibrahim/master
Browse files Browse the repository at this point in the history
bugfix: forceUpdate
  • Loading branch information
menekseibrahim authored Jan 12, 2017
2 parents 4931a17 + 84f69d7 commit d19ed11
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tr.com.turkcellteknoloji.turkcellupdater"
android:versionCode="4"
android:versionName="1.2.3" >
android:versionCode="5"
android:versionName="1.2.4" >

<uses-sdk
android:minSdkVersion="8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,22 +137,24 @@ Update getUpdate(Properties properties, UpdateDisplayRecords records) throws Upd
if (Utilities.isNullOrEmpty(packageName)) {
throw new UpdaterException("'packageName' property should not be null or empty.");
}
if (maxDisplayCount < Integer.MAX_VALUE) {
final int count = records.getUpdateDisplayCount(id);
if (count >= maxDisplayCount) {
return null;
}
}
// check if it is displayed earlier than specified period
if (displayPeriodInHours > 0) {
final Date updateLastDisplayDate = records.getUpdateLastDisplayDate(id);
// check if message displayed before
if (updateLastDisplayDate != null) {
final Date date = Utilities.addHours(now, -displayPeriodInHours);
if (updateLastDisplayDate.after(date)) {
if (!forceUpdate && !forceExit) {
if (maxDisplayCount < Integer.MAX_VALUE) {
final int count = records.getUpdateDisplayCount(id);
if (count >= maxDisplayCount) {
return null;
}
}
// check if it is displayed earlier than specified period
if (displayPeriodInHours > 0) {
final Date updateLastDisplayDate = records.getUpdateLastDisplayDate(id);
// check if message displayed before
if (updateLastDisplayDate != null) {
final Date date = Utilities.addHours(now, -displayPeriodInHours);
if (updateLastDisplayDate.after(date)) {
return null;
}
}
}
}
final UpdateDescription updateDescription = LocalizedStringMap.select(updateDescriptions, languageCode);
records.onUpdateDisplayed(id, now);
Expand All @@ -174,32 +176,33 @@ private void validate() throws UpdaterException {
boolean shouldDisplay(Properties properties, UpdateDisplayRecords records, Context context) {
if (isMatches(properties)) {
final Integer currentVersionCode = Utilities.tryParseInteger(properties.getValue(Properties.KEY_APP_VERSION_CODE));
if (currentVersionCode != null && targetVersionCode != currentVersionCode.intValue()) {
return true;
}
// check if it is displayed more than specified count
if (maxDisplayCount < Integer.MAX_VALUE) {
final int count = records.getUpdateDisplayCount(id);
if (count >= maxDisplayCount) {
return false;
}
}
// check if it is displayed earlier than specified period
if (displayPeriodInHours > 0) {
final Date updateLastDisplayDate = records.getUpdateLastDisplayDate(id);
// check if update displayed before
if (updateLastDisplayDate != null) {
Date now = new Date();
final Date date = Utilities.addHours(now, -displayPeriodInHours);
if (updateLastDisplayDate.after(date)) {
return false;
if (currentVersionCode != null && targetVersionCode > currentVersionCode.intValue()) {
if (forceUpdate || forceExit) {
return true;
} else {
boolean rtn = true;
// check if it is displayed more than specified count
if (maxDisplayCount < Integer.MAX_VALUE) {
final int count = records.getUpdateDisplayCount(id);
if (count >= maxDisplayCount) {
rtn = false;
}
}
// check if it is displayed earlier than specified period
if (displayPeriodInHours > 0) {
final Date updateLastDisplayDate = records.getUpdateLastDisplayDate(id);
// check if update displayed before
if (updateLastDisplayDate != null) {
Date now = new Date();
final Date date = Utilities.addHours(now, -displayPeriodInHours);
if (updateLastDisplayDate.after(date)) {
rtn = false;
}
}
}
return rtn;
}
}
final String currentPackageName = properties.getValue(Properties.KEY_APP_PACKAGE_NAME);
if (!Utilities.isNullOrEmpty(currentPackageName) && !Utilities.isNullOrEmpty(targetPackageName)) {
return !currentPackageName.equals(targetPackageName);
}
}
return false;
}
Expand Down

0 comments on commit d19ed11

Please sign in to comment.