This repository has been archived by the owner on Oct 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Converted three util classes to Kotlin (#2399)
* converted three util classes to kotlin * converted util classes to kotlin * format AuthUtil * fixed authorisation to be nullable
- Loading branch information
1 parent
e2c3001
commit 6c7560f
Showing
6 changed files
with
286 additions
and
296 deletions.
There are no files selected for viewing
106 changes: 0 additions & 106 deletions
106
android/app/src/main/java/org/fossasia/openevent/common/ConstantStrings.java
This file was deleted.
Oops, something went wrong.
106 changes: 106 additions & 0 deletions
106
android/app/src/main/java/org/fossasia/openevent/common/ConstantStrings.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package org.fossasia.openevent.common | ||
|
||
object ConstantStrings { | ||
|
||
const val TOKEN = "token" | ||
|
||
const val USER_EMAIL = "user_email" | ||
|
||
const val USER_FIRST_NAME = "user_first_name" | ||
|
||
const val USER_LAST_NAME = "user_last_name" | ||
|
||
const val TRACK = "TRACK" | ||
|
||
const val TRACK_ID = "TRACK_ID" | ||
|
||
const val SESSION = "SESSION" | ||
|
||
const val SESSION_TIMING = "SESSION_TIMING" | ||
|
||
const val EMAIL = "EMAIL" | ||
|
||
const val APP_NAME = "APP_NAME" | ||
|
||
const val IS_AUTH_ENABLED = "is_auth_enabled" | ||
|
||
const val EVENT_ID = "eventId" | ||
|
||
const val ORG_DESCRIPTION = "organizer_description" | ||
|
||
const val TIMEZONE = "timezone" | ||
|
||
const val BASE_API_URL = "BASE_API_URL" | ||
|
||
const val ID = "ID" | ||
|
||
const val YOUTUBE = "youtu.be" | ||
|
||
const val YOUTUBE_URI_1 = "http://img.youtube.com/vi/" | ||
|
||
const val YOUTUBE_URI_2 = "/0.jpg" | ||
|
||
const val EVENT_DAY = "EVENT_DAY" | ||
|
||
const val SPEAKERS = "speakers" | ||
|
||
const val SESSIONS = "sessions" | ||
|
||
const val TRACKS = "tracks" | ||
|
||
const val SESSION_TYPES = "session_types" | ||
|
||
const val FEED = "feed" | ||
|
||
const val VERSION = "version" | ||
|
||
const val EventDates = "eventDates" | ||
|
||
const val MICROLOCATIONS = "microlocations" | ||
|
||
const val SPONSORS = "sponsors" | ||
|
||
const val EVENT = "event" | ||
|
||
const val DATABASE_RECORDS_EXIST = "database_records_exist" | ||
|
||
const val IS_DOWNLOAD_DONE = "isDownloadDone" | ||
|
||
const val IS_MAP_FRAGMENT_FROM_MAIN_ACTIVITY = "isMapFragmenFromMainActivity" | ||
|
||
const val LOCATION_NAME = "locationName" | ||
|
||
const val SESSION_MAP_ID = "sessionMapId" | ||
|
||
const val IMAGE_ZOOM_KEY = "imageZoom" | ||
|
||
//Sort order | ||
|
||
const val PREF_SORT_SCHEDULE = "schedule_sort_type" | ||
|
||
const val PREF_SORT_SPEAKER = "speaker_sort_type" | ||
|
||
const val PREF_SORT_ORDER = "sort_order" | ||
|
||
const val FACEBOOK_PAGE_ID = "pageId" | ||
|
||
const val FACEBOOK_PAGE_NAME = "fbPageName" | ||
|
||
const val TWITTER_PAGE_NAME = "twitterPageName" | ||
|
||
const val FACEBOOK_COMMENTS = "comments" | ||
|
||
//Social link names | ||
|
||
const val SOCIAL_LINK_GITHUB = "GitHub" | ||
|
||
const val SOCIAL_LINK_TWITTER = "Twitter" | ||
|
||
const val SOCIAL_LINK_FACEBOOK = "Facebook" | ||
|
||
const val SOCIAL_LINK_LINKEDIN = "LinkedIn" | ||
|
||
const val SOCIAL_LINK_YOUTUBE = "YouTube" | ||
|
||
const val SOCIAL_LINK_GOOGLE = "Google" | ||
} |
57 changes: 0 additions & 57 deletions
57
android/app/src/main/java/org/fossasia/openevent/common/notification/NotificationUtil.java
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
android/app/src/main/java/org/fossasia/openevent/common/notification/NotificationUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.fossasia.openevent.common.notification | ||
|
||
import android.app.AlarmManager | ||
import android.app.PendingIntent | ||
import android.content.Context | ||
import android.content.Intent | ||
|
||
import org.fossasia.openevent.common.ConstantStrings | ||
import org.fossasia.openevent.common.date.DateConverter | ||
import org.fossasia.openevent.data.Session | ||
import org.fossasia.openevent.common.utils.SharedPreferencesUtil | ||
import org.threeten.bp.ZonedDateTime | ||
|
||
import io.reactivex.Completable | ||
import timber.log.Timber | ||
|
||
object NotificationUtil { | ||
|
||
private fun onSuccess(session: Session) { | ||
Timber.d("Created notification for Session ${session.id} ${session.title} at time ${session.startsAt}") | ||
} | ||
|
||
private fun onError(throwable: Throwable, session: Session) { | ||
Timber.e(throwable) | ||
Timber.e("Error creating Date for Session ${session.id} ${session.title} at time ${session.startsAt}") | ||
} | ||
|
||
@JvmStatic | ||
fun createNotification(session: Session, context: Context): Completable { | ||
return Completable.fromAction { | ||
val zonedDateTime = DateConverter.getDate(session.startsAt) | ||
|
||
val prefResult = Integer.parseInt(SharedPreferencesUtil.getString("notification", "10 mins")?.substring(0, 2)?.trim { it <= ' ' }) | ||
when (prefResult) { | ||
1 -> zonedDateTime.minusHours(-1) | ||
12 -> zonedDateTime.minusHours(12) | ||
else -> zonedDateTime.minusMinutes(10) | ||
} | ||
// Checking if the event time is after the current time | ||
if (zonedDateTime.isAfter(ZonedDateTime.now())) { | ||
val myIntent = Intent(context, NotificationAlarmReceiver::class.java) | ||
myIntent.putExtra(ConstantStrings.SESSION, session.id) | ||
val pendingIntent = PendingIntent.getBroadcast(context, 0, myIntent, PendingIntent.FLAG_UPDATE_CURRENT) | ||
|
||
val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager | ||
alarmManager.set(AlarmManager.RTC, zonedDateTime.toInstant().toEpochMilli(), pendingIntent) | ||
} else { | ||
Timber.d("Session is finished. Skipping showing notification") | ||
} | ||
}.doOnComplete { onSuccess(session) }.doOnError { throwable -> onError(throwable, session) } | ||
} | ||
} |
Oops, something went wrong.