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

Apply coding style to whole project

Summary: Sorry for the huge diff, but all I did was applying Android Studio's 'Reformat Code' to all files. If everyone does that before submitting a patch we can keep it clean easily.

Test Plan: Compiles

Reviewers: #kde_connect, mtijink

Reviewed By: #kde_connect, mtijink

Subscribers: mtijink, sredman, #kde_connect

Tags: #kde_connect

Differential Revision: https://phabricator.kde.org/D10905
This commit is contained in:
Nicolas Fella
2018-03-03 16:06:52 +01:00
parent 0a08cd43cb
commit fa5a37c472
89 changed files with 1505 additions and 1345 deletions

View File

@@ -1,26 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:paddingLeft="25dp"
android:paddingTop="25dp"
android:paddingRight="25dp"
android:paddingBottom="25dp"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingBottom="25dp"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:paddingTop="25dp">
<ImageView
android:id="@+id/album_art"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginRight="25dp"
android:layout_weight="1"
android:scaleType="fitCenter" />
<include
layout="@layout/mpris_control"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
layout="@layout/mpris_control" />
android:layout_weight="1" />
</LinearLayout>

View File

@@ -2,105 +2,99 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/activity_vertical_margin"
tools:context="org.kde.kdeconnect.UserInterface.DeviceFragment"
android:orientation="vertical">
tools:context="org.kde.kdeconnect.UserInterface.DeviceFragment">
<LinearLayout
android:id="@+id/pairing_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/pairing_buttons"
android:layout_gravity="center">
android:layout_gravity="center"
android:orientation="vertical">
<ProgressBar
android:visibility="gone"
android:id="@+id/pair_progress"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/pair_progress" />
android:visibility="gone" />
<TextView
android:id="@+id/pair_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/device_not_paired"
android:id="@+id/pair_message"
/>
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/pair_button"
android:background="@drawable/button_round"
android:textColor="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/button_round"
android:text="@string/request_pairing"
/>
android:textColor="@android:color/white" />
<LinearLayout
android:id="@+id/pair_request"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:id="@+id/pair_request"
android:layout_gravity="center">
android:layout_gravity="center"
android:visibility="gone">
<Button
android:background="@drawable/button_round"
android:textColor="@android:color/white"
android:layout_margin="4dip"
android:id="@+id/accept_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/pairing_accept"
android:layout_margin="4dip"
android:layout_weight="1"
/>
android:background="@drawable/button_round"
android:text="@string/pairing_accept"
android:textColor="@android:color/white" />
<Button
android:background="@drawable/button_round"
android:textColor="@android:color/white"
android:layout_margin="4dip"
android:id="@+id/reject_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="4dip"
android:layout_weight="1"
android:background="@drawable/button_round"
android:text="@string/pairing_reject"
android:layout_weight="1" />
android:textColor="@android:color/white" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/not_reachable_message"
android:visibility="gone"
android:layout_width="match_parent"
android:drawableStart="@drawable/ic_error_outline_black_48dp"
android:layout_height="match_parent"
android:drawableLeft="@drawable/ic_error_outline_black_48dp"
android:drawablePadding="8dip"
android:layout_height="match_parent"
android:drawableStart="@drawable/ic_error_outline_black_48dp"
android:gravity="center_vertical"
android:text="@string/unreachable_description"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
android:visibility="gone" />
<TextView
android:id="@+id/on_data_message"
android:visibility="gone"
android:layout_width="match_parent"
android:drawableStart="@drawable/ic_error_outline_black_48dp"
android:layout_height="match_parent"
android:drawableLeft="@drawable/ic_error_outline_black_48dp"
android:drawablePadding="8dip"
android:layout_height="match_parent"
android:drawableStart="@drawable/ic_error_outline_black_48dp"
android:gravity="center_vertical"
android:text="@string/on_data_message"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
android:visibility="gone" />
<ListView
android:id="@+id/buttons_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
tools:context=".DeviceActivity"
/>
tools:context=".DeviceActivity" />
</LinearLayout>

View File

@@ -2,25 +2,22 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="org.kde.kdeconnect.Plugins.FindMyPhonePlugin.FindMyPhoneActivity">
<Button
android:id="@+id/bFindMyPhone"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/findmyphone_found"
android:textSize="50dp"
android:id="@+id/bFindMyPhone"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
android:layout_alignParentStart="true"
android:text="@string/findmyphone_found"
android:textSize="50dp" />
</RelativeLayout>

View File

@@ -1,11 +1,10 @@
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:addStatesFromChildren="true"
android:orientation="vertical"
android:paddingLeft="16dip"
android:paddingRight="16dip"
tools:context="org.kde.kdeconnect.UserInterface.MaterialActivity"
android:id="@+id/listView1"
android:addStatesFromChildren="true"
android:orientation="vertical">
</ListView>
tools:context="org.kde.kdeconnect.UserInterface.MaterialActivity"></ListView>

View File

@@ -1,7 +1,6 @@
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -9,37 +8,35 @@
tools:context="org.kde.kdeconnect.UserInterface.MaterialActivity"> <!-- fitSystemWindows to make the drawer slide below the Lollipop transparent status bar -->
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:background="?attr/colorPrimary"
android:elevation="8dp"
android:background="?attr/colorPrimary" />
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
android:layout_height="match_parent"></FrameLayout>
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigation_drawer"
android:background="@drawable/state_list_drawer_background"
app:itemBackground="@drawable/state_list_drawer_background"
app:itemTextColor="@color/state_list_drawer_text"
app:itemIconTint="@color/state_list_drawer_text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@drawable/state_list_drawer_background"
app:headerLayout="@layout/nav_header"
/>
app:itemBackground="@drawable/state_list_drawer_background"
app:itemIconTint="@color/state_list_drawer_text"
app:itemTextColor="@color/state_list_drawer_text" />
</android.support.v4.widget.DrawerLayout>

View File

@@ -1,25 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:keepScreenOn="true"
android:orientation="vertical"
android:id="@+id/mousepad_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/mousepad_view">
android:keepScreenOn="true"
android:orientation="vertical">
<TextView
style="@android:style/TextAppearance.Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/mousepad_info"
android:gravity="center"
style="@android:style/TextAppearance.Medium"
android:layout_centerInParent="true"
android:padding="12dip" />
android:gravity="center"
android:padding="12dip"
android:text="@string/mousepad_info" />
<view
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/keyListener"
class="org.kde.kdeconnect.Plugins.MousePadPlugin.KeyListenerView"
android:id="@+id/keyListener" />
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>

View File

@@ -1,25 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:paddingLeft="25dp"
android:paddingTop="25dp"
android:paddingRight="25dp"
android:paddingBottom="25dp"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="25dp"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:paddingTop="25dp">
<ImageView
android:id="@+id/album_art"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:layout_marginBottom="25dp"
android:layout_weight="4"
android:scaleType="fitCenter" />
<include
layout="@layout/mpris_control"
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="@layout/mpris_control" />
android:layout_height="wrap_content" />
</LinearLayout>

View File

@@ -6,27 +6,26 @@
tools:context="org.kde.kdeconnect.Plugins.NotificationsPlugin.NotificationFilterActivity">
<TextView
android:text="@string/filter_apps_info"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:id="@+id/tFilter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:id="@+id/tFilter"/>
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:text="@string/filter_apps_info" />
<ProgressBar
android:layout_marginTop="64dip"
android:id="@+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/spinner" />
android:layout_marginTop="64dip" />
<ListView
android:id="@+id/lvFilterApps"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/lvFilterApps"
android:visibility="gone"
/>
android:visibility="gone" />
</LinearLayout>

View File

@@ -1,17 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/refresh_list_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/refresh_list_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView android:layout_width="match_parent"
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:addStatesFromChildren="true"
android:orientation="vertical"
android:paddingLeft="16dip"
android:paddingRight="16dip"
tools:context=".MainActivity"
android:id="@+id/listView1"
android:addStatesFromChildren="true"
android:orientation="vertical"/>
tools:context=".MainActivity" />
</android.support.v4.widget.SwipeRefreshLayout>

View File

@@ -1,36 +1,35 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:orientation="vertical">
android:paddingTop="@dimen/activity_vertical_margin">
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:id="@android:id/list"
android:layout_weight="1"
/>
android:layout_weight="1" />
<TextView
android:layout_width="fill_parent"
android:layout_height="100dp"
android:text="@string/custom_dev_list_help"/>
android:layout_width="fill_parent"
android:layout_height="100dp"
android:text="@string/custom_dev_list_help" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:imeOptions="actionSend"
android:hint="@string/add_host_hint"
android:id="@+id/ip_edittext"/>
android:id="@+id/ip_edittext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/add_host_hint"
android:imeOptions="actionSend" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/add_host"
android:id="@android:id/button1"/>
android:id="@android:id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/add_host" />
</LinearLayout>

View File

@@ -1,34 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:drawableBottom="@drawable/text_section_header"
android:textStyle="bold"
android:id="@+id/list_item_category_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:textColor="?android:textColorSecondary"
android:drawableBottom="@drawable/text_section_header"
android:drawablePadding="4dp"
android:textSize="14sp"
android:textAllCaps="true"
android:paddingLeft="8dip"
android:paddingRight="8dip"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/list_item_category_text"
/>
android:textAllCaps="true"
android:textColor="?android:textColorSecondary"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="@+id/list_item_category_empty_placeholder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dip"
android:visibility="gone"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/device_list_empty"
android:id="@+id/list_item_category_empty_placeholder"
android:layout_gravity="center" />
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="gone" />
</LinearLayout>

View File

@@ -1,37 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:baselineAligned="false"
android:layout_height="wrap_content"
android:paddingLeft="12dip"
android:paddingStart="12dip"
android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:paddingRight="?android:attr/scrollbarSize"
android:paddingEnd="?android:attr/scrollbarSize"
android:background="@drawable/abc_list_selector_holo_dark"
android:orientation="vertical">
android:baselineAligned="false"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeight"
android:orientation="vertical"
android:paddingEnd="?android:attr/scrollbarSize"
android:paddingLeft="12dip"
android:paddingRight="?android:attr/scrollbarSize"
android:paddingStart="12dip">
<!-- We should use android:background="@android:/listChoiceBackgroundIndicator"
instead of abc_list_selector_holo_dark but that's only supported from API11 -->
<TextView android:id="@+id/list_item_entry_title"
<TextView
android:id="@+id/list_item_entry_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:text="" />
android:singleLine="true"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView android:id="@+id/list_item_entry_summary"
<TextView
android:id="@+id/list_item_entry_summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:singleLine="true"
android:visibility="gone"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/darker_gray"
android:text="" />
android:visibility="gone" />
</LinearLayout>

View File

@@ -1,72 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:baselineAligned="false"
android:layout_height="wrap_content"
android:paddingLeft="12dip"
android:paddingStart="12dip"
android:minHeight="?android:attr/listPreferredItemHeight"
android:baselineAligned="false"
android:gravity="center_vertical"
android:paddingRight="?android:attr/scrollbarSize"
android:minHeight="?android:attr/listPreferredItemHeight"
android:orientation="horizontal"
android:paddingEnd="?android:attr/scrollbarSize"
android:orientation="horizontal">
android:paddingLeft="12dip"
android:paddingRight="?android:attr/scrollbarSize"
android:paddingStart="12dip">
<ImageView android:id="@+id/list_item_entry_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_device_laptop"
android:layout_weight="0" />
<ImageView
android:id="@+id/list_item_entry_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="0"
android:src="@drawable/ic_device_laptop" />
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="wrap_content">
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView android:id="@+id/list_item_entry_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="8dip"
android:layout_marginStart="8dip"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:text=""/>
<TextView
android:id="@+id/list_item_entry_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="8dip"
android:layout_marginStart="8dip"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:text=""
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView android:id="@+id/list_item_entry_summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:singleLine="true"
android:textColor="#CC2222"
android:visibility="gone"
android:text="" />
<TextView
android:id="@+id/list_item_entry_summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#CC2222"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar"
android:layout_weight="0"
android:indeterminate="true" />
<Button
android:layout_width="wrap_content"
android:minWidth="128dip"
android:layout_height="wrap_content"
android:text="@string/request_pairing"
android:padding="8dip"
android:background="@drawable/button_round"
android:textColor="#FFFFFF"
android:id="@+id/entry_pair_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:nestedScrollingEnabled="false" />
android:background="@drawable/button_round"
android:minWidth="128dip"
android:nestedScrollingEnabled="false"
android:padding="8dip"
android:text="@string/request_pairing"
android:textColor="#FFFFFF" />
</LinearLayout>

View File

@@ -1,52 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:baselineAligned="false"
android:layout_height="wrap_content"
android:paddingLeft="12dip"
android:paddingStart="12dip"
android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:paddingRight="?android:attr/scrollbarSize"
android:paddingEnd="?android:attr/scrollbarSize"
android:clickable="true"
android:background="@drawable/abc_list_selector_holo_dark"
android:orientation="horizontal">
android:baselineAligned="false"
android:clickable="true"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeight"
android:orientation="horizontal"
android:paddingEnd="?android:attr/scrollbarSize"
android:paddingLeft="12dip"
android:paddingRight="?android:attr/scrollbarSize"
android:paddingStart="12dip">
<ImageView android:id="@+id/list_item_entry_icon"
<ImageView
android:id="@+id/list_item_entry_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_device_laptop"
/>
android:src="@drawable/ic_device_laptop" />
<LinearLayout
android:layout_width="wrap_content"
android:orientation="vertical"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:id="@+id/list_item_entry_title"
<TextView
android:id="@+id/list_item_entry_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="8dip"
android:layout_marginStart="8dip"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:text="" />
android:singleLine="true"
android:text=""
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView android:id="@+id/list_item_entry_summary"
<TextView
android:id="@+id/list_item_entry_summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dip"
android:layout_marginStart="8dip"
android:textAppearance="?android:attr/textAppearanceSmall"
android:singleLine="true"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#CC2222"
android:visibility="gone"
android:text="" />
android:visibility="gone" />
</LinearLayout>

View File

@@ -2,164 +2,155 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:id="@+id/mpris_control_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/mpris_control_view"
android:layout_gravity="center"
android:gravity="center"
android:layout_gravity="center">
android:orientation="vertical">
<TextView
android:id="@+id/no_players"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_gravity="center_horizontal"
android:text="@string/no_players_connected"
android:id="@+id/no_players"
android:layout_gravity="center_horizontal" />
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="@+id/player_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/player_spinner"
android:layout_gravity="center"
/>
android:layout_gravity="center" />
<TextView
android:id="@+id/now_playing_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/now_playing_textview"
android:layout_gravity="center"
android:ellipsize="marquee"
android:gravity="center"
android:marqueeRepeatLimit="marquee_forever"
android:padding="8dip"
android:scrollHorizontally="true"
android:singleLine="true"
android:gravity="center"
android:padding="8dip"
android:layout_gravity="center"
/>
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageButton
android:id="@+id/play_button"
android:layout_width="fill_parent"
android:layout_height="75dp"
android:id="@+id/play_button"
android:src="@drawable/ic_play_black"
android:contentDescription="@string/mpris_play"
android:layout_gravity="center"
android:layout_weight="0"
android:clickable="false"
android:adjustViewBounds="false"
android:baselineAlignBottom="true" />
android:baselineAlignBottom="true"
android:clickable="false"
android:contentDescription="@string/mpris_play"
android:src="@drawable/ic_play_black" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="60dip"
android:layout_gravity="center"
>
android:orientation="horizontal">
<ImageButton
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:id="@+id/prev_button"
android:src="@drawable/ic_previous_black"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="0.25"
android:contentDescription="@string/mpris_previous"
android:layout_weight="0.25"
/>
android:src="@drawable/ic_previous_black" />
<ImageButton
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:id="@+id/rew_button"
android:src="@drawable/ic_rewind_black"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="0.25"
android:contentDescription="@string/mpris_rew"
android:layout_weight="0.25"
/>
android:src="@drawable/ic_rewind_black" />
<ImageButton
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:id="@+id/ff_button"
android:src="@drawable/ic_fast_forward_black"
android:contentDescription="@string/mpris_ff"
android:layout_weight="0.25"
/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:id="@+id/next_button"
android:src="@drawable/ic_next_black"
android:contentDescription="@string/mpris_next"
android:layout_weight="0.25"
/>
android:contentDescription="@string/mpris_ff"
android:src="@drawable/ic_fast_forward_black" />
<ImageButton
android:id="@+id/next_button"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="0.25"
android:contentDescription="@string/mpris_next"
android:src="@drawable/ic_next_black" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:id="@+id/progress_slider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/progress_slider">
android:orientation="horizontal">
<TextView
android:id="@+id/progress_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/progress_textview"
android:singleLine="true"
android:layout_gravity="center"
android:gravity="center"
android:padding="8dip"
android:layout_gravity="center"
android:text="00:00" />
android:singleLine="true"
android:text="00:00"
android:textAppearance="?android:attr/textAppearanceMedium" />
<SeekBar
android:id="@+id/positionSeek"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/positionSeek"
android:layout_weight="1"
android:layout_gravity="center" />
android:layout_gravity="center"
android:layout_weight="1" />
<TextView
android:id="@+id/time_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/time_textview"
android:singleLine="true"
android:layout_gravity="center"
android:gravity="center"
android:padding="8dip"
android:layout_gravity="center"
android:text="00:00" />
android:singleLine="true"
android:text="00:00"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/volume_layout"
android:layout_gravity="center"
android:layout_marginTop="8dip">
android:id="@+id/volume_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="8dip"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView"
android:layout_width="30dip"
android:layout_height="30dip"
android:maxWidth="30dip"
android:layout_marginRight="10dip"
android:layout_marginEnd="10dip"
android:id="@+id/imageView"
android:layout_marginRight="10dip"
android:layout_weight="0"
android:contentDescription="@string/mpris_volume"
android:src="@drawable/ic_volume_black"
/>
android:maxWidth="30dip"
android:src="@drawable/ic_volume_black" />
<SeekBar
android:id="@+id/volume_seek"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/volume_seek"
android:layout_weight="1"
android:max="100"
android:layout_gravity="center"
/>
android:layout_weight="1"
android:max="100" />
</LinearLayout>

View File

@@ -3,36 +3,35 @@
android:layout_width="match_parent"
android:layout_height="160dp"
android:background="@drawable/drawer_header"
android:orientation="vertical"
android:gravity="bottom">
android:gravity="bottom"
android:orientation="vertical">
<TextView
android:id="@+id/kdeconnect_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="KDE Connect"
android:textColor="#FFF"
android:textStyle="bold"
android:id="@+id/kdeconnect_label"
android:paddingEnd="48dp"
android:paddingLeft="16dp"
android:paddingRight="48dp"
android:paddingStart="16dp"
android:paddingTop="8dp"
android:paddingRight="48dp"
android:paddingEnd="48dp"
/>
android:text="KDE Connect"
android:textColor="#FFF"
android:textStyle="bold" />
<TextView
android:id="@+id/device_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="My device"
android:id="@+id/device_name"
android:layout_marginBottom="0dp"
android:textColor="#fff"
android:paddingBottom="16dp"
android:paddingTop="4dp"
android:paddingRight="48dp"
android:paddingEnd="48dp"
android:paddingLeft="16dp"
android:paddingRight="48dp"
android:paddingStart="16dp"
android:paddingLeft="16dp" />
android:paddingTop="4dp"
android:text="My device"
android:textColor="#fff" />
<!--
<ImageView

View File

@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2006 The Android Open Source Project
<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2006 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -20,16 +19,17 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingEnd="?android:attr/scrollbarSize"
android:paddingRight="?android:attr/scrollbarSize"
android:paddingStart="12dip"
android:paddingLeft="12dip"
android:background="?attr/selectableItemBackground">
android:paddingRight="?android:attr/scrollbarSize"
android:paddingStart="12dip">
<!-- Preference will place its actual preference widget here. -->
<LinearLayout android:id="@android:id/widget_frame"
<LinearLayout
android:id="@android:id/widget_frame"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
@@ -38,40 +38,42 @@
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dip"
android:layout_marginLeft="12dip"
android:layout_marginEnd="4dip"
android:layout_marginRight="4dip"
android:layout_marginTop="6dip"
android:layout_marginBottom="6dip"
android:layout_marginEnd="4dip"
android:layout_marginLeft="12dip"
android:layout_marginRight="4dip"
android:layout_marginStart="12dip"
android:layout_marginTop="6dip"
android:layout_weight="1">
<TextView android:id="@+android:id/title"
<TextView
android:id="@+android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:ellipsize="marquee"
android:fadingEdge="horizontal" />
android:fadingEdge="horizontal"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView android:id="@android:id/summary"
<TextView
android:id="@android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@android:id/title"
android:layout_alignStart="@android:id/title"
android:layout_alignLeft="@android:id/title"
android:layout_alignStart="@android:id/title"
android:layout_below="@android:id/title"
android:maxLines="3"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"
android:maxLines="3" />
android:textColor="?android:attr/textColorSecondary" />
</RelativeLayout>
<ImageButton
android:id="@+id/settingsButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/settingsButton"
android:padding="8dip"
android:background="@drawable/abc_btn_borderless_material"
android:src="@drawable/ic_action_settings_inverted"/>
android:padding="8dip"
android:src="@drawable/ic_action_settings_inverted" />
</LinearLayout>

View File

@@ -2,16 +2,19 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:kdeconnect="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/menu_show_keyboard"
android:title="@string/show_keyboard"
<item
android:id="@+id/menu_show_keyboard"
android:icon="@drawable/ic_action_keyboard"
android:title="@string/show_keyboard"
kdeconnect:showAsAction="ifRoom" />
<item android:id="@+id/menu_right_click"
<item
android:id="@+id/menu_right_click"
android:title="@string/right_click"
kdeconnect:showAsAction="never" />
<item android:id="@+id/menu_middle_click"
<item
android:id="@+id/menu_middle_click"
android:title="@string/middle_click"
kdeconnect:showAsAction="never" />

View File

@@ -5,22 +5,19 @@
android:id="@+id/menu_refresh"
android:icon="@drawable/ic_action_refresh"
android:orderInCategory="200"
kdeconnect:showAsAction="never"
android:title="@string/refresh"
/>
kdeconnect:showAsAction="never" />
<item
android:id="@+id/menu_rename"
android:orderInCategory="300"
android:title="@string/device_rename_title"
kdeconnect:showAsAction="never"
/>
kdeconnect:showAsAction="never" />
<item
<item
android:id="@+id/menu_custom_device_list"
android:orderInCategory="900"
android:title="@string/custom_device_list"
kdeconnect:showAsAction="never"
/>
kdeconnect:showAsAction="never" />
</menu>

View File

@@ -2,11 +2,10 @@
xmlns:kdeconnect="http://schemas.android.com/apk/res-auto/android">
<item
android:id="@+id/menu_refresh"
android:icon="@drawable/ic_action_refresh"
android:orderInCategory="200"
kdeconnect:showAsAction="never"
android:title="@string/refresh"
/>
android:id="@+id/menu_refresh"
android:icon="@drawable/ic_action_refresh"
android:orderInCategory="200"
android:title="@string/refresh"
kdeconnect:showAsAction="never" />
</menu>

View File

@@ -18,10 +18,8 @@
<item name="windowNoTitle">true</item>
</style>
<style name="KdeConnectTheme" parent="KdeConnectThemeBase">
</style>
<style name="KdeConnectTheme" parent="KdeConnectThemeBase"></style>
<style name="KdeConnectTheme.NoActionBar" parent="KdeConnectThemeBase.NoActionBar">
</style>
<style name="KdeConnectTheme.NoActionBar" parent="KdeConnectThemeBase.NoActionBar"></style>
</resources>

View File

@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="." />
<external-path
name="external_files"
path="." />
</paths>

View File

@@ -10,7 +10,7 @@
android:entryValues="@array/mousepad_tap_values"
android:key="@string/mousepad_double_tap_key"
android:summary="%s"
android:title="@string/mousepad_double_tap_settings_title"/>
android:title="@string/mousepad_double_tap_settings_title" />
<ListPreference
android:id="@+id/mousepad_triple_tap_preference"
@@ -19,7 +19,7 @@
android:entryValues="@array/mousepad_tap_values"
android:key="@string/mousepad_triple_tap_key"
android:summary="%s"
android:title="@string/mousepad_triple_tap_settings_title"/>
android:title="@string/mousepad_triple_tap_settings_title" />
<ListPreference
android:id="@+id/mousepad_sensitivity_preference"
@@ -28,11 +28,11 @@
android:entryValues="@array/mousepad_sensitivity_values"
android:key="@string/mousepad_sensitivity_key"
android:summary="%s"
android:title="@string/mousepad_sensitivity_settings_title"/>
android:title="@string/mousepad_sensitivity_settings_title" />
<CheckBoxPreference
android:id="@+id/mousepad_scroll_preference"
android:defaultValue="false"
android:key="@string/mousepad_scroll_direction"
android:title="@string/mousepad_scroll_direction_title"
android:defaultValue="false" />
android:title="@string/mousepad_scroll_direction_title" />
</PreferenceScreen>

View File

@@ -5,18 +5,18 @@
<ListPreference
android:id="@+id/mpris_time_preference"
android:key="@string/mpris_time_key"
android:title="@string/mpris_time_settings_title"
android:summary="@string/mpris_time_settings_summary"
android:defaultValue="@string/mpris_time_default"
android:entries="@array/mpris_time_entries"
android:entryValues="@array/mpris_time_entries_values"
android:defaultValue="@string/mpris_time_default" />
android:key="@string/mpris_time_key"
android:summary="@string/mpris_time_settings_summary"
android:title="@string/mpris_time_settings_title" />
<CheckBoxPreference
android:id="@+id/mpris_notification_preference"
android:defaultValue="true"
android:key="@string/mpris_notification_key"
android:title="@string/mpris_notification_settings_title"
android:summary="@string/mpris_notification_settings_summary"
android:defaultValue="true" />
android:title="@string/mpris_notification_settings_title" />
</PreferenceScreen>

View File

@@ -1,14 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Keyboard
xmlns:android="http://schemas.android.com/apk/res/android"
android:keyHeight="@dimen/key_height"
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:horizontalGap="0px"
android:verticalGap="0px" >
android:keyHeight="@dimen/key_height"
android:verticalGap="0px">
<Row android:rowEdgeFlags="bottom">
<Key android:keyIcon="@drawable/ic_keyboard_hide_white_36dp" android:codes="0" android:keyWidth="20%" />
<Key android:keyIcon="@drawable/ic_action_settings" android:codes="1" android:keyWidth="40%"/>
<Key android:keyIcon="@drawable/ic_action_keyboard" android:codes="2" android:keyWidth="40%"/>
<Key android:keyIcon="@drawable/ic_phonelink_white_36dp" android:codes="3" android:keyWidth="20%" />-->
</Row>
<Key
android:codes="0"
android:keyIcon="@drawable/ic_keyboard_hide_white_36dp"
android:keyWidth="20%" />
<Key
android:codes="1"
android:keyIcon="@drawable/ic_action_settings"
android:keyWidth="40%" />
<Key
android:codes="2"
android:keyIcon="@drawable/ic_action_keyboard"
android:keyWidth="40%" />
<Key
android:codes="3"
android:keyIcon="@drawable/ic_phonelink_white_36dp"
android:keyWidth="20%" />-->
</Row>
</Keyboard>

View File

@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<input-method xmlns:android="http://schemas.android.com/apk/res/android"
android:supportsSwitchingToNextInputMethod="true">
</input-method>
android:supportsSwitchingToNextInputMethod="true"></input-method>

View File

@@ -5,7 +5,7 @@
<CheckBoxPreference
android:id="@+id/remotekeyboard_editing_only"
android:defaultValue="true"
android:key="@string/remotekeyboard_editing_only"
android:title="@string/remotekeyboard_editing_only_title"
android:defaultValue="true" />
android:title="@string/remotekeyboard_editing_only_title" />
</PreferenceScreen>

View File

@@ -5,11 +5,11 @@
<CheckBoxPreference
android:id="@+id/share_destination_customize"
android:defaultValue="false"
android:key="share_destination_custom"
android:title="@string/share_destination_customize"
android:summaryOff="@string/share_destination_customize_summary_disabled"
android:summaryOn="@string/share_destination_customize_summary_enabled"
android:defaultValue="false" />
android:title="@string/share_destination_customize" />
<Preference
android:id="@+id/share_destination_folder_preference"
@@ -18,9 +18,9 @@
<CheckBoxPreference
android:id="@+id/share_notification_preference"
android:defaultValue="true"
android:key="share_notification_preference"
android:title="@string/share_notification_preference"
android:summary="@string/share_notification_preference_summary"
android:defaultValue="true" />
android:title="@string/share_notification_preference" />
</PreferenceScreen>

View File

@@ -2,9 +2,8 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<EditTextPreference
android:dialogMessage="@string/telephony_pref_blocked_dialog_desc"
android:key="telephony_blocked_numbers"
android:title="@string/telephony_pref_blocked_title"
android:dialogMessage="@string/telephony_pref_blocked_dialog_desc">
</EditTextPreference>
android:title="@string/telephony_pref_blocked_title"></EditTextPreference>
</PreferenceScreen>

View File

