Skip to content

Commit

Permalink
Removed unused imports, removed TODO comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ElliotJHayes committed Dec 1, 2019
1 parent 9159f58 commit d719891
Show file tree
Hide file tree
Showing 18 changed files with 33 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import android.widget.RadioButton
import android.content.pm.PackageManager
import android.os.Build
import android.media.AudioManager
import android.os.Bundle;
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
Expand All @@ -18,7 +18,7 @@ import com.example.ContextAwareRinger.Data.*
import com.google.android.gms.awareness.fence.DetectedActivityFence


class ActivitiesActivity(private val volumeMap: MutableMap<String, Int>) : Fragment(){
class ActivitiesFragment(private val volumeMap: MutableMap<String, Int>) : Fragment(){

private val TAG = "ActivitiesActivity"
private val ACTIVITY_PERMISSION_REQUEST = 1
Expand Down Expand Up @@ -56,9 +56,7 @@ class ActivitiesActivity(private val volumeMap: MutableMap<String, Int>) : Fragm
}


//TODO: look into making this class a fragment
//TODO: Add plus button to UI
//TODO: Change listview to cardview

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
// Inflate the layout for this fragment
val rootView = inflater!!.inflate(R.layout.activity, container, false)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.example.ContextAwareRinger.Activities

import android.app.Activity
import android.app.NotificationManager
import android.content.Context
import android.content.Intent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.ContextAwareRinger.Activities;
package com.example.ContextAwareRinger.Activities

import android.app.Activity;
import android.media.AudioManager
Expand All @@ -18,8 +18,7 @@ import com.example.ContextAwareRinger.Data.HEADPHONES_IN
import com.example.ContextAwareRinger.Data.HEADPHONES_OUT
import com.example.ContextAwareRinger.Data.HeadphonesData

//TODO: look into making this class a fragment
class HeadphonesActivity(private val volumeMap : MutableMap<String, Int>) : Fragment() {
class HeadphonesFragment(private val volumeMap : MutableMap<String, Int>) : Fragment() {

private val TAG = "HeadphonesActivity"
lateinit var mHeadphonesDataList: MutableList<HeadphonesData>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import com.google.android.libraries.places.widget.model.AutocompleteActivityMode
import java.text.FieldPosition
import java.util.*

class LocationsActivity(private val volumeMap: MutableMap<String, Int>) : Fragment() {
class LocationsFragment(private val volumeMap: MutableMap<String, Int>) : Fragment() {

var TAG = "LocationActivity"
var floatingActionButton: FloatingActionButton? = null
Expand Down Expand Up @@ -132,7 +132,7 @@ class LocationsActivity(private val volumeMap: MutableMap<String, Int>) : Fragme

private fun showUpdateDeleteDialog(location: LocationData, position: Int){
Log.i(TAG,"Update or Delete location")
//TODO: Set the Update-Delete Dialog

mLat = location.lat
mLong = location.lng
mPlaceName = location.placeName
Expand Down Expand Up @@ -175,7 +175,7 @@ class LocationsActivity(private val volumeMap: MutableMap<String, Int>) : Fragme
processClick()
}

//TODO: Handle Update
// Handle Update
buttonUpdate.setOnClickListener {
val title = locationTitle?.text.toString().trim { it <= ' ' }

Expand Down Expand Up @@ -217,10 +217,10 @@ class LocationsActivity(private val volumeMap: MutableMap<String, Int>) : Fragme
)
} else {

//TODO: Store location data in the file system

Log.i(TAG, "submitting")
b.dismiss()
//TODO: Update the location
//Update the location
deleteLocation(location)
updateLocation(title, mPlaceName!!, radius, mLat!!, mLong!!, location.fenceKey, ringerMode, position)
}
Expand All @@ -233,10 +233,10 @@ class LocationsActivity(private val volumeMap: MutableMap<String, Int>) : Fragme
}
}

//TODO: Handle Delete
//Handle Delete
buttonDelete.setOnClickListener{
deleteLocation(location)
//TODO: close the dialog box
//close the dialog box
b.dismiss()
}
}
Expand Down Expand Up @@ -386,7 +386,7 @@ class LocationsActivity(private val volumeMap: MutableMap<String, Int>) : Fragme
volumeMap[fenceKey] = ringerMode
writeVolumeMap(context!!, volumeMap, VOLUME_MAP_FILENAME)

// TODO: Register the fence
// Register the fence
registerLocationFence(context!!,latitude,longitude,radius,fenceKey)

}
Expand Down Expand Up @@ -416,7 +416,7 @@ class LocationsActivity(private val volumeMap: MutableMap<String, Int>) : Fragme
volumeMap[fenceKey] = ringerMode
writeVolumeMap(context!!, volumeMap, VOLUME_MAP_FILENAME)

