From eb3c742f653bd6efd38d7e7aea88ed1ddf2612ce Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 14 Oct 2021 17:55:48 +0200 Subject: [PATCH 1/5] remove vibrate setting Resolves #1630 Signed-off-by: Andy Scherzinger --- .../controllers/CallNotificationController.java | 4 +--- .../talk/controllers/SettingsController.java | 12 ------------ .../nextcloud/talk/jobs/NotificationWorker.java | 17 +++++++---------- .../talk/utils/preferences/AppPreferences.java | 11 ----------- 4 files changed, 8 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/CallNotificationController.java b/app/src/main/java/com/nextcloud/talk/controllers/CallNotificationController.java index baa3a5d04..6a24e7c28 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/CallNotificationController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/CallNotificationController.java @@ -358,9 +358,7 @@ public class CallNotificationController extends BaseController { playRingtoneSound(); } - if (DoNotDisturbUtils.INSTANCE.shouldVibrate(appPreferences.getShouldVibrateSetting())) { - vibrate(); - } + vibrate(); } @Subscribe(threadMode = ThreadMode.MAIN) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.java b/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.java index a0035bdce..1f369c0d7 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.java @@ -170,8 +170,6 @@ public class SettingsController extends BaseController { MaterialPreferenceCategory messageView; @BindView(R.id.settings_client_cert) MaterialStandardPreference certificateSetup; - @BindView(R.id.settings_always_vibrate) - MaterialSwitchPreference shouldVibrateSwitchPreference; @BindView(R.id.settings_incognito_keyboard) MaterialSwitchPreference incognitoKeyboardSwitchPreference; @BindView(R.id.settings_screen_security) @@ -263,10 +261,6 @@ public class SettingsController extends BaseController { licenceButton.setVisibility(View.GONE); } - if (!DoNotDisturbUtils.INSTANCE.hasVibrator()) { - shouldVibrateSwitchPreference.setVisibility(View.GONE); - } - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { incognitoKeyboardSwitchPreference.setVisibility(View.GONE); } @@ -280,7 +274,6 @@ public class SettingsController extends BaseController { getResources().getString(R.string.nc_app_product_name))); } - if (!TextUtils.isEmpty(getResources().getString(R.string.nc_privacy_url))) { privacyButton.addPreferenceClickListener(view12 -> { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(getResources(). @@ -353,7 +346,6 @@ public class SettingsController extends BaseController { alias = ""; } - userUtils.createOrUpdateUser(null, null, null, null, null, null, null, currentUser.getId(), null, alias, null); }, new String[]{"RSA", "EC"}, null, finalHost, finalPort, currentUser.getClientCertificate @@ -445,10 +437,6 @@ public class SettingsController extends BaseController { certificateSetup.setTitle(R.string.nc_client_cert_setup); } - if (shouldVibrateSwitchPreference.getVisibility() == View.VISIBLE) { - ((Checkable) shouldVibrateSwitchPreference.findViewById(R.id.mp_checkable)).setChecked(appPreferences.getShouldVibrateSetting()); - } - ((Checkable) screenSecuritySwitchPreference.findViewById(R.id.mp_checkable)).setChecked(appPreferences.getIsScreenSecured()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { ((Checkable) incognitoKeyboardSwitchPreference.findViewById(R.id.mp_checkable)).setChecked(appPreferences.getIsKeyboardIncognito()); diff --git a/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java b/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java index 587b82ae0..74496da80 100644 --- a/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java +++ b/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java @@ -537,18 +537,15 @@ public class NotificationWorker extends Worker { } } - - if (DoNotDisturbUtils.INSTANCE.shouldVibrate(appPreferences.getShouldVibrateSetting()) || importantConversation) { - Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); - - if (vibrator != null) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - //vibrator.vibrate(VibrationEffect.createOneShot(500, VibrationEffect.DEFAULT_AMPLITUDE)); - } else { - //vibrator.vibrate(500); - } + Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); + if (vibrator != null) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + //vibrator.vibrate(VibrationEffect.createOneShot(500, VibrationEffect.DEFAULT_AMPLITUDE)); + } else { + //vibrator.vibrate(500); } } + } } diff --git a/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java b/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java index cb7398309..30d725f91 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java +++ b/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java @@ -187,17 +187,6 @@ public interface AppPreferences { @RemoveMethod void removeNotificationChannelUpgradeToV3(); - @KeyByString("notifications_vibrate") - @DefaultValue(R.bool.value_true) - boolean getShouldVibrateSetting(); - - @KeyByString("notifications_vibrate") - void setVibrateSetting(boolean value); - - @KeyByString("notifications_vibrate") - @RemoveMethod - void removeVibrateSetting(); - @KeyByString("screen_security") @DefaultValue(R.bool.value_false) boolean getIsScreenSecured(); From 8c87c5b45d4ed9d22f2b3c379adb9f0ff45ee0f4 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 14 Oct 2021 18:28:19 +0200 Subject: [PATCH 2/5] remove unused vibrate code Signed-off-by: Andy Scherzinger --- .../CallNotificationController.java | 32 ------------------- .../talk/jobs/NotificationWorker.java | 11 ------- 2 files changed, 43 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/CallNotificationController.java b/app/src/main/java/com/nextcloud/talk/controllers/CallNotificationController.java index 6a24e7c28..dc8f1bfee 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/CallNotificationController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/CallNotificationController.java @@ -29,10 +29,8 @@ import android.graphics.drawable.ColorDrawable; import android.media.AudioAttributes; import android.media.MediaPlayer; import android.net.Uri; -import android.os.Build; import android.os.Bundle; import android.os.Handler; -import android.os.VibrationEffect; import android.os.Vibrator; import android.renderscript.RenderScript; import android.text.TextUtils; @@ -357,8 +355,6 @@ public class CallNotificationController extends BaseController { if (DoNotDisturbUtils.INSTANCE.shouldPlaySound()) { playRingtoneSound(); } - - vibrate(); } @Subscribe(threadMode = ThreadMode.MAIN) @@ -527,32 +523,4 @@ public class CallNotificationController extends BaseController { } } } - - private void vibrate() { - vibrator = (Vibrator) getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE); - - if (vibrator != null) { - long[] vibratePattern = new long[]{0, 400, 800, 600, 800, 800, 800, 1000}; - int[] amplitudes = new int[]{0, 255, 0, 255, 0, 255, 0, 255}; - - VibrationEffect vibrationEffect; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - if (vibrator.hasAmplitudeControl()) { - vibrationEffect = VibrationEffect.createWaveform(vibratePattern, amplitudes, -1); - //vibrator.vibrate(vibrationEffect); - } else { - vibrationEffect = VibrationEffect.createWaveform(vibratePattern, -1); - //vibrator.vibrate(vibrationEffect); - } - } else { - //vibrator.vibrate(vibratePattern, -1); - } - } - - handler.postDelayed(() -> { - if (vibrator != null) { - vibrator.cancel(); - } - }, 10000); - } } \ No newline at end of file diff --git a/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java b/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java index 74496da80..d11134a45 100644 --- a/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java +++ b/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java @@ -32,7 +32,6 @@ import android.media.MediaPlayer; import android.net.Uri; import android.os.Build; import android.os.Bundle; -import android.os.Vibrator; import android.service.notification.StatusBarNotification; import android.text.TextUtils; import android.util.Base64; @@ -536,16 +535,6 @@ public class NotificationWorker extends Worker { Log.e(TAG, "Failed to set data source"); } } - - Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); - if (vibrator != null) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - //vibrator.vibrate(VibrationEffect.createOneShot(500, VibrationEffect.DEFAULT_AMPLITUDE)); - } else { - //vibrator.vibrate(500); - } - } - } } From 4c7cf29bd932cb923fd023db6db46b67aa177ca7 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Mon, 25 Oct 2021 14:34:03 +0200 Subject: [PATCH 3/5] removing the vibrate setting from controller_settings.xml Signed-off-by: Andy Scherzinger --- app/src/main/res/layout/controller_settings.xml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/app/src/main/res/layout/controller_settings.xml b/app/src/main/res/layout/controller_settings.xml index c06f3ec7a..199407ed1 100644 --- a/app/src/main/res/layout/controller_settings.xml +++ b/app/src/main/res/layout/controller_settings.xml @@ -182,15 +182,6 @@ apc:mp_key="@string/nc_settings_message_ringtone_key" apc:mp_title="@string/nc_settings_other_notifications_ringtone" /> - - Date: Mon, 25 Oct 2021 12:44:23 +0000 Subject: [PATCH 4/5] Drone: update FindBugs results to reflect reduced error/warning count [skip ci] Signed-off-by: drone --- scripts/analysis/findbugs-results.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/analysis/findbugs-results.txt b/scripts/analysis/findbugs-results.txt index 6001de1bb..7dfce3516 100644 --- a/scripts/analysis/findbugs-results.txt +++ b/scripts/analysis/findbugs-results.txt @@ -1 +1 @@ -595 \ No newline at end of file +594 \ No newline at end of file From a5b1c1a34dab45d9248d43af627c98712effe8b3 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Mon, 25 Oct 2021 15:18:44 +0200 Subject: [PATCH 5/5] improve lint score Signed-off-by: Andy Scherzinger --- .../filebrowser/adapters/items/BrowserFileItem.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/nextcloud/talk/components/filebrowser/adapters/items/BrowserFileItem.java b/app/src/main/java/com/nextcloud/talk/components/filebrowser/adapters/items/BrowserFileItem.java index 1ec98bd66..95115fac7 100644 --- a/app/src/main/java/com/nextcloud/talk/components/filebrowser/adapters/items/BrowserFileItem.java +++ b/app/src/main/java/com/nextcloud/talk/components/filebrowser/adapters/items/BrowserFileItem.java @@ -28,6 +28,7 @@ import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; +import androidx.appcompat.content.res.AppCompatResources; import autodagger.AutoInjector; import butterknife.BindView; import butterknife.ButterKnife; @@ -140,7 +141,14 @@ public class BrowserFileItem extends AbstractFlexibleItem