changed StatValue name -> StatValueView

Replace authentication buttons (Google sign in, sign in with passsword, create account, etc) with TextActionChipView (Icons 14dp left from left edge of chip, 24dp icon, text starts 46 dp from left edge of chip)
This commit is contained in:
Hafiz 2022-07-06 22:06:41 -04:00
parent 4b65ffc4f0
commit 1061b19035
8 changed files with 104 additions and 32 deletions

View file

@ -9,7 +9,7 @@ import com.habitrpg.android.habitica.databinding.StatValueLayoutBinding
import com.habitrpg.common.habitica.extensions.layoutInflater
import com.habitrpg.common.habitica.helpers.NumberAbbreviator
class StatValue @JvmOverloads constructor(
class StatValueView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyle: Int = 0

View file

@ -0,0 +1,27 @@
package com.habitrpg.wearos.habitica.ui.views
import android.content.Context
import android.util.AttributeSet
import android.widget.RelativeLayout
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) :
RelativeLayout(context, attrs) {
private val attributes = context.theme?.obtainStyledAttributes(
attrs,
R.styleable.TextActionChip,
0, 0
)
val binding = TextActionChipBinding.inflate(context.layoutInflater, this)
init {
val chipText = attributes?.getText(R.styleable.TextActionChip_chipText)
val chipImage = attributes?.getDrawable(R.styleable.TextActionChip_chipImage)
binding.chipTextview.text = chipText
binding.chipImageview.setImageDrawable(chipImage)
}
}

View file

@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="19dp"
android:height="18dp"
android:viewportWidth="24"
android:viewportHeight="19">
<path

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<com.habitrpg.wearos.habitica.ui.views.HabiticaScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
<com.habitrpg.wearos.habitica.ui.views.HabiticaScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -33,46 +33,46 @@
style="@style/Text.Body2"
android:textColor="@color/watch_white"
android:layout_marginBottom="18dp"/>
<Button
<com.habitrpg.wearos.habitica.ui.views.TextActionChipView
android:id="@+id/sign_in_on_phone_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/ChipButton.Icon"
android:text="@string/sign_in_on_phone"
android:drawableStart="@drawable/handoff"
android:layout_marginBottom="@dimen/spacing_small"/>
<Button
android:layout_marginBottom="4dp"
app:chipImage="@drawable/handoff"
app:chipText="@string/sign_in_on_phone" />
<com.habitrpg.wearos.habitica.ui.views.TextActionChipView
android:id="@+id/other_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/ChipButton.Icon"
android:drawableStart="@drawable/ic_keyboard"
android:text="@string/other_options"/>
android:layout_marginBottom="4dp"
app:chipImage="@drawable/ic_keyboard"
app:chipText="@string/other_options" />
<Button
<com.habitrpg.wearos.habitica.ui.views.TextActionChipView
android:id="@+id/google_login_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableStart="@drawable/google_icon"
android:text="@string/login_btn_google"
android:layout_marginBottom="@dimen/spacing_small"
style="@style/ChipButton.Icon"/>
<Button
android:layout_marginBottom="4dp"
app:chipImage="@drawable/google_icon"
app:chipText="@string/login_btn_google" />
<com.habitrpg.wearos.habitica.ui.views.TextActionChipView
android:id="@+id/username_password_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sign_in_password"
android:layout_marginBottom="@dimen/spacing_small"
android:drawableStart="@drawable/ic_keyboard"
style="@style/ChipButton.Icon"/>
<Button
android:layout_marginBottom="4dp"
app:chipImage="@drawable/ic_keyboard"
app:chipText="@string/sign_in_password" />
<com.habitrpg.wearos.habitica.ui.views.TextActionChipView
android:id="@+id/register_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/create_account"
android:drawableStart="@drawable/handoff"
style="@style/ChipButton.Icon"/>
android:layout_marginBottom="4dp"
app:chipImage="@drawable/handoff"
app:chipText="@string/create_account" />
<EditText
android:id="@+id/username_edit_text"

View file

@ -43,20 +43,20 @@
android:layout_centerInParent="true"
android:orientation="vertical">
<com.habitrpg.wearos.habitica.ui.views.StatValue
<com.habitrpg.wearos.habitica.ui.views.StatValueView
android:id="@+id/hp_stat_value"
android:layout_width="match_parent"
android:layout_marginTop="5dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"/>
<com.habitrpg.wearos.habitica.ui.views.StatValue
<com.habitrpg.wearos.habitica.ui.views.StatValueView
android:id="@+id/exp_stat_value"
android:layout_width="match_parent"
android:layout_marginBottom="8dp"
android:layout_height="wrap_content" />
<com.habitrpg.wearos.habitica.ui.views.StatValue
<com.habitrpg.wearos.habitica.ui.views.StatValueView
android:id="@+id/mp_stat_value"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

View file

@ -6,7 +6,7 @@
android:layout_height="30dp"
android:paddingStart="16dp"
android:paddingEnd="0dp"
tools:parentTag="com.habitrpg.wearos.habitica.ui.views.StatValue">
tools:parentTag="com.habitrpg.wearos.habitica.ui.views.StatValueView">
<View
android:id="@+id/view"

View file

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:layout_height="wrap_content"
tools:layout_width="match_parent"
tools:parentTag="com.habitrpg.wearos.habitica.ui.views.TextActionChipView">
<ImageView
android:id="@+id/chip_imageview"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerVertical="true"
android:layout_marginStart="14dp"
android:clickable="false"
android:duplicateParentState="true"
android:elevation="2dp" />
<TextView
android:id="@+id/chip_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="34dp"
android:clickable="false"
android:duplicateParentState="true"
android:elevation="2dp"
android:fontFamily="sans-serif-medium"
android:letterSpacing=".01"
android:paddingHorizontal="@dimen/row_padding_horizontal"
android:textColor="@color/watch_white"
android:textSize="14sp" />
<ImageView
android:id="@+id/wear_chip_button"
style="@style/ChipButton.Icon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="false"
android:duplicateParentState="true" />
</merge>

View file

@ -13,4 +13,8 @@
<attr name="ellipsis" format="string" />
<attr name="ellipsisColor" format="color" />
</declare-styleable>
<declare-styleable name="TextActionChip">
<attr name="chipText" format="string" />
<attr name="chipImage" format="reference" />
</declare-styleable>
</resources>