From 9b334ffd25e837f7d9068307ed0ddfcdaef517e7 Mon Sep 17 00:00:00 2001 From: yova Date: Sat, 11 Feb 2023 20:48:39 +0100 Subject: [PATCH] initial --- .gitignore | 15 + .idea/.gitignore | 3 + .idea/compiler.xml | 6 + .idea/deploymentTargetDropDown.xml | 17 + .idea/gradle.xml | 20 + .idea/misc.xml | 34 + app/.gitignore | 1 + app/build.gradle | 53 ++ app/proguard-rules.pro | 21 + .../and04/layout/ExampleInstrumentedTest.kt | 24 + app/src/main/AndroidManifest.xml | 61 ++ .../java/sgd/and04/layout/DistanceActivity.kt | 94 +++ .../java/sgd/and04/layout/FrameActivity.kt | 18 + .../java/sgd/and04/layout/GridActivity.kt | 29 + .../java/sgd/and04/layout/Helpers/TiltData.kt | 61 ++ .../and04/layout/Helpers/TiltDirections.kt | 11 + .../sgd/and04/layout/Helpers/ZObjectsPos.kt | 30 + .../sgd/and04/layout/ImageSwitcherActivity.kt | 67 ++ .../java/sgd/and04/layout/MainActivity.kt | 44 + .../sgd/and04/layout/MainScreenActivity.kt | 332 ++++++++ .../java/sgd/and04/layout/OpenGLActivity.kt | 14 + .../java/sgd/and04/layout/RelativeActivity.kt | 29 + .../java/sgd/and04/layout/ScrollActivity.kt | 17 + .../sgd/and04/layout/Space3D/ShaderSource.kt | 85 ++ .../and04/layout/Space3D/SpaceGLRenderer.kt | 764 ++++++++++++++++++ .../and04/layout/Space3D/SpaceGLSurface.kt | 158 ++++ .../sgd/and04/layout/Space3D/VertexSource.kt | 274 +++++++ .../sgd/and04/layout/Spiral2D/MyGLRenderer.kt | 178 ++++ .../and04/layout/Spiral2D/MyGLSurfaceView.kt | 101 +++ .../java/sgd/and04/layout/Spiral2D/Spiral.kt | 148 ++++ .../java/sgd/and04/layout/Spiral2D/Square.kt | 117 +++ .../sgd/and04/layout/Spiral2D/Triangle.kt | 168 ++++ .../java/sgd/and04/layout/TableActivity.kt | 31 + .../drawable-v24/ic_launcher_foreground.xml | 30 + app/src/main/res/drawable-xhdpi/android.png | Bin 0 -> 1866 bytes .../main/res/drawable-xhdpi/baseline_icon.png | Bin 0 -> 136407 bytes .../main/res/drawable-xhdpi/headline_icon.png | Bin 0 -> 131221 bytes .../.comments/IMG_20230113_073241.jpg.xml | 7 + .../res/drawable/.comments/flower4.jpg.xml | 7 + .../res/drawable/.comments/marble_13.jpg.xml | 7 + .../res/drawable/.comments/marble_6.jpg.xml | 48 ++ .../res/drawable/.comments/marble_8.jpg.xml | 57 ++ app/src/main/res/drawable/accelerator.png | Bin 0 -> 1576 bytes app/src/main/res/drawable/app_background.xml | 12 + app/src/main/res/drawable/blue_card.xml | 11 + app/src/main/res/drawable/curve.png | Bin 0 -> 1084 bytes app/src/main/res/drawable/flower1.JPG | Bin 0 -> 5832217 bytes app/src/main/res/drawable/flower2.JPG | Bin 0 -> 3088745 bytes app/src/main/res/drawable/flower3.JPG | Bin 0 -> 2707374 bytes app/src/main/res/drawable/flower4.jpg | Bin 0 -> 3281977 bytes app/src/main/res/drawable/green_card.xml | 11 + app/src/main/res/drawable/horseshoe.jpg | Bin 0 -> 309426 bytes .../res/drawable/ic_launcher_background.xml | 74 ++ .../res/drawable/ic_launcher_foreground.xml | 34 + .../res/drawable/if_3d_touch_2_1504646.png | Bin 0 -> 789 bytes .../if_ic_3d_rotation_48px_351995.png | Bin 0 -> 705 bytes .../drawable/if_ic_dashboard_48px_352300.png | Bin 0 -> 196 bytes .../drawable/if_ic_history_48px_352426.png | Bin 0 -> 641 bytes .../main/res/drawable/if_triangle_3325157.png | Bin 0 -> 518 bytes app/src/main/res/drawable/leftright.png | Bin 0 -> 742 bytes app/src/main/res/drawable/marble_1.png | Bin 0 -> 210977 bytes app/src/main/res/drawable/marble_10.jpg | Bin 0 -> 132954 bytes app/src/main/res/drawable/marble_11.png | Bin 0 -> 595739 bytes app/src/main/res/drawable/marble_12.jpg | Bin 0 -> 151574 bytes app/src/main/res/drawable/marble_13.jpg | Bin 0 -> 460349 bytes app/src/main/res/drawable/marble_14.jpg | Bin 0 -> 91963 bytes app/src/main/res/drawable/marble_2.png | Bin 0 -> 1171472 bytes app/src/main/res/drawable/marble_3.jpg | Bin 0 -> 28422 bytes app/src/main/res/drawable/marble_4.jpg | Bin 0 -> 158338 bytes app/src/main/res/drawable/marble_5.png | Bin 0 -> 1250626 bytes app/src/main/res/drawable/marble_6.jpg | Bin 0 -> 356756 bytes app/src/main/res/drawable/marble_7.jpg | Bin 0 -> 176155 bytes app/src/main/res/drawable/marble_8.jpg | Bin 0 -> 351942 bytes app/src/main/res/drawable/marble_9.png | Bin 0 -> 1033349 bytes app/src/main/res/drawable/nonrotate.png | Bin 0 -> 1029 bytes app/src/main/res/drawable/red_card.xml | 11 + app/src/main/res/drawable/rotate.png | Bin 0 -> 2308 bytes app/src/main/res/drawable/spiral.png | Bin 0 -> 1718 bytes app/src/main/res/drawable/stop.xml | 12 + app/src/main/res/drawable/touch.png | Bin 0 -> 3497 bytes app/src/main/res/drawable/updown.png | Bin 0 -> 767 bytes app/src/main/res/layout/activity_distance.xml | 141 ++++ app/src/main/res/layout/activity_frame.xml | 57 ++ app/src/main/res/layout/activity_grid.xml | 32 + .../res/layout/activity_image_switcher.xml | 44 + app/src/main/res/layout/activity_main.xml | 73 ++ .../main/res/layout/activity_main_screen.xml | 34 + .../res/layout/activity_open_glactivity.xml | 19 + app/src/main/res/layout/activity_relative.xml | 83 ++ app/src/main/res/layout/activity_scroll.xml | 32 + app/src/main/res/layout/activity_table.xml | 35 + .../main/res/layout/content_main_screen.xml | 14 + app/src/main/res/layout/stop.xml | 24 + app/src/main/res/menu/menu_main_screen.xml | 68 ++ .../res/mipmap-anydpi-v26/ic_launcher.xml | 5 + .../mipmap-anydpi-v26/ic_launcher_round.xml | 5 + app/src/main/res/mipmap-hdpi/ic_launcher.webp | Bin 0 -> 1404 bytes .../res/mipmap-hdpi/ic_launcher_round.webp | Bin 0 -> 2898 bytes app/src/main/res/mipmap-mdpi/ic_launcher.webp | Bin 0 -> 982 bytes .../res/mipmap-mdpi/ic_launcher_round.webp | Bin 0 -> 1772 bytes .../main/res/mipmap-xhdpi/ic_launcher.webp | Bin 0 -> 1900 bytes .../res/mipmap-xhdpi/ic_launcher_round.webp | Bin 0 -> 3918 bytes .../main/res/mipmap-xxhdpi/ic_launcher.webp | Bin 0 -> 2884 bytes .../res/mipmap-xxhdpi/ic_launcher_round.webp | Bin 0 -> 5914 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin 0 -> 3844 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.webp | Bin 0 -> 7778 bytes app/src/main/res/raw/body_fragment_shader.cpp | 19 + app/src/main/res/raw/body_vertex_shader.cpp | 21 + .../raw/lignt_point_fragment_shader_code.cpp | 5 + .../raw/lignt_point_vertex_shader_code.cpp | 7 + app/src/main/res/values-night/themes.xml | 16 + app/src/main/res/values/colors.xml | 16 + app/src/main/res/values/dimens.xml | 3 + app/src/main/res/values/strings.xml | 31 + app/src/main/res/values/themes.xml | 25 + app/src/main/res/xml/backup_rules.xml | 13 + .../main/res/xml/data_extraction_rules.xml | 19 + .../java/sgd/and04/layout/ExampleUnitTest.kt | 17 + build.gradle | 10 + gradle.properties | 24 + gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 59203 bytes gradle/wrapper/gradle-wrapper.properties | 6 + gradlew | 185 +++++ gradlew.bat | 89 ++ layouts.zip | Bin 0 -> 6874247 bytes settings.gradle | 16 + 126 files changed, 4534 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/.gitignore create mode 100644 .idea/compiler.xml create mode 100644 .idea/deploymentTargetDropDown.xml create mode 100644 .idea/gradle.xml create mode 100644 .idea/misc.xml create mode 100644 app/.gitignore create mode 100644 app/build.gradle create mode 100644 app/proguard-rules.pro create mode 100644 app/src/androidTest/java/sgd/and04/layout/ExampleInstrumentedTest.kt create mode 100644 app/src/main/AndroidManifest.xml create mode 100644 app/src/main/java/sgd/and04/layout/DistanceActivity.kt create mode 100644 app/src/main/java/sgd/and04/layout/FrameActivity.kt create mode 100644 app/src/main/java/sgd/and04/layout/GridActivity.kt create mode 100644 app/src/main/java/sgd/and04/layout/Helpers/TiltData.kt create mode 100644 app/src/main/java/sgd/and04/layout/Helpers/TiltDirections.kt create mode 100644 app/src/main/java/sgd/and04/layout/Helpers/ZObjectsPos.kt create mode 100644 app/src/main/java/sgd/and04/layout/ImageSwitcherActivity.kt create mode 100644 app/src/main/java/sgd/and04/layout/MainActivity.kt create mode 100644 app/src/main/java/sgd/and04/layout/MainScreenActivity.kt create mode 100644 app/src/main/java/sgd/and04/layout/OpenGLActivity.kt create mode 100644 app/src/main/java/sgd/and04/layout/RelativeActivity.kt create mode 100644 app/src/main/java/sgd/and04/layout/ScrollActivity.kt create mode 100644 app/src/main/java/sgd/and04/layout/Space3D/ShaderSource.kt create mode 100644 app/src/main/java/sgd/and04/layout/Space3D/SpaceGLRenderer.kt create mode 100644 app/src/main/java/sgd/and04/layout/Space3D/SpaceGLSurface.kt create mode 100644 app/src/main/java/sgd/and04/layout/Space3D/VertexSource.kt create mode 100644 app/src/main/java/sgd/and04/layout/Spiral2D/MyGLRenderer.kt create mode 100644 app/src/main/java/sgd/and04/layout/Spiral2D/MyGLSurfaceView.kt create mode 100644 app/src/main/java/sgd/and04/layout/Spiral2D/Spiral.kt create mode 100644 app/src/main/java/sgd/and04/layout/Spiral2D/Square.kt create mode 100644 app/src/main/java/sgd/and04/layout/Spiral2D/Triangle.kt create mode 100644 app/src/main/java/sgd/and04/layout/TableActivity.kt create mode 100644 app/src/main/res/drawable-v24/ic_launcher_foreground.xml create mode 100644 app/src/main/res/drawable-xhdpi/android.png create mode 100644 app/src/main/res/drawable-xhdpi/baseline_icon.png create mode 100644 app/src/main/res/drawable-xhdpi/headline_icon.png create mode 100644 app/src/main/res/drawable/.comments/IMG_20230113_073241.jpg.xml create mode 100644 app/src/main/res/drawable/.comments/flower4.jpg.xml create mode 100644 app/src/main/res/drawable/.comments/marble_13.jpg.xml create mode 100644 app/src/main/res/drawable/.comments/marble_6.jpg.xml create mode 100644 app/src/main/res/drawable/.comments/marble_8.jpg.xml create mode 100644 app/src/main/res/drawable/accelerator.png create mode 100644 app/src/main/res/drawable/app_background.xml create mode 100644 app/src/main/res/drawable/blue_card.xml create mode 100644 app/src/main/res/drawable/curve.png create mode 100644 app/src/main/res/drawable/flower1.JPG create mode 100644 app/src/main/res/drawable/flower2.JPG create mode 100644 app/src/main/res/drawable/flower3.JPG create mode 100755 app/src/main/res/drawable/flower4.jpg create mode 100644 app/src/main/res/drawable/green_card.xml create mode 100644 app/src/main/res/drawable/horseshoe.jpg create mode 100644 app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 app/src/main/res/drawable/ic_launcher_foreground.xml create mode 100644 app/src/main/res/drawable/if_3d_touch_2_1504646.png create mode 100644 app/src/main/res/drawable/if_ic_3d_rotation_48px_351995.png create mode 100644 app/src/main/res/drawable/if_ic_dashboard_48px_352300.png create mode 100644 app/src/main/res/drawable/if_ic_history_48px_352426.png create mode 100644 app/src/main/res/drawable/if_triangle_3325157.png create mode 100644 app/src/main/res/drawable/leftright.png create mode 100644 app/src/main/res/drawable/marble_1.png create mode 100644 app/src/main/res/drawable/marble_10.jpg create mode 100644 app/src/main/res/drawable/marble_11.png create mode 100644 app/src/main/res/drawable/marble_12.jpg create mode 100644 app/src/main/res/drawable/marble_13.jpg create mode 100644 app/src/main/res/drawable/marble_14.jpg create mode 100644 app/src/main/res/drawable/marble_2.png create mode 100644 app/src/main/res/drawable/marble_3.jpg create mode 100644 app/src/main/res/drawable/marble_4.jpg create mode 100644 app/src/main/res/drawable/marble_5.png create mode 100644 app/src/main/res/drawable/marble_6.jpg create mode 100644 app/src/main/res/drawable/marble_7.jpg create mode 100644 app/src/main/res/drawable/marble_8.jpg create mode 100644 app/src/main/res/drawable/marble_9.png create mode 100644 app/src/main/res/drawable/nonrotate.png create mode 100644 app/src/main/res/drawable/red_card.xml create mode 100644 app/src/main/res/drawable/rotate.png create mode 100644 app/src/main/res/drawable/spiral.png create mode 100644 app/src/main/res/drawable/stop.xml create mode 100644 app/src/main/res/drawable/touch.png create mode 100644 app/src/main/res/drawable/updown.png create mode 100644 app/src/main/res/layout/activity_distance.xml create mode 100644 app/src/main/res/layout/activity_frame.xml create mode 100644 app/src/main/res/layout/activity_grid.xml create mode 100644 app/src/main/res/layout/activity_image_switcher.xml create mode 100644 app/src/main/res/layout/activity_main.xml create mode 100644 app/src/main/res/layout/activity_main_screen.xml create mode 100644 app/src/main/res/layout/activity_open_glactivity.xml create mode 100644 app/src/main/res/layout/activity_relative.xml create mode 100644 app/src/main/res/layout/activity_scroll.xml create mode 100644 app/src/main/res/layout/activity_table.xml create mode 100644 app/src/main/res/layout/content_main_screen.xml create mode 100644 app/src/main/res/layout/stop.xml create mode 100644 app/src/main/res/menu/menu_main_screen.xml create mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher.webp create mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher_round.webp create mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher.webp create mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher_round.webp create mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher.webp create mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher.webp create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp create mode 100644 app/src/main/res/raw/body_fragment_shader.cpp create mode 100644 app/src/main/res/raw/body_vertex_shader.cpp create mode 100644 app/src/main/res/raw/lignt_point_fragment_shader_code.cpp create mode 100644 app/src/main/res/raw/lignt_point_vertex_shader_code.cpp create mode 100644 app/src/main/res/values-night/themes.xml create mode 100644 app/src/main/res/values/colors.xml create mode 100644 app/src/main/res/values/dimens.xml create mode 100644 app/src/main/res/values/strings.xml create mode 100644 app/src/main/res/values/themes.xml create mode 100644 app/src/main/res/xml/backup_rules.xml create mode 100644 app/src/main/res/xml/data_extraction_rules.xml create mode 100644 app/src/test/java/sgd/and04/layout/ExampleUnitTest.kt create mode 100644 build.gradle create mode 100644 gradle.properties create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100755 gradlew create mode 100644 gradlew.bat create mode 100644 layouts.zip create mode 100644 settings.gradle diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/.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/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..d80a3f5 --- /dev/null +++ b/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..f3bbb26 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7766bbc --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..2ad848a --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,53 @@ +plugins { + id 'com.android.application' + id 'org.jetbrains.kotlin.android' + id 'kotlin-android-extensions' +} + +android { + compileSdk 33 + + defaultConfig { + applicationId "sgd.and04.layout" + minSdk 27 + targetSdk 32 + 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 'androidx.core:core-ktx:1.7.0' + implementation 'androidx.appcompat:appcompat:1.6.0' + //noinspection GradleCompatible +// implementation 'com.android.support:appcompat-v7:28.0.0' + + + implementation 'com.google.android.material:material:1.8.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation fileTree(dir: 'libs', include: ['*.jar']) +// implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7" +// +// implementation 'com.android.support.constraint:constraint-layout:1.1.2' + implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/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/app/src/androidTest/java/sgd/and04/layout/ExampleInstrumentedTest.kt b/app/src/androidTest/java/sgd/and04/layout/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..79b009b --- /dev/null +++ b/app/src/androidTest/java/sgd/and04/layout/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package sgd.and04.layout + +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("sgd.and04.layout", appContext.packageName) + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a43a6a1 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/sgd/and04/layout/DistanceActivity.kt b/app/src/main/java/sgd/and04/layout/DistanceActivity.kt new file mode 100644 index 0000000..f451bfc --- /dev/null +++ b/app/src/main/java/sgd/and04/layout/DistanceActivity.kt @@ -0,0 +1,94 @@ +package sgd.and04.layout + +import androidx.appcompat.app.AppCompatActivity +import android.os.Build +import android.os.Bundle +import android.widget.Button +import android.widget.SeekBar +import android.widget.TextView +import androidx.annotation.RequiresApi +import pavelsobolev.kotogl.Helpers.ZObjectsPos + +// activity for setting distances of the scene's objects +class DistanceActivity : AppCompatActivity() +{ + private var sbars: Array? = null + private var txts: Array? = null + private var txtids: IntArray? = null + private val MIN_DIST = 3 + + private var i = 0 + + @RequiresApi(api = Build.VERSION_CODES.N) + override fun onCreate(savedInstanceState: Bundle?) + { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_distance) + + setArraysOfControls() + + i = 0 + while (i < 5) + { + setDataToInterface(sbars!![i], i, txts!![i]) + sbars!![i].setOnSeekBarChangeListener( + object : SeekBar.OnSeekBarChangeListener { + var pos = i + override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) + { + getDataFromInterface(sbars!![pos], pos, txts!![pos]) + } + override fun onStopTrackingTouch(seekBar: SeekBar) {} + override fun onStartTrackingTouch(seekBar: SeekBar) {} + }) + i++ + } + + (findViewById(R.id.buttonOk) as Button).setOnClickListener { view -> + setResult(AppCompatActivity.RESULT_OK) + finish() + } + + (findViewById(R.id.buttonCancel) as Button).setOnClickListener { view -> + setResult(AppCompatActivity.RESULT_CANCELED) + finish() + } + } + + private fun setArraysOfControls() + { + sbars = arrayOf( + findViewById(R.id.seekBarCentral) as SeekBar, + findViewById(R.id.seekBarLeft) as SeekBar, + findViewById(R.id.seekBarRight) as SeekBar, + findViewById(R.id.seekBarTop) as SeekBar, + findViewById(R.id.seekBarBottom) as SeekBar) + + txts = arrayOf( + findViewById(R.id.textViewCenter) as TextView, + findViewById(R.id.textViewLeft) as TextView, + findViewById(R.id.textViewRight) as TextView, + findViewById(R.id.textViewTop) as TextView, + findViewById(R.id.textViewBottom) as TextView) + + txtids = intArrayOf( + R.string.center_pos_txt, + R.string.left_pos_txt, + R.string.right_pos_txt, + R.string.top_pos_txt, + R.string.bottom_pos_txt) + } + + private fun getDataFromInterface(sb: SeekBar, i: Int, tv: TextView) + { + tv.text = String.format("%s is %d units", getString(txtids!![i]), sb.progress + MIN_DIST) + ZObjectsPos.setPosition(i, -(sb.progress + MIN_DIST)) + } + + @RequiresApi(api = Build.VERSION_CODES.N) + private fun setDataToInterface(sb: SeekBar, i: Int, tv: TextView) + { + tv.text = String.format("%s is %d units", getString(txtids!![i]), -ZObjectsPos.getPosition(i)) + sb.setProgress(-ZObjectsPos.getPosition(i) - MIN_DIST, true) + } +} diff --git a/app/src/main/java/sgd/and04/layout/FrameActivity.kt b/app/src/main/java/sgd/and04/layout/FrameActivity.kt new file mode 100644 index 0000000..e7b991f --- /dev/null +++ b/app/src/main/java/sgd/and04/layout/FrameActivity.kt @@ -0,0 +1,18 @@ +package sgd.and04.layout + +import android.content.Intent +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import android.view.View + +class FrameActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_frame) + } + + fun onLayoutClick(view: View) { + startActivity(Intent(this, MainActivity::class.java)) + } + +} \ No newline at end of file diff --git a/app/src/main/java/sgd/and04/layout/GridActivity.kt b/app/src/main/java/sgd/and04/layout/GridActivity.kt new file mode 100644 index 0000000..75de81b --- /dev/null +++ b/app/src/main/java/sgd/and04/layout/GridActivity.kt @@ -0,0 +1,29 @@ +package sgd.and04.layout + +import android.content.Intent +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import android.view.View + +class GridActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_grid) + } + + fun onButtonTableLayoutClick(view: View) { + startActivity(Intent(this, TableActivity::class.java)) + } + fun onButtonLinearLayoutClick(view: View) { + startActivity(Intent(this, MainActivity::class.java)) + } + + fun onButtonRelativeLayoutClick(view: View) { + startActivity(Intent(this, RelativeActivity::class.java)) + } + + fun onButtonFrameLayoutClick(view: View) { + startActivity(Intent(this, FrameActivity::class.java)) + } + +} \ No newline at end of file diff --git a/app/src/main/java/sgd/and04/layout/Helpers/TiltData.kt b/app/src/main/java/sgd/and04/layout/Helpers/TiltData.kt new file mode 100644 index 0000000..4253032 --- /dev/null +++ b/app/src/main/java/sgd/and04/layout/Helpers/TiltData.kt @@ -0,0 +1,61 @@ +package pavelsobolev.kotogl.Helpers + +import java.util.* + + +// the class calculates angle of tilt of a device (on the base of data from its accelerator) +object TiltData : Observable() +{ + private var xTilt : Float = 0.0f + private var yTilt : Float = 0.0f + private var tiltScale : Float = 1.5f + + init + { + setData(0.0f,0.0f) + tiltScale = 1.5f + } + + // sets new tilt data for current object + fun setData(x:Float, y:Float) + { + if (Math.abs(x)>10 || Math.abs(y)>10) return; + + xTilt = x + yTilt = y + setChanged() + notifyObservers() + } + + fun getDirection(): TiltDirections + { + return getDirection(xTilt, yTilt) + } + + fun getDirection(tiltX:Float, tiltY:Float) : TiltDirections + { + if (Math.abs(Math.abs(tiltX)-Math.abs(tiltY)) <= 3.0) + { + return TiltDirections.UNKNOWN + } + + if (Math.abs(tiltX) > Math.abs(tiltY)) + { + if (tiltX < 0) return TiltDirections.RIGHT + if (tiltX > 0) return TiltDirections.LEFT + } + else + { + if (tiltY < 0) return TiltDirections.UP + if (tiltY > 0) return TiltDirections.DOWN + } + + val threshold = 1.0f + if (tiltX > -threshold && tiltX < threshold && tiltY > -threshold && tiltY < threshold) + { + return TiltDirections.UNKNOWN + } + + return TiltDirections.UNKNOWN + } +} \ No newline at end of file diff --git a/app/src/main/java/sgd/and04/layout/Helpers/TiltDirections.kt b/app/src/main/java/sgd/and04/layout/Helpers/TiltDirections.kt new file mode 100644 index 0000000..97a8590 --- /dev/null +++ b/app/src/main/java/sgd/and04/layout/Helpers/TiltDirections.kt @@ -0,0 +1,11 @@ +package pavelsobolev.kotogl.Helpers + +/** + * enumeration describes the possible direction of tilts + * from device's accelerometer + */ +enum class TiltDirections +{ + UP, DOWN, LEFT, RIGHT, UNKNOWN + //UNKNOWN means that there is not now strong tilt to some specific direction +} diff --git a/app/src/main/java/sgd/and04/layout/Helpers/ZObjectsPos.kt b/app/src/main/java/sgd/and04/layout/Helpers/ZObjectsPos.kt new file mode 100644 index 0000000..e477e50 --- /dev/null +++ b/app/src/main/java/sgd/and04/layout/Helpers/ZObjectsPos.kt @@ -0,0 +1,30 @@ +package pavelsobolev.kotogl.Helpers + +// distances from point of view to objects of 3D scene +object ZObjectsPos +{ + /** + * 0=>central polyhedron z-position, 1=>left, 2=>right, 3=>top, 4=>bottom + */ + private var zPositions: IntArray + + init + { + zPositions = IntArray(5) + zPositions[0] = -6 + zPositions[1] = -7 + zPositions[2] = -6 + zPositions[3] = -7 + zPositions[4] = -7 + } + + fun setPosition(pos: Int, newVal: Int) + { + zPositions[pos] = newVal + } + + fun getPosition(pos: Int): Int + { + return zPositions[pos] + } +} diff --git a/app/src/main/java/sgd/and04/layout/ImageSwitcherActivity.kt b/app/src/main/java/sgd/and04/layout/ImageSwitcherActivity.kt new file mode 100644 index 0000000..66da2d4 --- /dev/null +++ b/app/src/main/java/sgd/and04/layout/ImageSwitcherActivity.kt @@ -0,0 +1,67 @@ +package sgd.and04.layout + +import android.content.Intent +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import android.view.View +import android.widget.FrameLayout +import android.widget.ImageSwitcher +import android.widget.ImageView +import android.view.animation.AnimationUtils +import android.widget.Button + +class ImageSwitcherActivity : AppCompatActivity() { + + private val flowers = intArrayOf(R.drawable.flower1, R.drawable.flower2, + R.drawable.flower4) + private var index = 0 + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_image_switcher) + // create the ImageSwitcher + val imgSwitcher = ImageSwitcher(this) + + imgSwitcher?.setFactory({ + val imgView = ImageView(applicationContext) + imgView.scaleType = ImageView.ScaleType.CENTER + imgView.setPadding(20, 20, 20, 20) + imgView.setAdjustViewBounds(true) + imgView.setMaxHeight(2400) + + imgView + }) + + val c_Layout = findViewById(R.id.scrollView) + //add ImageSwitcher in constraint layout + c_Layout?.addView(imgSwitcher) + + // set the method and pass array as a parameter + imgSwitcher?.setImageResource(flowers[index]) + + val imgIn = AnimationUtils.loadAnimation( + this, android.R.anim.slide_in_left) + imgSwitcher?.inAnimation = imgIn + + val imgOut = AnimationUtils.loadAnimation( + this, android.R.anim.slide_out_right) + imgSwitcher?.outAnimation = imgOut + + // previous button functionality + val prev = findViewById