This commit is contained in:
Andrew 2023-02-28 20:57:21 +07:00
parent 6d3ab691fb
commit 387f10b920
82 changed files with 2916 additions and 0 deletions

1
app/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/build

70
app/build.gradle Normal file
View 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
View 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

View file

@ -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)
}
}

View 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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View 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
}
}

View file

@ -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,
)

View file

@ -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"
}
}

View 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"
}
}

View file

@ -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)
}

View file

@ -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
}

View 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"
}
}

View 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
}
}

View file

@ -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
}
}
}
}

View file

@ -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) {
}
}
}
}

View file

@ -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"
}
}

View file

@ -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
}
}

View file

@ -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"
}
}

View file

@ -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()
}
}

View file

@ -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)
}
}

View file

@ -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()
}
}
}

View file

@ -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()
}
}
}

View file

@ -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()
}
}
}

View file

@ -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()
}

View file

@ -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()
}
}
}

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 412 KiB

View 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>

View 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>

View 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>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#FFFA01</color>
</resources>

View 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>

View 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>

View 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>

View 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>

View 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)
}
}