commit
7da356f750
|
@ -140,7 +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);
|
hapticFeedback=prefs.getBoolean("hapticFeedback", true);
|
||||||
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);
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class BehaviourFragment extends SettingsBaseFragment{
|
||||||
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 -> {
|
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.hapticFeedback = i.checked;
|
||||||
GlobalUserPreferences.save();
|
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,15 +264,6 @@ 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;
|
||||||
|
|
|
@ -7,6 +7,8 @@ import android.content.Intent;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.VibrationEffect;
|
||||||
|
import android.os.Vibrator;
|
||||||
import android.view.HapticFeedbackConstants;
|
import android.view.HapticFeedbackConstants;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
@ -470,8 +472,24 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
|
||||||
|
|
||||||
private static void vibrateForAction(View view, boolean isPositive) {
|
private static void vibrateForAction(View view, boolean isPositive) {
|
||||||
if (!GlobalUserPreferences.hapticFeedback) return;
|
if (!GlobalUserPreferences.hapticFeedback) return;
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) return;
|
|
||||||
view.performHapticFeedback(isPositive ? HapticFeedbackConstants.CONFIRM : HapticFeedbackConstants.REJECT);
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
|
view.performHapticFeedback(isPositive ? HapticFeedbackConstants.CONFIRM : HapticFeedbackConstants.REJECT);
|
||||||
|
} else {
|
||||||
|
Vibrator vibrator = view.getContext().getSystemService(Vibrator.class);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
vibrator.vibrate(VibrationEffect.createPredefined(isPositive ? VibrationEffect.EFFECT_CLICK : VibrationEffect.EFFECT_DOUBLE_CLICK));
|
||||||
|
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
VibrationEffect effect = isPositive
|
||||||
|
? VibrationEffect.createOneShot(75L, 128)
|
||||||
|
: VibrationEffect.createWaveform(new long[]{0L, 75L, 75L, 75L}, new int[]{0, 128, 0, 128}, -1);
|
||||||
|
vibrator.vibrate(effect);
|
||||||
|
} else {
|
||||||
|
if (isPositive) vibrator.vibrate(75L);
|
||||||
|
else vibrator.vibrate(new long[]{0L, 75L, 75L, 75L}, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue