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

Compare commits

..

1 Commits

Author SHA1 Message Date
Albert Vaca Cintora
d114ff4c1c Use getDefault to get the SSLContext 2023-04-20 18:55:44 +02:00
43 changed files with 320 additions and 465 deletions

View File

@@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.kde.kdeconnect_tp"
android:versionCode="12405"
android:versionName="1.24.5">
android:versionCode="12401"
android:versionName="1.24.1">
<supports-screens
android:anyDensity="true"
@@ -275,10 +275,9 @@
</activity>
<activity
android:name="org.kde.kdeconnect.Plugins.MousePadPlugin.ComposeSendActivity"
android:label="@string/compose_send_title"
android:label="Compose send"
android:exported="false"
android:parentActivityName="org.kde.kdeconnect.Plugins.MousePadPlugin.MousePadActivity"
android:windowSoftInputMode="adjustResize">
android:parentActivityName="org.kde.kdeconnect.Plugins.MousePadPlugin.MousePadActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.kde.kdeconnect.Plugins.MousePadPlugin.MousePadActivity" />
@@ -366,7 +365,6 @@
<action android:name="android.service.chooser.ChooserTargetService" />
</intent-filter>
</service>
<!--
<service
android:name="org.kde.kdeconnect.Plugins.MouseReceiverPlugin.MouseReceiverService"
android:exported="true"
@@ -378,7 +376,6 @@
android:name="android.accessibilityservice"
android:resource="@xml/mouse_receiver_service" />
</service>
-->
<activity
android:name="org.kde.kdeconnect.Plugins.NotificationsPlugin.NotificationFilterActivity"

View File

