Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): getter/setter for applicationLocales in Android 12 and up #14008

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
2434943
feat(android): via app compat delegate set default night mode
AbdullahFaqeir Mar 19, 2024
2722197
feat(android): ti locale new property applicationLocales
AbdullahFaqeir Mar 19, 2024
db250da
Merge branch 'master' into master
m1ga Mar 19, 2024
c1db1e8
Update android/modules/locale/src/java/ti/modules/titanium/locale/Loc…
AbdullahFaqeir Mar 20, 2024
9158cda
Update android/modules/locale/src/java/ti/modules/titanium/locale/Loc…
AbdullahFaqeir Mar 20, 2024
85e48b1
Update android/modules/locale/src/java/ti/modules/titanium/locale/Loc…
AbdullahFaqeir Mar 20, 2024
94d91bb
Update android/modules/locale/src/java/ti/modules/titanium/locale/Loc…
AbdullahFaqeir Mar 20, 2024
556a721
Update android/modules/locale/src/java/ti/modules/titanium/locale/Loc…
AbdullahFaqeir Mar 20, 2024
940e54f
Update android/modules/locale/src/java/ti/modules/titanium/locale/Loc…
AbdullahFaqeir Mar 20, 2024
2f3b590
Update android/modules/locale/src/java/ti/modules/titanium/locale/Loc…
AbdullahFaqeir Mar 20, 2024
d5e1379
Update android/modules/locale/src/java/ti/modules/titanium/locale/Loc…
AbdullahFaqeir Mar 20, 2024
e6707e1
Update tests/Resources/ti.locale.test.js
AbdullahFaqeir Mar 20, 2024
dcde5d7
Update android/modules/locale/src/java/ti/modules/titanium/locale/Loc…
m1ga Mar 20, 2024
6468f89
Update android/modules/locale/src/java/ti/modules/titanium/locale/Loc…
m1ga Mar 20, 2024
7f17e50
Update Locale.yml for PR #14008
AbdullahFaqeir Mar 21, 2024
81a4f65
Update apidoc/Titanium/Locale/Locale.yml
m1ga Mar 21, 2024
56b4b9a
fix(android): add .idea to .gitignore,
AbdullahFaqeir Mar 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/.gitignore
Expand Up @@ -2,7 +2,7 @@
.cxx/
.externalNativeBuild/
.gradle/
.idea/*
.idea/
!/.idea/codeStyles/
!/.idea/inspectionProfiles/
.project/
Expand Down
3 changes: 3 additions & 0 deletions android/.idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions android/.idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 16 additions & 14 deletions android/app/build.gradle
Expand Up @@ -9,47 +9,49 @@ apply plugin: 'com.android.application'

// Set up Android app project.
android {
compileSdkVersion 33
ndkVersion project.ext.tiNdkVersion
defaultConfig {
applicationId 'com.titanium.test'
minSdkVersion 21
targetSdkVersion 33
compileSdk 34
minSdkVersion 26
targetSdkVersion 34
versionCode 1
versionName '1.0'
manifestPlaceholders = project.ext.tiManifestPlaceholders
manifestPlaceholders.put('localApplicationId', applicationId) // Legacy placeholder old AARs sometimes use.
}
lintOptions {
checkReleaseBuilds false
}
sourceSets {
main {
assets.srcDirs = [
'src/main/assets',
"${projectDir}/../titanium/build/outputs/ti-assets"
'src/main/assets',
"${projectDir}/../titanium/build/outputs/ti-assets"
]
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
namespace 'com.titanium.test'
lint {
checkReleaseBuilds false
}
}

// Checks our Java code against our style guidelines and for common coding mistakes using "checkstyle.xml".
// Will trigger a build failure if any violations have been detected.
// Customize all the Checkstyle tasks
tasks.withType(Checkstyle) {
tasks.withType(Checkstyle).configureEach {
// Specify all files that should be checked
classpath = files()
source android.sourceSets.main.java.srcDirs
}
// Execute Checkstyle on all files
task checkJavaStyle(type: Checkstyle) {
tasks.register('checkJavaStyle', Checkstyle) {
// include '**/*.java'
}
// Execute Checkstyle on all modified files
task checkstyleChanged(type: Checkstyle) {
tasks.register('checkstyleChanged', Checkstyle) {
include getChangedFiles()
}

Expand All @@ -73,7 +75,7 @@ def getChangedFiles() {
files
}

tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
dependsOn checkJavaStyle
}

