Skip to content

Commit

Permalink
breaking: only support androidx (apache#1052)
Browse files Browse the repository at this point in the history
* apacheGH-841 only support androix
  • Loading branch information
EinfachHans authored and wedgberto committed May 17, 2022
1 parent 97fdf8e commit 50d0369
Show file tree
Hide file tree
Showing 59 changed files with 21 additions and 4,705 deletions.
4 changes: 2 additions & 2 deletions bin/templates/cordova/lib/config/GradlePropertiesParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class GradlePropertiesParser {
'org.gradle.jvmargs': '-Xmx2048m',

// Android X
'android.useAndroidX': 'false',
'android.enableJetifier': 'false'
'android.useAndroidX': 'true',
'android.enableJetifier': 'true'

// Shaves another 100ms, but produces a "try at own risk" warning. Not worth it (yet):
// 'org.gradle.parallel': 'true'
Expand Down
7 changes: 0 additions & 7 deletions bin/templates/cordova/lib/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ module.exports.prepare = function (cordovaProject, options) {
const minSdkVersion = this._config.getPreference('android-minSdkVersion', 'android');
const maxSdkVersion = this._config.getPreference('android-maxSdkVersion', 'android');
const targetSdkVersion = this._config.getPreference('android-targetSdkVersion', 'android');
const androidXEnabled = this._config.getPreference('AndroidXEnabled', 'android');
const isGradlePluginKotlinEnabled = this._config.getPreference('GradlePluginKotlinEnabled', 'android');
const gradlePluginKotlinCodeStyle = this._config.getPreference('GradlePluginKotlinCodeStyle', 'android');

Expand All @@ -71,12 +70,6 @@ module.exports.prepare = function (cordovaProject, options) {
gradlePropertiesUserConfig['kotlin.code.style'] = gradlePluginKotlinCodeStyle || 'official';
}

// Both 'useAndroidX' and 'enableJetifier' are linked together.
if (androidXEnabled) {
gradlePropertiesUserConfig['android.useAndroidX'] = androidXEnabled;
gradlePropertiesUserConfig['android.enableJetifier'] = androidXEnabled;
}

const gradlePropertiesParser = new GradlePropertiesParser(this.locations.root);
gradlePropertiesParser.configure(gradlePropertiesUserConfig);

Expand Down
2 changes: 1 addition & 1 deletion bin/templates/project/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<activity android:name="__ACTIVITY__"
android:label="@string/activity_name"
android:launchMode="singleTop"
android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
android:theme="@style/Theme.AppCompat.NoActionBar"
android:windowSoftInputMode="adjustResize"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode">
<intent-filter android:label="@string/launcher_name">
Expand Down
1 change: 1 addition & 0 deletions bin/templates/project/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
implementation 'androidx.appcompat:appcompat:1.2.0'

if (cdvHelpers.getConfigPreference('GradlePluginKotlinEnabled', 'false').toBoolean()) {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
Expand Down
4 changes: 4 additions & 0 deletions framework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ task sourcesJar(type: Jar) {
classifier = 'sources'
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
}

artifacts {
archives sourcesJar
}
Expand Down
6 changes: 3 additions & 3 deletions framework/src/org/apache/cordova/CordovaActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ Licensed to the Apache Software Foundation (ASF) under one
import org.json.JSONException;
import org.json.JSONObject;

import android.app.Activity;
import android.app.AlertDialog;
import android.annotation.SuppressLint;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Color;
import android.media.AudioManager;
import android.os.Build;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
Expand All @@ -43,6 +41,8 @@ Licensed to the Apache Software Foundation (ASF) under one
import android.webkit.WebViewClient;
import android.widget.FrameLayout;

import androidx.appcompat.app.AppCompatActivity;

/**
* This class is the main Android activity that represents the Cordova
* application. It should be extended by the user to load the specific
Expand Down Expand Up @@ -74,7 +74,7 @@ Licensed to the Apache Software Foundation (ASF) under one
* deprecated in favor of the config.xml file.
*
*/
public class CordovaActivity extends Activity {
public class CordovaActivity extends AppCompatActivity {
public static String TAG = "CordovaActivity";

// The webview for our app
Expand Down
5 changes: 2 additions & 3 deletions framework/src/org/apache/cordova/CordovaInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ Licensed to the Apache Software Foundation (ASF) under one
*/
package org.apache.cordova;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;

import org.apache.cordova.CordovaPlugin;
import androidx.appcompat.app.AppCompatActivity;

import java.util.concurrent.ExecutorService;

Expand Down Expand Up @@ -56,7 +55,7 @@ public interface CordovaInterface {
*
* @return the Activity
*/
public abstract Activity getActivity();
public abstract AppCompatActivity getActivity();

/**
* Get the Android context.
Expand Down
13 changes: 7 additions & 6 deletions framework/src/org/apache/cordova/CordovaInterfaceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ Licensed to the Apache Software Foundation (ASF) under one
package org.apache.cordova;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.util.Pair;

import androidx.appcompat.app.AppCompatActivity;

import org.json.JSONException;
import org.json.JSONObject;

Expand All @@ -39,7 +40,7 @@ Licensed to the Apache Software Foundation (ASF) under one
*/
public class CordovaInterfaceImpl implements CordovaInterface {
private static final String TAG = "CordovaInterfaceImpl";
protected Activity activity;
protected AppCompatActivity activity;
protected ExecutorService threadPool;
protected PluginManager pluginManager;

Expand All @@ -51,11 +52,11 @@ public class CordovaInterfaceImpl implements CordovaInterface {
protected boolean activityWasDestroyed = false;
protected Bundle savedPluginState;

public CordovaInterfaceImpl(Activity activity) {
public CordovaInterfaceImpl(AppCompatActivity activity) {
this(activity, Executors.newCachedThreadPool());
}

public CordovaInterfaceImpl(Activity activity, ExecutorService threadPool) {
public CordovaInterfaceImpl(AppCompatActivity activity, ExecutorService threadPool) {
this.activity = activity;
this.threadPool = threadPool;
this.permissionResultCallbacks = new CallbackMap();
Expand All @@ -76,13 +77,13 @@ public void startActivityForResult(CordovaPlugin command, Intent intent, int req
public void setActivityResultCallback(CordovaPlugin plugin) {
// Cancel any previously pending activity.
if (activityResultCallback != null) {
activityResultCallback.onActivityResult(activityResultRequestCode, Activity.RESULT_CANCELED, null);
activityResultCallback.onActivityResult(activityResultRequestCode, AppCompatActivity.RESULT_CANCELED, null);
}
activityResultCallback = plugin;
}

@Override
public Activity getActivity() {
public AppCompatActivity getActivity() {
return activity;
}

Expand Down
60 changes: 0 additions & 60 deletions test/android/README.md

This file was deleted.

1 change: 0 additions & 1 deletion test/android/app/.gitignore

This file was deleted.

61 changes: 0 additions & 61 deletions test/android/app/build.gradle

This file was deleted.

36 changes: 0 additions & 36 deletions test/android/app/proguard-rules.pro

This file was deleted.

0 comments on commit 50d0369

Please sign in to comment.