mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-31 14:15:14 +00:00
Use TextUtils' isEmpty() and equals().
This commit is contained in:
committed by
Nicolas Fella
parent
0f589fd821
commit
80121a7951
@@ -28,6 +28,7 @@ import android.graphics.BitmapFactory;
|
|||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.jakewharton.disklrucache.DiskLruCache;
|
import com.jakewharton.disklrucache.DiskLruCache;
|
||||||
@@ -142,7 +143,7 @@ final class AlbumArtCache {
|
|||||||
*/
|
*/
|
||||||
static Bitmap getAlbumArt(String albumUrl, MprisPlugin plugin, String player) {
|
static Bitmap getAlbumArt(String albumUrl, MprisPlugin plugin, String player) {
|
||||||
//If the url is invalid, return "no album art"
|
//If the url is invalid, return "no album art"
|
||||||
if (albumUrl == null || albumUrl.isEmpty()) {
|
if (TextUtils.isEmpty(albumUrl)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -30,6 +30,7 @@ import android.os.Bundle;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@@ -382,7 +383,7 @@ public class MprisActivity extends AppCompatActivity {
|
|||||||
String targetPlayerName = getIntent().getStringExtra("player");
|
String targetPlayerName = getIntent().getStringExtra("player");
|
||||||
getIntent().removeExtra("player");
|
getIntent().removeExtra("player");
|
||||||
|
|
||||||
if (targetPlayerName == null || targetPlayerName.isEmpty()) {
|
if (TextUtils.isEmpty(targetPlayerName)) {
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
targetPlayerName = savedInstanceState.getString("targetPlayer");
|
targetPlayerName = savedInstanceState.getString("targetPlayer");
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,7 @@ import android.media.MediaMetadata;
|
|||||||
import android.media.session.MediaController;
|
import android.media.session.MediaController;
|
||||||
import android.media.session.PlaybackState;
|
import android.media.session.PlaybackState;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
|
|
||||||
@@ -110,9 +111,9 @@ class MprisReceiverPlayer {
|
|||||||
if (metadata == null) return "";
|
if (metadata == null) return "";
|
||||||
|
|
||||||
String artist = metadata.getString(MediaMetadata.METADATA_KEY_ARTIST);
|
String artist = metadata.getString(MediaMetadata.METADATA_KEY_ARTIST);
|
||||||
if (artist == null || artist.isEmpty()) artist = metadata.getString(MediaMetadata.METADATA_KEY_ALBUM_ARTIST);
|
if (TextUtils.isEmpty(artist)) artist = metadata.getString(MediaMetadata.METADATA_KEY_ALBUM_ARTIST);
|
||||||
if (artist == null || artist.isEmpty()) artist = metadata.getString(MediaMetadata.METADATA_KEY_AUTHOR);
|
if (TextUtils.isEmpty(artist)) artist = metadata.getString(MediaMetadata.METADATA_KEY_AUTHOR);
|
||||||
if (artist == null || artist.isEmpty()) artist = metadata.getString(MediaMetadata.METADATA_KEY_WRITER);
|
if (TextUtils.isEmpty(artist)) artist = metadata.getString(MediaMetadata.METADATA_KEY_WRITER);
|
||||||
|
|
||||||
return artist != null ? artist : "";
|
return artist != null ? artist : "";
|
||||||
}
|
}
|
||||||
@@ -122,7 +123,7 @@ class MprisReceiverPlayer {
|
|||||||
if (metadata == null) return "";
|
if (metadata == null) return "";
|
||||||
|
|
||||||
String title = metadata.getString(MediaMetadata.METADATA_KEY_TITLE);
|
String title = metadata.getString(MediaMetadata.METADATA_KEY_TITLE);
|
||||||
if (title == null || title.isEmpty()) title = metadata.getString(MediaMetadata.METADATA_KEY_DISPLAY_TITLE);
|
if (TextUtils.isEmpty(title)) title = metadata.getString(MediaMetadata.METADATA_KEY_DISPLAY_TITLE);
|
||||||
return title != null ? title : "";
|
return title != null ? title : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,6 +7,7 @@ import android.content.ComponentName;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.RemoteViews;
|
import android.widget.RemoteViews;
|
||||||
@@ -46,7 +47,7 @@ public class RunCommandWidget extends AppWidgetProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (intent != null && intent.getAction() != null && intent.getAction().equals(SET_CURRENT_DEVICE)) {
|
} else if (intent != null && TextUtils.equals(intent.getAction(), SET_CURRENT_DEVICE)) {
|
||||||
setCurrentDevice(context);
|
setCurrentDevice(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -127,7 +127,8 @@ public class StoragePreferenceDialogFragment extends PreferenceDialogFragmentCom
|
|||||||
storageLocation.setText(requireContext().getString(R.string.sftp_storage_preference_click_to_select));
|
storageLocation.setText(requireContext().getString(R.string.sftp_storage_preference_click_to_select));
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isClickToSelect = storageLocation.getText() != null && storageLocation.getText().toString().equals(getString(R.string.sftp_storage_preference_click_to_select));
|
boolean isClickToSelect = TextUtils.equals(storageLocation.getText(),
|
||||||
|
getString(R.string.sftp_storage_preference_click_to_select));
|
||||||
|
|
||||||
storageLocation.setCompoundDrawables(null, null, isClickToSelect ? arrowDropDownDrawable : null, null);
|
storageLocation.setCompoundDrawables(null, null, isClickToSelect ? arrowDropDownDrawable : null, null);
|
||||||
storageLocation.setEnabled(isClickToSelect);
|
storageLocation.setEnabled(isClickToSelect);
|
||||||
|
@@ -32,6 +32,7 @@ import android.os.Build;
|
|||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.telephony.PhoneNumberUtils;
|
import android.telephony.PhoneNumberUtils;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.kde.kdeconnect.Helpers.ContactsHelper;
|
import org.kde.kdeconnect.Helpers.ContactsHelper;
|
||||||
@@ -164,7 +165,7 @@ public class TelephonyPlugin extends Plugin {
|
|||||||
if (photoUri != null) {
|
if (photoUri != null) {
|
||||||
try {
|
try {
|
||||||
String base64photo = ContactsHelper.photoId64Encoded(context, photoUri);
|
String base64photo = ContactsHelper.photoId64Encoded(context, photoUri);
|
||||||
if (base64photo != null && !base64photo.isEmpty()) {
|
if (!TextUtils.isEmpty(base64photo)) {
|
||||||
np.set("phoneThumbnail", base64photo);
|
np.set("phoneThumbnail", base64photo);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Reference in New Issue
Block a user