Expand Down
14 changes: 7 additions & 7 deletions android/build.gradle
Expand Up @@ -6,17 +6,17 @@
*/

buildscript {
ext.kotlin_version = '1.8.20'
ext.kotlin_version = '1.9.23'

repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath 'com.google.gms:google-services:4.3.15'
classpath 'com.android.tools.build:gradle:8.3.1'
classpath 'com.google.gms:google-services:4.4.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'org.codehaus.groovy:groovy-json:3.0.11'
classpath 'org.codehaus.groovy:groovy-json:3.0.17'
}
}

Expand All @@ -30,7 +30,7 @@ allprojects {
project.apply plugin: 'checkstyle'
checkstyle {
toolVersion = '8.38'
configFile file("${rootDir}/checkstyle.xml");
configFile file("${rootDir}/checkstyle.xml")
ignoreFailures false
showViolations true
}
Expand All @@ -39,6 +39,6 @@ allprojects {
project.apply from: "${rootDir}/templates/build/ti.constants.gradle"
}

task clean(type: Delete) {
delete rootProject.buildDir
tasks.register('clean', Delete) {
delete project.layout.buildDirectory
}
3 changes: 3 additions & 0 deletions android/gradle.properties
Expand Up @@ -15,3 +15,6 @@ android.enableJetifier=false

# remove if com.android.tools.build:gradle can be raised in /android/build.gradle
android.suppressUnsupportedCompileSdk=33
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
3 changes: 2 additions & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,7 @@
#Tue Mar 19 21:28:34 EET 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
16 changes: 10 additions & 6 deletions android/kroll-apt/build.gradle
Expand Up @@ -7,22 +7,24 @@

apply plugin: 'java'

sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

// Checks our Java code against our style guidelines and for common coding mistakes using "checkstyle.xml".
// Will trigger a build failure if any violations have been detected.
// Customize all the Checkstyle tasks
tasks.withType(Checkstyle) {
tasks.withType(Checkstyle).configureEach {
// Specify all files that should be checked
classpath = files()
source 'src/main/java'
}
// Execute Checkstyle on all files
task checkJavaStyle(type: Checkstyle) {
tasks.register('checkJavaStyle', Checkstyle) {
// include '**/*.java'
}
task checkstyleChanged(type: Checkstyle) {
tasks.register('checkstyleChanged', Checkstyle) {
include getChangedFiles()
}

Expand All @@ -47,14 +49,15 @@ def getChangedFiles() {
}

// Hook into Java compile task.
tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
// Check Java code for mistakes before compiling.
dependsOn checkJavaStyle

// Suppress compiler warning "bootstrap class path not set in conjunction with source" which happens when
// building with JDK newer than the Java version we're targeting. (Ex: Build with JDK 8, but target Java 7.)
// Note: Build tool wants a reference to runtime JAR of the same version we're targeting. Not going to happen.
options.compilerArgs << '-Xlint:-options'
options.incremental = true
}

// Bundle the below library dependencies within this project's built JAR.
Expand All @@ -69,6 +72,7 @@ jar {
}
}
duplicatesStrategy = DuplicatesStrategy.INCLUDE
version '1.0.0'
}

dependencies {
Expand Down
Expand Up @@ -30,14 +30,14 @@
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.util.SimpleElementVisitor6;
import javax.lang.model.util.SimpleElementVisitor9;
import javax.tools.Diagnostic;
import javax.tools.FileObject;
import javax.tools.StandardLocation;

import org.json.simple.JSONValue;

@SupportedSourceVersion(SourceVersion.RELEASE_11)
@SupportedSourceVersion(SourceVersion.RELEASE_17)
@SuppressWarnings("unchecked")
@SupportedAnnotationTypes({
KrollJSONGenerator.Kroll_argument,
Expand Down Expand Up @@ -214,25 +214,26 @@ protected void initialize()
} catch (Exception e) {
// file doesn't exist, we'll just create it later
debug("No binding data found, creating new data file: %s/%s", this.jarJsonPackageName,
this.jarJsonFileName);
this.jarJsonFileName);
}
}
}

protected void processKrollProxy(final Element element)
{
utils.acceptAnnotations(
element, new String[] { Kroll_proxy, Kroll_module }, new KrollVisitor<AnnotationMirror>() {
protected Map<Object, Object> getProxyProperties(String packageName, String proxyClassName)
element, new String[] { Kroll_proxy, Kroll_module }, new KrollVisitor<>()
{
private Map<Object, Object> getProxyProperties(String packageName, String proxyClassName)
{
if (properties == null) {
properties = new HashMap<>();
}
return jsonUtils.getOrCreateMap(jsonUtils.getOrCreateMap(properties, "proxies"),
packageName + "." + proxyClassName);
packageName + "." + proxyClassName);
}

protected Map<Object, Object> getModule(String moduleClassName)
private Map<Object, Object> getModule(String moduleClassName)
{
if (properties == null) {
properties = new HashMap<>();
Expand Down Expand Up @@ -278,15 +279,15 @@ public boolean visit(AnnotationMirror annotation, Object arg)
String createInModuleClass = (String) proxyAttrs.get("creatableInModule");
if (!createInModuleClass.equals(Kroll_DEFAULT)) {
jsonUtils.appendUniqueObject(getModule(createInModuleClass), "createProxies",
"proxyClassName", proxyAttrs);
"proxyClassName", proxyAttrs);
}
}

if (isModule && proxyAttrs.containsKey("parentModule")) {
String parentModuleClass = (String) proxyAttrs.get("parentModule");
if (!parentModuleClass.equals(Kroll_DEFAULT)) {
jsonUtils.appendUniqueObject(getModule(parentModuleClass), "childModules", "proxyClassName",
proxyAttrs);
proxyAttrs);
} else {
proxyAttrs.remove("parentModule");
}
Expand All @@ -298,7 +299,7 @@ public boolean visit(AnnotationMirror annotation, Object arg)
HashMap<String, Object> topLevelParams = utils.getAnnotationParams(element, Kroll_topLevel);
List<?> topLevelNames = (List<?>) topLevelParams.get("value");
if (topLevelNames.size() == 1 && topLevelNames.get(0).equals(DEFAULT_NAME)) {
topLevelNames = Arrays.asList(apiName);
topLevelNames = Collections.singletonList(apiName);
}

proxyAttrs.put("topLevelNames", topLevelNames);
Expand All @@ -307,7 +308,8 @@ public boolean visit(AnnotationMirror annotation, Object arg)
BindingVisitor visitor = new BindingVisitor();
final BindingVisitor fVisitor = visitor;
if (utils.hasAnnotation(element, Kroll_dynamicApis)) {
utils.acceptAnnotations(element, Kroll_dynamicApis, new KrollVisitor<AnnotationMirror>() {
utils.acceptAnnotations(element, Kroll_dynamicApis, new KrollVisitor<>()
{
@Override
public boolean visit(AnnotationMirror annotation, Object arg)
{
Expand Down Expand Up @@ -352,7 +354,7 @@ public boolean visit(AnnotationMirror annotation, Object arg)
}

protected class BindingVisitor
extends SimpleElementVisitor6<Object, Object> implements KrollVisitor<AnnotationMirror>
extends SimpleElementVisitor9<Object, Object> implements KrollVisitor<AnnotationMirror>
{
@Override
public String visitExecutable(ExecutableElement e, Object p)
Expand Down Expand Up @@ -608,12 +610,12 @@ protected void visitInject(AnnotationMirror annotation, Element element, boolean
String defaultType = null;
if (isMethod) {
List<? extends VariableElement> params = ((ExecutableElement) element).getParameters();
if (params.size() > 0) {
if (!params.isEmpty()) {
VariableElement firstParam = params.get(0);
defaultType = utils.getType(firstParam);
} else {
warn("Skipping injection into method %s, at least one argument is required in a setter",
utils.getName(element));
utils.getName(element));
return;
}
} else {
Expand Down Expand Up @@ -779,7 +781,7 @@ protected void generateJSON()
writer.close();
} catch (Exception e) {
debug("Exception trying to generate JSON: %s/%s, %s", this.jarJsonPackageName, this.jarJsonFileName,
e.getMessage());
e.getMessage());
}
}

Expand Down