Update some buttons

This commit is contained in:
0xd9a 2025-04-03 17:24:29 +05:30
parent c542f97df0
commit dc486381ff
4 changed files with 40 additions and 27 deletions

View file

@ -34,6 +34,7 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.content.res.ColorStateList;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.database.Cursor; import android.database.Cursor;
@ -99,6 +100,7 @@ import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners; import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.load.resource.gif.GifDrawable; import com.bumptech.glide.load.resource.gif.GifDrawable;
import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
@ -1461,6 +1463,24 @@ public class Helper {
imageView.setColorFilter(color); imageView.setColorFilter(color);
} }
/**
* change color of a drawable
*
* @param materialButton {@link MaterialButton}
* @param hexaColor example 0xffff00
*/
public static void changeDrawableColor(Context context, MaterialButton materialButton, int hexaColor) {
if (materialButton == null)
return;
int color;
try {
color = context.getResources().getColor(hexaColor);
} catch (Resources.NotFoundException e) {
color = hexaColor;
}
materialButton.setIconTint(ColorStateList.valueOf(color));
}
/** /**
* change color of a drawable * change color of a drawable
* *

View file

@ -1279,8 +1279,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
holder.binding.actionButtonReply.getLayoutParams().height = (int) (normalSize * scaleIcon); holder.binding.actionButtonReply.getLayoutParams().height = (int) (normalSize * scaleIcon);
holder.binding.actionButtonReply.requestLayout(); holder.binding.actionButtonReply.requestLayout();
holder.binding.actionButtonTranslate.getLayoutParams().width = (int) (normalSize * scaleIcon); holder.binding.actionButtonTranslate.setIconSize((int) (normalSize * scaleIcon));
holder.binding.actionButtonTranslate.getLayoutParams().height = (int) (normalSize * scaleIcon);
holder.binding.actionButtonTranslate.requestLayout(); holder.binding.actionButtonTranslate.requestLayout();
holder.binding.actionButtonBoost.setImageSize((int) (normalSize * scaleIcon)); holder.binding.actionButtonBoost.setImageSize((int) (normalSize * scaleIcon));
@ -1292,8 +1291,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
holder.binding.statusAddCustomEmoji.getLayoutParams().height = (int) (normalSize * scaleIcon); holder.binding.statusAddCustomEmoji.getLayoutParams().height = (int) (normalSize * scaleIcon);
holder.binding.statusAddCustomEmoji.requestLayout(); holder.binding.statusAddCustomEmoji.requestLayout();
holder.binding.actionButtonQuote.getLayoutParams().width = (int) (normalSize * scaleIcon); holder.binding.actionButtonQuote.setIconSize((int) (normalSize * scaleIcon));
holder.binding.actionButtonQuote.getLayoutParams().height = (int) (normalSize * scaleIcon);
holder.binding.actionButtonQuote.requestLayout(); holder.binding.actionButtonQuote.requestLayout();
holder.binding.statusEmoji.getLayoutParams().width = (int) (normalSize * scaleIcon); holder.binding.statusEmoji.getLayoutParams().width = (int) (normalSize * scaleIcon);

View file

@ -726,23 +726,20 @@
</androidx.appcompat.widget.LinearLayoutCompat> </androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.AppCompatImageView <com.google.android.material.button.MaterialButton
android:id="@+id/action_button_quote" android:id="@+id/action_button_quote"
android:layout_width="28dp" style="@style/Widget.Material3.Button.IconButton"
android:layout_height="28dp" android:layout_width="48dp"
android:layout_gravity="center" android:layout_height="48dp"
android:adjustViewBounds="true"
android:background="@color/transparent"
android:clickable="true"
android:contentDescription="@string/action_quote" android:contentDescription="@string/action_quote"
android:focusable="true" app:icon="@drawable/ic_baseline_format_quote_24"
android:src="@drawable/ic_baseline_format_quote_24" app:iconGravity="textStart"
android:visibility="gone" app:iconSize="28dp"
app:iconTint="?colorControlNormal"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/action_button_favorite_container" app:layout_constraintEnd_toStartOf="@+id/action_button_favorite_container"
app:layout_constraintStart_toEndOf="@+id/action_button_boost_container" app:layout_constraintStart_toEndOf="@+id/action_button_boost_container"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent" />
tools:visibility="visible" />
<androidx.appcompat.widget.LinearLayoutCompat <androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/action_button_favorite_container" android:id="@+id/action_button_favorite_container"
@ -797,18 +794,17 @@
sparkbutton:iconSize="28dp" /> sparkbutton:iconSize="28dp" />
<androidx.appcompat.widget.AppCompatImageView <com.google.android.material.button.MaterialButton
android:id="@+id/action_button_translate" android:id="@+id/action_button_translate"
android:layout_width="28dp" style="@style/Widget.Material3.Button.IconButton"
android:layout_height="28dp" android:layout_width="48dp"
android:layout_gravity="center" android:layout_height="48dp"
android:adjustViewBounds="true"
android:background="@color/transparent"
android:clickable="true"
android:contentDescription="@string/translate" android:contentDescription="@string/translate"
android:focusable="true"
android:src="@drawable/ic_baseline_translate_24"
android:visibility="gone" android:visibility="gone"
app:icon="@drawable/ic_baseline_translate_24"
app:iconGravity="textStart"
app:iconSize="28dp"
app:iconTint="?colorControlNormal"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/action_button_maths" app:layout_constraintEnd_toStartOf="@+id/action_button_maths"
app:layout_constraintStart_toEndOf="@+id/action_button_bookmark" app:layout_constraintStart_toEndOf="@+id/action_button_bookmark"

View file

@ -36,12 +36,11 @@
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/settings" android:id="@+id/settings"
style="@style/Widget.Material3.Button.OutlinedButton.Icon" style="@style/Widget.Material3.Button.IconButton.Outlined"
android:layout_width="48dp" android:layout_width="48dp"
android:layout_height="48dp" android:layout_height="48dp"
android:layout_gravity="center" android:layout_gravity="center"
android:contentDescription="@string/more_options" android:contentDescription="@string/more_options"
android:minWidth="48dp"
app:icon="@drawable/ic_more" /> app:icon="@drawable/ic_more" />
</androidx.appcompat.widget.LinearLayoutCompat> </androidx.appcompat.widget.LinearLayoutCompat>