mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-21 22:03:37 +00:00
[android] Migrate send note button to Material 3
Signed-off-by: Jean-Baptiste <jeanbaptiste.charron@outlook.fr>
This commit is contained in:
@@ -1,16 +1,20 @@
|
|||||||
package app.organicmaps.editor;
|
package app.organicmaps.editor;
|
||||||
|
|
||||||
|
import android.content.res.ColorStateList;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
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 androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import app.organicmaps.R;
|
import app.organicmaps.R;
|
||||||
import app.organicmaps.sdk.editor.data.FeatureCategory;
|
import app.organicmaps.sdk.editor.data.FeatureCategory;
|
||||||
import app.organicmaps.sdk.util.StringUtils;
|
import app.organicmaps.sdk.util.StringUtils;
|
||||||
import app.organicmaps.util.UiUtils;
|
import app.organicmaps.util.UiUtils;
|
||||||
|
|
||||||
|
import com.google.android.material.button.MaterialButton;
|
||||||
import com.google.android.material.textfield.TextInputEditText;
|
import com.google.android.material.textfield.TextInputEditText;
|
||||||
import com.google.android.material.textview.MaterialTextView;
|
import com.google.android.material.textview.MaterialTextView;
|
||||||
|
|
||||||
@@ -119,7 +123,7 @@ public class FeatureCategoryAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
|||||||
protected static class FooterViewHolder extends RecyclerView.ViewHolder
|
protected static class FooterViewHolder extends RecyclerView.ViewHolder
|
||||||
{
|
{
|
||||||
private final TextInputEditText mNoteEditText;
|
private final TextInputEditText mNoteEditText;
|
||||||
private final View mSendNoteButton;
|
private final MaterialButton mSendNoteButton;
|
||||||
|
|
||||||
FooterViewHolder(@NonNull View itemView, @NonNull FooterListener listener)
|
FooterViewHolder(@NonNull View itemView, @NonNull FooterListener listener)
|
||||||
{
|
{
|
||||||
@@ -129,6 +133,29 @@ public class FeatureCategoryAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
|||||||
mNoteEditText = itemView.findViewById(R.id.note_edit_text);
|
mNoteEditText = itemView.findViewById(R.id.note_edit_text);
|
||||||
mSendNoteButton = itemView.findViewById(R.id.send_note_button);
|
mSendNoteButton = itemView.findViewById(R.id.send_note_button);
|
||||||
mSendNoteButton.setOnClickListener(v -> listener.onSendNoteClicked());
|
mSendNoteButton.setOnClickListener(v -> listener.onSendNoteClicked());
|
||||||
|
final ColorStateList bgButtonColor = new ColorStateList(
|
||||||
|
new int[][]{
|
||||||
|
new int[]{android.R.attr.state_enabled}, // enabled
|
||||||
|
new int[]{-android.R.attr.state_enabled} // disabled
|
||||||
|
},
|
||||||
|
new int[]{
|
||||||
|
ContextCompat.getColor(
|
||||||
|
mSendNoteButton.getContext(), R.color.base_accent),
|
||||||
|
ContextCompat.getColor(mSendNoteButton.getContext(), R.color.button_accent_disabled)
|
||||||
|
});
|
||||||
|
final ColorStateList textButtonColor = new ColorStateList(
|
||||||
|
new int[][]{
|
||||||
|
new int[]{android.R.attr.state_enabled}, // enabled
|
||||||
|
new int[]{-android.R.attr.state_enabled} // disabled
|
||||||
|
},
|
||||||
|
new int[]{
|
||||||
|
ContextCompat.getColor(
|
||||||
|
mSendNoteButton.getContext(),
|
||||||
|
UiUtils.getStyledResourceId(mSendNoteButton.getContext(), android.R.attr.textColorPrimaryInverse)),
|
||||||
|
ContextCompat.getColor(mSendNoteButton.getContext(), R.color.button_accent_text_disabled)
|
||||||
|
});
|
||||||
|
mSendNoteButton.setBackgroundTintList(bgButtonColor);
|
||||||
|
mSendNoteButton.setTextColor(textButtonColor);
|
||||||
mNoteEditText.addTextChangedListener(new StringUtils.SimpleTextWatcher() {
|
mNoteEditText.addTextChangedListener(new StringUtils.SimpleTextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count)
|
public void onTextChanged(CharSequence s, int start, int before, int count)
|
||||||
|
|||||||
@@ -51,9 +51,8 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:background="?accentButtonBackground"
|
|
||||||
android:layout_marginTop="@dimen/margin_base"
|
android:layout_marginTop="@dimen/margin_base"
|
||||||
android:enabled="true"
|
android:enabled="false"
|
||||||
android:text="@string/editor_report_problem_send_button"
|
android:text="@string/editor_report_problem_send_button"
|
||||||
app:backgroundTint="@null"/>
|
android:textColor="?android:textColorPrimaryInverse" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
Reference in New Issue
Block a user