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

Change to Material 3 components - part 1 #7887

Merged
merged 4 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
@@ -1,5 +1,6 @@
package com.fsck.k9.activity;


import java.util.ArrayList;
import java.util.List;

Expand All @@ -11,14 +12,14 @@
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.fsck.k9.Account;
import com.fsck.k9.BaseAccount;
import com.fsck.k9.K9;
import com.fsck.k9.Preferences;
import com.fsck.k9.ui.R;
import com.fsck.k9.search.SearchAccount;
import com.fsck.k9.ui.R;
import com.google.android.material.textview.MaterialTextView;


/**
Expand Down Expand Up @@ -138,8 +139,8 @@ public View getView(int position, View convertView, ViewGroup parent) {
}

class AccountViewHolder {
public TextView description;
public TextView email;
public MaterialTextView description;
public MaterialTextView email;
public View chip;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
import android.graphics.PorterDuff.Mode;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import androidx.annotation.AttrRes;
import androidx.annotation.DrawableRes;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.AttrRes;
import androidx.annotation.DrawableRes;
import androidx.appcompat.widget.TooltipCompat;
import com.fsck.k9.activity.compose.RecipientAdapter;
import com.fsck.k9.ui.ContactBadge;
import com.fsck.k9.ui.R;
import com.fsck.k9.view.RecipientSelectView.Recipient;
import com.fsck.k9.view.ThemeUtils;
import com.google.android.material.textview.MaterialTextView;


public class AlternateRecipientAdapter extends BaseAdapter {
Expand Down Expand Up @@ -124,10 +124,10 @@ public void bindHeaderView(View view, Recipient recipient) {

holder.headerName.setText(recipient.getNameOrUnknown(context));
if (!TextUtils.isEmpty(recipient.addressLabel)) {
holder.headerAddressLabel.setText(recipient.addressLabel);
holder.headerAddressLabel.setVisibility(View.VISIBLE);
holder.headerLabel.setText(recipient.addressLabel);
holder.headerLabel.setVisibility(View.VISIBLE);
} else {
holder.headerAddressLabel.setVisibility(View.GONE);
holder.headerLabel.setVisibility(View.GONE);
}

RecipientAdapter.setContactPhotoOrPlaceholder(context, holder.headerPhoto, recipient);
Expand Down Expand Up @@ -236,13 +236,13 @@ public void setShowAdvancedInfo(boolean showAdvancedInfo) {

private static class RecipientTokenHolder {
public final View layoutHeader, layoutItem;
public final TextView headerName;
public final TextView headerAddressLabel;
public final MaterialTextView headerName;
public final MaterialTextView headerLabel;
public final ContactBadge headerPhoto;
public final View headerRemove;
public final View copyEmailAddress;
public final TextView itemAddress;
public final TextView itemAddressLabel;
public final MaterialTextView itemAddress;
public final MaterialTextView itemAddressLabel;
public final View itemCryptoStatus;
public final ImageView itemCryptoStatusIcon;
public final ImageView itemCryptoStatusSimple;
Expand All @@ -253,7 +253,7 @@ public RecipientTokenHolder(View view) {
layoutItem = view.findViewById(R.id.alternate_container_item);

headerName = view.findViewById(R.id.alternate_header_name);
headerAddressLabel = view.findViewById(R.id.alternate_header_label);
headerLabel = view.findViewById(R.id.alternate_header_label);
headerPhoto = view.findViewById(R.id.alternate_contact_photo);
headerRemove = view.findViewById(R.id.alternate_remove);

Expand Down
32 changes: 16 additions & 16 deletions app/ui/legacy/src/main/java/com/fsck/k9/activity/EditIdentity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.widget.CheckBox
import android.widget.TextView
import android.widget.EditText
import androidx.core.content.IntentCompat
import androidx.core.os.BundleCompat
import androidx.core.view.isVisible
Expand All @@ -16,6 +15,7 @@ import com.fsck.k9.Identity
import com.fsck.k9.Preferences
import com.fsck.k9.ui.R
import com.fsck.k9.ui.base.K9Activity
import com.google.android.material.checkbox.MaterialCheckBox
import org.koin.android.ext.android.inject

class EditIdentity : K9Activity() {
Expand All @@ -24,12 +24,12 @@ class EditIdentity : K9Activity() {
private lateinit var account: Account
private lateinit var identity: Identity

private lateinit var description: TextView
private lateinit var name: TextView
private lateinit var email: TextView
private lateinit var replyTo: TextView
private lateinit var signatureUse: CheckBox
private lateinit var signature: TextView
private lateinit var description: EditText
private lateinit var name: EditText
private lateinit var email: EditText
private lateinit var replyTo: EditText
private lateinit var signatureUse: MaterialCheckBox
private lateinit var signature: EditText
private lateinit var signatureLayout: View

private var identityIndex: Int = 0
Expand Down Expand Up @@ -67,23 +67,23 @@ class EditIdentity : K9Activity() {
signature = findViewById(R.id.signature)
signatureLayout = findViewById(R.id.signature_layout)

description.text = identity.description
name.text = identity.name
email.text = identity.email
replyTo.text = identity.replyTo
description.setText(identity.description)
name.setText(identity.name)
email.setText(identity.email)
replyTo.setText(identity.replyTo)

signatureUse.isChecked = identity.signatureUse
signatureUse.setOnCheckedChangeListener { _, isChecked ->
if (isChecked) {
signatureLayout.isVisible = true
signature.text = identity.signature
signature.setText(identity.signature)
} else {
signatureLayout.isVisible = false
}
}

if (signatureUse.isChecked) {
signature.text = identity.signature
signature.setText(identity.signature)
} else {
signatureLayout.isVisible = false
}
Expand All @@ -104,11 +104,11 @@ class EditIdentity : K9Activity() {
invalidateOptionsMenu()
}

private fun isValidEmailAddress(textView: TextView): Boolean {
private fun isValidEmailAddress(textView: EditText): Boolean {
return emailAddressValidator.isValidAddressOnly(textView.text.trim())
}

private fun isValidEmailAddressOrEmpty(textView: TextView): Boolean {
private fun isValidEmailAddressOrEmpty(textView: EditText): Boolean {
return textView.text.isBlank() || isValidEmailAddress(textView)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
Expand Down Expand Up @@ -117,6 +116,7 @@
import com.fsck.k9.ui.helper.SizeFormatter;
import com.fsck.k9.ui.messagelist.DefaultFolderProvider;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.textview.MaterialTextView;
import org.openintents.openpgp.OpenPgpApiManager;
import org.openintents.openpgp.util.OpenPgpApi;
import org.openintents.openpgp.util.OpenPgpIntentStarter;
Expand Down Expand Up @@ -224,7 +224,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,

private boolean requestReadReceipt = false;

private TextView chooseIdentityButton;
private MaterialTextView chooseIdentityView;
private EditText subjectView;
private EditText signatureView;
private EditText messageContentView;
Expand Down Expand Up @@ -298,8 +298,8 @@ public void onCreate(Bundle savedInstanceState) {
return;
}

chooseIdentityButton = findViewById(R.id.identity);
chooseIdentityButton.setOnClickListener(this);
chooseIdentityView = findViewById(R.id.identity);
chooseIdentityView.setOnClickListener(this);

ReplyToView replyToView = new ReplyToView(this);
replyToPresenter = new ReplyToPresenter(replyToView);
Expand Down Expand Up @@ -937,7 +937,7 @@ private void switchToIdentity(Identity identity) {
}

private void updateFrom() {
chooseIdentityButton.setText(identity.getEmail());
chooseIdentityView.setText(identity.getEmail());
}

private void updateSignature() {
Expand Down Expand Up @@ -1828,7 +1828,7 @@ public void updateAttachmentView(Attachment attachment) {
throw new IllegalArgumentException();
}

TextView nameView = view.findViewById(R.id.attachment_name);
MaterialTextView nameView = view.findViewById(R.id.attachment_name);
boolean hasMetadata = (attachment.state != Attachment.LoadingState.URI_ONLY);
if (hasMetadata) {
nameView.setText(attachment.name);
Expand All @@ -1837,7 +1837,7 @@ public void updateAttachmentView(Attachment attachment) {
}

if (attachment.size != null && attachment.size >= 0) {
TextView sizeView = view.findViewById(R.id.attachment_size);
MaterialTextView sizeView = view.findViewById(R.id.attachment_size);
sizeView.setText(sizeFormatter.formatSize(attachment.size));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import android.view.MenuItem
import android.view.View
import android.view.animation.AnimationUtils
import android.widget.ProgressBar
import android.widget.TextView
import androidx.appcompat.app.ActionBar
import androidx.appcompat.view.ActionMode
import androidx.appcompat.widget.SearchView
Expand Down Expand Up @@ -61,6 +60,7 @@ import com.fsck.k9.ui.messageview.MessageViewFragment.MessageViewFragmentListene
import com.fsck.k9.ui.messageview.PlaceholderFragment
import com.fsck.k9.view.ViewSwitcher
import com.fsck.k9.view.ViewSwitcher.OnSwitchCompleteListener
import com.google.android.material.textview.MaterialTextView
import com.mikepenz.materialdrawer.util.getOptimalDrawerWidth
import org.koin.android.ext.android.inject
import org.koin.core.component.KoinComponent
Expand Down Expand Up @@ -934,8 +934,8 @@ open class MessageList :
}

private fun setActionBarTitle(title: String, subtitle: String? = null) {
findViewById<TextView>(R.id.toolbarTitle).text = title
findViewById<TextView>(R.id.toolbarSubtitle).apply {
findViewById<MaterialTextView>(R.id.toolbarTitle).text = title
findViewById<MaterialTextView>(R.id.toolbarSubtitle).apply {
if (subtitle != null) {
text = subtitle
isGone = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.TextView;

import androidx.core.content.IntentCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
Expand All @@ -20,6 +19,7 @@
import com.fsck.k9.service.DatabaseUpgradeService;
import com.fsck.k9.ui.R;
import com.fsck.k9.ui.base.K9Activity;
import com.google.android.material.textview.MaterialTextView;


/**
Expand Down Expand Up @@ -96,7 +96,7 @@ public static boolean actionUpgradeDatabases(Context context, Intent startIntent

private Intent mStartIntent;

private TextView mUpgradeText;
private MaterialTextView mUpgradeText;

private LocalBroadcastManager mLocalBroadcastManager;
private UpgradeDatabaseBroadcastReceiver mBroadcastReceiver;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
package com.fsck.k9.activity.compose;


import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.fsck.k9.Account;
import com.fsck.k9.DI;
import com.fsck.k9.Identity;
import com.fsck.k9.Preferences;
import com.fsck.k9.ui.R;
import com.fsck.k9.ui.identity.IdentityFormatter;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.google.android.material.textview.MaterialTextView;

/**
* Adapter for the <em>Choose identity</em> list view.
Expand Down Expand Up @@ -140,12 +141,12 @@ public static class IdentityContainer {
}

static class AccountHolder {
public TextView name;
public MaterialTextView name;
public View chip;
}

static class IdentityHolder {
public TextView name;
public TextView description;
public MaterialTextView name;
public MaterialTextView description;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

import android.content.Context;
import android.graphics.drawable.Drawable;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import android.text.Spannable;
import android.text.style.ForegroundColorSpan;
import android.view.LayoutInflater;
Expand All @@ -18,13 +16,15 @@
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import com.fsck.k9.activity.misc.ContactPicture;
import com.fsck.k9.ui.R;
import com.fsck.k9.view.RecipientSelectView.Recipient;
import com.fsck.k9.view.RecipientSelectView.RecipientCryptoStatus;
import com.fsck.k9.view.ThemeUtils;
import com.google.android.material.textview.MaterialTextView;


public class RecipientAdapter extends BaseAdapter implements Filterable {
Expand Down Expand Up @@ -185,8 +185,8 @@ public void setShowAdvancedInfo(boolean showAdvancedInfo) {


private static class RecipientTokenHolder {
public final TextView name;
public final TextView email;
public final MaterialTextView name;
public final MaterialTextView email;
final ImageView photo;
final View cryptoStatus;
final ImageView cryptoStatusIcon;
Expand Down
Loading