[android] Migrate login screen to Material components

Signed-off-by: Jean-Baptiste Charron <jeanbaptiste.charron@outlook.fr>
This commit is contained in:
Jean-Baptiste
2025-06-07 17:58:06 +02:00
committed by Konstantin Pastbin
parent 7d834beba5
commit d38ffe2fa8
5 changed files with 34 additions and 33 deletions

View File

@@ -6,7 +6,6 @@ import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.ScrollView; import android.widget.ScrollView;
@@ -24,14 +23,16 @@ import app.organicmaps.util.Utils;
import app.organicmaps.util.WindowInsetUtils.ScrollableContentInsetsListener; import app.organicmaps.util.WindowInsetUtils.ScrollableContentInsetsListener;
import app.organicmaps.util.concurrency.ThreadPool; import app.organicmaps.util.concurrency.ThreadPool;
import app.organicmaps.util.concurrency.UiThread; import app.organicmaps.util.concurrency.UiThread;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.textfield.TextInputEditText; import com.google.android.material.textfield.TextInputEditText;
public class OsmLoginFragment extends BaseMwmToolbarFragment public class OsmLoginFragment extends BaseMwmToolbarFragment
{ {
private ProgressBar mProgress; private ProgressBar mProgress;
private Button mLoginButton; private MaterialButton mLoginButton;
private Button mLostPasswordButton; private MaterialButton mLostPasswordButton;
private TextInputEditText mLoginInput; private TextInputEditText mLoginInput;
private TextInputEditText mPasswordInput; private TextInputEditText mPasswordInput;
@@ -51,7 +52,7 @@ public class OsmLoginFragment extends BaseMwmToolbarFragment
mPasswordInput = view.findViewById(R.id.osm_password); mPasswordInput = view.findViewById(R.id.osm_password);
mLoginButton = view.findViewById(R.id.login); mLoginButton = view.findViewById(R.id.login);
mLostPasswordButton = view.findViewById(R.id.lost_password); mLostPasswordButton = view.findViewById(R.id.lost_password);
Button registerButton = view.findViewById(R.id.register); MaterialButton registerButton = view.findViewById(R.id.register);
registerButton.setOnClickListener((v) -> Utils.openUrl(requireActivity(), Constants.Url.OSM_REGISTER)); registerButton.setOnClickListener((v) -> Utils.openUrl(requireActivity(), Constants.Url.OSM_REGISTER));
mProgress = view.findViewById(R.id.osm_login_progress); mProgress = view.findViewById(R.id.osm_login_progress);
final String dataVersion = DateUtils.getShortDateFormatter().format(Framework.getDataVersion()); final String dataVersion = DateUtils.getShortDateFormatter().format(Framework.getDataVersion());

View File

@@ -6,9 +6,7 @@ import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@@ -22,15 +20,17 @@ import app.organicmaps.util.WindowInsetUtils;
import app.organicmaps.util.concurrency.ThreadPool; import app.organicmaps.util.concurrency.ThreadPool;
import app.organicmaps.util.concurrency.UiThread; import app.organicmaps.util.concurrency.UiThread;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.imageview.ShapeableImageView;
import com.google.android.material.textview.MaterialTextView;
import java.text.NumberFormat; import java.text.NumberFormat;
public class ProfileFragment extends BaseMwmToolbarFragment public class ProfileFragment extends BaseMwmToolbarFragment
{ {
private View mUserInfoBlock; private View mUserInfoBlock;
private TextView mEditsSent; private MaterialTextView mEditsSent;
private TextView mProfileName; private MaterialTextView mProfileName;
private ImageView mProfileImage; private ShapeableImageView mProfileImage;
private ProgressBar mProfileInfoLoading; private ProgressBar mProfileInfoLoading;
@Nullable @Nullable

View File

@@ -35,7 +35,7 @@
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical" android:orientation="vertical"
android:padding="@dimen/margin_base"> android:padding="@dimen/margin_base">
<TextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/textView2" android:id="@+id/textView2"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -47,7 +47,7 @@
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<ImageView <com.google.android.material.imageview.ShapeableImageView
android:id="@+id/imageView" android:id="@+id/imageView"
android:layout_width="@dimen/osm_logo" android:layout_width="@dimen/osm_logo"
android:layout_height="@dimen/osm_logo" android:layout_height="@dimen/osm_logo"
@@ -56,7 +56,7 @@
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<TextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/osm_presentation" android:id="@+id/osm_presentation"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -108,7 +108,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/margin_base"> android:layout_marginBottom="@dimen/margin_base">
<Button <com.google.android.material.button.MaterialButton
android:id="@+id/login" android:id="@+id/login"
style="@style/MwmWidget.Button.Accent" style="@style/MwmWidget.Button.Accent"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -123,7 +123,7 @@
android:elevation="@dimen/design_fab_elevation" android:elevation="@dimen/design_fab_elevation"
android:visibility="gone" /> android:visibility="gone" />
</FrameLayout> </FrameLayout>
<Button <com.google.android.material.button.MaterialButton
android:id="@+id/lost_password" android:id="@+id/lost_password"
style="@style/MwmWidget.Button" style="@style/MwmWidget.Button"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -138,14 +138,14 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_base" android:layout_marginTop="@dimen/margin_base"
android:layout_marginBottom="@dimen/margin_base" /> android:layout_marginBottom="@dimen/margin_base" />
<TextView <com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:fontFamily="@string/robotoRegular" android:fontFamily="@string/robotoRegular"
android:text="@string/no_osm_account" android:text="@string/no_osm_account"
android:textAppearance="@style/MwmTextAppearance.Body2" android:textAppearance="@style/MwmTextAppearance.Body2"
android:textColor="?android:textColorPrimary" /> android:textColor="?android:textColorPrimary" />
<Button <com.google.android.material.button.MaterialButton
android:id="@+id/register" android:id="@+id/register"
style="@style/MwmWidget.Button.Accent" style="@style/MwmWidget.Button.Accent"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@@ -26,7 +26,7 @@
android:orientation="vertical" android:orientation="vertical"
android:padding="@dimen/margin_base" android:padding="@dimen/margin_base"
tools:ignore="ScrollViewSize"> tools:ignore="ScrollViewSize">
<TextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/textView2" android:id="@+id/textView2"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -39,7 +39,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/margin_base"> android:layout_marginBottom="@dimen/margin_base">
<ImageView <com.google.android.material.imageview.ShapeableImageView
android:id="@+id/osm_logo" android:id="@+id/osm_logo"
android:layout_width="@dimen/osm_logo" android:layout_width="@dimen/osm_logo"
android:layout_height="@dimen/osm_logo" android:layout_height="@dimen/osm_logo"
@@ -48,7 +48,7 @@
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<TextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/osm_presentation" android:id="@+id/osm_presentation"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -92,7 +92,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/margin_base"> android:layout_marginBottom="@dimen/margin_base">
<Button <com.google.android.material.button.MaterialButton
android:id="@+id/login" android:id="@+id/login"
style="@style/MwmWidget.Button.Accent" style="@style/MwmWidget.Button.Accent"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -107,7 +107,7 @@
android:elevation="@dimen/design_fab_elevation" android:elevation="@dimen/design_fab_elevation"
android:visibility="gone" /> android:visibility="gone" />
</FrameLayout> </FrameLayout>
<Button <com.google.android.material.button.MaterialButton
android:id="@+id/lost_password" android:id="@+id/lost_password"
style="@style/MwmWidget.Button" style="@style/MwmWidget.Button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@@ -122,14 +122,14 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_base" android:layout_marginTop="@dimen/margin_base"
android:layout_marginBottom="@dimen/margin_base" /> android:layout_marginBottom="@dimen/margin_base" />
<TextView <com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:fontFamily="@string/robotoRegular" android:fontFamily="@string/robotoRegular"
android:text="@string/no_osm_account" android:text="@string/no_osm_account"
android:textAppearance="@style/MwmTextAppearance.Body2" android:textAppearance="@style/MwmTextAppearance.Body2"
android:textColor="?android:textColorPrimary" /> android:textColor="?android:textColorPrimary" />
<Button <com.google.android.material.button.MaterialButton
android:id="@+id/register" android:id="@+id/register"
style="@style/MwmWidget.Button.Accent" style="@style/MwmWidget.Button.Accent"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@@ -6,7 +6,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<androidx.appcompat.widget.Toolbar <com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
style="@style/MwmWidget.ToolbarStyle" style="@style/MwmWidget.ToolbarStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -15,7 +15,7 @@
android:gravity="end|center_vertical" android:gravity="end|center_vertical"
android:theme="@style/MwmWidget.ToolbarTheme" android:theme="@style/MwmWidget.ToolbarTheme"
tools:ignore="UnusedAttribute"> tools:ignore="UnusedAttribute">
<ImageView <com.google.android.material.imageview.ShapeableImageView
android:id="@+id/logout" android:id="@+id/logout"
android:layout_width="?actionBarSize" android:layout_width="?actionBarSize"
android:layout_height="?actionBarSize" android:layout_height="?actionBarSize"
@@ -24,7 +24,7 @@
android:scaleType="center" android:scaleType="center"
app:srcCompat="@drawable/ic_logout" app:srcCompat="@drawable/ic_logout"
android:contentDescription="@string/logout" /> android:contentDescription="@string/logout" />
</androidx.appcompat.widget.Toolbar> </com.google.android.material.appbar.MaterialToolbar>
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -44,7 +44,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <com.google.android.material.imageview.ShapeableImageView
android:id="@+id/user_profile_image" android:id="@+id/user_profile_image"
android:layout_width="100dp" android:layout_width="100dp"
android:layout_height="match_parent" android:layout_height="match_parent"
@@ -57,7 +57,7 @@
android:layout_weight="1" android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/user_profile_name" android:id="@+id/user_profile_name"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@@ -68,7 +68,7 @@
android:autoSizeTextType="uniform" android:autoSizeTextType="uniform"
android:textSize="25sp" android:textSize="25sp"
tools:text="Long Username" /> tools:text="Long Username" />
<androidx.appcompat.widget.AppCompatTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/user_sent_edits" android:id="@+id/user_sent_edits"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@@ -76,7 +76,7 @@
android:textSize="35sp" android:textSize="35sp"
android:textStyle="bold" android:textStyle="bold"
tools:text="2,000,000" /> tools:text="2,000,000" />
<androidx.appcompat.widget.AppCompatTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/verified_changes_text" android:id="@+id/verified_changes_text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@@ -93,7 +93,7 @@
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1"> android:layout_weight="1">
<TextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/osm_history" android:id="@+id/osm_history"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -110,7 +110,7 @@
android:textColor="?colorAccent" android:textColor="?colorAccent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<TextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/osm_notes" android:id="@+id/osm_notes"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -126,7 +126,7 @@
android:textColor="?colorAccent" android:textColor="?colorAccent"
app:layout_constraintTop_toBottomOf="@id/osm_history" /> app:layout_constraintTop_toBottomOf="@id/osm_history" />
<TextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/about_osm" android:id="@+id/about_osm"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"