From 1fbce05dbd45f65d21b9d0aaf88a57670cf1109c Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 29 Nov 2022 11:06:37 +0100 Subject: [PATCH] Improvements --- app/src/main/AndroidManifest.xml | 8 +- .../app/fedilab/android/BaseMainActivity.java | 2 - .../android/helper/SpannableHelper.java | 11 -- .../fedilab/android/helper/ThemeHelper.java | 14 --- .../android/ui/drawer/ComposeAdapter.java | 28 +---- .../ui/drawer/ConversationAdapter.java | 26 +--- .../ui/drawer/NotificationAdapter.java | 17 +-- .../android/ui/drawer/StatusAdapter.java | 112 ----------------- .../ui/drawer/StatusHistoryAdapter.java | 28 ----- .../android/ui/drawer/TopMenuAdapter.java | 117 ------------------ .../res/layout/activity_instance_profile.xml | 1 - app/src/main/res/layout/nav_header_main.xml | 7 +- app/src/main/res/layout/row_emoji.xml | 1 - .../res/navigation/nav_graph_settings.xml | 14 +-- app/src/main/res/values-night/themes.xml | 2 + app/src/main/res/values/themes.xml | 2 + 16 files changed, 20 insertions(+), 370 deletions(-) delete mode 100644 app/src/main/java/app/fedilab/android/ui/drawer/TopMenuAdapter.java diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a9e48709c..88f68aaa6 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -293,15 +293,15 @@ android:name=".activities.InstanceActivity" android:configChanges="keyboardHidden|orientation|screenSize" android:label="@string/action_about_instance" - android:theme="@style/Theme.Material3.Dark.Dialog.Alert" /> + android:theme="@style/AlertDialog" /> + android:theme="@style/AlertDialog" /> + android:theme="@style/AlertDialog" /> @@ -316,7 +316,7 @@ + android:theme="@style/AlertDialog" /> { if (instanceInfo.configuration.media_attachments.supported_mime_types != null) { if (instanceInfo.getMimeTypeAudio().size() == 0) { diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/ConversationAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/ConversationAdapter.java index b266bda29..d64834d3c 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/ConversationAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/ConversationAdapter.java @@ -88,31 +88,9 @@ public class ConversationAdapter extends RecyclerView.Adapter(holderFollow.binding.displayName)), TextView.BufferType.SPANNABLE); holderFollow.binding.username.setText(String.format("@%s", notification.account.acct)); - SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context); - int theme_icons_color = -1; - int theme_text_color = -1; - if (sharedpreferences.getBoolean("use_custom_theme", false)) { - //Getting custom colors - theme_icons_color = sharedpreferences.getInt("theme_icons_color", -1); - theme_text_color = sharedpreferences.getInt("theme_text_color", -1); - } - if (theme_icons_color != -1) { - Helper.changeDrawableColor(context, holderFollow.binding.cacheIndicator, theme_icons_color); - } - if (theme_text_color != -1) { - holderFollow.binding.displayName.setTextColor(theme_text_color); - holderFollow.binding.username.setTextColor(theme_text_color); - holderFollow.binding.title.setTextColor(theme_text_color); - } + holderFollow.binding.rejectButton.setVisibility(View.GONE); holderFollow.binding.acceptButton.setVisibility(View.GONE); if (getItemViewType(position) == TYPE_FOLLOW_REQUEST) { diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java index a3fb426e0..f4204b885 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java @@ -46,9 +46,7 @@ import android.os.Handler; import android.os.Looper; import android.text.Html; import android.text.SpannableString; -import android.text.Spanned; import android.text.TextUtils; -import android.text.style.ForegroundColorSpan; import android.util.TypedValue; import android.view.LayoutInflater; import android.view.MotionEvent; @@ -498,56 +496,12 @@ public class StatusAdapter extends RecyclerView.Adapter } int truncate_toots_size = sharedpreferences.getInt(context.getString(R.string.SET_TRUNCATE_TOOTS_SIZE), 0); - // boolean display_video_preview = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_VIDEO_PREVIEWS), true); - // boolean isModerator = sharedpreferences.getBoolean(Helper.PREF_IS_MODERATOR, false); - // boolean isAdmin = sharedpreferences.getBoolean(Helper.PREF_IS_ADMINISTRATOR, false); - int theme_icons_color = -1; - int theme_statuses_color = -1; - int theme_boost_header_color = -1; - int theme_text_color = -1; - int theme_text_header_1_line = -1; - int theme_text_header_2_line = -1; - int link_color = -1; - /* if (sharedpreferences.getBoolean("use_custom_theme", false)) { - //Getting custom colors - theme_icons_color = sharedpreferences.getInt("theme_icons_color", -1); - theme_statuses_color = sharedpreferences.getInt("theme_statuses_color", -1); - theme_boost_header_color = sharedpreferences.getInt("theme_boost_header_color", -1); - theme_text_color = sharedpreferences.getInt("theme_text_color", -1); - theme_text_header_1_line = sharedpreferences.getInt("theme_text_header_1_line", -1); - theme_text_header_2_line = sharedpreferences.getInt("theme_text_header_2_line", -1); - theme_text_color = sharedpreferences.getInt("theme_text_color", -1); - link_color = sharedpreferences.getInt("theme_link_color", -1); - }*/ if (currentAccount != null && currentAccount.api == Account.API.PLEROMA) { holder.binding.statusAddCustomEmoji.setVisibility(View.VISIBLE); holder.binding.statusEmoji.setVisibility(View.VISIBLE); } - if (theme_icons_color != -1) { - Helper.changeDrawableColor(context, holder.binding.actionButtonReply, theme_icons_color); - Helper.changeDrawableColor(context, holder.binding.cacheIndicator, theme_icons_color); - Helper.changeDrawableColor(context, holder.binding.statusAddCustomEmoji, theme_icons_color); - Helper.changeDrawableColor(context, holder.binding.statusEmoji, theme_icons_color); - Helper.changeDrawableColor(context, holder.binding.actionButtonMore, theme_icons_color); - Helper.changeDrawableColor(context, R.drawable.ic_baseline_star_24, theme_icons_color); - Helper.changeDrawableColor(context, R.drawable.ic_repeat, theme_icons_color); - Helper.changeDrawableColor(context, holder.binding.visibility, theme_icons_color); - Helper.changeDrawableColor(context, R.drawable.ic_star_outline, theme_icons_color); - Helper.changeDrawableColor(context, R.drawable.ic_person, theme_icons_color); - Helper.changeDrawableColor(context, R.drawable.ic_bot, theme_icons_color); - Helper.changeDrawableColor(context, R.drawable.ic_baseline_reply_16, theme_icons_color); - holder.binding.actionButtonFavorite.setInActiveImageTintColor(theme_icons_color); - holder.binding.actionButtonBookmark.setInActiveImageTintColor(theme_icons_color); - holder.binding.actionButtonBoost.setInActiveImageTintColor(theme_icons_color); - holder.binding.replyCount.setTextColor(theme_icons_color); - } else { - holder.binding.actionButtonFavorite.setInActiveImageTintColor(ThemeHelper.getAttColor(context, R.attr.colorControlNormal)); - holder.binding.actionButtonBookmark.setInActiveImageTintColor(ThemeHelper.getAttColor(context, R.attr.colorControlNormal)); - holder.binding.actionButtonBoost.setInActiveImageTintColor(ThemeHelper.getAttColor(context, R.attr.colorControlNormal)); - } - holder.binding.actionButtonFavorite.pressOnTouch(false); holder.binding.actionButtonBoost.pressOnTouch(false); holder.binding.actionButtonBookmark.pressOnTouch(false); @@ -574,56 +528,6 @@ public class StatusAdapter extends RecyclerView.Adapter holder.binding.statusPinned.setVisibility(View.GONE); } - if (theme_text_header_2_line != -1) { - Pattern hashAcct; - SpannableString wordToSpan; - if (status.reblog != null) { - wordToSpan = new SpannableString("@" + status.reblog.account.acct); - hashAcct = Pattern.compile("(@" + status.reblog.account.acct + ")"); - } else { - wordToSpan = new SpannableString("@" + status.account.acct); - hashAcct = Pattern.compile("(@" + status.account.acct + ")"); - } - Matcher matcherAcct = hashAcct.matcher(wordToSpan); - while (matcherAcct.find()) { - int matchStart = matcherAcct.start(1); - int matchEnd = matcherAcct.end(); - if (wordToSpan.length() >= matchEnd && matchStart < matchEnd && matchStart >= 0) { - wordToSpan.setSpan(new ForegroundColorSpan(theme_text_header_2_line), matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); - } - } - Helper.changeDrawableColor(context, holder.binding.statusBoostIcon, theme_text_header_2_line); - Helper.changeDrawableColor(context, holder.binding.statusPinned, theme_text_header_2_line); - } - if (theme_statuses_color != -1) { - holder.binding.cardviewContainer.setBackgroundColor(theme_statuses_color); - holder.binding.translationLabel.setBackgroundColor(theme_statuses_color); - } - if (theme_boost_header_color != -1 && status.reblog != null) { - holder.binding.statusBoosterInfo.setBackgroundColor(theme_boost_header_color); - - } else { - holder.binding.statusBoosterInfo.setBackgroundColor(0); - } - if (theme_text_color != -1) { - holder.binding.statusContent.setTextColor(theme_text_color); - holder.binding.statusContentTranslated.setTextColor(theme_text_color); - holder.binding.spoiler.setTextColor(theme_text_color); - holder.binding.dateShort.setTextColor(theme_text_color); - holder.binding.poll.pollInfo.setTextColor(theme_text_color); - holder.binding.cardDescription.setTextColor(theme_text_color); - holder.binding.time.setTextColor(theme_text_color); - holder.binding.reblogsCount.setTextColor(theme_text_color); - holder.binding.favoritesCount.setTextColor(theme_text_color); - holder.binding.favoritesCount.setTextColor(theme_text_color); - Helper.changeDrawableColor(context, holder.binding.repeatInfo, theme_text_color); - Helper.changeDrawableColor(context, holder.binding.favInfo, theme_text_color); - Helper.changeDrawableColor(context, R.drawable.ic_baseline_lock_24, theme_text_color); - } - if (link_color != -1) { - holder.binding.cardUrl.setTextColor(link_color); - } - holder.binding.toggleTruncate.setVisibility(View.GONE); if (status.isFocused) { @@ -952,13 +856,7 @@ public class StatusAdapter extends RecyclerView.Adapter statusToDeal.account.getSpanDisplayName(context, new WeakReference<>(holder.binding.displayName)), TextView.BufferType.SPANNABLE); - if (theme_text_header_1_line != -1) { - holder.binding.displayName.setTextColor(theme_text_header_1_line); - } holder.binding.username.setText(String.format("@%s", statusToDeal.account.acct)); - if (theme_text_header_2_line != -1) { - holder.binding.username.setTextColor(theme_text_header_2_line); - } //final float scale = context.getResources().getDisplayMetrics().density; final float scale = sharedpreferences.getFloat(context.getString(R.string.SET_FONT_SCALE), 1.1f); final float scaleIcon = sharedpreferences.getFloat(context.getString(R.string.SET_FONT_SCALE_ICON), 1.1f); @@ -1130,13 +1028,7 @@ public class StatusAdapter extends RecyclerView.Adapter TextView.BufferType.SPANNABLE); holder.binding.statusBoosterInfo.setVisibility(View.VISIBLE); - if (theme_text_header_1_line != -1) { - holder.binding.statusBoosterDisplayName.setTextColor(theme_text_header_1_line); - } holder.binding.statusBoosterUsername.setText(String.format("@%s", status.account.acct)); - if (theme_text_header_2_line != -1) { - holder.binding.statusBoosterUsername.setTextColor(theme_text_header_2_line); - } } else { holder.binding.statusBoosterInfo.setVisibility(View.GONE); } @@ -1513,10 +1405,6 @@ public class StatusAdapter extends RecyclerView.Adapter @NonNull LayoutPollItemBinding pollItemBinding = LayoutPollItemBinding.inflate(inflater, holder.binding.poll.rated, true); double value = ((double) (pollItem.votes_count * 100) / (double) statusToDeal.poll.voters_count); pollItemBinding.pollItemPercent.setText(String.format("%s %%", (int) value)); - if (theme_text_color != -1) { - pollItemBinding.pollItemPercent.setTextColor(theme_text_color); - pollItemBinding.pollItemText.setTextColor(theme_text_color); - } pollItemBinding.pollItemText.setText( pollItem.getSpanTitle(context, statusToDeal, new WeakReference<>(pollItemBinding.pollItemText)), diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/StatusHistoryAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/StatusHistoryAdapter.java index 2d81d805f..66c2504ca 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/StatusHistoryAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/StatusHistoryAdapter.java @@ -15,14 +15,12 @@ package app.fedilab.android.ui.drawer; * see . */ import android.content.Context; -import android.content.SharedPreferences; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import androidx.annotation.NonNull; -import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.RecyclerView; import java.lang.ref.WeakReference; @@ -78,32 +76,6 @@ public class StatusHistoryAdapter extends RecyclerView.Adapter. */ - - -import android.content.Context; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.core.content.res.ResourcesCompat; -import androidx.recyclerview.widget.RecyclerView; - -import java.util.List; - -import app.fedilab.android.R; -import app.fedilab.android.client.entities.app.PinnedTimeline; -import app.fedilab.android.client.entities.app.Timeline; -import app.fedilab.android.databinding.DrawerTopMenuItemBinding; - - -public class TopMenuAdapter extends RecyclerView.Adapter { - private final List pinnedTimelines; - public TopMenuClicked itemListener; - private Context _mContext; - - public TopMenuAdapter(List pinnedTimelines) { - this.pinnedTimelines = pinnedTimelines; - } - - public int getCount() { - return pinnedTimelines.size(); - } - - public PinnedTimeline getItem(int position) { - return pinnedTimelines.get(position); - } - - @NonNull - @Override - public TopMenuHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - _mContext = parent.getContext(); - DrawerTopMenuItemBinding itemBinding = DrawerTopMenuItemBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false); - return new TopMenuHolder(itemBinding); - } - - @Override - public void onBindViewHolder(@NonNull TopMenuHolder holder, int position) { - - PinnedTimeline pinnedTimeline = pinnedTimelines.get(position); - if (pinnedTimeline.displayed) { - String name = ""; - if (pinnedTimeline.type == Timeline.TimeLineEnum.LIST) { - name = pinnedTimeline.mastodonList.title; - } else if (pinnedTimeline.type == Timeline.TimeLineEnum.TAG) { - name = pinnedTimeline.tagTimeline.name; - } else if (pinnedTimeline.type == Timeline.TimeLineEnum.REMOTE) { - name = pinnedTimeline.remoteInstance.host; - } - holder.binding.name.setText(name); - holder.binding.getRoot().setVisibility(View.VISIBLE); - } else { - holder.binding.getRoot().setVisibility(View.GONE); - } - holder.binding.getRoot().setOnClickListener(v -> itemListener.onClick(v, pinnedTimeline, position)); - holder.binding.getRoot().setOnLongClickListener(v -> { - itemListener.onLongClick(holder.binding.getRoot(), pinnedTimeline, position); - return true; - }); - //Manage item decoration below the text - if (pinnedTimeline.isSelected) { - holder.binding.underline.setVisibility(View.VISIBLE); - holder.binding.name.setTextColor(ResourcesCompat.getColor(_mContext.getResources(), R.color.colorAccent, _mContext.getTheme())); - } else { - holder.binding.underline.setVisibility(View.GONE); - int textColor = _mContext.getResources().getColor(android.R.color.primary_text_dark); - holder.binding.name.setTextColor(textColor); - } - } - - public long getItemId(int position) { - return position; - } - - @Override - public int getItemCount() { - return pinnedTimelines.size(); - } - - public interface TopMenuClicked { - void onClick(View v, PinnedTimeline pinnedTimeline, int position); - - void onLongClick(View v, PinnedTimeline pinnedTimeline, int position); - } - - static class TopMenuHolder extends RecyclerView.ViewHolder { - DrawerTopMenuItemBinding binding; - - TopMenuHolder(DrawerTopMenuItemBinding itemView) { - super(itemView.getRoot()); - binding = itemView; - } - } -} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_instance_profile.xml b/app/src/main/res/layout/activity_instance_profile.xml index 30d44c58f..306150fb5 100644 --- a/app/src/main/res/layout/activity_instance_profile.xml +++ b/app/src/main/res/layout/activity_instance_profile.xml @@ -175,7 +175,6 @@ android:layout_marginTop="20dp" android:text="@string/close" android:textAllCaps="false" - android:textColor="@color/white" android:textSize="16sp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" diff --git a/app/src/main/res/layout/nav_header_main.xml b/app/src/main/res/layout/nav_header_main.xml index 98fa7e65b..da7defe5e 100644 --- a/app/src/main/res/layout/nav_header_main.xml +++ b/app/src/main/res/layout/nav_header_main.xml @@ -3,8 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="@dimen/nav_header_height" - android:theme="@style/ThemeOverlay.AppCompat.Dark"> + android:layout_height="@dimen/nav_header_height"> + tools:text="@tools:sample/full_names" /> \ No newline at end of file diff --git a/app/src/main/res/navigation/nav_graph_settings.xml b/app/src/main/res/navigation/nav_graph_settings.xml index 56b5caf27..7c3426b32 100644 --- a/app/src/main/res/navigation/nav_graph_settings.xml +++ b/app/src/main/res/navigation/nav_graph_settings.xml @@ -55,11 +55,7 @@ + app:destination="@id/ThemeSettingsActivity" /> - + + diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml index 4aa324080..5d26b8995 100644 --- a/app/src/main/res/values-night/themes.xml +++ b/app/src/main/res/values-night/themes.xml @@ -83,4 +83,6 @@ true + +