Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Commit

Permalink
hearts everywhere
Browse files Browse the repository at this point in the history
closes #846
  • Loading branch information
sk22 committed Oct 8, 2023
1 parent df49ef9 commit a5c197b
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.joinmastodon.android.api.requests.statuses.SetStatusBookmarked;
import org.joinmastodon.android.api.requests.statuses.SetStatusFavorited;
import org.joinmastodon.android.api.requests.statuses.SetStatusReblogged;
import org.joinmastodon.android.api.session.AccountLocalPreferences;
import org.joinmastodon.android.api.session.AccountSession;
import org.joinmastodon.android.api.session.AccountSessionManager;
import org.joinmastodon.android.model.Account;
Expand Down Expand Up @@ -158,6 +159,7 @@ public void notifyUnifiedPush(Context context, String accountID, org.joinmastodo
private void notify(Context context, PushNotification pn, String accountID, org.joinmastodon.android.model.Notification notification){
NotificationManager nm=context.getSystemService(NotificationManager.class);
AccountSession session=AccountSessionManager.get(accountID);
AccountLocalPreferences lp=session.getLocalPreferences();
Account self=session.self;
String accountName="@"+self.username+"@"+AccountSessionManager.getInstance().getAccount(accountID).domain;
Notification.Builder builder;
Expand Down Expand Up @@ -212,7 +214,7 @@ private void notify(Context context, PushNotification pn, String accountID, org.

if (!GlobalUserPreferences.uniformNotificationIcon) {
builder.setSmallIcon(switch (pn.notificationType) {
case FAVORITE -> R.drawable.ic_fluent_star_24_filled;
case FAVORITE -> lp.likeIcon ? R.drawable.ic_fluent_heart_24_filled : R.drawable.ic_fluent_star_24_filled;
case REBLOG -> R.drawable.ic_fluent_arrow_repeat_all_24_filled;
case FOLLOW -> R.drawable.ic_fluent_person_add_24_filled;
case MENTION -> R.drawable.ic_fluent_mention_24_filled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ private boolean onFavoriteLongClick(View v) {
R.string.sk_favorite_as,
R.string.sk_favorited_as,
R.string.sk_already_favorited,
R.drawable.ic_fluent_star_28_regular
AccountSessionManager.get(item.accountID).getLocalPreferences().likeIcon ?
R.drawable.ic_fluent_heart_28_regular : R.drawable.ic_fluent_star_28_regular
);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.joinmastodon.android.GlobalUserPreferences;
import org.joinmastodon.android.R;
import org.joinmastodon.android.api.session.AccountLocalPreferences;
import org.joinmastodon.android.api.session.AccountSession;
import org.joinmastodon.android.api.session.AccountSessionManager;
import org.joinmastodon.android.fragments.BaseStatusListFragment;
Expand Down Expand Up @@ -47,12 +48,14 @@ public class NotificationHeaderStatusDisplayItem extends StatusDisplayItem{
private final CustomEmojiHelper emojiHelper=new CustomEmojiHelper();
private final CharSequence text;
private final CharSequence timestamp;
private final AccountLocalPreferences lp;

public NotificationHeaderStatusDisplayItem(String parentID, BaseStatusListFragment parentFragment, Notification notification, String accountID){
super(parentID, parentFragment);
this.notification=notification;
this.accountID=accountID;
this.timestamp=notification.createdAt==null ? null : UiUtils.formatRelativeTimestamp(context, notification.createdAt);
this.lp=AccountSessionManager.get(accountID).getLocalPreferences();

if(notification.type==Notification.Type.POLL){
text=parentFragment.getString(R.string.poll_ended);
Expand Down Expand Up @@ -158,7 +161,7 @@ public void onBind(NotificationHeaderStatusDisplayItem item){
timestamp.setText(item.timestamp);
avatar.setVisibility(item.notification.type==Notification.Type.POLL ? View.GONE : View.VISIBLE);
icon.setImageResource(switch(item.notification.type){
case FAVORITE -> R.drawable.ic_fluent_star_24_filled;
case FAVORITE -> item.lp.likeIcon ? R.drawable.ic_fluent_heart_24_filled : R.drawable.ic_fluent_star_24_filled;
case REBLOG -> R.drawable.ic_fluent_arrow_repeat_all_24_filled;
case FOLLOW, FOLLOW_REQUEST -> R.drawable.ic_fluent_person_add_24_filled;
case POLL -> R.drawable.ic_fluent_poll_24_filled;
Expand All @@ -169,7 +172,7 @@ public void onBind(NotificationHeaderStatusDisplayItem item){
default -> throw new IllegalStateException("Unexpected value: "+item.notification.type);
});
icon.setImageTintList(ColorStateList.valueOf(UiUtils.getThemeColor(item.parentFragment.getActivity(), switch(item.notification.type){
case FAVORITE -> R.attr.colorFavorite;
case FAVORITE -> item.lp.likeIcon ? R.attr.colorLike : R.attr.colorFavorite;
case REBLOG -> R.attr.colorBoost;
case POLL -> R.attr.colorPoll;
default -> android.R.attr.colorAccent;
Expand Down
3 changes: 3 additions & 0 deletions mastodon/src/main/res/drawable/ic_fluent_heart_28_regular.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="28dp" android:height="28dp" android:viewportWidth="28" android:viewportHeight="28">
<path android:pathData="M14.604 6.193c2.601-2.932 7.184-2.922 9.772 0.02 2.263 2.574 2.148 6.459-0.263 8.893l-9.58 9.672C14.392 24.92 14.2 25 14 25s-0.392-0.08-0.533-0.222l-9.58-9.672c-2.41-2.434-2.526-6.32-0.263-8.892 2.588-2.943 7.17-2.953 9.772-0.021L14 6.873l0.604-0.68zm8.646 1.011c-1.993-2.266-5.521-2.274-7.524-0.016L14.56 8.501C14.419 8.66 14.214 8.753 14 8.753c-0.215 0-0.419-0.092-0.561-0.252l-1.165-1.313c-2.003-2.257-5.53-2.25-7.524 0.016-1.742 1.981-1.653 4.973 0.203 6.847L14 23.184l9.047-9.133c1.856-1.874 1.945-4.866 0.203-6.847z" android:fillColor="@color/fluent_default_icon_tint"/>
</vector>
1 change: 1 addition & 0 deletions mastodon/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<attr name="colorSensitiveOverlay" format="color"/>
<attr name="colorWhite" format="color"/>
<attr name="colorFavorite" format="color" />
<attr name="colorLike" format="color" />
<attr name="colorBoost" format="color" />
<attr name="colorPoll" format="color" />
<attr name="colorProfileHeaderBackground" format="color"/>
Expand Down
1 change: 1 addition & 0 deletions mastodon/src/main/res/values/palettes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<item name="colorM3PrimaryInverse">?colorPrimary200</item>

<item name="colorFavorite">@color/favorite_selected</item>
<item name="colorLike">@color/like_selected</item>
<item name="colorBoost">?colorM3Primary</item>
<item name="colorPoll">@color/bookmark_selected</item>
<item name="colorTabBarAlpha">#14000000</item>
Expand Down

0 comments on commit a5c197b

Please sign in to comment.