mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-13 17:51:57 +00:00
Merge pull request #12 from HabitRPG/hafiz/textActionChip
text action chip UI updates
This commit is contained in:
commit
9fb51d7bfe
8 changed files with 104 additions and 32 deletions
|
|
@ -9,7 +9,7 @@ import com.habitrpg.android.habitica.databinding.StatValueLayoutBinding
|
||||||
import com.habitrpg.common.habitica.extensions.layoutInflater
|
import com.habitrpg.common.habitica.extensions.layoutInflater
|
||||||
import com.habitrpg.common.habitica.helpers.NumberAbbreviator
|
import com.habitrpg.common.habitica.helpers.NumberAbbreviator
|
||||||
|
|
||||||
class StatValue @JvmOverloads constructor(
|
class StatValueView @JvmOverloads constructor(
|
||||||
context: Context,
|
context: Context,
|
||||||
attrs: AttributeSet? = null,
|
attrs: AttributeSet? = null,
|
||||||
defStyle: Int = 0
|
defStyle: Int = 0
|
||||||
|
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:width="24dp"
|
android:width="24dp"
|
||||||
android:height="19dp"
|
android:height="18dp"
|
||||||
android:viewportWidth="24"
|
android:viewportWidth="24"
|
||||||
android:viewportHeight="19">
|
android:viewportHeight="19">
|
||||||
<path
|
<path
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<com.habitrpg.wearos.habitica.ui.views.HabiticaScrollView
|
<com.habitrpg.wearos.habitica.ui.views.HabiticaScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
@ -33,46 +33,46 @@
|
||||||
style="@style/Text.Body2"
|
style="@style/Text.Body2"
|
||||||
android:textColor="@color/watch_white"
|
android:textColor="@color/watch_white"
|
||||||
android:layout_marginBottom="18dp"/>
|
android:layout_marginBottom="18dp"/>
|
||||||
<Button
|
|
||||||
|
<com.habitrpg.wearos.habitica.ui.views.TextActionChipView
|
||||||
android:id="@+id/sign_in_on_phone_button"
|
android:id="@+id/sign_in_on_phone_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
style="@style/ChipButton.Icon"
|
android:layout_marginBottom="4dp"
|
||||||
android:text="@string/sign_in_on_phone"
|
app:chipImage="@drawable/handoff"
|
||||||
android:drawableStart="@drawable/handoff"
|
app:chipText="@string/sign_in_on_phone" />
|
||||||
android:layout_marginBottom="@dimen/spacing_small"/>
|
|
||||||
<Button
|
<com.habitrpg.wearos.habitica.ui.views.TextActionChipView
|
||||||
android:id="@+id/other_button"
|
android:id="@+id/other_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
style="@style/ChipButton.Icon"
|
android:layout_marginBottom="4dp"
|
||||||
android:drawableStart="@drawable/ic_keyboard"
|
app:chipImage="@drawable/ic_keyboard"
|
||||||
android:text="@string/other_options"/>
|
app:chipText="@string/other_options" />
|
||||||
|
|
||||||
|
<com.habitrpg.wearos.habitica.ui.views.TextActionChipView
|
||||||
<Button
|
|
||||||
android:id="@+id/google_login_button"
|
android:id="@+id/google_login_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:drawableStart="@drawable/google_icon"
|
android:layout_marginBottom="4dp"
|
||||||
android:text="@string/login_btn_google"
|
app:chipImage="@drawable/google_icon"
|
||||||
android:layout_marginBottom="@dimen/spacing_small"
|
app:chipText="@string/login_btn_google" />
|
||||||
style="@style/ChipButton.Icon"/>
|
|
||||||
<Button
|
<com.habitrpg.wearos.habitica.ui.views.TextActionChipView
|
||||||
android:id="@+id/username_password_button"
|
android:id="@+id/username_password_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/sign_in_password"
|
android:layout_marginBottom="4dp"
|
||||||
android:layout_marginBottom="@dimen/spacing_small"
|
app:chipImage="@drawable/ic_keyboard"
|
||||||
android:drawableStart="@drawable/ic_keyboard"
|
app:chipText="@string/sign_in_password" />
|
||||||
style="@style/ChipButton.Icon"/>
|
|
||||||
<Button
|
<com.habitrpg.wearos.habitica.ui.views.TextActionChipView
|
||||||
android:id="@+id/register_button"
|
android:id="@+id/register_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/create_account"
|
android:layout_marginBottom="4dp"
|
||||||
android:drawableStart="@drawable/handoff"
|
app:chipImage="@drawable/handoff"
|
||||||
style="@style/ChipButton.Icon"/>
|
app:chipText="@string/create_account" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/username_edit_text"
|
android:id="@+id/username_edit_text"
|
||||||
|
|
|
||||||
|
|
@ -43,20 +43,20 @@
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<com.habitrpg.wearos.habitica.ui.views.StatValue
|
<com.habitrpg.wearos.habitica.ui.views.StatValueView
|
||||||
android:id="@+id/hp_stat_value"
|
android:id="@+id/hp_stat_value"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="8dp"/>
|
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:id="@+id/exp_stat_value"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:layout_height="wrap_content" />
|
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:id="@+id/mp_stat_value"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
android:layout_height="30dp"
|
android:layout_height="30dp"
|
||||||
android:paddingStart="16dp"
|
android:paddingStart="16dp"
|
||||||
android:paddingEnd="0dp"
|
android:paddingEnd="0dp"
|
||||||
tools:parentTag="com.habitrpg.wearos.habitica.ui.views.StatValue">
|
tools:parentTag="com.habitrpg.wearos.habitica.ui.views.StatValueView">
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/view"
|
android:id="@+id/view"
|
||||||
|
|
|
||||||
41
wearos/src/main/res/layout/text_action_chip.xml
Normal file
41
wearos/src/main/res/layout/text_action_chip.xml
Normal 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>
|
||||||
|
|
@ -13,4 +13,8 @@
|
||||||
<attr name="ellipsis" format="string" />
|
<attr name="ellipsis" format="string" />
|
||||||
<attr name="ellipsisColor" format="color" />
|
<attr name="ellipsisColor" format="color" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
<declare-styleable name="TextActionChip">
|
||||||
|
<attr name="chipText" format="string" />
|
||||||
|
<attr name="chipImage" format="reference" />
|
||||||
|
</declare-styleable>
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Reference in a new issue