ExactCalculator: Migrate to AndroidX
Change-Id: If67cc8334cfd3ac2575d8769690b613f6f09c735
diff --git a/Android.bp b/Android.bp
index 0b867ed..3fe7580 100644
--- a/Android.bp
+++ b/Android.bp
@@ -33,7 +33,11 @@
static_libs: [
"cr",
- "androidx.legacy_legacy-support-v4",
+ "androidx.core_core",
+ "androidx.annotation_annotation",
+ "androidx.appcompat_appcompat",
+ "androidx.customview_customview",
+ "androidx.fragment_fragment",
"androidx.gridlayout_gridlayout",
"androidx.recyclerview_recyclerview",
],
diff --git a/res/layout/fragment_history.xml b/res/layout/fragment_history.xml
index 0559c87..a235c51 100644
--- a/res/layout/fragment_history.xml
+++ b/res/layout/fragment_history.xml
@@ -22,18 +22,18 @@
android:clipChildren="false"
android:orientation="vertical">
- <Toolbar
+ <androidx.appcompat.widget.Toolbar
android:id="@+id/history_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:background="?android:attr/colorPrimary"
+ android:background="?attr/colorPrimary"
android:elevation="4dip"
- android:minHeight="?android:attr/actionBarSize"
+ android:minHeight="?attr/actionBarSize"
android:navigationContentDescription="@string/desc_navigate_up"
- android:navigationIcon="?android:attr/homeAsUpIndicator"
- android:popupTheme="@android:style/ThemeOverlay.Material.Light"
+ app:navigationIcon="?attr/homeAsUpIndicator"
+ android:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:theme="@style/Theme.Toolbar"
- android:title="@string/title_history" />
+ app:title="@string/title_history" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/history_recycler_view"
diff --git a/res/layout/history_item.xml b/res/layout/history_item.xml
index cf8b6c0..b903564 100644
--- a/res/layout/history_item.xml
+++ b/res/layout/history_item.xml
@@ -42,7 +42,7 @@
android:paddingStart="@dimen/result_padding_start"
android:paddingEnd="@dimen/result_padding_end"
android:text="@string/title_current_expression"
- android:textColor="?android:attr/colorAccent"
+ android:textColor="?attr/colorAccent"
android:textSize="14dp" />
<com.android.calculator2.CalculatorScrollView
diff --git a/res/layout/toolbar.xml b/res/layout/toolbar.xml
index 56f05b6..6c2102b 100644
--- a/res/layout/toolbar.xml
+++ b/res/layout/toolbar.xml
@@ -15,11 +15,11 @@
limitations under the License.
-->
-<Toolbar
+<androidx.appcompat.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
- android:layout_height="?android:attr/actionBarSize"
+ android:layout_height="?attr/actionBarSize"
android:layout_gravity="top">
<TextView
@@ -30,4 +30,4 @@
android:textAllCaps="true"
android:textSize="16sp" />
-</Toolbar>
\ No newline at end of file
+</androidx.appcompat.widget.Toolbar>
\ No newline at end of file
diff --git a/res/values-w230dp-h275dp/styles.xml b/res/values-w230dp-h275dp/styles.xml
index bbb38be..ae3b971 100644
--- a/res/values-w230dp-h275dp/styles.xml
+++ b/res/values-w230dp-h275dp/styles.xml
@@ -18,13 +18,13 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="PadButtonStyle.Advanced">
- <item name="android:background">@drawable/pad_button_advanced_background</item>
+ <item name="background">@drawable/pad_button_advanced_background</item>
<item name="android:textColor">@color/pad_button_advanced_text_color</item>
<item name="android:textSize">16dip</item>
</style>
<style name="PadButtonStyle.Advanced.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">14dip</item>
</style>
@@ -41,12 +41,12 @@
</style>
<style name="PadButtonStyle.Operator.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">14dip</item>
</style>
<style name="PadLayoutStyle.Advanced">
- <item name="android:elevation">4dip</item>
+ <item name="elevation">4dip</item>
<item name="android:paddingTop">2dip</item>
<item name="android:paddingBottom">8dip</item>
<item name="android:paddingStart">18dip</item>
diff --git a/res/values-w230dp-h375dp/styles.xml b/res/values-w230dp-h375dp/styles.xml
index c72fd3f..412c736 100644
--- a/res/values-w230dp-h375dp/styles.xml
+++ b/res/values-w230dp-h375dp/styles.xml
@@ -18,13 +18,13 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="PadButtonStyle.Advanced">
- <item name="android:background">@drawable/pad_button_advanced_background</item>
+ <item name="background">@drawable/pad_button_advanced_background</item>
<item name="android:textColor">@color/pad_button_advanced_text_color</item>
<item name="android:textSize">17dip</item>
</style>
<style name="PadButtonStyle.Advanced.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">15dip</item>
</style>
@@ -41,12 +41,12 @@
</style>
<style name="PadButtonStyle.Operator.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">15dip</item>
</style>
<style name="PadLayoutStyle.Advanced">
- <item name="android:elevation">4dip</item>
+ <item name="elevation">4dip</item>
<item name="android:paddingTop">2dip</item>
<item name="android:paddingBottom">8dip</item>
<item name="android:paddingStart">18dip</item>
diff --git a/res/values-w230dp-h475dp-port/styles.xml b/res/values-w230dp-h475dp-port/styles.xml
index 05987ad..da149ae 100644
--- a/res/values-w230dp-h475dp-port/styles.xml
+++ b/res/values-w230dp-h475dp-port/styles.xml
@@ -18,13 +18,13 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="PadButtonStyle.Advanced">
- <item name="android:background">@drawable/pad_button_advanced_background</item>
+ <item name="background">@drawable/pad_button_advanced_background</item>
<item name="android:textColor">@color/pad_button_advanced_text_color</item>
<item name="android:textSize">20dip</item>
</style>
<style name="PadButtonStyle.Advanced.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">17dip</item>
</style>
@@ -41,12 +41,12 @@
</style>
<style name="PadButtonStyle.Operator.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">17dip</item>
</style>
<style name="PadLayoutStyle.Advanced">
- <item name="android:elevation">4dip</item>
+ <item name="elevation">4dip</item>
<item name="android:paddingTop">12dip</item>
<item name="android:paddingBottom">20dip</item>
<item name="android:paddingStart">18dip</item>
diff --git a/res/values-w375dp-h220dp/styles.xml b/res/values-w375dp-h220dp/styles.xml
index 16931ff..500d54e 100644
--- a/res/values-w375dp-h220dp/styles.xml
+++ b/res/values-w375dp-h220dp/styles.xml
@@ -18,13 +18,13 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="PadButtonStyle.Advanced">
- <item name="android:background">@drawable/pad_button_advanced_background</item>
+ <item name="background">@drawable/pad_button_advanced_background</item>
<item name="android:textColor">@color/pad_button_advanced_text_color</item>
<item name="android:textSize">14dip</item>
</style>
<style name="PadButtonStyle.Advanced.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">12dip</item>
</style>
@@ -41,12 +41,12 @@
</style>
<style name="PadButtonStyle.Operator.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">12dip</item>
</style>
<style name="PadLayoutStyle.Advanced">
- <item name="android:elevation">4dip</item>
+ <item name="elevation">4dip</item>
<item name="android:paddingTop">2dip</item>
<item name="android:paddingBottom">8dip</item>
<item name="android:paddingStart">20dip</item>
diff --git a/res/values-w375dp-h275dp/styles.xml b/res/values-w375dp-h275dp/styles.xml
index efed4dc..eced6fc 100644
--- a/res/values-w375dp-h275dp/styles.xml
+++ b/res/values-w375dp-h275dp/styles.xml
@@ -18,13 +18,13 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="PadButtonStyle.Advanced">
- <item name="android:background">@drawable/pad_button_advanced_background</item>
+ <item name="background">@drawable/pad_button_advanced_background</item>
<item name="android:textColor">@color/pad_button_advanced_text_color</item>
<item name="android:textSize">17dip</item>
</style>
<style name="PadButtonStyle.Advanced.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">14dip</item>
</style>
@@ -41,12 +41,12 @@
</style>
<style name="PadButtonStyle.Operator.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">14dip</item>
</style>
<style name="PadLayoutStyle.Advanced">
- <item name="android:elevation">4dip</item>
+ <item name="elevation">4dip</item>
<item name="android:paddingTop">2dip</item>
<item name="android:paddingBottom">8dip</item>
<item name="android:paddingStart">20dip</item>
diff --git a/res/values-w375dp-h375dp/styles.xml b/res/values-w375dp-h375dp/styles.xml
index b1d4ac5..1e4ddbd 100644
--- a/res/values-w375dp-h375dp/styles.xml
+++ b/res/values-w375dp-h375dp/styles.xml
@@ -18,13 +18,13 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="PadButtonStyle.Advanced">
- <item name="android:background">@drawable/pad_button_advanced_background</item>
+ <item name="background">@drawable/pad_button_advanced_background</item>
<item name="android:textColor">@color/pad_button_advanced_text_color</item>
<item name="android:textSize">17dip</item>
</style>
<style name="PadButtonStyle.Advanced.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">15dip</item>
</style>
@@ -41,12 +41,12 @@
</style>
<style name="PadButtonStyle.Operator.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">15dip</item>
</style>
<style name="PadLayoutStyle.Advanced">
- <item name="android:elevation">4dip</item>
+ <item name="elevation">4dip</item>
<item name="android:paddingTop">2dip</item>
<item name="android:paddingBottom">8dip</item>
<item name="android:paddingStart">20dip</item>
diff --git a/res/values-w375dp-h500dp-port/styles.xml b/res/values-w375dp-h500dp-port/styles.xml
index 5f5057e..198ad2b 100644
--- a/res/values-w375dp-h500dp-port/styles.xml
+++ b/res/values-w375dp-h500dp-port/styles.xml
@@ -18,13 +18,13 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="PadButtonStyle.Advanced">
- <item name="android:background">@drawable/pad_button_advanced_background</item>
+ <item name="background">@drawable/pad_button_advanced_background</item>
<item name="android:textColor">@color/pad_button_advanced_text_color</item>
<item name="android:textSize">23dip</item>
</style>
<style name="PadButtonStyle.Advanced.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">20dip</item>
</style>
@@ -41,12 +41,12 @@
</style>
<style name="PadButtonStyle.Operator.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">20dip</item>
</style>
<style name="PadLayoutStyle.Advanced">
- <item name="android:elevation">4dip</item>
+ <item name="elevation">4dip</item>
<item name="android:paddingTop">12dip</item>
<item name="android:paddingBottom">20dip</item>
<item name="android:paddingStart">20dip</item>
diff --git a/res/values-w375dp-h768dp-port/styles.xml b/res/values-w375dp-h768dp-port/styles.xml
index 2c5ae35..6d8a33f 100644
--- a/res/values-w375dp-h768dp-port/styles.xml
+++ b/res/values-w375dp-h768dp-port/styles.xml
@@ -18,13 +18,13 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="PadButtonStyle.Advanced">
- <item name="android:background">@drawable/pad_button_advanced_background</item>
+ <item name="background">@drawable/pad_button_advanced_background</item>
<item name="android:textColor">@color/pad_button_advanced_text_color</item>
<item name="android:textSize">27dip</item>
</style>
<style name="PadButtonStyle.Advanced.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">24dip</item>
</style>
@@ -41,7 +41,7 @@
</style>
<style name="PadButtonStyle.Operator.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">24dip</item>
</style>
diff --git a/res/values-w520dp-h220dp-land/styles.xml b/res/values-w520dp-h220dp-land/styles.xml
index 536d5e7..d96b447 100644
--- a/res/values-w520dp-h220dp-land/styles.xml
+++ b/res/values-w520dp-h220dp-land/styles.xml
@@ -18,13 +18,13 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="PadButtonStyle.Advanced">
- <item name="android:background">@drawable/pad_button_advanced_background</item>
+ <item name="background">@drawable/pad_button_advanced_background</item>
<item name="android:textColor">@color/pad_button_advanced_text_color</item>
<item name="android:textSize">14dip</item>
</style>
<style name="PadButtonStyle.Advanced.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">12dip</item>
</style>
@@ -41,7 +41,7 @@
</style>
<style name="PadButtonStyle.Operator.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">12dip</item>
</style>
diff --git a/res/values-w520dp-h275dp-land/styles.xml b/res/values-w520dp-h275dp-land/styles.xml
index 003949e..3d8a630 100644
--- a/res/values-w520dp-h275dp-land/styles.xml
+++ b/res/values-w520dp-h275dp-land/styles.xml
@@ -18,13 +18,13 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="PadButtonStyle.Advanced">
- <item name="android:background">@drawable/pad_button_advanced_background</item>
+ <item name="background">@drawable/pad_button_advanced_background</item>
<item name="android:textColor">@color/pad_button_advanced_text_color</item>
<item name="android:textSize">17dip</item>
</style>
<style name="PadButtonStyle.Advanced.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">14dip</item>
</style>
@@ -41,7 +41,7 @@
</style>
<style name="PadButtonStyle.Operator.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">14dip</item>
</style>
diff --git a/res/values-w520dp-h375dp-land/styles.xml b/res/values-w520dp-h375dp-land/styles.xml
index 8c7d0ed..35b6a5d 100644
--- a/res/values-w520dp-h375dp-land/styles.xml
+++ b/res/values-w520dp-h375dp-land/styles.xml
@@ -18,13 +18,13 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="PadButtonStyle.Advanced">
- <item name="android:background">@drawable/pad_button_advanced_background</item>
+ <item name="background">@drawable/pad_button_advanced_background</item>
<item name="android:textColor">@color/pad_button_advanced_text_color</item>
<item name="android:textSize">20dip</item>
</style>
<style name="PadButtonStyle.Advanced.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">17dip</item>
</style>
@@ -41,7 +41,7 @@
</style>
<style name="PadButtonStyle.Operator.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">17dip</item>
</style>
diff --git a/res/values-w520dp-h500dp-land/styles.xml b/res/values-w520dp-h500dp-land/styles.xml
index e0cc0e2..3cecdb7 100644
--- a/res/values-w520dp-h500dp-land/styles.xml
+++ b/res/values-w520dp-h500dp-land/styles.xml
@@ -18,13 +18,13 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="PadButtonStyle.Advanced">
- <item name="android:background">@drawable/pad_button_advanced_background</item>
+ <item name="background">@drawable/pad_button_advanced_background</item>
<item name="android:textColor">@color/pad_button_advanced_text_color</item>
<item name="android:textSize">23dip</item>
</style>
<style name="PadButtonStyle.Advanced.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">20dip</item>
</style>
@@ -41,7 +41,7 @@
</style>
<style name="PadButtonStyle.Operator.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">20dip</item>
</style>
diff --git a/res/values-w520dp-h768dp-land/styles.xml b/res/values-w520dp-h768dp-land/styles.xml
index 61acbd2..d73acc5 100644
--- a/res/values-w520dp-h768dp-land/styles.xml
+++ b/res/values-w520dp-h768dp-land/styles.xml
@@ -18,13 +18,13 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="PadButtonStyle.Advanced">
- <item name="android:background">@drawable/pad_button_advanced_background</item>
+ <item name="background">@drawable/pad_button_advanced_background</item>
<item name="android:textColor">@color/pad_button_advanced_text_color</item>
<item name="android:textSize">30dip</item>
</style>
<style name="PadButtonStyle.Advanced.Text">
- <item name="android:textAllCaps">true</item>s
+ <item name="textAllCaps">true</item>s
<item name="android:textSize">26dip</item>
</style>
@@ -41,7 +41,7 @@
</style>
<style name="PadButtonStyle.Operator.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">26dip</item>
</style>
diff --git a/res/values-w520dp-h768dp-port/styles.xml b/res/values-w520dp-h768dp-port/styles.xml
index 9136b50..3a87da0 100644
--- a/res/values-w520dp-h768dp-port/styles.xml
+++ b/res/values-w520dp-h768dp-port/styles.xml
@@ -18,13 +18,13 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="PadButtonStyle.Advanced">
- <item name="android:background">@drawable/pad_button_advanced_background</item>
+ <item name="background">@drawable/pad_button_advanced_background</item>
<item name="android:textColor">@color/pad_button_advanced_text_color</item>
<item name="android:textSize">32dip</item>
</style>
<style name="PadButtonStyle.Advanced.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">28dip</item>
</style>
@@ -41,7 +41,7 @@
</style>
<style name="PadButtonStyle.Operator.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">28dip</item>
</style>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index d8df617..b544fe0 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -19,7 +19,7 @@
<style name="DisplayTextStyle" parent="@android:style/Widget.Material.Light.TextView">
<item name="android:cursorVisible">false</item>
- <item name="android:fontFamily">sans-serif</item>
+ <item name="fontFamily">sans-serif</item>
<item name="android:includeFontPadding">false</item>
<item name="android:gravity">bottom|end</item>
<item name="android:textAlignment">viewEnd</item>
@@ -61,14 +61,14 @@
<style name="PadButtonStyle" parent="@android:style/Widget.Material.Light.Button.Borderless">
<item name="android:layout_width">0dip</item>
<item name="android:layout_height">0dip</item>
- <item name="android:background">@drawable/pad_button_background</item>
- <item name="android:fontFamily">sans-serif</item>
+ <item name="background">@drawable/pad_button_background</item>
+ <item name="fontFamily">sans-serif</item>
<item name="android:gravity">center</item>
<item name="android:includeFontPadding">false</item>
<item name="android:minWidth">0dip</item>
<item name="android:minHeight">0dip</item>
<item name="android:onClick">onButtonClick</item>
- <item name="android:textAllCaps">false</item>
+ <item name="textAllCaps">false</item>
<item name="android:textColor">@color/pad_button_text_color</item>
<item name="android:fontFeatureSettings">tnum, cv03, cv04</item>
@@ -79,13 +79,13 @@
</style>
<style name="PadButtonStyle.Advanced">
- <item name="android:background">@drawable/pad_button_advanced_background</item>
+ <item name="background">@drawable/pad_button_advanced_background</item>
<item name="android:textColor">@color/pad_button_advanced_text_color</item>
<item name="android:textSize">14dip</item>
</style>
<style name="PadButtonStyle.Advanced.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">12dip</item>
</style>
@@ -102,7 +102,7 @@
</style>
<style name="PadButtonStyle.Operator.Text">
- <item name="android:textAllCaps">true</item>
+ <item name="textAllCaps">true</item>
<item name="android:textSize">12dip</item>
</style>
@@ -112,7 +112,7 @@
</style>
<style name="PadLayoutStyle.Advanced">
- <item name="android:elevation">4dip</item>
+ <item name="elevation">4dip</item>
<item name="android:paddingTop">2dip</item>
<item name="android:paddingBottom">8dip</item>
<item name="android:paddingStart">18dip</item>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 2104fe3..cc6dc3e 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -18,8 +18,8 @@
<resources>
<style name="Theme" parent="@android:style/Theme.Material.Light">
- <item name="android:colorPrimary">@color/calculator_primary_color</item>
- <item name="android:colorAccent">@color/calculator_accent_color</item>
+ <item name="colorPrimary">@color/calculator_primary_color</item>
+ <item name="colorAccent">@color/calculator_accent_color</item>
<item name="android:statusBarColor">@color/calculator_statusbar_color</item>
<item name="android:windowSoftInputMode">stateAlwaysHidden</item>
<item name="android:navigationBarColor">@color/navigationBar_color</item>
@@ -29,15 +29,15 @@
</style>
<style name="Theme.Calculator">
- <item name="android:windowActionBar">false</item>
- <item name="android:windowActionModeOverlay">true</item>
+ <item name="windowActionBar">false</item>
+ <item name="windowActionModeOverlay">true</item>
<item name="android:windowContentOverlay">@null</item>
- <item name="android:windowNoTitle">true</item>
+ <item name="windowNoTitle">true</item>
<item name="android:layoutDirection">ltr</item>
</style>
<style name="Theme.Licenses">
- <item name="android:title">@string/menu_licenses</item>
+ <item name="title">@string/menu_licenses</item>
</style>
</resources>
diff --git a/src/com/android/calculator2/AlertDialogFragment.java b/src/com/android/calculator2/AlertDialogFragment.java
index 3939a73..e7a3110 100644
--- a/src/com/android/calculator2/AlertDialogFragment.java
+++ b/src/com/android/calculator2/AlertDialogFragment.java
@@ -17,17 +17,19 @@
package com.android.calculator2;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
-import android.app.DialogFragment;
-import android.app.FragmentManager;
import android.content.DialogInterface;
import android.os.Bundle;
-import androidx.annotation.Nullable;
-import androidx.annotation.StringRes;
import android.view.LayoutInflater;
import android.widget.TextView;
+import androidx.annotation.Nullable;
+import androidx.annotation.StringRes;
+import androidx.appcompat.app.AlertDialog;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.fragment.app.DialogFragment;
+import androidx.fragment.app.FragmentManager;
+
/**
* Display a message with a dismiss putton, and optionally a second button.
*/
@@ -61,8 +63,9 @@
* @param positiveButtonLabel label for second button, if any. If non-null, activity must
* implement AlertDialogFragment.OnClickListener to respond.
*/
- public static void showMessageDialog(Activity activity, @StringRes int title,
- @StringRes int message, @StringRes int positiveButtonLabel, @Nullable String tag) {
+ public static void showMessageDialog(AppCompatActivity activity, @StringRes int title,
+ @StringRes int message, @StringRes int positiveButtonLabel,
+ @Nullable String tag) {
showMessageDialog(activity, title != 0 ? activity.getString(title) : null,
activity.getString(message),
positiveButtonLabel != 0 ? activity.getString(positiveButtonLabel) : null,
@@ -78,10 +81,12 @@
* @param positiveButtonLabel label for second button, if any. If non-null, activity must
* implement AlertDialogFragment.OnClickListener to respond.
*/
- public static void showMessageDialog(Activity activity, @Nullable CharSequence title,
- CharSequence message, @Nullable CharSequence positiveButtonLabel, @Nullable String tag)
+ public static void showMessageDialog(AppCompatActivity activity, @Nullable CharSequence title,
+ CharSequence message,
+ @Nullable CharSequence positiveButtonLabel,
+ @Nullable String tag)
{
- final FragmentManager manager = activity.getFragmentManager();
+ final FragmentManager manager = activity.getSupportFragmentManager();
if (manager == null || manager.isDestroyed()) {
return;
}
diff --git a/src/com/android/calculator2/AlignedTextView.java b/src/com/android/calculator2/AlignedTextView.java
index 91ad0dd..d27c9ac 100644
--- a/src/com/android/calculator2/AlignedTextView.java
+++ b/src/com/android/calculator2/AlignedTextView.java
@@ -22,10 +22,12 @@
import android.util.AttributeSet;
import android.widget.TextView;
+import androidx.appcompat.widget.AppCompatTextView;
+
/**
* Extended {@link TextView} that supports ascent/baseline alignment.
*/
-public class AlignedTextView extends TextView {
+public class AlignedTextView extends AppCompatTextView {
private static final String LATIN_CAPITAL_LETTER = "H";
diff --git a/src/com/android/calculator2/Calculator.java b/src/com/android/calculator2/Calculator.java
index 3f00170..260bac4 100644
--- a/src/com/android/calculator2/Calculator.java
+++ b/src/com/android/calculator2/Calculator.java
@@ -25,17 +25,14 @@
package com.android.calculator2;
+import static com.android.calculator2.CalculatorFormula.OnFormulaContextMenuClickListener;
+
import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
-import android.app.ActionBar;
-import android.app.Activity;
-import android.app.Fragment;
-import android.app.FragmentManager;
-import android.app.FragmentTransaction;
import android.content.ClipData;
import android.content.DialogInterface;
import android.content.Intent;
@@ -44,10 +41,6 @@
import android.graphics.Rect;
import android.net.Uri;
import android.os.Bundle;
-import androidx.annotation.NonNull;
-import androidx.annotation.StringRes;
-import androidx.core.content.ContextCompat;
-import androidx.viewpager.widget.ViewPager;
import android.text.Editable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
@@ -70,7 +63,17 @@
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.HorizontalScrollView;
import android.widget.TextView;
-import android.widget.Toolbar;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.StringRes;
+import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentManager;
+import androidx.fragment.app.FragmentTransaction;
+import androidx.viewpager.widget.ViewPager;
import com.android.calculator2.CalculatorFormula.OnTextSizeChangeListener;
@@ -83,9 +86,7 @@
import java.io.ObjectOutputStream;
import java.text.DecimalFormatSymbols;
-import static com.android.calculator2.CalculatorFormula.OnFormulaContextMenuClickListener;
-
-public class Calculator extends Activity
+public class Calculator extends AppCompatActivity
implements OnTextSizeChangeListener, OnLongClickListener,
AlertDialogFragment.OnClickListener, Evaluator.EvaluationListener /* for main result */,
DragLayout.CloseCallback, DragLayout.DragCallback {
@@ -357,13 +358,13 @@
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_calculator_main);
- setActionBar((Toolbar) findViewById(R.id.toolbar));
+ setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
// Hide all default options in the ActionBar.
- getActionBar().setDisplayOptions(0);
+ getSupportActionBar().setDisplayOptions(0);
// Ensure the toolbar stays visible while the options menu is displayed.
- getActionBar().addOnMenuVisibilityListener(new ActionBar.OnMenuVisibilityListener() {
+ getSupportActionBar().addOnMenuVisibilityListener(new ActionBar.OnMenuVisibilityListener() {
@Override
public void onMenuVisibilityChanged(boolean isVisible) {
mDisplayView.setForceToolbarVisible(isVisible);
@@ -727,7 +728,7 @@
}
private void removeHistoryFragment() {
- final FragmentManager manager = getFragmentManager();
+ final FragmentManager manager = getSupportFragmentManager();
if (manager != null && !manager.isDestroyed()) {
manager.popBackStack(HistoryFragment.TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
}
@@ -1355,7 +1356,7 @@
}
private HistoryFragment getHistoryFragment() {
- final FragmentManager manager = getFragmentManager();
+ final FragmentManager manager = getSupportFragmentManager();
if (manager == null || manager.isDestroyed()) {
return null;
}
@@ -1369,7 +1370,7 @@
return;
}
- final FragmentManager manager = getFragmentManager();
+ final FragmentManager manager = getSupportFragmentManager();
if (manager == null || manager.isDestroyed() || !prepareForHistory()) {
// If the history fragment can not be shown, close the draglayout.
mDragLayout.setClosed();
diff --git a/src/com/android/calculator2/CalculatorDisplay.java b/src/com/android/calculator2/CalculatorDisplay.java
index 341564d..9960cb2 100644
--- a/src/com/android/calculator2/CalculatorDisplay.java
+++ b/src/com/android/calculator2/CalculatorDisplay.java
@@ -26,7 +26,8 @@
import android.view.View;
import android.view.accessibility.AccessibilityManager;
import android.widget.LinearLayout;
-import android.widget.Toolbar;
+
+import androidx.appcompat.widget.Toolbar;
public class CalculatorDisplay extends LinearLayout
implements AccessibilityManager.AccessibilityStateChangeListener {
diff --git a/src/com/android/calculator2/CalculatorExpr.java b/src/com/android/calculator2/CalculatorExpr.java
index e6b5870..bc40a71 100644
--- a/src/com/android/calculator2/CalculatorExpr.java
+++ b/src/com/android/calculator2/CalculatorExpr.java
@@ -30,7 +30,6 @@
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashSet;
/**
* A mathematical expression represented as a sequence of "tokens".
diff --git a/src/com/android/calculator2/ExpressionDB.java b/src/com/android/calculator2/ExpressionDB.java
index 9a0f8ec..68205b5 100644
--- a/src/com/android/calculator2/ExpressionDB.java
+++ b/src/com/android/calculator2/ExpressionDB.java
@@ -38,7 +38,6 @@
package com.android.calculator2;
-import android.app.Activity;
import android.content.ContentValues;
import android.content.Context;
import android.database.AbstractWindowedCursor;
@@ -50,7 +49,6 @@
import android.os.AsyncTask;
import android.provider.BaseColumns;
import android.util.Log;
-import android.view.View;
public class ExpressionDB {
private final boolean CONTINUE_WITH_BAD_DB = false;
diff --git a/src/com/android/calculator2/HapticButton.java b/src/com/android/calculator2/HapticButton.java
index a1f8c90..e58265a 100644
--- a/src/com/android/calculator2/HapticButton.java
+++ b/src/com/android/calculator2/HapticButton.java
@@ -16,18 +16,18 @@
package com.android.calculator2;
-import android.widget.Button;
import android.content.Context;
import android.util.AttributeSet;
-import android.view.View;
-import android.view.LayoutInflater;
-import android.view.MotionEvent;
import android.view.HapticFeedbackConstants;
+import android.view.MotionEvent;
+import android.view.View;
+
+import androidx.appcompat.widget.AppCompatButton;
/**
* A basic Button that vibrates on finger down.
*/
-public class HapticButton extends Button {
+public class HapticButton extends AppCompatButton {
public HapticButton(Context context) {
super(context);
initVibration(context);
@@ -43,11 +43,6 @@
initVibration(context);
}
- public HapticButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
- super(context, attrs, defStyleAttr, defStyleRes);
- initVibration(context);
- }
-
private void initVibration(Context context) {
setOnTouchListener(new View.OnTouchListener() {
@Override
diff --git a/src/com/android/calculator2/HapticImageButton.java b/src/com/android/calculator2/HapticImageButton.java
index b315559..a4623ce 100644
--- a/src/com/android/calculator2/HapticImageButton.java
+++ b/src/com/android/calculator2/HapticImageButton.java
@@ -16,17 +16,18 @@
package com.android.calculator2;
-import android.widget.ImageButton;
import android.content.Context;
import android.util.AttributeSet;
-import android.view.View;
-import android.view.MotionEvent;
import android.view.HapticFeedbackConstants;
+import android.view.MotionEvent;
+import android.view.View;
+
+import androidx.appcompat.widget.AppCompatImageButton;
/**
* A basic ImageButton that vibrates on finger down.
*/
-public class HapticImageButton extends ImageButton {
+public class HapticImageButton extends AppCompatImageButton {
public HapticImageButton(Context context) {
super(context);
initVibration(context);
@@ -42,11 +43,6 @@
initVibration(context);
}
- public HapticImageButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
- super(context, attrs, defStyleAttr, defStyleRes);
- initVibration(context);
- }
-
private void initVibration(Context context) {
setOnTouchListener(new View.OnTouchListener() {
@Override
diff --git a/src/com/android/calculator2/HistoryFragment.java b/src/com/android/calculator2/HistoryFragment.java
index eb2a325..a09bb53 100644
--- a/src/com/android/calculator2/HistoryFragment.java
+++ b/src/com/android/calculator2/HistoryFragment.java
@@ -16,21 +16,22 @@
package com.android.calculator2;
+import static androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_DRAGGING;
+
import android.animation.Animator;
-import android.app.Fragment;
import android.os.Bundle;
-import androidx.core.content.ContextCompat;
-import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.Toolbar;
+
+import androidx.appcompat.widget.Toolbar;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
-import static androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_DRAGGING;
-
public class HistoryFragment extends Fragment implements DragLayout.DragCallback {
public static final String TAG = "HistoryFragment";
diff --git a/src/com/android/calculator2/KeyMaps.java b/src/com/android/calculator2/KeyMaps.java
index 446c9b6..af700ed 100644
--- a/src/com/android/calculator2/KeyMaps.java
+++ b/src/com/android/calculator2/KeyMaps.java
@@ -16,13 +16,14 @@
package com.android.calculator2;
-import android.content.res.Resources;
import android.content.Context;
-import android.app.Activity;
+import android.content.res.Resources;
import android.util.Log;
import android.view.View;
import android.widget.Button;
+import androidx.appcompat.app.AppCompatActivity;
+
import java.text.DecimalFormatSymbols;
import java.util.HashMap;
import java.util.Locale;
@@ -435,13 +436,13 @@
/**
* Activity to use for looking up buttons.
*/
- private static Activity mActivity;
+ private static AppCompatActivity mActivity;
/**
* Set acttivity used for looking up button labels.
* Call only from UI thread.
*/
- public static void setActivity(Activity a) {
+ public static void setActivity(AppCompatActivity a) {
mActivity = a;
}
diff --git a/src/com/android/calculator2/Licenses.java b/src/com/android/calculator2/Licenses.java
index 4af1ea6..0ec17d7 100644
--- a/src/com/android/calculator2/Licenses.java
+++ b/src/com/android/calculator2/Licenses.java
@@ -1,11 +1,12 @@
package com.android.calculator2;
-import android.app.Activity;
import android.os.Bundle;
import android.view.MenuItem;
import android.webkit.WebView;
-public class Licenses extends Activity {
+import androidx.appcompat.app.AppCompatActivity;
+
+public class Licenses extends AppCompatActivity {
private static final String LICENSE_URL = "file:///android_asset/licenses.html";