forked from signalapp/Signal-Android
-
Notifications
You must be signed in to change notification settings - Fork 174
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
[SES-2107] Optimise SharedPreferences #1554
Open
bemusementpark
wants to merge
12
commits into
oxen-io:dev
Choose a base branch
from
bemusementpark:just-prefs
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6b2979d
Remove unused preferences
5855bcd
Remove unnecessary interface
f23a0fb
Remove static preferences methods
182d3f6
Use semi-type-safe Pref
0d901ef
Use Flow
268644e
Merge branch 'dev' into just-prefs
a196a98
Merge branch 'dev' into just-prefs
c9f5810
Fix tests
191c287
Convert BaseActivity to Kotlin
3c042a8
Convert DatabaseUpgradeActivity
e57c1cd
Cleanup DatabaseUpgradeActivity
7f8b133
Merge branch 'dev' into just-prefs
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 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
35 changes: 0 additions & 35 deletions
35
app/src/main/java/org/thoughtcrime/securesms/BaseActivity.java
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
app/src/main/java/org/thoughtcrime/securesms/BaseActivity.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,33 @@ | ||
package org.thoughtcrime.securesms | ||
|
||
import android.app.ActivityManager.TaskDescription | ||
import android.content.Context | ||
import android.graphics.BitmapFactory | ||
import androidx.fragment.app.FragmentActivity | ||
import network.loki.messenger.R | ||
import org.session.libsession.messaging.MessagingModuleConfiguration.Companion.shared | ||
import org.session.libsession.utilities.dynamiclanguage.DynamicLanguageActivityHelper | ||
import org.session.libsession.utilities.dynamiclanguage.DynamicLanguageContextWrapper | ||
|
||
abstract class BaseActivity : FragmentActivity() { | ||
override fun onResume() { | ||
super.onResume() | ||
DynamicLanguageActivityHelper.recreateIfNotInCorrectLanguage( | ||
this, | ||
shared.prefs.getLanguage() | ||
) | ||
val name = resources.getString(R.string.app_name) | ||
val icon = BitmapFactory.decodeResource(resources, R.drawable.ic_launcher_foreground) | ||
val color = resources.getColor(R.color.app_icon_background) | ||
setTaskDescription(TaskDescription(name, icon, color)) | ||
} | ||
|
||
override fun attachBaseContext(newBase: Context) { | ||
super.attachBaseContext( | ||
DynamicLanguageContextWrapper.updateContext( | ||
newBase, | ||
shared.prefs.getLanguage() | ||
) | ||
) | ||
} | ||
} |
57 changes: 0 additions & 57 deletions
57
app/src/main/java/org/thoughtcrime/securesms/DatabaseUpgradeActivity.java
This file was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
app/src/main/java/org/thoughtcrime/securesms/DatabaseUpgradeActivity.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,50 @@ | ||
/** | ||
* Copyright (C) 2013 Open Whisper Systems | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http:></http:>//www.gnu.org/licenses/>. | ||
*/ | ||
package org.thoughtcrime.securesms | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.os.Parcelable | ||
import androidx.lifecycle.lifecycleScope | ||
import kotlinx.coroutines.launch | ||
import org.thoughtcrime.securesms.util.Util | ||
import org.thoughtcrime.securesms.util.VersionTracker.getLastSeenVersion | ||
import org.thoughtcrime.securesms.util.VersionTracker.updateLastSeenVersion | ||
|
||
class DatabaseUpgradeActivity : BaseActivity() { | ||
public override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
updateLastSeenVersion(this) | ||
lifecycleScope.launch { | ||
ApplicationContext.getInstance(this@DatabaseUpgradeActivity) | ||
.messageNotifier.updateNotification(this@DatabaseUpgradeActivity) | ||
} | ||
startActivity(intent.getParcelableExtra<Parcelable>("next_intent") as? Intent) | ||
finish() | ||
} | ||
|
||
companion object { | ||
@JvmStatic | ||
fun isUpdate(context: Context?): Boolean { | ||
val currentVersionCode = Util.getCanonicalVersionCode() | ||
val previousVersionCode = getLastSeenVersion(context!!) | ||
|
||
return previousVersionCode < currentVersionCode | ||
} | ||
} | ||
} |
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.
Is it worth putting a... what's the word, um,
convenience getter
(? I can't think of it - but what I'm after is syntactic sugar!) on this so we can just callMessagingModuleConfiguration.getLanguage()
or something?Same for anything else that calls
MessagingModuleConfiguration.getShared().getPrefs()
before it's final "give me the thing".It looks like you have this further down where you just call
context.prefs.<something>
- is that the same thing?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.
Yeah, though ideally this is injected, I'll see if I can do that.
haha, yeah
context.prefs
should be the same thing, but again, ifprefs
is injected, that's more correct.I'll look into it.