mirror of https://github.com/NekoX-Dev/NekoX.git
Add follow request & Minor fixes
This commit is contained in:
parent
eda943636d
commit
d0a1ee27ef
|
@ -1,8 +1,8 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
|
||||
def verName = "7.2.1.2"
|
||||
def verCode = 119
|
||||
def verName = "7.2.1.3"
|
||||
def verCode = 120
|
||||
|
||||
def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json")
|
||||
|
||||
|
@ -112,7 +112,7 @@ android {
|
|||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
//noinspection ExpiredTargetSdkVersion,OldTargetApi
|
||||
targetSdkVersion 28
|
||||
targetSdkVersion 29
|
||||
|
||||
versionName verName
|
||||
versionCode verCode
|
||||
|
|
|
@ -120,6 +120,7 @@
|
|||
android:roundIcon="@mipmap/ic_launcher"
|
||||
android:supportsRtl="false"
|
||||
android:theme="@style/Theme.TMessages.Start"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
tools:replace="android:supportsRtl">
|
||||
|
||||
<activity
|
||||
|
|
|
@ -164,6 +164,7 @@ import java.util.ArrayList;
|
|||
import tw.nekomimi.nekogram.NekoConfig;
|
||||
import tw.nekomimi.nekogram.utils.PrivacyUtil;
|
||||
import tw.nekomimi.nekogram.utils.ProxyUtil;
|
||||
import tw.nekomimi.nekogram.utils.UpdateUtil;
|
||||
import tw.nekomimi.nekogram.utils.VibrateUtil;
|
||||
|
||||
public class DialogsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
@ -3052,6 +3053,7 @@ private int lastMeasuredTopPadding;
|
|||
}
|
||||
|
||||
PrivacyUtil.postCheckAll(getParentActivity(), currentAccount);
|
||||
UpdateUtil.postCheckFollowChannel(getParentActivity(), currentAccount);
|
||||
|
||||
return fragmentView;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ import android.os.Parcelable;
|
|||
import android.os.StatFs;
|
||||
import android.os.SystemClock;
|
||||
import android.provider.ContactsContract;
|
||||
import android.se.omapi.Session;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Base64;
|
||||
import android.view.ActionMode;
|
||||
|
@ -120,7 +119,6 @@ import org.telegram.ui.Components.StickersAlert;
|
|||
import org.telegram.ui.Components.Switch;
|
||||
import org.telegram.ui.Components.TermsOfServiceView;
|
||||
import org.telegram.ui.Components.ThemeEditorView;
|
||||
import org.telegram.ui.Components.UndoView;
|
||||
import org.telegram.ui.Components.voip.VoIPHelper;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -141,7 +139,6 @@ import tw.nekomimi.nekogram.settings.NekoSettingsActivity;
|
|||
import tw.nekomimi.nekogram.sub.SubInfo;
|
||||
import tw.nekomimi.nekogram.sub.SubManager;
|
||||
import tw.nekomimi.nekogram.utils.AlertUtil;
|
||||
import tw.nekomimi.nekogram.utils.PrivacyUtil;
|
||||
import tw.nekomimi.nekogram.utils.ProxyUtil;
|
||||
import tw.nekomimi.nekogram.utils.UIUtil;
|
||||
|
||||
|
@ -979,9 +976,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
|||
if (UserConfig.getInstance(account).unacceptedTermsOfService != null) {
|
||||
showTosActivity(account, UserConfig.getInstance(account).unacceptedTermsOfService);
|
||||
}
|
||||
if (afterLogin) {
|
||||
PrivacyUtil.postCheckAll(this, account);
|
||||
}
|
||||
updateCurrentConnectionState(currentAccount);
|
||||
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.updateUserStatus, (Object) null);
|
||||
}
|
||||
|
@ -2477,7 +2471,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
|||
return;
|
||||
} else if (loginToken != null) {
|
||||
BottomBuilder builder = new BottomBuilder(this);
|
||||
builder.addTitle(LocaleController.getString("AuthAnotherClientScan", R.string.AuthAnotherClientScan), LocaleController.getString("QRLoginNotice",R.string.QRLoginNotice));
|
||||
builder.addTitle(LocaleController.getString("AuthAnotherClientScan", R.string.AuthAnotherClientScan), LocaleController.getString("QRLoginNotice", R.string.QRLoginNotice));
|
||||
builder.addItem(LocaleController.getString("QRLoginConfirm", R.string.QRLoginConfirm), R.drawable.baseline_security_24, true, (c) -> {
|
||||
AlertDialog progressDialog = new AlertDialog(this, 3);
|
||||
progressDialog.setCanCacnel(false);
|
||||
|
@ -2509,7 +2503,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
|||
} else {
|
||||
text = LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred) + "\n" + error.text;
|
||||
}
|
||||
AlertUtil.showSimpleAlert(this, LocaleController.getString("AuthAnotherClient", R.string.AuthAnotherClient), text);
|
||||
AlertUtil.showSimpleAlert(this, LocaleController.getString("AuthAnotherClient", R.string.AuthAnotherClient), text);
|
||||
});
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -408,7 +408,7 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
|
|||
true,
|
||||
LocaleController.getString("UseCustomApiNotice", R.string.UseCustomApiNotice));
|
||||
|
||||
builder.addRadioItem(LocaleController.getString("", R.string.CustomApiNo), NekoXConfig.customApi == 0, (cell) -> {
|
||||
builder.addRadioItem(LocaleController.getString("CustomApiNo", R.string.CustomApiNo), NekoXConfig.customApi == 0, (cell) -> {
|
||||
|
||||
targetApi.set(0);
|
||||
|
||||
|
|
|
@ -428,7 +428,7 @@ public class ProxyListActivity extends BaseFragment implements NotificationCente
|
|||
|
||||
if (!errors.isEmpty()) {
|
||||
|
||||
status.append(LocaleController.getString("", R.string.ErrorsInImport));
|
||||
status.append(LocaleController.getString("ErrorsInImport", R.string.ErrorsInImport));
|
||||
|
||||
for (Map.Entry<String, String> error : errors.entrySet()) {
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ object PrivacyUtil {
|
|||
|
||||
val builder = AlertDialog.Builder(ctx)
|
||||
|
||||
builder.setTitle(LocaleController.getString("", R.string.PrivacyNotice))
|
||||
builder.setTitle(LocaleController.getString("PrivacyNotice", R.string.PrivacyNotice))
|
||||
|
||||
builder.setMessage(AndroidUtilities.replaceTags(when (type) {
|
||||
0 -> LocaleController.getString("PrivacyNoticePhoneVisible", R.string.PrivacyNoticePhoneVisible)
|
||||
|
@ -207,7 +207,7 @@ object PrivacyUtil {
|
|||
|
||||
}
|
||||
|
||||
builder.setNeutralButton(LocaleController.getString("Cancel", R.string.Cancel), null)
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null)
|
||||
|
||||
builder.setNeutralButton(LocaleController.getString("DoNotRemindAgain", R.string.DoNotRemindAgain)) { _, _ ->
|
||||
|
||||
|
@ -233,7 +233,7 @@ object PrivacyUtil {
|
|||
|
||||
val builder = AlertDialog.Builder(ctx)
|
||||
|
||||
builder.setTitle(LocaleController.getString("", R.string.PrivacyNotice))
|
||||
builder.setTitle(LocaleController.getString("PrivacyNotice", R.string.PrivacyNotice))
|
||||
|
||||
builder.setMessage(AndroidUtilities.replaceTags(LocaleController.getString("PrivacyNotice2fa", R.string.PrivacyNotice2fa)))
|
||||
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
package tw.nekomimi.nekogram.utils
|
||||
|
||||
import android.content.Context
|
||||
import org.telegram.messenger.*
|
||||
import org.telegram.messenger.browser.Browser
|
||||
import org.telegram.tgnet.ConnectionsManager
|
||||
import org.telegram.tgnet.TLObject
|
||||
import org.telegram.tgnet.TLRPC
|
||||
import org.telegram.ui.ActionBar.AlertDialog
|
||||
|
||||
object UpdateUtil {
|
||||
|
||||
const val channelUsername = "NekogramX"
|
||||
|
||||
@JvmStatic
|
||||
fun postCheckFollowChannel(ctx: Context, currentAccount: Int) = UIUtil.runOnIoDispatcher {
|
||||
|
||||
if (MessagesController.getMainSettings(currentAccount).getBoolean("update_channel_skip", false)) return@runOnIoDispatcher
|
||||
|
||||
val messagesCollector = MessagesController.getInstance(currentAccount)
|
||||
val connectionsManager = ConnectionsManager.getInstance(currentAccount)
|
||||
val messagesStorage = MessagesStorage.getInstance(currentAccount)
|
||||
val updateChannel = messagesCollector.getUserOrChat(channelUsername)
|
||||
|
||||
if (updateChannel is TLRPC.Chat) checkFollowChannel(ctx, currentAccount, updateChannel) else {
|
||||
connectionsManager.sendRequest(TLRPC.TL_contacts_resolveUsername().apply {
|
||||
username = channelUsername
|
||||
}) { response: TLObject?, error: TLRPC.TL_error? ->
|
||||
if (error == null) {
|
||||
val res = response as TLRPC.TL_contacts_resolvedPeer
|
||||
if (res.chats.isEmpty()) {
|
||||
return@sendRequest
|
||||
}
|
||||
messagesCollector.putChats(res.chats, false)
|
||||
messagesStorage.putUsersAndChats(res.users, res.chats, false, true)
|
||||
checkFollowChannel(ctx, currentAccount, res.chats.find { it.username == channelUsername }!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun checkFollowChannel(ctx: Context, currentAccount: Int, channel: TLRPC.Chat) {
|
||||
|
||||
if (!channel.left || channel.kicked) {
|
||||
|
||||
// MessagesController.getMainSettings(currentAccount).edit().putBoolean("update_channel_skip", true).apply()
|
||||
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
UIUtil.runOnUIThread {
|
||||
|
||||
val messagesCollector = MessagesController.getInstance(currentAccount)
|
||||
val userConfig = UserConfig.getInstance(currentAccount)
|
||||
|
||||
val builder = AlertDialog.Builder(ctx)
|
||||
|
||||
builder.setTitle(LocaleController.getString("FCTitle", R.string.FCTitle))
|
||||
builder.setMessage(LocaleController.getString("FCInfo", R.string.FCInfo))
|
||||
|
||||
builder.setPositiveButton(LocaleController.getString("ChannelJoin", R.string.ChannelJoin)) { _, _ ->
|
||||
messagesCollector.addUserToChat(channel.id, userConfig.currentUser, null, 0, null, null, null)
|
||||
Browser.openUrl(ctx, "https://t.me/$channelUsername")
|
||||
}
|
||||
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null)
|
||||
|
||||
builder.setNeutralButton(LocaleController.getString("DoNotRemindAgain", R.string.DoNotRemindAgain)) { _, _ ->
|
||||
MessagesController.getMainSettings(currentAccount).edit().putBoolean("update_channel_skip", true).apply()
|
||||
}
|
||||
|
||||
builder.show()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -258,4 +258,7 @@
|
|||
<string name="StorageReset">Clear Storage</string>
|
||||
<string name="StorageResetInfo">All data of this application will be permanently deleted (and try to log out of all accounts first).</string>
|
||||
|
||||
<string name="FCTitle">About application updates</string>
|
||||
<string name="FCInfo">Follow our announcements and updates channel?</string>
|
||||
|
||||
</resources>
|
Loading…
Reference in New Issue