add base app
|
|
@ -0,0 +1,14 @@
|
|||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<JetCodeStyleSettings>
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</JetCodeStyleSettings>
|
||||
<codeStyleSettings language="XML">
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
</indentOptions>
|
||||
<arrangement>
|
||||
<rules>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:android</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:id</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>style</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>ANDROID_ATTRIBUTE_ORDER</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
</rules>
|
||||
</arrangement>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="kotlin">
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<?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="PLATFORM" />
|
||||
<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>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1 @@
|
|||
/build
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
apply plugin: 'androidx.navigation.safeargs'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.3"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.taymath.tutortoolkit"
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
// Enables data binding.
|
||||
dataBinding {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$version_kotlin"
|
||||
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'androidx.core:core-ktx:1.2.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
|
||||
// Support libraries
|
||||
implementation "androidx.appcompat:appcompat:$version_appcompat"
|
||||
implementation "androidx.fragment:fragment:$version_fragment"
|
||||
implementation "androidx.constraintlayout:constraintlayout:$version_constraint_layout"
|
||||
|
||||
// Room and Lifecycle dependencies
|
||||
implementation "androidx.room:room-runtime:$version_room"
|
||||
kapt "androidx.room:room-compiler:$version_room"
|
||||
implementation "androidx.lifecycle:lifecycle-extensions:$version_lifecycle_extensions"
|
||||
|
||||
// Navigation
|
||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.2.1'
|
||||
implementation 'androidx.navigation:navigation-ui-ktx:2.2.1'
|
||||
|
||||
// Coroutines
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version_coroutine"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$version_coroutine"
|
||||
|
||||
// Testing
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
|
||||
}
|
||||
|
|
@ -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 com.taymath.tutortoolkit
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.taymath.tutortoolkit", appContext.packageName)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.taymath.tutortoolkit">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
After Width: | Height: | Size: 28 KiB |
|
|
@ -0,0 +1,17 @@
|
|||
package com.taymath.tutortoolkit
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
|
||||
/**
|
||||
* This main activity is just a container for our fragments,
|
||||
* where the real action is.
|
||||
*/
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
setContentView(R.layout.activity_main)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
package com.taymath.tutortoolkit.addgrade
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.EditText
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.ViewModelProviders
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.taymath.tutortoolkit.R
|
||||
import com.taymath.tutortoolkit.addstudent.AddStudentFragmentDirections
|
||||
import com.taymath.tutortoolkit.databinding.FragmentAddGradeBindingImpl
|
||||
import com.taymath.tutortoolkit.databinding.FragmentAddStudentBindingImpl
|
||||
import com.taymath.tutortoolkit.studentdatabase.StudentDatabase
|
||||
import kotlinx.android.synthetic.main.fragment_add_grade.*
|
||||
|
||||
class AddGradeFragment : Fragment() {
|
||||
|
||||
/**
|
||||
* Called when the Fragment is ready to display content to the screen.
|
||||
*
|
||||
* This function uses DataBindingUtil to inflate R.layout.fragment_add_grade.
|
||||
*/
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
|
||||
// Get a reference to the binding object and inflate the fragment views.
|
||||
val binding: FragmentAddGradeBindingImpl = DataBindingUtil.inflate(
|
||||
inflater, R.layout.fragment_add_grade, container, false)
|
||||
|
||||
// Get reference to application
|
||||
val application = requireNotNull(this.activity).application
|
||||
|
||||
// Get a reference to the DAO
|
||||
val dataSource = StudentDatabase.getInstance(application).studentDatabaseDao
|
||||
|
||||
// Grab our arguments from previous fragment
|
||||
val arguments = AddGradeFragmentArgs.fromBundle(arguments!!)
|
||||
|
||||
// Create instance of viewModelFactory using DAO and application
|
||||
val viewModelFactory = AddGradeViewModelFactory(arguments.studentId, dataSource)
|
||||
|
||||
// Get reference to viewModel
|
||||
val addGradeViewModel =
|
||||
ViewModelProviders.of(
|
||||
this, viewModelFactory).get(AddGradeViewModel::class.java)
|
||||
|
||||
// Add view model to our binding
|
||||
binding.addGradeViewModel = addGradeViewModel
|
||||
|
||||
binding.setLifecycleOwner(this)
|
||||
|
||||
// Listen for when we navigate to student list
|
||||
addGradeViewModel.navigateToStudentList.observe(viewLifecycleOwner, Observer {
|
||||
if (it == true) { // Observed state is true.
|
||||
this.findNavController().navigate(
|
||||
AddGradeFragmentDirections.actionAddGradeFragmentToStudentListFragment())
|
||||
addGradeViewModel.doneNavigating()
|
||||
}
|
||||
})
|
||||
return binding.root
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
package com.taymath.tutortoolkit.addgrade
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MediatorLiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.taymath.tutortoolkit.studentdatabase.Grade
|
||||
import com.taymath.tutortoolkit.studentdatabase.Student
|
||||
import com.taymath.tutortoolkit.studentdatabase.StudentDatabaseDao
|
||||
import kotlinx.coroutines.*
|
||||
|
||||
class AddGradeViewModel(
|
||||
var student_id: Long,
|
||||
val database: StudentDatabaseDao
|
||||
) : ViewModel() {
|
||||
|
||||
// Initialize viewModelJob
|
||||
private val viewModelJob = Job()
|
||||
|
||||
// Initialize uiScope
|
||||
private val uiScope = CoroutineScope(Dispatchers.Main + viewModelJob)
|
||||
|
||||
// Setup Livdata to signal when to navigate to studentList
|
||||
private val _navigateToStudentList = MutableLiveData<Boolean?>()
|
||||
val navigateToStudentList: LiveData<Boolean?>
|
||||
get() = _navigateToStudentList
|
||||
|
||||
val gradeFloatText = MutableLiveData<String>()
|
||||
|
||||
// Initialize mediatorLiveData containing Student Class
|
||||
private val student = MediatorLiveData<Student>()
|
||||
|
||||
fun getStudent() = student
|
||||
|
||||
// Add Student from database to our mediatorLiveData
|
||||
init {
|
||||
student.addSource(database.getStudentWithId(student_id), student::setValue)
|
||||
}
|
||||
|
||||
// fun validateForm(): Boolean {
|
||||
// return gradeFloatText.value!!.isNotEmpty()
|
||||
// }
|
||||
|
||||
|
||||
// Initialize Grade and add to grade_table
|
||||
fun onAddGrade(
|
||||
gradeString: String,
|
||||
gradeFloat: Float,
|
||||
noteString: String,
|
||||
studentNameString: String
|
||||
) {
|
||||
uiScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
val newGrade = Grade()
|
||||
newGrade.studentNameString = studentNameString
|
||||
newGrade.gradeString = gradeString
|
||||
newGrade.gradeFloat = gradeFloat
|
||||
newGrade.noteString = noteString
|
||||
newGrade.studentIdLong = student_id
|
||||
insert(newGrade)
|
||||
}
|
||||
}
|
||||
_navigateToStudentList.value = true
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
viewModelJob.cancel()
|
||||
}
|
||||
|
||||
fun doneNavigating() {
|
||||
_navigateToStudentList.value = false
|
||||
}
|
||||
|
||||
private fun insert(grade: Grade) {
|
||||
database.insertGrade(grade)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.taymath.tutortoolkit.addgrade
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.taymath.tutortoolkit.studentdatabase.Student
|
||||
import com.taymath.tutortoolkit.studentdatabase.StudentDatabaseDao
|
||||
|
||||
class AddGradeViewModelFactory(
|
||||
private val student_id: Long,
|
||||
private val dataSource: StudentDatabaseDao
|
||||
) : ViewModelProvider.Factory {
|
||||
|
||||
@Suppress("unchecked_cast")
|
||||
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
|
||||
if (modelClass.isAssignableFrom(AddGradeViewModel::class.java)) {
|
||||
return AddGradeViewModel(student_id, dataSource) as T
|
||||
}
|
||||
throw IllegalArgumentException("Unknown ViewModel class")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package com.taymath.tutortoolkit.addstudent
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.ViewModelProviders
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.taymath.tutortoolkit.R
|
||||
import com.taymath.tutortoolkit.databinding.FragmentAddStudentBindingImpl
|
||||
import com.taymath.tutortoolkit.studentdatabase.StudentDatabase
|
||||
|
||||
class AddStudentFragment : Fragment() {
|
||||
|
||||
/**
|
||||
* Called when the Fragment is ready to display content to the screen.
|
||||
*
|
||||
* This function uses DataBindingUtil to inflate R.layout.fragment_add_student.
|
||||
*/
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
|
||||
// Get a reference to the binding object and inflate the fragment views.
|
||||
val binding: FragmentAddStudentBindingImpl = DataBindingUtil.inflate(
|
||||
inflater, R.layout.fragment_add_student, container, false)
|
||||
|
||||
// Get reference to application
|
||||
val application = requireNotNull(this.activity).application
|
||||
|
||||
// Get a reference to the DAO
|
||||
val dataSource = StudentDatabase.getInstance(application).studentDatabaseDao
|
||||
|
||||
// Create instance of viewModelFactory using DAO and application
|
||||
val viewModelFactory = AddStudentViewModelFactory(dataSource)
|
||||
|
||||
// Get reference to viewModel
|
||||
val addStudentViewModel =
|
||||
ViewModelProviders.of(
|
||||
this, viewModelFactory).get(AddStudentViewModel::class.java)
|
||||
|
||||
// Add our viewModel to binding
|
||||
binding.addStudentViewModel = addStudentViewModel
|
||||
|
||||
binding.setLifecycleOwner(this)
|
||||
|
||||
// Listen for when we navigate to student list
|
||||
addStudentViewModel.navigateToStudentList.observe(viewLifecycleOwner, Observer {
|
||||
if (it == true) { // Observed state is true.
|
||||
this.findNavController().navigate(
|
||||
AddStudentFragmentDirections.actionAddStudentFragmentToStudentListFragment())
|
||||
addStudentViewModel.doneNavigating()
|
||||
}
|
||||
})
|
||||
return binding.root
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
package com.taymath.tutortoolkit.addstudent
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.taymath.tutortoolkit.studentdatabase.Student
|
||||
import com.taymath.tutortoolkit.studentdatabase.StudentDatabaseDao
|
||||
import kotlinx.coroutines.*
|
||||
|
||||
class AddStudentViewModel(
|
||||
val database: StudentDatabaseDao
|
||||
) : ViewModel() {
|
||||
|
||||
// Initialize viewModelJob
|
||||
private val viewModelJob = Job()
|
||||
|
||||
// Initialize uiScope
|
||||
private val uiScope = CoroutineScope(Dispatchers.Main + viewModelJob)
|
||||
|
||||
// Setup Livdata to signal when to navigate to studentList
|
||||
private val _navigateToStudentList = MutableLiveData<Boolean?>()
|
||||
val navigateToStudentList: LiveData<Boolean?>
|
||||
get() = _navigateToStudentList
|
||||
|
||||
// Initialize Student and add to student_table
|
||||
fun onAddStudent(studentNameString : String, subjectString: String,
|
||||
gradeLevelString: String, addressString: String, emailString: String) {
|
||||
uiScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
val newStudent = Student()
|
||||
newStudent.studentNameString = studentNameString
|
||||
newStudent.subjectString = subjectString
|
||||
newStudent.emailString = emailString
|
||||
newStudent.gradeLevelString = gradeLevelString
|
||||
newStudent.addressString = addressString
|
||||
insert(newStudent)
|
||||
}
|
||||
}
|
||||
_navigateToStudentList.value = true
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
viewModelJob.cancel()
|
||||
}
|
||||
|
||||
fun doneNavigating() {
|
||||
_navigateToStudentList.value = null
|
||||
}
|
||||
|
||||
private suspend fun insert(student: Student) {
|
||||
withContext(Dispatchers.IO) {
|
||||
database.insertStudent(student)
|
||||
}
|
||||
}
|
||||
|
||||
// fun onSetSleepQuality(quality: Int) {
|
||||
// uiScope.launch {
|
||||
// withContext(Dispatchers.IO) {
|
||||
// val tonight = database.get(sleepNightKey) ?: return@withContext
|
||||
// tonight.sleepQuality = quality
|
||||
// database.update(tonight)
|
||||
// }
|
||||
// _navigateToSleepTracker.value = true
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.taymath.tutortoolkit.addstudent
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.taymath.tutortoolkit.studentdatabase.StudentDatabaseDao
|
||||
|
||||
class AddStudentViewModelFactory(
|
||||
private val dataSource: StudentDatabaseDao
|
||||
) : ViewModelProvider.Factory {
|
||||
|
||||
@Suppress("unchecked_cast")
|
||||
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
|
||||
if (modelClass.isAssignableFrom(AddStudentViewModel::class.java)) {
|
||||
return AddStudentViewModel(dataSource) as T
|
||||
}
|
||||
throw IllegalArgumentException("Unknown ViewModel class")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package com.taymath.tutortoolkit.chooseicon
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProviders
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.taymath.tutortoolkit.R
|
||||
import com.taymath.tutortoolkit.databinding.FragmentChooseIconBinding
|
||||
import com.taymath.tutortoolkit.studentdatabase.StudentDatabase
|
||||
|
||||
class ChooseIconFragment : Fragment() {
|
||||
|
||||
/**
|
||||
* Called when the Fragment is ready to display content to the screen.
|
||||
*
|
||||
* This function uses DataBindingUtil to inflate R.layout.fragment_sleep_quality.
|
||||
*/
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
|
||||
// Get a reference to the binding object and inflate the fragment views.
|
||||
val binding: FragmentChooseIconBinding = DataBindingUtil.inflate(
|
||||
inflater, R.layout.fragment_choose_icon, container, false)
|
||||
|
||||
val application = requireNotNull(this.activity).application
|
||||
|
||||
// val arguments = SleepQualityFragmentArgs.fromBundle(arguments!!)
|
||||
|
||||
// Create an instance of the ViewModel Factory.
|
||||
val dataSource = StudentDatabase.getInstance(application).studentDatabaseDao
|
||||
val viewModelFactory = ChooseIconViewModelFactory(dataSource)
|
||||
|
||||
// Get a reference to the ViewModel associated with this fragment.
|
||||
val chooseIconViewModel =
|
||||
ViewModelProviders.of(
|
||||
this, viewModelFactory).get(ChooseIconViewModel::class.java)
|
||||
|
||||
// To use the View Model with data binding, you have to explicitly
|
||||
// give the binding object a reference to it.
|
||||
binding.chooseIconViewModel = chooseIconViewModel
|
||||
|
||||
// Add an Observer to the state variable for Navigating when a Quality icon is tapped.
|
||||
// chooseIconViewModel.navigateToSleepTracker.observe(this, Observer {
|
||||
// if (it == true) { // Observed state is true.
|
||||
// this.findNavController().navigate(
|
||||
// SleepQualityFragmentDirections.actionSleepQualityFragmentToSleepTrackerFragment())
|
||||
// // Reset state to make sure we only navigate once, even if the device
|
||||
// // has a configuration change.
|
||||
// sleepQualityViewModel.doneNavigating()
|
||||
// }
|
||||
// })
|
||||
|
||||
return binding.root
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
package com.taymath.tutortoolkit.chooseicon
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.taymath.tutortoolkit.studentdatabase.StudentDatabaseDao
|
||||
import kotlinx.coroutines.*
|
||||
|
||||
class ChooseIconViewModel(
|
||||
val database: StudentDatabaseDao) : ViewModel() {
|
||||
|
||||
/** Coroutine setup variables */
|
||||
|
||||
/**
|
||||
* viewModelJob allows us to cancel all coroutines started by this ViewModel.
|
||||
*/
|
||||
private val viewModelJob = Job()
|
||||
|
||||
/**
|
||||
* A [CoroutineScope] keeps track of all coroutines started by this ViewModel.
|
||||
*
|
||||
* Because we pass it [viewModelJob], any coroutine started in this scope can be cancelled
|
||||
* by calling `viewModelJob.cancel()`
|
||||
*
|
||||
* By default, all coroutines started in uiScope will launch in [Dispatchers.Main] which is
|
||||
* the main thread on Android. This is a sensible default because most coroutines started by
|
||||
* a [ViewModel] update the UI after performing some processing.
|
||||
*/
|
||||
private val uiScope = CoroutineScope(Dispatchers.Main + viewModelJob)
|
||||
|
||||
/**
|
||||
* Variable that tells the fragment whether it should navigate to [SleepTrackerFragment].
|
||||
*
|
||||
* This is `private` because we don't want to expose the ability to set [MutableLiveData] to
|
||||
* the [Fragment]
|
||||
*/
|
||||
private val _navigateToSleepTracker = MutableLiveData<Boolean?>()
|
||||
|
||||
/**
|
||||
* When true immediately navigate back to the [SleepTrackerFragment]
|
||||
*/
|
||||
val navigateToSleepTracker: LiveData<Boolean?>
|
||||
get() = _navigateToSleepTracker
|
||||
|
||||
/**
|
||||
* Cancels all coroutines when the ViewModel is cleared, to cleanup any pending work.
|
||||
*
|
||||
* onCleared() gets called when the ViewModel is destroyed.
|
||||
*/
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
viewModelJob.cancel()
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this immediately after navigating to [SleepTrackerFragment]
|
||||
*/
|
||||
fun doneNavigating() {
|
||||
_navigateToSleepTracker.value = null
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the sleep quality and updates the database.
|
||||
*
|
||||
* Then navigates back to the SleepTrackerFragment.
|
||||
*/
|
||||
// fun onSetSleepQuality(quality: Int) {
|
||||
// uiScope.launch {
|
||||
// // IO is a thread pool for running operations that access the disk, such as
|
||||
// // our Room database.
|
||||
// withContext(Dispatchers.IO) {
|
||||
// val tonight = database.get(sleepNightKey) ?: return@withContext
|
||||
// tonight.sleepQuality = quality
|
||||
// database.update(tonight)
|
||||
// }
|
||||
//
|
||||
// // Setting this state variable to true will alert the observer and trigger navigation.
|
||||
// _navigateToSleepTracker.value = true
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.taymath.tutortoolkit.chooseicon
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.taymath.tutortoolkit.studentdatabase.StudentDatabaseDao
|
||||
|
||||
class ChooseIconViewModelFactory(
|
||||
private val dataSource: StudentDatabaseDao) : ViewModelProvider.Factory {
|
||||
@Suppress("unchecked_cast")
|
||||
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
|
||||
if (modelClass.isAssignableFrom(ChooseIconViewModel::class.java)) {
|
||||
return ChooseIconViewModel(dataSource) as T
|
||||
}
|
||||
throw IllegalArgumentException("Unknown ViewModel class")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package com.taymath.tutortoolkit.studentdatabase
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(tableName = "grade_table")
|
||||
data class Grade (
|
||||
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
var gradeId: Long = 0L,
|
||||
|
||||
@ColumnInfo(name="grade_string")
|
||||
var gradeString: String = "BLANK Grade",
|
||||
|
||||
@ColumnInfo(name = "student_name_string")
|
||||
var studentNameString: String = "CHECK_GRADE.KT",
|
||||
|
||||
@ColumnInfo(name = "grade_float")
|
||||
var gradeFloat: Float = 0F,
|
||||
|
||||
@ColumnInfo(name = "time_milli")
|
||||
val startTimeMilli: Long = System.currentTimeMillis(),
|
||||
|
||||
@ColumnInfo(name = "note_string")
|
||||
var noteString: String = "CHECK_GRADE.KT",
|
||||
|
||||
@ColumnInfo(name= "student_id_long")
|
||||
var studentIdLong: Long = 0L
|
||||
)
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright 2018, The Android Open Source Project
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.
|
||||
*/
|
||||
|
||||
package com.taymath.tutortoolkit.studentdatabase
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(tableName = "student_table")
|
||||
data class Student (
|
||||
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
var studentId: Long = 0L,
|
||||
|
||||
@ColumnInfo(name="student_name")
|
||||
var studentNameString: String = "BLANK STUDENT",
|
||||
|
||||
@ColumnInfo(name = "todo_string")
|
||||
var todoString: String = "CHECK_Student.KT",
|
||||
|
||||
@ColumnInfo(name = "subject")
|
||||
var subjectString: String = "CHECK_Student.KT",
|
||||
|
||||
@ColumnInfo(name = "grade_level")
|
||||
var gradeLevelString: String = "CHECK_Student.KT",
|
||||
|
||||
@ColumnInfo(name = "address")
|
||||
var addressString: String = "CHECK_Student.KT",
|
||||
|
||||
@ColumnInfo(name = "email")
|
||||
var emailString: String = "CHECK_Student.KT"
|
||||
|
||||
)
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright 2018, The Android Open Source Project
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.
|
||||
*/
|
||||
|
||||
package com.taymath.tutortoolkit.studentdatabase
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Database
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
|
||||
@Database(entities = [Student::class, Grade::class], version = 1, exportSchema = false)
|
||||
abstract class StudentDatabase : RoomDatabase() {
|
||||
|
||||
abstract val studentDatabaseDao: StudentDatabaseDao
|
||||
|
||||
companion object {
|
||||
@Volatile
|
||||
private var INSTANCE: StudentDatabase? = null
|
||||
|
||||
fun getInstance(context: Context): StudentDatabase {
|
||||
synchronized(this) {
|
||||
var instance = INSTANCE
|
||||
|
||||
if (instance == null) {
|
||||
instance = Room.databaseBuilder(
|
||||
context.applicationContext,
|
||||
StudentDatabase::class.java,
|
||||
"student_database"
|
||||
).fallbackToDestructiveMigration().build()
|
||||
}
|
||||
|
||||
return instance
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Copyright 2018, The Android Open Source Project
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.
|
||||
*/
|
||||
|
||||
package com.taymath.tutortoolkit.studentdatabase
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.Query
|
||||
import androidx.room.Update
|
||||
|
||||
@Dao
|
||||
interface StudentDatabaseDao {
|
||||
|
||||
// Student Table Dao
|
||||
@Insert
|
||||
fun insertStudent(student: Student)
|
||||
|
||||
@Update
|
||||
fun updateStudent(student: Student)
|
||||
|
||||
@Query("DELETE FROM student_table WHERE studentId = :studentId")
|
||||
fun deleteStudent(studentId: Long)
|
||||
|
||||
@Query("DELETE FROM student_table")
|
||||
fun clearStudentTable()
|
||||
|
||||
@Query("SELECT * FROM student_table ORDER BY studentId DESC LIMIT 1")
|
||||
fun getStudent(): Student?
|
||||
|
||||
@Query("SELECT * FROM student_table ORDER BY studentId DESC")
|
||||
fun getAllStudents(): LiveData<List<Student>>
|
||||
|
||||
@Query("SELECT * from student_table WHERE studentId = :key")
|
||||
fun getStudentWithId(key: Long): LiveData<Student>
|
||||
|
||||
@Query("SELECT * FROM student_table WHERE studentId = :studentId")
|
||||
fun getStudentClassWithId(studentId: Long): Student
|
||||
|
||||
@Query("SELECT * from student_table WHERE student_name = :studentName")
|
||||
fun getStudentWithName(studentName: String): LiveData<Student>
|
||||
|
||||
|
||||
|
||||
// Grade Table Dao
|
||||
@Insert
|
||||
fun insertGrade(grade: Grade)
|
||||
|
||||
@Update
|
||||
fun updateGrade(grade: Grade)
|
||||
|
||||
@Query("DELETE FROM grade_table WHERE student_id_long = :studentId")
|
||||
fun deleteGradeTable(studentId: Long)
|
||||
|
||||
@Query("DELETE FROM grade_table")
|
||||
fun clearGradeTable()
|
||||
|
||||
@Query("SELECT * FROM grade_table ORDER BY gradeId DESC LIMIT 1")
|
||||
fun getGrade(): Grade?
|
||||
|
||||
@Query("SELECT * FROM grade_table ORDER BY student_name_string DESC")
|
||||
fun getAllGrades(): LiveData<List<Grade>>
|
||||
|
||||
@Query("SELECT * FROM grade_table WHERE student_name_string = :studentName")
|
||||
fun getGradesForStudent(studentName: String): LiveData<List<Grade>>
|
||||
|
||||
@Query("SELECT * from grade_table WHERE gradeId = :key")
|
||||
fun getGradeWithId(key: Long): LiveData<Grade>
|
||||
|
||||
@Query("SELECT * from grade_table WHERE student_id_long = :studentId")
|
||||
fun getGradesWithStudentId(studentId: Long): LiveData<List<Grade>>
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
package com.taymath.tutortoolkit.studentdetail
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.taymath.tutortoolkit.databinding.ListItemGradeBinding
|
||||
import com.taymath.tutortoolkit.studentdatabase.Grade
|
||||
|
||||
class GradeAdapter : ListAdapter<Grade,
|
||||
GradeAdapter.ViewHolder>(GradeDiffCallback()) {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
return ViewHolder.from(parent)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
holder.bind(getItem(position))
|
||||
}
|
||||
|
||||
class ViewHolder private constructor(val binding: ListItemGradeBinding)
|
||||
: RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
fun bind(item: Grade) {
|
||||
binding.grade = item
|
||||
binding.executePendingBindings()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun from(parent: ViewGroup): ViewHolder {
|
||||
val layoutInflater = LayoutInflater.from(parent.context)
|
||||
val binding = ListItemGradeBinding.inflate(layoutInflater, parent, false)
|
||||
return ViewHolder(binding)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GradeDiffCallback : DiffUtil.ItemCallback<Grade>() {
|
||||
override fun areItemsTheSame(oldItem: Grade, newItem: Grade): Boolean {
|
||||
return oldItem.gradeId == newItem.gradeId
|
||||
}
|
||||
|
||||
override fun areContentsTheSame(oldItem: Grade, newItem: Grade): Boolean {
|
||||
return oldItem == newItem
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for calculating the diff between two non-null items in a list.
|
||||
*
|
||||
* Used by ListAdapter to calculate the minumum number of changes between and old list and a new
|
||||
* list that's been passed to `submitList`.
|
||||
*/
|
||||
|
||||
|
||||
class GradeDiffCallback : DiffUtil.ItemCallback<Grade>() {
|
||||
override fun areItemsTheSame(oldItem: Grade, newItem: Grade): Boolean {
|
||||
return oldItem.gradeId == newItem.gradeId
|
||||
}
|
||||
|
||||
override fun areContentsTheSame(oldItem: Grade, newItem: Grade): Boolean {
|
||||
return oldItem == newItem
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.taymath.tutortoolkit.studentdetail
|
||||
|
||||
import android.widget.TextView
|
||||
import androidx.databinding.BindingAdapter
|
||||
import com.taymath.tutortoolkit.studentdatabase.Grade
|
||||
|
||||
@BindingAdapter("gradeFloat")
|
||||
fun TextView.setGradeFloat(item: Grade?){
|
||||
item?.let {
|
||||
text = item.gradeFloat.toString()
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter("gradeString")
|
||||
fun TextView.setSubjectText(item: Grade?){
|
||||
item?.let {
|
||||
text =item.gradeString
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter("noteString")
|
||||
fun TextView.setStudentNameText(item: Grade?){
|
||||
item?.let {
|
||||
text =item.noteString
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
package com.taymath.tutortoolkit.studentdetail
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.ViewModelProviders
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.taymath.tutortoolkit.R
|
||||
import com.taymath.tutortoolkit.databinding.FragmentStudentDetailBinding
|
||||
import com.taymath.tutortoolkit.studentdatabase.StudentDatabase
|
||||
import com.taymath.tutortoolkit.studentlist.StudentListFragmentDirections
|
||||
import com.taymath.tutortoolkit.studentlist.StudentListener
|
||||
|
||||
class StudentDetailFragment: Fragment() {
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
|
||||
val binding:FragmentStudentDetailBinding = DataBindingUtil.inflate(
|
||||
inflater, R.layout.fragment_student_detail, container,false
|
||||
)
|
||||
|
||||
val application = requireNotNull(this.activity).application
|
||||
val arguments = StudentDetailFragmentArgs.fromBundle(arguments!!)
|
||||
|
||||
// Create an instance of the ViewModel Factory.
|
||||
val dataSource = StudentDatabase.getInstance(application).studentDatabaseDao
|
||||
val viewModelFactory = StudentDetailViewModelFactory(dataSource, arguments.studentId)
|
||||
|
||||
// Get a reference to the ViewModel associated with this fragment.
|
||||
val studentDetailViewModel =
|
||||
ViewModelProviders.of(
|
||||
this, viewModelFactory).get(StudentDetailViewModel::class.java)
|
||||
|
||||
// To use the View Model with data binding, you have to explicitly
|
||||
// give the binding object a reference to it.
|
||||
binding.studentDetailViewModel = studentDetailViewModel
|
||||
|
||||
binding.setLifecycleOwner(this)
|
||||
|
||||
// Add an Observer to the state variable for Navigating when Add Grade button is clicked.
|
||||
studentDetailViewModel.navigateToAddGrade.observe(viewLifecycleOwner, Observer {
|
||||
if (it == true) { // Observed state is true.
|
||||
this.findNavController().navigate(
|
||||
StudentDetailFragmentDirections.actionStudentDetailFragmentToAddGradeFragment(arguments.studentId))
|
||||
// Reset state to make sure we only navigate once, even if the device
|
||||
// has a configuration change.
|
||||
studentDetailViewModel.doneNavigating()
|
||||
}
|
||||
})
|
||||
|
||||
// Add an Observer to the state variable for Navigating when Add Grade button is clicked.
|
||||
studentDetailViewModel.navigateToStudentList.observe(viewLifecycleOwner, Observer {
|
||||
if (it == true) { // Observed state is true.
|
||||
this.findNavController().navigate(
|
||||
StudentDetailFragmentDirections.actionStudentDetailFragmentToStudentListFragment())
|
||||
// Reset state to make sure we only navigate once, even if the device
|
||||
// has a configuration change.
|
||||
studentDetailViewModel.doneNavigating()
|
||||
}
|
||||
})
|
||||
|
||||
// Initialize adapter and add to gradeList
|
||||
val adapter = GradeAdapter()
|
||||
binding.gradeList.adapter = adapter
|
||||
|
||||
// If we have a list of grades, send it to the adapter
|
||||
studentDetailViewModel.grades.observe(viewLifecycleOwner, Observer {
|
||||
it?.let {
|
||||
adapter.submitList(it)
|
||||
}
|
||||
})
|
||||
|
||||
return binding.root
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
package com.taymath.tutortoolkit.studentdetail
|
||||
|
||||
import androidx.lifecycle.*
|
||||
import com.taymath.tutortoolkit.studentdatabase.Student
|
||||
import com.taymath.tutortoolkit.studentdatabase.StudentDatabaseDao
|
||||
import kotlinx.coroutines.*
|
||||
|
||||
class StudentDetailViewModel(
|
||||
val studentId: Long,
|
||||
dataSource: StudentDatabaseDao
|
||||
): ViewModel() {
|
||||
|
||||
/**
|
||||
* Hold a reference to StudentDatabase via its StudentDatabaseDao.
|
||||
*/
|
||||
val database = dataSource
|
||||
|
||||
// Initialize mediatorLiveData with student datatype
|
||||
private val student = MediatorLiveData<Student>()
|
||||
fun getStudent() = student
|
||||
|
||||
// Grab grades from grades_table with StudentId
|
||||
val grades = database.getGradesWithStudentId(studentId)
|
||||
|
||||
// add student from database as source for student
|
||||
init {
|
||||
student.addSource(database.getStudentWithId(studentId), student::setValue)
|
||||
}
|
||||
|
||||
// Initialize viewModelJob
|
||||
private val viewModelJob = Job()
|
||||
|
||||
// Initialize uiScope
|
||||
private val uiScope = CoroutineScope(Dispatchers.Main + viewModelJob)
|
||||
|
||||
// Setup Livedata to signal when to navigate to AddGrade
|
||||
private val _navigateToAddGrade = MutableLiveData<Boolean?>()
|
||||
val navigateToAddGrade: LiveData<Boolean?>
|
||||
get() = _navigateToAddGrade
|
||||
|
||||
// Setup Livedata to signal when to navigate to studentList
|
||||
private val _navigateToStudentList = MutableLiveData<Boolean>()
|
||||
val navigateToStudentList: LiveData<Boolean>
|
||||
get() = _navigateToStudentList
|
||||
|
||||
// Setup Livedata to tell whethere the clear button should be visible
|
||||
// Based on the contents of our grades list
|
||||
val clearButtonVisible = Transformations.map(grades) {
|
||||
it?.isNotEmpty()
|
||||
}
|
||||
|
||||
fun onNavigateToStudentList() {
|
||||
_navigateToStudentList.value = true
|
||||
}
|
||||
|
||||
fun onNavigateToAddGrade() {
|
||||
_navigateToAddGrade.value = true
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
viewModelJob.cancel()
|
||||
}
|
||||
|
||||
fun doneNavigating() {
|
||||
_navigateToAddGrade.value = null
|
||||
_navigateToStudentList.value = null
|
||||
}
|
||||
|
||||
fun onClear() {
|
||||
uiScope.launch {
|
||||
// Clear the database table.
|
||||
clearGrades(studentId)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun clearGrades(studentId: Long) {
|
||||
withContext(Dispatchers.IO) {
|
||||
database.deleteGradeTable(studentId)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun deleteStudent(studentId: Long) {
|
||||
withContext(Dispatchers.IO) {
|
||||
database.deleteGradeTable(studentId)
|
||||
database.deleteStudent(studentId)
|
||||
}
|
||||
}
|
||||
|
||||
fun onDeleteStudent() {
|
||||
uiScope.launch {
|
||||
deleteStudent(studentId)
|
||||
}
|
||||
_navigateToStudentList.value = true
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.taymath.tutortoolkit.studentdetail
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.taymath.tutortoolkit.studentdatabase.Student
|
||||
import com.taymath.tutortoolkit.studentdatabase.StudentDatabaseDao
|
||||
|
||||
class StudentDetailViewModelFactory(
|
||||
private val dataSource: StudentDatabaseDao,
|
||||
private val studentId: Long
|
||||
) : ViewModelProvider.Factory {
|
||||
@Suppress("unchecked_cast")
|
||||
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
|
||||
if (modelClass.isAssignableFrom(StudentDetailViewModel::class.java)) {
|
||||
return StudentDetailViewModel(studentId, dataSource) as T
|
||||
}
|
||||
throw IllegalArgumentException("Unknown ViewModel class")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package com.taymath.tutortoolkit.studentlist
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.taymath.tutortoolkit.databinding.ListItemStudentBinding
|
||||
import com.taymath.tutortoolkit.studentdatabase.Student
|
||||
|
||||
class StudentAdapter(val clickListener: StudentListener) : ListAdapter<Student, StudentAdapter.ViewHolder>(StudentDiffCallback()) {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
return ViewHolder.from(parent)
|
||||
}
|
||||
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
holder.bind(clickListener, getItem(position)!!)
|
||||
}
|
||||
|
||||
|
||||
class ViewHolder private constructor(val binding: ListItemStudentBinding): RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
fun bind(clickListener: StudentListener, item: Student) {
|
||||
binding.student = item
|
||||
binding.clickListener = clickListener
|
||||
binding.executePendingBindings()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun from(parent: ViewGroup): ViewHolder {
|
||||
val layoutInflater = LayoutInflater.from(parent.context)
|
||||
val binding = ListItemStudentBinding.inflate(layoutInflater, parent, false)
|
||||
return ViewHolder(binding)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class StudentDiffCallback : DiffUtil.ItemCallback<Student>() {
|
||||
override fun areItemsTheSame(oldItem: Student, newItem: Student): Boolean {
|
||||
return oldItem.studentId == newItem.studentId
|
||||
}
|
||||
|
||||
override fun areContentsTheSame(oldItem: Student, newItem: Student): Boolean {
|
||||
return oldItem == newItem
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class StudentListener(val clickListener: (studentId: Long) -> Unit) {
|
||||
fun onClick(student: Student) = clickListener(student.studentId)
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package com.taymath.tutortoolkit.studentlist
|
||||
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.databinding.BindingAdapter
|
||||
import com.taymath.tutortoolkit.R
|
||||
import com.taymath.tutortoolkit.studentdatabase.Student
|
||||
|
||||
@BindingAdapter("studentImage")
|
||||
fun ImageView.setStudentImage(item: Student?){
|
||||
item?.let {
|
||||
setImageResource(R.drawable.ic_item_test)
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter("subjectText")
|
||||
fun TextView.setSubjectText(item: Student?){
|
||||
item?.let {
|
||||
text =item.subjectString
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter("studentNameText")
|
||||
fun TextView.setStudentNameText(item: Student?){
|
||||
item?.let {
|
||||
text =item.studentNameString
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter("gradeLevelText")
|
||||
fun TextView.setGradeLevelText(item: Student?){
|
||||
item?.let {
|
||||
text =item.gradeLevelString
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
package com.taymath.tutortoolkit.studentlist
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.ViewModelProviders
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.taymath.tutortoolkit.R
|
||||
import com.taymath.tutortoolkit.databinding.FragmentStudentListBinding
|
||||
import com.taymath.tutortoolkit.studentdatabase.StudentDatabase
|
||||
import kotlinx.android.synthetic.main.fragment_add_student.*
|
||||
|
||||
/**
|
||||
* A fragment with buttons to record start and end times for sleep, which are saved in
|
||||
* a database. Cumulative data is displayed in a simple scrollable TextView.
|
||||
* (Because we have not learned about RecyclerView yet.)
|
||||
*/
|
||||
class StudentListFragment : Fragment() {
|
||||
|
||||
/**
|
||||
* Called when the Fragment is ready to display content to the screen.
|
||||
*
|
||||
* This function uses DataBindingUtil to inflate R.layout.fragment_get_todo.
|
||||
*/
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
|
||||
// Get a reference to the binding object and inflate the fragment views.
|
||||
val binding: FragmentStudentListBinding = DataBindingUtil.inflate(
|
||||
inflater, R.layout.fragment_student_list, container, false)
|
||||
|
||||
// Get reference to application
|
||||
val application = requireNotNull(this.activity).application
|
||||
|
||||
// Get a reference to the DAO
|
||||
val dataSource = StudentDatabase.getInstance(application).studentDatabaseDao
|
||||
|
||||
// Create instance of viewModelFactory using DAO and application
|
||||
val viewModelFactory = StudentListViewModelFactory(dataSource, application)
|
||||
|
||||
// Get reference to viewModel
|
||||
val studentListViewModel =
|
||||
ViewModelProviders.of(
|
||||
this, viewModelFactory).get(StudentListViewModel::class.java)
|
||||
|
||||
// Add ViewModel to our binding
|
||||
binding.studentListViewModel = studentListViewModel
|
||||
|
||||
binding.setLifecycleOwner(this)
|
||||
|
||||
// Add an Observer to the state variable for Navigating when Add Student button is clicked.
|
||||
studentListViewModel.navigateToAddStudent.observe(viewLifecycleOwner, Observer {
|
||||
if (it == true) { // Observed state is true.
|
||||
this.findNavController().navigate(
|
||||
StudentListFragmentDirections.actionStudentListFragmentToAddStudentFragment())
|
||||
studentListViewModel.onAddStudentNavigated()
|
||||
}
|
||||
})
|
||||
|
||||
// Add an Observer to the state variable for Navigating when student icon is clicked.
|
||||
studentListViewModel.navigateToStudentDetail.observe(viewLifecycleOwner, Observer {student ->
|
||||
student?.let {
|
||||
this.findNavController().navigate(StudentListFragmentDirections
|
||||
.actionStudentListFragmentToStudentDetailFragment(student))
|
||||
studentListViewModel.onStudentDetailNavigated()
|
||||
}
|
||||
})
|
||||
|
||||
// Initialize adapter and add to studentList
|
||||
val adapter = StudentAdapter(StudentListener {
|
||||
studentId -> studentListViewModel.onNavToStudentDetail(studentId)
|
||||
})
|
||||
binding.studentList.adapter = adapter
|
||||
|
||||
// If we have a list of students, send it to the adapter
|
||||
studentListViewModel.students.observe(viewLifecycleOwner, Observer {
|
||||
it?.let {
|
||||
adapter.submitList(it)
|
||||
}
|
||||
})
|
||||
|
||||
return binding.root
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
package com.taymath.tutortoolkit.studentlist
|
||||
|
||||
import android.app.Application
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.taymath.tutortoolkit.studentdatabase.Student
|
||||
import com.taymath.tutortoolkit.studentdatabase.StudentDatabaseDao
|
||||
import kotlinx.coroutines.*
|
||||
|
||||
class StudentListViewModel(
|
||||
val database: StudentDatabaseDao,
|
||||
application: Application
|
||||
) : AndroidViewModel(application) {
|
||||
|
||||
/** Coroutine setup variables */
|
||||
|
||||
/**
|
||||
* viewModelJob allows us to cancel all coroutines started by this ViewModel.
|
||||
*/
|
||||
private val viewModelJob = Job()
|
||||
|
||||
// Add variable to navigation signaller
|
||||
private val _navigateToAddStudent = MutableLiveData<Boolean?>()
|
||||
val navigateToAddStudent: LiveData<Boolean?>
|
||||
get() = _navigateToAddStudent
|
||||
|
||||
private val _navigateToStudentDetail = MutableLiveData<Long?>()
|
||||
val navigateToStudentDetail: LiveData<Long?>
|
||||
get() = _navigateToStudentDetail
|
||||
|
||||
val students = database.getAllStudents()
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
viewModelJob.cancel()
|
||||
}
|
||||
|
||||
// set navigate to student to be true when clicked
|
||||
fun onNavToAddStudent() {
|
||||
_navigateToAddStudent.value = true
|
||||
}
|
||||
|
||||
// Reset nav value after navigation
|
||||
fun onAddStudentNavigated() {
|
||||
_navigateToAddStudent.value = null
|
||||
}
|
||||
|
||||
fun onNavToStudentDetail(studentId: Long) {
|
||||
_navigateToStudentDetail.value = studentId
|
||||
}
|
||||
|
||||
fun onStudentDetailNavigated() {
|
||||
_navigateToStudentDetail.value = null
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.taymath.tutortoolkit.studentlist
|
||||
|
||||
import android.app.Application
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.taymath.tutortoolkit.studentdatabase.StudentDatabaseDao
|
||||
|
||||
class StudentListViewModelFactory(
|
||||
private val dataSource: StudentDatabaseDao,
|
||||
private val application: Application) : ViewModelProvider.Factory {
|
||||
@Suppress("unchecked_cast")
|
||||
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
|
||||
if (modelClass.isAssignableFrom(StudentListViewModel::class.java)) {
|
||||
return StudentListViewModel(dataSource, application) as T
|
||||
}
|
||||
throw IllegalArgumentException("Unknown ViewModel class")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:startY="49.59793"
|
||||
android:startX="42.9492"
|
||||
android:endY="92.4963"
|
||||
android:endX="85.84757"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000"/>
|
||||
</vector>
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector
|
||||
android:height="108dp"
|
||||
android:width="108dp"
|
||||
android:viewportHeight="108"
|
||||
android:viewportWidth="108"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M9,0L9,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,0L19,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M29,0L29,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M39,0L39,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M49,0L49,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M59,0L59,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M69,0L69,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M79,0L79,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M89,0L89,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M99,0L99,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,9L108,9"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,19L108,19"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,29L108,29"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,39L108,39"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,49L108,49"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,59L108,59"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,69L108,69"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,79L108,79"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,89L108,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,99L108,99"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,29L89,29"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,39L89,39"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,49L89,49"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,59L89,59"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,69L89,69"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,79L89,79"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M29,19L29,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M39,19L39,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M49,19L49,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M59,19L59,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M69,19L69,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M79,19L79,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
</vector>
|
||||
|
After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 5.7 KiB |
|
After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 5.7 KiB |
|
After Width: | Height: | Size: 5.5 KiB |
|
After Width: | Height: | Size: 5.7 KiB |
|
After Width: | Height: | Size: 5.5 KiB |
|
After Width: | Height: | Size: 5.8 KiB |
|
|
@ -0,0 +1,16 @@
|
|||
<!-- The merge tag can be used to eliminate redundant layouts when
|
||||
including layouts, and it's a good idea to use it.
|
||||
See: https://developer.android.com/training/improving-layouts/reusing-layouts -->
|
||||
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_host_fragment"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:defaultNavHost="true"
|
||||
app:navGraph="@navigation/navigation" />
|
||||
|
||||
</merge>
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<layout 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">
|
||||
|
||||
<data>
|
||||
<!-- Get reference to addStudentViewModel -->
|
||||
<variable
|
||||
name="addGradeViewModel"
|
||||
type="com.taymath.tutortoolkit.addgrade.AddGradeViewModel"/>
|
||||
<variable
|
||||
name="grade"
|
||||
type="com.taymath.tutortoolkit.studentdatabase.Grade" />
|
||||
</data>
|
||||
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/grade_float_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin"
|
||||
android:ems="10"
|
||||
android:hint="@string/decimal_grade"
|
||||
android:inputType="numberDecimal"
|
||||
android:text="@={addGradeViewModel.gradeFloatText}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/student_name_text" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/grade_string_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin"
|
||||
android:ems="10"
|
||||
android:hint="@string/letter_grade"
|
||||
android:inputType="textPersonName"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/grade_float_text" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/notes_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin"
|
||||
android:ems="10"
|
||||
android:gravity="start|top"
|
||||
android:hint="@string/notes"
|
||||
android:inputType="textMultiLine"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/grade_string_text" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/add_grade_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="@{() -> addGradeViewModel.onAddGrade(gradeStringText.getText().toString(), Float.parseFloat(gradeFloatText.getText().toString()), notesText.getText().toString(), studentNameText.getText().toString())}"
|
||||
android:text="@string/add_grade"
|
||||
android:enabled="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/notes_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/student_name_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin"
|
||||
android:hint="@string/student_name"
|
||||
android:text="@{addGradeViewModel.student.studentNameString}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.485"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<layout 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">
|
||||
|
||||
<data>
|
||||
<!-- Get reference to addStudentViewModel -->
|
||||
<variable
|
||||
name="addStudentViewModel"
|
||||
type="com.taymath.tutortoolkit.addstudent.AddStudentViewModel"/>
|
||||
<variable
|
||||
name="student"
|
||||
type="com.taymath.tutortoolkit.studentdatabase.Student" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:conext=".addstudent.AddStudentFragment">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/student_name_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/margin"
|
||||
android:layout_marginTop="64dp"
|
||||
android:layout_marginRight="@dimen/margin"
|
||||
android:autofillHints="@string/student_name"
|
||||
android:ems="10"
|
||||
android:hint="@string/student_name"
|
||||
android:inputType="textPersonName"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/subject_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin"
|
||||
android:autofillHints="@string/subject"
|
||||
android:ems="10"
|
||||
android:hint="@string/subject"
|
||||
android:inputType="textPersonName"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/student_name_text" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/grade_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin"
|
||||
android:layout_marginTop="99dp"
|
||||
android:autofillHints="@string/grade_level"
|
||||
android:ems="10"
|
||||
android:hint="@string/grade_level"
|
||||
android:inputType="textPersonName"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/subject_text" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/address_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin"
|
||||
android:layout_marginTop="72dp"
|
||||
android:autofillHints="@string/address"
|
||||
android:ems="10"
|
||||
android:hint="@string/address"
|
||||
android:inputType="textPostalAddress"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/grade_text" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/email_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin"
|
||||
android:layout_marginTop="188dp"
|
||||
android:autofillHints="@string/email"
|
||||
android:ems="10"
|
||||
android:hint="@string/email"
|
||||
android:inputType="textEmailAddress"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.906"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/address_text" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/add_student_button"
|
||||
style="@style/AddButtons"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:onClick="@{() -> addStudentViewModel.onAddStudent(studentNameText.getText().toString(), subjectText.getText().toString(), gradeText.getText().toString(), addressText.getText().toString(), emailText.getText().toString())}"
|
||||
android:text="@string/add_student"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageButton" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/imageButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/email_text"
|
||||
app:srcCompat="@drawable/icon_1"
|
||||
android:contentDescription="@string/student_image_icon_choice" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2018, The Android Open Source Project
|
||||
~
|
||||
~ 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
|
||||
~
|
||||
~ http://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.
|
||||
-->
|
||||
|
||||
<!-- Wrapping the layout into /layout to make it available with data binding. -->
|
||||
<layout 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">
|
||||
|
||||
<!-- Data to make available to the XML via data binding. In this case,
|
||||
the whole ViewModel, so that we can access the LiveData,
|
||||
click handlers, and state variables. -->
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="chooseIconViewModel"
|
||||
type="com.taymath.tutortoolkit.chooseicon.ChooseIconViewModel"/>
|
||||
</data>
|
||||
|
||||
<!-- Start of the visible fragment layout using ConstraintLayout -->
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/margin"
|
||||
android:text="@string/choose_your_icon"
|
||||
android:textSize="@dimen/title_text_size"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/quality_zero_image"
|
||||
android:layout_width="@dimen/icon_size"
|
||||
android:layout_height="@dimen/icon_size"
|
||||
android:contentDescription="@string/icon_1"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/title_text"
|
||||
app:srcCompat="@drawable/icon_1" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<data>
|
||||
<variable
|
||||
name="studentDetailViewModel"
|
||||
type="com.taymath.tutortoolkit.studentdetail.StudentDetailViewModel" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<Button
|
||||
android:id="@+id/add_grade_button"
|
||||
style="@style/AddButtons"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin"
|
||||
android:onClick="@{() -> studentDetailViewModel.onNavigateToAddGrade()}"
|
||||
android:text="@string/add_grade"
|
||||
app:layout_constraintBottom_toTopOf="@+id/gradeList"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/grade_float_text"
|
||||
app:layout_constraintVertical_bias="1.0" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/gradeList"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/add_grade_button" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/clear_grades_button"
|
||||
style="@style/AddButtons"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin"
|
||||
android:enabled="@{studentDetailViewModel.clearButtonVisible}"
|
||||
android:onClick="@{() -> studentDetailViewModel.onClear()}"
|
||||
android:text="@string/clear_grades"
|
||||
app:backgroundTint="@color/orange_color"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/gradeList" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/grade_float_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin"
|
||||
android:text="@{studentDetailViewModel.student.studentNameString}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="Student Name" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/delete_student_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin"
|
||||
android:onClick="@{() -> studentDetailViewModel.onDeleteStudent()}"
|
||||
android:text="@string/delete_student"
|
||||
style="@style/AddButtons"
|
||||
app:backgroundTint="@color/red_color"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout 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">
|
||||
|
||||
<data>
|
||||
<!-- Get reference to sleepTrackerViewModel -->
|
||||
<variable
|
||||
name="studentListViewModel"
|
||||
type="com.taymath.tutortoolkit.studentlist.StudentListViewModel"/>
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".studentlist.StudentListFragment">
|
||||
|
||||
<Button
|
||||
android:id="@+id/add_student_button"
|
||||
style="@style/AddButtons"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin"
|
||||
android:layout_marginTop="456dp"
|
||||
android:onClick="@{() -> studentListViewModel.onNavToAddStudent()}"
|
||||
android:text="@string/add_student"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/student_list"
|
||||
android:layout_width="409dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/add_student_button"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<layout 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">
|
||||
|
||||
<data>
|
||||
<variable
|
||||
name="grade"
|
||||
type="com.taymath.tutortoolkit.studentdatabase.Grade" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/grade_string_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin"
|
||||
android:hint="@string/a"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/grade_float_text"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:gradeString="@{grade}"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/grade_float_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin"
|
||||
android:hint="@string/_90"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:gradeFloat="@{grade}"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/note_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin"
|
||||
android:hint="@string/example_note_here"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/grade_string_text"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:noteString="@{grade}"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<layout 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">
|
||||
|
||||
<data>
|
||||
<variable
|
||||
name="student"
|
||||
type="com.taymath.tutortoolkit.studentdatabase.Student" />
|
||||
<variable
|
||||
name="clickListener"
|
||||
type="com.taymath.tutortoolkit.studentlist.StudentListener"/>
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/student_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin"
|
||||
android:contentDescription="@string/image_representing_student"
|
||||
android:isScrollContainer="false"
|
||||
android:onClick="@{() -> clickListener.onClick(student)}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:studentImage="@{student}"
|
||||
tools:srcCompat="@drawable/ic_item_test" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/grade_string_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin"
|
||||
android:hint="@string/subject"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/student_image"
|
||||
app:layout_constraintTop_toBottomOf="@+id/grade_float_text"
|
||||
app:subjectText="@{student}" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/grade_float_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/margin"
|
||||
android:layout_marginTop="@dimen/margin"
|
||||
android:layout_marginRight="@dimen/margin"
|
||||
android:hint="@string/student_name"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/student_image"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:studentNameText="@{student}" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/note_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin"
|
||||
android:hint="@string/grade_level"
|
||||
app:gradeLevelText="@{student}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/student_image"
|
||||
app:layout_constraintTop_toBottomOf="@+id/grade_string_text" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
|
|
@ -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="@drawable/ic_launcher_background"/>
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
||||
|
|
@ -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="@drawable/ic_launcher_background"/>
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
||||
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 5.3 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 8.2 KiB |
|
After Width: | Height: | Size: 8.6 KiB |
|
After Width: | Height: | Size: 7.0 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
|
@ -0,0 +1,59 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/navigation"
|
||||
app:startDestination="@id/studentListFragment">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/studentListFragment"
|
||||
android:name="com.taymath.tutortoolkit.studentlist.StudentListFragment"
|
||||
android:label="StudentListFragment" >
|
||||
<action
|
||||
android:id="@+id/action_studentListFragment_to_addStudentFragment"
|
||||
app:destination="@id/addStudentFragment" />
|
||||
<action
|
||||
android:id="@+id/action_studentListFragment_to_studentDetailFragment"
|
||||
app:destination="@id/studentDetailFragment" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/addStudentFragment"
|
||||
android:name="com.taymath.tutortoolkit.addstudent.AddStudentFragment"
|
||||
android:label="AddStudentFragment" >
|
||||
<action
|
||||
android:id="@+id/action_addStudentFragment_to_studentListFragment"
|
||||
app:destination="@id/studentListFragment" />
|
||||
<action
|
||||
android:id="@+id/action_addStudentFragment_to_chooseIconFragment"
|
||||
app:destination="@id/chooseIconFragment" />
|
||||
<action
|
||||
android:id="@+id/action_addStudentFragment_to_chooseIconFragment2"
|
||||
app:destination="@id/chooseIconFragment" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/studentDetailFragment"
|
||||
android:name="com.taymath.tutortoolkit.studentdetail.StudentDetailFragment"
|
||||
android:label="StudentDetailFragment" >
|
||||
<action
|
||||
android:id="@+id/action_studentDetailFragment_to_studentListFragment"
|
||||
app:destination="@id/studentListFragment" />
|
||||
<action
|
||||
android:id="@+id/action_studentDetailFragment_to_addGradeFragment"
|
||||
app:destination="@id/addGradeFragment" />
|
||||
<argument android:name="student_id"
|
||||
app:argType="long" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/addGradeFragment"
|
||||
android:name="com.taymath.tutortoolkit.addgrade.AddGradeFragment"
|
||||
android:label="AddGradeFragment" >
|
||||
<argument
|
||||
android:name="student_id"
|
||||
app:argType="long" />
|
||||
<action
|
||||
android:id="@+id/action_addGradeFragment_to_studentListFragment"
|
||||
app:destination="@id/studentListFragment" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/chooseIconFragment"
|
||||
android:name="com.taymath.tutortoolkit.chooseicon.ChooseIconFragment"
|
||||
android:label="ChooseIconFragment" />
|
||||
</navigation>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#6ab343</color>
|
||||
<color name="colorPrimaryDark">#388310</color>
|
||||
<color name="colorAccent">#6ab343</color>
|
||||
|
||||
<color name="green_color">#388310</color>
|
||||
<color name="white_text_color">#f0f0f0</color>
|
||||
|
||||
<color name="red_color">#DC2828</color>
|
||||
<color name="orange_color">#F44B03</color>
|
||||
<color name="black_text_color">#040404</color>
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="margin">16dp</dimen>
|
||||
<dimen name="icon_size">64dp</dimen>
|
||||
<dimen name="title_text_size">20sp</dimen>
|
||||
<dimen name="triple_margin">48dp</dimen>
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<resources>
|
||||
<string name="app_name">TutorToolkit</string>
|
||||
<string name="student_name">Student Name</string>
|
||||
<string name="subject">Subject</string>
|
||||
<string name="grade_level">Grade Level</string>
|
||||
<string name="address">Address</string>
|
||||
<string name="email">Email</string>
|
||||
<string name="add_student">Add Student</string>
|
||||
<string name="image_representing_student">Image representing student</string>
|
||||
<string name="delete">Delete</string>
|
||||
<string name="graph_of_grades">Graph of Grades</string>
|
||||
<string name="graph_of_students_grades">Graph of students\' grades</string>
|
||||
<string name="_90">90%</string>
|
||||
<string name="a">A</string>
|
||||
<string name="example_note_here">Example Note Here!</string>
|
||||
<string name="add_grade">Add Grade</string>
|
||||
<string name="textview">TextView</string>
|
||||
<string name="decimal_grade">Decimal Grade</string>
|
||||
<string name="letter_grade">Letter Grade</string>
|
||||
<string name="notes">Notes</string>
|
||||
<string name="clear_grades">Clear Grades</string>
|
||||
<string name="delete_student">Delete Student</string>
|
||||
<string name="student_image_icon_choice">Student Image Icon Choice</string>
|
||||
<string name="icon_1">Icon 1</string>
|
||||
<string name="choose_your_icon">Choose Your Icon!</string>
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
<!-- Basic styling for the buttons. -->
|
||||
<style name="AddButtons" parent="Buttons">
|
||||
<item name="colorAccent">@color/green_color</item>
|
||||
<item name="android:textColor">@color/white_text_color</item>
|
||||
<item name="android:textStyle">bold</item>
|
||||
<item name="colorControlHighlight">@color/green_color</item>
|
||||
</style>
|
||||
|
||||
<style name="Buttons" parent="Widget.AppCompat.Button.Colored">
|
||||
<item name="android:textStyle">bold</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package com.taymath.tutortoolkit
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Room
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.taymath.tutortoolkit.studentdatabase.Grade
|
||||
import com.taymath.tutortoolkit.studentdatabase.StudentDatabase
|
||||
import com.taymath.tutortoolkit.studentdatabase.StudentDatabaseDao
|
||||
import org.hamcrest.CoreMatchers.equalTo
|
||||
import org.junit.After
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Before
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.JUnit4
|
||||
import java.io.IOException
|
||||
|
||||
/**
|
||||
* 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)
|
||||
}
|
||||
}
|
||||
|
||||
@RunWith(JUnit4::class)
|
||||
class SimpleEntityReadWriteTest {
|
||||
private lateinit var userDao: StudentDatabaseDao
|
||||
private lateinit var db: StudentDatabase
|
||||
|
||||
@Before
|
||||
fun createDb() {
|
||||
val context = InstrumentationRegistry.getInstrumentation().getTargetContext()
|
||||
db = Room.inMemoryDatabaseBuilder(
|
||||
context, StudentDatabase::class.java
|
||||
).build()
|
||||
userDao = db.studentDatabaseDao
|
||||
}
|
||||
|
||||
@After
|
||||
@Throws(IOException::class)
|
||||
fun closeDb() {
|
||||
db.close()
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun writeUserAndReadInList() {
|
||||
val grade: Grade = Grade()
|
||||
userDao.insertGrade(grade)
|
||||
val byName = userDao.getGrade()
|
||||
assertThat(byName, equalTo(grade))
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext {
|
||||
version_core = "1.0.1"
|
||||
version_coroutine = "1.1.0"
|
||||
version_navigation = '1.0.0'
|
||||
version_constraint_layout = "2.0.0-alpha3"
|
||||
version_gradle = '3.3.2'
|
||||
version_kotlin = "1.3.21"
|
||||
version_lifecycle_extensions = "2.0.0"
|
||||
version_room = "2.0.0"
|
||||
version_appcompat = "1.0.2"
|
||||
version_fragment = "1.0.0"
|
||||
}
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.6.2'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$version_kotlin"
|
||||
classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:$version_navigation"
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
# Project-wide Gradle settings.
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx1536m
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app's APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
# Automatically convert third-party libraries to use AndroidX
|
||||
android.enableJetifier=true
|
||||
# Kotlin code style for this project: "official" or "obsolete":
|
||||
kotlin.code.style=official
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#Fri Apr 10 13:29:17 PDT 2020
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
rootProject.name='TutorToolkit'
|
||||
include ':app'
|
||||