Migrate to MDC text fields

This commit is contained in:
proletarius101 2021-05-18 12:01:15 +00:00 committed by Hans-Christoph Steiner
parent fc463810f6
commit ca54511cf6
6 changed files with 118 additions and 84 deletions

View File

@ -9,6 +9,8 @@ import org.fdroid.fdroid.R;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import com.google.android.material.textfield.TextInputLayout;
public class CrashReportActivity extends BaseCrashReportDialog public class CrashReportActivity extends BaseCrashReportDialog
implements DialogInterface.OnDismissListener, DialogInterface.OnClickListener { implements DialogInterface.OnDismissListener, DialogInterface.OnClickListener {
@ -30,7 +32,8 @@ public class CrashReportActivity extends BaseCrashReportDialog
dialog.setOnDismissListener(this); dialog.setOnDismissListener(this);
dialog.show(); dialog.show();
comment = (EditText) dialog.findViewById(android.R.id.input); TextInputLayout commentLayout = dialog.findViewById(android.R.id.input);
comment = commentLayout.getEditText();
if (savedInstanceState != null) { if (savedInstanceState != null) {
comment.setText(savedInstanceState.getString(STATE_COMMENT)); comment.setText(savedInstanceState.getString(STATE_COMMENT));
} }

View File

@ -50,8 +50,20 @@ import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.NavUtils;
import androidx.core.app.TaskStackBuilder;
import androidx.core.content.ContextCompat;
import androidx.loader.app.LoaderManager;
import androidx.loader.content.CursorLoader;
import androidx.loader.content.Loader;
import com.google.android.material.appbar.MaterialToolbar; import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.textfield.TextInputLayout;
import org.fdroid.fdroid.AddRepoIntentService; import org.fdroid.fdroid.AddRepoIntentService;
import org.fdroid.fdroid.FDroidApp; import org.fdroid.fdroid.FDroidApp;
@ -75,17 +87,6 @@ import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.NavUtils;
import androidx.core.app.TaskStackBuilder;
import androidx.core.content.ContextCompat;
import androidx.loader.app.LoaderManager;
import androidx.loader.content.CursorLoader;
import androidx.loader.content.Loader;
public class ManageReposActivity extends AppCompatActivity public class ManageReposActivity extends AppCompatActivity
implements LoaderManager.LoaderCallbacks<Cursor>, RepoAdapter.EnabledListener { implements LoaderManager.LoaderCallbacks<Cursor>, RepoAdapter.EnabledListener {
private static final String TAG = "ManageReposActivity"; private static final String TAG = "ManageReposActivity";
@ -296,8 +297,10 @@ public class ManageReposActivity extends AppCompatActivity
final View view = getLayoutInflater().inflate(R.layout.addrepo, null); final View view = getLayoutInflater().inflate(R.layout.addrepo, null);
MaterialAlertDialogBuilder addRepoDialogBuilder = new MaterialAlertDialogBuilder(context); MaterialAlertDialogBuilder addRepoDialogBuilder = new MaterialAlertDialogBuilder(context);
addRepoDialogBuilder.setView(view); addRepoDialogBuilder.setView(view);
final EditText uriEditText = (EditText) view.findViewById(R.id.edit_uri); final TextInputLayout uriEditTextLayout = view.findViewById(R.id.edit_uri);
final EditText fingerprintEditText = (EditText) view.findViewById(R.id.edit_fingerprint); final TextInputLayout fingerprintEditTextLayout = view.findViewById(R.id.edit_fingerprint);
final EditText uriEditText = uriEditTextLayout.getEditText();
final EditText fingerprintEditText = fingerprintEditTextLayout.getEditText();
addRepoDialogBuilder.setTitle(R.string.repo_add_title); addRepoDialogBuilder.setTitle(R.string.repo_add_title);
addRepoDialogBuilder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { addRepoDialogBuilder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

View File

@ -27,6 +27,7 @@ import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.google.android.material.appbar.MaterialToolbar; import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.textfield.TextInputLayout;
import org.fdroid.fdroid.FDroidApp; import org.fdroid.fdroid.FDroidApp;
import org.fdroid.fdroid.NfcHelper; import org.fdroid.fdroid.NfcHelper;
@ -424,8 +425,10 @@ public class RepoDetailsActivity extends AppCompatActivity {
public void showChangePasswordDialog(final View parentView) { public void showChangePasswordDialog(final View parentView) {
final View view = getLayoutInflater().inflate(R.layout.login, null); final View view = getLayoutInflater().inflate(R.layout.login, null);
final AlertDialog credentialsDialog = new AlertDialog.Builder(this).setView(view).create(); final AlertDialog credentialsDialog = new AlertDialog.Builder(this).setView(view).create();
final EditText nameInput = view.findViewById(R.id.edit_name); final TextInputLayout nameInputLayout = view.findViewById(R.id.edit_name);
final EditText passwordInput = view.findViewById(R.id.edit_password); final TextInputLayout passwordInputLayout = view.findViewById(R.id.edit_password);
final EditText nameInput = nameInputLayout.getEditText();
final EditText passwordInput = passwordInputLayout.getEditText();
nameInput.setText(repo.username); nameInput.setText(repo.username);
passwordInput.requestFocus(); passwordInput.requestFocus();

View File

@ -3,11 +3,11 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="24dp"
android:paddingStart="24dp" android:paddingStart="24dp"
android:paddingRight="24dp" android:paddingLeft="24dp"
android:paddingTop="20dp"
android:paddingEnd="24dp" android:paddingEnd="24dp"
android:paddingTop="20dp"> android:paddingRight="24dp">
<LinearLayout <LinearLayout
android:id="@+id/add_repo_form" android:id="@+id/add_repo_form"
@ -15,32 +15,41 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<TextView <com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/repo_add_url" />
<EditText
android:id="@+id/edit_uri" android:id="@+id/edit_uri"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="textUri" android:layout_margin="4dp"
android:maxLines="2" android:hint="@string/repo_add_url"
android:text="@string/https" /> android:text="@string/https">
<TextView <com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/repo_add_fingerprint" /> android:inputType="textUri"
android:maxLines="2" />
<EditText </com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/edit_fingerprint" android:id="@+id/edit_fingerprint"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="4dp"
android:digits="0123456789ABCDEFabcedf: " android:digits="0123456789ABCDEFabcedf: "
android:inputType="textNoSuggestions" android:hint="@string/repo_add_fingerprint"
android:maxLines="3" android:typeface="monospace">
android:typeface="monospace" />
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textNoSuggestions"
android:maxLines="3" />
</com.google.android.material.textfield.TextInputLayout>
<TextView <TextView
android:id="@+id/overwrite_message" android:id="@+id/overwrite_message"
@ -52,31 +61,31 @@
</LinearLayout> </LinearLayout>
<TextView <TextView
android:padding="10dp"
android:textSize="16sp"
android:id="@+id/text_searching_for_repo" android:id="@+id/text_searching_for_repo"
android:gravity="center"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center"
android:padding="10dp"
android:textSize="16sp"
tools:text="Searching for repository at\nhttps://www.example.com/fdroid/repo/" /> tools:text="Searching for repository at\nhttps://www.example.com/fdroid/repo/" />
</RelativeLayout> </RelativeLayout>
<!-- <!--
* Copyright (C) 2009 Roberto Jacinto * Copyright (C) 2009 Roberto Jacinto
* roberto.jacinto@caixamagica.pt * roberto.jacinto@caixamagica.pt
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
--> -->

View File

@ -4,13 +4,13 @@
android:layout_height="match_parent"> android:layout_height="match_parent">
<LinearLayout <LinearLayout
android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="24dp" android:paddingLeft="24dp"
android:paddingTop="20dp"
android:paddingRight="24dp" android:paddingRight="24dp"
android:paddingBottom="24dp" android:paddingBottom="24dp">
android:paddingTop="20dp">
<TextView <TextView
android:id="@android:id/text1" android:id="@android:id/text1"
@ -25,13 +25,19 @@
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:text="@string/crash_dialog_comment_prompt" /> android:text="@string/crash_dialog_comment_prompt" />
<EditText <com.google.android.material.textfield.TextInputLayout
android:id="@android:id/input" android:id="@android:id/input"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="textMultiLine" android:layout_marginTop="20dp">
android:layout_marginTop="20dp" />
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>

View File

@ -3,40 +3,50 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="24dp"
android:paddingStart="24dp" android:paddingStart="24dp"
android:paddingRight="24dp" android:paddingLeft="24dp"
android:paddingTop="20dp"
android:paddingEnd="24dp" android:paddingEnd="24dp"
android:paddingTop="20dp"> android:paddingRight="24dp">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<TextView <com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/login_name" />
<EditText
android:id="@+id/edit_name" android:id="@+id/edit_name"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="textNoSuggestions" android:layout_margin="4dp"
android:maxLines="1" /> android:hint="@string/login_name">
<TextView <com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/login_password" /> android:inputType="textNoSuggestions"
android:maxLines="1" />
<EditText </com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/edit_password" android:id="@+id/edit_password"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="textPassword" android:layout_margin="4dp"
android:maxLines="1" /> android:hint="@string/login_password">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>
<TextView <TextView
android:id="@+id/overwrite_message" android:id="@+id/overwrite_message"
@ -48,12 +58,12 @@
</LinearLayout> </LinearLayout>
<TextView <TextView
android:padding="10dp"
android:textSize="16sp"
android:id="@+id/text_searching_for_repo" android:id="@+id/text_searching_for_repo"
android:gravity="center"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center"
android:padding="10dp"
android:textSize="16sp"
tools:text="Searching for repository at\nhttps://www.example.com/fdroid/repo/" /> tools:text="Searching for repository at\nhttps://www.example.com/fdroid/repo/" />
</RelativeLayout> </RelativeLayout>