Skip to content

Commit

Permalink
Show more in home, removed estimations, fixed compilation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
AIDEA775 committed Oct 2, 2019
1 parent 956e8b6 commit 632cf8c
Show file tree
Hide file tree
Showing 21 changed files with 388 additions and 230 deletions.
22 changes: 13 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ android {
versionCode 11
versionName "v6.0 Florentina"
resValue "string", "app_name", "UNCmorfi"
kapt {
arguments {
arg("room.schemaLocation", "$projectDir/schemas".toString())
}
}
}
buildTypes {
release {
Expand All @@ -32,23 +37,22 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'org.apache.commons:commons-math3:3.6.1'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31'

implementation 'androidx.appcompat:appcompat:1.1.0-alpha05'
implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha05'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0-beta04'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0-alpha03'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0-alpha03'
implementation 'androidx.core:core-ktx:1.2.0-alpha01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0-alpha05'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0-alpha05'
implementation 'androidx.core:core-ktx:1.2.0-alpha04'

def room_version = "2.2.0-alpha02"
def room_version = "2.2.0-rc01"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"

implementation 'com.google.android.material:material:1.1.0-alpha07'
implementation 'com.google.android.material:material:1.1.0-alpha10'
implementation 'com.google.android.gms:play-services-maps:17.0.0'

implementation 'com.github.bumptech.glide:glide:4.9.0'
Expand Down
231 changes: 231 additions & 0 deletions app/schemas/com.uncmorfi.models.AppDatabase/1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
{
"formatVersion": 1,
"database": {
"version": 1,
"identityHash": "3973efb2e7e8de8d8e6b7afa6dd74adf",
"entities": [
{
"tableName": "users",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`card` TEXT NOT NULL, `name` TEXT, `type` TEXT, `image` TEXT, `balance` INTEGER NOT NULL, `expiration` TEXT NOT NULL, `lastUpdate` TEXT NOT NULL, PRIMARY KEY(`card`))",
"fields": [
{
"fieldPath": "card",
"columnName": "card",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "type",
"columnName": "type",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "image",
"columnName": "image",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "balance",
"columnName": "balance",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "expiration",
"columnName": "expiration",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "lastUpdate",
"columnName": "lastUpdate",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"card"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "menu",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`date` TEXT NOT NULL, `food` TEXT NOT NULL, PRIMARY KEY(`date`))",
"fields": [
{
"fieldPath": "date",
"columnName": "date",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "food",
"columnName": "food",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"date"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "servings",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`date` TEXT NOT NULL, `serving` INTEGER NOT NULL, PRIMARY KEY(`date`))",
"fields": [
{
"fieldPath": "date",
"columnName": "date",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "serving",
"columnName": "serving",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"date"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "reservations",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`code` TEXT NOT NULL, `token` TEXT NOT NULL, `path` TEXT NOT NULL, PRIMARY KEY(`code`), FOREIGN KEY(`code`) REFERENCES `users`(`card`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "code",
"columnName": "code",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "token",
"columnName": "token",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "path",
"columnName": "path",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"code"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": [
{
"table": "users",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"code"
],
"referencedColumns": [
"card"
]
}
]
},
{
"tableName": "cookies",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`cookieId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `code_id` TEXT NOT NULL, `domain` TEXT NOT NULL, `value` TEXT NOT NULL, `name` TEXT NOT NULL, FOREIGN KEY(`code_id`) REFERENCES `reservations`(`code`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "cookieId",
"columnName": "cookieId",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "code",
"columnName": "code_id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "domain",
"columnName": "domain",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "value",
"columnName": "value",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"cookieId"
],
"autoGenerate": true
},
"indices": [
{
"name": "index_cookies_code_id",
"unique": false,
"columnNames": [
"code_id"
],
"createSql": "CREATE INDEX IF NOT EXISTS `index_cookies_code_id` ON `${TABLE_NAME}` (`code_id`)"
}
],
"foreignKeys": [
{
"table": "reservations",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"code_id"
],
"referencedColumns": [
"code"
]
}
]
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '3973efb2e7e8de8d8e6b7afa6dd74adf')"
]
}
}
4 changes: 4 additions & 0 deletions app/src/main/java/com/uncmorfi/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,8 @@ class MainActivity :
return fragment
}

fun change(id: Int) {
replaceFragment(id)
navView.setCheckedItem(id)
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/uncmorfi/balance/BalanceFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class BalanceFragment : Fragment() {

private fun showUserOptionsDialog(user: User) {
UserOptionsDialog.newInstance(this, USER_OPTIONS_CODE, user)
.show(fragmentManager!!, "UserOptionsDialog")
.show(parentFragmentManager, "UserOptionsDialog")
}

override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ class UserOptionsDialog: BaseDialogHelper() {
1 -> reservation()
2 -> DeleteUserDialog
.newInstance(this, 0, user)
.show(fragmentManager!!, "DeleteUserDialog")
.show(parentFragmentManager, "DeleteUserDialog")
3 -> {
context?.copyToClipboard("card", user.card)
viewModel.status.value = StatusCode.COPIED
}
4 -> startActivity(BarcodeActivity.intent(context!!, user))
5 -> SetNameDialog
.newInstance(this, 0, user)
.show(fragmentManager!!, "SetNameDialog")
.show(parentFragmentManager, "SetNameDialog")
}
}
return builder.create()
Expand All @@ -64,11 +64,11 @@ class UserOptionsDialog: BaseDialogHelper() {
if (reserveCached) {
ReserveOptionsDialog
.newInstance(this, 0, user)
.show(fragmentManager!!, "ReserveOptionsDialog")
.show(parentFragmentManager, "ReserveOptionsDialog")
} else {
CaptchaDialog
.newInstance(this, 0, user)
.show(fragmentManager!!, "CaptchaDialog")
.show(parentFragmentManager, "CaptchaDialog")
}
}

Expand Down
24 changes: 17 additions & 7 deletions app/src/main/java/com/uncmorfi/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import com.uncmorfi.MainActivity
import com.uncmorfi.R
import com.uncmorfi.balance.dialogs.UserOptionsDialog
import com.uncmorfi.models.DayMenu
Expand Down Expand Up @@ -73,6 +74,9 @@ class HomeFragment : Fragment() {
homeMenuContainer.visibility = GONE
}
})
homeMenuShowMore.setOnClickListener {
(requireActivity() as MainActivity).change(R.id.nav_menu)
}

/*
* Tarjetas
Expand All @@ -88,31 +92,37 @@ class HomeFragment : Fragment() {
homeCardContainer.visibility = GONE
}
})
homeCardContainer.setOnClickListener {
homeCard.setOnClickListener {
UserOptionsDialog
.newInstance(this, USER_OPTIONS_CODE, mUser)
.show(fragmentManager!!, "UserOptionsDialog")
.show(parentFragmentManager, "UserOptionsDialog")
}
homeCardContainer.setOnLongClickListener {
homeCard.setOnLongClickListener {
mUser.isLoading = true
homeCard.setUser(mUser)
mViewModel.downloadUsers(mUser)
true
}
homeCardShowMore.setOnClickListener {
(requireActivity() as MainActivity).change(R.id.nav_balance)
}

/*
* Medidor
*/
mViewModel.getServings().observe(this, Observer {
if (it.isNotEmpty()) {
servingsPieChart.set(it)
homeServingsPieChart.set(it)
}
})
servingsPieChart.setTouchEnabled(false)
homeServingsContainer.setOnClickListener {
mRootView.snack(R.string.snack_updating, LOADING)
homeServingsPieChart.setTouchEnabled(false)
homeServingsPieChart.setOnClickListener {
homeSwipeRefresh.isRefreshing = true
mViewModel.updateServings()
}
homeServingsShowMore.setOnClickListener {
(requireActivity() as MainActivity).change(R.id.nav_servings)
}

/*
* Reservas
Expand Down
Loading

0 comments on commit 632cf8c

Please sign in to comment.