Skip to content

Commit

Permalink
Merge pull request #632 from processing/androidx
Browse files Browse the repository at this point in the history
Migration to AndroidX
  • Loading branch information
codeanticode authored Jan 4, 2021
2 parents 60212f2 + 4545829 commit fae1f8c
Show file tree
Hide file tree
Showing 131 changed files with 875 additions and 495 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ mode/mode/wearable.jar

mode/libraries/vr/library
mode/libraries/ar/library
mode/tools/SDKUpdated/tool
mode/tools/SDKUpdater/tool
mode/tools/SDKUpdater/lib

debug/.gradle
debug/.idea
Expand Down
40 changes: 21 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ apply plugin: 'java'
buildscript {
repositories {
google()
jcenter()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath group: 'commons-io', name: 'commons-io', version: '2.6'
classpath group: 'org.zeroturnaround', name: 'zt-zip', version: '1.13'
classpath 'com.android.tools.build:gradle:4.1.1'
classpath group: 'commons-io', name: 'commons-io', version: '2.8.0'
classpath group: 'org.zeroturnaround', name: 'zt-zip', version: '1.14'
}
}

Expand All @@ -25,7 +25,8 @@ allprojects {
Properties versions = new Properties()
versions.load(project.rootProject.file("mode/version.properties").newDataInputStream())
ext.targetSdkVersion = versions.getProperty("android-platform")
ext.supportLibsVersion = versions.getProperty("com.android.support%support-v4")
ext.appcompatVersion = versions.getProperty("androidx.appcompat%appcompat")
ext.v4legacyVersion = versions.getProperty("androidx.legacy%legacy-support-v4")
ext.wearVersion = versions.getProperty("com.google.android.support%wearable")
ext.gvrVersion = versions.getProperty("com.google.vr")
ext.garVersion = versions.getProperty("com.google.ar")
Expand Down Expand Up @@ -72,27 +73,26 @@ allprojects {
localProperties.load(project.rootProject.file("local.properties").newDataInputStream())
def sdkDir = localProperties.getProperty("sdk.dir")
ext.androidPlatformPath = "${sdkDir}/platforms/android-${targetSdkVersion}"
ext.androidToolsLibPath = "${sdkDir}/tools/lib"

ext.coreZipPath = "${rootDir}/mode/processing-core.zip"

repositories {
google()
jcenter()
maven {
// mavenCentral() does not work to download the Gradle releases of gradle-tooling-api, one needs
// to set the artifact url as below to get the latest packages.
// https://mvnrepository.com/artifact/org.gradle/gradle-tooling-api?repo=gradle-libs-releases-local
url "https://repo1.maven.org/maven2"
artifactUrls "https://repo.gradle.org/gradle/libs-releases-local"
}
maven { url "https://maven.google.com" }
maven { url "https://jitpack.io" }
maven { url 'https://repo.gradle.org/gradle/libs-releases' }
flatDir dirs: androidPlatformPath
flatDir dirs: androidToolsLibPath
flatDir dirs: "${rootDir}/core/dist"
}

sourceCompatibility = 1.8
targetCompatibility = 1.8
compileJava {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

// Uncomment this option when building with Java 11+
// https://github.com/processing/processing-android/issues/625
// options.release = 8
}
}

clean.doFirst {
Expand Down Expand Up @@ -128,9 +128,11 @@ task dist {
FileUtils.copyDirectory(file("mode/languages"),
file("${root}/languages"))

FileUtils.copyDirectory(file("mode/tools/SDKUpdater/tool"),
FileUtils.copyDirectory(file("mode/tools/SDKUpdater/tool"),
file("${root}/tools/SDKUpdater/tool"))
FileUtils.copyDirectory(file("mode/tools/SDKUpdater/src"),
FileUtils.copyDirectory(file("mode/tools/SDKUpdater/lib"),
file("${root}/tools/SDKUpdater/lib"))
FileUtils.copyDirectory(file("mode/tools/SDKUpdater/src"),
file("${root}/tools/SDKUpdater/src"))

FileUtils.copyDirectory(file("mode/libraries/vr/examples"),
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ repositories {
dependencies {
implementation gradleApi()
implementation localGroovy()
implementation 'com.android.tools.build:gradle:3.5.1'
implementation 'com.android.tools.build:gradle:4.1.1'
}
20 changes: 6 additions & 14 deletions core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import java.nio.file.Files
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING

apply plugin: 'maven'
apply plugin: 'aar'
apply plugin: 'maven'

dependencies {
implementation name: "android"

implementationAar "com.android.support:support-v4:${supportLibsVersion}"
implementationAar "androidx.legacy:legacy-support-v4:${v4legacyVersion}"
implementationAar "com.google.android.support:wearable:${wearVersion}"
}

Expand All @@ -27,9 +27,9 @@ task createPom {
}
dependencies {
dependency {
groupId "com.android.support"
artifactId "support-v4"
version "${supportLibsVersion}"
groupId "androidx.legacy"
artifactId "legacy-support-v4"
version "${v4legacyVersion}"
scope "implementation"
}
dependency {
Expand Down Expand Up @@ -80,15 +80,7 @@ clean.doFirst {
}

compileJava.doFirst {
String[] deps = ["percent.jar",
"recyclerview-v7.jar",
"support-compat.jar",
"support-core-ui.jar",
"support-core-utils.jar",
"support-fragment.jar",
"support-media-compat.jar",
"support-v4.jar",
"wearable.jar"]
String[] deps = ["wearable.jar"]
for (String fn : deps) {
Files.copy(file("${rootDir}/build/libs/" + fn).toPath(),
file("${rootDir}/mode/mode/" + fn).toPath(), REPLACE_EXISTING)
Expand Down
30 changes: 14 additions & 16 deletions core/src/processing/a2d/PGraphicsAndroid2D.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2012-16 The Processing Foundation
Copyright (c) 2012-21 The Processing Foundation
Copyright (c) 2005-12 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
Expand All @@ -23,6 +23,19 @@

package processing.a2d;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.MemoryInfo;
import android.content.Context;
import android.graphics.*;
import android.graphics.Bitmap.Config;
import android.graphics.Paint.Style;
import android.os.Build;
import android.os.Environment;
import android.view.SurfaceHolder;
import static android.os.Environment.isExternalStorageRemovable;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
Expand All @@ -45,21 +58,6 @@
import processing.core.PSurface;
import processing.data.XML;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.MemoryInfo;
import android.content.Context;
import android.graphics.*;
import android.graphics.Bitmap.Config;
import android.graphics.Paint.Style;
import android.os.Build;
import android.os.Environment;
import android.view.SurfaceHolder;

import static android.os.Environment.isExternalStorageRemovable;


/**
* Subclass for PGraphics that implements the graphics API using
* the Android 2D graphics model. Similar tradeoffs to JAVA2D mode
Expand Down
23 changes: 23 additions & 0 deletions core/src/processing/a2d/PShapeAndroid2D.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */

/*
Part of the Processing project - http://processing.org
Copyright (c) 2016-21 The Processing Foundation
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License version 2.1 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
*/

package processing.a2d;

import android.graphics.Shader;

import processing.core.PGraphics;
import processing.core.PShapeSVG;
import processing.data.XML;
Expand Down
4 changes: 2 additions & 2 deletions core/src/processing/a2d/PSurfaceAndroid2D.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2016 The Processing Foundation
Copyright (c) 2016-21 The Processing Foundation
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand All @@ -23,14 +23,14 @@
package processing.a2d;

import android.content.Context;

import android.graphics.Color;
import android.graphics.PixelFormat;
import android.service.wallpaper.WallpaperService;
import android.support.wearable.watchface.CanvasWatchFaceService;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

import processing.android.AppComponent;
import processing.android.PFragment;
import processing.core.PApplet;
Expand Down
2 changes: 1 addition & 1 deletion core/src/processing/android/ActivityAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2016-17 The Processing Foundation
Copyright (c) 2016-21 The Processing Foundation
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down
3 changes: 2 additions & 1 deletion core/src/processing/android/AppComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2016-17 The Processing Foundation
Copyright (c) 2016-21 The Processing Foundation
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand All @@ -23,6 +23,7 @@
package processing.android;

import android.content.Intent;

import processing.core.PApplet;
import processing.core.PConstants;

Expand Down
9 changes: 5 additions & 4 deletions core/src/processing/android/CompatUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2017 The Processing Foundation
Copyright (c) 2017-21 The Processing Foundation
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand All @@ -22,16 +22,17 @@

package processing.android;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.atomic.AtomicInteger;
import android.annotation.SuppressLint;
import android.os.Build;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.View;
import android.graphics.Point;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.atomic.AtomicInteger;

/**
* Compatibility utilities that work across versions of Android. Even though
* the mode sets API level 17 (Android 4.2) as the minimum target, because the
Expand Down
16 changes: 9 additions & 7 deletions core/src/processing/android/PFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2016-17 The Processing Foundation
Copyright (c) 2016-21 The Processing Foundation
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand All @@ -22,12 +22,6 @@

package processing.android;

import android.support.annotation.IdRes;
import android.support.annotation.LayoutRes;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.util.DisplayMetrics;
import android.content.Intent;
import android.content.pm.ActivityInfo;
Expand All @@ -44,6 +38,14 @@
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.ContextMenu.ContextMenuInfo;

import androidx.annotation.IdRes;
import androidx.annotation.LayoutRes;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import processing.core.PApplet;

public class PFragment extends Fragment implements AppComponent {
Expand Down
4 changes: 2 additions & 2 deletions core/src/processing/android/PWallpaper.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2016-17 The Processing Foundation
Copyright (c) 2016-21 The Processing Foundation
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand All @@ -26,12 +26,12 @@
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.WindowManager;
import processing.core.PApplet;
import android.util.DisplayMetrics;
import android.view.Display;
import android.graphics.Point;
import android.graphics.Rect;

import processing.core.PApplet;

public class PWallpaper extends WallpaperService implements AppComponent {
private Point size;
Expand Down
3 changes: 2 additions & 1 deletion core/src/processing/android/PWatchFaceCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2016-17 The Processing Foundation
Copyright (c) 2016-21 The Processing Foundation
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -38,6 +38,7 @@
import android.view.SurfaceHolder;
import android.view.WindowInsets;
import android.view.WindowManager;

import processing.a2d.PGraphicsAndroid2D;
import processing.core.PApplet;

Expand Down
Loading

0 comments on commit fae1f8c

Please sign in to comment.