Added clarifying tooltips and captions

This commit is contained in:
Viktor De Pasquale 2019-11-01 18:12:52 +01:00
parent fe5c65d798
commit 6720725d27
3 changed files with 30 additions and 9 deletions

View File

@ -14,10 +14,7 @@ import androidx.annotation.DrawableRes
import androidx.appcompat.widget.AppCompatImageView import androidx.appcompat.widget.AppCompatImageView
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.core.animation.doOnEnd import androidx.core.animation.doOnEnd
import androidx.core.view.isInvisible import androidx.core.view.*
import androidx.core.view.isVisible
import androidx.core.view.postDelayed
import androidx.core.view.updateLayoutParams
import androidx.databinding.BindingAdapter import androidx.databinding.BindingAdapter
import androidx.databinding.InverseBindingAdapter import androidx.databinding.InverseBindingAdapter
import androidx.databinding.InverseBindingListener import androidx.databinding.InverseBindingListener
@ -409,3 +406,8 @@ fun MaterialCardView.setCardStrokeWidthBound(stroke: Float) {
fun Toolbar.setOnMenuClickListener(listener: Toolbar.OnMenuItemClickListener) { fun Toolbar.setOnMenuClickListener(listener: Toolbar.OnMenuItemClickListener) {
setOnMenuItemClickListener(listener) setOnMenuItemClickListener(listener)
} }
@BindingAdapter("tooltipText")
fun View.setTooltipTextCompat(text: String) {
ViewCompat.setTooltipText(this, text)
}

View File

@ -23,7 +23,8 @@
android:alpha="@{item.isEnabled() ? 1f : .5f}" android:alpha="@{item.isEnabled() ? 1f : .5f}"
android:onClick="@{() -> item.toggle(viewModel)}" android:onClick="@{() -> item.toggle(viewModel)}"
tools:layout_marginBottom="@dimen/l1" tools:layout_marginBottom="@dimen/l1"
tools:layout_marginEnd="@dimen/l1"> tools:layout_marginEnd="@dimen/l1"
tools:layout_width="200dp">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -87,12 +88,15 @@
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/package_name"> app:layout_constraintTop_toBottomOf="@+id/package_name"
tools:visibility="visible">
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/bell" android:id="@+id/bell"
style="?styleIconNormal" style="?styleIconNormal"
isSelected="@{item.shouldNotify}" isSelected="@{item.shouldNotify}"
tooltipText="@{@string/superuser_toggle_notification}"
android:contentDescription="@string/superuser_toggle_notification"
android:onClick="@{() -> item.toggleNotify(viewModel)}" android:onClick="@{() -> item.toggleNotify(viewModel)}"
app:layout_constraintBottom_toTopOf="@+id/delete" app:layout_constraintBottom_toTopOf="@+id/delete"
app:layout_constraintEnd_toStartOf="@+id/bug" app:layout_constraintEnd_toStartOf="@+id/bug"
@ -107,6 +111,8 @@
android:id="@+id/bug" android:id="@+id/bug"
style="?styleIconNormal" style="?styleIconNormal"
isSelected="@{item.shouldLog}" isSelected="@{item.shouldLog}"
tooltipText="@{@string/superuser_toggle_log}"
android:contentDescription="@string/superuser_toggle_log"
android:onClick="@{() -> item.toggleLog(viewModel)}" android:onClick="@{() -> item.toggleLog(viewModel)}"
app:layout_constraintBottom_toBottomOf="@+id/bell" app:layout_constraintBottom_toBottomOf="@+id/bell"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
@ -115,15 +121,24 @@
app:srcCompat="@drawable/ic_bug_report" app:srcCompat="@drawable/ic_bug_report"
app:tint="@color/color_error_primary_transient" /> app:tint="@color/color_error_primary_transient" />
<androidx.appcompat.widget.AppCompatImageView <com.google.android.material.button.MaterialButton
android:id="@+id/delete" android:id="@+id/delete"
style="?styleIconError" style="?styleButtonText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="@{() -> viewModel.deletePressed(item)}" android:onClick="@{() -> viewModel.deletePressed(item)}"
android:text="@string/superuser_toggle_revoke"
android:textAllCaps="false"
android:textColor="?colorError"
android:textSize="12sp"
app:icon="@drawable/ic_delete_md2"
app:iconPadding="@dimen/l_50"
app:iconTint="?colorError"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/bell" app:layout_constraintTop_toBottomOf="@+id/bell"
app:srcCompat="@drawable/ic_delete_md2" /> app:rippleColor="?colorError" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -70,4 +70,8 @@
<string name="module_safe_mode_message">You\'re in safe mode. None of user modules will work.\nThis message will disappear once safe mode is disabled.</string> <string name="module_safe_mode_message">You\'re in safe mode. None of user modules will work.\nThis message will disappear once safe mode is disabled.</string>
<string name="superuser_toggle_log">Toggles logging</string>
<string name="superuser_toggle_notification">Toggles “toast” notifications</string>
<string name="superuser_toggle_revoke">Revoke</string>
</resources> </resources>