Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dialog button style #1329

Merged
merged 5 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ import androidx.annotation.LayoutRes
import androidx.annotation.StringRes
import androidx.annotation.StyleRes
import androidx.appcompat.app.AlertDialog
import androidx.core.view.setMargins
import androidx.core.view.setPadding
import androidx.core.view.updateMargins
import androidx.fragment.app.Fragment
import network.loki.messenger.R
import org.thoughtcrime.securesms.util.toPx


@DslMarker
@Target(AnnotationTarget.CLASS, AnnotationTarget.TYPE)
annotation class DialogDsl
Expand All @@ -31,6 +29,7 @@ class SessionDialogBuilder(val context: Context) {

private val dp20 = toPx(20, context.resources)
private val dp40 = toPx(40, context.resources)
private val dp60 = toPx(60, context.resources)

private val dialogBuilder: AlertDialog.Builder = AlertDialog.Builder(context)

Expand Down Expand Up @@ -64,7 +63,6 @@ class SessionDialogBuilder(val context: Context) {
}
}


private fun text(text: CharSequence?, @StyleRes style: Int, modify: TextView.() -> Unit) {
text ?: return
TextView(context, null, 0, style)
Expand Down Expand Up @@ -125,8 +123,7 @@ class SessionDialogBuilder(val context: Context) {
) = Button(context, null, 0, style).apply {
setText(text)
contentDescription = resources.getString(contentDescriptionRes)
layoutParams = LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT, 1f)
.apply { setMargins(toPx(20, resources)) }
layoutParams = LinearLayout.LayoutParams(MATCH_PARENT, dp60, 1f)
setOnClickListener {
listener.invoke()
if (dismiss) dismiss()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<item android:id="@android:id/mask">
<shape android:shape="rectangle">
<solid android:color="?android:textColorPrimary"/>
<corners android:radius="@dimen/medium_button_corner_radius" />
</shape>
</item>
</ripple>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<item android:id="@android:id/mask">
<shape android:shape="rectangle">
<solid android:color="?android:textColorPrimary"/>
<corners android:radius="@dimen/medium_button_corner_radius" />
</shape>
</item>
</ripple>
8 changes: 3 additions & 5 deletions app/src/main/res/layout/dialog_clear_all_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:elevation="4dp"
android:padding="@dimen/medium_spacing">
android:elevation="4dp">

<TextView
android:layout_width="wrap_content"
Expand Down Expand Up @@ -46,16 +45,15 @@
style="@style/Widget.Session.Button.Dialog.DestructiveText"
android:id="@+id/clearAllDataButton"
android:layout_width="0dp"
android:layout_height="@dimen/small_button_height"
android:layout_height="@dimen/dialog_button_height"
android:layout_weight="1"
android:layout_marginStart="@dimen/medium_spacing"
android:text="@string/dialog_clear_all_data_clear" />

<Button
style="@style/Widget.Session.Button.Dialog.UnimportantText"
android:id="@+id/cancelButton"
android:layout_width="0dp"
android:layout_height="@dimen/small_button_height"
android:layout_height="@dimen/dialog_button_height"
android:layout_weight="1"
android:text="@string/cancel" />

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/dialog_send_seed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@
style="@style/Widget.Session.Button.Dialog.UnimportantText"
android:id="@+id/cancelButton"
android:layout_width="0dp"
android:layout_height="@dimen/small_button_height"
android:layout_height="@dimen/dialog_button_height"
android:layout_weight="1"
android:text="@string/cancel" />

<Button
style="@style/Widget.Session.Button.Dialog.DestructiveText"
android:id="@+id/sendSeedButton"
android:layout_width="0dp"
android:layout_height="@dimen/small_button_height"
android:layout_height="@dimen/dialog_button_height"
android:layout_weight="1"
android:layout_marginStart="@dimen/medium_spacing"
android:text="@string/dialog_send_seed_send_button_title" />
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<dimen name="massive_font_size">50sp</dimen>

<!-- Element Sizes -->
<dimen name="dialog_button_height">60dp</dimen>
<dimen name="small_button_height">34dp</dimen>
<dimen name="medium_button_height">38dp</dimen>
<dimen name="large_button_height">54dp</dimen>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
<item name="android:textAllCaps">false</item>
<item name="android:textSize">@dimen/small_font_size</item>
<item name="android:textColor">?android:textColorPrimary</item>
<item name="android:textStyle">bold</item>
</style>

<style name="Widget.Session.Button.Dialog.UnimportantText">
Expand Down