forked from github/wulkanowy-mirror
Update dependencies (#474)
This commit is contained in:
parent
c60428e29b
commit
39fb4f5def
@ -28,7 +28,8 @@ android {
|
||||
]
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
|
||||
arguments = ["room.schemaLocation": "$projectDir/schemas".toString(),
|
||||
"room.incremental" : "true"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -86,6 +87,10 @@ android {
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
exclude 'META-INF/library_release.kotlin_module'
|
||||
exclude 'META-INF/library-core_release.kotlin_module'
|
||||
@ -105,7 +110,7 @@ play {
|
||||
|
||||
ext {
|
||||
work_manager = "2.2.0"
|
||||
room = "2.1.0"
|
||||
room = "2.2.0-beta01"
|
||||
dagger = "2.24"
|
||||
chucker = "2.0.4"
|
||||
mockk = "1.9.2"
|
||||
@ -114,35 +119,38 @@ ext {
|
||||
|
||||
configurations.all {
|
||||
resolutionStrategy.force "androidx.constraintlayout:constraintlayout:1.1.3"
|
||||
resolutionStrategy.force "com.google.android.material:material:1.1.0-alpha07"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "io.github.wulkanowy:api:0.9.4"
|
||||
implementation "io.github.wulkanowy:api:4b50c79"
|
||||
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
implementation "androidx.core:core:1.0.2"
|
||||
implementation "androidx.appcompat:appcompat:1.0.2"
|
||||
implementation "androidx.fragment:fragment:1.0.0"
|
||||
implementation "androidx.core:core-ktx:1.1.0-rc03"
|
||||
implementation "androidx.activity:activity-ktx:1.0.0-rc01"
|
||||
implementation "androidx.appcompat:appcompat:1.1.0-rc01"
|
||||
implementation "androidx.appcompat:appcompat-resources:1.1.0-rc01"
|
||||
implementation "androidx.fragment:fragment-ktx:1.1.0-rc04"
|
||||
implementation "androidx.annotation:annotation:1.1.0"
|
||||
implementation "androidx.multidex:multidex:2.0.1"
|
||||
|
||||
implementation "androidx.preference:preference:1.1.0-rc01"
|
||||
implementation "androidx.recyclerview:recyclerview:1.0.0"
|
||||
implementation "androidx.preference:preference-ktx:1.1.0-rc01"
|
||||
implementation "androidx.recyclerview:recyclerview:1.1.0-beta03"
|
||||
implementation "androidx.viewpager:viewpager:1.0.0"
|
||||
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
|
||||
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
|
||||
implementation "androidx.coordinatorlayout:coordinatorlayout:1.0.0"
|
||||
implementation "androidx.coordinatorlayout:coordinatorlayout:1.1.0-beta01"
|
||||
implementation "com.google.android.material:material:1.1.0-alpha07"
|
||||
implementation "com.github.wulkanowy:material-chips-input:2.0.1"
|
||||
implementation "com.github.PhilJay:MPAndroidChart:v3.1.0"
|
||||
implementation "me.zhanghai.android.materialprogressbar:library:1.6.1"
|
||||
|
||||
implementation "androidx.work:work-runtime:$work_manager"
|
||||
implementation "androidx.work:work-runtime-ktx:$work_manager"
|
||||
implementation "androidx.work:work-rxjava2:$work_manager"
|
||||
implementation "androidx.work:work-gcm:$work_manager"
|
||||
|
||||
implementation "androidx.room:room-runtime:$room"
|
||||
implementation "androidx.room:room-rxjava2:$room"
|
||||
implementation "androidx.room:room-ktx:$room"
|
||||
kapt "androidx.room:room-compiler:$room"
|
||||
|
||||
implementation "com.google.dagger:dagger-android-support:$dagger"
|
||||
|
@ -5,7 +5,7 @@ import androidx.room.Room
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import io.github.wulkanowy.data.db.AppDatabase
|
||||
import io.github.wulkanowy.data.db.SharedPrefHelper
|
||||
import io.github.wulkanowy.data.db.SharedPrefProvider
|
||||
import io.github.wulkanowy.data.db.entities.Student
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
@ -21,14 +21,14 @@ class StudentLocalTest {
|
||||
|
||||
private lateinit var testDb: AppDatabase
|
||||
|
||||
private lateinit var sharedHelper: SharedPrefHelper
|
||||
private lateinit var sharedProvider: SharedPrefProvider
|
||||
|
||||
@Before
|
||||
fun createDb() {
|
||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
testDb = Room.inMemoryDatabaseBuilder(context, AppDatabase::class.java)
|
||||
.build()
|
||||
sharedHelper = SharedPrefHelper(context.getSharedPreferences("TEST", Context.MODE_PRIVATE))
|
||||
sharedProvider = SharedPrefProvider(context.getSharedPreferences("TEST", Context.MODE_PRIVATE))
|
||||
studentLocal = StudentLocal(testDb.studentDao, context)
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ import android.util.Log.INFO
|
||||
import android.util.Log.VERBOSE
|
||||
import androidx.multidex.MultiDex
|
||||
import androidx.work.Configuration
|
||||
import androidx.work.WorkManager
|
||||
import com.jakewharton.threetenabp.AndroidThreeTen
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.support.DaggerApplication
|
||||
@ -25,7 +24,7 @@ import timber.log.Timber
|
||||
import java.io.IOException
|
||||
import javax.inject.Inject
|
||||
|
||||
class WulkanowyApp : DaggerApplication() {
|
||||
class WulkanowyApp : DaggerApplication(), Configuration.Provider {
|
||||
|
||||
@Inject
|
||||
lateinit var workerFactory: SyncWorkerFactory
|
||||
@ -47,19 +46,10 @@ class WulkanowyApp : DaggerApplication() {
|
||||
RxJavaPlugins.setErrorHandler(::onError)
|
||||
themeManager.applyDefaultTheme()
|
||||
|
||||
initWorkManager()
|
||||
initLogging()
|
||||
initCrashlytics(this, appInfo)
|
||||
}
|
||||
|
||||
private fun initWorkManager() {
|
||||
WorkManager.initialize(this,
|
||||
Configuration.Builder()
|
||||
.setWorkerFactory(workerFactory)
|
||||
.setMinimumLoggingLevel(if (appInfo.isDebug) VERBOSE else INFO)
|
||||
.build())
|
||||
}
|
||||
|
||||
private fun initLogging() {
|
||||
if (appInfo.isDebug) {
|
||||
Timber.plant(DebugLogTree())
|
||||
@ -81,4 +71,9 @@ class WulkanowyApp : DaggerApplication() {
|
||||
override fun applicationInjector(): AndroidInjector<out DaggerApplication> {
|
||||
return DaggerAppComponent.factory().create(this)
|
||||
}
|
||||
|
||||
override fun getWorkManagerConfiguration() = Configuration.Builder()
|
||||
.setWorkerFactory(workerFactory)
|
||||
.setMinimumLoggingLevel(if (appInfo.isDebug) VERBOSE else INFO)
|
||||
.build()
|
||||
}
|
||||
|
@ -1,18 +1,15 @@
|
||||
package io.github.wulkanowy.data.db
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.SharedPreferences
|
||||
import androidx.core.content.edit
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
@SuppressLint("ApplySharedPref")
|
||||
class SharedPrefHelper @Inject constructor(private val sharedPref: SharedPreferences) {
|
||||
class SharedPrefProvider @Inject constructor(private val sharedPref: SharedPreferences) {
|
||||
|
||||
fun putLong(key: String, value: Long, sync: Boolean = false) {
|
||||
sharedPref.edit().putLong(key, value).apply {
|
||||
if (sync) commit() else apply()
|
||||
}
|
||||
sharedPref.edit(sync) { putLong(key, value) }
|
||||
}
|
||||
|
||||
fun getLong(key: String, defaultValue: Long) = sharedPref.getLong(key, defaultValue)
|
@ -14,7 +14,7 @@ import javax.inject.Singleton
|
||||
AppModule::class,
|
||||
RepositoryModule::class,
|
||||
ServicesModule::class,
|
||||
BuilderModule::class])
|
||||
BindingModule::class])
|
||||
interface AppComponent : AndroidInjector<WulkanowyApp> {
|
||||
|
||||
@Component.Factory
|
||||
|
@ -16,7 +16,7 @@ import io.github.wulkanowy.ui.modules.timetablewidget.TimetableWidgetProvider
|
||||
|
||||
@Suppress("unused")
|
||||
@Module
|
||||
internal abstract class BuilderModule {
|
||||
internal abstract class BindingModule {
|
||||
|
||||
@PerActivity
|
||||
@ContributesAndroidInjector
|
@ -1,8 +1,6 @@
|
||||
package io.github.wulkanowy.services
|
||||
|
||||
import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import android.content.Context.NOTIFICATION_SERVICE
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import androidx.work.WorkManager
|
||||
import com.squareup.inject.assisted.dagger2.AssistedModule
|
||||
@ -38,17 +36,12 @@ abstract class ServicesModule {
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
fun provideWorkManager() = WorkManager.getInstance()
|
||||
fun provideWorkManager(context: Context) = WorkManager.getInstance(context)
|
||||
|
||||
@JvmStatic
|
||||
@Singleton
|
||||
@Provides
|
||||
fun provideNotificationManagerCompat(context: Context) = NotificationManagerCompat.from(context)
|
||||
|
||||
@JvmStatic
|
||||
@Singleton
|
||||
@Provides
|
||||
fun provideNotificationManager(context: Context) = context.getSystemService(NOTIFICATION_SERVICE) as NotificationManager
|
||||
fun provideNotificationManager(context: Context) = NotificationManagerCompat.from(context)
|
||||
}
|
||||
|
||||
@ContributesAndroidInjector
|
||||
|
@ -8,9 +8,9 @@ import androidx.work.ExistingPeriodicWorkPolicy.KEEP
|
||||
import androidx.work.ExistingPeriodicWorkPolicy.REPLACE
|
||||
import androidx.work.NetworkType.CONNECTED
|
||||
import androidx.work.NetworkType.UNMETERED
|
||||
import androidx.work.PeriodicWorkRequest
|
||||
import androidx.work.PeriodicWorkRequestBuilder
|
||||
import androidx.work.WorkManager
|
||||
import io.github.wulkanowy.data.db.SharedPrefHelper
|
||||
import io.github.wulkanowy.data.db.SharedPrefProvider
|
||||
import io.github.wulkanowy.data.repositories.preferences.PreferencesRepository
|
||||
import io.github.wulkanowy.services.sync.channels.DebugChannel
|
||||
import io.github.wulkanowy.services.sync.channels.NewEntriesChannel
|
||||
@ -26,14 +26,13 @@ import javax.inject.Singleton
|
||||
class SyncManager @Inject constructor(
|
||||
private val workManager: WorkManager,
|
||||
private val preferencesRepository: PreferencesRepository,
|
||||
sharedPrefHelper: SharedPrefHelper,
|
||||
sharedPrefProvider: SharedPrefProvider,
|
||||
newEntriesChannel: NewEntriesChannel,
|
||||
debugChannel: DebugChannel,
|
||||
appInfo: AppInfo
|
||||
) {
|
||||
|
||||
companion object {
|
||||
|
||||
private const val APP_VERSION_CODE_KEY = "app_version_code"
|
||||
}
|
||||
|
||||
@ -45,18 +44,18 @@ class SyncManager @Inject constructor(
|
||||
if (appInfo.isDebug) debugChannel.create()
|
||||
}
|
||||
|
||||
if (sharedPrefHelper.getLong(APP_VERSION_CODE_KEY, -1L) != appInfo.versionCode.toLong()) {
|
||||
if (sharedPrefProvider.getLong(APP_VERSION_CODE_KEY, -1L) != appInfo.versionCode.toLong()) {
|
||||
startSyncWorker(true)
|
||||
sharedPrefHelper.putLong(APP_VERSION_CODE_KEY, appInfo.versionCode.toLong(), true)
|
||||
sharedPrefProvider.putLong(APP_VERSION_CODE_KEY, appInfo.versionCode.toLong(), true)
|
||||
}
|
||||
|
||||
Timber.i("SyncManager was initialized")
|
||||
}
|
||||
|
||||
fun startSyncWorker(restart: Boolean = false) {
|
||||
if (preferencesRepository.isServiceEnabled && !now().isHolidays) {
|
||||
workManager.enqueueUniquePeriodicWork(SyncWorker::class.java.simpleName, if (restart) REPLACE else KEEP,
|
||||
PeriodicWorkRequest.Builder(SyncWorker::class.java, preferencesRepository.servicesInterval, MINUTES, 10, MINUTES)
|
||||
PeriodicWorkRequestBuilder<SyncWorker>(preferencesRepository.servicesInterval, MINUTES)
|
||||
.setInitialDelay(10, MINUTES)
|
||||
.setBackoffCriteria(EXPONENTIAL, 30, MINUTES)
|
||||
.setConstraints(Constraints.Builder()
|
||||
.setRequiredNetworkType(if (preferencesRepository.isServicesOnlyWifi) UNMETERED else CONNECTED)
|
||||
|
@ -3,15 +3,15 @@ package io.github.wulkanowy.services.sync.channels
|
||||
import android.annotation.TargetApi
|
||||
import android.app.Notification.VISIBILITY_PUBLIC
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.app.NotificationManager.IMPORTANCE_DEFAULT
|
||||
import android.content.Context
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import io.github.wulkanowy.R
|
||||
import javax.inject.Inject
|
||||
|
||||
@TargetApi(26)
|
||||
class DebugChannel @Inject constructor(
|
||||
private val notificationManager: NotificationManager,
|
||||
private val notificationManager: NotificationManagerCompat,
|
||||
private val context: Context
|
||||
) {
|
||||
|
||||
@ -21,8 +21,9 @@ class DebugChannel @Inject constructor(
|
||||
|
||||
fun create() {
|
||||
notificationManager.createNotificationChannel(
|
||||
NotificationChannel(CHANNEL_ID, context.getString(R.string.channel_debug), IMPORTANCE_DEFAULT).apply {
|
||||
lockscreenVisibility = VISIBILITY_PUBLIC
|
||||
})
|
||||
NotificationChannel(CHANNEL_ID, context.getString(R.string.channel_debug), IMPORTANCE_DEFAULT)
|
||||
.apply {
|
||||
lockscreenVisibility = VISIBILITY_PUBLIC
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -3,15 +3,15 @@ package io.github.wulkanowy.services.sync.channels
|
||||
import android.annotation.TargetApi
|
||||
import android.app.Notification.VISIBILITY_PUBLIC
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.app.NotificationManager.IMPORTANCE_HIGH
|
||||
import android.content.Context
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import io.github.wulkanowy.R
|
||||
import javax.inject.Inject
|
||||
|
||||
@TargetApi(26)
|
||||
class NewEntriesChannel @Inject constructor(
|
||||
private val notificationManager: NotificationManager,
|
||||
private val notificationManager: NotificationManagerCompat,
|
||||
private val context: Context
|
||||
) {
|
||||
|
||||
@ -21,10 +21,11 @@ class NewEntriesChannel @Inject constructor(
|
||||
|
||||
fun create() {
|
||||
notificationManager.createNotificationChannel(
|
||||
NotificationChannel(CHANNEL_ID, context.getString(R.string.channel_new_entries), IMPORTANCE_HIGH).apply {
|
||||
enableLights(true)
|
||||
enableVibration(true)
|
||||
lockscreenVisibility = VISIBILITY_PUBLIC
|
||||
})
|
||||
NotificationChannel(CHANNEL_ID, context.getString(R.string.channel_new_entries), IMPORTANCE_HIGH)
|
||||
.apply {
|
||||
enableLights(true)
|
||||
enableVibration(true)
|
||||
lockscreenVisibility = VISIBILITY_PUBLIC
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package io.github.wulkanowy.services.widgets
|
||||
import android.content.Intent
|
||||
import android.widget.RemoteViewsService
|
||||
import dagger.android.AndroidInjection
|
||||
import io.github.wulkanowy.data.db.SharedPrefHelper
|
||||
import io.github.wulkanowy.data.db.SharedPrefProvider
|
||||
import io.github.wulkanowy.data.repositories.semester.SemesterRepository
|
||||
import io.github.wulkanowy.data.repositories.student.StudentRepository
|
||||
import io.github.wulkanowy.data.repositories.timetable.TimetableRepository
|
||||
@ -23,7 +23,7 @@ class TimetableWidgetService : RemoteViewsService() {
|
||||
lateinit var semesterRepo: SemesterRepository
|
||||
|
||||
@Inject
|
||||
lateinit var sharedPref: SharedPrefHelper
|
||||
lateinit var sharedPref: SharedPrefProvider
|
||||
|
||||
@Inject
|
||||
lateinit var schedulers: SchedulersProvider
|
||||
|
@ -4,14 +4,15 @@ import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.fragment.app.FragmentPagerAdapter
|
||||
|
||||
class BaseFragmentPagerAdapter(private val fragmentManager: FragmentManager) : FragmentPagerAdapter(fragmentManager) {
|
||||
class BaseFragmentPagerAdapter(private val fragmentManager: FragmentManager) :
|
||||
FragmentPagerAdapter(fragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
|
||||
|
||||
private val pages = mutableMapOf<Fragment, String?>()
|
||||
|
||||
var containerId = 0
|
||||
|
||||
fun getFragmentInstance(position: Int): Fragment? {
|
||||
if (containerId == 0) throw IllegalArgumentException("Container id is 0")
|
||||
require(containerId != 0) { "Container id is 0" }
|
||||
return fragmentManager.findFragmentByTag("android:switcher:$containerId:$position")
|
||||
}
|
||||
|
||||
|
@ -2,13 +2,13 @@ package io.github.wulkanowy.ui.base
|
||||
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context.CLIPBOARD_SERVICE
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import android.widget.Toast.LENGTH_LONG
|
||||
import androidx.core.content.getSystemService
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import io.github.wulkanowy.R
|
||||
import kotlinx.android.synthetic.main.dialog_error.*
|
||||
@ -49,7 +49,7 @@ class ErrorDialog : DialogFragment() {
|
||||
errorDialogContent.text = writer.toString()
|
||||
errorDialogCopy.setOnClickListener {
|
||||
ClipData.newPlainText("wulkanowyError", writer.toString()).let { clip ->
|
||||
(activity?.getSystemService(CLIPBOARD_SERVICE) as? ClipboardManager)?.primaryClip = clip
|
||||
activity?.getSystemService<ClipboardManager>()?.primaryClip = clip
|
||||
}
|
||||
Toast.makeText(context, R.string.all_copied, LENGTH_LONG).show()
|
||||
}
|
||||
|
@ -7,8 +7,7 @@ import android.view.View.GONE
|
||||
import android.view.View.VISIBLE
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.core.text.HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||
import androidx.core.text.parseAsHtml
|
||||
import com.mikepenz.aboutlibraries.Libs
|
||||
import com.mikepenz.aboutlibraries.entity.Library
|
||||
import dagger.Lazy
|
||||
@ -69,7 +68,7 @@ class LicenseFragment : BaseFragment(), LicenseView, MainView.TitledView {
|
||||
context?.let {
|
||||
AlertDialog.Builder(it).apply {
|
||||
setTitle(R.string.license_dialog_title)
|
||||
setMessage(HtmlCompat.fromHtml(licenseHtml, FROM_HTML_MODE_LEGACY))
|
||||
setMessage(licenseHtml.parseAsHtml())
|
||||
setPositiveButton(android.R.string.ok) { _, _ -> }
|
||||
show()
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import android.view.ViewGroup
|
||||
import android.view.inputmethod.EditorInfo.IME_ACTION_DONE
|
||||
import android.view.inputmethod.EditorInfo.IME_NULL
|
||||
import android.widget.ArrayAdapter
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.data.db.entities.Student
|
||||
import io.github.wulkanowy.ui.base.BaseFragment
|
||||
@ -17,7 +18,6 @@ import io.github.wulkanowy.ui.modules.login.LoginActivity
|
||||
import io.github.wulkanowy.utils.AppInfo
|
||||
import io.github.wulkanowy.utils.hideSoftInput
|
||||
import io.github.wulkanowy.utils.openInternetBrowser
|
||||
import io.github.wulkanowy.utils.setOnTextChangedListener
|
||||
import io.github.wulkanowy.utils.showSoftInput
|
||||
import kotlinx.android.synthetic.main.fragment_login_form.*
|
||||
import javax.inject.Inject
|
||||
@ -60,8 +60,8 @@ class LoginFormFragment : BaseFragment(), LoginFormView {
|
||||
hostKeys = resources.getStringArray(R.array.endpoints_keys)
|
||||
hostValues = resources.getStringArray(R.array.endpoints_values)
|
||||
|
||||
loginFormName.setOnTextChangedListener { presenter.onNameTextChanged() }
|
||||
loginFormPass.setOnTextChangedListener { presenter.onPassTextChanged() }
|
||||
loginFormName.doOnTextChanged { _, _, _, _ -> presenter.onNameTextChanged() }
|
||||
loginFormPass.doOnTextChanged { _, _, _, _ -> presenter.onPassTextChanged() }
|
||||
loginFormHost.setOnItemClickListener { _, _, _, _ -> presenter.onHostSelected() }
|
||||
loginFormSignIn.setOnClickListener { presenter.onSignInClick() }
|
||||
loginFormPrivacyLink.setOnClickListener { presenter.onPrivacyLinkClick() }
|
||||
|
@ -9,12 +9,12 @@ import android.view.ViewGroup
|
||||
import android.view.inputmethod.EditorInfo.IME_ACTION_DONE
|
||||
import android.view.inputmethod.EditorInfo.IME_NULL
|
||||
import android.widget.ArrayAdapter
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.data.db.entities.Student
|
||||
import io.github.wulkanowy.ui.base.BaseFragment
|
||||
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
||||
import io.github.wulkanowy.utils.hideSoftInput
|
||||
import io.github.wulkanowy.utils.setOnTextChangedListener
|
||||
import io.github.wulkanowy.utils.showSoftInput
|
||||
import kotlinx.android.synthetic.main.fragment_login_symbol.*
|
||||
import javax.inject.Inject
|
||||
@ -45,7 +45,7 @@ class LoginSymbolFragment : BaseFragment(), LoginSymbolView {
|
||||
override fun initView() {
|
||||
loginSymbolSignIn.setOnClickListener { presenter.attemptLogin(loginSymbolName.text.toString()) }
|
||||
|
||||
loginSymbolName.setOnTextChangedListener { presenter.onSymbolTextChanged() }
|
||||
loginSymbolName.doOnTextChanged { _, _, _, _ -> presenter.onSymbolTextChanged() }
|
||||
|
||||
loginSymbolName.apply {
|
||||
setOnEditorActionListener { _, id, _ ->
|
||||
|
@ -1,7 +1,7 @@
|
||||
package io.github.wulkanowy.ui.modules.luckynumberwidget
|
||||
|
||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
||||
import io.github.wulkanowy.data.db.SharedPrefHelper
|
||||
import io.github.wulkanowy.data.db.SharedPrefProvider
|
||||
import io.github.wulkanowy.data.db.entities.Student
|
||||
import io.github.wulkanowy.data.repositories.student.StudentRepository
|
||||
import io.github.wulkanowy.ui.base.BasePresenter
|
||||
@ -14,7 +14,7 @@ class LuckyNumberWidgetConfigurePresenter @Inject constructor(
|
||||
schedulers: SchedulersProvider,
|
||||
errorHandler: ErrorHandler,
|
||||
studentRepository: StudentRepository,
|
||||
private val sharedPref: SharedPrefHelper
|
||||
private val sharedPref: SharedPrefProvider
|
||||
) : BasePresenter<LuckyNumberWidgetConfigureView>(errorHandler, studentRepository, schedulers) {
|
||||
|
||||
private var appWidgetId: Int? = null
|
||||
|
@ -21,7 +21,7 @@ import android.view.View.VISIBLE
|
||||
import android.widget.RemoteViews
|
||||
import dagger.android.AndroidInjection
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.data.db.SharedPrefHelper
|
||||
import io.github.wulkanowy.data.db.SharedPrefProvider
|
||||
import io.github.wulkanowy.data.db.entities.LuckyNumber
|
||||
import io.github.wulkanowy.data.repositories.luckynumber.LuckyNumberRepository
|
||||
import io.github.wulkanowy.data.repositories.semester.SemesterRepository
|
||||
@ -51,7 +51,7 @@ class LuckyNumberWidgetProvider : BroadcastReceiver() {
|
||||
lateinit var appWidgetManager: AppWidgetManager
|
||||
|
||||
@Inject
|
||||
lateinit var sharedPref: SharedPrefHelper
|
||||
lateinit var sharedPref: SharedPrefProvider
|
||||
|
||||
companion object {
|
||||
fun getStudentWidgetKey(appWidgetId: Int) = "lucky_number_widget_student_$appWidgetId"
|
||||
|
@ -1,7 +1,7 @@
|
||||
package io.github.wulkanowy.ui.modules.timetablewidget
|
||||
|
||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
||||
import io.github.wulkanowy.data.db.SharedPrefHelper
|
||||
import io.github.wulkanowy.data.db.SharedPrefProvider
|
||||
import io.github.wulkanowy.data.db.entities.Student
|
||||
import io.github.wulkanowy.data.repositories.student.StudentRepository
|
||||
import io.github.wulkanowy.ui.base.BasePresenter
|
||||
@ -14,7 +14,7 @@ class TimetableWidgetConfigurePresenter @Inject constructor(
|
||||
schedulers: SchedulersProvider,
|
||||
errorHandler: ErrorHandler,
|
||||
studentRepository: StudentRepository,
|
||||
private val sharedPref: SharedPrefHelper
|
||||
private val sharedPref: SharedPrefProvider
|
||||
) : BasePresenter<TimetableWidgetConfigureView>(errorHandler, studentRepository, schedulers) {
|
||||
|
||||
private var appWidgetId: Int? = null
|
||||
|
@ -11,7 +11,7 @@ import android.widget.AdapterView.INVALID_POSITION
|
||||
import android.widget.RemoteViews
|
||||
import android.widget.RemoteViewsService
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.data.db.SharedPrefHelper
|
||||
import io.github.wulkanowy.data.db.SharedPrefProvider
|
||||
import io.github.wulkanowy.data.db.entities.Timetable
|
||||
import io.github.wulkanowy.data.repositories.semester.SemesterRepository
|
||||
import io.github.wulkanowy.data.repositories.student.StudentRepository
|
||||
@ -28,7 +28,7 @@ class TimetableWidgetFactory(
|
||||
private val timetableRepository: TimetableRepository,
|
||||
private val studentRepository: StudentRepository,
|
||||
private val semesterRepository: SemesterRepository,
|
||||
private val sharedPref: SharedPrefHelper,
|
||||
private val sharedPref: SharedPrefProvider,
|
||||
private val schedulers: SchedulersProvider,
|
||||
private val context: Context,
|
||||
private val intent: Intent?
|
||||
|
@ -15,7 +15,7 @@ import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
import android.widget.RemoteViews
|
||||
import dagger.android.AndroidInjection
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.data.db.SharedPrefHelper
|
||||
import io.github.wulkanowy.data.db.SharedPrefProvider
|
||||
import io.github.wulkanowy.data.db.entities.Student
|
||||
import io.github.wulkanowy.data.repositories.student.StudentRepository
|
||||
import io.github.wulkanowy.services.widgets.TimetableWidgetService
|
||||
@ -43,7 +43,7 @@ class TimetableWidgetProvider : BroadcastReceiver() {
|
||||
lateinit var studentRepository: StudentRepository
|
||||
|
||||
@Inject
|
||||
lateinit var sharedPref: SharedPrefHelper
|
||||
lateinit var sharedPref: SharedPrefProvider
|
||||
|
||||
@Inject
|
||||
lateinit var schedulers: SchedulersProvider
|
||||
|
@ -1,17 +1,15 @@
|
||||
package io.github.wulkanowy.utils
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context.INPUT_METHOD_SERVICE
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import androidx.core.content.getSystemService
|
||||
|
||||
fun Activity.showSoftInput() {
|
||||
(getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager?)?.run {
|
||||
if (currentFocus != null) showSoftInput(currentFocus, 0)
|
||||
getSystemService<InputMethodManager>()?.let { manager ->
|
||||
currentFocus?.let { manager.showSoftInput(it, 0) }
|
||||
}
|
||||
}
|
||||
|
||||
fun Activity.hideSoftInput() {
|
||||
(getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager?)?.run {
|
||||
hideSoftInputFromWindow(window.decorView.applicationWindowToken, 0)
|
||||
}
|
||||
getSystemService<InputMethodManager>()?.hideSoftInputFromWindow(window.decorView.applicationWindowToken, 0)
|
||||
}
|
||||
|
@ -1,16 +0,0 @@
|
||||
package io.github.wulkanowy.utils
|
||||
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.widget.EditText
|
||||
|
||||
inline fun EditText.setOnTextChangedListener(crossinline listener: () -> Unit) {
|
||||
addTextChangedListener(object : TextWatcher {
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
listener()
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable?) {}
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
|
||||
})
|
||||
}
|
@ -13,6 +13,7 @@ android.enableJetifier=true
|
||||
android.useAndroidX=true
|
||||
android.enableR8=true
|
||||
org.gradle.jvmargs=-Xmx1536m
|
||||
kapt.incremental.apt=true
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
|
Loading…
x
Reference in New Issue
Block a user