mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
Improve phone communication handling
This commit is contained in:
parent
0eb876569b
commit
d5a3bb5635
9 changed files with 43 additions and 14 deletions
|
|
@ -1174,7 +1174,6 @@
|
|||
<string name="successful_purchase_generic">Purchase successful</string>
|
||||
<string name="starting_objectives">Starting Objectives</string>
|
||||
<string name="switch_class">Switch Class</string>
|
||||
<string name="task_container_name">task_container_name</string>
|
||||
<string name="onboarding_objectives">Starting Objectives</string>
|
||||
<string name="task_list_mode">Task list mode</string>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
NAME=4.0
|
||||
CODE=4250
|
||||
CODE=4260
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
android:required="true" />
|
||||
<meta-data
|
||||
android:name="com.google.android.wearable.standalone"
|
||||
android:value="true" />
|
||||
android:value="false" />
|
||||
|
||||
<activity
|
||||
android:name="com.habitrpg.wearos.habitica.ui.activities.MainActivity"
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class LoginActivity: BaseActivity<ActivityLoginBinding, LoginViewModel>() {
|
|||
binding.signInOnPhoneButton.isVisible = false
|
||||
binding.otherButton.isVisible = false
|
||||
binding.googleLoginButton.isVisible = true
|
||||
binding.registerButton.isVisible = true
|
||||
binding.registerButton.isVisible = binding.registerButton.isEnabled
|
||||
binding.usernamePasswordButton.isVisible = true
|
||||
binding.usernameEditText.isVisible = false
|
||||
binding.passwordEditText.isVisible = false
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
package com.habitrpg.wearos.habitica.ui.views
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import androidx.core.view.isVisible
|
||||
import com.google.android.gms.tasks.Tasks
|
||||
import com.google.android.gms.wearable.CapabilityClient
|
||||
import com.google.android.gms.wearable.Wearable
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class ConnectedActionChipView(context: Context, attrs: AttributeSet? = null) :
|
||||
TextActionChipView(context, attrs) {
|
||||
private val capabilityClient: CapabilityClient by lazy { Wearable.getCapabilityClient(context) }
|
||||
|
||||
init {
|
||||
checkIfPhoneAvailable()
|
||||
}
|
||||
|
||||
private fun checkIfPhoneAvailable() {
|
||||
MainScope().launch(Dispatchers.IO) {
|
||||
val result = Tasks.await(capabilityClient.getCapability("open_activity", CapabilityClient.FILTER_REACHABLE))
|
||||
launch(Dispatchers.Main) {
|
||||
isEnabled = result.nodes.firstOrNull { it.isNearby } != null
|
||||
isVisible = isEnabled
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ import com.habitrpg.android.habitica.R
|
|||
import com.habitrpg.android.habitica.databinding.TextActionChipBinding
|
||||
import com.habitrpg.common.habitica.extensions.layoutInflater
|
||||
|
||||
class TextActionChipView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
open class TextActionChipView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
RelativeLayout(context, attrs) {
|
||||
private val attributes = context.theme?.obtainStyledAttributes(
|
||||
attrs,
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
android:textColor="@color/watch_white"
|
||||
android:layout_marginBottom="18dp"/>
|
||||
|
||||
<com.habitrpg.wearos.habitica.ui.views.TextActionChipView
|
||||
<com.habitrpg.wearos.habitica.ui.views.ConnectedActionChipView
|
||||
android:id="@+id/sign_in_on_phone_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -66,7 +66,7 @@
|
|||
app:chipImage="@drawable/ic_keyboard"
|
||||
app:chipText="@string/sign_in_password" />
|
||||
|
||||
<com.habitrpg.wearos.habitica.ui.views.TextActionChipView
|
||||
<com.habitrpg.wearos.habitica.ui.views.ConnectedActionChipView
|
||||
android:id="@+id/register_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
<FrameLayout android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<com.habitrpg.wearos.habitica.ui.views.HabiticaScrollView
|
||||
android:id="@+id/scroll_view"
|
||||
android:orientation="vertical"
|
||||
|
|
@ -33,20 +34,19 @@
|
|||
android:textColor="@color/watch_white"
|
||||
style="@style/Text.SubHeader1"
|
||||
android:layout_marginBottom="@dimen/spacing_large"/>
|
||||
<Button
|
||||
<com.habitrpg.wearos.habitica.ui.views.TextActionChipView
|
||||
android:id="@+id/rya_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/review_dailies"
|
||||
style="@style/ChipButton.Purple"
|
||||
android:layout_marginBottom="@dimen/spacing_small"/>
|
||||
<Button
|
||||
<com.habitrpg.wearos.habitica.ui.views.ConnectedActionChipView
|
||||
android:id="@+id/phone_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/check_on_phone"
|
||||
android:drawableStart="@drawable/handoff"
|
||||
style="@style/ChipButton.Icon"/>
|
||||
app:chipImage="@drawable/handoff"
|
||||
app:chipText="@string/check_on_phone" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/task_view"
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
android:layout_marginTop="5dp"
|
||||
android:textSize="12sp"/>
|
||||
|
||||
<com.habitrpg.wearos.habitica.ui.views.TextActionChipView
|
||||
<com.habitrpg.wearos.habitica.ui.views.ConnectedActionChipView
|
||||
android:id="@+id/edit_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
|||
Loading…
Reference in a new issue