Skip to content

Commit

Permalink
Show recently updates for 3 days
Browse files Browse the repository at this point in the history
  • Loading branch information
anod committed Feb 19, 2018
1 parent 49347b1 commit aac13c1
Show file tree
Hide file tree
Showing 16 changed files with 156 additions and 153 deletions.
77 changes: 28 additions & 49 deletions playstore/playstore.iml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="SELECTED_BUILD_VARIANT" value="release" />
<option name="ASSEMBLE_TASK_NAME" value="assembleRelease" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileReleaseSources" />
<afterSyncTasks>
<task>generateDebugSources</task>
<task>generateReleaseSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
Expand All @@ -40,46 +40,32 @@
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<output url="file://$MODULE_DIR$/build/intermediates/classes/release" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/release" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/release" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/release" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/release" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/release" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/release" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/release" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/release" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/test/release" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/src/release/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/release/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/release/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/release/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/release/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/release/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/release/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/testRelease/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testRelease/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testRelease/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testRelease/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testRelease/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testRelease/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testRelease/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
Expand All @@ -101,31 +87,24 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/attr" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/extractedTypedefs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/intermediate-jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/library_and_local_jars_jni" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/packaged-aidl" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/packaged-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/packagedAssets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/packaged_res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/public_res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/publish-proguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/splits-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/kotlin" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/com/anod/appwatcher/backup/AppJsonObject.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.anod.appwatcher.backup
import android.text.TextUtils
import com.anod.appwatcher.model.AppInfo
import com.anod.appwatcher.model.Tag
import com.anod.appwatcher.model.schema.AppListTable
import info.anodsplace.framework.AppLog
import info.anodsplace.framework.json.JsonReader
import info.anodsplace.framework.json.JsonToken
Expand Down Expand Up @@ -36,9 +37,9 @@ class AppJsonObject(val app: AppInfo?, val tags: List<String>) {
writer.name("status").value(app.status.toLong())
writer.name("detailsUrl").value(app.detailsUrl)
writer.name("iconUrl").value(app.iconUrl)
writer.name("refreshTime").value(app.refreshTime)
writer.name("uploadTime").value(app.uploadTime)
writer.name("appType").value(app.appType)
writer.name("syncVersion").value(app.syncVersion.toLong())
writer.name("refreshTimestamp").value(app.refreshTime.toLong())

val tagsWriter = writer.name("tags")
tagsWriter.beginArray()
Expand All @@ -62,9 +63,10 @@ class AppJsonObject(val app: AppInfo?, val tags: List<String>) {
var appType = ""
var versionNumber = 0
var status = 0
var syncVersion = 0
var refreshTime: Long = 0
var uploadTime: Long = 0
val tags = mutableListOf<String>()
val recentTime = AppListTable.recentTime

reader.beginObject()
while (reader.hasNext()) {
Expand All @@ -91,12 +93,12 @@ class AppJsonObject(val app: AppInfo?, val tags: List<String>) {
detailsUrl = if (isNull) "" else reader.nextString()
} else if (name == "iconUrl") {
iconUrl = if (isNull) "" else reader.nextString()
} else if (name == "refreshTime") {
refreshTime = reader.nextLong()
} else if (name == "uploadTime") {
uploadTime = reader.nextLong()
} else if (name == "appType") {
appType = if (isNull) "" else reader.nextString()
} else if (name == "syncVersion") {
syncVersion = if (isNull) 0 else reader.nextInt()
} else if (name == "refreshTimestamp") {
refreshTime = if (isNull) 0 else reader.nextLong()
} else if (name == "tags") {
reader.beginArray()
while (reader.hasNext()) {
Expand All @@ -116,7 +118,7 @@ class AppJsonObject(val app: AppInfo?, val tags: List<String>) {
if (appId != null && pname != null) {
val info = AppInfo(0, appId, pname, versionNumber, versionName,
title, creator, iconUrl, status, uploadDate, null, null, null,
detailsUrl, refreshTime, appType, syncVersion)
detailsUrl, uploadTime, appType, refreshTime, uploadTime > recentTime)
onUpgrade(info)
return Pair(info, tags)
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/anod/appwatcher/content/AppListCursor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ class AppListCursor(cursor: Cursor?) : CursorIterator<AppInfo>(cursor) {
getString(AppListTable.Projection.priceCurrency),
getInt(AppListTable.Projection.priceMicros),
getString(AppListTable.Projection.detailsUrl),
getLong(AppListTable.Projection.refreshTime),
getLong(AppListTable.Projection.uploadTime),
getString(AppListTable.Projection.appType),
getInt(AppListTable.Projection.syncVersion)
getLong(AppListTable.Projection.refreshTime),
getInt(AppListTable.Projection.recentFlag) == 1
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,6 @@ class DbContentProviderClient(private val contentProviderClient: ContentProvider
return queryApps(sortOrder, selection, selectionArgs)
}

fun queryUpdated(tag: Tag?): AppListCursor {
val selc = ArrayList<String>(2)
val args = ArrayList<String>(2)

selc.add(AppListTable.Columns.status + " = ?")
args.add(AppInfoMetadata.STATUS_UPDATED.toString())

if (tag != null) {
selc.add(AppTagsTable.TableColumns.tagId + " = ?")
args.add(tag.id.toString())
selc.add(AppTagsTable.TableColumns.appId + " = " + AppListTable.TableColumns.appId)
}

val selection = TextUtils.join(" AND ", selc)
val selectionArgs = args.toTypedArray()

var cr: Cursor? = null
try {
cr = contentProviderClient.query(DbContentProvider.appsContentUri(tag),
AppListTable.projection, selection, selectionArgs, null
)
} catch (e: RemoteException) {
AppLog.e(e)
}
return AppListCursor(cr)
}

fun getCount(includeDeleted: Boolean): Int {
val cr = queryAll(includeDeleted)
return cr.count
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/anod/appwatcher/details/AppDetailsView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ class AppDetailsView(view: View, private val dataProvider: AppViewHolderBase.Dat
val appChange = dataProvider.appChangeContentProvider.query(app.appId, app.versionNumber)
this.recentChanges?.text = if (appChange?.details?.isBlank() != false) dataProvider.noRecentChangesText else Html.parse(appChange.details)
}
app.recentFlag -> {
version?.text = dataProvider.formatVersionText(app.versionName, app.versionNumber)
this.recentChanges?.visibility = View.VISIBLE
val appChange = dataProvider.appChangeContentProvider.query(app.appId, app.versionNumber)
this.recentChanges?.text = if (appChange?.details?.isBlank() != false) dataProvider.noRecentChangesText else Html.parse(appChange.details)
}
else -> {
version?.text = dataProvider.formatVersionText(app.versionName, app.versionNumber)
this.recentChanges?.visibility = View.GONE
Expand Down
29 changes: 17 additions & 12 deletions src/main/java/com/anod/appwatcher/model/AppInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,19 @@ class AppInfo : AppInfoMetadata, Parcelable {
val priceCur: String
val priceMicros: Int?
val iconUrl: String
val refreshTime: Long
val uploadTime: Long
val appType: String
val syncVersion: Int
val refreshTime: Long
val recentFlag: Boolean

private constructor(rowId: Int, packageName: String, versionCode: Int, versionName: String, title: String, iconUrl: String, status: Int, uploadDate: String)
: this(rowId, packageName, packageName, versionCode, versionName, title, null, iconUrl,
status, uploadDate, null, null, 0, createDetailsUrl(packageName), 0, "", 0)
status, uploadDate, null, null, 0, createDetailsUrl(packageName), 0, "", 0, false)

constructor(rowId: Int, appId: String, pname: String, versionNumber: Int, versionName: String,
title: String, creator: String?, iconUrl: String, status: Int, uploadDate: String,
priceText: String?, priceCur: String?, priceMicros: Int?, detailsUrl: String,
refreshTime: Long, appType: String, syncVersion: Int) : super(appId, status) {
uploadTime: Long, appType: String, refreshTime: Long, recentFlag: Boolean) : super(appId, status) {
this.rowId = rowId
this.packageName = pname
this.versionNumber = versionNumber
Expand All @@ -63,9 +64,10 @@ class AppInfo : AppInfoMetadata, Parcelable {
this.detailsUrl = detailsUrl

this.iconUrl = iconUrl
this.refreshTime = refreshTime
this.uploadTime = uploadTime
this.appType = appType
this.syncVersion = syncVersion
this.refreshTime = refreshTime
this.recentFlag = recentFlag
}

constructor(doc: Document) : this(0, AppInfoMetadata.STATUS_NORMAL, doc)
Expand All @@ -90,8 +92,9 @@ class AppInfo : AppInfoMetadata, Parcelable {
this.priceCur = offer.currencyCode ?: ""

this.iconUrl = doc.iconUrl ?: ""
this.refreshTime = doc.extractUploadDate()
this.syncVersion = 0
this.uploadTime = doc.extractUploadDate()
this.refreshTime = System.currentTimeMillis()
this.recentFlag = true
}

constructor(`in`: Parcel) : super(`in`.readString(), `in`.readInt()) {
Expand All @@ -109,9 +112,10 @@ class AppInfo : AppInfoMetadata, Parcelable {
detailsUrl = `in`.readString()

iconUrl = `in`.readString()
refreshTime = `in`.readLong()
uploadTime = `in`.readLong()
appType = `in`.readString()
syncVersion = `in`.readInt()
refreshTime = `in`.readLong()
recentFlag = `in`.readInt() == 1
}

override fun describeContents(): Int {
Expand All @@ -135,9 +139,10 @@ class AppInfo : AppInfoMetadata, Parcelable {
dest.writeString(detailsUrl)

dest.writeString(iconUrl)
dest.writeLong(refreshTime)
dest.writeLong(uploadTime)
dest.writeString(appType)
dest.writeInt(syncVersion)
dest.writeLong(refreshTime)
dest.writeInt(if (recentFlag) 1 else 0)
}

companion object {
Expand Down
Loading

0 comments on commit aac13c1

Please sign in to comment.