// TODO: Register the fence
//Register the fence
registerLocationFence(context!!,latitude,longitude,radius,fenceKey)
}

Expand All @@ -434,7 +434,7 @@ class LocationsActivity(private val volumeMap: MutableMap<String, Int>) : Fragme
volumeMap.remove(item.fenceKey)
writeVolumeMap(context!!, volumeMap, VOLUME_MAP_FILENAME)

//TODO: Unregister the Fence
//Unregister the Fence
unregisterFence(context!!,item.fenceKey)

// Doing adapter stuff here
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
package com.example.ContextAwareRinger.Activities

import android.content.Context
import android.media.AudioManager
import android.os.Bundle
import android.os.Environment
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.ViewModelProviders
import androidx.viewpager.widget.ViewPager
import com.example.ContextAwareRinger.*
import com.example.ContextAwareRinger.Data.ActivityData
import com.google.android.material.tabs.TabLayout
import kotlinx.android.synthetic.main.activity_main.*
import java.util.*

// Change UI to be loading screen that checks permissions
class MainActivity : FragmentActivity() {
var tabLayout: TabLayout? = null
val TAG = "MAIN_ACTIVITY"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import android.app.NotificationManager
import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import com.example.ContextAwareRinger.R
import android.content.Intent
import android.os.Build

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.example.ContextAwareRinger.Activities

import android.app.Dialog
import android.app.TimePickerDialog
import android.content.DialogInterface
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
Expand All @@ -12,7 +11,6 @@ import android.widget.*
import androidx.fragment.app.DialogFragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import com.example.ContextAwareRinger.Data.LocationData
import com.example.ContextAwareRinger.Data.TimeData
import java.util.*
import android.media.AudioManager
Expand Down Expand Up @@ -134,15 +132,13 @@ class TimeDialogFragment(var timeDataList : MutableList<TimeData>, var volumeMap

Log.i(TAG, "Time object created with Hour: " + hour + ", Minute: " + minute + ", Volume: " + selected!!.text + ", Interval: " + spinner.selectedItem.toString())

//TODO: Create list adapter stuff
val time = TimeData(hour!!, minute!!, repetitionInterval, workKey, ringerMode!!)
volumeMap[workKey] = ringerMode!!
writeVolumeMap(context!!, volumeMap, VOLUME_MAP_FILENAME)
timeDataList.add(time)
timeAdapter.add(time)
writeTimeDataList(context!!, timeDataList, TIME_LIST_FILENAME)

//TODO: Register Time Worker
enqueueTimeWorker(context!!, hour!!, minute!!, repetitionInterval, ringerMode!!, workKey)

//Close the dialog box
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.example.ContextAwareRinger.Data.TimeDataListAdapter
import com.example.ContextAwareRinger.Data.TimeData
import com.google.android.material.floatingactionbutton.FloatingActionButton

class TimeActivity() : Fragment() {
class TimeFragment() : Fragment() {
val TAG = "Time Activity"
var floatingActionButton : FloatingActionButton? = null
lateinit var timeDataList : MutableList<TimeData>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ class TimeUpdateDeleteDialogFragment(var timeDataList : MutableList<TimeData>, v
val radioGroup : RadioGroup = rootView.findViewById(R.id.volumeRadioGroupTime)
val spinner : Spinner = rootView.findViewById(R.id.timeSelectionSpinner)
timeButton = rootView.findViewById(R.id.startTimeButton)

//Initialize viewmodel and observe the time data
viewModel = ViewModelProviders.of(activity!!).get(TimeViewModel::class.java)
Log.i(TAG, "Oncreate called")

//TODO: Add code so that information is restored when update dialog box is started

var tempHr = (timeItem.hour%12).toString()
if(timeItem.hour%12 == 0){
tempHr = "12"
Expand All @@ -58,11 +59,6 @@ class TimeUpdateDeleteDialogFragment(var timeDataList : MutableList<TimeData>, v
}
timeButton.text = "Time Selected - " + tempHr + ":" + tempMn

/*this.hour = timeItem.hour!!
this.minute = timeItem.min!!
Log.i(TAG,"CHECKING IF HOUR WORKING" + this.hour.toString())
Log.i(TAG,"CHECKING IF MINUTE WORKING" + this.minute.toString())*/

when(timeItem.ringerMode){
AudioManager.RINGER_MODE_SILENT -> (rootView.findViewById(R.id.radioButtonUpdateDeleteTime) as RadioButton).isChecked = true
AudioManager.RINGER_MODE_VIBRATE -> (rootView.findViewById(R.id.radioButtonUpdateDeleteTime2) as RadioButton).isChecked = true
Expand Down Expand Up @@ -101,7 +97,7 @@ class TimeUpdateDeleteDialogFragment(var timeDataList : MutableList<TimeData>, v
val timeText : TextView = rootView.findViewById(R.id.startTimeButton)

//Check that appropriate values have been provided
if (hour != null && minute != null && hour != -1 && minute != 1) {
if (hour != null && minute != null && hour != -1 && minute != -1) {
var hourStr = ""

//Pad hour with a 0 if it is < 10
Expand Down Expand Up @@ -180,7 +176,7 @@ class TimeUpdateDeleteDialogFragment(var timeDataList : MutableList<TimeData>, v

Log.i(TAG, "Time object created with Hour: " + hour + ", Minute: " + minute + ", Volume: " + selected!!.text + ", Interval: " + spinner.selectedItem.toString())

//TODO: Delete the existing time object
//Delete the existing time object
timeDataList.remove(timeItem)
writeTimeDataList(context!!,timeDataList, TIME_LIST_FILENAME)

Expand All @@ -189,18 +185,18 @@ class TimeUpdateDeleteDialogFragment(var timeDataList : MutableList<TimeData>, v

timeAdapter.delete(timeItem)

//TODO: Unregister the Time Worker
//Unregister the Time Worker
removeTimeWorker(context!!, timeItem.workKey)

//TODO: Add the updated time object
//Add the updated time object
val time = TimeData(hour!!, minute!!, repetitionInterval, workKey, ringerMode!!)
volumeMap[workKey] = ringerMode!!
writeVolumeMap(context!!, volumeMap, VOLUME_MAP_FILENAME)
timeDataList.add(positionInView,time)
timeAdapter.add(time,positionInView)
writeTimeDataList(context!!, timeDataList, TIME_LIST_FILENAME)

//TODO: Register Time Worker
//Register Time Worker
enqueueTimeWorker(context!!, hour!!, minute!!, repetitionInterval, ringerMode!!, workKey)
}
else {
Expand All @@ -213,7 +209,7 @@ class TimeUpdateDeleteDialogFragment(var timeDataList : MutableList<TimeData>, v
}

deleteButton.setOnClickListener {
//TODO: Delete the item
//Delete the item
timeDataList.remove(timeItem)
writeTimeDataList(context!!,timeDataList, TIME_LIST_FILENAME)

Expand All @@ -222,20 +218,14 @@ class TimeUpdateDeleteDialogFragment(var timeDataList : MutableList<TimeData>, v

timeAdapter.delete(timeItem)

//TODO: Unregister the fence
//Unregister the fence
removeTimeWorker(context!!, timeItem.workKey)
dismiss()
}

return rootView
}

/*override fun onDetach() {
super.onDetach()
viewModel.hour.value = -1
viewModel.minute.value = -1
}*/



}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import android.widget.Toast
import com.example.ContextAwareRinger.Data.HEADPHONES_IN

class BootBroadcastReceiver : BroadcastReceiver() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
package com.example.ContextAwareRinger.Data

import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.location.Location
import android.view.LayoutInflater

import android.view.View
import android.view.ViewGroup
import android.widget.*
import com.example.ContextAwareRinger.Activities.LocationsActivity
import com.example.ContextAwareRinger.R
import org.w3c.dom.Text
import java.util.ArrayList

class LocationDataListAdapter (private val mContext: Context) : BaseAdapter() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.example.ContextAwareRinger.Data

import android.content.Context
import android.provider.CalendarContract
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ package com.example.ContextAwareRinger
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import com.example.ContextAwareRinger.Activities.ActivitiesActivity
import com.example.ContextAwareRinger.Activities.HeadphonesActivity
import com.example.ContextAwareRinger.Activities.LocationsActivity
import com.example.ContextAwareRinger.Activities.TimeActivity
import com.example.ContextAwareRinger.Activities.ActivitiesFragment
import com.example.ContextAwareRinger.Activities.HeadphonesFragment
import com.example.ContextAwareRinger.Activities.LocationsFragment
import com.example.ContextAwareRinger.Activities.TimeFragment

class TabAdapter(fm: FragmentManager, private val volumeMap: MutableMap<String, Int>) : FragmentPagerAdapter(fm) {

override fun getItem(position: Int): Fragment {
return when (position) {
0 -> {
TimeActivity()
TimeFragment()
}
1 -> LocationsActivity(volumeMap)
2-> ActivitiesActivity(volumeMap)
1 -> LocationsFragment(volumeMap)
2-> ActivitiesFragment(volumeMap)
else -> {
return HeadphonesActivity(volumeMap)
return HeadphonesFragment(volumeMap)
}
}
}
Expand Down
Loading

0 comments on commit d719891

Please sign in to comment.