clipboard: Vertical layout

Put the recently copied text at the top and the pinned text at the
bottom.
This should remain intuitive as the recent history should stay small.
This commit is contained in:
Jules Aguillon 2024-06-16 20:42:40 +02:00
parent d657d51c2b
commit 3b2fad8996
7 changed files with 59 additions and 16 deletions

View File

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:id="@+id/clipboard_entry_text" style="@style/clipboardEntry"/>
<LinearLayout style="@style/clipboardEntryButtons">
<View android:id="@+id/clipboard_entry_addpin" style="@style/clipboardEntryButton" android:background="@android:drawable/ic_menu_add"/>
</LinearLayout>
</LinearLayout>

View File

@ -1,14 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:background="?attr/colorKeyboard" android:hardwareAccelerated="false">
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="@dimen/clipboard_view_height">
<LinearLayout android:orientation="vertical" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="fill_parent">
<ScrollView android:layout_width="fill_parent" android:layout_height="@dimen/clipboard_view_height">
<LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:text="@string/clipboard_history_heading" style="@style/clipboardHeading" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
<juloo.keyboard2.ClipboardHistoryView android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:divider="?attr/clipboard_divider_color" android:dividerHeight="?attr/clipboard_divider_height"/>
</LinearLayout>
<LinearLayout android:orientation="vertical" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="fill_parent">
<juloo.keyboard2.ClipboardHistoryView android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:divider="?attr/clipboard_divider_color" android:dividerHeight="?attr/clipboard_divider_height"/>
<TextView android:text="@string/clipboard_pin_heading" style="@style/clipboardHeading" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
<juloo.keyboard2.ClipboardPinView android:id="@+id/clipboard_pin_view" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:divider="?attr/clipboard_divider_color" android:dividerHeight="?attr/clipboard_divider_height"/>
</LinearLayout>
<juloo.keyboard2.ClipboardPinView android:id="@+id/clipboard_pin_view" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:divider="?attr/clipboard_divider_color" android:dividerHeight="?attr/clipboard_divider_height"/>
</LinearLayout>
</ScrollView>
<juloo.keyboard2.Keyboard2View layout="@xml/clipboard_bottom_row" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="?attr/colorKeyboard"/>
</LinearLayout>

View File

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:id="@+id/clipboard_pin_text" style="@style/clipboardEntry" android:maxLines="3"/>
<LinearLayout style="@style/clipboardEntryButtons">
<View android:id="@+id/clipboard_pin_remove" style="@style/clipboardEntryButton" android:background="@android:drawable/ic_menu_delete"/>
</LinearLayout>
</LinearLayout>

View File

@ -34,12 +34,17 @@
<item name="android:fontWeight">700</item>
<item name="android:textColor">?attr/colorSubLabel</item>
</style>
<style name="clipboardEntryButtons">
<item name="android:orientation">horizontal</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_gravity">center_vertical</item>
<item name="android:layout_marginRight">12dp</item>
</style>
<style name="clipboardEntryButton">
<item name="android:layout_gravity">top</item>
<item name="android:layout_width">24dp</item>
<item name="android:layout_height">24dp</item>
<item name="android:layout_marginVertical">14dp</item>
<item name="android:layout_marginRight">6dp</item>
<item name="android:layout_marginHorizontal">2dp</item>
</style>
<!-- Launcher activity -->
<style name="paragraph">

View File

@ -5,13 +5,12 @@ import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public final class ClipboardHistoryView extends ListView
public final class ClipboardHistoryView extends NonScrollListView
implements ClipboardHistoryService.OnClipboardHistoryChange
{
List<String> _history;

View File

@ -6,7 +6,6 @@ import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Collections;
@ -14,7 +13,7 @@ import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
public final class ClipboardPinView extends ListView
public final class ClipboardPinView extends NonScrollListView
{
/** Preference file name that store pinned clipboards. */
static final String PERSIST_FILE_NAME = "clipboards";

View File

@ -0,0 +1,38 @@
package juloo.keyboard2;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View.MeasureSpec;
import android.view.ViewGroup;
import android.widget.ListView;
/** A non-scrollable list view that can be embedded in a bigger ScrollView.
Credits to Dedaniya HirenKumar in
https://stackoverflow.com/questions/18813296/non-scrollable-listview-inside-scrollview */
public class NonScrollListView extends ListView
{
public NonScrollListView(Context context)
{
super(context);
}
public NonScrollListView(Context context, AttributeSet attrs)
{
super(context, attrs);
}
public NonScrollListView(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
int heightMeasureSpec_custom = MeasureSpec.makeMeasureSpec(
Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, heightMeasureSpec_custom);
ViewGroup.LayoutParams params = getLayoutParams();
params.height = getMeasuredHeight();
}
}