mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-22 13:48:55 +00:00
Inform users on about screen that update is available
This commit is contained in:
parent
396b87ef40
commit
067d2ba609
6 changed files with 80 additions and 15 deletions
|
|
@ -5,7 +5,8 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:scrollbarSize="3dp"
|
||||
android:scrollbarThumbVertical="@color/scrollbarThumb"
|
||||
android:scrollbars="vertical">
|
||||
android:scrollbars="vertical"
|
||||
android:background="@color/white">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
@ -22,15 +23,55 @@
|
|||
android:layout_marginTop="20dp"
|
||||
android:src="@mipmap/ic_launcher" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/versionInfo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:layout_marginTop="@dimen/spacing_medium"
|
||||
android:textSize="@dimen/abc_text_size_small_material"
|
||||
tools:text="Version 1.0 (1)"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/update_available_wrapper"
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/layout_rounded_bg_gray_700"
|
||||
android:layout_marginTop="@dimen/spacing_small"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="@dimen/spacing_small"
|
||||
android:paddingBottom="@dimen/spacing_small">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/update_available_textview"
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="Update Available: 1.1"
|
||||
android:textStyle="bold"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/green_100"
|
||||
android:textSize="@dimen/card_medium_text"
|
||||
/>
|
||||
<TextView
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="See what's new"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/brand_300"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/twitter"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="10sp"
|
||||
android:layout_marginTop="20sp"
|
||||
android:autoLink="web"
|
||||
android:text="\@habitica"
|
||||
android:textSize="@dimen/abc_text_size_title_material" />
|
||||
android:textSize="@dimen/abc_text_size_medium_material" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/webSite"
|
||||
|
|
@ -112,14 +153,6 @@
|
|||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/abc_text_size_medium_material" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/versionInfo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:layout_marginTop="30sp"
|
||||
android:textSize="@dimen/abc_text_size_small_material"
|
||||
tools:text="Version 1.0 (1)"/>
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
|
@ -881,4 +881,5 @@
|
|||
<string name="checklist_text">Checklist Text</string>
|
||||
<string name="new_reminder">New reminder</string>
|
||||
<string name="streak">Streak</string>
|
||||
<string name="update_available">Update available: %1$s (%2$d)</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -24,5 +24,13 @@
|
|||
<key>enableLocalChanges</key>
|
||||
<value>true</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>lastVersionNumber</key>
|
||||
<value></value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>lastVersionCode</key>
|
||||
<value>0</value>
|
||||
</entry>
|
||||
</defaultsMap>
|
||||
<!-- END xml_defaults -->
|
||||
|
|
@ -44,4 +44,12 @@ class RemoteConfigManager {
|
|||
fun enableLocalChanges(): Boolean {
|
||||
return remoteConfig.getBoolean("enableLocalChanges")
|
||||
}
|
||||
|
||||
fun lastVersionNumber(): String {
|
||||
return remoteConfig.getString("lastVersionNumber")
|
||||
}
|
||||
|
||||
fun lastVersionCode(): Long {
|
||||
return remoteConfig.getLong("lastVersionCode")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ class AvatarView : View {
|
|||
.build()
|
||||
|
||||
val draweeHolder = DraweeHolder.create(hierarchy, context)
|
||||
draweeHolder.topLevelDrawable.callback = this
|
||||
draweeHolder.topLevelDrawable?.callback = this
|
||||
multiDraweeHolder.add(draweeHolder)
|
||||
|
||||
val controller = Fresco.newDraweeControllerBuilder()
|
||||
|
|
@ -134,7 +134,7 @@ class AvatarView : View {
|
|||
anim: Animatable?) {
|
||||
if (imageInfo != null) {
|
||||
if (multiDraweeHolder.size() > layerNumber) {
|
||||
multiDraweeHolder.get(layerNumber).topLevelDrawable.bounds = getLayerBounds(layerKey, layerName, imageInfo)
|
||||
multiDraweeHolder.get(layerNumber).topLevelDrawable?.bounds = getLayerBounds(layerKey, layerName, imageInfo)
|
||||
}
|
||||
onLayerComplete()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,10 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.animation.AccelerateInterpolator
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.core.net.toUri
|
||||
import com.google.firebase.analytics.FirebaseAnalytics
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.components.AppComponent
|
||||
import com.habitrpg.android.habitica.data.UserRepository
|
||||
|
|
@ -20,6 +22,7 @@ import com.habitrpg.android.habitica.helpers.RemoteConfigManager
|
|||
import com.habitrpg.android.habitica.models.user.User
|
||||
import com.habitrpg.android.habitica.modules.AppModule
|
||||
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
|
||||
import com.habitrpg.android.habitica.ui.helpers.bindView
|
||||
import com.plattysoft.leonids.ParticleSystem
|
||||
import kotlinx.android.synthetic.main.fragment_about.*
|
||||
import javax.inject.Inject
|
||||
|
|
@ -34,6 +37,9 @@ class AboutFragment : BaseMainFragment() {
|
|||
@Inject
|
||||
lateinit var remoteConfigManager: RemoteConfigManager
|
||||
|
||||
private val updateAvailableWrapper: ViewGroup by bindView(R.id.update_available_wrapper)
|
||||
private val updateAvailableTextView: TextView by bindView(R.id.update_available_textview)
|
||||
|
||||
override fun injectFragment(component: AppComponent) {
|
||||
component.inject(this)
|
||||
}
|
||||
|
|
@ -50,8 +56,8 @@ class AboutFragment : BaseMainFragment() {
|
|||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
super.onCreateView(inflater, container, savedInstanceState)
|
||||
this.hidesToolbar = true
|
||||
super.onCreateView(inflater, container, savedInstanceState)
|
||||
return inflater.inflate(R.layout.fragment_about, container, false)
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +70,7 @@ class AboutFragment : BaseMainFragment() {
|
|||
1 -> context.notNull { context ->
|
||||
Toast.makeText(context, "Oh! You tapped me!", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
in 4..7 -> context.notNull { context ->
|
||||
in 5..7 -> context.notNull { context ->
|
||||
Toast.makeText(context, "Only ${8 - versionNumberTappedCount} taps left!", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
8 -> {
|
||||
|
|
@ -100,12 +106,20 @@ class AboutFragment : BaseMainFragment() {
|
|||
|
||||
versionInfo.text = getString(R.string.version_info, versionName, versionCode)
|
||||
|
||||
if (remoteConfigManager.lastVersionCode() > versionCode) {
|
||||
updateAvailableWrapper.visibility = View.VISIBLE
|
||||
updateAvailableTextView.text = getString(R.string.update_available, remoteConfigManager.lastVersionNumber(), remoteConfigManager.lastVersionCode())
|
||||
} else {
|
||||
updateAvailableWrapper.visibility = View.GONE
|
||||
}
|
||||
|
||||
sourceCodeLink.setOnClickListener { openBrowserLink(androidSourceCodeLink) }
|
||||
twitter.setOnClickListener { openBrowserLink(twitterLink) }
|
||||
sourceCodeButton.setOnClickListener { openBrowserLink(androidSourceCodeLink) }
|
||||
reportBug.setOnClickListener { sendEmail("[Android] Bugreport") }
|
||||
sendFeedback.setOnClickListener { sendEmail("[Android] Feedback") }
|
||||
googlePlayStoreButton.setOnClickListener { openGooglePlay() }
|
||||
updateAvailableWrapper.setOnClickListener { openGooglePlay() }
|
||||
}
|
||||
|
||||
private fun openBrowserLink(url: String) {
|
||||
|
|
@ -142,6 +156,7 @@ class AboutFragment : BaseMainFragment() {
|
|||
}
|
||||
|
||||
private fun doTheThing() {
|
||||
context?.let { FirebaseAnalytics.getInstance(it).logEvent("found_easter_egg", null) }
|
||||
DataBindingUtils.loadImage("Pet-Sabretooth-Base") {bitmap ->
|
||||
activity?.runOnUiThread {
|
||||
activity.notNull {
|
||||
|
|
|
|||
Loading…
Reference in a new issue