forked from github/wulkanowy-mirror
Settings revamp (#1160)
This commit is contained in:
@ -52,7 +52,6 @@ class WulkanowyApp : Application(), Configuration.Provider {
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
FragmentManager.enableNewStateManager(false)
|
||||
|
||||
initializeAppLanguage()
|
||||
themeManager.applyDefaultTheme()
|
||||
initLogging()
|
||||
|
@ -18,26 +18,43 @@ class PreferencesRepository @Inject constructor(
|
||||
get() = getString(R.string.pref_key_start_menu, R.string.pref_default_startup).toInt()
|
||||
|
||||
val isShowPresent: Boolean
|
||||
get() = getBoolean(R.string.pref_key_attendance_present, R.bool.pref_default_attendance_present)
|
||||
get() = getBoolean(
|
||||
R.string.pref_key_attendance_present,
|
||||
R.bool.pref_default_attendance_present
|
||||
)
|
||||
|
||||
val gradeAverageMode: GradeAverageMode
|
||||
get() = GradeAverageMode.getByValue(getString(R.string.pref_key_grade_average_mode, R.string.pref_default_grade_average_mode))
|
||||
get() = GradeAverageMode.getByValue(
|
||||
getString(
|
||||
R.string.pref_key_grade_average_mode,
|
||||
R.string.pref_default_grade_average_mode
|
||||
)
|
||||
)
|
||||
|
||||
val gradeAverageForceCalc: Boolean
|
||||
get() = getBoolean(R.string.pref_key_grade_average_force_calc, R.bool.pref_default_grade_average_force_calc)
|
||||
get() = getBoolean(
|
||||
R.string.pref_key_grade_average_force_calc,
|
||||
R.bool.pref_default_grade_average_force_calc
|
||||
)
|
||||
|
||||
val isGradeExpandable: Boolean
|
||||
get() = !getBoolean(R.string.pref_key_expand_grade, R.bool.pref_default_expand_grade)
|
||||
|
||||
val showAllSubjectsOnStatisticsList: Boolean
|
||||
get() = getBoolean(R.string.pref_key_grade_statistics_list, R.bool.pref_default_grade_statistics_list)
|
||||
get() = getBoolean(
|
||||
R.string.pref_key_grade_statistics_list,
|
||||
R.bool.pref_default_grade_statistics_list
|
||||
)
|
||||
|
||||
val appThemeKey = context.getString(R.string.pref_key_app_theme)
|
||||
val appTheme: String
|
||||
get() = getString(appThemeKey, R.string.pref_default_app_theme)
|
||||
|
||||
val gradeColorTheme: String
|
||||
get() = getString(R.string.pref_key_grade_color_scheme, R.string.pref_default_grade_color_scheme)
|
||||
get() = getString(
|
||||
R.string.pref_key_grade_color_scheme,
|
||||
R.string.pref_default_grade_color_scheme
|
||||
)
|
||||
|
||||
val appLanguageKey = context.getString(R.string.pref_key_app_language)
|
||||
val appLanguage
|
||||
@ -55,50 +72,86 @@ class PreferencesRepository @Inject constructor(
|
||||
val isServicesOnlyWifi: Boolean
|
||||
get() = getBoolean(servicesOnlyWifiKey, R.bool.pref_default_services_wifi_only)
|
||||
|
||||
val notificationsEnableKey = context.getString(R.string.pref_key_notifications_enable)
|
||||
val isNotificationsEnable: Boolean
|
||||
get() = getBoolean(R.string.pref_key_notifications_enable, R.bool.pref_default_notifications_enable)
|
||||
get() = getBoolean(notificationsEnableKey, R.bool.pref_default_notifications_enable)
|
||||
|
||||
val isUpcomingLessonsNotificationsEnableKey = context.getString(R.string.pref_key_notifications_upcoming_lessons_enable)
|
||||
val isUpcomingLessonsNotificationsEnableKey =
|
||||
context.getString(R.string.pref_key_notifications_upcoming_lessons_enable)
|
||||
val isUpcomingLessonsNotificationsEnable: Boolean
|
||||
get() = getBoolean(isUpcomingLessonsNotificationsEnableKey, R.bool.pref_default_notification_upcoming_lessons_enable)
|
||||
get() = getBoolean(
|
||||
isUpcomingLessonsNotificationsEnableKey,
|
||||
R.bool.pref_default_notification_upcoming_lessons_enable
|
||||
)
|
||||
|
||||
val isDebugNotificationEnableKey = context.getString(R.string.pref_key_notification_debug)
|
||||
val isDebugNotificationEnable: Boolean
|
||||
get() = getBoolean(isDebugNotificationEnableKey, R.bool.pref_default_notification_debug)
|
||||
|
||||
val gradePlusModifier: Double
|
||||
get() = getString(R.string.pref_key_grade_modifier_plus, R.string.pref_default_grade_modifier_plus).toDouble()
|
||||
get() = getString(
|
||||
R.string.pref_key_grade_modifier_plus,
|
||||
R.string.pref_default_grade_modifier_plus
|
||||
).toDouble()
|
||||
|
||||
val gradeMinusModifier: Double
|
||||
get() = getString(R.string.pref_key_grade_modifier_minus, R.string.pref_default_grade_modifier_minus).toDouble()
|
||||
get() = getString(
|
||||
R.string.pref_key_grade_modifier_minus,
|
||||
R.string.pref_default_grade_modifier_minus
|
||||
).toDouble()
|
||||
|
||||
val fillMessageContent: Boolean
|
||||
get() = getBoolean(R.string.pref_key_fill_message_content, R.bool.pref_default_fill_message_content)
|
||||
get() = getBoolean(
|
||||
R.string.pref_key_fill_message_content,
|
||||
R.bool.pref_default_fill_message_content
|
||||
)
|
||||
|
||||
val showGroupsInPlan: Boolean
|
||||
get() = getBoolean(R.string.pref_key_timetable_show_groups, R.bool.pref_default_timetable_show_groups)
|
||||
get() = getBoolean(
|
||||
R.string.pref_key_timetable_show_groups,
|
||||
R.bool.pref_default_timetable_show_groups
|
||||
)
|
||||
|
||||
val showWholeClassPlan: String
|
||||
get() = getString(R.string.pref_key_timetable_show_whole_class, R.string.pref_default_timetable_show_whole_class)
|
||||
get() = getString(
|
||||
R.string.pref_key_timetable_show_whole_class,
|
||||
R.string.pref_default_timetable_show_whole_class
|
||||
)
|
||||
|
||||
val gradeSortingMode: GradeSortingMode
|
||||
get() = GradeSortingMode.getByValue(getString(R.string.pref_key_grade_sorting_mode, R.string.pref_default_grade_sorting_mode))
|
||||
get() = GradeSortingMode.getByValue(
|
||||
getString(
|
||||
R.string.pref_key_grade_sorting_mode,
|
||||
R.string.pref_default_grade_sorting_mode
|
||||
)
|
||||
)
|
||||
|
||||
val showTimetableTimers: Boolean
|
||||
get() = getBoolean(R.string.pref_key_timetable_show_timers, R.bool.pref_default_timetable_show_timers)
|
||||
get() = getBoolean(
|
||||
R.string.pref_key_timetable_show_timers,
|
||||
R.bool.pref_default_timetable_show_timers
|
||||
)
|
||||
|
||||
var isHomeworkFullscreen: Boolean
|
||||
get() = getBoolean(R.string.pref_key_homework_fullscreen, R.bool.pref_default_homework_fullscreen)
|
||||
get() = getBoolean(
|
||||
R.string.pref_key_homework_fullscreen,
|
||||
R.bool.pref_default_homework_fullscreen
|
||||
)
|
||||
set(value) = sharedPref.edit().putBoolean("homework_fullscreen", value).apply()
|
||||
|
||||
val showSubjectsWithoutGrades: Boolean
|
||||
get() = getBoolean(R.string.pref_key_subjects_without_grades, R.bool.pref_default_subjects_without_grades)
|
||||
get() = getBoolean(
|
||||
R.string.pref_key_subjects_without_grades,
|
||||
R.bool.pref_default_subjects_without_grades
|
||||
)
|
||||
|
||||
private fun getString(id: Int, default: Int) = getString(context.getString(id), default)
|
||||
|
||||
private fun getString(id: String, default: Int) = sharedPref.getString(id, context.getString(default)) ?: context.getString(default)
|
||||
private fun getString(id: String, default: Int) =
|
||||
sharedPref.getString(id, context.getString(default)) ?: context.getString(default)
|
||||
|
||||
private fun getBoolean(id: Int, default: Int) = getBoolean(context.getString(id), default)
|
||||
|
||||
private fun getBoolean(id: String, default: Int) = sharedPref.getBoolean(id, context.resources.getBoolean(default))
|
||||
private fun getBoolean(id: String, default: Int) =
|
||||
sharedPref.getBoolean(id, context.resources.getBoolean(default))
|
||||
}
|
||||
|
@ -15,12 +15,17 @@ import android.os.Build.VERSION_CODES.P
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.content.getSystemService
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.core.view.updateMargins
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.aurelhubert.ahbottomnavigation.AHBottomNavigation.TitleState.ALWAYS_SHOW
|
||||
import com.aurelhubert.ahbottomnavigation.AHBottomNavigationItem
|
||||
import com.google.android.material.elevation.ElevationOverlayProvider
|
||||
@ -55,7 +60,8 @@ import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainView {
|
||||
class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainView,
|
||||
PreferenceFragmentCompat.OnPreferenceStartFragmentCallback {
|
||||
|
||||
@Inject
|
||||
override lateinit var presenter: MainPresenter
|
||||
@ -245,12 +251,20 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
|
||||
with(navController) {
|
||||
setOnViewChangeListener { section, name ->
|
||||
if (section == MainView.Section.ACCOUNT || section == MainView.Section.STUDENT_INFO) {
|
||||
binding.mainBottomNav.visibility = View.GONE
|
||||
binding.mainBottomNav.isVisible = false
|
||||
binding.mainFragmentContainer.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
updateMargins(bottom = 0)
|
||||
}
|
||||
|
||||
if (appInfo.systemVersion >= P) {
|
||||
window.navigationBarColor = getThemeAttrColor(R.attr.colorSurface)
|
||||
}
|
||||
} else {
|
||||
binding.mainBottomNav.visibility = View.VISIBLE
|
||||
binding.mainBottomNav.isVisible = true
|
||||
binding.mainFragmentContainer.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
updateMargins(bottom = dpToPx(56f).toInt())
|
||||
}
|
||||
|
||||
if (appInfo.systemVersion >= P) {
|
||||
window.navigationBarColor =
|
||||
getThemeAttrColor(android.R.attr.navigationBarColor)
|
||||
@ -271,6 +285,16 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPreferenceStartFragment(
|
||||
caller: PreferenceFragmentCompat,
|
||||
pref: Preference
|
||||
): Boolean {
|
||||
val fragment =
|
||||
supportFragmentManager.fragmentFactory.instantiate(classLoader, pref.fragment)
|
||||
navController.pushFragment(fragment)
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return if (item.itemId == R.id.mainMenuAccount) presenter.onAccountManagerSelected()
|
||||
else false
|
||||
|
@ -63,9 +63,6 @@ class MoreFragment : BaseFragment<FragmentMoreBinding>(R.layout.fragment_more),
|
||||
override val settingsRes: Pair<String, Drawable?>?
|
||||
get() = context?.run { getString(R.string.settings_title) to getCompatDrawable(R.drawable.ic_more_settings) }
|
||||
|
||||
override val aboutRes: Pair<String, Drawable?>?
|
||||
get() = context?.run { getString(R.string.about_title) to getCompatDrawable(R.drawable.ic_all_about) }
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
binding = FragmentMoreBinding.bind(view)
|
||||
@ -124,10 +121,6 @@ class MoreFragment : BaseFragment<FragmentMoreBinding>(R.layout.fragment_more),
|
||||
(activity as? MainActivity)?.pushView(SettingsFragment.newInstance())
|
||||
}
|
||||
|
||||
override fun openAboutView() {
|
||||
(activity as? MainActivity)?.pushView(AboutFragment.newInstance())
|
||||
}
|
||||
|
||||
override fun popView(depth: Int) {
|
||||
(activity as? MainActivity)?.popView(depth)
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ class MorePresenter @Inject constructor(
|
||||
conferencesRes?.first -> openConferencesView()
|
||||
schoolAndTeachersRes?.first -> openSchoolAndTeachersView()
|
||||
settingsRes?.first -> openSettingsView()
|
||||
aboutRes?.first -> openAboutView()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -51,8 +50,7 @@ class MorePresenter @Inject constructor(
|
||||
mobileDevicesRes,
|
||||
conferencesRes,
|
||||
schoolAndTeachersRes,
|
||||
settingsRes,
|
||||
aboutRes
|
||||
settingsRes
|
||||
))
|
||||
}
|
||||
}
|
||||
|
@ -21,16 +21,12 @@ interface MoreView : BaseView {
|
||||
|
||||
val settingsRes: Pair<String, Drawable?>?
|
||||
|
||||
val aboutRes: Pair<String, Drawable?>?
|
||||
|
||||
fun initView()
|
||||
|
||||
fun updateData(data: List<Pair<String, Drawable?>>)
|
||||
|
||||
fun openSettingsView()
|
||||
|
||||
fun openAboutView()
|
||||
|
||||
fun popView(depth: Int)
|
||||
|
||||
fun openMessagesView()
|
||||
|
@ -1,153 +1,22 @@
|
||||
package io.github.wulkanowy.ui.modules.settings
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.thelittlefireman.appkillermanager.AppKillerManager
|
||||
import com.thelittlefireman.appkillermanager.exceptions.NoActionFoundException
|
||||
import com.yariksoffice.lingver.Lingver
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.ui.base.BaseActivity
|
||||
import io.github.wulkanowy.ui.base.ErrorDialog
|
||||
import io.github.wulkanowy.ui.modules.main.MainView
|
||||
import io.github.wulkanowy.utils.AppInfo
|
||||
import io.github.wulkanowy.utils.openInternetBrowser
|
||||
import javax.inject.Inject
|
||||
import timber.log.Timber
|
||||
|
||||
@AndroidEntryPoint
|
||||
class SettingsFragment : PreferenceFragmentCompat(),
|
||||
SharedPreferences.OnSharedPreferenceChangeListener,
|
||||
MainView.TitledView, SettingsView {
|
||||
|
||||
@Inject
|
||||
lateinit var presenter: SettingsPresenter
|
||||
|
||||
@Inject
|
||||
lateinit var appInfo: AppInfo
|
||||
|
||||
@Inject
|
||||
lateinit var lingver: Lingver
|
||||
class SettingsFragment : PreferenceFragmentCompat(), MainView.TitledView {
|
||||
|
||||
companion object {
|
||||
|
||||
fun newInstance() = SettingsFragment()
|
||||
}
|
||||
|
||||
override val titleStringId get() = R.string.settings_title
|
||||
|
||||
override val syncSuccessString get() = getString(R.string.pref_services_message_sync_success)
|
||||
|
||||
override val syncFailedString get() = getString(R.string.pref_services_message_sync_failed)
|
||||
|
||||
override fun initView() {
|
||||
findPreference<Preference>(getString(R.string.pref_key_services_force_sync))?.run {
|
||||
onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||
presenter.onSyncNowClicked()
|
||||
true
|
||||
}
|
||||
}
|
||||
findPreference<Preference>(getString(R.string.pref_key_notifications_fix_issues))?.run {
|
||||
isVisible =
|
||||
AppKillerManager.isDeviceSupported() && AppKillerManager.isAnyActionAvailable(
|
||||
requireContext()
|
||||
)
|
||||
setOnPreferenceClickListener {
|
||||
presenter.onFixSyncIssuesClicked()
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
presenter.onAttachView(this)
|
||||
}
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.scheme_preferences, rootKey)
|
||||
findPreference<Preference>(getString(R.string.pref_key_notification_debug))?.isVisible =
|
||||
appInfo.isDebug
|
||||
}
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
||||
presenter.onSharedPreferenceChanged(key)
|
||||
}
|
||||
|
||||
override fun recreateView() {
|
||||
activity?.recreate()
|
||||
}
|
||||
|
||||
override fun updateLanguage(langCode: String) {
|
||||
lingver.setLocale(requireContext(), langCode)
|
||||
}
|
||||
|
||||
override fun updateLanguageToFollowSystem() {
|
||||
lingver.setFollowSystemLocale(requireContext())
|
||||
}
|
||||
|
||||
override fun setServicesSuspended(serviceEnablesKey: String, isHolidays: Boolean) {
|
||||
findPreference<Preference>(serviceEnablesKey)?.run {
|
||||
summary = if (isHolidays) getString(R.string.pref_services_suspended) else ""
|
||||
isEnabled = !isHolidays
|
||||
}
|
||||
}
|
||||
|
||||
override fun setSyncInProgress(inProgress: Boolean) {
|
||||
if (activity == null || !isAdded) return
|
||||
|
||||
findPreference<Preference>(getString(R.string.pref_key_services_force_sync))?.run {
|
||||
isEnabled = !inProgress
|
||||
summary = if (inProgress) getString(R.string.pref_services_sync_in_progress) else ""
|
||||
}
|
||||
}
|
||||
|
||||
override fun showError(text: String, error: Throwable) {
|
||||
(activity as? BaseActivity<*, *>)?.showError(text, error)
|
||||
}
|
||||
|
||||
override fun showMessage(text: String) {
|
||||
(activity as? BaseActivity<*, *>)?.showMessage(text)
|
||||
}
|
||||
|
||||
override fun showExpiredDialog() {
|
||||
(activity as? BaseActivity<*, *>)?.showExpiredDialog()
|
||||
}
|
||||
|
||||
override fun openClearLoginView() {
|
||||
(activity as? BaseActivity<*, *>)?.openClearLoginView()
|
||||
}
|
||||
|
||||
override fun showErrorDetailsDialog(error: Throwable) {
|
||||
ErrorDialog.newInstance(error).show(childFragmentManager, error.toString())
|
||||
}
|
||||
|
||||
override fun showFixSyncDialog() {
|
||||
AlertDialog.Builder(requireContext())
|
||||
.setTitle(R.string.pref_notify_fix_sync_issues)
|
||||
.setMessage(R.string.pref_notify_fix_sync_issues_message)
|
||||
.setNegativeButton(android.R.string.cancel) { _, _ -> }
|
||||
.setPositiveButton(R.string.pref_notify_fix_sync_issues_settings_button) { _, _ ->
|
||||
try {
|
||||
AppKillerManager.doActionPowerSaving(requireContext())
|
||||
AppKillerManager.doActionAutoStart(requireContext())
|
||||
AppKillerManager.doActionNotification(requireContext())
|
||||
} catch (e: NoActionFoundException) {
|
||||
requireContext().openInternetBrowser("https://dontkillmyapp.com/${AppKillerManager.getDevice()?.manufacturer}", ::showMessage)
|
||||
}
|
||||
}
|
||||
.show()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
preferenceScreen.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
preferenceScreen.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
|
||||
Timber.i("Settings view was initialized")
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,78 @@
|
||||
package io.github.wulkanowy.ui.modules.settings.advanced
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.yariksoffice.lingver.Lingver
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.ui.base.BaseActivity
|
||||
import io.github.wulkanowy.ui.base.ErrorDialog
|
||||
import io.github.wulkanowy.ui.modules.main.MainView
|
||||
import io.github.wulkanowy.utils.AppInfo
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class AdvancedFragment : PreferenceFragmentCompat(),
|
||||
SharedPreferences.OnSharedPreferenceChangeListener,
|
||||
MainView.TitledView, AdvancedView {
|
||||
|
||||
@Inject
|
||||
lateinit var presenter: AdvancedPresenter
|
||||
|
||||
@Inject
|
||||
lateinit var appInfo: AppInfo
|
||||
|
||||
@Inject
|
||||
lateinit var lingver: Lingver
|
||||
|
||||
companion object {
|
||||
fun newInstance() = AdvancedFragment()
|
||||
}
|
||||
|
||||
override val titleStringId get() = R.string.pref_settings_advanced_title
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
presenter.onAttachView(this)
|
||||
}
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.scheme_preferences_advanced, rootKey)
|
||||
}
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
||||
presenter.onSharedPreferenceChanged(key)
|
||||
}
|
||||
|
||||
override fun showError(text: String, error: Throwable) {
|
||||
(activity as? BaseActivity<*, *>)?.showError(text, error)
|
||||
}
|
||||
|
||||
override fun showMessage(text: String) {
|
||||
(activity as? BaseActivity<*, *>)?.showMessage(text)
|
||||
}
|
||||
|
||||
override fun showExpiredDialog() {
|
||||
(activity as? BaseActivity<*, *>)?.showExpiredDialog()
|
||||
}
|
||||
|
||||
override fun openClearLoginView() {
|
||||
(activity as? BaseActivity<*, *>)?.openClearLoginView()
|
||||
}
|
||||
|
||||
override fun showErrorDetailsDialog(error: Throwable) {
|
||||
ErrorDialog.newInstance(error).show(childFragmentManager, error.toString())
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
preferenceScreen.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
preferenceScreen.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package io.github.wulkanowy.ui.modules.settings.advanced
|
||||
|
||||
import io.github.wulkanowy.data.repositories.StudentRepository
|
||||
import io.github.wulkanowy.ui.base.BasePresenter
|
||||
import io.github.wulkanowy.ui.base.ErrorHandler
|
||||
import io.github.wulkanowy.utils.AnalyticsHelper
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class AdvancedPresenter @Inject constructor(
|
||||
errorHandler: ErrorHandler,
|
||||
studentRepository: StudentRepository,
|
||||
private val analytics: AnalyticsHelper,
|
||||
) : BasePresenter<AdvancedView>(errorHandler, studentRepository) {
|
||||
|
||||
override fun onAttachView(view: AdvancedView) {
|
||||
super.onAttachView(view)
|
||||
Timber.i("Settings advanced view was initialized")
|
||||
}
|
||||
|
||||
fun onSharedPreferenceChanged(key: String) {
|
||||
Timber.i("Change settings $key")
|
||||
analytics.logEvent("setting_changed", "name" to key)
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package io.github.wulkanowy.ui.modules.settings.advanced
|
||||
|
||||
import io.github.wulkanowy.ui.base.BaseView
|
||||
|
||||
interface AdvancedView : BaseView {}
|
@ -0,0 +1,90 @@
|
||||
package io.github.wulkanowy.ui.modules.settings.appearance
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.yariksoffice.lingver.Lingver
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.ui.base.BaseActivity
|
||||
import io.github.wulkanowy.ui.base.ErrorDialog
|
||||
import io.github.wulkanowy.ui.modules.main.MainView
|
||||
import io.github.wulkanowy.utils.AppInfo
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class AppearanceFragment : PreferenceFragmentCompat(),
|
||||
SharedPreferences.OnSharedPreferenceChangeListener,
|
||||
MainView.TitledView, AppearanceView {
|
||||
|
||||
@Inject
|
||||
lateinit var presenter: AppearancePresenter
|
||||
|
||||
@Inject
|
||||
lateinit var appInfo: AppInfo
|
||||
|
||||
@Inject
|
||||
lateinit var lingver: Lingver
|
||||
|
||||
companion object {
|
||||
fun newInstance() = AppearanceFragment()
|
||||
}
|
||||
|
||||
override val titleStringId get() = R.string.pref_settings_appearance_title
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
presenter.onAttachView(this)
|
||||
}
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.scheme_preferences_appearance, rootKey)
|
||||
}
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
||||
presenter.onSharedPreferenceChanged(key)
|
||||
}
|
||||
|
||||
override fun recreateView() {
|
||||
activity?.recreate()
|
||||
}
|
||||
|
||||
override fun updateLanguage(langCode: String) {
|
||||
lingver.setLocale(requireContext(), langCode)
|
||||
}
|
||||
|
||||
override fun updateLanguageToFollowSystem() {
|
||||
lingver.setFollowSystemLocale(requireContext())
|
||||
}
|
||||
|
||||
override fun showError(text: String, error: Throwable) {
|
||||
(activity as? BaseActivity<*, *>)?.showError(text, error)
|
||||
}
|
||||
|
||||
override fun showMessage(text: String) {
|
||||
(activity as? BaseActivity<*, *>)?.showMessage(text)
|
||||
}
|
||||
|
||||
override fun showExpiredDialog() {
|
||||
(activity as? BaseActivity<*, *>)?.showExpiredDialog()
|
||||
}
|
||||
|
||||
override fun openClearLoginView() {
|
||||
(activity as? BaseActivity<*, *>)?.openClearLoginView()
|
||||
}
|
||||
|
||||
override fun showErrorDetailsDialog(error: Throwable) {
|
||||
ErrorDialog.newInstance(error).show(childFragmentManager, error.toString())
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
preferenceScreen.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
preferenceScreen.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package io.github.wulkanowy.ui.modules.settings.appearance
|
||||
|
||||
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
||||
import io.github.wulkanowy.data.repositories.StudentRepository
|
||||
import io.github.wulkanowy.ui.base.BasePresenter
|
||||
import io.github.wulkanowy.ui.base.ErrorHandler
|
||||
import io.github.wulkanowy.utils.AnalyticsHelper
|
||||
import io.github.wulkanowy.utils.AppInfo
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class AppearancePresenter @Inject constructor(
|
||||
errorHandler: ErrorHandler,
|
||||
studentRepository: StudentRepository,
|
||||
private val preferencesRepository: PreferencesRepository,
|
||||
private val analytics: AnalyticsHelper,
|
||||
private val appInfo: AppInfo
|
||||
) : BasePresenter<AppearanceView>(errorHandler, studentRepository) {
|
||||
|
||||
override fun onAttachView(view: AppearanceView) {
|
||||
super.onAttachView(view)
|
||||
Timber.i("Settings appearance view was initialized")
|
||||
}
|
||||
|
||||
fun onSharedPreferenceChanged(key: String) {
|
||||
Timber.i("Change settings $key")
|
||||
|
||||
preferencesRepository.apply {
|
||||
when (key) {
|
||||
appThemeKey -> view?.recreateView()
|
||||
appLanguageKey -> view?.run {
|
||||
if (appLanguage == "system") {
|
||||
updateLanguageToFollowSystem()
|
||||
analytics.logEvent("language", "setting_changed" to appInfo.systemLanguage)
|
||||
} else {
|
||||
updateLanguage(appLanguage)
|
||||
analytics.logEvent("language", "setting_changed" to appLanguage)
|
||||
}
|
||||
recreateView()
|
||||
}
|
||||
}
|
||||
}
|
||||
analytics.logEvent("setting_changed", "name" to key)
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package io.github.wulkanowy.ui.modules.settings.appearance
|
||||
|
||||
import io.github.wulkanowy.ui.base.BaseView
|
||||
|
||||
interface AppearanceView : BaseView {
|
||||
|
||||
fun recreateView()
|
||||
|
||||
fun updateLanguage(langCode: String)
|
||||
|
||||
fun updateLanguageToFollowSystem()
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
package io.github.wulkanowy.ui.modules.settings.notifications
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.thelittlefireman.appkillermanager.AppKillerManager
|
||||
import com.thelittlefireman.appkillermanager.exceptions.NoActionFoundException
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.ui.base.BaseActivity
|
||||
import io.github.wulkanowy.ui.base.ErrorDialog
|
||||
import io.github.wulkanowy.ui.modules.main.MainView
|
||||
import io.github.wulkanowy.utils.openInternetBrowser
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class NotificationsFragment : PreferenceFragmentCompat(),
|
||||
SharedPreferences.OnSharedPreferenceChangeListener,
|
||||
MainView.TitledView, NotificationsView {
|
||||
|
||||
@Inject
|
||||
lateinit var presenter: NotificationsPresenter
|
||||
|
||||
companion object {
|
||||
fun newInstance() = NotificationsFragment()
|
||||
}
|
||||
|
||||
override val titleStringId get() = R.string.pref_settings_notifications_title
|
||||
|
||||
override fun initView(showDebugNotificationSwitch: Boolean) {
|
||||
findPreference<Preference>(getString(R.string.pref_key_notification_debug))?.isVisible =
|
||||
showDebugNotificationSwitch
|
||||
|
||||
findPreference<Preference>(getString(R.string.pref_key_notifications_fix_issues))?.run {
|
||||
isVisible = AppKillerManager.isDeviceSupported()
|
||||
&& AppKillerManager.isAnyActionAvailable(requireContext())
|
||||
|
||||
setOnPreferenceClickListener {
|
||||
presenter.onFixSyncIssuesClicked()
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateRecyclerView(
|
||||
inflater: LayoutInflater?,
|
||||
parent: ViewGroup?,
|
||||
state: Bundle?
|
||||
): RecyclerView? = super.onCreateRecyclerView(inflater, parent, state)
|
||||
.also {
|
||||
it.itemAnimator = null
|
||||
it.layoutAnimation = null
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
presenter.onAttachView(this)
|
||||
}
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.scheme_preferences_notifications, rootKey)
|
||||
}
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
||||
presenter.onSharedPreferenceChanged(key)
|
||||
}
|
||||
|
||||
override fun enableNotification(notificationKey: String, enable: Boolean) {
|
||||
findPreference<Preference>(notificationKey)?.run {
|
||||
isEnabled = enable
|
||||
summary = if (enable) null else getString(R.string.pref_notify_disabled_summary)
|
||||
}
|
||||
}
|
||||
|
||||
override fun showError(text: String, error: Throwable) {
|
||||
(activity as? BaseActivity<*, *>)?.showError(text, error)
|
||||
}
|
||||
|
||||
override fun showMessage(text: String) {
|
||||
(activity as? BaseActivity<*, *>)?.showMessage(text)
|
||||
}
|
||||
|
||||
override fun showExpiredDialog() {
|
||||
(activity as? BaseActivity<*, *>)?.showExpiredDialog()
|
||||
}
|
||||
|
||||
override fun openClearLoginView() {
|
||||
(activity as? BaseActivity<*, *>)?.openClearLoginView()
|
||||
}
|
||||
|
||||
override fun showErrorDetailsDialog(error: Throwable) {
|
||||
ErrorDialog.newInstance(error).show(childFragmentManager, error.toString())
|
||||
}
|
||||
|
||||
override fun showFixSyncDialog() {
|
||||
AlertDialog.Builder(requireContext())
|
||||
.setTitle(R.string.pref_notify_fix_sync_issues)
|
||||
.setMessage(R.string.pref_notify_fix_sync_issues_message)
|
||||
.setNegativeButton(android.R.string.cancel) { _, _ -> }
|
||||
.setPositiveButton(R.string.pref_notify_fix_sync_issues_settings_button) { _, _ ->
|
||||
try {
|
||||
AppKillerManager.doActionPowerSaving(requireContext())
|
||||
AppKillerManager.doActionAutoStart(requireContext())
|
||||
AppKillerManager.doActionNotification(requireContext())
|
||||
} catch (e: NoActionFoundException) {
|
||||
requireContext().openInternetBrowser(
|
||||
"https://dontkillmyapp.com/${AppKillerManager.getDevice()?.manufacturer}",
|
||||
::showMessage
|
||||
)
|
||||
}
|
||||
}
|
||||
.show()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
preferenceScreen.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
preferenceScreen.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package io.github.wulkanowy.ui.modules.settings.notifications
|
||||
|
||||
import com.chuckerteam.chucker.api.ChuckerCollector
|
||||
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
||||
import io.github.wulkanowy.data.repositories.StudentRepository
|
||||
import io.github.wulkanowy.services.alarm.TimetableNotificationSchedulerHelper
|
||||
import io.github.wulkanowy.ui.base.BasePresenter
|
||||
import io.github.wulkanowy.ui.base.ErrorHandler
|
||||
import io.github.wulkanowy.utils.AnalyticsHelper
|
||||
import io.github.wulkanowy.utils.AppInfo
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class NotificationsPresenter @Inject constructor(
|
||||
errorHandler: ErrorHandler,
|
||||
studentRepository: StudentRepository,
|
||||
private val preferencesRepository: PreferencesRepository,
|
||||
private val timetableNotificationHelper: TimetableNotificationSchedulerHelper,
|
||||
private val appInfo: AppInfo,
|
||||
private val analytics: AnalyticsHelper,
|
||||
private val chuckerCollector: ChuckerCollector
|
||||
) : BasePresenter<NotificationsView>(errorHandler, studentRepository) {
|
||||
|
||||
override fun onAttachView(view: NotificationsView) {
|
||||
super.onAttachView(view)
|
||||
|
||||
with(view) {
|
||||
enableNotification(
|
||||
preferencesRepository.notificationsEnableKey,
|
||||
preferencesRepository.isServiceEnabled
|
||||
)
|
||||
initView(appInfo.isDebug)
|
||||
}
|
||||
Timber.i("Settings notifications view was initialized")
|
||||
}
|
||||
|
||||
fun onSharedPreferenceChanged(key: String) {
|
||||
Timber.i("Change settings $key")
|
||||
|
||||
preferencesRepository.apply {
|
||||
when (key) {
|
||||
isUpcomingLessonsNotificationsEnableKey -> {
|
||||
if (!isUpcomingLessonsNotificationsEnable) {
|
||||
timetableNotificationHelper.cancelNotification()
|
||||
}
|
||||
}
|
||||
isDebugNotificationEnableKey -> {
|
||||
chuckerCollector.showNotification = isDebugNotificationEnable
|
||||
}
|
||||
}
|
||||
}
|
||||
analytics.logEvent("setting_changed", "name" to key)
|
||||
}
|
||||
|
||||
fun onFixSyncIssuesClicked() {
|
||||
view?.showFixSyncDialog()
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package io.github.wulkanowy.ui.modules.settings.notifications
|
||||
|
||||
import io.github.wulkanowy.ui.base.BaseView
|
||||
|
||||
interface NotificationsView : BaseView {
|
||||
|
||||
fun initView(showDebugNotificationSwitch: Boolean)
|
||||
|
||||
fun showFixSyncDialog()
|
||||
|
||||
fun enableNotification(notificationKey: String, enable: Boolean)
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
package io.github.wulkanowy.ui.modules.settings.sync
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.ui.base.BaseActivity
|
||||
import io.github.wulkanowy.ui.base.ErrorDialog
|
||||
import io.github.wulkanowy.ui.modules.main.MainView
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class SyncFragment : PreferenceFragmentCompat(),
|
||||
SharedPreferences.OnSharedPreferenceChangeListener,
|
||||
MainView.TitledView, SyncView {
|
||||
|
||||
@Inject
|
||||
lateinit var presenter: SyncPresenter
|
||||
|
||||
companion object {
|
||||
fun newInstance() = SyncFragment()
|
||||
}
|
||||
|
||||
override val titleStringId get() = R.string.pref_settings_sync_title
|
||||
|
||||
override val syncSuccessString get() = getString(R.string.pref_services_message_sync_success)
|
||||
|
||||
override val syncFailedString get() = getString(R.string.pref_services_message_sync_failed)
|
||||
|
||||
override fun initView() {
|
||||
findPreference<Preference>(getString(R.string.pref_key_services_force_sync))?.run {
|
||||
onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||
presenter.onSyncNowClicked()
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
presenter.onAttachView(this)
|
||||
}
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.scheme_preferences_sync, rootKey)
|
||||
}
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
||||
presenter.onSharedPreferenceChanged(key)
|
||||
}
|
||||
|
||||
override fun setServicesSuspended(serviceEnablesKey: String, isHolidays: Boolean) {
|
||||
findPreference<Preference>(serviceEnablesKey)?.run {
|
||||
summary = if (isHolidays) getString(R.string.pref_services_suspended) else ""
|
||||
isEnabled = !isHolidays
|
||||
}
|
||||
}
|
||||
|
||||
override fun setSyncInProgress(inProgress: Boolean) {
|
||||
if (activity == null || !isAdded) return
|
||||
|
||||
findPreference<Preference>(getString(R.string.pref_key_services_force_sync))?.run {
|
||||
isEnabled = !inProgress
|
||||
summary = if (inProgress) getString(R.string.pref_services_sync_in_progress) else ""
|
||||
}
|
||||
}
|
||||
|
||||
override fun showError(text: String, error: Throwable) {
|
||||
(activity as? BaseActivity<*, *>)?.showError(text, error)
|
||||
}
|
||||
|
||||
override fun showMessage(text: String) {
|
||||
(activity as? BaseActivity<*, *>)?.showMessage(text)
|
||||
}
|
||||
|
||||
override fun showExpiredDialog() {
|
||||
(activity as? BaseActivity<*, *>)?.showExpiredDialog()
|
||||
}
|
||||
|
||||
override fun openClearLoginView() {
|
||||
(activity as? BaseActivity<*, *>)?.openClearLoginView()
|
||||
}
|
||||
|
||||
override fun showErrorDetailsDialog(error: Throwable) {
|
||||
ErrorDialog.newInstance(error).show(childFragmentManager, error.toString())
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
preferenceScreen.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
preferenceScreen.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
|
||||
}
|
||||
}
|
@ -1,15 +1,12 @@
|
||||
package io.github.wulkanowy.ui.modules.settings
|
||||
package io.github.wulkanowy.ui.modules.settings.sync
|
||||
|
||||
import androidx.work.WorkInfo
|
||||
import com.chuckerteam.chucker.api.ChuckerCollector
|
||||
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
||||
import io.github.wulkanowy.data.repositories.StudentRepository
|
||||
import io.github.wulkanowy.services.alarm.TimetableNotificationSchedulerHelper
|
||||
import io.github.wulkanowy.services.sync.SyncManager
|
||||
import io.github.wulkanowy.ui.base.BasePresenter
|
||||
import io.github.wulkanowy.ui.base.ErrorHandler
|
||||
import io.github.wulkanowy.utils.AnalyticsHelper
|
||||
import io.github.wulkanowy.utils.AppInfo
|
||||
import io.github.wulkanowy.utils.isHolidays
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
@ -17,20 +14,17 @@ import timber.log.Timber
|
||||
import java.time.LocalDate.now
|
||||
import javax.inject.Inject
|
||||
|
||||
class SettingsPresenter @Inject constructor(
|
||||
class SyncPresenter @Inject constructor(
|
||||
errorHandler: ErrorHandler,
|
||||
studentRepository: StudentRepository,
|
||||
private val preferencesRepository: PreferencesRepository,
|
||||
private val timetableNotificationHelper: TimetableNotificationSchedulerHelper,
|
||||
private val analytics: AnalyticsHelper,
|
||||
private val syncManager: SyncManager,
|
||||
private val chuckerCollector: ChuckerCollector,
|
||||
private val appInfo: AppInfo
|
||||
) : BasePresenter<SettingsView>(errorHandler, studentRepository) {
|
||||
) : BasePresenter<SyncView>(errorHandler, studentRepository) {
|
||||
|
||||
override fun onAttachView(view: SettingsView) {
|
||||
override fun onAttachView(view: SyncView) {
|
||||
super.onAttachView(view)
|
||||
Timber.i("Settings view was initialized")
|
||||
Timber.i("Settings sync view was initialized")
|
||||
view.setServicesSuspended(preferencesRepository.serviceEnableKey, now().isHolidays)
|
||||
view.initView()
|
||||
}
|
||||
@ -42,20 +36,6 @@ class SettingsPresenter @Inject constructor(
|
||||
when (key) {
|
||||
serviceEnableKey -> with(syncManager) { if (isServiceEnabled) startPeriodicSyncWorker() else stopSyncWorker() }
|
||||
servicesIntervalKey, servicesOnlyWifiKey -> syncManager.startPeriodicSyncWorker(true)
|
||||
isDebugNotificationEnableKey -> chuckerCollector.showNotification =
|
||||
isDebugNotificationEnable
|
||||
appThemeKey -> view?.recreateView()
|
||||
isUpcomingLessonsNotificationsEnableKey -> if (!isUpcomingLessonsNotificationsEnable) timetableNotificationHelper.cancelNotification()
|
||||
appLanguageKey -> view?.run {
|
||||
if (appLanguage == "system") {
|
||||
updateLanguageToFollowSystem()
|
||||
analytics.logEvent("language", "setting_changed" to appInfo.systemLanguage)
|
||||
} else {
|
||||
updateLanguage(appLanguage)
|
||||
analytics.logEvent("language", "setting_changed" to appLanguage)
|
||||
}
|
||||
recreateView()
|
||||
}
|
||||
}
|
||||
}
|
||||
analytics.logEvent("setting_changed", "name" to key)
|
||||
@ -89,8 +69,4 @@ class SettingsPresenter @Inject constructor(
|
||||
}.launch("sync")
|
||||
}
|
||||
}
|
||||
|
||||
fun onFixSyncIssuesClicked() {
|
||||
view?.showFixSyncDialog()
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package io.github.wulkanowy.ui.modules.settings
|
||||
package io.github.wulkanowy.ui.modules.settings.sync
|
||||
|
||||
import io.github.wulkanowy.ui.base.BaseView
|
||||
|
||||
interface SettingsView : BaseView {
|
||||
interface SyncView : BaseView {
|
||||
|
||||
val syncSuccessString: String
|
||||
|
||||
@ -10,15 +10,7 @@ interface SettingsView : BaseView {
|
||||
|
||||
fun initView()
|
||||
|
||||
fun recreateView()
|
||||
|
||||
fun updateLanguage(langCode: String)
|
||||
|
||||
fun updateLanguageToFollowSystem()
|
||||
|
||||
fun setServicesSuspended(serviceEnablesKey: String, isHolidays: Boolean)
|
||||
|
||||
fun setSyncInProgress(inProgress: Boolean)
|
||||
|
||||
fun showFixSyncDialog()
|
||||
}
|
Reference in New Issue
Block a user