Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f766745e authored by Moez Bhatti's avatar Moez Bhatti
Browse files

Store changelog locally

#1708
parent 48a0803b
Loading
Loading
Loading
Loading
+272 −0
Original line number Diff line number Diff line
[
  {
    "versionCode": "2218",
    "versionName": "3.9.4",
    "fixed": [
      "Incorrect handling of shared text that contains a question mark"
    ]
  },
  {
    "versionCode": "2217",
    "versionName": "3.9.3",
    "improved": [
      "Message sync is now 2x faster"
    ]
  },
  {
    "versionCode": "2216",
    "versionName": "3.9.2",
    "fixed": [
      "Crash when launching app in 3.9.1"
    ]
  },
  {
    "versionCode": "2215",
    "versionName": "3.9.1",
    "improved": [
      "Support SMS URIs that only have a body"
    ],
    "fixed": [
      "Slowness introduced in 3.9.0"
    ]
  },
  {
    "versionCode": "2214",
    "versionName": "3.9.0",
    "added": [
      "Auto-delete old messages",
      "Block/archive messages from notification",
      "Swipe to block conversation",
      "Share vCard from other apps"
    ],
    "improved": [
      "Better visibility for conversations with drafts",
      "Remember send-as-group preference",
      "Shorten \"mark read\" string for notification actions",
      "Clarify delayed message durations",
      "Trim whitespace when searching",
      "Line count limit for contact groups in compose screen",
      "Buzz and show warning when SIM is changed",
      "Removed Mixpanel"
    ],
    "fixed": [
      "Incorrect selection state when picking contact phone number",
      "Max height for QK dialog",
      "Duplicate phone numbers when multiple contacts apps are installed",
      "Swipe state gets stuck when marking read conversation as read again",
      "Titles and special characters included in contact's initials",
      "Subject text not included when sharing",
      "Message history not appearing",
      "Dismiss notification for failed message not working",
      "Incorrect padding for SIM selector",
      "Incorrect padding for contact search",
      "Incorrect empty state for messasge search",
      "Pressing enter creates line break when searching",
      "Crash when composing message",
      "Scheduled message date picker can be blocked by keyboard",
      "Cursor set to wrong position when cancelling message",
      "Can't share to group via Simple Contacts",
      "\"View more conversations\" button on widget broken"
    ]
  },
  {
    "versionCode": "2213",
    "versionName": "3.8.1",
    "fixed": [
      "MMS not sending",
      "Crash when deleting conversation",
      "Crash on startup when upgrading from old version",
      "Contact Groups not showing up in some cases"
    ]
  },
  {
    "versionCode": "2212",
    "versionName": "3.8.0",
    "improved": [
      "Updated translations"
    ]
  },
  {
    "versionCode": "2211",
    "versionName": "3.8.0-beta2",
    "fixed": [
      "Crash when starting new conversation",
      "Swipe actions not working"
    ]
  },
  {
    "versionCode": "2210",
    "versionName": "3.8.0-beta1",
    "added": [
      "Support for Contact Groups and Starred Contacts",
      "Wake screen setting",
      "Per-contact colours",
      "Automatic colours",
      "Option to send long messages as MMS",
      "Long-press recipient to copy phone number",
      "Copy text from multiple messages",
      "Share photos externally"
    ],
    "improved": [
      "Redesigned compose message screen",
      "Redesigned avatars",
      "More reliable contact photo loading",
      "Custom colours for contacts will appear everywhere, not just inside the conversation",
      "More intuitive unicode stripping",
      "Make drafts easier to find",
      "Faster scrolling performance everywhere",
      "Increased max signature length"
    ],
    "fixed": [
      "Sent attachments are always low quality",
      "Not receiving all MMS",
      "Contact name/photo might be out of sync with contacts app",
      "MMS might appear in the wrong thread",
      "Duplicate phone numbers appear when Whatsapp is installed",
      "Can't share to multiple people via another app",
      "Body not parsed correctly in SMS Uri",
      "Notification sounds not working on Android 7",
      "Sometimes can't add number to contacts",
      "Default SMS \"CHANGE\" button sometimes doesn't work",
      "24h timestamps don't work correctly when language set to Japanese",
      "Conversation details page slow when there are lots of attachments"
    ]
  },
  {
    "versionCode": "2209",
    "versionName": "3.7.10",
    "improved": [
      "Include archived conversations in search results",
      "Allow manually blocking non-numeric addresses"
    ],
    "fixed": [
      "MMS appear to have sent, but they haven't",
      "New conversations sometimes don't appear"
    ]
  },
  {
    "versionCode": "2208",
    "versionName": "3.7.9",
    "improved": [
      "Better reliability for sending MMS"
    ],
    "fixed": [
      "Fixed delayed messages getting stuck \"Sending...\""
    ]
  },
  {
    "versionCode": "2207",
    "versionName": "3.7.8",
    "fixed": [
      "Contact not always linked to conversation",
      "Wrong colour for disabled preference icons",
      "Multiple crashes"
    ]
  },
  {
    "versionCode": "2206",
    "versionName": "3.7.7",
    "fixed": [
      "New conversations may not appear in inbox"
    ]
  },
  {
    "versionCode": "2204",
    "versionName": "3.7.5",
    "added": [
      "Added ability to retry sending failed MMS"
    ],
    "improved": [
      "Show hint for signature setting",
      "Keep widget more up-to-date",
      "Improve MMS support for Dual-SIM phones",
      "Display sent time for incoming MMS",
      "Improve MMS sending reliability"
    ],
    "fixed": [
      "Contacts sometimes not linked to conversation correctly",
      "Sometimes can't save multiple attachments to phone"
    ]
  },
  {
    "versionCode": "2203",
    "versionName": "3.7.4",
    "added": [
      "Support for Android Q Roles"
    ],
    "improved": [
      "Use theme color for text cursor",
      "Better matching between phone number and conversation"
    ],
    "fixed": [
      "Messages often stuck \"Sending...\"",
      "Short codes won't show up as valid number when composing new message"
    ]
  },
  {
    "versionCode": "2202",
    "versionName": "3.7.3",
    "added": [
      "You can now view attachments of any filetype"
    ],
    "improved": [
      "Improve search for contacts with accents in their names",
      "Custom labels for phone numbers will show the custom text",
      "Include MMS in search results",
      "Made it easier to access blocked numbers list",
      "Added option to add number to contacts from main conversation list",
      "Conversations with drafts will be indicated appropriately in conversation list",
      "You can now copy text from a scheduled message",
      "Show blocking reason for numbers blocked via Call Control"
    ],
    "fixed": [
      "Can't open vCard attachments",
      "Phone number gets blocked when it shouldn't",
      "Icon gets stretched when swiping conversation",
      "Can't forward text in MMS message"
    ]
  },
  {
    "versionCode": "2201",
    "versionName": "3.7.2",
    "fixed": [
      "Various crashes from 3.7.1"
    ]
  },
  {
    "versionCode": "2200",
    "versionName": "3.7.1",
    "fixed": [
      "Various crashes from 3.7.0"
    ]
  },
  {
    "versionCode": "2198",
    "versionName": "3.6.8",
    "fixed": [
      "Messages can't be sent or received on older devices",
      "Norweigan translations not working"
    ]
  },
  {
    "versionCode": "2197",
    "versionName": "3.6.7",
    "added": [
      "Signature support",
      "System dark mode support for Android Q"
    ],
    "improved": [
      "You'll be asked for storage permission before trying to save a photo if necessary",
      "Smaller download size",
      "Load high resolution contact photos"
    ],
    "fixed": [
      "Contact photos never update",
      "Can't create new conversation on Huawei devices",
      "Can't receive MMS on Xiaomi devices",
      "Visual glitch on compose bar in night mode",
      "Theme doesn't update in preview after going back to settings",
      "Search hint gets cut off after rotating screen"
    ]
  }
]
+25 −85
Original line number Diff line number Diff line
@@ -24,14 +24,14 @@ import com.moez.QKSMS.util.Preferences
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
import io.reactivex.Single
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import okhttp3.Call
import okhttp3.Callback
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import java.io.IOException
import javax.inject.Inject
@@ -44,54 +44,24 @@ class ChangelogManagerImpl @Inject constructor(

    override fun didUpdate(): Boolean = prefs.changelogVersion.get() != context.versionCode

    override fun getChangelog(): Single<ChangelogManager.Changelog> {
        val url = "https://firestore.googleapis.com/v1/projects/qksms-app/databases/(default)/documents/changelog"
        val request = url.toHttpUrlOrNull()?.let { Request.Builder().url(it).build() }
        val call = request?.let { OkHttpClient().newCall(it) }
        val adapter = moshi.adapter(ChangelogResponse::class.java)
    override suspend fun getChangelog(): ChangelogManager.CumulativeChangelog {
        val listType = Types.newParameterizedType(List::class.java, Changeset::class.java)
        val adapter = moshi.adapter<List<Changeset>>(listType)

        return Single
                .create<Response> { emitter ->
                    call?.enqueue(object : Callback {
                        override fun onResponse(call: Call, response: Response) {
                            if (!emitter.isDisposed) {
                                emitter.onSuccess(response)
                            }
        return withContext(Dispatchers.IO) {
            val changelogs = context.assets.open("changelog.json").bufferedReader().use { it.readText() }
                    .let(adapter::fromJson)
                    .orEmpty()
                    .sortedBy { changelog -> changelog.versionCode }
                    .filter { changelog ->
                        changelog.versionCode in prefs.changelogVersion.get().inc()..context.versionCode
                    }

                        override fun onFailure(call: Call, e: IOException) {
                            if (!emitter.isDisposed) {
                                emitter.onError(e)
                            }
                        }
                    })
                    emitter.setCancellable {
                        call?.cancel()
                    }
                }
                .map { response -> response.body?.string()?.let(adapter::fromJson) }
                .map { response ->
                    response.documents
                            .sortedBy { document -> document.fields.versionCode.value }
                            .filter { document ->
                                val range = (prefs.changelogVersion.get() + 1)..context.versionCode
                                document.fields.versionCode.value.toInt() in range
                            }
                }
                .map { documents ->
                    val added = documents.fold(listOf<String>()) { acc, document ->
                        acc + document.fields.added?.value?.values?.map { value -> value.value }.orEmpty()
            ChangelogManager.CumulativeChangelog(
                    added = changelogs.fold(listOf()) { acc, changelog -> acc + changelog.added.orEmpty()},
                    improved = changelogs.fold(listOf()) { acc, changelog -> acc + changelog.improved.orEmpty()},
                    fixed = changelogs.fold(listOf()) { acc, changelog -> acc + changelog.fixed.orEmpty()})
        }
                    val improved = documents.fold(listOf<String>()) { acc, document ->
                        acc + document.fields.improved?.value?.values?.map { value -> value.value }.orEmpty()
                    }
                    val fixed = documents.fold(listOf<String>()) { acc, document ->
                        acc + document.fields.fixed?.value?.values?.map { value -> value.value }.orEmpty()
                    }
                    ChangelogManager.Changelog(added, improved, fixed)
                }
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
    }

    override fun markChangelogSeen() {
@@ -99,42 +69,12 @@ class ChangelogManagerImpl @Inject constructor(
    }

    @JsonClass(generateAdapter = true)
    data class ChangelogResponse(
        @Json(name = "documents") val documents: List<Document>
    )

    @JsonClass(generateAdapter = true)
    data class Document(
        @Json(name = "fields") val fields: Changelog
    )

    @JsonClass(generateAdapter = true)
    data class Changelog(
        @Json(name = "added") val added: ArrayField?,
        @Json(name = "improved") val improved: ArrayField?,
        @Json(name = "fixed") val fixed: ArrayField?,
        @Json(name = "versionName") val versionName: StringField,
        @Json(name = "versionCode") val versionCode: IntegerField
    )

    @JsonClass(generateAdapter = true)
    data class ArrayField(
        @Json(name = "arrayValue") val value: ArrayValues
    )

    @JsonClass(generateAdapter = true)
    data class ArrayValues(
        @Json(name = "values") val values: List<StringField>
    )

    @JsonClass(generateAdapter = true)
    data class StringField(
        @Json(name = "stringValue") val value: String
    )

    @JsonClass(generateAdapter = true)
    data class IntegerField(
        @Json(name = "integerValue") val value: String
    data class Changeset(
        @Json(name = "added") val added: List<String>?,
        @Json(name = "improved") val improved: List<String>?,
        @Json(name = "fixed") val fixed: List<String>?,
        @Json(name = "versionName") val versionName: String,
        @Json(name = "versionCode") val versionCode: Int
    )

}
+2 −4
Original line number Diff line number Diff line
@@ -18,11 +18,9 @@
 */
package com.moez.QKSMS.manager

import io.reactivex.Single

interface ChangelogManager {

    data class Changelog(
    data class CumulativeChangelog(
        val added: List<String>,
        val improved: List<String>,
        val fixed: List<String>
@@ -33,7 +31,7 @@ interface ChangelogManager {
     */
    fun didUpdate(): Boolean

    fun getChangelog(): Single<Changelog>
    suspend fun getChangelog(): CumulativeChangelog

    fun markChangelogSeen()

+4 −4
Original line number Diff line number Diff line
@@ -32,21 +32,21 @@ class ChangelogAdapter(private val context: Context) : QkAdapter<ChangelogAdapte

    data class ChangelogItem(val type: Int, val label: String)

    fun setChangelog(changelog: ChangelogManager.Changelog) {
    fun setChangelog(changelog: ChangelogManager.CumulativeChangelog) {
        val changes = mutableListOf<ChangelogItem>()
        if (changelog.added.isNotEmpty()) {
            changes += ChangelogItem(0, context.getString(R.string.changelog_added))
            changes += changelog.added.map { change -> ChangelogItem(1, change) }
            changes += changelog.added.map { change -> ChangelogItem(1, "• $change") }
            changes += ChangelogItem(0, "")
        }
        if (changelog.improved.isNotEmpty()) {
            changes += ChangelogItem(0, context.getString(R.string.changelog_improved))
            changes += changelog.improved.map { change -> ChangelogItem(1, change) }
            changes += changelog.improved.map { change -> ChangelogItem(1, "• $change") }
            changes += ChangelogItem(0, "")
        }
        if (changelog.fixed.isNotEmpty()) {
            changes += ChangelogItem(0, context.getString(R.string.changelog_fixed))
            changes += changelog.fixed.map { change -> ChangelogItem(1, change) }
            changes += changelog.fixed.map { change -> ChangelogItem(1, "• $change") }
            changes += ChangelogItem(0, "")
        }
        data = changes
+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ class ChangelogDialog(activity: MainActivity) {
        layout.dismiss.setOnClickListener { dialog.dismiss() }
    }

    fun show(changelog: ChangelogManager.Changelog) {
    fun show(changelog: ChangelogManager.CumulativeChangelog) {
        adapter.setChangelog(changelog)
        dialog.show()
    }
Loading