mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-31 14:15:14 +00:00
Small tweaks suggested by static code analyzer
This commit is contained in:
@@ -281,7 +281,7 @@ public class BluetoothLinkProvider extends BaseLinkProvider {
|
||||
@TargetApi(value = Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (action.equals(BluetoothDevice.ACTION_UUID)) {
|
||||
if (BluetoothDevice.ACTION_UUID.equals(action)) {
|
||||
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
||||
Parcelable[] activeUuids = intent.getParcelableArrayExtra(BluetoothDevice.EXTRA_UUID);
|
||||
|
||||
|
@@ -395,7 +395,7 @@ public class TelephonyHelper {
|
||||
}
|
||||
}
|
||||
|
||||
private ApnSetting() {};
|
||||
private ApnSetting() {}
|
||||
|
||||
public Uri getMmsc() {
|
||||
return mmscUri;
|
||||
|
@@ -15,7 +15,7 @@ public class ASUUtils {
|
||||
* Implementation of SignalStrength.toLevel usable from API Level 7+
|
||||
*/
|
||||
public static int signalStrengthToLevel(SignalStrength signalStrength) {
|
||||
int level = 0;
|
||||
int level;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
level = signalStrength.getLevel();
|
||||
} else {
|
||||
|
@@ -229,7 +229,7 @@ public class ConnectivityReportPlugin extends Plugin {
|
||||
|
||||
@Override
|
||||
public boolean onPacketReceived(NetworkPacket np) {
|
||||
if (np.getType() == PACKET_TYPE_CONNECTIVITY_REPORT_REQUEST) {
|
||||
if (PACKET_TYPE_CONNECTIVITY_REPORT_REQUEST.equals(np.getType())) {
|
||||
Log.i("ConnectivityReport", "Requested");
|
||||
serializeSignalStrengths();
|
||||
device.sendPacket(connectivityInfo);
|
||||
|
@@ -55,7 +55,6 @@ public class FindMyPhonePlugin extends Plugin {
|
||||
case Tablet:
|
||||
return context.getString(R.string.findmyphone_title_tablet);
|
||||
case Phone:
|
||||
return context.getString(R.string.findmyphone_title);
|
||||
default:
|
||||
return context.getString(R.string.findmyphone_title);
|
||||
}
|
||||
|
@@ -152,6 +152,7 @@ public class PointerAccelerationProfileFactory {
|
||||
public static PointerAccelerationProfile getProfileWithName(String name) {
|
||||
switch (name) {
|
||||
case "noacceleration":
|
||||
default:
|
||||
return new DefaultProfile();
|
||||
case "weaker":
|
||||
return new PolynomialProfile(0.25f);
|
||||
@@ -163,8 +164,6 @@ public class PointerAccelerationProfileFactory {
|
||||
return new PolynomialProfile(1.5f);
|
||||
case "stronger":
|
||||
return new PolynomialProfile(2.0f);
|
||||
default:
|
||||
return new DefaultProfile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -77,9 +77,7 @@ public class MprisActivity extends AppCompatActivity {
|
||||
TabLayoutMediator tabLayoutMediator = new TabLayoutMediator(
|
||||
activityMprisBinding.mprisTabs,
|
||||
activityMprisBinding.mprisPager,
|
||||
(tab, position) -> {
|
||||
tab.setText(mprisPagerAdapter.getTitle(position));
|
||||
}
|
||||
(tab, position) -> tab.setText(mprisPagerAdapter.getTitle(position))
|
||||
);
|
||||
|
||||
activityMprisBinding.mprisTabs.getSelectedTabPosition();
|
||||
|
@@ -427,11 +427,7 @@ public class MprisMediaSession implements SharedPreferences.OnSharedPreferenceCh
|
||||
mediaSession.setPlaybackState(playbackState.build());
|
||||
|
||||
//Only allow deletion if no music is notificationPlayer
|
||||
if (notificationPlayer.isPlaying()) {
|
||||
notification.setOngoing(true);
|
||||
} else {
|
||||
notification.setOngoing(false);
|
||||
}
|
||||
notification.setOngoing(notificationPlayer.isPlaying());
|
||||
|
||||
//Use the MediaStyle notification, so it feels like other media players. That also allows adding actions
|
||||
MediaStyle mediaStyle = new MediaStyle();
|
||||
|
@@ -80,7 +80,7 @@ public class MprisPlugin extends Plugin {
|
||||
}
|
||||
|
||||
boolean isSpotify() {
|
||||
return getPlayer().toLowerCase().equals("spotify");
|
||||
return getPlayer().equalsIgnoreCase("spotify");
|
||||
}
|
||||
|
||||
public String getLoopStatus() {
|
||||
|
@@ -117,8 +117,8 @@ public class RemoteKeyboardPlugin extends Plugin implements SharedPreferences.On
|
||||
PreferenceManager.getDefaultSharedPreferences(context).registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
final boolean editingOnly = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(context.getString(R.string.remotekeyboard_editing_only), true);
|
||||
if (RemoteKeyboardService.instance != null)
|
||||
notifyKeyboardState(editingOnly ? RemoteKeyboardService.instance.visible : true);
|
||||
final boolean visible = RemoteKeyboardService.instance != null && RemoteKeyboardService.instance.visible;
|
||||
notifyKeyboardState(!editingOnly || visible);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -511,7 +511,7 @@ public class SMSPlugin extends Plugin {
|
||||
private boolean handleRequestSingleConversation(NetworkPacket packet) {
|
||||
SMSHelper.ThreadID threadID = new SMSHelper.ThreadID(packet.getLong("threadID"));
|
||||
|
||||
Long rangeStartTimestamp = packet.getLong("rangeStartTimestamp", -1);
|
||||
long rangeStartTimestamp = packet.getLong("rangeStartTimestamp", -1);
|
||||
Long numberToGet = packet.getLong("numberToRequest", -1);
|
||||
|
||||
if (numberToGet < 0) {
|
||||
|
@@ -99,7 +99,7 @@ public class AndroidSafFileSystemView implements FileSystemView {
|
||||
String treeDocumentId = DocumentsContract.getTreeDocumentId(treeUri);
|
||||
File nameWithoutRootFile = new File(nameWithoutRoot);
|
||||
String parentSuffix = nameWithoutRootFile.getParent();
|
||||
String parentDocumentId = treeDocumentId + (parentSuffix.equals("/") ? "" : parentSuffix);
|
||||
String parentDocumentId = treeDocumentId + ("/".equals(parentSuffix) ? "" : parentSuffix);
|
||||
|
||||
Uri parentUri = DocumentsContract.buildDocumentUriUsingTree(treeUri, parentDocumentId);
|
||||
|
||||
|
@@ -277,7 +277,7 @@ public class StoragePreferenceDialogFragment extends PreferenceDialogFragmentCom
|
||||
}
|
||||
}
|
||||
|
||||
private class FileSeparatorCharFilter implements InputFilter {
|
||||
private static class FileSeparatorCharFilter implements InputFilter {
|
||||
//TODO: Add more chars to refuse?
|
||||
//https://www.cyberciti.biz/faq/linuxunix-rules-for-naming-file-and-directory-names/
|
||||
String notAllowed = "/\\><|:&?*";
|
||||
|
@@ -214,7 +214,7 @@ public class CustomDevicesActivity extends AppCompatActivity implements CustomDe
|
||||
}
|
||||
}
|
||||
|
||||
private class DeletedCustomDevice {
|
||||
private static class DeletedCustomDevice {
|
||||
@NonNull String hostnameOrIP;
|
||||
int position;
|
||||
|
||||
|
@@ -8,7 +8,6 @@ package org.kde.kdeconnect.UserInterface;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
@@ -24,22 +23,16 @@ import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.klinker.android.send_message.Utils;
|
||||
|
||||
import org.kde.kdeconnect.BackgroundService;
|
||||
import org.kde.kdeconnect.Device;
|
||||
import org.kde.kdeconnect.Helpers.SecurityHelpers.SslHelper;
|
||||
import org.kde.kdeconnect.Helpers.TelephonyHelper;
|
||||
import org.kde.kdeconnect.NetworkPacket;
|
||||
import org.kde.kdeconnect.Plugins.BatteryPlugin.BatteryPlugin;
|
||||
import org.kde.kdeconnect.Plugins.BatteryPlugin.DeviceBatteryInfo;
|
||||
import org.kde.kdeconnect.Plugins.Plugin;
|
||||
import org.kde.kdeconnect.Plugins.SMSPlugin.SMSPlugin;
|
||||
import org.kde.kdeconnect.UserInterface.List.FailedPluginListItem;
|
||||
import org.kde.kdeconnect.UserInterface.List.ListAdapter;
|
||||
import org.kde.kdeconnect.UserInterface.List.PluginItem;
|
||||
import org.kde.kdeconnect.UserInterface.List.PluginListHeaderItem;
|
||||
import org.kde.kdeconnect.UserInterface.List.SetDefaultAppPluginListItem;
|
||||
import org.kde.kdeconnect_tp.R;
|
||||
import org.kde.kdeconnect_tp.databinding.ActivityDeviceBinding;
|
||||
import org.kde.kdeconnect_tp.databinding.ViewPairErrorBinding;
|
||||
@@ -48,7 +41,6 @@ import org.kde.kdeconnect_tp.databinding.ViewPairRequestBinding;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
||||
@@ -277,7 +269,7 @@ public class DeviceFragment extends Fragment {
|
||||
}
|
||||
|
||||
private void refreshUI() {
|
||||
if (device == null || binding == null || binding.getRoot() == null) {
|
||||
if (device == null || binding == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -366,7 +358,7 @@ public class DeviceFragment extends Fragment {
|
||||
@Override
|
||||
public void pairingFailed(final String error) {
|
||||
mActivity.runOnUiThread(() -> {
|
||||
if (binding == null || binding.getRoot() == null) return;
|
||||
if (binding == null) return;
|
||||
binding.pairMessage.setText(error);
|
||||
binding.pairVerification.setText("");
|
||||
binding.pairVerification.setVisibility(View.GONE);
|
||||
@@ -380,7 +372,7 @@ public class DeviceFragment extends Fragment {
|
||||
@Override
|
||||
public void unpaired() {
|
||||
mActivity.runOnUiThread(() -> {
|
||||
if (binding == null || binding.getRoot() == null) return;
|
||||
if (binding == null) return;
|
||||
binding.pairMessage.setText(R.string.device_not_paired);
|
||||
binding.pairVerification.setVisibility(View.GONE);
|
||||
binding.pairProgress.setVisibility(View.GONE);
|
||||
|
@@ -17,24 +17,19 @@ import org.kde.kdeconnect.Plugins.Plugin;
|
||||
import org.kde.kdeconnect_tp.R;
|
||||
import org.kde.kdeconnect_tp.databinding.ListItemWithIconEntryBinding;
|
||||
|
||||
public class PluginItem implements ListAdapter.Item {
|
||||
private final Plugin plugin;
|
||||
public class PluginItem extends EntryItemWithIcon {
|
||||
private final View.OnClickListener clickListener;
|
||||
|
||||
public PluginItem(Plugin p, View.OnClickListener clickListener) {
|
||||
this.plugin = p;
|
||||
super(p.getActionName(), p.getIcon());
|
||||
this.clickListener = clickListener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public View inflateView(@NonNull LayoutInflater layoutInflater) {
|
||||
final ListItemWithIconEntryBinding binding = ListItemWithIconEntryBinding.inflate(layoutInflater);
|
||||
|
||||
binding.listItemEntryTitle.setText(plugin.getActionName());
|
||||
binding.listItemEntryIcon.setImageDrawable(plugin.getIcon());
|
||||
binding.getRoot().setOnClickListener(clickListener);
|
||||
|
||||
return binding.getRoot();
|
||||
final View root = super.inflateView(layoutInflater);
|
||||
root.setOnClickListener(clickListener);
|
||||
return root;
|
||||
}
|
||||
}
|
||||
|
@@ -77,8 +77,8 @@ public class MainActivity extends AppCompatActivity implements SharedPreferences
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
ThemeUtil.setUserPreferredTheme(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
ThemeUtil.setUserPreferredTheme(this); // Workaround: If the activity starts in landscape orientation and we call this before super.onCreate, the PluginItem entries appears with white on white background
|
||||
|
||||
final ActivityMainBinding binding = ActivityMainBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
Reference in New Issue
Block a user