2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-31 06:05:12 +00:00

Remove even more checks for deprecated Android versions

This commit is contained in:
Albert Vaca Cintora
2023-03-05 22:24:47 +01:00
parent 3bfae23d1b
commit 1002275ebe
7 changed files with 7 additions and 19 deletions

View File

@@ -20,7 +20,6 @@ import android.preference.PreferenceManager;
import android.provider.Settings;
import android.util.Log;
import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationCompat;
import androidx.core.content.ContextCompat;
@@ -125,7 +124,6 @@ public class FindMyPhonePlugin extends Plugin {
return true;
}
@RequiresApi(16)
private void showBroadcastNotification() {
Intent intent = new Intent(context, FindMyPhoneReceiver.class);
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);

View File

@@ -287,6 +287,7 @@ public class MprisMediaSession implements
if (mediaSession == null) {
mediaSession = new MediaSessionCompat(context, MPRIS_MEDIA_SESSION_TAG);
mediaSession.setCallback(mediaSessionCallback);
// Deprecated flags not required in Build.VERSION_CODES.O and later
mediaSession.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
}
@@ -369,7 +370,7 @@ public class MprisMediaSession implements
*/
PendingIntent piOpenActivity = TaskStackBuilder.create(context)
.addNextIntentWithParentStack(iOpenActivity)
.getPendingIntent(Build.VERSION.SDK_INT > 15 ? 0 : (int) System.currentTimeMillis(), PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
.getPendingIntent((int) System.currentTimeMillis(), PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
NotificationCompat.Builder notification = new NotificationCompat.Builder(context, NotificationHelper.Channels.MEDIA_CONTROL);

View File

@@ -154,6 +154,7 @@ public class PresenterActivity extends AppCompatActivity implements SensorEventL
private void createMediaSession() {
mMediaSession = new MediaSessionCompat(this, "kdeconnect");
// Deprecated flags not required in Build.VERSION_CODES.O and later
mMediaSession.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS |
MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
mMediaSession.setPlaybackState(new PlaybackStateCompat.Builder()

View File

@@ -8,7 +8,6 @@
package org.kde.kdeconnect.Plugins.RunCommandPlugin;
import android.content.ClipboardManager;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.ContextMenu;
@@ -18,7 +17,6 @@ import android.view.View;
import android.widget.AdapterView;
import android.widget.Toast;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
@@ -118,7 +116,6 @@ public class RunCommandActivity extends AppCompatActivity {
inflater.inflate(R.menu.runcommand_context, menu);
}
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

View File

@@ -10,6 +10,7 @@ import android.app.PendingIntent
import android.content.Intent
import android.content.SharedPreferences
import android.graphics.drawable.Icon
import android.os.Build
import android.service.controls.Control
import android.service.controls.ControlsProviderService
import android.service.controls.actions.CommandAction
@@ -33,7 +34,7 @@ import java.util.function.Consumer
private class CommandEntryWithDevice(name: String, cmd: String, key: String, val device: Device) : CommandEntry(name, cmd, key)
@RequiresApi(30)
@RequiresApi(Build.VERSION_CODES.R)
class RunCommandControlsProviderService : ControlsProviderService() {
private lateinit var updatePublisher: ReplayProcessor<Control>
private lateinit var sharedPreferences: SharedPreferences

View File

@@ -7,7 +7,6 @@
package org.kde.kdeconnect.Plugins.SftpPlugin;
import android.content.Context;
import android.os.Build;
import android.provider.DocumentsContract;
import android.util.AttributeSet;
import android.view.View;
@@ -67,11 +66,7 @@ public class StoragePreference extends DialogPreference {
this.storageInfo = storageInfo;
setTitle(storageInfo.displayName);
if (Build.VERSION.SDK_INT < 21) {
setSummary(storageInfo.uri.getPath());
} else {
setSummary(DocumentsContract.getTreeDocumentId(storageInfo.uri));
}
setSummary(DocumentsContract.getTreeDocumentId(storageInfo.uri));
}
@Nullable

View File

@@ -5,7 +5,6 @@ import android.app.Dialog;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.DocumentsContract;
import android.text.Editable;
@@ -145,11 +144,7 @@ public class StoragePreferenceDialogFragment extends PreferenceDialogFragmentCom
storageInfo = SftpPlugin.StorageInfo.copy(info);
if (Build.VERSION.SDK_INT < 21) {
binding.storageLocation.setText(storageInfo.uri.getPath());
} else {
binding.storageLocation.setText(DocumentsContract.getTreeDocumentId(storageInfo.uri));
}
binding.storageLocation.setText(DocumentsContract.getTreeDocumentId(storageInfo.uri));
binding.storageDisplayName.setText(storageInfo.displayName);
}