Skip to content

Commit

Permalink
Update library and Settings Activity
Browse files Browse the repository at this point in the history
  • Loading branch information
huikaihoo committed Aug 27, 2019
1 parent 6fa447d commit 99a6b1a
Show file tree
Hide file tree
Showing 15 changed files with 254 additions and 187 deletions.
116 changes: 116 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
implementation 'androidx.core:core:1.1.0-rc02'
implementation 'androidx.core:core-ktx:1.1.0-rc02'
implementation 'androidx.drawerlayout:drawerlayout:1.1.0-alpha02'
implementation 'androidx.drawerlayout:drawerlayout:1.1.0-alpha03'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.preference:preference:1.1.0-rc01'
implementation 'androidx.preference:preference-ktx:1.1.0-rc01'
Expand All @@ -111,14 +111,14 @@ dependencies {
implementation 'com.google.android.gms:play-services-oss-licenses:17.0.0'

// Firebase
implementation 'com.google.firebase:firebase-core:17.0.1'
implementation 'com.google.firebase:firebase-config:18.0.0'
implementation 'com.google.firebase:firebase-perf:18.0.1'
implementation 'com.google.firebase:firebase-core:17.1.0'
implementation 'com.google.firebase:firebase-config:19.0.0'
implementation 'com.google.firebase:firebase-perf:19.0.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'

// ViewModel + LiveData + Room + Paging
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
kapt 'androidx.lifecycle:lifecycle-compiler:2.0.0'
implementation "androidx.lifecycle:lifecycle-common-java8:2.0.0"
implementation 'androidx.room:room-runtime:2.1.0'
kapt 'androidx.room:room-compiler:2.1.0'
implementation 'androidx.paging:paging-runtime:2.1.0'
Expand Down Expand Up @@ -146,8 +146,8 @@ dependencies {
//implementation 'com.squareup.okhttp3:okhttp:3.12.1'

// Location Picker
//implementation ('com.schibstedspain.android:leku:6.2.1') {
implementation ('com.github.huikaihoo:leku:6.2.1-lite') {
//implementation('com.schibstedspain.android:leku:6.2.1') {
implementation('com.github.huikaihoo:leku:6.2.1-lite') {
exclude group: 'com.google.android.gms'
exclude group: 'androidx.appcompat'
}
Expand All @@ -156,12 +156,12 @@ dependencies {
implementation 'com.facebook.stetho:stetho:1.5.1'
implementation 'com.facebook.stetho:stetho-okhttp3:1.5.1'
debugImplementation 'com.facebook.flipper:flipper:0.23.4'
debugImplementation 'com.facebook.soloader:soloader:0.6.1'
debugImplementation 'com.facebook.soloader:soloader:0.7.0'
//releaseImplementation 'com.facebook.flipper:flipper-noop:0.23.4'
releaseImplementation ('com.github.huikaihoo:flipper-android-no-op:0.1.1') {
releaseImplementation('com.github.theGlenn:flipper-android-no-op:0.2.0') {
exclude group: 'com.squareup.okhttp3'
}
//debugImplementation 'com.amitshekhar.android:debug-db:1.0.4'
//debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'

// Unit Test
testImplementation 'androidx.arch.core:core-testing:2.1.0-rc01'
Expand Down
8 changes: 6 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" />

<uses-feature android:name="android.hardware.location.network" android:required="false" />
<uses-feature android:name="android.hardware.location.gps" android:required="false" />
<uses-feature
android:name="android.hardware.location.network"
android:required="false" />
<uses-feature
android:name="android.hardware.location.gps"
android:required="false" />

<application
android:name=".view.App"
Expand Down
30 changes: 0 additions & 30 deletions app/src/main/java/hoo/etahk/view/base/BasePrefFragment.kt
Original file line number Diff line number Diff line change
@@ -1,41 +1,11 @@
package hoo.etahk.view.base

import androidx.annotation.StringRes
import androidx.preference.CheckBoxPreference
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreference
import hoo.etahk.common.extensions.setSummary
import hoo.etahk.common.helper.SharedPrefsHelper

abstract class BasePrefFragment: PreferenceFragmentCompat() {

companion object {
/**
* A preference value change listener that updates the preference's summary
* to reflect its new value.
*/
private val bindSummaryOnPreferenceChangeListener =
Preference.OnPreferenceChangeListener { preference, newValue ->
preference?.setSummary(newValue)
true
}
}

fun findPreference(@StringRes resId: Int): Preference {
return super.findPreference(getString(resId))!!
}

fun bindPreferenceSummary(@StringRes resId: Int, onPreferenceChangeListener: Preference.OnPreferenceChangeListener = bindSummaryOnPreferenceChangeListener) {
val preference = findPreference(resId)
preference.onPreferenceChangeListener = onPreferenceChangeListener

// Trigger the listener immediately with the preference's
// current value.
if ( preference is SwitchPreference || preference is CheckBoxPreference ) {
preference.setSummary(SharedPrefsHelper.get<Boolean>(resId))
} else {
preference.setSummary(SharedPrefsHelper.get<String>(resId) as Any?)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,6 @@ class ParametersPrefFragment : BasePrefFragment() {
*/
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
addPreferencesFromResource(R.xml.pref_parameters)
setHasOptionsMenu(true)

// Bind the summaries of EditText/List/Dialog/Ringtone preferences
// to their values. When their values change, their summaries are
// updated to reflect the new value, per the Android Design
// guidelines.

// Firebase
bindPreferenceSummary(R.string.param_user_uuid)
bindPreferenceSummary(R.string.param_enable_remote_config)
// App
bindPreferenceSummary(R.string.param_app_mode)
bindPreferenceSummary(R.string.param_accepted_terms)
bindPreferenceSummary(R.string.param_paged_list_page_size)
// Feature
bindPreferenceSummary(R.string.param_enable_bus_list)
bindPreferenceSummary(R.string.param_enable_gmb_list)
bindPreferenceSummary(R.string.param_enable_tram_list)
bindPreferenceSummary(R.string.param_enable_mtr_list)
// Gist
bindPreferenceSummary(R.string.param_gist_id_kmb)
bindPreferenceSummary(R.string.param_gist_id_nwfb)
bindPreferenceSummary(R.string.param_gist_id_mtrb)
// OkHttp
bindPreferenceSummary(R.string.param_user_agent)
}

override fun onResume() {
Expand Down
Loading

0 comments on commit 99a6b1a

Please sign in to comment.