Add instant build label

This commit is contained in:
Lucas Lima 2020-10-27 08:29:40 -03:00
parent 78c1935040
commit 72c26f4a58
2 changed files with 24 additions and 0 deletions

View file

@ -1,7 +1,9 @@
package dev.lucasnlm.antimine.about.views.info
import android.content.pm.PackageManager
import android.os.Bundle
import android.view.View
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import dev.lucasnlm.antimine.BuildConfig
import dev.lucasnlm.antimine.R
@ -25,6 +27,16 @@ class AboutInfoFragment : Fragment(R.layout.fragment_about_info) {
super.onViewCreated(view, savedInstanceState)
version.text = getString(R.string.version_s, BuildConfig.VERSION_NAME)
instant.isVisible = view.context.run {
try {
val info = packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA)
val bundle: Bundle = info.metaData
val appId = bundle.getInt(INSTANT_BUILD_FLAVOR, 0)
appId > 0
} catch (e: Exception) {
false
}
}
if (preferencesRepository.showSupport()) {
supportUs.setOnClickListener {
@ -46,4 +58,8 @@ class AboutInfoFragment : Fragment(R.layout.fragment_about_info) {
aboutViewModel.sendEvent(AboutEvent.Translators)
}
}
companion object {
private const val INSTANT_BUILD_FLAVOR = "com.google.android.gms.instant.flavor"
}
}

View file

@ -46,6 +46,14 @@
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="?android:attr/textColorPrimary"
tools:text="Version 7.1.0" />
<TextView
android:id="@+id/instant"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorSecondary"
android:text="Instant Build"
tools:ignore="HardcodedText" />
</LinearLayout>
<LinearLayout