Merge pull request #214
feat: Add haptic feedback on boost/favourite/bookmark
This commit is contained in:
commit
17227cdb7d
|
@ -52,6 +52,7 @@ public class GlobalUserPreferences{
|
||||||
public static boolean doubleTapToSwipe;
|
public static boolean doubleTapToSwipe;
|
||||||
public static boolean compactReblogReplyLine;
|
public static boolean compactReblogReplyLine;
|
||||||
public static boolean confirmBeforeReblog;
|
public static boolean confirmBeforeReblog;
|
||||||
|
public static boolean hapticFeedback;
|
||||||
public static boolean replyLineAboveHeader;
|
public static boolean replyLineAboveHeader;
|
||||||
public static boolean swapBookmarkWithBoostAction;
|
public static boolean swapBookmarkWithBoostAction;
|
||||||
public static boolean loadRemoteAccountFollowers;
|
public static boolean loadRemoteAccountFollowers;
|
||||||
|
@ -139,6 +140,7 @@ public class GlobalUserPreferences{
|
||||||
replyLineAboveHeader=prefs.getBoolean("replyLineAboveHeader", true);
|
replyLineAboveHeader=prefs.getBoolean("replyLineAboveHeader", true);
|
||||||
compactReblogReplyLine=prefs.getBoolean("compactReblogReplyLine", true);
|
compactReblogReplyLine=prefs.getBoolean("compactReblogReplyLine", true);
|
||||||
confirmBeforeReblog=prefs.getBoolean("confirmBeforeReblog", false);
|
confirmBeforeReblog=prefs.getBoolean("confirmBeforeReblog", false);
|
||||||
|
hapticFeedback=prefs.getBoolean("hapticFeedback", Build.VERSION.SDK_INT >= Build.VERSION_CODES.R);
|
||||||
swapBookmarkWithBoostAction=prefs.getBoolean("swapBookmarkWithBoostAction", false);
|
swapBookmarkWithBoostAction=prefs.getBoolean("swapBookmarkWithBoostAction", false);
|
||||||
loadRemoteAccountFollowers=prefs.getBoolean("loadRemoteAccountFollowers", true);
|
loadRemoteAccountFollowers=prefs.getBoolean("loadRemoteAccountFollowers", true);
|
||||||
mentionRebloggerAutomatically=prefs.getBoolean("mentionRebloggerAutomatically", false);
|
mentionRebloggerAutomatically=prefs.getBoolean("mentionRebloggerAutomatically", false);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.joinmastodon.android.fragments.settings;
|
package org.joinmastodon.android.fragments.settings;
|
||||||
|
|
||||||
|
import android.os.Build;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -63,6 +64,10 @@ public class BehaviourFragment extends SettingsBaseFragment{
|
||||||
GlobalUserPreferences.save();
|
GlobalUserPreferences.save();
|
||||||
needAppRestart=true;
|
needAppRestart=true;
|
||||||
}));
|
}));
|
||||||
|
items.add(new SwitchItem(R.string.mo_haptic_feedback, R.string.mo_setting_haptic_feedback_summary, R.drawable.ic_fluent_phone_vibrate_24_filled, GlobalUserPreferences.hapticFeedback, i -> {
|
||||||
|
GlobalUserPreferences.hapticFeedback = i.checked;
|
||||||
|
GlobalUserPreferences.save();
|
||||||
|
}, Build.VERSION.SDK_INT >= Build.VERSION_CODES.R));
|
||||||
items.add(new SwitchItem(R.string.sk_settings_confirm_before_reblog, R.drawable.ic_fluent_checkmark_circle_24_regular, GlobalUserPreferences.confirmBeforeReblog, i->{
|
items.add(new SwitchItem(R.string.sk_settings_confirm_before_reblog, R.drawable.ic_fluent_checkmark_circle_24_regular, GlobalUserPreferences.confirmBeforeReblog, i->{
|
||||||
GlobalUserPreferences.confirmBeforeReblog=i.checked;
|
GlobalUserPreferences.confirmBeforeReblog=i.checked;
|
||||||
GlobalUserPreferences.save();
|
GlobalUserPreferences.save();
|
||||||
|
|
|
@ -264,6 +264,15 @@ public abstract class SettingsBaseFragment extends MastodonToolbarFragment imple
|
||||||
this.onChanged=onChanged;
|
this.onChanged=onChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SwitchItem(@StringRes int title, @StringRes int summary, @DrawableRes int icon, boolean checked, Consumer<SwitchItem> onChanged, boolean enabled){
|
||||||
|
this.title=getString(title);
|
||||||
|
this.summary=getString(summary);
|
||||||
|
this.icon=icon;
|
||||||
|
this.checked=checked;
|
||||||
|
this.onChanged=onChanged;
|
||||||
|
this.enabled=enabled;
|
||||||
|
}
|
||||||
|
|
||||||
public SwitchItem(@StringRes int title, @DrawableRes int icon, boolean checked, Consumer<SwitchItem> onChanged, boolean enabled){
|
public SwitchItem(@StringRes int title, @DrawableRes int icon, boolean checked, Consumer<SwitchItem> onChanged, boolean enabled){
|
||||||
this.title=getString(title);
|
this.title=getString(title);
|
||||||
this.icon=icon;
|
this.icon=icon;
|
||||||
|
|
|
@ -5,7 +5,9 @@ import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.HapticFeedbackConstants;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -244,12 +246,14 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
|
||||||
if(status == null)
|
if(status == null)
|
||||||
return;
|
return;
|
||||||
boost.setSelected(!status.reblogged);
|
boost.setSelected(!status.reblogged);
|
||||||
|
vibrateForAction(boost, !status.reblogged);
|
||||||
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setReblogged(status, !status.reblogged, null, r->boostConsumer(v, r));
|
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setReblogged(status, !status.reblogged, null, r->boostConsumer(v, r));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boost.setSelected(!item.status.reblogged);
|
boost.setSelected(!item.status.reblogged);
|
||||||
|
vibrateForAction(boost, !item.status.reblogged);
|
||||||
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setReblogged(item.status, !item.status.reblogged, null, r->boostConsumer(v, r));
|
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setReblogged(item.status, !item.status.reblogged, null, r->boostConsumer(v, r));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,6 +365,7 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
|
||||||
if(status == null)
|
if(status == null)
|
||||||
return;
|
return;
|
||||||
favorite.setSelected(!status.favourited);
|
favorite.setSelected(!status.favourited);
|
||||||
|
vibrateForAction(favorite, !status.favourited);
|
||||||
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setFavorited(status, !status.favourited, r->{
|
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setFavorited(status, !status.favourited, r->{
|
||||||
if (status.favourited) {
|
if (status.favourited) {
|
||||||
v.startAnimation(GlobalUserPreferences.reduceMotion ? opacityIn : animSet);
|
v.startAnimation(GlobalUserPreferences.reduceMotion ? opacityIn : animSet);
|
||||||
|
@ -374,6 +379,7 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
favorite.setSelected(!item.status.favourited);
|
favorite.setSelected(!item.status.favourited);
|
||||||
|
vibrateForAction(favorite, !item.status.favourited);
|
||||||
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setFavorited(item.status, !item.status.favourited, r->{
|
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setFavorited(item.status, !item.status.favourited, r->{
|
||||||
if (item.status.favourited) {
|
if (item.status.favourited) {
|
||||||
v.startAnimation(GlobalUserPreferences.reduceMotion ? opacityIn : animSet);
|
v.startAnimation(GlobalUserPreferences.reduceMotion ? opacityIn : animSet);
|
||||||
|
@ -406,6 +412,7 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
|
||||||
if(status == null)
|
if(status == null)
|
||||||
return;
|
return;
|
||||||
bookmark.setSelected(!status.bookmarked);
|
bookmark.setSelected(!status.bookmarked);
|
||||||
|
vibrateForAction(bookmark, !status.bookmarked);
|
||||||
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setBookmarked(status, !status.bookmarked, r->{
|
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setBookmarked(status, !status.bookmarked, r->{
|
||||||
v.startAnimation(opacityIn);
|
v.startAnimation(opacityIn);
|
||||||
});
|
});
|
||||||
|
@ -414,6 +421,7 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bookmark.setSelected(!item.status.bookmarked);
|
bookmark.setSelected(!item.status.bookmarked);
|
||||||
|
vibrateForAction(bookmark, !item.status.bookmarked);
|
||||||
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setBookmarked(item.status, !item.status.bookmarked, r->{
|
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setBookmarked(item.status, !item.status.bookmarked, r->{
|
||||||
v.startAnimation(opacityIn);
|
v.startAnimation(opacityIn);
|
||||||
});
|
});
|
||||||
|
@ -459,5 +467,11 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
|
||||||
return R.string.button_share;
|
return R.string.button_share;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void vibrateForAction(View view, boolean isPositive) {
|
||||||
|
if (!GlobalUserPreferences.hapticFeedback) return;
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) return;
|
||||||
|
view.performHapticFeedback(isPositive ? HapticFeedbackConstants.CONFIRM : HapticFeedbackConstants.REJECT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:pathData="M15.75,2A2.25,2.25 0,0 1,18 4.25v15.5A2.25,2.25 0,0 1,15.75 22h-7.5A2.25,2.25 0,0 1,6 19.75L6,4.25A2.25,2.25 0,0 1,8.25 2h7.5ZM13.25,18h-2.5a0.75,0.75 0,0 0,-0.102 1.493l0.102,0.007h2.5a0.75,0.75 0,1 0,0 -1.5ZM20.129,7.572a1,1 0,0 1,1.25 0.45l0.05,0.107 0.582,1.456a3,3 0,0 1,-0.266 2.743l-0.12,0.171 -0.15,0.202a1,1 0,0 0,-0.17 0.848l0.041,0.123 0.582,1.457a1,1 0,0 1,-1.807 0.848l-0.05,-0.106 -0.582,-1.456a3,3 0,0 1,0.266 -2.743l0.12,-0.171 0.15,-0.202a1,1 0,0 0,0.17 -0.848l-0.04,-0.123 -0.583,-1.457a1,1 0,0 1,0.557 -1.3ZM2.629,7.572a1,1 0,0 1,1.25 0.45l0.05,0.107 0.582,1.456a3,3 0,0 1,-0.266 2.743l-0.12,0.171 -0.15,0.202a1,1 0,0 0,-0.17 0.848l0.041,0.123 0.583,1.457a1,1 0,0 1,-1.808 0.848l-0.05,-0.106 -0.582,-1.456a3,3 0,0 1,0.266 -2.743l0.12,-0.171 0.15,-0.202a1,1 0,0 0,0.17 -0.848l-0.04,-0.123 -0.583,-1.457a1,1 0,0 1,0.557 -1.3Z"
|
||||||
|
android:fillColor="#212121"/>
|
||||||
|
</vector>
|
|
@ -53,6 +53,7 @@
|
||||||
|
|
||||||
<string name="mo_share_open_url">Open in App</string>
|
<string name="mo_share_open_url">Open in App</string>
|
||||||
<string name="mo_double_tap_to_swipe_between_tabs">Double tap to swipe between tabs</string>
|
<string name="mo_double_tap_to_swipe_between_tabs">Double tap to swipe between tabs</string>
|
||||||
|
<string name="mo_haptic_feedback">Haptic feedback</string>
|
||||||
<string name="mo_swap_bookmark_with_reblog">Swap bookmark with reblog action</string>
|
<string name="mo_swap_bookmark_with_reblog">Swap bookmark with reblog action</string>
|
||||||
<string name="mo_download_latest_nightly_release">Download latest nightly release</string>
|
<string name="mo_download_latest_nightly_release">Download latest nightly release</string>
|
||||||
<string name="mo_load_remote_followers">Load remote profile follows and followers</string>
|
<string name="mo_load_remote_followers">Load remote profile follows and followers</string>
|
||||||
|
@ -83,6 +84,7 @@
|
||||||
<string name="mo_setting_default_reply_privacy_summary">Replies will be opted out of discovery features</string>
|
<string name="mo_setting_default_reply_privacy_summary">Replies will be opted out of discovery features</string>
|
||||||
<string name="mo_setting_interaction_count_summary">Show how many people interacted with a post in the timeline</string>
|
<string name="mo_setting_interaction_count_summary">Show how many people interacted with a post in the timeline</string>
|
||||||
<string name="mo_setting_disable_swipe_summary">Swipe to change viewed timeline</string>
|
<string name="mo_setting_disable_swipe_summary">Swipe to change viewed timeline</string>
|
||||||
|
<string name="mo_setting_haptic_feedback_summary">Vibrate when interacting with posts</string>
|
||||||
<string name="mo_swap_bookmark_with_reblog_summary">Bookmark or reblog posts from the notification</string>
|
<string name="mo_swap_bookmark_with_reblog_summary">Bookmark or reblog posts from the notification</string>
|
||||||
|
|
||||||
<!-- Settings -->
|
<!-- Settings -->
|
||||||
|
|
Loading…
Reference in New Issue