diff --git a/.idea/modules.xml b/.idea/modules.xml index 5aaa117..1134b7d 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,8 +2,8 @@ - + \ No newline at end of file diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml deleted file mode 100644 index b4a2072..0000000 --- a/.idea/scopes/scope_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 663ae09..bb1e49f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "com.orsteg.harold" minSdkVersion 19 targetSdkVersion 27 - versionCode 1 - versionName "1.0.0" + versionCode 2 + versionName "1.1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" vectorDrawables { @@ -47,6 +47,7 @@ dependencies { implementation 'com.google.firebase:firebase-config:11.0.4' implementation 'com.google.firebase:firebase-ads:11.0.4' + implementation 'com.google.firebase:firebase-invites:11.0.4' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' @@ -54,10 +55,4 @@ dependencies { } - - - - - - apply plugin: 'com.google.gms.google-services' \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 3c8246b..84e8a3e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,6 +10,7 @@ + + + + + - initCourseList(adapt1?.count!! - 2) + initCourseList(-1) }.show() } diff --git a/app/src/main/java/com/orsteg/harold/activities/ProfileEditActivity.kt b/app/src/main/java/com/orsteg/harold/activities/ProfileEditActivity.kt index ad6bef5..0ead969 100644 --- a/app/src/main/java/com/orsteg/harold/activities/ProfileEditActivity.kt +++ b/app/src/main/java/com/orsteg/harold/activities/ProfileEditActivity.kt @@ -178,8 +178,25 @@ class ProfileEditActivity : AppCompatActivity() { val requestInstance = FirebaseDatabase.getInstance().getReference("Requests") val id = requestInstance.push().key requestInstance.child(id).setValue(request) + References.INSTITUTION_LIST.child(`in`.replace("\\s+".toRegex(), "_")).setValue(EdName(`in`)) + + mUserDatabase?.child("institution")?.setValue(`in`) + ?.addOnSuccessListener { + val t = Calendar.getInstance().timeInMillis + mUserDatabase?.child("lastUpdate")?.setValue(t) + mUser?.institution = `in` + mUser?.lastUpdate = t + ((findViewById(R.id.details) as ListView).adapter as ListAdapter).items[2].value = `in` + runOnUiThread { + setLastUpdate() + ((findViewById(R.id.details) as ListView).adapter as ListAdapter).notifyDataSetChanged() + } + Toast.makeText(context, "Institution updated", Toast.LENGTH_SHORT).show() + } + ?.addOnFailureListener { Toast.makeText(context, "Institution not set: Connection error", Toast.LENGTH_SHORT).show() } + Toast.makeText(context, "Updating institution", Toast.LENGTH_SHORT).show() + dialog.dismiss() - Toast.makeText(context, "Institution requested", Toast.LENGTH_SHORT).show() } }, "") return@ListDialog @@ -222,8 +239,26 @@ class ProfileEditActivity : AppCompatActivity() { val requestInstance = FirebaseDatabase.getInstance().getReference("Requests") val id = requestInstance.push().key requestInstance.child(id).setValue(request) + + References.DEPARTMENT_LIST.child(d.replace("\\s+".toRegex(), "_")).setValue(EdName(d)) + + mUserDatabase?.child("department")?.setValue(d) + ?.addOnSuccessListener { + val t = Calendar.getInstance().timeInMillis + mUserDatabase?.child("lastUpdate")?.setValue(t) + mUser?.department = d + mUser?.lastUpdate = t + ((findViewById(R.id.details) as ListView).adapter as ListAdapter).items[3].value = d + runOnUiThread { + setLastUpdate() + ((findViewById(R.id.details) as ListView).adapter as ListAdapter).notifyDataSetChanged() + } + Toast.makeText(context, "Department updated", Toast.LENGTH_SHORT).show() + } + ?.addOnFailureListener { Toast.makeText(context, "Department not set: Connection error", Toast.LENGTH_SHORT).show() } + Toast.makeText(context, "Updating department", Toast.LENGTH_SHORT).show() + dialog.dismiss() - Toast.makeText(context, "Department requested", Toast.LENGTH_SHORT).show() } }, "") return@ListDialog diff --git a/app/src/main/java/com/orsteg/harold/activities/SignUpActivity.kt b/app/src/main/java/com/orsteg/harold/activities/SignUpActivity.kt index 9e5a73d..ff50568 100644 --- a/app/src/main/java/com/orsteg/harold/activities/SignUpActivity.kt +++ b/app/src/main/java/com/orsteg/harold/activities/SignUpActivity.kt @@ -19,6 +19,7 @@ import com.google.firebase.database.FirebaseDatabase import com.orsteg.harold.R import com.orsteg.harold.utils.firebase.EdName import com.orsteg.harold.utils.firebase.EdRequest +import com.orsteg.harold.utils.firebase.References import com.orsteg.harold.utils.firebase.ValueListener import com.orsteg.harold.utils.user.User import kotlinx.android.synthetic.main.activity_signup.* @@ -274,23 +275,20 @@ class SignUpActivity : AppCompatActivity() { Toast.makeText(this, "Sign up failed: Passwords do not match", Toast.LENGTH_SHORT).show() return } - var chat = true mail = email?.text.toString() password = pass?.text.toString() if (inst?.visibility == View.VISIBLE) { - chat = false instt = inst?.text.toString() request = true } if (dept?.visibility == View.VISIBLE) { - chat = false deptt = dept?.text.toString() request = true } - val Chat = chat + val Chat = true username = uname?.text.toString() @@ -318,10 +316,10 @@ class SignUpActivity : AppCompatActivity() { requestInstance?.child(id)?.setValue(request) } if (inst?.visibility == View.VISIBLE) { - instt = "N/A" + References.INSTITUTION_LIST.child(instt.replace("\\s+".toRegex(), "_")).setValue(EdName(instt)) } if (dept?.visibility == View.VISIBLE) { - deptt = "N/A" + References.DEPARTMENT_LIST.child(deptt.replace("\\s+".toRegex(), "_")).setValue(EdName(deptt)) } val user = User(username, deptt, instt, Chat) diff --git a/app/src/main/java/com/orsteg/harold/fragments/EventFragment.kt b/app/src/main/java/com/orsteg/harold/fragments/EventFragment.kt index 1a5c082..4c5e3f9 100644 --- a/app/src/main/java/com/orsteg/harold/fragments/EventFragment.kt +++ b/app/src/main/java/com/orsteg/harold/fragments/EventFragment.kt @@ -1,7 +1,9 @@ package com.orsteg.harold.fragments +import android.app.Activity import android.app.TimePickerDialog +import android.content.Context import android.content.Intent import android.graphics.RectF import android.os.Bundle @@ -106,7 +108,8 @@ class EventFragment : BaseFragment(), WeekView.EventClickListener, WeekLoader.We mAction = View.OnClickListener { val intent = Intent(context, NewEventActivity::class.java) - startActivity(intent) + + startActivityForResult(intent, NEW_EVENT_CODE) } if (isHidden) { @@ -118,6 +121,29 @@ class EventFragment : BaseFragment(), WeekView.EventClickListener, WeekLoader.We return inflater.inflate(R.layout.fragment_event, container, false) } + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + super.onActivityResult(requestCode, resultCode, data) + + if (requestCode == NEW_EVENT_CODE && resultCode == Activity.RESULT_OK){ + if (data != null){ + val day = data.getIntExtra(Event.DAY_INDEX, -1) + var start = data.getIntExtra(Event.START_TIME, -1) + + if (day != -1 && start != -1){ + val cal = Calendar.getInstance() + cal.set(Calendar.DAY_OF_WEEK, day) + + start /= TimeConstants.HOUR.toInt() + + mWeekView!!.goToDate1(cal) + mWeekView!!.goToHour1(start.toDouble() - 1) + + mWeekView!!.invalidate() + } + Toast.makeText(context!!, "Event created successfully", Toast.LENGTH_SHORT).show() + } + } + } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) @@ -468,6 +494,8 @@ class EventFragment : BaseFragment(), WeekView.EventClickListener, WeekLoader.We private val TYPE_THREE_DAY_VIEW = 2 private val TYPE_WEEK_VIEW = 3 + private val NEW_EVENT_CODE = 33 + /** * Use this factory method to create a new instance of * this fragment using the provided parameters. diff --git a/app/src/main/java/com/orsteg/harold/fragments/ResultFragment.kt b/app/src/main/java/com/orsteg/harold/fragments/ResultFragment.kt index 81db98d..0ca0323 100644 --- a/app/src/main/java/com/orsteg/harold/fragments/ResultFragment.kt +++ b/app/src/main/java/com/orsteg/harold/fragments/ResultFragment.kt @@ -313,6 +313,8 @@ class ResultFragment : BaseFragment() { if (levels.size != 0) { + semNav?.findViewById(R.id.nav)?.visibility = View.VISIBLE + val adapt1 = spinAdapt1(context!!, levels, num) @@ -368,6 +370,9 @@ class ResultFragment : BaseFragment() { val s = ArrayList() s.add("SEM") + semNav?.findViewById(R.id.nav)?.visibility = View.GONE + + spin1?.onItemSelectedListener = null spin2?.onItemSelectedListener = null spin1?.adapter = ArrayAdapter(context, android.R.layout.simple_spinner_dropdown_item, l) diff --git a/app/src/main/java/com/orsteg/harold/utils/result/FileHandler.kt b/app/src/main/java/com/orsteg/harold/utils/result/FileHandler.kt index a0bc9e9..1e6fcec 100644 --- a/app/src/main/java/com/orsteg/harold/utils/result/FileHandler.kt +++ b/app/src/main/java/com/orsteg/harold/utils/result/FileHandler.kt @@ -147,15 +147,10 @@ class FileHandler { } - if (targets.length() != 0) { - result.put("courses", targets) - result.put("validity", true) - result.put("message", "") - - } else { - result.put("validity", false) - result.put("message", "") - } + result.put("courses", targets) + result.put("validity", true) + result.put("message", "") + } catch (e: JSONException){ result.put("validity", false) result.put("message", "") diff --git a/app/src/main/res/layout/result_top_tool.xml b/app/src/main/res/layout/result_top_tool.xml index 70ded3e..d6e27ed 100644 --- a/app/src/main/res/layout/result_top_tool.xml +++ b/app/src/main/res/layout/result_top_tool.xml @@ -1,13 +1,18 @@ - + + - \ No newline at end of file + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3b6e71b..f7d1720 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,8 +1,8 @@ Harold - 1 + 2 - http://github.com/goody-h/harold + http://github.com/goody-h/Harold orsteg.apps@gmail.com ca-app-pub-2224977611625866~6153956063 diff --git a/app/src/main/res/xml/remote_config_defaults.xml b/app/src/main/res/xml/remote_config_defaults.xml index 54cee06..a5c109e 100644 --- a/app/src/main/res/xml/remote_config_defaults.xml +++ b/app/src/main/res/xml/remote_config_defaults.xml @@ -3,16 +3,16 @@ contact_info - Email: orsteg.apps@gmail.com||Github: github.com/goody-h/harold + Email: orsteg.apps@gmail.com||Github: github.com/goody-h/Harold help_site - http://goody-h.github.io/harold + http://goody-h.github.io/Harold version - 1 + 2