@@ -36,7 +36,11 @@ import org.kde.kdeconnect.Device;
import org.kde.kdeconnect.Helpers.SecurityHelpers.RsaHelper;
import org.kde.kdeconnect.NetworkPackage;
import java.io.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.nio.charset.Charset;
import java.security.PublicKey;
import java.util.UUID;
@@ -88,7 +92,7 @@ public class BluetoothLink extends BaseLink {
if (np.getType().equals(NetworkPackage.PACKAGE_TYPE_ENCRYPTED)) {
try {
np = RsaHelper.decrypt(np, privateKey);
} catch(Exception e) {
} catch (Exception e) {
Log.e("BluetoothLink/receiving", "Exception decrypting the package", e);
}
}
@@ -102,7 +106,10 @@ public class BluetoothLink extends BaseLink {
np.setPayload(transferSocket.getInputStream(), np.getPayloadSize());
} catch (Exception e) {
if (transferSocket != null) {
try { transferSocket.close(); } catch(IOException ignored) { }
try {
transferSocket.close();
} catch (IOException ignored) {
}
}
Log.e("BluetoothLink/receiving", "Unable to get payload", e);
}
@@ -147,9 +154,9 @@ public class BluetoothLink extends BaseLink {
private void sendMessage(NetworkPackage np) throws JSONException, IOException {
byte[] message = np.serialize().getBytes(Charset.forName("UTF-8"));
OutputStream socket = this.socket.getOutputStream();
Log.i("BluetoothLink","Beginning to send message");
Log.i("BluetoothLink", "Beginning to send message");
socket.write(message);
Log.i("BluetoothLink","Finished sending message");
Log.i("BluetoothLink", "Finished sending message");
}
@Override
@@ -219,7 +226,10 @@ public class BluetoothLink extends BaseLink {
callback.onFailure(e);
return false;
} finally {
try { transferSocket.close(); } catch (IOException ignored) { }
try {
transferSocket.close();
} catch (IOException ignored) {
}
}
}

View File

@@ -23,8 +23,8 @@ package org.kde.kdeconnect.Backends.BluetoothBackend;
import android.annotation.TargetApi;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.bluetooth.BluetoothServerSocket;
import android.bluetooth.BluetoothSocket;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -37,11 +37,14 @@ import org.kde.kdeconnect.Backends.BaseLinkProvider;
import org.kde.kdeconnect.Device;
import org.kde.kdeconnect.NetworkPackage;
import java.io.*;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.Set;
import java.util.UUID;
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public class BluetoothLinkProvider extends BaseLinkProvider {
@@ -60,7 +63,7 @@ public class BluetoothLinkProvider extends BaseLinkProvider {
private void addLink(NetworkPackage identityPackage, BluetoothLink link) {
String deviceId = identityPackage.getString("deviceId");
Log.i("BluetoothLinkProvider","addLink to "+deviceId);
Log.i("BluetoothLinkProvider", "addLink to " + deviceId);
BluetoothLink oldLink = visibleComputers.get(deviceId);
if (oldLink == link) {
Log.e("BluetoothLinkProvider", "oldLink == link. This should not happen!");
@@ -70,7 +73,7 @@ public class BluetoothLinkProvider extends BaseLinkProvider {
connectionAccepted(identityPackage, link);
link.startListening();
if (oldLink != null) {
Log.i("BluetoothLinkProvider","Removing old connection to same device");
Log.i("BluetoothLinkProvider", "Removing old connection to same device");
oldLink.disconnect();
}
}
@@ -80,7 +83,7 @@ public class BluetoothLinkProvider extends BaseLinkProvider {
bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (bluetoothAdapter == null) {
Log.e("BluetoothLinkProvider","No bluetooth adapter found.");
Log.e("BluetoothLinkProvider", "No bluetooth adapter found.");
}
}
@@ -92,7 +95,7 @@ public class BluetoothLinkProvider extends BaseLinkProvider {
if (!bluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
Log.e("BluetoothLinkProvider","Bluetooth adapter not enabled.");
Log.e("BluetoothLinkProvider", "Bluetooth adapter not enabled.");
// TODO: next line needs to be called from an existing activity, so move it?
// startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
// TODO: Check result of the previous command, whether the user allowed bluetooth or not.
@@ -194,7 +197,7 @@ public class BluetoothLinkProvider extends BaseLinkProvider {
Reader reader = new InputStreamReader(socket.getInputStream(), "UTF-8");
int charsRead;
char[] buf = new char[512];
while(sb.lastIndexOf("\n") == -1 && (charsRead = reader.read(buf)) != -1) {
while (sb.lastIndexOf("\n") == -1 && (charsRead = reader.read(buf)) != -1) {
sb.append(buf, 0, charsRead);
}
@@ -263,7 +266,7 @@ public class BluetoothLinkProvider extends BaseLinkProvider {
}
@Override
@TargetApi(value=Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
@TargetApi(value = Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(BluetoothDevice.ACTION_UUID)) {
@@ -278,7 +281,7 @@ public class BluetoothLinkProvider extends BaseLinkProvider {
return;
}
for (Parcelable uuid: activeUuids) {
for (Parcelable uuid : activeUuids) {
if (uuid.toString().equals(SERVICE_UUID.toString())) {
connectToDevice(device);
return;
@@ -327,8 +330,8 @@ public class BluetoothLinkProvider extends BaseLinkProvider {
try {
int character;
StringBuilder sb = new StringBuilder();
while(sb.lastIndexOf("\n") == -1 && (character = socket.getInputStream().read()) != -1) {
sb.append((char)character);
while (sb.lastIndexOf("\n") == -1 && (character = socket.getInputStream().read()) != -1) {
sb.append((char) character);
}
String message = sb.toString();
@@ -359,7 +362,7 @@ public class BluetoothLinkProvider extends BaseLinkProvider {
identityPackage.getString("deviceId"), BluetoothLinkProvider.this);
NetworkPackage np2 = NetworkPackage.createIdentityPackage(context);
link.sendPackage(np2,new Device.SendPackageStatusCallback() {
link.sendPackage(np2, new Device.SendPackageStatusCallback() {
@Override
public void onSuccess() {
addLink(identityPackage, link);

View File

@@ -21,6 +21,7 @@
package org.kde.kdeconnect.Backends.BluetoothBackend;
import android.util.Log;
import org.kde.kdeconnect.Backends.BasePairingHandler;
import org.kde.kdeconnect.Device;
import org.kde.kdeconnect.NetworkPackage;
@@ -32,6 +33,7 @@ import java.util.TimerTask;
public class BluetoothPairingHandler extends BasePairingHandler {
Timer mPairingTimer;
public BluetoothPairingHandler(Device device, final PairingHandlerCallback callback) {
super(device, callback);
@@ -42,7 +44,7 @@ public class BluetoothPairingHandler extends BasePairingHandler {
}
}
// @Override
// @Override
public NetworkPackage createPairPackage() {
NetworkPackage np = new NetworkPackage(NetworkPackage.PACKAGE_TYPE_PAIR);
np.set("pair", true);
@@ -50,7 +52,7 @@ public class BluetoothPairingHandler extends BasePairingHandler {
}
@Override
public void packageReceived(NetworkPackage np) throws Exception{
public void packageReceived(NetworkPackage np) throws Exception {
boolean wantsPair = np.getBoolean("pair");
@@ -66,7 +68,7 @@ public class BluetoothPairingHandler extends BasePairingHandler {
if (wantsPair) {
if (mPairStatus == PairStatus.Requested) { //We started pairing
if (mPairStatus == PairStatus.Requested) { //We started pairing
hidePairingNotification();
pairingDone();
} else {
@@ -89,11 +91,11 @@ public class BluetoothPairingHandler extends BasePairingHandler {
mPairingTimer.schedule(new TimerTask() {
@Override
public void run() {
Log.w("KDE/Device","Unpairing (timeout B)");
Log.w("KDE/Device", "Unpairing (timeout B)");
mPairStatus = PairStatus.NotPaired;
hidePairingNotification();
}
}, 25*1000); //Time to show notification, waiting for user to accept (peer will timeout in 30 seconds)
}, 25 * 1000); //Time to show notification, waiting for user to accept (peer will timeout in 30 seconds)
mPairStatus = PairStatus.RequestedByPeer;
mCallback.incomingRequest();
@@ -126,10 +128,10 @@ public class BluetoothPairingHandler extends BasePairingHandler {
@Override
public void run() {
mCallback.pairingFailed(mDevice.getContext().getString(R.string.error_timed_out));
Log.w("KDE/Device","Unpairing (timeout A)");
Log.w("KDE/Device", "Unpairing (timeout A)");
mPairStatus = PairStatus.NotPaired;
}
}, 30*1000); //Time to wait for the other to accept
}, 30 * 1000); //Time to wait for the other to accept
mPairStatus = PairStatus.Requested;
}
@@ -144,7 +146,7 @@ public class BluetoothPairingHandler extends BasePairingHandler {
public void hidePairingNotification() {
mDevice.hidePairingNotification();
if (mPairingTimer != null) {
mPairingTimer .cancel();
mPairingTimer.cancel();
}
}

View File

@@ -60,7 +60,7 @@ public class BackgroundService extends Service {
private final HashSet<Object> discoveryModeAcquisitions = new HashSet<>();
public static BackgroundService getInstance(){
public static BackgroundService getInstance() {
return instance;
}
@@ -113,14 +113,17 @@ public class BackgroundService extends Service {
public void incomingRequest() {
onDeviceListChanged();
}
@Override
public void pairingSuccessful() {
onDeviceListChanged();
}
@Override
public void pairingFailed(String error) {
onDeviceListChanged();
}
@Override
public void unpaired() {
onDeviceListChanged();
@@ -128,7 +131,7 @@ public class BackgroundService extends Service {
};
public void onDeviceListChanged() {
for(DeviceListChangedCallback callback : deviceListChangedCallbacks.values()) {
for (DeviceListChangedCallback callback : deviceListChangedCallbacks.values()) {
callback.onDeviceListChanged();
}
}
@@ -137,11 +140,11 @@ public class BackgroundService extends Service {
//Log.e("BackgroundService", "Loading remembered trusted devices");
SharedPreferences preferences = getSharedPreferences("trusted_devices", Context.MODE_PRIVATE);
Set<String> trustedDevices = preferences.getAll().keySet();
for(String deviceId : trustedDevices) {
for (String deviceId : trustedDevices) {
//Log.e("BackgroundService", "Loading device "+deviceId);
if (preferences.getBoolean(deviceId, false)) {
Device device = new Device(this, deviceId);
devices.put(deviceId,device);
devices.put(deviceId, device);
device.addPairingCallback(devicePairingCallback);
}
}
@@ -167,7 +170,7 @@ public class BackgroundService extends Service {
new Thread(new Runnable() {
@Override
public void run() {
for(Device d : devices.values()) {
for (Device d : devices.values()) {
if (!d.isPaired() && !d.isPairRequested() && !d.isPairRequestedByPeer() && !d.deviceShouldBeKeptAlive()) {
d.disconnect();
}
@@ -192,8 +195,7 @@ public class BackgroundService extends Service {
device = new Device(BackgroundService.this, identityPackage, link);
if (device.isPaired() || device.isPairRequested() || device.isPairRequestedByPeer()
|| link.linkShouldBeKeptAlive()
||!discoveryModeAcquisitions.isEmpty() )
{
|| !discoveryModeAcquisitions.isEmpty()) {
devices.put(deviceId, device);
device.addPairingCallback(devicePairingCallback);
} else {
@@ -247,6 +249,7 @@ public class BackgroundService extends Service {
public void addDeviceListChangedCallback(String key, DeviceListChangedCallback callback) {
deviceListChangedCallbacks.put(key, callback);
}
public void removeDeviceListChangedCallback(String key) {
deviceListChangedCallbacks.remove(key);
}
@@ -290,7 +293,7 @@ public class BackgroundService extends Service {
}
@Override
public IBinder onBind (Intent intent) {
public IBinder onBind(Intent intent) {
return new Binder();
}

View File

@@ -110,19 +110,26 @@ public class Device implements BaseLink.PackageReceiver {
if ("phone".equals(s)) return Phone;
return Computer; //Default
}
public String toString() {
switch (this) {
case Tablet: return "tablet";
case Phone: return "phone";
default: return "desktop";
case Tablet:
return "tablet";
case Phone:
return "phone";
default:
return "desktop";
}
}
}
public interface PairingCallback {
void incomingRequest();
void pairingSuccessful();
void pairingFailed(String error);
void unpaired();
}
@@ -147,7 +154,7 @@ public class Device implements BaseLink.PackageReceiver {
}
} catch (Exception e) {
e.printStackTrace();
Log.e("KDE/Device","Exception deserializing stored public key for device");
Log.e("KDE/Device", "Exception deserializing stored public key for device");
}
//Assume every plugin is supported until addLink is called and we can get the actual list
@@ -176,16 +183,20 @@ public class Device implements BaseLink.PackageReceiver {
}
public String getName() {
return name != null? name : context.getString(R.string.unknown_device);
return name != null ? name : context.getString(R.string.unknown_device);
}
public Drawable getIcon()
{
public Drawable getIcon() {
int drawableId;
switch (deviceType) {
case Phone: drawableId = R.drawable.ic_device_phone; break;
case Tablet: drawableId = R.drawable.ic_device_tablet; break;
default: drawableId = R.drawable.ic_device_laptop;
case Phone:
drawableId = R.drawable.ic_device_phone;
break;
case Tablet:
drawableId = R.drawable.ic_device_tablet;
break;
default:
drawableId = R.drawable.ic_device_laptop;
}
return ContextCompat.getDrawable(context, drawableId);
}
@@ -208,8 +219,6 @@ public class Device implements BaseLink.PackageReceiver {
}
//
// Pairing-related functions
//
@@ -221,7 +230,7 @@ public class Device implements BaseLink.PackageReceiver {
/* Asks all pairing handlers that, is pair requested? */
public boolean isPairRequested() {
boolean pairRequested = false;
for (BasePairingHandler ph: pairingHandlers.values()) {
for (BasePairingHandler ph : pairingHandlers.values()) {
pairRequested = pairRequested || ph.isPairRequested();
}
return pairRequested;
@@ -248,7 +257,7 @@ public class Device implements BaseLink.PackageReceiver {
Resources res = context.getResources();
switch(pairStatus) {
switch (pairStatus) {
case Paired:
for (PairingCallback cb : pairingCallback) {
cb.pairingFailed(res.getString(R.string.error_already_paired));
@@ -311,7 +320,7 @@ public class Device implements BaseLink.PackageReceiver {
//Store as trusted device
SharedPreferences preferences = context.getSharedPreferences("trusted_devices", Context.MODE_PRIVATE);
preferences.edit().putBoolean(deviceId,true).apply();
preferences.edit().putBoolean(deviceId, true).apply();
SharedPreferences.Editor editor = context.getSharedPreferences(deviceId, Context.MODE_PRIVATE).edit();
editor.putString("deviceName", name);
@@ -366,7 +375,7 @@ public class Device implements BaseLink.PackageReceiver {
hidePairingNotification();
notificationId = (int)System.currentTimeMillis();
notificationId = (int) System.currentTimeMillis();
Intent intent = new Intent(getContext(), MaterialActivity.class);
intent.putExtra("deviceId", getDeviceId());
@@ -378,12 +387,12 @@ public class Device implements BaseLink.PackageReceiver {
acceptIntent.putExtra("deviceId", getDeviceId());
acceptIntent.putExtra("notificationId", notificationId);
acceptIntent.setAction("action "+System.currentTimeMillis());
acceptIntent.setAction("action " + System.currentTimeMillis());
acceptIntent.putExtra(MaterialActivity.PAIR_REQUEST_STATUS, MaterialActivity.PAIRING_ACCEPTED);
rejectIntent.putExtra("deviceId", getDeviceId());
rejectIntent.putExtra("notificationId", notificationId);
rejectIntent.setAction("action "+System.currentTimeMillis());
rejectIntent.setAction("action " + System.currentTimeMillis());
rejectIntent.putExtra(MaterialActivity.PAIR_REQUEST_STATUS, MaterialActivity.PAIRING_REJECTED);
PendingIntent acceptedPendingIntent = PendingIntent.getActivity(getContext(), 2, acceptIntent, PendingIntent.FLAG_ONE_SHOT);
@@ -466,7 +475,7 @@ public class Device implements BaseLink.PackageReceiver {
Log.e("KDE/Device", "Exception reading our own private key"); //Should not happen
}
Log.i("KDE/Device","addLink "+link.getLinkProvider().getName()+" -> "+getName() + " active links: "+ links.size());
Log.i("KDE/Device", "addLink " + link.getLinkProvider().getName() + " -> " + getName() + " active links: " + links.size());
if (!pairingHandlers.containsKey(link.getName())) {
BasePairingHandler.PairingHandlerCallback callback = new BasePairingHandler.PairingHandlerCallback() {
@@ -543,12 +552,12 @@ public class Device implements BaseLink.PackageReceiver {
Log.i("KDE/Device", "Pair package");
for (BasePairingHandler ph: pairingHandlers.values()) {
for (BasePairingHandler ph : pairingHandlers.values()) {
try {
ph.packageReceived(np);
} catch (Exception e) {
e.printStackTrace();
Log.e("PairingPackageReceived","Exception");
Log.e("PairingPackageReceived", "Exception");
}
}
} else if (isPaired()) {
@@ -600,13 +609,18 @@ public class Device implements BaseLink.PackageReceiver {
public static abstract class SendPackageStatusCallback {
public abstract void onSuccess();
public abstract void onFailure(Throwable e);
public void onProgressChanged(int percent) { }
public void onProgressChanged(int percent) {
}
}
private SendPackageStatusCallback defaultCallback = new SendPackageStatusCallback() {
@Override
public void onSuccess() { }
public void onSuccess() {
}
@Override
public void onFailure(Throwable e) {
if (e != null) {
@@ -651,7 +665,8 @@ public class Device implements BaseLink.PackageReceiver {
boolean success = false;
//Make a copy to avoid concurrent modification exception if the original list changes
for (final BaseLink link : links) {
if (link == null) continue; //Since we made a copy, maybe somebody destroyed the link in the meanwhile
if (link == null)
continue; //Since we made a copy, maybe somebody destroyed the link in the meanwhile
if (useEncryption) {
success = link.sendPackageEncrypted(np, callback, publicKey);
} else {
@@ -661,7 +676,7 @@ public class Device implements BaseLink.PackageReceiver {
}
if (!success) {
Log.e("KDE/sendPackage", "No device link (of "+links.size()+" available) could send the package. Package "+np.getType()+" to " + name + " lost!");
Log.e("KDE/sendPackage", "No device link (of " + links.size() + " available) could send the package. Package " + np.getType() + " to " + name + " lost!");
}
return success;
@@ -672,11 +687,11 @@ public class Device implements BaseLink.PackageReceiver {
//
public <T extends Plugin> T getPlugin(Class<T> pluginClass) {
return (T)getPlugin(Plugin.getPluginKey(pluginClass));
return (T) getPlugin(Plugin.getPluginKey(pluginClass));
}
public <T extends Plugin> T getPlugin(Class<T> pluginClass, boolean includeFailed) {
return (T)getPlugin(Plugin.getPluginKey(pluginClass), includeFailed);
return (T) getPlugin(Plugin.getPluginKey(pluginClass), includeFailed);
}
public Plugin getPlugin(String pluginKey) {
@@ -713,7 +728,7 @@ public class Device implements BaseLink.PackageReceiver {
final Plugin plugin = PluginFactory.instantiatePluginForDevice(context, pluginKey, this);
if (plugin == null) {
Log.e("KDE/addPlugin","could not instantiate plugin: "+pluginKey);
Log.e("KDE/addPlugin", "could not instantiate plugin: " + pluginKey);
//Can't put a null
//failedPlugins.put(pluginKey, null);
return false;
@@ -743,7 +758,7 @@ public class Device implements BaseLink.PackageReceiver {
failedPlugins.put(pluginKey, plugin);
}
if(!plugin.checkRequiredPermissions()){
if (!plugin.checkRequiredPermissions()) {
Log.e("KDE/addPlugin", "No permission " + pluginKey);
plugins.remove(pluginKey);
pluginsWithoutPermissions.put(pluginKey, plugin);
@@ -782,14 +797,14 @@ public class Device implements BaseLink.PackageReceiver {
//Log.e("removePlugin","removed " + pluginKey);
} catch (Exception e) {
e.printStackTrace();
Log.e("KDE/removePlugin","Exception calling onDestroy for plugin "+pluginKey);
Log.e("KDE/removePlugin", "Exception calling onDestroy for plugin " + pluginKey);
}
return true;
}
public void setPluginEnabled(String pluginKey, boolean value) {
settings.edit().putBoolean(pluginKey,value).apply();
settings.edit().putBoolean(pluginKey, value).apply();
reloadPluginsFromSettings();
}
@@ -842,11 +857,11 @@ public class Device implements BaseLink.PackageReceiver {
}
}
public ConcurrentHashMap<String,Plugin> getLoadedPlugins() {
public ConcurrentHashMap<String, Plugin> getLoadedPlugins() {
return plugins;
}
public ConcurrentHashMap<String,Plugin> getFailedPlugins() {
public ConcurrentHashMap<String, Plugin> getFailedPlugins() {
return failedPlugins;
}
@@ -854,7 +869,7 @@ public class Device implements BaseLink.PackageReceiver {
return pluginsWithoutPermissions;
}
public ConcurrentHashMap<String,Plugin> getPluginsWithoutOptionalPermissions() {
public ConcurrentHashMap<String, Plugin> getPluginsWithoutOptionalPermissions() {
return pluginsWithoutOptionalPermissions;
}
@@ -867,7 +882,7 @@ public class Device implements BaseLink.PackageReceiver {
}
public void disconnect() {
for(BaseLink link : links) {
for (BaseLink link : links) {
link.disconnect();
}
}
@@ -880,7 +895,7 @@ public class Device implements BaseLink.PackageReceiver {
return true; //Already paired
}
for(BaseLink l : links) {
for (BaseLink l : links) {
if (l.linkShouldBeKeptAlive()) {
return true;
}
@@ -894,8 +909,9 @@ public class Device implements BaseLink.PackageReceiver {
public void hackToMakeRetrocompatiblePacketTypes(NetworkPackage np) {
if (protocolVersion >= 6) return;
np.mType = np.getType().replace(".request","");
np.mType = np.getType().replace(".request", "");
}
public String hackToMakeRetrocompatiblePacketTypes(String type) {
if (protocolVersion >= 6) return type;
return type.replace(".request", "");

View File

@@ -40,7 +40,7 @@ public class AppsHelper {
} catch (final PackageManager.NameNotFoundException e) {
e.printStackTrace();
Log.e("AppsHelper","Could not resolve name "+packageName);
Log.e("AppsHelper", "Could not resolve name " + packageName);
return null;
@@ -53,13 +53,13 @@ public class AppsHelper {
try {
PackageManager pm = context.getPackageManager();
ApplicationInfo ai = pm.getApplicationInfo( packageName, 0);
ApplicationInfo ai = pm.getApplicationInfo(packageName, 0);
return pm.getApplicationIcon(ai);
} catch (final PackageManager.NameNotFoundException e) {
e.printStackTrace();
Log.e("AppsHelper","Could not find icon for "+packageName);
Log.e("AppsHelper", "Could not find icon for " + packageName);
return null;
@@ -68,5 +68,4 @@ public class AppsHelper {
}
}

View File

@@ -51,7 +51,7 @@ public class ContactsHelper {
try {
cursor = context.getContentResolver().query(
uri,
new String[] {
new String[]{
PhoneLookup.DISPLAY_NAME,
ContactsContract.PhoneLookup.PHOTO_URI
/*, PhoneLookup.TYPE
@@ -75,7 +75,10 @@ public class ContactsHelper {
contactInfo.put("photoID", cursor.getString(nameIndex));
}
try { cursor.close(); } catch (Exception e) {}
try {
cursor.close();
} catch (Exception e) {
}
if (!contactInfo.isEmpty()) {
return contactInfo;
@@ -92,7 +95,7 @@ public class ContactsHelper {
Uri photoUri = Uri.parse(photoId);
InputStream input = null;
Base64OutputStream output= null;
Base64OutputStream output = null;
try {
ByteArrayOutputStream encodedPhoto = new ByteArrayOutputStream();
output = new Base64OutputStream(encodedPhoto, Base64.DEFAULT);
@@ -107,8 +110,16 @@ public class ContactsHelper {
Log.e("ContactsHelper", ex.toString());
return "";
} finally {
try { input.close(); } catch(Exception ignored) { };
try { output.close(); } catch(Exception ignored) { };
try {
input.close();
} catch (Exception ignored) {
}
;
try {
output.close();
} catch (Exception ignored) {
}
;
}
}
}

View File

@@ -38,412 +38,413 @@ public class DeviceHelper {
//from https://github.com/meetup/android-device-names
//Converted to java using:
//cat android_models.properties | awk -F'=' '{sub(/ *$/, "", $1)} sub(/^ */, "", $2) { if ($2 != "") print "humanReadableNames.put(\""$1"\",\"" $2 "\");"}' | sed -e 's/\\ /_/g'
private final static HashMap<String,String> humanReadableNames = new HashMap<>();
private final static HashMap<String, String> humanReadableNames = new HashMap<>();
static {
humanReadableNames.put("5860E","Coolpad Quattro 4G");
humanReadableNames.put("831C","HTC One M8");
humanReadableNames.put("9920","Star Alps S9920");
humanReadableNames.put("A0001","OnePlus One");
humanReadableNames.put("A1-810","Acer Iconia A1-810");
humanReadableNames.put("ADR6300","HTC Droid Incredible");
humanReadableNames.put("ADR6330VW","HTC Rhyme");
humanReadableNames.put("ADR6350","HTC Droid Incredible 2");
humanReadableNames.put("ADR6400L","HTC Thunderbolt");
humanReadableNames.put("ADR6410LVW","HTC Droid Incredible 4G");
humanReadableNames.put("ADR6425LVW","HTC Rezound 4G");
humanReadableNames.put("ALCATEL_ONE_TOUCH_5035X","Alcatel One Touch X Pop");
humanReadableNames.put("ALCATEL_ONE_TOUCH_7041X","Alcatel One Touch Pop C7");
humanReadableNames.put("ASUS_T00J","Asus ZenFone 5");
humanReadableNames.put("ASUS_Transformer_Pad_TF300T","Asus Transformer Pad");
humanReadableNames.put("ASUS_Transformer_Pad_TF700T","Asus Transformer Pad");
humanReadableNames.put("Aquaris_E4.5","bq Aquaris E4.5");
humanReadableNames.put("C1905","Sony Xperia M");
humanReadableNames.put("C2105","Sony Xperia L");
humanReadableNames.put("C5155","Kyocera Rise");
humanReadableNames.put("C5170","Kyocera Hydro");
humanReadableNames.put("C5302","Xperia SP");
humanReadableNames.put("C5303","Sony Xperia SP");
humanReadableNames.put("C5306","Xperia SP");
humanReadableNames.put("C6603","Sony Xperia Z");
humanReadableNames.put("C6606","Sony Xperia Z");
humanReadableNames.put("C6833","Sony Xperia Z Ultra");
humanReadableNames.put("C6903","Sony Xperia Z1");
humanReadableNames.put("C6916","Sony Xperia Z1S");
humanReadableNames.put("CM990","Huawei Evolution III");
humanReadableNames.put("CUBOT_ONE","Cubot One");
humanReadableNames.put("D2005","Sony Xperia E1");
humanReadableNames.put("D2302","Xperia M2");
humanReadableNames.put("D2303","Sony Xperia M2");
humanReadableNames.put("D2305","Xperia M2");
humanReadableNames.put("D2306","Xperia M2");
humanReadableNames.put("D2316","Xperia M2");
humanReadableNames.put("D5503","Sony Xperia Z1");
humanReadableNames.put("D5803","Sony Xperia Z3 Compact");
humanReadableNames.put("D5833","Xperia Z3 Compact");
humanReadableNames.put("D6503","Sony Xperia Z2");
humanReadableNames.put("D6603","Sony Xperia Z3");
humanReadableNames.put("D6653","Sony Xperia Z3");
humanReadableNames.put("DROID2","Motorola Droid 2");
humanReadableNames.put("DROID2_GLOBAL","Motorola Droid 2 Global");
humanReadableNames.put("DROID3","Motorola Droid 3");
humanReadableNames.put("DROID4","Motorola Droid 4");
humanReadableNames.put("DROIDX","Motorola Droid X");
humanReadableNames.put("DROID_BIONIC","Motorola Droid Bionic");
humanReadableNames.put("DROID_Pro","Motorola Droid Pro");
humanReadableNames.put("DROID_RAZR","Motorola Droid Razr");
humanReadableNames.put("DROID_RAZR_HD","Motorola Droid Razr HD");
humanReadableNames.put("DROID_X2","Motorola Droid X2");
humanReadableNames.put("Desire_HD","HTC Desire HD");
humanReadableNames.put("Droid","Motorola Droid");
humanReadableNames.put("EVO","HTC Evo");
humanReadableNames.put("GT-I8160","Samsung Galaxy Ace 2");
humanReadableNames.put("GT-I8190","Samsung Galaxy S III Mini");
humanReadableNames.put("GT-I8190L","Samsung Galaxy S3 Mini");
humanReadableNames.put("GT-I8190N","Samsung Galaxy S III Mini");
humanReadableNames.put("GT-I8260","Samsung Galaxy Core");
humanReadableNames.put("GT-I8262","Samsung Galaxy Core");
humanReadableNames.put("GT-I8550L","Samsung Galaxy Win");
humanReadableNames.put("GT-I9000","Samsung Galaxy S");
humanReadableNames.put("GT-I9001","Samsung Galaxy S Plus");
humanReadableNames.put("GT-I9060","Samsung Galaxy Grand Neo");
humanReadableNames.put("GT-I9063T","Samsung Galaxy Grand Neo Duos");
humanReadableNames.put("GT-I9070","Samsung Galaxy S Advance");
humanReadableNames.put("GT-I9082","Samsung Galaxy Grand");
humanReadableNames.put("GT-I9100","Samsung Galaxy S II");
humanReadableNames.put("GT-I9100M","Samsung Galaxy S II");
humanReadableNames.put("GT-I9100P","Samsung Galaxy S II");
humanReadableNames.put("GT-I9100T","Samsung Galaxy S II");
humanReadableNames.put("GT-I9105P","Samsung Galaxy S2 Plus");
humanReadableNames.put("GT-I9190","Samsung Galaxy S4 Mini");
humanReadableNames.put("GT-I9192","Samsung Galaxy S4 Mini Duos");
humanReadableNames.put("GT-I9195","Samsung Galaxy S4 Mini");
humanReadableNames.put("GT-I9197","Galaxy S4 Mini");
humanReadableNames.put("GT-I9198","Galaxy S4 Mini");
humanReadableNames.put("GT-I9210","Galaxy S2");
humanReadableNames.put("GT-I9295","Samsung Galaxy S4 Active");
humanReadableNames.put("GT-I9300","Samsung Galaxy S III");
humanReadableNames.put("GT-I9300T","Samsung Galaxy S III");
humanReadableNames.put("GT-I9305","Samsung Galaxy S III");
humanReadableNames.put("GT-I9305T","Samsung Galaxy S III");
humanReadableNames.put("GT-I9500","Samsung Galaxy S4");
humanReadableNames.put("GT-I9505","Samsung Galaxy S4");
humanReadableNames.put("GT-I9506","Samsung Galaxy S4");
humanReadableNames.put("GT-I9507","Samsung Galaxy S4");
humanReadableNames.put("GT-N5110","Samsung Galaxy Note 8.0");
humanReadableNames.put("GT-N7000","Samsung Galaxy Note");
humanReadableNames.put("GT-N7100","Samsung Galaxy Note II");
humanReadableNames.put("GT-N7105","Samsung Galaxy Note II");
humanReadableNames.put("GT-N7105T","Samsung Galaxy Note II");
humanReadableNames.put("GT-N8000","Samsung Galaxy Note 10.1");
humanReadableNames.put("GT-N8010","Samsung Galaxy Note 10.1");
humanReadableNames.put("GT-N8013","Samsung Galaxy Note 10.1");
humanReadableNames.put("GT-P3100","Samsung Galaxy Tab 2");
humanReadableNames.put("GT-P3110","Samsung Galaxy Tab 2");
humanReadableNames.put("GT-P3113","Samsung Galaxy Tab 2 7.0");
humanReadableNames.put("GT-P5110","Samsung Galaxy Tab 2");
humanReadableNames.put("GT-P5113","Samsnung Galaxy Tab 2 10.1");
humanReadableNames.put("GT-P5210","Samsung Galaxy Tab 3 10.1");
humanReadableNames.put("GT-P7510","Samsung Galaxy Tab 10.1");
humanReadableNames.put("GT-S5301L","Samsung Galaxy Pocket Plus");
humanReadableNames.put("GT-S5360","Samsung Galaxy Y");
humanReadableNames.put("GT-S5570","Samsung Galaxy Mini");
humanReadableNames.put("GT-S5830","Samsung Galaxy Ace");
humanReadableNames.put("GT-S5830i","Samsung Galaxy Ace");
humanReadableNames.put("GT-S6310","Samsung Galaxy Young");
humanReadableNames.put("GT-S6310N","Samsung Galaxy Young");
humanReadableNames.put("GT-S6810P","Samsung Galaxy Fame");
humanReadableNames.put("GT-S7560M","Samsung Galaxy Ace II X");
humanReadableNames.put("GT-S7562","Samsung Galaxy S Duos");
humanReadableNames.put("GT-S7580","Samsung Galaxy Trend Plus");
humanReadableNames.put("Galaxy_Nexus","Samsung Galaxy Nexus");
humanReadableNames.put("HM_1SW","Xiaomi Redmi");
humanReadableNames.put("HTC6435LVW","HTC Droid DNA");
humanReadableNames.put("HTC6500LVW","HTC One");
humanReadableNames.put("HTC6525LVW","HTC One M8");
humanReadableNames.put("HTCEVODesign4G","HTC Evo Design 4G");
humanReadableNames.put("HTCEVOV4G","HTC Evo V 4G");
humanReadableNames.put("HTCONE","HTC One");
humanReadableNames.put("HTC_Desire_500","HTC Desire 500");
humanReadableNames.put("HTC_Desire_HD_A9191","HTC Desire HD");
humanReadableNames.put("HTC_One_mini","HTC One mini");
humanReadableNames.put("HTC_PH39100","HTC Vivid 4G");
humanReadableNames.put("HTC_PN071","HTC One");
humanReadableNames.put("HTC_Sensation_Z710e","HTC Sensation");
humanReadableNames.put("HTC_Sensation_4G","HTC Sensation");
humanReadableNames.put("HTC_VLE_U","HTC One S");
humanReadableNames.put("HUAWEI_G510-0251","Huawei Ascend G510");
humanReadableNames.put("HUAWEI_P6-U06","Huawei Ascend P6");
humanReadableNames.put("HUAWEI_Y300-0100","Huawei Ascend Y300");
humanReadableNames.put("ISW11SC","Galaxy S2");
humanReadableNames.put("KFJWA","Kindle Fire HD 8.9");
humanReadableNames.put("KFJWI","Kindle Fire HD 8.9");
humanReadableNames.put("KFOT","Kindle Fire");
humanReadableNames.put("KFTT","Kindle Fire HD 7");
humanReadableNames.put("L-01F","G2");
humanReadableNames.put("LG-C800","LG myTouch Q");
humanReadableNames.put("LG-D415","LG Optimus L90");
humanReadableNames.put("LG-D620","LG G2 Mini");
humanReadableNames.put("LG-D686","LG G Pro Lite Dual");
humanReadableNames.put("LG-D800","LG G2");
humanReadableNames.put("LG-D801","LG G2");
humanReadableNames.put("LG-D802","LG G2");
humanReadableNames.put("LG-D803","G2");
humanReadableNames.put("LG-D805","G2");
humanReadableNames.put("LG-D850","LG G3");
humanReadableNames.put("LG-D851","LG G3");
humanReadableNames.put("LG-D852","G3");
humanReadableNames.put("LG-D855","LG G3");
humanReadableNames.put("LG-E411g","LG Optimus L1 II");
humanReadableNames.put("LG-E425g","LG Optimus L3 II");
humanReadableNames.put("LG-E440g","LG Optimus L4 II");
humanReadableNames.put("LG-E460","LG Optimus L5 II");
humanReadableNames.put("LG-E610","LG Optimus L5");
humanReadableNames.put("LG-E612g","LG Optimus L5 Dual");
humanReadableNames.put("LG-E739","LG MyTouch e739");
humanReadableNames.put("LG-E970","LG Optimus G");
humanReadableNames.put("LG-E971","Optimus G");
humanReadableNames.put("LG-E980","LG Optimus G Pro");
humanReadableNames.put("LG-H815","G4");
humanReadableNames.put("LG-LG730","LG Venice");
humanReadableNames.put("LG-LS720","LG Optimus F3");
humanReadableNames.put("LG-LS840","LG Viper");
humanReadableNames.put("LG-LS970","LG Optimus G");
humanReadableNames.put("LG-LS980","LG G2");
humanReadableNames.put("LG-MS770","LG Motion 4G");
humanReadableNames.put("LG-MS910","LG Esteem");
humanReadableNames.put("LG-P509","LG Optimus T");
humanReadableNames.put("LG-P760","LG Optimus L9");
humanReadableNames.put("LG-P768","LG Optimus L9");
humanReadableNames.put("LG-P769","LG Optimus L9");
humanReadableNames.put("LG-P999","LG G2X P999");
humanReadableNames.put("LG-VM696","LG Optimus Elite");
humanReadableNames.put("LGL34C","LG Optimus Fuel");
humanReadableNames.put("LGL55C","LG LGL55C");
humanReadableNames.put("LGLS740","LG Volt");
humanReadableNames.put("LGLS990","LG G3");
humanReadableNames.put("LGMS323","LG Optimus L70");
humanReadableNames.put("LGMS500","LG Optimus F6");
humanReadableNames.put("LGMS769","LG Optimus L9");
humanReadableNames.put("LS670","LG Optimus S");
humanReadableNames.put("LT22i","Sony Xperia P");
humanReadableNames.put("LT25i","Sony Xperia V");
humanReadableNames.put("LT26i","Sony Xperia S");
humanReadableNames.put("LT30p","Sony Xperia T");
humanReadableNames.put("MB855","Motorola Photon 4G");
humanReadableNames.put("MB860","Motorola Atrix 4G");
humanReadableNames.put("MB865","Motorola Atrix 2");
humanReadableNames.put("MB886","Motorola Atrix HD");
humanReadableNames.put("ME173X","Asus MeMO Pad HD 7");
humanReadableNames.put("MI_3W","Xiaomi Mi 3");
humanReadableNames.put("MOTWX435KT","Motorola Triumph");
humanReadableNames.put("N3","Star NO.1 N3");
humanReadableNames.put("N860","ZTE Warp N860");
humanReadableNames.put("NEXUS_4","Nexus 4");
humanReadableNames.put("NEXUS_5","Nexus 5");
humanReadableNames.put("NEXUS_5X","Nexus 5X");
humanReadableNames.put("LG-D820","Nexus 5");
humanReadableNames.put("LG-D821","Nexus 5");
humanReadableNames.put("NEXUS_6","Nexus 6");
humanReadableNames.put("NEXUS_6P","Nexus 6P");
humanReadableNames.put("Nexus_10","Google Nexus 10");
humanReadableNames.put("Nexus_4","Google Nexus 4");
humanReadableNames.put("Nexus_7","Asus Nexus 7");
humanReadableNames.put("Nexus_S","Samsung Nexus S");
humanReadableNames.put("Nexus_S_4G","Samsung Nexus S 4G");
humanReadableNames.put("Orange_Daytona","Huawei Ascend G510");
humanReadableNames.put("PC36100","HTC Evo 4G");
humanReadableNames.put("PG06100","HTC EVO Shift 4G");
humanReadableNames.put("PG86100","HTC Evo 3D");
humanReadableNames.put("PH44100","HTC Evo Design 4G");
humanReadableNames.put("PantechP9070","Pantech Burst");
humanReadableNames.put("QMV7A","Verizon Ellipsis 7");
humanReadableNames.put("SAMSUNG-SGH-I317","Samsung Galaxy Note II");
humanReadableNames.put("SAMSUNG-SGH-I337","Samsung Galaxy S4");
humanReadableNames.put("SAMSUNG-SGH-I527","Samsung Galaxy Mega");
humanReadableNames.put("SAMSUNG-SGH-I537","Samsung Galaxy S4 Active");
humanReadableNames.put("SAMSUNG-SGH-I717","Samsung Galaxy Note");
humanReadableNames.put("SAMSUNG-SGH-I727","Samsung Skyrocket");
humanReadableNames.put("SAMSUNG-SGH-I747","Samsung Galaxy S III");
humanReadableNames.put("SAMSUNG-SGH-I777","Samsung Galaxy S II");
humanReadableNames.put("SAMSUNG-SGH-I897","Samsung Captivate");
humanReadableNames.put("SAMSUNG-SGH-I927","Samsung Captivate Glide");
humanReadableNames.put("SAMSUNG-SGH-I997","Samsung Infuse 4G");
humanReadableNames.put("SAMSUNG-SM-G730A","Samsung Galaxy S3 Mini");
humanReadableNames.put("SAMSUNG-SM-G870A","Samsung Galaxy S5 Active");
humanReadableNames.put("SAMSUNG-SM-G900A","Samsung Galaxy S5");
humanReadableNames.put("SAMSUNG-SM-G920A","Samsung Galaxy S6");
humanReadableNames.put("SAMSUNG-SM-N900A","Samsung Galaxy Note 3");
humanReadableNames.put("SAMSUNG-SM-N910A","Samsung Galaxy Note 4");
humanReadableNames.put("SC-02C","Galaxy S2");
humanReadableNames.put("SC-03E","Galaxy S3");
humanReadableNames.put("SC-04E","Galaxy S4");
humanReadableNames.put("SC-06D","Galaxy S3");
humanReadableNames.put("SCH-I200","Samsung Galaxy Stellar");
humanReadableNames.put("SCH-I337","Galaxy S4");
humanReadableNames.put("SCH-I405","Samsung Stratosphere");
humanReadableNames.put("SCH-I415","Samsung Galaxy Stratosphere II");
humanReadableNames.put("SCH-I435","Samsung Galaxy S4 Mini");
humanReadableNames.put("SCH-I500","Samsung Fascinate");
humanReadableNames.put("SCH-I510","Samsung Droid Charge");
humanReadableNames.put("SCH-I535","Samsung Galaxy S III");
humanReadableNames.put("SCH-I545","Samsung Galaxy S4");
humanReadableNames.put("SCH-I605","Samsung Galaxy Note II");
humanReadableNames.put("SCH-I800","Samsung Galaxy Tab 7.0");
humanReadableNames.put("SCH-I939","Galaxy S3");
humanReadableNames.put("SCH-I959","Galaxy S4");
humanReadableNames.put("SCH-J021","Galaxy S3");
humanReadableNames.put("SCH-R530C","Samsung Galaxy S3");
humanReadableNames.put("SCH-R530M","Samsung Galaxy S III");
humanReadableNames.put("SCH-R530U","Samsung Galaxy S III");
humanReadableNames.put("SCH-R720","Samsung Admire");
humanReadableNames.put("SCH-R760","Galaxy S2");
humanReadableNames.put("SCH-R970","Samsung Galaxy S4");
humanReadableNames.put("SCH-S720C","Samsung Proclaim");
humanReadableNames.put("SCH-S738C","Samsung Galaxy Centura");
humanReadableNames.put("SCH-S968C","Samsung Galaxy S III");
humanReadableNames.put("SCL21","Galaxy S3");
humanReadableNames.put("SGH-I257M","Samsung Galaxy S4 Mini");
humanReadableNames.put("SGH-I317M","Samsung Galaxy Note II");
humanReadableNames.put("SGH-I337M","Samsung Galaxy S4");
humanReadableNames.put("SGH-I727R","Samsung Galaxy S II");
humanReadableNames.put("SGH-I747M","Samsung Galaxy S III");
humanReadableNames.put("SGH-I757M","Galaxy S2");
humanReadableNames.put("SGH-I777M","Galaxy S2");
humanReadableNames.put("SGH-M919","Samsung Galaxy S4");
humanReadableNames.put("SGH-M919N","Samsung Galaxy S4");
humanReadableNames.put("SGH-N035","Galaxy S3");
humanReadableNames.put("SGH-N045","Galaxy S4");
humanReadableNames.put("SGH-N064","Galaxy S3");
humanReadableNames.put("SGH-T399","Samsung Galaxy Light");
humanReadableNames.put("SGH-T399N","Samsung Galaxy Light");
humanReadableNames.put("SGH-T599N","Samsung Galaxy Exhibit");
humanReadableNames.put("SGH-T679","Samsung Exhibit II");
humanReadableNames.put("SGH-T769","Samsung Galaxy S Blaze");
humanReadableNames.put("SGH-T889","Samsung Galaxy Note II");
humanReadableNames.put("SGH-T959","Samsung Galaxy S Vibrant");
humanReadableNames.put("SGH-T959V","Samsung Galaxy S 4G");
humanReadableNames.put("SGH-T989","Samsung Galaxy S II");
humanReadableNames.put("SGH-T989D","Samsung Galaxy S II");
humanReadableNames.put("SGH-T999","Samsung Galaxy S III");
humanReadableNames.put("SGH-T999L","Samsung Galaxy S III");
humanReadableNames.put("SGH-T999V","Samsung Galaxy S III");
humanReadableNames.put("SGP312","Sony Xperia Tablet Z");
humanReadableNames.put("SHV-E210K","Samsung Galaxy S3");
humanReadableNames.put("SHV-E210S","Samsung Galaxy S III");
humanReadableNames.put("SHV-E250K","Samsung Galaxy Note 2");
humanReadableNames.put("SHV-E250S","Samsung Galaxy Note II");
humanReadableNames.put("SHV-E300","Galaxy S4");
humanReadableNames.put("SHW-M250","Galaxy S2");
humanReadableNames.put("SM-G3815","Samsung Galaxy Express II");
humanReadableNames.put("SM-G386T","Samsung Galaxy Avant");
humanReadableNames.put("SM-G386T1","Samsung Galaxy Avant");
humanReadableNames.put("SM-G7102","Samsung Galaxy Grand II");
humanReadableNames.put("SM-G800F","Samsung Galaxy S5 Mini");
humanReadableNames.put("SM-G860P","Samsung Galaxy S5 Sport");
humanReadableNames.put("SM-G900F","Samsung Galaxy S5");
humanReadableNames.put("SM-G900H","Samsung Galaxy S5");
humanReadableNames.put("SM-G900I","Samsung Galaxy S5");
humanReadableNames.put("SM-G900P","Samsung Galaxy S5");
humanReadableNames.put("SM-G900R4","Galaxy S5");
humanReadableNames.put("SM-G900RZWAUSC","Galaxy S5");
humanReadableNames.put("SM-G900T","Samsung Galaxy S5");
humanReadableNames.put("SM-G900V","Samsung Galaxy S5");
humanReadableNames.put("SM-G900W8","Samsung Galaxy S5");
humanReadableNames.put("SM-G9200","Galaxy S6");
humanReadableNames.put("SM-G920F","Galaxy S6");
humanReadableNames.put("SM-G920I","Galaxy S6");
humanReadableNames.put("SM-G920P","Samsung Galaxy S6");
humanReadableNames.put("SM-G920R","Galaxy S6");
humanReadableNames.put("SM-G920T","Samsung Galaxy S6");
humanReadableNames.put("SM-G920V","Samsung Galaxy S6");
humanReadableNames.put("SM-G920W8","Galaxy S6");
humanReadableNames.put("SM-G9250","Galaxy S6 Edge");
humanReadableNames.put("SM-G925A","Galaxy S6 Edge");
humanReadableNames.put("SM-G925F","Galaxy S6 Edge");
humanReadableNames.put("SM-G925P","Galaxy S6 Edge");
humanReadableNames.put("SM-G925R","Galaxy S6 Edge");
humanReadableNames.put("SM-G925T","Galaxy S6 Edge");
humanReadableNames.put("SM-G925V","Galaxy S6 Edge");
humanReadableNames.put("SM-G925W8","Galaxy S6 Edge");
humanReadableNames.put("SM-N7505","Samsung Galaxy Note 3 Neo");
humanReadableNames.put("SM-N900","Samsung Galaxy Note 3");
humanReadableNames.put("SM-N9005","Samsung Galaxy Note 3");
humanReadableNames.put("SM-N9006","Samsung Galaxy Note 3");
humanReadableNames.put("SM-N900P","Samsung Galaxy Note 3");
humanReadableNames.put("SM-N900T","Samsung Galaxy Note 3");
humanReadableNames.put("SM-N900V","Samsung Galaxy Note 3");
humanReadableNames.put("SM-N900W8","Samsung Galaxy Note 3");
humanReadableNames.put("SM-N910C","Samsung Galaxy Note 4");
humanReadableNames.put("SM-N910F","Samsung Galaxy Note 4");
humanReadableNames.put("SM-N910G","Samsung Galaxy Note 4");
humanReadableNames.put("SM-N910P","Samsung Galaxy Note 4");
humanReadableNames.put("SM-N910T","Samsung Galaxy Note 4");
humanReadableNames.put("SM-N910V","Samsung Galaxy Note 4");
humanReadableNames.put("SM-N910W8","Samsung Galaxy Note 4");
humanReadableNames.put("SM-P600","Samsung Galaxy Note 10.1");
humanReadableNames.put("SM-T210R","Samsung Galaxy Tab 3 7.0");
humanReadableNames.put("SM-T217S","Samsung Galaxy Tab 3 7.0");
humanReadableNames.put("SM-T230NU","Samsung Galaxy Tab 4");
humanReadableNames.put("SM-T310","Samsung Galaxy Tab 3 8.0");
humanReadableNames.put("SM-T530NU","Samsung Galaxy Tab 4 10.1");
humanReadableNames.put("SM-T800","Samsung Galaxy Tab S 10.5");
humanReadableNames.put("SPH-D600","Samsung Conquer 4G");
humanReadableNames.put("SPH-D700","Samsung Epic 4G");
humanReadableNames.put("SPH-D710","Samsung Epic");
humanReadableNames.put("SPH-D710BST","Samsung Galaxy S II");
humanReadableNames.put("SPH-D710VMUB","Samsung Galaxy S II");
humanReadableNames.put("SPH-L300","Samsung Galaxy Victory");
humanReadableNames.put("SPH-L520","Samsung Galaxy S4 Mini");
humanReadableNames.put("SPH-L710","Samsung Galaxy S III");
humanReadableNames.put("SPH-L710T","Samsung Galaxy S III");
humanReadableNames.put("SPH-L720","Samsung Galaxy S4");
humanReadableNames.put("SPH-L720T","Samsung Galaxy S4");
humanReadableNames.put("SPH-L900","Samsung Galaxy Note II");
humanReadableNames.put("SPH-M820-BST","Samsung Galaxy Prevail");
humanReadableNames.put("SPH-M830","Samsung Galaxy Rush");
humanReadableNames.put("SPH-M840","Samsung Galaxy Prevail 2");
humanReadableNames.put("SPH-M930BST","Samsung Transform Ultra");
humanReadableNames.put("ST21i","Sony Xperia Tipo");
humanReadableNames.put("ST25i","Sony Xperia U");
humanReadableNames.put("ST26i","Sony Xperia J");
humanReadableNames.put("Transformer_Prime_TF201","Asus Transformer Prime");
humanReadableNames.put("Transformer_TF101","Asus Transformer");
humanReadableNames.put("VM670","LG Optimus V");
humanReadableNames.put("VS840_4G","LG Lucid 4G");
humanReadableNames.put("VS870_4G","LG Lucid 2");
humanReadableNames.put("VS910_4G","LG Revolution 4G");
humanReadableNames.put("VS920_4G","LG Spectrum 4G");
humanReadableNames.put("VS930_4G","LG Spectrum 2");
humanReadableNames.put("VS980_4G","LG G2");
humanReadableNames.put("VS985_4G","LG G3 4G");
humanReadableNames.put("XT1022","Motorola Moto E");
humanReadableNames.put("XT1028","Motorola Moto G");
humanReadableNames.put("XT1030","Motorola Droid Mini");
humanReadableNames.put("XT1031","Motorola Moto G");
humanReadableNames.put("XT1032","Motorola Moto G");
humanReadableNames.put("XT1033","Motorola Moto G");
humanReadableNames.put("XT1034","Motorola Moto G");
humanReadableNames.put("XT1039","Motorola Moto G");
humanReadableNames.put("XT1045","Motorola Moto G");
humanReadableNames.put("XT1049","Motorola Moto X");
humanReadableNames.put("XT1053","Motorola Moto X");
humanReadableNames.put("XT1056","Motorola Moto X");
humanReadableNames.put("XT1058","Motorola Moto X");
humanReadableNames.put("XT1060","Motorola Moto X");
humanReadableNames.put("XT1068","Motorola Moto G");
humanReadableNames.put("XT1080","Motorola Droid Ultra");
humanReadableNames.put("XT1095","Motorola Moto X");
humanReadableNames.put("XT1096","Motorola Moto X");
humanReadableNames.put("XT1097","Motorola Moto X");
humanReadableNames.put("XT1254","Motorola Droid Turbo");
humanReadableNames.put("XT897","Motorola Photo Q");
humanReadableNames.put("XT907","Motorola Droid Razr M");
humanReadableNames.put("Xoom","Motorola Xoom");
humanReadableNames.put("Z970","ZTE ZMax");
humanReadableNames.put("bq_Aquaris_5","bq Aquaris 5");
humanReadableNames.put("bq_Aquaris_5_HD","bq Aquaris 5 HD");
humanReadableNames.put("google_sdk","Android Emulator");
humanReadableNames.put("myTouch_4G_Slide","HTC myTouch 4G Slide");
humanReadableNames.put("5860E", "Coolpad Quattro 4G");
humanReadableNames.put("831C", "HTC One M8");
humanReadableNames.put("9920", "Star Alps S9920");
humanReadableNames.put("A0001", "OnePlus One");
humanReadableNames.put("A1-810", "Acer Iconia A1-810");
humanReadableNames.put("ADR6300", "HTC Droid Incredible");
humanReadableNames.put("ADR6330VW", "HTC Rhyme");
humanReadableNames.put("ADR6350", "HTC Droid Incredible 2");
humanReadableNames.put("ADR6400L", "HTC Thunderbolt");
humanReadableNames.put("ADR6410LVW", "HTC Droid Incredible 4G");
humanReadableNames.put("ADR6425LVW", "HTC Rezound 4G");
humanReadableNames.put("ALCATEL_ONE_TOUCH_5035X", "Alcatel One Touch X Pop");
humanReadableNames.put("ALCATEL_ONE_TOUCH_7041X", "Alcatel One Touch Pop C7");
humanReadableNames.put("ASUS_T00J", "Asus ZenFone 5");
humanReadableNames.put("ASUS_Transformer_Pad_TF300T", "Asus Transformer Pad");
humanReadableNames.put("ASUS_Transformer_Pad_TF700T", "Asus Transformer Pad");
humanReadableNames.put("Aquaris_E4.5", "bq Aquaris E4.5");
humanReadableNames.put("C1905", "Sony Xperia M");
humanReadableNames.put("C2105", "Sony Xperia L");
humanReadableNames.put("C5155", "Kyocera Rise");
humanReadableNames.put("C5170", "Kyocera Hydro");
humanReadableNames.put("C5302", "Xperia SP");
humanReadableNames.put("C5303", "Sony Xperia SP");
humanReadableNames.put("C5306", "Xperia SP");
humanReadableNames.put("C6603", "Sony Xperia Z");
humanReadableNames.put("C6606", "Sony Xperia Z");
humanReadableNames.put("C6833", "Sony Xperia Z Ultra");
humanReadableNames.put("C6903", "Sony Xperia Z1");
humanReadableNames.put("C6916", "Sony Xperia Z1S");
humanReadableNames.put("CM990", "Huawei Evolution III");
humanReadableNames.put("CUBOT_ONE", "Cubot One");
humanReadableNames.put("D2005", "Sony Xperia E1");
humanReadableNames.put("D2302", "Xperia M2");
humanReadableNames.put("D2303", "Sony Xperia M2");
humanReadableNames.put("D2305", "Xperia M2");
humanReadableNames.put("D2306", "Xperia M2");
humanReadableNames.put("D2316", "Xperia M2");
humanReadableNames.put("D5503", "Sony Xperia Z1");
humanReadableNames.put("D5803", "Sony Xperia Z3 Compact");
humanReadableNames.put("D5833", "Xperia Z3 Compact");
humanReadableNames.put("D6503", "Sony Xperia Z2");
humanReadableNames.put("D6603", "Sony Xperia Z3");
humanReadableNames.put("D6653", "Sony Xperia Z3");
humanReadableNames.put("DROID2", "Motorola Droid 2");
humanReadableNames.put("DROID2_GLOBAL", "Motorola Droid 2 Global");
humanReadableNames.put("DROID3", "Motorola Droid 3");
humanReadableNames.put("DROID4", "Motorola Droid 4");
humanReadableNames.put("DROIDX", "Motorola Droid X");
humanReadableNames.put("DROID_BIONIC", "Motorola Droid Bionic");
humanReadableNames.put("DROID_Pro", "Motorola Droid Pro");
humanReadableNames.put("DROID_RAZR", "Motorola Droid Razr");
humanReadableNames.put("DROID_RAZR_HD", "Motorola Droid Razr HD");
humanReadableNames.put("DROID_X2", "Motorola Droid X2");
humanReadableNames.put("Desire_HD", "HTC Desire HD");
humanReadableNames.put("Droid", "Motorola Droid");
humanReadableNames.put("EVO", "HTC Evo");
humanReadableNames.put("GT-I8160", "Samsung Galaxy Ace 2");
humanReadableNames.put("GT-I8190", "Samsung Galaxy S III Mini");
humanReadableNames.put("GT-I8190L", "Samsung Galaxy S3 Mini");
humanReadableNames.put("GT-I8190N", "Samsung Galaxy S III Mini");
humanReadableNames.put("GT-I8260", "Samsung Galaxy Core");
humanReadableNames.put("GT-I8262", "Samsung Galaxy Core");
humanReadableNames.put("GT-I8550L", "Samsung Galaxy Win");
humanReadableNames.put("GT-I9000", "Samsung Galaxy S");
humanReadableNames.put("GT-I9001", "Samsung Galaxy S Plus");
humanReadableNames.put("GT-I9060", "Samsung Galaxy Grand Neo");
humanReadableNames.put("GT-I9063T", "Samsung Galaxy Grand Neo Duos");
humanReadableNames.put("GT-I9070", "Samsung Galaxy S Advance");
humanReadableNames.put("GT-I9082", "Samsung Galaxy Grand");
humanReadableNames.put("GT-I9100", "Samsung Galaxy S II");
humanReadableNames.put("GT-I9100M", "Samsung Galaxy S II");
humanReadableNames.put("GT-I9100P", "Samsung Galaxy S II");
humanReadableNames.put("GT-I9100T", "Samsung Galaxy S II");
humanReadableNames.put("GT-I9105P", "Samsung Galaxy S2 Plus");
humanReadableNames.put("GT-I9190", "Samsung Galaxy S4 Mini");
humanReadableNames.put("GT-I9192", "Samsung Galaxy S4 Mini Duos");
humanReadableNames.put("GT-I9195", "Samsung Galaxy S4 Mini");
humanReadableNames.put("GT-I9197", "Galaxy S4 Mini");
humanReadableNames.put("GT-I9198", "Galaxy S4 Mini");
humanReadableNames.put("GT-I9210", "Galaxy S2");
humanReadableNames.put("GT-I9295", "Samsung Galaxy S4 Active");
humanReadableNames.put("GT-I9300", "Samsung Galaxy S III");
humanReadableNames.put("GT-I9300T", "Samsung Galaxy S III");
humanReadableNames.put("GT-I9305", "Samsung Galaxy S III");
humanReadableNames.put("GT-I9305T", "Samsung Galaxy S III");
humanReadableNames.put("GT-I9500", "Samsung Galaxy S4");
humanReadableNames.put("GT-I9505", "Samsung Galaxy S4");
humanReadableNames.put("GT-I9506", "Samsung Galaxy S4");
humanReadableNames.put("GT-I9507", "Samsung Galaxy S4");
humanReadableNames.put("GT-N5110", "Samsung Galaxy Note 8.0");
humanReadableNames.put("GT-N7000", "Samsung Galaxy Note");
humanReadableNames.put("GT-N7100", "Samsung Galaxy Note II");
humanReadableNames.put("GT-N7105", "Samsung Galaxy Note II");
humanReadableNames.put("GT-N7105T", "Samsung Galaxy Note II");
humanReadableNames.put("GT-N8000", "Samsung Galaxy Note 10.1");
humanReadableNames.put("GT-N8010", "Samsung Galaxy Note 10.1");
humanReadableNames.put("GT-N8013", "Samsung Galaxy Note 10.1");
humanReadableNames.put("GT-P3100", "Samsung Galaxy Tab 2");
humanReadableNames.put("GT-P3110", "Samsung Galaxy Tab 2");
humanReadableNames.put("GT-P3113", "Samsung Galaxy Tab 2 7.0");
humanReadableNames.put("GT-P5110", "Samsung Galaxy Tab 2");
humanReadableNames.put("GT-P5113", "Samsnung Galaxy Tab 2 10.1");
humanReadableNames.put("GT-P5210", "Samsung Galaxy Tab 3 10.1");
humanReadableNames.put("GT-P7510", "Samsung Galaxy Tab 10.1");
humanReadableNames.put("GT-S5301L", "Samsung Galaxy Pocket Plus");
humanReadableNames.put("GT-S5360", "Samsung Galaxy Y");
humanReadableNames.put("GT-S5570", "Samsung Galaxy Mini");
humanReadableNames.put("GT-S5830", "Samsung Galaxy Ace");
humanReadableNames.put("GT-S5830i", "Samsung Galaxy Ace");
humanReadableNames.put("GT-S6310", "Samsung Galaxy Young");
humanReadableNames.put("GT-S6310N", "Samsung Galaxy Young");
humanReadableNames.put("GT-S6810P", "Samsung Galaxy Fame");
humanReadableNames.put("GT-S7560M", "Samsung Galaxy Ace II X");
humanReadableNames.put("GT-S7562", "Samsung Galaxy S Duos");
humanReadableNames.put("GT-S7580", "Samsung Galaxy Trend Plus");
humanReadableNames.put("Galaxy_Nexus", "Samsung Galaxy Nexus");
humanReadableNames.put("HM_1SW", "Xiaomi Redmi");
humanReadableNames.put("HTC6435LVW", "HTC Droid DNA");
humanReadableNames.put("HTC6500LVW", "HTC One");
humanReadableNames.put("HTC6525LVW", "HTC One M8");
humanReadableNames.put("HTCEVODesign4G", "HTC Evo Design 4G");
humanReadableNames.put("HTCEVOV4G", "HTC Evo V 4G");
humanReadableNames.put("HTCONE", "HTC One");
humanReadableNames.put("HTC_Desire_500", "HTC Desire 500");
humanReadableNames.put("HTC_Desire_HD_A9191", "HTC Desire HD");
humanReadableNames.put("HTC_One_mini", "HTC One mini");
humanReadableNames.put("HTC_PH39100", "HTC Vivid 4G");
humanReadableNames.put("HTC_PN071", "HTC One");
humanReadableNames.put("HTC_Sensation_Z710e", "HTC Sensation");
humanReadableNames.put("HTC_Sensation_4G", "HTC Sensation");
humanReadableNames.put("HTC_VLE_U", "HTC One S");
humanReadableNames.put("HUAWEI_G510-0251", "Huawei Ascend G510");
humanReadableNames.put("HUAWEI_P6-U06", "Huawei Ascend P6");
humanReadableNames.put("HUAWEI_Y300-0100", "Huawei Ascend Y300");
humanReadableNames.put("ISW11SC", "Galaxy S2");
humanReadableNames.put("KFJWA", "Kindle Fire HD 8.9");
humanReadableNames.put("KFJWI", "Kindle Fire HD 8.9");
humanReadableNames.put("KFOT", "Kindle Fire");
humanReadableNames.put("KFTT", "Kindle Fire HD 7");
humanReadableNames.put("L-01F", "G2");
humanReadableNames.put("LG-C800", "LG myTouch Q");
humanReadableNames.put("LG-D415", "LG Optimus L90");
humanReadableNames.put("LG-D620", "LG G2 Mini");
humanReadableNames.put("LG-D686", "LG G Pro Lite Dual");
humanReadableNames.put("LG-D800", "LG G2");
humanReadableNames.put("LG-D801", "LG G2");
humanReadableNames.put("LG-D802", "LG G2");
humanReadableNames.put("LG-D803", "G2");
humanReadableNames.put("LG-D805", "G2");
humanReadableNames.put("LG-D850", "LG G3");
humanReadableNames.put("LG-D851", "LG G3");
humanReadableNames.put("LG-D852", "G3");
humanReadableNames.put("LG-D855", "LG G3");
humanReadableNames.put("LG-E411g", "LG Optimus L1 II");
humanReadableNames.put("LG-E425g", "LG Optimus L3 II");
humanReadableNames.put("LG-E440g", "LG Optimus L4 II");
humanReadableNames.put("LG-E460", "LG Optimus L5 II");
humanReadableNames.put("LG-E610", "LG Optimus L5");
humanReadableNames.put("LG-E612g", "LG Optimus L5 Dual");
humanReadableNames.put("LG-E739", "LG MyTouch e739");
humanReadableNames.put("LG-E970", "LG Optimus G");
humanReadableNames.put("LG-E971", "Optimus G");
humanReadableNames.put("LG-E980", "LG Optimus G Pro");
humanReadableNames.put("LG-H815", "G4");
humanReadableNames.put("LG-LG730", "LG Venice");
humanReadableNames.put("LG-LS720", "LG Optimus F3");
humanReadableNames.put("LG-LS840", "LG Viper");
humanReadableNames.put("LG-LS970", "LG Optimus G");
humanReadableNames.put("LG-LS980", "LG G2");
humanReadableNames.put("LG-MS770", "LG Motion 4G");
humanReadableNames.put("LG-MS910", "LG Esteem");
humanReadableNames.put("LG-P509", "LG Optimus T");
humanReadableNames.put("LG-P760", "LG Optimus L9");
humanReadableNames.put("LG-P768", "LG Optimus L9");
humanReadableNames.put("LG-P769", "LG Optimus L9");
humanReadableNames.put("LG-P999", "LG G2X P999");
humanReadableNames.put("LG-VM696", "LG Optimus Elite");
humanReadableNames.put("LGL34C", "LG Optimus Fuel");
humanReadableNames.put("LGL55C", "LG LGL55C");
humanReadableNames.put("LGLS740", "LG Volt");
humanReadableNames.put("LGLS990", "LG G3");
humanReadableNames.put("LGMS323", "LG Optimus L70");
humanReadableNames.put("LGMS500", "LG Optimus F6");
humanReadableNames.put("LGMS769", "LG Optimus L9");
humanReadableNames.put("LS670", "LG Optimus S");
humanReadableNames.put("LT22i", "Sony Xperia P");
humanReadableNames.put("LT25i", "Sony Xperia V");
humanReadableNames.put("LT26i", "Sony Xperia S");
humanReadableNames.put("LT30p", "Sony Xperia T");
humanReadableNames.put("MB855", "Motorola Photon 4G");
humanReadableNames.put("MB860", "Motorola Atrix 4G");
humanReadableNames.put("MB865", "Motorola Atrix 2");
humanReadableNames.put("MB886", "Motorola Atrix HD");
humanReadableNames.put("ME173X", "Asus MeMO Pad HD 7");
humanReadableNames.put("MI_3W", "Xiaomi Mi 3");
humanReadableNames.put("MOTWX435KT", "Motorola Triumph");
humanReadableNames.put("N3", "Star NO.1 N3");
humanReadableNames.put("N860", "ZTE Warp N860");
humanReadableNames.put("NEXUS_4", "Nexus 4");
humanReadableNames.put("NEXUS_5", "Nexus 5");
humanReadableNames.put("NEXUS_5X", "Nexus 5X");
humanReadableNames.put("LG-D820", "Nexus 5");
humanReadableNames.put("LG-D821", "Nexus 5");
humanReadableNames.put("NEXUS_6", "Nexus 6");
humanReadableNames.put("NEXUS_6P", "Nexus 6P");
humanReadableNames.put("Nexus_10", "Google Nexus 10");
humanReadableNames.put("Nexus_4", "Google Nexus 4");
humanReadableNames.put("Nexus_7", "Asus Nexus 7");
humanReadableNames.put("Nexus_S", "Samsung Nexus S");
humanReadableNames.put("Nexus_S_4G", "Samsung Nexus S 4G");
humanReadableNames.put("Orange_Daytona", "Huawei Ascend G510");
humanReadableNames.put("PC36100", "HTC Evo 4G");
humanReadableNames.put("PG06100", "HTC EVO Shift 4G");
humanReadableNames.put("PG86100", "HTC Evo 3D");
humanReadableNames.put("PH44100", "HTC Evo Design 4G");
humanReadableNames.put("PantechP9070", "Pantech Burst");
humanReadableNames.put("QMV7A", "Verizon Ellipsis 7");
humanReadableNames.put("SAMSUNG-SGH-I317", "Samsung Galaxy Note II");
humanReadableNames.put("SAMSUNG-SGH-I337", "Samsung Galaxy S4");
humanReadableNames.put("SAMSUNG-SGH-I527", "Samsung Galaxy Mega");
humanReadableNames.put("SAMSUNG-SGH-I537", "Samsung Galaxy S4 Active");
humanReadableNames.put("SAMSUNG-SGH-I717", "Samsung Galaxy Note");
humanReadableNames.put("SAMSUNG-SGH-I727", "Samsung Skyrocket");
humanReadableNames.put("SAMSUNG-SGH-I747", "Samsung Galaxy S III");
humanReadableNames.put("SAMSUNG-SGH-I777", "Samsung Galaxy S II");
humanReadableNames.put("SAMSUNG-SGH-I897", "Samsung Captivate");
humanReadableNames.put("SAMSUNG-SGH-I927", "Samsung Captivate Glide");
humanReadableNames.put("SAMSUNG-SGH-I997", "Samsung Infuse 4G");
humanReadableNames.put("SAMSUNG-SM-G730A", "Samsung Galaxy S3 Mini");
humanReadableNames.put("SAMSUNG-SM-G870A", "Samsung Galaxy S5 Active");
humanReadableNames.put("SAMSUNG-SM-G900A", "Samsung Galaxy S5");
humanReadableNames.put("SAMSUNG-SM-G920A", "Samsung Galaxy S6");
humanReadableNames.put("SAMSUNG-SM-N900A", "Samsung Galaxy Note 3");
humanReadableNames.put("SAMSUNG-SM-N910A", "Samsung Galaxy Note 4");
humanReadableNames.put("SC-02C", "Galaxy S2");
humanReadableNames.put("SC-03E", "Galaxy S3");
humanReadableNames.put("SC-04E", "Galaxy S4");
humanReadableNames.put("SC-06D", "Galaxy S3");
humanReadableNames.put("SCH-I200", "Samsung Galaxy Stellar");
humanReadableNames.put("SCH-I337", "Galaxy S4");
humanReadableNames.put("SCH-I405", "Samsung Stratosphere");
humanReadableNames.put("SCH-I415", "Samsung Galaxy Stratosphere II");
humanReadableNames.put("SCH-I435", "Samsung Galaxy S4 Mini");
humanReadableNames.put("SCH-I500", "Samsung Fascinate");
humanReadableNames.put("SCH-I510", "Samsung Droid Charge");
humanReadableNames.put("SCH-I535", "Samsung Galaxy S III");
humanReadableNames.put("SCH-I545", "Samsung Galaxy S4");
humanReadableNames.put("SCH-I605", "Samsung Galaxy Note II");
humanReadableNames.put("SCH-I800", "Samsung Galaxy Tab 7.0");
humanReadableNames.put("SCH-I939", "Galaxy S3");
humanReadableNames.put("SCH-I959", "Galaxy S4");
humanReadableNames.put("SCH-J021", "Galaxy S3");
humanReadableNames.put("SCH-R530C", "Samsung Galaxy S3");
humanReadableNames.put("SCH-R530M", "Samsung Galaxy S III");
humanReadableNames.put("SCH-R530U", "Samsung Galaxy S III");
humanReadableNames.put("SCH-R720", "Samsung Admire");
humanReadableNames.put("SCH-R760", "Galaxy S2");
humanReadableNames.put("SCH-R970", "Samsung Galaxy S4");
humanReadableNames.put("SCH-S720C", "Samsung Proclaim");
humanReadableNames.put("SCH-S738C", "Samsung Galaxy Centura");
humanReadableNames.put("SCH-S968C", "Samsung Galaxy S III");
humanReadableNames.put("SCL21", "Galaxy S3");
humanReadableNames.put("SGH-I257M", "Samsung Galaxy S4 Mini");
humanReadableNames.put("SGH-I317M", "Samsung Galaxy Note II");
humanReadableNames.put("SGH-I337M", "Samsung Galaxy S4");
humanReadableNames.put("SGH-I727R", "Samsung Galaxy S II");
humanReadableNames.put("SGH-I747M", "Samsung Galaxy S III");
humanReadableNames.put("SGH-I757M", "Galaxy S2");
humanReadableNames.put("SGH-I777M", "Galaxy S2");
humanReadableNames.put("SGH-M919", "Samsung Galaxy S4");
humanReadableNames.put("SGH-M919N", "Samsung Galaxy S4");
humanReadableNames.put("SGH-N035", "Galaxy S3");
humanReadableNames.put("SGH-N045", "Galaxy S4");
humanReadableNames.put("SGH-N064", "Galaxy S3");
humanReadableNames.put("SGH-T399", "Samsung Galaxy Light");
humanReadableNames.put("SGH-T399N", "Samsung Galaxy Light");
humanReadableNames.put("SGH-T599N", "Samsung Galaxy Exhibit");
humanReadableNames.put("SGH-T679", "Samsung Exhibit II");
humanReadableNames.put("SGH-T769", "Samsung Galaxy S Blaze");
humanReadableNames.put("SGH-T889", "Samsung Galaxy Note II");
humanReadableNames.put("SGH-T959", "Samsung Galaxy S Vibrant");
humanReadableNames.put("SGH-T959V", "Samsung Galaxy S 4G");
humanReadableNames.put("SGH-T989", "Samsung Galaxy S II");
humanReadableNames.put("SGH-T989D", "Samsung Galaxy S II");
humanReadableNames.put("SGH-T999", "Samsung Galaxy S III");
humanReadableNames.put("SGH-T999L", "Samsung Galaxy S III");
humanReadableNames.put("SGH-T999V", "Samsung Galaxy S III");
humanReadableNames.put("SGP312", "Sony Xperia Tablet Z");
humanReadableNames.put("SHV-E210K", "Samsung Galaxy S3");
humanReadableNames.put("SHV-E210S", "Samsung Galaxy S III");
humanReadableNames.put("SHV-E250K", "Samsung Galaxy Note 2");
humanReadableNames.put("SHV-E250S", "Samsung Galaxy Note II");
humanReadableNames.put("SHV-E300", "Galaxy S4");
humanReadableNames.put("SHW-M250", "Galaxy S2");
humanReadableNames.put("SM-G3815", "Samsung Galaxy Express II");
humanReadableNames.put("SM-G386T", "Samsung Galaxy Avant");
humanReadableNames.put("SM-G386T1", "Samsung Galaxy Avant");
humanReadableNames.put("SM-G7102", "Samsung Galaxy Grand II");
humanReadableNames.put("SM-G800F", "Samsung Galaxy S5 Mini");
humanReadableNames.put("SM-G860P", "Samsung Galaxy S5 Sport");
humanReadableNames.put("SM-G900F", "Samsung Galaxy S5");
humanReadableNames.put("SM-G900H", "Samsung Galaxy S5");
humanReadableNames.put("SM-G900I", "Samsung Galaxy S5");
humanReadableNames.put("SM-G900P", "Samsung Galaxy S5");
humanReadableNames.put("SM-G900R4", "Galaxy S5");
humanReadableNames.put("SM-G900RZWAUSC", "Galaxy S5");
humanReadableNames.put("SM-G900T", "Samsung Galaxy S5");
humanReadableNames.put("SM-G900V", "Samsung Galaxy S5");
humanReadableNames.put("SM-G900W8", "Samsung Galaxy S5");
humanReadableNames.put("SM-G9200", "Galaxy S6");
humanReadableNames.put("SM-G920F", "Galaxy S6");
humanReadableNames.put("SM-G920I", "Galaxy S6");
humanReadableNames.put("SM-G920P", "Samsung Galaxy S6");
humanReadableNames.put("SM-G920R", "Galaxy S6");
humanReadableNames.put("SM-G920T", "Samsung Galaxy S6");
humanReadableNames.put("SM-G920V", "Samsung Galaxy S6");
humanReadableNames.put("SM-G920W8", "Galaxy S6");
humanReadableNames.put("SM-G9250", "Galaxy S6 Edge");
humanReadableNames.put("SM-G925A", "Galaxy S6 Edge");
humanReadableNames.put("SM-G925F", "Galaxy S6 Edge");
humanReadableNames.put("SM-G925P", "Galaxy S6 Edge");
humanReadableNames.put("SM-G925R", "Galaxy S6 Edge");
humanReadableNames.put("SM-G925T", "Galaxy S6 Edge");
humanReadableNames.put("SM-G925V", "Galaxy S6 Edge");
humanReadableNames.put("SM-G925W8", "Galaxy S6 Edge");
humanReadableNames.put("SM-N7505", "Samsung Galaxy Note 3 Neo");
humanReadableNames.put("SM-N900", "Samsung Galaxy Note 3");
humanReadableNames.put("SM-N9005", "Samsung Galaxy Note 3");
humanReadableNames.put("SM-N9006", "Samsung Galaxy Note 3");
humanReadableNames.put("SM-N900P", "Samsung Galaxy Note 3");
humanReadableNames.put("SM-N900T", "Samsung Galaxy Note 3");
humanReadableNames.put("SM-N900V", "Samsung Galaxy Note 3");
humanReadableNames.put("SM-N900W8", "Samsung Galaxy Note 3");
humanReadableNames.put("SM-N910C", "Samsung Galaxy Note 4");
humanReadableNames.put("SM-N910F", "Samsung Galaxy Note 4");
humanReadableNames.put("SM-N910G", "Samsung Galaxy Note 4");
humanReadableNames.put("SM-N910P", "Samsung Galaxy Note 4");
humanReadableNames.put("SM-N910T", "Samsung Galaxy Note 4");
humanReadableNames.put("SM-N910V", "Samsung Galaxy Note 4");
humanReadableNames.put("SM-N910W8", "Samsung Galaxy Note 4");
humanReadableNames.put("SM-P600", "Samsung Galaxy Note 10.1");
humanReadableNames.put("SM-T210R", "Samsung Galaxy Tab 3 7.0");
humanReadableNames.put("SM-T217S", "Samsung Galaxy Tab 3 7.0");
humanReadableNames.put("SM-T230NU", "Samsung Galaxy Tab 4");
humanReadableNames.put("SM-T310", "Samsung Galaxy Tab 3 8.0");
humanReadableNames.put("SM-T530NU", "Samsung Galaxy Tab 4 10.1");
humanReadableNames.put("SM-T800", "Samsung Galaxy Tab S 10.5");
humanReadableNames.put("SPH-D600", "Samsung Conquer 4G");
humanReadableNames.put("SPH-D700", "Samsung Epic 4G");
humanReadableNames.put("SPH-D710", "Samsung Epic");
humanReadableNames.put("SPH-D710BST", "Samsung Galaxy S II");
humanReadableNames.put("SPH-D710VMUB", "Samsung Galaxy S II");
humanReadableNames.put("SPH-L300", "Samsung Galaxy Victory");
humanReadableNames.put("SPH-L520", "Samsung Galaxy S4 Mini");
humanReadableNames.put("SPH-L710", "Samsung Galaxy S III");
humanReadableNames.put("SPH-L710T", "Samsung Galaxy S III");
humanReadableNames.put("SPH-L720", "Samsung Galaxy S4");
humanReadableNames.put("SPH-L720T", "Samsung Galaxy S4");
humanReadableNames.put("SPH-L900", "Samsung Galaxy Note II");
humanReadableNames.put("SPH-M820-BST", "Samsung Galaxy Prevail");
humanReadableNames.put("SPH-M830", "Samsung Galaxy Rush");
humanReadableNames.put("SPH-M840", "Samsung Galaxy Prevail 2");
humanReadableNames.put("SPH-M930BST", "Samsung Transform Ultra");
humanReadableNames.put("ST21i", "Sony Xperia Tipo");
humanReadableNames.put("ST25i", "Sony Xperia U");
humanReadableNames.put("ST26i", "Sony Xperia J");
humanReadableNames.put("Transformer_Prime_TF201", "Asus Transformer Prime");
humanReadableNames.put("Transformer_TF101", "Asus Transformer");
humanReadableNames.put("VM670", "LG Optimus V");
humanReadableNames.put("VS840_4G", "LG Lucid 4G");
humanReadableNames.put("VS870_4G", "LG Lucid 2");
humanReadableNames.put("VS910_4G", "LG Revolution 4G");
humanReadableNames.put("VS920_4G", "LG Spectrum 4G");
humanReadableNames.put("VS930_4G", "LG Spectrum 2");
humanReadableNames.put("VS980_4G", "LG G2");
humanReadableNames.put("VS985_4G", "LG G3 4G");
humanReadableNames.put("XT1022", "Motorola Moto E");
humanReadableNames.put("XT1028", "Motorola Moto G");
humanReadableNames.put("XT1030", "Motorola Droid Mini");
humanReadableNames.put("XT1031", "Motorola Moto G");
humanReadableNames.put("XT1032", "Motorola Moto G");
humanReadableNames.put("XT1033", "Motorola Moto G");
humanReadableNames.put("XT1034", "Motorola Moto G");
humanReadableNames.put("XT1039", "Motorola Moto G");
humanReadableNames.put("XT1045", "Motorola Moto G");
humanReadableNames.put("XT1049", "Motorola Moto X");
humanReadableNames.put("XT1053", "Motorola Moto X");
humanReadableNames.put("XT1056", "Motorola Moto X");
humanReadableNames.put("XT1058", "Motorola Moto X");
humanReadableNames.put("XT1060", "Motorola Moto X");
humanReadableNames.put("XT1068", "Motorola Moto G");
humanReadableNames.put("XT1080", "Motorola Droid Ultra");
humanReadableNames.put("XT1095", "Motorola Moto X");
humanReadableNames.put("XT1096", "Motorola Moto X");
humanReadableNames.put("XT1097", "Motorola Moto X");
humanReadableNames.put("XT1254", "Motorola Droid Turbo");
humanReadableNames.put("XT897", "Motorola Photo Q");
humanReadableNames.put("XT907", "Motorola Droid Razr M");
humanReadableNames.put("Xoom", "Motorola Xoom");
humanReadableNames.put("Z970", "ZTE ZMax");
humanReadableNames.put("bq_Aquaris_5", "bq Aquaris 5");
humanReadableNames.put("bq_Aquaris_5_HD", "bq Aquaris 5 HD");
humanReadableNames.put("google_sdk", "Android Emulator");
humanReadableNames.put("myTouch_4G_Slide", "HTC myTouch 4G Slide");
}
@@ -481,11 +482,11 @@ public class DeviceHelper {
}
//It returns getAndroidDeviceName() if no user-defined name has been set with setDeviceName().
public static String getDeviceName(Context context){
public static String getDeviceName(Context context) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
// Could use prefrences.contains but would need to check for empty String anyway.
String deviceName = preferences.getString(KEY_DEVICE_NAME_PREFERENCE, "");
if (deviceName.isEmpty()){
if (deviceName.isEmpty()) {
deviceName = DeviceHelper.getAndroidDeviceName();
Log.i("MainSettingsActivity", "New device name: " + deviceName);
preferences.edit().putString(KEY_DEVICE_NAME_PREFERENCE, deviceName).apply();
@@ -493,7 +494,7 @@ public class DeviceHelper {
return deviceName;
}
public static void setDeviceName(Context context, String name){
public static void setDeviceName(Context context, String name) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
preferences.edit().putString(KEY_DEVICE_NAME_PREFERENCE, name).apply();
}

View File

@@ -34,8 +34,9 @@ public class FilesHelper {
public static String getFileNameWithoutExt(String filename) {
int dot = filename.lastIndexOf(".");
return (dot < 0)? filename : filename.substring(0, dot);
return (dot < 0) ? filename : filename.substring(0, dot);
}
public static String getMimeTypeFromFile(String file) {
String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(getFileExt(file));
if (mime == null) mime = "*/*";
@@ -44,12 +45,12 @@ public class FilesHelper {
public static String findNonExistingNameForNewFile(String path, String filename) {
int dot = filename.lastIndexOf(".");
String name = (dot < 0)? filename : filename.substring(0, dot);
String ext = (dot < 0)? "" : filename.substring(filename.lastIndexOf("."));
String name = (dot < 0) ? filename : filename.substring(0, dot);
String ext = (dot < 0) ? "" : filename.substring(filename.lastIndexOf("."));
int num = 1;
while (new File(path+"/"+filename).exists()) {
filename = name+" ("+num+")"+ext;
while (new File(path + "/" + filename).exists()) {
filename = name + " (" + num + ")" + ext;
num++;
}
@@ -57,6 +58,7 @@ public class FilesHelper {
}
//Following code from http://activemq.apache.org/maven/5.7.0/kahadb/apidocs/src-html/org/apache/kahadb/util/IOHelper.html
/**
* Converts any string into a string that is safe to use as a file name.
* The result will only include ascii characters and numbers, and the "-","_", and "." characters.
@@ -70,7 +72,7 @@ public class FilesHelper {
valid = valid || (c >= 'A' && c <= 'Z');
valid = valid || (c >= '0' && c <= '9');
valid = valid || (c == '_') || (c == '-') || (c == '.');
valid = valid || (dirSeparators && ( (c == '/') || (c == '\\')));
valid = valid || (dirSeparators && ((c == '/') || (c == '\\')));
if (valid) {
rc.append(c);
@@ -78,13 +80,15 @@ public class FilesHelper {
}
String result = rc.toString();
if (result.length() > maxFileLength) {
result = result.substring(result.length()-maxFileLength,result.length());
result = result.substring(result.length() - maxFileLength, result.length());
}
return result;
}
public static String toFileSystemSafeName(String name, boolean dirSeparators) {
return toFileSystemSafeName(name, dirSeparators, 255);
}
public static String toFileSystemSafeName(String name) {
return toFileSystemSafeName(name, true, 255);
}
@@ -94,6 +98,6 @@ public class FilesHelper {
}
public static void LogOpenFileCount() {
Log.e("KDE/FileCount",""+GetOpenFileCount());
Log.e("KDE/FileCount", "" + GetOpenFileCount());
}
}

View File

@@ -27,9 +27,9 @@ import android.graphics.drawable.Drawable;
public class ImagesHelper {
public static Bitmap drawableToBitmap (Drawable drawable) {
public static Bitmap drawableToBitmap(Drawable drawable) {
if (drawable instanceof BitmapDrawable) {
return ((BitmapDrawable)drawable).getBitmap();
return ((BitmapDrawable) drawable).getBitmap();
}
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);

View File

@@ -32,7 +32,8 @@ public class NetworkHelper {
continue;
}
//Log.e(info.getTypeName(),""+info.isAvailable());
if (info.isAvailable()) return false; //We are connected to at least one non-mobile network
if (info.isAvailable())
return false; //We are connected to at least one non-mobile network
}
if (mobile) { //We suspect we are on a mobile net
try {
@@ -48,7 +49,7 @@ public class NetworkHelper {
e.printStackTrace();
}
}
} catch(Exception e) {
} catch (Exception e) {
e.printStackTrace();
Log.d("isOnMobileNetwork", "Something went wrong, but this is non-critical.");
}

View File

@@ -8,7 +8,7 @@ public class NotificationHelper {
public static void notifyCompat(NotificationManager notificationManager, int notificationId, Notification notification) {
try {
notificationManager.notify(notificationId, notification);
} catch(Exception e) {
} catch (Exception e) {
//4.1 will throw an exception about not having the VIBRATE permission, ignore it.
//https://android.googlesource.com/platform/frameworks/base/+/android-4.2.1_r1.2%5E%5E!/
}
@@ -17,7 +17,7 @@ public class NotificationHelper {
public static void notifyCompat(NotificationManager notificationManager, String tag, int notificationId, Notification notification) {
try {
notificationManager.notify(tag, notificationId, notification);
} catch(Exception e) {
} catch (Exception e) {
//4.1 will throw an exception about not having the VIBRATE permission, ignore it.
//https://android.googlesource.com/platform/frameworks/base/+/android-4.2.1_r1.2%5E%5E!/
}

View File

@@ -6,13 +6,13 @@ import java.security.SecureRandom;
public class RandomHelper {
public static SecureRandom secureRandom = new SecureRandom();
private static final char[] symbols = ("ABCDEFGHIJKLMNOPQRSTUVWXYZ"+
"abcdefghijklmnopqrstuvwxyz"+
"1234567890").toCharArray();
private static final char[] symbols = ("ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"abcdefghijklmnopqrstuvwxyz" +
"1234567890").toCharArray();
public static String randomString(int length) {
char[] buffer= new char[length];
char[] buffer = new char[length];
for (int idx = 0; idx < length; ++idx) {
buffer[idx] = symbols[secureRandom.nextInt(symbols.length)];
}

View File

@@ -76,8 +76,8 @@ public class RsaHelper {
try {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
byte[] publicKeyBytes = Base64.decode(settings.getString("publicKey", ""), 0);
return KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(publicKeyBytes));
} catch (Exception e) {
throw e;
}

View File

@@ -64,7 +64,7 @@ import javax.net.ssl.X509TrustManager;
public class SslHelper {
public enum SslMode{
public enum SslMode {
Client,
Server
}
@@ -73,14 +73,14 @@ public class SslHelper {
public static final BouncyCastleProvider BC = new BouncyCastleProvider();
public static void initialiseCertificate(Context context){
public static void initialiseCertificate(Context context) {
PrivateKey privateKey;
PublicKey publicKey;
try {
privateKey = RsaHelper.getPrivateKey(context);
publicKey = RsaHelper.getPublicKey(context);
}catch (Exception e){
} catch (Exception e) {
Log.e("SslHelper", "Error getting keys, can't create certificate");
return;
}
@@ -112,7 +112,7 @@ public class SslHelper {
edit.putString("certificate", Base64.encodeToString(certificate.getEncoded(), 0));
edit.apply();
} catch(Exception e) {
} catch (Exception e) {
e.printStackTrace();
Log.e("KDE/initialiseCert", "Exception");
}
@@ -144,7 +144,7 @@ public class SslHelper {
// Get remote device certificate if trusted
X509Certificate remoteDeviceCertificate = null;
if (isDeviceTrusted){
if (isDeviceTrusted) {
SharedPreferences devicePreferences = context.getSharedPreferences(deviceId, Context.MODE_PRIVATE);
byte[] certificateBytes = Base64.decode(devicePreferences.getString("certificate", ""), 0);
X509CertificateHolder certificateHolder = new X509CertificateHolder(certificateBytes);
@@ -156,7 +156,7 @@ public class SslHelper {
keyStore.load(null, null);
keyStore.setKeyEntry("key", privateKey, "".toCharArray(), new Certificate[]{certificate});
// Set certificate if device trusted
if (remoteDeviceCertificate != null){
if (remoteDeviceCertificate != null) {
keyStore.setCertificateEntry(deviceId, remoteDeviceCertificate);
}
@@ -170,7 +170,7 @@ public class SslHelper {
trustManagerFactory.init(keyStore);
// Setup custom trust manager if device not trusted
TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
@@ -189,7 +189,7 @@ public class SslHelper {
SSLContext tlsContext = SSLContext.getInstance("TLSv1"); //Newer TLS versions are only supported on API 16+
if (isDeviceTrusted) {
tlsContext.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), RandomHelper.secureRandom);
}else {
} else {
tlsContext.init(keyManagerFactory.getKeyManagers(), trustAllCerts, RandomHelper.secureRandom);
}
return tlsContext;
@@ -203,7 +203,7 @@ public class SslHelper {
public static void configureSslSocket(SSLSocket socket, boolean isDeviceTrusted, boolean isClient) {
socket.setEnabledProtocols(new String[]{ "TLSv1" }); //Newer TLS versions are only supported on API 16+
socket.setEnabledProtocols(new String[]{"TLSv1"}); //Newer TLS versions are only supported on API 16+
// These cipher suites are most common of them that are accepted by kde and android during handshake
ArrayList<String> supportedCiphers = new ArrayList<>();
@@ -223,9 +223,9 @@ public class SslHelper {
}
socket.setEnabledCipherSuites(supportedCiphers.toArray(new String[supportedCiphers.size()]));
if (isClient){
if (isClient) {
socket.setUseClientMode(true);
}else{
} else {
socket.setUseClientMode(false);
if (isDeviceTrusted) {
socket.setNeedClientAuth(true);
@@ -238,7 +238,7 @@ public class SslHelper {
public static SSLSocket convertToSslSocket(Context context, Socket socket, String deviceId, boolean isDeviceTrusted, boolean clientMode) throws IOException {
SSLSocketFactory sslsocketFactory = SslHelper.getSslContext(context, deviceId, isDeviceTrusted).getSocketFactory();
SSLSocket sslsocket = (SSLSocket)sslsocketFactory.createSocket(socket, socket.getInetAddress().getHostAddress(), socket.getPort(), true);
SSLSocket sslsocket = (SSLSocket) sslsocketFactory.createSocket(socket, socket.getInetAddress().getHostAddress(), socket.getPort(), true);
SslHelper.configureSslSocket(sslsocket, isDeviceTrusted, clientMode);
return sslsocket;
}
@@ -248,7 +248,7 @@ public class SslHelper {
byte[] hash = MessageDigest.getInstance("SHA-1").digest(certificate.getEncoded());
Formatter formatter = new Formatter();
int i;
for (i = 0; i < hash.length-1; i++) {
for (i = 0; i < hash.length - 1; i++) {
formatter.format("%02x:", hash[i]);
}
formatter.format("%02x", hash[i]);

View File

@@ -81,11 +81,11 @@ public class StorageHelper {
if (storage.exists() && storage.isDirectory()) {
String mounts = null;
try {
Scanner scanner = new Scanner( new File("/proc/mounts") );
Scanner scanner = new Scanner(new File("/proc/mounts"));
mounts = scanner.useDelimiter("\\A").next();
scanner.close();
//Log.e("Mounts",mounts);
} catch(Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
@@ -98,7 +98,7 @@ public class StorageHelper {
try {
//Log.e(dir.getAbsolutePath(), dir.getCanonicalPath());
path = dir.getCanonicalPath();
} catch(Exception e){
} catch (Exception e) {
path = path2;
}
if (!path.startsWith("/storage/emulated") || dirs.length == 1) {
@@ -120,7 +120,7 @@ public class StorageHelper {
try {
buf_reader = new BufferedReader(new FileReader("/proc/mounts"));
String entry;
while((entry = buf_reader.readLine()) != null) {
while ((entry = buf_reader.readLine()) != null) {
//Log.e("getStorageList", entry);
if (entry.contains("vfat") || entry.contains("exfat") || entry.contains("ntfs") || entry.contains("/mnt")) {
if (entry.contains("/storage/sdcard")) entries.add(0, entry);

View File

@@ -27,8 +27,7 @@ import android.net.ConnectivityManager;
import android.net.wifi.WifiManager;
import android.util.Log;
public class KdeConnectBroadcastReceiver extends BroadcastReceiver
{
public class KdeConnectBroadcastReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
@@ -37,7 +36,7 @@ public class KdeConnectBroadcastReceiver extends BroadcastReceiver
String action = intent.getAction();
switch(action) {
switch (action) {
case Intent.ACTION_PACKAGE_REPLACED:
Log.i("KdeConnect", "UpdateReceiver");
if (!intent.getData().getSchemeSpecificPart().equals(context.getPackageName())) {
@@ -81,12 +80,11 @@ public class KdeConnectBroadcastReceiver extends BroadcastReceiver
});
break;
default:
Log.i("BroadcastReceiver", "Ignoring broadcast event: "+intent.getAction());
Log.i("BroadcastReceiver", "Ignoring broadcast event: " + intent.getAction());
break;
}
}
}

View File

@@ -79,22 +79,85 @@ public class NetworkPackage {
}
//Most commons getters and setters defined for convenience
public String getString(String key) { return mBody.optString(key,""); }
public String getString(String key, String defaultValue) { return mBody.optString(key,defaultValue); }
public void set(String key, String value) { if (value == null) return; try { mBody.put(key,value); } catch(Exception e) { } }
public int getInt(String key) { return mBody.optInt(key,-1); }
public int getInt(String key, int defaultValue) { return mBody.optInt(key,defaultValue); }
public long getLong(String key) { return mBody.optLong(key,-1); }
public long getLong(String key,long defaultValue) { return mBody.optLong(key,defaultValue); }
public void set(String key, int value) { try { mBody.put(key,value); } catch(Exception e) { } }
public boolean getBoolean(String key) { return mBody.optBoolean(key,false); }
public boolean getBoolean(String key, boolean defaultValue) { return mBody.optBoolean(key,defaultValue); }
public void set(String key, boolean value) { try { mBody.put(key,value); } catch(Exception e) { } }
public double getDouble(String key) { return mBody.optDouble(key,Double.NaN); }
public double getDouble(String key, double defaultValue) { return mBody.optDouble(key,defaultValue); }
public void set(String key, double value) { try { mBody.put(key,value); } catch(Exception e) { } }
public JSONArray getJSONArray(String key) { return mBody.optJSONArray(key); }
public void set(String key, JSONArray value) { try { mBody.put(key,value); } catch(Exception e) { } }
public String getString(String key) {
return mBody.optString(key, "");
}
public String getString(String key, String defaultValue) {
return mBody.optString(key, defaultValue);
}
public void set(String key, String value) {
if (value == null) return;
try {
mBody.put(key, value);
} catch (Exception e) {
}
}
public int getInt(String key) {
return mBody.optInt(key, -1);
}
public int getInt(String key, int defaultValue) {
return mBody.optInt(key, defaultValue);
}
public long getLong(String key) {
return mBody.optLong(key, -1);
}
public long getLong(String key, long defaultValue) {
return mBody.optLong(key, defaultValue);
}
public void set(String key, int value) {
try {
mBody.put(key, value);
} catch (Exception e) {
}
}
public boolean getBoolean(String key) {
return mBody.optBoolean(key, false);
}
public boolean getBoolean(String key, boolean defaultValue) {
return mBody.optBoolean(key, defaultValue);
}
public void set(String key, boolean value) {
try {
mBody.put(key, value);
} catch (Exception e) {
}
}
public double getDouble(String key) {
return mBody.optDouble(key, Double.NaN);
}
public double getDouble(String key, double defaultValue) {
return mBody.optDouble(key, defaultValue);
}
public void set(String key, double value) {
try {
mBody.put(key, value);
} catch (Exception e) {
}
}
public JSONArray getJSONArray(String key) {
return mBody.optJSONArray(key);
}
public void set(String key, JSONArray value) {
try {
mBody.put(key, value);
} catch (Exception e) {
}
}
public Set<String> getStringSet(String key) {
JSONArray jsonArray = mBody.optJSONArray(key);
@@ -105,22 +168,26 @@ public class NetworkPackage {
try {
String str = jsonArray.getString(i);
list.add(str);
} catch(Exception e) { }
} catch (Exception e) {
}
}
return list;
}
public Set<String> getStringSet(String key, Set<String> defaultValue) {
if (mBody.has(key)) return getStringSet(key);
else return defaultValue;
}
public void set(String key, Set<String> value) {
try {
JSONArray jsonArray = new JSONArray();
for(String str : value) {
for (String str : value) {
jsonArray.put(str);
}
mBody.put(key,jsonArray);
} catch(Exception e) { }
mBody.put(key, jsonArray);
} catch (Exception e) {
}
}
public List<String> getStringList(String key) {
@@ -132,24 +199,31 @@ public class NetworkPackage {
try {
String str = jsonArray.getString(i);
list.add(str);
} catch(Exception e) { }
} catch (Exception e) {
}
}
return list;
}
public List<String> getStringList(String key, List<String> defaultValue) {
if (mBody.has(key)) return getStringList(key);
else return defaultValue;
}
public void set(String key, List<String> value) {
try {
JSONArray jsonArray = new JSONArray();
for(String str : value) {
for (String str : value) {
jsonArray.put(str);
}
mBody.put(key,jsonArray);
} catch(Exception e) { }
mBody.put(key, jsonArray);
} catch (Exception e) {
}
}
public boolean has(String key) {
return mBody.has(key);
}
public boolean has(String key) { return mBody.has(key); }
public String serialize() throws JSONException {
JSONObject jo = new JSONObject();
@@ -190,12 +264,12 @@ public class NetworkPackage {
np.mBody.put("deviceId", deviceId);
np.mBody.put("deviceName", DeviceHelper.getDeviceName(context));
np.mBody.put("protocolVersion", NetworkPackage.ProtocolVersion);
np.mBody.put("deviceType", DeviceHelper.isTablet()? "tablet" : "phone");
np.mBody.put("deviceType", DeviceHelper.isTablet() ? "tablet" : "phone");
np.mBody.put("incomingCapabilities", new JSONArray(PluginFactory.getIncomingCapabilities(context)));
np.mBody.put("outgoingCapabilities", new JSONArray(PluginFactory.getOutgoingCapabilities(context)));
} catch (Exception e) {
e.printStackTrace();
Log.e("NetworkPacakge","Exception on createIdentityPackage");
Log.e("NetworkPacakge", "Exception on createIdentityPackage");
}
return np;

View File

@@ -37,7 +37,7 @@ public class BatteryPlugin extends Plugin {
public final static String PACKAGE_TYPE_BATTERY_REQUEST = "kdeconnect.battery.request";
// keep these fields in sync with kdeconnect-kded:BatteryPlugin.h:ThresholdBatteryEvent
private static final int THRESHOLD_EVENT_NONE= 0;
private static final int THRESHOLD_EVENT_NONE = 0;
private static final int THRESHOLD_EVENT_BATTERY_LOW = 1;
private NetworkPackage batteryInfo = new NetworkPackage(PACKAGE_TYPE_BATTERY);
@@ -60,15 +60,15 @@ public class BatteryPlugin extends Plugin {
int scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, 1);
int plugged = batteryIntent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
int currentCharge = (level == -1)? batteryInfo.getInt("currentCharge") : level*100 / scale;
boolean isCharging = (plugged == -1)? batteryInfo.getBoolean("isCharging") : (0 != plugged);
int currentCharge = (level == -1) ? batteryInfo.getInt("currentCharge") : level * 100 / scale;
boolean isCharging = (plugged == -1) ? batteryInfo.getBoolean("isCharging") : (0 != plugged);
boolean lowBattery = Intent.ACTION_BATTERY_LOW.equals(batteryIntent.getAction());
int thresholdEvent = lowBattery? THRESHOLD_EVENT_BATTERY_LOW : THRESHOLD_EVENT_NONE;
int thresholdEvent = lowBattery ? THRESHOLD_EVENT_BATTERY_LOW : THRESHOLD_EVENT_NONE;
if (isCharging == batteryInfo.getBoolean("isCharging")
&& currentCharge == batteryInfo.getInt("currentCharge")
&& thresholdEvent == batteryInfo.getInt("thresholdEvent")
) {
&& currentCharge == batteryInfo.getInt("currentCharge")
&& thresholdEvent == batteryInfo.getInt("thresholdEvent")
) {
//Do not send again if nothing has changed

View File

@@ -36,6 +36,7 @@ public class ClipboardListener {
public interface ClipboardObserver {
void clipboardChanged(String content);
}
private HashSet<ClipboardObserver> observers = new HashSet<>();
private final Context context;
@@ -45,6 +46,7 @@ public class ClipboardListener {
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 @@ public class ClipboardListener {
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 @@ public class ClipboardListener {
@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);
}
}

View File

@@ -10,7 +10,8 @@ public class KeyInputConnection extends BaseInputConnection {
view = targetView;
}
@Override public boolean commitText(CharSequence text, int newCursorPosition) {
@Override
public boolean commitText(CharSequence text, int newCursorPosition) {
view.sendChars(text);
return true;
}

View File

@@ -33,16 +33,18 @@ import org.kde.kdeconnect.BackgroundService;
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 @@ public class KeyListenerView extends View {
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);

View File

@@ -62,11 +62,15 @@ public class MousePadActivity extends AppCompatActivity implements GestureDetect
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 @@ public class MousePadActivity extends AppCompatActivity implements GestureDetect
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 @@ public class MousePadActivity extends AppCompatActivity implements GestureDetect
doubleTapAction = ClickType.fromString(doubleTapSetting);
tripleTapAction = ClickType.fromString(tripleTapSetting);
switch (sensitivitySetting){
switch (sensitivitySetting) {
case "slowest":
mCurrentSensitivity = 0.2f;
break;
@@ -185,7 +189,7 @@ public class MousePadActivity extends AppCompatActivity implements GestureDetect
if (mMousePadGestureDetector.onTouchEvent(event)) {
return true;
}
if ( mDetector.onTouchEvent(event) ) {
if (mDetector.onTouchEvent(event)) {
return true;
}
@@ -240,8 +244,7 @@ public class MousePadActivity extends AppCompatActivity implements GestureDetect
}
@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 @@ public class MousePadActivity extends AppCompatActivity implements GestureDetect
isScrolling = true;
accumulatedDistanceY += distanceY;
if (accumulatedDistanceY > MinDistanceToSendScroll || accumulatedDistanceY < -MinDistanceToSendScroll)
{
if (accumulatedDistanceY > MinDistanceToSendScroll || accumulatedDistanceY < -MinDistanceToSendScroll) {
sendScroll(scrollDirection * accumulatedDistanceY);
accumulatedDistanceY = 0;
@@ -334,7 +336,7 @@ public class MousePadActivity extends AppCompatActivity implements GestureDetect
@Override
public boolean onTripleFingerTap(MotionEvent ev) {
switch(tripleTapAction){
switch (tripleTapAction) {
case RIGHT:
sendRightClick();
break;
@@ -348,7 +350,7 @@ public class MousePadActivity extends AppCompatActivity implements GestureDetect
@Override
public boolean onDoubleFingerTap(MotionEvent ev) {
switch(doubleTapAction){
switch (doubleTapAction) {
case RIGHT:
sendRightClick();
break;

View File

@@ -88,8 +88,8 @@ public class MousePadPlugin extends Plugin {
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 @@ public class MousePadPlugin extends Plugin {
device.sendPackage(np);
}
public void sendSingleHold(){
public void sendSingleHold() {
NetworkPackage np = new NetworkPackage(PACKAGE_TYPE_MOUSEPAD_REQUEST);
np.set("singlehold", true);
device.sendPackage(np);

View File

@@ -78,6 +78,7 @@ public final class AlbumArtCache {
/**
* 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,6 +100,7 @@ public final class AlbumArtCache {
/**
* Registers a mpris plugin, such that it gets notified of fetched album art
*
* @param mpris The mpris plugin
*/
public static void registerPlugin(MprisPlugin mpris) {
@@ -107,6 +109,7 @@ public final class AlbumArtCache {
/**
* Deregister a mpris plugin
*
* @param mpris The mpris plugin
*/
public static void deregisterPlugin(MprisPlugin mpris) {
@@ -192,6 +195,7 @@ public final class AlbumArtCache {
/**
* 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 @@ public final class AlbumArtCache {
/**
* 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,6 +237,7 @@ public final class AlbumArtCache {
/**
* Opens the http(s) connection
*
* @return True if succeeded
* @throws IOException
*/
@@ -240,7 +245,7 @@ public final class AlbumArtCache {
//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 @@ public final class AlbumArtCache {
--numFetching;
initiateFetch();
}
};
}
;
/**
* Does the actual fetching and makes sure only not too many fetches are running at the same time
@@ -357,6 +364,7 @@ public final class AlbumArtCache {
/**
* 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 @@ public final class AlbumArtCache {
/**
* 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

View File

@@ -58,7 +58,7 @@ public class MprisActivity extends AppCompatActivity {
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 @@ public class MprisActivity extends AppCompatActivity {
}
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 @@ public class MprisActivity extends AppCompatActivity {
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,7 +253,7 @@ public class MprisActivity extends AppCompatActivity {
/**
* 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) {
@@ -259,11 +261,11 @@ public class MprisActivity extends AppCompatActivity {
}
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 @@ public class MprisActivity extends AppCompatActivity {
}
});
((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 @@ public class MprisActivity extends AppCompatActivity {
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 @@ public class MprisActivity extends AppCompatActivity {
};
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

View File

@@ -42,20 +42,22 @@ import java.util.HashSet;
/**
* Controls the mpris media control notification
*
* <p>
* 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;
}
@@ -106,11 +108,12 @@ public class MprisMediaSession implements SharedPreferences.OnSharedPreferenceCh
/**
* Called by the mpris plugin when it wants media control notifications for its device
*
* <p>
* 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()) {
@@ -128,9 +131,10 @@ public class MprisMediaSession implements SharedPreferences.OnSharedPreferenceCh
/**
* Called when a device disconnects/does not want notifications anymore
*
* <p>
* 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) {
@@ -147,9 +151,10 @@ public class MprisMediaSession implements SharedPreferences.OnSharedPreferenceCh
/**
* Updates which device+player we're going to use in the notification
*
* <p>
* 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) {
@@ -208,176 +213,176 @@ public class MprisMediaSession implements SharedPreferences.OnSharedPreferenceCh
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);
//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 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 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 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);
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));
//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.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());
//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);
}
//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());
}
});
}

View File

@@ -92,7 +92,9 @@ public class MprisPlugin extends Plugin {
return volume;
}
public long getLength(){ return length; }
public long getLength() {
return length;
}
public boolean isPlaying() {
return playing;
@@ -124,6 +126,7 @@ public class MprisPlugin extends Plugin {
/**
* 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 @@ public class MprisPlugin extends Plugin {
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 class MprisPlugin extends Plugin {
public final static String PACKAGE_TYPE_MPRIS_REQUEST = "kdeconnect.mpris.request";
private HashMap<String, MprisPlayer> players = new HashMap<>();
private HashMap<String,Handler> playerStatusUpdated = new HashMap<>();
private HashMap<String, Handler> playerStatusUpdated = new HashMap<>();
private HashMap<String,Handler> playerListUpdated = new HashMap<>();
private HashMap<String, Handler> playerListUpdated = new HashMap<>();
@Override
public String getDisplayName() {
@@ -273,7 +276,7 @@ public class MprisPlugin extends Plugin {
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,15 @@ public class MprisPlugin extends Plugin {
//Turn the url into canonical form (and check its validity)
URL newAlbumArtUrl = new URL(newAlbumArtUrlstring);
playerStatus.albumArtUrl = newAlbumArtUrl.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 +342,9 @@ public class MprisPlugin extends Plugin {
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 +356,12 @@ public class MprisPlugin extends Plugin {
@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 +375,7 @@ public class MprisPlugin extends Plugin {
}
public void setPlayerListUpdatedHandler(String id, Handler h) {
playerListUpdated.put(id,h);
playerListUpdated.put(id, h);
h.dispatchMessage(new Message());
}
@@ -395,6 +400,7 @@ public class MprisPlugin extends Plugin {
/**
* Returns a playing mpris player, if any exist
*
* @return null if no players are playing, a playing player otherwise
*/
public MprisPlayer getPlayingPlayer() {
@@ -408,15 +414,15 @@ public class MprisPlugin extends Plugin {
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 +455,9 @@ public class MprisPlugin extends Plugin {
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);
}
}

View File

@@ -65,15 +65,15 @@ public class PingPlugin extends Plugin {
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

View File

@@ -75,6 +75,7 @@ public abstract class Plugin {
public String getPluginKey() {
return getPluginKey(this.getClass());
}
public static String getPluginKey(Class<? extends Plugin> p) {
return p.getSimpleName();
}
@@ -146,7 +147,8 @@ public abstract class Plugin {
/**
* 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
@@ -167,14 +169,17 @@ public abstract class Plugin {
* 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
@@ -221,8 +226,8 @@ public abstract class Plugin {
}
protected boolean arePermissionsGranted(String[] permissions) {
for(String permission: permissions){
if(!isPermissionGranted(permission)){
for (String permission : permissions) {
if (!isPermissionGranted(permission)) {
return false;
}
}
@@ -233,7 +238,7 @@ public abstract class Plugin {
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)
@@ -243,7 +248,7 @@ public abstract class Plugin {
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
@@ -262,19 +267,19 @@ public abstract class Plugin {
}
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() {

View File

@@ -79,7 +79,9 @@ public class PluginFactory {
return icon;
}
public boolean hasSettings() { return hasSettings; }
public boolean hasSettings() {
return hasSettings;
}
public boolean isEnabledByDefault() {
return enabledByDefault;
@@ -136,15 +138,15 @@ public class PluginFactory {
}
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 class PluginFactory {
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 @@ public class PluginFactory {
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 @@ public class PluginFactory {
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
}

View File

@@ -93,7 +93,10 @@ public class ReceiveNotificationsPlugin extends Plugin {
}
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) {

View File

@@ -52,17 +52,21 @@ public class RemoteKeyboardPlugin extends Plugin {
*/
private static ArrayList<RemoteKeyboardPlugin> instances = new ArrayList<RemoteKeyboardPlugin>();
private static ReentrantLock instancesLock = new ReentrantLock(true);
public static ArrayList<RemoteKeyboardPlugin> getInstances() {
return instances;
}
public static ArrayList<RemoteKeyboardPlugin> acquireInstances() {
instancesLock.lock();
return getInstances();
}
public static ArrayList<RemoteKeyboardPlugin> releaseInstances() {
instancesLock.unlock();
return getInstances();
}
public static boolean isConnected() {
return instances.size() > 0;
}
@@ -210,7 +214,7 @@ public class RemoteKeyboardPlugin extends Plugin {
return -1;
}
private Pair<Integer,Integer> currentSelection(ExtractedText extractedText) {
private Pair<Integer, Integer> currentSelection(ExtractedText extractedText) {
if (extractedText != null)
return new Pair<>(extractedText.selectionStart, extractedText.selectionEnd);
return new Pair<>(-1, -1);
@@ -235,12 +239,12 @@ public class RemoteKeyboardPlugin extends Plugin {
int startPos = pos;
int endPos = pos;
if (shift) { // Shift -> select word (otherwise jump)
Pair<Integer,Integer> sel = currentSelection(extractedText);
Pair<Integer, Integer> 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 @@ public class RemoteKeyboardPlugin extends Plugin {
int startPos = pos;
int endPos = pos;
if (shift) {
Pair<Integer,Integer> sel = currentSelection(extractedText);
Pair<Integer, Integer> 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 @@ public class RemoteKeyboardPlugin extends Plugin {
// 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++) {

View File

@@ -119,7 +119,7 @@ public class RemoteKeyboardService
visible = true;
ArrayList<RemoteKeyboardPlugin> instances = RemoteKeyboardPlugin.acquireInstances();
try {
for (RemoteKeyboardPlugin i: instances)
for (RemoteKeyboardPlugin i : instances)
i.notifyKeyboardState(true);
} finally {
RemoteKeyboardPlugin.releaseInstances();
@@ -133,7 +133,7 @@ public class RemoteKeyboardService
visible = false;
ArrayList<RemoteKeyboardPlugin> instances = RemoteKeyboardPlugin.acquireInstances();
try {
for (RemoteKeyboardPlugin i: instances)
for (RemoteKeyboardPlugin i : instances)
i.notifyKeyboardState(false);
} finally {
RemoteKeyboardPlugin.releaseInstances();

View File

@@ -53,7 +53,7 @@ public class RunCommandPlugin extends Plugin {
interface CommandsChangedCallback {
void update();
};
}
public ArrayList<JSONObject> getCommandList() {
return commandList;
@@ -88,7 +88,7 @@ public class RunCommandPlugin extends Plugin {
try {
JSONObject obj = new JSONObject(np.getString("commandList"));
Iterator<String> keys = obj.keys();
while(keys.hasNext()){
while (keys.hasNext()) {
String s = keys.next();
JSONObject o = obj.getJSONObject(s);
o.put("key", s);

View File

@@ -78,6 +78,7 @@ class SimpleSftpServer {
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 @@ class SimpleSftpServer {
sshd.setFileSystemFactory(new AndroidFileSystemFactory(context));
sshd.setCommandFactory(new ScpCommandFactory());
sshd.setSubsystemFactories(Collections.singletonList((NamedFactory<Command>)new SftpSubsystem.Factory()));
sshd.setSubsystemFactories(Collections.singletonList((NamedFactory<Command>) new SftpSubsystem.Factory()));
if (device.publicKey != null) {
keyAuth.deviceKey = device.publicKey;
@@ -105,12 +106,12 @@ class SimpleSftpServer {
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 @@ class SimpleSftpServer {
public String getLocalIpAddress() {
String ip6 = null;
try {
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) {
NetworkInterface intf = en.nextElement();
// Anything with rmnet is related to cellular connections or USB
@@ -156,13 +157,13 @@ class SimpleSftpServer {
// 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<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
for (Enumeration<InetAddress> 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;

View File

@@ -39,7 +39,7 @@ class NotificationUpdateCallback extends Device.SendPackageStatusCallback {
} 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)
@@ -47,7 +47,7 @@ class NotificationUpdateCallback extends Device.SendPackageStatusCallback {
.setContentTitle(title)
.setTicker(title);
notificationId = (int)System.currentTimeMillis();
notificationId = (int) System.currentTimeMillis();
numFiles = toSend.size();

View File

@@ -80,7 +80,10 @@ public class ShareActivity extends AppCompatActivity {
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() {
@@ -167,13 +170,13 @@ public class ShareActivity extends AppCompatActivity {
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);

View File

@@ -42,8 +42,8 @@ public class ShareChooserTargetService extends ChooserTargetService {
public List<ChooserTarget> onGetChooserTargets(ComponentName targetActivityName, IntentFilter matchedFilter) {
Log.d("DirectShare", "invoked");
final List<ChooserTarget> 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);

View File

@@ -72,7 +72,7 @@ public class ShareNotification {
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) {

View File

@@ -118,7 +118,7 @@ public class SharePlugin extends Plugin {
if (np.hasPayload()) {
Log.i("SharePlugin", "hasPayload");
if (isPermissionGranted(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
receiveFile(np);
} else {
@@ -401,7 +401,7 @@ public class SharePlugin extends Plugin {
}
}
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)) {

View File

@@ -95,7 +95,7 @@ public class ShareSettingsActivity extends PluginSettingsActivity {
}
try {
getDefaultDestinationDirectory().mkdirs();
} catch(Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
return DocumentFile.fromFile(getDefaultDestinationDirectory());
@@ -112,7 +112,7 @@ public class ShareSettingsActivity extends PluginSettingsActivity {
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());

View File

@@ -75,7 +75,7 @@ public class TelepathyPlugin extends Plugin {
int permissionCheck = ContextCompat.checkSelfPermission(context,
Manifest.permission.SEND_SMS);
if(permissionCheck == PackageManager.PERMISSION_GRANTED) {
if (permissionCheck == PackageManager.PERMISSION_GRANTED) {
SmsManager smsManager = SmsManager.getDefault();
ArrayList<String> parts = smsManager.divideMessage(sms);
@@ -83,7 +83,7 @@ public class TelepathyPlugin extends Plugin {
// 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){
} else if (permissionCheck == PackageManager.PERMISSION_DENIED) {
// TODO Request Permission SEND_SMS
}
//TODO: Notify other end

View File

@@ -303,7 +303,7 @@ public class TelephonyPlugin extends Plugin {
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;
}

View File

@@ -33,7 +33,7 @@ import org.kde.kdeconnect.BackgroundService;
/**
* A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls
* to be used with AppCompat.
*
* <p>
* This technique can be used with an {@link android.app.Activity} class, not just
* {@link android.preference.PreferenceActivity}.
*/

View File

@@ -45,7 +45,7 @@ import java.util.ArrayList;
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 @@ public class CustomDevicesActivity extends AppCompatActivity {
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 @@ public class CustomDevicesActivity extends AppCompatActivity {
}
});
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 @@ public class CustomDevicesActivity extends AppCompatActivity {
};
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 @@ public class CustomDevicesActivity extends AppCompatActivity {
}
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<String> 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 @@ public class CustomDevicesActivity extends AppCompatActivity {
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();

View File

@@ -442,7 +442,7 @@ public class DeviceFragment extends Fragment {
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 class DeviceFragment extends Fragment {
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 @@ public class DeviceFragment extends Fragment {
}
@Override
public PluginClickListener clone(){
public PluginClickListener clone() {
try {
return (PluginClickListener) super.clone();
} catch (CloneNotSupportedException e) {

View File

@@ -25,11 +25,11 @@ import android.view.View;
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) {

View File

@@ -28,8 +28,8 @@ import org.kde.kdeconnect_tp.R;
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;
@@ -37,15 +37,15 @@ public class EntryItem implements ListAdapter.Item {
}
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) {

View File

@@ -34,19 +34,19 @@ public class ListAdapter extends ArrayAdapter<ListAdapter.Item> {
View inflateView(LayoutInflater layoutInflater);
}
private final ArrayList<Item> items;
private final LayoutInflater layoutInflater;
private final ArrayList<Item> items;
private final LayoutInflater layoutInflater;
public ListAdapter(Context context, ArrayList<Item> items) {
super(context, 0, items);
public ListAdapter(Context context, ArrayList<Item> 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);
}

View File

@@ -57,7 +57,7 @@ public class PairingDeviceItem implements ListAdapter.Item {
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);

View File

@@ -30,23 +30,23 @@ import org.kde.kdeconnect_tp.R;
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);

View File

@@ -28,13 +28,13 @@ import org.kde.kdeconnect_tp.R;
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) {

View File

@@ -29,13 +29,13 @@ import org.kde.kdeconnect_tp.R;
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 class SmallEntryItem implements ListAdapter.Item {
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) {

View File

@@ -114,7 +114,7 @@ public class MaterialActivity extends AppCompatActivity {
} 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) {
@@ -126,7 +126,7 @@ public class MaterialActivity extends AppCompatActivity {
}
//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);
@@ -134,7 +134,7 @@ public class MaterialActivity extends AppCompatActivity {
//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();

View File

@@ -73,7 +73,6 @@ public class PairingFragment extends Fragment implements PairingDeviceItem.Callb
mActivity.getSupportActionBar().setTitle(R.string.pairing_title);
setHasOptionsMenu(true);
rootView = inflater.inflate(R.layout.activity_refresh_list, container, false);
@@ -113,7 +112,10 @@ public class PairingFragment extends Fragment implements PairingDeviceItem.Callb
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() {

View File

@@ -68,7 +68,7 @@ public class DeviceTest extends AndroidTestCase {
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 @@ public class DeviceTest extends AndroidTestCase {
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 @@ public class DeviceTest extends AndroidTestCase {
}
// Basic paired device testing
public void testDevice(){
public void testDevice() {
Device device = new Device(getContext(), "testDevice");
@@ -123,7 +123,7 @@ public class DeviceTest extends AndroidTestCase {
// 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 @@ public class DeviceTest extends AndroidTestCase {
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,7 +162,7 @@ public class DeviceTest extends AndroidTestCase {
method = Device.class.getDeclaredMethod("pairingDone");
method.setAccessible(true);
method.invoke(device);
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
@@ -171,7 +171,7 @@ public class DeviceTest extends AndroidTestCase {
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 class DeviceTest extends AndroidTestCase {
}
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 @@ public class DeviceTest extends AndroidTestCase {
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,7 +246,7 @@ public class DeviceTest extends AndroidTestCase {
method = Device.class.getDeclaredMethod("pairingDone");
method.setAccessible(true);
method.invoke(device);
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
@@ -255,7 +255,7 @@ public class DeviceTest extends AndroidTestCase {
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");
@@ -264,7 +264,7 @@ public class DeviceTest extends AndroidTestCase {
settings.edit().clear().apply();
}
public void testUnpair(){
public void testUnpair() {
Device device = new Device(getContext(), "testDevice");

View File

@@ -50,7 +50,7 @@ public class LanLinkProviderTest extends AndroidTestCase {
}
public void testIdentityPackageReceived() throws Exception{
public void testIdentityPackageReceived() throws Exception {
NetworkPackage networkPackage = Mockito.mock(NetworkPackage.class);
Mockito.when(networkPackage.getType()).thenReturn("kdeconnect.identity");
@@ -67,7 +67,7 @@ public class LanLinkProviderTest extends AndroidTestCase {
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;
}
@@ -75,8 +75,8 @@ public class LanLinkProviderTest extends AndroidTestCase {
try {
Field field = LanLinkProvider.class.getDeclaredField("visibleComputers");
field.setAccessible(true);
visibleComputers = (HashMap<String, LanLink>)field.get(linkProvider);
}catch (Exception e){
visibleComputers = (HashMap<String, LanLink>) field.get(linkProvider);
} catch (Exception e) {
throw e;
}
assertNotNull(visibleComputers.get("testDevice"));

View File

@@ -110,23 +110,23 @@ public class LanLinkTest extends AndroidTestCase {
}
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 @@ public class LanLinkTest extends AndroidTestCase {
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 @@ public class LanLinkTest extends AndroidTestCase {
outputStream.close();
input.close();
} catch(Exception e) {
} catch (Exception e) {
Log.e("Downloader Test", "Exception");
e.printStackTrace();
}
@@ -175,15 +179,15 @@ public class LanLinkTest extends AndroidTestCase {
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 @@ public class LanLinkTest extends AndroidTestCase {
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 @@ public class LanLinkTest extends AndroidTestCase {
@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 @@ public class LanLinkTest extends AndroidTestCase {
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;
}

View File

@@ -32,7 +32,7 @@ import java.security.KeyPairGenerator;
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 @@ public class NetworkPackageTest extends AndroidTestCase{
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 @@ public class NetworkPackageTest extends AndroidTestCase{
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 @@ public class NetworkPackageTest extends AndroidTestCase{
// 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 @@ public class NetworkPackageTest extends AndroidTestCase{
decrypted = RsaHelper.decrypt(encrypted, privateKey);
String decryptedJson = decrypted.serialize();
JSONAssert.assertEquals(json, decryptedJson, true);
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
}