Update contact name editor.

fork-5.53.8
Alex Hart 2022-07-15 13:18:38 -03:00 zatwierdzone przez Cody Henthorne
rodzic 00d5724cec
commit 17b00734ac
5 zmienionych plików z 82 dodań i 46 usunięć

Wyświetl plik

@ -7,11 +7,10 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
import androidx.lifecycle.ViewModelProviders;
import androidx.lifecycle.ViewModelProvider;
import org.thoughtcrime.securesms.PassphraseRequiredActivity;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.util.DynamicLanguage;
import org.thoughtcrime.securesms.util.DynamicNoActionBarTheme;
import org.thoughtcrime.securesms.util.DynamicTheme;
@ -22,10 +21,8 @@ public class ContactNameEditActivity extends PassphraseRequiredActivity {
public static final String KEY_NAME = "name";
public static final String KEY_CONTACT_INDEX = "contact_index";
private final DynamicTheme dynamicTheme = new DynamicNoActionBarTheme();
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
private final DynamicTheme dynamicTheme = new DynamicNoActionBarTheme();
private TextView displayNameView;
private ContactNameEditViewModel viewModel;
static Intent getIntent(@NonNull Context context, @NonNull Name name, int contactPosition) {
@ -38,7 +35,6 @@ public class ContactNameEditActivity extends PassphraseRequiredActivity {
@Override
protected void onPreCreate() {
dynamicTheme.onCreate(this);
dynamicLanguage.onCreate(this);
}
@Override
@ -59,16 +55,14 @@ public class ContactNameEditActivity extends PassphraseRequiredActivity {
initializeToolbar();
initializeViews(name);
viewModel = ViewModelProviders.of(this).get(ContactNameEditViewModel.class);
viewModel = new ViewModelProvider(this).get(ContactNameEditViewModel.class);
viewModel.setName(name);
viewModel.getDisplayName().observe(this, displayNameView::setText);
}
@Override
protected void onResume() {
super.onResume();
dynamicTheme.onResume(this);
dynamicLanguage.onResume(this);
}
private void initializeToolbar() {
@ -86,8 +80,6 @@ public class ContactNameEditActivity extends PassphraseRequiredActivity {
}
private void initializeViews(@NonNull Name name) {
displayNameView = findViewById(R.id.name_edit_display_name);
TextView givenName = findViewById(R.id.name_edit_given_name);
TextView familyName = findViewById(R.id.name_edit_family_name);
TextView middleName = findViewById(R.id.name_edit_middle_name);

Wyświetl plik

@ -39,10 +39,6 @@ public class ContactNameEditViewModel extends ViewModel {
return new Name(displayName.getValue(), givenName, familyName, prefix, suffix, middleName);
}
LiveData<String> getDisplayName() {
return displayName;
}
void updateGivenName(@NonNull String givenName) {
this.givenName = givenName;
displayName.postValue(buildDisplayName());

Wyświetl plik

@ -2,19 +2,19 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="?attr/actionBarStyle"
android:minHeight="?attr/actionBarSize"
android:elevation="4dp"
app:navigationIcon="@drawable/ic_check_24_tinted" />
android:layout_height="@dimen/signal_m3_toolbar_height"
android:minHeight="@dimen/signal_m3_toolbar_height"
app:navigationIcon="@drawable/ic_x"
app:title="@string/ContactShareEditActivity__edit_name"
app:titleTextAppearance="@style/Signal.Text.TitleLarge" />
<ScrollView
android:layout_width="match_parent"
@ -23,46 +23,83 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="12dp">
android:orientation="vertical">
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/name_edit_display_name"
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.Signal.TextInputLayout.FilledBox.ContactNameEditor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:textSize="20sp"
tools:text="Peter Parker"/>
android:layout_marginBottom="16dp"
android:minHeight="56dp">
<org.thoughtcrime.securesms.components.emoji.EmojiEditText
android:id="@+id/name_edit_prefix"
<org.thoughtcrime.securesms.components.emoji.EmojiEditText
android:id="@+id/name_edit_prefix"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/ContactNameEditActivity_prefix"
android:textAppearance="@style/Signal.Text.BodyLarge" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.Signal.TextInputLayout.FilledBox.ContactNameEditor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/ContactNameEditActivity_prefix"/>
android:layout_marginBottom="16dp"
android:minHeight="56dp">
<org.thoughtcrime.securesms.components.emoji.EmojiEditText
android:id="@+id/name_edit_given_name"
<org.thoughtcrime.securesms.components.emoji.EmojiEditText
android:id="@+id/name_edit_given_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/ContactNameEditActivity_given_name"
tools:text="@tools:sample/first_names"
android:textAppearance="@style/Signal.Text.BodyLarge" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.Signal.TextInputLayout.FilledBox.ContactNameEditor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/ContactNameEditActivity_given_name"/>
android:layout_marginBottom="16dp"
android:minHeight="56dp">
<org.thoughtcrime.securesms.components.emoji.EmojiEditText
android:id="@+id/name_edit_middle_name"
<org.thoughtcrime.securesms.components.emoji.EmojiEditText
android:id="@+id/name_edit_middle_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/ContactNameEditActivity_middle_name"
android:textAppearance="@style/Signal.Text.BodyLarge" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.Signal.TextInputLayout.FilledBox.ContactNameEditor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/ContactNameEditActivity_middle_name"/>
android:layout_marginBottom="16dp"
android:minHeight="56dp">
<org.thoughtcrime.securesms.components.emoji.EmojiEditText
android:id="@+id/name_edit_family_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/ContactNameEditActivity_family_name"/>
<org.thoughtcrime.securesms.components.emoji.EmojiEditText
android:id="@+id/name_edit_family_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/ContactNameEditActivity_family_name"
android:textAppearance="@style/Signal.Text.BodyLarge" />
</com.google.android.material.textfield.TextInputLayout>
<org.thoughtcrime.securesms.components.emoji.EmojiEditText
android:id="@+id/name_edit_suffix"
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.Signal.TextInputLayout.FilledBox.ContactNameEditor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/ContactNameEditActivity_suffix"/>
android:layout_height="wrap_content">
<org.thoughtcrime.securesms.components.emoji.EmojiEditText
android:id="@+id/name_edit_suffix"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/ContactNameEditActivity_suffix"
android:textAppearance="@style/Signal.Text.BodyLarge" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>

Wyświetl plik

@ -210,6 +210,8 @@
<string name="ContactsDatabase_signal_call_s">Signal Call %s</string>
<!-- ContactNameEditActivity -->
<!-- Toolbar title for contact name edit activity -->
<string name="ContactNameEditActivity__edit_name">Edit name</string>
<string name="ContactNameEditActivity_given_name">Given name</string>
<string name="ContactNameEditActivity_family_name">Family name</string>
<string name="ContactNameEditActivity_prefix">Prefix</string>

Wyświetl plik

@ -482,6 +482,15 @@
<item name="android:textColorHint">@color/signal_text_hint</item>
</style>
<style name="Widget.Signal.TextInputLayout.FilledBox.ContactNameEditor">
<item name="boxCornerRadiusBottomEnd">0dp</item>
<item name="boxCornerRadiusBottomStart">0dp</item>
<item name="boxStrokeWidth">1dp</item>
<item name="boxStrokeColor">@color/signal_colorOutline</item>
<item name="boxStrokeErrorColor">@color/signal_colorError</item>
<item name="hintTextAppearance">@style/Signal.Text.LabelMedium</item>
</style>
<style name="Widget.MaterialComponents.Button.TextButton.Dialog">
<item name="android:minWidth">@dimen/mtrl_btn_dialog_btn_min_width</item>
<!-- Allow buttons to span more than one line so that the end isn't cut