-
Notifications
You must be signed in to change notification settings - Fork 2
new user preferences e.g. dark mode, language, currency #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4535ed5
chore: remove unused code at LegacyNavigation.startBreadActivity
andhikayuana 0449554
chore: remove unused file
andhikayuana 4323daa
chore: remove TODO at PasscodeKeypad
andhikayuana bdbcc11
chore: move hardcoded strings to strings.xml
andhikayuana bfd1ae6
chore: update translations strings.xml files
andhikayuana f8ec938
chore: adjust coloring for buy tab related
andhikayuana 96f9f06
chore: adjust tint logo for UnLockScreen
andhikayuana eb955f6
Rename .java to .kt
andhikayuana 69e60e9
feat: wip app setting for user preferences e.g. dark mode, language, …
andhikayuana 7cc56e9
feat: implement functionality for change language, change fiat currency
andhikayuana acbfd39
feat: implement functionality for change dark mode inside SettingsAct…
andhikayuana b774c16
fix: fix currency by iso null from sqlite
andhikayuana f668807
fix: change from breadContext to applicationContext at BreadActivity.…
andhikayuana File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,156 @@ | ||
| package com.brainwallet | ||
|
|
||
| import android.annotation.SuppressLint | ||
| import android.app.Activity | ||
| import android.app.Application | ||
| import android.content.Context | ||
| import android.content.res.Resources | ||
| import com.appsflyer.AppsFlyerLib | ||
| import com.brainwallet.di.Module | ||
| import com.brainwallet.notification.setupNotificationChannels | ||
| import com.brainwallet.presenter.activities.util.BRActivity | ||
| import com.brainwallet.presenter.entities.ServiceItems | ||
| import com.brainwallet.tools.listeners.SyncReceiver | ||
| import com.brainwallet.tools.manager.AnalyticsManager | ||
| import com.brainwallet.tools.util.BRConstants | ||
| import com.brainwallet.tools.util.Utils | ||
| import com.brainwallet.util.cryptography.KeyStoreKeyGenerator | ||
| import com.brainwallet.util.cryptography.KeyStoreManager | ||
| import com.google.firebase.crashlytics.FirebaseCrashlytics | ||
| import timber.log.Timber | ||
| import timber.log.Timber.DebugTree | ||
| import java.util.Timer | ||
| import java.util.TimerTask | ||
| import java.util.concurrent.atomic.AtomicInteger | ||
|
|
||
| class BrainwalletApp : Application() { | ||
|
|
||
| override fun onCreate() { | ||
| super.onCreate() | ||
|
|
||
| /** DEV: Top placement requirement. */ | ||
| val enableCrashlytics = !Utils.isEmulatorOrDebug(this) | ||
| FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(enableCrashlytics) | ||
|
|
||
| initializeModule() | ||
|
|
||
| setupNotificationChannels(this) | ||
|
|
||
| AnalyticsManager.init(this) | ||
| AnalyticsManager.logCustomEvent(BRConstants._20191105_AL) | ||
|
|
||
| if (BuildConfig.DEBUG) Timber.plant(DebugTree()) | ||
|
|
||
| // DEV: uncomment for debugging | ||
| // FirebaseMessaging.getInstance() | ||
| // .getToken() | ||
| // .addOnSuccessListener(new OnSuccessListener<String>() { | ||
| // @Override | ||
| // public void onSuccess(String s) { | ||
| // Timber.d("timber: fcm getToken= %s", s); | ||
| // } | ||
| // }) | ||
| // .addOnFailureListener(new OnFailureListener() { | ||
| // @Override | ||
| // public void onFailure(@NonNull Exception e) { | ||
| // Timber.d(e, "timber: fcm getToken failure"); | ||
| // } | ||
| // }); | ||
| if (BuildConfig.DEBUG) Timber.plant(DebugTree()) | ||
| DISPLAY_HEIGHT_PX = Resources.getSystem().displayMetrics.heightPixels | ||
|
|
||
| val afID = Utils.fetchServiceItem(this, ServiceItems.AFDEVID) | ||
| val appsFlyerLib = AppsFlyerLib.getInstance() | ||
| appsFlyerLib.init(afID, null, this) | ||
| appsFlyerLib.setDebugLog(BuildConfig.DEBUG) | ||
| appsFlyerLib.setCollectAndroidID(true) | ||
| appsFlyerLib.start(this) | ||
| } | ||
|
|
||
| protected fun initializeModule() { | ||
| module = Module(this) | ||
| module!!.remoteConfigSource.initialize() | ||
| keyStoreManager = KeyStoreManager(this, KeyStoreKeyGenerator.Impl()) | ||
| } | ||
|
|
||
| // override fun attachBaseContext(base: Context) { | ||
| // init(base) | ||
| // super.attachBaseContext(instance.setLocale(base)) | ||
| // } | ||
|
|
||
| interface OnAppBackgrounded { | ||
| fun onBackgrounded() | ||
| } | ||
|
|
||
| companion object { | ||
| @JvmField | ||
| var DISPLAY_HEIGHT_PX: Int = 0 | ||
|
|
||
| @JvmField | ||
| var HOST: String = "apigsltd.net" | ||
| private var listeners: MutableList<OnAppBackgrounded>? = null | ||
| private var isBackgroundChecker: Timer? = null | ||
|
|
||
| @JvmField | ||
| var activityCounter: AtomicInteger = AtomicInteger() | ||
|
|
||
| @JvmField | ||
| var backgroundedTime: Long = 0 | ||
|
|
||
| @SuppressLint("StaticFieldLeak") | ||
| private var currentActivity: Activity? = null | ||
|
|
||
| //TODO: revisit this, please migrate using koin for DI Framework | ||
| @SuppressLint("StaticFieldLeak") | ||
| @JvmField | ||
| var module: Module? = null | ||
|
|
||
| @SuppressLint("StaticFieldLeak") | ||
| @JvmField | ||
| var keyStoreManager: KeyStoreManager? = null | ||
|
|
||
| @JvmStatic | ||
| val breadContext: Context | ||
| get() = if (currentActivity == null) SyncReceiver.app else currentActivity!! | ||
|
|
||
| @JvmStatic | ||
| fun setBreadContext(app: Activity?) { | ||
| currentActivity = app | ||
| } | ||
|
|
||
| fun fireListeners() { | ||
| if (listeners == null) return | ||
| for (lis in listeners!!) lis.onBackgrounded() | ||
| } | ||
|
|
||
| fun addOnBackgroundedListener(listener: OnAppBackgrounded) { | ||
| if (listeners == null) listeners = ArrayList() | ||
| if (!listeners!!.contains(listener)) listeners!!.add(listener) | ||
| } | ||
|
|
||
| @JvmStatic | ||
| fun isAppInBackground(context: Context?): Boolean { | ||
| return context == null || activityCounter.get() <= 0 | ||
| } | ||
|
|
||
| //call onStop on evert activity so | ||
| @JvmStatic | ||
| fun onStop(app: BRActivity?) { | ||
| if (isBackgroundChecker != null) isBackgroundChecker!!.cancel() | ||
| isBackgroundChecker = Timer() | ||
| val backgroundCheck: TimerTask = object : TimerTask() { | ||
| override fun run() { | ||
| if (isAppInBackground(app)) { | ||
| backgroundedTime = System.currentTimeMillis() | ||
| Timber.d("timber: App went in background!") | ||
| // APP in background, do something | ||
| isBackgroundChecker!!.cancel() | ||
| fireListeners() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| isBackgroundChecker!!.schedule(backgroundCheck, 500, 500) | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
...et/presenter/entities/CurrencyEntity.java → ...rainwallet/data/model/CurrencyEntity.java
This file contains hidden or 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,4 +1,4 @@ | ||
| package com.brainwallet.presenter.entities; | ||
| package com.brainwallet.data.model; | ||
|
|
||
| import java.io.Serializable; | ||
|
|
||
|
|
||
This file contains hidden or 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,5 +1,7 @@ | ||
| package com.brainwallet.data.model | ||
|
|
||
| import java.util.Locale | ||
|
|
||
| enum class Language( | ||
| val code: String, | ||
| val title: String, | ||
|
|
@@ -25,6 +27,16 @@ enum class Language( | |
| ; | ||
|
|
||
| companion object { | ||
| fun find(code: String?): Language = values().find { it.code == code } ?: ENGLISH | ||
| fun find(code: String?): Language = entries.find { it.code == code } ?: ENGLISH | ||
| } | ||
|
|
||
| fun toLocale(): Locale { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks nice and neat @andhikayuana . Does this work for all cases? Does it work for xhants and Ru? We had issues in the past |
||
| val codes = code.split("-") | ||
| return if (codes.size == 2) { | ||
| Locale(codes[0], codes[1]) | ||
| } else { | ||
| Locale(codes[0]) | ||
| } | ||
| } | ||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice