From e57e7b0257be16913305f44af422af560614d15c Mon Sep 17 00:00:00 2001 From: Maxim Leshchenko Date: Tue, 9 Mar 2021 22:13:30 +0200 Subject: [PATCH] Improve and fixup SendKeystrokesToHostActivity Changes: 1. Add toolbar 2. Add device icons 3. Fix unexpected on-screen keyboard popping up when starting an activity on some Android versions 4. The distance between the device list and the text box has been reduced --- res/layout/activity_sendkeystrokes.xml | 82 ++++++++++--------- .../SendKeystrokesToHostActivity.java | 9 +- 2 files changed, 51 insertions(+), 40 deletions(-) diff --git a/res/layout/activity_sendkeystrokes.xml b/res/layout/activity_sendkeystrokes.xml index c9b7c283..b22481b3 100644 --- a/res/layout/activity_sendkeystrokes.xml +++ b/res/layout/activity_sendkeystrokes.xml @@ -1,49 +1,55 @@ - - + xmlns:tools="http://schemas.android.com/tools" + tools:context="org.kde.kdeconnect.Plugins.MousePadPlugin.SendKeystrokesToHostActivity"> - + - - - - - - + android:descendantFocusability="beforeDescendants" + android:focusableInTouchMode="true" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> + - \ No newline at end of file + + + + + + \ No newline at end of file diff --git a/src/org/kde/kdeconnect/Plugins/MousePadPlugin/SendKeystrokesToHostActivity.java b/src/org/kde/kdeconnect/Plugins/MousePadPlugin/SendKeystrokesToHostActivity.java index ff6474ec..b64944c8 100644 --- a/src/org/kde/kdeconnect/Plugins/MousePadPlugin/SendKeystrokesToHostActivity.java +++ b/src/org/kde/kdeconnect/Plugins/MousePadPlugin/SendKeystrokesToHostActivity.java @@ -20,7 +20,7 @@ import org.kde.kdeconnect.BackgroundService; import org.kde.kdeconnect.Device; import org.kde.kdeconnect.Helpers.SafeTextChecker; import org.kde.kdeconnect.NetworkPacket; -import org.kde.kdeconnect.UserInterface.List.EntryItem; +import org.kde.kdeconnect.UserInterface.List.EntryItemWithIcon; import org.kde.kdeconnect.UserInterface.List.ListAdapter; import org.kde.kdeconnect.UserInterface.List.SectionItem; import org.kde.kdeconnect.UserInterface.ThemeUtil; @@ -30,6 +30,7 @@ import org.kde.kdeconnect_tp.databinding.ActivitySendkeystrokesBinding; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; public class SendKeystrokesToHostActivity extends AppCompatActivity { @@ -51,6 +52,10 @@ public class SendKeystrokesToHostActivity extends AppCompatActivity { binding = ActivitySendkeystrokesBinding.inflate(getLayoutInflater()); setContentView(binding.getRoot()); + + setSupportActionBar(binding.toolbarLayout.toolbar); + Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayShowHomeEnabled(true); } @@ -151,7 +156,7 @@ public class SendKeystrokesToHostActivity extends AppCompatActivity { for (Device d : devices) { if (d.isReachable() && d.isPaired()) { devicesList.add(d); - items.add(new EntryItem(d.getName())); + items.add(new EntryItemWithIcon(d.getName(), d.getIcon())); section.isEmpty = false; } }