From 97fc3cec70a16f947b65c9c6ad813230002be8d1 Mon Sep 17 00:00:00 2001 From: Janne Koschinski <janne@kuschku.de> Date: Sat, 24 Feb 2018 15:30:50 +0100 Subject: [PATCH] Improved input handling with hardware keyboards --- .../quasseldroid_ng/ui/chat/ChatActivity.kt | 6 ++-- app/src/main/res/layout-land/layout_main.xml | 32 ++++++++++++++++++ .../res/layout-sw600dp-land/layout_main.xml | 33 +++++++++++++++++++ app/src/main/res/layout/layout_editor.xml | 9 ++--- app/src/main/res/layout/layout_main.xml | 1 - 5 files changed, 74 insertions(+), 7 deletions(-) create mode 100644 app/src/main/res/layout-land/layout_main.xml create mode 100644 app/src/main/res/layout-sw600dp-land/layout_main.xml diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/ChatActivity.kt b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/ChatActivity.kt index 9f75fec59..ad10acecc 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/ChatActivity.kt +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/ChatActivity.kt @@ -110,8 +110,10 @@ class ChatActivity : ServiceBoundActivity() { chatline.setOnKeyListener { _, keyCode, event -> if (event.hasNoModifiers() && (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_NUMPAD_ENTER)) { send() + true + } else { + false } - false } viewModel.getBuffer().observe( @@ -187,7 +189,7 @@ class ChatActivity : ServiceBoundActivity() { editorPanel.panelState = SlidingUpPanelLayout.PanelState.COLLAPSED } - fun send() { + private fun send() { viewModel.session { session -> viewModel.getBuffer().let { bufferId -> session.bufferSyncer?.bufferInfo(bufferId)?.also { bufferInfo -> diff --git a/app/src/main/res/layout-land/layout_main.xml b/app/src/main/res/layout-land/layout_main.xml new file mode 100644 index 000000000..d02f4ac54 --- /dev/null +++ b/app/src/main/res/layout-land/layout_main.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8"?> +<com.sothree.slidinguppanel.SlidingUpPanelLayout 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/editor_panel" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="bottom" + app:umanoAntiDragView="@id/card_panel" + app:umanoPanelHeight="?actionBarSize" + app:umanoScrollableView="@id/chatline_scroller" + app:umanoShadowHeight="4dp"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:fitsSystemWindows="true" + android:orientation="vertical"> + + <include layout="@layout/layout_toolbar" /> + + <fragment + android:id="@+id/fragment_messages" + android:name="de.kuschku.quasseldroid_ng.ui.chat.messages.MessageListFragment" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:layout="@layout/fragment_messages" /> + </LinearLayout> + + <include layout="@layout/layout_slider" /> + +</com.sothree.slidinguppanel.SlidingUpPanelLayout> \ No newline at end of file diff --git a/app/src/main/res/layout-sw600dp-land/layout_main.xml b/app/src/main/res/layout-sw600dp-land/layout_main.xml new file mode 100644 index 000000000..9ec10cd07 --- /dev/null +++ b/app/src/main/res/layout-sw600dp-land/layout_main.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout 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" + android:fitsSystemWindows="true" + android:orientation="vertical"> + + <include layout="@layout/layout_toolbar" /> + + <com.sothree.slidinguppanel.SlidingUpPanelLayout + android:id="@+id/editor_panel" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="bottom" + app:umanoAntiDragView="@id/card_panel" + app:umanoPanelHeight="?actionBarSize" + app:umanoScrollableView="@id/chatline_scroller" + app:umanoShadowHeight="4dp"> + + <fragment + android:id="@+id/fragment_messages" + android:name="de.kuschku.quasseldroid_ng.ui.chat.messages.MessageListFragment" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:layout="@layout/fragment_messages" /> + + <include layout="@layout/layout_slider" /> + + </com.sothree.slidinguppanel.SlidingUpPanelLayout> + +</LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/layout_editor.xml b/app/src/main/res/layout/layout_editor.xml index f2c4e903a..a1e6accbb 100644 --- a/app/src/main/res/layout/layout_editor.xml +++ b/app/src/main/res/layout/layout_editor.xml @@ -21,14 +21,15 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/transparent" - android:gravity="top" + android:gravity="center_vertical" android:hint="@string/label_placeholder" - android:imeOptions="actionSend|flagNoEnterAction" + android:imeOptions="actionSend|flagNoEnterAction|flagNoExtractUi" android:inputType="textCapSentences|textAutoCorrect|textShortMessage" - android:paddingBottom="17dp" + android:minHeight="?actionBarSize" + android:paddingBottom="8dp" android:paddingLeft="20dp" android:paddingRight="20dp" - android:paddingTop="17dp" + android:paddingTop="8dp" android:textColor="?attr/colorForeground" android:textSize="16sp" /> diff --git a/app/src/main/res/layout/layout_main.xml b/app/src/main/res/layout/layout_main.xml index ef45eb6e9..9ec10cd07 100644 --- a/app/src/main/res/layout/layout_main.xml +++ b/app/src/main/res/layout/layout_main.xml @@ -1,5 +1,4 @@ <?xml version="1.0" encoding="utf-8"?> - <LinearLayout 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" -- GitLab