diff --git a/FancyWork/.gitignore b/FancyWork/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/FancyWork/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/FancyWork/.idea/.gitignore b/FancyWork/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/FancyWork/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/FancyWork/.idea/compiler.xml b/FancyWork/.idea/compiler.xml new file mode 100644 index 0000000..61a9130 --- /dev/null +++ b/FancyWork/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/FancyWork/.idea/gradle.xml b/FancyWork/.idea/gradle.xml new file mode 100644 index 0000000..18de3ac --- /dev/null +++ b/FancyWork/.idea/gradle.xml @@ -0,0 +1,21 @@ + + + + + + \ No newline at end of file diff --git a/FancyWork/.idea/jarRepositories.xml b/FancyWork/.idea/jarRepositories.xml new file mode 100644 index 0000000..a5f05cd --- /dev/null +++ b/FancyWork/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/FancyWork/.idea/misc.xml b/FancyWork/.idea/misc.xml new file mode 100644 index 0000000..d5d35ec --- /dev/null +++ b/FancyWork/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/FancyWork/.idea/vcs.xml b/FancyWork/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/FancyWork/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/FancyWork/app/.gitignore b/FancyWork/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/FancyWork/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/FancyWork/app/build.gradle b/FancyWork/app/build.gradle new file mode 100644 index 0000000..45bf9c5 --- /dev/null +++ b/FancyWork/app/build.gradle @@ -0,0 +1,45 @@ +plugins { + id 'com.android.application' + id 'kotlin-android' +} + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.2" + + defaultConfig { + applicationId "com.example.fancywork" + minSdkVersion 16 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } +} + +dependencies { + + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'com.google.android.material:material:1.3.0' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.+' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' +} \ No newline at end of file diff --git a/FancyWork/app/proguard-rules.pro b/FancyWork/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/FancyWork/app/proguard-rules.pro @@ -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 \ No newline at end of file diff --git a/FancyWork/app/src/androidTest/java/com/example/fancywork/ExampleInstrumentedTest.kt b/FancyWork/app/src/androidTest/java/com/example/fancywork/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..0297721 --- /dev/null +++ b/FancyWork/app/src/androidTest/java/com/example/fancywork/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.example.fancywork + +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("com.example.fancywork", appContext.packageName) + } +} \ No newline at end of file diff --git a/FancyWork/app/src/main/AndroidManifest.xml b/FancyWork/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..ce40722 --- /dev/null +++ b/FancyWork/app/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/FancyWork/app/src/main/java/com/example/fancywork/MainActivity.kt b/FancyWork/app/src/main/java/com/example/fancywork/MainActivity.kt new file mode 100644 index 0000000..2bf6ffb --- /dev/null +++ b/FancyWork/app/src/main/java/com/example/fancywork/MainActivity.kt @@ -0,0 +1,12 @@ +package com.example.fancywork + +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle + +///obviously we haven't done anything yet +class MainActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + } +} \ No newline at end of file diff --git a/FancyWork/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/FancyWork/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/FancyWork/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/FancyWork/app/src/main/res/drawable/ic_launcher_background.xml b/FancyWork/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/FancyWork/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FancyWork/app/src/main/res/layout/activity_main.xml b/FancyWork/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..bad745b --- /dev/null +++ b/FancyWork/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/FancyWork/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/FancyWork/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/FancyWork/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/FancyWork/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/FancyWork/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/FancyWork/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/FancyWork/app/src/main/res/mipmap-hdpi/ic_launcher.png b/FancyWork/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 Binary files /dev/null and b/FancyWork/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/FancyWork/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/FancyWork/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 Binary files /dev/null and b/FancyWork/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/FancyWork/app/src/main/res/mipmap-mdpi/ic_launcher.png b/FancyWork/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 Binary files /dev/null and b/FancyWork/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/FancyWork/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/FancyWork/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a Binary files /dev/null and b/FancyWork/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/FancyWork/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/FancyWork/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..6dba46d Binary files /dev/null and b/FancyWork/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/FancyWork/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/FancyWork/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..da31a87 Binary files /dev/null and b/FancyWork/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/FancyWork/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/FancyWork/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..15ac681 Binary files /dev/null and b/FancyWork/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/FancyWork/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/FancyWork/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..b216f2d Binary files /dev/null and b/FancyWork/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/FancyWork/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/FancyWork/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..f25a419 Binary files /dev/null and b/FancyWork/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/FancyWork/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/FancyWork/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..e96783c Binary files /dev/null and b/FancyWork/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/FancyWork/app/src/main/res/values-night/themes.xml b/FancyWork/app/src/main/res/values-night/themes.xml new file mode 100644 index 0000000..1950faa --- /dev/null +++ b/FancyWork/app/src/main/res/values-night/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/FancyWork/app/src/main/res/values/colors.xml b/FancyWork/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..f8c6127 --- /dev/null +++ b/FancyWork/app/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/FancyWork/app/src/main/res/values/strings.xml b/FancyWork/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..43de5a1 --- /dev/null +++ b/FancyWork/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + FancyWork + \ No newline at end of file diff --git a/FancyWork/app/src/main/res/values/themes.xml b/FancyWork/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..ec97901 --- /dev/null +++ b/FancyWork/app/src/main/res/values/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/FancyWork/app/src/test/java/com/example/fancywork/ExampleUnitTest.kt b/FancyWork/app/src/test/java/com/example/fancywork/ExampleUnitTest.kt new file mode 100644 index 0000000..c41564a --- /dev/null +++ b/FancyWork/app/src/test/java/com/example/fancywork/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.example.fancywork + +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) + } +} \ No newline at end of file diff --git a/FancyWork/build.gradle b/FancyWork/build.gradle new file mode 100644 index 0000000..6534ac0 --- /dev/null +++ b/FancyWork/build.gradle @@ -0,0 +1,26 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + ext.kotlin_version = "1.4.21" + repositories { + google() + jcenter() + } + dependencies { + classpath "com.android.tools.build:gradle:4.1.1" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} \ No newline at end of file diff --git a/FancyWork/gradle.properties b/FancyWork/gradle.properties new file mode 100644 index 0000000..98bed16 --- /dev/null +++ b/FancyWork/gradle.properties @@ -0,0 +1,21 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app"s APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Automatically convert third-party libraries to use AndroidX +android.enableJetifier=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official \ No newline at end of file diff --git a/FancyWork/gradle/wrapper/gradle-wrapper.jar b/FancyWork/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..f6b961f Binary files /dev/null and b/FancyWork/gradle/wrapper/gradle-wrapper.jar differ diff --git a/FancyWork/gradle/wrapper/gradle-wrapper.properties b/FancyWork/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..57967f7 --- /dev/null +++ b/FancyWork/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sat Mar 13 23:41:35 MSK 2021 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip diff --git a/FancyWork/gradlew b/FancyWork/gradlew new file mode 100644 index 0000000..cccdd3d --- /dev/null +++ b/FancyWork/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# 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 +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="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# 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 + ;; +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" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +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. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +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" ;; + 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, 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" + +# 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")" +fi + +exec "$JAVACMD" "$@" diff --git a/FancyWork/gradlew.bat b/FancyWork/gradlew.bat new file mode 100644 index 0000000..f955316 --- /dev/null +++ b/FancyWork/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@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= + +@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 + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +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% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="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 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/FancyWork/settings.gradle b/FancyWork/settings.gradle new file mode 100644 index 0000000..86e60ec --- /dev/null +++ b/FancyWork/settings.gradle @@ -0,0 +1,2 @@ +include ':app' +rootProject.name = "FancyWork" \ No newline at end of file diff --git a/app/src/main/java/com/example/fancywork/PixelizationAlgorythm.kt b/app/src/main/java/com/example/fancywork/PixelizationAlgorythm.kt new file mode 100644 index 0000000..b50b177 --- /dev/null +++ b/app/src/main/java/com/example/fancywork/PixelizationAlgorythm.kt @@ -0,0 +1,79 @@ +package com.example.fancywork + +import android.content.res.Resources +import android.graphics.Bitmap +import android.graphics.Color +import kotlin.math.ceil +import kotlin.math.max +import kotlin.math.min +import kotlin.math.pow + + +class PixelizationAlgorythm { + fun getPixelsFromImage(bitmap: Bitmap, resources: Resources, pixelSize: Int): + Array>?>> { + val stream = resources.openRawResource(R.raw.colors) + val colors = stream + .bufferedReader() + .readLines() + .drop(1) + .map { x -> x.split(",") } + .map { x -> x[0] to Triple(x[1].toInt(), x[2].toInt(), x[3].toInt()) } + val resultTable = Array(ceil(bitmap.width.toDouble() / pixelSize).toInt()) { + arrayOfNulls>>(ceil(bitmap.height.toDouble()).toInt()) + } + for (i in 0 until bitmap.width step pixelSize) { + for (j in 0 until bitmap.height step pixelSize) { + val pixelWidth = + if (bitmap.width - i >= 2 * pixelSize) pixelSize else bitmap.width - i + val pixelHeight = + if (bitmap.height - j >= 2 * pixelSize) pixelSize else bitmap.height - j + val pixelColors = IntArray(pixelWidth * pixelHeight) + bitmap.getPixels(pixelColors, 0, pixelWidth, i, j, pixelWidth, pixelHeight) + val colorsAv = colorToTriple(findAverageColor(pixelColors, pixelWidth, pixelHeight)) + val mainColor = colors.minByOrNull { x -> findDistance(x.second, colorsAv) }!! + resultTable[i / pixelSize][j / pixelSize] = mainColor + } + } + return resultTable + } + + private fun colorToTriple(color: Int): Triple { + return Triple( + (color shr 16) and 0xff, + (color shr 8) and 0xff, + color and 0xff + ) + } + + private fun findAverageColor(pixel: IntArray, pixelWidth: Int, pixelHeight: Int): Int { + val colorsSum = pixel + .fold(Triple(0, 0, 0), { x, y -> + Triple( + x.first + (y shr 16) and 0xff, + x.second + (y shr 8) and 0xff, + x.third + y and 0xff + ) + }) + return Color.rgb( + colorsSum.first / (pixelWidth * pixelHeight), + colorsSum.second / (pixelWidth * pixelHeight), + colorsSum.third / (pixelWidth * pixelHeight) + ) + } + + private fun findDistance(x: Triple, colorsAv: Triple): Double { + return (((1 + max(x.first, colorsAv.first)).toDouble() / (1 + min( + x.first, + colorsAv.first + ))).pow(2) + + ((1 + max(x.second, colorsAv.second)).toDouble() / (1 + min( + x.second, + colorsAv.second + ))).pow(2) + + ((1 + max(x.third, colorsAv.third)).toDouble() / (1 + min( + x.third, + colorsAv.third + ))).pow(2)) + } +} \ No newline at end of file diff --git a/app/src/main/res/raw/colors.csv b/app/src/main/res/raw/colors.csv new file mode 100644 index 0000000..385133d --- /dev/null +++ b/app/src/main/res/raw/colors.csv @@ -0,0 +1,425 @@ +DMC,Red,Green,Blue +208,159,72,178 +209,191,116,202 +210,208,149,228 +211,222,179,235 +221,145,41,52 +223,195,92,118 +224,225,148,157 +225,243,198,208 +256,207,91,82 +300,121,48,34 +301,175,76,33 +3011,114,97,50 +3012,143,124,64 +3013,172,161,104 +3021,87,66,57 +3022,142,130,113 +3023,172,157,141 +3024,195,190,186 +3031,83,56,51 +3032,163,133,107 +3033,220,197,185 +304,190,15,43 +3041,144,99,126 +3042,181,142,175 +3045,187,139,88 +3046,209,178,108 +3047,228,212,150 +3051,92,90,53 +3052,128,132,89 +3053,150,153,105 +3064,207,128,108 +307,229,207,7 +3072,207,206,199 +3078,236,227,140 +309,206,29,83 +310,42,38,40 +311,58,65,107 +312,66,84,139 +315,145,64,89 +316,199,107,157 +317,103,96,111 +318,157,151,172 +319,50,77,52 +320,99,136,93 +321,202,5,32 +322,94,119,181 +326,200,16,58 +327,124,47,119 +3325,161,184,221 +3326,243,143,182 +3328,223,70,85 +333,116,65,169 +334,110,136,185 +3340,244,80,77 +3341,244,124,127 +3345,61,85,44 +3346,93,116,58 +3347,108,133,70 +3348,158,178,96 +335,234,68,128 +3350,207,45,106 +3354,236,138,183 +336,59,55,96 +3362,82,93,65 +3363,105,126,89 +3364,138,151,98 +3371,57,47,48 +340,153,129,212 +341,164,163,214 +347,216,36,50 +349,206,8,43 +350,233,66,65 +351,241,93,91 +352,245,144,137 +353,246,187,176 +355,174,48,48 +3607,215,63,151 +3608,239,122,199 +3609,242,152,219 +367,78,116,77 +368,135,166,118 +3685,158,42,91 +3687,202,64,125 +3688,241,162,203 +3689,241,162,203 +369,182,208,163 +370,156,127,72 +3705,240,50,93 +3706,248,83,139 +3708,195,9,28 +371,156,130,74 +3712,235,95,110 +3713,246,187,205 +3716,244,145,193 +372,175,155,103 +3721,166,58,73 +3722,183,78,98 +3726,159,80,105 +3727,215,140,177 +3731,217,67,130 +3733,235,106,159 +3740,125,78,99 +3743,206,179,207 +3746,129,92,187 +3747,198,193,229 +3750,56,67,97 +3752,169,186,209 +3753,191,206,224 +3755,137,166,207 +3756,220,228,234 +3760,90,134,171 +3761,172,211,222 +3765,60,109,142 +3766,135,187,198 +3768,95,115,120 +3770,246,224,207 +3772,174,96,90 +3773,212,139,128 +3774,239,197,182 +3776,214,104,52 +3777,156,35,45 +3778,223,116,106 +3779,240,168,161 +3781,109,74,60 +3782,185,154,132 +3787,108,90,79 +3790,131,99,83 +3799,76,65,71 +3801,243,29,72 +3802,127,47,76 +3803,158,42,91 +3804,218,15,116 +3806,236,85,167 +3807,109,102,170 +3808,46,92,90 +3809,59,114,123 +3810,87,144,154 +3811,171,212,212 +3812,18,154,106 +3813,157,187,176 +3814,62,142,108 +3815,86,133,102 +3816,112,158,133 +3817,149,184,164 +3818,16,97,43 +3819,191,193,24 +3820,222,161,29 +3821,228,180,53 +3822,239,202,91 +3823,238,223,174 +3824,245,142,145 +3825,243,150,113 +3826,179,84,40 +3827,229,155,94 +3828,188,131,76 +3829,174,109,44 +3830,197,69,63 +3831,205,36,75 +3832,229,52,106 +3833,237,89,138 +3834,120,48,101 +3835,155,80,142 +3836,192,119,178 +3837,142,50,164 +3838,109,105,189 +3839,130,132,206 +3840,168,183,233 +3841,184,203,225 +3842,60,87,134 +3843,19,127,202 +3844,7,146,178 +3845,11,182,211 +3846,55,200,225 +3847,42,108,89 +3848,68,141,122 +3849,101,166,150 +3850,13,148,80 +3851,76,184,126 +3852,207,136,14 +3853,225,106,37 +3854,238,145,74 +3855,241,194,125 +3856,238,172,127 +3857,125,50,48 +3858,148,69,71 +3859,198,114,108 +3860,139,91,100 +3861,167,123,133 +3862,136,89,71 +3863,159,109,92 +3864,194,151,137 +3865,248,247,245 +3866,229,215,209 +400,147,53,28 +402,235,138,95 +407,199,124,118 +413,86,82,91 +414,124,114,134 +415,180,175,193 +420,162,100,54 +422,208,160,100 +433,125,63,46 +434,158,81,48 +435,185,110,55 +436,208,140,84 +437,218,159,108 +444,225,181,7 +445,231,232,89 +451,147,116,125 +452,182,149,162 +453,205,183,186 +469,86,100,42 +470,116,133,44 +471,132,143,72 +472,174,185,96 +498,184,15,40 +500,48,67,58 +501,76,107,95 +502,104,139,124 +503,135,171,159 +504,179,209,193 +517,76,110,163 +518,104,154,179 +519,145,185,210 +520,74,91,69 +522,129,140,115 +523,150,156,129 +524,161,164,135 +535,93,86,87 +543,229,197,188 +550,96,25,97 +552,150,55,157 +553,170,78,176 +554,212,135,210 +561,59,107,85 +562,90,148,101 +563,135,193,147 +564,160,209,166 +580,92,99,38 +581,123,137,43 +597,113,167,173 +598,151,198,197 +600,209,6,88 +601,225,7,109 +602,234,32,132 +603,241,76,163 +604,242,119,191 +605,245,153,213 +606,225,2,14 +608,242,5,40 +610,114,86,64 +611,143,106,78 +612,174,141,100 +613,207,184,160 +632,146,69,62 +640,139,113,90 +642,160,139,116 +644,203,186,165 +645,111,100,96 +646,125,117,114 +647,153,145,133 +648,178,170,164 +666,230,5,25 +676,230,183,109 +677,236,214,157 +680,178,117,50 +699,9,105,35 +700,33,128,43 +701,49,140,46 +702,74,156,47 +703,108,177,56 +704,128,184,43 +712,240,228,213 +718,197,21,117 +720,222,60,20 +721,238,84,42 +722,244,123,83 +725,234,173,32 +726,241,199,28 +727,239,219,94 +729,205,143,72 +730,110,90,28 +731,129,110,22 +732,125,105,20 +733,162,140,34 +734,181,160,63 +738,214,171,132 +739,230,199,169 +740,234,192,7 +741,242,106,6 +742,243,139,23 +743,242,179,56 +744,242,201,104 +745,240,211,143 +746,246,242,210 +747,198,233,235 +754,240,180,165 +758,234,151,136 +760,244,122,143 +761,244,159,176 +762,215,211,226 +772,185,211,149 +775,198,214,228 +776,244,160,193 +778,222,159,180 +780,162,75,33 +781,180,100,17 +782,188,108,14 +783,207,124,33 +791,71,47,122 +792,94,77,158 +793,119,119,177 +794,146,159,204 +796,56,45,132 +797,72,67,150 +798,82,97,183 +799,121,141,201 +800,166,191,223 +801,117,61,47 +806,87,133,165 +807,101,160,173 +809,142,158,216 +813,127,163,201 +814,140,28,50 +815,159,28,42 +816,173,33,49 +817,195,9,28 +818,247,204,223 +819,246,223,232 +820,48,34,120 +822,226,210,189 +823,50,43,69 +824,62,79,144 +825,69,97,161 +826,93,129,184 +827,165,196,224 +828,186,214,224 +829,111,72,38 +830,122,81,38 +831,139,102,36 +832,164,122,37 +833,177,140,55 +834,199,165,79 +838,95,58,52 +839,109,69,61 +840,147,104,91 +841,171,130,120 +842,206,173,163 +844,80,71,69 +869,134,82,47 +890,37,64,39 +891,242,15,91 +892,245,44,111 +893,245,67,137 +894,246,109,174 +895,51,75,46 +898,101,57,47 +899,238,89,152 +900,200,22,39 +902,129,34,53 +904,64,100,39 +905,74,123,26 +906,81,150,8 +907,124,172,13 +909,9,117,36 +910,21,136,44 +911,49,157,63 +912,83,179,97 +913,107,191,110 +915,155,16,75 +917,180,31,110 +918,163,50,37 +919,176,49,28 +920,184,58,32 +921,208,79,39 +922,231,103,53 +924,67,84,91 +926,126,140,145 +927,163,177,177 +928,187,193,194 +930,70,81,108 +931,104,121,150 +932,141,158,184 +934,56,56,44 +935,67,71,52 +936,75,78,45 +937,75,93,40 +938,84,50,47 +939,50,38,59 +943,38,165,102 +945,239,180,153 +946,231,24,19 +947,234,13,35 +948,243,209,200 +950,235,184,171 +951,241,202,182 +954,131,203,127 +955,167,226,160 +956,245,44,139 +957,248,125,190 +958,79,187,142 +959,103,199,161 +961,233,75,135 +962,240,100,161 +963,246,185,220 +964,151,224,199 +966,152,198,154 +970,244,69,10 +972,236,146,6 +973,234,192,7 +975,141,61,40 +976,203,106,44 +977,216,130,65 +986,53,94,47 +987,79,113,61 +988,101,137,68 +989,115,153,83 +991,47,122,91 +992,94,173,136 +993,116,192,153 +995,16,108,190 +996,75,166,231 +b5200,244,244,246 +blanc,247,247,249