-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
49 changed files
with
777 additions
and
764 deletions.
There are no files selected for viewing
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
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
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
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
5 changes: 5 additions & 0 deletions
5
app/src/main/java/os/dtakac/feritraspored/common/assets/AssetProvider.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,5 @@ | ||
package os.dtakac.feritraspored.common.assets | ||
|
||
interface AssetProvider { | ||
suspend fun readFile(fileName: String): String | ||
} |
25 changes: 25 additions & 0 deletions
25
app/src/main/java/os/dtakac/feritraspored/common/assets/AssetProviderImpl.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,25 @@ | ||
package os.dtakac.feritraspored.common.assets | ||
|
||
import android.content.Context | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.withContext | ||
import java.util.* | ||
|
||
class AssetProviderImpl( | ||
private val applicationContext: Context | ||
) : AssetProvider { | ||
override suspend fun readFile(fileName: String): String { | ||
return withContext(Dispatchers.IO) { | ||
val stringBuilder = StringBuilder() | ||
|
||
@Suppress("BlockingMethodInNonBlockingContext") | ||
applicationContext.assets.open(fileName).use { | ||
val scanner = Scanner(it) | ||
while (scanner.hasNextLine()) { | ||
stringBuilder.append(scanner.nextLine()) | ||
} | ||
stringBuilder.toString() | ||
} | ||
} | ||
} | ||
} |
59 changes: 50 additions & 9 deletions
59
app/src/main/java/os/dtakac/feritraspored/common/constants/Constants.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 |
---|---|---|
@@ -1,11 +1,52 @@ | ||
package os.dtakac.feritraspored.common.constants | ||
|
||
const val DIALOG_WHATS_NEW = "whats_new" | ||
const val DIALOG_TIME_PICKER = "time_picker" | ||
const val DIALOG_FILTERS_HELP = "filters_help" | ||
const val DIALOG_COURSE_IDENTIFIER_HELP = "course_identifier_help" | ||
|
||
/** | ||
* Default click debounce interval in ms. | ||
*/ | ||
const val DEBOUNCE_INTERVAL = 300L | ||
import androidx.appcompat.app.AppCompatDelegate | ||
import os.dtakac.feritraspored.R | ||
|
||
const val DEBOUNCE_INTERVAL_MS = 300L | ||
const val SHOW_CHANGELOG = false | ||
|
||
object SharedPreferenceKeys { | ||
const val SKIP_SAT = "skip_saturday_key" | ||
const val SKIP_DAY = "skip_day_key" | ||
const val FILTERS = "group_highlight_key" | ||
const val PROGRAMME = "programme_key" | ||
const val YEAR = "year_key" | ||
const val TIME_PICKER = "timepicker_key" | ||
const val TIME_HOUR = "hour_key" | ||
const val TIME_MINUTE = "minute_key" | ||
const val SETTINGS_MODIFIED = "settings_modified" | ||
const val LOAD_ON_RESUME = "load_on_resume_key" | ||
const val FILTERS_TOGGLE = "group_toggle_key" | ||
const val FILTERS_HELP = "group_help_key" | ||
const val THEME = "prefkey_theme" | ||
const val CHANGELOG = "changelog_key" | ||
const val DEV_MESSAGE = "dev_msg_key" | ||
const val VERSION = "version_key" | ||
const val IDENTIFIER = "course_identifier" | ||
const val TIME_ON_BLOCKS = "key_time_on_blocks" | ||
const val IDENTIFIER_HELP = "course_identifier_help" | ||
const val SCHEDULE_LANG = "url_key" | ||
} | ||
|
||
object DialogKeys { | ||
const val WHATS_NEW = "whats_new" | ||
const val TIME_PICKER = "time_picker" | ||
const val FILTERS_HELP = "filters_help" | ||
const val COURSE_IDENTIFIER_HELP = "course_identifier_help" | ||
} | ||
|
||
val SCHEDULE_LANGUAGES = arrayOf( | ||
"https://www.ferit.unios.hr/studenti/raspored-nastave-i-ispita/%s/%s", | ||
"https://www.ferit.unios.hr/students/schedule-of-classes-and-exams/%s/%s" | ||
) | ||
|
||
val SUPPORT_EMAILS = arrayOf( | ||
"developer.takac@gmail.com" | ||
) | ||
|
||
val THEME_NAMES_TO_VALUES = linkedMapOf( | ||
R.string.theme_option_system to AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM, | ||
R.string.theme_option_light to AppCompatDelegate.MODE_NIGHT_NO, | ||
R.string.theme_option_dark to AppCompatDelegate.MODE_NIGHT_YES | ||
) |
6 changes: 0 additions & 6 deletions
6
app/src/main/java/os/dtakac/feritraspored/common/data/EmailEditorData.kt
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
app/src/main/java/os/dtakac/feritraspored/common/data/StringResourceWithArgs.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,18 @@ | ||
package os.dtakac.feritraspored.common.data | ||
|
||
import android.content.res.Resources | ||
import androidx.annotation.StringRes | ||
|
||
data class StringResourceWithArgs( | ||
@StringRes val content: Int, | ||
val args: List<String>? = null | ||
) { | ||
fun buildString(resources: Resources): String { | ||
val string = resources.getString(content) | ||
return if (!args.isNullOrEmpty()) { | ||
string.format(*args.toTypedArray()) | ||
} else { | ||
string | ||
} | ||
} | ||
} |
15 changes: 9 additions & 6 deletions
15
app/src/main/java/os/dtakac/feritraspored/common/di/AppModule.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 |
---|---|---|
@@ -1,16 +1,19 @@ | ||
package os.dtakac.feritraspored.common.di | ||
|
||
import android.content.SharedPreferences | ||
import androidx.preference.PreferenceManager | ||
import org.koin.android.ext.koin.androidContext | ||
import org.koin.dsl.module | ||
import os.dtakac.feritraspored.common.assets.AssetProvider | ||
import os.dtakac.feritraspored.common.assets.AssetProviderImpl | ||
import os.dtakac.feritraspored.common.network.NetworkChecker | ||
import os.dtakac.feritraspored.common.network.NetworkCheckerImpl | ||
import os.dtakac.feritraspored.common.preferences.PreferenceRepository | ||
import os.dtakac.feritraspored.common.preferences.PreferenceRepositoryImpl | ||
import os.dtakac.feritraspored.common.resources.ResourceRepository | ||
import os.dtakac.feritraspored.common.resources.ResourceRepositoryImpl | ||
|
||
val appModule = module { | ||
single<ResourceRepository>{ ResourceRepositoryImpl(androidContext()) } | ||
single<PreferenceRepository> { | ||
PreferenceRepositoryImpl(get(), PreferenceManager.getDefaultSharedPreferences(get())) | ||
} | ||
single<AssetProvider> { AssetProviderImpl(androidContext()) } | ||
single<NetworkChecker> { NetworkCheckerImpl(androidContext()) } | ||
single<SharedPreferences> { PreferenceManager.getDefaultSharedPreferences(get()) } | ||
single<PreferenceRepository> { PreferenceRepositoryImpl(get()) } | ||
} |
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
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
7 changes: 7 additions & 0 deletions
7
app/src/main/java/os/dtakac/feritraspored/common/extensions/DisplayMetrics.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,7 @@ | ||
package os.dtakac.feritraspored.common.extensions | ||
|
||
import android.util.DisplayMetrics | ||
import android.util.TypedValue | ||
|
||
fun DisplayMetrics.toPixels(dp: Float): Float = | ||
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, this) |
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
1 change: 0 additions & 1 deletion
1
app/src/main/java/os/dtakac/feritraspored/common/extensions/LocalDate.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
18 changes: 18 additions & 0 deletions
18
app/src/main/java/os/dtakac/feritraspored/common/extensions/LocalTime.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,18 @@ | ||
package os.dtakac.feritraspored.common.extensions | ||
|
||
import java.time.LocalTime | ||
import java.time.format.DateTimeFormatter | ||
|
||
private val TIME_FORMAT = DateTimeFormatter.ofPattern("HH:mm") | ||
|
||
fun LocalTime.timeFormat(): String = try { | ||
format(TIME_FORMAT) | ||
} catch (e: Exception) { | ||
"" | ||
} | ||
|
||
fun String.toLocalTime(): LocalTime = try { | ||
LocalTime.parse(this, TIME_FORMAT) | ||
} catch (e: Exception) { | ||
LocalTime.of(0, 0) | ||
} |
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
5 changes: 5 additions & 0 deletions
5
app/src/main/java/os/dtakac/feritraspored/common/network/NetworkChecker.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,5 @@ | ||
package os.dtakac.feritraspored.common.network | ||
|
||
interface NetworkChecker { | ||
val isOnline: Boolean | ||
} |
16 changes: 16 additions & 0 deletions
16
app/src/main/java/os/dtakac/feritraspored/common/network/NetworkCheckerImpl.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,16 @@ | ||
package os.dtakac.feritraspored.common.network | ||
|
||
import android.content.Context | ||
import android.net.ConnectivityManager | ||
|
||
class NetworkCheckerImpl( | ||
private val applicationContext: Context | ||
) : NetworkChecker { | ||
override val isOnline: Boolean | ||
get() { | ||
val connectivityManager = applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE) | ||
as? ConnectivityManager | ||
@Suppress("DEPRECATION") | ||
return connectivityManager?.activeNetworkInfo?.isConnectedOrConnecting == true | ||
} | ||
} |
Oops, something went wrong.