@@ -6,7 +6,7 @@ import com.github.jk1.license.render.TextReportRenderer
buildscript {
ext.kotlin_version = '1.8.10'
dependencies {
classpath 'com.android.tools.build:gradle:8.0.0'
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
@@ -20,7 +20,6 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
namespace 'org.kde.kdeconnect_tp'
compileSdkVersion 33
defaultConfig {
minSdkVersion 21
@@ -29,13 +28,7 @@ android {
}
buildFeatures {
viewBinding true
compose true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.4.2"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
@@ -145,12 +138,6 @@ ext {
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
implementation 'androidx.compose.material3:material3:1.0.1'
implementation 'androidx.compose.ui:ui-tooling-preview:1.4.2'
implementation 'androidx.activity:activity-compose:1.7.1'
implementation 'com.google.accompanist:accompanist-themeadapter-material3:0.31.0-alpha'
implementation 'androidx.constraintlayout:constraintlayout-compose:1.0.1'
implementation 'androidx.media:media:1.6.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.core:core-ktx:1.10.0'

View File

@@ -1,6 +1,3 @@
android.defaults.buildfeatures.buildconfig=true
android.enableJetifier=false
android.nonFinalResIds=false
android.nonTransitiveRClass=false
android.useAndroidX=true
org.gradle.jvmargs=-Xmx4096m

View File

@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip

View File

@@ -18,7 +18,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
#: dummy:1
msgid "Integrate Android with the KDE Plasma Desktop."

View File

@@ -16,8 +16,7 @@
android:id="@+id/coordinatorLayout"
android:layout_height="match_parent"
android:layout_width="match_parent"
tools:context="org.kde.kdeconnect.UserInterface.MainActivity"
android:fitsSystemWindows="true">
tools:context="org.kde.kdeconnect.UserInterface.MainActivity">
<include layout="@layout/toolbar" android:id="@+id/toolbar_layout" />

View File

@@ -5,8 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
tools:context="org.kde.kdeconnect.UserInterface.About.AboutKDEActivity"
android:fitsSystemWindows="true">
tools:context="org.kde.kdeconnect.UserInterface.About.AboutKDEActivity">
<include layout="@layout/toolbar" android:id="@+id/toolbar_layout" />

View File

@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" />
</com.google.android.material.appbar.AppBarLayout>
<EditText
android:id="@+id/compose"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
android:ems="10"
android:hint="@string/click_here_to_type"
android:imeActionLabel="@string/send_compose"
android:imeOptions="actionSend|actionDone"
android:importantForAutofill="no"
android:inputType="textLongMessage|textMultiLine"
android:isScrollContainer="true"
android:saveEnabled="true"
android:scrollbars="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/appBarLayout2"
app:layout_constraintVertical_bias="1.0"
tools:ignore="SpeakableTextPresentCheck,TextContrastCheck" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -6,8 +6,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
tools:context="org.kde.kdeconnect.UserInterface.CustomDevicesActivity"
android:fitsSystemWindows="true">
tools:context="org.kde.kdeconnect.UserInterface.CustomDevicesActivity">
<include layout="@layout/toolbar" android:id="@+id/toolbar_layout" />

View File

@@ -4,7 +4,6 @@
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:fitsSystemWindows="true"
tools:context="org.kde.kdeconnect.UserInterface.About.LicensesActivity">
<include layout="@layout/toolbar" android:id="@+id/toolbar_layout" />

View File

@@ -7,14 +7,14 @@
<androidx.drawerlayout.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:fitsSystemWindows="true"> <!-- fitSystemWindows to make the drawer slide below the Lollipop transparent status bar -->
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/coordinatorLayout"
android:layout_height="match_parent"
android:layout_width="match_parent"
tools:context="org.kde.kdeconnect.UserInterface.MainActivity"
android:fitsSystemWindows="true">
tools:context="org.kde.kdeconnect.UserInterface.MainActivity">
<include layout="@layout/toolbar" android:id="@+id/toolbar_layout"/>

View File

@@ -9,7 +9,9 @@
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:elevation="8dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
@@ -19,7 +21,10 @@
<com.google.android.material.tabs.TabLayout
android:id="@+id/mpris_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:background="@color/toolbar_color"
app:tabIndicatorColor="?android:textColorPrimary"
app:tabSelectedTextColor="?android:textColorPrimary" />
</com.google.android.material.appbar.AppBarLayout>

View File

@@ -6,8 +6,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
tools:context="org.kde.kdeconnect.UserInterface.PluginSettingsActivity"
android:fitsSystemWindows="true">
tools:context="org.kde.kdeconnect.UserInterface.PluginSettingsActivity">
<include layout="@layout/toolbar" android:id="@+id/toolbar_layout" />

View File

@@ -5,11 +5,12 @@
android:layout_height="wrap_content"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:fitsSystemWindows="true">
android:theme="@style/ThemeOverlay.AppCompat.ActionBar">
<com.google.android.material.appbar.MaterialToolbar
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="8dp"
app:title="@string/kde_connect"/>
</com.google.android.material.appbar.AppBarLayout>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:kdeconnect="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_send_compose"
android:icon="@android:drawable/ic_menu_send"
android:title="@string/send_compose"
kdeconnect:showAsAction="ifRoom" />
<item
android:id="@+id/menu_clear_compose"
android:title="@string/clear_compose"
kdeconnect:showAsAction="always" />
</menu>

View File

@@ -6,13 +6,13 @@
android:id="@+id/menu_rise_up"
android:icon="@drawable/ic_arrow_upward_black_24dp"
android:title="@string/rise_up"
kdeconnect:iconTint="?colorOnSurfaceVariant"
android:iconTint="@color/text_color"
kdeconnect:showAsAction="ifRoom" />
<item
android:id="@+id/menu_rise_down"
android:icon="@drawable/ic_arrow_downward_black_24dp"
android:title="@string/rise_down"
kdeconnect:iconTint="?colorOnSurfaceVariant"
android:iconTint="@color/text_color"
kdeconnect:showAsAction="ifRoom" />
</menu>

View File

@@ -51,13 +51,11 @@
<string name="remotekeyboard_connected">Uzaq klaviatura bağlantısını aktiv edin</string>
<string name="remotekeyboard_multiple_connections">Birdən çox uzaq klaviatura bağlantısı var, tənzimləmək üçün cihazı seçin</string>
<string name="open_mousepad">Məsafədən giriş</string>
<string name="mousepad_info">Siçan kursorunu hərəkət etdirmək üçün barmağı ekranda sürüşdürün. Klik üçün ekrana vurun, sağ və orta siçan düymələri üçün iki/üç barmaqla toxunuş edin. Sürüşdürmək üçün iki barmaqdan istifadə edin. Hiroskop siçan funksionallığı plaqin ayarlarında aktiv edilməlidir</string>
<string name="mousepad_keyboard_input_not_supported">Qoşulmuş cihaz üçün klaviatura ilə daxiletmə dəstəklənmir</string>
<string name="mousepad_single_tap_settings_title">Bir barmaq toxunuşu əməlini təyin edin</string>
<string name="mousepad_double_tap_settings_title">İki barmaq toxunuşu əməlini təyin edin</string>
<string name="mousepad_triple_tap_settings_title">Üç barmaq toxunuşu əməlini təyin edin</string>
<string name="mousepad_sensitivity_settings_title">Toxunma panelinin həsassləğını təyin edin</string>
<string name="mousepad_mouse_buttons_title">Siçan düymələrini göstərmək</string>
<string name="mousepad_acceleration_profile_settings_title">Kursorun sürətini təyin edin</string>
<string name="mousepad_scroll_direction_title">Sürüşdürmənin əks istiqaməti</string>
<string-array name="mousepad_tap_entries">
@@ -218,11 +216,8 @@
<string name="sftp_action_mode_menu_delete">Silmək</string>
<string name="sftp_no_storage_locations_configured">Saxlama yeri tənzimlənməyib</string>
<string name="sftp_saf_permission_explanation">Fayllara uzaqdan daxil olmaq üçün saxlama yerlərini konfiqurasiya etməlisiniz</string>
<string name="sftp_manage_storage_permission_explanation">Bu cihazdakı fayllara giriş əldə etmək üçün KDE Connect-ə yaddaşı idarə etməyə icazə vermək lazımdır.</string>
<string name="no_players_connected">Pleyer tapılmadı</string>
<string name="send_files">Faylları göndərmək</string>
<string name="block_notification_contents">Bildirilərin tərkiblərini kilidləmək</string>
<string name="block_notification_images">Bildiriş şəlkillərini kilidləmək</string>
<string name="pairing_title">KDE Connect Cihazları</string>
<string name="pairing_description">Eyni şəbəkədəki KDE Connect işləyən digər cihazlar burada görünməlidir</string>
<string name="device_rename_title">Cihazın adını dəyişmək</string>
@@ -245,10 +240,8 @@
<string name="close">Bağlamaq</string>
<string name="plugins_need_permission">Bəzi qoşmaların işləməsi üçün icazələr lazımdır (daha çox məlumat üçün toxunun):</string>
<string name="permission_explanation">Bu qoşmanın işləməsi üçün icazələr lazımdır</string>
<string name="all_permissions_granted">Bütün icazələr verildi 🎉</string>
<string name="optional_permission_explanation">Bütün funksiyaların işləməsi üçün əlavə icazələr verməlisiniz</string>
<string name="plugins_need_optional_permission">Bəzi qoşmalarda icazə çatışmamazlığı səbəbindən bir sıra imkanlar söndürülmüşdür (daha çox məlumat üçün toxunun)</string>
<string name="share_optional_permission_explanation">Faylları qəbul etmək üçün yaddaşa girişə icazə verilməlidirü</string>
<string name="telepathy_permission_explanation">İş Masanızdan telefonunuzdakı SMS\'ləri oxumaq və SMS göndərmək üçün SMS\'ə girişə icazə verməlisiniz</string>
<string name="telephony_permission_explanation">İş Masanızda telefon zənglərini görmək üçün Zəng Tarixçəsinə və Zəng yığımı vəziyyətinə icazə verməlisiniz</string>
<string name="telephony_optional_permission_explanation">Telefon nömrəsi əvəzinə əlaqənin adını görmək üçün Əlaqə Kitabçasına girişə icazə verməlisiniz</string>

View File

@@ -51,13 +51,11 @@
<string name="remotekeyboard_connected">Remote keyboard connection is active</string>
<string name="remotekeyboard_multiple_connections">There is more than one remote keyboard connection, select the device to configure</string>
<string name="open_mousepad">Remote input</string>
<string name="mousepad_info">Move a finger on the screen to move the mouse cursor. Tap for a click, and use two/three fingers for right and middle buttons. Use 2 fingers to scroll. Use a long press to drag and drop. Gyro mouse functionality can be enabled from plugin preferences</string>
<string name="mousepad_keyboard_input_not_supported">Keyboard input not supported by the paired device</string>
<string name="mousepad_single_tap_settings_title">Set one finger tap action</string>
<string name="mousepad_double_tap_settings_title">Set two finger tap action</string>
<string name="mousepad_triple_tap_settings_title">Set three finger tap action</string>
<string name="mousepad_sensitivity_settings_title">Set touchpad sensitivity</string>
<string name="mousepad_mouse_buttons_title">Show mouse buttons</string>
<string name="mousepad_acceleration_profile_settings_title">Set pointer acceleration</string>
<string name="mousepad_scroll_direction_title">Reverse Scrolling Direction</string>
<string-array name="mousepad_tap_entries">

View File

@@ -51,13 +51,11 @@
<string name="remotekeyboard_connected">Etänäppäimistöyhteys on käytössä</string>
<string name="remotekeyboard_multiple_connections">Etänäppäimistöyhteyksiä on useampia: valitse asetettava laite</string>
<string name="open_mousepad">Kauko-ohjaus</string>
<string name="mousepad_info">Siirrä hiirikohdistinta liikuttamalla sormea näytöllä. Tee hiirenpainallus napauttamalla, ja käytä kahta tai kolmea sormea oikealle ja keskipainikkeelle. Vieritä kahdella sormella. Pitkällä painalluksella voit vetää ja pudottaa. Gyrohiiritoiminnon voi ottaa käyttää liitännäisen asetuksista</string>
<string name="mousepad_keyboard_input_not_supported">Paritettu laite ei tue näppäimistösyötettä</string>
<string name="mousepad_single_tap_settings_title">Aseta yhden sormen napautuksen toiminto</string>
<string name="mousepad_double_tap_settings_title">Aseta kahden sormen napautuksen toiminto</string>
<string name="mousepad_triple_tap_settings_title">Aseta kolmen sormen napautuksen toiminto</string>
<string name="mousepad_sensitivity_settings_title">Aseta kosketuslevyn herkkyys</string>
<string name="mousepad_mouse_buttons_title">Näytä hiiripainikkeet</string>
<string name="mousepad_acceleration_profile_settings_title">Aseta osoittimen kiihdytys</string>
<string name="mousepad_scroll_direction_title">Käänteinen vierityssuunta</string>
<string-array name="mousepad_tap_entries">

View File

@@ -51,13 +51,11 @@
<string name="remotekeyboard_connected">원격 키보드 연결이 활성화됨</string>
<string name="remotekeyboard_multiple_connections">원격 키보드 연결이 여러 개 있습니다. 설정할 장치를 선택하십시오</string>
<string name="open_mousepad">원격 입력</string>
<string name="mousepad_info">화면에서 손가락을 움직이면 마우스 커서를 움직입니다. 화면을 누르면 왼쪽 단추를 누르고, 두 손가락과 세 손가락으로 누르면 오른쪽/가운데 단추를 누릅니다. 두 손가락을 사용하여 스크롤할 수 있습니다. 드래그 앤 드롭을 사용하려면 길게 누르십시오. 플러그인 설정에서 자이로 마우스를 활성화할 수 있습니다</string>
<string name="mousepad_keyboard_input_not_supported">페어링된 장치에서 키보드 입력을 지원하지 않음</string>
<string name="mousepad_single_tap_settings_title">한 손가락으로 눌렀을 때 동작 설정</string>
<string name="mousepad_double_tap_settings_title">두 손가락으로 눌렀을 때 동작 설정</string>
<string name="mousepad_triple_tap_settings_title">세 손가락으로 눌렀을 때 동작 설정</string>
<string name="mousepad_sensitivity_settings_title">터치패드 감도 설정</string>
<string name="mousepad_mouse_buttons_title">마우스 단추 표시</string>
<string name="mousepad_acceleration_profile_settings_title">포인터 가속 설정</string>
<string name="mousepad_scroll_direction_title">스크롤 방향 뒤집기</string>
<string-array name="mousepad_tap_entries">
@@ -210,11 +208,8 @@
<string name="sftp_action_mode_menu_delete">삭제</string>
<string name="sftp_no_storage_locations_configured">저장소 위치가 설정되지 않았음</string>
<string name="sftp_saf_permission_explanation">원격으로 파일에 접근하려면 저장소 위치를 설정해야 함</string>
<string name="sftp_manage_storage_permission_explanation">이 장치에 있는 파일에 원격 접근을 허용하려면 KDE Connect에서 저장소를 관리할 수 있도록 허용해야 합니다.</string>
<string name="no_players_connected">재생기를 찾을 수 없음</string>
<string name="send_files">파일 보내기</string>
<string name="block_notification_contents">알림 내용 숨기기</string>
<string name="block_notification_images">알림 이미지 숨기기</string>
<string name="pairing_title">KDE Connect 장치</string>
<string name="pairing_description">같은 네트워크에서 KDE Connect를 실행하는 다른 장치가 여기에 표시됩니다.</string>
<string name="device_rename_title">장치 이름 바꾸기</string>
@@ -237,10 +232,8 @@
<string name="close">닫기</string>
<string name="plugins_need_permission">권한이 필요한 플러그인(정보를 보려면 누르기):</string>
<string name="permission_explanation">이 플러그인을 사용하려면 권한이 필요합니다</string>
<string name="all_permissions_granted">모든 권한 허가됨 🎉</string>
<string name="optional_permission_explanation">모든 기능을 사용하려면 추가 권한이 필요합니다</string>
<string name="plugins_need_optional_permission">일부 플러그인은 권한이 없어서 비활성화되었습니다(정보를 보려면 누르기):</string>
<string name="share_optional_permission_explanation">공유된 파일을 받으려면 저장소 접근을 허가해야 합니다</string>
<string name="telepathy_permission_explanation">데스크톱에서 문자 메시지를 읽고 보내려면 문자 메시지 접근 권한이 필요합니다</string>
<string name="telephony_permission_explanation">데스크톱에서 통화와 문자 메시지를 보려면 통화 기록 및 휴대폰 상태 접근 권한이 필요합니다</string>
<string name="telephony_optional_permission_explanation">전화번호 대신 연락처에 등록된 이름을 보려면 주소록 접근 권한이 필요합니다</string>

View File

@@ -11,6 +11,7 @@
<color name="toolbar_color">@android:color/system_neutral1_900</color>
<color name="card_stroke_color">@android:color/system_neutral2_800</color>
<color name="activity_background">@android:color/system_neutral1_900</color>
<item name="lightMode" type="bool">false</item>
<!-- This is for dark theme. In dark theme both selected and unselected text in the
navigation bar should be white. This is different from the light theme as both states have

View File

@@ -11,6 +11,7 @@
<color name="toolbar_color">@android:color/black</color>
<color name="card_stroke_color">#8C8C8C</color>
<color name="activity_background">@android:color/black</color>
<item name="lightMode" type="bool">false</item>
<!-- This is for dark theme. In dark theme both selected and unselected text in the
navigation bar should be white. This is different from the light theme as both states have

View File

@@ -11,5 +11,6 @@
<color name="toolbar_color">@android:color/system_neutral1_50</color>
<color name="card_stroke_color">@android:color/system_neutral2_100</color>
<color name="activity_background">@android:color/system_neutral1_50</color>
<item name="lightMode" type="bool">true</item>
</resources>

View File

@@ -3,7 +3,7 @@
<style name="KdeConnectTheme.NoActionBar" parent="KdeConnectThemeBase.NoActionBar">
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowLightStatusBar">?attr/isLightTheme</item>
<item name="android:windowLightStatusBar">@bool/lightMode</item>
</style>
</resources>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="KdeConnectThemeBase.V27" parent="KdeConnectThemeBase">
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@color/activity_background</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowLightNavigationBar">?attr/isLightTheme</item>
</style>

View File

@@ -11,4 +11,5 @@
<color name="toolbar_color">@android:color/white</color>
<color name="card_stroke_color">#C8C8C8</color>
<color name="activity_background">@android:color/white</color>
<item name="lightMode" type="bool">true</item>
</resources>

View File

@@ -75,9 +75,6 @@
<string name="mousepad_scroll_direction" translatable="false">mousepad_scroll_direction</string>
<string name="gyro_mouse_enabled" translatable="false">gyro_mouse_enabled</string>
<string name="mousepad_mouse_buttons_enabled_pref" translatable="false">mouse_buttons_enabled</string>
<string name="gyro_mouse_enabled_title">Enable gyroscope mouse</string>
<string name="gyro_mouse_sensitivity_title">Gyroscope sensitivity</string>
<string name="gyro_mouse_sensitivity" translatable="false">gyro_mouse_sensitivity</string>
<string-array name="mousepad_tap_entries">
<item>Left click</item>
<item>Right click</item>
@@ -488,7 +485,6 @@
<string name="click_here_to_type">Tap here to type</string>
<string name="clear_compose">Clear</string>
<string name="send_compose">Send</string>
<string name="compose_send_title">Compose send</string>
<string name="open_compose_send">Compose text</string>
<string name="about_kde_about"><![CDATA[

View File

@@ -2,24 +2,25 @@
<!-- NoActionBar because we use a Toolbar widget as ActionBar -->
<style name="KdeConnectThemeBase" parent="Theme.Material3.DayNight.NoActionBar">
<!-- The main color attributes -->
<!-- The three colors used by system widgets, according to https://chris.banes.me/2014/10/17/appcompat-v21/ -->
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primaryDark</item>
<item name="colorSecondary">@color/primary</item>
<item name="colorOnSecondary">@color/on_secondary</item>
<item name="colorAccent">@color/accent</item>
<item name="colorHighContrast">@color/on_high_contrast</item>
<item name="android:windowBackground">@color/activity_background</item>
<item name="android:colorBackground">@color/activity_background</item>
<!-- TODO: The 2 items below change too much (eg snackbar text is now black, should be white) -->
<item name="android:textColorPrimary">@color/text_color_primary</item>
<item name="android:textColor">@color/text_color</item>
<!--For android below 23 api-->
<item name="android:statusBarColor">@android:color/black</item>
<!-- Drawable definitions and overrides -->
<item name="divider">?colorHighContrast</item>
<!-- Style overrides -->
<item name="actionModeStyle">@style/Widget.Material3.ActionMode</item>
<item name="toolbarStyle">@style/Widget.Material3.Toolbar</item>
<item name="actionModeStyle">@style/ActionModeStyle</item>
<item name="toolbarStyle">@style/KdeConnectTheme.Toolbar</item>
<!-- Theme overrides -->
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>

View File

@@ -61,14 +61,7 @@
android:id="@+id/gyro_mouse_enabled"
android:defaultValue="false"
android:key="@string/gyro_mouse_enabled"
android:title="@string/gyro_mouse_enabled_title" />
<SeekBarPreference
android:id="@+id/mousepad_gyro_sensitivity"
android:defaultValue="100"
android:key="@string/gyro_mouse_sensitivity"
android:title="@string/gyro_mouse_sensitivity_title"
android:layout_width="wrap_content" />
android:title="Gyro mouse" />
<SwitchPreference
android:id="@+id/mousepad_mouse_buttons_enabled_pref"

View File

@@ -209,7 +209,7 @@ public class SslHelper {
trustManagerFactory.init(keyStore);
// Setup custom trust manager if device not trusted
SSLContext tlsContext = SSLContext.getInstance("TLSv1.2"); // Use TLS up to 1.2, since 1.3 seems to cause issues in some (older?) devices
SSLContext tlsContext = SSLContext.getDefault();
if (isDeviceTrusted) {
tlsContext.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), RandomHelper.secureRandom);
} else {

View File

@@ -151,7 +151,7 @@ public class ConnectivityReportPlugin extends Plugin {
serializeSignalStrengths();
device.sendPacket(connectivityInfo);
//Log.i("ConnectivityReport", "signalStrength of #" + subID + " updated to " + level);
Log.i("ConnectivityReport", "signalStrength of #" + subID + " updated to " + level);
}
@Override
@@ -164,7 +164,7 @@ public class ConnectivityReportPlugin extends Plugin {
serializeSignalStrengths();
device.sendPacket(connectivityInfo);
//Log.i("ConnectivityReport", "networkType of #" + subID + " updated to " + networkTypeToString(networkType));
Log.i("ConnectivityReport", "networkType of #" + subID + " updated to " + networkTypeToString(networkType));
}
};
}

View File

@@ -0,0 +1,114 @@
/*
* SPDX-FileCopyrightText: 2021 Forrest Hilton <forrestmhilton@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
package org.kde.kdeconnect.Plugins.MousePadPlugin;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import androidx.appcompat.app.AppCompatActivity;
import org.kde.kdeconnect.BackgroundService;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.UserInterface.ThemeUtil;
import org.kde.kdeconnect_tp.R;
import java.util.Objects;
public class ComposeSendActivity extends AppCompatActivity {
private String deviceId;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_compose_send);
setSupportActionBar(findViewById(R.id.toolbar));
Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
Intent intent = getIntent();
deviceId = intent.getStringExtra("org.kde.kdeconnect.Plugins.MousePadPlugin.deviceId");
EditText editText = findViewById(R.id.compose);
editText.requestFocus();
// this is almost never used
editText.setOnEditorActionListener((v, actionId, event) -> {
if (actionId == EditorInfo.IME_ACTION_SEND) {
sendComposed();
return true;
}
if (actionId == EditorInfo.IME_ACTION_DONE) {
clear();
return true;
}
return false;
});
}
public void sendChars(CharSequence chars) {
final NetworkPacket np = new NetworkPacket(MousePadPlugin.PACKET_TYPE_MOUSEPAD_REQUEST);
np.set("key", chars.toString());
sendKeyPressPacket(np);
}
private void sendKeyPressPacket(final NetworkPacket np) {
try {
Log.d("packed", np.serialize());
} catch (Exception e) {
Log.e("KDE/ComposeSend", "Exception", e);
}
BackgroundService.RunWithPlugin(this, deviceId, MousePadPlugin.class, plugin -> plugin.sendKeyboardPacket(np));
}
public void sendComposed() {
EditText editText = findViewById(R.id.compose);
String editTextStr = editText.getText().toString();
sendChars(editTextStr);
clear();
}
public void clear() {
EditText editText = findViewById(R.id.compose);
editText.setText("");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_compose_send, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.menu_clear_compose) {
clear();
return true;
} else if (id == R.id.menu_send_compose) {
sendComposed();
return true;
} else {
return super.onOptionsItemSelected(item);
}
}
}

View File

@@ -1,130 +0,0 @@
/*
* SPDX-FileCopyrightText: 2023 Dmitry Yudin <dgyudin@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
package org.kde.kdeconnect.Plugins.MousePadPlugin
import android.os.Bundle
import android.util.Log
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.Send
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.preference.PreferenceManager
import com.google.accompanist.themeadapter.material3.Mdc3Theme
import org.kde.kdeconnect.BackgroundService
import org.kde.kdeconnect.NetworkPacket
import org.kde.kdeconnect.UserInterface.compose.KdeTextButton
import org.kde.kdeconnect.UserInterface.compose.KdeTextField
import org.kde.kdeconnect.UserInterface.compose.KdeTopAppBar
import org.kde.kdeconnect_tp.R
private const val INPUT_CACHE_KEY = "compose_send_input_cache"
class ComposeSendActivity : AppCompatActivity() {
private var deviceId: String? = null
private val userInput = mutableStateOf(String())
private val prefs by lazy { PreferenceManager.getDefaultSharedPreferences(this) }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
prefs.getString(INPUT_CACHE_KEY, null)?.let { userInput.value = it }
setContent { ComposeSendScreen() }
deviceId = intent.getStringExtra("org.kde.kdeconnect.Plugins.MousePadPlugin.deviceId")
}
override fun onStop() {
super.onStop()
with(prefs.edit()) {
if (userInput.value.isNotBlank()) putString(INPUT_CACHE_KEY, userInput.value) else remove(INPUT_CACHE_KEY)
apply()
}
}
private fun sendChars(chars: String) {
val np = NetworkPacket(MousePadPlugin.PACKET_TYPE_MOUSEPAD_REQUEST)
np["key"] = chars
sendKeyPressPacket(np)
}
private fun sendKeyPressPacket(np: NetworkPacket) {
try {
Log.d("packed", np.serialize())
} catch (e: Exception) {
Log.e("KDE/ComposeSend", "Exception", e)
}
BackgroundService.RunWithPlugin(
this, deviceId, MousePadPlugin::class.java
) { plugin: MousePadPlugin -> plugin.sendKeyboardPacket(np) }
}
private fun sendComposed() {
sendChars(userInput.value)
clearComposeInput()
}
private fun clearComposeInput() {
userInput.value = String()
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun ComposeSendScreen() {
Mdc3Theme {
Scaffold(
topBar = {
KdeTopAppBar(
title = stringResource(R.string.compose_send_title),
navIcon = Icons.Default.ArrowBack,
navIconOnClick = { onBackPressedDispatcher.onBackPressed() },
actions = {
KdeTextButton(
modifier = Modifier.padding(horizontal = 8.dp),
onClick = { clearComposeInput() },
text = stringResource(R.string.clear_compose),
)
}
)
},
) { scaffoldPadding ->
Box(modifier = Modifier.padding(scaffoldPadding).fillMaxSize()) {
KdeTextField(
modifier = Modifier
.padding(horizontal = 16.dp)
.padding(bottom = 80.dp)
.align(Alignment.BottomStart)
.fillMaxWidth(),
input = userInput,
label = stringResource(R.string.click_here_to_type),
)
KdeTextButton(
onClick = { sendComposed() },
modifier = Modifier.padding(all = 16.dp).align(Alignment.BottomEnd),
enabled = userInput.value.isNotEmpty(),
text = stringResource(R.string.send_compose),
iconLeft = Icons.Default.Send,
)
}
}
}
}
}

View File

@@ -8,10 +8,6 @@ package org.kde.kdeconnect.Plugins.MousePadPlugin;
import android.content.Intent;
import android.content.SharedPreferences;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.HapticFeedbackConstants;
@@ -19,11 +15,17 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.hardware.SensorManager;
import android.hardware.SensorEventListener;
import android.hardware.SensorEvent;
import android.hardware.Sensor;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.preference.PreferenceManager;
import org.kde.kdeconnect.BackgroundService;
import org.kde.kdeconnect.UserInterface.PluginSettingsActivity;
@@ -31,13 +33,7 @@ import org.kde.kdeconnect_tp.R;
import java.util.Objects;
public class MousePadActivity
extends AppCompatActivity
implements GestureDetector.OnGestureListener,
GestureDetector.OnDoubleTapListener,
MousePadGestureDetector.OnGestureListener,
SensorEventListener,
SharedPreferences.OnSharedPreferenceChangeListener {
public class MousePadActivity extends AppCompatActivity implements GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener, MousePadGestureDetector.OnGestureListener, SensorEventListener {
private String deviceId;
private final static float MinDistanceToSendScroll = 2.5f; // touch gesture scroll
@@ -53,7 +49,6 @@ public class MousePadActivity
private int scrollDirection = 1;
private boolean allowGyro = false;
private boolean gyroEnabled = false;
private int gyroscopeSensitivity = 100;
private boolean isScrolling = false;
private float accumulatedDistanceY = 0;
@@ -68,8 +63,6 @@ public class MousePadActivity
private SharedPreferences prefs = null;
private boolean prefsApplied = false;
enum ClickType {
LEFT, RIGHT, MIDDLE, NONE;
@@ -97,25 +90,27 @@ public class MousePadActivity
public void onSensorChanged(SensorEvent event) {
float[] values = event.values;
float X = -values[2] * 70 * (gyroscopeSensitivity/100.0f);
float Y = -values[0] * 70 * (gyroscopeSensitivity/100.0f);
float X = -values[2] * 70 * mCurrentSensitivity * displayDpiMultiplier;
float Y = -values[0] * 70 * mCurrentSensitivity * displayDpiMultiplier;
if (X < 0.25 && X > -0.25) {
X = 0;
} else {
X = X * (gyroscopeSensitivity/100.0f);
X = X * mCurrentSensitivity * displayDpiMultiplier;
}
if (Y < 0.25 && Y > -0.25) {
Y = 0;
} else {
Y = Y * (gyroscopeSensitivity/100.0f);
Y = Y * mCurrentSensitivity * displayDpiMultiplier;
}
final float nX = X;
final float nY = Y;
BackgroundService.RunWithPlugin(this, deviceId, MousePadPlugin.class, plugin -> plugin.sendMouseDelta(nX, nY));
BackgroundService.RunWithPlugin(this, deviceId, MousePadPlugin.class, plugin -> {
plugin.sendMouseDelta(nX, nY);
});
}
@Override
@@ -128,10 +123,6 @@ public class MousePadActivity
Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
findViewById(R.id.mouse_click_left).setOnClickListener(v -> sendLeftClick());
findViewById(R.id.mouse_click_middle).setOnClickListener(v -> sendMiddleClick());
findViewById(R.id.mouse_click_right).setOnClickListener(v -> sendRightClick());
deviceId = getIntent().getStringExtra("deviceId");
getWindow().getDecorView().setHapticFeedbackEnabled(true);
@@ -145,13 +136,57 @@ public class MousePadActivity
keyListenerView.setDeviceId(deviceId);
prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.registerOnSharedPreferenceChangeListener(this);
applyPrefs();
if (prefs.getBoolean(getString(R.string.mousepad_scroll_direction), false)) {
scrollDirection = -1;
} else {
scrollDirection = 1;
}
if (mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null
&& prefs.getBoolean(getString(R.string.gyro_mouse_enabled), false)) {
allowGyro = true;
}
String singleTapSetting = prefs.getString(getString(R.string.mousepad_single_tap_key),
getString(R.string.mousepad_default_single));
String doubleTapSetting = prefs.getString(getString(R.string.mousepad_double_tap_key),
getString(R.string.mousepad_default_double));
String tripleTapSetting = prefs.getString(getString(R.string.mousepad_triple_tap_key),
getString(R.string.mousepad_default_triple));
String sensitivitySetting = prefs.getString(getString(R.string.mousepad_sensitivity_key),
getString(R.string.mousepad_default_sensitivity));
String accelerationProfileName = prefs.getString(getString(R.string.mousepad_acceleration_profile_key),
getString(R.string.mousepad_default_acceleration_profile));
mPointerAccelerationProfile = PointerAccelerationProfileFactory.getProfileWithName(accelerationProfileName);
singleTapAction = ClickType.fromString(singleTapSetting);
doubleTapAction = ClickType.fromString(doubleTapSetting);
tripleTapAction = ClickType.fromString(tripleTapSetting);
//Technically xdpi and ydpi should be handled separately,
//but since ydpi is usually almost equal to xdpi, only xdpi is used for the multiplier.
displayDpiMultiplier = StandardDpi / getResources().getDisplayMetrics().xdpi;
switch (sensitivitySetting) {
case "slowest":
mCurrentSensitivity = 0.2f;
break;
case "aboveSlowest":
mCurrentSensitivity = 0.5f;
break;
case "default":
mCurrentSensitivity = 1.0f;
break;
case "aboveDefault":
mCurrentSensitivity = 1.5f;
break;
case "fastest":
mCurrentSensitivity = 2.0f;
break;
default:
mCurrentSensitivity = 1.0f;
return;
}
final View decorView = getWindow().getDecorView();
decorView.setOnSystemUiVisibilityChangeListener(visibility -> {
@@ -170,13 +205,19 @@ public class MousePadActivity
@Override
protected void onResume() {
applyPrefs();
if (allowGyro && !gyroEnabled) {
mSensorManager.registerListener(this, mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE), SensorManager.SENSOR_DELAY_GAME);
gyroEnabled = true;
}
if (prefs.getBoolean(getString(R.string.mousepad_mouse_buttons_enabled_pref), true)) {
findViewById(R.id.mouse_buttons).setVisibility(View.VISIBLE);
findViewById(R.id.mouse_click_left).setOnClickListener(v -> sendLeftClick());
findViewById(R.id.mouse_click_middle).setOnClickListener(v -> sendMiddleClick());
findViewById(R.id.mouse_click_right).setOnClickListener(v -> sendRightClick());
} else {
findViewById(R.id.mouse_buttons).setVisibility(View.GONE);
}
invalidateMenu();
super.onResume();
@@ -191,8 +232,7 @@ public class MousePadActivity
super.onPause();
}
@Override
protected void onStop() {
@Override protected void onStop() {
if (gyroEnabled) {
mSensorManager.unregisterListener(this);
gyroEnabled = false;
@@ -200,12 +240,6 @@ public class MousePadActivity
super.onStop();
}
@Override
protected void onDestroy() {
prefs.unregisterOnSharedPreferenceChangeListener(this);
super.onDestroy();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
@@ -431,11 +465,6 @@ public class MousePadActivity
return true;
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (prefsApplied) prefsApplied = false;
}
private void sendLeftClick() {
BackgroundService.RunWithPlugin(this, deviceId, MousePadPlugin.class, MousePadPlugin::sendLeftClick);
@@ -453,6 +482,7 @@ public class MousePadActivity
BackgroundService.RunWithPlugin(this, deviceId, MousePadPlugin.class, plugin -> plugin.sendScroll(0, y));
}
//TODO: Does not work on KitKat with or without requestFocus()
private void showKeyboard() {
InputMethodManager imm = ContextCompat.getSystemService(this, InputMethodManager.class);
keyListenerView.requestFocus();
@@ -465,70 +495,6 @@ public class MousePadActivity
startActivity(intent);
}
private void applyPrefs() {
if (prefsApplied) return;
if (prefs.getBoolean(getString(R.string.mousepad_scroll_direction), false)) {
scrollDirection = -1;
} else {
scrollDirection = 1;
}
allowGyro = isGyroSensorAvailable() && prefs.getBoolean(getString(R.string.gyro_mouse_enabled), false);
if (allowGyro) gyroscopeSensitivity = prefs.getInt(getString(R.string.gyro_mouse_sensitivity), 100);
String singleTapSetting = prefs.getString(getString(R.string.mousepad_single_tap_key),
getString(R.string.mousepad_default_single));
String doubleTapSetting = prefs.getString(getString(R.string.mousepad_double_tap_key),
getString(R.string.mousepad_default_double));
String tripleTapSetting = prefs.getString(getString(R.string.mousepad_triple_tap_key),
getString(R.string.mousepad_default_triple));
String sensitivitySetting = prefs.getString(getString(R.string.mousepad_sensitivity_key),
getString(R.string.mousepad_default_sensitivity));
String accelerationProfileName = prefs.getString(getString(R.string.mousepad_acceleration_profile_key),
getString(R.string.mousepad_default_acceleration_profile));
mPointerAccelerationProfile = PointerAccelerationProfileFactory.getProfileWithName(accelerationProfileName);
singleTapAction = ClickType.fromString(singleTapSetting);
doubleTapAction = ClickType.fromString(doubleTapSetting);
tripleTapAction = ClickType.fromString(tripleTapSetting);
switch (sensitivitySetting) {
case "slowest":
mCurrentSensitivity = 0.2f;
break;
case "aboveSlowest":
mCurrentSensitivity = 0.5f;
break;
case "default":
mCurrentSensitivity = 1.0f;
break;
case "aboveDefault":
mCurrentSensitivity = 1.5f;
break;
case "fastest":
mCurrentSensitivity = 2.0f;
break;
default:
mCurrentSensitivity = 1.0f;
return;
}
if (prefs.getBoolean(getString(R.string.mousepad_mouse_buttons_enabled_pref), true)) {
findViewById(R.id.mouse_buttons).setVisibility(View.VISIBLE);
} else {
findViewById(R.id.mouse_buttons).setVisibility(View.GONE);
}
prefsApplied = true;
}
private boolean isGyroSensorAvailable() {
return mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null;
}
@Override
public boolean onSupportNavigateUp() {
super.onBackPressed();

View File

@@ -21,7 +21,7 @@ import org.kde.kdeconnect.UserInterface.MainActivity;
import org.kde.kdeconnect.UserInterface.StartActivityAlertDialogFragment;
import org.kde.kdeconnect_tp.R;
//@PluginFactory.LoadablePlugin
@PluginFactory.LoadablePlugin
@RequiresApi(api = Build.VERSION_CODES.N)
public class MouseReceiverPlugin extends Plugin {
private final static String PACKET_TYPE_MOUSEPAD_REQUEST = "kdeconnect.mousepad.request";

View File

@@ -6,6 +6,7 @@
package org.kde.kdeconnect.Plugins.MprisPlugin
import android.content.Context
import android.content.pm.PackageManager.NameNotFoundException
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.net.ConnectivityManager
@@ -19,7 +20,6 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.kde.kdeconnect.NetworkPacket.Payload
import org.kde.kdeconnect_tp.BuildConfig
import java.io.File
import java.io.IOException
import java.io.InputStream
@@ -78,9 +78,14 @@ internal object AlbumArtCache {
fun initializeDiskCache(context: Context) {
if (this::diskCache.isInitialized) return
val cacheDir = File(context.cacheDir, "album_art")
val versionCode: Int
try {
val info = context.packageManager.getPackageInfo(context.packageName, 0)
versionCode = info.versionCode
//Initialize the disk cache with a limit of 5 MB storage (fits ~830 images, taking Spotify as reference)
diskCache = DiskLruCache.open(cacheDir, BuildConfig.VERSION_CODE, 1, 1000 * 1000 * 5.toLong())
diskCache = DiskLruCache.open(cacheDir, versionCode, 1, 1000 * 1000 * 5.toLong())
} catch (e: NameNotFoundException) {
throw AssertionError(e)
} catch (e: IOException) {
Log.e("KDE/Mpris/AlbumArtCache", "Could not open the album art disk cache!", e)
}

View File

@@ -67,10 +67,8 @@ public class SystemVolumePlugin extends Plugin {
Log.e("KDEConnect", "Exception", e);
}
synchronized(listeners) {
for (SinkListener l : listeners) {
l.sinksChanged();
}
for (SinkListener l : listeners) {
l.sinksChanged();
}
} else {
@@ -142,15 +140,11 @@ public class SystemVolumePlugin extends Plugin {
}
void addSinkListener(SinkListener listener) {
synchronized(listeners) {
listeners.add(listener);
}
listeners.add(listener);
}
void removeSinkListener(SinkListener listener) {
synchronized(listeners) {
listeners.remove(listener);
}
listeners.remove(listener);
}
}

View File

@@ -221,20 +221,18 @@ class DeviceFragment : Fragment() {
override fun onResume() {
super.onResume()
with(requireView()) {
isFocusableInTouchMode = true
requestFocus()
setOnKeyListener { _, keyCode, event ->
if (event.action == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
val fromDeviceList = requireArguments().getBoolean(ARG_FROM_DEVICE_LIST, false)
// Handle back button, so we go to the list of devices in case we came from there
if (fromDeviceList) {
mActivity?.onDeviceSelected(null)
return@setOnKeyListener true
}
requireView().isFocusableInTouchMode = true
requireView().requestFocus()
requireView().setOnKeyListener { view, keyCode, event ->
if (event.action == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
val fromDeviceList = requireArguments().getBoolean(ARG_FROM_DEVICE_LIST, false)
// Handle back button, so we go to the list of devices in case we came from there
if (fromDeviceList) {
mActivity?.onDeviceSelected(null)
return@setOnKeyListener true
}
false
}
false
}
}

View File

@@ -20,7 +20,7 @@ class PluginItem(
textStyleRes: Int? = null,
) : this(
context = context,
header = plugin.actionName,
header = plugin.displayName,
textStyleRes = textStyleRes,
) {
this.action = { action(plugin) }

View File

@@ -89,6 +89,7 @@ class MainActivity : AppCompatActivity(), OnSharedPreferenceChangeListener {
it.addDrawerListener(mDrawerToggle)
it.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START)
} ?: {
closeDrawerCallback.isEnabled = false
supportActionBar?.setDisplayShowHomeEnabled(false)
supportActionBar?.setHomeButtonEnabled(false)
}
@@ -109,11 +110,13 @@ class MainActivity : AppCompatActivity(), OnSharedPreferenceChangeListener {
}
MENU_ENTRY_SETTINGS -> {
// mCurrentDevice = null
preferences.edit().putString(STATE_SELECTED_DEVICE, null).apply()
setContentFragment(SettingsFragment())
}
MENU_ENTRY_ABOUT -> {
// mCurrentDevice = null
preferences.edit().putString(STATE_SELECTED_DEVICE, null).apply()
setContentFragment(newInstance(getApplicationAboutData(this)))
}
@@ -184,6 +187,9 @@ class MainActivity : AppCompatActivity(), OnSharedPreferenceChangeListener {
else -> setContentFragment(PairingFragment())
}
}
onBackPressedDispatcher.addCallback(mainFragmentCallback)
onBackPressedDispatcher.addCallback(closeDrawerCallback)
}
override fun onDestroy() {
@@ -268,16 +274,11 @@ class MainActivity : AppCompatActivity(), OnSharedPreferenceChangeListener {
service.addDeviceListChangedCallback(this::class.simpleName) { updateDeviceList() }
}
updateDeviceList()
onBackPressedDispatcher.addCallback(mainFragmentCallback)
onBackPressedDispatcher.addCallback(closeDrawerCallback)
if (mDrawerLayout == null) closeDrawerCallback.isEnabled = false
}
override fun onStop() {
BackgroundService.RunCommand(this) { service: BackgroundService -> service.removeDeviceListChangedCallback(this::class.simpleName) }
super.onStop()
mainFragmentCallback.remove()
closeDrawerCallback.remove()
}
@JvmOverloads

View File

@@ -1,42 +0,0 @@
/*
* SPDX-FileCopyrightText: 2023 Dmitry Yudin <dgyudin@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
package org.kde.kdeconnect.UserInterface.compose
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.width
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.dp
@Composable
fun KdeTextButton(
onClick: () -> Unit,
modifier: Modifier,
text: String,
enabled: Boolean = true,
contentPadding: PaddingValues = PaddingValues(16.dp),
iconLeft: ImageVector? = null,
) {
TextButton(
onClick = onClick,
modifier = modifier,
enabled = enabled,
contentPadding = contentPadding,
content = {
iconLeft?.let {
Icon(imageVector = it, contentDescription = null)
Spacer(Modifier.width(16.dp))
}
Text(text = text)
}
)
}

View File

@@ -1,41 +0,0 @@
/*
* SPDX-FileCopyrightText: 2023 Dmitry Yudin <dgyudin@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
package org.kde.kdeconnect.UserInterface.compose
import android.annotation.SuppressLint
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import org.kde.kdeconnect_tp.R
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun KdeTextField(modifier: Modifier = Modifier, input: MutableState<String>, label: String) {
var value by rememberSaveable { input }
OutlinedTextField(
modifier = modifier,
value = value,
onValueChange = { userInput -> value = userInput },
label = { Text(label) },
)
}
@SuppressLint("UnrememberedMutableState")
@Preview
@Composable
fun Preview() {
KdeTextField(
input = mutableStateOf("John Doe"),
label = stringResource(R.string.click_here_to_type),
)
}

View File

@@ -1,33 +0,0 @@
/*
* SPDX-FileCopyrightText: 2023 Dmitry Yudin <dgyudin@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
package org.kde.kdeconnect.UserInterface.compose
import androidx.compose.foundation.layout.RowScope
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.vector.ImageVector
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun KdeTopAppBar(
title: String,
navIcon: ImageVector,
navIconOnClick: () -> Unit,
actions: @Composable (RowScope.() -> Unit) = {},
) {
TopAppBar(
navigationIcon = {
IconButton(onClick = navIconOnClick, content = { Icon(navIcon, null) })
},
title = { Text(title) },
actions = actions
)
}