Refine codes

This commit is contained in:
luvletter2333 2021-09-21 00:36:48 +08:00
parent 219549f0fd
commit 87a6a5b5e9
No known key found for this signature in database
GPG Key ID: BFD68B892BECC1D8
3 changed files with 1 additions and 125 deletions

View File

@ -2922,7 +2922,6 @@ public class AndroidUtilities {
public static boolean openForView(MessageObject message, Activity activity) {
return openForView(message, activity, null);
// NekoX: 8.0.1, resourcesProvider null??
}
public static boolean openForView(MessageObject message, Activity activity, Theme.ResourcesProvider resourcesProvider) {

View File

@ -1799,7 +1799,6 @@ public class SecretChatHelper extends BaseController {
}
}
// NekoX: 8.0.1 - still int??
public void declineSecretChat(int chat_id, boolean revoke) {
declineSecretChat(chat_id, revoke, 0);
}

View File

@ -4088,130 +4088,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
}
private boolean processOnClickOrPress(final int position) {
// NekoX: move long lick actions to click
// Merge it in 8.0.1, need to be fixed
if (position == usernameRow || position == setUsernameRow) {
final String username;
if (userId != 0) {
final TLRPC.User user = getMessagesController().getUser(userId);
if (user == null || user.username == null) {
return false;
}
username = user.username;
} else if (chatId != 0) {
final TLRPC.Chat chat = getMessagesController().getChat(chatId);
if (chat == null || chat.username == null) {
return false;
}
username = chat.username;
} else {
return false;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setItems(new CharSequence[]{LocaleController.getString("Copy", R.string.Copy)}, (dialogInterface, i) -> {
if (i == 0) {
try {
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
String text;
if (userId != 0) {
text = "@" + username;
BulletinFactory.of(this).createCopyBulletin(LocaleController.getString("UsernameCopied", R.string.UsernameCopied)).show();
} else {
text = "https://" + MessagesController.getInstance(UserConfig.selectedAccount).linkPrefix + "/" + username;
BulletinFactory.of(this).createCopyBulletin(LocaleController.getString("LinkCopied", R.string.LinkCopied)).show();
}
android.content.ClipData clip = android.content.ClipData.newPlainText("label", text);
clipboard.setPrimaryClip(clip);
} catch (Exception e) {
FileLog.e(e);
}
}
});
showDialog(builder.create());
return true;
} else if (position == phoneRow || position == numberRow) {
final TLRPC.User user = getMessagesController().getUser(userId);
if (user == null || user.phone == null || user.phone.length() == 0 || getParentActivity() == null) {
return false;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
ArrayList<CharSequence> items = new ArrayList<>();
final ArrayList<Integer> actions = new ArrayList<>();
if (position == phoneRow) {
if (userInfo != null && userInfo.phone_calls_available) {
items.add(LocaleController.getString("CallViaTelegram", R.string.CallViaTelegram));
actions.add(2);
if (Build.VERSION.SDK_INT >= 18 && userInfo.video_calls_available) {
items.add(LocaleController.getString("VideoCallViaTelegram", R.string.VideoCallViaTelegram));
actions.add(3);
}
}
items.add(LocaleController.getString("Call", R.string.Call));
actions.add(0);
}
items.add(LocaleController.getString("Copy", R.string.Copy));
actions.add(1);
builder.setItems(items.toArray(new CharSequence[0]), (dialogInterface, i) -> {
i = actions.get(i);
if (i == 0) {
try {
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:+" + user.phone));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getParentActivity().startActivityForResult(intent, 500);
} catch (Exception e) {
FileLog.e(e);
}
} else if (i == 1) {
try {
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
android.content.ClipData clip = android.content.ClipData.newPlainText("label", "+" + user.phone);
clipboard.setPrimaryClip(clip);
BulletinFactory.of(this).createCopyBulletin(LocaleController.getString("PhoneCopied", R.string.PhoneCopied)).show();
} catch (Exception e) {
FileLog.e(e);
}
} else if (i == 2 || i == 3) {
VoIPHelper.startCall(user, i == 3, userInfo != null && userInfo.video_calls_available, getParentActivity(), userInfo, getAccountInstance());
}
});
showDialog(builder.create());
return true;
} else if (position == channelInfoRow || position == userInfoRow || position == locationRow || position == bioRow) {
if (position == bioRow && (userInfo == null || TextUtils.isEmpty(userInfo.about))) {
return false;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setItems(new CharSequence[]{LocaleController.getString("Copy", R.string.Copy)}, (dialogInterface, i) -> {
try {
String about;
if (position == locationRow) {
about = chatInfo != null && chatInfo.location instanceof TLRPC.TL_channelLocation ? ((TLRPC.TL_channelLocation) chatInfo.location).address : null;
} else if (position == channelInfoRow) {
about = chatInfo != null ? chatInfo.about : null;
} else {
about = userInfo != null ? userInfo.about : null;
}
if (TextUtils.isEmpty(about)) {
return;
}
AndroidUtilities.addToClipboard(about);
if (position == bioRow) {
BulletinFactory.of(this).createCopyBulletin(LocaleController.getString("BioCopied", R.string.BioCopied)).show();
} else {
BulletinFactory.of(this).createCopyBulletin(LocaleController.getString("TextCopied", R.string.TextCopied)).show();
}
} catch (Exception e) {
FileLog.e(e);
}
});
showDialog(builder.create());
return true;
}
return false;
// NekoX: move long lick actions to click
}
private void leaveChatPressed() {