chinwag-android/app/src/main/java/com/keylesspalace/tusky
Konrad Pozniak d554d71958
inject SharedPreferences (#4441)
(this one is for @charlag)

Calling `PreferenceManager.getDefaultSharedPreferences()` will read the
preference file from disk every time. This PR makes `SharedPreferences`
a singleton so they will only be created once at appstart (with a few
exceptions where it is hard to inject, e.g. in the `openLink` helper)
which should help getting our ANRs down.

```
StrictMode policy violation; ~duration=285 ms: android.os.strictmode.DiskReadViolation
    at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1666)
    at libcore.io.BlockGuardOs.access(BlockGuardOs.java:74)
    at libcore.io.ForwardingOs.access(ForwardingOs.java:128)
    at android.app.ActivityThread$AndroidOs.access(ActivityThread.java:8054)
    at java.io.UnixFileSystem.checkAccess(UnixFileSystem.java:313)
    at java.io.File.exists(File.java:813)
    at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:790)
    at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:781)
    at android.app.ContextImpl.getPreferencesDir(ContextImpl.java:737)
    at android.app.ContextImpl.getSharedPreferencesPath(ContextImpl.java:962)
    at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:583)
    at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:221)
    at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:221)
    at androidx.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:119)
    at com.keylesspalace.tusky.BaseActivity.onCreate(BaseActivity.java:96)
   ...
```
2024-05-24 08:05:09 +02:00
..
adapter inject SharedPreferences (#4441) 2024-05-24 08:05:09 +02:00
appstore Refactor notifications to Kotlin & paging (#4026) 2024-05-03 18:27:10 +02:00
components inject SharedPreferences (#4441) 2024-05-24 08:05:09 +02:00
db inject SharedPreferences (#4441) 2024-05-24 08:05:09 +02:00
di inject SharedPreferences (#4441) 2024-05-24 08:05:09 +02:00
entity make Status.filtered nullable to make some weird api implementations work again (#4426) 2024-05-10 12:21:48 +02:00
fragment Replace Dagger-Android with Hilt and remove Kapt (#4423) 2024-05-10 15:55:07 +02:00
interfaces Refactor permissions requests to use ActivityResultContract (#4391) 2024-05-03 21:42:35 +02:00
json Replace Gson library with Moshi (#4309) 2024-04-02 21:01:04 +02:00
network make Status.filtered nullable to make some weird api implementations work again (#4426) 2024-05-10 12:21:48 +02:00
pager upgrade ktlint plugin to 12.0.3 (#4169) 2024-01-04 17:00:55 +01:00
receiver Replace Dagger-Android with Hilt and remove Kapt (#4423) 2024-05-10 15:55:07 +02:00
service Replace Dagger-Android with Hilt and remove Kapt (#4423) 2024-05-10 15:55:07 +02:00
settings Add a feature and preference to confirm follows. (#4445) 2024-05-13 19:02:21 +02:00
usecase Replace Dagger-Android with Hilt and remove Kapt (#4423) 2024-05-10 15:55:07 +02:00
util inject SharedPreferences (#4441) 2024-05-24 08:05:09 +02:00
view Fix various lint warnings (#4409) 2024-05-05 08:34:41 +02:00
viewdata Refactor notifications to Kotlin & paging (#4026) 2024-05-03 18:27:10 +02:00
viewmodel Replace Dagger-Android with Hilt and remove Kapt (#4423) 2024-05-10 15:55:07 +02:00
worker Replace Dagger-Android with Hilt and remove Kapt (#4423) 2024-05-10 15:55:07 +02:00
AboutActivity.kt Replace Dagger-Android with Hilt and remove Kapt (#4423) 2024-05-10 15:55:07 +02:00
AccountsInListFragment.kt inject SharedPreferences (#4441) 2024-05-24 08:05:09 +02:00
BaseActivity.java inject SharedPreferences (#4441) 2024-05-24 08:05:09 +02:00
BottomSheetActivity.kt Replace RxJava3 code with coroutines (#4290) 2024-02-29 15:28:48 +01:00
EditProfileActivity.kt Replace Dagger-Android with Hilt and remove Kapt (#4423) 2024-05-10 15:55:07 +02:00
LicenseActivity.kt Replace Dagger-Android with Hilt and remove Kapt (#4423) 2024-05-10 15:55:07 +02:00
ListsActivity.kt Replace Dagger-Android with Hilt and remove Kapt (#4423) 2024-05-10 15:55:07 +02:00
MainActivity.kt inject SharedPreferences (#4441) 2024-05-24 08:05:09 +02:00
StatusListActivity.kt Replace Dagger-Android with Hilt and remove Kapt (#4423) 2024-05-10 15:55:07 +02:00
TabData.kt Refactor notifications to Kotlin & paging (#4026) 2024-05-03 18:27:10 +02:00
TabPreferenceActivity.kt Replace Dagger-Android with Hilt and remove Kapt (#4423) 2024-05-10 15:55:07 +02:00
TuskyApplication.kt inject SharedPreferences (#4441) 2024-05-24 08:05:09 +02:00
ViewMediaActivity.kt Replace Dagger-Android with Hilt and remove Kapt (#4423) 2024-05-10 15:55:07 +02:00