Skip to content

Commit

Permalink
AppUpgrade: re-set selected tab for shows, lists and movies
Browse files Browse the repository at this point in the history
  • Loading branch information
UweTrottmann committed Jul 18, 2024
1 parent 7c4ba00 commit 90268d6
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Version 2024.3

* 🔨 Widgets: content does not longer protrude from the widget.
* 🔧 More: add link to what's new.
* 🔧 Re-set remembered selected tab for shows, lists and movies.
* 📝 Latest user interface translations from Crowdin.

#### 2024.3.4 🧪
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/com/battlelancer/seriesguide/SgApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ class SgApp : Application() {
*/
const val RELEASE_VERSION_72_0_1 = 2107201

/**
* Reset selected shows and movies tab as there is
* a new discover tab for shows and the order has changed for movies.
*/
const val RELEASE_VERSION_2024_3_5 = 21240305

/**
* The content authority used to identify the SeriesGuide [android.content.ContentProvider].
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2023 Uwe Trottmann
// SPDX-License-Identifier: Apache-2.0
// Copyright 2022-2024 Uwe Trottmann

package com.battlelancer.seriesguide.lists

Expand All @@ -8,7 +8,7 @@ import androidx.preference.PreferenceManager

object ListsSettings {

const val KEY_LAST_ACTIVE_LISTS_TAB = "com.battlelancer.seriesguide.listsActiveTab"
const val KEY_LAST_ACTIVE_LISTS_TAB = "seriesguide.lists.selectedtab"

/**
* Return the position of the last selected lists tab.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2023 Uwe Trottmann
// SPDX-License-Identifier: Apache-2.0
// Copyright 2022-2024 Uwe Trottmann

package com.battlelancer.seriesguide.movies

Expand All @@ -12,12 +12,11 @@ import java.util.Locale

object MoviesSettings {

private const val KEY_LAST_ACTIVE_MOVIES_TAB = "com.battlelancer.seriesguide.moviesActiveTab"
private const val KEY_LAST_ACTIVE_MOVIES_TAB = "seriesguide.movies.selectedtab"

private const val KEY_MOVIES_LANGUAGE = "com.battlelancer.seriesguide.languagemovies"
private const val KEY_MOVIES_REGION = "com.battlelancer.seriesguide.regionmovies"

@JvmStatic
fun saveLastMoviesTabPosition(context: Context, position: Int) {
PreferenceManager.getDefaultSharedPreferences(context).edit()
.putInt(KEY_LAST_ACTIVE_MOVIES_TAB, position)
Expand All @@ -27,7 +26,6 @@ object MoviesSettings {
/**
* Return the position of the last selected movies tab.
*/
@JvmStatic
fun getLastMoviesTabPosition(context: Context): Int {
return PreferenceManager.getDefaultSharedPreferences(context)
.getInt(KEY_LAST_ACTIVE_MOVIES_TAB, 0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2023 Uwe Trottmann
// SPDX-License-Identifier: Apache-2.0
// Copyright 2022-2024 Uwe Trottmann

package com.battlelancer.seriesguide.shows

Expand All @@ -11,7 +11,7 @@ import com.battlelancer.seriesguide.util.LanguageTools

object ShowsSettings {

private const val KEY_LAST_ACTIVE_SHOWS_TAB = "com.battlelancer.seriesguide.activitytab"
private const val KEY_LAST_ACTIVE_SHOWS_TAB = "seriesguide.shows.selectedtab"

// @Deprecated("language is stored per show or defined by place of usage")
// private const val KEY_LANGUAGE_PREFERRED = "language"
Expand All @@ -20,7 +20,7 @@ object ShowsSettings {

fun saveLastShowsTabPosition(context: Context, position: Int) {
PreferenceManager.getDefaultSharedPreferences(context).edit()
.putInt(ShowsSettings.KEY_LAST_ACTIVE_SHOWS_TAB, position)
.putInt(KEY_LAST_ACTIVE_SHOWS_TAB, position)
.apply()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// Copyright 2023 Uwe Trottmann
// SPDX-License-Identifier: Apache-2.0
// Copyright 2021-2024 Uwe Trottmann

package com.battlelancer.seriesguide.util

import android.app.AlarmManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import androidx.core.content.edit
import androidx.core.content.getSystemService
import androidx.preference.PreferenceManager
import com.battlelancer.seriesguide.BuildConfig
Expand Down Expand Up @@ -111,6 +112,16 @@ class AppUpgrade(
}
}
}

if (lastVersion < SgApp.RELEASE_VERSION_2024_3_5) {
PreferenceManager.getDefaultSharedPreferences(context).edit {
// Remove old settings keys for selected tab
remove("com.battlelancer.seriesguide.activitytab")
remove("com.battlelancer.seriesguide.moviesActiveTab")
// For consistency also re-set lists pref key
remove("com.battlelancer.seriesguide.listsActiveTab")
}
}
}

/**
Expand Down

0 comments on commit 90268d6

Please sign in to comment.