Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
goody-h committed May 17, 2018
1 parent 47424da commit d4fbb7c
Show file tree
Hide file tree
Showing 14 changed files with 120 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions .idea/scopes/scope_settings.xml

This file was deleted.

11 changes: 3 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -47,17 +47,12 @@ 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'

}








apply plugin: 'com.google.gms.google-services'
8 changes: 8 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<application
android:allowBackup="true"
android:fullBackupContent="true"
android:icon="@mipmap/icon_filled"
android:label="@string/app_name"
android:roundIcon="@mipmap/icon_filled"
Expand All @@ -23,6 +24,13 @@
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />

<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data
android:host="harold.apps.orsteg.com"
android:scheme="https"/>
</intent-filter>
</activity>
<activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ class MainActivity : AppCompatActivity(), BaseFragment.OnFragmentInteractionList
}
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
}

override fun onBackPressed() {

if (mFragmentManager?.onBackPresses(actionBtn!!) == true)
Expand Down
13 changes: 10 additions & 3 deletions app/src/main/java/com/orsteg/harold/activities/NewEventActivity.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.orsteg.harold.activities

import android.app.Activity
import android.app.TimePickerDialog
import android.content.Context
import android.content.Intent
Expand Down Expand Up @@ -126,9 +127,14 @@ class NewEventActivity : AppCompatActivity() {
ok?.setOnClickListener {
val count = Event.eventCount(this, Day)

val t = Event(context, 0, time[2] as Int, Day,count + 1, venue?.text.toString(), Start, end)
val t = Event(context, 0, time[2] as Int , Day,count + 1, venue?.text.toString(), Start, end)
t.addEvent()
setAlarm(t)

val result = Intent()
result.putExtra(Event.DAY_INDEX, Nday)
result.putExtra(Event.START_TIME, Start)
setResult(Activity.RESULT_OK, result)
finish()
}

Expand Down Expand Up @@ -235,7 +241,8 @@ class NewEventActivity : AppCompatActivity() {

code?.adapter = adapt1

code?.setSelection(select)
if (select != -1) code?.setSelection(select)
else code?.setSelection(adapt1!!.count - 2)
}

private fun initiateTime() {
Expand Down Expand Up @@ -285,7 +292,7 @@ class NewEventActivity : AppCompatActivity() {
private fun addNew(currSem: Int) {

AddDialog(this, currSem, true, true){_, _, _ ->
initCourseList(adapt1?.count!! - 2)
initCourseList(-1)
}.show()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<View>(R.id.details) as ListView).adapter as ListAdapter).items[2].value = `in`
runOnUiThread {
setLastUpdate()
((findViewById<View>(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
Expand Down Expand Up @@ -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<View>(R.id.details) as ListView).adapter as ListAdapter).items[3].value = d
runOnUiThread {
setLastUpdate()
((findViewById<View>(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
Expand Down
10 changes: 4 additions & 6 deletions app/src/main/java/com/orsteg/harold/activities/SignUpActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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)
Expand Down
30 changes: 29 additions & 1 deletion app/src/main/java/com/orsteg/harold/fragments/EventFragment.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ class ResultFragment : BaseFragment() {

if (levels.size != 0) {

semNav?.findViewById<View>(R.id.nav)?.visibility = View.VISIBLE

val adapt1 = spinAdapt1(context!!, levels, num)


Expand Down Expand Up @@ -368,6 +370,9 @@ class ResultFragment : BaseFragment() {
val s = ArrayList<String>()
s.add("SEM")

semNav?.findViewById<View>(R.id.nav)?.visibility = View.GONE


spin1?.onItemSelectedListener = null
spin2?.onItemSelectedListener = null
spin1?.adapter = ArrayAdapter(context, android.R.layout.simple_spinner_dropdown_item, l)
Expand Down
13 changes: 4 additions & 9 deletions app/src/main/java/com/orsteg/harold/utils/result/FileHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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", "")
Expand Down
13 changes: 10 additions & 3 deletions app/src/main/res/layout/result_top_tool.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingLeft="90dp"
android:paddingRight="50dp"
app:layout_scrollFlags="scroll|enterAlways|snap">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/nav"
android:orientation="horizontal">

<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -49,4 +54,6 @@

</android.support.v7.widget.CardView>

</LinearLayout>
</LinearLayout>

</FrameLayout>
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<resources>
<string name="app_name">Harold</string>
<string name="version">1</string>
<string name="version">2</string>

<string name="github_repo">http://github.com/goody-h/harold</string>
<string name="github_repo">http://github.com/goody-h/Harold</string>
<string name="email">[email protected]</string>

<string name="admob_app_id">ca-app-pub-2224977611625866~6153956063</string>
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/xml/remote_config_defaults.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
<defaultsMap>
<entry>
<key>contact_info</key>
<value>Email: [email protected]||Github: github.com/goody-h/harold</value>
<value>Email: [email protected]||Github: github.com/goody-h/Harold</value>
</entry>
<entry>
<key>help_site</key>
<value>http://goody-h.github.io/harold</value>
<value>http://goody-h.github.io/Harold</value>
</entry>

<entry>
<key>version</key>
<value>1</value>
<value>2</value>
</entry>

</defaultsMap>
Expand Down

0 comments on commit d4fbb7c

Please sign in to comment.