refactor android app to AndroidX

This commit is contained in:
Dusan Klinec
2021-02-06 17:35:53 +01:00
parent 82e68a6339
commit 7dc697e608
12 changed files with 50 additions and 40 deletions

View File

@@ -1,14 +1,14 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {
compileSdkVersion 23 compileSdkVersion 29
buildToolsVersion "23.0.1" buildToolsVersion "23.0.3"
defaultConfig { defaultConfig {
applicationId "com.vsmartcard.remotesmartcardreader.app" applicationId "com.vsmartcard.remotesmartcardreader.app"
// NFC reader mode was added in KitKat // NFC reader mode was added in KitKat
minSdkVersion 19 minSdkVersion 19
targetSdkVersion 23 targetSdkVersion 29
versionCode 6 versionCode 6
versionName "2.2" versionName "2.2"
} }
@@ -38,7 +38,7 @@ android.applicationVariants.all { variant ->
} else { } else {
newApkName = "${appName}-${output.baseName}-${variant.versionName}-unaligned.apk" newApkName = "${appName}-${output.baseName}-${variant.versionName}-unaligned.apk"
} }
output.outputFile = new File(output.outputFile.parent, newApkName) //output.outputFile = new File(output.outputFile.parent, newApkName)
} }
} }
@@ -47,12 +47,12 @@ repositories {
} }
dependencies { dependencies {
compile fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1' implementation 'androidx.appcompat:appcompat:1.2.0'
compile 'com.android.support:design:23.2.1' implementation 'com.google.android.material:material:1.3.0'
compile 'com.android.support:support-v4:23.2.1' implementation 'androidx.legacy:legacy-support-v4:1.0.0'
compile 'com.journeyapps:zxing-android-embedded:3.2.0@aar' implementation 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
compile 'com.google.zxing:core:3.2.1' implementation 'com.google.zxing:core:3.2.1'
} }

View File

@@ -33,7 +33,6 @@ package com.example.android.common.logger;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.view.Gravity; import android.view.Gravity;
@@ -42,6 +41,8 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ScrollView; import android.widget.ScrollView;
import androidx.fragment.app.Fragment;
/** /**
* Simple fraggment which contains a LogView and uses is to output log data it receives * Simple fraggment which contains a LogView and uses is to output log data it receives
* through the LogNode interface. * through the LogNode interface.

View File

@@ -3,15 +3,16 @@ package com.vsmartcard.remotesmartcardreader.app;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatDelegate;
import android.support.v7.widget.Toolbar;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar;
/** /**
* A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls * A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls
* to be used with AppCompat. * to be used with AppCompat.

View File

@@ -31,20 +31,21 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.Settings; import android.provider.Settings;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import com.example.android.common.logger.Log; import com.example.android.common.logger.Log;
import com.example.android.common.logger.LogFragment; import com.example.android.common.logger.LogFragment;
import com.example.android.common.logger.LogWrapper; import com.example.android.common.logger.LogWrapper;
import com.example.android.common.logger.MessageOnlyLogFilter; import com.example.android.common.logger.MessageOnlyLogFilter;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import com.vsmartcard.remotesmartcardreader.app.screaders.*; import com.vsmartcard.remotesmartcardreader.app.screaders.*;
@TargetApi(Build.VERSION_CODES.KITKAT) @TargetApi(Build.VERSION_CODES.KITKAT)
@@ -231,6 +232,7 @@ public class MainActivity extends AppCompatActivity implements NfcAdapter.Reader
@Override @Override
public void onNewIntent(Intent intent) { public void onNewIntent(Intent intent) {
// onResume gets called after this to handle the intent // onResume gets called after this to handle the intent
super.onNewIntent(intent);
setIntent(intent); setIntent(intent);
} }

View File

@@ -23,12 +23,12 @@ import android.content.ClipData;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import com.example.android.common.logger.LogFragment; import com.example.android.common.logger.LogFragment;
import com.google.android.material.snackbar.Snackbar;
public class MyLogFragment extends LogFragment { public class MyLogFragment extends LogFragment {

View File

@@ -32,11 +32,13 @@ import android.preference.ListPreference;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import android.provider.Settings; import android.provider.Settings;
import android.support.design.widget.Snackbar;
import android.support.v7.app.ActionBar;
import android.preference.PreferenceFragment; import android.preference.PreferenceFragment;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.view.MenuItem; import android.view.MenuItem;
import androidx.appcompat.app.ActionBar;
import com.google.android.material.snackbar.Snackbar;
import com.google.zxing.integration.android.IntentIntegrator; import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult; import com.google.zxing.integration.android.IntentResult;

View File

@@ -20,7 +20,8 @@
package com.vsmartcard.remotesmartcardreader.app; package com.vsmartcard.remotesmartcardreader.app;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import com.example.android.common.logger.Log; import com.example.android.common.logger.Log;
import com.vsmartcard.remotesmartcardreader.app.screaders.SCReader; import com.vsmartcard.remotesmartcardreader.app.screaders.SCReader;

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -7,14 +7,14 @@
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
tools:context="com.vsmartcard.remotesmartcardreader.app.MainActivity"> tools:context="com.vsmartcard.remotesmartcardreader.app.MainActivity">
<android.support.design.widget.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar" android:id="@+id/app_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height" android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout <com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/toolbar_layout" android:id="@+id/toolbar_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@@ -22,19 +22,19 @@
app:contentScrim="?attr/colorPrimary" app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"> app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin" app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay" /> app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout> </com.google.android.material.appbar.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>
<include layout="@layout/content_main" /> <include layout="@layout/content_main" />
<android.support.design.widget.FloatingActionButton <com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab" android:id="@+id/fab"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -43,4 +43,4 @@
app:layout_anchor="@id/app_bar" app:layout_anchor="@id/app_bar"
app:layout_anchorGravity="bottom|end" /> app:layout_anchorGravity="bottom|end" />
</android.support.design.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" <androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@@ -16,4 +16,4 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
</android.support.v4.widget.NestedScrollView> </androidx.core.widget.NestedScrollView>

View File

@@ -2,10 +2,11 @@
buildscript { buildscript {
repositories { repositories {
google()
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:1.5.0' classpath 'com.android.tools.build:gradle:4.1.2'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
@@ -15,6 +16,7 @@ buildscript {
allprojects { allprojects {
repositories { repositories {
jcenter() jcenter()
google()
} }
} }

View File

@@ -15,4 +15,6 @@
# When configured, Gradle will run in incubating parallel mode. # When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit # This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true # org.gradle.parallel=true
android.enableJetifier=true
android.useAndroidX=true

View File

@@ -1,6 +1,5 @@
#Wed Oct 21 11:34:03 PDT 2015
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip