You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iceraven-browser/app/src/main/java/org/mozilla/fenix/whatsnew/WhatsNewVersion.kt

38 lines
1.1 KiB
Kotlin

package org.mozilla.fenix.whatsnew
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import android.content.Context
import mozilla.components.support.ktx.android.content.appVersionName
// This file is a modified port from Focus Android
/**
* Convenience class to deal with the application version number
* I opted to keep it contained to the whatsnew package. We may
* want to pull it
*/
open class WhatsNewVersion(internal open val version: String) {
override fun hashCode(): Int {
return version.hashCode()
}
override fun equals(other: Any?): Boolean {
if (other is WhatsNewVersion) {
return version == other.version
}
return false
}
val majorVersionNumber: Int
get() = version.split(".").first().toInt()
}
data class ContextWhatsNewVersion(private val context: Context) : WhatsNewVersion("") {
override val version: String
get() = context.appVersionName ?: ""
}