Initial version -- added millennium read funcionality
This commit is contained in:
+144
@@ -0,0 +1,144 @@
|
||||
package com.sistemasolton.itranvias.data.preferences;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import kotlin.Metadata;
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import kotlin.jvm.internal.DefaultConstructorMarker;
|
||||
import kotlin.jvm.internal.Intrinsics;
|
||||
|
||||
/* JADX INFO: compiled from: OldSettingsMigration.android.kt */
|
||||
/* JADX INFO: loaded from: classes2.dex */
|
||||
@Metadata(d1 = {"\u0000,\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0002\b\u0002\b\u0007\u0018\u0000 \u000f2\u00020\u0001:\u0001\u000fB\u000f\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0004\b\u0004\u0010\u0005J\b\u0010\t\u001a\u0004\u0018\u00010\nJ\b\u0010\u000b\u001a\u0004\u0018\u00010\nJ\b\u0010\f\u001a\u0004\u0018\u00010\nJ\u0006\u0010\r\u001a\u00020\u000eR\u0014\u0010\u0006\u001a\b\u0012\u0004\u0012\u00020\b0\u0007X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u0010"}, d2 = {"Lcom/sistemasolton/itranvias/data/preferences/OldSettingsMigration;", "", "context", "Landroid/content/Context;", "<init>", "(Landroid/content/Context;)V", "possiblePreferences", "", "Landroid/content/SharedPreferences;", "getOldLanguage", "", "getOldTheme", "getOldPreferredTab", "hasOldSettings", "", "Companion", "composeApp_release"}, k = 1, mv = {2, 1, 0}, xi = 48)
|
||||
public final class OldSettingsMigration {
|
||||
|
||||
@Deprecated
|
||||
public static final String TAG = "OldSettingsMigration";
|
||||
private final List<SharedPreferences> possiblePreferences;
|
||||
private static final Companion Companion = new Companion(null);
|
||||
public static final int $stable = 8;
|
||||
|
||||
public OldSettingsMigration(Context context) {
|
||||
Intrinsics.checkNotNullParameter(context, "context");
|
||||
this.possiblePreferences = CollectionsKt.listOf((Object[]) new SharedPreferences[]{PreferenceManager.getDefaultSharedPreferences(context), context.getSharedPreferences("com.russhwolf.settings.Settings", 0), context.getSharedPreferences(context.getPackageName(), 0), context.getSharedPreferences("app_preferences", 0)});
|
||||
}
|
||||
|
||||
/* JADX INFO: compiled from: OldSettingsMigration.android.kt */
|
||||
@Metadata(d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0000\b\u0082\u0003\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0002\u0010\u0003R\u000e\u0010\u0004\u001a\u00020\u0005X\u0086T¢\u0006\u0002\n\u0000¨\u0006\u0006"}, d2 = {"Lcom/sistemasolton/itranvias/data/preferences/OldSettingsMigration$Companion;", "", "<init>", "()V", "TAG", "", "composeApp_release"}, k = 1, mv = {2, 1, 0}, xi = 48)
|
||||
private static final class Companion {
|
||||
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
||||
this();
|
||||
}
|
||||
|
||||
private Companion() {
|
||||
}
|
||||
}
|
||||
|
||||
public final String getOldLanguage() {
|
||||
String str;
|
||||
Log.d(TAG, "🔍 Buscando 'app_language' en SharedPreferences...");
|
||||
Iterator<T> it = this.possiblePreferences.iterator();
|
||||
int i = 0;
|
||||
while (it.hasNext()) {
|
||||
int i2 = i + 1;
|
||||
String string = ((SharedPreferences) it.next()).getString("app_language", null);
|
||||
if (string != null) {
|
||||
if (i == 0) {
|
||||
str = "Default SharedPreferences";
|
||||
} else if (i == 1) {
|
||||
str = "com.russhwolf.settings.Settings";
|
||||
} else if (i == 2) {
|
||||
str = "Nombre del paquete";
|
||||
} else if (i == 3) {
|
||||
str = "app_preferences";
|
||||
} else {
|
||||
str = "Ubicación desconocida";
|
||||
}
|
||||
Log.i(TAG, "✅ 'app_language' encontrado en: " + str + " = '" + string + "'");
|
||||
return string;
|
||||
}
|
||||
i = i2;
|
||||
}
|
||||
Log.w(TAG, "⚠️ 'app_language' NO encontrado en ninguna ubicación");
|
||||
return null;
|
||||
}
|
||||
|
||||
public final String getOldTheme() {
|
||||
String str;
|
||||
Log.d(TAG, "🔍 Buscando 'app_theme' en SharedPreferences...");
|
||||
Iterator<T> it = this.possiblePreferences.iterator();
|
||||
int i = 0;
|
||||
while (it.hasNext()) {
|
||||
int i2 = i + 1;
|
||||
String string = ((SharedPreferences) it.next()).getString("app_theme", null);
|
||||
if (string != null) {
|
||||
if (i == 0) {
|
||||
str = "Default SharedPreferences";
|
||||
} else if (i == 1) {
|
||||
str = "com.russhwolf.settings.Settings";
|
||||
} else if (i == 2) {
|
||||
str = "Nombre del paquete";
|
||||
} else if (i == 3) {
|
||||
str = "app_preferences";
|
||||
} else {
|
||||
str = "Ubicación desconocida";
|
||||
}
|
||||
Log.i(TAG, "✅ 'app_theme' encontrado en: " + str + " = '" + string + "'");
|
||||
return string;
|
||||
}
|
||||
i = i2;
|
||||
}
|
||||
Log.w(TAG, "⚠️ 'app_theme' NO encontrado en ninguna ubicación");
|
||||
return null;
|
||||
}
|
||||
|
||||
public final String getOldPreferredTab() {
|
||||
String str;
|
||||
Log.d(TAG, "🔍 Buscando 'preferred_tab' en SharedPreferences...");
|
||||
Iterator<T> it = this.possiblePreferences.iterator();
|
||||
int i = 0;
|
||||
while (it.hasNext()) {
|
||||
int i2 = i + 1;
|
||||
String string = ((SharedPreferences) it.next()).getString("preferred_tab", null);
|
||||
if (string != null) {
|
||||
if (i == 0) {
|
||||
str = "Default SharedPreferences";
|
||||
} else if (i == 1) {
|
||||
str = "com.russhwolf.settings.Settings";
|
||||
} else if (i == 2) {
|
||||
str = "Nombre del paquete";
|
||||
} else if (i == 3) {
|
||||
str = "app_preferences";
|
||||
} else {
|
||||
str = "Ubicación desconocida";
|
||||
}
|
||||
Log.i(TAG, "✅ 'preferred_tab' encontrado en: " + str + " = '" + string + "'");
|
||||
return string;
|
||||
}
|
||||
i = i2;
|
||||
}
|
||||
Log.w(TAG, "⚠️ 'preferred_tab' NO encontrado en ninguna ubicación");
|
||||
return null;
|
||||
}
|
||||
|
||||
public final boolean hasOldSettings() {
|
||||
Log.d(TAG, "🔍 Verificando si hay datos antiguos para migrar...");
|
||||
boolean z = true;
|
||||
boolean z2 = getOldLanguage() != null;
|
||||
boolean z3 = getOldTheme() != null;
|
||||
boolean z4 = getOldPreferredTab() != null;
|
||||
if (!z2 && !z3 && !z4) {
|
||||
z = false;
|
||||
}
|
||||
if (z) {
|
||||
Log.i(TAG, "✅ Datos antiguos encontrados (Language: " + z2 + ", Theme: " + z3 + ", Tab: " + z4 + ")");
|
||||
} else {
|
||||
Log.i(TAG, "ℹ️ No se encontraron datos antiguos para migrar");
|
||||
}
|
||||
return z;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user