Skip to content

Commit

Permalink
Switch to AndroidX (fix cgeo#7748)
Browse files Browse the repository at this point in the history
Switch to AndroidX (fix cgeo#7748)

in addition to the automatic changes (and manual polish)
- edit checkstyle rule: ImportOrder; add androidx group after android
- it was necessary to update butterknife, use newest (10.2.0)
- replace ButterKnife.findById by findViewById (findById was removed in ButterKnife)
- remove unused: main\thirdparty\android\support\v4\app\FragmentListActivity.java
- Then updated to the latest androidx versions.
  • Loading branch information
bekuno authored and moving-bits committed Dec 14, 2019
1 parent 1089fab commit b912a9f
Show file tree
Hide file tree
Showing 386 changed files with 1,174 additions and 1,295 deletions.
4 changes: 2 additions & 2 deletions cgeo-contacts/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ dependencies {
implementation 'org.apache.commons:commons-lang3:3.5'

// Support Library AppCompat
implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
implementation 'androidx.appcompat:appcompat:1.1.0'

// Android annotations
implementation "com.android.support:support-annotations:$supportLibraryVersion"
implementation 'androidx.annotation:annotation:1.1.0'
}

/*
Expand Down
3 changes: 2 additions & 1 deletion cgeo-contacts/src/cgeo/contacts/ContactsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
import android.os.Bundle;
import android.provider.BaseColumns;
import android.provider.ContactsContract;
import android.support.annotation.NonNull;
import android.util.Log;
import android.util.Pair;
import android.view.Gravity;
import android.widget.Toast;

import androidx.annotation.NonNull;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;

import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

public class PermissionHandler {

Expand Down
2 changes: 1 addition & 1 deletion checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
<property name="severity" value="info" />
</module>
<module name="ImportOrder">
<property name="groups" value="cgeo,android,java,javax,*"/>
<property name="groups" value="cgeo,android,androidx,java,javax,*"/>
<property name="ordered" value="true"/>
<property name="separated" value="true"/>
<property name="option" value="top"/>
Expand Down
2 changes: 1 addition & 1 deletion common/src/cgeo/contacts/IContacts.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cgeo.contacts;

import android.support.annotation.NonNull;
import androidx.annotation.NonNull;

public interface IContacts {
@NonNull String INTENT = "cgeo.contacts.FIND";
Expand Down
6 changes: 5 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ org.gradle.caching=true

# Avoid printing release notes after gradle version upgrades. See https://github.com/gradle/gradle/issues/5213
org.gradle.internal.launcher.welcomeMessageEnabled=false
systemProp.org.gradle.internal.launcher.welcomeMessageEnabled=false
systemProp.org.gradle.internal.launcher.welcomeMessageEnabled=false

# AndroidX configuration
android.useAndroidX=true
android.enableJetifier=true
2 changes: 1 addition & 1 deletion main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@

<!-- fileprovider to be able to share files -->
<provider
android:name="android.support.v4.content.FileProvider"
android:name="androidx.core.content.FileProvider"
android:authorities="@string/file_provider_authority"
android:exported="false"
android:grantUriPermissions="true">
Expand Down
25 changes: 13 additions & 12 deletions main/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ android {
testFunctionalTest true

// set the default test runner to be used by IDE and command line
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

// by convention, the folder name "main" is used for the APK file name. we want cgeo instead
archivesBaseName = "cgeo"
Expand Down Expand Up @@ -275,7 +275,7 @@ dependencies {
androidTestImplementation "org.assertj:assertj-core:$assertJVersion"

// ButterKnife view injection, https://github.com/JakeWharton/butterknife
def butterKnifeVersion = '8.8.1'
def butterKnifeVersion = '10.2.0'
implementation "com.jakewharton:butterknife:$butterKnifeVersion"
annotationProcessor "com.jakewharton:butterknife-compiler:$butterKnifeVersion"

Expand Down Expand Up @@ -353,26 +353,27 @@ dependencies {
// Support Libraries. All com.android.support.* libraries must use the same version

// Support Library AppCompat
implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
implementation 'androidx.appcompat:appcompat:1.1.0'

// Support Library ExifInterface replaces com.android.media.ExifInterface by com.android.support.media.ExifInterface
implementation "com.android.support:exifinterface:$supportLibraryVersion"
// Support Library ExifInterface
implementation 'androidx.exifinterface:exifinterface:1.1.0'

// Support Library GridLayout used by the coordinate calculator
implementation "com.android.support:gridlayout-v7:$supportLibraryVersion"
implementation 'androidx.gridlayout:gridlayout:1.0.0'

// Support Library RecyclerView
implementation "com.android.support:recyclerview-v7:$supportLibraryVersion"
implementation 'androidx.recyclerview:recyclerview:1.1.0'
// we don't want to implement decorators on our own
implementation 'com.yqritc:recyclerview-flexibledivider:1.4.0'

// Support Annotations. enforce same version for the main app and the test app
implementation "com.android.support:support-annotations:$supportLibraryVersion"
androidTestImplementation "com.android.support:support-annotations:$supportLibraryVersion"
// Support Annotations. use same version for the main app and the test app
def annotationVersion = '1.1.0'
implementation "androidx.annotation:annotation:$annotationVersion"
androidTestImplementation "androidx.annotation:annotation:$annotationVersion"

// Testing Support Libraries
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation "com.android.support.test.espresso:espresso-core:3.0.2"
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

// Undo toast
implementation 'com.github.jenzz.undobar:library:1.3:api8Release@aar'
Expand Down
2 changes: 1 addition & 1 deletion main/res/layout/addresslist_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:orientation="vertical"
tools:context=".address.AddressListActivity" >

<android.support.v7.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/address_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
Expand Down
2 changes: 1 addition & 1 deletion main/res/layout/cachedetail_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:orientation="vertical"
tools:context=".CacheDetailActivity" >

<android.support.v4.view.ViewPager
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewpager"
android:layout_width="fill_parent"
android:layout_height="0dp"
Expand Down
2 changes: 1 addition & 1 deletion main/res/layout/cachedetail_inventory_page.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
Expand Down
4 changes: 2 additions & 2 deletions main/res/layout/coordinates_calculate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
</LinearLayout>

<!-- H DDD°MM'SS.PPPPP" -->
<android.support.v7.widget.GridLayout
<androidx.gridlayout.widget.GridLayout
android:id="@+id/coordTable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -200,5 +200,5 @@
android:textSize="22sp"
android:layout_marginRight="1dp"
tools:ignore="HardcodedText" />
</android.support.v7.widget.GridLayout>
</androidx.gridlayout.widget.GridLayout>
</merge>
8 changes: 3 additions & 5 deletions main/res/layout/coordinates_equations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
android:orientation="horizontal"
android:padding="6dp" >

<android.support.v7.widget.GridLayout
xmlns:grid="http://schemas.android.com/apk/res-auto"
<androidx.gridlayout.widget.GridLayout

android:id="@+id/EquationTable"
android:layout_height="wrap_content"
Expand All @@ -39,13 +38,12 @@
android:layout_marginRight="4dp"
android:background="@color/just_white"/>

<android.support.v7.widget.GridLayout
<androidx.gridlayout.widget.GridLayout
android:id="@+id/FreeVariableTable"
xmlns:grid="http://schemas.android.com/apk/res-auto"

android:layout_height="wrap_content"
android:layout_width="match_parent"

app:orientation="vertical"/>
app:orientation="vertical" />
</LinearLayout>
</HorizontalScrollView>
2 changes: 1 addition & 1 deletion main/res/layout/gpx.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
android:visibility="gone"
tools:visibility="visible"/>

<android.support.v7.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
Expand Down
2 changes: 1 addition & 1 deletion main/res/layout/pocketquery_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:orientation="vertical"
tools:context=".connector.gc.PocketQueryListActivity" >

<android.support.v7.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/pocketquery_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
Expand Down
2 changes: 1 addition & 1 deletion main/res/layout/usefulapps_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
android:orientation="vertical"
tools:context=".helper.UsefulAppsActivity" >

<android.support.v7.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/apps_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
Expand Down
2 changes: 1 addition & 1 deletion main/res/layout/viewpager_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:background="?background_color"
android:orientation="vertical" >

<android.support.v4.view.ViewPager
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewpager"
android:layout_width="fill_parent"
android:layout_height="0dp"
Expand Down
2 changes: 1 addition & 1 deletion main/res/menu/cache_options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
android:id="@+id/menu_share"
android:icon="@drawable/ic_menu_share"
android:title="@string/cache_menu_share"
app:actionProviderClass="android.support.v7.widget.ShareActionProvider"
app:actionProviderClass="androidx.appcompat.widget.ShareActionProvider"
app:showAsAction="ifRoom">
</item>
<item
Expand Down
2 changes: 1 addition & 1 deletion main/res/menu/main_activity_options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
android:id="@+id/menu_gosearch"
android:icon="@android:drawable/ic_menu_search"
android:title="@string/search_bar_hint"
app:actionViewClass="android.support.v7.widget.SearchView"
app:actionViewClass="androidx.appcompat.widget.SearchView"
app:iconifiedByDefault="true"
app:showAsAction="collapseActionView|always"/>
<item
Expand Down
3 changes: 2 additions & 1 deletion main/src/cgeo/contacts/ContactsAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.annotation.NonNull;

import androidx.annotation.NonNull;

public class ContactsAddon {

Expand Down
5 changes: 3 additions & 2 deletions main/src/cgeo/geocaching/AboutActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.RawRes;
import android.support.annotation.StringRes;
import android.text.Html;
import android.text.SpannableStringBuilder;
import android.view.View;
Expand All @@ -23,6 +21,9 @@
import android.widget.ScrollView;
import android.widget.TextView;

import androidx.annotation.RawRes;
import androidx.annotation.StringRes;

import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
Expand Down
12 changes: 6 additions & 6 deletions main/src/cgeo/geocaching/AbstractDialogFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.v4.app.DialogFragment;
import android.support.v7.widget.PopupMenu;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuInflater;
Expand All @@ -38,9 +36,11 @@
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.widget.PopupMenu;
import androidx.fragment.app.DialogFragment;

import java.util.concurrent.Callable;

import butterknife.ButterKnife;
import io.reactivex.Maybe;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.functions.Consumer;
Expand Down Expand Up @@ -85,7 +85,7 @@ public void onCreate(final Bundle savedInstanceState) {
}

protected void initCustomActionBar(final View v) {
final ImageView defaultNavigationImageView = ButterKnife.findById(v, R.id.defaultNavigation);
final ImageView defaultNavigationImageView = v.findViewById(R.id.defaultNavigation);
defaultNavigationImageView.setOnLongClickListener(v12 -> {
startDefaultNavigation2();
return true;
Expand All @@ -110,7 +110,7 @@ protected void initCustomActionBar(final View v) {
public final void setTitle(final CharSequence title) {
final View view = getView();
assert view != null;
final TextView titleview = ButterKnife.findById(view, R.id.actionbar_title);
final TextView titleview = view.findViewById(R.id.actionbar_title);
if (titleview != null) {
titleview.setText(title);
}
Expand Down Expand Up @@ -228,7 +228,7 @@ protected final void addCacheDetails() {
// more details
final View view = getView();
assert view != null;
final Button buttonMore = ButterKnife.findById(view, R.id.more_details);
final Button buttonMore = view.findViewById(R.id.more_details);

buttonMore.setOnClickListener(arg0 -> {
CacheDetailActivity.startActivity(getActivity(), geocode);
Expand Down
Loading

0 comments on commit b912a9f

Please sign in to comment.