From f49b1cc7446b867c506bbf6449820ae8623f0441 Mon Sep 17 00:00:00 2001 From: Nik Clayton Date: Tue, 22 Aug 2023 18:22:45 +0200 Subject: [PATCH 1/3] Fix exception when updating summary notifications (#3976) https://github.com/tuskyapp/Tusky/commit/dc9e9f2aebfd3feb057fee4c3ac72b05cbc75a12 modifed the code that fetched the value of EXTRA_NOTIFICATION_TYPE in an intent, to use getSerializable(). However, the value was being placed in to the intent using putString(). This caused an exception when trying to update the summary notification, so it would never update. ``` java.lang.ClassCastException: java.lang.String cannot be cast to com.keylesspalace.tusky.entity.Notification$Type at com.keylesspalace.tusky.components.notifications.NotificationHelper.updateSummaryNotifications(NotificationHelper.java:321) at com.keylesspalace.tusky.components.notifications.NotificationFetcher.fetchAndShow(NotificationFetcher.kt:87) at com.keylesspalace.tusky.components.notifications.NotificationFetcher$fetchAndShow$1.invokeSuspend(Unknown Source:14) ``` Fix this by placing the value in to the intent using putSerializable(), to match how it will be fetched. --- .../tusky/components/notifications/NotificationHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationHelper.java b/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationHelper.java index a0c5a8ed5..f15d44d2a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationHelper.java +++ b/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationHelper.java @@ -238,7 +238,7 @@ public class NotificationHelper { Bundle extras = new Bundle(); // Add the sending account's name, so it can be used when summarising this notification extras.putString(EXTRA_ACCOUNT_NAME, body.getAccount().getName()); - extras.putString(EXTRA_NOTIFICATION_TYPE, body.getType().toString()); + extras.putSerializable(EXTRA_NOTIFICATION_TYPE, body.getType()); builder.addExtras(extras); // Only alert for the first notification of a batch to avoid multiple alerts at once From dd0cf9c366f08f98e0f0ad46b5b00cc043d22fed Mon Sep 17 00:00:00 2001 From: Weblate <42475313+nailyk-weblate@users.noreply.github.com> Date: Tue, 22 Aug 2023 22:23:07 +0200 Subject: [PATCH 2/3] Translations update from Weblate (#3971) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Translations update from [Weblate](https://weblate.tusky.app) for [Tusky/Tusky](https://weblate.tusky.app/projects/tusky/tusky/). Current translation status: ![Weblate translation status](https://weblate.tusky.app/widgets/tusky/-/tusky/horizontal-auto.svg) --------- Co-authored-by: ButterflyOfFire Co-authored-by: puf Co-authored-by: Danial Behzadi Co-authored-by: Oliebol Co-authored-by: Eric Co-authored-by: Hồ Nhất Duy Co-authored-by: XoseM Co-authored-by: Nik Clayton --- app/src/main/res/values-cy/strings.xml | 2 ++ app/src/main/res/values-fa/strings.xml | 2 ++ app/src/main/res/values-fr/strings.xml | 4 ++-- app/src/main/res/values-gl/strings.xml | 25 ++++++++++++++++------ app/src/main/res/values-nl/strings.xml | 8 +++---- app/src/main/res/values-vi/strings.xml | 2 ++ app/src/main/res/values-zh-rCN/strings.xml | 2 ++ 7 files changed, 32 insertions(+), 13 deletions(-) diff --git a/app/src/main/res/values-cy/strings.xml b/app/src/main/res/values-cy/strings.xml index eb6c33ba7..647644737 100644 --- a/app/src/main/res/values-cy/strings.xml +++ b/app/src/main/res/values-cy/strings.xml @@ -731,4 +731,6 @@ Copïwyd fersiwn a gwybodaeth dyfais Cuddio o\'r ffrwd cartref Methodd chwarae: %s + Dileu + Dileu\'r hidlydd \'%1$s\'\? diff --git a/app/src/main/res/values-fa/strings.xml b/app/src/main/res/values-fa/strings.xml index 31570ad4f..7d65376bd 100644 --- a/app/src/main/res/values-fa/strings.xml +++ b/app/src/main/res/values-fa/strings.xml @@ -683,4 +683,6 @@ اطّلاعات افزاره و نگارش رونوشت شد نهفتن از خط زمانی خانگی پخش شکست خورد: %s + حذف + حذف پالایهٔ «%1$s»؟ diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 9fa13bffa..22eb4313c 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -439,7 +439,7 @@ Ajouter un choix Choix multiples Choix %d - Éditer + Modifier Pouets planifiés Modifier Messages programmés @@ -682,4 +682,4 @@ Ajouter un mot-clé Modifier mot-clé %s : %s - + \ No newline at end of file diff --git a/app/src/main/res/values-gl/strings.xml b/app/src/main/res/values-gl/strings.xml index f74f3a961..2dc51827b 100644 --- a/app/src/main/res/values-gl/strings.xml +++ b/app/src/main/res/values-gl/strings.xml @@ -262,10 +262,10 @@ Engadir conta á listaxe Atopar persoas ás que segues Eliminar a listaxe - Renomear a listaxe + Actualizar a listaxe Crear unha listaxe Non se puido eliminar a listaxe - Non se puido renomear a listaxe + Non se actualizou a listaxe Non se puido crear a listaxe Listaxes Listaxes @@ -304,10 +304,9 @@ Compartir ligazón ao toot Compartir contido do toot Perfil de Tusky - Informar de fallos e solicitar funcións: -\n https://github.com/tuskyapp/Tusky/issues - Web do proxecto: -\n https://tusky.app + Informar de fallos e solicitar funcións: +\nhttps://github.com/tuskyapp/Tusky/issues + Web do proxecto: https://tusky.app Tusky é software libre e de código aberto. Está baixo a licenza GNU General Public License Version 3. Podes ver a licenza aquí: https://www.gnu.org/licenses/gpl-3.0.en.html Desenvolta por Tusky Tusky %s @@ -666,4 +665,16 @@ Obtendo as notificacións… Mantemento da caché… Fallou a subida: %s - + O teu dispositivo + %s %s +\nVersión de Android: %s +\nVersión SDK: %d + A túa conta + \@%s@%s +\nVersión: %s + Copiouse a información sobre o dispositivo e versión + Copiar a información da versión e o dispositivo + Eliminar + Agochar na cronoloxía de inicio + Eliminar o filtro \'%1$s\'\? + \ No newline at end of file diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index d883dc95e..bad61b2e9 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -259,10 +259,8 @@ Lijsten Berichten plaatsen als %1$s - Omschrijf dit voor iemand met een visuele beperking -\n(tekenlimiet is %d) - Omschrijf dit voor mensen met een visuele beperking -\n(tekenlimiet is %d) + Omschrijf inhoud voor iemand met een visuele beperking (tekenlimiet is %d) + Omschrijf inhoud voor mensen met een visuele beperking (tekenlimiet is %d) Beschrijving toevoegen Verwijderen @@ -663,4 +661,6 @@ Versie en apparaatinformatie gekopieerd De upload is mislukt: %s Contact zoeken met je server duurde te lang + Verwijder + Verwijder filter \'%1$s\'\? diff --git a/app/src/main/res/values-vi/strings.xml b/app/src/main/res/values-vi/strings.xml index ffc70bee0..aeeb84f93 100644 --- a/app/src/main/res/values-vi/strings.xml +++ b/app/src/main/res/values-vi/strings.xml @@ -665,4 +665,6 @@ Thiết bị của bạn Ẩn khỏi bảng tin Không thể phát: %s + Xóa bộ lọc \'%1$s\'\? + Xóa diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 61aec7198..3729e425f 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -679,4 +679,6 @@ 复制版本及设备信息 不出现在首页时间线中 播放失败了:%s + 删除筛选器\'%1$s\'吗? + 删除 From 85888ac23820ae56a925e222514b7c023191e373 Mon Sep 17 00:00:00 2001 From: SpaceFox Date: Wed, 23 Aug 2023 15:04:24 +0200 Subject: [PATCH 3/3] Uses the system theme as default theme (#3813) Set the "System Design" as the default theme. This ensures that the app's initial behaviour respect's the user's system-wide theme choice, while still allowing the user to adjust it later. This is only done for new installs of Tusky. If the user is upgrading from a previous release and they did not have an explicit theme set then the dark theme is used, and the UX does not change. --- .../com/keylesspalace/tusky/BaseActivity.java | 4 +++- .../com/keylesspalace/tusky/TuskyApplication.kt | 15 +++++++++++++-- .../tusky/components/compose/ComposeActivity.kt | 3 ++- .../components/preference/PreferencesActivity.kt | 5 +++-- .../tusky/settings/SettingsConstants.kt | 5 ++++- .../com/keylesspalace/tusky/util/ThemeUtils.kt | 12 ++++++------ 6 files changed, 31 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java b/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java index 6cdc471a0..4c8e35f5e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java @@ -56,6 +56,8 @@ import java.util.List; import javax.inject.Inject; +import static com.keylesspalace.tusky.settings.PrefKeys.APP_THEME; + public abstract class BaseActivity extends AppCompatActivity implements Injectable { private static final String TAG = "BaseActivity"; @@ -74,7 +76,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab /* There isn't presently a way to globally change the theme of a whole application at * runtime, just individual activities. So, each activity has to set its theme before any * views are created. */ - String theme = preferences.getString("appTheme", ThemeUtils.APP_THEME_DEFAULT); + String theme = preferences.getString(APP_THEME, ThemeUtils.APP_THEME_DEFAULT); Log.d("activeTheme", theme); if (theme.equals("black")) { setTheme(R.style.TuskyBlackTheme); diff --git a/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.kt b/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.kt index 3c943863d..84fbabbaf 100644 --- a/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.kt +++ b/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.kt @@ -25,10 +25,13 @@ import androidx.work.WorkManager import autodispose2.AutoDisposePlugins import com.keylesspalace.tusky.components.notifications.NotificationHelper import com.keylesspalace.tusky.di.AppInjector +import com.keylesspalace.tusky.settings.NEW_INSTALL_SCHEMA_VERSION import com.keylesspalace.tusky.settings.PrefKeys +import com.keylesspalace.tusky.settings.PrefKeys.APP_THEME import com.keylesspalace.tusky.settings.SCHEMA_VERSION import com.keylesspalace.tusky.util.APP_THEME_DEFAULT import com.keylesspalace.tusky.util.LocaleManager +import com.keylesspalace.tusky.util.THEME_NIGHT import com.keylesspalace.tusky.util.setAppNightMode import com.keylesspalace.tusky.worker.PruneCacheWorker import com.keylesspalace.tusky.worker.WorkerFactory @@ -76,7 +79,7 @@ class TuskyApplication : Application(), HasAndroidInjector { AppInjector.init(this) // Migrate shared preference keys and defaults from version to version. - val oldVersion = sharedPreferences.getInt(PrefKeys.SCHEMA_VERSION, 0) + val oldVersion = sharedPreferences.getInt(PrefKeys.SCHEMA_VERSION, NEW_INSTALL_SCHEMA_VERSION) if (oldVersion != SCHEMA_VERSION) { upgradeSharedPreferences(oldVersion, SCHEMA_VERSION) } @@ -87,7 +90,7 @@ class TuskyApplication : Application(), HasAndroidInjector { EmojiPackHelper.init(this, DefaultEmojiPackList.get(this), allowPackImports = false) // init night mode - val theme = sharedPreferences.getString("appTheme", APP_THEME_DEFAULT) + val theme = sharedPreferences.getString(APP_THEME, APP_THEME_DEFAULT) setAppNightMode(theme) localeManager.setLocale() @@ -136,6 +139,14 @@ class TuskyApplication : Application(), HasAndroidInjector { editor.remove(PrefKeys.Deprecated.SHOW_NOTIFICATIONS_FILTER) } + if (oldVersion != NEW_INSTALL_SCHEMA_VERSION && oldVersion < 2023082301) { + // Default value for appTheme is now THEME_SYSTEM. If the user is upgrading and + // didn't have an explicit preference set use the previous default, so the + // theme does not unexpectedly change. + if (!sharedPreferences.contains(APP_THEME)) { + editor.putString(APP_THEME, THEME_NIGHT) + } + } editor.putInt(PrefKeys.SCHEMA_VERSION, newVersion) editor.apply() } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt index a2828f3a3..14f9b947e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt @@ -94,6 +94,7 @@ import com.keylesspalace.tusky.entity.Emoji import com.keylesspalace.tusky.entity.NewPoll import com.keylesspalace.tusky.entity.Status import com.keylesspalace.tusky.settings.PrefKeys +import com.keylesspalace.tusky.settings.PrefKeys.APP_THEME import com.keylesspalace.tusky.util.APP_THEME_DEFAULT import com.keylesspalace.tusky.util.MentionSpan import com.keylesspalace.tusky.util.PickMediaFiles @@ -208,7 +209,7 @@ class ComposeActivity : activeAccount = accountManager.activeAccount ?: return - val theme = preferences.getString("appTheme", APP_THEME_DEFAULT) + val theme = preferences.getString(APP_THEME, APP_THEME_DEFAULT) if (theme == "black") { setTheme(R.style.TuskyDialogActivityBlackTheme) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/preference/PreferencesActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/preference/PreferencesActivity.kt index b47df1596..f8464ea02 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/preference/PreferencesActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/preference/PreferencesActivity.kt @@ -34,6 +34,7 @@ import com.keylesspalace.tusky.appstore.EventHub import com.keylesspalace.tusky.appstore.PreferenceChangedEvent import com.keylesspalace.tusky.databinding.ActivityPreferencesBinding import com.keylesspalace.tusky.settings.PrefKeys +import com.keylesspalace.tusky.settings.PrefKeys.APP_THEME import com.keylesspalace.tusky.util.APP_THEME_DEFAULT import com.keylesspalace.tusky.util.getNonNullString import com.keylesspalace.tusky.util.setAppNightMode @@ -145,8 +146,8 @@ class PreferencesActivity : override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { when (key) { - "appTheme" -> { - val theme = sharedPreferences.getNonNullString("appTheme", APP_THEME_DEFAULT) + APP_THEME -> { + val theme = sharedPreferences.getNonNullString(APP_THEME, APP_THEME_DEFAULT) Log.d("activeTheme", theme) setAppNightMode(theme) diff --git a/app/src/main/java/com/keylesspalace/tusky/settings/SettingsConstants.kt b/app/src/main/java/com/keylesspalace/tusky/settings/SettingsConstants.kt index 636c1fc69..49041c1aa 100644 --- a/app/src/main/java/com/keylesspalace/tusky/settings/SettingsConstants.kt +++ b/app/src/main/java/com/keylesspalace/tusky/settings/SettingsConstants.kt @@ -41,7 +41,10 @@ enum class AppTheme(val value: String) { * * - Adding a new preference that does not change the interpretation of an existing preference */ -const val SCHEMA_VERSION = 2023072401 +const val SCHEMA_VERSION = 2023082301 + +/** The schema version for fresh installs */ +const val NEW_INSTALL_SCHEMA_VERSION = 0 object PrefKeys { // Note: not all of these keys are actually used as SharedPreferences keys but we must give diff --git a/app/src/main/java/com/keylesspalace/tusky/util/ThemeUtils.kt b/app/src/main/java/com/keylesspalace/tusky/util/ThemeUtils.kt index a03a50260..10f8df1a4 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/ThemeUtils.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/ThemeUtils.kt @@ -30,12 +30,12 @@ import com.google.android.material.color.MaterialColors * the ability to do so is not supported in resource files. */ -private const val THEME_NIGHT = "night" -private const val THEME_DAY = "day" -private const val THEME_BLACK = "black" -private const val THEME_AUTO = "auto" -private const val THEME_SYSTEM = "auto_system" -const val APP_THEME_DEFAULT = THEME_NIGHT +const val THEME_NIGHT = "night" +const val THEME_DAY = "day" +const val THEME_BLACK = "black" +const val THEME_AUTO = "auto" +const val THEME_SYSTEM = "auto_system" +const val APP_THEME_DEFAULT = THEME_SYSTEM fun getDimension(context: Context, @AttrRes attribute: Int): Int { return context.obtainStyledAttributes(intArrayOf(attribute)).use { array ->