commit b494b5f9025c59fc64823839e2f71f7ed09ac5bd Author: rhinemann Date: Sat Jun 15 19:49:28 2024 +0300 Kotlin Branch 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/TemperResult.kt b/app/TemperResult.kt new file mode 100644 index 0000000..79af4d8 --- /dev/null +++ b/app/TemperResult.kt @@ -0,0 +1,4 @@ +package com.example.courseworkkotlin + +class TemperResult { +} \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..f48309b --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,74 @@ +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.jetbrains.kotlin.android) + alias(libs.plugins.compose.compiler) +} + +android { + namespace = "com.example.courseworkkotlin" + compileSdk = 34 + + defaultConfig { + applicationId = "com.example.courseworkkotlin" + minSdk = 28 + targetSdk = 34 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + vectorDrawables { + useSupportLibrary = true + } + } + + buildTypes { + release { + isMinifyEnabled = 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" + } + buildFeatures { + compose = true + viewBinding = true + } + composeOptions { + kotlinCompilerExtensionVersion = "1.5.1" + } + packaging { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" + } + } +} + +dependencies { + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.activity.compose) + implementation(platform(libs.androidx.compose.bom)) + implementation(libs.androidx.ui) + implementation(libs.androidx.ui.graphics) + implementation(libs.androidx.ui.tooling.preview) + implementation(libs.androidx.material3) + implementation(libs.androidx.constraintlayout) + implementation(libs.androidx.appcompat) + implementation(libs.androidx.appcompatold) + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.junit) + androidTestImplementation(libs.androidx.espresso.core) + androidTestImplementation(platform(libs.androidx.compose.bom)) + androidTestImplementation(libs.androidx.ui.test.junit4) + debugImplementation(libs.androidx.ui.tooling) + debugImplementation(libs.androidx.ui.test.manifest) + implementation(libs.mpandroidchart) +} \ 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/com/example/courseworkkotlin/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/example/courseworkkotlin/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..b461b14 --- /dev/null +++ b/app/src/androidTest/java/com/example/courseworkkotlin/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.example.courseworkkotlin + +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.courseworkkotlin", 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..92e51ac --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/example/courseworkkotlin/About.kt b/app/src/main/java/com/example/courseworkkotlin/About.kt new file mode 100644 index 0000000..a0d9a9e --- /dev/null +++ b/app/src/main/java/com/example/courseworkkotlin/About.kt @@ -0,0 +1,18 @@ +package com.example.courseworkkotlin + +import android.content.Intent +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.example.courseworkkotlin.databinding.ActivityAboutBinding + +class About : AppCompatActivity() { + private lateinit var binding: ActivityAboutBinding + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = ActivityAboutBinding.inflate(layoutInflater) + setContentView(binding.root) + + binding.homeButton.setOnClickListener { startActivity(Intent(this, HomeScreen::class.java)) } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/courseworkkotlin/Calculator.kt b/app/src/main/java/com/example/courseworkkotlin/Calculator.kt new file mode 100644 index 0000000..79ac4d5 --- /dev/null +++ b/app/src/main/java/com/example/courseworkkotlin/Calculator.kt @@ -0,0 +1,282 @@ +package com.example.courseworkkotlin + +import android.content.Intent +import android.graphics.Color +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.children +import com.example.courseworkkotlin.databinding.ActivityCalculatorBinding +import java.util.Locale + +class Calculator : AppCompatActivity() { + private lateinit var binding: ActivityCalculatorBinding + private var hours = DoubleArray(22) + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = ActivityCalculatorBinding.inflate(layoutInflater) + setContentView(binding.root) + + disableGroups() + + setUpListeners() + + checkDefault() + + setTime() + } + + private fun disableGroups() { + binding.Art.children.forEach { it.isEnabled = false } + binding.IT.children.forEach { it.isEnabled = false } + binding.Tech.children.forEach { it.isEnabled = false } + + binding.Alg.children.forEach { it.isEnabled = false } + binding.Geom.children.forEach { it.isEnabled = false } + binding.Law.children.forEach { it.isEnabled = false } + binding.Econ.children.forEach { it.isEnabled = false } + } + + private fun checkDefault() { + binding.UALanSt.isChecked = true + binding.UALitSt.isChecked = true + binding.FLitSt.isChecked = true + binding.FLanSt.isChecked = true + binding.UAHistSt.isChecked = true + binding.FHistSt.isChecked = true + binding.AnFLanSt.isChecked = true + binding.MathSt.isChecked = true + binding.PhysAstrSt.isChecked = true + binding.BioEcoSt.isChecked = true + binding.ChemSt.isChecked = true + binding.GeoSt.isChecked = true + binding.PESt.isChecked = true + binding.MilitSt.isChecked = true + binding.SocEdSt.isChecked = true + } + + private fun setUpListeners() { + binding.UALan.setOnCheckedChangeListener { _, checkedId -> + when (checkedId) { + R.id.UALanSt -> hours[0] = 2.0 + R.id.UALanPro -> hours[0] = 4.0 + } + setTime() + } + + binding.UALit.setOnCheckedChangeListener { _, checkedId -> + when (checkedId) { + R.id.UALitSt -> hours[1] = 2.0 + R.id.UALitPro -> hours[1] = 4.0 + } + setTime() + } + + binding.FLit.setOnCheckedChangeListener { _, checkedId -> + when (checkedId) { + R.id.FLitSt -> hours[2] = 1.0 + R.id.FLitPro -> hours[2] = 3.0 + } + setTime() + } + + binding.FLan.setOnCheckedChangeListener { _, checkedId -> + when (checkedId) { + R.id.FLanSt -> hours[3] = 2.0 + R.id.FLanPro -> hours[3] = 5.0 + } + setTime() + } + + binding.UAHist.setOnCheckedChangeListener { _, checkedId -> + when (checkedId) { + R.id.UAHistSt -> hours[4] = 1.5 + R.id.UAHistPro -> hours[4] = 3.0 + } + setTime() + } + + binding.FHist.setOnCheckedChangeListener { _, checkedId -> + when (checkedId) { + R.id.FHistSt -> hours[5] = 1.0 + R.id.FHistPro -> hours[5] = 3.0 + } + setTime() + } + + binding.AnFLan.setOnCheckedChangeListener { _, checkedId -> + when (checkedId) { + R.id.AnFLanSt -> hours[6] = 0.0 + R.id.AnFLanPro -> hours[6] = 3.0 + } + setTime() + } + + binding.Math.setOnCheckedChangeListener { _, checkedId -> + when (checkedId) { + R.id.MathSt -> { + hours[7] = 3.0 + binding.AlgSt.isChecked = true + binding.GeomSt.isChecked = true + } + R.id.MathPro -> { + hours[7] = 0.0 + binding.AlgPro.isChecked = true + binding.GeomPro.isChecked = true + } + } + setTime() + } + + binding.Alg.setOnCheckedChangeListener { _, checkedId -> + when (checkedId) { + R.id.AlgSt -> hours[8] = 0.0 + R.id.AlgPro -> hours[8] = 6.0 + } + } + + binding.Geom.setOnCheckedChangeListener { _, checkedId -> + when (checkedId) { + R.id.GeomSt -> hours[9] = 0.0 + R.id.GeomPro -> hours[9] = 3.0 + } + } + + binding.PhysAstr.setOnCheckedChangeListener { _, checkedId -> + when (checkedId) { + R.id.PhysAstrSt -> hours[10] = 3.0 + R.id.PhysAstrPro -> hours[10] = 6.0 + } + setTime() + } + + binding.BioEco.setOnCheckedChangeListener { _, checkedId -> + when (checkedId) { + R.id.BioEcoSt -> hours[11] = 2.0 + R.id.BioEcoPro -> hours[11] = 5.0 + } + setTime() + } + + binding.Chem.setOnCheckedChangeListener { _, checkedId -> + when (checkedId) { + R.id.ChemSt -> hours[12] = 1.5 + R.id.ChemPro -> hours[12] = 4.0 + } + setTime() + } + + binding.Geo.setOnCheckedChangeListener { _, checkedId -> + when (checkedId) { + R.id.GeoSt -> hours[13] = 1.5 + R.id.GeoPro -> hours[13] = 5.0 + } + setTime() + } + + binding.PE.setOnCheckedChangeListener { _, checkedId -> + when (checkedId) { + R.id.PESt -> hours[14] = 2.0 + R.id.PEPro -> hours[14] = 6.0 + } + setTime() + } + + binding.Milit.setOnCheckedChangeListener { _, checkedId -> + when (checkedId) { + R.id.MilitSt -> hours[15] = 1.5 + R.id.MilitPro -> hours[15] = 5.0 + } + setTime() + } + + binding.SocEd.setOnCheckedChangeListener { _, checkedId -> + when (checkedId) { + R.id.SocEdSt -> { + hours[16] = 2.0 + binding.LawSt.isChecked = true + binding.EconSt.isChecked = true + } + R.id.SocEdPro -> { + hours[16] = 0.0 + binding.LawPro.isChecked = true + binding.EconPro.isChecked = true + } + } + setTime() + } + + binding.Law.setOnCheckedChangeListener { _, checkedId -> + when (checkedId) { + R.id.LawSt -> hours[17] = 0.0 + R.id.LawPro -> hours[17] = 3.0 + } + } + + binding.Econ.setOnCheckedChangeListener { _, checkedId -> + when (checkedId) { + R.id.EconSt -> hours[18] = 0.0 + R.id.EconPro -> hours[18] = 3.0 + } + } + + binding.IT.setOnCheckedChangeListener { _, checkedId -> + when (checkedId) { + R.id.ITSt -> hours[19] = 3.0 + R.id.ITPro -> hours[19] = 5.0 + else -> hours[19] = 0.0 + } + setTime() + } + + binding.Tech.setOnCheckedChangeListener { _, checkedId -> + when (checkedId) { + R.id.TechSt -> hours[20] = 3.0 + R.id.TechPro -> hours[20] = 5.0 + else -> hours[20] = 0.0 + } + setTime() + } + + binding.Art.setOnCheckedChangeListener { _, checkedId -> + when (checkedId) { + R.id.ArtSt -> hours[21] = 3.0 + R.id.ArtPro -> hours[21] = 5.0 + else -> hours[21] = 0.0 + } + setTime() + } + + binding.checkBoxIT.setOnCheckedChangeListener { _, isChecked -> + binding.IT.children.forEach { it.isEnabled = isChecked } + if (isChecked) binding.ITSt.isChecked = true + else binding.IT.clearCheck() + setTime() + } + + binding.checkBoxTech.setOnCheckedChangeListener { _, isChecked -> + binding.Tech.children.forEach { it.isEnabled = isChecked } + if (isChecked) binding.TechSt.isChecked = true + else binding.Tech.clearCheck() + setTime() + } + + binding.checkBoxArt.setOnCheckedChangeListener { _, isChecked -> + binding.Art.children.forEach { it.isEnabled = isChecked } + if (isChecked) binding.ArtSt.isChecked = true + else binding.Art.clearCheck() + setTime() + } + + binding.home.setOnClickListener { startActivity(Intent(this, HomeScreen::class.java)) } + } + + private fun setTime() { + val totalHours = hours.sum() + + if (totalHours >= 33f) binding.Hours.setTextColor(Color.RED) + else binding.Hours.setTextColor(Color.BLACK) + + binding.Hours.text = String.format(Locale("UA"), "Годин вибрано: %.1f", totalHours) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/courseworkkotlin/HomeScreen.kt b/app/src/main/java/com/example/courseworkkotlin/HomeScreen.kt new file mode 100644 index 0000000..13a1811 --- /dev/null +++ b/app/src/main/java/com/example/courseworkkotlin/HomeScreen.kt @@ -0,0 +1,20 @@ +package com.example.courseworkkotlin + +import android.content.Intent +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.example.courseworkkotlin.databinding.ActivityHomeScreenBinding + +class HomeScreen : AppCompatActivity() { + private lateinit var binding: ActivityHomeScreenBinding + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = ActivityHomeScreenBinding.inflate(layoutInflater) + setContentView(binding.root) + + binding.ButtonAbout.setOnClickListener { startActivity(Intent(this, About::class.java)) } + binding.ButtonCalculator.setOnClickListener { startActivity(Intent(this, Calculator::class.java)) } + binding.ButtonTests.setOnClickListener { startActivity(Intent(this, Tests::class.java)) } + } +} diff --git a/app/src/main/java/com/example/courseworkkotlin/Instruction.kt b/app/src/main/java/com/example/courseworkkotlin/Instruction.kt new file mode 100644 index 0000000..51e29bb --- /dev/null +++ b/app/src/main/java/com/example/courseworkkotlin/Instruction.kt @@ -0,0 +1,19 @@ +package com.example.courseworkkotlin + +import android.content.Intent +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.example.courseworkkotlin.databinding.ActivityInstructionBinding + +class Instruction : AppCompatActivity() { + private lateinit var binding: ActivityInstructionBinding + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = ActivityInstructionBinding.inflate(layoutInflater) + setContentView(binding.root) + + binding.buttonProf.setOnClickListener { startActivity(Intent(this, Profile::class.java)) } + binding.homeInst.setOnClickListener { startActivity(Intent(this, HomeScreen::class.java)) } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/courseworkkotlin/MBTI.kt b/app/src/main/java/com/example/courseworkkotlin/MBTI.kt new file mode 100644 index 0000000..e8cf357 --- /dev/null +++ b/app/src/main/java/com/example/courseworkkotlin/MBTI.kt @@ -0,0 +1,70 @@ +package com.example.courseworkkotlin + +import android.content.Intent +import android.os.Bundle +import android.util.Log +import android.widget.Button +import androidx.appcompat.app.AppCompatActivity +import com.example.courseworkkotlin.databinding.ActivityMbtiBinding + +class MBTI : AppCompatActivity() { + private lateinit var binding: ActivityMbtiBinding + + private var results = CharArray(4) + private var questionId = 0 + private lateinit var questions: Array + private lateinit var answers: Array + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = ActivityMbtiBinding.inflate(layoutInflater) + setContentView(binding.root) + + questions = resources.getStringArray(R.array.MBTI_Questions) + answers = resources.getStringArray(R.array.MBTI_Answers) + + binding.ButtonA.setOnClickListener { processQuestion(binding.ButtonA) } + binding.ButtonB.setOnClickListener { processQuestion(binding.ButtonB) } + + binding.home.setOnClickListener { startActivity(Intent(this, HomeScreen::class.java)) } + + trackQuestionNumber() + setQuestion() + } + + private fun trackQuestionNumber() { + binding.tracker.text = String.format("%s/%s", questionId + 1, questions.size) + } + + private fun setQuestion() { + binding.MBTIQuestion.text = questions[questionId] + binding.MBTIAnswer.text = answers[questionId] + } + + private fun processQuestion(buttonClicked: Button) { + when (buttonClicked) { + binding.ButtonA -> when (questionId) { + 0 -> results[0] = 'E' + 1 -> results[1] = 'S' + 2 -> results[2] = 'T' + 3 -> results[3] = 'J' + } + binding.ButtonB -> when (questionId) { + 0 -> results[0] = 'I' + 1 -> results[1] = 'N' + 2 -> results[2] = 'F' + 3 -> results[3] = 'P' + } + } + + if (questionId < questions.size - 1) { + questionId ++ + + setQuestion() + trackQuestionNumber() + } else { + val intent = Intent(this, MBTIResult::class.java).apply { putExtra("answer", results.concatToString()) } + startActivity(intent) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/courseworkkotlin/MBTIResult.kt b/app/src/main/java/com/example/courseworkkotlin/MBTIResult.kt new file mode 100644 index 0000000..47794cd --- /dev/null +++ b/app/src/main/java/com/example/courseworkkotlin/MBTIResult.kt @@ -0,0 +1,46 @@ +package com.example.courseworkkotlin + +import android.content.Intent +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.example.courseworkkotlin.databinding.ActivityMbtiResultBinding + +class MBTIResult : AppCompatActivity() { + private lateinit var binding: ActivityMbtiResultBinding + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = ActivityMbtiResultBinding.inflate(layoutInflater) + setContentView(binding.root) + + displayResult() + + binding.home.setOnClickListener { startActivity(Intent(this, HomeScreen::class.java)) } + } + + private fun displayResult() { + val answer = intent.getStringExtra("answer") + binding.Result.text = answer + + when (answer) { + "ESTJ" -> binding.Explanation.text = resources.getText(R.string.ESTJ) + "ISTJ" -> binding.Explanation.text = resources.getText(R.string.ISTJ) + "ESTP" -> binding.Explanation.text = resources.getText(R.string.ESTP) + "ISTP" -> binding.Explanation.text = resources.getText(R.string.ISTP) + "ENTJ" -> binding.Explanation.text = resources.getText(R.string.ENTJ) + "INTJ" -> binding.Explanation.text = resources.getText(R.string.INTJ) + "ENTP" -> binding.Explanation.text = resources.getText(R.string.ENTP) + "INTP" -> binding.Explanation.text = resources.getText(R.string.INTP) + "ESFJ" -> binding.Explanation.text = resources.getText(R.string.ESFJ) + "ISFJ" -> binding.Explanation.text = resources.getText(R.string.ISFJ) + "ESFP" -> binding.Explanation.text = resources.getText(R.string.ESFP) + "ISFP" -> binding.Explanation.text = resources.getText(R.string.ISFP) + "ENFJ" -> binding.Explanation.text = resources.getText(R.string.ENFJ) + "INFJ" -> binding.Explanation.text = resources.getText(R.string.INFJ) + "ENFP" -> binding.Explanation.text = resources.getText(R.string.ENFP) + "INFP" -> binding.Explanation.text = resources.getText(R.string.INFP) + else -> binding.Explanation.text = "That's not supposed to happen." + } + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/courseworkkotlin/Profile.kt b/app/src/main/java/com/example/courseworkkotlin/Profile.kt new file mode 100644 index 0000000..2def2b0 --- /dev/null +++ b/app/src/main/java/com/example/courseworkkotlin/Profile.kt @@ -0,0 +1,63 @@ +package com.example.courseworkkotlin + +import android.content.Intent +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.example.courseworkkotlin.databinding.ActivityProfileBinding + +class Profile : AppCompatActivity() { + private lateinit var binding: ActivityProfileBinding + + private var questionId = 0 + private var discipline = 0 + private var results = IntArray(17) + private lateinit var questions: Array + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = ActivityProfileBinding.inflate(layoutInflater) + setContentView(binding.root) + + questions = resources.getStringArray(R.array.Profile_Questions) + + binding.ButtonDoublePlus.setOnClickListener { processQuestion(2) } + binding.ButtonPlus.setOnClickListener { processQuestion(1) } + binding.ButtonZero.setOnClickListener { processQuestion(0) } + binding.ButtonMinus.setOnClickListener { processQuestion(-1) } + binding.ButtonDoubleMinus.setOnClickListener { processQuestion(-2) } + + binding.home.setOnClickListener { startActivity(Intent(this, HomeScreen::class.java)) } + + trackQuestionNumber() + setQuestion() + } + + private fun trackQuestionNumber() { + binding.tracker.text = String.format("%s/%s", questionId + 1, questions.size) + } + + private fun setQuestion() { + binding.ProfileQuestion.text = questions[questionId] + } + + private fun processQuestion(amount: Int) { + if (questionId < questions.size - 1) { + questionId ++ + + results[discipline] += amount + + discipline = (discipline + 1) % 17 + + if (discipline == 16) discipline = 0 + else discipline ++ + + setQuestion() + trackQuestionNumber() + } else { + val intent = Intent(this, ProfileResult::class.java).apply { putExtra("answers", results) } + Log.d("answers", results.contentToString()) + startActivity(intent) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/courseworkkotlin/ProfileResult.kt b/app/src/main/java/com/example/courseworkkotlin/ProfileResult.kt new file mode 100644 index 0000000..9c8484d --- /dev/null +++ b/app/src/main/java/com/example/courseworkkotlin/ProfileResult.kt @@ -0,0 +1,83 @@ +package com.example.courseworkkotlin + +import android.content.Intent +import android.os.Bundle +import android.graphics.Color +import androidx.appcompat.app.AppCompatActivity +import com.example.courseworkkotlin.databinding.ActivityProfileResultBinding +import com.github.mikephil.charting.components.XAxis +import com.github.mikephil.charting.data.BarData +import com.github.mikephil.charting.data.BarDataSet +import com.github.mikephil.charting.data.BarEntry +import com.github.mikephil.charting.formatter.IndexAxisValueFormatter +import com.github.mikephil.charting.utils.ColorTemplate + +class ProfileResult : AppCompatActivity() { + private lateinit var binding: ActivityProfileResultBinding + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = ActivityProfileResultBinding.inflate(layoutInflater) + setContentView(binding.root) + + displayResult() + + binding.home.setOnClickListener { startActivity(Intent(this, HomeScreen::class.java)) } + } + + private fun displayResult() { + val labels: Array = arrayOf( + "Фізика", "", + "Математика", "", + "Електро- та радіотехніка", "", + "Техніка", "", + "Хімія", "", + "Біологія", "", + "Медицина", "", + "Географія", "", + "Історія", "", + "Філологія", "", + "Мистецтво", "", + "Педагогіка", "", + "Психологія, філософія", "", + "Бізнес", "", + "Сфера обслуговувуння", "", + "Військова справа", "", + "Спорт", "" + ) + val answers = intent.getIntArrayExtra("answers") + + val barEntries: ArrayList = ArrayList() + + answers?.forEachIndexed { index, answer -> barEntries.add(BarEntry(index*2f, answer.toFloat())) } + + val barDataSet = BarDataSet(barEntries, "profileAnswers").apply { + colors = ColorTemplate.MATERIAL_COLORS.toList() + valueTextColor = Color.BLACK + setDrawValues(false) + } + + val barData = BarData(barDataSet) + + binding.Graph.xAxis.apply { + yOffset = 0f + xOffset = 0f + position = XAxis.XAxisPosition.BOTTOM + setDrawGridLines(false) + textSize = 16f + valueFormatter = IndexAxisValueFormatter(labels) + } + + binding.Graph.apply { + setFitBars(true) + setDrawBarShadow(false) + data = barData + description.isEnabled = false + legend.isEnabled = false + setVisibleXRangeMaximum(3.8f) + scaleY = 1f + axisRight.isEnabled = false + setDrawGridBackground(false) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/courseworkkotlin/Temper.kt b/app/src/main/java/com/example/courseworkkotlin/Temper.kt new file mode 100644 index 0000000..4bf0891 --- /dev/null +++ b/app/src/main/java/com/example/courseworkkotlin/Temper.kt @@ -0,0 +1,57 @@ +package com.example.courseworkkotlin + +import android.content.Intent +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.example.courseworkkotlin.databinding.ActivityTemperBinding + +class Temper : AppCompatActivity() { + private lateinit var binding: ActivityTemperBinding + + private var results = IntArray(4) + private var questionId = 0 + private lateinit var questions: Array + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = ActivityTemperBinding.inflate(layoutInflater) + setContentView(binding.root) + + questions = resources.getStringArray(R.array.Temper_Questions) + + binding.ButtonYes.setOnClickListener { processQuestion(1) } + binding.ButtonNo.setOnClickListener { processQuestion(0) } + + binding.home.setOnClickListener { startActivity(Intent(this, HomeScreen::class.java)) } + + trackQuestionNumber() + setQuestion() + } + + private fun trackQuestionNumber() { + binding.tracker.text = String.format("%s/%s", questionId + 1, questions.size) + } + + private fun setQuestion() { + binding.TemperQuestion.text = questions[questionId] + } + + private fun processQuestion(amount: Int) { + when (questionId) { + in 0..19 -> results[0] += amount + in 20..39 -> results[1] += amount + in 40..59 -> results[2] += amount + in 60..79 -> results[3] += amount + } + + if (questionId < questions.size - 1) { + questionId ++ + + setQuestion() + trackQuestionNumber() + } else { + val intent = Intent(this, TemperResult::class.java).apply { putExtra("answers", results) } + startActivity(intent) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/courseworkkotlin/TemperResult.kt b/app/src/main/java/com/example/courseworkkotlin/TemperResult.kt new file mode 100644 index 0000000..73bef3a --- /dev/null +++ b/app/src/main/java/com/example/courseworkkotlin/TemperResult.kt @@ -0,0 +1,63 @@ +package com.example.courseworkkotlin + +import android.content.Intent +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.example.courseworkkotlin.databinding.ActivityTemperResultBinding +import com.github.mikephil.charting.data.RadarData +import com.github.mikephil.charting.data.RadarDataSet +import com.github.mikephil.charting.data.RadarEntry +import com.github.mikephil.charting.formatter.IndexAxisValueFormatter + +class TemperResult : AppCompatActivity() { + private lateinit var binding: ActivityTemperResultBinding + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = ActivityTemperResultBinding.inflate(layoutInflater) + setContentView(binding.root) + + displayResult() + + binding.home.setOnClickListener { startActivity(Intent(this, HomeScreen::class.java)) } + } + + private fun displayResult() { + val labels: Array = arrayOf("Холерик", "Сангвінік", "Флегматик", "Меланхолік") + val answers = intent.getIntArrayExtra("answers") + + val radarEntries: ArrayList = ArrayList() + + answers?.forEach { + if (it < 1) radarEntries.add(RadarEntry(1f)) + else radarEntries.add(RadarEntry(it.toFloat())) + } + + val dataSet = RadarDataSet(radarEntries, "Tempers").apply { + color = R.color.colorPrimary + fillColor = R.color.colorAccent + lineWidth = 2f + setDrawFilled(true) + fillAlpha = 200 + } + + val radarData = RadarData().apply { + addDataSet(dataSet) + setDrawValues(false) + } + + binding.Graph.xAxis.apply { + xOffset = 0f + yOffset = 0f + valueFormatter = IndexAxisValueFormatter(labels) + textSize = 16f + } + + binding.Graph.apply { + data = radarData + description.isEnabled = false + legend.isEnabled = false + yAxis.isEnabled = false + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/courseworkkotlin/Tests.kt b/app/src/main/java/com/example/courseworkkotlin/Tests.kt new file mode 100644 index 0000000..fe4ad8e --- /dev/null +++ b/app/src/main/java/com/example/courseworkkotlin/Tests.kt @@ -0,0 +1,22 @@ +package com.example.courseworkkotlin + +import android.content.Intent +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.example.courseworkkotlin.databinding.ActivityTestsBinding + +class Tests : AppCompatActivity() { + private lateinit var binding: ActivityTestsBinding + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = ActivityTestsBinding.inflate(layoutInflater) + setContentView(binding.root) + + binding.buttonTemper.setOnClickListener { startActivity(Intent(this, Temper::class.java)) } + binding.buttonProfile.setOnClickListener { startActivity(Intent(this, Instruction::class.java)) } + binding.buttonMBTI.setOnClickListener { startActivity(Intent(this, MBTI::class.java)) } + + binding.home.setOnClickListener { startActivity(Intent(this, HomeScreen::class.java)) } + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/background_dark.png b/app/src/main/res/drawable/background_dark.png new file mode 100644 index 0000000..bcff2d2 Binary files /dev/null and b/app/src/main/res/drawable/background_dark.png differ diff --git a/app/src/main/res/drawable/background_light.png b/app/src/main/res/drawable/background_light.png new file mode 100644 index 0000000..ff6f34e Binary files /dev/null and b/app/src/main/res/drawable/background_light.png differ diff --git a/app/src/main/res/drawable/background_very_light.png b/app/src/main/res/drawable/background_very_light.png new file mode 100644 index 0000000..cb361b6 Binary files /dev/null and b/app/src/main/res/drawable/background_very_light.png differ diff --git a/app/src/main/res/drawable/custom_button_sqare_1.xml b/app/src/main/res/drawable/custom_button_sqare_1.xml new file mode 100644 index 0000000..5b208ae --- /dev/null +++ b/app/src/main/res/drawable/custom_button_sqare_1.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/custom_button_sqare_2.xml b/app/src/main/res/drawable/custom_button_sqare_2.xml new file mode 100644 index 0000000..94f494d --- /dev/null +++ b/app/src/main/res/drawable/custom_button_sqare_2.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/custom_button_sqare_3.xml b/app/src/main/res/drawable/custom_button_sqare_3.xml new file mode 100644 index 0000000..1dd09a9 --- /dev/null +++ b/app/src/main/res/drawable/custom_button_sqare_3.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/hexagon1.xml b/app/src/main/res/drawable/hexagon1.xml new file mode 100644 index 0000000..d65400f --- /dev/null +++ b/app/src/main/res/drawable/hexagon1.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/hexagon2.xml b/app/src/main/res/drawable/hexagon2.xml new file mode 100644 index 0000000..b57a043 --- /dev/null +++ b/app/src/main/res/drawable/hexagon2.xml @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/hexagon3.xml b/app/src/main/res/drawable/hexagon3.xml new file mode 100644 index 0000000..3fbcea3 --- /dev/null +++ b/app/src/main/res/drawable/hexagon3.xml @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/hexagon_button.xml b/app/src/main/res/drawable/hexagon_button.xml new file mode 100644 index 0000000..35d93b7 --- /dev/null +++ b/app/src/main/res/drawable/hexagon_button.xml @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/font/roboto.xml b/app/src/main/res/font/roboto.xml new file mode 100644 index 0000000..3ff48cb --- /dev/null +++ b/app/src/main/res/font/roboto.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/font/roboto_black.ttf b/app/src/main/res/font/roboto_black.ttf new file mode 100644 index 0000000..0112e7d Binary files /dev/null and b/app/src/main/res/font/roboto_black.ttf differ diff --git a/app/src/main/res/font/roboto_blackitalic.ttf b/app/src/main/res/font/roboto_blackitalic.ttf new file mode 100644 index 0000000..b2c6aca Binary files /dev/null and b/app/src/main/res/font/roboto_blackitalic.ttf differ diff --git a/app/src/main/res/font/roboto_bold.ttf b/app/src/main/res/font/roboto_bold.ttf new file mode 100644 index 0000000..43da14d Binary files /dev/null and b/app/src/main/res/font/roboto_bold.ttf differ diff --git a/app/src/main/res/font/roboto_bolditalic.ttf b/app/src/main/res/font/roboto_bolditalic.ttf new file mode 100644 index 0000000..bcfdab4 Binary files /dev/null and b/app/src/main/res/font/roboto_bolditalic.ttf differ diff --git a/app/src/main/res/font/roboto_italic.ttf b/app/src/main/res/font/roboto_italic.ttf new file mode 100644 index 0000000..1b5eaa3 Binary files /dev/null and b/app/src/main/res/font/roboto_italic.ttf differ diff --git a/app/src/main/res/font/roboto_light.ttf b/app/src/main/res/font/roboto_light.ttf new file mode 100644 index 0000000..e7307e7 Binary files /dev/null and b/app/src/main/res/font/roboto_light.ttf differ diff --git a/app/src/main/res/font/roboto_lightitalic.ttf b/app/src/main/res/font/roboto_lightitalic.ttf new file mode 100644 index 0000000..2d277af Binary files /dev/null and b/app/src/main/res/font/roboto_lightitalic.ttf differ diff --git a/app/src/main/res/font/roboto_medium.ttf b/app/src/main/res/font/roboto_medium.ttf new file mode 100644 index 0000000..ac0f908 Binary files /dev/null and b/app/src/main/res/font/roboto_medium.ttf differ diff --git a/app/src/main/res/font/roboto_mediumitalic.ttf b/app/src/main/res/font/roboto_mediumitalic.ttf new file mode 100644 index 0000000..fc36a47 Binary files /dev/null and b/app/src/main/res/font/roboto_mediumitalic.ttf differ diff --git a/app/src/main/res/font/roboto_regular.ttf b/app/src/main/res/font/roboto_regular.ttf new file mode 100644 index 0000000..ddf4bfa Binary files /dev/null and b/app/src/main/res/font/roboto_regular.ttf differ diff --git a/app/src/main/res/font/roboto_thin.ttf b/app/src/main/res/font/roboto_thin.ttf new file mode 100644 index 0000000..2e0dee6 Binary files /dev/null and b/app/src/main/res/font/roboto_thin.ttf differ diff --git a/app/src/main/res/font/roboto_thinitalic.ttf b/app/src/main/res/font/roboto_thinitalic.ttf new file mode 100644 index 0000000..084f9c0 Binary files /dev/null and b/app/src/main/res/font/roboto_thinitalic.ttf differ diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml new file mode 100644 index 0000000..9615592 --- /dev/null +++ b/app/src/main/res/layout/activity_about.xml @@ -0,0 +1,50 @@ + + + +