Allow ignore content restrictions

This commit is contained in:
世界 2020-10-11 09:30:08 +00:00
parent f1d1f3df0c
commit df19b1b865
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
9 changed files with 35 additions and 22 deletions

View File

@ -5,8 +5,8 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
def verName = "7.1.3-preview02"
def verCode = 75
def verName = "7.1.3-rc03"
def verCode = 78
def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json")
@ -344,6 +344,9 @@ android {
}
full {
}
fullPlay {
versionNameSuffix '-play'
}
fullNoEmoji {
versionNameSuffix '-full-no-emoji'
}

View File

@ -13264,7 +13264,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
for (int a = 0, N = reasons.size(); a < N; a++) {
TLRPC.TL_restrictionReason reason = reasons.get(a);
if ("all".equals(reason.platform) || "android".equals(reason.platform)) {
if ("all".equals(reason.platform) || "android".equals(reason.platform) && !NekoConfig.ignoreContentRestrictions) {
return reason.text;
}
}
@ -13369,7 +13369,7 @@ public class MessagesController extends BaseController implements NotificationCe
closeLast = true;
}
}
if (reason != null) {
if (reason != null && !NekoConfig.ignoreContentRestrictions) {
showCantOpenAlert(fragment, reason);
} else {
Bundle args = new Bundle();

View File

@ -119,6 +119,8 @@ public class NekoConfig {
public static boolean autoPauseVideo;
public static boolean disableProximityEvents;
public static boolean ignoreContentRestrictions;
public static String getOpenPGPAppName() {
if (StrUtil.isNotBlank(openPGPApp)) {
@ -249,6 +251,8 @@ public class NekoConfig {
disableVibration = preferences.getBoolean("disableVibration", false);
autoPauseVideo = preferences.getBoolean("autoPauseVideo", false);
ignoreContentRestrictions = preferences.getBoolean("ignoreContentRestrictions", false);
}
public static void toggleShowAddToSavedMessages() {
@ -779,4 +783,10 @@ public class NekoConfig {
}
public static void toggleIgnoreContentRestrictions() {
preferences.edit().putBoolean("ignoreContentRestrictions",ignoreContentRestrictions = !ignoreContentRestrictions).apply();
}
}

View File

@ -17,6 +17,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.BuildConfig;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.R;
@ -44,6 +45,7 @@ import java.util.ArrayList;
import tw.nekomimi.nekogram.MessageHelper;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.NekoXConfig;
@SuppressLint("RtlHardcoded")
public class NekoExperimentalSettingsActivity extends BaseFragment {
@ -62,6 +64,7 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
private int mediaPreviewRow;
private int proxyAutoSwitchRow;
private int disableFilteringRow;
private int ignoreContentRestrictionsRow;
private int unlimitedFavedStickersRow;
private int unlimitedPinnedDialogsRow;
private int deleteAccountRow;
@ -124,6 +127,11 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
AndroidUtilities.runOnUIThread(() -> AlertsCreator.processError(currentAccount, error, this, req));
}
}));
} else if (position == ignoreContentRestrictionsRow) {
NekoConfig.toggleIgnoreContentRestrictions();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.ignoreContentRestrictions);
}
} else if (position == unlimitedFavedStickersRow) {
NekoConfig.toggleUnlimitedFavedStickers();
if (view instanceof TextCheckCell) {
@ -254,6 +262,7 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
mediaPreviewRow = rowCount++;
proxyAutoSwitchRow = rowCount++;
disableFilteringRow = rowCount++;
ignoreContentRestrictionsRow = !BuildConfig.VERSION_NAME.contains("play") || NekoXConfig.developerMode ? rowCount++ : -1;
unlimitedFavedStickersRow = rowCount++;
unlimitedPinnedDialogsRow = rowCount++;
deleteAccountRow = rowCount++;
@ -388,6 +397,8 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
if (position == disableFilteringRow) {
textCell.setTextAndValueAndCheck(LocaleController.getString("SensitiveDisableFiltering", R.string.SensitiveDisableFiltering), LocaleController.getString("SensitiveAbout", R.string.SensitiveAbout), sensitiveEnabled, true, true);
textCell.setEnabled(sensitiveCanChange, null);
} else if (position == ignoreContentRestrictionsRow) {
textCell.setTextAndValueAndCheck(LocaleController.getString("IgnoreContentRestrictions", R.string.IgnoreContentRestrictions), LocaleController.getString("IgnoreContentRestrictionsNotice", R.string.IgnoreContentRestrictionsNotice), NekoConfig.ignoreContentRestrictions, true, true);
} else if (position == unlimitedFavedStickersRow) {
textCell.setTextAndValueAndCheck(LocaleController.getString("UnlimitedFavoredStickers", R.string.UnlimitedFavoredStickers), LocaleController.getString("UnlimitedFavoredStickersAbout", R.string.UnlimitedFavoredStickersAbout), NekoConfig.unlimitedFavedStickers, true, true);
} else if (position == smoothKeyboardRow) {

View File

@ -54,7 +54,6 @@ public class NekoSettingsActivity extends BaseFragment {
private int googlePlayRow;
private int sourceCodeRow;
private int translationRow;
private int donateRow;
private int about2Row;
@Override
@ -104,8 +103,6 @@ public class NekoSettingsActivity extends BaseFragment {
presentFragment(new NekoExperimentalSettingsActivity());
} else if (position == channelRow) {
MessagesController.getInstance(currentAccount).openByUserName("NekogramX", this, 1);
} else if (position == donateRow) {
Browser.openUrl(getParentActivity(), "https://patreon.com/NekoXDev");
} else if (position == translationRow) {
Browser.openUrl(getParentActivity(), "https://nekox.crowdin.com/nekox");
} else if (position == googlePlayRow) {
@ -143,11 +140,6 @@ public class NekoSettingsActivity extends BaseFragment {
}
sourceCodeRow = rowCount++;
translationRow = rowCount++;
if ("release".equals(BuildConfig.BUILD_TYPE)) {
donateRow = -1;
} else {
donateRow = rowCount++;
}
about2Row = rowCount++;
if (listAdapter != null) {
@ -253,13 +245,6 @@ public class NekoSettingsActivity extends BaseFragment {
}
break;
}
case 6: {
TextDetailSettingsCell textCell = (TextDetailSettingsCell) holder.itemView;
if (position == donateRow) {
textCell.setTextAndValue(LocaleController.getString("Donate", R.string.Donate), LocaleController.getString("DonateAbout", R.string.DonateAbout), false);
}
break;
}
}
}
@ -316,8 +301,6 @@ public class NekoSettingsActivity extends BaseFragment {
return 3;
} else if (position == categoriesRow || position == aboutRow) {
return 4;
} else if (position == donateRow) {
return 6;
}
return 2;
}

View File

@ -177,4 +177,6 @@
<string name="PGPImportPrivate">导入私钥</string>
<string name="ShareMyKey">分享我的公钥</string>
<string name="DisableVibration">禁用振动</string>
<string name="IgnoreContentRestrictions">忽略内容限制</string>
<string name="IgnoreContentRestrictionsNotice">在本机忽略消息针对 Android 平台的限制. 这可能在未来被服务器禁止, 您需要自行评估在当地的合法性.</string>
</resources>

View File

@ -233,5 +233,8 @@
<string name="ShareMyKey">Share My Public Key</string>
<string name="DisableVibration">Disable Vibration</string>
<string name="IgnoreContentRestrictions">Ignore Content Restrictions</string>
<string name="IgnoreContentRestrictionsNotice">Ignores android restrictions on messages locally. This may be banned by the server in the future, and you will need to evaluate the local legality of this option yourself.</string>
</resources>

View File

@ -1,3 +1,3 @@
#!/bin/bash
./gradlew TMessagesProj:publishFullRelease
./gradlew TMessagesProj:publishFullPlayRelease

View File

@ -13,4 +13,5 @@ fi
rm -rf build/release &&
mkdir -p build/release &&
find TMessagesProj/build/outputs/apk -name "*.apk" -exec cp {} build/release \; &&
rm -f build/release/*-debug.apk &&
ghr -delete -n "$1" "$1" build/release