feat(android): edge to edge (#10774)
@@ -6,8 +6,8 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
// Updated for Java 21 compatibility via Gradle 8.4
|
||||
classpath 'com.android.tools.build:gradle:8.3.2'
|
||||
classpath 'com.android.tools.build:gradle:8.11.1'
|
||||
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.21'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#Fri Jul 25 11:31:30 AST 2025
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
309
packages/ui-mobile-base/android/gradlew
vendored
@@ -1,78 +1,127 @@
|
||||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
@@ -81,92 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
|
||||
56
packages/ui-mobile-base/android/gradlew.bat
vendored
@@ -1,4 +1,20 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@@ -9,19 +25,23 @@
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
@@ -35,7 +55,7 @@ goto fail
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
@@ -45,38 +65,26 @@ echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
include ':widgets'
|
||||
include ':widgetdemo'
|
||||
|
||||
1
packages/ui-mobile-base/android/widgetdemo/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
49
packages/ui-mobile-base/android/widgetdemo/build.gradle.kts
Normal file
@@ -0,0 +1,49 @@
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "org.nativescript.widgetsdemo"
|
||||
compileSdk = 35
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "org.nativescript.widgetsdemo"
|
||||
minSdk = 21
|
||||
targetSdk = 35
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = "11"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation("androidx.core:core-ktx:1.16.0")
|
||||
implementation("androidx.appcompat:appcompat:1.7.1")
|
||||
implementation("com.google.android.material:material:1.12.0")
|
||||
implementation("androidx.activity:activity:1.10.1")
|
||||
implementation("androidx.constraintlayout:constraintlayout:2.2.1")
|
||||
implementation(project(":widgets"))
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
androidTestImplementation("androidx.test.ext:junit:1.2.1")
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
|
||||
}
|
||||
21
packages/ui-mobile-base/android/widgetdemo/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.nativescript.widgetsdemo
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("org.nativescript.widgetsdemo", appContext.packageName)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Android">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,136 @@
|
||||
package org.nativescript.widgetsdemo
|
||||
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.widget.NestedScrollView
|
||||
import org.nativescript.widgets.CommonLayoutParams
|
||||
import org.nativescript.widgets.ContentLayout
|
||||
import org.nativescript.widgets.GridLayout
|
||||
import org.nativescript.widgets.LayoutBase
|
||||
import org.nativescript.widgets.StackLayout
|
||||
import org.nativescript.widgets.Utils
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
Utils.enableEdgeToEdge(this)
|
||||
val frame = ContentLayout(this)
|
||||
val page = GridLayout(this)
|
||||
page.layoutParams = CommonLayoutParams(
|
||||
ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
)
|
||||
page.setBackgroundColor(Color.MAGENTA)
|
||||
page.overflowEdge = LayoutBase.OverflowEdgeAllButTop
|
||||
// page.setInsetListener {
|
||||
// val insets = it.asIntBuffer()
|
||||
// insets.put(0,0)
|
||||
// insets.put(1,0)
|
||||
// insets.put(2,0)
|
||||
// insets.put(3,0)
|
||||
//// insets.put(3,0)
|
||||
//// insets.put(5,1)
|
||||
// }
|
||||
|
||||
frame.setBackgroundColor(Color.BLUE)
|
||||
frame.overflowEdge = LayoutBase.OverflowEdgeDontApply
|
||||
frame.layoutParams = CommonLayoutParams(
|
||||
ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
)
|
||||
|
||||
val svp = StackLayout(this)
|
||||
// svp.setBackgroundColor(Color.YELLOW)
|
||||
svp.layoutParams = CommonLayoutParams(
|
||||
ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
)
|
||||
// svp.setInsetListener {
|
||||
// val insets = it.asIntBuffer()
|
||||
// insets.put(0,0)
|
||||
// insets.put(1,0)
|
||||
// insets.put(2,0)
|
||||
// insets.put(3,0)
|
||||
// // insets.put(7, 1)
|
||||
// }
|
||||
|
||||
svp.overflowEdge = StackLayout.OverflowEdgeAllButBottom
|
||||
val scrollView = NestedScrollView(this)
|
||||
scrollView.layoutParams = CommonLayoutParams(
|
||||
ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
)
|
||||
svp.addView(scrollView)
|
||||
|
||||
val container = StackLayout(this)
|
||||
container.setBackgroundColor(Color.RED)
|
||||
container.overflowEdge = StackLayout.OverflowEdgeNone
|
||||
|
||||
val text = TextView(this)
|
||||
text.text = getString(R.string.ipsum)
|
||||
text.textSize = 40f
|
||||
text.setTextColor(Color.WHITE)
|
||||
container.addView(text)
|
||||
scrollView.addView(container)
|
||||
page.addView(svp)
|
||||
val btn = Button(this)
|
||||
btn.text = "Toggle Overflow"
|
||||
val params = CommonLayoutParams(
|
||||
ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
)
|
||||
params.width = 300
|
||||
params.height = 300
|
||||
params.width
|
||||
btn.layoutParams = params
|
||||
btn.setOnClickListener {
|
||||
val new_page = StackLayout(this)
|
||||
new_page.setBackgroundColor(Color.BLUE)
|
||||
new_page.layoutParams = CommonLayoutParams(
|
||||
ViewGroup.LayoutParams(
|
||||
300, 300
|
||||
)
|
||||
)
|
||||
container.addView(new_page)
|
||||
|
||||
|
||||
svp.overflowEdge = when (svp.overflowEdge) {
|
||||
LayoutBase.OverflowEdgeNone -> {
|
||||
LayoutBase.OverflowEdgeDontApply
|
||||
}
|
||||
|
||||
LayoutBase.OverflowEdgeDontApply -> {
|
||||
LayoutBase.OverflowEdgeTop
|
||||
}
|
||||
|
||||
LayoutBase.OverflowEdgeTop -> {
|
||||
LayoutBase.OverflowEdgeBottom
|
||||
}
|
||||
|
||||
LayoutBase.OverflowEdgeBottom -> {
|
||||
LayoutBase.OverflowEdgeTop.and(LayoutBase.OverflowEdgeBottom)
|
||||
}
|
||||
|
||||
else -> LayoutBase.OverflowEdgeDontApply
|
||||
}
|
||||
}
|
||||
page.addView(btn)
|
||||
frame.addView(page)
|
||||
setContentView(frame)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
||||
@@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World!"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 982 B |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 7.6 KiB |
@@ -0,0 +1,7 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.Android" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<!-- Customize your dark theme here. -->
|
||||
<!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
|
||||
</style>
|
||||
</resources>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
</resources>
|
||||
@@ -0,0 +1,9 @@
|
||||
<resources>
|
||||
<string name="app_name">WidgetDemo</string>
|
||||
<string name="ipsum">
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur euismod dictum purus, non tempor tortor fermentum vehicula. Donec condimentum eleifend lacus, non varius dui feugiat quis. Integer tincidunt, erat nec lacinia maximus, ante tortor placerat arcu, eu dignissim mauris ipsum et diam. Proin sed magna dui. Donec consequat volutpat mi, sed facilisis quam sollicitudin ac. Nullam pulvinar nunc nec diam molestie, sit amet semper lectus efficitur. Aenean ut lacus arcu. Donec non tempor risus.
|
||||
|
||||
Pellentesque blandit congue mattis. Proin eget nibh id nisl pellentesque elementum. Vestibulum neque arcu, luctus vitae pretium sed, venenatis quis odio. Quisque varius ligula id quam ullamcorper, ut gravida magna aliquam. Proin sit amet nibh tempus, aliquam justo ut, accumsan nibh. Curabitur non neque dui. Phasellus ac semper nunc. Aenean placerat lacinia suscipit. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,9 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.Android" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<!-- Customize your light theme here. -->
|
||||
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
|
||||
</style>
|
||||
|
||||
<style name="Theme.Android" parent="Base.Theme.Android" />
|
||||
</resources>
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.nativescript.widgetsdemo
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
class ExampleUnitTest {
|
||||
@Test
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
}
|
||||
@@ -1,114 +1,123 @@
|
||||
import groovy.json.JsonSlurper // used to parse package.json
|
||||
import groovy.json.JsonBuilder
|
||||
import groovy.json.JsonOutput
|
||||
// used to parse package.json
|
||||
|
||||
def isWinOs = System.properties['os.name'].toLowerCase().contains('windows')
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
def computeCompileSdkValue () {
|
||||
if(project.hasProperty("compileSdk")) {
|
||||
return compileSdk
|
||||
}
|
||||
else {
|
||||
return 31
|
||||
}
|
||||
def computeCompileSdkVersion() {
|
||||
if (project.hasProperty("compileSdk")) {
|
||||
return compileSdk
|
||||
} else {
|
||||
return 35
|
||||
}
|
||||
}
|
||||
|
||||
def computeBuildToolsVersion() {
|
||||
if (project.hasProperty("buildToolsVersion")) {
|
||||
return buildToolsVersion
|
||||
} else {
|
||||
return "35.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
def computeTargetSdkVersion() {
|
||||
if(project.hasProperty("targetSdk")) {
|
||||
return targetSdk
|
||||
}
|
||||
else {
|
||||
return 30
|
||||
}
|
||||
if (project.hasProperty("targetSdk")) {
|
||||
return targetSdk
|
||||
} else {
|
||||
return 35
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
// AGP 8 DSL: use 'compileSdk' and specify namespace
|
||||
compileSdk computeCompileSdkValue()
|
||||
namespace "org.nativescript.widgets"
|
||||
namespace "org.nativescript.widgets"
|
||||
compileSdkVersion computeCompileSdkVersion()
|
||||
buildToolsVersion computeBuildToolsVersion()
|
||||
|
||||
defaultConfig {
|
||||
minSdk 17
|
||||
targetSdk computeTargetSdkVersion()
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
defaultConfig {
|
||||
minSdkVersion 21
|
||||
targetSdkVersion computeTargetSdkVersion()
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
def androidXViewPagerVersion = "1.0.0"
|
||||
if (project.hasProperty("androidXViewPager")) {
|
||||
androidXViewPagerVersion = androidXViewPager
|
||||
println "\t + using android X library androidx.viewpager2:viewpager2:$androidXViewPagerVersion"
|
||||
}
|
||||
def androidXViewPagerVersion = "1.1.0"
|
||||
if (project.hasProperty("androidXViewPager")) {
|
||||
androidXViewPagerVersion = androidXViewPager
|
||||
println "\t + using android X library androidx.viewpager2:viewpager2:$androidXViewPagerVersion"
|
||||
}
|
||||
|
||||
def androidXFragmentVersion = "1.4.1"
|
||||
if (project.hasProperty("androidXFragment")) {
|
||||
androidXFragmentVersion = androidXFragment
|
||||
outLogger.withStyle(Style.SuccessHeader).println "\t + using android X library androidx.fragment:fragment:$androidXFragmentVersion"
|
||||
}
|
||||
def androidXFragmentVersion = "1.8.8"
|
||||
if (project.hasProperty("androidXFragment")) {
|
||||
androidXFragmentVersion = androidXFragment
|
||||
outLogger.withStyle(Style.SuccessHeader).println "\t + using android X library androidx.fragment:fragment:$androidXFragmentVersion"
|
||||
}
|
||||
|
||||
def androidXTransitionVersion = "1.4.1"
|
||||
if (project.hasProperty("androidXTransition")) {
|
||||
androidXTransitionVersion = androidXTransition
|
||||
outLogger.withStyle(Style.SuccessHeader).println "\t + using android X library androidx.transition:transition:$androidXTransitionVersion"
|
||||
}
|
||||
def androidXTransitionVersion = "1.6.0"
|
||||
if (project.hasProperty("androidXTransition")) {
|
||||
androidXTransitionVersion = androidXTransition
|
||||
outLogger.withStyle(Style.SuccessHeader).println "\t + using android X library androidx.transition:transition:$androidXTransitionVersion"
|
||||
}
|
||||
|
||||
def androidXExifInterfaceVersion = "1.3.3"
|
||||
if (project.hasProperty("androidXExifInterface")) {
|
||||
androidXExifInterfaceVersion = androidXExifInterface
|
||||
outLogger.withStyle(Style.SuccessHeader).println "\t + using android X library androidx.exifinterface:exifinterface:$androidXExifInterfaceVersion"
|
||||
}
|
||||
|
||||
|
||||
def androidXAppCompatVersion = "1.4.1"
|
||||
if (project.hasProperty("androidXAppCompat")) {
|
||||
androidXAppCompatVersion = androidXAppCompat
|
||||
outLogger.withStyle(Style.SuccessHeader).println "\t + using android X library androidx.appcompat:appcompat:$androidXAppCompatVersion"
|
||||
}
|
||||
|
||||
def androidXDocumentFileVersion = "1.0.1"
|
||||
if (project.hasProperty("androidXDocumentFile")) {
|
||||
androidXDocumentFileVersion = androidXDocumentFile
|
||||
outLogger.withStyle(Style.SuccessHeader).println "\t + using android X library androidx.documentfile:documentfile:$androidXDocumentFileVersion"
|
||||
def androidXExifInterfaceVersion = "1.4.1"
|
||||
if (project.hasProperty("androidXExifInterface")) {
|
||||
androidXExifInterfaceVersion = androidXExifInterface
|
||||
outLogger.withStyle(Style.SuccessHeader).println "\t + using android X library androidx.exifinterface:exifinterface:$androidXExifInterfaceVersion"
|
||||
}
|
||||
|
||||
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
def androidXAppCompatVersion = "1.7.1"
|
||||
if (project.hasProperty("androidXAppCompat")) {
|
||||
androidXAppCompatVersion = androidXAppCompat
|
||||
outLogger.withStyle(Style.SuccessHeader).println "\t + using android X library androidx.appcompat:appcompat:$androidXAppCompatVersion"
|
||||
}
|
||||
|
||||
println 'Using android X'
|
||||
// implementation 'androidx.viewpager:viewpager:' + androidxVersion
|
||||
implementation "androidx.viewpager2:viewpager2:$androidXViewPagerVersion"
|
||||
implementation "androidx.fragment:fragment:$androidXFragmentVersion"
|
||||
implementation "androidx.transition:transition:$androidXTransitionVersion"
|
||||
implementation "androidx.exifinterface:exifinterface:$androidXExifInterfaceVersion"
|
||||
implementation "androidx.appcompat:appcompat:$androidXAppCompatVersion"
|
||||
implementation "androidx.documentfile:documentfile:$androidXDocumentFileVersion"
|
||||
def androidXDocumentFileVersion = "1.1.0"
|
||||
if (project.hasProperty("androidXDocumentFile")) {
|
||||
androidXDocumentFileVersion = androidXDocumentFile
|
||||
outLogger.withStyle(Style.SuccessHeader).println "\t + using android X library androidx.documentfile:documentfile:$androidXDocumentFileVersion"
|
||||
}
|
||||
|
||||
def androidXActivityVersion = "1.10.1"
|
||||
if (project.hasProperty("androidXActivity")) {
|
||||
androidXActivityVersion = androidXActivity
|
||||
outLogger.withStyle(Style.SuccessHeader).println "\t + using android X library androidx.activity:activity:$androidXActivityVersion"
|
||||
}
|
||||
|
||||
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
|
||||
println 'Using android X'
|
||||
// implementation 'androidx.viewpager:viewpager:' + androidxVersion
|
||||
implementation "androidx.viewpager2:viewpager2:$androidXViewPagerVersion"
|
||||
implementation "androidx.fragment:fragment:$androidXFragmentVersion"
|
||||
implementation "androidx.transition:transition:$androidXTransitionVersion"
|
||||
implementation "androidx.exifinterface:exifinterface:$androidXExifInterfaceVersion"
|
||||
implementation "androidx.appcompat:appcompat:$androidXAppCompatVersion"
|
||||
implementation "androidx.documentfile:documentfile:$androidXDocumentFileVersion"
|
||||
implementation "androidx.activity:activity:$androidXActivityVersion"
|
||||
}
|
||||
|
||||
task cleanBuildDir (type: Delete) {
|
||||
delete "../build/"
|
||||
tasks.register('cleanBuildDir', Delete) {
|
||||
delete "../build/"
|
||||
}
|
||||
|
||||
task copyAar {
|
||||
doLast {
|
||||
copy {
|
||||
from "build/outputs/aar/widgets-release.aar"
|
||||
into "../build/"
|
||||
}
|
||||
}
|
||||
tasks.register('copyAar') {
|
||||
doLast {
|
||||
copy {
|
||||
from "build/outputs/aar/widgets-release.aar"
|
||||
into "../build/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.deprecation = true
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.deprecation = true
|
||||
}
|
||||
|
||||
assemble.dependsOn(cleanBuildDir)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package org.nativescript.widgets;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.View.MeasureSpec;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
@@ -29,18 +29,22 @@ public class GridLayout extends LayoutBase {
|
||||
private final HashMap<View, MeasureSpecs> map = new HashMap<>();
|
||||
|
||||
public GridLayout(Context context) {
|
||||
this(context, (AttributeSet)null);
|
||||
this(context, (AttributeSet) null);
|
||||
}
|
||||
|
||||
public GridLayout(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public GridLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public GridLayout(Context context, String rows) {
|
||||
this(context);
|
||||
this.addRowsFromJSON(rows);
|
||||
}
|
||||
|
||||
public GridLayout(Context context, String rows, String columns) {
|
||||
this(context, rows);
|
||||
this.addColumnsFromJSON(rows);
|
||||
@@ -92,7 +96,7 @@ public class GridLayout extends LayoutBase {
|
||||
return;
|
||||
}
|
||||
JSONArray rows = new JSONArray(value);
|
||||
for (int i = 0; i < rows.length() ; i++) {
|
||||
for (int i = 0; i < rows.length(); i++) {
|
||||
JSONObject row = rows.getJSONObject(i);
|
||||
addRow(row.getInt("value"), GridUnitType.values()[row.getInt("type")]);
|
||||
}
|
||||
@@ -101,13 +105,14 @@ public class GridLayout extends LayoutBase {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void addColumnsFromJSON(String value) {
|
||||
try {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
JSONArray columns = new JSONArray(value);
|
||||
for (int i = 0; i < columns.length() ; i++) {
|
||||
for (int i = 0; i < columns.length(); i++) {
|
||||
JSONObject column = columns.getJSONObject(i);
|
||||
addColumn(column.getInt("value"), GridUnitType.values()[column.getInt("type")]);
|
||||
}
|
||||
@@ -116,6 +121,7 @@ public class GridLayout extends LayoutBase {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void addRowsAndColumnsFromJSON(String rowsString, String jsonString) {
|
||||
addRowsFromJSON(rowsString);
|
||||
addColumnsFromJSON(jsonString);
|
||||
@@ -223,7 +229,7 @@ public class GridLayout extends LayoutBase {
|
||||
}
|
||||
|
||||
private ItemSpec getColumnSpec(CommonLayoutParams lp) {
|
||||
if (this._cols.size() == 0) {
|
||||
if (this._cols.isEmpty()) {
|
||||
return this.helper.singleColumn;
|
||||
}
|
||||
|
||||
@@ -232,7 +238,7 @@ public class GridLayout extends LayoutBase {
|
||||
}
|
||||
|
||||
private ItemSpec getRowSpec(CommonLayoutParams lp) {
|
||||
if (this._rows.size() == 0) {
|
||||
if (this._rows.isEmpty()) {
|
||||
return this.helper.singleRow;
|
||||
}
|
||||
|
||||
@@ -241,7 +247,7 @@ public class GridLayout extends LayoutBase {
|
||||
}
|
||||
|
||||
private int getColumnSpan(CommonLayoutParams lp, int columnIndex) {
|
||||
if (this._cols.size() == 0) {
|
||||
if (this._cols.isEmpty()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -249,7 +255,7 @@ public class GridLayout extends LayoutBase {
|
||||
}
|
||||
|
||||
private int getRowSpan(CommonLayoutParams lp, int rowIndex) {
|
||||
if (this._rows.size() == 0) {
|
||||
if (this._rows.isEmpty()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -344,8 +350,10 @@ public class GridLayout extends LayoutBase {
|
||||
}
|
||||
|
||||
MeasureSpecs measureSpecs = this.map.get(child);
|
||||
this.updateMeasureSpecs(child, measureSpecs);
|
||||
this.helper.addMeasureSpec(measureSpecs);
|
||||
if (measureSpecs != null) {
|
||||
this.updateMeasureSpecs(child, measureSpecs);
|
||||
this.helper.addMeasureSpec(measureSpecs);
|
||||
}
|
||||
}
|
||||
|
||||
this.helper.measure();
|
||||
@@ -1145,7 +1153,7 @@ class MeasureHelper {
|
||||
}
|
||||
|
||||
if (remainingSpace > 0) {
|
||||
this.minRowStarValue = Math.max(remainingSpace / measureSpec.starRowsCount, this.minRowStarValue);
|
||||
this.minRowStarValue = Math.max((float) remainingSpace / measureSpec.starRowsCount, this.minRowStarValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1165,7 +1173,7 @@ class MeasureHelper {
|
||||
}
|
||||
|
||||
if (remainingSpace > 0) {
|
||||
this.minColumnStarValue = Math.max(remainingSpace / measureSpec.starColumnsCount, this.minColumnStarValue);
|
||||
this.minColumnStarValue = Math.max((float) remainingSpace / measureSpec.starColumnsCount, this.minColumnStarValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,22 +6,113 @@ import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowInsets;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
/**
|
||||
* @author hhristov
|
||||
*/
|
||||
public abstract class LayoutBase extends ViewGroup {
|
||||
private boolean passThroughParent;
|
||||
boolean applyingEdges;
|
||||
|
||||
public static final int OverflowEdgeIgnore = -1;
|
||||
public static final int OverflowEdgeNone = 0;
|
||||
public static final int OverflowEdgeLeft = 1 << 1;
|
||||
public static final int OverflowEdgeTop = 1 << 2;
|
||||
public static final int OverflowEdgeRight = 1 << 3;
|
||||
public static final int OverflowEdgeBottom = 1 << 4;
|
||||
public static final int OverflowEdgeDontApply = 1 << 5;
|
||||
public static final int OverflowEdgeLeftDontConsume = 1 << 6;
|
||||
public static final int OverflowEdgeTopDontConsume = 1 << 7;
|
||||
public static final int OverflowEdgeRightDontConsume = 1 << 8;
|
||||
public static final int OverflowEdgeBottomDontConsume = 1 << 9;
|
||||
public static final int OverflowEdgeAllButLeft = 1 << 10;
|
||||
public static final int OverflowEdgeAllButTop = 1 << 11;
|
||||
public static final int OverflowEdgeAllButRight = 1 << 12;
|
||||
public static final int OverflowEdgeAllButBottom = 1 << 13;
|
||||
|
||||
public static final class BufferOffset {
|
||||
public static final int INSET_LEFT = 0;
|
||||
public static final int INSET_TOP = 4;
|
||||
public static final int INSET_RIGHT = 8;
|
||||
public static final int INSET_BOTTOM = 12;
|
||||
|
||||
public static final int INSET_LEFT_CONSUMED = 16;
|
||||
public static final int INSET_TOP_CONSUMED = 20;
|
||||
public static final int INSET_RIGHT_CONSUMED = 24;
|
||||
public static final int INSET_BOTTOM_CONSUMED = 28;
|
||||
}
|
||||
|
||||
int mPaddingLeft = 0;
|
||||
int mPaddingTop = 0;
|
||||
int mPaddingRight = 0;
|
||||
int mPaddingBottom = 0;
|
||||
|
||||
Insets edgeInsets = Insets.NONE;
|
||||
|
||||
int overflowEdge = OverflowEdgeIgnore;
|
||||
|
||||
private final ByteBuffer insetBuffer = ByteBuffer.allocateDirect(32);
|
||||
|
||||
private WindowInsetListener insetListener = null;
|
||||
private androidx.core.view.OnApplyWindowInsetsListener windowInsetsListener = null;
|
||||
|
||||
public void setInsetListener(@Nullable WindowInsetListener insetListener) {
|
||||
this.insetListener = insetListener;
|
||||
}
|
||||
|
||||
public interface WindowInsetListener {
|
||||
void onApplyWindowInsets(ByteBuffer inset);
|
||||
}
|
||||
|
||||
private static final byte[] EMPTY_INSETS = new byte[32];
|
||||
|
||||
|
||||
private boolean pendingInsetApply = false;
|
||||
private final OnAttachStateChangeListener onAttachStateChangeListener = new OnAttachStateChangeListener() {
|
||||
@Override
|
||||
public void onViewAttachedToWindow(@NonNull View v) {
|
||||
if (pendingInsetApply) {
|
||||
pendingInsetApply = false;
|
||||
removeOnAttachStateChangeListener(onAttachStateChangeListener);
|
||||
ViewCompat.requestApplyInsets(v);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewDetachedFromWindow(@NonNull View v) {
|
||||
}
|
||||
};
|
||||
|
||||
public LayoutBase(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
insetBuffer.order(ByteOrder.nativeOrder());
|
||||
}
|
||||
|
||||
@Override
|
||||
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
|
||||
return super.onApplyWindowInsets(insets);
|
||||
}
|
||||
|
||||
public LayoutBase(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public Insets getEdgeInsets() {
|
||||
return edgeInsets;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LayoutParams generateDefaultLayoutParams() {
|
||||
return new CommonLayoutParams();
|
||||
@@ -95,4 +186,237 @@ public abstract class LayoutBase extends ViewGroup {
|
||||
public void setPassThroughParent(boolean value) {
|
||||
this.passThroughParent = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPadding(int left, int top, int right, int bottom) {
|
||||
if (!applyingEdges) {
|
||||
mPaddingLeft = left;
|
||||
mPaddingTop = top;
|
||||
mPaddingRight = right;
|
||||
mPaddingBottom = bottom;
|
||||
}
|
||||
super.setPadding(left, top, right, bottom);
|
||||
}
|
||||
|
||||
public void setOverflowEdge(int value) {
|
||||
overflowEdge = value;
|
||||
|
||||
if (value == OverflowEdgeIgnore) {
|
||||
ViewCompat.setOnApplyWindowInsetsListener(this, null);
|
||||
ViewCompat.requestApplyInsets(this);
|
||||
} else if (windowInsetsListener == null) {
|
||||
// if incoming inset is empty and previous inset is empty return consumed
|
||||
// an incoming empty inset is one way to detect a consumed inset e.g multiple views consumed top/bottom
|
||||
windowInsetsListener = new androidx.core.view.OnApplyWindowInsetsListener() {
|
||||
@NonNull
|
||||
@Override
|
||||
public WindowInsetsCompat onApplyWindowInsets(@NonNull View v, @NonNull WindowInsetsCompat insets) {
|
||||
if (insets.isConsumed()) {
|
||||
return insets;
|
||||
}
|
||||
if (v instanceof LayoutBase) {
|
||||
LayoutBase base = (LayoutBase) v;
|
||||
|
||||
// should not occur but if it does return the inset
|
||||
if (overflowEdge == OverflowEdgeIgnore) {
|
||||
return insets;
|
||||
}
|
||||
|
||||
Insets statusBar = insets.getInsets(WindowInsetsCompat.Type.statusBars());
|
||||
Insets navBar = insets.getInsets(WindowInsetsCompat.Type.navigationBars());
|
||||
Insets ime = insets.getInsets(WindowInsetsCompat.Type.ime());
|
||||
|
||||
int insetLeft = navBar.left;
|
||||
int insetRight = navBar.right;
|
||||
int insetBottom = Math.max(navBar.bottom, ime.bottom);
|
||||
|
||||
insetBuffer.put(EMPTY_INSETS, 0, 32);
|
||||
insetBuffer.rewind();
|
||||
|
||||
if (overflowEdge == OverflowEdgeNone) {
|
||||
base.applyingEdges = true;
|
||||
v.setPadding(mPaddingLeft + insetLeft, mPaddingTop + statusBar.top, mPaddingRight + insetRight, mPaddingBottom + insetBottom);
|
||||
edgeInsets = Insets.of(insetLeft, statusBar.top, insetRight, insetBottom);
|
||||
base.applyingEdges = false;
|
||||
return WindowInsetsCompat.CONSUMED;
|
||||
}
|
||||
|
||||
if (base.insetListener != null) {
|
||||
if (overflowEdge == OverflowEdgeDontApply) {
|
||||
// if incoming inset is empty and previous inset is empty return consumed
|
||||
// an incoming empty inset is one way to detect a consumed inset e.g multiple views consumed top/bottom
|
||||
if (Insets.NONE.equals(statusBar) && Insets.NONE.equals(navBar) && Insets.NONE.equals(ime) && Insets.NONE.equals(edgeInsets)) {
|
||||
return WindowInsetsCompat.CONSUMED;
|
||||
}
|
||||
|
||||
IntBuffer insetData = insetBuffer.asIntBuffer();
|
||||
|
||||
boolean leftPreviouslyConsumed = insetLeft == 0;
|
||||
boolean topPreviouslyConsumed = statusBar.top == 0;
|
||||
boolean rightPreviouslyConsumed = insetRight == 0;
|
||||
boolean bottomPreviouslyConsumed = insetBottom == 0;
|
||||
|
||||
|
||||
insetData.put(0, insetLeft).put(1, statusBar.top).put(2, insetRight).put(3, insetBottom).put(4, leftPreviouslyConsumed ? 1 : 0).put(5, topPreviouslyConsumed ? 1 : 0).put(6, rightPreviouslyConsumed ? 1 : 0).put(7, bottomPreviouslyConsumed ? 1 : 0);
|
||||
|
||||
base.insetListener.onApplyWindowInsets(insetBuffer);
|
||||
|
||||
int leftInset = insetData.get(0);
|
||||
int topInset = insetData.get(1);
|
||||
int rightInset = insetData.get(2);
|
||||
int bottomInset = insetData.get(3);
|
||||
|
||||
boolean leftConsumed = insetData.get(4) > 0;
|
||||
boolean topConsumed = insetData.get(5) > 0;
|
||||
boolean rightConsumed = insetData.get(6) > 0;
|
||||
boolean bottomConsumed = insetData.get(7) > 0;
|
||||
|
||||
if (leftConsumed && topConsumed && rightConsumed && bottomConsumed) {
|
||||
edgeInsets = Insets.of(leftInset, topInset, rightInset, bottomInset);
|
||||
base.setPadding(leftInset, topInset, rightInset, bottomInset);
|
||||
return new WindowInsetsCompat.Builder().setInsets(WindowInsetsCompat.Type.systemBars(), Insets.NONE).build();
|
||||
}
|
||||
|
||||
base.setPadding(leftPreviouslyConsumed ? 0 : leftInset, topPreviouslyConsumed ? 0 : topInset, rightPreviouslyConsumed ? 0 : rightInset, bottomPreviouslyConsumed ? 0 : bottomInset);
|
||||
|
||||
// restore inset edge if not consumed
|
||||
|
||||
if (!(leftPreviouslyConsumed || leftConsumed)) {
|
||||
leftInset = insetLeft;
|
||||
}
|
||||
|
||||
if (!(topPreviouslyConsumed || topConsumed)) {
|
||||
topInset = statusBar.top;
|
||||
}
|
||||
|
||||
if (!(rightPreviouslyConsumed || rightConsumed)) {
|
||||
rightInset = insetRight;
|
||||
}
|
||||
|
||||
if (!(bottomPreviouslyConsumed || bottomConsumed)) {
|
||||
bottomInset = insetBottom;
|
||||
}
|
||||
|
||||
edgeInsets = Insets.of(leftPreviouslyConsumed ? 0 : leftInset, topPreviouslyConsumed ? 0 : topInset, rightPreviouslyConsumed ? 0 : rightInset, bottomPreviouslyConsumed ? 0 : bottomInset);
|
||||
|
||||
return new WindowInsetsCompat.Builder().setInsets(WindowInsetsCompat.Type.systemBars(), Insets.of(leftPreviouslyConsumed || leftConsumed ? 0 : leftInset, topPreviouslyConsumed || topConsumed ? 0 : topInset, rightPreviouslyConsumed || rightConsumed ? 0 : rightInset, bottomPreviouslyConsumed || bottomConsumed ? 0 : bottomInset)).build();
|
||||
}
|
||||
}
|
||||
|
||||
boolean overflowLeftConsume = (overflowEdge & OverflowEdgeLeft) == OverflowEdgeLeft;
|
||||
boolean overflowTopConsume = (overflowEdge & OverflowEdgeTop) == OverflowEdgeTop;
|
||||
boolean overflowRightConsume = (overflowEdge & OverflowEdgeRight) == OverflowEdgeRight;
|
||||
boolean overflowBottomConsume = (overflowEdge & OverflowEdgeBottom) == OverflowEdgeBottom;
|
||||
|
||||
boolean overflowLeft = (overflowEdge & OverflowEdgeLeftDontConsume) == OverflowEdgeLeftDontConsume;
|
||||
boolean overflowTop = (overflowEdge & OverflowEdgeTopDontConsume) == OverflowEdgeTopDontConsume;
|
||||
boolean overflowRight = (overflowEdge & OverflowEdgeRightDontConsume) == OverflowEdgeRightDontConsume;
|
||||
boolean overflowBottom = (overflowEdge & OverflowEdgeBottomDontConsume) == OverflowEdgeBottomDontConsume;
|
||||
|
||||
|
||||
boolean overflowAllButLeft = (overflowEdge & OverflowEdgeAllButLeft) == OverflowEdgeAllButLeft;
|
||||
boolean overflowAllButTop = (overflowEdge & OverflowEdgeAllButTop) == OverflowEdgeAllButTop;
|
||||
boolean overflowAllButRight = (overflowEdge & OverflowEdgeAllButRight) == OverflowEdgeAllButRight;
|
||||
boolean overflowAllButBottom = (overflowEdge & OverflowEdgeAllButBottom) == OverflowEdgeAllButBottom;
|
||||
|
||||
|
||||
WindowInsetsCompat ret = insets;
|
||||
base.applyingEdges = true;
|
||||
int left = 0;
|
||||
int top = 0;
|
||||
int right = 0;
|
||||
int bottom = 0;
|
||||
|
||||
|
||||
if (overflowAllButLeft || overflowAllButTop || overflowAllButRight || overflowAllButBottom) {
|
||||
Insets newInset;
|
||||
if (overflowAllButLeft) {
|
||||
left = mPaddingLeft + insetLeft;
|
||||
edgeInsets = Insets.of(insetLeft, 0, 0, 0);
|
||||
newInset = Insets.of(0, statusBar.top, insetRight, insetBottom);
|
||||
} else if (overflowAllButTop) {
|
||||
top = mPaddingTop + statusBar.top;
|
||||
edgeInsets = Insets.of(0, statusBar.top, 0, 0);
|
||||
newInset = Insets.of(insetLeft, 0, insetRight, insetBottom);
|
||||
} else if (overflowAllButRight) {
|
||||
right = mPaddingRight + insetRight;
|
||||
edgeInsets = Insets.of(0, 0, insetRight, 0);
|
||||
newInset = Insets.of(insetLeft, statusBar.top, 0, insetBottom);
|
||||
} else {
|
||||
bottom = mPaddingBottom + insetBottom;
|
||||
edgeInsets = Insets.of(0, 0, 0, insetBottom);
|
||||
newInset = Insets.of(insetLeft, statusBar.top, insetRight, 0);
|
||||
}
|
||||
|
||||
ret = new WindowInsetsCompat.Builder().setInsets(WindowInsetsCompat.Type.systemBars(), newInset).build();
|
||||
base.setPadding(left, top, right, bottom);
|
||||
base.applyingEdges = false;
|
||||
if (newInset == Insets.NONE) {
|
||||
return WindowInsetsCompat.CONSUMED;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (overflowLeftConsume || overflowLeft) {
|
||||
top = mPaddingTop + statusBar.top;
|
||||
right = mPaddingRight + insetRight;
|
||||
bottom = mPaddingBottom + insetBottom;
|
||||
edgeInsets = Insets.of(insetLeft, statusBar.top, insetRight, insetBottom);
|
||||
if (overflowRightConsume) {
|
||||
ret = WindowInsetsCompat.CONSUMED;
|
||||
}
|
||||
}
|
||||
if (overflowTopConsume || overflowTop) {
|
||||
left = mPaddingLeft + insetLeft;
|
||||
right = mPaddingRight + insetRight;
|
||||
bottom = mPaddingBottom + insetBottom;
|
||||
edgeInsets = Insets.of(insetLeft, statusBar.top, insetRight, insetBottom);
|
||||
if (overflowTopConsume) {
|
||||
ret = WindowInsetsCompat.CONSUMED;
|
||||
}
|
||||
}
|
||||
if (overflowRightConsume || overflowRight) {
|
||||
left = mPaddingLeft + insetLeft;
|
||||
top = mPaddingTop + statusBar.top;
|
||||
bottom = mPaddingBottom + insetBottom;
|
||||
edgeInsets = Insets.of(insetLeft, statusBar.top, insetRight, insetBottom);
|
||||
if (overflowRightConsume) {
|
||||
ret = WindowInsetsCompat.CONSUMED;
|
||||
}
|
||||
}
|
||||
if (overflowBottomConsume || overflowBottom) {
|
||||
left = mPaddingLeft + insetLeft;
|
||||
top = mPaddingTop + statusBar.top;
|
||||
right = mPaddingRight + insetRight;
|
||||
edgeInsets = Insets.of(insetLeft, statusBar.top, insetRight, insetBottom);
|
||||
if (overflowBottomConsume) {
|
||||
ret = WindowInsetsCompat.CONSUMED;
|
||||
}
|
||||
}
|
||||
|
||||
base.setPadding(left, top, right, bottom);
|
||||
|
||||
base.applyingEdges = false;
|
||||
return ret;
|
||||
}
|
||||
return insets;
|
||||
}
|
||||
};
|
||||
ViewCompat.setOnApplyWindowInsetsListener(this, windowInsetsListener);
|
||||
}
|
||||
|
||||
if (pendingInsetApply) {
|
||||
return;
|
||||
}
|
||||
if (isAttachedToWindow()) {
|
||||
ViewCompat.requestApplyInsets(this);
|
||||
} else {
|
||||
pendingInsetApply = true;
|
||||
addOnAttachStateChangeListener(onAttachStateChangeListener);
|
||||
}
|
||||
}
|
||||
|
||||
public int getOverflowEdge() {
|
||||
return overflowEdge;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.nativescript.widgets;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
@@ -23,6 +24,9 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
|
||||
import androidx.activity.ComponentActivity;
|
||||
import androidx.activity.SystemBarStyle;
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.exifinterface.media.ExifInterface;
|
||||
@@ -38,8 +42,53 @@ import java.io.IOException;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
|
||||
public class Utils {
|
||||
|
||||
public interface HandleDarkMode {
|
||||
boolean onHandle(int bar, Resources resources);
|
||||
}
|
||||
|
||||
enum HandleDarkModeBar {
|
||||
status(0),
|
||||
navigation(1);
|
||||
|
||||
private final int mValue;
|
||||
|
||||
HandleDarkModeBar(int i) {
|
||||
this.mValue = i;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return this.mValue;
|
||||
}
|
||||
}
|
||||
|
||||
// The light scrim color used in the platform API 29+
|
||||
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/com/android/internal/policy/DecorView.java;drc=6ef0f022c333385dba2c294e35b8de544455bf19;l=142
|
||||
static final int DefaultLightScrim = Color.argb(0xe6, 0xFF, 0xFF, 0xFF);
|
||||
|
||||
// The dark scrim color used in the platform.
|
||||
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/res/res/color/system_bar_background_semi_transparent.xml
|
||||
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/res/remote_color_resources_res/values/colors.xml;l=67
|
||||
static final int DefaultDarkScrim = Color.argb(0x80, 0x1b, 0x1b, 0x1b);
|
||||
|
||||
public static void enableEdgeToEdge(ComponentActivity activity) {
|
||||
androidx.activity.EdgeToEdge.enable(activity);
|
||||
}
|
||||
|
||||
public static void enableEdgeToEdge(ComponentActivity activity, HandleDarkMode handleDarkMode) {
|
||||
androidx.activity.EdgeToEdge.enable(activity, SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT, resources -> handleDarkMode.onHandle(HandleDarkModeBar.status.getValue(), resources)), SystemBarStyle.auto(DefaultLightScrim, DefaultDarkScrim, resources -> handleDarkMode.onHandle(HandleDarkModeBar.navigation.getValue(), resources)));
|
||||
}
|
||||
|
||||
public static void enableEdgeToEdge(ComponentActivity activity, @ColorInt Integer statusBarLight, @ColorInt Integer statusBarDark, @ColorInt Integer navigationBarLight, @ColorInt Integer navigationBarDark) {
|
||||
androidx.activity.EdgeToEdge.enable(activity, SystemBarStyle.auto(statusBarLight, statusBarDark), SystemBarStyle.auto(navigationBarLight, navigationBarDark));
|
||||
}
|
||||
|
||||
public static void enableEdgeToEdge(ComponentActivity activity, @ColorInt Integer statusBarLight, @ColorInt Integer statusBarDark, @ColorInt Integer navigationBarLight, @ColorInt Integer navigationBarDark, HandleDarkMode handleDarkMode) {
|
||||
androidx.activity.EdgeToEdge.enable(activity, SystemBarStyle.auto(statusBarLight, statusBarDark, resources -> handleDarkMode.onHandle(HandleDarkModeBar.status.getValue(), resources)), SystemBarStyle.auto(navigationBarLight, navigationBarDark, resources -> handleDarkMode.onHandle(HandleDarkModeBar.navigation.getValue(), resources)));
|
||||
}
|
||||
|
||||
public static Drawable getDrawable(String uri, Context context) {
|
||||
int resId = 0;
|
||||
int resPrefixLength = "res://".length();
|
||||
@@ -457,10 +506,7 @@ public class Utils {
|
||||
|
||||
Bitmap.CompressFormat targetFormat = getTargetFormat(format);
|
||||
|
||||
try (
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
Base64OutputStream base64Stream = new Base64OutputStream(outputStream, android.util.Base64.NO_WRAP)
|
||||
) {
|
||||
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Base64OutputStream base64Stream = new Base64OutputStream(outputStream, android.util.Base64.NO_WRAP)) {
|
||||
bitmap.compress(targetFormat, quality, base64Stream);
|
||||
result = outputStream.toString();
|
||||
} catch (Exception e) {
|
||||
@@ -491,9 +537,7 @@ public class Utils {
|
||||
return new Pair<>((int) width, (int) height);
|
||||
}
|
||||
|
||||
return new Pair<>(
|
||||
Math.round((maxSize * width) / height)
|
||||
, (int) maxSize);
|
||||
return new Pair<>(Math.round((maxSize * width) / height), (int) maxSize);
|
||||
}
|
||||
|
||||
if (width <= maxSize) {
|
||||
|
||||