From 70cb4955f1c099b030567e6bf4702f7dc6ee521a Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Thu, 14 Apr 2022 11:29:27 +0200 Subject: android: Port from Android Support Lib to AndroidX Replace the no longer maintained Android Support Library with the Android Jetpack libraries. Quoting [1]: > Version 28.0.0 is the last release of the Support Library. There will be > no more android.support library releases. All new feature development > will be in the androidx namespace. Most porting was done automatically by using Android Studio's "Refactor" -> "Migrate to AndroidX..." function. In `android/source/res/layout/toolbar_bottom.xml` and `android/source/res/layout/toolbar_color_picker.xml`, the uses of `app:layout_behavior="android.support.design.widget.BottomSheetBehavior"` had to be replaced manually as described at [2], because the app would crash when using the old "android.support" values. Also drop the Android Support Library related bits from configure.ac In a quick test, this worked fine and no obvious difference was visible when running this in various AVDs. When trying to test this in an x86 AVD still using SDK 16 (Android 4.1), which is currently specified as Android Viewer's `minSdkVersion`, only various unrelated issues showed up, some of which will be handled in follow-up commits. After the migration, many weird errors showed up in Android Studio, which disappeared after invalidating the caches (via "File" -> "Invalidate Caches..."). [1] https://developer.android.com/jetpack/androidx [2] https://stackoverflow.com/questions/45100963/runtimeexception-could-not-inflate-behavior-subclass Change-Id: I2a57f0ebd56e7ecc09b7d65aae17fd15088a633b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133002 Tested-by: Jenkins Reviewed-by: Michael Weghorn --- android/source/AndroidManifest.xml | 2 +- android/source/build.gradle | 4 ++-- android/source/gradle.properties | 2 ++ .../res/layout/activity_document_browser.xml | 28 +++++++++++----------- android/source/res/layout/activity_main.xml | 14 +++++------ android/source/res/layout/number_picker.xml | 4 ++-- android/source/res/layout/toolbar_bottom.xml | 2 +- android/source/res/layout/toolbar_color_picker.xml | 12 +++++----- .../java/org/libreoffice/AboutDialogFragment.java | 4 ++-- .../java/org/libreoffice/ColorPaletteAdapter.java | 4 ++-- .../java/org/libreoffice/ColorPickerAdapter.java | 4 ++-- .../src/java/org/libreoffice/FontController.java | 6 ++--- .../java/org/libreoffice/FormattingController.java | 4 ++-- .../org/libreoffice/LibreOfficeMainActivity.java | 10 ++++---- .../org/libreoffice/PasswordDialogFragment.java | 6 ++--- .../java/org/libreoffice/PresentationActivity.java | 8 +++---- .../java/org/libreoffice/ToolbarController.java | 2 +- .../org/libreoffice/UNOCommandsController.java | 2 +- .../java/org/libreoffice/canvas/BitmapHandle.java | 2 +- .../libreoffice/overlay/CalcHeadersController.java | 2 +- .../org/libreoffice/overlay/CalcHeadersView.java | 2 +- .../org/libreoffice/ui/LibreOfficeUIActivity.java | 18 +++++++------- .../org/libreoffice/ui/RecentFilesAdapter.java | 4 ++-- 23 files changed, 73 insertions(+), 73 deletions(-) (limited to 'android') diff --git a/android/source/AndroidManifest.xml b/android/source/AndroidManifest.xml index 987aeed66ae6..43f790fca985 100644 --- a/android/source/AndroidManifest.xml +++ b/android/source/AndroidManifest.xml @@ -116,7 +116,7 @@ diff --git a/android/source/build.gradle b/android/source/build.gradle index a690749ff0ee..7dc93e778a7c 100644 --- a/android/source/build.gradle +++ b/android/source/build.gradle @@ -27,8 +27,8 @@ dependencies { "libreoffice.jar", "unoloader.jar" ]) - implementation 'com.android.support:design:27.1.1' // also pulls-in corresponding support libraries - implementation 'com.android.support.constraint:constraint-layout:1.1.2' + implementation 'com.google.android.material:material:1.0.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' } android { diff --git a/android/source/gradle.properties b/android/source/gradle.properties index ad1671ef57fd..414d53485e7f 100644 --- a/android/source/gradle.properties +++ b/android/source/gradle.properties @@ -1 +1,3 @@ +android.enableJetifier=true +android.useAndroidX=true org.gradle.jvmargs=-Xmx3072m diff --git a/android/source/res/layout/activity_document_browser.xml b/android/source/res/layout/activity_document_browser.xml index 559d92efbb38..1632770d97a8 100644 --- a/android/source/res/layout/activity_document_browser.xml +++ b/android/source/res/layout/activity_document_browser.xml @@ -6,7 +6,7 @@ License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - - - + - - @@ -99,7 +99,7 @@ android:textStyle="bold" /> - - + - + - - - - - - + diff --git a/android/source/res/layout/activity_main.xml b/android/source/res/layout/activity_main.xml index c2528023d0f8..bd444f9fe79f 100644 --- a/android/source/res/layout/activity_main.xml +++ b/android/source/res/layout/activity_main.xml @@ -1,5 +1,5 @@ - - @@ -18,12 +18,12 @@ android:layout_height="match_parent" android:orientation="vertical"> - - - + - + - + diff --git a/android/source/res/layout/number_picker.xml b/android/source/res/layout/number_picker.xml index 51463926c70f..32eea0e80a84 100644 --- a/android/source/res/layout/number_picker.xml +++ b/android/source/res/layout/number_picker.xml @@ -1,5 +1,5 @@ - - \ No newline at end of file + diff --git a/android/source/res/layout/toolbar_bottom.xml b/android/source/res/layout/toolbar_bottom.xml index f4b3f3c5f8cc..7d420f35cbca 100644 --- a/android/source/res/layout/toolbar_bottom.xml +++ b/android/source/res/layout/toolbar_bottom.xml @@ -13,7 +13,7 @@ app:popupTheme="@style/LibreOfficeTheme.Toolbar" app:theme="@style/LibreOfficeTheme.Toolbar" tools:showIn="@layout/activity_main" - app:layout_behavior="android.support.design.widget.BottomSheetBehavior" + app:layout_behavior="@string/bottom_sheet_behavior" app:behavior_hideable="true" app:behavior_peekHeight="0dp"> diff --git a/android/source/res/layout/toolbar_color_picker.xml b/android/source/res/layout/toolbar_color_picker.xml index 9393259123be..e80f25bf46f6 100644 --- a/android/source/res/layout/toolbar_color_picker.xml +++ b/android/source/res/layout/toolbar_color_picker.xml @@ -12,7 +12,7 @@ app:popupTheme="@style/LibreOfficeTheme.Toolbar" app:theme="@style/LibreOfficeTheme.Toolbar" tools:showIn="@layout/activity_main" - app:layout_behavior="android.support.design.widget.BottomSheetBehavior" + app:layout_behavior="@string/bottom_sheet_behavior" app:behavior_hideable="true" app:behavior_peekHeight="0dp"> @@ -29,15 +29,15 @@ android:background="@drawable/image_button_background" android:layout_marginBottom="10dp"/> - - + - - + - \ No newline at end of file + diff --git a/android/source/src/java/org/libreoffice/AboutDialogFragment.java b/android/source/src/java/org/libreoffice/AboutDialogFragment.java index b8e22077e928..9695d1e9d650 100644 --- a/android/source/src/java/org/libreoffice/AboutDialogFragment.java +++ b/android/source/src/java/org/libreoffice/AboutDialogFragment.java @@ -18,8 +18,8 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.net.Uri; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.v4.app.DialogFragment; +import androidx.annotation.NonNull; +import androidx.fragment.app.DialogFragment; import android.text.Html; import android.text.Spanned; import android.text.method.LinkMovementMethod; diff --git a/android/source/src/java/org/libreoffice/ColorPaletteAdapter.java b/android/source/src/java/org/libreoffice/ColorPaletteAdapter.java index 6ec6aa138f66..41aed46ca915 100644 --- a/android/source/src/java/org/libreoffice/ColorPaletteAdapter.java +++ b/android/source/src/java/org/libreoffice/ColorPaletteAdapter.java @@ -1,7 +1,7 @@ package org.libreoffice; import android.content.Context; -import android.support.v7.widget.RecyclerView; +import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -128,4 +128,4 @@ public class ColorPaletteAdapter extends RecyclerView.Adapter