observers = new HashSet<>();
private final Context context;
@@ -45,6 +46,7 @@
private ClipboardManager.OnPrimaryClipChangedListener listener;
private static ClipboardListener _instance = null;
+
public static ClipboardListener instance(Context context) {
if (_instance == null) {
_instance = new ClipboardListener(context);
@@ -63,7 +65,7 @@
ClipboardListener(final Context ctx) {
context = ctx;
- if(android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
+ if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
return;
}
@@ -102,12 +104,10 @@
@SuppressWarnings("deprecation")
public void setText(String text) {
currentContent = text;
- if(android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
+ if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(text);
- }
- else
- {
+ } else {
cm.setText(text);
}
}
diff --git a/src/org/kde/kdeconnect/Plugins/MousePadPlugin/KeyInputConnection.java b/src/org/kde/kdeconnect/Plugins/MousePadPlugin/KeyInputConnection.java
--- a/src/org/kde/kdeconnect/Plugins/MousePadPlugin/KeyInputConnection.java
+++ b/src/org/kde/kdeconnect/Plugins/MousePadPlugin/KeyInputConnection.java
@@ -10,8 +10,9 @@
view = targetView;
}
- @Override public boolean commitText(CharSequence text, int newCursorPosition) {
+ @Override
+ public boolean commitText(CharSequence text, int newCursorPosition) {
view.sendChars(text);
return true;
}
}
\ No newline at end of file
diff --git a/src/org/kde/kdeconnect/Plugins/MousePadPlugin/KeyListenerView.java b/src/org/kde/kdeconnect/Plugins/MousePadPlugin/KeyListenerView.java
--- a/src/org/kde/kdeconnect/Plugins/MousePadPlugin/KeyListenerView.java
+++ b/src/org/kde/kdeconnect/Plugins/MousePadPlugin/KeyListenerView.java
@@ -33,16 +33,18 @@
import org.kde.kdeconnect.Device;
import org.kde.kdeconnect.NetworkPackage;
-public class KeyListenerView extends View {
+public class KeyListenerView extends View {
private String deviceId;
private static SparseIntArray SpecialKeysMap = new SparseIntArray();
+
static {
int i = 0;
SpecialKeysMap.put(KeyEvent.KEYCODE_DEL, ++i); // 1
SpecialKeysMap.put(KeyEvent.KEYCODE_TAB, ++i); // 2
- SpecialKeysMap.put(KeyEvent.KEYCODE_ENTER, 12); ++i; // 3 is not used, return is 12 instead
+ SpecialKeysMap.put(KeyEvent.KEYCODE_ENTER, 12);
+ ++i; // 3 is not used, return is 12 instead
SpecialKeysMap.put(KeyEvent.KEYCODE_DPAD_LEFT, ++i); // 4
SpecialKeysMap.put(KeyEvent.KEYCODE_DPAD_UP, ++i); // 5
SpecialKeysMap.put(KeyEvent.KEYCODE_DPAD_RIGHT, ++i); // 6
@@ -165,7 +167,7 @@
np.set("key", new String(new char[]{keyCharacter}).toLowerCase());
} else {
//A normal key, but still not handled by the KeyInputConnection (happens with numbers)
- np.set("key", new String(new char[]{(char)event.getUnicodeChar()}));
+ np.set("key", new String(new char[]{(char) event.getUnicodeChar()}));
}
sendKeyPressPackage(np);
diff --git a/src/org/kde/kdeconnect/Plugins/MousePadPlugin/MousePadActivity.java b/src/org/kde/kdeconnect/Plugins/MousePadPlugin/MousePadActivity.java
--- a/src/org/kde/kdeconnect/Plugins/MousePadPlugin/MousePadActivity.java
+++ b/src/org/kde/kdeconnect/Plugins/MousePadPlugin/MousePadActivity.java
@@ -62,11 +62,15 @@
enum ClickType {
RIGHT, MIDDLE, NONE;
+
static ClickType fromString(String s) {
- switch(s) {
- case "right": return RIGHT;
- case "middle": return MIDDLE;
- default: return NONE;
+ switch (s) {
+ case "right":
+ return RIGHT;
+ case "middle":
+ return MIDDLE;
+ default:
+ return NONE;
}
}
}
@@ -87,11 +91,11 @@
mMousePadGestureDetector = new MousePadGestureDetector(this, this);
mDetector.setOnDoubleTapListener(this);
- keyListenerView = (KeyListenerView)findViewById(R.id.keyListener);
+ keyListenerView = (KeyListenerView) findViewById(R.id.keyListener);
keyListenerView.setDeviceId(deviceId);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
- if (prefs.getBoolean(getString(R.string.mousepad_scroll_direction),false)) {
+ if (prefs.getBoolean(getString(R.string.mousepad_scroll_direction), false)) {
scrollDirection = -1;
} else {
scrollDirection = 1;
@@ -106,7 +110,7 @@
doubleTapAction = ClickType.fromString(doubleTapSetting);
tripleTapAction = ClickType.fromString(tripleTapSetting);
- switch (sensitivitySetting){
+ switch (sensitivitySetting) {
case "slowest":
mCurrentSensitivity = 0.2f;
break;
@@ -185,7 +189,7 @@
if (mMousePadGestureDetector.onTouchEvent(event)) {
return true;
}
- if ( mDetector.onTouchEvent(event) ) {
+ if (mDetector.onTouchEvent(event)) {
return true;
}
@@ -240,8 +244,7 @@
}
@Override
- public boolean onGenericMotionEvent(MotionEvent e)
- {
+ public boolean onGenericMotionEvent(MotionEvent e) {
if (android.os.Build.VERSION.SDK_INT >= 12) { // MotionEvent.getAxisValue is >= 12
if (e.getAction() == MotionEvent.ACTION_SCROLL) {
final float distanceY = e.getAxisValue(MotionEvent.AXIS_VSCROLL);
@@ -268,8 +271,7 @@
isScrolling = true;
accumulatedDistanceY += distanceY;
- if (accumulatedDistanceY > MinDistanceToSendScroll || accumulatedDistanceY < -MinDistanceToSendScroll)
- {
+ if (accumulatedDistanceY > MinDistanceToSendScroll || accumulatedDistanceY < -MinDistanceToSendScroll) {
sendScroll(scrollDirection * accumulatedDistanceY);
accumulatedDistanceY = 0;
@@ -334,7 +336,7 @@
@Override
public boolean onTripleFingerTap(MotionEvent ev) {
- switch(tripleTapAction){
+ switch (tripleTapAction) {
case RIGHT:
sendRightClick();
break;
@@ -348,7 +350,7 @@
@Override
public boolean onDoubleFingerTap(MotionEvent ev) {
- switch(doubleTapAction){
+ switch (doubleTapAction) {
case RIGHT:
sendRightClick();
break;
diff --git a/src/org/kde/kdeconnect/Plugins/MousePadPlugin/MousePadPlugin.java b/src/org/kde/kdeconnect/Plugins/MousePadPlugin/MousePadPlugin.java
--- a/src/org/kde/kdeconnect/Plugins/MousePadPlugin/MousePadPlugin.java
+++ b/src/org/kde/kdeconnect/Plugins/MousePadPlugin/MousePadPlugin.java
@@ -88,8 +88,8 @@
sensitivity = 1.0f;
}
- np.set("dx", dx*sensitivity);
- np.set("dy", dy*sensitivity);
+ np.set("dx", dx * sensitivity);
+ np.set("dy", dy * sensitivity);
device.sendPackage(np);
}
@@ -118,7 +118,7 @@
device.sendPackage(np);
}
- public void sendSingleHold(){
+ public void sendSingleHold() {
NetworkPackage np = new NetworkPackage(PACKAGE_TYPE_MOUSEPAD_REQUEST);
np.set("singlehold", true);
device.sendPackage(np);
diff --git a/src/org/kde/kdeconnect/Plugins/MprisPlugin/AlbumArtCache.java b/src/org/kde/kdeconnect/Plugins/MprisPlugin/AlbumArtCache.java
--- a/src/org/kde/kdeconnect/Plugins/MprisPlugin/AlbumArtCache.java
+++ b/src/org/kde/kdeconnect/Plugins/MprisPlugin/AlbumArtCache.java
@@ -78,6 +78,7 @@
/**
* Initializes the disk cache. Needs to be called at least once before trying to use the cache
+ *
* @param context The context
*/
public static void initializeDiskCache(Context context) {
@@ -99,14 +100,16 @@
/**
* Registers a mpris plugin, such that it gets notified of fetched album art
+ *
* @param mpris The mpris plugin
*/
public static void registerPlugin(MprisPlugin mpris) {
registeredPlugins.add(mpris);
}
/**
* Deregister a mpris plugin
+ *
* @param mpris The mpris plugin
*/
public static void deregisterPlugin(MprisPlugin mpris) {
@@ -192,6 +195,7 @@
/**
* Fetches an album art url and puts it in the cache
+ *
* @param url The url
*/
private static void fetchUrl(URL url) {
@@ -219,9 +223,9 @@
/**
* Initialize an url fetch
*
- * @param url The url being fetched
+ * @param url The url being fetched
* @param payloadInput A payload input stream (if from the connected device). null if fetched from http(s)
- * @param cacheItem The disk cache item to edit
+ * @param cacheItem The disk cache item to edit
* @throws IOException
*/
FetchURLTask(URL url, InputStream payloadInput, DiskLruCache.Editor cacheItem) throws IOException {
@@ -233,14 +237,15 @@
/**
* Opens the http(s) connection
+ *
* @return True if succeeded
* @throws IOException
*/
private boolean openHttp() throws IOException {
//Default android behaviour does not follow https -> http urls, so do this manually
URL currentUrl = url;
HttpURLConnection connection;
- for (int i = 0; i<5; ++i) {
+ for (int i = 0; i < 5; ++i) {
connection = (HttpURLConnection) currentUrl.openConnection();
connection.setConnectTimeout(10000);
connection.setReadTimeout(10000);
@@ -324,7 +329,9 @@
--numFetching;
initiateFetch();
}
- };
+ }
+
+ ;
/**
* Does the actual fetching and makes sure only not too many fetches are running at the same time
@@ -357,6 +364,7 @@
/**
* The disk cache requires mostly alphanumeric characters, and at most 64 characters.
* So hash the url to get a valid key
+ *
* @param url The url
* @return A valid disk cache key
*/
@@ -378,8 +386,9 @@
/**
* Transfer an asked-for album art payload to the disk cache.
+ *
* @param albumUrl The url of the album art (should be a file:// url)
- * @param payload The payload input stream
+ * @param payload The payload input stream
*/
public static void payloadToDiskCache(String albumUrl, InputStream payload) {
//We need the disk cache for this
diff --git a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java
--- a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java
+++ b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java
@@ -58,7 +58,7 @@
private MprisPlugin.MprisPlayer targetPlayer = null;
private static String milisToProgress(long milis) {
- int length = (int)(milis / 1000); //From milis to seconds
+ int length = (int) (milis / 1000); //From milis to seconds
StringBuilder text = new StringBuilder();
int minutes = length / 60;
if (minutes > 60) {
@@ -69,10 +69,12 @@
}
text.append(minutes).append(':');
int seconds = (length % 60);
- if(seconds < 10) text.append('0'); // needed to show length properly (eg 4:05 instead of 4:5)
+ if (seconds < 10)
+ text.append('0'); // needed to show length properly (eg 4:05 instead of 4:5)
text.append(seconds);
return text.toString();
}
+
protected void connectToPlugin(final String targetPlayerName) {
BackgroundService.RunCommand(this, new BackgroundService.InstanceCallback() {
@@ -221,9 +223,9 @@
if (playerStatus.isSeekAllowed()) {
((TextView) findViewById(R.id.time_textview)).setText(milisToProgress(playerStatus.getLength()));
- SeekBar positionSeek = (SeekBar)findViewById(R.id.positionSeek);
- positionSeek.setMax((int)(playerStatus.getLength()));
- positionSeek.setProgress((int)(playerStatus.getPosition()));
+ SeekBar positionSeek = (SeekBar) findViewById(R.id.positionSeek);
+ positionSeek.setMax((int) (playerStatus.getLength()));
+ positionSeek.setProgress((int) (playerStatus.getPosition()));
findViewById(R.id.progress_slider).setVisibility(View.VISIBLE);
} else {
findViewById(R.id.progress_slider).setVisibility(View.GONE);
@@ -251,19 +253,19 @@
/**
* Change current volume with provided step.
*
- * @param step step size volume change
+ * @param step step size volume change
*/
private void updateVolume(int step) {
if (targetPlayer == null) {
return;
}
final int currentVolume = targetPlayer.getVolume();
- if(currentVolume < 100 || currentVolume > 0) {
+ if (currentVolume < 100 || currentVolume > 0) {
int newVolume = currentVolume + step;
- if(newVolume > 100) {
+ if (newVolume > 100) {
newVolume = 100;
- } else if (newVolume <0 ) {
+ } else if (newVolume < 0) {
newVolume = 0;
}
targetPlayer.setVolume(newVolume);
@@ -383,7 +385,7 @@
}
});
- ((SeekBar)findViewById(R.id.volume_seek)).setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
+ ((SeekBar) findViewById(R.id.volume_seek)).setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
}
@@ -408,7 +410,7 @@
positionSeekUpdateRunnable = new Runnable() {
@Override
public void run() {
- final SeekBar positionSeek = (SeekBar)findViewById(R.id.positionSeek);
+ final SeekBar positionSeek = (SeekBar) findViewById(R.id.positionSeek);
BackgroundService.RunCommand(MprisActivity.this, new BackgroundService.InstanceCallback() {
@Override
public void onServiceStart(BackgroundService service) {
@@ -424,10 +426,10 @@
};
positionSeekUpdateHandler.postDelayed(positionSeekUpdateRunnable, 200);
- ((SeekBar)findViewById(R.id.positionSeek)).setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
+ ((SeekBar) findViewById(R.id.positionSeek)).setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean byUser) {
- ((TextView)findViewById(R.id.progress_textview)).setText(milisToProgress(progress));
+ ((TextView) findViewById(R.id.progress_textview)).setText(milisToProgress(progress));
}
@Override
diff --git a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.java b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.java
--- a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.java
+++ b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.java
@@ -44,20 +44,22 @@
/**
* Controls the mpris media control notification
- *
+ *
* There are two parts to this:
- * - The notification (with buttons etc.)
- * - The media session (via MediaSessionCompat; for lock screen control on
- * older Android version. And in the future for lock screen album covers)
+ * - The notification (with buttons etc.)
+ * - The media session (via MediaSessionCompat; for lock screen control on
+ * older Android version. And in the future for lock screen album covers)
*/
public class MprisMediaSession implements SharedPreferences.OnSharedPreferenceChangeListener {
public final static int MPRIS_MEDIA_NOTIFICATION_ID = 0x91b70463; // echo MprisNotification | md5sum | head -c 8
public final static String MPRIS_MEDIA_SESSION_TAG = "org.kde.kdeconnect_tp.media_session";
private static MprisMediaSession instance = new MprisMediaSession();
+
public static MprisMediaSession getInstance() {
return instance;
}
+
public static MediaSessionCompat getMediaSession() {
return instance.mediaSession;
}
@@ -108,11 +110,12 @@
/**
* Called by the mpris plugin when it wants media control notifications for its device
- *
+ *
* Can be called multiple times, once for each device
+ *
* @param _context The context
- * @param mpris The mpris plugin
- * @param device The device id
+ * @param mpris The mpris plugin
+ * @param device The device id
*/
public void onCreate(Context _context, MprisPlugin mpris, String device) {
if (mprisDevices.isEmpty()) {
@@ -130,9 +133,10 @@
/**
* Called when a device disconnects/does not want notifications anymore
- *
+ *
* Can be called multiple times, once for each device
- * @param mpris The mpris plugin
+ *
+ * @param mpris The mpris plugin
* @param device The device id
*/
public void onDestroy(MprisPlugin mpris, String device) {
@@ -149,9 +153,10 @@
/**
* Updates which device+player we're going to use in the notification
- *
+ *
* Prefers playing devices/mpris players, but tries to keep displaying the same
* player and device, while possible.
+ *
* @param service The background service
*/
private void updateCurrentPlayer(BackgroundService service) {
@@ -210,176 +215,176 @@
BackgroundService.RunCommand(context, new BackgroundService.InstanceCallback() {
@Override
public void onServiceStart(BackgroundService service) {
- //If the user disabled the media notification, do not show it
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
- if (!prefs.getBoolean(context.getString(R.string.mpris_notification_key), true)) {
- closeMediaNotification();
- return;
- }
+ //If the user disabled the media notification, do not show it
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ if (!prefs.getBoolean(context.getString(R.string.mpris_notification_key), true)) {
+ closeMediaNotification();
+ return;
+ }
- //Make sure our information is up-to-date
- updateCurrentPlayer(service);
+ //Make sure our information is up-to-date
+ updateCurrentPlayer(service);
- //If the player disappeared (and no other playing one found), just remove the notification
- if (notificationPlayer == null) {
- closeMediaNotification();
- return;
- }
+ //If the player disappeared (and no other playing one found), just remove the notification
+ if (notificationPlayer == null) {
+ closeMediaNotification();
+ return;
+ }
- //Update the metadata and playback status
- if (mediaSession == null) {
- mediaSession = new MediaSessionCompat(context, MPRIS_MEDIA_SESSION_TAG);
- mediaSession.setCallback(mediaSessionCallback);
- mediaSession.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
- }
- MediaMetadataCompat.Builder metadata = new MediaMetadataCompat.Builder();
+ //Update the metadata and playback status
+ if (mediaSession == null) {
+ mediaSession = new MediaSessionCompat(context, MPRIS_MEDIA_SESSION_TAG);
+ mediaSession.setCallback(mediaSessionCallback);
+ mediaSession.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
+ }
+ MediaMetadataCompat.Builder metadata = new MediaMetadataCompat.Builder();
- //Fallback because older KDE connect versions do not support getTitle()
- if (!notificationPlayer.getTitle().isEmpty()) {
- metadata.putString(MediaMetadataCompat.METADATA_KEY_TITLE, notificationPlayer.getTitle());
- } else {
- metadata.putString(MediaMetadataCompat.METADATA_KEY_TITLE, notificationPlayer.getCurrentSong());
- }
- if (!notificationPlayer.getArtist().isEmpty()) {
- metadata.putString(MediaMetadataCompat.METADATA_KEY_AUTHOR, notificationPlayer.getArtist());
- }
- if (!notificationPlayer.getAlbum().isEmpty()) {
- metadata.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, notificationPlayer.getAlbum());
- }
- if (notificationPlayer.getLength() > 0) {
- metadata.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, notificationPlayer.getLength());
- }
+ //Fallback because older KDE connect versions do not support getTitle()
+ if (!notificationPlayer.getTitle().isEmpty()) {
+ metadata.putString(MediaMetadataCompat.METADATA_KEY_TITLE, notificationPlayer.getTitle());
+ } else {
+ metadata.putString(MediaMetadataCompat.METADATA_KEY_TITLE, notificationPlayer.getCurrentSong());
+ }
+ if (!notificationPlayer.getArtist().isEmpty()) {
+ metadata.putString(MediaMetadataCompat.METADATA_KEY_AUTHOR, notificationPlayer.getArtist());
+ }
+ if (!notificationPlayer.getAlbum().isEmpty()) {
+ metadata.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, notificationPlayer.getAlbum());
+ }
+ if (notificationPlayer.getLength() > 0) {
+ metadata.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, notificationPlayer.getLength());
+ }
- mediaSession.setMetadata(metadata.build());
- PlaybackStateCompat.Builder playbackState = new PlaybackStateCompat.Builder();
+ mediaSession.setMetadata(metadata.build());
+ PlaybackStateCompat.Builder playbackState = new PlaybackStateCompat.Builder();
- if (notificationPlayer.isPlaying()) {
- playbackState.setState(PlaybackStateCompat.STATE_PLAYING, notificationPlayer.getPosition(), 1.0f);
- } else {
- playbackState.setState(PlaybackStateCompat.STATE_PAUSED, notificationPlayer.getPosition(), 0.0f);
- }
+ if (notificationPlayer.isPlaying()) {
+ playbackState.setState(PlaybackStateCompat.STATE_PLAYING, notificationPlayer.getPosition(), 1.0f);
+ } else {
+ playbackState.setState(PlaybackStateCompat.STATE_PAUSED, notificationPlayer.getPosition(), 0.0f);
+ }
- //Create all actions (previous/play/pause/next)
- Intent iPlay = new Intent(service, MprisMediaNotificationReceiver.class);
- iPlay.setAction(MprisMediaNotificationReceiver.ACTION_PLAY);
- iPlay.putExtra(MprisMediaNotificationReceiver.EXTRA_DEVICE_ID, notificationDevice);
- iPlay.putExtra(MprisMediaNotificationReceiver.EXTRA_MPRIS_PLAYER, notificationPlayer.getPlayer());
- PendingIntent piPlay = PendingIntent.getBroadcast(service, 0, iPlay, PendingIntent.FLAG_UPDATE_CURRENT);
- NotificationCompat.Action.Builder aPlay = new NotificationCompat.Action.Builder(
- R.drawable.ic_play_white, service.getString(R.string.mpris_play), piPlay);
-
- Intent iPause = new Intent(service, MprisMediaNotificationReceiver.class);
- iPause.setAction(MprisMediaNotificationReceiver.ACTION_PAUSE);
- iPause.putExtra(MprisMediaNotificationReceiver.EXTRA_DEVICE_ID, notificationDevice);
- iPause.putExtra(MprisMediaNotificationReceiver.EXTRA_MPRIS_PLAYER, notificationPlayer.getPlayer());
- PendingIntent piPause = PendingIntent.getBroadcast(service, 0, iPause, PendingIntent.FLAG_UPDATE_CURRENT);
- NotificationCompat.Action.Builder aPause = new NotificationCompat.Action.Builder(
- R.drawable.ic_pause_white, service.getString(R.string.mpris_pause), piPause);
-
- Intent iPrevious = new Intent(service, MprisMediaNotificationReceiver.class);
- iPrevious.setAction(MprisMediaNotificationReceiver.ACTION_PREVIOUS);
- iPrevious.putExtra(MprisMediaNotificationReceiver.EXTRA_DEVICE_ID, notificationDevice);
- iPrevious.putExtra(MprisMediaNotificationReceiver.EXTRA_MPRIS_PLAYER, notificationPlayer.getPlayer());
- PendingIntent piPrevious = PendingIntent.getBroadcast(service, 0, iPrevious, PendingIntent.FLAG_UPDATE_CURRENT);
- NotificationCompat.Action.Builder aPrevious = new NotificationCompat.Action.Builder(
- R.drawable.ic_previous_white, service.getString(R.string.mpris_previous), piPrevious);
-
- Intent iNext = new Intent(service, MprisMediaNotificationReceiver.class);
- iNext.setAction(MprisMediaNotificationReceiver.ACTION_NEXT);
- iNext.putExtra(MprisMediaNotificationReceiver.EXTRA_DEVICE_ID, notificationDevice);
- iNext.putExtra(MprisMediaNotificationReceiver.EXTRA_MPRIS_PLAYER, notificationPlayer.getPlayer());
- PendingIntent piNext = PendingIntent.getBroadcast(service, 0, iNext, PendingIntent.FLAG_UPDATE_CURRENT);
- NotificationCompat.Action.Builder aNext = new NotificationCompat.Action.Builder(
- R.drawable.ic_next_white, service.getString(R.string.mpris_next), piNext);
-
- Intent iOpenActivity = new Intent(service, MprisActivity.class);
- iOpenActivity.putExtra("deviceId", notificationDevice);
- iOpenActivity.putExtra("player", notificationPlayer.getPlayer());
- PendingIntent piOpenActivity = PendingIntent.getActivity(service, 0, iOpenActivity, PendingIntent.FLAG_UPDATE_CURRENT);
-
- //Create the notification
- final NotificationCompat.Builder notification = new NotificationCompat.Builder(service);
- notification
- .setAutoCancel(false)
- .setContentIntent(piOpenActivity)
- .setSmallIcon(R.drawable.ic_play_white)
- .setShowWhen(false)
- .setColor(service.getResources().getColor(R.color.primary));
-
- if (!notificationPlayer.getTitle().isEmpty()) {
- notification.setContentTitle(notificationPlayer.getTitle());
- } else {
- notification.setContentTitle(notificationPlayer.getCurrentSong());
- }
- //Only set the notification body text if we have an author and/or album
- if (!notificationPlayer.getArtist().isEmpty() && !notificationPlayer.getAlbum().isEmpty()) {
- notification.setContentText(notificationPlayer.getArtist() + " - " + notificationPlayer.getAlbum() + " (" + notificationPlayer.getPlayer() + ")");
- } else if (!notificationPlayer.getArtist().isEmpty()) {
- notification.setContentText(notificationPlayer.getArtist() + " (" + notificationPlayer.getPlayer() + ")");
- } else if (!notificationPlayer.getAlbum().isEmpty()) {
- notification.setContentText(notificationPlayer.getAlbum() + " (" + notificationPlayer.getPlayer() + ")");
- } else {
- notification.setContentText(notificationPlayer.getPlayer());
- }
+ //Create all actions (previous/play/pause/next)
+ Intent iPlay = new Intent(service, MprisMediaNotificationReceiver.class);
+ iPlay.setAction(MprisMediaNotificationReceiver.ACTION_PLAY);
+ iPlay.putExtra(MprisMediaNotificationReceiver.EXTRA_DEVICE_ID, notificationDevice);
+ iPlay.putExtra(MprisMediaNotificationReceiver.EXTRA_MPRIS_PLAYER, notificationPlayer.getPlayer());
+ PendingIntent piPlay = PendingIntent.getBroadcast(service, 0, iPlay, PendingIntent.FLAG_UPDATE_CURRENT);
+ NotificationCompat.Action.Builder aPlay = new NotificationCompat.Action.Builder(
+ R.drawable.ic_play_white, service.getString(R.string.mpris_play), piPlay);
+
+ Intent iPause = new Intent(service, MprisMediaNotificationReceiver.class);
+ iPause.setAction(MprisMediaNotificationReceiver.ACTION_PAUSE);
+ iPause.putExtra(MprisMediaNotificationReceiver.EXTRA_DEVICE_ID, notificationDevice);
+ iPause.putExtra(MprisMediaNotificationReceiver.EXTRA_MPRIS_PLAYER, notificationPlayer.getPlayer());
+ PendingIntent piPause = PendingIntent.getBroadcast(service, 0, iPause, PendingIntent.FLAG_UPDATE_CURRENT);
+ NotificationCompat.Action.Builder aPause = new NotificationCompat.Action.Builder(
+ R.drawable.ic_pause_white, service.getString(R.string.mpris_pause), piPause);
+
+ Intent iPrevious = new Intent(service, MprisMediaNotificationReceiver.class);
+ iPrevious.setAction(MprisMediaNotificationReceiver.ACTION_PREVIOUS);
+ iPrevious.putExtra(MprisMediaNotificationReceiver.EXTRA_DEVICE_ID, notificationDevice);
+ iPrevious.putExtra(MprisMediaNotificationReceiver.EXTRA_MPRIS_PLAYER, notificationPlayer.getPlayer());
+ PendingIntent piPrevious = PendingIntent.getBroadcast(service, 0, iPrevious, PendingIntent.FLAG_UPDATE_CURRENT);
+ NotificationCompat.Action.Builder aPrevious = new NotificationCompat.Action.Builder(
+ R.drawable.ic_previous_white, service.getString(R.string.mpris_previous), piPrevious);
+
+ Intent iNext = new Intent(service, MprisMediaNotificationReceiver.class);
+ iNext.setAction(MprisMediaNotificationReceiver.ACTION_NEXT);
+ iNext.putExtra(MprisMediaNotificationReceiver.EXTRA_DEVICE_ID, notificationDevice);
+ iNext.putExtra(MprisMediaNotificationReceiver.EXTRA_MPRIS_PLAYER, notificationPlayer.getPlayer());
+ PendingIntent piNext = PendingIntent.getBroadcast(service, 0, iNext, PendingIntent.FLAG_UPDATE_CURRENT);
+ NotificationCompat.Action.Builder aNext = new NotificationCompat.Action.Builder(
+ R.drawable.ic_next_white, service.getString(R.string.mpris_next), piNext);
+
+ Intent iOpenActivity = new Intent(service, MprisActivity.class);
+ iOpenActivity.putExtra("deviceId", notificationDevice);
+ iOpenActivity.putExtra("player", notificationPlayer.getPlayer());
+ PendingIntent piOpenActivity = PendingIntent.getActivity(service, 0, iOpenActivity, PendingIntent.FLAG_UPDATE_CURRENT);
+
+ //Create the notification
+ final NotificationCompat.Builder notification = new NotificationCompat.Builder(service);
+ notification
+ .setAutoCancel(false)
+ .setContentIntent(piOpenActivity)
+ .setSmallIcon(R.drawable.ic_play_white)
+ .setShowWhen(false)
+ .setColor(service.getResources().getColor(R.color.primary));
+
+ if (!notificationPlayer.getTitle().isEmpty()) {
+ notification.setContentTitle(notificationPlayer.getTitle());
+ } else {
+ notification.setContentTitle(notificationPlayer.getCurrentSong());
+ }
+ //Only set the notification body text if we have an author and/or album
+ if (!notificationPlayer.getArtist().isEmpty() && !notificationPlayer.getAlbum().isEmpty()) {
+ notification.setContentText(notificationPlayer.getArtist() + " - " + notificationPlayer.getAlbum() + " (" + notificationPlayer.getPlayer() + ")");
+ } else if (!notificationPlayer.getArtist().isEmpty()) {
+ notification.setContentText(notificationPlayer.getArtist() + " (" + notificationPlayer.getPlayer() + ")");
+ } else if (!notificationPlayer.getAlbum().isEmpty()) {
+ notification.setContentText(notificationPlayer.getAlbum() + " (" + notificationPlayer.getPlayer() + ")");
+ } else {
+ notification.setContentText(notificationPlayer.getPlayer());
+ }
- if (!notificationPlayer.isPlaying()) {
- Intent iCloseNotification = new Intent(service, MprisMediaNotificationReceiver.class);
- iCloseNotification.setAction(MprisMediaNotificationReceiver.ACTION_CLOSE_NOTIFICATION);
- iCloseNotification.putExtra(MprisMediaNotificationReceiver.EXTRA_DEVICE_ID, notificationDevice);
- iCloseNotification.putExtra(MprisMediaNotificationReceiver.EXTRA_MPRIS_PLAYER, notificationPlayer.getPlayer());
- PendingIntent piCloseNotification = PendingIntent.getActivity(service, 0, iCloseNotification, PendingIntent.FLAG_UPDATE_CURRENT);
- notification.setDeleteIntent(piCloseNotification);
- }
+ if (!notificationPlayer.isPlaying()) {
+ Intent iCloseNotification = new Intent(service, MprisMediaNotificationReceiver.class);
+ iCloseNotification.setAction(MprisMediaNotificationReceiver.ACTION_CLOSE_NOTIFICATION);
+ iCloseNotification.putExtra(MprisMediaNotificationReceiver.EXTRA_DEVICE_ID, notificationDevice);
+ iCloseNotification.putExtra(MprisMediaNotificationReceiver.EXTRA_MPRIS_PLAYER, notificationPlayer.getPlayer());
+ PendingIntent piCloseNotification = PendingIntent.getActivity(service, 0, iCloseNotification, PendingIntent.FLAG_UPDATE_CURRENT);
+ notification.setDeleteIntent(piCloseNotification);
+ }
- //Add media control actions
- int numActions = 0;
- long playbackActions = 0;
- if (notificationPlayer.isGoPreviousAllowed()) {
- notification.addAction(aPrevious.build());
- playbackActions |= PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS;
- ++numActions;
- }
- if (notificationPlayer.isPlaying() && notificationPlayer.isPauseAllowed()) {
- notification.addAction(aPause.build());
- playbackActions |= PlaybackStateCompat.ACTION_PAUSE;
- ++numActions;
- }
- if (!notificationPlayer.isPlaying() && notificationPlayer.isPlayAllowed()) {
- notification.addAction(aPlay.build());
- playbackActions |= PlaybackStateCompat.ACTION_PLAY;
- ++numActions;
- }
- if (notificationPlayer.isGoNextAllowed()) {
- notification.addAction(aNext.build());
- playbackActions |= PlaybackStateCompat.ACTION_SKIP_TO_NEXT;
- ++numActions;
- }
- playbackState.setActions(playbackActions);
- mediaSession.setPlaybackState(playbackState.build());
-
- //Only allow deletion if no music is notificationPlayer
- if (notificationPlayer.isPlaying()) {
- notification.setOngoing(true);
- } else {
- notification.setOngoing(false);
- }
+ //Add media control actions
+ int numActions = 0;
+ long playbackActions = 0;
+ if (notificationPlayer.isGoPreviousAllowed()) {
+ notification.addAction(aPrevious.build());
+ playbackActions |= PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS;
+ ++numActions;
+ }
+ if (notificationPlayer.isPlaying() && notificationPlayer.isPauseAllowed()) {
+ notification.addAction(aPause.build());
+ playbackActions |= PlaybackStateCompat.ACTION_PAUSE;
+ ++numActions;
+ }
+ if (!notificationPlayer.isPlaying() && notificationPlayer.isPlayAllowed()) {
+ notification.addAction(aPlay.build());
+ playbackActions |= PlaybackStateCompat.ACTION_PLAY;
+ ++numActions;
+ }
+ if (notificationPlayer.isGoNextAllowed()) {
+ notification.addAction(aNext.build());
+ playbackActions |= PlaybackStateCompat.ACTION_SKIP_TO_NEXT;
+ ++numActions;
+ }
+ playbackState.setActions(playbackActions);
+ mediaSession.setPlaybackState(playbackState.build());
+
+ //Only allow deletion if no music is notificationPlayer
+ if (notificationPlayer.isPlaying()) {
+ notification.setOngoing(true);
+ } else {
+ notification.setOngoing(false);
+ }
- //Use the MediaStyle notification, so it feels like other media players. That also allows adding actions
- NotificationCompat.MediaStyle mediaStyle = new NotificationCompat.MediaStyle();
- if (numActions == 1) {
- mediaStyle.setShowActionsInCompactView(0);
- } else if (numActions == 2) {
- mediaStyle.setShowActionsInCompactView(0, 1);
- } else if (numActions >= 3) {
- mediaStyle.setShowActionsInCompactView(0, 1, 2);
- }
- mediaStyle.setMediaSession(mediaSession.getSessionToken());
- notification.setStyle(mediaStyle);
+ //Use the MediaStyle notification, so it feels like other media players. That also allows adding actions
+ NotificationCompat.MediaStyle mediaStyle = new NotificationCompat.MediaStyle();
+ if (numActions == 1) {
+ mediaStyle.setShowActionsInCompactView(0);
+ } else if (numActions == 2) {
+ mediaStyle.setShowActionsInCompactView(0, 1);
+ } else if (numActions >= 3) {
+ mediaStyle.setShowActionsInCompactView(0, 1, 2);
+ }
+ mediaStyle.setMediaSession(mediaSession.getSessionToken());
+ notification.setStyle(mediaStyle);
- //Display the notification
- mediaSession.setActive(true);
- final NotificationManager nm = (NotificationManager) service.getSystemService(Context.NOTIFICATION_SERVICE);
- nm.notify(MPRIS_MEDIA_NOTIFICATION_ID, notification.build());
+ //Display the notification
+ mediaSession.setActive(true);
+ final NotificationManager nm = (NotificationManager) service.getSystemService(Context.NOTIFICATION_SERVICE);
+ nm.notify(MPRIS_MEDIA_NOTIFICATION_ID, notification.build());
}
});
}
diff --git a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisPlugin.java b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisPlugin.java
--- a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisPlugin.java
+++ b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisPlugin.java
@@ -92,7 +92,9 @@
return volume;
}
- public long getLength(){ return length; }
+ public long getLength() {
+ return length;
+ }
public boolean isPlaying() {
return playing;
@@ -124,6 +126,7 @@
/**
* Returns the album art (if available). Note that this can return null even if hasAlbumArt() returns true.
+ *
* @return The album art, or null if not available
*/
public Bitmap getAlbumArt() {
@@ -134,8 +137,8 @@
return !isSpotify();
}
- public long getPosition(){
- if(playing) {
+ public long getPosition() {
+ if (playing) {
return lastPosition + (System.currentTimeMillis() - lastPositionTime);
} else {
return lastPosition;
@@ -202,9 +205,9 @@
public final static String PACKAGE_TYPE_MPRIS_REQUEST = "kdeconnect.mpris.request";
private HashMap players = new HashMap<>();
- private HashMap playerStatusUpdated = new HashMap<>();
+ private HashMap playerStatusUpdated = new HashMap<>();
- private HashMap playerListUpdated = new HashMap<>();
+ private HashMap playerListUpdated = new HashMap<>();
@Override
public String getDisplayName() {
@@ -273,7 +276,7 @@
playerStatus.album = np.getString("album", playerStatus.album);
playerStatus.volume = np.getInt("volume", playerStatus.volume);
playerStatus.length = np.getLong("length", playerStatus.length);
- if(np.has("pos")){
+ if (np.has("pos")) {
playerStatus.lastPosition = np.getLong("pos", playerStatus.lastPosition);
playerStatus.lastPositionTime = System.currentTimeMillis();
}
@@ -288,13 +291,14 @@
//Turn the url into canonical form (and check its validity)
URL newAlbumArtUrl = new URL(newAlbumArtUrlstring);
playerStatus.albumArtUrl = newAlbumArtUrlstring.toString();
- } catch (MalformedURLException ignored) {}
+ } catch (MalformedURLException ignored) {
+ }
for (String key : playerStatusUpdated.keySet()) {
try {
playerStatusUpdated.get(key).dispatchMessage(new Message());
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
- Log.e("MprisControl","Exception");
+ Log.e("MprisControl", "Exception");
playerStatusUpdated.remove(key);
}
}
@@ -337,9 +341,9 @@
for (String key : playerListUpdated.keySet()) {
try {
playerListUpdated.get(key).dispatchMessage(new Message());
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
- Log.e("MprisControl","Exception");
+ Log.e("MprisControl", "Exception");
playerListUpdated.remove(key);
}
}
@@ -351,12 +355,12 @@
@Override
public String[] getSupportedPackageTypes() {
- return new String[] {PACKAGE_TYPE_MPRIS};
+ return new String[]{PACKAGE_TYPE_MPRIS};
}
@Override
public String[] getOutgoingPackageTypes() {
- return new String[] {PACKAGE_TYPE_MPRIS_REQUEST};
+ return new String[]{PACKAGE_TYPE_MPRIS_REQUEST};
}
public void setPlayerStatusUpdatedHandler(String id, Handler h) {
@@ -370,7 +374,7 @@
}
public void setPlayerListUpdatedHandler(String id, Handler h) {
- playerListUpdated.put(id,h);
+ playerListUpdated.put(id, h);
h.dispatchMessage(new Message());
}
@@ -395,6 +399,7 @@
/**
* Returns a playing mpris player, if any exist
+ *
* @return null if no players are playing, a playing player otherwise
*/
public MprisPlayer getPlayingPlayer() {
@@ -408,15 +413,15 @@
private void requestPlayerList() {
NetworkPackage np = new NetworkPackage(PACKAGE_TYPE_MPRIS_REQUEST);
- np.set("requestPlayerList",true);
+ np.set("requestPlayerList", true);
device.sendPackage(np);
}
private void requestPlayerStatus(String player) {
NetworkPackage np = new NetworkPackage(PACKAGE_TYPE_MPRIS_REQUEST);
np.set("player", player);
- np.set("requestNowPlaying",true);
- np.set("requestVolume",true);
+ np.set("requestNowPlaying", true);
+ np.set("requestVolume", true);
device.sendPackage(np);
}
@@ -449,9 +454,9 @@
for (String key : playerStatusUpdated.keySet()) {
try {
playerStatusUpdated.get(key).dispatchMessage(new Message());
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
- Log.e("MprisControl","Exception");
+ Log.e("MprisControl", "Exception");
playerStatusUpdated.remove(key);
}
}
diff --git a/src/org/kde/kdeconnect/Plugins/PingPlugin/PingPlugin.java b/src/org/kde/kdeconnect/Plugins/PingPlugin/PingPlugin.java
--- a/src/org/kde/kdeconnect/Plugins/PingPlugin/PingPlugin.java
+++ b/src/org/kde/kdeconnect/Plugins/PingPlugin/PingPlugin.java
@@ -65,15 +65,15 @@
stackBuilder.addParentStack(MaterialActivity.class);
stackBuilder.addNextIntent(new Intent(context, MaterialActivity.class));
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(
- 0,
- PendingIntent.FLAG_UPDATE_CURRENT
+ 0,
+ PendingIntent.FLAG_UPDATE_CURRENT
);
int id;
String message;
if (np.has("message")) {
message = np.getString("message");
- id = (int)System.currentTimeMillis();
+ id = (int) System.currentTimeMillis();
} else {
message = "Ping!";
id = 42; //A unique id to create only one notification
diff --git a/src/org/kde/kdeconnect/Plugins/Plugin.java b/src/org/kde/kdeconnect/Plugins/Plugin.java
--- a/src/org/kde/kdeconnect/Plugins/Plugin.java
+++ b/src/org/kde/kdeconnect/Plugins/Plugin.java
@@ -78,6 +78,7 @@
public String getPluginKey() {
return getPluginKey(this.getClass());
}
+
public static String getPluginKey(Class extends Plugin> p) {
return p.getSimpleName();
}
@@ -149,7 +150,8 @@
/**
* Implement here what your plugin should do when clicked
*/
- public void startMainActivity(Activity parentActivity) { }
+ public void startMainActivity(Activity parentActivity) {
+ }
/**
* Return true if the entry for this app should appear in the context menu instead of the main view
@@ -170,14 +172,17 @@
* Finish any ongoing operations, remove listeners... so
* this object could be garbage collected.
*/
- public void onDestroy() { }
+ public void onDestroy() {
+ }
/**
* Called when a plugin receives a package. By convention we return true
* when we have done something in response to the package or false
* otherwise, even though that value is unused as of now.
*/
- public boolean onPackageReceived(NetworkPackage np) { return false; }
+ public boolean onPackageReceived(NetworkPackage np) {
+ return false;
+ }
/**
* Should return the list of NetworkPackage types that this plugin can handle
@@ -224,8 +229,8 @@
}
protected boolean arePermissionsGranted(String[] permissions) {
- for(String permission: permissions){
- if(!isPermissionGranted(permission)){
+ for (String permission : permissions) {
+ if (!isPermissionGranted(permission)) {
return false;
}
}
@@ -236,7 +241,7 @@
return requestPermissionDialog(activity, new String[]{permissions}, reason);
}
- protected AlertDialog requestPermissionDialog(final Activity activity, final String[] permissions, @StringRes int reason){
+ protected AlertDialog requestPermissionDialog(final Activity activity, final String[] permissions, @StringRes int reason) {
return new AlertDialog.Builder(activity)
.setTitle(getDisplayName())
.setMessage(reason)
@@ -246,7 +251,7 @@
ActivityCompat.requestPermissions(activity, permissions, 0);
}
})
- .setNegativeButton(R.string.cancel,new DialogInterface.OnClickListener() {
+ .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
//Do nothing
@@ -265,19 +270,19 @@
}
public AlertDialog getPermissionExplanationDialog(Activity deviceActivity) {
- return requestPermissionDialog(deviceActivity,getRequiredPermissions(), permissionExplanation);
+ return requestPermissionDialog(deviceActivity, getRequiredPermissions(), permissionExplanation);
}
public AlertDialog getOptionalPermissionExplanationDialog(Activity deviceActivity) {
- return requestPermissionDialog(deviceActivity,getOptionalPermissions(), optionalPermissionExplanation);
+ return requestPermissionDialog(deviceActivity, getOptionalPermissions(), optionalPermissionExplanation);
}
- public boolean checkRequiredPermissions(){
+ public boolean checkRequiredPermissions() {
return arePermissionsGranted(getRequiredPermissions());
}
- public boolean checkOptionalPermissions(){
- return arePermissionsGranted(getOptionalPermissions());
+ public boolean checkOptionalPermissions() {
+ return arePermissionsGranted(getOptionalPermissions());
}
public int getMinSdk() {
diff --git a/src/org/kde/kdeconnect/Plugins/PluginFactory.java b/src/org/kde/kdeconnect/Plugins/PluginFactory.java
--- a/src/org/kde/kdeconnect/Plugins/PluginFactory.java
+++ b/src/org/kde/kdeconnect/Plugins/PluginFactory.java
@@ -79,7 +79,9 @@
return icon;
}
- public boolean hasSettings() { return hasSettings; }
+ public boolean hasSettings() {
+ return hasSettings;
+ }
public boolean isEnabledByDefault() {
return enabledByDefault;
@@ -136,15 +138,15 @@
}
try {
- Plugin p = ((Plugin)availablePlugins.get(pluginKey).newInstance());
+ Plugin p = ((Plugin) availablePlugins.get(pluginKey).newInstance());
p.setContext(context, null);
info = new PluginInfo(p.getDisplayName(), p.getDescription(), p.getIcon(),
p.isEnabledByDefault(), p.hasSettings(), p.listensToUnpairedDevices(),
p.getSupportedPackageTypes(), p.getOutgoingPackageTypes());
pluginInfoCache.put(pluginKey, info); //Cache it
return info;
- } catch(Exception e) {
- Log.e("PluginFactory","getPluginInfo exception");
+ } catch (Exception e) {
+ Log.e("PluginFactory", "getPluginInfo exception");
e.printStackTrace();
throw new RuntimeException(e);
}
@@ -158,16 +160,16 @@
public static Plugin instantiatePluginForDevice(Context context, String pluginKey, Device device) {
Class c = availablePlugins.get(pluginKey);
if (c == null) {
- Log.e("PluginFactory", "Plugin not found: "+pluginKey);
+ Log.e("PluginFactory", "Plugin not found: " + pluginKey);
return null;
}
try {
- Plugin plugin = (Plugin)c.newInstance();
+ Plugin plugin = (Plugin) c.newInstance();
plugin.setContext(context, device);
return plugin;
- } catch(Exception e) {
- Log.e("PluginFactory", "Could not instantiate plugin: "+pluginKey);
+ } catch (Exception e) {
+ Log.e("PluginFactory", "Could not instantiate plugin: " + pluginKey);
e.printStackTrace();
return null;
}
@@ -178,8 +180,8 @@
try {
String pluginKey = Plugin.getPluginKey(pluginClass);
availablePlugins.put(pluginKey, pluginClass);
- } catch(Exception e) {
- Log.e("PluginFactory","addPlugin exception");
+ } catch (Exception e) {
+ Log.e("PluginFactory", "addPlugin exception");
e.printStackTrace();
}
}
@@ -210,7 +212,7 @@
PluginInfo plugin = getPluginInfo(context, pluginId);
//Check incoming against outgoing
if (Collections.disjoint(outgoing, plugin.getSupportedPackageTypes())
- && Collections.disjoint(incoming, plugin.getOutgoingPackageTypes())) {
+ && Collections.disjoint(incoming, plugin.getOutgoingPackageTypes())) {
Log.i("PluginFactory", "Won't load " + pluginId + " because of unmatched capabilities");
continue; //No capabilities in common, do not load this plugin
}
diff --git a/src/org/kde/kdeconnect/Plugins/ReceiveNotificationsPlugin/ReceiveNotificationsPlugin.java b/src/org/kde/kdeconnect/Plugins/ReceiveNotificationsPlugin/ReceiveNotificationsPlugin.java
--- a/src/org/kde/kdeconnect/Plugins/ReceiveNotificationsPlugin/ReceiveNotificationsPlugin.java
+++ b/src/org/kde/kdeconnect/Plugins/ReceiveNotificationsPlugin/ReceiveNotificationsPlugin.java
@@ -93,7 +93,10 @@
}
final InputStream input = np.getPayload();
largeIcon = BitmapFactory.decodeStream(np.getPayload());
- try { input.close(); } catch (Exception e) { }
+ try {
+ input.close();
+ } catch (Exception e) {
+ }
if (largeIcon != null) {
//Log.i("NotificationsPlugin", "hasPayload: size=" + largeIcon.getWidth() + "/" + largeIcon.getHeight() + " opti=" + width + "/" + height);
if (largeIcon.getWidth() > width || largeIcon.getHeight() > height) {
diff --git a/src/org/kde/kdeconnect/Plugins/RemoteKeyboardPlugin/RemoteKeyboardPlugin.java b/src/org/kde/kdeconnect/Plugins/RemoteKeyboardPlugin/RemoteKeyboardPlugin.java
--- a/src/org/kde/kdeconnect/Plugins/RemoteKeyboardPlugin/RemoteKeyboardPlugin.java
+++ b/src/org/kde/kdeconnect/Plugins/RemoteKeyboardPlugin/RemoteKeyboardPlugin.java
@@ -52,17 +52,21 @@
*/
private static ArrayList instances = new ArrayList();
private static ReentrantLock instancesLock = new ReentrantLock(true);
+
public static ArrayList getInstances() {
return instances;
}
+
public static ArrayList acquireInstances() {
instancesLock.lock();
return getInstances();
}
+
public static ArrayList releaseInstances() {
instancesLock.unlock();
return getInstances();
}
+
public static boolean isConnected() {
return instances.size() > 0;
}
@@ -210,7 +214,7 @@
return -1;
}
- private Pair currentSelection(ExtractedText extractedText) {
+ private Pair currentSelection(ExtractedText extractedText) {
if (extractedText != null)
return new Pair<>(extractedText.selectionStart, extractedText.selectionEnd);
return new Pair<>(-1, -1);
@@ -235,12 +239,12 @@
int startPos = pos;
int endPos = pos;
if (shift) { // Shift -> select word (otherwise jump)
- Pair sel = currentSelection(extractedText);
+ Pair sel = currentSelection(extractedText);
int cursor = currentCursorPos(extractedText);
// Log.d("RemoteKeyboardPlugin", "Selection (to right): " + sel.first + " / " + sel.second + " cursor: " + cursor);
startPos = cursor;
if (sel.first < cursor || // active selection from left to right -> grow
- sel.first > sel.second) // active selection from right to left -> shrink
+ sel.first > sel.second) // active selection from right to left -> shrink
startPos = sel.first;
}
inputConn.setSelection(startPos, endPos);
@@ -255,12 +259,12 @@
int startPos = pos;
int endPos = pos;
if (shift) {
- Pair sel = currentSelection(extractedText);
+ Pair sel = currentSelection(extractedText);
int cursor = currentCursorPos(extractedText);
// Log.d("RemoteKeyboardPlugin", "Selection (to left): " + sel.first + " / " + sel.second + " cursor: " + cursor);
startPos = cursor;
if (cursor < sel.first || // active selection from right to left -> grow
- sel.first < sel.second) // active selection from right to left -> shrink
+ sel.first < sel.second) // active selection from right to left -> shrink
startPos = sel.first;
}
inputConn.setSelection(startPos, endPos);
@@ -284,9 +288,9 @@
// Log.d("RemoteKeyboardPlugin", "Enter: " + editorInfo.imeOptions);
if (editorInfo != null
&& (((editorInfo.imeOptions & EditorInfo.IME_FLAG_NO_ENTER_ACTION) == 0)
- || ctrl)) { // Ctrl+Return overrides IME_FLAG_NO_ENTER_ACTION (FIXME: make configurable?)
+ || ctrl)) { // Ctrl+Return overrides IME_FLAG_NO_ENTER_ACTION (FIXME: make configurable?)
// check for special DONE/GO/etc actions first:
- int[] actions = { EditorInfo.IME_ACTION_GO, EditorInfo.IME_ACTION_NEXT,
+ int[] actions = {EditorInfo.IME_ACTION_GO, EditorInfo.IME_ACTION_NEXT,
EditorInfo.IME_ACTION_SEND, EditorInfo.IME_ACTION_SEARCH,
EditorInfo.IME_ACTION_DONE}; // note: DONE should be last or we might hide the ime instead of "go"
for (int i = 0; i < actions.length; i++) {
diff --git a/src/org/kde/kdeconnect/Plugins/RemoteKeyboardPlugin/RemoteKeyboardService.java b/src/org/kde/kdeconnect/Plugins/RemoteKeyboardPlugin/RemoteKeyboardService.java
--- a/src/org/kde/kdeconnect/Plugins/RemoteKeyboardPlugin/RemoteKeyboardService.java
+++ b/src/org/kde/kdeconnect/Plugins/RemoteKeyboardPlugin/RemoteKeyboardService.java
@@ -119,7 +119,7 @@
visible = true;
ArrayList instances = RemoteKeyboardPlugin.acquireInstances();
try {
- for (RemoteKeyboardPlugin i: instances)
+ for (RemoteKeyboardPlugin i : instances)
i.notifyKeyboardState(true);
} finally {
RemoteKeyboardPlugin.releaseInstances();
@@ -133,7 +133,7 @@
visible = false;
ArrayList instances = RemoteKeyboardPlugin.acquireInstances();
try {
- for (RemoteKeyboardPlugin i: instances)
+ for (RemoteKeyboardPlugin i : instances)
i.notifyKeyboardState(false);
} finally {
RemoteKeyboardPlugin.releaseInstances();
diff --git a/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandPlugin.java b/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandPlugin.java
--- a/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandPlugin.java
+++ b/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandPlugin.java
@@ -53,7 +53,7 @@
interface CommandsChangedCallback {
void update();
- };
+ }
public ArrayList getCommandList() {
return commandList;
@@ -88,7 +88,7 @@
try {
JSONObject obj = new JSONObject(np.getString("commandList"));
Iterator keys = obj.keys();
- while(keys.hasNext()){
+ while (keys.hasNext()) {
String s = keys.next();
JSONObject o = obj.getJSONObject(s);
o.put("key", s);
diff --git a/src/org/kde/kdeconnect/Plugins/SftpPlugin/SimpleSftpServer.java b/src/org/kde/kdeconnect/Plugins/SftpPlugin/SimpleSftpServer.java
--- a/src/org/kde/kdeconnect/Plugins/SftpPlugin/SimpleSftpServer.java
+++ b/src/org/kde/kdeconnect/Plugins/SftpPlugin/SimpleSftpServer.java
@@ -78,6 +78,7 @@
Security.insertProviderAt(SslHelper.BC, 1);
SecurityUtils.setRegisterBouncyCastle(false);
}
+
private final SshServer sshd = SshServer.setUpDefaultServer();
public void init(Context context, Device device) {
@@ -90,7 +91,7 @@
sshd.setFileSystemFactory(new AndroidFileSystemFactory(context));
sshd.setCommandFactory(new ScpCommandFactory());
- sshd.setSubsystemFactories(Collections.singletonList((NamedFactory)new SftpSubsystem.Factory()));
+ sshd.setSubsystemFactories(Collections.singletonList((NamedFactory) new SftpSubsystem.Factory()));
if (device.publicKey != null) {
keyAuth.deviceKey = device.publicKey;
@@ -105,12 +106,12 @@
passwordAuth.password = RandomHelper.randomString(28);
port = STARTPORT;
- while(!started) {
+ while (!started) {
try {
sshd.setPort(port);
sshd.start();
started = true;
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
port++;
if (port >= ENDPORT) {
@@ -145,7 +146,7 @@
public String getLocalIpAddress() {
String ip6 = null;
try {
- for (Enumeration en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
+ for (Enumeration en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) {
NetworkInterface intf = en.nextElement();
// Anything with rmnet is related to cellular connections or USB
@@ -156,13 +157,13 @@
// If we run across an interface that has this, we can safely
// ignore it. In fact, it's much safer to do. If we don't, we
// might get invalid IP adddresses out of it.
- if(intf.getDisplayName().contains("rmnet")) continue;
+ if (intf.getDisplayName().contains("rmnet")) continue;
- for (Enumeration enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
+ for (Enumeration enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements(); ) {
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress()) {
String address = inetAddress.getHostAddress();
- if(inetAddress instanceof Inet4Address) { //Prefer IPv4 over IPv6, because sshfs doesn't seem to like IPv6
+ if (inetAddress instanceof Inet4Address) { //Prefer IPv4 over IPv6, because sshfs doesn't seem to like IPv6
return address;
} else {
ip6 = address;
diff --git a/src/org/kde/kdeconnect/Plugins/SharePlugin/NotificationUpdateCallback.java b/src/org/kde/kdeconnect/Plugins/SharePlugin/NotificationUpdateCallback.java
--- a/src/org/kde/kdeconnect/Plugins/SharePlugin/NotificationUpdateCallback.java
+++ b/src/org/kde/kdeconnect/Plugins/SharePlugin/NotificationUpdateCallback.java
@@ -39,15 +39,15 @@
} else {
title = res.getString(R.string.outgoing_file_title, device.getName());
}
- notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
+ notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
builder = new NotificationCompat.Builder(context)
.setSmallIcon(android.R.drawable.stat_sys_upload)
.setAutoCancel(true)
.setProgress(100, 0, false)
.setContentTitle(title)
.setTicker(title);
- notificationId = (int)System.currentTimeMillis();
+ notificationId = (int) System.currentTimeMillis();
numFiles = toSend.size();
diff --git a/src/org/kde/kdeconnect/Plugins/SharePlugin/ShareActivity.java b/src/org/kde/kdeconnect/Plugins/SharePlugin/ShareActivity.java
--- a/src/org/kde/kdeconnect/Plugins/SharePlugin/ShareActivity.java
+++ b/src/org/kde/kdeconnect/Plugins/SharePlugin/ShareActivity.java
@@ -84,7 +84,10 @@
new Thread(new Runnable() {
@Override
public void run() {
- try { Thread.sleep(1500); } catch (InterruptedException ignored) { }
+ try {
+ Thread.sleep(1500);
+ } catch (InterruptedException ignored) {
+ }
runOnUiThread(new Runnable() {
@Override
public void run() {
@@ -171,13 +174,13 @@
final Intent intent = getIntent();
final String deviceId = intent.getStringExtra("deviceId");
- if (deviceId!=null) {
+ if (deviceId != null) {
- BackgroundService.RunCommand(this, new BackgroundService.InstanceCallback(){
+ BackgroundService.RunCommand(this, new BackgroundService.InstanceCallback() {
@Override
public void onServiceStart(BackgroundService service) {
- Log.d("DirectShare", "sharing to "+service.getDevice(deviceId).getName());
+ Log.d("DirectShare", "sharing to " + service.getDevice(deviceId).getName());
Device device = service.getDevice(deviceId);
if (device.isReachable() && device.isPaired()) {
SharePlugin.share(intent, device);
diff --git a/src/org/kde/kdeconnect/Plugins/SharePlugin/ShareChooserTargetService.java b/src/org/kde/kdeconnect/Plugins/SharePlugin/ShareChooserTargetService.java
--- a/src/org/kde/kdeconnect/Plugins/SharePlugin/ShareChooserTargetService.java
+++ b/src/org/kde/kdeconnect/Plugins/SharePlugin/ShareChooserTargetService.java
@@ -42,8 +42,8 @@
public List onGetChooserTargets(ComponentName targetActivityName, IntentFilter matchedFilter) {
Log.d("DirectShare", "invoked");
final List targets = new ArrayList<>();
- for(Device d: BackgroundService.getInstance().getDevices().values()){
- if(d.isReachable() && d.isPaired()) {
+ for (Device d : BackgroundService.getInstance().getDevices().values()) {
+ if (d.isReachable() && d.isPaired()) {
Log.d("DirectShare", d.getName());
final String targetName = d.getName();
final Icon targetIcon = Icon.createWithResource(this, R.drawable.icon);
diff --git a/src/org/kde/kdeconnect/Plugins/SharePlugin/ShareNotification.java b/src/org/kde/kdeconnect/Plugins/SharePlugin/ShareNotification.java
--- a/src/org/kde/kdeconnect/Plugins/SharePlugin/ShareNotification.java
+++ b/src/org/kde/kdeconnect/Plugins/SharePlugin/ShareNotification.java
@@ -72,7 +72,7 @@
public void setProgress(int progress) {
builder.setProgress(100, progress, false)
- .setContentTitle(device.getContext().getResources().getString(R.string.incoming_file_title, device.getName())+" ("+progress+"%)");
+ .setContentTitle(device.getContext().getResources().getString(R.string.incoming_file_title, device.getName()) + " (" + progress + "%)");
}
public void setFinished(boolean success) {
diff --git a/src/org/kde/kdeconnect/Plugins/SharePlugin/SharePlugin.java b/src/org/kde/kdeconnect/Plugins/SharePlugin/SharePlugin.java
--- a/src/org/kde/kdeconnect/Plugins/SharePlugin/SharePlugin.java
+++ b/src/org/kde/kdeconnect/Plugins/SharePlugin/SharePlugin.java
@@ -118,7 +118,7 @@
if (np.hasPayload()) {
Log.i("SharePlugin", "hasPayload");
-
+
if (isPermissionGranted(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
receiveFile(np);
} else {
@@ -397,7 +397,7 @@
}
}
- public static void share(Intent intent, Device device){
+ public static void share(Intent intent, Device device) {
Bundle extras = intent.getExtras();
if (extras != null) {
if (extras.containsKey(Intent.EXTRA_STREAM)) {
diff --git a/src/org/kde/kdeconnect/Plugins/SharePlugin/ShareSettingsActivity.java b/src/org/kde/kdeconnect/Plugins/SharePlugin/ShareSettingsActivity.java
--- a/src/org/kde/kdeconnect/Plugins/SharePlugin/ShareSettingsActivity.java
+++ b/src/org/kde/kdeconnect/Plugins/SharePlugin/ShareSettingsActivity.java
@@ -95,7 +95,7 @@
}
try {
getDefaultDestinationDirectory().mkdirs();
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
return DocumentFile.fromFile(getDefaultDestinationDirectory());
@@ -112,7 +112,7 @@
Uri uri = resultData.getData();
getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION |
- Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
+ Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
Preference filePicker = findPreference("share_destination_folder_preference");
filePicker.setSummary(uri.getPath());
diff --git a/src/org/kde/kdeconnect/Plugins/TelepathyPlugin/TelepathyPlugin.java b/src/org/kde/kdeconnect/Plugins/TelepathyPlugin/TelepathyPlugin.java
--- a/src/org/kde/kdeconnect/Plugins/TelepathyPlugin/TelepathyPlugin.java
+++ b/src/org/kde/kdeconnect/Plugins/TelepathyPlugin/TelepathyPlugin.java
@@ -21,29 +21,23 @@
package org.kde.kdeconnect.Plugins.TelepathyPlugin;
import android.Manifest;
-import android.content.pm.PackageManager;
-import android.support.v4.app.ActivityCompat;
-import android.support.v4.content.ContextCompat;
import android.telephony.SmsManager;
import android.util.Log;
-import java.util.ArrayList;
-
import org.kde.kdeconnect.NetworkPackage;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.TelephonyPlugin.TelephonyPlugin;
import org.kde.kdeconnect_tp.R;
-public class TelepathyPlugin extends Plugin {
-
+import java.util.ArrayList;
- public final static String PACKAGE_TYPE_SMS_REQUEST = "kdeconnect.sms.request";
+public class TelepathyPlugin extends Plugin {
- private int telepathyPermissionExplanation = R.string.telepathy_permission_explanation;
+ private final static String PACKAGE_TYPE_SMS_REQUEST = "kdeconnect.sms.request";
@Override
public boolean onCreate() {
- permissionExplanation = telepathyPermissionExplanation;
+ permissionExplanation = R.string.telepathy_permission_explanation;
return true;
}
@@ -58,10 +52,6 @@
}
@Override
- public void onDestroy() {
- }
-
- @Override
public boolean onPackageReceived(NetworkPackage np) {
if (!np.getType().equals(PACKAGE_TYPE_SMS_REQUEST)) {
@@ -71,119 +61,23 @@
if (np.getBoolean("sendSms")) {
String phoneNo = np.getString("phoneNumber");
String sms = np.getString("messageBody");
- try {
- int permissionCheck = ContextCompat.checkSelfPermission(context,
- Manifest.permission.SEND_SMS);
- if(permissionCheck == PackageManager.PERMISSION_GRANTED) {
- SmsManager smsManager = SmsManager.getDefault();
+ try {
+ SmsManager smsManager = SmsManager.getDefault();
+ ArrayList parts = smsManager.divideMessage(sms);
- ArrayList parts = smsManager.divideMessage(sms);
+ // If this message turns out to fit in a single SMS, sendMultipartTextMessage
+ // properly handles that case
+ smsManager.sendMultipartTextMessage(phoneNo, null, parts, null, null);
- // If this message turns out to fit in a single SMS, sendMultpartTextMessage
- // properly handles that case
- smsManager.sendMultipartTextMessage(phoneNo, null, parts, null, null);
- } else if(permissionCheck == PackageManager.PERMISSION_DENIED){
- // TODO Request Permission SEND_SMS
- }
//TODO: Notify other end
} catch (Exception e) {
//TODO: Notify other end
Log.e("TelepathyPlugin", e.getMessage());
e.printStackTrace();
}
}
-/*
- if (np.getBoolean("requestContacts")) {
-
- ArrayList vCards = new ArrayList();
-
- Cursor cursor = context.getContentResolver().query(
- Contacts.CONTENT_URI,
- null,
- Contacts.HAS_PHONE_NUMBER + " > 0 ",
- null,
- null
- );
-
- if (cursor != null && cursor.moveToFirst()) {
- try {
- do {
- String lookupKey = cursor.getString(cursor.getColumnIndex(Contacts.LOOKUP_KEY));
- Uri uri = Uri.withAppendedPath(Contacts.CONTENT_VCARD_URI, lookupKey);
- AssetFileDescriptor fd = null;
- try {
- fd = context.getContentResolver()
- .openAssetFileDescriptor(uri, "r");
- FileInputStream fis = fd.createInputStream();
- byte[] b = new byte[(int) fd.getDeclaredLength()];
- fis.read(b);
- String vCard = new String(b);
- vCards.add(vCard);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- Log.e("RequestContacts", e.getMessage());
- } catch (Exception e) {
- e.printStackTrace();
- Log.e("RequestContacts", e.getMessage());
- } finally {
- if (fd != null) fd.close();
- }
- } while (cursor.moveToNext());
- Log.e("Contacts","Size: "+vCards.size());
- } catch (Exception e) {
- e.printStackTrace();
- Log.e("RequestContacts", e.getMessage());
- } finally {
- cursor.close();
- }
- }
-
- NetworkPackage answer = new NetworkPackage(NetworkPackage.PACKAGE_TYPE_TELEPHONY);
- answer.set("contacts",vCards);
- device.sendPackage(answer);
-
- }
-*/
-/*
- if (np.getBoolean("requestNumbers")) {
-
- ArrayList numbers = new ArrayList();
-
- Cursor cursor = context.getContentResolver().query(
- CommonDataKinds.Phone.CONTENT_URI,
- new String[]{
- CommonDataKinds.Phone.DISPLAY_NAME,
- CommonDataKinds.Phone.NUMBER
- },
- Contacts.HAS_PHONE_NUMBER + " > 0 ",
- null,
- null
- );
-
- if (cursor != null && cursor.moveToFirst()) {
- try {
- do {
- String number = cursor.getString(cursor.getColumnIndex(CommonDataKinds.Phone.NUMBER));
- String name = cursor.getString(cursor.getColumnIndex(CommonDataKinds.Phone.DISPLAY_NAME));
- numbers.add(number);
- } while (cursor.moveToNext());
- Log.e("Numbers","Size: "+numbers.size());
- } catch (Exception e) {
- e.printStackTrace();
- Log.e("RequestContacts", e.getMessage());
- } finally {
- cursor.close();
- }
- }
-
- NetworkPackage answer = new NetworkPackage(NetworkPackage.PACKAGE_TYPE_TELEPHONY);
- answer.set("numbers",numbers);
- device.sendPackage(answer);
- }
-*/
-
return true;
}
@@ -199,6 +93,6 @@
@Override
public String[] getRequiredPermissions() {
- return new String[]{Manifest.permission.SEND_SMS/*, Manifest.permission.READ_CONTACTS*/};
+ return new String[]{Manifest.permission.SEND_SMS};
}
}
diff --git a/src/org/kde/kdeconnect/Plugins/TelephonyPlugin/TelephonyPlugin.java b/src/org/kde/kdeconnect/Plugins/TelephonyPlugin/TelephonyPlugin.java
--- a/src/org/kde/kdeconnect/Plugins/TelephonyPlugin/TelephonyPlugin.java
+++ b/src/org/kde/kdeconnect/Plugins/TelephonyPlugin/TelephonyPlugin.java
@@ -303,7 +303,7 @@
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
String[] blockedNumbers = sharedPref.getString(KEY_PREF_BLOCKED_NUMBERS, "").split("\n");
- for (String s: blockedNumbers) {
+ for (String s : blockedNumbers) {
if (PhoneNumberUtils.compare(number, s))
return true;
}
diff --git a/src/org/kde/kdeconnect/UserInterface/AppCompatPreferenceActivity.java b/src/org/kde/kdeconnect/UserInterface/AppCompatPreferenceActivity.java
--- a/src/org/kde/kdeconnect/UserInterface/AppCompatPreferenceActivity.java
+++ b/src/org/kde/kdeconnect/UserInterface/AppCompatPreferenceActivity.java
@@ -33,7 +33,7 @@
/**
* A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls
* to be used with AppCompat.
- *
+ *
* This technique can be used with an {@link android.app.Activity} class, not just
* {@link android.preference.PreferenceActivity}.
*/
diff --git a/src/org/kde/kdeconnect/UserInterface/CustomDevicesActivity.java b/src/org/kde/kdeconnect/UserInterface/CustomDevicesActivity.java
--- a/src/org/kde/kdeconnect/UserInterface/CustomDevicesActivity.java
+++ b/src/org/kde/kdeconnect/UserInterface/CustomDevicesActivity.java
@@ -45,7 +45,7 @@
public class CustomDevicesActivity extends AppCompatActivity {
private static final String LOG_ID = "CustomDevicesActivity";
- public static final String KEY_CUSTOM_DEVLIST_PREFERENCE = "device_list_preference";
+ public static final String KEY_CUSTOM_DEVLIST_PREFERENCE = "device_list_preference";
private static final String IP_DELIM = ",";
private ListView list;
@@ -58,7 +58,7 @@
initializeDeviceList(this);
setContentView(R.layout.custom_ip_list);
- list = (ListView)findViewById(android.R.id.list);
+ list = (ListView) findViewById(android.R.id.list);
list.setOnItemClickListener(onClickListener);
list.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, ipAddressList));
@@ -70,7 +70,7 @@
}
});
- EditText ipEntryBox = (EditText)findViewById(R.id.ip_edittext);
+ EditText ipEntryBox = (EditText) findViewById(R.id.ip_edittext);
ipEntryBox.setOnEditorActionListener(new TextView.OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEND) {
@@ -126,7 +126,7 @@
};
private void addNewDevice() {
- EditText ipEntryBox = (EditText)findViewById(R.id.ip_edittext);
+ EditText ipEntryBox = (EditText) findViewById(R.id.ip_edittext);
String enteredText = ipEntryBox.getText().toString().trim();
if (!enteredText.isEmpty()) {
// don't add empty string (after trimming)
@@ -154,14 +154,14 @@
}
PreferenceManager.getDefaultSharedPreferences(CustomDevicesActivity.this).edit().putString(
KEY_CUSTOM_DEVLIST_PREFERENCE, serialized).commit();
- ((ArrayAdapter)list.getAdapter()).notifyDataSetChanged();
+ ((ArrayAdapter) list.getAdapter()).notifyDataSetChanged();
}
public static String serializeIpList(ArrayList ipList) {
String serialized = "";
for (String ipAddress : ipList) {
- serialized += IP_DELIM+ipAddress;
+ serialized += IP_DELIM + ipAddress;
}
// remove first delimiter
serialized = serialized.substring(IP_DELIM.length());
@@ -176,10 +176,10 @@
return ipList;
}
- private void initializeDeviceList(Context context){
+ private void initializeDeviceList(Context context) {
String deviceListPrefs = PreferenceManager.getDefaultSharedPreferences(context).getString(
KEY_CUSTOM_DEVLIST_PREFERENCE, "");
- if(deviceListPrefs.isEmpty()){
+ if (deviceListPrefs.isEmpty()) {
PreferenceManager.getDefaultSharedPreferences(context).edit().putString(
KEY_CUSTOM_DEVLIST_PREFERENCE,
deviceListPrefs).commit();
diff --git a/src/org/kde/kdeconnect/UserInterface/DeviceFragment.java b/src/org/kde/kdeconnect/UserInterface/DeviceFragment.java
--- a/src/org/kde/kdeconnect/UserInterface/DeviceFragment.java
+++ b/src/org/kde/kdeconnect/UserInterface/DeviceFragment.java
@@ -442,7 +442,7 @@
public void onServiceStart(BackgroundService service) {
Device dev = service.getDevice(devId);
if (dev == null) {
- Log.w("rejectPairing", "Device no longer exists: "+devId);
+ Log.w("rejectPairing", "Device no longer exists: " + devId);
return;
}
activity.getSupportActionBar().setTitle(dev.getName());
@@ -465,7 +465,7 @@
public void onServiceStart(BackgroundService service) {
Device dev = service.getDevice(devId);
if (dev == null) {
- Log.w("rejectPairing", "Device no longer exists: "+devId);
+ Log.w("rejectPairing", "Device no longer exists: " + devId);
return;
}
activity.getSupportActionBar().setTitle(dev.getName());
@@ -527,7 +527,7 @@
}
@Override
- public PluginClickListener clone(){
+ public PluginClickListener clone() {
try {
return (PluginClickListener) super.clone();
} catch (CloneNotSupportedException e) {
diff --git a/src/org/kde/kdeconnect/UserInterface/List/CustomItem.java b/src/org/kde/kdeconnect/UserInterface/List/CustomItem.java
--- a/src/org/kde/kdeconnect/UserInterface/List/CustomItem.java
+++ b/src/org/kde/kdeconnect/UserInterface/List/CustomItem.java
@@ -25,11 +25,11 @@
public class CustomItem implements ListAdapter.Item {
- private final View view;
+ private final View view;
- public CustomItem(View v) {
+ public CustomItem(View v) {
this.view = v;
- }
+ }
@Override
public View inflateView(LayoutInflater layoutInflater) {
diff --git a/src/org/kde/kdeconnect/UserInterface/List/EntryItem.java b/src/org/kde/kdeconnect/UserInterface/List/EntryItem.java
--- a/src/org/kde/kdeconnect/UserInterface/List/EntryItem.java
+++ b/src/org/kde/kdeconnect/UserInterface/List/EntryItem.java
@@ -28,24 +28,24 @@
public class EntryItem implements ListAdapter.Item {
- protected final String title;
- protected final String subtitle;
+ protected final String title;
+ protected final String subtitle;
public EntryItem(String title) {
this.title = title;
this.subtitle = null;
}
public EntryItem(String title, String subtitle) {
- this.title = title;
+ this.title = title;
this.subtitle = subtitle;
- }
+ }
@Override
public View inflateView(LayoutInflater layoutInflater) {
View v = layoutInflater.inflate(R.layout.list_item_entry, null);
- TextView titleView = (TextView)v.findViewById(R.id.list_item_entry_title);
+ TextView titleView = (TextView) v.findViewById(R.id.list_item_entry_title);
if (titleView != null) titleView.setText(title);
if (subtitle != null) {
diff --git a/src/org/kde/kdeconnect/UserInterface/List/ListAdapter.java b/src/org/kde/kdeconnect/UserInterface/List/ListAdapter.java
--- a/src/org/kde/kdeconnect/UserInterface/List/ListAdapter.java
+++ b/src/org/kde/kdeconnect/UserInterface/List/ListAdapter.java
@@ -34,19 +34,19 @@
View inflateView(LayoutInflater layoutInflater);
}
- private final ArrayList- items;
- private final LayoutInflater layoutInflater;
+ private final ArrayList
- items;
+ private final LayoutInflater layoutInflater;
- public ListAdapter(Context context, ArrayList
- items) {
- super(context, 0, items);
+ public ListAdapter(Context context, ArrayList
- items) {
+ super(context, 0, items);
this.items = items;
- layoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- }
+ layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ }
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- final Item i = items.get(position);
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ final Item i = items.get(position);
return i.inflateView(layoutInflater);
}
diff --git a/src/org/kde/kdeconnect/UserInterface/List/PairingDeviceItem.java b/src/org/kde/kdeconnect/UserInterface/List/PairingDeviceItem.java
--- a/src/org/kde/kdeconnect/UserInterface/List/PairingDeviceItem.java
+++ b/src/org/kde/kdeconnect/UserInterface/List/PairingDeviceItem.java
@@ -57,7 +57,7 @@
titleView.setText(device.getName());
if (device.compareProtocolVersion() != 0) {
- TextView summaryView = (TextView)v.findViewById(R.id.list_item_entry_summary);
+ TextView summaryView = (TextView) v.findViewById(R.id.list_item_entry_summary);
if (device.compareProtocolVersion() > 0) {
summaryView.setText(R.string.protocol_version_newer);
diff --git a/src/org/kde/kdeconnect/UserInterface/List/PluginItem.java b/src/org/kde/kdeconnect/UserInterface/List/PluginItem.java
--- a/src/org/kde/kdeconnect/UserInterface/List/PluginItem.java
+++ b/src/org/kde/kdeconnect/UserInterface/List/PluginItem.java
@@ -30,23 +30,23 @@
public class PluginItem implements ListAdapter.Item {
- private final Plugin plugin;
+ private final Plugin plugin;
private final View.OnClickListener clickListener;
- public PluginItem(Plugin p, View.OnClickListener clickListener) {
- this.plugin = p;
+ public PluginItem(Plugin p, View.OnClickListener clickListener) {
+ this.plugin = p;
this.clickListener = clickListener;
- }
+ }
@Override
public View inflateView(final LayoutInflater layoutInflater) {
View v = layoutInflater.inflate(R.layout.list_item_with_icon_entry, null);
- TextView titleView = (TextView)v.findViewById(R.id.list_item_entry_title);
+ TextView titleView = (TextView) v.findViewById(R.id.list_item_entry_title);
titleView.setText(plugin.getActionName());
- ImageView imageView = (ImageView)v.findViewById(R.id.list_item_entry_icon);
+ ImageView imageView = (ImageView) v.findViewById(R.id.list_item_entry_icon);
imageView.setImageDrawable(plugin.getIcon());
v.setOnClickListener(clickListener);
diff --git a/src/org/kde/kdeconnect/UserInterface/List/SectionItem.java b/src/org/kde/kdeconnect/UserInterface/List/SectionItem.java
--- a/src/org/kde/kdeconnect/UserInterface/List/SectionItem.java
+++ b/src/org/kde/kdeconnect/UserInterface/List/SectionItem.java
@@ -28,13 +28,13 @@
public class SectionItem implements ListAdapter.Item {
- private final String title;
+ private final String title;
public boolean isSectionEmpty;
- public SectionItem(String title) {
- this.title = title;
+ public SectionItem(String title) {
+ this.title = title;
this.isSectionEmpty = false;
- }
+ }
@Override
public View inflateView(LayoutInflater layoutInflater) {
diff --git a/src/org/kde/kdeconnect/UserInterface/List/SmallEntryItem.java b/src/org/kde/kdeconnect/UserInterface/List/SmallEntryItem.java
--- a/src/org/kde/kdeconnect/UserInterface/List/SmallEntryItem.java
+++ b/src/org/kde/kdeconnect/UserInterface/List/SmallEntryItem.java
@@ -29,13 +29,13 @@
public class SmallEntryItem implements ListAdapter.Item {
- private final String title;
+ private final String title;
private final View.OnClickListener clickListener;
- public SmallEntryItem(String title) {
- this.title = title;
+ public SmallEntryItem(String title) {
+ this.title = title;
this.clickListener = null;
- }
+ }
public SmallEntryItem(String title, View.OnClickListener clickListener) {
this.title = title;
@@ -46,7 +46,7 @@
public View inflateView(LayoutInflater layoutInflater) {
View v = layoutInflater.inflate(android.R.layout.simple_list_item_1, null);
- TextView titleView = (TextView)v.findViewById(android.R.id.text1);
+ TextView titleView = (TextView) v.findViewById(android.R.id.text1);
if (titleView != null) {
titleView.setText(title);
if (clickListener != null) {
diff --git a/src/org/kde/kdeconnect/UserInterface/MaterialActivity.java b/src/org/kde/kdeconnect/UserInterface/MaterialActivity.java
--- a/src/org/kde/kdeconnect/UserInterface/MaterialActivity.java
+++ b/src/org/kde/kdeconnect/UserInterface/MaterialActivity.java
@@ -116,7 +116,7 @@
} else if (getIntent().hasExtra("deviceId")) {
Log.i("MaterialActivity", "Loading selected device from parameter");
savedDevice = getIntent().getStringExtra("deviceId");
- if(getIntent().hasExtra(PAIR_REQUEST_STATUS)){
+ if (getIntent().hasExtra(PAIR_REQUEST_STATUS)) {
pairStatus = getIntent().getStringExtra(PAIR_REQUEST_STATUS);
}
} else if (savedInstanceState != null) {
@@ -128,15 +128,15 @@
}
//if pairStatus is not empty, then the decision has been made...
if (!pairStatus.equals("")) {
- Log.i("MaterialActivity", "pair status is "+pairStatus);
+ Log.i("MaterialActivity", "pair status is " + pairStatus);
onNewDeviceSelected(savedDevice, pairStatus);
}
onDeviceSelected(savedDevice);
}
//like onNewDeviceSelected but assumes that the new device is simply requesting to be paired
//and can't be null
- private void onNewDeviceSelected(String deviceId, String pairStatus){
+ private void onNewDeviceSelected(String deviceId, String pairStatus) {
mCurrentDevice = deviceId;
preferences.edit().putString(STATE_SELECTED_DEVICE, mCurrentDevice).apply();
diff --git a/src/org/kde/kdeconnect/UserInterface/PairingFragment.java b/src/org/kde/kdeconnect/UserInterface/PairingFragment.java
--- a/src/org/kde/kdeconnect/UserInterface/PairingFragment.java
+++ b/src/org/kde/kdeconnect/UserInterface/PairingFragment.java
@@ -73,7 +73,6 @@
mActivity.getSupportActionBar().setTitle(R.string.pairing_title);
-
setHasOptionsMenu(true);
rootView = inflater.inflate(R.layout.activity_refresh_list, container, false);
@@ -113,7 +112,10 @@
new Thread(new Runnable() {
@Override
public void run() {
- try { Thread.sleep(1500); } catch (InterruptedException ignored) { }
+ try {
+ Thread.sleep(1500);
+ } catch (InterruptedException ignored) {
+ }
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
diff --git a/tests/org/kde/kdeconnect/DeviceTest.java b/tests/org/kde/kdeconnect/DeviceTest.java
--- a/tests/org/kde/kdeconnect/DeviceTest.java
+++ b/tests/org/kde/kdeconnect/DeviceTest.java
@@ -68,7 +68,7 @@
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
keyGen.initialize(2048);
keyPair = keyGen.genKeyPair();
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
Log.e("KDE/initializeRsaKeys", "Exception");
return;
@@ -84,7 +84,7 @@
editor.apply();
SharedPreferences preferences = context.getSharedPreferences("trusted_devices", Context.MODE_PRIVATE);
- preferences.edit().putBoolean(deviceId,true).apply();
+ preferences.edit().putBoolean(deviceId, true).apply();
}
@@ -110,7 +110,7 @@
}
// Basic paired device testing
- public void testDevice(){
+ public void testDevice() {
Device device = new Device(getContext(), "testDevice");
@@ -123,7 +123,7 @@
// Testing pairing done using reflection since it is private
// Created an unpaired device inside this test
- public void testPairingDone(){
+ public void testPairingDone() {
NetworkPackage fakeNetworkPackage = new NetworkPackage(NetworkPackage.PACKAGE_TYPE_IDENTITY);
fakeNetworkPackage.set("deviceId", "unpairedTestDevice");
@@ -143,7 +143,7 @@
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
keyGen.initialize(2048);
keyPair = keyGen.genKeyPair();
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
Log.e("KDE/initializeRsaKeys", "Exception");
return;
@@ -162,16 +162,16 @@
method = Device.class.getDeclaredMethod("pairingDone");
method.setAccessible(true);
method.invoke(device);
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
}
assertEquals(device.isPaired(), true);
SharedPreferences preferences = getContext().getSharedPreferences("trusted_devices", Context.MODE_PRIVATE);
assertEquals(preferences.getBoolean(device.getDeviceId(), false), true);
- SharedPreferences settings = getContext().getSharedPreferences(device.getDeviceId(),Context.MODE_PRIVATE);
+ SharedPreferences settings = getContext().getSharedPreferences(device.getDeviceId(), Context.MODE_PRIVATE);
assertEquals(settings.getString("deviceName", "Unknown device"), "Unpaired Test Device");
assertEquals(settings.getString("deviceType", "tablet"), "phone");
@@ -181,13 +181,13 @@
}
- public void testPairingDoneWithCertificate() throws Exception{
+ public void testPairingDoneWithCertificate() throws Exception {
KeyPair keyPair = null;
try {
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
keyGen.initialize(2048);
keyPair = keyGen.genKeyPair();
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
Log.e("KDE/initializeRsaKeys", "Exception");
}
@@ -214,7 +214,7 @@
ContentSigner contentSigner = new JcaContentSignerBuilder("SHA256WithRSAEncryption").setProvider(BC).build(keyPair.getPrivate());
certificate = new JcaX509CertificateConverter().setProvider(BC).getCertificate(certificateBuilder.build(contentSigner));
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
Log.e("KDE/initialiseCert", "Exception");
}
@@ -246,25 +246,25 @@
method = Device.class.getDeclaredMethod("pairingDone");
method.setAccessible(true);
method.invoke(device);
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
}
assertEquals(device.isPaired(), true);
SharedPreferences preferences = getContext().getSharedPreferences("trusted_devices", Context.MODE_PRIVATE);
assertEquals(preferences.getBoolean(device.getDeviceId(), false), true);
- SharedPreferences settings = getContext().getSharedPreferences(device.getDeviceId(),Context.MODE_PRIVATE);
+ SharedPreferences settings = getContext().getSharedPreferences(device.getDeviceId(), Context.MODE_PRIVATE);
assertEquals(settings.getString("deviceName", "Unknown device"), "Unpaired Test Device");
assertEquals(settings.getString("deviceType", "tablet"), "phone");
// Cleanup for unpaired test device
preferences.edit().remove(device.getDeviceId()).apply();
settings.edit().clear().apply();
}
- public void testUnpair(){
+ public void testUnpair() {
Device device = new Device(getContext(), "testDevice");
diff --git a/tests/org/kde/kdeconnect/LanLinkProviderTest.java b/tests/org/kde/kdeconnect/LanLinkProviderTest.java
--- a/tests/org/kde/kdeconnect/LanLinkProviderTest.java
+++ b/tests/org/kde/kdeconnect/LanLinkProviderTest.java
@@ -50,7 +50,7 @@
}
- public void testIdentityPackageReceived() throws Exception{
+ public void testIdentityPackageReceived() throws Exception {
NetworkPackage networkPackage = Mockito.mock(NetworkPackage.class);
Mockito.when(networkPackage.getType()).thenReturn("kdeconnect.identity");
@@ -67,16 +67,16 @@
Method method = LanLinkProvider.class.getDeclaredMethod("identityPackageReceived", NetworkPackage.class, Socket.class, LanLink.ConnectionStarted.class);
method.setAccessible(true);
method.invoke(linkProvider, networkPackage, channel, LanLink.ConnectionStarted.Locally);
- }catch (Exception e){
+ } catch (Exception e) {
throw e;
}
HashMap visibleComputers;
try {
Field field = LanLinkProvider.class.getDeclaredField("visibleComputers");
field.setAccessible(true);
- visibleComputers = (HashMap)field.get(linkProvider);
- }catch (Exception e){
+ visibleComputers = (HashMap) field.get(linkProvider);
+ } catch (Exception e) {
throw e;
}
assertNotNull(visibleComputers.get("testDevice"));
diff --git a/tests/org/kde/kdeconnect/LanLinkTest.java b/tests/org/kde/kdeconnect/LanLinkTest.java
--- a/tests/org/kde/kdeconnect/LanLinkTest.java
+++ b/tests/org/kde/kdeconnect/LanLinkTest.java
@@ -110,23 +110,23 @@
}
- public void testSendPayload() throws Exception{
+ public void testSendPayload() throws Exception {
class Downloader extends Thread {
NetworkPackage np;
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- public void setNetworkPackage(NetworkPackage networkPackage){
+ public void setNetworkPackage(NetworkPackage networkPackage) {
this.np = networkPackage;
}
- public ByteArrayOutputStream getOutputStream(){
+ public ByteArrayOutputStream getOutputStream() {
return outputStream;
}
@Override
- public void run(){
+ public void run() {
try {
Socket socket = null;
@@ -137,7 +137,11 @@
socket.connect(new InetSocketAddress(address.getAddress(), tcpPort));
np.setPayload(socket.getInputStream(), np.getPayloadSize());
} catch (Exception e) {
- try { socket.close(); } catch(Exception ignored) { throw ignored; }
+ try {
+ socket.close();
+ } catch (Exception ignored) {
+ throw ignored;
+ }
e.printStackTrace();
Log.e("KDE/LanLinkTest", "Exception connecting to remote socket");
throw e;
@@ -164,7 +168,7 @@
outputStream.close();
input.close();
- } catch(Exception e) {
+ } catch (Exception e) {
Log.e("Downloader Test", "Exception");
e.printStackTrace();
}
@@ -175,15 +179,15 @@
final Downloader downloader = new Downloader();
// Using byte array for payload, try to use input stream as used in real device
- String dataString = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."+
- " Cras vel erat et ante fringilla tristique. Sed consequat ligula at interdum "+
- "rhoncus. Integer semper enim felis, id sodales tellus aliquet eget."+
- " Sed fringilla ac metus eget dictum. Aliquam euismod non sem sit"+
- " amet dapibus. Interdum et malesuada fames ac ante ipsum primis "+
- "in faucibus. Nam et ligula placerat, varius justo eu, convallis "+
- "lorem. Nam consequat consequat tortor et gravida. Praesent "+
- "ultricies tortor eget ex elementum gravida. Suspendisse aliquet "+
- "erat a orci feugiat dignissim.";
+ String dataString = "Lorem ipsum dolor sit amet, consectetur adipiscing elit." +
+ " Cras vel erat et ante fringilla tristique. Sed consequat ligula at interdum " +
+ "rhoncus. Integer semper enim felis, id sodales tellus aliquet eget." +
+ " Sed fringilla ac metus eget dictum. Aliquam euismod non sem sit" +
+ " amet dapibus. Interdum et malesuada fames ac ante ipsum primis " +
+ "in faucibus. Nam et ligula placerat, varius justo eu, convallis " +
+ "lorem. Nam consequat consequat tortor et gravida. Praesent " +
+ "ultricies tortor eget ex elementum gravida. Suspendisse aliquet " +
+ "erat a orci feugiat dignissim.";
// reallyLongString contains dataString 16 times
String reallyLongString = dataString + dataString;
@@ -217,7 +221,7 @@
Mockito.doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
- JSONObject object = (JSONObject)invocationOnMock.getArguments()[0];
+ JSONObject object = (JSONObject) invocationOnMock.getArguments()[0];
sharePackageJson.put("payloadTransferInfo", object);
return null;
@@ -228,8 +232,8 @@
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
- Log.e("LanLinkTest","Write to stream");
- String stringNetworkPackage = new String((byte[])invocationOnMock.getArguments()[0]);
+ Log.e("LanLinkTest", "Write to stream");
+ String stringNetworkPackage = new String((byte[]) invocationOnMock.getArguments()[0]);
final NetworkPackage np = NetworkPackage.unserialize(stringNetworkPackage);
downloader.setNetworkPackage(np);
@@ -243,8 +247,8 @@
try {
// Wait 1 secs for downloader to finish (if some error, it will continue and assert will fail)
- downloader.join(1*1000);
- }catch (Exception e){
+ downloader.join(1 * 1000);
+ } catch (Exception e) {
e.printStackTrace();
throw e;
}
diff --git a/tests/org/kde/kdeconnect/NetworkPackageTest.java b/tests/org/kde/kdeconnect/NetworkPackageTest.java
--- a/tests/org/kde/kdeconnect/NetworkPackageTest.java
+++ b/tests/org/kde/kdeconnect/NetworkPackageTest.java
@@ -32,7 +32,7 @@
import java.security.PrivateKey;
import java.security.PublicKey;
-public class NetworkPackageTest extends AndroidTestCase{
+public class NetworkPackageTest extends AndroidTestCase {
@Override
protected void setUp() throws Exception {
@@ -67,14 +67,14 @@
String json = "{\"id\":123,\"type\":\"test\",\"body\":{\"testing\":true}}";
np2 = NetworkPackage.unserialize(json);
- assertEquals(np2.getId(),123);
+ assertEquals(np2.getId(), 123);
assertEquals(np2.getBoolean("testing"), true);
assertEquals(np2.getBoolean("not_testing"), false);
assertEquals(np2.getBoolean("not_testing", true), true);
}
- public void testIdentity(){
+ public void testIdentity() {
NetworkPackage np = NetworkPackage.createIdentityPackage(getContext());
@@ -95,7 +95,7 @@
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
keyGen.initialize(2048);
keyPair = keyGen.genKeyPair();
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
Log.e("KDE/initializeRsaKeys", "Exception");
return;
@@ -110,13 +110,13 @@
// Encrypt and decrypt np
assertEquals(original.getType(), "com.test");
try {
- NetworkPackage encrypted = RsaHelper.encrypt(original,publicKey);
+ NetworkPackage encrypted = RsaHelper.encrypt(original, publicKey);
assertEquals(encrypted.getType(), NetworkPackage.PACKAGE_TYPE_ENCRYPTED);
decrypted = RsaHelper.decrypt(encrypted, privateKey);
assertEquals(decrypted.getType(), "com.test");
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
}
@@ -132,7 +132,7 @@
decrypted = RsaHelper.decrypt(encrypted, privateKey);
String decryptedJson = decrypted.serialize();
JSONAssert.assertEquals(json, decryptedJson, true);
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
}
}