From d71989105a35d6664550b3c6d4725b00b5d773c7 Mon Sep 17 00:00:00 2001 From: Elliot Date: Sun, 1 Dec 2019 18:23:53 -0500 Subject: [PATCH] Removed unused imports, removed TODO comments --- ...itiesActivity.kt => ActivitiesFragment.kt} | 8 ++-- .../Activities/DNDPermissionActivity.kt | 1 - ...honesActivity.kt => HeadphonesFragment.kt} | 5 +-- ...ationsActivity.kt => LocationsFragment.kt} | 20 ++++----- .../Activities/MainActivity.kt | 8 ---- .../Activities/SplashActivity.kt | 2 - .../Activities/TimeDialogFragment.kt | 4 -- .../{TimeActivity.kt => TimeFragment.kt} | 2 +- .../TimeUpdateDeleteDialogFragment.kt | 28 ++++--------- .../BootBroadcastReceiver.kt | 1 - .../Data/LocationDataListAdapter.kt | 5 --- .../Data/TimeDataListAdapter.kt | 1 - .../example/ContextAwareRinger/TabAdapter.kt | 16 +++---- .../com/example/ContextAwareRinger/Utils.kt | 42 ------------------- .../ContextAwareRinger/VolumeWorker.kt | 2 - .../app/src/main/res/layout/time_dialog.xml | 1 - .../res/layout/update_delete_time_dialog.xml | 1 - .../example/myapplication/ExampleUnitTest.kt | 13 ------ 18 files changed, 33 insertions(+), 127 deletions(-) rename ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/{ActivitiesActivity.kt => ActivitiesFragment.kt} (97%) rename ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/{HeadphonesActivity.kt => HeadphonesFragment.kt} (96%) rename ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/{LocationsActivity.kt => LocationsFragment.kt} (97%) rename ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/{TimeActivity.kt => TimeFragment.kt} (98%) delete mode 100644 ContextAwareRingerApp/app/src/test/java/com/example/myapplication/ExampleUnitTest.kt diff --git a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/ActivitiesActivity.kt b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/ActivitiesFragment.kt similarity index 97% rename from ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/ActivitiesActivity.kt rename to ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/ActivitiesFragment.kt index bc27b2a..2738849 100644 --- a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/ActivitiesActivity.kt +++ b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/ActivitiesFragment.kt @@ -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 @@ -18,7 +18,7 @@ import com.example.ContextAwareRinger.Data.* import com.google.android.gms.awareness.fence.DetectedActivityFence -class ActivitiesActivity(private val volumeMap: MutableMap) : Fragment(){ +class ActivitiesFragment(private val volumeMap: MutableMap) : Fragment(){ private val TAG = "ActivitiesActivity" private val ACTIVITY_PERMISSION_REQUEST = 1 @@ -56,9 +56,7 @@ class ActivitiesActivity(private val volumeMap: MutableMap) : 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) diff --git a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/DNDPermissionActivity.kt b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/DNDPermissionActivity.kt index 71825c5..711c8f5 100644 --- a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/DNDPermissionActivity.kt +++ b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/DNDPermissionActivity.kt @@ -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 diff --git a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/HeadphonesActivity.kt b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/HeadphonesFragment.kt similarity index 96% rename from ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/HeadphonesActivity.kt rename to ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/HeadphonesFragment.kt index 9e3c49f..70bb71e 100644 --- a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/HeadphonesActivity.kt +++ b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/HeadphonesFragment.kt @@ -1,4 +1,4 @@ -package com.example.ContextAwareRinger.Activities; +package com.example.ContextAwareRinger.Activities import android.app.Activity; import android.media.AudioManager @@ -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) : Fragment() { +class HeadphonesFragment(private val volumeMap : MutableMap) : Fragment() { private val TAG = "HeadphonesActivity" lateinit var mHeadphonesDataList: MutableList diff --git a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/LocationsActivity.kt b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/LocationsFragment.kt similarity index 97% rename from ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/LocationsActivity.kt rename to ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/LocationsFragment.kt index e836bc3..894e1a2 100644 --- a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/LocationsActivity.kt +++ b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/LocationsFragment.kt @@ -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) : Fragment() { +class LocationsFragment(private val volumeMap: MutableMap) : Fragment() { var TAG = "LocationActivity" var floatingActionButton: FloatingActionButton? = null @@ -132,7 +132,7 @@ class LocationsActivity(private val volumeMap: MutableMap) : 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 @@ -175,7 +175,7 @@ class LocationsActivity(private val volumeMap: MutableMap) : Fragme processClick() } - //TODO: Handle Update + // Handle Update buttonUpdate.setOnClickListener { val title = locationTitle?.text.toString().trim { it <= ' ' } @@ -217,10 +217,10 @@ class LocationsActivity(private val volumeMap: MutableMap) : 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) } @@ -233,10 +233,10 @@ class LocationsActivity(private val volumeMap: MutableMap) : Fragme } } - //TODO: Handle Delete + //Handle Delete buttonDelete.setOnClickListener{ deleteLocation(location) - //TODO: close the dialog box + //close the dialog box b.dismiss() } } @@ -386,7 +386,7 @@ class LocationsActivity(private val volumeMap: MutableMap) : Fragme volumeMap[fenceKey] = ringerMode writeVolumeMap(context!!, volumeMap, VOLUME_MAP_FILENAME) - // TODO: Register the fence + // Register the fence registerLocationFence(context!!,latitude,longitude,radius,fenceKey) } @@ -416,7 +416,7 @@ class LocationsActivity(private val volumeMap: MutableMap) : Fragme volumeMap[fenceKey] = ringerMode writeVolumeMap(context!!, volumeMap, VOLUME_MAP_FILENAME) - // TODO: Register the fence + //Register the fence registerLocationFence(context!!,latitude,longitude,radius,fenceKey) } @@ -434,7 +434,7 @@ class LocationsActivity(private val volumeMap: MutableMap) : 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 diff --git a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/MainActivity.kt b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/MainActivity.kt index 2d32b28..1ae507a 100644 --- a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/MainActivity.kt +++ b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/MainActivity.kt @@ -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" diff --git a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/SplashActivity.kt b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/SplashActivity.kt index 07cae16..c3556b8 100644 --- a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/SplashActivity.kt +++ b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/SplashActivity.kt @@ -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 diff --git a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/TimeDialogFragment.kt b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/TimeDialogFragment.kt index 56e6374..a07cc32 100644 --- a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/TimeDialogFragment.kt +++ b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/TimeDialogFragment.kt @@ -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 @@ -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 @@ -134,7 +132,6 @@ class TimeDialogFragment(var timeDataList : MutableList, 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) @@ -142,7 +139,6 @@ class TimeDialogFragment(var timeDataList : MutableList, var volumeMap timeAdapter.add(time) writeTimeDataList(context!!, timeDataList, TIME_LIST_FILENAME) - //TODO: Register Time Worker enqueueTimeWorker(context!!, hour!!, minute!!, repetitionInterval, ringerMode!!, workKey) //Close the dialog box diff --git a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/TimeActivity.kt b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/TimeFragment.kt similarity index 98% rename from ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/TimeActivity.kt rename to ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/TimeFragment.kt index 333f5b6..2e45125 100644 --- a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/TimeActivity.kt +++ b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/TimeFragment.kt @@ -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 diff --git a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/TimeUpdateDeleteDialogFragment.kt b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/TimeUpdateDeleteDialogFragment.kt index 5365637..98484b5 100644 --- a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/TimeUpdateDeleteDialogFragment.kt +++ b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Activities/TimeUpdateDeleteDialogFragment.kt @@ -40,11 +40,12 @@ class TimeUpdateDeleteDialogFragment(var timeDataList : MutableList, 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" @@ -58,11 +59,6 @@ class TimeUpdateDeleteDialogFragment(var timeDataList : MutableList, 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 @@ -101,7 +97,7 @@ class TimeUpdateDeleteDialogFragment(var timeDataList : MutableList, 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 @@ -180,7 +176,7 @@ class TimeUpdateDeleteDialogFragment(var timeDataList : MutableList, 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) @@ -189,10 +185,10 @@ class TimeUpdateDeleteDialogFragment(var timeDataList : MutableList, 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) @@ -200,7 +196,7 @@ class TimeUpdateDeleteDialogFragment(var timeDataList : MutableList, v 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 { @@ -213,7 +209,7 @@ class TimeUpdateDeleteDialogFragment(var timeDataList : MutableList, v } deleteButton.setOnClickListener { - //TODO: Delete the item + //Delete the item timeDataList.remove(timeItem) writeTimeDataList(context!!,timeDataList, TIME_LIST_FILENAME) @@ -222,7 +218,7 @@ class TimeUpdateDeleteDialogFragment(var timeDataList : MutableList, v timeAdapter.delete(timeItem) - //TODO: Unregister the fence + //Unregister the fence removeTimeWorker(context!!, timeItem.workKey) dismiss() } @@ -230,12 +226,6 @@ class TimeUpdateDeleteDialogFragment(var timeDataList : MutableList, v return rootView } - /*override fun onDetach() { - super.onDetach() - viewModel.hour.value = -1 - viewModel.minute.value = -1 - }*/ - } diff --git a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/BootBroadcastReceiver.kt b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/BootBroadcastReceiver.kt index 5105e32..f6d66aa 100644 --- a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/BootBroadcastReceiver.kt +++ b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/BootBroadcastReceiver.kt @@ -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() { diff --git a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Data/LocationDataListAdapter.kt b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Data/LocationDataListAdapter.kt index a4221f7..01f1263 100644 --- a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Data/LocationDataListAdapter.kt +++ b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Data/LocationDataListAdapter.kt @@ -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() { diff --git a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Data/TimeDataListAdapter.kt b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Data/TimeDataListAdapter.kt index ad254a5..49af361 100644 --- a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Data/TimeDataListAdapter.kt +++ b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Data/TimeDataListAdapter.kt @@ -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 diff --git a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/TabAdapter.kt b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/TabAdapter.kt index 1ead3d8..32ab9d3 100644 --- a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/TabAdapter.kt +++ b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/TabAdapter.kt @@ -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) : 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) } } } diff --git a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Utils.kt b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Utils.kt index a0b5102..4bb171c 100644 --- a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Utils.kt +++ b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/Utils.kt @@ -41,48 +41,6 @@ val TIME_LIST_FILENAME = "timeList.txt" val HEADPHONES_LIST_FILENAME = "headphonesList.txt" val ACTIVITY_LIST_FILENAME = "activityList.txt" -//Example usage of these functions, the following code will write an object to a file then read it back: -// val activityData = ActivityData(1, "test", 1) -// writeToFile(filesDir.toString() + "/out.tmp", activityData as Object) -// val data = readFromFile(filesDir.toString() + "/out.tmp") as ActivityData - -/*fun writeToFile(fileName: String?, obj: Object?) { - try { - // write object to file - val fileOut = FileOutputStream(fileName) - val objectOut = ObjectOutputStream(fileOut) - objectOut.writeObject(obj) - objectOut.close() - Log.i(TAG, "Finished writing to file") - - } catch (e: FileNotFoundException) { - e.printStackTrace() - } catch (e: IOException) { - e.printStackTrace() - } catch (e: ClassNotFoundException) { - e.printStackTrace() - } - -} - -fun readFromFile(fileName: String?): Any? { - try { - val fileInput = FileInputStream(fileName) - val objectInput = ObjectInputStream(fileInput) - val obj = objectInput.readObject() ?: return null - Log.i(TAG, "Finished reading from file, returning non null object") - return obj - - } catch (e: FileNotFoundException) { - e.printStackTrace() - } catch (e: IOException) { - e.printStackTrace() - } catch (e: ClassNotFoundException) { - e.printStackTrace() - } - return null -}*/ - private fun getPendingIntent(context: Context): PendingIntent { val intent = Intent(context, FenceBroadcastReceiver::class.java) intent.action = FENCE_RECEIVER_ACTION diff --git a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/VolumeWorker.kt b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/VolumeWorker.kt index bdd4a8d..8e6d041 100644 --- a/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/VolumeWorker.kt +++ b/ContextAwareRingerApp/app/src/main/java/com/example/ContextAwareRinger/VolumeWorker.kt @@ -4,8 +4,6 @@ import android.content.Context import android.media.AudioManager import android.util.Log import androidx.work.* -import java.util.* -import java.util.concurrent.TimeUnit class VolumeWorker(private val context: Context, private val params: WorkerParameters) : Worker(context, params) { diff --git a/ContextAwareRingerApp/app/src/main/res/layout/time_dialog.xml b/ContextAwareRingerApp/app/src/main/res/layout/time_dialog.xml index 901bcac..ac308dc 100644 --- a/ContextAwareRingerApp/app/src/main/res/layout/time_dialog.xml +++ b/ContextAwareRingerApp/app/src/main/res/layout/time_dialog.xml @@ -54,7 +54,6 @@ style="?android:attr/buttonBarButtonStyle" android:textColor="@color/primary_dark"/> - -