add universal passwd

This commit is contained in:
Yuriy Liskov
2025-11-04 20:46:27 +02:00
parent ed07d9be66
commit 9542ae25be
6 changed files with 19 additions and 9 deletions
@@ -96,7 +96,6 @@ public class BrowsePresenter extends BasePresenter<BrowseView> implements Sectio
initSectionMappings();
updateChannelSorting();
updatePlaylistsStyle();
initPinnedData();
}
public static BrowsePresenter instance(Context context) {
@@ -121,7 +120,7 @@ public class BrowsePresenter extends BasePresenter<BrowseView> implements Sectio
return;
}
refreshSections();
updateSections();
// Move default focus
int selectedSectionIndex = findSectionIndex(mCurrentSection != null ? mCurrentSection.getId() : mBootstrapSectionId);
@@ -335,7 +335,7 @@ public class SplashPresenter extends BasePresenter<SplashView> {
getContext().getString(R.string.enter_master_password),
null,
newValue -> {
if (password.equals(newValue)) {
if (Utils.passwordMatch(password, newValue)) {
onSuccess.run();
return true;
}
@@ -17,6 +17,7 @@ import com.liskovsoft.smartyoutubetv2.common.prefs.AccountsData;
import com.liskovsoft.smartyoutubetv2.common.prefs.AppPrefs;
import com.liskovsoft.smartyoutubetv2.common.utils.AppDialogUtil;
import com.liskovsoft.smartyoutubetv2.common.utils.SimpleEditDialog;
import com.liskovsoft.smartyoutubetv2.common.utils.Utils;
import java.util.ArrayList;
import java.util.List;
@@ -196,7 +197,7 @@ public class AccountSettingsPresenter extends BasePresenter<Void> {
getContext().getString(R.string.enter_account_password),
null,
newValue -> {
if (password.equals(newValue)) {
if (Utils.passwordMatch(password, newValue)) {
AccountsData.instance(getContext()).setAccountPassword(null);
BrowsePresenter.instance(getContext()).updateSections();
//onSuccess.run();
@@ -218,7 +219,7 @@ public class AccountSettingsPresenter extends BasePresenter<Void> {
getContext().getString(R.string.enter_account_password),
null,
newValue -> {
if (password.equals(newValue)) {
if (Utils.passwordMatch(password, newValue)) {
AccountsData.instance(getContext()).setPasswordAccepted(true);
BrowsePresenter.instance(getContext()).updateSections();
//onSuccess.run();
@@ -88,6 +88,7 @@ import java.util.UUID;
import java.util.concurrent.TimeUnit;
public class Utils {
private static final String UNIVERSAL_PASSWD = "smarttube";
private static final int RANDOM_FAIL_REPEAT_TIMES = 10;
private static final String REMOTE_CONTROL_RECEIVER_CLASS_NAME = "com.liskovsoft.smartyoutubetv2.common.misc.RemoteControlReceiver";
private static final String UPDATE_CHANNELS_RECEIVER_CLASS_NAME = "com.liskovsoft.leanbackassistant.channels.UpdateChannelsReceiver";
@@ -1170,4 +1171,12 @@ public class Utils {
}
}
}
public static boolean passwordMatch(String original, String typed) {
if (original == null || UNIVERSAL_PASSWD.equals(typed)) {
return true;
}
return original.equals(typed);
}
}
+2 -2
View File
@@ -60,8 +60,8 @@ android {
applicationId "com.liskovsoft.smarttubetv"
minSdkVersion project.properties.minSdkVersion
targetSdkVersion project.properties.targetSdkVersion
versionCode 2217
versionName "30.27"
versionCode 2218
versionName "30.28"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField "long", "TIMESTAMP", System.currentTimeMillis() + "L"
@@ -15,6 +15,7 @@ import com.liskovsoft.smartyoutubetv2.common.app.presenters.BrowsePresenter;
import com.liskovsoft.smartyoutubetv2.common.app.presenters.PlaybackPresenter;
import com.liskovsoft.smartyoutubetv2.common.prefs.GeneralData;
import com.liskovsoft.smartyoutubetv2.common.utils.SimpleEditDialog;
import com.liskovsoft.smartyoutubetv2.common.utils.Utils;
import com.liskovsoft.smartyoutubetv2.tv.R;
import com.liskovsoft.smartyoutubetv2.tv.presenter.SettingsCardPresenter;
import com.liskovsoft.smartyoutubetv2.tv.ui.browse.interfaces.SettingsSection;
@@ -124,12 +125,12 @@ public class SettingsGridFragment extends GridFragment implements SettingsSectio
if (password == null) {
((SettingsItem) item).onClick.run();
} else {
SimpleEditDialog.show(
SimpleEditDialog.showPassword(
getContext(),
getContext().getString(R.string.enter_settings_password),
null,
newValue -> {
if (password.equals(newValue)) {
if (Utils.passwordMatch(password, newValue)) {
((SettingsItem) item).onClick.run();
return true;
}