Skip to content

Commit

Permalink
refactor the code
Browse files Browse the repository at this point in the history
  • Loading branch information
eslamfaisal committed Sep 8, 2021
1 parent d8899be commit 6f8b255
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 29 deletions.
8 changes: 4 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
android:supportsRtl="true"
android:theme="@style/Theme.EfficientAlarm">
<activity
android:name=".MainActivity"
android:name=".ui.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -27,17 +27,17 @@
</intent-filter>
</activity>

<activity android:name=".AlarmActivity">
<activity android:name=".ui.AlarmActivity">

</activity>

<service
android:name=".AlarmsForegroundService"
android:name=".services.AlarmsForegroundService"
android:enabled="true"
android:exported="false" />

<receiver
android:name=".AlarmsReceiver"
android:name=".services.AlarmsReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.eslam.efficientalarm
package com.eslam.efficientalarm.listeners

interface OnDateSet {
fun pickedDate(year: Int, month: Int, day: Int)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.eslam.efficientalarm
package com.eslam.efficientalarm.listeners

interface OnTimeSet {
fun pickedTime(hoursOfDay: Int, minutes: Int)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.eslam.efficientalarm
package com.eslam.efficientalarm.model

import android.os.Parcelable
import androidx.annotation.Keep
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.eslam.efficientalarm
package com.eslam.efficientalarm.services

import android.app.Notification
import android.app.NotificationChannel
Expand All @@ -12,9 +12,13 @@ import android.os.IBinder
import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationCompat.PRIORITY_MIN
import com.eslam.efficientalarm.Constants.ALARM_DATA
import com.eslam.efficientalarm.Constants.OPEN_TYPE
import com.eslam.efficientalarm.Constants.REFRESH
import com.eslam.efficientalarm.model.AlarmData
import com.eslam.efficientalarm.R
import com.eslam.efficientalarm.ui.AlarmActivity
import com.eslam.efficientalarm.utils.Constants.ALARM_DATA
import com.eslam.efficientalarm.utils.Constants.OPEN_TYPE
import com.eslam.efficientalarm.utils.Constants.REFRESH
import com.eslam.efficientalarm.utils.scheduleAlarm
import com.google.gson.Gson
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers.IO
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.eslam.efficientalarm
package com.eslam.efficientalarm.services

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.eslam.efficientalarm.Constants.BOOT_COMPLETED
import com.eslam.efficientalarm.Constants.FIRE_ALARM
import com.eslam.efficientalarm.Constants.OPEN_TYPE
import com.eslam.efficientalarm.Constants.REFRESH
import com.eslam.efficientalarm.Constants.alarm_id
import com.eslam.efficientalarm.utils.Constants.BOOT_COMPLETED
import com.eslam.efficientalarm.utils.Constants.FIRE_ALARM
import com.eslam.efficientalarm.utils.Constants.OPEN_TYPE
import com.eslam.efficientalarm.utils.Constants.REFRESH
import com.eslam.efficientalarm.utils.Constants.alarm_id

class AlarmsReceiver : BroadcastReceiver() {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.eslam.efficientalarm
package com.eslam.efficientalarm.ui

import android.content.Context
import android.os.Bundle
import android.os.PowerManager
import android.view.WindowManager
import androidx.appcompat.app.AppCompatActivity
import com.eslam.efficientalarm.AlarmData
import com.eslam.efficientalarm.Constants
import com.eslam.efficientalarm.NotificationHelper.cancelNotification
import com.eslam.efficientalarm.NotificationHelper.runNotification
import com.eslam.efficientalarm.model.AlarmData
import com.eslam.efficientalarm.utils.Constants
import com.eslam.efficientalarm.utils.NotificationHelper.cancelNotification
import com.eslam.efficientalarm.utils.NotificationHelper.runNotification
import com.eslam.efficientalarm.R
import kotlinx.android.synthetic.main.activity_alarm.*
import java.util.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.eslam.efficientalarm
package com.eslam.efficientalarm.ui

import android.app.DatePickerDialog
import android.app.Dialog
import android.os.Bundle
import android.widget.DatePicker
import androidx.fragment.app.DialogFragment
import com.eslam.efficientalarm.listeners.OnDateSet
import java.util.*

class DatePickerFragment constructor(val dateListener: OnDateSet) : DialogFragment(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.eslam.efficientalarm
package com.eslam.efficientalarm.ui

import android.Manifest
import android.content.Context
Expand All @@ -17,6 +17,11 @@ import androidx.annotation.RequiresApi
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import com.eslam.efficientalarm.model.AlarmData
import com.eslam.efficientalarm.R
import com.eslam.efficientalarm.listeners.OnDateSet
import com.eslam.efficientalarm.listeners.OnTimeSet
import com.eslam.efficientalarm.utils.scheduleAlarm
import com.google.gson.Gson
import kotlinx.android.synthetic.main.activity_main.*
import java.util.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.eslam.efficientalarm
package com.eslam.efficientalarm.ui

import android.app.Dialog
import android.app.TimePickerDialog
import android.os.Bundle
import android.widget.TimePicker
import androidx.fragment.app.DialogFragment
import com.eslam.efficientalarm.listeners.OnTimeSet
import java.util.*

class TimePickerFragment constructor(val timeListener: OnTimeSet? = null) : DialogFragment(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.eslam.efficientalarm
package com.eslam.efficientalarm.utils

import android.app.AlarmManager
import android.app.PendingIntent
Expand All @@ -9,7 +9,9 @@ import android.content.Intent
import android.content.pm.PackageManager
import android.os.Build
import android.util.Log
import com.eslam.efficientalarm.Constants.alarm_id
import com.eslam.efficientalarm.model.AlarmData
import com.eslam.efficientalarm.services.AlarmsReceiver
import com.eslam.efficientalarm.utils.Constants.alarm_id
import java.util.*
import java.util.concurrent.TimeUnit

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.eslam.efficientalarm
package com.eslam.efficientalarm.utils

object Constants {
const val alarm_id = "alarm_id"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.eslam.efficientalarm
package com.eslam.efficientalarm.utils

import android.app.Notification
import android.app.NotificationChannel
Expand All @@ -9,6 +9,8 @@ import android.content.Intent
import android.media.RingtoneManager
import android.os.Build
import androidx.core.app.NotificationCompat
import com.eslam.efficientalarm.R
import com.eslam.efficientalarm.ui.MainActivity

object NotificationHelper {
private var NotificationID = 1005
Expand Down

0 comments on commit 6f8b255

Please sign in to comment.