All done
1
.gitignore
vendored
|
|
@ -1,6 +1,7 @@
|
|||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/app/signing.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
|
|
|
|||
3
.idea/.gitignore
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
1
.idea/.name
generated
Normal file
|
|
@ -0,0 +1 @@
|
|||
Poms Lab 1
|
||||
6
.idea/compiler.xml
generated
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="11" />
|
||||
</component>
|
||||
</project>
|
||||
17
.idea/deploymentTargetDropDown.xml
generated
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<targetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="QUICK_BOOT_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="VIRTUAL_DEVICE_PATH" />
|
||||
<value value="C:\Users\Admin\.android\avd\Pixel_6_API_32.avd" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</targetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2023-02-22T14:23:20.490659300Z" />
|
||||
</component>
|
||||
</project>
|
||||
19
.idea/gradle.xml
generated
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
10
.idea/misc.xml
generated
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
1
app/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
/build
|
||||
70
app/build.gradle
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'org.jetbrains.kotlin.android'
|
||||
id 'kotlin-kapt'
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'xyz.nuark.pomslab1'
|
||||
compileSdk 33
|
||||
|
||||
defaultConfig {
|
||||
applicationId "xyz.nuark.pomslab1"
|
||||
minSdk 24
|
||||
targetSdk 33
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
release {
|
||||
def props = new Properties()
|
||||
file("signing.properties").withInputStream { props.load(it) }
|
||||
|
||||
storeFile file(props.RELEASE_STORE_FILE)
|
||||
storePassword props.RELEASE_STORE_PASSWORD
|
||||
keyAlias props.RELEASE_KEY_ALIAS
|
||||
keyPassword props.RELEASE_KEY_PASSWORD
|
||||
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = '1.8'
|
||||
}
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
dataBinding true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'androidx.core:core-ktx:1.9.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||
implementation 'com.google.android.material:material:1.8.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation "androidx.activity:activity-ktx:1.6.1"
|
||||
implementation "androidx.fragment:fragment-ktx:1.5.5"
|
||||
implementation "androidx.room:room-runtime:2.5.0"
|
||||
annotationProcessor "androidx.room:room-compiler:2.5.0"
|
||||
kapt "androidx.room:room-compiler:2.5.0"
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||
}
|
||||
21
app/proguard-rules.pro
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package xyz.nuark.pomslab1
|
||||
|
||||
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("xyz.nuark.pomslab1", appContext.packageName)
|
||||
}
|
||||
}
|
||||
59
app/src/main/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<application
|
||||
android:name=".PomsApp"
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.PomsLab1"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".view.activities.GraphicsActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".view.activities.LinkerActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data android:scheme="https" />
|
||||
<data
|
||||
android:host="blog.nuark.xyz"
|
||||
android:pathPrefix="/blog" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".view.activities.ServiceCommunicatorActivity"
|
||||
android:exported="false" />
|
||||
|
||||
<service
|
||||
android:name=".services.HeavyTask"
|
||||
android:enabled="true"
|
||||
android:exported="true" />
|
||||
|
||||
<activity
|
||||
android:name=".view.activities.ResultActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".view.activities.SwitcherActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".view.activities.MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
BIN
app/src/main/ic_launcher-playstore.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
25
app/src/main/java/xyz/nuark/pomslab1/PomsApp.kt
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package xyz.nuark.pomslab1
|
||||
|
||||
import android.app.Application
|
||||
import androidx.room.Room
|
||||
import xyz.nuark.pomslab1.model.repo.AppDatabase
|
||||
|
||||
class PomsApp : Application() {
|
||||
lateinit var db: AppDatabase
|
||||
private set
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
||||
instance = this
|
||||
db = Room.databaseBuilder(
|
||||
applicationContext,
|
||||
AppDatabase::class.java, "poms-database"
|
||||
).build()
|
||||
}
|
||||
|
||||
companion object {
|
||||
lateinit var instance: PomsApp
|
||||
private set
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package xyz.nuark.pomslab1.model.data
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import java.util.*
|
||||
|
||||
@Entity(tableName = "calc_records", primaryKeys = ["date", "equation"])
|
||||
data class CalculationRecord(
|
||||
@ColumnInfo(name = "date") val date: Date,
|
||||
@ColumnInfo(name = "equation") val equation: String,
|
||||
@ColumnInfo(name = "result") val result: String,
|
||||
)
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
package xyz.nuark.pomslab1.model.data
|
||||
|
||||
import kotlin.math.sqrt
|
||||
|
||||
class QuadraticEquationModel {
|
||||
var a: Double? = null
|
||||
var b: Double? = null
|
||||
var c: Double? = null
|
||||
|
||||
val ok: Boolean get() = a != null && b != null && c != null
|
||||
|
||||
val result: Array<Double>
|
||||
get() {
|
||||
if (!ok) {
|
||||
return emptyArray()
|
||||
}
|
||||
val _a = a!!
|
||||
val _b = b!!
|
||||
val _c = c!!
|
||||
val d = _b * _b - 4 * _a * _c
|
||||
if (d < 0) {
|
||||
return emptyArray()
|
||||
}
|
||||
val x1 = (-_b + sqrt(d)) / (2 * _a)
|
||||
val x2 = (-_b - sqrt(d)) / (2 * _a)
|
||||
return arrayOf(x1, x2)
|
||||
}
|
||||
|
||||
fun setAV(v: String) {
|
||||
a = v.toDoubleOrNull()
|
||||
}
|
||||
|
||||
fun setBV(v: String) {
|
||||
b = v.toDoubleOrNull()
|
||||
}
|
||||
|
||||
fun setCV(v: String) {
|
||||
c = v.toDoubleOrNull()
|
||||
}
|
||||
|
||||
val formatMain: String
|
||||
get() = when (ok) {
|
||||
true -> "$a*x^2 + $b*x + $c"
|
||||
false -> ""
|
||||
}
|
||||
|
||||
val formatResult: String
|
||||
get() = when (result.size) {
|
||||
0 -> "x = []"
|
||||
1 -> "x = ${result[0]}"
|
||||
2 -> "x = [${result[0]}; ${result[1]}]"
|
||||
else -> ""
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
if (!ok) {
|
||||
return ""
|
||||
}
|
||||
return "$formatMain;\n$formatResult"
|
||||
}
|
||||
}
|
||||
45
app/src/main/java/xyz/nuark/pomslab1/model/data/SumModel.kt
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
package xyz.nuark.pomslab1.model.data
|
||||
|
||||
class SumModel {
|
||||
var a: Double? = null
|
||||
var b: Double? = null
|
||||
|
||||
val ok: Boolean get() = a != null && b != null
|
||||
|
||||
val result: Array<Double>
|
||||
get() {
|
||||
if (a == null || b == null) {
|
||||
return emptyArray()
|
||||
}
|
||||
val _a = a!!
|
||||
val _b = b!!
|
||||
return arrayOf(_a + _b)
|
||||
}
|
||||
|
||||
fun setAV(v: String) {
|
||||
a = v.toDoubleOrNull()
|
||||
}
|
||||
|
||||
fun setBV(v: String) {
|
||||
b = v.toDoubleOrNull()
|
||||
}
|
||||
|
||||
val formatMain: String
|
||||
get() = when (ok) {
|
||||
true -> "$a + $b"
|
||||
false -> ""
|
||||
}
|
||||
|
||||
val formatResult: String
|
||||
get() = when (result.size) {
|
||||
1 -> "${result[0]}"
|
||||
else -> ""
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
if (!ok) {
|
||||
return ""
|
||||
}
|
||||
return "$formatMain = $formatResult"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package xyz.nuark.pomslab1.model.interfaces
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.room.*
|
||||
import xyz.nuark.pomslab1.model.data.CalculationRecord
|
||||
|
||||
@Dao
|
||||
interface CalculationRecordDao {
|
||||
@Query("SELECT * FROM calc_records")
|
||||
fun getAll(): LiveData<List<CalculationRecord>>
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insertOne(record: CalculationRecord)
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insertAll(vararg records: CalculationRecord)
|
||||
|
||||
@Delete
|
||||
fun delete(user: CalculationRecord)
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package xyz.nuark.pomslab1.model.repo
|
||||
|
||||
import androidx.room.Database
|
||||
import androidx.room.RoomDatabase
|
||||
import androidx.room.TypeConverters
|
||||
import xyz.nuark.pomslab1.model.data.CalculationRecord
|
||||
import xyz.nuark.pomslab1.model.interfaces.CalculationRecordDao
|
||||
import xyz.nuark.pomslab1.utils.RoomConverters
|
||||
|
||||
@Database(entities = [CalculationRecord::class], version = 1)
|
||||
@TypeConverters(RoomConverters::class)
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
abstract fun calculationRecordDao(): CalculationRecordDao
|
||||
}
|
||||
88
app/src/main/java/xyz/nuark/pomslab1/services/HeavyTask.kt
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
package xyz.nuark.pomslab1.services
|
||||
|
||||
import android.app.Service
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Binder
|
||||
import android.os.IBinder
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import xyz.nuark.pomslab1.R
|
||||
import java.io.*
|
||||
|
||||
class HeavyTask : Service() {
|
||||
private val binder = HeavyTaskBinder()
|
||||
|
||||
private val _messengerChannel = MutableLiveData<String>()
|
||||
val messengerChannel: LiveData<String> = _messengerChannel
|
||||
|
||||
private var outputStreamWriter: OutputStreamWriter? = null
|
||||
|
||||
override fun onBind(intent: Intent): IBinder {
|
||||
return binder
|
||||
}
|
||||
|
||||
override fun onUnbind(intent: Intent?): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
fun startCalculationOfPI(steps: Int) {
|
||||
outputStreamWriter = OutputStreamWriter(applicationContext.openFileOutput(LOG_FILENAME, Context.MODE_APPEND))
|
||||
log("startCalculationOfPI: starting\n")
|
||||
Thread {
|
||||
_messengerChannel.postValue(buildString {
|
||||
append(getString(R.string.messagePICalculationStarted))
|
||||
append(steps)
|
||||
})
|
||||
var index = 0
|
||||
var pi = 0.0
|
||||
var denominator = 1
|
||||
|
||||
while (index < steps) {
|
||||
if (index % 2 == 0) {
|
||||
pi += 4.0 / denominator
|
||||
} else {
|
||||
pi -= 4.0 / denominator
|
||||
}
|
||||
|
||||
index += 1
|
||||
denominator += 2
|
||||
}
|
||||
|
||||
log("startCalculationOfPI: posting value $pi to live data channel\n")
|
||||
_messengerChannel.postValue(getString(R.string.messagePICalculationEnded).format(steps, pi))
|
||||
outputStreamWriter?.flush()
|
||||
outputStreamWriter?.close()
|
||||
}.start()
|
||||
}
|
||||
|
||||
fun getLogText(): String {
|
||||
return try {
|
||||
val inputStream: InputStream = applicationContext.openFileInput(LOG_FILENAME)
|
||||
inputStream.bufferedReader().use(BufferedReader::readText)
|
||||
} catch (e: FileNotFoundException) {
|
||||
Log.e(TAG, "getLogText: ENOENT", e)
|
||||
e.stackTraceToString()
|
||||
} catch (e: IOException) {
|
||||
Log.e(TAG, "getLogText: IOE", e)
|
||||
e.stackTraceToString()
|
||||
}.ifEmpty { getString(R.string.empty) }
|
||||
}
|
||||
|
||||
private fun log(line: String) {
|
||||
outputStreamWriter?.write(line)
|
||||
Log.i(TAG, "log: $outputStreamWriter")
|
||||
Log.i(TAG, line)
|
||||
}
|
||||
|
||||
inner class HeavyTaskBinder : Binder() {
|
||||
val service: HeavyTask get() = this@HeavyTask
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TAG = "HeavyTask"
|
||||
|
||||
const val LOG_FILENAME = "heavy_task.log"
|
||||
}
|
||||
}
|
||||
16
app/src/main/java/xyz/nuark/pomslab1/utils/RoomConverters.kt
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
package xyz.nuark.pomslab1.utils
|
||||
|
||||
import androidx.room.TypeConverter
|
||||
import java.util.*
|
||||
|
||||
class RoomConverters {
|
||||
@TypeConverter
|
||||
fun fromTimestamp(value: Long?): Date? {
|
||||
return if (value == null) null else Date(value)
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun dateToTimestamp(date: Date?): Long? {
|
||||
return date?.time
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
package xyz.nuark.pomslab1.view.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import xyz.nuark.pomslab1.databinding.ActivityGraphicsBinding
|
||||
|
||||
class GraphicsActivity : AppCompatActivity() {
|
||||
private var _binding: ActivityGraphicsBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
_binding = ActivityGraphicsBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
binding.tractor.setOnClickListener {
|
||||
binding.tractor.apply {
|
||||
clearAnimation()
|
||||
rotation = 0f
|
||||
scaleX = 1f
|
||||
scaleY = 1f
|
||||
translationX = 0f
|
||||
translationY = 0f
|
||||
alpha = 1f
|
||||
}
|
||||
}
|
||||
|
||||
binding.rotate.setOnClickListener {
|
||||
binding.tractor.animate().rotation(3600f).duration = 500
|
||||
}
|
||||
|
||||
binding.scale.setOnClickListener {
|
||||
binding.tractor.animate().scaleXBy(-4f).scaleYBy(-4f).setDuration(1000).withEndAction {
|
||||
binding.tractor.animate().scaleXBy(4f).scaleYBy(4f).duration = 1000
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
binding.translate.setOnClickListener {
|
||||
binding.tractor.animation
|
||||
binding.tractor.animate().translationXBy(-100f).setDuration(100).withEndAction {
|
||||
binding.tractor.animate().translationXBy(200f).setDuration(800).withEndAction {
|
||||
binding.tractor.animate().translationXBy(-100f).duration = 100
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
binding.alpha.setOnClickListener {
|
||||
binding.tractor.animate().alpha(0f).setDuration(100).withEndAction {
|
||||
binding.tractor.animate().alpha(1f).duration = 1000
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package xyz.nuark.pomslab1.view.activities
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.text.buildSpannedString
|
||||
import xyz.nuark.pomslab1.R
|
||||
import xyz.nuark.pomslab1.databinding.ActivityLinkerBinding
|
||||
|
||||
class LinkerActivity : AppCompatActivity() {
|
||||
private var _binding: ActivityLinkerBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
_binding = ActivityLinkerBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
binding.intentContents.text = intent.let {
|
||||
buildSpannedString {
|
||||
append(getString(R.string.youTriedToOpen))
|
||||
appendLine(it.dataString)
|
||||
}
|
||||
}
|
||||
|
||||
binding.openInBrowser.setOnClickListener {
|
||||
try {
|
||||
startActivity(Intent.createChooser(Intent(Intent.ACTION_VIEW).apply {
|
||||
data = Uri.parse(binding.linkEditor.text.toString())
|
||||
}, getString(R.string.chooseBrowserTitle)))
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
package xyz.nuark.pomslab1.view.activities
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.Menu
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.core.content.edit
|
||||
import xyz.nuark.pomslab1.R
|
||||
import xyz.nuark.pomslab1.databinding.ActivityMainBinding
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
private var _binding: ActivityMainBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
updateTheme()
|
||||
super.onCreate(savedInstanceState)
|
||||
_binding = ActivityMainBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||
return super.onCreateOptionsMenu(menu?.apply {
|
||||
addSubMenu(getString(R.string.openActionsLabel)).apply {
|
||||
add(getString(R.string.openSwitcher))?.apply {
|
||||
setOnMenuItemClickListener {
|
||||
startActivity(Intent(this@MainActivity, SwitcherActivity::class.java).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
||||
})
|
||||
true
|
||||
}
|
||||
}
|
||||
add(getString(R.string.openCalcHistory))?.apply {
|
||||
setOnMenuItemClickListener {
|
||||
startActivity(Intent(this@MainActivity, ResultActivity::class.java))
|
||||
true
|
||||
}
|
||||
}
|
||||
add(getString(R.string.openHeavyTaskConnector))?.apply {
|
||||
setOnMenuItemClickListener {
|
||||
startActivity(Intent(this@MainActivity, ServiceCommunicatorActivity::class.java))
|
||||
true
|
||||
}
|
||||
}
|
||||
add(getString(R.string.openGraphicsActivity))?.apply {
|
||||
setOnMenuItemClickListener {
|
||||
startActivity(Intent(this@MainActivity, GraphicsActivity::class.java))
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
val sp = getSharedPreferences(SPG_THEME_MODE, Context.MODE_PRIVATE)
|
||||
if (sp.getBoolean(SP_LIGHT_MODE_ENABLED, false)) {
|
||||
add(getString(R.string.switchToDarkLabel))?.apply {
|
||||
setOnMenuItemClickListener {
|
||||
sp.edit(true) {
|
||||
putBoolean(SP_LIGHT_MODE_ENABLED, false)
|
||||
}
|
||||
updateTheme()
|
||||
true
|
||||
}
|
||||
}
|
||||
} else {
|
||||
add(getString(R.string.switchToLightLabel))?.apply {
|
||||
setOnMenuItemClickListener {
|
||||
sp.edit(true) {
|
||||
putBoolean(SP_LIGHT_MODE_ENABLED, true)
|
||||
}
|
||||
updateTheme()
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun updateTheme() {
|
||||
val sp = getSharedPreferences(SPG_THEME_MODE, Context.MODE_PRIVATE)
|
||||
val lightMode = when (sp.getBoolean(SP_LIGHT_MODE_ENABLED, false)) {
|
||||
true -> AppCompatDelegate.MODE_NIGHT_NO
|
||||
false -> AppCompatDelegate.MODE_NIGHT_YES
|
||||
}
|
||||
Log.i(TAG, "updateTheme: lightMode")
|
||||
AppCompatDelegate.setDefaultNightMode(lightMode)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TAG = "MainActivity"
|
||||
|
||||
const val SPG_THEME_MODE = "SPG_THEME_MODE"
|
||||
const val SP_LIGHT_MODE_ENABLED = "SP_LIGHT_MODE_ENABLED"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package xyz.nuark.pomslab1.view.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import xyz.nuark.pomslab1.databinding.ActivityResultBinding
|
||||
import xyz.nuark.pomslab1.view.adapters.CalculationHistoryAdapter
|
||||
import xyz.nuark.pomslab1.viewmodels.ResultActivityViewModel
|
||||
|
||||
class ResultActivity : AppCompatActivity() {
|
||||
private var _binding: ActivityResultBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
private val viewModel: ResultActivityViewModel by viewModels()
|
||||
|
||||
private val adapter = CalculationHistoryAdapter()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
_binding = ActivityResultBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
viewModel.records.observe(this) {
|
||||
binding.noHistoryLabel.visibility = if (it.isEmpty()) View.VISIBLE else View.GONE
|
||||
adapter.setRecords(it)
|
||||
}
|
||||
|
||||
binding.historyList.layoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, true)
|
||||
binding.historyList.adapter = adapter
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
package xyz.nuark.pomslab1.view.activities
|
||||
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.ServiceConnection
|
||||
import android.os.Bundle
|
||||
import android.os.IBinder
|
||||
import android.util.Log
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import xyz.nuark.pomslab1.R
|
||||
import xyz.nuark.pomslab1.databinding.ActivityServiceCommunicatorBinding
|
||||
import xyz.nuark.pomslab1.services.HeavyTask
|
||||
|
||||
class ServiceCommunicatorActivity : AppCompatActivity() {
|
||||
private var _binding: ActivityServiceCommunicatorBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
private val connection = HeavyServiceConnector()
|
||||
private lateinit var heavyIntentService: Intent
|
||||
|
||||
private var subscribed = false
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
_binding = ActivityServiceCommunicatorBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
heavyIntentService = Intent(this, HeavyTask::class.java)
|
||||
|
||||
binding.serviceController.setOnClickListener {
|
||||
if (connection.bound.value == true) {
|
||||
unbindService(connection)
|
||||
connection.stopService(this)
|
||||
subscribed = false
|
||||
} else {
|
||||
binding.logHolder.text = ""
|
||||
bindService(heavyIntentService, connection, Context.BIND_AUTO_CREATE)
|
||||
}
|
||||
}
|
||||
|
||||
binding.calc.setOnClickListener {
|
||||
val stepsString = binding.stepsCount.editText?.text?.toString() ?: ""
|
||||
if (stepsString.isEmpty()) {
|
||||
return@setOnClickListener
|
||||
}
|
||||
val steps = stepsString.toIntOrNull()
|
||||
if (steps == null || steps <= 0) {
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
val binder = connection.binder
|
||||
if (connection.bound.value == true && binder != null && binder.isBinderAlive) {
|
||||
Log.i(TAG, "onCreate: service is ready for work!")
|
||||
binder.service.startCalculationOfPI(steps)
|
||||
Log.i(TAG, "onCreate: started calculation thread in service for 200 steps")
|
||||
if (!subscribed) {
|
||||
binder.service.messengerChannel.observe(this) {
|
||||
appendLogLine(it)
|
||||
}
|
||||
subscribed = true
|
||||
}
|
||||
} else {
|
||||
Log.i(TAG, "onCreate: service is not ready! (binder: $binder)")
|
||||
}
|
||||
}
|
||||
|
||||
binding.readServiceLog.setOnClickListener {
|
||||
connection.binder?.service?.let {
|
||||
binding.serviceLogHolder.text = it.getLogText()
|
||||
}
|
||||
}
|
||||
|
||||
connection.bound.observe(this) { result ->
|
||||
binding.serviceController.apply {
|
||||
setChipIconResource(if (result) R.drawable.baseline_play_arrow_24 else R.drawable.baseline_stop_24)
|
||||
setChipIconTintResource(if (result) R.color.green else R.color.red)
|
||||
text = getText(if (result) R.string.serviceStatusRunning else R.string.serviceStatusStopped)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun appendLogLine(line: String) {
|
||||
binding.logHolder.text = buildString {
|
||||
appendLine(line)
|
||||
append(binding.logHolder.text)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
if (connection.bound.value == true) {
|
||||
unbindService(connection)
|
||||
}
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
class HeavyServiceConnector : ServiceConnection {
|
||||
private var _bound = MutableLiveData<Boolean>()
|
||||
val bound: LiveData<Boolean> get() = _bound
|
||||
|
||||
var binder: HeavyTask.HeavyTaskBinder? = null
|
||||
private set
|
||||
|
||||
init {
|
||||
_bound.value = false
|
||||
}
|
||||
|
||||
override fun onServiceConnected(service: ComponentName?, binder: IBinder?) {
|
||||
Log.i(TAG, "onServiceConnected: service connected, got $service and $binder")
|
||||
if (binder == null) {
|
||||
Log.e(TAG, "onServiceConnected: binder is null!")
|
||||
return
|
||||
}
|
||||
if (binder !is HeavyTask.HeavyTaskBinder) {
|
||||
Log.e(TAG, "onServiceConnected: binder is not ours!")
|
||||
return
|
||||
}
|
||||
this.binder = binder
|
||||
_bound.value = true
|
||||
}
|
||||
|
||||
override fun onServiceDisconnected(service: ComponentName?) {
|
||||
Log.i(TAG, "onServiceDisconnected: service disconnected, got $service")
|
||||
binder = null
|
||||
_bound.value = false
|
||||
}
|
||||
|
||||
fun stopService(lifecycleOwner: LifecycleOwner) {
|
||||
binder?.service?.stopSelf()
|
||||
binder?.service?.messengerChannel?.removeObservers(lifecycleOwner)
|
||||
binder = null
|
||||
_bound.value = false
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TAG = "HeavyServiceConnector"
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TAG = "ServiceCommunicatorActivity"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
package xyz.nuark.pomslab1.view.activities
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import xyz.nuark.pomslab1.R
|
||||
import xyz.nuark.pomslab1.databinding.ActivitySwitcherBinding
|
||||
import xyz.nuark.pomslab1.view.fragments.QuadraticFragment
|
||||
import xyz.nuark.pomslab1.view.fragments.SumFragment
|
||||
|
||||
class SwitcherActivity : AppCompatActivity() {
|
||||
private var _binding: ActivitySwitcherBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
_binding = ActivitySwitcherBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
supportFragmentManager
|
||||
.beginTransaction().apply {
|
||||
add(binding.fragmentHolder.id, sumFragment)
|
||||
add(binding.fragmentHolder.id, quadraticFragment)
|
||||
}
|
||||
.commit()
|
||||
supportFragmentManager.executePendingTransactions()
|
||||
supportFragmentManager
|
||||
.beginTransaction().apply {
|
||||
detach(sumFragment)
|
||||
}
|
||||
.commit()
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||
return super.onCreateOptionsMenu(menu?.apply {
|
||||
add(getString(R.string.openMultipanel))?.apply {
|
||||
setOnMenuItemClickListener {
|
||||
startActivity(Intent(this@SwitcherActivity, MainActivity::class.java).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
||||
})
|
||||
true
|
||||
}
|
||||
}
|
||||
add(getString(R.string.switchFragment))?.apply {
|
||||
setOnMenuItemClickListener {
|
||||
this@SwitcherActivity.switchFragment()
|
||||
true
|
||||
}
|
||||
}
|
||||
add(getString(R.string.openCalcHistory))?.apply {
|
||||
setOnMenuItemClickListener {
|
||||
startActivity(Intent(this@SwitcherActivity, ResultActivity::class.java))
|
||||
true
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun switchFragment() {
|
||||
supportFragmentManager
|
||||
.beginTransaction().apply {
|
||||
if (quadraticFragment.isDetached) {
|
||||
detach(sumFragment)
|
||||
attach(quadraticFragment)
|
||||
} else if (sumFragment.isDetached) {
|
||||
attach(sumFragment)
|
||||
detach(quadraticFragment)
|
||||
}
|
||||
}
|
||||
.commit()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val quadraticFragment = QuadraticFragment()
|
||||
private val sumFragment = SumFragment()
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package xyz.nuark.pomslab1.view.adapters
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import xyz.nuark.pomslab1.databinding.CalculationHistoryItemBinding
|
||||
import xyz.nuark.pomslab1.model.data.CalculationRecord
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
class CalculationHistoryAdapter : RecyclerView.Adapter<CalculationHistoryAdapter.VH>() {
|
||||
private val records = arrayListOf<CalculationRecord>()
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH {
|
||||
val inflater = LayoutInflater.from(parent.context)
|
||||
val binding = CalculationHistoryItemBinding.inflate(
|
||||
inflater, parent,
|
||||
false
|
||||
)
|
||||
return VH(binding)
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return records.size
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: VH, position: Int) {
|
||||
holder.bind(records[position])
|
||||
}
|
||||
|
||||
fun setRecords(newRecords: List<CalculationRecord>) {
|
||||
val size = records.size
|
||||
records.clear()
|
||||
if (size > 0) {
|
||||
notifyItemRangeRemoved(0, size)
|
||||
}
|
||||
records.addAll(newRecords)
|
||||
if (records.size > 0) {
|
||||
notifyItemRangeInserted(0, records.size)
|
||||
}
|
||||
}
|
||||
|
||||
fun isEmpty(): Boolean {
|
||||
return records.isEmpty()
|
||||
}
|
||||
|
||||
class VH(private val binding: CalculationHistoryItemBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||
fun bind(record: CalculationRecord) {
|
||||
binding.dateHolder.text = formatter.format(record.date)
|
||||
binding.equHolder.text = record.equation
|
||||
binding.resultHolder.text = record.result
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val formatter = SimpleDateFormat("dd.MM.yy HH:mm:ss", Locale.CANADA)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package xyz.nuark.pomslab1.view.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import xyz.nuark.pomslab1.databinding.FragmentQuadraticBinding
|
||||
import xyz.nuark.pomslab1.viewmodels.QuadraticCalculationViewModel
|
||||
|
||||
class QuadraticFragment : Fragment() {
|
||||
private var _binding: FragmentQuadraticBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
private val calculationViewModel: QuadraticCalculationViewModel by activityViewModels()
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = FragmentQuadraticBinding.inflate(inflater)
|
||||
binding.equation = calculationViewModel.quadraticEquationModel
|
||||
binding.resultString = calculationViewModel.quadraticEquationModel.toString()
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
binding.button.setOnClickListener { v: View? ->
|
||||
binding.resultString = calculationViewModel.quadraticEquationModel.toString()
|
||||
calculationViewModel.saveQuadraticCalculation()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package xyz.nuark.pomslab1.view.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import xyz.nuark.pomslab1.databinding.FragmentSumBinding
|
||||
import xyz.nuark.pomslab1.viewmodels.SumCalculationViewModel
|
||||
|
||||
class SumFragment : Fragment() {
|
||||
private var _binding: FragmentSumBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
private val calculationViewModel: SumCalculationViewModel by activityViewModels()
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = FragmentSumBinding.inflate(inflater)
|
||||
binding.equation = calculationViewModel.sumModel
|
||||
binding.resultString = calculationViewModel.sumModel.toString()
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
binding.button.setOnClickListener { v: View? ->
|
||||
binding.resultString = calculationViewModel.sumModel.toString()
|
||||
calculationViewModel.saveSumCalculation()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package xyz.nuark.pomslab1.viewmodels
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import xyz.nuark.pomslab1.PomsApp
|
||||
import xyz.nuark.pomslab1.model.data.CalculationRecord
|
||||
import xyz.nuark.pomslab1.model.data.QuadraticEquationModel
|
||||
import java.util.*
|
||||
|
||||
class QuadraticCalculationViewModel : ViewModel() {
|
||||
val quadraticEquationModel = QuadraticEquationModel()
|
||||
|
||||
fun saveQuadraticCalculation() {
|
||||
if (quadraticEquationModel.ok) {
|
||||
Thread {
|
||||
PomsApp.instance.db.calculationRecordDao().insertOne(
|
||||
CalculationRecord(
|
||||
Date(), quadraticEquationModel.formatMain, quadraticEquationModel.formatResult
|
||||
)
|
||||
)
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package xyz.nuark.pomslab1.viewmodels
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import xyz.nuark.pomslab1.PomsApp
|
||||
import xyz.nuark.pomslab1.model.data.CalculationRecord
|
||||
|
||||
class ResultActivityViewModel : ViewModel() {
|
||||
val records: LiveData<List<CalculationRecord>> = PomsApp.instance.db.calculationRecordDao().getAll()
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package xyz.nuark.pomslab1.viewmodels
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import xyz.nuark.pomslab1.PomsApp
|
||||
import xyz.nuark.pomslab1.model.data.CalculationRecord
|
||||
import xyz.nuark.pomslab1.model.data.SumModel
|
||||
import java.util.*
|
||||
|
||||
class SumCalculationViewModel : ViewModel() {
|
||||
val sumModel = SumModel()
|
||||
|
||||
fun saveSumCalculation() {
|
||||
if (sumModel.ok) {
|
||||
Thread {
|
||||
PomsApp.instance.db.calculationRecordDao().insertOne(
|
||||
CalculationRecord(
|
||||
Date(), sumModel.formatMain, sumModel.formatResult
|
||||
)
|
||||
)
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
5
app/src/main/res/drawable/baseline_play_arrow_24.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#000000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M8,5v14l11,-7z"/>
|
||||
</vector>
|
||||
5
app/src/main/res/drawable/baseline_stop_24.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#000000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M6,6h12v12H6z"/>
|
||||
</vector>
|
||||
10
app/src/main/res/drawable/ic_launcher_background.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#FFFA01"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
</vector>
|
||||
22
app/src/main/res/drawable/ic_launcher_foreground.xml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="367"
|
||||
android:viewportHeight="210.30469">
|
||||
<group android:scaleX="0.47314286"
|
||||
android:scaleY="0.2711285"
|
||||
android:translateX="95.87438"
|
||||
android:translateY="83.09189">
|
||||
<group android:translateY="129.44531">
|
||||
<path android:pathData="M41,-33.140625L41,-58.265625Q50,-58.265625,50,-64.390625Q50,-70,43.53125,-70Q37,-70,37,-62.625L37,-0L8,-0L8,-59.671875Q8,-68.890625,9.859375,-74.78125Q11.71875,-80.6875,16.21875,-85.78125Q21.265625,-91.4375,28.84375,-94.71875Q36.4375,-98,44.515625,-98Q59.125,-98,69.0625,-88.1875Q79,-78.390625,79,-63.890625Q79,-49.8125,70.046875,-41.0625Q61.875,-33,45.375,-33L41,-33.140625Z"
|
||||
android:fillColor="#020903"/>
|
||||
<path android:pathData="M136.34375,-98Q156.76562,-98,171.375,-83.265625Q186,-68.546875,186,-48.03125Q186,-27.171875,171.28125,-12.578125Q156.5625,2,135.5,2Q114.578125,2,99.78125,-12.65625Q85,-27.3125,85,-48.03125Q85,-68.96875,99.890625,-83.484375Q114.796875,-98,136.34375,-98ZM135.5,-70Q126.578125,-70,120.28125,-63.546875Q114,-57.109375,114,-48Q114,-38.890625,120.3125,-32.4375Q126.640625,-26,135.5,-26Q144.5,-26,150.75,-32.40625Q157,-38.828125,157,-48Q157,-57.171875,150.75,-63.578125Q144.5,-70,135.5,-70Z"
|
||||
android:fillColor="#020903"/>
|
||||
<path android:pathData="M198,0L198,-69.078125Q198,-81.828125,205.75,-89.90625Q213.5,-98,225.85938,-98Q240.53125,-98,248.42188,-84.765625Q253.25,-91.890625,258.76562,-94.9375Q264.29688,-98,272.42188,-98Q285.28125,-98,292.14062,-89.90625Q299,-81.828125,299,-66.625L299,0L270,0L270,-62.34375Q270,-66.984375,269.34375,-68.484375Q268.70312,-70,266.71875,-70Q263,-70,263,-62.84375L263,0L234,0L234,-62.34375Q234,-66.90625,233.32812,-68.453125Q232.65625,-70,230.6875,-70Q227,-70,227,-62.34375L227,0L198,0Z"
|
||||
android:fillColor="#020903"/>
|
||||
<path android:pathData="M362,-96.421875L362,-68.9375Q359.0625,-70,357.46875,-70Q354.40625,-70,352.20312,-67.625Q350,-65.25,350,-61.90625Q350,-59.03125,352.39062,-54.640625L354.4375,-50.859375Q360,-40.671875,360,-31.171875Q360,-17.28125,350.01562,-7.640625Q340.04688,2,325.67188,2Q318.76562,2,312,-0.78125L312,-28.5Q316.09375,-26,319.26562,-26Q323,-26,325.5,-28.125Q328,-30.265625,328,-33.484375Q328,-35.578125,324.15625,-42.640625Q318,-53.828125,318,-65Q318,-78.5,327.57812,-88.25Q337.17188,-98,350.5,-98Q356.35938,-98,362,-96.421875Z"
|
||||
android:fillColor="#020903"/>
|
||||
</group>
|
||||
</group>
|
||||
</vector>
|
||||
49
app/src/main/res/layout-land/activity_main.xml
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
tools:context=".view.activities.MainActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="8dp"
|
||||
android:elevation="16dp"
|
||||
android:padding="8dp"
|
||||
app:contentPadding="8dp">
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/quadraticHolder"
|
||||
android:name="xyz.nuark.pomslab1.view.fragments.QuadraticFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:layout="@layout/fragment_quadratic" />
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="8dp"
|
||||
android:elevation="16dp"
|
||||
android:padding="8dp">
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/sumHolder"
|
||||
android:name="xyz.nuark.pomslab1.view.fragments.SumFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:layout="@layout/fragment_sum" />
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
</LinearLayout>
|
||||
|
||||
</HorizontalScrollView>
|
||||
112
app/src/main/res/layout-land/fragment_quadratic.xml
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="equation"
|
||||
type="xyz.nuark.pomslab1.model.data.QuadraticEquationModel" />
|
||||
|
||||
<variable
|
||||
name="resultString"
|
||||
type="String" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".view.fragments.QuadraticFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
style="@style/TextAppearance.AppCompat.Headline"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/title"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/aCoef"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/a"
|
||||
android:inputType="numberDecimal|numberSigned"
|
||||
android:onTextChanged="@{(cs, s, b, c) -> equation.setAV(cs.toString())}"
|
||||
android:text="@{``+(equation.a ?? ``)}"
|
||||
app:layout_constraintEnd_toStartOf="@+id/bCoef"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/bCoef"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/b"
|
||||
android:inputType="numberDecimal|numberSigned"
|
||||
android:onTextChanged="@{(cs, s, b, c) -> equation.setBV(cs.toString())}"
|
||||
android:text="@{``+(equation.b ?? ``)}"
|
||||
app:layout_constraintEnd_toStartOf="@+id/cCoef"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/aCoef"
|
||||
app:layout_constraintTop_toTopOf="@+id/aCoef" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/cCoef"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/c"
|
||||
android:inputType="numberDecimal|numberSigned"
|
||||
android:onTextChanged="@{(cs, s, b, c) -> equation.setCV(cs.toString())}"
|
||||
android:text="@{``+(equation.c ?? ``)}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/bCoef"
|
||||
app:layout_constraintTop_toTopOf="@+id/bCoef" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/calculate"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/cCoef" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/result"
|
||||
style="@style/TextAppearance.AppCompat.Headline"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="@{resultString}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/button"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
99
app/src/main/res/layout-land/fragment_sum.xml
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="equation"
|
||||
type="xyz.nuark.pomslab1.model.data.SumModel" />
|
||||
|
||||
<variable
|
||||
name="resultString"
|
||||
type="String" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".view.fragments.SumFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
style="@style/TextAppearance.AppCompat.Headline"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/sumTitle"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/aCoef"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/a"
|
||||
android:inputType="numberDecimal|numberSigned"
|
||||
android:onTextChanged="@{(cs, s, b, c) -> equation.setAV(cs.toString())}"
|
||||
android:text="@{``+(equation.a ?? ``)}"
|
||||
app:layout_constraintEnd_toStartOf="@+id/bCoef"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/bCoef"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/b"
|
||||
android:inputType="numberDecimal|numberSigned"
|
||||
android:onTextChanged="@{(cs, s, b, c) -> equation.setBV(cs.toString())}"
|
||||
android:text="@{``+(equation.b ?? ``)}"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/aCoef"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/aCoef"
|
||||
app:layout_constraintTop_toTopOf="@+id/aCoef" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/calculate"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/bCoef" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/result"
|
||||
style="@style/TextAppearance.AppCompat.Headline"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="@{resultString}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/button"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
60
app/src/main/res/layout-sw600dp/activity_main.xml
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".view.activities.MainActivity">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cardView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_margin="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:elevation="16dp"
|
||||
android:padding="8dp"
|
||||
app:contentPadding="8dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/cardView2"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/quadraticHolder"
|
||||
android:name="xyz.nuark.pomslab1.view.fragments.QuadraticFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:layout="@layout/fragment_quadratic" />
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cardView2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_margin="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:elevation="16dp"
|
||||
android:padding="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/cardView">
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/sumHolder"
|
||||
android:name="xyz.nuark.pomslab1.view.fragments.SumFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:layout="@layout/fragment_sum" />
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
111
app/src/main/res/layout-sw600dp/fragment_quadratic.xml
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="equation"
|
||||
type="xyz.nuark.pomslab1.model.data.QuadraticEquationModel" />
|
||||
|
||||
<variable
|
||||
name="resultString"
|
||||
type="String" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".view.fragments.QuadraticFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
style="@style/TextAppearance.AppCompat.Headline"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/title"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/aCoef"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/a"
|
||||
android:inputType="numberDecimal|numberSigned"
|
||||
android:onTextChanged="@{(cs, s, b, c) -> equation.setAV(cs.toString())}"
|
||||
android:text="@{``+(equation.a ?? ``)}"
|
||||
app:layout_constraintEnd_toStartOf="@+id/bCoef"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/bCoef"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/b"
|
||||
android:inputType="numberDecimal|numberSigned"
|
||||
android:onTextChanged="@{(cs, s, b, c) -> equation.setBV(cs.toString())}"
|
||||
android:text="@{``+(equation.b ?? ``)}"
|
||||
app:layout_constraintEnd_toStartOf="@+id/cCoef"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/aCoef"
|
||||
app:layout_constraintTop_toTopOf="@+id/aCoef" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/cCoef"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/c"
|
||||
android:inputType="numberDecimal|numberSigned"
|
||||
android:onTextChanged="@{(cs, s, b, c) -> equation.setCV(cs.toString())}"
|
||||
android:text="@{``+(equation.c ?? ``)}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/bCoef"
|
||||
app:layout_constraintTop_toTopOf="@+id/bCoef" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="@string/calculate"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@+id/cCoef"
|
||||
app:layout_constraintTop_toBottomOf="@+id/cCoef"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/result"
|
||||
style="@style/TextAppearance.AppCompat.Headline"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@{resultString}"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/button"
|
||||
app:layout_constraintEnd_toStartOf="@+id/button"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/button" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
98
app/src/main/res/layout-sw600dp/fragment_sum.xml
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="equation"
|
||||
type="xyz.nuark.pomslab1.model.data.SumModel" />
|
||||
|
||||
<variable
|
||||
name="resultString"
|
||||
type="String" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".view.fragments.SumFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
style="@style/TextAppearance.AppCompat.Headline"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/sumTitle"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/aCoef"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/a"
|
||||
android:inputType="numberDecimal|numberSigned"
|
||||
android:onTextChanged="@{(cs, s, b, c) -> equation.setAV(cs.toString())}"
|
||||
android:text="@{``+(equation.a ?? ``)}"
|
||||
app:layout_constraintEnd_toStartOf="@+id/bCoef"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/bCoef"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/b"
|
||||
android:inputType="numberDecimal|numberSigned"
|
||||
android:onTextChanged="@{(cs, s, b, c) -> equation.setBV(cs.toString())}"
|
||||
android:text="@{``+(equation.b ?? ``)}"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/aCoef"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/aCoef"
|
||||
app:layout_constraintTop_toTopOf="@+id/aCoef" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="@string/calculate"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@+id/bCoef"
|
||||
app:layout_constraintTop_toBottomOf="@+id/bCoef"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/result"
|
||||
style="@style/TextAppearance.AppCompat.Headline"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@{resultString}"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/button"
|
||||
app:layout_constraintEnd_toStartOf="@+id/button"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/button" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
79
app/src/main/res/layout/activity_graphics.xml
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".view.activities.GraphicsActivity">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/tractor"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="300dp"
|
||||
android:scaleType="centerCrop"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@raw/shining_tractor" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/rotate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/rotate"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/scale"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/scale"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/scale"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/translate"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/rotate" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/translate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/translate"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/alpha"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/scale" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/alpha"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/alpha"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/translate" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
61
app/src/main/res/layout/activity_linker.xml
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".view.activities.LinkerActivity">
|
||||
|
||||
<Button
|
||||
android:id="@+id/openInBrowser"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/openInBrowserLabel"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/linkEditor" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/intentContentsLabel"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/intentContents"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView4"
|
||||
tools:text="TextView" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/linkEditor"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:ems="10"
|
||||
android:hint="Link"
|
||||
android:inputType="textUri"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/intentContents" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
49
app/src/main/res/layout/activity_main.xml
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".view.activities.MainActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:elevation="16dp"
|
||||
android:padding="8dp"
|
||||
app:contentPadding="8dp">
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/quadraticHolder"
|
||||
android:name="xyz.nuark.pomslab1.view.fragments.QuadraticFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:layout="@layout/fragment_quadratic" />
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:elevation="16dp"
|
||||
android:padding="8dp">
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/sumHolder"
|
||||
android:name="xyz.nuark.pomslab1.view.fragments.SumFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:layout="@layout/fragment_sum" />
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
45
app/src/main/res/layout/activity_result.xml
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".view.activities.ResultActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/historyTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/calculationHistory"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/historyList"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/historyTitle" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/noHistoryLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/noHistory"
|
||||
app:layout_constraintStart_toStartOf="@+id/historyList"
|
||||
app:layout_constraintTop_toTopOf="@+id/historyList" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
164
app/src/main/res/layout/activity_service_communicator.xml
Normal file
|
|
@ -0,0 +1,164 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".view.activities.ServiceCommunicatorActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/hscTitle"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:text="@string/serviceStatusLabel"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/serviceController"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/serviceController" />
|
||||
|
||||
<com.google.android.material.chip.Chip
|
||||
android:id="@+id/serviceController"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/serviceStatusStopped"
|
||||
app:chipIcon="@drawable/baseline_stop_24"
|
||||
app:chipIconVisible="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintStart_toEndOf="@+id/textView3"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView2" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/calc"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/calculate"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/stepsCount"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/stepsCount"
|
||||
app:layout_constraintTop_toTopOf="@+id/stepsCount" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/stepsCount"
|
||||
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
app:layout_constraintEnd_toStartOf="@+id/calc"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/serviceController">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:hint="Steps"
|
||||
android:text="200" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView5"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="Log"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/stepsCount" />
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/logScroller"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="256dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView5">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/logHolder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="log" />
|
||||
</ScrollView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView6"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="Service file log contents"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/logScroller" />
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/serviceLogScroller"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="256dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView6">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/serviceLogHolder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="log" />
|
||||
</ScrollView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/readServiceLog"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="Read service log"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/serviceLogScroller" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</ScrollView>
|
||||
19
app/src/main/res/layout/activity_switcher.xml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".view.activities.SwitcherActivity">
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/fragmentHolder"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:layout="@layout/fragment_quadratic" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
80
app/src/main/res/layout/calculation_history_item.xml
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:padding="8dp"
|
||||
app:contentPadding="8dp"
|
||||
android:layout_margin="8dp"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="4dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/datePrev"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:text="@string/dateCHI"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/dateHolder" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dateHolder"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:ellipsize="marquee"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/datePrev"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="05.06.2001 16:30" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/equPrev"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/equationCHI"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/equHolder" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/equHolder"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:ellipsize="marquee"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/equPrev"
|
||||
app:layout_constraintTop_toBottomOf="@+id/dateHolder"
|
||||
tools:text="5x^2+2x-3" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/resultPrev"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/resultCHI"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/resultHolder" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/resultHolder"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:ellipsize="none"
|
||||
tools:text="x=182"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/resultPrev"
|
||||
app:layout_constraintTop_toBottomOf="@+id/equHolder" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
113
app/src/main/res/layout/fragment_quadratic.xml
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="equation"
|
||||
type="xyz.nuark.pomslab1.model.data.QuadraticEquationModel" />
|
||||
|
||||
<variable
|
||||
name="resultString"
|
||||
type="String" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".view.fragments.QuadraticFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
style="@style/TextAppearance.AppCompat.Headline"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/title"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/aCoef"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/a"
|
||||
android:inputType="numberDecimal|numberSigned"
|
||||
android:onTextChanged="@{(cs, s, b, c) -> equation.setAV(cs.toString())}"
|
||||
android:text="@{``+(equation.a ?? ``)}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/bCoef"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/b"
|
||||
android:inputType="numberDecimal|numberSigned"
|
||||
android:onTextChanged="@{(cs, s, b, c) -> equation.setBV(cs.toString())}"
|
||||
android:text="@{``+(equation.b ?? ``)}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/aCoef" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/cCoef"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/c"
|
||||
android:inputType="numberDecimal|numberSigned"
|
||||
android:onTextChanged="@{(cs, s, b, c) -> equation.setCV(cs.toString())}"
|
||||
android:text="@{``+(equation.c ?? ``)}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/bCoef" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/calculate"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/cCoef" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/result"
|
||||
style="@style/TextAppearance.AppCompat.Headline"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="@{resultString}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/button"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
97
app/src/main/res/layout/fragment_sum.xml
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="equation"
|
||||
type="xyz.nuark.pomslab1.model.data.SumModel" />
|
||||
|
||||
<variable
|
||||
name="resultString"
|
||||
type="String" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".view.fragments.SumFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
style="@style/TextAppearance.AppCompat.Headline"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/sumTitle"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/aCoef"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/a"
|
||||
android:inputType="numberDecimal|numberSigned"
|
||||
android:onTextChanged="@{(cs, s, b, c) -> equation.setAV(cs.toString())}"
|
||||
android:text="@{``+(equation.a ?? ``)}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/bCoef"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/b"
|
||||
android:inputType="numberDecimal|numberSigned"
|
||||
android:onTextChanged="@{(cs, s, b, c) -> equation.setBV(cs.toString())}"
|
||||
android:text="@{``+(equation.b ?? ``)}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/aCoef" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/calculate"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/bCoef" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/result"
|
||||
style="@style/TextAppearance.AppCompat.Headline"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="@{resultString}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/button"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
5
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
||||
5
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
||||
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
app/src/main/res/raw/shining_tractor.png
Normal file
|
After Width: | Height: | Size: 412 KiB |
16
app/src/main/res/values-night/themes.xml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.PomsLab1" parent="Theme.Material3.DayNight">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/purple_200</item>
|
||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||
<item name="colorOnPrimary">@color/black</item>
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="colorSecondary">@color/teal_200</item>
|
||||
<item name="colorSecondaryVariant">@color/teal_200</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
</resources>
|
||||
37
app/src/main/res/values-ru/strings.xml
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">ПОМС Лаба</string>
|
||||
<string name="title">Рассчёт корней квадратного уравнения</string>
|
||||
<string name="a">Коэф. A</string>
|
||||
<string name="b">Коэф. B</string>
|
||||
<string name="c">Коэф. C</string>
|
||||
<string name="calculate">Рассчитать</string>
|
||||
<string name="errorInput">Проверьте вводимые данные!</string>
|
||||
<string name="noRoots">Нет корней</string>
|
||||
<string name="openSwitcher">Открыть свитчер</string>
|
||||
<string name="openMultipanel">Открыть мультипанель</string>
|
||||
<string name="switchFragment">Поменять фрагмент</string>
|
||||
<string name="sumTitle">Сумма А и Б</string>
|
||||
<string name="calculationHistory">История вычислений</string>
|
||||
<string name="dateCHI">Дата:</string>
|
||||
<string name="equationCHI">Уравнение:</string>
|
||||
<string name="resultCHI">Результат:</string>
|
||||
<string name="openCalcHistory">Открыть историю вычислений</string>
|
||||
<string name="noHistory">Нет истории</string>
|
||||
<string name="hscTitle">HeavyService коммуникатор</string>
|
||||
<string name="serviceStatusLabel">Статус сервиса</string>
|
||||
<string name="serviceStatusStopped">Остановлен</string>
|
||||
<string name="serviceStatusRunning">Запущен</string>
|
||||
<string name="openHeavyTaskConnector">Открыть HeavyTask коммуникатор</string>
|
||||
<string name="chooseBrowserTitle">Выберите браузер для открытия</string>
|
||||
<string name="switchToDarkLabel">Включить тёмный режим</string>
|
||||
<string name="switchToLightLabel">Включить светлый режим</string>
|
||||
<string name="openActionsLabel">Переходы</string>
|
||||
<string name="openInBrowserLabel">Открыть в браузере</string>
|
||||
<string name="intentContentsLabel">Содержимое Intent</string>
|
||||
<string name="messagePICalculationStarted">"Вычисляем число Пи за "</string>
|
||||
<string name="messagePICalculationEnded">Результат вычисления числа Пи за %d шагов - %f</string>
|
||||
<string name="empty">Пусто</string>
|
||||
<string name="youTriedToOpen">Вы попробовали открыть</string>
|
||||
<string name="openGraphicsActivity">Открыть активити с графикой</string>
|
||||
</resources>
|
||||
12
app/src/main/res/values/colors.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="purple_200">#FFBB86FC</color>
|
||||
<color name="purple_500">#FF6200EE</color>
|
||||
<color name="purple_700">#FF3700B3</color>
|
||||
<color name="teal_200">#FF03DAC5</color>
|
||||
<color name="teal_700">#FF018786</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
<color name="red">#EF5350</color>
|
||||
<color name="green">#9CCC65</color>
|
||||
</resources>
|
||||
4
app/src/main/res/values/ic_launcher_background.xml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#FFFA01</color>
|
||||
</resources>
|
||||
40
app/src/main/res/values/strings.xml
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<resources>
|
||||
<string name="app_name">POMS Lab</string>
|
||||
<string name="title">Quadratic equation calculator</string>
|
||||
<string name="a">Coef. A</string>
|
||||
<string name="b">Coef. B</string>
|
||||
<string name="c">Coef. C</string>
|
||||
<string name="calculate">Calculate</string>
|
||||
<string name="errorInput">Check your input!</string>
|
||||
<string name="noRoots">No roots</string>
|
||||
<string name="openSwitcher">Open switcher</string>
|
||||
<string name="openMultipanel">Open multipanel</string>
|
||||
<string name="switchFragment">Switch fragment</string>
|
||||
<string name="sumTitle">Sum of A and B</string>
|
||||
<string name="calculationHistory">Calculation history</string>
|
||||
<string name="dateCHI">Date:</string>
|
||||
<string name="equationCHI">Equation:</string>
|
||||
<string name="resultCHI">Result:</string>
|
||||
<string name="openCalcHistory">Open calc history</string>
|
||||
<string name="noHistory">No history</string>
|
||||
<string name="hscTitle">HeavyService Communicator</string>
|
||||
<string name="serviceStatusLabel">Service status:</string>
|
||||
<string name="serviceStatusStopped">Stopped</string>
|
||||
<string name="serviceStatusRunning">Running</string>
|
||||
<string name="openHeavyTaskConnector">Open HeavyTask connector</string>
|
||||
<string name="chooseBrowserTitle">Chooser your browser</string>
|
||||
<string name="switchToDarkLabel">Switch to dark</string>
|
||||
<string name="switchToLightLabel">Switch to light</string>
|
||||
<string name="openActionsLabel">Open actions</string>
|
||||
<string name="openInBrowserLabel">Open in browser</string>
|
||||
<string name="intentContentsLabel">Intent contents</string>
|
||||
<string name="messagePICalculationStarted">"Started calculating PI for "</string>
|
||||
<string name="messagePICalculationEnded">Result of calculating PI for %d step is %f</string>
|
||||
<string name="empty">Empty</string>
|
||||
<string name="youTriedToOpen">"You tried to open "</string>
|
||||
<string name="openGraphicsActivity">Open Graphics activity</string>
|
||||
<string name="rotate" translatable="false">Rotate</string>
|
||||
<string name="scale" translatable="false">Scale</string>
|
||||
<string name="translate" translatable="false">Translate</string>
|
||||
<string name="alpha" translatable="false">Alpha</string>
|
||||
</resources>
|
||||
16
app/src/main/res/values/themes.xml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.PomsLab1" parent="Theme.Material3.DayNight">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/purple_500</item>
|
||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||
<item name="colorOnPrimary">@color/white</item>
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="colorSecondary">@color/teal_200</item>
|
||||
<item name="colorSecondaryVariant">@color/teal_700</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
</resources>
|
||||
13
app/src/main/res/xml/backup_rules.xml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample backup rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/guide/topics/data/autobackup
|
||||
for details.
|
||||
Note: This file is ignored for devices older that API 31
|
||||
See https://developer.android.com/about/versions/12/backup-restore
|
||||
-->
|
||||
<full-backup-content>
|
||||
<!--
|
||||
<include domain="sharedpref" path="."/>
|
||||
<exclude domain="sharedpref" path="device.xml"/>
|
||||
-->
|
||||
</full-backup-content>
|
||||
19
app/src/main/res/xml/data_extraction_rules.xml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample data extraction rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
||||
for details.
|
||||
-->
|
||||
<data-extraction-rules>
|
||||
<cloud-backup>
|
||||
<!-- TODO: Use <include> and <exclude> to control what is backed up.
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
-->
|
||||
</cloud-backup>
|
||||
<!--
|
||||
<device-transfer>
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
</device-transfer>
|
||||
-->
|
||||
</data-extraction-rules>
|
||||
17
app/src/test/java/xyz/nuark/pomslab1/ExampleUnitTest.kt
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
package xyz.nuark.pomslab1
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
6
build.gradle
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
plugins {
|
||||
id 'com.android.application' version '7.4.1' apply false
|
||||
id 'com.android.library' version '7.4.1' apply false
|
||||
id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
|
||||
}
|
||||
4
gradle.properties
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||
android.useAndroidX=true
|
||||
kotlin.code.style=official
|
||||
android.nonTransitiveRClass=true
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#Fri Feb 10 15:08:34 KRAT 2023
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
185
gradlew
vendored
Normal file
|
|
@ -0,0 +1,185 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# 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='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# 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 or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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"
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
89
gradlew.bat
vendored
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@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 Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
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 execute
|
||||
|
||||
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
|
||||
|
||||
: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 %*
|
||||
|
||||
: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
|
||||
16
settings.gradle
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
pluginManagement {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
rootProject.name = "Poms Lab 1"
|
||||
include ':app'
|
||||