Skip to content

Commit

Permalink
redesign fragment_registration_welcome.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszKataMobitouch authored and skustra committed Feb 23, 2023
1 parent 0ee2d58 commit 9c1d3c0
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@

import java.util.Optional;

import pigeon.extensions.JavaExtensions;

import static org.thoughtcrime.securesms.registration.fragments.RegistrationViewDelegate.setDebugLogSubmitMultiTapView;

public final class WelcomeFragment extends LoggingFragment {
Expand Down Expand Up @@ -117,6 +119,8 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
TextView welcomeTermsButton = view.findViewById(R.id.welcome_terms_button);
welcomeTermsButton.setOnClickListener(v -> onTermsClicked());

JavaExtensions.onFocusTextChangeListener(welcomeTermsButton);

if (!canUserSelectBackup()) {
restoreFromBackup.setText(R.string.registration_activity__transfer_account);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ import android.os.Parcelable
import android.util.AttributeSet
import android.view.ViewAnimationUtils
import android.widget.FrameLayout
import android.widget.TextView
import androidx.annotation.StringRes
import androidx.annotation.VisibleForTesting
import androidx.core.animation.doOnEnd
import androidx.core.content.withStyledAttributes
import com.google.android.material.button.MaterialButton
import com.google.android.material.progressindicator.CircularProgressIndicator
import com.google.android.material.theme.overlay.MaterialThemeOverlay
import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.util.visible
import pigeon.extensions.onFocusTextChangeListener
import kotlin.math.max

/**
Expand All @@ -34,8 +33,8 @@ class CircularProgressMaterialButton @JvmOverloads constructor(

private var animator: Animator? = null

private val materialButton: MaterialButton = findViewById(R.id.button)
private val progressIndicator: CircularProgressIndicator = findViewById(R.id.progress_indicator)
private val materialButton: TextView = findViewById(R.id.button)
// private val progressIndicator: CircularProgressIndicator = findViewById(R.id.progress_indicator)

var text: CharSequence?
get() = materialButton.text
Expand All @@ -46,9 +45,10 @@ class CircularProgressMaterialButton @JvmOverloads constructor(
init {
getContext().withStyledAttributes(attrs, R.styleable.CircularProgressMaterialButton) {
val label = getString(R.styleable.CircularProgressMaterialButton_circularProgressMaterialButton__label)

materialButton.text = label
materialButton.onFocusTextChangeListener()
}

}

fun setText(@StringRes resId: Int) {
Expand All @@ -58,13 +58,13 @@ class CircularProgressMaterialButton @JvmOverloads constructor(
override fun setEnabled(enabled: Boolean) {
super.setEnabled(enabled)
materialButton.isEnabled = enabled
progressIndicator.visible = enabled
// progressIndicator.visible = enabled
}

override fun setClickable(clickable: Boolean) {
super.setClickable(clickable)
materialButton.isClickable = clickable
progressIndicator.visible = clickable
// progressIndicator.visible = clickable
}

override fun onSaveInstanceState(): Parcelable {
Expand Down Expand Up @@ -94,11 +94,11 @@ class CircularProgressMaterialButton @JvmOverloads constructor(
}

fun setSpinning() {
transformTo(State.PROGRESS, true)
// transformTo(State.PROGRESS, true)
}

fun cancelSpinning() {
transformTo(State.BUTTON, true)
// transformTo(State.BUTTON, true)
}

private fun transformTo(state: State, animate: Boolean) {
Expand Down Expand Up @@ -150,7 +150,7 @@ class CircularProgressMaterialButton @JvmOverloads constructor(
return
}

transformTo(requestedState, animate)
// transformTo(requestedState, animate)
}

enum class State(val code: Int, val materialButtonVisibility: Int) {
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/java/pigeon/extensions/JavaExtensions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package pigeon.extensions;

public class JavaExtensions {

public static void onFocusTextChangeListener(android.widget.TextView view) {
view.setOnFocusChangeListener((v, hasFocus) -> {
float textSize;
if (hasFocus) {
textSize = 36f;
} else {
textSize = 24f;
}
view.setTextSize(textSize);
});
}
}
16 changes: 16 additions & 0 deletions app/src/main/java/pigeon/extensions/KotilinExtensions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package pigeon.extensions

import android.view.View
import android.widget.TextView

fun TextView.onFocusTextChangeListener() {
val focus = View.OnFocusChangeListener { _, hasFocus ->
val textSize = if (hasFocus) {
36f
} else {
24f
}
this.textSize = textSize
}
this.onFocusChangeListener = focus
}
20 changes: 11 additions & 9 deletions app/src/main/res/layout/circular_progress_material_button.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:parentTag="org.thoughtcrime.securesms.util.views.CircularProgressMaterialButton">

<com.google.android.material.progressindicator.CircularProgressIndicator
android:id="@+id/progress_indicator"
style="?circularProgressIndicatorStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
<!-- <com.google.android.material.progressindicator.CircularProgressIndicator-->
<!-- android:id="@+id/progress_indicator"-->
<!-- style="?circularProgressIndicatorStyle"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:visibility="gone"-->
<!-- android:layout_gravity="center_horizontal" />-->

<com.google.android.material.button.MaterialButton
<TextView
android:id="@+id/button"
style="?circularProgressMaterialButtonStyle"
style="@style/Mp02.Signal.Text.CommonTextButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Material Button"
tools:visibility="invisible" />
tools:visibility="visible" />
<!-- style="?circularProgressMaterialButtonStyle"-->

</merge>
43 changes: 21 additions & 22 deletions app/src/main/res/layout/fragment_registration_welcome.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
xmlns:tools="http://schemas.android.com/tools"
tools:viewBindingIgnore="true"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/Mp02.Signal.Background"
android:padding="@dimen/pigeon_small_margin"
android:layout_width="match_parent"
android:layout_height="match_parent">

Expand All @@ -12,6 +14,7 @@
android:layout_height="0dp"
android:layout_margin="16dp"
android:importantForAccessibility="no"
android:visibility="gone"
android:src="@drawable/welcome"
app:layout_constraintBottom_toTopOf="@+id/title"
app:layout_constraintEnd_toEndOf="parent"
Expand All @@ -20,49 +23,45 @@

<TextView
android:id="@+id/title"
android:layout_width="0dp"
style="@style/Mp02.Signal.Text.CommonTextButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="40dp"
android:textColor="@color/white_not_focus"
android:layout_marginTop="@dimen/pigeon_normal_margin"
android:layout_marginStart="@dimen/pigeon_normal_margin"
android:gravity="center"
android:text="@string/RegistrationActivity_take_privacy_with_you_be_yourself_in_every_message"
android:textAppearance="@style/Signal.Text.HeadlineMedium"
app:layout_constraintBottom_toTopOf="@+id/welcome_terms_button"
app:layout_constraintEnd_toEndOf="@+id/welcome_continue_button"
app:layout_constraintStart_toStartOf="@+id/welcome_continue_button" />
app:layout_constraintStart_toStartOf="@+id/welcome_continue_button"
app:layout_constraintTop_toTopOf="parent" />

<com.google.android.material.button.MaterialButton
<TextView
android:id="@+id/welcome_terms_button"
style="@style/Signal.Widget.Button.Large.Secondary"
android:layout_width="wrap_content"
style="@style/Mp02.Signal.Text.CommonTextButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:gravity="center"
android:ellipsize="end"
android:layout_marginStart="@dimen/pigeon_normal_margin"
android:text="@string/RegistrationActivity_terms_and_privacy"
android:textColor="@color/signal_colorOnSurfaceVariant"
app:layout_constraintBottom_toTopOf="@+id/welcome_continue_button"
app:layout_constraintEnd_toEndOf="@+id/welcome_continue_button"
app:layout_constraintStart_toStartOf="@+id/welcome_continue_button" />
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/title" />

<org.thoughtcrime.securesms.util.views.CircularProgressMaterialButton
android:id="@+id/welcome_continue_button"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
android:layout_marginBottom="17dp"
app:circularProgressMaterialButton__label="@string/RegistrationActivity_continue"
app:layout_constraintBottom_toTopOf="@id/welcome_transfer_or_restore"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_goneMarginBottom="@dimen/registration_button_bottom_margin"
app:materialThemeOverlay="@style/ThemeOverlay.Signal.CircularProgressIndicator.Tonal" />
app:layout_constraintTop_toBottomOf="@+id/welcome_terms_button"
app:layout_goneMarginBottom="@dimen/registration_button_bottom_margin" />

<com.google.android.material.button.MaterialButton
android:id="@+id/welcome_transfer_or_restore"
style="@style/Signal.Widget.Button.Large.Secondary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:visibility="gone"
android:layout_marginEnd="32dp"
android:layout_marginBottom="24dp"
android:text="@string/registration_activity__transfer_or_restore_account"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,6 @@
<dimen name="media_rail_item_size">46dp</dimen>
<dimen name="media_rail_thumbnail_size">44dp</dimen>
<dimen name="registrationactivity_text_view_padding">32dp</dimen>
<dimen name="pigeon_normal_margin">25dp</dimen>
<dimen name="pigeon_small_margin">5dp</dimen>
</resources>
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,7 @@
<string name="RegistrationActivity_i_understand">I understand</string>
<string name="RegistrationActivity_play_services_error">Play Services Error</string>
<string name="RegistrationActivity_google_play_services_is_updating_or_unavailable">Google Play Services is updating or temporarily unavailable. Please try again.</string>
<string name="RegistrationActivity_terms_and_privacy">Terms &amp; Privacy Policy</string>
<string name="RegistrationActivity_terms_and_privacy">Signal Terms &amp; Privacy Policy</string>
<string name="RegistrationActivity_signal_needs_access_to_your_contacts_and_media_in_order_to_connect_with_friends">Signal needs the contacts and media permissions to help you connect with friends and send messages. Your contacts are uploaded using Signal\'s private contact discovery, which means they are end-to-end encrypted and never visible to the Signal service.</string>
<string name="RegistrationActivity_signal_needs_access_to_your_contacts_in_order_to_connect_with_friends">Signal needs the contacts permission to help you connect with friends. Your contacts are uploaded using Signal\'s private contact discovery, which means they are end-to-end encrypted and never visible to the Signal service.</string>
<string name="RegistrationActivity_rate_limited_to_service">You\'ve made too many attempts to register this number. Please try again later.</string>
Expand All @@ -1812,7 +1812,7 @@
<string name="RegistrationActivity_we_need_to_verify_that_youre_human">We need to verify that you\'re human.</string>
<string name="RegistrationActivity_next">Next</string>
<string name="RegistrationActivity_continue">Continue</string>
<string name="RegistrationActivity_take_privacy_with_you_be_yourself_in_every_message">Take privacy with you.\nBe yourself in every message.</string>
<string name="RegistrationActivity_take_privacy_with_you_be_yourself_in_every_message">Pigeon disclaimer</string>
<string name="RegistrationActivity_enter_your_phone_number">Enter your phone number</string>
<string name="RegistrationActivity_you_will_receive_a_verification_code">You will receive a verification code.\nCarrier rates may apply.</string>
<string name="RegistrationActivity_enter_the_code_we_sent_to_s">Enter the code we sent to %s</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/text_styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<item name="android:textColor">@color/mp02_common_text_button</item>
<item name="android:textAlignment">textStart</item>
<item name="android:singleLine">true</item>
<item name="android:ellipsize">end</item>
<item name="android:defaultFocusHighlightEnabled" tools:ignore="NewApi">false</item>
</style>

Expand Down

0 comments on commit 9c1d3c0

Please sign in to comment.