Merge pull request #13 from HabitRPG/hafiz/text_action_chip-fixes

TextActionChip updates
This commit is contained in:
Phillip Thelen 2022-07-18 19:36:59 +02:00 committed by GitHub
commit 19456dd357
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 57 additions and 45 deletions

View file

@ -13,6 +13,7 @@ import com.habitrpg.android.habitica.databinding.ActivitySettingsBinding
import com.habitrpg.wearos.habitica.ui.adapters.SettingsAdapter
import com.habitrpg.wearos.habitica.ui.adapters.SettingsItem
import com.habitrpg.wearos.habitica.ui.viewmodels.SettingsViewModel
import com.habitrpg.wearos.habitica.ui.views.TextActionChipView
import com.habitrpg.wearos.habitica.util.HabiticaScrollingLayoutCallback
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch
@ -104,12 +105,12 @@ class SettingsActivity: BaseActivity<ActivitySettingsBinding, SettingsViewModel>
private fun showLogoutConfirmation() {
val logoutDialog = Dialog(this)
val myLayout = layoutInflater.inflate(R.layout.logout_layout, null)
val positiveButton: Button = myLayout.findViewById(R.id.logout_button)
val positiveButton: TextActionChipView = myLayout.findViewById(R.id.logout_button)
positiveButton.setOnClickListener {
logout()
logoutDialog.dismiss()
}
val negativeButton: Button = myLayout.findViewById(R.id.cancel_button)
val negativeButton: TextActionChipView = myLayout.findViewById(R.id.cancel_button)
negativeButton.setOnClickListener {
logoutDialog.dismiss()
}

View file

@ -34,7 +34,7 @@ class TaskFormActivity : BaseActivity<ActivityTaskFormBinding, TaskFormViewModel
else -> R.string.task
})
binding.confirmationTitle.text = getString(R.string.new_task_x, typeName)
binding.saveButton.text = getString(R.string.save_task_x, typeName)
binding.saveButton.setChipText(getString(R.string.save_task_x, typeName))
}
override val viewModel: TaskFormViewModel by viewModels()

View file

@ -24,4 +24,8 @@ class TextActionChipView @JvmOverloads constructor(context: Context, attrs: Attr
binding.chipTextview.text = chipText
binding.chipImageview.setImageDrawable(chipImage)
}
fun setChipText(text: String) {
binding.chipTextview.text = text
}
}

View file

@ -1,8 +1,8 @@
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -42,13 +42,14 @@
style="@style/Text.Body1"
android:layout_marginTop="5dp"
android:textSize="12sp"/>
<Button
<com.habitrpg.wearos.habitica.ui.views.TextActionChipView
android:id="@+id/edit_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/ChipButton.Icon"
android:drawableStart="@drawable/handoff"
android:text="@string/edit_on_phone"
android:layout_marginTop="12dp"/>
android:layout_marginTop="12dp"
app:chipImage="@drawable/handoff"
app:chipText="@string/edit_on_phone" />
</LinearLayout>
</com.habitrpg.wearos.habitica.ui.views.HabiticaScrollView>

View file

@ -2,7 +2,8 @@
<com.habitrpg.wearos.habitica.ui.views.HabiticaScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
@ -30,22 +31,22 @@
android:textSize="14sp"
android:textColor="@color/watch_white"
/>
<Button
<com.habitrpg.wearos.habitica.ui.views.TextActionChipView
android:id="@+id/save_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/ChipButton.Icon"
android:text="@string/save"
app:chipImage="@drawable/save"
app:chipText="@string/save"
android:layout_marginTop="20dp"
android:layout_marginBottom="4dp"
android:drawableStart="@drawable/save"/>
<Button
android:layout_marginBottom="4dp"/>
<com.habitrpg.wearos.habitica.ui.views.TextActionChipView
android:id="@+id/edit_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/ChipButton.Icon"
android:text="@string/action_edit"
android:drawableStart="@drawable/edit"/>
app:chipImage="@drawable/edit"
app:chipText="@string/action_edit" />
</LinearLayout>
<LinearLayout
android:id="@+id/edit_task_wrapper"

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<com.habitrpg.wearos.habitica.ui.views.HabiticaScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:layout_width="match_parent"
@ -20,22 +21,21 @@
android:textColor="@color/watch_white"
android:layout_marginBottom="18dp"/>
<Button
android:id="@+id/logout_button"
style="@style/ChipButton.Icon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/spacing_small"
android:drawableStart="@drawable/logout"
android:text="@string/logout" />
<Button
android:id="@+id/cancel_button"
style="@style/ChipButton.Icon"
<com.habitrpg.wearos.habitica.ui.views.TextActionChipView
android:id="@+id/logout_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableStart="@drawable/cancel"
android:text="@string/action_cancel" />
app:chipImage="@drawable/logout"
app:chipText="@string/logout"
android:layout_marginBottom="4dp"/>
<com.habitrpg.wearos.habitica.ui.views.TextActionChipView
android:id="@+id/cancel_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:chipImage="@drawable/cancel"
app:chipText="@string/action_cancel" />
</LinearLayout>

View file

@ -19,16 +19,7 @@
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" />
style="@style/Text.TextActionChipTextView"/>
<ImageView
android:id="@+id/wear_chip_button"

View file

@ -85,4 +85,18 @@
<item name="android:textSize">14sp</item>
<item name="android:fontFamily">sans-serif</item>
</style>
<style name="Text.TextActionChipTextView">
<item name="android:layout_centerVertical">true</item>
<item name="android:layout_marginStart">37dp</item>
<item name="android:clickable">false</item>
<item name="android:duplicateParentState">true</item>
<item name="android:elevation">2dp</item>
<item name="android:fontFamily">sans-serif-medium</item>
<item name="android:letterSpacing">.01</item>
<item name="android:paddingHorizontal">10dp</item>
<item name="android:textColor">@color/watch_white</item>
<item name="android:textSize">14sp</item>
</style>
</resources>