TV Bro: TV Web Browser v1.8.2版本的 MD5 值为:1f764660d14956f3a51779008857502a
以下内容为反编译后的 SettingsModel.java 源代码,内容仅作参考
package com.phlox.tvwebbrowser.activity.main;
import androidx.constraintlayout.core.motion.utils.TypedValues;
import com.phlox.tvwebbrowser.Config;
import com.phlox.tvwebbrowser.TVBro;
import com.phlox.tvwebbrowser.utils.ExtensionsKt;
import com.phlox.tvwebbrowser.utils.UpdateChecker;
import com.phlox.tvwebbrowser.utils.activemodel.ActiveModel;
import com.phlox.tvwebbrowser.utils.observable.ObservableValue;
import com.phlox.tvwebbrowser.utils.observable.SimpleObservableKt;
import java.util.Calendar;
import java.util.List;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.collections.CollectionsKt;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.MutablePropertyReference0Impl;
import kotlin.jvm.internal.Reflection;
import kotlin.text.MatchResult;
import kotlin.text.Regex;
import kotlinx.coroutines.BuildersKt__Builders_commonKt;
import kotlinx.coroutines.Dispatchers;
import kotlinx.coroutines.Job;
@Metadata(d1 = {"\u0000p\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0011\n\u0002\u0010\u000e\n\u0002\b\u0004\n\u0002\u0010 \n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0014\n\u0002\u0018\u0002\n\u0002\b\u0012\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0002\b\u0002\u0018\u0000 [2\u00020\u0001:\u0001[B\u0005¢\u0006\u0002\u0010\u0002J\u000e\u0010I\u001a\u00020J2\u0006\u0010K\u001a\u00020\u0005J\u001c\u0010L\u001a\u00020M2\u0006\u0010N\u001a\u00020\u00182\f\u0010O\u001a\b\u0012\u0004\u0012\u00020J0PJ\u000e\u0010Q\u001a\u00020J2\u0006\u0010R\u001a\u00020\u0018J\u000e\u0010S\u001a\u00020J2\u0006\u0010T\u001a\u00020\u0005J\u000e\u0010U\u001a\u00020J2\u0006\u0010V\u001a\u00020\u0005J\u0016\u0010-\u001a\u00020J2\u0006\u0010W\u001a\u00020\u00182\u0006\u0010K\u001a\u00020\u0005J\u0018\u0010X\u001a\u00020J2\u0006\u0010Y\u001a\u00020Z2\b\b\u0002\u0010N\u001a\u00020\u0018R\u0019\u0010\u0003\u001a\b\u0012\u0004\u0012\u00020\u00050\u0004¢\u0006\n\n\u0002\u0010\b\u001a\u0004\b\u0006\u0010\u0007R\u0017\u0010\t\u001a\b\u0012\u0004\u0012\u00020\u00050\n¢\u0006\b\n\u0000\u001a\u0004\b\u000b\u0010\fR\u0011\u0010\r\u001a\u00020\u000e¢\u0006\b\n\u0000\u001a\u0004\b\u000f\u0010\u0010R \u0010\u0011\u001a\b\u0012\u0004\u0012\u00020\u00050\u0012X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0013\u0010\u0014\"\u0004\b\u0015\u0010\u0016R \u0010\u0017\u001a\b\u0012\u0004\u0012\u00020\u00180\u0012X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0019\u0010\u0014\"\u0004\b\u001a\u0010\u0016R\u001a\u0010\u001b\u001a\u00020\u001cX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u001d\u0010\u001e\"\u0004\b\u001f\u0010 R$\u0010\"\u001a\u00020\u00182\u0006\u0010!\u001a\u00020\u00188F@FX\u0086\u000e¢\u0006\f\u001a\u0004\b#\u0010$\"\u0004\b%\u0010&R\u001a\u0010'\u001a\u00020\u0018X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b(\u0010$\"\u0004\b)\u0010&R \u0010*\u001a\b\u0012\u0004\u0012\u00020\u00050\u0012X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b+\u0010\u0014\"\u0004\b,\u0010\u0016R\u001a\u0010-\u001a\u00020\u0018X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b.\u0010$\"\u0004\b/\u0010&R+\u00102\u001a\u0002012\u0006\u00100\u001a\u0002018F@FX\u0086\u008e\u0002¢\u0006\u0012\u001a\u0004\b5\u00106\"\u0004\b7\u00108*\u0004\b3\u00104R \u00109\u001a\b\u0012\u0004\u0012\u00020\u00050\u0012X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b:\u0010\u0014\"\u0004\b;\u0010\u0016R\u0017\u0010<\u001a\b\u0012\u0004\u0012\u00020\u00050\n¢\u0006\b\n\u0000\u001a\u0004\b=\u0010\fR\u001a\u0010>\u001a\u00020\u0005X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b?\u0010@\"\u0004\bA\u0010BR\u0011\u0010C\u001a\u00020D¢\u0006\b\n\u0000\u001a\u0004\bE\u0010FR\u0019\u0010G\u001a\b\u0012\u0004\u0012\u00020\u00050\u0004¢\u0006\n\n\u0002\u0010\b\u001a\u0004\bH\u0010\u0007¨\u0006\\"}, d2 = {"Lcom/phlox/tvwebbrowser/activity/main/SettingsModel;", "Lcom/phlox/tvwebbrowser/utils/activemodel/ActiveModel;", "()V", "SearchEnginesTitles", "", "", "getSearchEnginesTitles", "()[Ljava/lang/String;", "[Ljava/lang/String;", "SearchEnginesURLs", "", "getSearchEnginesURLs", "()Ljava/util/List;", "config", "Lcom/phlox/tvwebbrowser/Config;", "getConfig", "()Lcom/phlox/tvwebbrowser/Config;", "homePage", "Lcom/phlox/tvwebbrowser/utils/observable/ObservableValue;", "getHomePage", "()Lcom/phlox/tvwebbrowser/utils/observable/ObservableValue;", "setHomePage", "(Lcom/phlox/tvwebbrowser/utils/observable/ObservableValue;)V", "keepScreenOn", "", "getKeepScreenOn", "setKeepScreenOn", "lastUpdateNotificationTime", "Ljava/util/Calendar;", "getLastUpdateNotificationTime", "()Ljava/util/Calendar;", "setLastUpdateNotificationTime", "(Ljava/util/Calendar;)V", "value", "needAutockeckUpdates", "getNeedAutockeckUpdates", "()Z", "setNeedAutockeckUpdates", "(Z)V", "needToShowUpdateDlgAgain", "getNeedToShowUpdateDlgAgain", "setNeedToShowUpdateDlgAgain", "searchEngineURL", "getSearchEngineURL", "setSearchEngineURL", "setSearchEngineAsHomePage", "getSetSearchEngineAsHomePage", "setSetSearchEngineAsHomePage", "<set-?>", "Lcom/phlox/tvwebbrowser/Config$Theme;", Config.THEME_KEY, "getTheme$delegate", "(Lcom/phlox/tvwebbrowser/activity/main/SettingsModel;)Ljava/lang/Object;", "getTheme", "()Lcom/phlox/tvwebbrowser/Config$Theme;", "setTheme", "(Lcom/phlox/tvwebbrowser/Config$Theme;)V", "uaString", "getUaString", "setUaString", "uaStrings", "getUaStrings", "updateChannel", "getUpdateChannel", "()Ljava/lang/String;", "setUpdateChannel", "(Ljava/lang/String;)V", "updateChecker", "Lcom/phlox/tvwebbrowser/utils/UpdateChecker;", "getUpdateChecker", "()Lcom/phlox/tvwebbrowser/utils/UpdateChecker;", "userAgentStringTitles", "getUserAgentStringTitles", "changeSearchEngineUrl", "", "url", "checkUpdate", "Lkotlinx/coroutines/Job;", "force", "onDoneCallback", "Lkotlin/Function0;", "saveAutoCheckUpdates", "need", "saveUAString", "uas", "saveUpdateChannel", "selectedChannel", "searchEngineIsHomePage", "showUpdateDialogIfNeeded", "activity", "Lcom/phlox/tvwebbrowser/activity/main/MainActivity;", "Companion", "app_googleRelease"}, k = 1, mv = {1, 6, 0}, xi = 48)
public final class SettingsModel extends ActiveModel {
public static final Companion INSTANCE = new Companion(null);
private static final String TAG = "SettingsModel";
public static final String TV_BRO_UA_PREFIX = "TV Bro/1.0 ";
private final String[] SearchEnginesTitles;
private final List<String> SearchEnginesURLs;
private final Config config;
private ObservableValue<String> homePage;
private ObservableValue<Boolean> keepScreenOn;
private Calendar lastUpdateNotificationTime;
private boolean needToShowUpdateDlgAgain;
private ObservableValue<String> searchEngineURL;
private boolean setSearchEngineAsHomePage;
private ObservableValue<String> uaString;
private final List<String> uaStrings;
private String updateChannel;
private final UpdateChecker updateChecker;
private final String[] userAgentStringTitles;
@Metadata(d1 = {"\u0000\u0014\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0005\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002R\u0019\u0010\u0003\u001a\n \u0005*\u0004\u0018\u00010\u00040\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u0006\u0010\u0007R\u000e\u0010\b\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000¨\u0006\t"}, d2 = {"Lcom/phlox/tvwebbrowser/activity/main/SettingsModel$Companion;", "", "()V", "TAG", "", "kotlin.jvm.PlatformType", "getTAG", "()Ljava/lang/String;", "TV_BRO_UA_PREFIX", "app_googleRelease"}, k = 1, mv = {1, 6, 0}, xi = 48)
public static final class Companion {
public Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
public final String getTAG() {
return SettingsModel.TAG;
}
}
public SettingsModel() {
Calendar calendar;
Config config = TVBro.INSTANCE.getConfig();
this.config = config;
this.SearchEnginesTitles = new String[]{"Google", "Bing", "Yahoo!", "DuckDuckGo", "Yandex", TypedValues.Custom.NAME};
this.SearchEnginesURLs = CollectionsKt.listOf((Object[]) new String[]{"https://www.google.com/search?q=[query]", "https://www.bing.com/search?q=[query]", "https://search.yahoo.com/search?p=[query]", "https://duckduckgo.com/?q=[query]", "https://yandex.com/search/?text=[query]", ""});
this.searchEngineURL = new ObservableValue<>(config.getSearchEngineURL());
this.setSearchEngineAsHomePage = config.getSearchEngineAsHomePage();
this.homePage = new ObservableValue<>(config.getHomePage());
this.userAgentStringTitles = new String[]{"TV Bro", "Chrome (Desktop)", "Chrome (Mobile)", "Chrome (Tablet)", "Firefox (Desktop)", "Firefox (Tablet)", "Edge (Desktop)", "Safari (Desktop)", "Safari (iPad)", "Apple TV", TypedValues.Custom.NAME};
this.uaStrings = CollectionsKt.listOf((Object[]) new String[]{"", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36", "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Mobile Safari/537.36", "Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Mobile Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0", "Mozilla/5.0 (Android 10; Tablet; rv:68.0) Gecko/68.0 Firefox/68.0", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36 Edg/84.0.522.44", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Safari/605.1.15", "Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Mobile/15E148 Safari/604.1", "AppleTV6,2/11.1", ""});
this.uaString = new ObservableValue<>(config.getUserAgentString());
this.updateChecker = new UpdateChecker(53);
this.keepScreenOn = SimpleObservableKt.makeObservable(new MutablePropertyReference0Impl(config) {
@Override
public Object get() {
return Boolean.valueOf(((Config) this.receiver).getKeepScreenOn());
}
@Override
public void set(Object obj) {
((Config) this.receiver).setKeepScreenOn(((Boolean) obj).booleanValue());
}
});
if (config.getPrefs().contains(Config.LAST_UPDATE_USER_NOTIFICATION_TIME_KEY)) {
calendar = Calendar.getInstance();
calendar.setTimeInMillis(config.getPrefs().getLong(Config.LAST_UPDATE_USER_NOTIFICATION_TIME_KEY, 0L));
Intrinsics.checkNotNullExpressionValue(calendar, "getInstance().apply { ti…TIFICATION_TIME_KEY, 0) }");
} else {
calendar = Calendar.getInstance();
Intrinsics.checkNotNullExpressionValue(calendar, "getInstance()");
}
this.lastUpdateNotificationTime = calendar;
this.updateChannel = config.getUpdateChannel();
}
public final Config getConfig() {
return this.config;
}
public final String[] getSearchEnginesTitles() {
return this.SearchEnginesTitles;
}
public final List<String> getSearchEnginesURLs() {
return this.SearchEnginesURLs;
}
public final ObservableValue<String> getSearchEngineURL() {
return this.searchEngineURL;
}
public final void setSearchEngineURL(ObservableValue<String> observableValue) {
Intrinsics.checkNotNullParameter(observableValue, "<set-?>");
this.searchEngineURL = observableValue;
}
public final boolean getSetSearchEngineAsHomePage() {
return this.setSearchEngineAsHomePage;
}
public final void setSetSearchEngineAsHomePage(boolean z) {
this.setSearchEngineAsHomePage = z;
}
public final ObservableValue<String> getHomePage() {
return this.homePage;
}
public final void setHomePage(ObservableValue<String> observableValue) {
Intrinsics.checkNotNullParameter(observableValue, "<set-?>");
this.homePage = observableValue;
}
public final String[] getUserAgentStringTitles() {
return this.userAgentStringTitles;
}
public final List<String> getUaStrings() {
return this.uaStrings;
}
public final ObservableValue<String> getUaString() {
return this.uaString;
}
public final void setUaString(ObservableValue<String> observableValue) {
Intrinsics.checkNotNullParameter(observableValue, "<set-?>");
this.uaString = observableValue;
}
public final boolean getNeedToShowUpdateDlgAgain() {
return this.needToShowUpdateDlgAgain;
}
public final void setNeedToShowUpdateDlgAgain(boolean z) {
this.needToShowUpdateDlgAgain = z;
}
public final UpdateChecker getUpdateChecker() {
return this.updateChecker;
}
public final Calendar getLastUpdateNotificationTime() {
return this.lastUpdateNotificationTime;
}
public final void setLastUpdateNotificationTime(Calendar calendar) {
Intrinsics.checkNotNullParameter(calendar, "<set-?>");
this.lastUpdateNotificationTime = calendar;
}
public final boolean getNeedAutockeckUpdates() {
return this.config.isNeedAutoCheckUpdates();
}
public final void setNeedAutockeckUpdates(boolean z) {
this.config.setAutoCheckUpdates(z);
}
public static Object getTheme$delegate(SettingsModel settingsModel) {
Intrinsics.checkNotNullParameter(settingsModel, "<this>");
return Reflection.mutableProperty0(new MutablePropertyReference0Impl(settingsModel.config, Config.class, Config.THEME_KEY, "getTheme()Lcom/phlox/tvwebbrowser/Config$Theme;", 0));
}
public final Config.Theme getTheme() {
return this.config.getTheme();
}
public final void setTheme(Config.Theme theme) {
Intrinsics.checkNotNullParameter(theme, "<set-?>");
this.config.setTheme(theme);
}
public final String getUpdateChannel() {
return this.updateChannel;
}
public final void setUpdateChannel(String str) {
Intrinsics.checkNotNullParameter(str, "<set-?>");
this.updateChannel = str;
}
public final ObservableValue<Boolean> getKeepScreenOn() {
return this.keepScreenOn;
}
public final void setKeepScreenOn(ObservableValue<Boolean> observableValue) {
Intrinsics.checkNotNullParameter(observableValue, "<set-?>");
this.keepScreenOn = observableValue;
}
public final void changeSearchEngineUrl(String url) {
Intrinsics.checkNotNullParameter(url, "url");
this.config.setSearchEngineURL(url);
this.searchEngineURL.setValue(url);
}
public final void setSearchEngineAsHomePage(boolean searchEngineIsHomePage, String url) {
String value;
Intrinsics.checkNotNullParameter(url, "url");
String str = Config.DEFAULT_HOME_URL;
if (searchEngineIsHomePage) {
Regex regex = new Regex("^https?:\\/\\/[^#?\\/]+");
ObservableValue<String> observableValue = this.homePage;
MatchResult find$default = Regex.find$default(regex, url, 0, 2, null);
if (find$default != null && (value = find$default.getValue()) != null) {
str = value;
}
observableValue.setValue(str);
} else {
this.homePage.setValue(Config.DEFAULT_HOME_URL);
}
this.config.setSearchEngineAsHomePage(searchEngineIsHomePage);
this.setSearchEngineAsHomePage = searchEngineIsHomePage;
this.config.setHomePage(this.homePage.getValue());
}
public final void saveUAString(String uas) {
Intrinsics.checkNotNullParameter(uas, "uas");
this.config.setUserAgentString(uas);
this.uaString.setValue(uas);
}
public final void saveAutoCheckUpdates(boolean need) {
this.config.setAutoCheckUpdates(need);
}
public final void saveUpdateChannel(String selectedChannel) {
Intrinsics.checkNotNullParameter(selectedChannel, "selectedChannel");
this.config.setUpdateChannel(selectedChannel);
this.updateChannel = selectedChannel;
}
public final Job checkUpdate(boolean force, Function0<Unit> onDoneCallback) {
Job launch$default;
Intrinsics.checkNotNullParameter(onDoneCallback, "onDoneCallback");
launch$default = BuildersKt__Builders_commonKt.launch$default(getModelScope(), Dispatchers.getMain(), null, new SettingsModel$checkUpdate$1(this, force, onDoneCallback, null), 2, null);
return launch$default;
}
public static void showUpdateDialogIfNeeded$default(SettingsModel settingsModel, MainActivity mainActivity, boolean z, int i, Object obj) {
if ((i & 2) != 0) {
z = false;
}
settingsModel.showUpdateDialogIfNeeded(mainActivity, z);
}
public final void showUpdateDialogIfNeeded(MainActivity activity, boolean force) {
Intrinsics.checkNotNullParameter(activity, "activity");
Calendar now = Calendar.getInstance();
Calendar calendar = this.lastUpdateNotificationTime;
Intrinsics.checkNotNullExpressionValue(now, "now");
if (!ExtensionsKt.sameDay(calendar, now) || force) {
if (!this.updateChecker.hasUpdate()) {
throw new IllegalStateException();
}
this.lastUpdateNotificationTime = now;
this.config.getPrefs().edit().putLong(Config.LAST_UPDATE_USER_NOTIFICATION_TIME_KEY, this.lastUpdateNotificationTime.getTimeInMillis()).apply();
this.updateChecker.showUpdateDialog(activity, new SettingsModel$showUpdateDialogIfNeeded$1(activity, this));
}
}
}