diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/FindPhoneActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/FindPhoneActivity.java index f84136b19..4516c0a5f 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/FindPhoneActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/FindPhoneActivity.java @@ -33,6 +33,7 @@ import android.os.Vibrator; import android.view.View; import android.widget.Button; +import androidx.core.content.ContextCompat; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import org.slf4j.Logger; @@ -92,9 +93,9 @@ public class FindPhoneActivity extends AbstractGBActivity { filter.addAction(ACTION_VIBRATE); filter.addAction(ACTION_RING); LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filter); - registerReceiver(mReceiver, filter); // for ACTION_FOUND + ContextCompat.registerReceiver(this, mReceiver, filter, ContextCompat.RECEIVER_NOT_EXPORTED); // for ACTION_FOUND - Button foundButton = (Button) findViewById(R.id.foundbutton); + Button foundButton = findViewById(R.id.foundbutton); foundButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -111,10 +112,10 @@ public class FindPhoneActivity extends AbstractGBActivity { GBApplication.deviceService().onFindPhone(true); } - private void vibrate(){ - mVibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE); + private void vibrate() { + mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); - long[] vibrationPattern = new long[]{ 1000, 1000 }; + long[] vibrationPattern = new long[]{1000, 1000}; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { VibrationEffect vibrationEffect = VibrationEffect.createWaveform(vibrationPattern, 0); @@ -126,7 +127,7 @@ public class FindPhoneActivity extends AbstractGBActivity { } private void playRingtone() { - mAudioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE); + mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); if (mAudioManager != null) { userVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_ALARM); } @@ -153,7 +154,7 @@ public class FindPhoneActivity extends AbstractGBActivity { /** * Attempt to play the configured ringtone. This fails to get the default ringtone on some ROMs - * (https://codeberg.org/Freeyourgadget/Gadgetbridge/pulls/2697) + * (#2697) * * @return whether playing the configured ringtone was successful or not. */ diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/QHybridConfigActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/QHybridConfigActivity.java index 366f3bbfd..197b5a63d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/QHybridConfigActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/QHybridConfigActivity.java @@ -57,6 +57,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; +import androidx.core.content.ContextCompat; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import com.google.android.material.dialog.MaterialAlertDialogBuilder; @@ -530,7 +531,7 @@ public class QHybridConfigActivity extends AbstractGBActivity { protected void onResume() { super.onResume(); refreshList(); - registerReceiver(buttonReceiver, new IntentFilter(QHybridSupport.QHYBRID_EVENT_BUTTON_PRESS)); + ContextCompat.registerReceiver(this, buttonReceiver, new IntentFilter(QHybridSupport.QHYBRID_EVENT_BUTTON_PRESS), ContextCompat.RECEIVER_NOT_EXPORTED); LocalBroadcastManager.getInstance(this).registerReceiver(settingsReceiver, new IntentFilter(QHybridSupport.QHYBRID_EVENT_SETTINGS_UPDATED)); LocalBroadcastManager.getInstance(this).registerReceiver(fileReceiver, new IntentFilter(QHybridSupport.QHYBRID_EVENT_FILE_UPLOADED)); }