ExactCalculator: Add drag handle to display view
Change-Id: I11acc81cfe91e64a873c3095bdd7b03644bb5cb2
diff --git a/res/drawable/drag_handle.xml b/res/drawable/drag_handle.xml
new file mode 100644
index 0000000..ca119dc
--- /dev/null
+++ b/res/drawable/drag_handle.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SPDX-FileCopyrightText: 2023 The LineageOS Project
+ SPDX-License-Identifier: Apache-2.0
+-->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <solid android:color="@android:color/white" />
+ <corners android:radius="2.0dip" />
+</shape>
diff --git a/res/layout/display_one_line.xml b/res/layout/display_one_line.xml
index ca694b5..e5a83b3 100644
--- a/res/layout/display_one_line.xml
+++ b/res/layout/display_one_line.xml
@@ -19,7 +19,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/display"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
+ android:layout_height="match_parent"
android:background="@drawable/rounded_bottom"
android:clipChildren="false"
android:elevation="4dip"
@@ -29,13 +29,13 @@
<FrameLayout
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="0dp"
+ android:layout_weight="1">
<com.android.calculator2.CalculatorScrollView
- android:id="@+id/formula_container"
+ android:id="@+id/formula_scroll_view"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom"
+ android:layout_height="match_parent"
android:overScrollMode="never"
android:scrollbars="none">
@@ -44,9 +44,7 @@
style="@style/DisplayTextStyle.Formula"
android:layout_width="wrap_content"
android:layout_height="match_parent"
- android:layout_gravity="bottom|end"
android:ellipsize="none"
- android:gravity="bottom|end"
android:longClickable="true"
android:singleLine="true"
android:textColor="@color/display_formula_text_color"
@@ -58,13 +56,13 @@
android:id="@+id/result"
style="@style/DisplayTextStyle.Result"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom"
+ android:layout_height="match_parent"
android:bufferType="spannable"
android:singleLine="true"
android:textColor="@color/display_result_text_color"
android:visibility="invisible" />
-
</FrameLayout>
+ <include layout="@layout/drag_handle" />
+
</com.android.calculator2.CalculatorDisplay>
diff --git a/res/layout/display_two_line.xml b/res/layout/display_two_line.xml
index 59dd4f9..1b36799 100644
--- a/res/layout/display_two_line.xml
+++ b/res/layout/display_two_line.xml
@@ -19,38 +19,48 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/display"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
+ android:layout_height="match_parent"
android:background="@drawable/rounded_bottom"
android:elevation="4dip"
android:orientation="vertical">
<include layout="@layout/toolbar" />
- <com.android.calculator2.CalculatorScrollView
- android:id="@+id/formula_container"
+ <LinearLayout
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:overScrollMode="never"
- android:scrollbars="none">
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:orientation="vertical">
- <com.android.calculator2.CalculatorFormula
- android:id="@+id/formula"
- style="@style/DisplayTextStyle.Formula"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:ellipsize="none"
- android:maxLines="1"
- android:textColor="@color/display_formula_text_color" />
+ <com.android.calculator2.CalculatorScrollView
+ android:id="@+id/formula_scroll_view"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:overScrollMode="never"
+ android:scrollbars="none">
- </com.android.calculator2.CalculatorScrollView>
+ <com.android.calculator2.CalculatorFormula
+ android:id="@+id/formula"
+ style="@style/DisplayTextStyle.Formula"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:ellipsize="none"
+ android:maxLines="1"
+ android:textColor="@color/display_formula_text_color" />
+ </com.android.calculator2.CalculatorScrollView>
- <com.android.calculator2.CalculatorResult
- android:id="@+id/result"
- style="@style/DisplayTextStyle.Result"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:bufferType="spannable"
- android:singleLine="true"
- android:textColor="@color/display_result_text_color" />
+ <com.android.calculator2.CalculatorResult
+ android:id="@+id/result"
+ style="@style/DisplayTextStyle.Result"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:bufferType="spannable"
+ android:singleLine="true"
+ android:textColor="@color/display_result_text_color" />
+ </LinearLayout>
+
+ <include layout="@layout/drag_handle" />
</com.android.calculator2.CalculatorDisplay>
diff --git a/res/layout/drag_handle.xml b/res/layout/drag_handle.xml
new file mode 100644
index 0000000..39fbf5b
--- /dev/null
+++ b/res/layout/drag_handle.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SPDX-FileCopyrightText: 2023 The LineageOS Project
+ SPDX-License-Identifier: Apache-2.0
+-->
+<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/drag_handle_view"
+ android:layout_width="24.0dip"
+ android:layout_height="4.0dip"
+ android:layout_gravity="bottom|center"
+ android:layout_marginBottom="@dimen/drag_handle_margin"
+ android:layout_marginTop="@dimen/drag_handle_margin"
+ android:clickable="false"
+ android:importantForAccessibility="no"
+ android:src="@drawable/drag_handle"
+ app:tint="?android:textColorSecondary" />
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index e431b75..abf3a45 100644
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -16,6 +16,8 @@
-->
<resources>
+ <dimen name="drag_handle_margin">16dp</dimen>
+
<!-- Dimens for display formula. -->
<dimen name="formula_padding_top">32dip</dimen>
<dimen name="formula_padding_bottom">22dip</dimen>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 567f2b0..3be01ea 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -22,6 +22,7 @@
<dimen name="history_item_text_padding_top">8dip</dimen>
<dimen name="history_item_text_padding_bottom">16dip</dimen>
+ <dimen name="drag_handle_margin">8dp</dimen>
<dimen name="display_corner_radius">16dp</dimen>
<!-- Dimens for display formula. -->
diff --git a/src/com/android/calculator2/Calculator.java b/src/com/android/calculator2/Calculator.java
index dac1503..cda4f3e 100644
--- a/src/com/android/calculator2/Calculator.java
+++ b/src/com/android/calculator2/Calculator.java
@@ -344,7 +344,7 @@
mModeView = (TextView) findViewById(R.id.mode);
mFormulaText = (CalculatorFormula) findViewById(R.id.formula);
mResultText = (CalculatorResult) findViewById(R.id.result);
- mFormulaContainer = (HorizontalScrollView) findViewById(R.id.formula_container);
+ mFormulaContainer = (HorizontalScrollView) findViewById(R.id.formula_scroll_view);
mEvaluator = Evaluator.getInstance(this);
mEvaluator.setCallback(mEvaluatorCallback);
mResultText.setEvaluator(mEvaluator, Evaluator.MAIN_INDEX);