OverviewPrzegląd

The ForceUpdate module allows you to enforce minimum app versions for your users. It supports blocking updates (user cannot proceed without updating) and soft recommendations with skip options. Works with Remote Config for dynamic control. Moduł ForceUpdate pozwala wymuszać minimalne wersje aplikacji dla użytkowników. Obsługuje blokujące aktualizacje (użytkownik nie może kontynuować bez aktualizacji) i miękkie rekomendacje z opcją pominięcia. Działa z Remote Config dla dynamicznej kontroli.

Basic UsagePodstawowe użycie

// In MainActivity.onCreate() / W MainActivity.onCreate()
ADict.ForceUpdate.check(activity) {
    minVersionCode = 15
    storeUrl = "https://play.google.com/store/apps/details?id=com.example"

    onUpdateRequired = { currentVersion, minVersion ->
        Log.w("Update", "Required: $currentVersion < $minVersion")
    }

    onUpToDate = {
        proceedToMainScreen()
    }
}

Auto-Show DialogAutomatyczne wyświetlanie dialogu

// Automatically shows appropriate dialog / Automatycznie pokazuje odpowiedni dialog
ADict.ForceUpdate.checkAndShowDialog(activity) {
    minVersionCode = 15              // Required minimum / Wymagane minimum
    recommendedVersionCode = 20      // Soft recommendation / Miękka rekomendacja
    blocking = true                  // Cannot dismiss required update / Nie można odrzucić
    showSkipOption = true            // Show "Skip this version" / Pokaż "Pomiń tę wersję"
    storeUrl = "https://play.google.com/..."
}

Remote Config IntegrationIntegracja z Remote Config

// Check versions from Remote Config / Sprawdź wersje z Remote Config
ADict.ForceUpdate.checkFromRemoteConfig(
    activity = activity,
    minVersionKey = "min_app_version",
    recommendedVersionKey = "recommended_app_version",
    storeUrlKey = "store_url",
    blocking = true,
    showDialog = true
) { result ->
    when (result) {
        is ForceUpdate.CheckResult.UpToDate -> proceedNormally()
        is ForceUpdate.CheckResult.UpdateRequired -> { /* Dialog shown */ }
        is ForceUpdate.CheckResult.UpdateRecommended -> { /* Dialog shown */ }
        is ForceUpdate.CheckResult.Error -> Log.e("Update", result.message)
    }
}

// Remote Config keys:
// min_app_version: 15
// recommended_app_version: 20
// store_url: "https://play.google.com/..."

Custom StringsWłasne teksty dialogów

All dialog strings are configurable. Create a custom Strings instance: Wszystkie teksty dialogów są konfigurowalne. Utwórz własną instancję Strings:

import rip.nerd.adictlibrary.modules.ForceUpdate

// Custom strings / Własne teksty
val strings = ForceUpdate.Strings(
    updateRequiredTitle = "Wymagana aktualizacja",
    updateRequiredMessage = "Proszę zaktualizować aplikację.",
    updateRecommendedTitle = "Dostępna aktualizacja",
    updateRecommendedMessage = "Nowa wersja jest dostępna.",
    updateButton = "Aktualizuj",
    laterButton = "Później",
    skipButton = "Pomiń tę wersję"
)

ADict.ForceUpdate.checkAndShowDialog(activity, strings = strings) {
    minVersionCode = 15
}

Available String PropertiesDostępne właściwości tekstów

PropertyWłaściwość Default ValueWartość domyślna DescriptionOpis
updateRequiredTitle "Update Required" Title for blocking update dialogTytuł blokującego dialogu aktualizacji
updateRequiredMessage "Your app version is outdated..." Message for blocking update dialogTreść blokującego dialogu aktualizacji
updateRecommendedTitle "Update Available" Title for soft update dialogTytuł miękkiego dialogu aktualizacji
updateRecommendedMessage "A new version is available..." Message for soft update dialogTreść miękkiego dialogu aktualizacji
updateButton "Update" Update button textTekst przycisku aktualizacji
laterButton "Later" Later button textTekst przycisku "Później"
skipButton "Skip This Version" Skip button textTekst przycisku "Pomiń"

Check ResultsWyniki sprawdzenia

ResultWynik DescriptionOpis
UpToDate App meets all version requirementsAplikacja spełnia wszystkie wymagania wersji
UpdateRequired App is below minimum version (blocking)Aplikacja poniżej minimalnej wersji (blokująca)
UpdateRecommended Newer version available (non-blocking)Nowsza wersja dostępna (nieblokująca)
Error Error during check (with message)Błąd podczas sprawdzania (z komunikatem)

Version Name SupportObsługa nazw wersji

// Use version names instead of codes / Użyj nazw wersji zamiast kodów
ADict.ForceUpdate.check(activity) {
    minVersionName = "2.0.0"          // Parsed as 20000
    recommendedVersionName = "2.1.5"  // Parsed as 20105
}

Check IntervalInterwał sprawdzania

// Only check once per hour / Sprawdzaj tylko raz na godzinę
ADict.ForceUpdate.check(activity) {
    minVersionCode = 15
    checkIntervalMs = 60 * 60 * 1000L  // 1 hour / 1 godzina
}

UtilitiesNarzędzia

// Get current app version / Pobierz aktualną wersję aplikacji
val versionCode = ADict.ForceUpdate.getAppVersionCode(context)
val versionName = ADict.ForceUpdate.getAppVersionName(context)

// Reset saved data / Zresetuj zapisane dane (pominięte wersje itp.)
ADict.ForceUpdate.reset()