Fix issue #128 - Better indicator for media descriptions when composing
This commit is contained in:
parent
132f48fbef
commit
a680b11e96
|
@ -263,6 +263,44 @@ public class ThemeHelper {
|
||||||
return readValues;
|
return readValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow to set colors for no description on media
|
||||||
|
*
|
||||||
|
* @param context - Context
|
||||||
|
* @return - ColorStateList
|
||||||
|
*/
|
||||||
|
public static ColorStateList getNoDescriptionColorStateList(Context context) {
|
||||||
|
int[][] states = new int[][]{
|
||||||
|
new int[]{android.R.attr.state_selected},
|
||||||
|
new int[]{-android.R.attr.state_selected},
|
||||||
|
};
|
||||||
|
int[] colors = new int[]{
|
||||||
|
ContextCompat.getColor(context, R.color.no_description),
|
||||||
|
ContextCompat.getColor(context, R.color.no_description),
|
||||||
|
};
|
||||||
|
return new ColorStateList(states, colors);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow to set colors for having description on media
|
||||||
|
*
|
||||||
|
* @param context - Context
|
||||||
|
* @return - ColorStateList
|
||||||
|
*/
|
||||||
|
public static ColorStateList getHavingDescriptionColorStateList(Context context) {
|
||||||
|
int[][] states = new int[][]{
|
||||||
|
new int[]{android.R.attr.state_selected},
|
||||||
|
new int[]{-android.R.attr.state_selected},
|
||||||
|
};
|
||||||
|
int[] colors = new int[]{
|
||||||
|
ContextCompat.getColor(context, R.color.having_description),
|
||||||
|
ContextCompat.getColor(context, R.color.having_description),
|
||||||
|
};
|
||||||
|
return new ColorStateList(states, colors);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow to set colors for tablayout
|
* Allow to set colors for tablayout
|
||||||
*
|
*
|
||||||
|
|
|
@ -98,6 +98,7 @@ import app.fedilab.android.databinding.PopupMediaDescriptionBinding;
|
||||||
import app.fedilab.android.exception.DBException;
|
import app.fedilab.android.exception.DBException;
|
||||||
import app.fedilab.android.helper.Helper;
|
import app.fedilab.android.helper.Helper;
|
||||||
import app.fedilab.android.helper.MastodonHelper;
|
import app.fedilab.android.helper.MastodonHelper;
|
||||||
|
import app.fedilab.android.helper.ThemeHelper;
|
||||||
import app.fedilab.android.viewmodel.mastodon.AccountsVM;
|
import app.fedilab.android.viewmodel.mastodon.AccountsVM;
|
||||||
import app.fedilab.android.viewmodel.mastodon.SearchVM;
|
import app.fedilab.android.viewmodel.mastodon.SearchVM;
|
||||||
import es.dmoral.toasty.Toasty;
|
import es.dmoral.toasty.Toasty;
|
||||||
|
@ -556,9 +557,17 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||||
});
|
});
|
||||||
composeAttachmentItemBinding.preview.setOnClickListener(v -> displayAttachments(holder, position, finalMediaPosition));
|
composeAttachmentItemBinding.preview.setOnClickListener(v -> displayAttachments(holder, position, finalMediaPosition));
|
||||||
if (attachment.description == null || attachment.description.trim().isEmpty()) {
|
if (attachment.description == null || attachment.description.trim().isEmpty()) {
|
||||||
ImageViewCompat.setImageTintList(composeAttachmentItemBinding.buttonDescription, ColorStateList.valueOf(ContextCompat.getColor(context, R.color.errorColor)));
|
composeAttachmentItemBinding.buttonDescription.setIconResource(R.drawable.ic_baseline_warning_24);
|
||||||
|
composeAttachmentItemBinding.buttonDescription.setStrokeColor(ThemeHelper.getNoDescriptionColorStateList(context));
|
||||||
|
composeAttachmentItemBinding.buttonDescription.setTextColor(ContextCompat.getColor(context, R.color.no_description));
|
||||||
|
Helper.changeDrawableColor(context, R.drawable.ic_baseline_warning_24, ContextCompat.getColor(context, R.color.no_description));
|
||||||
|
composeAttachmentItemBinding.buttonDescription.setIconTint(ThemeHelper.getNoDescriptionColorStateList(context));
|
||||||
} else {
|
} else {
|
||||||
ImageViewCompat.setImageTintList(composeAttachmentItemBinding.buttonDescription, ColorStateList.valueOf(ContextCompat.getColor(context, R.color.successColor)));
|
composeAttachmentItemBinding.buttonDescription.setIconTint(ThemeHelper.getHavingDescriptionColorStateList(context));
|
||||||
|
composeAttachmentItemBinding.buttonDescription.setIconResource(R.drawable.ic_baseline_check_circle_24);
|
||||||
|
composeAttachmentItemBinding.buttonDescription.setTextColor(ContextCompat.getColor(context, R.color.having_description));
|
||||||
|
composeAttachmentItemBinding.buttonDescription.setStrokeColor(ThemeHelper.getHavingDescriptionColorStateList(context));
|
||||||
|
Helper.changeDrawableColor(context, R.drawable.ic_baseline_check_circle_24, ContextCompat.getColor(context, R.color.having_description));
|
||||||
}
|
}
|
||||||
holder.binding.attachmentsList.addView(composeAttachmentItemBinding.getRoot());
|
holder.binding.attachmentsList.addView(composeAttachmentItemBinding.getRoot());
|
||||||
mediaPosition++;
|
mediaPosition++;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
android:height="24dp"
|
android:height="24dp"
|
||||||
android:viewportWidth="24"
|
android:viewportWidth="24"
|
||||||
android:viewportHeight="24"
|
android:viewportHeight="24"
|
||||||
android:tint="?attr/colorControlNormal">
|
android:tint="@color/having_description">
|
||||||
<path
|
<path
|
||||||
android:fillColor="@android:color/white"
|
android:fillColor="@android:color/white"
|
||||||
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM10,17l-5,-5 1.41,-1.41L10,14.17l7.59,-7.59L19,8l-9,9z" />
|
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM10,17l-5,-5 1.41,-1.41L10,14.17l7.59,-7.59L19,8l-9,9z" />
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="?attr/colorControlNormal"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z" />
|
||||||
|
</vector>
|
|
@ -0,0 +1,10 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="@color/no_description"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M1,21h22L12,2 1,21zM13,18h-2v-2h2v2zM13,14h-2v-4h2v4z" />
|
||||||
|
</vector>
|
|
@ -23,6 +23,7 @@
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:src="@tools:sample/backgrounds/scenic" />
|
tools:src="@tools:sample/backgrounds/scenic" />
|
||||||
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageButton
|
<androidx.appcompat.widget.AppCompatImageButton
|
||||||
android:id="@+id/button_play"
|
android:id="@+id/button_play"
|
||||||
style="@style/Widget.AppCompat.Button.Borderless"
|
style="@style/Widget.AppCompat.Button.Borderless"
|
||||||
|
@ -37,6 +38,15 @@
|
||||||
app:layout_constraintStart_toStartOf="@id/preview"
|
app:layout_constraintStart_toStartOf="@id/preview"
|
||||||
app:layout_constraintTop_toTopOf="@id/preview" />
|
app:layout_constraintTop_toTopOf="@id/preview" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageButton
|
||||||
|
android:id="@+id/edit_preview"
|
||||||
|
android:layout_width="36dp"
|
||||||
|
android:layout_height="36dp"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:backgroundTint="@color/editColor"
|
||||||
|
android:src="@drawable/ic_baseline_mode_edit_24"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageButton
|
<androidx.appcompat.widget.AppCompatImageButton
|
||||||
android:id="@+id/button_remove"
|
android:id="@+id/button_remove"
|
||||||
|
@ -58,17 +68,24 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/preview" />
|
app:layout_constraintTop_toBottomOf="@id/preview" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/button_description"
|
android:id="@+id/button_description"
|
||||||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
||||||
android:layout_width="48dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:adjustViewBounds="true"
|
android:layout_marginStart="2dp"
|
||||||
android:src="@drawable/ic_compose_attachment_description"
|
android:layout_marginEnd="2dp"
|
||||||
|
android:text="@string/description"
|
||||||
|
android:textAlignment="textStart"
|
||||||
|
android:textColor="@color/no_description"
|
||||||
|
app:icon="@drawable/ic_baseline_warning_24"
|
||||||
|
app:iconGravity="end"
|
||||||
|
app:strokeColor="@color/no_description"
|
||||||
app:layout_constraintEnd_toStartOf="@id/button_order_down"
|
app:layout_constraintEnd_toStartOf="@id/button_order_down"
|
||||||
app:layout_constraintStart_toEndOf="@id/button_order_up"
|
app:layout_constraintStart_toEndOf="@id/button_order_up"
|
||||||
app:layout_constraintTop_toBottomOf="@id/preview" />
|
app:layout_constraintTop_toBottomOf="@id/preview" />
|
||||||
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageButton
|
<androidx.appcompat.widget.AppCompatImageButton
|
||||||
android:id="@+id/button_order_down"
|
android:id="@+id/button_order_down"
|
||||||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
<color name="dark_text_toot_header">#d9d9d9</color>
|
<color name="dark_text_toot_header">#d9d9d9</color>
|
||||||
|
|
||||||
|
<color name="no_description">#FFEA00</color>
|
||||||
|
<color name="having_description">#42A5F5</color>
|
||||||
|
|
||||||
<color name="dark_text">#f3f3f3</color>
|
<color name="dark_text">#f3f3f3</color>
|
||||||
<color name="dark_icon">#606984</color>
|
<color name="dark_icon">#606984</color>
|
||||||
|
@ -112,6 +114,8 @@
|
||||||
<color name="chart_notif_mention">#0288D1</color>
|
<color name="chart_notif_mention">#0288D1</color>
|
||||||
<color name="chart_notif_follow">#512DA8</color>
|
<color name="chart_notif_follow">#512DA8</color>
|
||||||
|
|
||||||
|
<color name="editColor">#BDBDBD</color>
|
||||||
|
|
||||||
<!-- TOASTY -->
|
<!-- TOASTY -->
|
||||||
<color name="defaultTextColor">#2e2e2e</color>
|
<color name="defaultTextColor">#2e2e2e</color>
|
||||||
<color name="errorColor">#EF5350</color>
|
<color name="errorColor">#EF5350</color>
|
||||||
|
|
Loading…
Reference in New Issue