mirror of https://github.com/NekoX-Dev/NekoX.git
Update to 7.5.0 (2243)
This commit is contained in:
parent
3480f19272
commit
92cfded3fc
|
@ -26,9 +26,9 @@ dependencies {
|
|||
compileOnly 'org.checkerframework:checker-qual:2.5.2'
|
||||
compileOnly 'org.checkerframework:checker-compat-qual:2.5.0'
|
||||
implementation 'com.google.firebase:firebase-messaging:21.0.1'
|
||||
implementation 'com.google.firebase:firebase-config:20.0.2'
|
||||
implementation 'com.google.firebase:firebase-datatransport:17.0.10'
|
||||
implementation 'com.google.firebase:firebase-appindexing:19.1.0'
|
||||
implementation 'com.google.firebase:firebase-config:20.0.3'
|
||||
implementation 'com.google.firebase:firebase-datatransport:17.0.11'
|
||||
implementation 'com.google.firebase:firebase-appindexing:19.2.0'
|
||||
implementation 'com.google.android.gms:play-services-maps:17.0.0'
|
||||
implementation 'com.google.android.gms:play-services-auth:19.0.0'
|
||||
implementation 'com.google.android.gms:play-services-vision:16.2.0'
|
||||
|
@ -290,7 +290,7 @@ android {
|
|||
}
|
||||
}
|
||||
|
||||
defaultConfig.versionCode = 2227
|
||||
defaultConfig.versionCode = 2243
|
||||
|
||||
applicationVariants.all { variant ->
|
||||
variant.outputs.all { output ->
|
||||
|
@ -309,7 +309,7 @@ android {
|
|||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 29
|
||||
versionName "7.4.2"
|
||||
versionName "7.5.0"
|
||||
|
||||
vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']
|
||||
|
||||
|
|
|
@ -136,6 +136,9 @@ void NetworkManager::start() {
|
|||
if (!_enableP2P) {
|
||||
flags |= cricket::PORTALLOCATOR_DISABLE_UDP;
|
||||
flags |= cricket::PORTALLOCATOR_DISABLE_STUN;
|
||||
uint32_t candidateFilter = _portAllocator->candidate_filter();
|
||||
candidateFilter &= ~(cricket::CF_REFLEXIVE);
|
||||
_portAllocator->SetCandidateFilter(candidateFilter);
|
||||
}
|
||||
|
||||
if (_proxy) {
|
||||
|
|
|
@ -199,15 +199,24 @@
|
|||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<!-- <activity-->
|
||||
<!-- android:name="org.telegram.ui.ShortcutWidgetConfigActivity"-->
|
||||
<!-- android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"-->
|
||||
<!-- android:hardwareAccelerated="@bool/useHardwareAcceleration"-->
|
||||
<!-- android:windowSoftInputMode="adjustPan">-->
|
||||
<!-- <intent-filter android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round">-->
|
||||
<!-- <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>-->
|
||||
<!-- </intent-filter>-->
|
||||
<!-- </activity>-->
|
||||
<activity
|
||||
android:name="org.telegram.ui.ChatsWidgetConfigActivity"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
|
||||
android:hardwareAccelerated="@bool/useHardwareAcceleration"
|
||||
android:windowSoftInputMode="adjustPan">
|
||||
<intent-filter android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round">
|
||||
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="org.telegram.ui.ContactsWidgetConfigActivity"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
|
||||
android:hardwareAccelerated="@bool/useHardwareAcceleration"
|
||||
android:windowSoftInputMode="adjustPan">
|
||||
<intent-filter android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round">
|
||||
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<!-- <activity-->
|
||||
<!-- android:name="org.telegram.ui.FeedWidgetConfigActivity"-->
|
||||
<!-- android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"-->
|
||||
|
@ -415,17 +424,29 @@
|
|||
android:name=".voip.CallNotificationSoundProvider"
|
||||
android:exported="true"/>
|
||||
|
||||
<!-- <receiver android:name=".ShortcutWidgetProvider">-->
|
||||
<!-- <meta-data android:name="android.appwidget.provider"-->
|
||||
<!-- android:resource="@xml/shortcut_widget_info" />-->
|
||||
<!-- <intent-filter>-->
|
||||
<!-- <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />-->
|
||||
<!-- </intent-filter>-->
|
||||
<!-- </receiver>-->
|
||||
<receiver android:name=".ChatsWidgetProvider">
|
||||
<meta-data android:name="android.appwidget.provider"
|
||||
android:resource="@xml/chats_widget_info" />
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<!-- <service android:name=".ShortcutWidgetService"-->
|
||||
<!-- android:permission="android.permission.BIND_REMOTEVIEWS"-->
|
||||
<!-- android:exported="false" />-->
|
||||
<service android:name=".ChatsWidgetService"
|
||||
android:permission="android.permission.BIND_REMOTEVIEWS"
|
||||
android:exported="false" />
|
||||
|
||||
<receiver android:name=".ContactsWidgetProvider">
|
||||
<meta-data android:name="android.appwidget.provider"
|
||||
android:resource="@xml/contacts_widget_info" />
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<service android:name=".ContactsWidgetService"
|
||||
android:permission="android.permission.BIND_REMOTEVIEWS"
|
||||
android:exported="false" />
|
||||
|
||||
<!-- <receiver android:name=".FeedWidgetProvider">-->
|
||||
<!-- <meta-data android:name="android.appwidget.provider"-->
|
||||
|
|
|
@ -53,6 +53,8 @@ public final class QRCodeWriter {
|
|||
private int imageBlockX;
|
||||
private int sideQuadSize;
|
||||
|
||||
private int imageSize;
|
||||
|
||||
public Bitmap encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType, ?> hints, Bitmap bitmap, Context context) throws WriterException {
|
||||
|
||||
if (contents.isEmpty()) {
|
||||
|
@ -118,7 +120,7 @@ public final class QRCodeWriter {
|
|||
imageBloks++;
|
||||
}
|
||||
imageBlockX = (inputWidth - imageBloks) / 2;
|
||||
int imageSize = imageBloks * multiple - 24;
|
||||
imageSize = imageBloks * multiple - 24;
|
||||
int imageX = (size - imageSize) / 2;
|
||||
|
||||
for (int a = 0; a < 3; a++) {
|
||||
|
@ -235,4 +237,8 @@ public final class QRCodeWriter {
|
|||
}
|
||||
return x >= 0 && y >= 0 && x < input.getWidth() && y < input.getHeight() && input.get(x, y) == 1;
|
||||
}
|
||||
|
||||
public int getImageSize() {
|
||||
return imageSize;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,6 +138,7 @@ import java.io.OutputStream;
|
|||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.IDN;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
@ -2986,6 +2987,9 @@ public class AndroidUtilities {
|
|||
if (path != null) {
|
||||
if (path.startsWith("/socks") || path.startsWith("/proxy")) {
|
||||
address = data.getQueryParameter("server");
|
||||
if (AndroidUtilities.checkHostForPunycode(address)) {
|
||||
address = IDN.toASCII(address, IDN.ALLOW_UNASSIGNED);
|
||||
}
|
||||
port = data.getQueryParameter("port");
|
||||
user = data.getQueryParameter("user");
|
||||
password = data.getQueryParameter("pass");
|
||||
|
@ -2999,6 +3003,9 @@ public class AndroidUtilities {
|
|||
url = url.replace("tg:proxy", "tg://telegram.org").replace("tg://proxy", "tg://telegram.org").replace("tg://socks", "tg://telegram.org").replace("tg:socks", "tg://telegram.org");
|
||||
data = Uri.parse(url);
|
||||
address = data.getQueryParameter("server");
|
||||
if (AndroidUtilities.checkHostForPunycode(address)) {
|
||||
address = IDN.toASCII(address, IDN.ALLOW_UNASSIGNED);
|
||||
}
|
||||
port = data.getQueryParameter("port");
|
||||
user = data.getQueryParameter("user");
|
||||
password = data.getQueryParameter("pass");
|
||||
|
@ -3558,13 +3565,10 @@ public class AndroidUtilities {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean shouldShowUrlInAlert(String url) {
|
||||
public static boolean checkHostForPunycode(String url) {
|
||||
boolean hasLatin = false;
|
||||
boolean hasNonLatin = false;
|
||||
try {
|
||||
Uri uri = Uri.parse(url);
|
||||
url = uri.getHost();
|
||||
|
||||
for (int a = 0, N = url.length(); a < N; a++) {
|
||||
char ch = url.charAt(a);
|
||||
if (ch == '.' || ch == '-' || ch == '/' || ch == '+' || ch >= '0' && ch <= '9') {
|
||||
|
@ -3579,13 +3583,23 @@ public class AndroidUtilities {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
return hasLatin && hasNonLatin;
|
||||
}
|
||||
|
||||
public static boolean shouldShowUrlInAlert(String url) {
|
||||
try {
|
||||
Uri uri = Uri.parse(url);
|
||||
url = uri.getHost();
|
||||
return checkHostForPunycode(url);
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void scrollToFragmentRow(ActionBarLayout parentLayout, String rowName) {
|
||||
if (parentLayout == null || rowName == null) {
|
||||
return;
|
||||
|
|
|
@ -18,8 +18,8 @@ public class BuildVars {
|
|||
public static boolean LOGS_ENABLED = false;
|
||||
public static boolean USE_CLOUD_STRINGS = true;
|
||||
public static boolean CHECK_UPDATES = true;
|
||||
public static int BUILD_VERSION = 2227;
|
||||
public static String BUILD_VERSION_STRING = "7.4.0";
|
||||
public static int BUILD_VERSION = 2243;
|
||||
public static String BUILD_VERSION_STRING = "7.5.0";
|
||||
public static int APP_ID = 4;
|
||||
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
|
||||
public static String APPCENTER_HASH = "a5b5c4f5-51da-dedc-9918-d9766a22ca7c";
|
||||
|
|
|
@ -813,7 +813,7 @@ public class ChatObject {
|
|||
}
|
||||
|
||||
public static boolean canWriteToChat(TLRPC.Chat chat) {
|
||||
return !isChannel(chat) || chat.creator || chat.admin_rights != null && chat.admin_rights.post_messages || !chat.broadcast;
|
||||
return !isChannel(chat) || chat.creator || chat.admin_rights != null && chat.admin_rights.post_messages || !chat.broadcast && !chat.gigagroup || chat.gigagroup && ChatObject.hasAdminRights(chat);
|
||||
}
|
||||
|
||||
public static String getBannedRightsString(TLRPC.TL_chatBannedRights bannedRights) {
|
||||
|
|
|
@ -0,0 +1,114 @@
|
|||
package org.telegram.messenger;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.PendingIntent;
|
||||
import android.appwidget.AppWidgetManager;
|
||||
import android.appwidget.AppWidgetProvider;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
import org.telegram.ui.EditWidgetActivity;
|
||||
import org.telegram.ui.LaunchActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ChatsWidgetProvider extends AppWidgetProvider {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
super.onReceive(context, intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
||||
super.onUpdate(context, appWidgetManager, appWidgetIds);
|
||||
for (int i = 0; i < appWidgetIds.length; i++) {
|
||||
int appWidgetId = appWidgetIds[i];
|
||||
updateWidget(context, appWidgetManager, appWidgetId, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions) {
|
||||
updateWidget(context, appWidgetManager, appWidgetId, true);
|
||||
super.onAppWidgetOptionsChanged(context, appWidgetManager, appWidgetId, newOptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleted(Context context, int[] appWidgetIds) {
|
||||
super.onDeleted(context, appWidgetIds);
|
||||
SharedPreferences preferences = context.getSharedPreferences("shortcut_widget", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
for (int a = 0; a < appWidgetIds.length; a++) {
|
||||
int accountId = preferences.getInt("account" + appWidgetIds[a], -1);
|
||||
if (accountId >= 0) {
|
||||
AccountInstance accountInstance = AccountInstance.getInstance(accountId);
|
||||
accountInstance.getMessagesStorage().clearWidgetDialogs(appWidgetIds[a]);
|
||||
}
|
||||
editor.remove("account" + appWidgetIds[a]);
|
||||
editor.remove("type" + appWidgetIds[a]);
|
||||
editor.remove("deleted" + appWidgetIds[a]);
|
||||
}
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
private static int getCellsForSize(int size) {
|
||||
int n = 2;
|
||||
while (70 * n - 30 < size) {
|
||||
++n;
|
||||
}
|
||||
return n - 1;
|
||||
}
|
||||
|
||||
public static void updateWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId, boolean edit) {
|
||||
Bundle options = appWidgetManager.getAppWidgetOptions(appWidgetId);
|
||||
int minHeight = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT);
|
||||
int rows = getCellsForSize(minHeight);
|
||||
|
||||
Intent intent2 = new Intent(context, ChatsWidgetService.class);
|
||||
intent2.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
|
||||
intent2.setData(Uri.parse(intent2.toUri(Intent.URI_INTENT_SCHEME)));
|
||||
|
||||
SharedPreferences preferences = context.getSharedPreferences("shortcut_widget", Activity.MODE_PRIVATE);
|
||||
boolean deleted = preferences.getBoolean("deleted" + appWidgetId, false);
|
||||
int id;
|
||||
if (!deleted) {
|
||||
int accountId = preferences.getInt("account" + appWidgetId, -1);
|
||||
ArrayList<Long> selectedDialogs = new ArrayList<>();
|
||||
if (accountId >= 0) {
|
||||
AccountInstance.getInstance(accountId).getMessagesStorage().getWidgetDialogIds(appWidgetId, EditWidgetActivity.TYPE_CHATS, selectedDialogs, null, null, false);
|
||||
}
|
||||
|
||||
if (rows == 1 || selectedDialogs.size() <= 1) {
|
||||
id = R.layout.shortcut_widget_layout_1;
|
||||
} else if (rows == 2 || selectedDialogs.size() <= 2) {
|
||||
id = R.layout.shortcut_widget_layout_2;
|
||||
} else if (rows == 3 || selectedDialogs.size() <= 3) {
|
||||
id = R.layout.shortcut_widget_layout_3;
|
||||
} else {
|
||||
id = R.layout.shortcut_widget_layout_4;
|
||||
}
|
||||
} else {
|
||||
id = R.layout.shortcut_widget_layout_1;
|
||||
}
|
||||
RemoteViews rv = new RemoteViews(context.getPackageName(), id);
|
||||
rv.setRemoteAdapter(appWidgetId, R.id.list_view, intent2);
|
||||
rv.setEmptyView(R.id.list_view, R.id.empty_view);
|
||||
|
||||
Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class);
|
||||
intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
rv.setPendingIntentTemplate(R.id.list_view, contentIntent);
|
||||
appWidgetManager.updateAppWidget(appWidgetId, rv);
|
||||
if (edit) {
|
||||
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.list_view);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,20 +27,21 @@ import org.telegram.tgnet.TLRPC;
|
|||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Components.AvatarDrawable;
|
||||
import org.telegram.ui.Components.ForegroundColorSpanThemable;
|
||||
import org.telegram.ui.EditWidgetActivity;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ShortcutWidgetService extends RemoteViewsService {
|
||||
public class ChatsWidgetService extends RemoteViewsService {
|
||||
@Override
|
||||
public RemoteViewsFactory onGetViewFactory(Intent intent) {
|
||||
return new ShortcutRemoteViewsFactory(getApplicationContext(), intent);
|
||||
return new ChatsRemoteViewsFactory(getApplicationContext(), intent);
|
||||
}
|
||||
}
|
||||
|
||||
class ShortcutRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactory {
|
||||
class ChatsRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactory {
|
||||
|
||||
private ArrayList<Integer> dids = new ArrayList<>();
|
||||
private ArrayList<Long> dids = new ArrayList<>();
|
||||
private Context mContext;
|
||||
private int appWidgetId;
|
||||
private AccountInstance accountInstance;
|
||||
|
@ -48,8 +49,9 @@ class ShortcutRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactor
|
|||
private RectF bitmapRect;
|
||||
private LongSparseArray<TLRPC.Dialog> dialogs = new LongSparseArray<>();
|
||||
private LongSparseArray<MessageObject> messageObjects = new LongSparseArray<>();
|
||||
private boolean deleted;
|
||||
|
||||
public ShortcutRemoteViewsFactory(Context context, Intent intent) {
|
||||
public ChatsRemoteViewsFactory(Context context, Intent intent) {
|
||||
mContext = context;
|
||||
Theme.createDialogsResources(context);
|
||||
appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
|
||||
|
@ -58,6 +60,7 @@ class ShortcutRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactor
|
|||
if (accountId >= 0) {
|
||||
accountInstance = AccountInstance.getInstance(accountId);
|
||||
}
|
||||
deleted = preferences.getBoolean("deleted" + appWidgetId, false) || accountInstance == null;
|
||||
}
|
||||
|
||||
public void onCreate() {
|
||||
|
@ -69,33 +72,58 @@ class ShortcutRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactor
|
|||
}
|
||||
|
||||
public int getCount() {
|
||||
return dids.size();
|
||||
if (deleted) {
|
||||
return 1;
|
||||
}
|
||||
return dids.size() + 1;
|
||||
}
|
||||
|
||||
public RemoteViews getViewAt(int position) {
|
||||
Integer id = dids.get(position);
|
||||
String name;
|
||||
if (deleted) {
|
||||
RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.widget_deleted);
|
||||
rv.setTextViewText(R.id.widget_deleted_text, LocaleController.getString("WidgetLoggedOff", R.string.WidgetLoggedOff));
|
||||
return rv;
|
||||
} else if (position >= dids.size()) {
|
||||
RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.widget_edititem);
|
||||
rv.setTextViewText(R.id.widget_edititem_text, LocaleController.getString("TapToEditWidget", R.string.TapToEditWidget));
|
||||
Bundle extras = new Bundle();
|
||||
extras.putInt("appWidgetId", appWidgetId);
|
||||
extras.putInt("appWidgetType", EditWidgetActivity.TYPE_CHATS);
|
||||
extras.putInt("currentAccount", accountInstance.getCurrentAccount());
|
||||
Intent fillInIntent = new Intent();
|
||||
fillInIntent.putExtras(extras);
|
||||
rv.setOnClickFillInIntent(R.id.widget_edititem, fillInIntent);
|
||||
return rv;
|
||||
}
|
||||
Long id = dids.get(position);
|
||||
String name = "";
|
||||
|
||||
TLRPC.FileLocation photoPath = null;
|
||||
TLRPC.User user = null;
|
||||
TLRPC.Chat chat = null;
|
||||
if (id > 0) {
|
||||
user = accountInstance.getMessagesController().getUser(id);
|
||||
if (UserObject.isUserSelf(user)) {
|
||||
name = LocaleController.getString("SavedMessages", R.string.SavedMessages);
|
||||
} else if (UserObject.isReplyUser(user)) {
|
||||
name = LocaleController.getString("RepliesTitle", R.string.RepliesTitle);
|
||||
} else {
|
||||
name = ContactsController.formatName(user.first_name, user.last_name);
|
||||
}
|
||||
if (!UserObject.isReplyUser(user) && !UserObject.isUserSelf(user) && user.photo != null && user.photo.photo_small != null && user.photo.photo_small.volume_id != 0 && user.photo.photo_small.local_id != 0) {
|
||||
photoPath = user.photo.photo_small;
|
||||
user = accountInstance.getMessagesController().getUser((int) (long) id);
|
||||
if (user != null) {
|
||||
if (UserObject.isUserSelf(user)) {
|
||||
name = LocaleController.getString("SavedMessages", R.string.SavedMessages);
|
||||
} else if (UserObject.isReplyUser(user)) {
|
||||
name = LocaleController.getString("RepliesTitle", R.string.RepliesTitle);
|
||||
} else if (UserObject.isDeleted(user)) {
|
||||
name = LocaleController.getString("HiddenName", R.string.HiddenName);
|
||||
} else {
|
||||
name = ContactsController.formatName(user.first_name, user.last_name);
|
||||
}
|
||||
if (!UserObject.isReplyUser(user) && !UserObject.isUserSelf(user) && user != null && user.photo != null && user.photo.photo_small != null && user.photo.photo_small.volume_id != 0 && user.photo.photo_small.local_id != 0) {
|
||||
photoPath = user.photo.photo_small;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
chat = accountInstance.getMessagesController().getChat(-id);
|
||||
name = chat.title;
|
||||
if (chat.photo != null && chat.photo.photo_small != null && chat.photo.photo_small.volume_id != 0 && chat.photo.photo_small.local_id != 0) {
|
||||
photoPath = chat.photo.photo_small;
|
||||
chat = accountInstance.getMessagesController().getChat(-(int) (long) id);
|
||||
if (chat != null) {
|
||||
name = chat.title;
|
||||
if (chat.photo != null && chat.photo.photo_small != null && chat.photo.photo_small.volume_id != 0 && chat.photo.photo_small.local_id != 0) {
|
||||
photoPath = chat.photo.photo_small;
|
||||
}
|
||||
}
|
||||
}
|
||||
RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.shortcut_widget_item);
|
||||
|
@ -159,7 +187,7 @@ class ShortcutRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactor
|
|||
}
|
||||
CharSequence messageString;
|
||||
CharSequence messageNameString;
|
||||
int textColor = 0xff212121;
|
||||
int textColor = mContext.getResources().getColor(R.color.widget_text);
|
||||
if (message.messageOwner instanceof TLRPC.TL_messageService) {
|
||||
if (ChatObject.isChannel(chat) && (message.messageOwner.action instanceof TLRPC.TL_messageActionHistoryClear ||
|
||||
message.messageOwner.action instanceof TLRPC.TL_messageActionChannelMigrateFrom)) {
|
||||
|
@ -167,7 +195,7 @@ class ShortcutRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactor
|
|||
} else {
|
||||
messageString = message.messageText;
|
||||
}
|
||||
textColor = 0xff3c7eb0;
|
||||
textColor = mContext.getResources().getColor(R.color.widget_action_text);
|
||||
} else {
|
||||
boolean needEmoji = true;
|
||||
if (chat != null && chat.id > 0 && fromChat == null && (!ChatObject.isChannel(chat) || ChatObject.isMegagroup(chat))) {
|
||||
|
@ -199,7 +227,7 @@ class ShortcutRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactor
|
|||
}
|
||||
stringBuilder = SpannableStringBuilder.valueOf(String.format(messageFormat, emoji + mess.replace('\n', ' '), messageNameString));
|
||||
} else if (message.messageOwner.media != null && !message.isMediaEmpty()) {
|
||||
textColor = 0xff3c7eb0;
|
||||
textColor = mContext.getResources().getColor(R.color.widget_action_text);
|
||||
String innerMessage;
|
||||
if (message.messageOwner.media instanceof TLRPC.TL_messageMediaPoll) {
|
||||
TLRPC.TL_messageMediaPoll mediaPoll = (TLRPC.TL_messageMediaPoll) message.messageOwner.media;
|
||||
|
@ -245,7 +273,7 @@ class ShortcutRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactor
|
|||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
messageString = stringBuilder;//Emoji.replaceEmoji(stringBuilder, Theme.dialogs_messagePaint[paintIndex].getFontMetricsInt(), AndroidUtilities.dp(20), false);
|
||||
messageString = stringBuilder;
|
||||
} else {
|
||||
if (message.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto && message.messageOwner.media.photo instanceof TLRPC.TL_photoEmpty && message.messageOwner.media.ttl_seconds != 0) {
|
||||
messageString = LocaleController.getString("AttachPhotoExpired", R.string.AttachPhotoExpired);
|
||||
|
@ -278,23 +306,31 @@ class ShortcutRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactor
|
|||
AndroidUtilities.highlightText(messageString, message.highlightedWords);
|
||||
}
|
||||
if (message.messageOwner.media != null && !message.isMediaEmpty()) {
|
||||
textColor = 0xff3c7eb0;
|
||||
textColor = mContext.getResources().getColor(R.color.widget_action_text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rv.setTextViewText(R.id.shortcut_widget_item_time, LocaleController.stringForMessageListDate(message.messageOwner.date));
|
||||
rv.setTextViewText(R.id.shortcut_widget_item_message, messageString);
|
||||
rv.setTextViewText(R.id.shortcut_widget_item_message, messageString.toString());
|
||||
rv.setTextColor(R.id.shortcut_widget_item_message, textColor);
|
||||
} else {
|
||||
if (dialog != null) {
|
||||
if (dialog != null && dialog.last_message_date != 0) {
|
||||
rv.setTextViewText(R.id.shortcut_widget_item_time, LocaleController.stringForMessageListDate(dialog.last_message_date));
|
||||
} else {
|
||||
rv.setTextViewText(R.id.shortcut_widget_item_time, "");
|
||||
}
|
||||
rv.setTextViewText(R.id.shortcut_widget_item_message, "");
|
||||
}
|
||||
if (dialog != null && dialog.unread_count > 0) {
|
||||
rv.setTextViewText(R.id.shortcut_widget_item_badge, String.format("%d", dialog.unread_count));
|
||||
rv.setViewVisibility(R.id.shortcut_widget_item_badge, View.VISIBLE);
|
||||
if (accountInstance.getMessagesController().isDialogMuted(dialog.id)) {
|
||||
rv.setInt(R.id.shortcut_widget_item_badge, "setBackgroundResource", R.drawable.widget_counter_muted);
|
||||
} else {
|
||||
rv.setInt(R.id.shortcut_widget_item_badge, "setBackgroundResource", R.drawable.widget_counter);
|
||||
}
|
||||
} else {
|
||||
rv.setViewVisibility(R.id.shortcut_widget_item_badge, View.GONE);
|
||||
}
|
||||
|
@ -302,9 +338,9 @@ class ShortcutRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactor
|
|||
Bundle extras = new Bundle();
|
||||
|
||||
if (id > 0) {
|
||||
extras.putInt("userId", id);
|
||||
extras.putInt("userId", (int) (long) id);
|
||||
} else {
|
||||
extras.putInt("chatId", -id);
|
||||
extras.putInt("chatId", -(int) (long) id);
|
||||
}
|
||||
extras.putInt("currentAccount", accountInstance.getCurrentAccount());
|
||||
|
||||
|
@ -322,7 +358,7 @@ class ShortcutRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactor
|
|||
}
|
||||
|
||||
public int getViewTypeCount() {
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
public long getItemId(int position) {
|
||||
|
@ -342,7 +378,7 @@ class ShortcutRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactor
|
|||
ArrayList<TLRPC.User> users = new ArrayList<>();
|
||||
ArrayList<TLRPC.Chat> chats = new ArrayList<>();
|
||||
LongSparseArray<TLRPC.Message> messages = new LongSparseArray<>();
|
||||
accountInstance.getMessagesStorage().getWidgetDialogs(appWidgetId, dids, dialogs, messages, users, chats);
|
||||
accountInstance.getMessagesStorage().getWidgetDialogs(appWidgetId, 0, dids, dialogs, messages, users, chats);
|
||||
accountInstance.getMessagesController().putUsers(users, true);
|
||||
accountInstance.getMessagesController().putChats(chats, true);
|
||||
messageObjects.clear();
|
|
@ -30,6 +30,7 @@ import org.telegram.PhoneFormat.PhoneFormat;
|
|||
import org.telegram.messenger.support.SparseLongArray;
|
||||
import org.telegram.tgnet.ConnectionsManager;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.Components.Bulletin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -1081,7 +1082,7 @@ public class ContactsController extends BaseController {
|
|||
}
|
||||
|
||||
if (!toDelete.isEmpty()) {
|
||||
deleteContact(toDelete);
|
||||
deleteContact(toDelete, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -2206,7 +2207,7 @@ public class ContactsController extends BaseController {
|
|||
}, ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagCanCompress);
|
||||
}
|
||||
|
||||
public void deleteContact(final ArrayList<TLRPC.User> users) {
|
||||
public void deleteContact(final ArrayList<TLRPC.User> users, boolean showBulletin) {
|
||||
if (users == null || users.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -2221,6 +2222,7 @@ public class ContactsController extends BaseController {
|
|||
uids.add(user.id);
|
||||
req.id.add(inputUser);
|
||||
}
|
||||
String userName = users.get(0).first_name;
|
||||
getConnectionsManager().sendRequest(req, (response, error) -> {
|
||||
if (error != null) {
|
||||
return;
|
||||
|
@ -2263,6 +2265,9 @@ public class ContactsController extends BaseController {
|
|||
}
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_NAME);
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.contactsDidLoad);
|
||||
if (showBulletin) {
|
||||
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.showBulletin, Bulletin.TYPE_ERROR, LocaleController.formatString("DeletedFromYourContacts", R.string.DeletedFromYourContacts, userName));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,116 @@
|
|||
package org.telegram.messenger;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.PendingIntent;
|
||||
import android.appwidget.AppWidgetManager;
|
||||
import android.appwidget.AppWidgetProvider;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
import org.telegram.ui.EditWidgetActivity;
|
||||
import org.telegram.ui.LaunchActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ContactsWidgetProvider extends AppWidgetProvider {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
super.onReceive(context, intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
||||
super.onUpdate(context, appWidgetManager, appWidgetIds);
|
||||
for (int i = 0; i < appWidgetIds.length; i++) {
|
||||
int appWidgetId = appWidgetIds[i];
|
||||
updateWidget(context, appWidgetManager, appWidgetId, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleted(Context context, int[] appWidgetIds) {
|
||||
super.onDeleted(context, appWidgetIds);
|
||||
SharedPreferences preferences = context.getSharedPreferences("shortcut_widget", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
for (int a = 0; a < appWidgetIds.length; a++) {
|
||||
int accountId = preferences.getInt("account" + appWidgetIds[a], -1);
|
||||
if (accountId >= 0) {
|
||||
AccountInstance accountInstance = AccountInstance.getInstance(accountId);
|
||||
accountInstance.getMessagesStorage().clearWidgetDialogs(appWidgetIds[a]);
|
||||
}
|
||||
editor.remove("account" + appWidgetIds[a]);
|
||||
editor.remove("type" + appWidgetIds[a]);
|
||||
editor.remove("deleted" + appWidgetIds[a]);
|
||||
}
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions) {
|
||||
updateWidget(context, appWidgetManager, appWidgetId, true);
|
||||
super.onAppWidgetOptionsChanged(context, appWidgetManager, appWidgetId, newOptions);
|
||||
}
|
||||
|
||||
private static int getCellsForSize(int size) {
|
||||
int n = 2;
|
||||
while (86 * n - 30 < size) {
|
||||
++n;
|
||||
}
|
||||
return n - 1;
|
||||
}
|
||||
|
||||
public static void updateWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId, boolean edit) {
|
||||
Bundle options = appWidgetManager.getAppWidgetOptions(appWidgetId);
|
||||
int minHeight = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT);
|
||||
int rows = getCellsForSize(minHeight);
|
||||
|
||||
Intent intent2 = new Intent(context, ContactsWidgetService.class);
|
||||
intent2.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
|
||||
intent2.setData(Uri.parse(intent2.toUri(Intent.URI_INTENT_SCHEME)));
|
||||
|
||||
SharedPreferences preferences = context.getSharedPreferences("shortcut_widget", Activity.MODE_PRIVATE);
|
||||
boolean deleted = preferences.getBoolean("deleted" + appWidgetId, false);
|
||||
int id;
|
||||
if (!deleted) {
|
||||
int accountId = preferences.getInt("account" + appWidgetId, -1);
|
||||
ArrayList<Long> selectedDialogs = new ArrayList<>();
|
||||
if (accountId >= 0) {
|
||||
AccountInstance.getInstance(accountId).getMessagesStorage().getWidgetDialogIds(appWidgetId, EditWidgetActivity.TYPE_CONTACTS, selectedDialogs, null, null, false);
|
||||
}
|
||||
int count = (int) Math.ceil(selectedDialogs.size() / 2.0f);
|
||||
|
||||
if (rows == 1 || count <= 1) {
|
||||
id = R.layout.contacts_widget_layout_1;
|
||||
} else if (rows == 2 || count <= 2) {
|
||||
id = R.layout.contacts_widget_layout_2;
|
||||
} else if (rows == 3 || count <= 3) {
|
||||
id = R.layout.contacts_widget_layout_3;
|
||||
} else {
|
||||
id = R.layout.contacts_widget_layout_4;
|
||||
}
|
||||
} else {
|
||||
id = R.layout.contacts_widget_layout_1;
|
||||
}
|
||||
RemoteViews rv = new RemoteViews(context.getPackageName(), id);
|
||||
rv.setRemoteAdapter(appWidgetId, R.id.list_view, intent2);
|
||||
rv.setEmptyView(R.id.list_view, R.id.empty_view);
|
||||
|
||||
Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class);
|
||||
intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
rv.setPendingIntentTemplate(R.id.list_view, contentIntent);
|
||||
|
||||
appWidgetManager.updateAppWidget(appWidgetId, rv);
|
||||
if (edit) {
|
||||
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.list_view);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,229 @@
|
|||
package org.telegram.messenger;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.appwidget.AppWidgetManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.BitmapShader;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Shader;
|
||||
import android.os.Bundle;
|
||||
import android.util.LongSparseArray;
|
||||
import android.view.View;
|
||||
import android.widget.RemoteViews;
|
||||
import android.widget.RemoteViewsService;
|
||||
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Components.AvatarDrawable;
|
||||
import org.telegram.ui.EditWidgetActivity;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ContactsWidgetService extends RemoteViewsService {
|
||||
@Override
|
||||
public RemoteViewsFactory onGetViewFactory(Intent intent) {
|
||||
return new ContactsRemoteViewsFactory(getApplicationContext(), intent);
|
||||
}
|
||||
}
|
||||
|
||||
class ContactsRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactory {
|
||||
|
||||
private ArrayList<Long> dids = new ArrayList<>();
|
||||
private Context mContext;
|
||||
private int appWidgetId;
|
||||
private AccountInstance accountInstance;
|
||||
private Paint roundPaint;
|
||||
private RectF bitmapRect;
|
||||
private LongSparseArray<TLRPC.Dialog> dialogs = new LongSparseArray<>();
|
||||
private boolean deleted;
|
||||
|
||||
public ContactsRemoteViewsFactory(Context context, Intent intent) {
|
||||
mContext = context;
|
||||
Theme.createDialogsResources(context);
|
||||
appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
|
||||
SharedPreferences preferences = context.getSharedPreferences("shortcut_widget", Activity.MODE_PRIVATE);
|
||||
int accountId = preferences.getInt("account" + appWidgetId, -1);
|
||||
if (accountId >= 0) {
|
||||
accountInstance = AccountInstance.getInstance(accountId);
|
||||
}
|
||||
deleted = preferences.getBoolean("deleted" + appWidgetId, false) || accountInstance == null;
|
||||
}
|
||||
|
||||
public void onCreate() {
|
||||
ApplicationLoader.postInitApplication();
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
if (deleted) {
|
||||
return 1;
|
||||
}
|
||||
int count = (int) Math.ceil(dids.size() / 2.0f);
|
||||
return count + 1;
|
||||
}
|
||||
|
||||
public RemoteViews getViewAt(int position) {
|
||||
if (deleted) {
|
||||
RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.widget_deleted);
|
||||
rv.setTextViewText(R.id.widget_deleted_text, LocaleController.getString("WidgetLoggedOff", R.string.WidgetLoggedOff));
|
||||
return rv;
|
||||
} else if (position >= getCount() - 1) {
|
||||
RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.widget_edititem);
|
||||
rv.setTextViewText(R.id.widget_edititem_text, LocaleController.getString("TapToEditWidgetShort", R.string.TapToEditWidgetShort));
|
||||
Bundle extras = new Bundle();
|
||||
extras.putInt("appWidgetId", appWidgetId);
|
||||
extras.putInt("appWidgetType", EditWidgetActivity.TYPE_CONTACTS);
|
||||
extras.putInt("currentAccount", accountInstance.getCurrentAccount());
|
||||
Intent fillInIntent = new Intent();
|
||||
fillInIntent.putExtras(extras);
|
||||
rv.setOnClickFillInIntent(R.id.widget_edititem, fillInIntent);
|
||||
return rv;
|
||||
}
|
||||
RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.contacts_widget_item);
|
||||
for (int a = 0; a < 2; a++) {
|
||||
int num = position * 2 + a;
|
||||
if (num >= dids.size()) {
|
||||
rv.setViewVisibility(a == 0 ? R.id.contacts_widget_item1 : R.id.contacts_widget_item2, View.INVISIBLE);
|
||||
} else {
|
||||
rv.setViewVisibility(a == 0 ? R.id.contacts_widget_item1 : R.id.contacts_widget_item2, View.VISIBLE);
|
||||
|
||||
Long id = dids.get(position * 2 + a);
|
||||
String name;
|
||||
|
||||
TLRPC.FileLocation photoPath = null;
|
||||
TLRPC.User user = null;
|
||||
TLRPC.Chat chat = null;
|
||||
if (id > 0) {
|
||||
user = accountInstance.getMessagesController().getUser((int) (long) id);
|
||||
if (UserObject.isUserSelf(user)) {
|
||||
name = LocaleController.getString("SavedMessages", R.string.SavedMessages);
|
||||
} else if (UserObject.isReplyUser(user)) {
|
||||
name = LocaleController.getString("RepliesTitle", R.string.RepliesTitle);
|
||||
} else if (UserObject.isDeleted(user)) {
|
||||
name = LocaleController.getString("HiddenName", R.string.HiddenName);
|
||||
} else {
|
||||
name = UserObject.getFirstName(user);
|
||||
}
|
||||
if (!UserObject.isReplyUser(user) && !UserObject.isUserSelf(user) && user != null && user.photo != null && user.photo.photo_small != null && user.photo.photo_small.volume_id != 0 && user.photo.photo_small.local_id != 0) {
|
||||
photoPath = user.photo.photo_small;
|
||||
}
|
||||
} else {
|
||||
chat = accountInstance.getMessagesController().getChat(-(int) (long) id);
|
||||
name = chat.title;
|
||||
if (chat.photo != null && chat.photo.photo_small != null && chat.photo.photo_small.volume_id != 0 && chat.photo.photo_small.local_id != 0) {
|
||||
photoPath = chat.photo.photo_small;
|
||||
}
|
||||
}
|
||||
rv.setTextViewText(a == 0 ? R.id.contacts_widget_item_text1 : R.id.contacts_widget_item_text2, name);
|
||||
|
||||
try {
|
||||
Bitmap bitmap = null;
|
||||
if (photoPath != null) {
|
||||
File path = FileLoader.getPathToAttach(photoPath, true);
|
||||
bitmap = BitmapFactory.decodeFile(path.toString());
|
||||
}
|
||||
|
||||
int size = AndroidUtilities.dp(48);
|
||||
Bitmap result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
|
||||
result.eraseColor(Color.TRANSPARENT);
|
||||
Canvas canvas = new Canvas(result);
|
||||
if (bitmap == null) {
|
||||
AvatarDrawable avatarDrawable;
|
||||
if (user != null) {
|
||||
avatarDrawable = new AvatarDrawable(user);
|
||||
if (UserObject.isReplyUser(user)) {
|
||||
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_REPLIES);
|
||||
} else if (UserObject.isUserSelf(user)) {
|
||||
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED);
|
||||
}
|
||||
} else {
|
||||
avatarDrawable = new AvatarDrawable(chat);
|
||||
}
|
||||
avatarDrawable.setBounds(0, 0, size, size);
|
||||
avatarDrawable.draw(canvas);
|
||||
} else {
|
||||
BitmapShader shader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
|
||||
if (roundPaint == null) {
|
||||
roundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
bitmapRect = new RectF();
|
||||
}
|
||||
float scale = size / (float) bitmap.getWidth();
|
||||
canvas.save();
|
||||
canvas.scale(scale, scale);
|
||||
roundPaint.setShader(shader);
|
||||
bitmapRect.set(0, 0, bitmap.getWidth(), bitmap.getHeight());
|
||||
canvas.drawRoundRect(bitmapRect, bitmap.getWidth(), bitmap.getHeight(), roundPaint);
|
||||
canvas.restore();
|
||||
}
|
||||
canvas.setBitmap(null);
|
||||
rv.setImageViewBitmap(a == 0 ? R.id.contacts_widget_item_avatar1 : R.id.contacts_widget_item_avatar2, result);
|
||||
} catch (Throwable e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
|
||||
TLRPC.Dialog dialog = dialogs.get(id);
|
||||
|
||||
if (dialog != null && dialog.unread_count > 0) {
|
||||
rv.setTextViewText(a == 0 ? R.id.contacts_widget_item_badge1 : R.id.contacts_widget_item_badge2, String.format("%d", dialog.unread_count));
|
||||
rv.setViewVisibility(a == 0 ? R.id.contacts_widget_item_badge_bg1 : R.id.contacts_widget_item_badge_bg2, View.VISIBLE);
|
||||
} else {
|
||||
rv.setViewVisibility(a == 0 ? R.id.contacts_widget_item_badge_bg1 : R.id.contacts_widget_item_badge_bg2, View.GONE);
|
||||
}
|
||||
|
||||
Bundle extras = new Bundle();
|
||||
|
||||
if (id > 0) {
|
||||
extras.putInt("userId", (int) (long) id);
|
||||
} else {
|
||||
extras.putInt("chatId", -(int) (long) id);
|
||||
}
|
||||
extras.putInt("currentAccount", accountInstance.getCurrentAccount());
|
||||
|
||||
Intent fillInIntent = new Intent();
|
||||
fillInIntent.putExtras(extras);
|
||||
rv.setOnClickFillInIntent(a == 0 ? R.id.contacts_widget_item1 : R.id.contacts_widget_item2, fillInIntent);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
public RemoteViews getLoadingView() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getViewTypeCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
public boolean hasStableIds() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onDataSetChanged() {
|
||||
dids.clear();
|
||||
if (accountInstance == null || !accountInstance.getUserConfig().isClientActivated()) {
|
||||
return;
|
||||
}
|
||||
ArrayList<TLRPC.User> users = new ArrayList<>();
|
||||
ArrayList<TLRPC.Chat> chats = new ArrayList<>();
|
||||
LongSparseArray<TLRPC.Message> messages = new LongSparseArray<>();
|
||||
accountInstance.getMessagesStorage().getWidgetDialogs(appWidgetId, 1, dids, dialogs, messages, users, chats);
|
||||
accountInstance.getMessagesController().putUsers(users, true);
|
||||
accountInstance.getMessagesController().putChats(chats, true);
|
||||
}
|
||||
}
|
|
@ -33,7 +33,7 @@ public class FeedWidgetProvider extends AppWidgetProvider {
|
|||
public void onDeleted(Context context, int[] appWidgetIds) {
|
||||
super.onDeleted(context, appWidgetIds);
|
||||
for (int a = 0; a < appWidgetIds.length; a++) {
|
||||
SharedPreferences preferences = context.getSharedPreferences("feed_widget", Activity.MODE_PRIVATE);
|
||||
SharedPreferences preferences = context.getSharedPreferences("shortcut_widget", Activity.MODE_PRIVATE);
|
||||
preferences.edit().remove("account" + appWidgetIds[a]).remove("dialogId" + appWidgetIds[a]).commit();
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class FeedWidgetProvider extends AppWidgetProvider {
|
|||
|
||||
Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class);
|
||||
intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class FeedRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactory, N
|
|||
public FeedRemoteViewsFactory(Context context, Intent intent) {
|
||||
mContext = context;
|
||||
appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
|
||||
SharedPreferences preferences = context.getSharedPreferences("feed_widget", Activity.MODE_PRIVATE);
|
||||
SharedPreferences preferences = context.getSharedPreferences("shortcut_widget", Activity.MODE_PRIVATE);
|
||||
int accountId = preferences.getInt("account" + appWidgetId, -1);
|
||||
if (accountId >= 0) {
|
||||
dialogId = preferences.getLong("dialogId" + appWidgetId, 0);
|
||||
|
|
|
@ -1216,7 +1216,12 @@ public class FileLoadOperation {
|
|||
FileLog.e(e);
|
||||
}
|
||||
} else {
|
||||
renameResult = cacheFileTemp.renameTo(cacheFileFinal);
|
||||
try {
|
||||
renameResult = cacheFileTemp.renameTo(cacheFileFinal);
|
||||
} catch (Exception e) {
|
||||
renameResult = false;
|
||||
FileLog.e(e);
|
||||
}
|
||||
}
|
||||
if (!renameResult) {
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
|
|
|
@ -883,7 +883,7 @@ public class FileLoader extends BaseController {
|
|||
} else if (message.media instanceof TLRPC.TL_messageMediaPhoto) {
|
||||
ArrayList<TLRPC.PhotoSize> sizes = message.media.photo.sizes;
|
||||
if (sizes.size() > 0) {
|
||||
TLRPC.PhotoSize sizeFull = getClosestPhotoSizeWithSize(sizes, AndroidUtilities.getPhotoSize());
|
||||
TLRPC.PhotoSize sizeFull = getClosestPhotoSizeWithSize(sizes, AndroidUtilities.getPhotoSize(), false, null, true);
|
||||
if (sizeFull != null) {
|
||||
return getAttachFileName(sizeFull);
|
||||
}
|
||||
|
@ -930,7 +930,7 @@ public class FileLoader extends BaseController {
|
|||
} else if (message.media instanceof TLRPC.TL_messageMediaPhoto) {
|
||||
ArrayList<TLRPC.PhotoSize> sizes = message.media.photo.sizes;
|
||||
if (sizes.size() > 0) {
|
||||
TLRPC.PhotoSize sizeFull = getClosestPhotoSizeWithSize(sizes, AndroidUtilities.getPhotoSize());
|
||||
TLRPC.PhotoSize sizeFull = getClosestPhotoSizeWithSize(sizes, AndroidUtilities.getPhotoSize(), false, null, true);
|
||||
if (sizeFull != null) {
|
||||
return getPathToAttach(sizeFull, message.media.ttl_seconds != 0);
|
||||
}
|
||||
|
@ -1032,10 +1032,10 @@ public class FileLoader extends BaseController {
|
|||
}
|
||||
|
||||
public static TLRPC.PhotoSize getClosestPhotoSizeWithSize(ArrayList<TLRPC.PhotoSize> sizes, int side, boolean byMinSide) {
|
||||
return getClosestPhotoSizeWithSize(sizes, side, byMinSide, null);
|
||||
return getClosestPhotoSizeWithSize(sizes, side, byMinSide, null, false);
|
||||
}
|
||||
|
||||
public static TLRPC.PhotoSize getClosestPhotoSizeWithSize(ArrayList<TLRPC.PhotoSize> sizes, int side, boolean byMinSide, TLRPC.PhotoSize toIgnore) {
|
||||
public static TLRPC.PhotoSize getClosestPhotoSizeWithSize(ArrayList<TLRPC.PhotoSize> sizes, int side, boolean byMinSide, TLRPC.PhotoSize toIgnore, boolean ignoreStripped) {
|
||||
if (sizes == null || sizes.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
@ -1043,7 +1043,7 @@ public class FileLoader extends BaseController {
|
|||
TLRPC.PhotoSize closestObject = null;
|
||||
for (int a = 0; a < sizes.size(); a++) {
|
||||
TLRPC.PhotoSize obj = sizes.get(a);
|
||||
if (obj == null || obj == toIgnore || obj instanceof TLRPC.TL_photoSizeEmpty || obj instanceof TLRPC.TL_photoPathSize) {
|
||||
if (obj == null || obj == toIgnore || obj instanceof TLRPC.TL_photoSizeEmpty || obj instanceof TLRPC.TL_photoPathSize || ignoreStripped && obj instanceof TLRPC.TL_photoStrippedSize) {
|
||||
continue;
|
||||
}
|
||||
if (byMinSide) {
|
||||
|
|
|
@ -816,15 +816,15 @@ public class ImageLoader {
|
|||
}
|
||||
if (args.length >= 5) {
|
||||
if ("c1".equals(args[4])) {
|
||||
colors = new int[]{0xf77e41, 0xca907a, 0xffb139, 0xedc5a5, 0xffd140, 0xf7e3c3, 0xffdf79, 0xfbefd6};
|
||||
colors = new int[]{0xf77e41, 0xcb7b55, 0xffb139, 0xf6b689, 0xffd140, 0xffcda7, 0xffdf79, 0xffdfc5};
|
||||
} else if ("c2".equals(args[4])) {
|
||||
colors = new int[]{0xf77e41, 0xaa7c60, 0xffb139, 0xc8a987, 0xffd140, 0xddc89f, 0xffdf79, 0xe6d6b2};
|
||||
colors = new int[]{0xf77e41, 0xa45a38, 0xffb139, 0xdf986b, 0xffd140, 0xedb183, 0xffdf79, 0xf4c3a0};
|
||||
} else if ("c3".equals(args[4])) {
|
||||
colors = new int[]{0xf77e41, 0x8c6148, 0xffb139, 0xad8562, 0xffd140, 0xc49e76, 0xffdf79, 0xd4b188};
|
||||
colors = new int[]{0xf77e41, 0x703a17, 0xffb139, 0xab673d, 0xffd140, 0xc37f4e, 0xffdf79, 0xd89667};
|
||||
} else if ("c4".equals(args[4])) {
|
||||
colors = new int[]{0xf77e41, 0x6e3c2c, 0xffb139, 0x925a34, 0xffd140, 0xa16e46, 0xffdf79, 0xac7a52};
|
||||
colors = new int[]{0xf77e41, 0x4a2409, 0xffb139, 0x7d3e0e, 0xffd140, 0x965529, 0xffdf79, 0xa96337};
|
||||
} else if ("c5".equals(args[4])) {
|
||||
colors = new int[]{0xf77e41, 0x291c12, 0xffb139, 0x472a22, 0xffd140, 0x573b30, 0xffdf79, 0x68493c};
|
||||
colors = new int[]{0xf77e41, 0x200f0a, 0xffb139, 0x412924, 0xffd140, 0x593d37, 0xffdf79, 0x63453f};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ import android.text.TextUtils;
|
|||
import android.text.style.CharacterStyle;
|
||||
import android.util.LongSparseArray;
|
||||
import android.util.SparseArray;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.telegram.SQLite.SQLiteCursor;
|
||||
import org.telegram.SQLite.SQLiteDatabase;
|
||||
|
@ -305,9 +304,9 @@ public class MediaDataController extends BaseController {
|
|||
int maxCount;
|
||||
if (type == TYPE_FAVE) {
|
||||
if (remove) {
|
||||
Toast.makeText(ApplicationLoader.applicationContext, LocaleController.getString("RemovedFromFavorites", R.string.RemovedFromFavorites), Toast.LENGTH_SHORT).show();
|
||||
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.showBulletin, Bulletin.TYPE_STICKER, document, StickerSetBulletinLayout.TYPE_REMOVED_FROM_FAVORITES);
|
||||
} else {
|
||||
Toast.makeText(ApplicationLoader.applicationContext, LocaleController.getString("AddedToFavorites", R.string.AddedToFavorites), Toast.LENGTH_SHORT).show();
|
||||
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.showBulletin, Bulletin.TYPE_STICKER, document, StickerSetBulletinLayout.TYPE_ADDED_TO_FAVORITES);
|
||||
}
|
||||
TLRPC.TL_messages_faveSticker req = new TLRPC.TL_messages_faveSticker();
|
||||
req.id = new TLRPC.TL_inputDocument();
|
||||
|
@ -328,7 +327,7 @@ public class MediaDataController extends BaseController {
|
|||
maxCount = getMessagesController().maxFaveStickersCount;
|
||||
} else {
|
||||
if (type == TYPE_IMAGE && remove) {
|
||||
Toast.makeText(ApplicationLoader.applicationContext, LocaleController.getString("RemovedFromRecent", R.string.RemovedFromRecent), Toast.LENGTH_SHORT).show();
|
||||
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.showBulletin, Bulletin.TYPE_STICKER, document, StickerSetBulletinLayout.TYPE_REMOVED_FROM_RECENT);
|
||||
TLRPC.TL_messages_saveRecentSticker req = new TLRPC.TL_messages_saveRecentSticker();
|
||||
req.id = new TLRPC.TL_inputDocument();
|
||||
req.id.id = document.id;
|
||||
|
@ -3897,16 +3896,26 @@ public class MediaDataController extends BaseController {
|
|||
getMessagesController().putUsers(users, isCache);
|
||||
getMessagesController().putChats(chats, isCache);
|
||||
});
|
||||
int checkedCount = 0;
|
||||
for (int a = 0, N = results.size(); a < N; a++) {
|
||||
messageObjects.add(new MessageObject(currentAccount, results.get(a), usersDict, chatsDict, false, false));
|
||||
TLRPC.Message message = results.get(a);
|
||||
if (message.media instanceof TLRPC.TL_messageMediaDocument || message.media instanceof TLRPC.TL_messageMediaPhoto) {
|
||||
checkedCount++;
|
||||
}
|
||||
messageObjects.add(new MessageObject(currentAccount, message, usersDict, chatsDict, false, checkedCount < 30));
|
||||
}
|
||||
return messageObjects;
|
||||
} else {
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
getMessagesController().putUsers(users, isCache);
|
||||
getMessagesController().putChats(chats, isCache);
|
||||
int checkedCount = 0;
|
||||
for (int a = 0, N = results.size(); a < N; a++) {
|
||||
messageObjects.add(new MessageObject(currentAccount, results.get(a), usersDict, chatsDict, false, false));
|
||||
TLRPC.Message message = results.get(a);
|
||||
if (message.media instanceof TLRPC.TL_messageMediaDocument || message.media instanceof TLRPC.TL_messageMediaPhoto) {
|
||||
checkedCount++;
|
||||
}
|
||||
messageObjects.add(new MessageObject(currentAccount, message, usersDict, chatsDict, false, checkedCount < 30));
|
||||
}
|
||||
AndroidUtilities.runOnUIThread(() -> getNotificationCenter().postNotificationName(NotificationCenter.didLoadPinnedMessages, messageObjects.get(0).getDialogId(), null, true, messageObjects, null, 0, -1, false));
|
||||
});
|
||||
|
|
|
@ -1136,11 +1136,6 @@ public class MessageObject {
|
|||
int offset = str.indexOf("%1$s");
|
||||
rights = new StringBuilder(String.format(str, getUserName(whoUser, messageOwner.entities, offset)));
|
||||
} else {
|
||||
String str = LocaleController.getString("EventLogPromoted", R.string.EventLogPromoted);
|
||||
int offset = str.indexOf("%1$s");
|
||||
rights = new StringBuilder(String.format(str, getUserName(whoUser, messageOwner.entities, offset)));
|
||||
rights.append("\n");
|
||||
|
||||
TLRPC.TL_chatAdminRights o = prev_participant.admin_rights;
|
||||
TLRPC.TL_chatAdminRights n = new_participant.admin_rights;
|
||||
if (o == null) {
|
||||
|
@ -1149,6 +1144,15 @@ public class MessageObject {
|
|||
if (n == null) {
|
||||
n = new TLRPC.TL_chatAdminRights();
|
||||
}
|
||||
String str;
|
||||
if (n.other) {
|
||||
str = LocaleController.getString("EventLogPromotedNoRights", R.string.EventLogPromotedNoRights);
|
||||
} else {
|
||||
str = LocaleController.getString("EventLogPromoted", R.string.EventLogPromoted);
|
||||
}
|
||||
int offset = str.indexOf("%1$s");
|
||||
rights = new StringBuilder(String.format(str, getUserName(whoUser, messageOwner.entities, offset)));
|
||||
rights.append("\n");
|
||||
if (!TextUtils.equals(prev_participant.rank, new_participant.rank)) {
|
||||
if (TextUtils.isEmpty(new_participant.rank)) {
|
||||
rights.append('\n').append('-').append(' ');
|
||||
|
@ -1190,7 +1194,7 @@ public class MessageObject {
|
|||
rights.append(LocaleController.getString("EventLogPromotedBanUsers", R.string.EventLogPromotedBanUsers));
|
||||
}
|
||||
if (o.manage_call != n.manage_call) {
|
||||
rights.append('\n').append(n.ban_users ? '+' : '-').append(' ');
|
||||
rights.append('\n').append(n.manage_call ? '+' : '-').append(' ');
|
||||
rights.append(LocaleController.getString("EventLogPromotedManageCall", R.string.EventLogPromotedManageCall));
|
||||
}
|
||||
}
|
||||
|
@ -1668,6 +1672,51 @@ public class MessageObject {
|
|||
} else {
|
||||
messageText = replaceWithLink(LocaleController.getString("EventLogVoiceChatAllowedToSpeak", R.string.EventLogVoiceChatAllowedToSpeak), "un1", fromUser);
|
||||
}
|
||||
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionParticipantJoinByInvite) {
|
||||
TLRPC.TL_channelAdminLogEventActionParticipantJoinByInvite action = (TLRPC.TL_channelAdminLogEventActionParticipantJoinByInvite) event.action;
|
||||
messageText = replaceWithLink(LocaleController.getString("ActionInviteUser", R.string.ActionInviteUser), "un1", fromUser);
|
||||
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionExportedInviteDelete) {
|
||||
TLRPC.TL_channelAdminLogEventActionExportedInviteDelete action = (TLRPC.TL_channelAdminLogEventActionExportedInviteDelete) event.action;
|
||||
messageText = replaceWithLink(LocaleController.formatString("ActionDeletedInviteLink", R.string.ActionDeletedInviteLink, action.invite.link), "un1", fromUser);
|
||||
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionExportedInviteRevoke) {
|
||||
TLRPC.TL_channelAdminLogEventActionExportedInviteRevoke action = (TLRPC.TL_channelAdminLogEventActionExportedInviteRevoke) event.action;
|
||||
messageText = replaceWithLink(LocaleController.formatString("ActionRevokedInviteLink", R.string.ActionRevokedInviteLink, action.invite.link), "un1", fromUser);
|
||||
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionExportedInviteEdit) {
|
||||
TLRPC.TL_channelAdminLogEventActionExportedInviteEdit action = (TLRPC.TL_channelAdminLogEventActionExportedInviteEdit) event.action;
|
||||
if (action.prev_invite.link != null && action.prev_invite.link.equals(action.new_invite.link)){
|
||||
messageText = replaceWithLink(LocaleController.formatString("ActionEditedInviteLinkToSame", R.string.ActionEditedInviteLinkToSame, action.prev_invite.link), "un1", fromUser);
|
||||
} else {
|
||||
messageText = replaceWithLink(LocaleController.formatString("ActionEditedInviteLink", R.string.ActionEditedInviteLink, action.prev_invite.link, action.new_invite.link), "un1", fromUser);
|
||||
}
|
||||
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionParticipantVolume) {
|
||||
TLRPC.TL_channelAdminLogEventActionParticipantVolume action = (TLRPC.TL_channelAdminLogEventActionParticipantVolume) event.action;
|
||||
double vol = ChatObject.getParticipantVolume(action.participant) / 100.0;
|
||||
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(action.participant.user_id);
|
||||
messageText = replaceWithLink(LocaleController.formatString("ActionVolumeChanged", R.string.ActionVolumeChanged, (int) (vol > 0 ? Math.max(vol, 1) : 0)), "un1", fromUser);
|
||||
messageText = replaceWithLink(messageText, "un2", user);
|
||||
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionChangeHistoryTTL) {
|
||||
TLRPC.TL_channelAdminLogEventActionChangeHistoryTTL action = (TLRPC.TL_channelAdminLogEventActionChangeHistoryTTL) event.action;
|
||||
if (!chat.megagroup) {
|
||||
if (action.new_value != 0) {
|
||||
messageText = LocaleController.formatString("ActionTTLChannelChanged", R.string.ActionTTLChannelChanged, LocaleController.formatTTLString(action.new_value));
|
||||
} else {
|
||||
messageText = LocaleController.getString("ActionTTLChannelDisabled", R.string.ActionTTLChannelDisabled);
|
||||
}
|
||||
} else if (action.new_value == 0) {
|
||||
messageText = replaceWithLink(LocaleController.getString("ActionTTLDisabled", R.string.ActionTTLDisabled), "un1", fromUser);
|
||||
} else {
|
||||
String time;
|
||||
if (action.new_value > 24 * 60 * 60) {
|
||||
time = LocaleController.formatPluralString("Days", action.new_value / (24 * 60 * 60));
|
||||
} else if (action.new_value >= 60 * 60) {
|
||||
time = LocaleController.formatPluralString("Hours", action.new_value / (60 * 60));
|
||||
} else if (action.new_value >= 60) {
|
||||
time = LocaleController.formatPluralString("Minutes", action.new_value / 60);
|
||||
} else {
|
||||
time = LocaleController.formatPluralString("Seconds", action.new_value);
|
||||
}
|
||||
messageText = replaceWithLink(LocaleController.formatString("ActionTTLChanged", R.string.ActionTTLChanged, time), "un1", fromUser);
|
||||
}
|
||||
} else {
|
||||
messageText = "unsupported " + event.action;
|
||||
}
|
||||
|
@ -2533,6 +2582,28 @@ public class MessageObject {
|
|||
messageText = LocaleController.formatString("MessageLifetimeRemoved", R.string.MessageLifetimeRemoved, UserObject.getFirstName(fromUser));
|
||||
}
|
||||
}
|
||||
} else if (messageOwner.action instanceof TLRPC.TL_messageActionSetMessagesTTL) {
|
||||
TLRPC.TL_messageActionSetMessagesTTL action = (TLRPC.TL_messageActionSetMessagesTTL) messageOwner.action;
|
||||
TLRPC.Chat chat = messageOwner.peer_id != null && messageOwner.peer_id.channel_id != 0 ? getChat(chats, sChats, messageOwner.peer_id.channel_id) : null;
|
||||
if (chat != null && !chat.megagroup) {
|
||||
if (action.period != 0) {
|
||||
messageText = LocaleController.formatString("ActionTTLChannelChanged", R.string.ActionTTLChannelChanged, LocaleController.formatTTLString(action.period));
|
||||
} else {
|
||||
messageText = LocaleController.getString("ActionTTLChannelDisabled", R.string.ActionTTLChannelDisabled);
|
||||
}
|
||||
} else if (action.period != 0) {
|
||||
if (isOut()) {
|
||||
messageText = LocaleController.formatString("ActionTTLYouChanged", R.string.ActionTTLYouChanged, LocaleController.formatTTLString(action.period));
|
||||
} else {
|
||||
messageText = replaceWithLink(LocaleController.formatString("ActionTTLChanged", R.string.ActionTTLChanged, LocaleController.formatTTLString(action.period)), "un1", fromObject);
|
||||
}
|
||||
} else {
|
||||
if (isOut()) {
|
||||
messageText = LocaleController.getString("ActionTTLYouDisabled", R.string.ActionTTLYouDisabled);
|
||||
} else {
|
||||
messageText = replaceWithLink(LocaleController.getString("ActionTTLDisabled", R.string.ActionTTLDisabled), "un1", fromObject);
|
||||
}
|
||||
}
|
||||
} else if (messageOwner.action instanceof TLRPC.TL_messageActionLoginUnknownLocation) {
|
||||
String date;
|
||||
long time = ((long) messageOwner.date) * 1000;
|
||||
|
@ -5499,6 +5570,9 @@ public class MessageObject {
|
|||
if (inScheduleMode && !chat.megagroup) {
|
||||
return chat.creator || chat.admin_rights != null && (chat.admin_rights.delete_messages || message.out);
|
||||
}
|
||||
if (message.out && message instanceof TLRPC.TL_messageService) {
|
||||
return message.id != 1 && ChatObject.canUserDoAdminAction(chat, ChatObject.ACTION_DELETE_MESSAGES);
|
||||
}
|
||||
return inScheduleMode || message.id != 1 && (chat.creator || chat.admin_rights != null && (chat.admin_rights.delete_messages || message.out && (chat.megagroup || chat.admin_rights.post_messages)) || chat.megagroup && message.out && message.from_id instanceof TLRPC.TL_peerUser);
|
||||
}
|
||||
return inScheduleMode || isOut(message) || !ChatObject.isChannel(chat);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
package org.telegram.messenger;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.appwidget.AppWidgetManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
|
@ -23,7 +24,6 @@ import android.util.LongSparseArray;
|
|||
import android.util.SparseArray;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.util.SparseIntArray;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
|
@ -41,7 +41,9 @@ import org.telegram.ui.ActionBar.BaseFragment;
|
|||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.ChatActivity;
|
||||
import org.telegram.ui.Components.AlertsCreator;
|
||||
import org.telegram.ui.Components.BulletinFactory;
|
||||
import org.telegram.ui.DialogsActivity;
|
||||
import org.telegram.ui.EditWidgetActivity;
|
||||
import org.telegram.ui.ProfileActivity;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -52,6 +54,7 @@ import java.util.Comparator;
|
|||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
@ -179,6 +182,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
private boolean gettingNewDeleteTask;
|
||||
private int currentDeletingTaskTime;
|
||||
private ArrayList<Integer> currentDeletingTaskMids;
|
||||
private boolean currentDeletingTaskMedia;
|
||||
private int currentDeletingTaskChannelId;
|
||||
private Runnable currentDeleteTaskRunnable;
|
||||
|
||||
|
@ -294,6 +298,8 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
public boolean suggestStickersApiOnly;
|
||||
public ArrayList<String> gifSearchEmojies = new ArrayList<>();
|
||||
public HashSet<String> diceEmojies;
|
||||
public Set<String> autologinDomains;
|
||||
public String autologinToken;
|
||||
public HashMap<String, DiceFrameSuccess> diceSuccess = new HashMap<>();
|
||||
public HashMap<String, EmojiSound> emojiSounds = new HashMap<>();
|
||||
|
||||
|
@ -759,6 +765,15 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
exportPrivateUri.add("@s.whatsapp.net/");
|
||||
}
|
||||
|
||||
autologinDomains = mainPreferences.getStringSet("autologinDomains", null);
|
||||
if (autologinDomains != null) {
|
||||
autologinDomains = new HashSet<>(autologinDomains);
|
||||
} else {
|
||||
autologinDomains = new HashSet<>();
|
||||
}
|
||||
|
||||
autologinToken = mainPreferences.getString("autologinToken", null);
|
||||
|
||||
Set<String> emojies = mainPreferences.getStringSet("diceEmojies", null);
|
||||
if (emojies == null) {
|
||||
diceEmojies = new HashSet<>();
|
||||
|
@ -1386,6 +1401,36 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
break;
|
||||
}
|
||||
case "autologin_domains" : {
|
||||
HashSet<String> newDomains = new HashSet<>();
|
||||
if (value.value instanceof TLRPC.TL_jsonArray) {
|
||||
TLRPC.TL_jsonArray array = (TLRPC.TL_jsonArray) value.value;
|
||||
for (int b = 0, N2 = array.value.size(); b < N2; b++) {
|
||||
TLRPC.JSONValue val = array.value.get(b);
|
||||
if (val instanceof TLRPC.TL_jsonString) {
|
||||
TLRPC.TL_jsonString string = (TLRPC.TL_jsonString) val;
|
||||
newDomains.add(string.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!autologinDomains.equals(newDomains)) {
|
||||
autologinDomains = newDomains;
|
||||
editor.putStringSet("autologinDomains", autologinDomains);
|
||||
changed = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "autologin_token" : {
|
||||
if (value.value instanceof TLRPC.TL_jsonString) {
|
||||
TLRPC.TL_jsonString string = (TLRPC.TL_jsonString) value.value;
|
||||
if (!string.value.equals(autologinToken)) {
|
||||
autologinToken = string.value;
|
||||
editor.putString("autologinToken", autologinToken);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "emojies_send_dice": {
|
||||
HashSet<String> newEmojies = new HashSet<>();
|
||||
if (value.value instanceof TLRPC.TL_jsonArray) {
|
||||
|
@ -1640,20 +1685,29 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}));
|
||||
}
|
||||
|
||||
public void removeSuggestion(String suggestion) {
|
||||
if (suggestion == null) {
|
||||
public void removeSuggestion(long did, String suggestion) {
|
||||
if (TextUtils.isEmpty(suggestion)) {
|
||||
return;
|
||||
}
|
||||
if (pendingSuggestions.remove(suggestion)) {
|
||||
SharedPreferences.Editor editor = mainPreferences.edit();
|
||||
editor.putStringSet("pendingSuggestions", pendingSuggestions);
|
||||
editor.commit();
|
||||
TLRPC.TL_help_dismissSuggestion req = new TLRPC.TL_help_dismissSuggestion();
|
||||
req.suggestion = suggestion;
|
||||
getConnectionsManager().sendRequest(req, (response, error) -> {
|
||||
|
||||
});
|
||||
if (did == 0) {
|
||||
if (pendingSuggestions.remove(suggestion)) {
|
||||
SharedPreferences.Editor editor = mainPreferences.edit();
|
||||
editor.putStringSet("pendingSuggestions", pendingSuggestions);
|
||||
editor.commit();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
TLRPC.TL_help_dismissSuggestion req = new TLRPC.TL_help_dismissSuggestion();
|
||||
req.suggestion = suggestion;
|
||||
if (did == 0) {
|
||||
req.peer = new TLRPC.TL_inputPeerEmpty();
|
||||
} else {
|
||||
req.peer = getInputPeer((int) did);
|
||||
}
|
||||
getConnectionsManager().sendRequest(req, (response, error) -> {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public void updateConfig(final TLRPC.TL_config config) {
|
||||
|
@ -2273,6 +2327,8 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
getLocationController().cleanup();
|
||||
getMediaDataController().cleanup();
|
||||
|
||||
showFiltersTooltip = false;
|
||||
|
||||
DialogsActivity.dialogsLoaded[currentAccount] = false;
|
||||
|
||||
SharedPreferences.Editor editor = notificationsPreferences.edit();
|
||||
|
@ -2280,7 +2336,52 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
editor = emojiPreferences.edit();
|
||||
editor.putLong("lastGifLoadTime", 0).putLong("lastStickersLoadTime", 0).putLong("lastStickersLoadTimeMask", 0).putLong("lastStickersLoadTimeFavs", 0).commit();
|
||||
editor = mainPreferences.edit();
|
||||
editor.remove("archivehint").remove("proximityhint").remove("archivehint_l").remove("gifhint").remove("soundHint").remove("dcDomainName2").remove("webFileDatacenterId").remove("themehint").commit();
|
||||
editor.remove("archivehint").remove("proximityhint").remove("archivehint_l").remove("gifhint").remove("soundHint").remove("dcDomainName2").remove("webFileDatacenterId").remove("themehint").remove("showFiltersTooltip").commit();
|
||||
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("shortcut_widget", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor widgetEditor = null;
|
||||
AppWidgetManager appWidgetManager = null;
|
||||
ArrayList<Integer> chatsWidgets = null;
|
||||
ArrayList<Integer> contactsWidgets = null;
|
||||
Map<String, ?> values = preferences.getAll();
|
||||
for (Map.Entry<String, ?> entry : values.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if (key.startsWith("account")) {
|
||||
Integer value = (Integer) entry.getValue();
|
||||
if (value == currentAccount) {
|
||||
int widgetId = Utilities.parseInt(key);
|
||||
if (widgetEditor == null) {
|
||||
widgetEditor = preferences.edit();
|
||||
appWidgetManager = AppWidgetManager.getInstance(ApplicationLoader.applicationContext);
|
||||
}
|
||||
widgetEditor.putBoolean("deleted" + widgetId, true);
|
||||
if (preferences.getInt("type" + widgetId, 0) == EditWidgetActivity.TYPE_CHATS) {
|
||||
if (chatsWidgets == null) {
|
||||
chatsWidgets = new ArrayList<>();
|
||||
}
|
||||
chatsWidgets.add(widgetId);
|
||||
} else {
|
||||
if (contactsWidgets == null) {
|
||||
contactsWidgets = new ArrayList<>();
|
||||
}
|
||||
contactsWidgets.add(widgetId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (widgetEditor != null) {
|
||||
widgetEditor.commit();
|
||||
}
|
||||
if (chatsWidgets != null) {
|
||||
for (int a = 0, N = chatsWidgets.size(); a < N; a++) {
|
||||
ChatsWidgetProvider.updateWidget(ApplicationLoader.applicationContext, appWidgetManager, chatsWidgets.get(a), true);
|
||||
}
|
||||
}
|
||||
if (contactsWidgets != null) {
|
||||
for (int a = 0, N = contactsWidgets.size(); a < N; a++) {
|
||||
ContactsWidgetProvider.updateWidget(ApplicationLoader.applicationContext, appWidgetManager, contactsWidgets.get(a), true);
|
||||
}
|
||||
}
|
||||
|
||||
lastScheduledServerQueryTime.clear();
|
||||
lastServerQueryTime.clear();
|
||||
|
@ -2393,6 +2494,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
|
||||
currentDeletingTaskTime = 0;
|
||||
currentDeletingTaskMids = null;
|
||||
currentDeletingTaskMedia = false;
|
||||
currentDeletingTaskChannelId = 0;
|
||||
gettingNewDeleteTask = false;
|
||||
loadingBlockedPeers = false;
|
||||
|
@ -3340,6 +3442,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
} else if (currentUser != null) {
|
||||
req.peer = getInputPeer(currentUser.id);
|
||||
}
|
||||
req.message = "";
|
||||
req.reason = new TLRPC.TL_inputReportReasonGeoIrrelevant();
|
||||
getConnectionsManager().sendRequest(req, (response, error) -> {
|
||||
|
||||
|
@ -3531,7 +3634,9 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
getNewDeleteTask(null, 0);
|
||||
}
|
||||
});
|
||||
AndroidUtilities.runOnUIThread(() -> getNotificationCenter().postNotificationName(NotificationCenter.didCreatedNewDeleteTask, mids));
|
||||
if (mids != null) {
|
||||
AndroidUtilities.runOnUIThread(() -> getNotificationCenter().postNotificationName(NotificationCenter.didCreatedNewDeleteTask, mids));
|
||||
}
|
||||
}
|
||||
|
||||
public void getNewDeleteTask(final ArrayList<Integer> oldTask, final int channelId) {
|
||||
|
@ -3552,15 +3657,17 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
currentDeleteTaskRunnable = null;
|
||||
final ArrayList<Integer> mids = new ArrayList<>(currentDeletingTaskMids);
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
if (!mids.isEmpty() && mids.get(0) > 0) {
|
||||
if (currentDeletingTaskMedia) {
|
||||
getMessagesStorage().emptyMessagesMedia(mids);
|
||||
} else {
|
||||
deleteMessages(mids, null, null, 0, 0, false, false);
|
||||
deleteMessages(mids, null, null, 0, 0, false, false, !mids.isEmpty() && mids.get(0) > 0);
|
||||
}
|
||||
Utilities.stageQueue.postRunnable(() -> {
|
||||
getNewDeleteTask(mids, currentDeletingTaskChannelId);
|
||||
currentDeletingTaskTime = 0;
|
||||
currentDeletingTaskMids = null;
|
||||
currentDeletingTaskMedia = false;
|
||||
currentDeletingTaskChannelId = 0;
|
||||
});
|
||||
});
|
||||
return true;
|
||||
|
@ -3568,12 +3675,14 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
return false;
|
||||
}
|
||||
|
||||
public void processLoadedDeleteTask(final int taskTime, final ArrayList<Integer> messages, final int channelId) {
|
||||
public void processLoadedDeleteTask(int taskTime, ArrayList<Integer> messages, boolean media, int channelId) {
|
||||
Utilities.stageQueue.postRunnable(() -> {
|
||||
gettingNewDeleteTask = false;
|
||||
if (messages != null) {
|
||||
currentDeletingTaskTime = taskTime;
|
||||
currentDeletingTaskMids = messages;
|
||||
currentDeletingTaskMedia = media;
|
||||
currentDeletingTaskChannelId = channelId;
|
||||
|
||||
if (currentDeleteTaskRunnable != null) {
|
||||
Utilities.stageQueue.cancelRunnable(currentDeleteTaskRunnable);
|
||||
|
@ -3588,6 +3697,8 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
} else {
|
||||
currentDeletingTaskTime = 0;
|
||||
currentDeletingTaskMids = null;
|
||||
currentDeletingTaskMedia = false;
|
||||
currentDeletingTaskChannelId = 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -4089,20 +4200,26 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
|
||||
public void deleteMessages(ArrayList<Integer> messages, ArrayList<Long> randoms, TLRPC.EncryptedChat encryptedChat, final long dialogId, final int channelId, boolean forAll, boolean scheduled) {
|
||||
deleteMessages(messages, randoms, encryptedChat, dialogId, channelId, forAll, scheduled, 0, null);
|
||||
deleteMessages(messages, randoms, encryptedChat, dialogId, channelId, forAll, scheduled, false, 0, null);
|
||||
}
|
||||
|
||||
public void deleteMessages(ArrayList<Integer> messages, ArrayList<Long> randoms, TLRPC.EncryptedChat encryptedChat, final long dialogId, final int channelId, boolean forAll, boolean scheduled, long taskId, TLObject taskRequest) {
|
||||
public void deleteMessages(ArrayList<Integer> messages, ArrayList<Long> randoms, TLRPC.EncryptedChat encryptedChat, final long dialogId, final int channelId, boolean forAll, boolean scheduled, boolean cacheOnly) {
|
||||
deleteMessages(messages, randoms, encryptedChat, dialogId, channelId, forAll, scheduled, cacheOnly, 0, null);
|
||||
}
|
||||
|
||||
public void deleteMessages(ArrayList<Integer> messages, ArrayList<Long> randoms, TLRPC.EncryptedChat encryptedChat, final long dialogId, final int channelId, boolean forAll, boolean scheduled, boolean cacheOnly, long taskId, TLObject taskRequest) {
|
||||
if ((messages == null || messages.isEmpty()) && taskId == 0) {
|
||||
return;
|
||||
}
|
||||
ArrayList<Integer> toSend = null;
|
||||
if (taskId == 0) {
|
||||
toSend = new ArrayList<>();
|
||||
for (int a = 0, N = messages.size(); a < N; a++) {
|
||||
Integer mid = messages.get(a);
|
||||
if (mid > 0) {
|
||||
toSend.add(mid);
|
||||
if (!cacheOnly) {
|
||||
toSend = new ArrayList<>();
|
||||
for (int a = 0, N = messages.size(); a < N; a++) {
|
||||
Integer mid = messages.get(a);
|
||||
if (mid > 0) {
|
||||
toSend.add(mid);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (scheduled) {
|
||||
|
@ -4124,6 +4241,9 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.messagesDeleted, messages, channelId, scheduled);
|
||||
}
|
||||
if (cacheOnly) {
|
||||
return;
|
||||
}
|
||||
|
||||
final long newTaskId;
|
||||
if (scheduled) {
|
||||
|
@ -4425,6 +4545,45 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
deleteDialog(did, 1, onlyHistory, 0, revoke, null, 0);
|
||||
}
|
||||
|
||||
public void setDialogHistoryTTL(final long did, int ttl) {
|
||||
TLRPC.TL_messages_setHistoryTTL req = new TLRPC.TL_messages_setHistoryTTL();
|
||||
req.peer = getInputPeer((int) did);
|
||||
req.period = ttl;
|
||||
getConnectionsManager().sendRequest(req, (response, error) -> {
|
||||
if (response != null) {
|
||||
TLRPC.Updates updates = (TLRPC.Updates) response;
|
||||
processUpdates(updates, false);
|
||||
}
|
||||
});
|
||||
int lowerId = (int) did;
|
||||
TLRPC.ChatFull chatFull = null;
|
||||
TLRPC.UserFull userFull = null;
|
||||
if (lowerId > 0) {
|
||||
userFull = getUserFull(lowerId);
|
||||
if (userFull == null) {
|
||||
return;
|
||||
}
|
||||
userFull.ttl_period = ttl;
|
||||
userFull.flags |= 16384;
|
||||
} else {
|
||||
chatFull = getChatFull(-lowerId);
|
||||
if (chatFull == null) {
|
||||
return;
|
||||
}
|
||||
chatFull.ttl_period = ttl;
|
||||
if (chatFull instanceof TLRPC.TL_channelFull) {
|
||||
chatFull.flags |= 16777216;
|
||||
} else {
|
||||
chatFull.flags |= 16384;
|
||||
}
|
||||
}
|
||||
if (chatFull != null) {
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.chatInfoDidLoad, chatFull, 0, false);
|
||||
} else {
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.userInfoDidLoad, lowerId, userFull);
|
||||
}
|
||||
}
|
||||
|
||||
public void setDialogsInTransaction(boolean transaction) {
|
||||
dialogsInTransaction = transaction;
|
||||
if (!transaction) {
|
||||
|
@ -8544,8 +8703,60 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
progressDialog.setOnCancelListener(dialog -> getConnectionsManager().cancelRequest(reqId, true));
|
||||
try {
|
||||
progressDialog.show();
|
||||
} catch (Exception e) {
|
||||
//don't promt
|
||||
} catch (Exception ignore) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void convertToGigaGroup(final Context context, TLRPC.Chat chat, BaseFragment fragment, MessagesStorage.BooleanCallback convertRunnable) {
|
||||
TLRPC.TL_channels_convertToGigagroup req = new TLRPC.TL_channels_convertToGigagroup();
|
||||
req.channel = getInputChannel(chat);
|
||||
final AlertDialog progressDialog = context != null ? new AlertDialog(context, 3) : null;
|
||||
final int reqId = getConnectionsManager().sendRequest(req, (response, error) -> {
|
||||
if (error == null) {
|
||||
if (context != null) {
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
if (!((Activity) context).isFinishing()) {
|
||||
try {
|
||||
progressDialog.dismiss();
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
TLRPC.Updates updates = (TLRPC.Updates) response;
|
||||
processUpdates((TLRPC.Updates) response, false);
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
if (convertRunnable != null) {
|
||||
convertRunnable.run(true);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
if (convertRunnable != null) {
|
||||
convertRunnable.run(false);
|
||||
}
|
||||
if (context != null) {
|
||||
if (!((Activity) context).isFinishing()) {
|
||||
try {
|
||||
progressDialog.dismiss();
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
AlertsCreator.processError(currentAccount, error, fragment, req, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if (progressDialog != null) {
|
||||
progressDialog.setOnCancelListener(dialog -> getConnectionsManager().cancelRequest(reqId, true));
|
||||
try {
|
||||
progressDialog.showDelayed(400);
|
||||
} catch (Exception ignore) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10651,6 +10862,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
message.via_bot_id = updates.via_bot_id;
|
||||
message.flags = updates.flags | TLRPC.MESSAGE_FLAG_HAS_FROM_ID;
|
||||
message.reply_to = updates.reply_to;
|
||||
message.ttl_period = updates.ttl_period;
|
||||
message.media = new TLRPC.TL_messageMediaEmpty();
|
||||
|
||||
ConcurrentHashMap<Long, Integer> read_max = message.out ? dialogs_read_outbox_max : dialogs_read_inbox_max;
|
||||
|
@ -12134,6 +12346,11 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
updatesOnMainThread = new ArrayList<>();
|
||||
}
|
||||
updatesOnMainThread.add(baseUpdate);
|
||||
} else if (baseUpdate instanceof TLRPC.TL_updatePeerHistoryTTL) {
|
||||
if (updatesOnMainThread == null) {
|
||||
updatesOnMainThread = new ArrayList<>();
|
||||
}
|
||||
updatesOnMainThread.add(baseUpdate);
|
||||
}
|
||||
}
|
||||
if (messages != null) {
|
||||
|
@ -12743,6 +12960,47 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
} else if (baseUpdate instanceof TLRPC.TL_updateReadChannelDiscussionOutbox) {
|
||||
TLRPC.TL_updateReadChannelDiscussionOutbox update = (TLRPC.TL_updateReadChannelDiscussionOutbox) baseUpdate;
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.threadMessagesRead, (long) -update.channel_id, update.top_msg_id, 0, update.read_max_id);
|
||||
} else if (baseUpdate instanceof TLRPC.TL_updatePeerHistoryTTL) {
|
||||
TLRPC.TL_updatePeerHistoryTTL updatePeerHistoryTTL = (TLRPC.TL_updatePeerHistoryTTL) baseUpdate;
|
||||
int lowerId = MessageObject.getPeerId(updatePeerHistoryTTL.peer);
|
||||
TLRPC.ChatFull chatFull = null;
|
||||
TLRPC.UserFull userFull = null;
|
||||
if (lowerId > 0) {
|
||||
userFull = getUserFull(lowerId);
|
||||
if (userFull != null) {
|
||||
userFull.ttl_period = updatePeerHistoryTTL.ttl_period;
|
||||
if (userFull.ttl_period == 0) {
|
||||
userFull.flags &=~ 16384;
|
||||
} else {
|
||||
userFull.flags |= 16384;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
chatFull = getChatFull(-lowerId);
|
||||
if (chatFull != null) {
|
||||
chatFull.ttl_period = updatePeerHistoryTTL.ttl_period;
|
||||
if (chatFull instanceof TLRPC.TL_channelFull) {
|
||||
if (chatFull.ttl_period == 0) {
|
||||
chatFull.flags &= ~16777216;
|
||||
} else {
|
||||
chatFull.flags |= 16777216;
|
||||
}
|
||||
} else {
|
||||
if (chatFull.ttl_period == 0) {
|
||||
chatFull.flags &= ~16384;
|
||||
} else {
|
||||
chatFull.flags |= 16384;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (chatFull != null) {
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.chatInfoDidLoad, chatFull, 0, false);
|
||||
getMessagesStorage().updateChatInfo(chatFull, false);
|
||||
} else if (userFull != null) {
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.userInfoDidLoad, lowerId, userFull);
|
||||
getMessagesStorage().updateUserInfo(userFull, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (editor != null) {
|
||||
|
@ -13475,6 +13733,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
if (chat != null && chat.megagroup) {
|
||||
dialogsGroupsOnly.add(d);
|
||||
canAddToForward = !chat.gigagroup || ChatObject.hasAdminRights(chat);
|
||||
} else {
|
||||
dialogsChannelsOnly.add(d);
|
||||
canAddToForward = ChatObject.hasAdminRights(chat) && ChatObject.canPost(chat);
|
||||
|
@ -13751,9 +14010,9 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
openChatOrProfileWith(res.users.get(0), null, fragment, type, false);
|
||||
}
|
||||
} else {
|
||||
if (fragment.getParentActivity() != null) {
|
||||
if (fragment != null) {
|
||||
try {
|
||||
Toast.makeText(fragment.getParentActivity(), LocaleController.getString("NoUsernameFound", R.string.NoUsernameFound), Toast.LENGTH_SHORT).show();
|
||||
BulletinFactory.of(fragment).createErrorBulletin(LocaleController.getString("NoUsernameFound", R.string.NoUsernameFound)).show();
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.telegram.tgnet.TLObject;
|
|||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Adapters.DialogsSearchAdapter;
|
||||
import org.telegram.ui.EditWidgetActivity;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
@ -88,7 +89,7 @@ public class MessagesStorage extends BaseController {
|
|||
private CountDownLatch openSync = new CountDownLatch(1);
|
||||
|
||||
private static volatile MessagesStorage[] Instance = new MessagesStorage[UserConfig.MAX_ACCOUNT_COUNT];
|
||||
private final static int LAST_DB_VERSION = 76;
|
||||
private final static int LAST_DB_VERSION = 77;
|
||||
|
||||
public static MessagesStorage getInstance(int num) {
|
||||
MessagesStorage localInstance = Instance[num];
|
||||
|
@ -318,7 +319,7 @@ public class MessagesStorage extends BaseController {
|
|||
database.executeFast("CREATE TABLE randoms(random_id INTEGER, mid INTEGER, PRIMARY KEY (random_id, mid))").stepThis().dispose();
|
||||
database.executeFast("CREATE INDEX IF NOT EXISTS mid_idx_randoms ON randoms(mid);").stepThis().dispose();
|
||||
|
||||
database.executeFast("CREATE TABLE enc_tasks_v2(mid INTEGER PRIMARY KEY, date INTEGER)").stepThis().dispose();
|
||||
database.executeFast("CREATE TABLE enc_tasks_v2(mid INTEGER PRIMARY KEY, date INTEGER, media INTEGER)").stepThis().dispose();
|
||||
database.executeFast("CREATE INDEX IF NOT EXISTS date_idx_enc_tasks_v2 ON enc_tasks_v2(date);").stepThis().dispose();
|
||||
|
||||
database.executeFast("CREATE TABLE messages_seq(mid INTEGER PRIMARY KEY, seq_in INTEGER, seq_out INTEGER);").stepThis().dispose();
|
||||
|
@ -448,6 +449,13 @@ public class MessagesStorage extends BaseController {
|
|||
openDatabase(openTries == 1 ? 2 : 3);
|
||||
}
|
||||
}
|
||||
if (BuildVars.DEBUG_PRIVATE_VERSION) { //TODO remove later
|
||||
try {
|
||||
database.executeFast("DELETE FROM pending_tasks WHERE 1").stepThis().dispose();
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
}
|
||||
loadDialogFilters();
|
||||
loadUnreadMessages();
|
||||
loadPendingTasks();
|
||||
|
@ -939,6 +947,11 @@ public class MessagesStorage extends BaseController {
|
|||
version = 76;
|
||||
}
|
||||
if (version == 76) {
|
||||
executeNoException("ALTER TABLE enc_tasks_v2 ADD COLUMN media INTEGER default -1");
|
||||
database.executeFast("PRAGMA user_version = 77").stepThis().dispose();
|
||||
version = 77;
|
||||
}
|
||||
if (version == 77) {
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -1194,7 +1207,7 @@ public class MessagesStorage extends BaseController {
|
|||
removePendingTask(taskId);
|
||||
} else {
|
||||
final TLObject finalRequest = request;
|
||||
AndroidUtilities.runOnUIThread(() -> getMessagesController().deleteMessages(null, null, null, 0, channelId, true, false, taskId, finalRequest));
|
||||
AndroidUtilities.runOnUIThread(() -> getMessagesController().deleteMessages(null, null, null, 0, channelId, true, false, false, taskId, finalRequest));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1283,7 +1296,7 @@ public class MessagesStorage extends BaseController {
|
|||
removePendingTask(taskId);
|
||||
} else {
|
||||
final TLObject finalRequest = request;
|
||||
AndroidUtilities.runOnUIThread(() -> MessagesController.getInstance(currentAccount).deleteMessages(null, null, null, dialogId, channelId, true, true, taskId, finalRequest));
|
||||
AndroidUtilities.runOnUIThread(() -> MessagesController.getInstance(currentAccount).deleteMessages(null, null, null, dialogId, channelId, true, true, false, taskId, finalRequest));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -3603,13 +3616,30 @@ public class MessagesStorage extends BaseController {
|
|||
storageQueue.postRunnable(() -> {
|
||||
try {
|
||||
if (oldTask != null) {
|
||||
String ids = TextUtils.join(",", oldTask);
|
||||
String ids;
|
||||
if (channelId != 0) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int a = 0, N = oldTask.size(); a < N; a++) {
|
||||
long messageId = oldTask.get(a);
|
||||
if (channelId != 0) {
|
||||
messageId |= ((long) channelId) << 32;
|
||||
}
|
||||
if (builder.length() > 0) {
|
||||
builder.append(",");
|
||||
}
|
||||
builder.append(messageId);
|
||||
}
|
||||
ids = builder.toString();
|
||||
} else {
|
||||
ids = TextUtils.join(",", oldTask);
|
||||
}
|
||||
database.executeFast(String.format(Locale.US, "DELETE FROM enc_tasks_v2 WHERE mid IN(%s)", ids)).stepThis().dispose();
|
||||
}
|
||||
int date = 0;
|
||||
int channelId1 = -1;
|
||||
boolean media = false;
|
||||
ArrayList<Integer> arr = null;
|
||||
SQLiteCursor cursor = database.queryFinalized("SELECT mid, date FROM enc_tasks_v2 WHERE date = (SELECT min(date) FROM enc_tasks_v2)");
|
||||
SQLiteCursor cursor = database.queryFinalized("SELECT mid, date, media FROM enc_tasks_v2 WHERE date = (SELECT min(date) FROM enc_tasks_v2)");
|
||||
while (cursor.next()) {
|
||||
long mid = cursor.longValue(0);
|
||||
if (channelId1 == -1) {
|
||||
|
@ -3622,10 +3652,17 @@ public class MessagesStorage extends BaseController {
|
|||
if (arr == null) {
|
||||
arr = new ArrayList<>();
|
||||
}
|
||||
arr.add((int) mid);
|
||||
int m = (int) mid;
|
||||
arr.add(m);
|
||||
int isMedia = cursor.intValue(2);
|
||||
if (isMedia == -1) {
|
||||
media = m > 0;
|
||||
} else {
|
||||
media = isMedia != 0;
|
||||
}
|
||||
}
|
||||
cursor.dispose();
|
||||
getMessagesController().processLoadedDeleteTask(date, arr, channelId1);
|
||||
getMessagesController().processLoadedDeleteTask(date, arr, media, channelId1);
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
|
@ -3719,7 +3756,7 @@ public class MessagesStorage extends BaseController {
|
|||
getNotificationCenter().postNotificationName(NotificationCenter.messagesReadContent, midsArray);
|
||||
});
|
||||
|
||||
SQLitePreparedStatement state = database.executeFast("REPLACE INTO enc_tasks_v2 VALUES(?, ?)");
|
||||
SQLitePreparedStatement state = database.executeFast("REPLACE INTO enc_tasks_v2 VALUES(?, ?, ?)");
|
||||
for (int a = 0; a < messages.size(); a++) {
|
||||
int key = messages.keyAt(a);
|
||||
ArrayList<Long> arr = messages.get(key);
|
||||
|
@ -3727,6 +3764,7 @@ public class MessagesStorage extends BaseController {
|
|||
state.requery();
|
||||
state.bindLong(1, arr.get(b));
|
||||
state.bindInteger(2, key);
|
||||
state.bindInteger(3, 1);
|
||||
state.step();
|
||||
}
|
||||
}
|
||||
|
@ -3786,7 +3824,7 @@ public class MessagesStorage extends BaseController {
|
|||
|
||||
if (messages.size() != 0) {
|
||||
database.beginTransaction();
|
||||
SQLitePreparedStatement state = database.executeFast("REPLACE INTO enc_tasks_v2 VALUES(?, ?)");
|
||||
SQLitePreparedStatement state = database.executeFast("REPLACE INTO enc_tasks_v2 VALUES(?, ?, ?)");
|
||||
for (int a = 0; a < messages.size(); a++) {
|
||||
int key = messages.keyAt(a);
|
||||
ArrayList<Long> arr = messages.get(key);
|
||||
|
@ -3794,6 +3832,7 @@ public class MessagesStorage extends BaseController {
|
|||
state.requery();
|
||||
state.bindLong(1, arr.get(b));
|
||||
state.bindInteger(2, key);
|
||||
state.bindInteger(3, 0);
|
||||
state.step();
|
||||
}
|
||||
}
|
||||
|
@ -6846,9 +6885,13 @@ public class MessagesStorage extends BaseController {
|
|||
}
|
||||
|
||||
private void updateWidgets(ArrayList<Long> dids) {
|
||||
if (dids.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
AppWidgetManager appWidgetManager = null;
|
||||
SQLiteCursor cursor = database.queryFinalized(String.format(Locale.US, "SELECT DISTINCT id FROM shortcut_widget WHERE did IN(%s)", TextUtils.join(",", dids)));
|
||||
String ids = TextUtils.join(",", dids);
|
||||
SQLiteCursor cursor = database.queryFinalized(String.format(Locale.US, "SELECT DISTINCT id FROM shortcut_widget WHERE did IN(%s,-1)", TextUtils.join(",", dids)));
|
||||
while (cursor.next()) {
|
||||
if (appWidgetManager == null) {
|
||||
appWidgetManager = AppWidgetManager.getInstance(ApplicationLoader.applicationContext);
|
||||
|
@ -6864,16 +6907,27 @@ public class MessagesStorage extends BaseController {
|
|||
public void putWidgetDialogs(int widgetId, ArrayList<Long> dids) {
|
||||
storageQueue.postRunnable(() -> {
|
||||
try {
|
||||
database.beginTransaction();
|
||||
database.executeFast("DELETE FROM shortcut_widget WHERE id = " + widgetId).stepThis().dispose();
|
||||
SQLitePreparedStatement state = database.executeFast("REPLACE INTO shortcut_widget VALUES(?, ?, ?)");
|
||||
for (int a = 0, N = dids.size(); a < N; a++) {
|
||||
long did = dids.get(a);
|
||||
if (dids.isEmpty()) {
|
||||
state.requery();
|
||||
state.bindInteger(1, widgetId);
|
||||
state.bindInteger(2, (int) did);
|
||||
state.bindInteger(3, a);
|
||||
state.bindLong(2, -1);
|
||||
state.bindInteger(3, 0);
|
||||
state.step();
|
||||
} else {
|
||||
for (int a = 0, N = dids.size(); a < N; a++) {
|
||||
long did = dids.get(a);
|
||||
state.requery();
|
||||
state.bindInteger(1, widgetId);
|
||||
state.bindLong(2, did);
|
||||
state.bindInteger(3, a);
|
||||
state.step();
|
||||
}
|
||||
}
|
||||
state.dispose();
|
||||
database.commitTransaction();
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
|
@ -6890,7 +6944,7 @@ public class MessagesStorage extends BaseController {
|
|||
});
|
||||
}
|
||||
|
||||
public void getWidgetDialogs(int widgetId, ArrayList<Integer> dids, LongSparseArray<TLRPC.Dialog> dialogs, LongSparseArray<TLRPC.Message> messages, ArrayList<TLRPC.User> users, ArrayList<TLRPC.Chat> chats) {
|
||||
public void getWidgetDialogIds(int widgetId, int type, ArrayList<Long> dids, ArrayList<TLRPC.User> users, ArrayList<TLRPC.Chat> chats, boolean edit) {
|
||||
final CountDownLatch countDownLatch = new CountDownLatch(1);
|
||||
storageQueue.postRunnable(() -> {
|
||||
try {
|
||||
|
@ -6898,18 +6952,128 @@ public class MessagesStorage extends BaseController {
|
|||
ArrayList<Integer> chatsToLoad = new ArrayList<>();
|
||||
SQLiteCursor cursor = database.queryFinalized(String.format(Locale.US, "SELECT did FROM shortcut_widget WHERE id = %d ORDER BY ord ASC", widgetId));
|
||||
while (cursor.next()) {
|
||||
int id = cursor.intValue(0);
|
||||
long id = cursor.longValue(0);
|
||||
if (id == -1) {
|
||||
continue;
|
||||
}
|
||||
dids.add(id);
|
||||
if (id > 0) {
|
||||
usersToLoad.add(id);
|
||||
} else {
|
||||
chatsToLoad.add(-id);
|
||||
if (users != null && chats != null) {
|
||||
int lowerId = (int) id;
|
||||
if (lowerId > 0) {
|
||||
usersToLoad.add(lowerId);
|
||||
} else {
|
||||
chatsToLoad.add(-lowerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
cursor.dispose();
|
||||
cursor = database.queryFinalized(String.format(Locale.US, "SELECT d.did, d.last_mid, d.unread_count, d.date, m.data, m.read_state, m.mid, m.send_state, m.date FROM dialogs as d LEFT JOIN messages as m ON d.last_mid = m.mid WHERE d.did IN(%s)", TextUtils.join(",", dids)));
|
||||
if (!edit && dids.isEmpty()) {
|
||||
if (type == EditWidgetActivity.TYPE_CHATS) {
|
||||
cursor = database.queryFinalized("SELECT did FROM dialogs WHERE folder_id = 0 ORDER BY pinned DESC, date DESC LIMIT 0,10");
|
||||
while (cursor.next()) {
|
||||
long dialogId = cursor.longValue(0);
|
||||
if (DialogObject.isFolderDialogId(dialogId)) {
|
||||
continue;
|
||||
}
|
||||
dids.add(dialogId);
|
||||
if (users != null && chats != null) {
|
||||
int lowerId = (int) dialogId;
|
||||
if (lowerId > 0) {
|
||||
usersToLoad.add(lowerId);
|
||||
} else {
|
||||
chatsToLoad.add(-lowerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
cursor.dispose();
|
||||
} else {
|
||||
cursor = getMessagesStorage().getDatabase().queryFinalized("SELECT did FROM chat_hints WHERE type = 0 ORDER BY rating DESC LIMIT 4");
|
||||
while (cursor.next()) {
|
||||
long dialogId = cursor.longValue(0);
|
||||
dids.add(dialogId);
|
||||
if (users != null && chats != null) {
|
||||
int lowerId = (int) dialogId;
|
||||
if (lowerId > 0) {
|
||||
usersToLoad.add(lowerId);
|
||||
} else {
|
||||
chatsToLoad.add(-lowerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
cursor.dispose();
|
||||
}
|
||||
}
|
||||
if (users != null && chats != null) {
|
||||
if (!chatsToLoad.isEmpty()) {
|
||||
getChatsInternal(TextUtils.join(",", chatsToLoad), chats);
|
||||
}
|
||||
if (!usersToLoad.isEmpty()) {
|
||||
getUsersInternal(TextUtils.join(",", usersToLoad), users);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
} finally {
|
||||
countDownLatch.countDown();
|
||||
}
|
||||
});
|
||||
try {
|
||||
countDownLatch.await();
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void getWidgetDialogs(int widgetId, int type, ArrayList<Long> dids, LongSparseArray<TLRPC.Dialog> dialogs, LongSparseArray<TLRPC.Message> messages, ArrayList<TLRPC.User> users, ArrayList<TLRPC.Chat> chats) {
|
||||
final CountDownLatch countDownLatch = new CountDownLatch(1);
|
||||
storageQueue.postRunnable(() -> {
|
||||
try {
|
||||
boolean add = false;
|
||||
ArrayList<Integer> usersToLoad = new ArrayList<>();
|
||||
ArrayList<Integer> chatsToLoad = new ArrayList<>();
|
||||
SQLiteCursor cursor = database.queryFinalized(String.format(Locale.US, "SELECT did FROM shortcut_widget WHERE id = %d ORDER BY ord ASC", widgetId));
|
||||
while (cursor.next()) {
|
||||
long id = cursor.longValue(0);
|
||||
if (id == -1) {
|
||||
continue;
|
||||
}
|
||||
dids.add(id);
|
||||
int lowerId = (int) id;
|
||||
if (lowerId > 0) {
|
||||
usersToLoad.add(lowerId);
|
||||
} else {
|
||||
chatsToLoad.add(-lowerId);
|
||||
}
|
||||
}
|
||||
cursor.dispose();
|
||||
if (dids.isEmpty() && type == EditWidgetActivity.TYPE_CONTACTS) {
|
||||
cursor = getMessagesStorage().getDatabase().queryFinalized("SELECT did FROM chat_hints WHERE type = 0 ORDER BY rating DESC LIMIT 4");
|
||||
while (cursor.next()) {
|
||||
long dialogId = cursor.longValue(0);
|
||||
dids.add(dialogId);
|
||||
int lowerId = (int) dialogId;
|
||||
if (lowerId > 0) {
|
||||
usersToLoad.add(lowerId);
|
||||
} else {
|
||||
chatsToLoad.add(-lowerId);
|
||||
}
|
||||
}
|
||||
cursor.dispose();
|
||||
}
|
||||
if (dids.isEmpty()) {
|
||||
add = true;
|
||||
cursor = database.queryFinalized("SELECT d.did, d.last_mid, d.unread_count, d.date, m.data, m.read_state, m.mid, m.send_state, m.date FROM dialogs as d LEFT JOIN messages as m ON d.last_mid = m.mid WHERE d.folder_id = 0 ORDER BY d.pinned DESC, d.date DESC LIMIT 0,10");
|
||||
} else {
|
||||
cursor = database.queryFinalized(String.format(Locale.US, "SELECT d.did, d.last_mid, d.unread_count, d.date, m.data, m.read_state, m.mid, m.send_state, m.date FROM dialogs as d LEFT JOIN messages as m ON d.last_mid = m.mid WHERE d.did IN(%s)", TextUtils.join(",", dids)));
|
||||
}
|
||||
while (cursor.next()) {
|
||||
long dialogId = cursor.longValue(0);
|
||||
if (DialogObject.isFolderDialogId(dialogId)) {
|
||||
continue;
|
||||
}
|
||||
if (add) {
|
||||
dids.add(dialogId);
|
||||
}
|
||||
TLRPC.Dialog dialog = new TLRPC.TL_dialog();
|
||||
dialog.id = dialogId;
|
||||
dialog.top_message = cursor.intValue(1);
|
||||
|
@ -6936,6 +7100,28 @@ public class MessagesStorage extends BaseController {
|
|||
}
|
||||
}
|
||||
cursor.dispose();
|
||||
if (!add) {
|
||||
if (dids.size() > dialogs.size()) {
|
||||
for (int a = 0, N = dids.size(); a < N; a++) {
|
||||
long did = dids.get(a);
|
||||
if (dialogs.get(dids.get(a)) == null) {
|
||||
TLRPC.TL_dialog dialog = new TLRPC.TL_dialog();
|
||||
dialog.id = did;
|
||||
dialogs.put(dialog.id, dialog);
|
||||
int lowerId = (int) did;
|
||||
if (lowerId < 0) {
|
||||
if (chatsToLoad.contains(-lowerId)) {
|
||||
chatsToLoad.add(-lowerId);
|
||||
}
|
||||
} else {
|
||||
if (usersToLoad.contains(lowerId)) {
|
||||
usersToLoad.add(lowerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!chatsToLoad.isEmpty()) {
|
||||
getChatsInternal(TextUtils.join(",", chatsToLoad), chats);
|
||||
}
|
||||
|
@ -8168,6 +8354,8 @@ public class MessagesStorage extends BaseController {
|
|||
SQLitePreparedStatement state_download = database.executeFast("REPLACE INTO download_queue VALUES(?, ?, ?, ?, ?)");
|
||||
SQLitePreparedStatement state_webpage = database.executeFast("REPLACE INTO webpage_pending VALUES(?, ?)");
|
||||
SQLitePreparedStatement state_polls = null;
|
||||
SQLitePreparedStatement state_tasks = null;
|
||||
int minDeleteTime = Integer.MAX_VALUE;
|
||||
|
||||
for (int a = 0; a < messages.size(); a++) {
|
||||
TLRPC.Message message = messages.get(a);
|
||||
|
@ -8403,6 +8591,18 @@ public class MessagesStorage extends BaseController {
|
|||
state_media.step();
|
||||
}
|
||||
|
||||
if (message.ttl_period != 0 && message.id > 0) {
|
||||
if (state_tasks == null) {
|
||||
state_tasks = database.executeFast("REPLACE INTO enc_tasks_v2 VALUES(?, ?, ?)");
|
||||
}
|
||||
state_tasks.requery();
|
||||
state_tasks.bindLong(1, messageId);
|
||||
state_tasks.bindInteger(2, message.date + message.ttl_period);
|
||||
state_tasks.bindInteger(3, 0);
|
||||
state_tasks.step();
|
||||
minDeleteTime = Math.min(minDeleteTime, message.date + message.ttl_period);
|
||||
}
|
||||
|
||||
if (message.media instanceof TLRPC.TL_messageMediaPoll) {
|
||||
if (state_polls == null) {
|
||||
state_polls = database.executeFast("REPLACE INTO polls VALUES(?, ?)");
|
||||
|
@ -8492,6 +8692,10 @@ public class MessagesStorage extends BaseController {
|
|||
if (state_media != null) {
|
||||
state_media.dispose();
|
||||
}
|
||||
if (state_tasks != null) {
|
||||
state_tasks.dispose();
|
||||
getMessagesController().didAddedNewTask(minDeleteTime, null);
|
||||
}
|
||||
if (state_polls != null) {
|
||||
state_polls.dispose();
|
||||
}
|
||||
|
@ -9867,7 +10071,6 @@ public class MessagesStorage extends BaseController {
|
|||
|
||||
SQLitePreparedStatement state = database.executeFast("REPLACE INTO messages VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?)");
|
||||
SQLitePreparedStatement state2 = database.executeFast("REPLACE INTO media_v2 VALUES(?, ?, ?, ?, ?)");
|
||||
|
||||
if (message.dialog_id == 0) {
|
||||
MessageObject.getDialogId(message);
|
||||
}
|
||||
|
@ -10033,6 +10236,8 @@ public class MessagesStorage extends BaseController {
|
|||
SQLitePreparedStatement state_media = database.executeFast("REPLACE INTO media_v2 VALUES(?, ?, ?, ?, ?)");
|
||||
SQLitePreparedStatement state_polls = null;
|
||||
SQLitePreparedStatement state_webpage = null;
|
||||
SQLitePreparedStatement state_tasks = null;
|
||||
int minDeleteTime = Integer.MAX_VALUE;
|
||||
TLRPC.Message botKeyboard = null;
|
||||
int channelId = 0;
|
||||
for (int a = 0; a < count; a++) {
|
||||
|
@ -10204,6 +10409,18 @@ public class MessagesStorage extends BaseController {
|
|||
}
|
||||
data.reuse();
|
||||
|
||||
if (message.ttl_period != 0 && message.id > 0) {
|
||||
if (state_tasks == null) {
|
||||
state_tasks = database.executeFast("REPLACE INTO enc_tasks_v2 VALUES(?, ?, ?)");
|
||||
}
|
||||
state_tasks.requery();
|
||||
state_tasks.bindLong(1, messageId);
|
||||
state_tasks.bindInteger(2, message.date + message.ttl_period);
|
||||
state_tasks.bindInteger(3, 0);
|
||||
state_tasks.step();
|
||||
minDeleteTime = Math.min(minDeleteTime, message.date + message.ttl_period);
|
||||
}
|
||||
|
||||
if (message.media instanceof TLRPC.TL_messageMediaPoll) {
|
||||
if (state_polls == null) {
|
||||
state_polls = database.executeFast("REPLACE INTO polls VALUES(?, ?)");
|
||||
|
@ -10234,6 +10451,10 @@ public class MessagesStorage extends BaseController {
|
|||
if (state_webpage != null) {
|
||||
state_webpage.dispose();
|
||||
}
|
||||
if (state_tasks != null) {
|
||||
state_tasks.dispose();
|
||||
getMessagesController().didAddedNewTask(minDeleteTime, null);
|
||||
}
|
||||
if (state_polls != null) {
|
||||
state_polls.dispose();
|
||||
}
|
||||
|
@ -10701,6 +10922,8 @@ public class MessagesStorage extends BaseController {
|
|||
SQLitePreparedStatement state_holes = database.executeFast("REPLACE INTO messages_holes VALUES(?, ?, ?)");
|
||||
SQLitePreparedStatement state_media_holes = database.executeFast("REPLACE INTO media_holes_v2 VALUES(?, ?, ?, ?)");
|
||||
SQLitePreparedStatement state_polls = null;
|
||||
SQLitePreparedStatement state_tasks = null;
|
||||
int minDeleteTime = Integer.MAX_VALUE;
|
||||
|
||||
for (int a = 0; a < dialogs.dialogs.size(); a++) {
|
||||
TLRPC.Dialog dialog = dialogs.dialogs.get(a);
|
||||
|
@ -10802,6 +11025,18 @@ public class MessagesStorage extends BaseController {
|
|||
}
|
||||
data.reuse();
|
||||
|
||||
if (message.ttl_period != 0 && message.id > 0) {
|
||||
if (state_tasks == null) {
|
||||
state_tasks = database.executeFast("REPLACE INTO enc_tasks_v2 VALUES(?, ?, ?)");
|
||||
}
|
||||
state_tasks.requery();
|
||||
state_tasks.bindLong(1, messageId);
|
||||
state_tasks.bindInteger(2, message.date + message.ttl_period);
|
||||
state_tasks.bindInteger(3, 0);
|
||||
state_tasks.step();
|
||||
minDeleteTime = Math.min(minDeleteTime, message.date + message.ttl_period);
|
||||
}
|
||||
|
||||
if (message.media instanceof TLRPC.TL_messageMediaPoll) {
|
||||
if (state_polls == null) {
|
||||
state_polls = database.executeFast("REPLACE INTO polls VALUES(?, ?)");
|
||||
|
@ -10872,6 +11107,10 @@ public class MessagesStorage extends BaseController {
|
|||
state_settings.dispose();
|
||||
state_holes.dispose();
|
||||
state_media_holes.dispose();
|
||||
if (state_tasks != null) {
|
||||
state_tasks.dispose();
|
||||
getMessagesController().didAddedNewTask(minDeleteTime, null);
|
||||
}
|
||||
if (state_polls != null) {
|
||||
state_polls.dispose();
|
||||
}
|
||||
|
|
|
@ -299,6 +299,7 @@ public class MusicPlayerService extends Service implements NotificationCenter.No
|
|||
MediaMetadata.Builder meta = new MediaMetadata.Builder()
|
||||
.putBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART, fullAlbumArt)
|
||||
.putString(MediaMetadata.METADATA_KEY_ALBUM_ARTIST, authorName)
|
||||
.putString(MediaMetadata.METADATA_KEY_ARTIST, authorName)
|
||||
.putLong(MediaMetadata.METADATA_KEY_DURATION, duration)
|
||||
.putString(MediaMetadata.METADATA_KEY_TITLE, songName)
|
||||
.putString(MediaMetadata.METADATA_KEY_ALBUM, audioInfo != null ? audioInfo.getAlbum() : null);
|
||||
|
|
|
@ -212,6 +212,7 @@ public class NotificationCenter {
|
|||
public static final int voipServiceCreated = totalEvents++;
|
||||
public static final int webRtcMicAmplitudeEvent = totalEvents++;
|
||||
public static final int webRtcSpeakerAmplitudeEvent = totalEvents++;
|
||||
public static final int showBulletin = totalEvents++;
|
||||
|
||||
private SparseArray<ArrayList<NotificationCenterDelegate>> observers = new SparseArray<>();
|
||||
private SparseArray<ArrayList<NotificationCenterDelegate>> removeAfterBroadcast = new SparseArray<>();
|
||||
|
|
|
@ -3471,7 +3471,8 @@ public class NotificationsController extends BaseController {
|
|||
|
||||
Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class);
|
||||
intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
//intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
if ((int) dialog_id != 0) {
|
||||
if (pushDialogs.size() == 1) {
|
||||
if (chat_id != 0) {
|
||||
|
@ -4188,7 +4189,7 @@ public class NotificationsController extends BaseController {
|
|||
|
||||
Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class);
|
||||
intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
if (lowerId != 0) {
|
||||
if (lowerId > 0) {
|
||||
|
|
|
@ -57,6 +57,8 @@ import org.telegram.ui.Cells.ChatMessageCell;
|
|||
import org.telegram.ui.ChatActivity;
|
||||
import org.telegram.ui.Components.AlertsCreator;
|
||||
import org.telegram.ui.Components.AnimatedFileDrawable;
|
||||
import org.telegram.ui.Components.Bulletin;
|
||||
import org.telegram.ui.Components.BulletinFactory;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.Point;
|
||||
import org.telegram.ui.PaymentFormActivity;
|
||||
|
@ -1827,6 +1829,10 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
|
|||
final ArrayList<TLRPC.Message> sentMessages = new ArrayList<>();
|
||||
sentMessages.add(message);
|
||||
msgObj1.messageOwner.post_author = message.post_author;
|
||||
if ((message.flags & 33554432) != 0) {
|
||||
msgObj1.messageOwner.ttl_period = message.ttl_period;
|
||||
msgObj1.messageOwner.flags |= 33554432;
|
||||
}
|
||||
updateMediaPaths(msgObj1, message, message.id, null, true);
|
||||
int existFlags = msgObj1.getMediaExistanceFlags();
|
||||
newMsgObj1.id = message.id;
|
||||
|
@ -4796,6 +4802,10 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
|
|||
if (message != null) {
|
||||
MessageObject.getDialogId(message);
|
||||
sentMessages.add(message);
|
||||
if ((message.flags & 33554432) != 0) {
|
||||
msgObj.messageOwner.ttl_period = message.ttl_period;
|
||||
msgObj.messageOwner.flags |= 33554432;
|
||||
}
|
||||
updateMediaPaths(msgObj, message, message.id, originalPath, false);
|
||||
existFlags = msgObj.getMediaExistanceFlags();
|
||||
newMsgObj.id = message.id;
|
||||
|
@ -4994,6 +5004,10 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
|
|||
newMsgObj.date = res.date;
|
||||
newMsgObj.entities = res.entities;
|
||||
newMsgObj.out = res.out;
|
||||
if ((res.flags & 33554432) != 0) {
|
||||
newMsgObj.ttl_period = res.ttl_period;
|
||||
newMsgObj.flags |= 33554432;
|
||||
}
|
||||
if (res.media != null) {
|
||||
newMsgObj.media = res.media;
|
||||
newMsgObj.flags |= TLRPC.MESSAGE_FLAG_HAS_MEDIA;
|
||||
|
@ -5085,6 +5099,10 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
|
|||
message.unread = value < message.id;
|
||||
}
|
||||
msgObj.messageOwner.post_author = message.post_author;
|
||||
if ((message.flags & 33554432) != 0) {
|
||||
msgObj.messageOwner.ttl_period = message.ttl_period;
|
||||
msgObj.messageOwner.flags |= 33554432;
|
||||
}
|
||||
updateMediaPaths(msgObj, message, message.id, originalPath, false);
|
||||
existFlags = msgObj.getMediaExistanceFlags();
|
||||
newMsgObj.id = message.id;
|
||||
|
@ -6032,8 +6050,7 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
|
|||
if (error) {
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
try {
|
||||
Toast toast = Toast.makeText(ApplicationLoader.applicationContext, LocaleController.getString("UnsupportedAttachment", R.string.UnsupportedAttachment), Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.showBulletin, Bulletin.TYPE_ERROR, LocaleController.getString("UnsupportedAttachment", R.string.UnsupportedAttachment));
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
package org.telegram.messenger;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.PendingIntent;
|
||||
import android.appwidget.AppWidgetManager;
|
||||
import android.appwidget.AppWidgetProvider;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
import org.telegram.ui.LaunchActivity;
|
||||
|
||||
public class ShortcutWidgetProvider extends AppWidgetProvider {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
super.onReceive(context, intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
||||
super.onUpdate(context, appWidgetManager, appWidgetIds);
|
||||
for (int i = 0; i < appWidgetIds.length; i++) {
|
||||
int appWidgetId = appWidgetIds[i];
|
||||
updateWidget(context, appWidgetManager, appWidgetId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleted(Context context, int[] appWidgetIds) {
|
||||
super.onDeleted(context, appWidgetIds);
|
||||
for (int a = 0; a < appWidgetIds.length; a++) {
|
||||
SharedPreferences preferences = context.getSharedPreferences("shortcut_widget", Activity.MODE_PRIVATE);
|
||||
int accountId = preferences.getInt("account" + appWidgetIds[a], -1);
|
||||
if (accountId >= 0) {
|
||||
AccountInstance accountInstance = AccountInstance.getInstance(accountId);
|
||||
accountInstance.getMessagesStorage().clearWidgetDialogs(appWidgetIds[a]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
|
||||
Intent intent2 = new Intent(context, ShortcutWidgetService.class);
|
||||
intent2.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
|
||||
intent2.setData(Uri.parse(intent2.toUri(Intent.URI_INTENT_SCHEME)));
|
||||
RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.shortcut_widget_layout);
|
||||
rv.setRemoteAdapter(appWidgetId, R.id.list_view, intent2);
|
||||
rv.setEmptyView(R.id.list_view, R.id.empty_view);
|
||||
|
||||
Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class);
|
||||
intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
rv.setPendingIntentTemplate(R.id.list_view, contentIntent);
|
||||
|
||||
appWidgetManager.updateAppWidget(appWidgetId, rv);
|
||||
}
|
||||
}
|
|
@ -19,12 +19,14 @@ import android.net.Uri;
|
|||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.telegram.messenger.AccountInstance;
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.BuildVars;
|
||||
import org.telegram.messenger.CustomTabsCopyReceiver;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.ShareBroadcastReceiver;
|
||||
|
@ -45,6 +47,7 @@ import org.telegram.ui.ActionBar.Theme;
|
|||
import org.telegram.ui.LaunchActivity;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
|
||||
public class Browser {
|
||||
|
@ -237,6 +240,24 @@ public class Browser {
|
|||
FileLog.e(e);
|
||||
}
|
||||
}
|
||||
String host = uri.getHost() != null ? uri.getHost().toLowerCase() : "";
|
||||
if (AccountInstance.getInstance(currentAccount).getMessagesController().autologinDomains.contains(host)) {
|
||||
String token = "autologin_token=" + URLEncoder.encode(AccountInstance.getInstance(UserConfig.selectedAccount).getMessagesController().autologinToken, "UTF-8");
|
||||
String url = uri.toString();
|
||||
int idx = url.indexOf("://");
|
||||
String path = idx >= 0 ? url.substring(idx + 3) : url;
|
||||
String[] args = path.split("#");
|
||||
String finalPath = args[0];
|
||||
if (finalPath.indexOf('?') >= 0) {
|
||||
finalPath += "&" + token;
|
||||
} else {
|
||||
finalPath += "?" + token;
|
||||
}
|
||||
if (args.length > 1) {
|
||||
finalPath += args[1];
|
||||
}
|
||||
uri = Uri.parse("https://" + finalPath);
|
||||
}
|
||||
if (allowCustom && SharedConfig.customTabs && !internalUri && !scheme.equals("tel")) {
|
||||
String[] browserPackageNames = null;
|
||||
try {
|
||||
|
|
|
@ -148,7 +148,7 @@ public abstract class VoIPBaseService extends Service implements SensorEventList
|
|||
protected PowerManager.WakeLock cpuWakelock;
|
||||
protected boolean isProximityNear;
|
||||
protected boolean isHeadsetPlugged;
|
||||
protected int previousAudioOutput;
|
||||
protected int previousAudioOutput = -1;
|
||||
protected ArrayList<StateListener> stateListeners = new ArrayList<>();
|
||||
protected MediaPlayer ringtonePlayer;
|
||||
protected Vibrator vibrator;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -30,12 +30,9 @@ import android.view.MotionEvent;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewPropertyAnimator;
|
||||
import android.view.animation.OvershootInterpolator;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.google.android.exoplayer2.util.Log;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
|
@ -482,97 +479,161 @@ public class ActionBar extends FrameLayout {
|
|||
}
|
||||
|
||||
public void showActionMode() {
|
||||
showActionMode(null, null, null, null, null, 0);
|
||||
showActionMode(true, null, null, null, null, null, 0);
|
||||
}
|
||||
|
||||
public void showActionMode(View extraView, View showingView, View[] hidingViews, boolean[] hideView, View translationView, int translation) {
|
||||
public void showActionMode(boolean animated) {
|
||||
showActionMode(animated, null, null, null, null, null, 0);
|
||||
}
|
||||
|
||||
public void showActionMode(boolean animated, View extraView, View showingView, View[] hidingViews, boolean[] hideView, View translationView, int translation) {
|
||||
if (actionMode == null || actionModeVisible) {
|
||||
return;
|
||||
}
|
||||
actionModeVisible = true;
|
||||
ArrayList<Animator> animators = new ArrayList<>();
|
||||
animators.add(ObjectAnimator.ofFloat(actionMode, View.ALPHA, 0.0f, 1.0f));
|
||||
if (hidingViews != null) {
|
||||
for (int a = 0; a < hidingViews.length; a++) {
|
||||
if (hidingViews[a] != null) {
|
||||
animators.add(ObjectAnimator.ofFloat(hidingViews[a], View.ALPHA, 1.0f, 0.0f));
|
||||
if (animated) {
|
||||
ArrayList<Animator> animators = new ArrayList<>();
|
||||
animators.add(ObjectAnimator.ofFloat(actionMode, View.ALPHA, 0.0f, 1.0f));
|
||||
if (hidingViews != null) {
|
||||
for (int a = 0; a < hidingViews.length; a++) {
|
||||
if (hidingViews[a] != null) {
|
||||
animators.add(ObjectAnimator.ofFloat(hidingViews[a], View.ALPHA, 1.0f, 0.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (showingView != null) {
|
||||
animators.add(ObjectAnimator.ofFloat(showingView, View.ALPHA, 0.0f, 1.0f));
|
||||
}
|
||||
if (translationView != null) {
|
||||
animators.add(ObjectAnimator.ofFloat(translationView, View.TRANSLATION_Y, translation));
|
||||
actionModeTranslationView = translationView;
|
||||
}
|
||||
actionModeExtraView = extraView;
|
||||
actionModeShowingView = showingView;
|
||||
actionModeHidingViews = hidingViews;
|
||||
if (occupyStatusBar && actionModeTop != null && !SharedConfig.noStatusBar) {
|
||||
animators.add(ObjectAnimator.ofFloat(actionModeTop, View.ALPHA, 0.0f, 1.0f));
|
||||
}
|
||||
if (SharedConfig.noStatusBar) {
|
||||
if (AndroidUtilities.computePerceivedBrightness(actionModeColor) < 0.721f) {
|
||||
AndroidUtilities.setLightStatusBar(((Activity) getContext()).getWindow(), false);
|
||||
} else {
|
||||
AndroidUtilities.setLightStatusBar(((Activity) getContext()).getWindow(), true);
|
||||
if (showingView != null) {
|
||||
animators.add(ObjectAnimator.ofFloat(showingView, View.ALPHA, 0.0f, 1.0f));
|
||||
}
|
||||
}
|
||||
if (actionModeAnimation != null) {
|
||||
actionModeAnimation.cancel();
|
||||
}
|
||||
actionModeAnimation = new AnimatorSet();
|
||||
actionModeAnimation.playTogether(animators);
|
||||
actionModeAnimation.setDuration(200);
|
||||
actionModeAnimation.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
actionMode.setVisibility(VISIBLE);
|
||||
if (occupyStatusBar && actionModeTop != null && !SharedConfig.noStatusBar) {
|
||||
actionModeTop.setVisibility(VISIBLE);
|
||||
if (translationView != null) {
|
||||
animators.add(ObjectAnimator.ofFloat(translationView, View.TRANSLATION_Y, translation));
|
||||
actionModeTranslationView = translationView;
|
||||
}
|
||||
actionModeExtraView = extraView;
|
||||
actionModeShowingView = showingView;
|
||||
actionModeHidingViews = hidingViews;
|
||||
if (occupyStatusBar && actionModeTop != null && !SharedConfig.noStatusBar) {
|
||||
animators.add(ObjectAnimator.ofFloat(actionModeTop, View.ALPHA, 0.0f, 1.0f));
|
||||
}
|
||||
if (SharedConfig.noStatusBar) {
|
||||
if (AndroidUtilities.computePerceivedBrightness(actionModeColor) < 0.721f) {
|
||||
AndroidUtilities.setLightStatusBar(((Activity) getContext()).getWindow(), false);
|
||||
} else {
|
||||
AndroidUtilities.setLightStatusBar(((Activity) getContext()).getWindow(), true);
|
||||
}
|
||||
}
|
||||
if (actionModeAnimation != null) {
|
||||
actionModeAnimation.cancel();
|
||||
}
|
||||
actionModeAnimation = new AnimatorSet();
|
||||
actionModeAnimation.playTogether(animators);
|
||||
actionModeAnimation.setDuration(200);
|
||||
actionModeAnimation.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
actionMode.setVisibility(VISIBLE);
|
||||
if (occupyStatusBar && actionModeTop != null && !SharedConfig.noStatusBar) {
|
||||
actionModeTop.setVisibility(VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
if (actionModeAnimation != null && actionModeAnimation.equals(animation)) {
|
||||
actionModeAnimation = null;
|
||||
if (titleTextView[0] != null) {
|
||||
titleTextView[0].setVisibility(INVISIBLE);
|
||||
}
|
||||
if (subtitleTextView != null && !TextUtils.isEmpty(subtitleTextView.getText())) {
|
||||
subtitleTextView.setVisibility(INVISIBLE);
|
||||
}
|
||||
if (menu != null) {
|
||||
menu.setVisibility(INVISIBLE);
|
||||
}
|
||||
if (actionModeHidingViews != null) {
|
||||
for (int a = 0; a < actionModeHidingViews.length; a++) {
|
||||
if (actionModeHidingViews[a] != null) {
|
||||
if (hideView == null || a >= hideView.length || hideView[a]) {
|
||||
actionModeHidingViews[a].setVisibility(INVISIBLE);
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
if (actionModeAnimation != null && actionModeAnimation.equals(animation)) {
|
||||
actionModeAnimation = null;
|
||||
if (titleTextView[0] != null) {
|
||||
titleTextView[0].setVisibility(INVISIBLE);
|
||||
}
|
||||
if (subtitleTextView != null && !TextUtils.isEmpty(subtitleTextView.getText())) {
|
||||
subtitleTextView.setVisibility(INVISIBLE);
|
||||
}
|
||||
if (menu != null) {
|
||||
menu.setVisibility(INVISIBLE);
|
||||
}
|
||||
if (actionModeHidingViews != null) {
|
||||
for (int a = 0; a < actionModeHidingViews.length; a++) {
|
||||
if (actionModeHidingViews[a] != null) {
|
||||
if (hideView == null || a >= hideView.length || hideView[a]) {
|
||||
actionModeHidingViews[a].setVisibility(INVISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
if (actionModeAnimation != null && actionModeAnimation.equals(animation)) {
|
||||
actionModeAnimation = null;
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
if (actionModeAnimation != null && actionModeAnimation.equals(animation)) {
|
||||
actionModeAnimation = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
actionModeAnimation.start();
|
||||
if (backButtonImageView != null) {
|
||||
Drawable drawable = backButtonImageView.getDrawable();
|
||||
if (drawable instanceof BackDrawable) {
|
||||
((BackDrawable) drawable).setRotation(1, true);
|
||||
}
|
||||
backButtonImageView.setBackgroundDrawable(Theme.createSelectorDrawable(itemsActionModeBackgroundColor));
|
||||
}
|
||||
} else {
|
||||
actionMode.setAlpha(1.0f);
|
||||
if (hidingViews != null) {
|
||||
for (int a = 0; a < hidingViews.length; a++) {
|
||||
if (hidingViews[a] != null) {
|
||||
hidingViews[a].setAlpha(0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
actionModeAnimation.start();
|
||||
if (backButtonImageView != null) {
|
||||
Drawable drawable = backButtonImageView.getDrawable();
|
||||
if (drawable instanceof BackDrawable) {
|
||||
((BackDrawable) drawable).setRotation(1, true);
|
||||
if (showingView != null) {
|
||||
showingView.setAlpha(1.0f);
|
||||
}
|
||||
if (translationView != null) {
|
||||
translationView.setTranslationY(translation);
|
||||
actionModeTranslationView = translationView;
|
||||
}
|
||||
actionModeExtraView = extraView;
|
||||
actionModeShowingView = showingView;
|
||||
actionModeHidingViews = hidingViews;
|
||||
if (occupyStatusBar && actionModeTop != null && !SharedConfig.noStatusBar) {
|
||||
actionModeTop.setAlpha(1.0f);
|
||||
}
|
||||
if (SharedConfig.noStatusBar) {
|
||||
if (AndroidUtilities.computePerceivedBrightness(actionModeColor) < 0.721f) {
|
||||
AndroidUtilities.setLightStatusBar(((Activity) getContext()).getWindow(), false);
|
||||
} else {
|
||||
AndroidUtilities.setLightStatusBar(((Activity) getContext()).getWindow(), true);
|
||||
}
|
||||
}
|
||||
actionMode.setVisibility(VISIBLE);
|
||||
if (occupyStatusBar && actionModeTop != null && !SharedConfig.noStatusBar) {
|
||||
actionModeTop.setVisibility(VISIBLE);
|
||||
}
|
||||
if (titleTextView[0] != null) {
|
||||
titleTextView[0].setVisibility(INVISIBLE);
|
||||
}
|
||||
if (subtitleTextView != null && !TextUtils.isEmpty(subtitleTextView.getText())) {
|
||||
subtitleTextView.setVisibility(INVISIBLE);
|
||||
}
|
||||
if (menu != null) {
|
||||
menu.setVisibility(INVISIBLE);
|
||||
}
|
||||
if (actionModeHidingViews != null) {
|
||||
for (int a = 0; a < actionModeHidingViews.length; a++) {
|
||||
if (actionModeHidingViews[a] != null) {
|
||||
if (hideView == null || a >= hideView.length || hideView[a]) {
|
||||
actionModeHidingViews[a].setVisibility(INVISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (backButtonImageView != null) {
|
||||
Drawable drawable = backButtonImageView.getDrawable();
|
||||
if (drawable instanceof BackDrawable) {
|
||||
((BackDrawable) drawable).setRotation(1, false);
|
||||
}
|
||||
backButtonImageView.setBackgroundDrawable(Theme.createSelectorDrawable(itemsActionModeBackgroundColor));
|
||||
}
|
||||
backButtonImageView.setBackgroundDrawable(Theme.createSelectorDrawable(itemsActionModeBackgroundColor));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -586,7 +647,7 @@ public class ActionBar extends FrameLayout {
|
|||
animators.add(ObjectAnimator.ofFloat(actionMode, View.ALPHA, 0.0f));
|
||||
if (actionModeHidingViews != null) {
|
||||
for (int a = 0; a < actionModeHidingViews.length; a++) {
|
||||
if (actionModeHidingViews != null) {
|
||||
if (actionModeHidingViews[a] != null) {
|
||||
actionModeHidingViews[a].setVisibility(VISIBLE);
|
||||
animators.add(ObjectAnimator.ofFloat(actionModeHidingViews[a], View.ALPHA, 1.0f));
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.telegram.messenger.FileLog;
|
|||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.SharedConfig;
|
||||
import org.telegram.ui.Components.Bulletin;
|
||||
import org.telegram.ui.Components.CubicBezierInterpolator;
|
||||
import org.telegram.ui.Components.GroupCallPip;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
|
@ -1418,6 +1419,9 @@ public class ActionBarLayout extends FrameLayout {
|
|||
}
|
||||
} else {
|
||||
currentAnimation = animation;
|
||||
if (Bulletin.getVisibleBulletin() != null && Bulletin.getVisibleBulletin().isShowing()) {
|
||||
Bulletin.getVisibleBulletin().hide();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
currentFragment.onTransitionAnimationEnd(false, true);
|
||||
|
|
|
@ -128,6 +128,10 @@ public class ActionBarMenuSubItem extends FrameLayout {
|
|||
textView.setText(text);
|
||||
}
|
||||
|
||||
public void setSubtextColor(int color) {
|
||||
subtextView.setTextColor(color);
|
||||
}
|
||||
|
||||
public void setSubtext(String text) {
|
||||
if (subtextView == null) {
|
||||
subtextView = new TextView(getContext());
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.content.Context;
|
|||
import android.view.ContextThemeWrapper;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.Window;
|
||||
import android.view.animation.Interpolator;
|
||||
|
@ -45,6 +46,8 @@ public class AdjustPanLayoutHelper {
|
|||
ArrayList<View> viewsToHeightSet = new ArrayList<>();
|
||||
protected float keyboardSize;
|
||||
|
||||
boolean checkHierarchyHeight;
|
||||
|
||||
ViewTreeObserver.OnPreDrawListener onPreDrawListener = new ViewTreeObserver.OnPreDrawListener() {
|
||||
@Override
|
||||
public boolean onPreDraw() {
|
||||
|
@ -92,10 +95,17 @@ public class AdjustPanLayoutHelper {
|
|||
|
||||
int startOffset = startOffset();
|
||||
getViewsToSetHeight(parent);
|
||||
setViewHeight(Math.max(previousHeight, contentHeight));
|
||||
int additionalContentHeight = 0;
|
||||
if (checkHierarchyHeight) {
|
||||
ViewParent viewParent = parent.getParent();
|
||||
if (viewParent instanceof View) {
|
||||
additionalContentHeight = ((View) viewParent).getHeight() - contentHeight;
|
||||
}
|
||||
}
|
||||
setViewHeight(Math.max(previousHeight, contentHeight + additionalContentHeight));
|
||||
resizableView.requestLayout();
|
||||
|
||||
onTransitionStart(isKeyboardVisible);
|
||||
onTransitionStart(isKeyboardVisible, contentHeight);
|
||||
|
||||
float dy = contentHeight - previousHeight;
|
||||
float from;
|
||||
|
@ -240,7 +250,7 @@ public class AdjustPanLayoutHelper {
|
|||
|
||||
}
|
||||
|
||||
protected void onTransitionStart(boolean keyboardVisible) {
|
||||
protected void onTransitionStart(boolean keyboardVisible, int contentHeight) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -255,4 +265,8 @@ public class AdjustPanLayoutHelper {
|
|||
public boolean animationInProgress() {
|
||||
return animationInProgress;
|
||||
}
|
||||
|
||||
public void setCheckHierarchyHeight(boolean checkHierarchyHeight) {
|
||||
this.checkHierarchyHeight = checkHierarchyHeight;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ import org.telegram.messenger.NotificationCenter;
|
|||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.ui.Components.AnimationProperties;
|
||||
import org.telegram.ui.Components.Bulletin;
|
||||
import org.telegram.ui.Components.CubicBezierInterpolator;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
|
||||
|
@ -1190,6 +1191,7 @@ public class BottomSheet extends Dialog {
|
|||
onHideListener.onDismiss(this);
|
||||
}
|
||||
cancelSheetAnimation();
|
||||
long duration = 0;
|
||||
if (!allowCustomAnimation || !onCustomCloseAnimation()) {
|
||||
currentSheetAnimationType = 2;
|
||||
currentSheetAnimation = new AnimatorSet();
|
||||
|
@ -1199,10 +1201,11 @@ public class BottomSheet extends Dialog {
|
|||
);
|
||||
if (useFastDismiss) {
|
||||
int height = containerView.getMeasuredHeight();
|
||||
currentSheetAnimation.setDuration(Math.max(60, (int) (250 * (height - containerView.getTranslationY()) / (float) height)));
|
||||
duration = Math.max(60, (int) (250 * (height - containerView.getTranslationY()) / (float) height));
|
||||
currentSheetAnimation.setDuration(duration);
|
||||
useFastDismiss = false;
|
||||
} else {
|
||||
currentSheetAnimation.setDuration(250);
|
||||
currentSheetAnimation.setDuration(duration = 250);
|
||||
}
|
||||
currentSheetAnimation.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
||||
currentSheetAnimation.addListener(new AnimatorListenerAdapter() {
|
||||
|
@ -1233,6 +1236,15 @@ public class BottomSheet extends Dialog {
|
|||
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.stopAllHeavyOperations, 512);
|
||||
currentSheetAnimation.start();
|
||||
}
|
||||
|
||||
Bulletin bulletin = Bulletin.getVisibleBulletin();
|
||||
if (bulletin != null && bulletin.isShowing()) {
|
||||
if (duration > 0) {
|
||||
bulletin.hide((long) (duration * 0.6f));
|
||||
} else {
|
||||
bulletin.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getSheetAnimationType() {
|
||||
|
|
|
@ -290,6 +290,13 @@ public class DrawerLayoutContainer extends FrameLayout {
|
|||
parentActionBarLayout = layout;
|
||||
}
|
||||
|
||||
public void closeDrawer() {
|
||||
if (drawerPosition != 0) {
|
||||
setDrawerPosition(0);
|
||||
onDrawerAnimationEnd(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAllowOpenDrawer(boolean value, boolean animated) {
|
||||
allowOpenDrawer = value;
|
||||
if (!allowOpenDrawer && drawerPosition != 0) {
|
||||
|
|
|
@ -63,8 +63,6 @@ import java.util.HashMap;
|
|||
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.google.android.exoplayer2.util.Log;
|
||||
|
||||
public class ThemeDescription {
|
||||
|
||||
public static int FLAG_BACKGROUND = 0x00000001;
|
||||
|
|
|
@ -556,11 +556,12 @@ public class ActionIntroActivity extends BaseFragment implements LocationControl
|
|||
|
||||
switch (currentType) {
|
||||
case ACTION_TYPE_CHANNEL_CREATE: {
|
||||
imageView.setImageResource(R.drawable.channelintro);
|
||||
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
imageView.setAnimation(R.raw.channel_create, 200, 200);
|
||||
titleTextView.setText(LocaleController.getString("ChannelAlertTitle", R.string.ChannelAlertTitle));
|
||||
descriptionText.setText(LocaleController.getString("ChannelAlertText", R.string.ChannelAlertText));
|
||||
buttonTextView.setText(LocaleController.getString("ChannelAlertCreate2", R.string.ChannelAlertCreate2));
|
||||
imageView.playAnimation();
|
||||
break;
|
||||
}
|
||||
case ACTION_TYPE_NEARBY_LOCATION_ACCESS: {
|
||||
|
|
|
@ -82,6 +82,7 @@ public class MentionsAdapter extends RecyclerListView.SelectionAdapter {
|
|||
private int resultStartPosition;
|
||||
private int resultLength;
|
||||
private String lastText;
|
||||
private boolean lastForSearch;
|
||||
private boolean lastUsernameOnly;
|
||||
private int lastPosition;
|
||||
private ArrayList<MessageObject> messages;
|
||||
|
@ -147,7 +148,7 @@ public class MentionsAdapter extends RecyclerListView.SelectionAdapter {
|
|||
@Override
|
||||
public void onSetHashtags(ArrayList<SearchAdapterHelper.HashtagObject> arrayList, HashMap<String, SearchAdapterHelper.HashtagObject> hashMap) {
|
||||
if (lastText != null) {
|
||||
searchUsernameOrHashtag(lastText, lastPosition, messages, lastUsernameOnly);
|
||||
searchUsernameOrHashtag(lastText, lastPosition, messages, lastUsernameOnly, lastForSearch);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -196,7 +197,7 @@ public class MentionsAdapter extends RecyclerListView.SelectionAdapter {
|
|||
}
|
||||
}
|
||||
if (lastText != null) {
|
||||
searchUsernameOrHashtag(lastText, lastPosition, messages, lastUsernameOnly);
|
||||
searchUsernameOrHashtag(lastText, lastPosition, messages, lastUsernameOnly, lastForSearch);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -550,7 +551,7 @@ public class MentionsAdapter extends RecyclerListView.SelectionAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
public void searchUsernameOrHashtag(String text, int position, ArrayList<MessageObject> messageObjects, boolean usernameOnly) {
|
||||
public void searchUsernameOrHashtag(String text, int position, ArrayList<MessageObject> messageObjects, boolean usernameOnly, boolean forSearch) {
|
||||
if (cancelDelayRunnable != null) {
|
||||
AndroidUtilities.cancelRunOnUIThread(cancelDelayRunnable);
|
||||
cancelDelayRunnable = null;
|
||||
|
@ -575,6 +576,7 @@ public class MentionsAdapter extends RecyclerListView.SelectionAdapter {
|
|||
}
|
||||
lastText = null;
|
||||
lastUsernameOnly = usernameOnly;
|
||||
lastForSearch = forSearch;
|
||||
StringBuilder result = new StringBuilder();
|
||||
int foundType = -1;
|
||||
if (!usernameOnly && needBotContext && text.charAt(0) == '@') {
|
||||
|
@ -695,7 +697,7 @@ public class MentionsAdapter extends RecyclerListView.SelectionAdapter {
|
|||
if (user == null) {
|
||||
continue;
|
||||
}
|
||||
if (user.username != null && user.username.length() > 0 && (usernameString.length() > 0 && user.username.toLowerCase().startsWith(usernameString) || usernameString.length() == 0)) {
|
||||
if (!TextUtils.isEmpty(user.username) && (usernameString.length() == 0 || user.username.toLowerCase().startsWith(usernameString))) {
|
||||
newResult.add(user);
|
||||
newResultsHashMap.put(user.id, user);
|
||||
newMap.put(user.id, user);
|
||||
|
@ -719,7 +721,7 @@ public class MentionsAdapter extends RecyclerListView.SelectionAdapter {
|
|||
threadId = 0;
|
||||
}
|
||||
if (chat != null && info != null && info.participants != null && (!ChatObject.isChannel(chat) || chat.megagroup)) {
|
||||
for (int a = -1; a < info.participants.participants.size(); a++) {
|
||||
for (int a = (forSearch ? -1 : 0); a < info.participants.participants.size(); a++) {
|
||||
String username;
|
||||
String firstName;
|
||||
String lastName;
|
||||
|
|
|
@ -445,10 +445,10 @@ public class StickersSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
if (payloads.contains(PAYLOAD_ANIMATED)) {
|
||||
if (holder.getItemViewType() == 3) {
|
||||
bindFeaturedStickerSetInfoCell((FeaturedStickerSetInfoCell) holder.itemView, position, true);
|
||||
} else {
|
||||
super.onBindViewHolder(holder, position, payloads);
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.onBindViewHolder(holder, position, payloads);
|
||||
}
|
||||
|
||||
public void installStickerSet(TLRPC.InputStickerSet inputSet) {
|
||||
|
|
|
@ -135,6 +135,7 @@ import org.telegram.ui.Components.AnchorSpan;
|
|||
import org.telegram.ui.Components.AnimatedArrowDrawable;
|
||||
import org.telegram.ui.Components.AnimationProperties;
|
||||
import org.telegram.ui.Components.AvatarDrawable;
|
||||
import org.telegram.ui.Components.BulletinFactory;
|
||||
import org.telegram.ui.Components.CloseProgressDrawable2;
|
||||
import org.telegram.ui.Components.CombinedDrawable;
|
||||
import org.telegram.ui.Components.ContextProgressView;
|
||||
|
@ -3651,7 +3652,7 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
|
|||
|
||||
@Override
|
||||
public void onTextCopied() {
|
||||
|
||||
BulletinFactory.of(containerView).createCopyBulletin(LocaleController.getString("TextCopied", R.string.TextCopied)).show();
|
||||
}
|
||||
});
|
||||
containerView.addView(textSelectionHelper.getOverlayView(activity));
|
||||
|
|
|
@ -66,6 +66,8 @@ import org.telegram.ui.ActionBar.ThemeDescription;
|
|||
import org.telegram.ui.Components.AlertsCreator;
|
||||
import org.telegram.ui.Components.EditTextBoldCursor;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.RLottieDrawable;
|
||||
import org.telegram.ui.Components.RLottieImageView;
|
||||
import org.telegram.ui.Components.RadialProgressView;
|
||||
import org.telegram.ui.Components.SlideView;
|
||||
import org.telegram.ui.Components.URLSpanNoUnderline;
|
||||
|
@ -402,11 +404,13 @@ public class CancelAccountDeletionActivity extends BaseFragment {
|
|||
private TextView confirmTextView;
|
||||
private TextView titleTextView;
|
||||
private ImageView blackImageView;
|
||||
private ImageView blueImageView;
|
||||
private RLottieImageView blueImageView;
|
||||
private TextView timeText;
|
||||
private TextView problemText;
|
||||
private ProgressView progressView;
|
||||
|
||||
RLottieDrawable hintDrawable;
|
||||
|
||||
private Timer timeTimer;
|
||||
private Timer codeTimer;
|
||||
private final Object timerSync = new Object();
|
||||
|
@ -471,17 +475,19 @@ public class CancelAccountDeletionActivity extends BaseFragment {
|
|||
blackImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText), PorterDuff.Mode.MULTIPLY));
|
||||
frameLayout.addView(blackImageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0));
|
||||
|
||||
blueImageView = new ImageView(context);
|
||||
blueImageView = new RLottieImageView(context);
|
||||
blueImageView.setImageResource(R.drawable.sms_bubble);
|
||||
blueImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionBackground), PorterDuff.Mode.MULTIPLY));
|
||||
frameLayout.addView(blueImageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0));
|
||||
|
||||
titleTextView.setText(LocaleController.getString("SentAppCodeTitle", R.string.SentAppCodeTitle));
|
||||
} else {
|
||||
blueImageView = new ImageView(context);
|
||||
blueImageView.setImageResource(R.drawable.sms_code);
|
||||
blueImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionBackground), PorterDuff.Mode.MULTIPLY));
|
||||
frameLayout.addView(blueImageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0));
|
||||
blueImageView = new RLottieImageView(context);
|
||||
hintDrawable = new RLottieDrawable(R.raw.sms_incoming_info, "" + R.raw.sms_incoming_info, AndroidUtilities.dp(48), AndroidUtilities.dp(48), true, null);
|
||||
hintDrawable.setLayerColor("Bubble.**", Theme.getColor(Theme.key_chats_actionBackground));
|
||||
hintDrawable.setLayerColor("Phone.**", Theme.getColor(Theme.key_chats_actionBackground));
|
||||
blueImageView.setAnimation(hintDrawable);
|
||||
frameLayout.addView(blueImageView, LayoutHelper.createFrame(48, 48, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0));
|
||||
|
||||
titleTextView.setText(LocaleController.getString("SentSmsCodeTitle", R.string.SentSmsCodeTitle));
|
||||
}
|
||||
|
@ -1036,6 +1042,9 @@ public class CancelAccountDeletionActivity extends BaseFragment {
|
|||
if (currentType == 3) {
|
||||
return;
|
||||
}
|
||||
if (hintDrawable != null) {
|
||||
hintDrawable.setCurrentFrame(0);
|
||||
}
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
if (codeField != null) {
|
||||
for (int a = codeField.length - 1; a >= 0; a--) {
|
||||
|
@ -1047,6 +1056,9 @@ public class CancelAccountDeletionActivity extends BaseFragment {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (hintDrawable != null) {
|
||||
hintDrawable.start();
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
|
@ -1081,6 +1093,18 @@ public class CancelAccountDeletionActivity extends BaseFragment {
|
|||
|
||||
ArrayList<ThemeDescription> arrayList = new ArrayList<>();
|
||||
|
||||
ThemeDescription.ThemeDescriptionDelegate descriptionDelegate = () -> {
|
||||
for (int i = 0; i < views.length; i++) {
|
||||
if (views[i] instanceof LoginActivity.LoginActivitySmsView) {
|
||||
LoginActivity.LoginActivitySmsView smsView = (LoginActivity.LoginActivitySmsView) views[i];
|
||||
if (smsView.hintDrawable != null) {
|
||||
smsView.hintDrawable.setLayerColor("Bubble.**", Theme.getColor(Theme.key_chats_actionBackground));
|
||||
smsView.hintDrawable.setLayerColor("Phone.**", Theme.getColor(Theme.key_chats_actionBackground));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
arrayList.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite));
|
||||
|
||||
arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_actionBarDefault));
|
||||
|
@ -1151,6 +1175,7 @@ public class CancelAccountDeletionActivity extends BaseFragment {
|
|||
arrayList.add(new ThemeDescription(smsView4.progressView, 0, new Class[]{ProgressView.class}, new String[]{"paint"}, null, null, null, Theme.key_login_progressOuter));
|
||||
arrayList.add(new ThemeDescription(smsView4.blackImageView, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
||||
arrayList.add(new ThemeDescription(smsView4.blueImageView, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chats_actionBackground));
|
||||
arrayList.add(new ThemeDescription(smsView4.blueImageView, 0, null, null, null, descriptionDelegate, Theme.key_chats_actionBackground));
|
||||
|
||||
return arrayList;
|
||||
}
|
||||
|
|
|
@ -25,21 +25,23 @@ import android.view.accessibility.AccessibilityNodeInfo;
|
|||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.DownloadController;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.ImageLoader;
|
||||
import org.telegram.messenger.ImageLocation;
|
||||
import org.telegram.messenger.ImageReceiver;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessageObject;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.SharedConfig;
|
||||
import org.telegram.messenger.browser.Browser;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.browser.Browser;
|
||||
import org.telegram.tgnet.TLObject;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.PhotoViewer;
|
||||
import org.telegram.ui.Components.AvatarDrawable;
|
||||
import org.telegram.ui.Components.URLSpanNoUnderline;
|
||||
import org.telegram.ui.PhotoViewer;
|
||||
|
||||
public class ChatActionCell extends BaseCell implements DownloadController.FileDownloadProgressListener {
|
||||
|
||||
|
@ -489,8 +491,29 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
int dx;
|
||||
int dx2;
|
||||
int dy;
|
||||
int previousLineWidth = 0;
|
||||
for (int a = 0; a < count; a++) {
|
||||
int width = findMaxWidthAroundLine(a);
|
||||
int nextWidth = a < count - 1 ? findMaxWidthAroundLine(a + 1) : 0;
|
||||
int w1 = 0;
|
||||
int w2 = 0;
|
||||
if (previousLineWidth != 0) {
|
||||
int dw = width - previousLineWidth;
|
||||
if (dw > 0 && dw < AndroidUtilities.dp(15) * 2) {
|
||||
width = w1 = previousLineWidth + AndroidUtilities.dp(15) * 2;
|
||||
}
|
||||
|
||||
}
|
||||
if (nextWidth != 0) {
|
||||
int dw = width - nextWidth;
|
||||
if (dw > 0 && dw < AndroidUtilities.dp(15) * 2) {
|
||||
width = w2 = nextWidth + AndroidUtilities.dp(15) * 2;
|
||||
}
|
||||
}
|
||||
if (w1 != 0 && w2 != 0) {
|
||||
width = Math.max(w1, w2);
|
||||
}
|
||||
previousLineWidth = width;
|
||||
int x = (getMeasuredWidth() - width - cornerRest) / 2;
|
||||
width += cornerRest;
|
||||
int lineBottom = textLayout.getLineBottom(a);
|
||||
|
|
|
@ -3068,7 +3068,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
createSelectorDrawable(0);
|
||||
}
|
||||
photoImage.setAlpha(1.0f);
|
||||
if (messageChanged || dataChanged) {
|
||||
if ((messageChanged || dataChanged) && !pollUnvoteInProgress) {
|
||||
pollButtons.clear();
|
||||
}
|
||||
int captionNewLine = 0;
|
||||
|
@ -8335,7 +8335,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
} else {
|
||||
buttonState = 2;
|
||||
}
|
||||
} else if (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO) {
|
||||
} else if (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO && !hasEmbed) {
|
||||
buttonState = 3;
|
||||
} else {
|
||||
buttonState = -1;
|
||||
|
@ -13550,9 +13550,24 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
|
||||
animateMessageText = false;
|
||||
if (currentMessageObject.textLayoutBlocks != lastDrawingTextBlocks) {
|
||||
animateMessageText = true;
|
||||
animateOutTextBlocks = lastDrawingTextBlocks;
|
||||
changed = true;
|
||||
boolean sameText = true;
|
||||
if (currentMessageObject.textLayoutBlocks != null && lastDrawingTextBlocks != null && currentMessageObject.textLayoutBlocks.size() == lastDrawingTextBlocks.size()) {
|
||||
for (int i = 0; i < lastDrawingTextBlocks.size(); i++) {
|
||||
String newText = currentMessageObject.textLayoutBlocks.get(i).textLayout == null ? null : currentMessageObject.textLayoutBlocks.get(i).textLayout.getText().toString();
|
||||
String oldText = lastDrawingTextBlocks.get(i).textLayout == null ? null : lastDrawingTextBlocks.get(i).textLayout.getText().toString();
|
||||
if ((newText == null && oldText != null) || (newText != null && oldText == null) || !newText.equals(oldText)) {
|
||||
sameText = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sameText = false;
|
||||
}
|
||||
if (!sameText) {
|
||||
animateMessageText = true;
|
||||
animateOutTextBlocks = lastDrawingTextBlocks;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (edited && !lastDrawingEdited && timeLayout != null) {
|
||||
String editedStr = LocaleController.getString("EditedMessage", R.string.EditedMessage);
|
||||
|
|
|
@ -2706,7 +2706,7 @@ public class DialogCell extends BaseCell {
|
|||
} else if (chat != null) {
|
||||
hasCall = chat.call_active && chat.call_not_empty;
|
||||
if (hasCall || chatCallProgress != 0) {
|
||||
float checkProgress = checkBox.isChecked() ? 1.0f - checkBox.getProgress() : 1.0f;
|
||||
float checkProgress = checkBox != null && checkBox.isChecked() ? 1.0f - checkBox.getProgress() : 1.0f;
|
||||
int top = (int) (avatarImage.getImageY2() - AndroidUtilities.dp(useForceThreeLines || SharedConfig.useThreeLinesLayout ? 6 : 8));
|
||||
int left;
|
||||
if (LocaleController.isRTL) {
|
||||
|
|
|
@ -121,7 +121,7 @@ public class DrawerProfileCell extends FrameLayout {
|
|||
@Override
|
||||
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
|
||||
super.onInitializeAccessibilityNodeInfo(info);
|
||||
if (sunDrawable.getCustomEndFrame() == 0) {
|
||||
if (sunDrawable.getCustomEndFrame() != 0) {
|
||||
info.setText(LocaleController.getString("AccDescrSwitchToNightTheme", R.string.AccDescrSwitchToNightTheme));
|
||||
} else {
|
||||
info.setText(LocaleController.getString("AccDescrSwitchToDayTheme", R.string.AccDescrSwitchToDayTheme));
|
||||
|
|
|
@ -117,6 +117,11 @@ public class GroupCreateUserCell extends FrameLayout {
|
|||
return currentObject;
|
||||
}
|
||||
|
||||
public void setDrawDivider(boolean value) {
|
||||
drawDivider = value;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(currentObject instanceof String ? 50 : 58), MeasureSpec.EXACTLY));
|
||||
|
|
|
@ -193,7 +193,7 @@ public class SharedPhotoVideoCell extends FrameLayout {
|
|||
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto && messageObject.messageOwner.media.photo != null && !messageObject.photoThumbs.isEmpty()) {
|
||||
videoInfoContainer.setVisibility(INVISIBLE);
|
||||
TLRPC.PhotoSize currentPhotoObjectThumb = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 50);
|
||||
TLRPC.PhotoSize currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 320, false, currentPhotoObjectThumb);
|
||||
TLRPC.PhotoSize currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 320, false, currentPhotoObjectThumb, false);
|
||||
if (messageObject.mediaExists || DownloadController.getInstance(currentAccount).canDownloadMedia(messageObject)) {
|
||||
if (currentPhotoObject == currentPhotoObjectThumb) {
|
||||
currentPhotoObjectThumb = null;
|
||||
|
|
|
@ -79,6 +79,10 @@ public class TextCell extends FrameLayout {
|
|||
return textView;
|
||||
}
|
||||
|
||||
public ImageView getImageView() {
|
||||
return imageView;
|
||||
}
|
||||
|
||||
public SimpleTextView getValueTextView() {
|
||||
return valueTextView;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.animation.AnimatorListenerAdapter;
|
|||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.Rect;
|
||||
|
@ -32,6 +33,7 @@ import android.view.animation.OvershootInterpolator;
|
|||
import android.widget.Magnifier;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
|
@ -122,6 +124,8 @@ public abstract class TextSelectionHelper<Cell extends TextSelectionHelper.Selec
|
|||
|
||||
protected boolean showActionsAsPopupAlways = false;
|
||||
|
||||
int keyboardSize;
|
||||
|
||||
private Runnable scrollRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -1022,7 +1026,7 @@ public abstract class TextSelectionHelper<Cell extends TextSelectionHelper.Selec
|
|||
y += layoutBlock.yOffset;
|
||||
x += layoutBlock.xOffset;
|
||||
|
||||
if (y + yOffset > top && y + yOffset < parentView.getMeasuredHeight()) {
|
||||
if (y + yOffset > top + keyboardSize && y + yOffset < parentView.getMeasuredHeight()) {
|
||||
if (!layout.isRtlCharAt(selectionEnd)) {
|
||||
canvas.save();
|
||||
canvas.translate(x, y);
|
||||
|
@ -1082,7 +1086,7 @@ public abstract class TextSelectionHelper<Cell extends TextSelectionHelper.Selec
|
|||
y += layoutBlock.yOffset;
|
||||
x += layoutBlock.xOffset;
|
||||
|
||||
if (y + yOffset > top && y + yOffset < parentView.getMeasuredHeight()) {
|
||||
if (y + yOffset > top + keyboardSize && y + yOffset < parentView.getMeasuredHeight()) {
|
||||
if (!layout.isRtlCharAt(selectionStart)) {
|
||||
canvas.save();
|
||||
canvas.translate(x - handleViewSize, y);
|
||||
|
@ -2607,4 +2611,9 @@ public abstract class TextSelectionHelper<Cell extends TextSelectionHelper.Selec
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setKeyboardSize(int keyboardSize) {
|
||||
this.keyboardSize = keyboardSize;
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,6 +72,8 @@ import org.telegram.ui.Components.AlertsCreator;
|
|||
import org.telegram.ui.Components.EditTextBoldCursor;
|
||||
import org.telegram.ui.Components.HintEditText;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.RLottieDrawable;
|
||||
import org.telegram.ui.Components.RLottieImageView;
|
||||
import org.telegram.ui.Components.SlideView;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
@ -830,12 +832,14 @@ public class ChangePhoneActivity extends BaseFragment {
|
|||
private TextView confirmTextView;
|
||||
private TextView titleTextView;
|
||||
private ImageView blackImageView;
|
||||
private ImageView blueImageView;
|
||||
private RLottieImageView blueImageView;
|
||||
private TextView timeText;
|
||||
private TextView problemText;
|
||||
private Bundle currentParams;
|
||||
private ProgressView progressView;
|
||||
|
||||
RLottieDrawable hintDrawable;
|
||||
|
||||
private Timer timeTimer;
|
||||
private Timer codeTimer;
|
||||
private final Object timerSync = new Object();
|
||||
|
@ -898,16 +902,19 @@ public class ChangePhoneActivity extends BaseFragment {
|
|||
blackImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText), PorterDuff.Mode.MULTIPLY));
|
||||
frameLayout.addView(blackImageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0));
|
||||
|
||||
blueImageView = new ImageView(context);
|
||||
blueImageView = new RLottieImageView(context);
|
||||
blueImageView.setImageResource(R.drawable.sms_bubble);
|
||||
blueImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionBackground), PorterDuff.Mode.MULTIPLY));
|
||||
frameLayout.addView(blueImageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0));
|
||||
|
||||
titleTextView.setText(LocaleController.getString("SentAppCodeTitle", R.string.SentAppCodeTitle));
|
||||
} else {
|
||||
blueImageView = new ImageView(context);
|
||||
blueImageView.setImageResource(R.drawable.sms_code);
|
||||
blueImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionBackground), PorterDuff.Mode.MULTIPLY));
|
||||
blueImageView = new RLottieImageView(context);
|
||||
hintDrawable = new RLottieDrawable(R.raw.sms_incoming_info, "" + R.raw.sms_incoming_info, AndroidUtilities.dp(64), AndroidUtilities.dp(64), true, null);
|
||||
hintDrawable.setLayerColor("Bubble.**", Theme.getColor(Theme.key_chats_actionBackground));
|
||||
hintDrawable.setLayerColor("Phone.**", Theme.getColor(Theme.key_chats_actionBackground));
|
||||
blueImageView.setAnimation(hintDrawable);
|
||||
|
||||
frameLayout.addView(blueImageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0));
|
||||
|
||||
titleTextView.setText(LocaleController.getString("SentSmsCodeTitle", R.string.SentSmsCodeTitle));
|
||||
|
@ -1515,6 +1522,9 @@ public class ChangePhoneActivity extends BaseFragment {
|
|||
if (currentType == 3) {
|
||||
return;
|
||||
}
|
||||
if (hintDrawable != null) {
|
||||
hintDrawable.setCurrentFrame(0);
|
||||
}
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
if (codeField != null) {
|
||||
for (int a = codeField.length - 1; a >= 0; a--) {
|
||||
|
@ -1526,6 +1536,9 @@ public class ChangePhoneActivity extends BaseFragment {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (hintDrawable != null) {
|
||||
hintDrawable.start();
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
|
@ -1560,6 +1573,18 @@ public class ChangePhoneActivity extends BaseFragment {
|
|||
|
||||
ArrayList<ThemeDescription> arrayList = new ArrayList<>();
|
||||
|
||||
ThemeDescription.ThemeDescriptionDelegate descriptionDelegate = () -> {
|
||||
for (int i = 0; i < views.length; i++) {
|
||||
if (views[i] instanceof LoginActivity.LoginActivitySmsView) {
|
||||
LoginActivity.LoginActivitySmsView smsView = (LoginActivity.LoginActivitySmsView) views[i];
|
||||
if (smsView.hintDrawable != null) {
|
||||
smsView.hintDrawable.setLayerColor("Bubble.**", Theme.getColor(Theme.key_chats_actionBackground));
|
||||
smsView.hintDrawable.setLayerColor("Phone.**", Theme.getColor(Theme.key_chats_actionBackground));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
arrayList.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite));
|
||||
|
||||
arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_actionBarDefault));
|
||||
|
@ -1640,6 +1665,7 @@ public class ChangePhoneActivity extends BaseFragment {
|
|||
arrayList.add(new ThemeDescription(smsView4.progressView, 0, new Class[]{ProgressView.class}, new String[]{"paint"}, null, null, null, Theme.key_login_progressOuter));
|
||||
arrayList.add(new ThemeDescription(smsView4.blackImageView, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
||||
arrayList.add(new ThemeDescription(smsView4.blueImageView, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chats_actionBackground));
|
||||
arrayList.add(new ThemeDescription(smsView4.blueImageView, 0, null, null, null, descriptionDelegate, Theme.key_chats_actionBackground));
|
||||
|
||||
return arrayList;
|
||||
}
|
||||
|
|
|
@ -182,8 +182,12 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
if (firstNameField.length() > 0) {
|
||||
String url = "https://" + MessagesController.getInstance(currentAccount).linkPrefix + "/" + firstNameField.getText();
|
||||
String name = firstNameField.getText().toString();
|
||||
if (name.startsWith("@")) {
|
||||
name = name.substring(1);
|
||||
}
|
||||
if (name.length() > 0) {
|
||||
String url = "https://" + MessagesController.getInstance(currentAccount).linkPrefix + "/" + name;
|
||||
String text = LocaleController.formatString("UsernameHelpLink", R.string.UsernameHelpLink, url);
|
||||
int index = text.indexOf(url);
|
||||
SpannableStringBuilder textSpan = new SpannableStringBuilder(text);
|
||||
|
@ -237,8 +241,11 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean checkUserName(final String name, boolean alert) {
|
||||
if (name != null && name.length() > 0) {
|
||||
private boolean checkUserName(String name, boolean alert) {
|
||||
if (name != null && name.startsWith("@")) {
|
||||
name = name.substring(1);
|
||||
}
|
||||
if (!TextUtils.isEmpty(name)) {
|
||||
checkTextView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
checkTextView.setVisibility(View.GONE);
|
||||
|
@ -323,14 +330,15 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
checkTextView.setTag(Theme.key_windowBackgroundWhiteGrayText8);
|
||||
checkTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText8));
|
||||
lastCheckName = name;
|
||||
final String nameFinal = name;
|
||||
checkRunnable = () -> {
|
||||
TLRPC.TL_account_checkUsername req = new TLRPC.TL_account_checkUsername();
|
||||
req.username = name;
|
||||
req.username = nameFinal;
|
||||
checkReqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
checkReqId = 0;
|
||||
if (lastCheckName != null && lastCheckName.equals(name)) {
|
||||
if (lastCheckName != null && lastCheckName.equals(nameFinal)) {
|
||||
if (error == null && response instanceof TLRPC.TL_boolTrue) {
|
||||
checkTextView.setText(LocaleController.formatString("UsernameAvailable", R.string.UsernameAvailable, name));
|
||||
checkTextView.setText(LocaleController.formatString("UsernameAvailable", R.string.UsernameAvailable, nameFinal));
|
||||
checkTextView.setTag(Theme.key_windowBackgroundWhiteGreenText);
|
||||
checkTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGreenText));
|
||||
lastNameAvailable = true;
|
||||
|
@ -349,7 +357,11 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
}
|
||||
|
||||
private void saveName() {
|
||||
if (!checkUserName(firstNameField.getText().toString(), true)) {
|
||||
String newName = firstNameField.getText().toString();
|
||||
if (newName.startsWith("@")) {
|
||||
newName = newName.substring(1);
|
||||
}
|
||||
if (!checkUserName(newName, true)) {
|
||||
return;
|
||||
}
|
||||
TLRPC.User user = UserConfig.getInstance(currentAccount).getCurrentUser();
|
||||
|
@ -360,7 +372,6 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
if (currentName == null) {
|
||||
currentName = "";
|
||||
}
|
||||
String newName = firstNameField.getText().toString();
|
||||
if (currentName.equals(newName)) {
|
||||
finishFragment();
|
||||
return;
|
||||
|
@ -374,7 +385,7 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_NAME);
|
||||
final int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
|
||||
if (error == null) {
|
||||
final TLRPC.User user1 = (TLRPC.User)response;
|
||||
final TLRPC.User user1 = (TLRPC.User) response;
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
try {
|
||||
progressDialog.dismiss();
|
||||
|
|
|
@ -95,7 +95,9 @@ import org.telegram.ui.Cells.ChatUnreadCell;
|
|||
import org.telegram.ui.Components.AdminLogFilterAlert;
|
||||
import org.telegram.ui.Components.AlertsCreator;
|
||||
import org.telegram.ui.Components.ChatAvatarContainer;
|
||||
import org.telegram.ui.Components.ClearHistoryAlert;
|
||||
import org.telegram.ui.Components.EmbedBottomSheet;
|
||||
import org.telegram.ui.Components.InviteLinkBottomSheet;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.PhonebookShareAlert;
|
||||
import org.telegram.ui.Components.PipRoundVideoView;
|
||||
|
@ -108,6 +110,7 @@ import org.telegram.ui.Components.URLSpanMono;
|
|||
import org.telegram.ui.Components.URLSpanNoUnderline;
|
||||
import org.telegram.ui.Components.URLSpanReplacement;
|
||||
import org.telegram.ui.Components.URLSpanUserMention;
|
||||
import org.telegram.ui.Components.UndoView;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
|
@ -125,6 +128,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
private View progressView2;
|
||||
private RadialProgressView progressBar;
|
||||
private RecyclerListView chatListView;
|
||||
private UndoView undoView;
|
||||
private LinearLayoutManager chatLayoutManager;
|
||||
private ChatActivityAdapter chatAdapter;
|
||||
private TextView bottomOverlayChatText;
|
||||
|
@ -987,6 +991,10 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
chatListView.setEmptyView(emptyViewContainer);
|
||||
}
|
||||
|
||||
undoView = new UndoView(context);
|
||||
undoView.setAdditionalTranslationY(AndroidUtilities.dp(51));
|
||||
contentView.addView(undoView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8));
|
||||
|
||||
updateEmptyPlaceholder();
|
||||
|
||||
return fragmentView;
|
||||
|
@ -1027,6 +1035,21 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
showDialog(new StickersAlert(getParentActivity(), ChannelAdminLogActivity.this, stickerSet, null, null));
|
||||
return;
|
||||
}
|
||||
} else if (selectedObject.currentEvent != null && selectedObject.currentEvent.action instanceof TLRPC.TL_channelAdminLogEventActionChangeHistoryTTL) {
|
||||
if (ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_DELETE_MESSAGES)) {
|
||||
ClearHistoryAlert alert = new ClearHistoryAlert(getParentActivity(), null, currentChat, false);
|
||||
alert.setDelegate(new ClearHistoryAlert.ClearHistoryAlertDelegate() {
|
||||
@Override
|
||||
public void onAutoDeleteHistory(int ttl, int action) {
|
||||
getMessagesController().setDialogHistoryTTL(-currentChat.id, ttl);
|
||||
TLRPC.ChatFull chatInfo = getMessagesController().getChatFull(currentChat.id);
|
||||
if (chatInfo != null) {
|
||||
undoView.showWithAction(-currentChat.id, action, null, chatInfo.ttl_period, null, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
showDialog(alert);
|
||||
}
|
||||
}
|
||||
} else if (type == 3) {
|
||||
if (selectedObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage && MessageObject.isNewGifDocument(selectedObject.messageOwner.media.webpage.document)) {
|
||||
|
@ -1755,6 +1778,9 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
if (contentView != null) {
|
||||
contentView.onPause();
|
||||
}
|
||||
if (undoView != null) {
|
||||
undoView.hide(true, 0);
|
||||
}
|
||||
paused = true;
|
||||
wasPaused = true;
|
||||
if (AvatarPreviewer.hasVisibleInstance()) {
|
||||
|
@ -1762,6 +1788,13 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBecomeFullyHidden() {
|
||||
if (undoView != null) {
|
||||
undoView.hide(true, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void openVCard(TLRPC.User user, String vcard, String first_name, String last_name) {
|
||||
try {
|
||||
File f = AndroidUtilities.getSharingDirectory();
|
||||
|
@ -2225,6 +2258,12 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
}
|
||||
}
|
||||
|
||||
public void needOpenInviteLink(TLRPC.TL_chatInviteExported invite) {
|
||||
TLRPC.ChatFull chatInfo = getMessagesController().getChatFull(currentChat.id);
|
||||
InviteLinkBottomSheet inviteLinkBottomSheet = new InviteLinkBottomSheet(contentView.getContext(), invite, chatInfo, null, ChannelAdminLogActivity.this, chatInfo.id, false, ChatObject.isChannel(currentChat));
|
||||
inviteLinkBottomSheet.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didPressReplyMessage(ChatActionCell cell, int id) {
|
||||
|
||||
|
@ -2644,6 +2683,14 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
|
||||
themeDescriptions.add(new ThemeDescription(avatarContainer != null ? avatarContainer.getTimeItem() : null, 0, null, null, null, null, Theme.key_chat_secretTimerBackground));
|
||||
themeDescriptions.add(new ThemeDescription(avatarContainer != null ? avatarContainer.getTimeItem() : null, 0, null, null, null, null, Theme.key_chat_secretTimerText));
|
||||
|
||||
themeDescriptions.add(new ThemeDescription(undoView, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_undo_background));
|
||||
themeDescriptions.add(new ThemeDescription(undoView, 0, new Class[]{UndoView.class}, new String[]{"undoImageView"}, null, null, null, Theme.key_undo_cancelColor));
|
||||
themeDescriptions.add(new ThemeDescription(undoView, 0, new Class[]{UndoView.class}, new String[]{"undoTextView"}, null, null, null, Theme.key_undo_cancelColor));
|
||||
themeDescriptions.add(new ThemeDescription(undoView, 0, new Class[]{UndoView.class}, new String[]{"infoTextView"}, null, null, null, Theme.key_undo_infoColor));
|
||||
themeDescriptions.add(new ThemeDescription(undoView, 0, new Class[]{UndoView.class}, new String[]{"textPaint"}, null, null, null, Theme.key_undo_infoColor));
|
||||
themeDescriptions.add(new ThemeDescription(undoView, 0, new Class[]{UndoView.class}, new String[]{"progressPaint"}, null, null, null, Theme.key_undo_infoColor));
|
||||
themeDescriptions.add(new ThemeDescription(undoView, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{UndoView.class}, new String[]{"leftImageView"}, null, null, null, Theme.key_undo_infoColor));
|
||||
|
||||
return themeDescriptions;
|
||||
}
|
||||
|
|
|
@ -718,8 +718,9 @@ public class ChannelCreateActivity extends BaseFragment implements NotificationC
|
|||
privateContainer.setOrientation(LinearLayout.VERTICAL);
|
||||
linkContainer.addView(privateContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
|
||||
permanentLinkView = new LinkActionView(context, this, null, chatId, true);
|
||||
permanentLinkView.showOptions(false);
|
||||
permanentLinkView = new LinkActionView(context, this, null, chatId, true, ChatObject.isChannel(getMessagesController().getChat(chatId)));
|
||||
//permanentLinkView.showOptions(false);
|
||||
permanentLinkView.showRevokeOption(true);
|
||||
permanentLinkView.setUsers(0, null);
|
||||
privateContainer.addView(permanentLinkView);
|
||||
|
||||
|
@ -755,19 +756,15 @@ public class ChannelCreateActivity extends BaseFragment implements NotificationC
|
|||
if (loadingInvite || invite != null) {
|
||||
return;
|
||||
}
|
||||
TLRPC.ChatFull chatFull = getMessagesController().getChatFull(chatId);
|
||||
if (chatFull != null) {
|
||||
invite = chatFull.exported_invite;
|
||||
}
|
||||
if (invite != null) {
|
||||
return;
|
||||
}
|
||||
loadingInvite = true;
|
||||
TLRPC.TL_messages_exportChatInvite req = new TLRPC.TL_messages_exportChatInvite();
|
||||
req.peer = getMessagesController().getInputPeer(-chatId);
|
||||
final int reqId = getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
if (error == null) {
|
||||
invite = (TLRPC.TL_chatInviteExported) response;
|
||||
}
|
||||
loadingInvite = false;
|
||||
permanentLinkView.setLink(invite != null ? invite.link : null);
|
||||
}));
|
||||
getConnectionsManager().bindRequestToGuid(reqId, classGuid);
|
||||
|
||||
/*TLRPC.TL_messages_getExportedChatInvites req = new TLRPC.TL_messages_getExportedChatInvites(); TODO layer 124
|
||||
TLRPC.TL_messages_getExportedChatInvites req = new TLRPC.TL_messages_getExportedChatInvites();
|
||||
req.peer = getMessagesController().getInputPeer(-chatId);
|
||||
req.admin_id = getMessagesController().getInputUser(getUserConfig().getCurrentUser());
|
||||
req.limit = 1;
|
||||
|
@ -779,7 +776,7 @@ public class ChannelCreateActivity extends BaseFragment implements NotificationC
|
|||
}
|
||||
loadingInvite = false;
|
||||
permanentLinkView.setLink(invite != null ? invite.link : null);
|
||||
}));*/
|
||||
}));
|
||||
}
|
||||
|
||||
private void updatePrivatePublic() {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -69,6 +69,7 @@ import org.telegram.ui.Components.EditTextBoldCursor;
|
|||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.RadialProgressView;
|
||||
import org.telegram.ui.Components.SizeNotifierFrameLayout;
|
||||
import org.telegram.ui.Components.UndoView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
@ -79,6 +80,8 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
|
|||
|
||||
private AlertDialog progressDialog;
|
||||
|
||||
private UndoView undoView;
|
||||
|
||||
private LinearLayout avatarContainer;
|
||||
private BackupImageView avatarImage;
|
||||
private View avatarOverlay;
|
||||
|
@ -217,18 +220,18 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
|
|||
}
|
||||
|
||||
private void loadLinksCount() {
|
||||
// TLRPC.TL_messages_getExportedChatInvites req = new TLRPC.TL_messages_getExportedChatInvites();
|
||||
// req.peer = getMessagesController().getInputPeer(-chatId);
|
||||
// req.admin_id = getMessagesController().getInputUser(getUserConfig().getCurrentUser());
|
||||
// req.limit = 0;
|
||||
// getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
// if (error == null) {
|
||||
// TLRPC.TL_messages_exportedChatInvites invites = (TLRPC.TL_messages_exportedChatInvites) response;
|
||||
// info.invitesCount = invites.count;
|
||||
// getMessagesStorage().saveChatLinksCount(chatId, info.invitesCount);
|
||||
// updateFields(false);
|
||||
// }
|
||||
// }));
|
||||
TLRPC.TL_messages_getExportedChatInvites req = new TLRPC.TL_messages_getExportedChatInvites();
|
||||
req.peer = getMessagesController().getInputPeer(-chatId);
|
||||
req.admin_id = getMessagesController().getInputUser(getUserConfig().getCurrentUser());
|
||||
req.limit = 0;
|
||||
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
if (error == null) {
|
||||
TLRPC.TL_messages_exportedChatInvites invites = (TLRPC.TL_messages_exportedChatInvites) response;
|
||||
info.invitesCount = invites.count;
|
||||
getMessagesStorage().saveChatLinksCount(chatId, info.invitesCount);
|
||||
updateFields(false);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -262,9 +265,19 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
|
|||
if (nameTextView != null) {
|
||||
nameTextView.onPause();
|
||||
}
|
||||
if (undoView != null) {
|
||||
undoView.hide(true, 0);
|
||||
}
|
||||
imageUpdater.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBecomeFullyHidden() {
|
||||
if (undoView != null) {
|
||||
undoView.hide(true, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismissCurrentDialog() {
|
||||
if (imageUpdater.dismissCurrentDialog(visibleDialog)) {
|
||||
|
@ -766,19 +779,19 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
|
|||
blockCell.setOnClickListener(v -> {
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("chat_id", chatId);
|
||||
args.putInt("type", !isChannel ? ChatUsersActivity.TYPE_KICKED : ChatUsersActivity.TYPE_BANNED);
|
||||
args.putInt("type", !isChannel && !currentChat.gigagroup ? ChatUsersActivity.TYPE_KICKED : ChatUsersActivity.TYPE_BANNED);
|
||||
ChatUsersActivity fragment = new ChatUsersActivity(args);
|
||||
fragment.setInfo(info);
|
||||
presentFragment(fragment);
|
||||
});
|
||||
|
||||
// inviteLinksCell = new TextCell(context);
|
||||
// inviteLinksCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
|
||||
// inviteLinksCell.setOnClickListener(v -> {
|
||||
// ManageLinksActivity fragment = new ManageLinksActivity(chatId);
|
||||
// fragment.setInfo(info, info.exported_invite);
|
||||
// presentFragment(fragment);
|
||||
// });
|
||||
inviteLinksCell = new TextCell(context);
|
||||
inviteLinksCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
|
||||
inviteLinksCell.setOnClickListener(v -> {
|
||||
ManageLinksActivity fragment = new ManageLinksActivity(chatId, 0, 0);
|
||||
fragment.setInfo(info, info.exported_invite);
|
||||
presentFragment(fragment);
|
||||
});
|
||||
|
||||
adminCell = new TextCell(context);
|
||||
adminCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
|
||||
|
@ -802,20 +815,25 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
|
|||
presentFragment(fragment);
|
||||
});
|
||||
|
||||
if (ChatObject.isChannel(currentChat)) {
|
||||
if (ChatObject.isChannel(currentChat) || currentChat.gigagroup) {
|
||||
logCell = new TextCell(context);
|
||||
logCell.setTextAndIcon(LocaleController.getString("EventLog", R.string.EventLog), R.drawable.group_log, false);
|
||||
logCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
|
||||
logCell.setOnClickListener(v -> presentFragment(new ChannelAdminLogActivity(currentChat)));
|
||||
}
|
||||
|
||||
if (!isChannel) {
|
||||
if (!isChannel && !currentChat.gigagroup) {
|
||||
infoContainer.addView(blockCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
}
|
||||
// infoContainer.addView(inviteLinksCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
if (!isChannel) {
|
||||
infoContainer.addView(inviteLinksCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
}
|
||||
infoContainer.addView(adminCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
infoContainer.addView(membersCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
if (isChannel) {
|
||||
infoContainer.addView(inviteLinksCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
}
|
||||
if (isChannel || currentChat.gigagroup) {
|
||||
infoContainer.addView(blockCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
}
|
||||
if (logCell != null) {
|
||||
|
@ -893,6 +911,9 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
|
|||
}
|
||||
}
|
||||
|
||||
undoView = new UndoView(context);
|
||||
sizeNotifierFrameLayout.addView(undoView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8));
|
||||
|
||||
nameTextView.setText(currentChat.title);
|
||||
nameTextView.setSelection(nameTextView.length());
|
||||
if (info != null) {
|
||||
|
@ -1007,6 +1028,10 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
|
|||
return nameTextView.getText().toString();
|
||||
}
|
||||
|
||||
public void showConvertTooltip() {
|
||||
undoView.showWithAction(0, UndoView.ACTION_GIGAGROUP_SUCCESS, null);
|
||||
}
|
||||
|
||||
private boolean checkDiscard() {
|
||||
String about = info != null && info.about != null ? info.about : "";
|
||||
if (info != null && ChatObject.isChannel(currentChat) && info.hidden_prehistory != historyHidden ||
|
||||
|
@ -1217,7 +1242,7 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
|
|||
}
|
||||
|
||||
if (logCell != null) {
|
||||
logCell.setVisibility(!currentChat.megagroup || info != null && info.participants_count > 200 ? View.VISIBLE : View.GONE);
|
||||
logCell.setVisibility(!currentChat.megagroup || currentChat.gigagroup || info != null && info.participants_count > 200 ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
if (linkedCell != null) {
|
||||
|
@ -1288,7 +1313,7 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
|
|||
}
|
||||
}
|
||||
|
||||
if (info != null && historyCell != null) {
|
||||
if (historyCell != null) {
|
||||
String type = historyHidden ? LocaleController.getString("ChatHistoryHidden", R.string.ChatHistoryHidden) : LocaleController.getString("ChatHistoryVisible", R.string.ChatHistoryVisible);
|
||||
historyCell.setTextAndValue(LocaleController.getString("ChatHistory", R.string.ChatHistory), type, false);
|
||||
}
|
||||
|
@ -1312,36 +1337,40 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
|
|||
} else {
|
||||
membersCell.setTextAndValueAndIcon(LocaleController.getString("ChannelMembers", R.string.ChannelMembers), String.format("%d", info.participants.participants.size()), R.drawable.actions_viewmembers, logCell != null && logCell.getVisibility() == View.VISIBLE);
|
||||
}
|
||||
int count = 0;
|
||||
if (currentChat.default_banned_rights != null) {
|
||||
if (!currentChat.default_banned_rights.send_stickers) {
|
||||
count++;
|
||||
}
|
||||
if (!currentChat.default_banned_rights.send_media) {
|
||||
count++;
|
||||
}
|
||||
if (!currentChat.default_banned_rights.embed_links) {
|
||||
count++;
|
||||
}
|
||||
if (!currentChat.default_banned_rights.send_messages) {
|
||||
count++;
|
||||
}
|
||||
if (!currentChat.default_banned_rights.pin_messages) {
|
||||
count++;
|
||||
}
|
||||
if (!currentChat.default_banned_rights.send_polls) {
|
||||
count++;
|
||||
}
|
||||
if (!currentChat.default_banned_rights.invite_users) {
|
||||
count++;
|
||||
}
|
||||
if (!currentChat.default_banned_rights.change_info) {
|
||||
count++;
|
||||
}
|
||||
if (currentChat.gigagroup) {
|
||||
blockCell.setTextAndValueAndIcon(LocaleController.getString("ChannelBlacklist", R.string.ChannelBlacklist), String.format("%d", Math.max(info.banned_count, info.kicked_count)), R.drawable.actions_removed, logCell != null && logCell.getVisibility() == View.VISIBLE);
|
||||
} else {
|
||||
count = 8;
|
||||
int count = 0;
|
||||
if (currentChat.default_banned_rights != null) {
|
||||
if (!currentChat.default_banned_rights.send_stickers) {
|
||||
count++;
|
||||
}
|
||||
if (!currentChat.default_banned_rights.send_media) {
|
||||
count++;
|
||||
}
|
||||
if (!currentChat.default_banned_rights.embed_links) {
|
||||
count++;
|
||||
}
|
||||
if (!currentChat.default_banned_rights.send_messages) {
|
||||
count++;
|
||||
}
|
||||
if (!currentChat.default_banned_rights.pin_messages) {
|
||||
count++;
|
||||
}
|
||||
if (!currentChat.default_banned_rights.send_polls) {
|
||||
count++;
|
||||
}
|
||||
if (!currentChat.default_banned_rights.invite_users) {
|
||||
count++;
|
||||
}
|
||||
if (!currentChat.default_banned_rights.change_info) {
|
||||
count++;
|
||||
}
|
||||
} else {
|
||||
count = 8;
|
||||
}
|
||||
blockCell.setTextAndValueAndIcon(LocaleController.getString("ChannelPermissions", R.string.ChannelPermissions), String.format("%d/%d", count, 8), R.drawable.actions_permissions, true);
|
||||
}
|
||||
blockCell.setTextAndValueAndIcon(LocaleController.getString("ChannelPermissions", R.string.ChannelPermissions), String.format("%d/%d", count, 8), R.drawable.actions_permissions, true);
|
||||
}
|
||||
adminCell.setTextAndValueAndIcon(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), String.format("%d", ChatObject.isChannel(currentChat) ? info.admins_count : getAdminCount()), R.drawable.actions_addadmin, true);
|
||||
} else {
|
||||
|
@ -1350,15 +1379,23 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
|
|||
blockCell.setTextAndIcon(LocaleController.getString("ChannelBlacklist", R.string.ChannelBlacklist), R.drawable.actions_removed, logCell != null && logCell.getVisibility() == View.VISIBLE);
|
||||
} else {
|
||||
membersCell.setTextAndIcon(LocaleController.getString("ChannelMembers", R.string.ChannelMembers), R.drawable.actions_viewmembers, logCell != null && logCell.getVisibility() == View.VISIBLE);
|
||||
blockCell.setTextAndIcon(LocaleController.getString("ChannelPermissions", R.string.ChannelPermissions), R.drawable.actions_permissions, true);
|
||||
if (currentChat.gigagroup) {
|
||||
blockCell.setTextAndIcon(LocaleController.getString("ChannelBlacklist", R.string.ChannelBlacklist), R.drawable.actions_removed, logCell != null && logCell.getVisibility() == View.VISIBLE);
|
||||
} else {
|
||||
blockCell.setTextAndIcon(LocaleController.getString("ChannelPermissions", R.string.ChannelPermissions), R.drawable.actions_permissions, true);
|
||||
}
|
||||
}
|
||||
adminCell.setTextAndIcon(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), R.drawable.actions_addadmin, true);
|
||||
}
|
||||
// if (info != null && info.invitesCount >= 0) {
|
||||
// inviteLinksCell.setTextAndValueAndIcon(LocaleController.getString("InviteLinks", R.string.InviteLinks), Integer.toString(info.invitesCount), R.drawable.actions_link, true);
|
||||
// } else {
|
||||
// inviteLinksCell.setTextAndIcon(LocaleController.getString("InviteLinks", R.string.InviteLinks), R.drawable.actions_link, true);
|
||||
// }
|
||||
if (info == null || !ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_INVITE) || (!isPrivate && currentChat.creator)) {
|
||||
inviteLinksCell.setVisibility(View.GONE);
|
||||
} else {
|
||||
if (info.invitesCount > 0) {
|
||||
inviteLinksCell.setTextAndValueAndIcon(LocaleController.getString("InviteLinks", R.string.InviteLinks), Integer.toString(info.invitesCount), R.drawable.actions_link, true);
|
||||
} else {
|
||||
inviteLinksCell.setTextAndValueAndIcon(LocaleController.getString("InviteLinks", R.string.InviteLinks), "1", R.drawable.actions_link, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (stickersCell != null && info != null) {
|
||||
|
@ -1396,9 +1433,9 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
|
|||
themeDescriptions.add(new ThemeDescription(adminCell, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector));
|
||||
themeDescriptions.add(new ThemeDescription(adminCell, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{TextCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
||||
themeDescriptions.add(new ThemeDescription(adminCell, 0, new Class[]{TextCell.class}, new String[]{"imageView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayIcon));
|
||||
// themeDescriptions.add(new ThemeDescription(inviteLinksCell, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector));
|
||||
// themeDescriptions.add(new ThemeDescription(inviteLinksCell, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{TextCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
||||
// themeDescriptions.add(new ThemeDescription(inviteLinksCell, 0, new Class[]{TextCell.class}, new String[]{"imageView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayIcon));
|
||||
themeDescriptions.add(new ThemeDescription(inviteLinksCell, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector));
|
||||
themeDescriptions.add(new ThemeDescription(inviteLinksCell, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{TextCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
||||
themeDescriptions.add(new ThemeDescription(inviteLinksCell, 0, new Class[]{TextCell.class}, new String[]{"imageView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayIcon));
|
||||
|
||||
themeDescriptions.add(new ThemeDescription(blockCell, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector));
|
||||
themeDescriptions.add(new ThemeDescription(blockCell, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{TextCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
||||
|
@ -1458,6 +1495,14 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
|
|||
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundBlue));
|
||||
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundPink));
|
||||
|
||||
themeDescriptions.add(new ThemeDescription(undoView, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_undo_background));
|
||||
themeDescriptions.add(new ThemeDescription(undoView, 0, new Class[]{UndoView.class}, new String[]{"undoImageView"}, null, null, null, Theme.key_undo_cancelColor));
|
||||
themeDescriptions.add(new ThemeDescription(undoView, 0, new Class[]{UndoView.class}, new String[]{"undoTextView"}, null, null, null, Theme.key_undo_cancelColor));
|
||||
themeDescriptions.add(new ThemeDescription(undoView, 0, new Class[]{UndoView.class}, new String[]{"infoTextView"}, null, null, null, Theme.key_undo_infoColor));
|
||||
themeDescriptions.add(new ThemeDescription(undoView, 0, new Class[]{UndoView.class}, new String[]{"textPaint"}, null, null, null, Theme.key_undo_infoColor));
|
||||
themeDescriptions.add(new ThemeDescription(undoView, 0, new Class[]{UndoView.class}, new String[]{"progressPaint"}, null, null, null, Theme.key_undo_infoColor));
|
||||
themeDescriptions.add(new ThemeDescription(undoView, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{UndoView.class}, new String[]{"leftImageView"}, null, null, null, Theme.key_undo_infoColor));
|
||||
|
||||
return themeDescriptions;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,8 +72,8 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
|
|||
private LinearLayout publicContainer;
|
||||
private LinearLayout privateContainer;
|
||||
private LinkActionView permanentLinkView;
|
||||
// private TextCell manageLinksTextView;
|
||||
// private TextInfoPrivacyCell manageLinksInfoCell;
|
||||
private TextCell manageLinksTextView;
|
||||
private TextInfoPrivacyCell manageLinksInfoCell;
|
||||
private ShadowSectionCell sectionCell2;
|
||||
private TextInfoPrivacyCell infoCell;
|
||||
private TextSettingsCell textCell;
|
||||
|
@ -348,7 +348,7 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
|
|||
privateContainer.setOrientation(LinearLayout.VERTICAL);
|
||||
linkContainer.addView(privateContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
|
||||
permanentLinkView = new LinkActionView(context, this, null, chatId, true);
|
||||
permanentLinkView = new LinkActionView(context, this, null, chatId, true, ChatObject.isChannel(currentChat));
|
||||
permanentLinkView.setDelegate(new LinkActionView.Delegate() {
|
||||
@Override
|
||||
public void revokeLink() {
|
||||
|
@ -357,7 +357,7 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
|
|||
|
||||
@Override
|
||||
public void showUsersForPermanentLink() {
|
||||
inviteLinkBottomSheet = new InviteLinkBottomSheet(context, invite, info, usersMap, ChatEditTypeActivity.this, chatId, true);
|
||||
inviteLinkBottomSheet = new InviteLinkBottomSheet(context, invite, info, usersMap, ChatEditTypeActivity.this, chatId, true, ChatObject.isChannel(currentChat));
|
||||
inviteLinkBottomSheet.show();
|
||||
}
|
||||
});
|
||||
|
@ -384,23 +384,23 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
|
|||
linearLayout.addView(adminedInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
|
||||
|
||||
// manageLinksTextView = new TextCell(context);
|
||||
// manageLinksTextView.setBackgroundDrawable(Theme.getSelectorDrawable(true));
|
||||
// manageLinksTextView.setOnClickListener(v -> {
|
||||
// if (invite == null) {
|
||||
// return;
|
||||
// }
|
||||
// });
|
||||
// manageLinksTextView.setTextAndIcon(LocaleController.getString("ManageInviteLinks", R.string.ManageInviteLinks), R.drawable.actions_link, false);
|
||||
// manageLinksTextView.setOnClickListener(v -> {
|
||||
// ManageLinksActivity fragment = new ManageLinksActivity(chatId);
|
||||
// fragment.setInfo(info, invite);
|
||||
// presentFragment(fragment);
|
||||
// });
|
||||
// linearLayout.addView(manageLinksTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
//
|
||||
// manageLinksInfoCell = new TextInfoPrivacyCell(context);
|
||||
// linearLayout.addView(manageLinksInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
manageLinksTextView = new TextCell(context);
|
||||
manageLinksTextView.setBackgroundDrawable(Theme.getSelectorDrawable(true));
|
||||
manageLinksTextView.setOnClickListener(v -> {
|
||||
if (invite == null) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
manageLinksTextView.setTextAndIcon(LocaleController.getString("ManageInviteLinks", R.string.ManageInviteLinks), R.drawable.actions_link, false);
|
||||
manageLinksTextView.setOnClickListener(v -> {
|
||||
ManageLinksActivity fragment = new ManageLinksActivity(chatId, 0, 0);
|
||||
fragment.setInfo(info, invite);
|
||||
presentFragment(fragment);
|
||||
});
|
||||
linearLayout.addView(manageLinksTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
|
||||
manageLinksInfoCell = new TextInfoPrivacyCell(context);
|
||||
linearLayout.addView(manageLinksInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
|
||||
if (!isPrivate && currentChat.username != null) {
|
||||
ignoreTextChanges = true;
|
||||
|
@ -580,16 +580,16 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
|
|||
}
|
||||
publicContainer.setVisibility(isPrivate ? View.GONE : View.VISIBLE);
|
||||
privateContainer.setVisibility(isPrivate ? View.VISIBLE : View.GONE);
|
||||
//manageLinksTextView.setVisibility(isPrivate ? View.VISIBLE : View.GONE);
|
||||
// manageLinksInfoCell.setVisibility(isPrivate ? View.VISIBLE : View.GONE);
|
||||
manageLinksTextView.setVisibility(View.VISIBLE);
|
||||
manageLinksInfoCell.setVisibility(View.VISIBLE);
|
||||
linkContainer.setPadding(0, 0, 0, isPrivate ? 0 : AndroidUtilities.dp(7));
|
||||
permanentLinkView.setLink(invite != null ? invite.link : null);
|
||||
permanentLinkView.loadUsers(invite, chatId);
|
||||
checkTextView.setVisibility(!isPrivate && checkTextView.length() != 0 ? View.VISIBLE : View.GONE);
|
||||
if (isPrivate) {
|
||||
typeInfoCell.setBackgroundDrawable(Theme.getThemedDrawable(typeInfoCell.getContext(), R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
|
||||
// manageLinksInfoCell.setBackground(Theme.getThemedDrawable(typeInfoCell.getContext(), R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
|
||||
// manageLinksInfoCell.setText(LocaleController.getString("ManageLinksInfoHelp", R.string.ManageLinksInfoHelp));
|
||||
manageLinksInfoCell.setBackground(Theme.getThemedDrawable(typeInfoCell.getContext(), R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
|
||||
manageLinksInfoCell.setText(LocaleController.getString("ManageLinksInfoHelp", R.string.ManageLinksInfoHelp));
|
||||
} else {
|
||||
typeInfoCell.setBackgroundDrawable(checkTextView.getVisibility() == View.VISIBLE ? null : Theme.getThemedDrawable(typeInfoCell.getContext(), R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
|
||||
}
|
||||
|
@ -688,7 +688,7 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
|
|||
private void generateLink(final boolean newRequest) {
|
||||
loadingInvite = true;
|
||||
TLRPC.TL_messages_exportChatInvite req = new TLRPC.TL_messages_exportChatInvite();
|
||||
//req.legacy_revoke_permanent = true; TODO layer 124
|
||||
req.legacy_revoke_permanent = true;
|
||||
req.peer = getMessagesController().getInputPeer(-chatId);
|
||||
final int reqId = getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
if (error == null) {
|
||||
|
@ -731,7 +731,7 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
|
|||
}
|
||||
|
||||
permanentLinkView.updateColors();
|
||||
// manageLinksTextView.setBackgroundDrawable(Theme.getSelectorDrawable(true));
|
||||
manageLinksTextView.setBackgroundDrawable(Theme.getSelectorDrawable(true));
|
||||
if (inviteLinkBottomSheet != null) {
|
||||
inviteLinkBottomSheet.updateColors();
|
||||
}
|
||||
|
@ -772,9 +772,9 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
|
|||
themeDescriptions.add(new ThemeDescription(typeInfoCell, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText4));
|
||||
themeDescriptions.add(new ThemeDescription(typeInfoCell, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteRedText4));
|
||||
|
||||
// themeDescriptions.add(new ThemeDescription(manageLinksInfoCell, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{TextInfoPrivacyCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow));
|
||||
// themeDescriptions.add(new ThemeDescription(manageLinksInfoCell, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText4));
|
||||
// themeDescriptions.add(new ThemeDescription(manageLinksInfoCell, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteRedText4));
|
||||
themeDescriptions.add(new ThemeDescription(manageLinksInfoCell, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{TextInfoPrivacyCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow));
|
||||
themeDescriptions.add(new ThemeDescription(manageLinksInfoCell, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText4));
|
||||
themeDescriptions.add(new ThemeDescription(manageLinksInfoCell, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteRedText4));
|
||||
|
||||
themeDescriptions.add(new ThemeDescription(adminedInfoCell, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{TextInfoPrivacyCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow));
|
||||
themeDescriptions.add(new ThemeDescription(adminnedChannelsLayout, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite));
|
||||
|
@ -803,9 +803,9 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
|
|||
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundBlue));
|
||||
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundPink));
|
||||
|
||||
// themeDescriptions.add(new ThemeDescription(manageLinksTextView, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector));
|
||||
// themeDescriptions.add(new ThemeDescription(manageLinksTextView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{TextCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
||||
// themeDescriptions.add(new ThemeDescription(manageLinksTextView, 0, new Class[]{TextCell.class}, new String[]{"imageView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayIcon));
|
||||
themeDescriptions.add(new ThemeDescription(manageLinksTextView, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector));
|
||||
themeDescriptions.add(new ThemeDescription(manageLinksTextView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{TextCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
||||
themeDescriptions.add(new ThemeDescription(manageLinksTextView, 0, new Class[]{TextCell.class}, new String[]{"imageView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayIcon));
|
||||
|
||||
|
||||
return themeDescriptions;
|
||||
|
|
|
@ -912,12 +912,20 @@ public class ChatRightsEditActivity extends BaseFragment {
|
|||
} else {
|
||||
adminRights.post_messages = adminRights.edit_messages = false;
|
||||
}
|
||||
if (!adminRights.change_info && !adminRights.post_messages && !adminRights.edit_messages &&
|
||||
!adminRights.delete_messages && !adminRights.ban_users && !adminRights.invite_users &&
|
||||
!adminRights.pin_messages && !adminRights.add_admins && !adminRights.anonymous && !adminRights.manage_call) {
|
||||
adminRights.other = true;
|
||||
} else {
|
||||
adminRights.other = false;
|
||||
}
|
||||
MessagesController.getInstance(currentAccount).setUserAdminRole(chatId, currentUser, adminRights, currentRank, isChannel, getFragmentForAlert(1), isAddingNew);
|
||||
if (delegate != null) {
|
||||
delegate.didSetRights(
|
||||
adminRights.change_info || adminRights.post_messages || adminRights.edit_messages ||
|
||||
adminRights.delete_messages || adminRights.ban_users || adminRights.invite_users ||
|
||||
adminRights.pin_messages || adminRights.add_admins || adminRights.anonymous || adminRights.manage_call ? 1 : 0, adminRights, bannedRights, currentRank);
|
||||
adminRights.pin_messages || adminRights.add_admins || adminRights.anonymous || adminRights.manage_call ||
|
||||
adminRights.other ? 1 : 0, adminRights, bannedRights, currentRank);
|
||||
}
|
||||
} else if (currentType == TYPE_BANNED) {
|
||||
MessagesController.getInstance(currentAccount).setUserBannedRole(chatId, currentUser, bannedRights, isChannel, getFragmentForAlert(1));
|
||||
|
|
|
@ -37,7 +37,6 @@ import android.widget.FrameLayout;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator;
|
||||
import androidx.recyclerview.widget.DiffUtil;
|
||||
|
@ -74,6 +73,7 @@ import org.telegram.ui.Cells.TextInfoPrivacyCell;
|
|||
import org.telegram.ui.Cells.TextSettingsCell;
|
||||
import org.telegram.ui.Components.BulletinFactory;
|
||||
import org.telegram.ui.Components.FlickerLoadingView;
|
||||
import org.telegram.ui.Components.GigagroupConvertAlert;
|
||||
import org.telegram.ui.Components.IntSeekBarAccessibilityDelegate;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.RadialProgressView;
|
||||
|
@ -127,6 +127,10 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
private int addUsersRow;
|
||||
private int pinMessagesRow;
|
||||
|
||||
private int gigaHeaderRow;
|
||||
private int gigaConvertRow;
|
||||
private int gigaInfoRow;
|
||||
|
||||
private int recentActionsRow;
|
||||
private int addNewRow;
|
||||
private int addNew2Row;
|
||||
|
@ -440,6 +444,9 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
participantsStartRow = -1;
|
||||
participantsDividerRow = -1;
|
||||
participantsDivider2Row = -1;
|
||||
gigaInfoRow = -1;
|
||||
gigaConvertRow = -1;
|
||||
gigaHeaderRow = -1;
|
||||
participantsEndRow = -1;
|
||||
participantsInfoRow = -1;
|
||||
blockedEmptyRow = -1;
|
||||
|
@ -478,8 +485,21 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
addUsersRow = rowCount++;
|
||||
pinMessagesRow = rowCount++;
|
||||
changeInfoRow = rowCount++;
|
||||
if (!ChatObject.isChannel(currentChat) && currentChat.creator || currentChat.megagroup && ChatObject.canBlockUsers(currentChat)) {
|
||||
participantsDivider2Row = rowCount++;
|
||||
|
||||
if (ChatObject.isChannel(currentChat) && currentChat.creator && currentChat.megagroup && !currentChat.gigagroup) {
|
||||
int count = Math.max(currentChat.participants_count, info != null ? info.participants_count : 0);
|
||||
if (count >= getMessagesController().maxMegagroupCount - 1000) {
|
||||
participantsDivider2Row = rowCount++;
|
||||
gigaHeaderRow = rowCount++;
|
||||
gigaConvertRow = rowCount++;
|
||||
gigaInfoRow = rowCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ChatObject.isChannel(currentChat) && currentChat.creator || currentChat.megagroup && !currentChat.gigagroup && ChatObject.canBlockUsers(currentChat)) {
|
||||
if (participantsDivider2Row == -1) {
|
||||
participantsDivider2Row = rowCount++;
|
||||
}
|
||||
slowmodeRow = rowCount++;
|
||||
slowmodeSelectRow = rowCount++;
|
||||
slowmodeInfoRow = rowCount++;
|
||||
|
@ -490,14 +510,20 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
}
|
||||
removedUsersRow = rowCount++;
|
||||
}
|
||||
if (slowmodeInfoRow == -1 || removedUsersRow != -1) {
|
||||
if (slowmodeInfoRow == -1 && gigaHeaderRow == -1 || removedUsersRow != -1) {
|
||||
participantsDividerRow = rowCount++;
|
||||
}
|
||||
if (ChatObject.canBlockUsers(currentChat)) {
|
||||
addNewRow = rowCount++;
|
||||
}
|
||||
|
||||
if (!(loadingUsers && !firstLoaded)) {
|
||||
if (loadingUsers && !firstLoaded) {
|
||||
if (!firstLoaded) {
|
||||
if (info != null && info.banned_count > 0) {
|
||||
loadingUserCellRow = rowCount++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!participants.isEmpty()) {
|
||||
participantsStartRow = rowCount;
|
||||
rowCount += participants.size();
|
||||
|
@ -506,10 +532,6 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
if (addNewRow != -1 || participantsStartRow != -1) {
|
||||
addNewSectionRow = rowCount++;
|
||||
}
|
||||
} else if (!firstLoaded) {
|
||||
if (info != null && info.banned_count > 0) {
|
||||
loadingUserCellRow = rowCount++;
|
||||
}
|
||||
}
|
||||
} else if (type == TYPE_BANNED) {
|
||||
if (ChatObject.canBlockUsers(currentChat)) {
|
||||
|
@ -532,7 +554,7 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
addNewSectionRow = rowCount++;
|
||||
}
|
||||
} else {
|
||||
restricted1SectionRow = rowCount++;
|
||||
//restricted1SectionRow = rowCount++;
|
||||
blockedEmptyRow = rowCount++;
|
||||
}
|
||||
} else if (!firstLoaded) {
|
||||
|
@ -540,7 +562,7 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
loadingUserCellRow = rowCount++;
|
||||
}
|
||||
} else if (type == TYPE_ADMIN) {
|
||||
if (ChatObject.isChannel(currentChat) && currentChat.megagroup && (info == null || info.participants_count <= 200)) {
|
||||
if (ChatObject.isChannel(currentChat) && currentChat.megagroup && !currentChat.gigagroup && (info == null || info.participants_count <= 200)) {
|
||||
recentActionsRow = rowCount++;
|
||||
addNewSectionRow = rowCount++;
|
||||
}
|
||||
|
@ -753,7 +775,7 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
listView.setLayoutManager(layoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) {
|
||||
@Override
|
||||
public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) {
|
||||
if (!firstLoaded && type != TYPE_KICKED) {
|
||||
if (!firstLoaded && type == TYPE_BANNED && participants.size() == 0) {
|
||||
return 0;
|
||||
}
|
||||
return super.scrollVerticallyBy(dy, recycler, state);
|
||||
|
@ -785,6 +807,26 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
public long getAddDuration() {
|
||||
return 220;
|
||||
}
|
||||
|
||||
int animationIndex = -1;
|
||||
|
||||
@Override
|
||||
protected void onAllAnimationsDone() {
|
||||
super.onAllAnimationsDone();
|
||||
getNotificationCenter().onAnimationFinish(animationIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runPendingAnimations() {
|
||||
boolean removalsPending = !mPendingRemovals.isEmpty();
|
||||
boolean movesPending = !mPendingMoves.isEmpty();
|
||||
boolean changesPending = !mPendingChanges.isEmpty();
|
||||
boolean additionsPending = !mPendingAdditions.isEmpty();
|
||||
if (removalsPending || movesPending || additionsPending || changesPending) {
|
||||
animationIndex = getNotificationCenter().setAnimationInProgress(animationIndex, null);
|
||||
}
|
||||
super.runPendingAnimations();
|
||||
}
|
||||
};
|
||||
listView.setItemAnimator(itemAnimator);
|
||||
itemAnimator.setSupportsChangeAnimations(false);
|
||||
|
@ -949,6 +991,35 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
fragment.setInfo(info);
|
||||
presentFragment(fragment);
|
||||
return;
|
||||
} else if (position == gigaConvertRow) {
|
||||
showDialog(new GigagroupConvertAlert(getParentActivity(), ChatUsersActivity.this) {
|
||||
@Override
|
||||
protected void onCovert() {
|
||||
getMessagesController().convertToGigaGroup(getParentActivity(), currentChat, ChatUsersActivity.this, (result) -> {
|
||||
if (result && parentLayout != null) {
|
||||
BaseFragment editActivity = parentLayout.fragmentsStack.get(parentLayout.fragmentsStack.size() - 2);
|
||||
if (editActivity instanceof ChatEditActivity) {
|
||||
editActivity.removeSelfFromStack();
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("chat_id", chatId);
|
||||
ChatEditActivity fragment = new ChatEditActivity(args);
|
||||
fragment.setInfo(info);
|
||||
parentLayout.addFragmentToStack(fragment, parentLayout.fragmentsStack.size() - 1);
|
||||
finishFragment();
|
||||
fragment.showConvertTooltip();
|
||||
} else {
|
||||
finishFragment();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCancel() {
|
||||
|
||||
}
|
||||
});
|
||||
} else if (position == addNew2Row) {
|
||||
presentFragment(new GroupInviteActivity(chatId));
|
||||
return;
|
||||
|
@ -959,9 +1030,9 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
}
|
||||
if (checkCell.hasIcon()) {
|
||||
if (!TextUtils.isEmpty(currentChat.username) && (position == pinMessagesRow || position == changeInfoRow)) {
|
||||
Toast.makeText(getParentActivity(), LocaleController.getString("EditCantEditPermissionsPublic", R.string.EditCantEditPermissionsPublic), Toast.LENGTH_SHORT).show();
|
||||
BulletinFactory.of(this).createErrorBulletin(LocaleController.getString("EditCantEditPermissionsPublic", R.string.EditCantEditPermissionsPublic)).show();
|
||||
} else {
|
||||
Toast.makeText(getParentActivity(), LocaleController.getString("EditCantEditPermissions", R.string.EditCantEditPermissions), Toast.LENGTH_SHORT).show();
|
||||
BulletinFactory.of(this).createErrorBulletin(LocaleController.getString("EditCantEditPermissions", R.string.EditCantEditPermissions)).show();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1682,7 +1753,7 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
getMessagesController().deleteUserFromChat(chatId, user, null);
|
||||
removeParticipants(userId);
|
||||
if (currentChat != null && user != null && BulletinFactory.canShowBulletin(this)) {
|
||||
BulletinFactory.createRemoveFromChatBulletin(this, user.first_name, currentChat.title).show();
|
||||
BulletinFactory.createRemoveFromChatBulletin(this, user, currentChat.title).show();
|
||||
}
|
||||
} else {
|
||||
if (actions.get(i) == 1 && canEditAdmin && (participant instanceof TLRPC.TL_channelParticipantAdmin || participant instanceof TLRPC.TL_chatParticipantAdmin)) {
|
||||
|
@ -3072,6 +3143,8 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
} else {
|
||||
privacyCell.setText(LocaleController.formatString("SlowmodeInfoSelected", R.string.SlowmodeInfoSelected, formatSeconds(seconds)));
|
||||
}
|
||||
} else if (position == gigaInfoRow) {
|
||||
privacyCell.setText(LocaleController.getString("BroadcastGroupConvertInfo", R.string.BroadcastGroupConvertInfo));
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
|
@ -3100,6 +3173,9 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
actionCell.setText(LocaleController.getString("EventLog", R.string.EventLog), null, R.drawable.group_log, false);
|
||||
} else if (position == addNew2Row) {
|
||||
actionCell.setText(LocaleController.getString("ChannelInviteViaLink", R.string.ChannelInviteViaLink), null, R.drawable.profile_link, true);
|
||||
} else if (position == gigaConvertRow) {
|
||||
actionCell.setColors(Theme.key_windowBackgroundWhiteBlueIcon, Theme.key_windowBackgroundWhiteBlueButton);
|
||||
actionCell.setText(LocaleController.getString("BroadcastGroupConvert", R.string.BroadcastGroupConvert), null, R.drawable.msg_channel, false);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
|
@ -3126,6 +3202,8 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
headerCell.setText(LocaleController.getString("ChannelPermissionsHeader", R.string.ChannelPermissionsHeader));
|
||||
} else if (position == slowmodeRow) {
|
||||
headerCell.setText(LocaleController.getString("Slowmode", R.string.Slowmode));
|
||||
} else if (position == gigaHeaderRow) {
|
||||
headerCell.setText(LocaleController.getString("BroadcastGroup", R.string.BroadcastGroup));
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
|
@ -3210,7 +3288,7 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (position == addNewRow || position == addNew2Row || position == recentActionsRow) {
|
||||
if (position == addNewRow || position == addNew2Row || position == recentActionsRow || position == gigaConvertRow) {
|
||||
return 2;
|
||||
} else if (position >= participantsStartRow && position < participantsEndRow ||
|
||||
position >= botStartRow && position < botEndRow ||
|
||||
|
@ -3218,9 +3296,9 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
return 0;
|
||||
} else if (position == addNewSectionRow || position == participantsDividerRow || position == participantsDivider2Row) {
|
||||
return 3;
|
||||
} else if (position == restricted1SectionRow || position == permissionsSectionRow || position == slowmodeRow) {
|
||||
} else if (position == restricted1SectionRow || position == permissionsSectionRow || position == slowmodeRow || position == gigaHeaderRow) {
|
||||
return 5;
|
||||
} else if (position == participantsInfoRow || position == slowmodeInfoRow) {
|
||||
} else if (position == participantsInfoRow || position == slowmodeInfoRow || position == gigaInfoRow) {
|
||||
return 1;
|
||||
} else if (position == blockedEmptyRow) {
|
||||
return 4;
|
||||
|
@ -3360,6 +3438,9 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
put(++pointer, restricted1SectionRow, sparseIntArray);
|
||||
put(++pointer, participantsDividerRow, sparseIntArray);
|
||||
put(++pointer, participantsDivider2Row, sparseIntArray);
|
||||
put(++pointer, gigaHeaderRow, sparseIntArray);
|
||||
put(++pointer, gigaConvertRow, sparseIntArray);
|
||||
put(++pointer, gigaInfoRow, sparseIntArray);
|
||||
put(++pointer, participantsInfoRow, sparseIntArray);
|
||||
put(++pointer, blockedEmptyRow, sparseIntArray);
|
||||
put(++pointer, permissionsSectionRow, sparseIntArray);
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
package org.telegram.ui;
|
||||
|
||||
import android.appwidget.AppWidgetManager;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
|
||||
public class ChatsWidgetConfigActivity extends ExternalActionActivity {
|
||||
|
||||
private int creatingAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
|
||||
|
||||
@Override
|
||||
protected boolean handleIntent(Intent intent, boolean isNew, boolean restore, boolean fromPassword, int intentAccount, int state) {
|
||||
if (!checkPasscode(intent, isNew, restore, fromPassword, intentAccount, state)) {
|
||||
return false;
|
||||
}
|
||||
Bundle extras = intent.getExtras();
|
||||
if (extras != null) {
|
||||
creatingAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
|
||||
}
|
||||
if (creatingAppWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) {
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean("onlySelect", true);
|
||||
args.putInt("dialogsType", 10);
|
||||
args.putBoolean("allowSwitchAccount", true);
|
||||
EditWidgetActivity fragment = new EditWidgetActivity(EditWidgetActivity.TYPE_CHATS, creatingAppWidgetId, false);
|
||||
fragment.setDelegate(dialogs -> {
|
||||
Intent resultValue = new Intent();
|
||||
resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, creatingAppWidgetId);
|
||||
setResult(RESULT_OK, resultValue);
|
||||
finish();
|
||||
});
|
||||
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
if (layersActionBarLayout.fragmentsStack.isEmpty()) {
|
||||
layersActionBarLayout.addFragmentToStack(fragment);
|
||||
}
|
||||
} else {
|
||||
if (actionBarLayout.fragmentsStack.isEmpty()) {
|
||||
actionBarLayout.addFragmentToStack(fragment);
|
||||
}
|
||||
}
|
||||
if (!AndroidUtilities.isTablet()) {
|
||||
backgroundTablet.setVisibility(View.GONE);
|
||||
}
|
||||
actionBarLayout.showLastFragment();
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
layersActionBarLayout.showLastFragment();
|
||||
}
|
||||
intent.setAction(null);
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -67,6 +67,7 @@ public class AdminLogFilterAlert extends BottomSheet {
|
|||
private int restrictionsRow;
|
||||
private int adminsRow;
|
||||
private int membersRow;
|
||||
private int invitesRow;
|
||||
private int infoRow;
|
||||
private int deleteRow;
|
||||
private int editRow;
|
||||
|
@ -94,6 +95,7 @@ public class AdminLogFilterAlert extends BottomSheet {
|
|||
currentFilter.edit = filter.edit;
|
||||
currentFilter.delete = filter.delete;
|
||||
currentFilter.group_call = filter.group_call;
|
||||
currentFilter.invites = filter.invites;
|
||||
}
|
||||
if (admins != null) {
|
||||
selectedAdmins = admins.clone();
|
||||
|
@ -108,6 +110,7 @@ public class AdminLogFilterAlert extends BottomSheet {
|
|||
}
|
||||
adminsRow = rowCount++;
|
||||
membersRow = rowCount++;
|
||||
invitesRow = rowCount++;
|
||||
infoRow = rowCount++;
|
||||
deleteRow = rowCount++;
|
||||
editRow = rowCount++;
|
||||
|
@ -117,8 +120,12 @@ public class AdminLogFilterAlert extends BottomSheet {
|
|||
pinnedRow = -1;
|
||||
}
|
||||
leavingRow = rowCount++;
|
||||
callsRow = rowCount;
|
||||
rowCount += 2;
|
||||
if (isMegagroup) {
|
||||
callsRow = rowCount++;
|
||||
} else {
|
||||
callsRow = -1;
|
||||
}
|
||||
rowCount += 1;
|
||||
allAdminsRow = rowCount;
|
||||
|
||||
shadowDrawable = context.getResources().getDrawable(R.drawable.sheet_shadow_round).mutate();
|
||||
|
@ -147,7 +154,7 @@ public class AdminLogFilterAlert extends BottomSheet {
|
|||
height -= AndroidUtilities.statusBarHeight;
|
||||
}
|
||||
int measuredWidth = getMeasuredWidth();
|
||||
int contentSize = AndroidUtilities.dp(48) + (isMegagroup ? 10 : 7) * AndroidUtilities.dp(48) + backgroundPaddingTop;
|
||||
int contentSize = AndroidUtilities.dp(48) + (isMegagroup ? 11 : 7) * AndroidUtilities.dp(48) + backgroundPaddingTop + AndroidUtilities.dp(17);
|
||||
if (currentAdmins != null) {
|
||||
contentSize += (currentAdmins.size() + 1) * AndroidUtilities.dp(48) + AndroidUtilities.dp(20);
|
||||
}
|
||||
|
@ -228,7 +235,7 @@ public class AdminLogFilterAlert extends BottomSheet {
|
|||
currentFilter.join = currentFilter.leave = currentFilter.invite = currentFilter.ban =
|
||||
currentFilter.unban = currentFilter.kick = currentFilter.unkick = currentFilter.promote =
|
||||
currentFilter.demote = currentFilter.info = currentFilter.settings = currentFilter.pinned =
|
||||
currentFilter.edit = currentFilter.delete = currentFilter.group_call = false;
|
||||
currentFilter.edit = currentFilter.delete = currentFilter.group_call = currentFilter.invites = false;
|
||||
} else {
|
||||
currentFilter = null;
|
||||
}
|
||||
|
@ -263,7 +270,7 @@ public class AdminLogFilterAlert extends BottomSheet {
|
|||
currentFilter.join = currentFilter.leave = currentFilter.invite = currentFilter.ban =
|
||||
currentFilter.unban = currentFilter.kick = currentFilter.unkick = currentFilter.promote =
|
||||
currentFilter.demote = currentFilter.info = currentFilter.settings = currentFilter.pinned =
|
||||
currentFilter.edit = currentFilter.delete = currentFilter.group_call = true;
|
||||
currentFilter.edit = currentFilter.delete = currentFilter.group_call = currentFilter.invites = true;
|
||||
RecyclerView.ViewHolder holder = listView.findViewHolderForAdapterPosition(0);
|
||||
if (holder != null) {
|
||||
((CheckBoxCell) holder.itemView).setChecked(false, true);
|
||||
|
@ -287,14 +294,15 @@ public class AdminLogFilterAlert extends BottomSheet {
|
|||
currentFilter.leave = !currentFilter.leave;
|
||||
} else if (position == callsRow) {
|
||||
currentFilter.group_call = !currentFilter.group_call;
|
||||
} else if (position == invitesRow) {
|
||||
currentFilter.invites = !currentFilter.invites;
|
||||
}
|
||||
}
|
||||
if (currentFilter != null && !currentFilter.join && !currentFilter.leave &&
|
||||
!currentFilter.leave && !currentFilter.invite && !currentFilter.ban &&
|
||||
!currentFilter.unban && !currentFilter.kick && !currentFilter.unkick &&
|
||||
!currentFilter.promote && !currentFilter.demote && !currentFilter.info &&
|
||||
!currentFilter.settings && !currentFilter.pinned && !currentFilter.edit &&
|
||||
!currentFilter.delete && !currentFilter.group_call) {
|
||||
if (currentFilter != null &&
|
||||
!currentFilter.join && !currentFilter.leave && !currentFilter.invite && !currentFilter.ban &&
|
||||
!currentFilter.invites && !currentFilter.unban && !currentFilter.kick && !currentFilter.unkick &&
|
||||
!currentFilter.promote && !currentFilter.demote && !currentFilter.info && !currentFilter.settings &&
|
||||
!currentFilter.pinned && !currentFilter.edit && !currentFilter.delete && !currentFilter.group_call) {
|
||||
saveButton.setEnabled(false);
|
||||
saveButton.setAlpha(0.5f);
|
||||
} else {
|
||||
|
@ -386,7 +394,7 @@ public class AdminLogFilterAlert extends BottomSheet {
|
|||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return (isMegagroup ? 10 : 7) + (currentAdmins != null ? 2 + currentAdmins.size() : 0);
|
||||
return (isMegagroup ? 11 : 7) + (currentAdmins != null ? 2 + currentAdmins.size() : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -452,6 +460,8 @@ public class AdminLogFilterAlert extends BottomSheet {
|
|||
cell.setChecked(currentFilter == null || currentFilter.leave, false);
|
||||
} else if (position == callsRow) {
|
||||
cell.setChecked(currentFilter == null || currentFilter.group_call, false);
|
||||
} else if (position == invitesRow) {
|
||||
cell.setChecked(currentFilter == null || currentFilter.invites, false);
|
||||
} else if (position == allAdminsRow) {
|
||||
cell.setChecked(selectedAdmins == null, false);
|
||||
}
|
||||
|
@ -492,9 +502,11 @@ public class AdminLogFilterAlert extends BottomSheet {
|
|||
} else if (position == pinnedRow) {
|
||||
cell.setText(LocaleController.getString("EventLogFilterPinnedMessages", R.string.EventLogFilterPinnedMessages), "", currentFilter == null || currentFilter.pinned, true);
|
||||
} else if (position == leavingRow) {
|
||||
cell.setText(LocaleController.getString("EventLogFilterLeavingMembers", R.string.EventLogFilterLeavingMembers), "", currentFilter == null || currentFilter.leave, true);
|
||||
cell.setText(LocaleController.getString("EventLogFilterLeavingMembers", R.string.EventLogFilterLeavingMembers), "", currentFilter == null || currentFilter.leave, callsRow != -1);
|
||||
} else if (position == callsRow) {
|
||||
cell.setText(LocaleController.getString("EventLogFilterCalls", R.string.EventLogFilterCalls), "", currentFilter == null || currentFilter.group_call, false);
|
||||
} else if (position == invitesRow) {
|
||||
cell.setText(LocaleController.getString("EventLogFilterInvites", R.string.EventLogFilterInvites), "", currentFilter == null || currentFilter.invites, true);
|
||||
} else if (position == allAdminsRow) {
|
||||
cell.setText(LocaleController.getString("EventLogAllAdmins", R.string.EventLogAllAdmins), "", selectedAdmins == null, true);
|
||||
}
|
||||
|
|
|
@ -92,7 +92,6 @@ import org.telegram.ui.LaunchActivity;
|
|||
import org.telegram.ui.NotificationsCustomSettingsActivity;
|
||||
import org.telegram.ui.NotificationsSettingsActivity;
|
||||
import org.telegram.ui.ProfileNotificationsActivity;
|
||||
import org.telegram.ui.ReportOtherActivity;
|
||||
import org.telegram.ui.ThemePreviewActivity;
|
||||
import org.telegram.ui.TooManyCommunitiesActivity;
|
||||
|
||||
|
@ -113,7 +112,7 @@ public class AlertsCreator {
|
|||
if (error.code == 406 || error.text == null) {
|
||||
return null;
|
||||
}
|
||||
if (request instanceof TLRPC.TL_messages_initHistoryImport || request instanceof TLRPC.TL_messages_checkHistoryImport || request instanceof TLRPC.TL_messages_startHistoryImport) {
|
||||
if (request instanceof TLRPC.TL_messages_initHistoryImport || request instanceof TLRPC.TL_messages_checkHistoryImportPeer || request instanceof TLRPC.TL_messages_checkHistoryImport || request instanceof TLRPC.TL_messages_startHistoryImport) {
|
||||
TLRPC.InputPeer peer;
|
||||
if (request instanceof TLRPC.TL_messages_initHistoryImport) {
|
||||
peer = ((TLRPC.TL_messages_initHistoryImport) request).peer;
|
||||
|
@ -136,6 +135,8 @@ public class AlertsCreator {
|
|||
showSimpleAlert(fragment, LocaleController.getString("ImportErrorTitle", R.string.ImportErrorTitle), LocaleController.getString("ImportErrorNotAdmin", R.string.ImportErrorNotAdmin));
|
||||
} else if (error.text.startsWith("IMPORT_FORMAT")) {
|
||||
showSimpleAlert(fragment, LocaleController.getString("ImportErrorTitle", R.string.ImportErrorTitle), LocaleController.getString("ImportErrorFileFormatInvalid", R.string.ImportErrorFileFormatInvalid));
|
||||
} else if (error.text.startsWith("PEER_ID_INVALID")) {
|
||||
showSimpleAlert(fragment, LocaleController.getString("ImportErrorTitle", R.string.ImportErrorTitle), LocaleController.getString("ImportErrorPeerInvalid", R.string.ImportErrorPeerInvalid));
|
||||
} else if (error.text.contains("IMPORT_LANG_NOT_FOUND")) {
|
||||
showSimpleAlert(fragment, LocaleController.getString("ImportErrorTitle", R.string.ImportErrorTitle), LocaleController.getString("ImportErrorFileLang", R.string.ImportErrorFileLang));
|
||||
} else if (error.text.contains("IMPORT_UPLOAD_FAILED")) {
|
||||
|
@ -229,6 +230,8 @@ public class AlertsCreator {
|
|||
showSimpleAlert(fragment, LocaleController.getString("JoinToGroupErrorFull", R.string.JoinToGroupErrorFull));
|
||||
} else if (error.text.equals("CHANNELS_TOO_MUCH")) {
|
||||
fragment.presentFragment(new TooManyCommunitiesActivity(TooManyCommunitiesActivity.TYPE_JOIN));
|
||||
} else if (error.text.equals("INVITE_HASH_EXPIRED")) {
|
||||
showSimpleAlert(fragment, LocaleController.getString("ExpiredLink", R.string.ExpiredLink), LocaleController.getString("InviteExpired", R.string.InviteExpired));
|
||||
} else {
|
||||
showSimpleAlert(fragment, LocaleController.getString("JoinToGroupErrorNotExist", R.string.JoinToGroupErrorNotExist));
|
||||
}
|
||||
|
@ -575,7 +578,13 @@ public class AlertsCreator {
|
|||
if (cells[0].isChecked()) {
|
||||
request.report_spam = true;
|
||||
if (fragment.getParentActivity() != null) {
|
||||
Toast.makeText(fragment.getParentActivity(), LocaleController.getString("ReportChatSent", R.string.ReportChatSent), Toast.LENGTH_SHORT).show();
|
||||
if (fragment instanceof ChatActivity) {
|
||||
fragment.getUndoView().showWithAction(0, UndoView.ACTION_REPORT_SENT, null);
|
||||
} else if (fragment != null) {
|
||||
BulletinFactory.of(fragment).createReportSent().show();
|
||||
} else {
|
||||
Toast.makeText(fragment.getParentActivity(), LocaleController.getString("ReportChatSent", R.string.ReportChatSent), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
accountInstance.getConnectionsManager().sendRequest(request, (response, error) -> {
|
||||
|
@ -1076,7 +1085,7 @@ public class AlertsCreator {
|
|||
}
|
||||
}
|
||||
|
||||
public static void createImportDialogAlert(BaseFragment fragment, String title, TLRPC.User user, TLRPC.Chat chat, Runnable onProcessRunnable) {
|
||||
public static void createImportDialogAlert(BaseFragment fragment, String title, String message, TLRPC.User user, TLRPC.Chat chat, Runnable onProcessRunnable) {
|
||||
if (fragment == null || fragment.getParentActivity() == null || chat == null && user == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -1110,7 +1119,7 @@ public class AlertsCreator {
|
|||
textView.setSingleLine(true);
|
||||
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
|
||||
textView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
textView.setText(LocaleController.formatString("ImportMessages", R.string.ImportMessages));
|
||||
textView.setText(LocaleController.getString("ImportMessages", R.string.ImportMessages));
|
||||
|
||||
frameLayout.addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 21 : 76), 11, (LocaleController.isRTL ? 76 : 21), 0));
|
||||
frameLayout.addView(messageTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 24, 57, 24, 9));
|
||||
|
@ -1134,7 +1143,8 @@ public class AlertsCreator {
|
|||
imageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, chat);
|
||||
}
|
||||
|
||||
if (chat != null) {
|
||||
messageTextView.setText(AndroidUtilities.replaceTags(message));
|
||||
/*if (chat != null) {
|
||||
if (TextUtils.isEmpty(title)) {
|
||||
messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("ImportToChatNoTitle", R.string.ImportToChatNoTitle, chat.title)));
|
||||
} else {
|
||||
|
@ -1146,7 +1156,7 @@ public class AlertsCreator {
|
|||
} else {
|
||||
messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("ImportToUser", R.string.ImportToUser, title, ContactsController.formatName(user.first_name, user.last_name))));
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
builder.setPositiveButton(LocaleController.getString("Import", R.string.Import), (dialogInterface, i) -> {
|
||||
if (onProcessRunnable != null) {
|
||||
|
@ -1259,12 +1269,10 @@ public class AlertsCreator {
|
|||
final boolean[] deleteForAll = new boolean[1];
|
||||
boolean deleteChatForAll = false;
|
||||
|
||||
if (!second && (secret || canDeleteInbox) && !UserObject.isDeleted(user) || (deleteChatForAll = checkDeleteForAll && !clear && chat != null && chat.creator)) {
|
||||
if (!second && (secret && !clear || canDeleteInbox) && !UserObject.isDeleted(user) || (deleteChatForAll = checkDeleteForAll && !clear && chat != null && chat.creator)) {
|
||||
cell[0] = new CheckBoxCell(context, 1);
|
||||
cell[0].setBackgroundDrawable(Theme.getSelectorDrawable(false));
|
||||
if (secret) {
|
||||
cell[0].setText(LocaleController.formatString("DeleteForUser", R.string.DeleteForUser, UserObject.getFirstName(user)), "", false, false);
|
||||
} else if (deleteChatForAll) {
|
||||
if (deleteChatForAll) {
|
||||
if (ChatObject.isChannel(chat) && !chat.megagroup) {
|
||||
cell[0].setText(LocaleController.getString("DeleteChannelForAll", R.string.DeleteChannelForAll), "", false, false);
|
||||
} else {
|
||||
|
@ -2401,6 +2409,29 @@ public class AlertsCreator {
|
|||
return builder.create();
|
||||
}
|
||||
|
||||
public static void sendReport(TLRPC.InputPeer peer, int type, String message, ArrayList<Integer> messages) {
|
||||
TLRPC.TL_messages_report request = new TLRPC.TL_messages_report();
|
||||
request.peer = peer;
|
||||
request.id.addAll(messages);
|
||||
request.message = message;
|
||||
if (type == 0) {
|
||||
request.reason = new TLRPC.TL_inputReportReasonSpam();
|
||||
} else if (type == 1) {
|
||||
request.reason = new TLRPC.TL_inputReportReasonFake();
|
||||
} else if (type == 2) {
|
||||
request.reason = new TLRPC.TL_inputReportReasonViolence();
|
||||
} else if (type == 3) {
|
||||
request.reason = new TLRPC.TL_inputReportReasonChildAbuse();
|
||||
} else if (type == 4) {
|
||||
request.reason = new TLRPC.TL_inputReportReasonPornography();
|
||||
} else if (type == 5) {
|
||||
request.reason = new TLRPC.TL_inputReportReasonOther();
|
||||
}
|
||||
ConnectionsManager.getInstance(UserConfig.selectedAccount).sendRequest(request, (response, error) -> {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public static void createReportAlert(final Context context, final long dialog_id, final int messageId, final BaseFragment parentFragment) {
|
||||
if (context == null || parentFragment == null) {
|
||||
return;
|
||||
|
@ -2409,6 +2440,7 @@ public class AlertsCreator {
|
|||
BottomSheet.Builder builder = new BottomSheet.Builder(context);
|
||||
builder.setTitle(LocaleController.getString("ReportChat", R.string.ReportChat), true);
|
||||
CharSequence[] items;
|
||||
int[] icons;
|
||||
if (messageId != 0) {
|
||||
items = new CharSequence[]{
|
||||
LocaleController.getString("ReportChatSpam", R.string.ReportChatSpam),
|
||||
|
@ -2417,6 +2449,13 @@ public class AlertsCreator {
|
|||
LocaleController.getString("ReportChatPornography", R.string.ReportChatPornography),
|
||||
LocaleController.getString("ReportChatOther", R.string.ReportChatOther)
|
||||
};
|
||||
icons = new int[]{
|
||||
R.drawable.msg_report_spam,
|
||||
R.drawable.msg_report_violence,
|
||||
R.drawable.msg_report_abuse,
|
||||
R.drawable.msg_report_xxx,
|
||||
R.drawable.msg_report_other
|
||||
};
|
||||
} else {
|
||||
items = new CharSequence[]{
|
||||
LocaleController.getString("ReportChatSpam", R.string.ReportChatSpam),
|
||||
|
@ -2426,53 +2465,79 @@ public class AlertsCreator {
|
|||
LocaleController.getString("ReportChatPornography", R.string.ReportChatPornography),
|
||||
LocaleController.getString("ReportChatOther", R.string.ReportChatOther)
|
||||
};
|
||||
icons = new int[]{
|
||||
R.drawable.msg_report_spam,
|
||||
R.drawable.msg_report_fake,
|
||||
R.drawable.msg_report_violence,
|
||||
R.drawable.msg_report_abuse,
|
||||
R.drawable.msg_report_xxx,
|
||||
R.drawable.msg_report_other
|
||||
};
|
||||
}
|
||||
builder.setItems(items, (dialogInterface, i) -> {
|
||||
if (i == 4) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("dialog_id", dialog_id);
|
||||
args.putLong("message_id", messageId);
|
||||
parentFragment.presentFragment(new ReportOtherActivity(args));
|
||||
return;
|
||||
}
|
||||
TLObject req;
|
||||
TLRPC.InputPeer peer = MessagesController.getInstance(UserConfig.selectedAccount).getInputPeer((int) dialog_id);
|
||||
if (messageId != 0) {
|
||||
TLRPC.TL_messages_report request = new TLRPC.TL_messages_report();
|
||||
request.peer = peer;
|
||||
request.id.add(messageId);
|
||||
if (i == 0) {
|
||||
request.reason = new TLRPC.TL_inputReportReasonSpam();
|
||||
} else if (i == 1) {
|
||||
request.reason = new TLRPC.TL_inputReportReasonViolence();
|
||||
} else if (i == 2) {
|
||||
request.reason = new TLRPC.TL_inputReportReasonChildAbuse();
|
||||
} else if (i == 3) {
|
||||
request.reason = new TLRPC.TL_inputReportReasonPornography();
|
||||
builder.setItems(items, icons, (dialogInterface, i) -> {
|
||||
if (messageId == 0 && (i == 0 || i == 2 || i == 3 || i == 4) && parentFragment instanceof ChatActivity) {
|
||||
((ChatActivity) parentFragment).openReportChat(i);
|
||||
return;
|
||||
} else if (messageId == 0 && (i == 5 || i == 1) || messageId != 0 && i == 4) {
|
||||
parentFragment.showDialog(new ReportAlert(context, i == 4 ? 5 : i) {
|
||||
@Override
|
||||
protected void onSend(int type, String message) {
|
||||
ArrayList<Integer> ids = new ArrayList<>();
|
||||
if (messageId != 0) {
|
||||
ids.add(messageId);
|
||||
}
|
||||
req = request;
|
||||
} else {
|
||||
TLRPC.TL_account_reportPeer request = new TLRPC.TL_account_reportPeer();
|
||||
request.peer = peer;
|
||||
if (i == 0) {
|
||||
request.reason = new TLRPC.TL_inputReportReasonSpam();
|
||||
} else if (i == 1) {
|
||||
request.reason = new TLRPC.TL_inputReportReasonFake();
|
||||
} else if (i == 2) {
|
||||
request.reason = new TLRPC.TL_inputReportReasonViolence();
|
||||
} else if (i == 3) {
|
||||
request.reason = new TLRPC.TL_inputReportReasonChildAbuse();
|
||||
} else if (i == 4) {
|
||||
request.reason = new TLRPC.TL_inputReportReasonPornography();
|
||||
TLRPC.InputPeer peer = MessagesController.getInstance(UserConfig.selectedAccount).getInputPeer((int) dialog_id);
|
||||
sendReport(peer, type, message, ids);
|
||||
if (parentFragment instanceof ChatActivity) {
|
||||
((ChatActivity) parentFragment).getUndoView().showWithAction(0, UndoView.ACTION_REPORT_SENT, null);
|
||||
}
|
||||
req = request;
|
||||
}
|
||||
ConnectionsManager.getInstance(UserConfig.selectedAccount).sendRequest(req, (response, error) -> {
|
||||
|
||||
});
|
||||
Toast.makeText(context, LocaleController.getString("ReportChatSent", R.string.ReportChatSent), Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
return;
|
||||
}
|
||||
TLObject req;
|
||||
TLRPC.InputPeer peer = MessagesController.getInstance(UserConfig.selectedAccount).getInputPeer((int) dialog_id);
|
||||
if (messageId != 0) {
|
||||
TLRPC.TL_messages_report request = new TLRPC.TL_messages_report();
|
||||
request.peer = peer;
|
||||
request.id.add(messageId);
|
||||
request.message = "";
|
||||
if (i == 0) {
|
||||
request.reason = new TLRPC.TL_inputReportReasonSpam();
|
||||
} else if (i == 1) {
|
||||
request.reason = new TLRPC.TL_inputReportReasonViolence();
|
||||
} else if (i == 2) {
|
||||
request.reason = new TLRPC.TL_inputReportReasonChildAbuse();
|
||||
} else if (i == 3) {
|
||||
request.reason = new TLRPC.TL_inputReportReasonPornography();
|
||||
}
|
||||
);
|
||||
req = request;
|
||||
} else {
|
||||
TLRPC.TL_account_reportPeer request = new TLRPC.TL_account_reportPeer();
|
||||
request.peer = peer;
|
||||
request.message = "";
|
||||
if (i == 0) {
|
||||
request.reason = new TLRPC.TL_inputReportReasonSpam();
|
||||
} else if (i == 1) {
|
||||
request.reason = new TLRPC.TL_inputReportReasonFake();
|
||||
} else if (i == 2) {
|
||||
request.reason = new TLRPC.TL_inputReportReasonViolence();
|
||||
} else if (i == 3) {
|
||||
request.reason = new TLRPC.TL_inputReportReasonChildAbuse();
|
||||
} else if (i == 4) {
|
||||
request.reason = new TLRPC.TL_inputReportReasonPornography();
|
||||
}
|
||||
req = request;
|
||||
}
|
||||
ConnectionsManager.getInstance(UserConfig.selectedAccount).sendRequest(req, (response, error) -> {
|
||||
|
||||
});
|
||||
if (parentFragment instanceof ChatActivity) {
|
||||
((ChatActivity) parentFragment).getUndoView().showWithAction(0, UndoView.ACTION_REPORT_SENT, null);
|
||||
} else {
|
||||
BulletinFactory.of(parentFragment).createReportSent().show();
|
||||
}
|
||||
});
|
||||
BottomSheet sheet = builder.create();
|
||||
parentFragment.showDialog(sheet);
|
||||
}
|
||||
|
@ -2948,6 +3013,33 @@ public class AlertsCreator {
|
|||
return builder;
|
||||
}
|
||||
|
||||
public static AlertDialog.Builder createGigagroupConvertAlert(Activity activity, DialogInterface.OnClickListener onProcess, DialogInterface.OnClickListener onCancel) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
String svg = RLottieDrawable.readRes(null, R.raw.gigagroup);
|
||||
FrameLayout frameLayout = new FrameLayout(activity);
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
frameLayout.setClipToOutline(true);
|
||||
frameLayout.setOutlineProvider(new ViewOutlineProvider() {
|
||||
@Override
|
||||
public void getOutline(View view, Outline outline) {
|
||||
outline.setRoundRect(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight() + AndroidUtilities.dp(6), AndroidUtilities.dp(6));
|
||||
}
|
||||
});
|
||||
}
|
||||
float aspectRatio = 372f / 936f;
|
||||
View background = new View(activity);
|
||||
background.setBackground(new BitmapDrawable(SvgHelper.getBitmap(svg, AndroidUtilities.dp(320), AndroidUtilities.dp(320 * aspectRatio), false)));
|
||||
frameLayout.addView(background, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0, -1, -1, -1, -1));
|
||||
|
||||
builder.setTopView(frameLayout);
|
||||
builder.setTopViewAspectRatio(aspectRatio);
|
||||
builder.setTitle(LocaleController.getString("GigagroupAlertTitle", R.string.GigagroupAlertTitle));
|
||||
builder.setMessage(AndroidUtilities.replaceTags(LocaleController.getString("GigagroupAlertText", R.string.GigagroupAlertText)));
|
||||
builder.setPositiveButton(LocaleController.getString("GigagroupAlertLearnMore", R.string.GigagroupAlertLearnMore), onProcess);
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), onCancel);
|
||||
return builder;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public static AlertDialog.Builder createDrawOverlayPermissionDialog(Activity activity, DialogInterface.OnClickListener onCancel) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
|
|
|
@ -583,10 +583,10 @@ public class AudioPlayerAlert extends BottomSheet implements NotificationCenter.
|
|||
|
||||
textView.setOnClickListener(view -> {
|
||||
int dialogsCount = MessagesController.getInstance(currentAccount).getTotalDialogsCount();
|
||||
if (dialogsCount <= 10) {
|
||||
if (dialogsCount <= 10 || TextUtils.isEmpty(textView.getText().toString())) {
|
||||
return;
|
||||
}
|
||||
String query = (String) textView.getText();
|
||||
String query = textView.getText().toString();
|
||||
if (parentActivity.getActionBarLayout().getLastFragment() instanceof DialogsActivity) {
|
||||
DialogsActivity dialogsActivity = (DialogsActivity) parentActivity.getActionBarLayout().getLastFragment();
|
||||
if (!dialogsActivity.onlyDialogsAdapter()) {
|
||||
|
|
|
@ -240,6 +240,9 @@ public class BackgroundGradientDrawable extends GradientDrawable {
|
|||
|
||||
for (int i = 0; i < sizesArr.length; i++) {
|
||||
final IntSize size = sizesArr[i];
|
||||
if (size.width == 0 || size.height == 0) {
|
||||
continue;
|
||||
}
|
||||
final int index = i;
|
||||
Utilities.globalQueue.postRunnable(runnables[i] = () -> {
|
||||
Bitmap gradientBitmap = null;
|
||||
|
|
|
@ -59,6 +59,9 @@ public final class Bulletin {
|
|||
public static final int DURATION_SHORT = 1500;
|
||||
public static final int DURATION_LONG = 2750;
|
||||
|
||||
public static final int TYPE_STICKER = 0;
|
||||
public static final int TYPE_ERROR = 1;
|
||||
|
||||
public static Bulletin make(@NonNull FrameLayout containerLayout, @NonNull Layout contentLayout, int duration) {
|
||||
return new Bulletin(containerLayout, contentLayout, duration);
|
||||
}
|
||||
|
@ -90,7 +93,7 @@ public final class Bulletin {
|
|||
public static void hide(@NonNull FrameLayout containerLayout, boolean animated) {
|
||||
final Bulletin bulletin = find(containerLayout);
|
||||
if (bulletin != null) {
|
||||
bulletin.hide(animated && isTransitionsEnabled());
|
||||
bulletin.hide(animated && isTransitionsEnabled(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,7 +197,7 @@ public final class Bulletin {
|
|||
@Override
|
||||
public void onViewDetachedFromWindow(View v) {
|
||||
layout.removeOnAttachStateChangeListener(this);
|
||||
hide(false);
|
||||
hide(false, 0);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -221,10 +224,14 @@ public final class Bulletin {
|
|||
}
|
||||
|
||||
public void hide() {
|
||||
hide(isTransitionsEnabled());
|
||||
hide(isTransitionsEnabled(), 0);
|
||||
}
|
||||
|
||||
public void hide(boolean animated) {
|
||||
public void hide(long duration) {
|
||||
hide(isTransitionsEnabled(), duration);
|
||||
}
|
||||
|
||||
public void hide(boolean animated, long duration) {
|
||||
if (showing) {
|
||||
showing = false;
|
||||
|
||||
|
@ -241,7 +248,13 @@ public final class Bulletin {
|
|||
layout.transitionRunning = true;
|
||||
layout.delegate = currentDelegate;
|
||||
layout.invalidate();
|
||||
ensureLayoutTransitionCreated();
|
||||
if (duration >= 0) {
|
||||
Layout.DefaultTransition transition = new Layout.DefaultTransition();
|
||||
transition.duration = duration;
|
||||
layoutTransition = transition;
|
||||
} else {
|
||||
ensureLayoutTransitionCreated();
|
||||
}
|
||||
layoutTransition.animateExit(layout, layout::onExitTransitionStart, () -> {
|
||||
if (currentDelegate != null) {
|
||||
currentDelegate.onOffsetChange(0);
|
||||
|
@ -682,6 +695,8 @@ public final class Bulletin {
|
|||
|
||||
public static class DefaultTransition implements Transition {
|
||||
|
||||
long duration = 255;
|
||||
|
||||
@Override
|
||||
public void animateEnter(@NonNull Layout layout, @Nullable Runnable startAction, @Nullable Runnable endAction, @Nullable Consumer<Float> onUpdate, int bottomOffset) {
|
||||
layout.setInOutOffset(layout.getMeasuredHeight());
|
||||
|
@ -689,7 +704,7 @@ public final class Bulletin {
|
|||
onUpdate.accept(layout.getTranslationY());
|
||||
}
|
||||
final ObjectAnimator animator = ObjectAnimator.ofFloat(layout, IN_OUT_OFFSET_Y2, 0);
|
||||
animator.setDuration(225);
|
||||
animator.setDuration(duration);
|
||||
animator.setInterpolator(Easings.easeOutQuad);
|
||||
if (startAction != null || endAction != null) {
|
||||
animator.addListener(new AnimatorListenerAdapter() {
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.telegram.messenger.AndroidUtilities;
|
|||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.NotificationsController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
|
||||
public final class BulletinFactory {
|
||||
|
@ -25,6 +26,9 @@ public final class BulletinFactory {
|
|||
return fragment != null && fragment.getParentActivity() != null && fragment.getLayoutContainer() != null;
|
||||
}
|
||||
|
||||
public static final int ICON_TYPE_NOT_FOUND = 0;
|
||||
public static final int ICON_TYPE_WARNING = 1;
|
||||
|
||||
public enum FileType {
|
||||
|
||||
PHOTO("PhotoSavedHint", R.string.PhotoSavedHint, Icon.SAVED_TO_GALLERY),
|
||||
|
@ -108,6 +112,13 @@ public final class BulletinFactory {
|
|||
this.fragment = null;
|
||||
}
|
||||
|
||||
public Bulletin createSimpleBulletin(int iconRawId, String text) {
|
||||
final Bulletin.LottieLayout layout = new Bulletin.LottieLayout(getContext());
|
||||
layout.setAnimation(iconRawId, 36, 36);
|
||||
layout.textView.setText(text);
|
||||
return create(layout, Bulletin.DURATION_SHORT);
|
||||
}
|
||||
|
||||
@CheckResult
|
||||
public Bulletin createDownloadBulletin(FileType fileType) {
|
||||
return createDownloadBulletin(fileType, 1);
|
||||
|
@ -118,6 +129,13 @@ public final class BulletinFactory {
|
|||
return createDownloadBulletin(fileType, filesAmount, 0, 0);
|
||||
}
|
||||
|
||||
public Bulletin createReportSent() {
|
||||
final Bulletin.LottieLayout layout = new Bulletin.LottieLayout(getContext());
|
||||
layout.setAnimation(R.raw.chats_infotip);
|
||||
layout.textView.setText(LocaleController.getString("ReportChatSent", R.string.ReportChatSent));
|
||||
return create(layout, Bulletin.DURATION_SHORT);
|
||||
}
|
||||
|
||||
@CheckResult
|
||||
public Bulletin createDownloadBulletin(FileType fileType, int filesAmount, int backgroundColor, int textColor) {
|
||||
final Bulletin.LottieLayout layout;
|
||||
|
@ -134,11 +152,29 @@ public final class BulletinFactory {
|
|||
return create(layout, Bulletin.DURATION_SHORT);
|
||||
}
|
||||
|
||||
|
||||
public Bulletin createErrorBulletin(String errorMessage) {
|
||||
Bulletin.LottieLayout layout = new Bulletin.LottieLayout(getContext());
|
||||
layout.setAnimation(R.raw.chats_infotip);
|
||||
layout.textView.setText(errorMessage);
|
||||
layout.textView.setSingleLine(false);
|
||||
layout.textView.setMaxLines(2);
|
||||
return create(layout, Bulletin.DURATION_SHORT);
|
||||
}
|
||||
|
||||
@CheckResult
|
||||
public Bulletin createCopyLinkBulletin() {
|
||||
return createCopyLinkBulletin(false);
|
||||
}
|
||||
|
||||
@CheckResult
|
||||
public Bulletin createCopyBulletin(String message) {
|
||||
final Bulletin.LottieLayout layout = new Bulletin.LottieLayout(getContext());
|
||||
layout.setAnimation(R.raw.copy, 36, 36, "NULL ROTATION", "Back", "Front");
|
||||
layout.textView.setText(message);
|
||||
return create(layout, Bulletin.DURATION_SHORT);
|
||||
}
|
||||
|
||||
@CheckResult
|
||||
public Bulletin createCopyLinkBulletin(boolean isPrivate) {
|
||||
if (isPrivate) {
|
||||
|
@ -268,10 +304,16 @@ public final class BulletinFactory {
|
|||
}
|
||||
|
||||
@CheckResult
|
||||
public static Bulletin createRemoveFromChatBulletin(BaseFragment fragment, String userFirstName, String chatName) {
|
||||
public static Bulletin createRemoveFromChatBulletin(BaseFragment fragment, TLRPC.User user, String chatName) {
|
||||
final Bulletin.LottieLayout layout = new Bulletin.LottieLayout(fragment.getParentActivity());
|
||||
layout.setAnimation(R.raw.ic_ban, "Hand");
|
||||
layout.textView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("UserRemovedFromChatHint", R.string.UserRemovedFromChatHint, userFirstName, chatName)));
|
||||
String name;
|
||||
if (user.deleted) {
|
||||
name = LocaleController.formatString("HiddenName", R.string.HiddenName);
|
||||
} else {
|
||||
name = user.first_name;
|
||||
}
|
||||
layout.textView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("UserRemovedFromChatHint", R.string.UserRemovedFromChatHint, name, chatName)));
|
||||
return Bulletin.make(fragment, layout, Bulletin.DURATION_SHORT);
|
||||
}
|
||||
|
||||
|
|
|
@ -584,8 +584,8 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
|
|||
AdjustPanLayoutHelper adjustPanLayoutHelper = new AdjustPanLayoutHelper(this) {
|
||||
|
||||
@Override
|
||||
protected void onTransitionStart(boolean keyboardVisible) {
|
||||
super.onTransitionStart(keyboardVisible);
|
||||
protected void onTransitionStart(boolean keyboardVisible, int contentHeight) {
|
||||
super.onTransitionStart(keyboardVisible, contentHeight);
|
||||
if (previousScrollOffsetY > 0 && previousScrollOffsetY != scrollOffsetY[0] && keyboardVisible) {
|
||||
fromScrollY = previousScrollOffsetY;
|
||||
toScrollY = scrollOffsetY[0];
|
||||
|
|
|
@ -64,6 +64,8 @@ public class ChatAvatarContainer extends FrameLayout implements NotificationCent
|
|||
|
||||
private boolean[] isOnline = new boolean[1];
|
||||
|
||||
private boolean secretChatTimer;
|
||||
|
||||
private int onlineCount = -1;
|
||||
private int currentConnectionState;
|
||||
private CharSequence lastSubtitle;
|
||||
|
@ -118,14 +120,30 @@ public class ChatAvatarContainer extends FrameLayout implements NotificationCent
|
|||
subtitleTextView.setGravity(Gravity.LEFT);
|
||||
addView(subtitleTextView);
|
||||
|
||||
if (needTime) {
|
||||
if (parentFragment != null) {
|
||||
timeItem = new ImageView(context);
|
||||
timeItem.setPadding(AndroidUtilities.dp(10), AndroidUtilities.dp(10), AndroidUtilities.dp(5), AndroidUtilities.dp(5));
|
||||
timeItem.setScaleType(ImageView.ScaleType.CENTER);
|
||||
timeItem.setAlpha(0.0f);
|
||||
timeItem.setScaleY(0.0f);
|
||||
timeItem.setScaleX(0.0f);
|
||||
timeItem.setVisibility(GONE);
|
||||
timeItem.setImageDrawable(timerDrawable = new TimerDrawable(context));
|
||||
addView(timeItem);
|
||||
timeItem.setOnClickListener(v -> parentFragment.showDialog(AlertsCreator.createTTLAlert(getContext(), parentFragment.getCurrentEncryptedChat()).create()));
|
||||
timeItem.setContentDescription(LocaleController.getString("SetTimer", R.string.SetTimer));
|
||||
secretChatTimer = needTime;
|
||||
|
||||
timeItem.setOnClickListener(v -> {
|
||||
if (secretChatTimer) {
|
||||
parentFragment.showDialog(AlertsCreator.createTTLAlert(getContext(), parentFragment.getCurrentEncryptedChat()).create());
|
||||
} else {
|
||||
openSetTimer();
|
||||
}
|
||||
});
|
||||
if (secretChatTimer) {
|
||||
timeItem.setContentDescription(LocaleController.getString("SetTimer", R.string.SetTimer));
|
||||
} else {
|
||||
timeItem.setContentDescription(LocaleController.getString("AccAutoDeleteTimer", R.string.AccAutoDeleteTimer));
|
||||
}
|
||||
}
|
||||
|
||||
if (parentFragment != null && parentFragment.getChatMode() == 0) {
|
||||
|
@ -145,6 +163,33 @@ public class ChatAvatarContainer extends FrameLayout implements NotificationCent
|
|||
}
|
||||
}
|
||||
|
||||
public boolean openSetTimer() {
|
||||
if (parentFragment.getParentActivity() == null) {
|
||||
return false;
|
||||
}
|
||||
TLRPC.Chat chat = parentFragment.getCurrentChat();
|
||||
if (chat != null && !ChatObject.canUserDoAdminAction(chat, ChatObject.ACTION_DELETE_MESSAGES)) {
|
||||
if (timeItem.getTag() != null) {
|
||||
parentFragment.showTimerHint();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
ClearHistoryAlert alert = new ClearHistoryAlert(parentFragment.getParentActivity(), parentFragment.getCurrentUser(), parentFragment.getCurrentChat(), false);
|
||||
alert.setDelegate(new ClearHistoryAlert.ClearHistoryAlertDelegate() {
|
||||
@Override
|
||||
public void onAutoDeleteHistory(int ttl, int action) {
|
||||
parentFragment.getMessagesController().setDialogHistoryTTL(parentFragment.getDialogId(), ttl);
|
||||
TLRPC.ChatFull chatInfo = parentFragment.getCurrentChatInfo();
|
||||
TLRPC.UserFull userInfo = parentFragment.getCurrentUserInfo();
|
||||
if (userInfo != null || chatInfo != null) {
|
||||
parentFragment.getUndoView().showWithAction(parentFragment.getDialogId(), action, parentFragment.getCurrentUser(), userInfo != null ? userInfo.ttl_period : chatInfo.ttl_period, null, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
parentFragment.showDialog(alert);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void openProfile(boolean byAvatar) {
|
||||
if (byAvatar && (AndroidUtilities.isTablet() || AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y || !avatarImageView.getImageReceiver().hasNotThumb())) {
|
||||
byAvatar = false;
|
||||
|
@ -235,24 +280,51 @@ public class ChatAvatarContainer extends FrameLayout implements NotificationCent
|
|||
leftPadding = value;
|
||||
}
|
||||
|
||||
public void showTimeItem() {
|
||||
if (timeItem == null) {
|
||||
public void showTimeItem(boolean animated) {
|
||||
if (timeItem == null || timeItem.getTag() != null) {
|
||||
return;
|
||||
}
|
||||
timeItem.clearAnimation();
|
||||
timeItem.setVisibility(VISIBLE);
|
||||
timeItem.setTag(1);
|
||||
if (animated) {
|
||||
timeItem.animate().setDuration(180).alpha(1.0f).scaleX(1.0f).scaleY(1.0f).setListener(null).start();
|
||||
} else {
|
||||
timeItem.setAlpha(1.0f);
|
||||
timeItem.setScaleY(1.0f);
|
||||
timeItem.setScaleX(1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public void hideTimeItem() {
|
||||
if (timeItem == null) {
|
||||
public void hideTimeItem(boolean animated) {
|
||||
if (timeItem == null || timeItem.getTag() == null) {
|
||||
return;
|
||||
}
|
||||
timeItem.setVisibility(GONE);
|
||||
timeItem.clearAnimation();
|
||||
timeItem.setTag(null);
|
||||
if (animated) {
|
||||
timeItem.animate().setDuration(180).alpha(0.0f).scaleX(0.0f).scaleY(0.0f).setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
timeItem.setVisibility(GONE);
|
||||
super.onAnimationEnd(animation);
|
||||
}
|
||||
}).start();
|
||||
} else {
|
||||
timeItem.setVisibility(GONE);
|
||||
timeItem.setAlpha(0.0f);
|
||||
timeItem.setScaleY(0.0f);
|
||||
timeItem.setScaleX(0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTime(int value) {
|
||||
if (timerDrawable == null) {
|
||||
return;
|
||||
}
|
||||
if (value == 0 && !secretChatTimer) {
|
||||
return;
|
||||
}
|
||||
timerDrawable.setTime(value);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,443 @@
|
|||
/*
|
||||
* This is the source code of Telegram for Android v. 7.x.x.
|
||||
* It is licensed under GNU GPL v. 2 or later.
|
||||
* You should have received a copy of the license in this archive (see LICENSE).
|
||||
*
|
||||
* Copyright Nikolai Kudashov, 2013-2021.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Components;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.BuildVars;
|
||||
import org.telegram.messenger.ChatObject;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.UserObject;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.BottomSheet;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Cells.CheckBoxCell;
|
||||
import org.telegram.ui.Cells.HeaderCell;
|
||||
import org.telegram.ui.Cells.ShadowSectionCell;
|
||||
import org.telegram.ui.Cells.TextInfoPrivacyCell;
|
||||
|
||||
import androidx.core.widget.NestedScrollView;
|
||||
|
||||
public class ClearHistoryAlert extends BottomSheet {
|
||||
|
||||
private Drawable shadowDrawable;
|
||||
private LinearLayout linearLayout;
|
||||
private BottomSheetCell setTimerButton;
|
||||
private CheckBoxCell cell;
|
||||
|
||||
private boolean autoDeleteOnly;
|
||||
private int scrollOffsetY;
|
||||
|
||||
private int[] location = new int[2];
|
||||
|
||||
private int currentTimer;
|
||||
private int newTimer;
|
||||
|
||||
private boolean dismissedDelayed;
|
||||
|
||||
private ClearHistoryAlertDelegate delegate;
|
||||
|
||||
public interface ClearHistoryAlertDelegate {
|
||||
|
||||
default void onClearHistory(boolean revoke) {
|
||||
|
||||
}
|
||||
|
||||
default void onAutoDeleteHistory(int ttl, int action) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static class BottomSheetCell extends FrameLayout {
|
||||
|
||||
private View background;
|
||||
private TextView textView;
|
||||
private LinearLayout linearLayout;
|
||||
|
||||
public BottomSheetCell(Context context) {
|
||||
super(context);
|
||||
|
||||
background = new View(context);
|
||||
background.setBackground(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(4), Theme.getColor(Theme.key_featuredStickers_addButton), Theme.getColor(Theme.key_featuredStickers_addButtonPressed)));
|
||||
addView(background, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0, 16, 16, 16, 16));
|
||||
|
||||
textView = new TextView(context);
|
||||
textView.setLines(1);
|
||||
textView.setSingleLine(true);
|
||||
textView.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
textView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
textView.setGravity(Gravity.CENTER);
|
||||
textView.setTextColor(Theme.getColor(Theme.key_featuredStickers_buttonText));
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(80), MeasureSpec.EXACTLY));
|
||||
}
|
||||
|
||||
public void setText(CharSequence text) {
|
||||
textView.setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
public ClearHistoryAlert(final Context context, TLRPC.User user, TLRPC.Chat chat, boolean full) {
|
||||
super(context, false);
|
||||
autoDeleteOnly = !full;
|
||||
setApplyBottomPadding(false);
|
||||
|
||||
int ttl;
|
||||
if (user != null) {
|
||||
TLRPC.UserFull userFull = MessagesController.getInstance(currentAccount).getUserFull(user.id);
|
||||
ttl = userFull != null ? userFull.ttl_period : 0;
|
||||
} else {
|
||||
TLRPC.ChatFull chatFull = MessagesController.getInstance(currentAccount).getChatFull(chat.id);
|
||||
ttl = chatFull != null ? chatFull.ttl_period : 0;
|
||||
}
|
||||
if (ttl == 0) {
|
||||
newTimer = currentTimer = 0;
|
||||
} else if (ttl == 24 * 60 * 60) {
|
||||
newTimer = currentTimer = 1;
|
||||
} else {
|
||||
newTimer = currentTimer = 2;
|
||||
}
|
||||
|
||||
shadowDrawable = context.getResources().getDrawable(R.drawable.sheet_shadow_round).mutate();
|
||||
shadowDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogBackground), PorterDuff.Mode.MULTIPLY));
|
||||
|
||||
NestedScrollView scrollView = new NestedScrollView(context) {
|
||||
|
||||
private boolean ignoreLayout;
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
if (ev.getAction() == MotionEvent.ACTION_DOWN && scrollOffsetY != 0 && ev.getY() < scrollOffsetY) {
|
||||
dismiss();
|
||||
return true;
|
||||
}
|
||||
return super.onInterceptTouchEvent(ev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent e) {
|
||||
return !isDismissed() && super.onTouchEvent(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTranslationY(float translationY) {
|
||||
super.setTranslationY(translationY);
|
||||
updateLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int height = MeasureSpec.getSize(heightMeasureSpec);
|
||||
measureChildWithMargins(linearLayout, widthMeasureSpec, 0, heightMeasureSpec, 0);
|
||||
int contentHeight = linearLayout.getMeasuredHeight();
|
||||
int padding = (height / 5 * 3);
|
||||
int visiblePart = height - padding;
|
||||
if (autoDeleteOnly || contentHeight - visiblePart < AndroidUtilities.dp(90) || contentHeight < height / 2 + AndroidUtilities.dp(90)) {
|
||||
padding = height - contentHeight;
|
||||
} else {
|
||||
int minHeight = contentHeight / 2 + AndroidUtilities.dp(40);
|
||||
if (visiblePart < minHeight) {
|
||||
padding = height - minHeight;
|
||||
}
|
||||
}
|
||||
if (getPaddingTop() != padding) {
|
||||
ignoreLayout = true;
|
||||
setPadding(0, padding, 0, 0);
|
||||
ignoreLayout = false;
|
||||
}
|
||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
updateLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestLayout() {
|
||||
if (ignoreLayout) {
|
||||
return;
|
||||
}
|
||||
super.requestLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
int top = (int) (scrollOffsetY - backgroundPaddingTop + getScrollY() - getTranslationY());
|
||||
shadowDrawable.setBounds(0, top, getMeasuredWidth(), top + linearLayout.getMeasuredHeight() + backgroundPaddingTop + AndroidUtilities.dp(19));
|
||||
shadowDrawable.draw(canvas);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
|
||||
super.onScrollChanged(l, t, oldl, oldt);
|
||||
updateLayout();
|
||||
}
|
||||
};
|
||||
scrollView.setFillViewport(true);
|
||||
scrollView.setWillNotDraw(false);
|
||||
scrollView.setClipToPadding(false);
|
||||
scrollView.setPadding(backgroundPaddingLeft, 0, backgroundPaddingLeft, 0);
|
||||
containerView = scrollView;
|
||||
|
||||
linearLayout = new LinearLayout(context) {
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
super.onLayout(changed, l, t, r, b);
|
||||
updateLayout();
|
||||
}
|
||||
};
|
||||
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
scrollView.addView(linearLayout, LayoutHelper.createScroll(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM));
|
||||
setCustomView(linearLayout);
|
||||
|
||||
int selfUserId = UserConfig.getInstance(currentAccount).getClientUserId();
|
||||
|
||||
boolean canRevokeInbox = user != null && !user.bot && user.id != selfUserId && MessagesController.getInstance(currentAccount).canRevokePmInbox;
|
||||
int revokeTimeLimit;
|
||||
if (user != null) {
|
||||
revokeTimeLimit = MessagesController.getInstance(currentAccount).revokeTimePmLimit;
|
||||
} else {
|
||||
revokeTimeLimit = MessagesController.getInstance(currentAccount).revokeTimeLimit;
|
||||
}
|
||||
boolean canDeleteInbox = user != null && canRevokeInbox && revokeTimeLimit == 0x7fffffff;
|
||||
final boolean[] deleteForAll = new boolean[]{false};
|
||||
boolean deleteChatForAll = false;
|
||||
|
||||
if (!autoDeleteOnly) {
|
||||
TextView textView = new TextView(context);
|
||||
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
|
||||
textView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
|
||||
textView.setText(LocaleController.getString("ClearHistory", R.string.ClearHistory));
|
||||
textView.setSingleLine(true);
|
||||
textView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
linearLayout.addView(textView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 23, 20, 23, 0));
|
||||
|
||||
TextView messageTextView = new TextView(getContext());
|
||||
messageTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
|
||||
messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||
messageTextView.setText(LocaleController.getString(""));
|
||||
messageTextView.setMovementMethod(new AndroidUtilities.LinkMovementMethodMy());
|
||||
messageTextView.setLinkTextColor(Theme.getColor(Theme.key_dialogTextLink));
|
||||
messageTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
|
||||
linearLayout.addView(messageTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 23, 16, 23, 5));
|
||||
if (user != null) {
|
||||
messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("AreYouSureClearHistoryWithUser", R.string.AreYouSureClearHistoryWithUser, UserObject.getUserName(user))));
|
||||
} else {
|
||||
if (!ChatObject.isChannel(chat) || chat.megagroup && TextUtils.isEmpty(chat.username)) {
|
||||
messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("AreYouSureClearHistoryWithChat", R.string.AreYouSureClearHistoryWithChat, chat.title)));
|
||||
} else if (chat.megagroup) {
|
||||
messageTextView.setText(LocaleController.getString("AreYouSureClearHistoryGroup", R.string.AreYouSureClearHistoryGroup));
|
||||
} else {
|
||||
messageTextView.setText(LocaleController.getString("AreYouSureClearHistoryChannel", R.string.AreYouSureClearHistoryChannel));
|
||||
}
|
||||
}
|
||||
|
||||
if (canDeleteInbox && !UserObject.isDeleted(user)) {
|
||||
cell = new CheckBoxCell(context, 1);
|
||||
cell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
|
||||
cell.setText(LocaleController.formatString("ClearHistoryOptionAlso", R.string.ClearHistoryOptionAlso, UserObject.getFirstName(user)), "", false, false);
|
||||
cell.setPadding(LocaleController.isRTL ? AndroidUtilities.dp(16) : AndroidUtilities.dp(5), 0, LocaleController.isRTL ? AndroidUtilities.dp(5) : AndroidUtilities.dp(16), 0);
|
||||
linearLayout.addView(cell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48, Gravity.TOP | Gravity.LEFT, 0, 0, 0, 0));
|
||||
cell.setOnClickListener(v -> {
|
||||
CheckBoxCell cell1 = (CheckBoxCell) v;
|
||||
deleteForAll[0] = !deleteForAll[0];
|
||||
cell1.setChecked(deleteForAll[0], true);
|
||||
});
|
||||
}
|
||||
|
||||
BottomSheetCell clearButton = new BottomSheetCell(context);
|
||||
clearButton.setBackground(null);
|
||||
clearButton.setText(LocaleController.getString("AlertClearHistory", R.string.AlertClearHistory));
|
||||
clearButton.background.setOnClickListener(v -> {
|
||||
if (dismissedDelayed) {
|
||||
return;
|
||||
}
|
||||
delegate.onClearHistory(cell != null && cell.isChecked());
|
||||
dismiss();
|
||||
});
|
||||
linearLayout.addView(clearButton, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 50, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0));
|
||||
|
||||
ShadowSectionCell shadowSectionCell = new ShadowSectionCell(context);
|
||||
Drawable drawable = Theme.getThemedDrawable(context, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow);
|
||||
CombinedDrawable combinedDrawable = new CombinedDrawable(new ColorDrawable(Theme.getColor(Theme.key_windowBackgroundGray)), drawable);
|
||||
combinedDrawable.setFullsize(true);
|
||||
shadowSectionCell.setBackgroundDrawable(combinedDrawable);
|
||||
linearLayout.addView(shadowSectionCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
|
||||
HeaderCell headerCell = new HeaderCell(context);
|
||||
headerCell.setText(LocaleController.getString("AutoDeleteHeader", R.string.AutoDeleteHeader));
|
||||
linearLayout.addView(headerCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 1, autoDeleteOnly ? 20 : 0, 1, 0));
|
||||
} else {
|
||||
RLottieImageView lottieImageView = new RLottieImageView(context);
|
||||
lottieImageView.setAutoRepeat(false);
|
||||
lottieImageView.setAnimation(R.raw.utyan_private, 120, 120);
|
||||
lottieImageView.setPadding(0, AndroidUtilities.dp(20), 0, 0);
|
||||
lottieImageView.playAnimation();
|
||||
linearLayout.addView(lottieImageView, LayoutHelper.createLinear(160, 160, Gravity.CENTER_HORIZONTAL | Gravity.TOP, 17, 0, 17, 0));
|
||||
|
||||
TextView percentTextView = new TextView(context);
|
||||
percentTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
percentTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 24);
|
||||
percentTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
|
||||
percentTextView.setText(LocaleController.getString("AutoDeleteAlertTitle", R.string.AutoDeleteAlertTitle));
|
||||
linearLayout.addView(percentTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 17, 18, 17, 0));
|
||||
|
||||
TextView infoTextView = new TextView(context);
|
||||
infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
infoTextView.setTextColor(Theme.getColor(Theme.key_dialogTextGray3));
|
||||
infoTextView.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
if (user != null) {
|
||||
infoTextView.setText(LocaleController.formatString("AutoDeleteAlertUserInfo", R.string.AutoDeleteAlertUserInfo, UserObject.getFirstName(user)));
|
||||
} else {
|
||||
if (ChatObject.isChannel(chat) && !chat.megagroup) {
|
||||
infoTextView.setText(LocaleController.getString("AutoDeleteAlertChannelInfo", R.string.AutoDeleteAlertChannelInfo));
|
||||
} else {
|
||||
infoTextView.setText(LocaleController.getString("AutoDeleteAlertGroupInfo", R.string.AutoDeleteAlertGroupInfo));
|
||||
}
|
||||
}
|
||||
linearLayout.addView(infoTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 30, 22, 30, 20));
|
||||
}
|
||||
|
||||
SlideChooseView slideChooseView = new SlideChooseView(context);
|
||||
slideChooseView.setCallback(new SlideChooseView.Callback() {
|
||||
@Override
|
||||
public void onOptionSelected(int index) {
|
||||
newTimer = index;
|
||||
updateTimerButton(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouchEnd() {
|
||||
scrollView.smoothScrollTo(0, linearLayout.getMeasuredHeight());
|
||||
}
|
||||
});
|
||||
String[] strings = new String[]{
|
||||
LocaleController.getString("AutoDeleteNever", R.string.AutoDeleteNever),
|
||||
LocaleController.getString("AutoDelete24Hours", R.string.AutoDelete24Hours),
|
||||
LocaleController.getString("AutoDelete7Days", R.string.AutoDelete7Days)
|
||||
};
|
||||
slideChooseView.setOptions(currentTimer, strings);
|
||||
linearLayout.addView(slideChooseView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 8, 0, 0));
|
||||
|
||||
FrameLayout buttonContainer = new FrameLayout(context);
|
||||
Drawable drawable = Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow);
|
||||
CombinedDrawable combinedDrawable = new CombinedDrawable(new ColorDrawable(Theme.getColor(Theme.key_windowBackgroundGray)), drawable);
|
||||
combinedDrawable.setFullsize(true);
|
||||
buttonContainer.setBackgroundDrawable(combinedDrawable);
|
||||
linearLayout.addView(buttonContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
|
||||
TextInfoPrivacyCell infoCell = new TextInfoPrivacyCell(context);
|
||||
|
||||
infoCell.setText(LocaleController.getString("AutoDeleteInfo", R.string.AutoDeleteInfo));
|
||||
buttonContainer.addView(infoCell);
|
||||
|
||||
setTimerButton = new BottomSheetCell(context);
|
||||
setTimerButton.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));
|
||||
if (autoDeleteOnly) {
|
||||
setTimerButton.setText(LocaleController.getString("AutoDeleteSet", R.string.AutoDeleteSet));
|
||||
} else if (full && currentTimer == 0) {
|
||||
setTimerButton.setText(LocaleController.getString("EnableAutoDelete", R.string.EnableAutoDelete));
|
||||
} else {
|
||||
setTimerButton.setText(LocaleController.getString("AutoDeleteConfirm", R.string.AutoDeleteConfirm));
|
||||
}
|
||||
setTimerButton.background.setOnClickListener(v -> {
|
||||
if (dismissedDelayed) {
|
||||
return;
|
||||
}
|
||||
if (newTimer != currentTimer) {
|
||||
dismissedDelayed = true;
|
||||
int time;
|
||||
int action;
|
||||
if (newTimer == 2) {
|
||||
time = BuildVars.DEBUG_PRIVATE_VERSION ? 5 : 7 * 24 * 60 * 60;
|
||||
action = UndoView.ACTION_AUTO_DELETE_ON;
|
||||
} else if (newTimer == 1) {
|
||||
time = 24 * 60 * 60;
|
||||
action = UndoView.ACTION_AUTO_DELETE_ON;
|
||||
} else {
|
||||
time = 0;
|
||||
action = UndoView.ACTION_AUTO_DELETE_OFF;
|
||||
}
|
||||
delegate.onAutoDeleteHistory(time, action);
|
||||
}
|
||||
if (dismissedDelayed) {
|
||||
AndroidUtilities.runOnUIThread(this::dismiss, 200);
|
||||
} else {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
buttonContainer.addView(setTimerButton);
|
||||
|
||||
updateTimerButton(false);
|
||||
}
|
||||
|
||||
private void updateTimerButton(boolean animated) {
|
||||
if (currentTimer == newTimer && !autoDeleteOnly) {
|
||||
if (animated) {
|
||||
setTimerButton.animate().alpha(0.0f).setDuration(180).start();
|
||||
} else {
|
||||
setTimerButton.setVisibility(View.INVISIBLE);
|
||||
setTimerButton.setAlpha(0.0f);
|
||||
}
|
||||
} else {
|
||||
setTimerButton.setVisibility(View.VISIBLE);
|
||||
if (animated) {
|
||||
setTimerButton.animate().alpha(1.0f).setDuration(180).start();
|
||||
} else {
|
||||
setTimerButton.setAlpha(1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateLayout() {
|
||||
View child = linearLayout.getChildAt(0);
|
||||
child.getLocationInWindow(location);
|
||||
int top = location[1] - AndroidUtilities.dp(autoDeleteOnly ? 6 : 19);
|
||||
int newOffset = Math.max(top, 0);
|
||||
if (scrollOffsetY != newOffset) {
|
||||
scrollOffsetY = newOffset;
|
||||
containerView.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canDismissWithSwipe() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setDelegate(ClearHistoryAlertDelegate clearHistoryAlertDelegate) {
|
||||
delegate = clearHistoryAlertDelegate;
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ import android.graphics.ColorFilter;
|
|||
import android.graphics.Paint;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
|
@ -67,14 +68,15 @@ public class CrossOutDrawable extends Drawable {
|
|||
progress = 0;
|
||||
}
|
||||
}
|
||||
if (progress == 0) {
|
||||
iconDrawable.draw(canvas);
|
||||
return;
|
||||
}
|
||||
int newColor = Theme.getColor(colorKey);
|
||||
if (color != newColor) {
|
||||
color = newColor;
|
||||
paint.setColor(newColor);
|
||||
iconDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(colorKey), PorterDuff.Mode.MULTIPLY));
|
||||
}
|
||||
if (progress == 0) {
|
||||
iconDrawable.draw(canvas);
|
||||
return;
|
||||
}
|
||||
rectF.set(iconDrawable.getBounds());
|
||||
canvas.saveLayerAlpha(rectF, 255, Canvas.ALL_SAVE_FLAG);
|
||||
|
@ -101,14 +103,14 @@ public class CrossOutDrawable extends Drawable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setBounds(int left, int top, int right, int bottom) {
|
||||
super.setBounds(left, top, right, bottom);
|
||||
iconDrawable.setBounds(left, top, right, bottom);
|
||||
public void setColorFilter(@Nullable ColorFilter colorFilter) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(@Nullable ColorFilter colorFilter) {
|
||||
iconDrawable.setColorFilter(colorFilter);
|
||||
public void setBounds(int left, int top, int right, int bottom) {
|
||||
super.setBounds(left, top, right, bottom);
|
||||
iconDrawable.setBounds(left, top, right, bottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -123,10 +125,11 @@ public class CrossOutDrawable extends Drawable {
|
|||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return PixelFormat.TRANSLUCENT;
|
||||
return PixelFormat.TRANSPARENT;
|
||||
}
|
||||
|
||||
public void setColorKey(String colorKey) {
|
||||
this.colorKey = colorKey;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -830,9 +830,10 @@ public class EmbedBottomSheet extends BottomSheet {
|
|||
dismiss();
|
||||
});
|
||||
|
||||
boolean canHandleUrl = videoView.canHandleUrl(embedUrl);
|
||||
if (!canHandleUrl) {
|
||||
videoView.setVisibility(View.INVISIBLE);
|
||||
boolean canHandleUrl = videoView.canHandleUrl(embedUrl) || videoView.canHandleUrl(originalUrl);
|
||||
videoView.setVisibility(canHandleUrl ? View.VISIBLE : View.INVISIBLE);
|
||||
if (canHandleUrl) {
|
||||
videoView.willHandle();
|
||||
}
|
||||
|
||||
setDelegate(new BottomSheet.BottomSheetDelegate() {
|
||||
|
|
|
@ -2,6 +2,8 @@ package org.telegram.ui.Components;
|
|||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.text.Layout;
|
||||
import android.text.style.AlignmentSpan;
|
||||
import android.text.style.ReplacementSpan;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
|
|
@ -1394,7 +1394,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
|
|||
}
|
||||
TypefaceSpan span = new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf"), 0, Theme.getColor(Theme.key_inappPlayerPerformer));
|
||||
stringBuilder.setSpan(span, 0, messageObject.getMusicAuthor().length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
titleTextView.setText(stringBuilder, !create && wasVisible);
|
||||
titleTextView.setText(stringBuilder, !create && wasVisible && isMusic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,9 +153,11 @@ public class FragmentContextViewWavesDrawable {
|
|||
lineBlobDrawable2.minRadius = AndroidUtilities.dp(0);
|
||||
lineBlobDrawable2.maxRadius = AndroidUtilities.dp(3) + AndroidUtilities.dp(9) * amplitude;
|
||||
|
||||
lineBlobDrawable.update(amplitude, 0.3f);
|
||||
lineBlobDrawable1.update(amplitude, 0.7f);
|
||||
lineBlobDrawable2.update(amplitude, 0.7f);
|
||||
if (i == 1) {
|
||||
lineBlobDrawable.update(amplitude, 0.3f);
|
||||
lineBlobDrawable1.update(amplitude, 0.7f);
|
||||
lineBlobDrawable2.update(amplitude, 0.7f);
|
||||
}
|
||||
|
||||
// if (rippleTransition) {
|
||||
// paint.setAlpha(76);
|
||||
|
|
|
@ -0,0 +1,165 @@
|
|||
/*
|
||||
* This is the source code of Telegram for Android v. 5.x.x.
|
||||
* It is licensed under GNU GPL v. 2 or later.
|
||||
* You should have received a copy of the license in this archive (see LICENSE).
|
||||
*
|
||||
* Copyright Nikolai Kudashov, 2013-2018.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Components;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.ActionBar.AlertDialog;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.BottomSheet;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
|
||||
public class GigagroupConvertAlert extends BottomSheet {
|
||||
|
||||
private boolean compteled;
|
||||
|
||||
public static class BottomSheetCell extends FrameLayout {
|
||||
|
||||
private View background;
|
||||
private TextView textView;
|
||||
private LinearLayout linearLayout;
|
||||
|
||||
public BottomSheetCell(Context context) {
|
||||
super(context);
|
||||
|
||||
background = new View(context);
|
||||
background.setBackground(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(4), Theme.getColor(Theme.key_featuredStickers_addButton), Theme.getColor(Theme.key_featuredStickers_addButtonPressed)));
|
||||
addView(background, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0, 16, 16, 16, 16));
|
||||
|
||||
textView = new TextView(context);
|
||||
textView.setLines(1);
|
||||
textView.setSingleLine(true);
|
||||
textView.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
textView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
textView.setGravity(Gravity.CENTER);
|
||||
textView.setTextColor(Theme.getColor(Theme.key_featuredStickers_buttonText));
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(80), MeasureSpec.EXACTLY));
|
||||
}
|
||||
|
||||
public void setText(CharSequence text) {
|
||||
textView.setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
public GigagroupConvertAlert(final Context context, BaseFragment parentFragment) {
|
||||
super(context, true);
|
||||
setApplyBottomPadding(false);
|
||||
setApplyTopPadding(false);
|
||||
|
||||
LinearLayout linearLayout = new LinearLayout(context);
|
||||
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
setCustomView(linearLayout);
|
||||
|
||||
RLottieImageView lottieImageView = new RLottieImageView(context);
|
||||
lottieImageView.setAutoRepeat(true);
|
||||
lottieImageView.setAnimation(R.raw.utyan_gigagroup, 120, 120);
|
||||
lottieImageView.playAnimation();
|
||||
linearLayout.addView(lottieImageView, LayoutHelper.createLinear(160, 160, Gravity.CENTER_HORIZONTAL | Gravity.TOP, 17, 30, 17, 0));
|
||||
|
||||
TextView percentTextView = new TextView(context);
|
||||
percentTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
percentTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 24);
|
||||
percentTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
|
||||
percentTextView.setText(LocaleController.getString("GigagroupConvertTitle", R.string.GigagroupConvertTitle));
|
||||
linearLayout.addView(percentTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 17, 18, 17, 0));
|
||||
|
||||
LinearLayout container = new LinearLayout(context);
|
||||
container.setOrientation(LinearLayout.VERTICAL);
|
||||
linearLayout.addView(container, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL, 0, 12, 0, 0));
|
||||
|
||||
for (int a = 0; a < 3; a++) {
|
||||
LinearLayout linearLayout2 = new LinearLayout(context);
|
||||
linearLayout2.setOrientation(LinearLayout.HORIZONTAL);
|
||||
container.addView(linearLayout2, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 0, 8, 0, 0));
|
||||
|
||||
ImageView imageView = new ImageView(context);
|
||||
imageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogTextGray3), PorterDuff.Mode.MULTIPLY));
|
||||
imageView.setImageResource(R.drawable.list_circle);
|
||||
|
||||
TextView textView = new TextView(context);
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
|
||||
textView.setTextColor(Theme.getColor(Theme.key_dialogTextGray3));
|
||||
textView.setGravity(Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
|
||||
textView.setMaxWidth(AndroidUtilities.dp(260));
|
||||
|
||||
switch (a) {
|
||||
case 0:
|
||||
textView.setText(LocaleController.getString("GigagroupConvertInfo1", R.string.GigagroupConvertInfo1));
|
||||
break;
|
||||
case 1:
|
||||
textView.setText(LocaleController.getString("GigagroupConvertInfo2", R.string.GigagroupConvertInfo2));
|
||||
break;
|
||||
case 2:
|
||||
textView.setText(LocaleController.getString("GigagroupConvertInfo3", R.string.GigagroupConvertInfo3));
|
||||
break;
|
||||
}
|
||||
|
||||
if (LocaleController.isRTL) {
|
||||
linearLayout2.addView(textView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
|
||||
linearLayout2.addView(imageView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, 8, 7, 0, 0));
|
||||
} else {
|
||||
linearLayout2.addView(imageView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, 0, 8, 8, 0));
|
||||
linearLayout2.addView(textView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
|
||||
}
|
||||
}
|
||||
|
||||
BottomSheetCell clearButton = new BottomSheetCell(context);
|
||||
clearButton.setBackground(null);
|
||||
clearButton.setText(LocaleController.getString("GigagroupConvertProcessButton", R.string.GigagroupConvertProcessButton));
|
||||
clearButton.background.setOnClickListener(v -> {
|
||||
dismiss();
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(LocaleController.getString("GigagroupConvertAlertTitle", R.string.GigagroupConvertAlertTitle));
|
||||
builder.setMessage(AndroidUtilities.replaceTags(LocaleController.getString("GigagroupConvertAlertText", R.string.GigagroupConvertAlertText)));
|
||||
builder.setPositiveButton(LocaleController.getString("GigagroupConvertAlertConver", R.string.GigagroupConvertAlertConver), (dialogInterface, i) -> onCovert());
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
parentFragment.showDialog(builder.create());
|
||||
});
|
||||
linearLayout.addView(clearButton, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 50, Gravity.LEFT | Gravity.TOP, 0, 29, 0, 0));
|
||||
|
||||
TextView cancelTextView = new TextView(context);
|
||||
cancelTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
cancelTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlue2));
|
||||
cancelTextView.setText(LocaleController.getString("GigagroupConvertCancelButton", R.string.GigagroupConvertCancelButton));
|
||||
cancelTextView.setGravity(Gravity.CENTER);
|
||||
linearLayout.addView(cancelTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 48, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 17, 0, 17, 16));
|
||||
cancelTextView.setOnClickListener(v -> {
|
||||
onCancel();
|
||||
dismiss();
|
||||
});
|
||||
}
|
||||
|
||||
protected void onCovert() {
|
||||
|
||||
}
|
||||
|
||||
protected void onCancel() {
|
||||
|
||||
}
|
||||
}
|
|
@ -8,38 +8,15 @@
|
|||
|
||||
package org.telegram.ui.Components;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.text.Editable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.util.Property;
|
||||
import android.util.SparseArray;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ChatObject;
|
||||
|
@ -53,12 +30,9 @@ import org.telegram.messenger.Utilities;
|
|||
import org.telegram.tgnet.ConnectionsManager;
|
||||
import org.telegram.tgnet.TLObject;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.BottomSheet;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Adapters.SearchAdapterHelper;
|
||||
import org.telegram.ui.Cells.GraySectionCell;
|
||||
import org.telegram.ui.Cells.GroupCallTextCell;
|
||||
import org.telegram.ui.Cells.GroupCallUserCell;
|
||||
import org.telegram.ui.Cells.ManageChatTextCell;
|
||||
import org.telegram.ui.Cells.ManageChatUserCell;
|
||||
import org.telegram.ui.ChatUsersActivity;
|
||||
|
@ -67,7 +41,6 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class GroupVoipInviteAlert extends UsersAlertBase {
|
||||
|
@ -366,7 +339,13 @@ public class GroupVoipInviteAlert extends UsersAlertBase {
|
|||
if (delayResults <= 0) {
|
||||
loadingUsers = false;
|
||||
firstLoaded = true;
|
||||
showItemsAnimated(listViewAdapter != null ? listViewAdapter.getItemCount() - 1 : 0);
|
||||
int num;
|
||||
if (flickerProgressRow == 1) {
|
||||
num = 1;
|
||||
} else {
|
||||
num = listViewAdapter != null ? listViewAdapter.getItemCount() - 1 : 0;
|
||||
}
|
||||
showItemsAnimated(num);
|
||||
}
|
||||
updateRows();
|
||||
if (listViewAdapter != null) {
|
||||
|
|
|
@ -62,7 +62,13 @@ public class HintView extends FrameLayout {
|
|||
textView.setTextColor(Theme.getColor(Theme.key_chat_gifSaveHintText));
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
textView.setMaxLines(2);
|
||||
textView.setMaxWidth(AndroidUtilities.dp(type == 4 ? 280 : 250));
|
||||
if (type == 7) {
|
||||
textView.setMaxWidth(AndroidUtilities.dp(310));
|
||||
} else if (type == 4) {
|
||||
textView.setMaxWidth(AndroidUtilities.dp(280));
|
||||
} else {
|
||||
textView.setMaxWidth(AndroidUtilities.dp(250));
|
||||
}
|
||||
if (currentType == TYPE_SEARCH_AS_LIST) {
|
||||
textView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
|
||||
textView.setBackground(Theme.createRoundRectDrawable(AndroidUtilities.dp(5), Theme.getColor(Theme.key_chat_gifSaveHintBackground)));
|
||||
|
@ -70,11 +76,13 @@ public class HintView extends FrameLayout {
|
|||
addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 30, Gravity.LEFT | Gravity.TOP, 0, topArrow ? 6 : 0, 0, topArrow ? 0 : 6));
|
||||
} else {
|
||||
textView.setGravity(Gravity.LEFT | Gravity.TOP);
|
||||
textView.setBackground(Theme.createRoundRectDrawable(AndroidUtilities.dp(3), Theme.getColor(Theme.key_chat_gifSaveHintBackground)));
|
||||
textView.setBackground(Theme.createRoundRectDrawable(AndroidUtilities.dp(currentType == 7 ? 6 : 3), Theme.getColor(Theme.key_chat_gifSaveHintBackground)));
|
||||
if (currentType == TYPE_POLL_VOTE || currentType == 4) {
|
||||
textView.setPadding(AndroidUtilities.dp(9), AndroidUtilities.dp(6), AndroidUtilities.dp(9), AndroidUtilities.dp(7));
|
||||
} else if (currentType == 2) {
|
||||
textView.setPadding(AndroidUtilities.dp(7), AndroidUtilities.dp(6), AndroidUtilities.dp(7), AndroidUtilities.dp(7));
|
||||
} else if (currentType == 7) {
|
||||
textView.setPadding(AndroidUtilities.dp(8), AndroidUtilities.dp(7), AndroidUtilities.dp(8), AndroidUtilities.dp(8));
|
||||
} else {
|
||||
textView.setPadding(AndroidUtilities.dp(currentType == 0 ? 54 : 5), AndroidUtilities.dp(6), AndroidUtilities.dp(5), AndroidUtilities.dp(7));
|
||||
}
|
||||
|
@ -281,15 +289,18 @@ public class HintView extends FrameLayout {
|
|||
top += AndroidUtilities.dp(4);
|
||||
} else if (currentType == 6) {
|
||||
top += view.getMeasuredHeight() + getMeasuredHeight() + AndroidUtilities.dp(10);
|
||||
} else if (currentType == 7) {
|
||||
top += view.getMeasuredHeight() + getMeasuredHeight() + AndroidUtilities.dp(8);
|
||||
}
|
||||
|
||||
int centerX;
|
||||
if (currentType == TYPE_SEARCH_AS_LIST) {
|
||||
if (view instanceof SimpleTextView) {
|
||||
centerX = position[0] + ((SimpleTextView) view).getTextWidth() / 2;
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
// if (view instanceof SimpleTextView) {
|
||||
// centerX = position[0] + ((SimpleTextView) view).getTextWidth() / 2;
|
||||
// } else {
|
||||
// throw new IllegalArgumentException();
|
||||
// }
|
||||
centerX = position[0];
|
||||
} else {
|
||||
centerX = position[0] + view.getMeasuredWidth() / 2;
|
||||
}
|
||||
|
@ -302,7 +313,7 @@ public class HintView extends FrameLayout {
|
|||
top -= bottomOffset;
|
||||
|
||||
int parentWidth = parentView.getMeasuredWidth();
|
||||
if (isTopArrow && currentType != 6) {
|
||||
if (isTopArrow && currentType != 6 && currentType != 7) {
|
||||
setTranslationY(extraTranslationY + (translationY = AndroidUtilities.dp(44)));
|
||||
} else {
|
||||
setTranslationY(extraTranslationY + (translationY = top - getMeasuredHeight()));
|
||||
|
@ -330,6 +341,9 @@ public class HintView extends FrameLayout {
|
|||
}
|
||||
setTranslationX(offset);
|
||||
float arrowX = centerX - (leftMargin + offset) - arrowImageView.getMeasuredWidth() / 2;
|
||||
if (currentType == 7) {
|
||||
arrowX += AndroidUtilities.dp(2);
|
||||
}
|
||||
arrowImageView.setTranslationX(arrowX);
|
||||
if (centerX > parentView.getMeasuredWidth() / 2) {
|
||||
if (arrowX < AndroidUtilities.dp(10)) {
|
||||
|
|
|
@ -28,11 +28,11 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.MessagesStorage;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.tgnet.ConnectionsManager;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.AlertDialog;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.BottomSheet;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
|
@ -40,11 +40,13 @@ import org.telegram.ui.Cells.HeaderCell;
|
|||
import org.telegram.ui.Cells.ShadowSectionCell;
|
||||
import org.telegram.ui.Cells.TextInfoPrivacyCell;
|
||||
import org.telegram.ui.Cells.UserCell;
|
||||
import org.telegram.ui.LinkEditActivity;
|
||||
import org.telegram.ui.ManageLinksActivity;
|
||||
import org.telegram.ui.ProfileActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
|
||||
public class InviteLinkBottomSheet extends BottomSheet {
|
||||
|
||||
|
@ -64,6 +66,7 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
int loadingRow;
|
||||
int emptyView;
|
||||
int emptyView2;
|
||||
int emptyHintRow;
|
||||
|
||||
boolean usersLoading;
|
||||
boolean hasMore;
|
||||
|
@ -80,12 +83,15 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
private int scrollOffsetY;
|
||||
private boolean ignoreLayout;
|
||||
private boolean permanent;
|
||||
private boolean titleVisible;
|
||||
|
||||
ArrayList<TLRPC.TL_chatInviteImporter> invitedUsers = new ArrayList<>();
|
||||
|
||||
private int chatId;
|
||||
private boolean isChannel;
|
||||
private final long timeDif;
|
||||
|
||||
public InviteLinkBottomSheet(Context context, TLRPC.TL_chatInviteExported invite, TLRPC.ChatFull info, HashMap<Integer, TLRPC.User> users, BaseFragment fragment, int chatId, boolean permanent) {
|
||||
public InviteLinkBottomSheet(Context context, TLRPC.TL_chatInviteExported invite, TLRPC.ChatFull info, HashMap<Integer, TLRPC.User> users, BaseFragment fragment, int chatId, boolean permanent, boolean isChannel) {
|
||||
super(context, false);
|
||||
this.invite = invite;
|
||||
this.users = users;
|
||||
|
@ -93,6 +99,13 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
this.info = info;
|
||||
this.chatId = chatId;
|
||||
this.permanent = permanent;
|
||||
this.isChannel = isChannel;
|
||||
|
||||
if (this.users == null) {
|
||||
this.users = new HashMap<>();
|
||||
}
|
||||
|
||||
timeDif = ConnectionsManager.getInstance(currentAccount).getCurrentTime() - (System.currentTimeMillis() / 1000L);
|
||||
|
||||
containerView = new FrameLayout(context) {
|
||||
|
||||
|
@ -192,6 +205,7 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
listView = new RecyclerListView(context) {
|
||||
|
||||
int lastH;
|
||||
|
||||
@Override
|
||||
public void requestLayout() {
|
||||
if (ignoreLayout) {
|
||||
|
@ -247,6 +261,9 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
listView.setOnItemClickListener(new RecyclerListView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(View view, int position) {
|
||||
if (position == creatorRow && invite.admin_id == UserConfig.getInstance(currentAccount).clientUserId) {
|
||||
return;
|
||||
}
|
||||
if (position == creatorRow || (position >= usersStartRow && position < usersEndRow)) {
|
||||
TLRPC.User user;
|
||||
if (position == creatorRow) {
|
||||
|
@ -266,24 +283,31 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
}
|
||||
}
|
||||
});
|
||||
containerView.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, permanent ? 0 : 48, 0, 0));
|
||||
|
||||
titleTextView = new TextView(context);
|
||||
titleTextView.setLines(1);
|
||||
titleTextView.setSingleLine(true);
|
||||
titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
|
||||
titleTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
titleTextView.setPadding(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(18), 0);
|
||||
titleTextView.setGravity(Gravity.CENTER_VERTICAL);
|
||||
titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
if (!permanent) {
|
||||
titleTextView = new TextView(context);
|
||||
titleTextView.setLines(1);
|
||||
titleTextView.setSingleLine(true);
|
||||
titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
|
||||
titleTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
titleTextView.setPadding(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(18), 0);
|
||||
titleTextView.setGravity(Gravity.CENTER_VERTICAL);
|
||||
titleTextView.setText(invite.revoked ? LocaleController.getString("RevokedLink", R.string.RevokedLink) : LocaleController.getString("InviteLink", R.string.InviteLink));
|
||||
titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
containerView.addView(titleTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 50, Gravity.LEFT | Gravity.TOP, 0, 0, 40, 0));
|
||||
titleVisible = true;
|
||||
} else {
|
||||
titleTextView.setText(LocaleController.getString("InviteLink", R.string.InviteLink));
|
||||
titleVisible = false;
|
||||
titleTextView.setVisibility(View.INVISIBLE);
|
||||
titleTextView.setAlpha(0f);
|
||||
}
|
||||
|
||||
containerView.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, !titleVisible ? 0 : 48, 0, 0));
|
||||
containerView.addView(titleTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, !titleVisible ? 48 : 50, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0));
|
||||
|
||||
updateRows();
|
||||
loadUsers();
|
||||
if (users.get(invite.admin_id) == null) {
|
||||
if (users == null || users.get(invite.admin_id) == null) {
|
||||
loadCreator();
|
||||
}
|
||||
|
||||
|
@ -295,6 +319,9 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
titleTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
|
||||
titleTextView.setLinkTextColor(Theme.getColor(Theme.key_dialogTextLink));
|
||||
titleTextView.setHighlightColor(Theme.getColor(Theme.key_dialogLinkSelection));
|
||||
if (!titleVisible) {
|
||||
titleTextView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
||||
}
|
||||
}
|
||||
listView.setGlowColor(Theme.getColor(Theme.key_dialogScrollGlow));
|
||||
shadow.setBackgroundColor(Theme.getColor(Theme.key_dialogShadowLine));
|
||||
|
@ -323,7 +350,7 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
private void updateColorForView(View view) {
|
||||
if (view instanceof HeaderCell) {
|
||||
((HeaderCell) view).getTextView().setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueHeader));
|
||||
} else if (view instanceof LinkActionView){
|
||||
} else if (view instanceof LinkActionView) {
|
||||
((LinkActionView) view).updateColors();
|
||||
} else if (view instanceof TextInfoPrivacyCell) {
|
||||
CombinedDrawable combinedDrawable = new CombinedDrawable(new ColorDrawable(Theme.getColor(Theme.key_windowBackgroundGray)), Theme.getThemedDrawable(view.getContext(), R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
|
||||
|
@ -334,7 +361,7 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
((UserCell) view).update(0);
|
||||
}
|
||||
RecyclerView.ViewHolder holder = listView.getChildViewHolder(view);
|
||||
if (holder != null){
|
||||
if (holder != null) {
|
||||
if (holder.getItemViewType() == 7) {
|
||||
Drawable shadowDrawable = Theme.getThemedDrawable(view.getContext(), R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow);
|
||||
Drawable background = new ColorDrawable(Theme.getColor(Theme.key_windowBackgroundGray));
|
||||
|
@ -366,7 +393,6 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -385,7 +411,7 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
emptyView2 = -1;
|
||||
linkActionRow = -1;
|
||||
linkInfoRow = -1;
|
||||
|
||||
emptyHintRow = -1;
|
||||
|
||||
if (!permanent) {
|
||||
linkActionRow = rowCount++;
|
||||
|
@ -395,19 +421,24 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
creatorRow = rowCount++;
|
||||
emptyView = rowCount++;
|
||||
|
||||
if (invite.usage > 0) {
|
||||
if (!(invite.usage == 0 && invite.usage_limit == 0)) {
|
||||
dividerRow = rowCount++;
|
||||
usersHeaderRow = rowCount++;
|
||||
if (!invitedUsers.isEmpty()) {
|
||||
usersStartRow = rowCount;
|
||||
rowCount += invitedUsers.size();
|
||||
usersEndRow = rowCount;
|
||||
} else {
|
||||
emptyView2 = rowCount++;
|
||||
} else if (invite.usage > 0) {
|
||||
loadingRow = rowCount++;
|
||||
emptyView2 = rowCount++;
|
||||
} else {
|
||||
emptyHintRow = rowCount++;
|
||||
}
|
||||
emptyView2 = rowCount++;
|
||||
}
|
||||
divider2Row = rowCount++;
|
||||
if (emptyHintRow == -1) {
|
||||
divider2Row = rowCount++;
|
||||
}
|
||||
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
@ -432,6 +463,8 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
return 6;
|
||||
} else if (position == divider2Row) {
|
||||
return 7;
|
||||
} else if (position == emptyHintRow) {
|
||||
return 8;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -444,7 +477,11 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
switch (viewType) {
|
||||
default:
|
||||
case 0:
|
||||
view = new HeaderCell(context);
|
||||
HeaderCell headerCell = new HeaderCell(context, Theme.key_windowBackgroundWhiteBlueHeader, 21, 15, true);
|
||||
headerCell.getTextView2().setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText));
|
||||
headerCell.getTextView2().setTextSize(15);
|
||||
headerCell.getTextView2().setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
view = headerCell;
|
||||
break;
|
||||
case 1:
|
||||
view = new UserCell(context, 12, 0, true);
|
||||
|
@ -453,13 +490,36 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
view = new ShadowSectionCell(context, 12, Theme.getColor(Theme.key_windowBackgroundGray));
|
||||
break;
|
||||
case 3:
|
||||
LinkActionView linkActionView = new LinkActionView(context, fragment, InviteLinkBottomSheet.this, chatId, false);
|
||||
LinkActionView linkActionView = new LinkActionView(context, fragment, InviteLinkBottomSheet.this, chatId, false, isChannel);
|
||||
view = linkActionView;
|
||||
linkActionView.setDelegate(new LinkActionView.Delegate() {
|
||||
@Override
|
||||
public void revokeLink() {
|
||||
if (fragment instanceof ManageLinksActivity) {
|
||||
((ManageLinksActivity) fragment).revokeLink(invite);
|
||||
} else {
|
||||
TLRPC.TL_messages_editExportedChatInvite req = new TLRPC.TL_messages_editExportedChatInvite();
|
||||
req.link = invite.link;
|
||||
req.revoked = true;
|
||||
req.peer = MessagesController.getInstance(currentAccount).getInputPeer(-chatId);
|
||||
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
if (error == null) {
|
||||
if (response instanceof TLRPC.TL_messages_exportedChatInviteReplaced) {
|
||||
TLRPC.TL_messages_exportedChatInviteReplaced replaced = (TLRPC.TL_messages_exportedChatInviteReplaced) response;
|
||||
if (info != null) {
|
||||
info.exported_invite = (TLRPC.TL_chatInviteExported) replaced.new_invite;
|
||||
}
|
||||
} else {
|
||||
if (info != null) {
|
||||
info.invitesCount--;
|
||||
if (info.invitesCount < 0) {
|
||||
info.invitesCount = 0;
|
||||
}
|
||||
MessagesStorage.getInstance(currentAccount).saveChatLinksCount(chatId, info.invitesCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
|
@ -468,6 +528,10 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
public void editLink() {
|
||||
if (fragment instanceof ManageLinksActivity) {
|
||||
((ManageLinksActivity) fragment).editLink(invite);
|
||||
} else {
|
||||
LinkEditActivity activity = new LinkEditActivity(LinkEditActivity.EDIT_TYPE, chatId);
|
||||
activity.setInviteToEdit(invite);
|
||||
fragment.presentFragment(activity);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
|
@ -476,6 +540,15 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
public void removeLink() {
|
||||
if (fragment instanceof ManageLinksActivity) {
|
||||
((ManageLinksActivity) fragment).deleteLink(invite);
|
||||
} else {
|
||||
TLRPC.TL_messages_deleteExportedChatInvite req = new TLRPC.TL_messages_deleteExportedChatInvite();
|
||||
req.link = invite.link;
|
||||
req.peer = MessagesController.getInstance(currentAccount).getInputPeer(-chatId);
|
||||
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
if (error == null) {
|
||||
|
||||
}
|
||||
}));
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
|
@ -483,7 +556,7 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
view.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
break;
|
||||
case 4:
|
||||
view = new TextInfoPrivacyCell(context);
|
||||
view = new TimerPrivacyCell(context);
|
||||
CombinedDrawable combinedDrawable = new CombinedDrawable(new ColorDrawable(Theme.getColor(Theme.key_windowBackgroundGray)), Theme.getThemedDrawable(context, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
|
||||
combinedDrawable.setFullsize(true);
|
||||
view.setBackground(combinedDrawable);
|
||||
|
@ -511,6 +584,9 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
combinedDrawable.setFullsize(true);
|
||||
view.setBackgroundDrawable(combinedDrawable);
|
||||
break;
|
||||
case 8:
|
||||
view = new EmptyHintRow(context);
|
||||
break;
|
||||
}
|
||||
view.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
return new RecyclerListView.Holder(view);
|
||||
|
@ -523,8 +599,18 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
HeaderCell headerCell = (HeaderCell) holder.itemView;
|
||||
if (position == creatorHeaderRow) {
|
||||
headerCell.setText(LocaleController.getString("LinkCreatedeBy", R.string.LinkCreatedeBy));
|
||||
headerCell.setText2(null);
|
||||
} else if (position == usersHeaderRow) {
|
||||
headerCell.setText(LocaleController.formatPluralString("PeopleJoined", invite.usage));
|
||||
if (invite.usage > 0) {
|
||||
headerCell.setText(LocaleController.formatPluralString("PeopleJoined", invite.usage));
|
||||
} else {
|
||||
headerCell.setText(LocaleController.getString("NoOneJoined", R.string.NoOneJoined));
|
||||
}
|
||||
if (!invite.expired && !invite.revoked && invite.usage_limit > 0 && invite.usage > 0) {
|
||||
headerCell.setText2(LocaleController.formatPluralString("PeopleJoinedRemaining", invite.usage_limit - invite.usage));
|
||||
} else {
|
||||
headerCell.setText2(null);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
|
@ -534,10 +620,13 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
String status = null;
|
||||
if (position == creatorRow) {
|
||||
user = users.get(invite.admin_id);
|
||||
if (user == null) {
|
||||
user = MessagesController.getInstance(currentAccount).getUser(invite.admin_id);
|
||||
}
|
||||
if (user != null) {
|
||||
status = LocaleController.formatDateAudio(invite.date, false);
|
||||
}
|
||||
if (info != null && user != null) {
|
||||
if (info != null && user != null && info.participants != null) {
|
||||
for (int i = 0; i < info.participants.participants.size(); i++) {
|
||||
if (info.participants.participants.get(i).user_id == user.id) {
|
||||
TLRPC.ChatParticipant part = info.participants.participants.get(i);
|
||||
|
@ -567,7 +656,6 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
TLRPC.TL_chatInviteImporter invitedUser = invitedUsers.get(position - usersStartRow);
|
||||
|
@ -581,19 +669,59 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
actionView.setUsers(0, null);
|
||||
actionView.setLink(invite.link);
|
||||
actionView.setRevoke(invite.revoked);
|
||||
actionView.setPermanent(invite.permanent);
|
||||
break;
|
||||
case 4:
|
||||
TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
|
||||
TimerPrivacyCell privacyCell = (TimerPrivacyCell) holder.itemView;
|
||||
privacyCell.cancelTimer();
|
||||
privacyCell.timer = false;
|
||||
privacyCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText4));
|
||||
privacyCell.setFixedSize(0);
|
||||
if (invite.revoked) {
|
||||
privacyCell.setText(LocaleController.getString("LinkIsNoActive", R.string.LinkIsNoActive));
|
||||
} else if (invite.expired) {
|
||||
privacyCell.setText(LocaleController.getString("LinkIsExpired", R.string.LinkIsExpired));
|
||||
if (invite.usage_limit > 0 && invite.usage_limit == invite.usage) {
|
||||
privacyCell.setText(LocaleController.getString("LinkIsExpiredLimitReached", R.string.LinkIsExpiredLimitReached));
|
||||
} else {
|
||||
privacyCell.setText(LocaleController.getString("LinkIsExpired", R.string.LinkIsExpired));
|
||||
privacyCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText));
|
||||
}
|
||||
|
||||
} else if (invite.expire_date > 0) {
|
||||
privacyCell.setText(LocaleController.formatString("LinkExpiresIn", R.string.LinkExpiresIn, LocaleController.formatDateAudio(invite.expire_date, false)));
|
||||
long currentTime = System.currentTimeMillis() + timeDif * 1000L;
|
||||
long expireTime = invite.expire_date * 1000L;
|
||||
|
||||
long timeLeft = expireTime - currentTime;
|
||||
if (timeLeft < 0) {
|
||||
timeLeft = 0;
|
||||
}
|
||||
String time;
|
||||
if (timeLeft > 86400000L) {
|
||||
time = LocaleController.formatDateAudio(invite.expire_date, false);
|
||||
privacyCell.setText(LocaleController.formatString("LinkExpiresIn", R.string.LinkExpiresIn, time));
|
||||
} else {
|
||||
int s = (int) ((timeLeft / 1000) % 60);
|
||||
int m = (int) ((timeLeft / 1000 / 60) % 60);
|
||||
int h = (int) ((timeLeft / 1000 / 60 / 60));
|
||||
time = String.format(Locale.ENGLISH, "%02d", h) + String.format(Locale.ENGLISH, ":%02d", m) + String.format(Locale.ENGLISH, ":%02d", s);
|
||||
privacyCell.timer = true;
|
||||
privacyCell.runTimer();
|
||||
privacyCell.setText(LocaleController.formatString("LinkExpiresInTime", R.string.LinkExpiresInTime, time));
|
||||
}
|
||||
} else {
|
||||
privacyCell.setFixedSize(12);
|
||||
privacyCell.setText(null);
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
EmptyHintRow emptyHintRow = (EmptyHintRow) holder.itemView;
|
||||
if (invite.usage_limit > 0) {
|
||||
emptyHintRow.textView.setText(LocaleController.formatPluralString("PeopleCanJoinViaLink", invite.usage_limit));
|
||||
emptyHintRow.textView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
emptyHintRow.textView.setVisibility(View.GONE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -605,7 +733,12 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
@Override
|
||||
public boolean isEnabled(RecyclerView.ViewHolder holder) {
|
||||
int position = holder.getAdapterPosition();
|
||||
if (position == creatorRow || (position >= usersStartRow && position < usersEndRow)) {
|
||||
if (position == creatorRow) {
|
||||
if (invite.admin_id == UserConfig.getInstance(currentAccount).clientUserId) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else if (position >= usersStartRow && position < usersEndRow) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -645,12 +778,16 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
shadow.setTag(show ? null : 1);
|
||||
if (show) {
|
||||
shadow.setVisibility(View.VISIBLE);
|
||||
titleTextView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (shadowAnimation != null) {
|
||||
shadowAnimation.cancel();
|
||||
}
|
||||
shadowAnimation = new AnimatorSet();
|
||||
shadowAnimation.playTogether(ObjectAnimator.ofFloat(shadow, View.ALPHA, show ? 1.0f : 0.0f));
|
||||
if (!titleVisible) {
|
||||
shadowAnimation.playTogether(ObjectAnimator.ofFloat(titleTextView, View.ALPHA, show ? 1.0f : 0.0f));
|
||||
}
|
||||
shadowAnimation.setDuration(150);
|
||||
shadowAnimation.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
|
@ -658,6 +795,7 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
if (shadowAnimation != null && shadowAnimation.equals(animation)) {
|
||||
if (!show) {
|
||||
shadow.setVisibility(View.INVISIBLE);
|
||||
titleTextView.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
shadowAnimation = null;
|
||||
}
|
||||
|
@ -707,4 +845,67 @@ public class InviteLinkBottomSheet extends BottomSheet {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
private class TimerPrivacyCell extends TextInfoPrivacyCell {
|
||||
|
||||
Runnable timerRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (listView != null && listView.getAdapter() != null) {
|
||||
int p = listView.getChildAdapterPosition(TimerPrivacyCell.this);
|
||||
if (p >= 0)
|
||||
adapter.onBindViewHolder(listView.getChildViewHolder(TimerPrivacyCell.this), p);
|
||||
}
|
||||
AndroidUtilities.runOnUIThread(this);
|
||||
}
|
||||
};
|
||||
|
||||
boolean timer;
|
||||
|
||||
public TimerPrivacyCell(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
runTimer();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
cancelTimer();
|
||||
}
|
||||
|
||||
public void cancelTimer() {
|
||||
AndroidUtilities.cancelRunOnUIThread(timerRunnable);
|
||||
}
|
||||
|
||||
public void runTimer() {
|
||||
cancelTimer();
|
||||
if (timer) {
|
||||
AndroidUtilities.runOnUIThread(timerRunnable, 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class EmptyHintRow extends FrameLayout {
|
||||
|
||||
TextView textView;
|
||||
|
||||
public EmptyHintRow(@NonNull Context context) {
|
||||
super(context);
|
||||
textView = new TextView(context);
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText));
|
||||
textView.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, 60, 0, 60, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(84), MeasureSpec.EXACTLY));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ import android.view.ViewConfiguration;
|
|||
import android.view.ViewGroup;
|
||||
import android.view.ViewOutlineProvider;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -38,12 +37,11 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.ChatObject;
|
||||
import org.telegram.messenger.ContactsController;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserObject;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.tgnet.ConnectionsManager;
|
||||
import org.telegram.tgnet.TLObject;
|
||||
|
@ -52,7 +50,6 @@ import org.telegram.ui.ActionBar.AlertDialog;
|
|||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Adapters.SearchAdapterHelper;
|
||||
import org.telegram.ui.Cells.CheckBoxCell;
|
||||
import org.telegram.ui.Cells.GroupCreateSectionCell;
|
||||
import org.telegram.ui.Cells.GroupCreateUserCell;
|
||||
import org.telegram.ui.Cells.ManageChatTextCell;
|
||||
|
@ -62,12 +59,12 @@ import org.telegram.ui.LaunchActivity;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class InviteMembersBottomSheet extends UsersAlertBase {
|
||||
public class InviteMembersBottomSheet extends UsersAlertBase implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
||||
private SparseArray<TLObject> ignoreUsers;
|
||||
private final SpansContainer spansContainer;
|
||||
private final ScrollView spansScrollView;
|
||||
SearchAdapter searchAdapter;
|
||||
private SearchAdapter searchAdapter;
|
||||
|
||||
private int emptyRow;
|
||||
private int copyLinkRow;
|
||||
|
@ -82,21 +79,22 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
|
||||
private ArrayList<TLObject> contacts = new ArrayList<>();
|
||||
private SparseArray<GroupCreateSpan> selectedContacts = new SparseArray<>();
|
||||
private ArrayList<GroupCreateSpan> allSpans = new ArrayList<>();
|
||||
|
||||
boolean spanEnter;
|
||||
float spansEnterProgress = 0;
|
||||
private boolean spanEnter;
|
||||
private float spansEnterProgress = 0;
|
||||
private ValueAnimator spansEnterAnimator;
|
||||
private GroupCreateSpan currentDeletingSpan;
|
||||
int scrollViewH;
|
||||
private int scrollViewH;
|
||||
private GroupCreateActivity.ContactsAddActivityDelegate delegate;
|
||||
private InviteMembersBottomSheetDelegate dialogsDelegate;
|
||||
private ArrayList<TLRPC.Dialog> dialogsServerOnly;
|
||||
|
||||
int additionalHeight;
|
||||
private int additionalHeight;
|
||||
|
||||
float touchSlop;
|
||||
BaseFragment parentFragment;
|
||||
private float touchSlop;
|
||||
private BaseFragment parentFragment;
|
||||
|
||||
View.OnClickListener spanClickListener = new View.OnClickListener() {
|
||||
private View.OnClickListener spanClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
GroupCreateSpan span = (GroupCreateSpan) v;
|
||||
|
@ -104,7 +102,7 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
currentDeletingSpan = null;
|
||||
selectedContacts.remove(span.getUid());
|
||||
spansContainer.removeSpan(span);
|
||||
spansCountChanged();
|
||||
spansCountChanged(true);
|
||||
AndroidUtilities.updateVisibleRows(listView);
|
||||
} else {
|
||||
if (currentDeletingSpan != null) {
|
||||
|
@ -121,6 +119,10 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
private int searchAdditionalHeight;
|
||||
private int chatId;
|
||||
|
||||
public interface InviteMembersBottomSheetDelegate {
|
||||
void didSelectDialogs(ArrayList<Long> dids);
|
||||
}
|
||||
|
||||
public InviteMembersBottomSheet(Context context, int account, SparseArray<TLObject> ignoreUsers, int chatId, BaseFragment parentFragment) {
|
||||
super(context, false, account);
|
||||
this.ignoreUsers = ignoreUsers;
|
||||
|
@ -128,6 +130,8 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
this.parentFragment = parentFragment;
|
||||
this.chatId = chatId;
|
||||
|
||||
searchView.searchEditText.setHint(LocaleController.getString("SearchForChats", R.string.SearchForChats));
|
||||
|
||||
final ViewConfiguration configuration = ViewConfiguration.get(context);
|
||||
touchSlop = configuration.getScaledTouchSlop();
|
||||
|
||||
|
@ -160,6 +164,9 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
} else if (position > localCount + localServerCount && position <= globalCount + localCount + localServerCount) {
|
||||
object = searchAdapter.searchAdapterHelper.getGlobalSearch().get(position - localCount - localServerCount - 1);
|
||||
}
|
||||
if (dialogsDelegate != null) {
|
||||
searchView.closeSearch();
|
||||
}
|
||||
} else {
|
||||
if (position == copyLinkRow) {
|
||||
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(chatId);
|
||||
|
@ -179,11 +186,11 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
android.content.ClipData clip = android.content.ClipData.newPlainText("label", link);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
BulletinFactory.createCopyLinkBulletin(parentFragment).show();
|
||||
dismiss();
|
||||
BulletinFactory.createCopyLinkBulletin(parentFragment).show();
|
||||
|
||||
} else if (position >= contactsStartRow && position < contactsEndRow) {
|
||||
object = contacts.get(position - contactsStartRow);
|
||||
object = ((ListAdapter) listViewAdapter).getObject(position);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,10 +215,10 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
GroupCreateSpan groupCreateSpan = new GroupCreateSpan(context, object);
|
||||
groupCreateSpan.setOnClickListener(spanClickListener);
|
||||
selectedContacts.put(id, groupCreateSpan);
|
||||
spansContainer.addSpan(groupCreateSpan);
|
||||
spansContainer.addSpan(groupCreateSpan, true);
|
||||
}
|
||||
}
|
||||
spansCountChanged();
|
||||
spansCountChanged(true);
|
||||
AndroidUtilities.updateVisibleRows(listView);
|
||||
}
|
||||
});
|
||||
|
@ -232,9 +239,7 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
} else {
|
||||
maxSize = AndroidUtilities.dp(56);
|
||||
}
|
||||
int lastH = getMeasuredHeight();
|
||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(maxSize, MeasureSpec.AT_MOST));
|
||||
|
||||
}
|
||||
};
|
||||
spansScrollView.setVisibility(View.GONE);
|
||||
|
@ -272,67 +277,57 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
}
|
||||
|
||||
floatingButton.setOnClickListener(v -> {
|
||||
if (selectedContacts.size() == 0) {
|
||||
if (dialogsDelegate == null && selectedContacts.size() == 0) {
|
||||
return;
|
||||
}
|
||||
Activity activity = AndroidUtilities.findActivity(context);
|
||||
if (activity == null) {
|
||||
return;
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
if (selectedContacts.size() == 1) {
|
||||
builder.setTitle(LocaleController.getString("AddOneMemberAlertTitle", R.string.AddOneMemberAlertTitle));
|
||||
if (dialogsDelegate != null) {
|
||||
ArrayList<Long> dialogs = new ArrayList<>();
|
||||
for (int a = 0; a < selectedContacts.size(); a++) {
|
||||
int uid = selectedContacts.keyAt(a);
|
||||
dialogs.add((long) uid);
|
||||
}
|
||||
dialogsDelegate.didSelectDialogs(dialogs);
|
||||
dismiss();
|
||||
} else {
|
||||
builder.setTitle(LocaleController.formatString("AddMembersAlertTitle", R.string.AddMembersAlertTitle, LocaleController.formatPluralString("Members", selectedContacts.size())));
|
||||
}
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (int a = 0; a < selectedContacts.size(); a++) {
|
||||
int uid = selectedContacts.keyAt(a);
|
||||
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(uid);
|
||||
if (user == null) {
|
||||
continue;
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
if (selectedContacts.size() == 1) {
|
||||
builder.setTitle(LocaleController.getString("AddOneMemberAlertTitle", R.string.AddOneMemberAlertTitle));
|
||||
} else {
|
||||
builder.setTitle(LocaleController.formatString("AddMembersAlertTitle", R.string.AddMembersAlertTitle, LocaleController.formatPluralString("Members", selectedContacts.size())));
|
||||
}
|
||||
if (stringBuilder.length() > 0) {
|
||||
stringBuilder.append(", ");
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (int a = 0; a < selectedContacts.size(); a++) {
|
||||
int uid = selectedContacts.keyAt(a);
|
||||
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(uid);
|
||||
if (user == null) {
|
||||
continue;
|
||||
}
|
||||
if (stringBuilder.length() > 0) {
|
||||
stringBuilder.append(", ");
|
||||
}
|
||||
stringBuilder.append("**").append(ContactsController.formatName(user.first_name, user.last_name)).append("**");
|
||||
}
|
||||
stringBuilder.append("**").append(ContactsController.formatName(user.first_name, user.last_name)).append("**");
|
||||
}
|
||||
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(chatId);
|
||||
if (selectedContacts.size() > 5) {
|
||||
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(AndroidUtilities.replaceTags(LocaleController.formatString("AddMembersAlertNamesText", R.string.AddMembersAlertNamesText, LocaleController.formatPluralString("Members", selectedContacts.size()), chat.title)));
|
||||
String countString = String.format("%d", selectedContacts.size());
|
||||
int index = TextUtils.indexOf(spannableStringBuilder, countString);
|
||||
if (index >= 0) {
|
||||
spannableStringBuilder.setSpan(new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf")), index, index + countString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(chatId);
|
||||
if (selectedContacts.size() > 5) {
|
||||
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(AndroidUtilities.replaceTags(LocaleController.formatString("AddMembersAlertNamesText", R.string.AddMembersAlertNamesText, LocaleController.formatPluralString("Members", selectedContacts.size()), chat.title)));
|
||||
String countString = String.format("%d", selectedContacts.size());
|
||||
int index = TextUtils.indexOf(spannableStringBuilder, countString);
|
||||
if (index >= 0) {
|
||||
spannableStringBuilder.setSpan(new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf")), index, index + countString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
builder.setMessage(spannableStringBuilder);
|
||||
} else {
|
||||
builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("AddMembersAlertNamesText", R.string.AddMembersAlertNamesText, stringBuilder, chat.title)));
|
||||
}
|
||||
builder.setMessage(spannableStringBuilder);
|
||||
} else {
|
||||
builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("AddMembersAlertNamesText", R.string.AddMembersAlertNamesText, stringBuilder, chat.title)));
|
||||
builder.setPositiveButton(LocaleController.getString("Add", R.string.Add), (dialogInterface, i) -> onAddToGroupDone(0));
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
builder.create();
|
||||
builder.show();
|
||||
}
|
||||
// CheckBoxCell[] cells = new CheckBoxCell[1];
|
||||
// if (!ChatObject.isChannel(chat)) {
|
||||
// LinearLayout linearLayout = new LinearLayout(activity);
|
||||
// linearLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
// cells[0] = new CheckBoxCell(activity, 1);
|
||||
// cells[0].setBackgroundDrawable(Theme.getSelectorDrawable(false));
|
||||
// cells[0].setMultiline(true);
|
||||
// if (selectedContacts.size() == 1) {
|
||||
// TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(selectedContacts.keyAt(0));
|
||||
// cells[0].setText(AndroidUtilities.replaceTags(LocaleController.formatString("AddOneMemberForwardMessages", R.string.AddOneMemberForwardMessages, UserObject.getFirstName(user))), "", true, false);
|
||||
// } else {
|
||||
// cells[0].setText(LocaleController.getString("AddMembersForwardMessages", R.string.AddMembersForwardMessages), "", true, false);
|
||||
// }
|
||||
// cells[0].setPadding(LocaleController.isRTL ? AndroidUtilities.dp(16) : AndroidUtilities.dp(8), 0, LocaleController.isRTL ? AndroidUtilities.dp(8) : AndroidUtilities.dp(16), 0);
|
||||
// linearLayout.addView(cells[0], LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
// cells[0].setOnClickListener(v1 -> cells[0].setChecked(!cells[0].isChecked(), true));
|
||||
//
|
||||
// builder.setCustomViewOffset(12);
|
||||
// builder.setView(linearLayout);
|
||||
// }
|
||||
builder.setPositiveButton(LocaleController.getString("Add", R.string.Add), (dialogInterface, i) -> onAddToGroupDone(0));
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
builder.create();
|
||||
builder.show();
|
||||
});
|
||||
floatingButton.setVisibility(View.INVISIBLE);
|
||||
floatingButton.setScaleX(0.0f);
|
||||
|
@ -359,7 +354,75 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
dismiss();
|
||||
}
|
||||
|
||||
private void spansCountChanged() {
|
||||
@Override
|
||||
public void dismiss() {
|
||||
super.dismiss();
|
||||
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.dialogsNeedReload);
|
||||
}
|
||||
|
||||
public void setSelectedContacts(ArrayList<Long> dialogs) {
|
||||
for (int a = 0, N = dialogs.size(); a < N; a++) {
|
||||
int lowerId = (int) (long) dialogs.get(a);
|
||||
TLObject object;
|
||||
if (lowerId < 0) {
|
||||
object = MessagesController.getInstance(currentAccount).getChat(-lowerId);
|
||||
} else {
|
||||
object = MessagesController.getInstance(currentAccount).getUser(lowerId);
|
||||
}
|
||||
GroupCreateSpan span = new GroupCreateSpan(spansContainer.getContext(), object);
|
||||
spansContainer.addSpan(span, false);
|
||||
span.setOnClickListener(spanClickListener);
|
||||
}
|
||||
spansCountChanged(false);
|
||||
|
||||
int count = spansContainer.getChildCount();
|
||||
|
||||
boolean isPortrait = AndroidUtilities.displaySize.x < AndroidUtilities.displaySize.y;
|
||||
|
||||
if (AndroidUtilities.isTablet() || isPortrait) {
|
||||
maxSize = AndroidUtilities.dp(144);
|
||||
} else {
|
||||
maxSize = AndroidUtilities.dp(56);
|
||||
}
|
||||
|
||||
int width;
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
width = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.8f);
|
||||
} else {
|
||||
width = isPortrait ? AndroidUtilities.displaySize.x : (int) Math.max(AndroidUtilities.displaySize.x * 0.8f, Math.min(AndroidUtilities.dp(480), AndroidUtilities.displaySize.x));
|
||||
}
|
||||
int maxWidth = width - AndroidUtilities.dp(26);
|
||||
int currentLineWidth = 0;
|
||||
int y = AndroidUtilities.dp(10);
|
||||
for (int a = 0; a < count; a++) {
|
||||
View child = spansContainer.getChildAt(a);
|
||||
if (!(child instanceof GroupCreateSpan)) {
|
||||
continue;
|
||||
}
|
||||
child.measure(View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(32), View.MeasureSpec.EXACTLY));
|
||||
if (currentLineWidth + child.getMeasuredWidth() > maxWidth) {
|
||||
y += child.getMeasuredHeight() + AndroidUtilities.dp(8);
|
||||
currentLineWidth = 0;
|
||||
}
|
||||
currentLineWidth += child.getMeasuredWidth() + AndroidUtilities.dp(9);
|
||||
}
|
||||
|
||||
int animateToH = y + AndroidUtilities.dp(32 + 10);
|
||||
|
||||
int newAdditionalH;
|
||||
if (dialogsDelegate != null) {
|
||||
newAdditionalH = spanEnter ? Math.min(maxSize, animateToH) : 0;
|
||||
} else {
|
||||
newAdditionalH = Math.max(0, Math.min(maxSize, animateToH) - AndroidUtilities.dp(52));
|
||||
}
|
||||
int oldSearchAdditionalH = searchAdditionalHeight;
|
||||
searchAdditionalHeight = (selectedContacts.size() > 0 ? AndroidUtilities.dp(56) : 0);
|
||||
if (newAdditionalH != additionalHeight || oldSearchAdditionalH != searchAdditionalHeight) {
|
||||
additionalHeight = newAdditionalH;
|
||||
}
|
||||
}
|
||||
|
||||
private void spansCountChanged(boolean animated) {
|
||||
boolean enter = selectedContacts.size() > 0;
|
||||
if (spanEnter != enter) {
|
||||
if (spansEnterAnimator != null) {
|
||||
|
@ -370,51 +433,73 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
if (spanEnter) {
|
||||
spansScrollView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
spansEnterAnimator = ValueAnimator.ofFloat(spansEnterProgress, enter ? 1f : 0f);
|
||||
spansEnterAnimator.addUpdateListener(valueAnimator1 -> {
|
||||
spansEnterProgress = (float) valueAnimator1.getAnimatedValue();
|
||||
containerView.invalidate();
|
||||
});
|
||||
spansEnterAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
spansEnterProgress = enter ? 1f : 0f;
|
||||
if (animated) {
|
||||
spansEnterAnimator = ValueAnimator.ofFloat(spansEnterProgress, enter ? 1f : 0f);
|
||||
spansEnterAnimator.addUpdateListener(valueAnimator1 -> {
|
||||
spansEnterProgress = (float) valueAnimator1.getAnimatedValue();
|
||||
containerView.invalidate();
|
||||
if (!enter) {
|
||||
spansScrollView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
spansEnterAnimator.setDuration(150);
|
||||
spansEnterAnimator.start();
|
||||
|
||||
if (!spanEnter) {
|
||||
if (currentDoneButtonAnimation != null) {
|
||||
currentDoneButtonAnimation.cancel();
|
||||
}
|
||||
currentDoneButtonAnimation = new AnimatorSet();
|
||||
currentDoneButtonAnimation.playTogether(ObjectAnimator.ofFloat(floatingButton, View.SCALE_X, 0.0f),
|
||||
ObjectAnimator.ofFloat(floatingButton, View.SCALE_Y, 0.0f),
|
||||
ObjectAnimator.ofFloat(floatingButton, View.ALPHA, 0.0f));
|
||||
currentDoneButtonAnimation.addListener(new AnimatorListenerAdapter() {
|
||||
});
|
||||
spansEnterAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
floatingButton.setVisibility(View.INVISIBLE);
|
||||
spansEnterProgress = enter ? 1f : 0f;
|
||||
containerView.invalidate();
|
||||
if (!enter) {
|
||||
spansScrollView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
currentDoneButtonAnimation.setDuration(180);
|
||||
currentDoneButtonAnimation.start();
|
||||
spansEnterAnimator.setDuration(150);
|
||||
spansEnterAnimator.start();
|
||||
|
||||
if (!spanEnter && dialogsDelegate == null) {
|
||||
if (currentDoneButtonAnimation != null) {
|
||||
currentDoneButtonAnimation.cancel();
|
||||
}
|
||||
currentDoneButtonAnimation = new AnimatorSet();
|
||||
currentDoneButtonAnimation.playTogether(ObjectAnimator.ofFloat(floatingButton, View.SCALE_X, 0.0f),
|
||||
ObjectAnimator.ofFloat(floatingButton, View.SCALE_Y, 0.0f),
|
||||
ObjectAnimator.ofFloat(floatingButton, View.ALPHA, 0.0f));
|
||||
currentDoneButtonAnimation.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
floatingButton.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
currentDoneButtonAnimation.setDuration(180);
|
||||
currentDoneButtonAnimation.start();
|
||||
} else {
|
||||
if (currentDoneButtonAnimation != null) {
|
||||
currentDoneButtonAnimation.cancel();
|
||||
}
|
||||
currentDoneButtonAnimation = new AnimatorSet();
|
||||
floatingButton.setVisibility(View.VISIBLE);
|
||||
currentDoneButtonAnimation.playTogether(ObjectAnimator.ofFloat(floatingButton, View.SCALE_X, 1.0f),
|
||||
ObjectAnimator.ofFloat(floatingButton, View.SCALE_Y, 1.0f),
|
||||
ObjectAnimator.ofFloat(floatingButton, View.ALPHA, 1.0f));
|
||||
currentDoneButtonAnimation.setDuration(180);
|
||||
currentDoneButtonAnimation.start();
|
||||
}
|
||||
} else {
|
||||
spansEnterProgress = enter ? 1.0f : 0.0f;
|
||||
containerView.invalidate();
|
||||
if (!enter) {
|
||||
spansScrollView.setVisibility(View.GONE);
|
||||
}
|
||||
if (currentDoneButtonAnimation != null) {
|
||||
currentDoneButtonAnimation.cancel();
|
||||
}
|
||||
currentDoneButtonAnimation = new AnimatorSet();
|
||||
floatingButton.setVisibility(View.VISIBLE);
|
||||
currentDoneButtonAnimation.playTogether(ObjectAnimator.ofFloat(floatingButton, View.SCALE_X, 1.0f),
|
||||
ObjectAnimator.ofFloat(floatingButton, View.SCALE_Y, 1.0f),
|
||||
ObjectAnimator.ofFloat(floatingButton, View.ALPHA, 1.0f));
|
||||
currentDoneButtonAnimation.setDuration(180);
|
||||
currentDoneButtonAnimation.start();
|
||||
if (!spanEnter && dialogsDelegate == null) {
|
||||
floatingButton.setScaleY(0.0f);
|
||||
floatingButton.setScaleX(0.0f);
|
||||
floatingButton.setAlpha(0.0f);
|
||||
floatingButton.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
floatingButton.setScaleY(1.0f);
|
||||
floatingButton.setScaleX(1.0f);
|
||||
floatingButton.setAlpha(1.0f);
|
||||
floatingButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -426,19 +511,39 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
|
||||
rowCount = 0;
|
||||
emptyRow = rowCount++;
|
||||
copyLinkRow = rowCount++;
|
||||
|
||||
if (contacts.size() != 0) {
|
||||
contactsStartRow = rowCount;
|
||||
rowCount += contacts.size();
|
||||
contactsEndRow = rowCount;
|
||||
if (dialogsDelegate == null) {
|
||||
copyLinkRow = rowCount++;
|
||||
if (contacts.size() != 0) {
|
||||
contactsStartRow = rowCount;
|
||||
rowCount += contacts.size();
|
||||
contactsEndRow = rowCount;
|
||||
} else {
|
||||
noContactsStubRow = rowCount++;
|
||||
}
|
||||
} else {
|
||||
noContactsStubRow = rowCount++;
|
||||
copyLinkRow = -1;
|
||||
if (dialogsServerOnly.size() != 0) {
|
||||
contactsStartRow = rowCount;
|
||||
rowCount += dialogsServerOnly.size();
|
||||
contactsEndRow = rowCount;
|
||||
} else {
|
||||
noContactsStubRow = rowCount++;
|
||||
}
|
||||
}
|
||||
|
||||
lastRow = rowCount++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didReceivedNotification(int id, int account, Object... args) {
|
||||
if (id == NotificationCenter.dialogsNeedReload) {
|
||||
if (dialogsDelegate != null && dialogsServerOnly.isEmpty()) {
|
||||
dialogsServerOnly = new ArrayList<>(MessagesController.getInstance(currentAccount).dialogsServerOnly);
|
||||
listViewAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class ListAdapter extends RecyclerListView.SelectionAdapter {
|
||||
|
||||
@NonNull
|
||||
|
@ -463,7 +568,7 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
};
|
||||
break;
|
||||
case 3:
|
||||
view = new GroupCreateUserCell(context, true, 0, false);
|
||||
view = new GroupCreateUserCell(context, true, 0, dialogsDelegate != null);
|
||||
break;
|
||||
case 4:
|
||||
view = new View(context);
|
||||
|
@ -478,7 +583,11 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
};
|
||||
stickerEmptyView.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
stickerEmptyView.subtitle.setVisibility(View.GONE);
|
||||
stickerEmptyView.title.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
|
||||
if (dialogsDelegate != null) {
|
||||
stickerEmptyView.title.setText(LocaleController.getString("FilterNoChats", R.string.FilterNoChats));
|
||||
} else {
|
||||
stickerEmptyView.title.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
|
||||
}
|
||||
stickerEmptyView.setAnimateLayoutChange(true);
|
||||
view = stickerEmptyView;
|
||||
break;
|
||||
|
@ -486,6 +595,20 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
return new RecyclerListView.Holder(view);
|
||||
}
|
||||
|
||||
public TLObject getObject(int position) {
|
||||
if (dialogsDelegate != null) {
|
||||
TLRPC.Dialog dialog = dialogsServerOnly.get(position - contactsStartRow);
|
||||
int lowerId = (int) dialog.id;
|
||||
if (lowerId > 0) {
|
||||
return MessagesController.getInstance(currentAccount).getUser(lowerId);
|
||||
} else {
|
||||
return MessagesController.getInstance(currentAccount).getChat(-lowerId);
|
||||
}
|
||||
} else {
|
||||
return contacts.get(position - contactsStartRow);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
switch (holder.getItemViewType()) {
|
||||
|
@ -494,10 +617,7 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
break;
|
||||
case 3:
|
||||
GroupCreateUserCell cell = (GroupCreateUserCell) holder.itemView;
|
||||
TLObject object;
|
||||
CharSequence username = null;
|
||||
CharSequence name = null;
|
||||
object = contacts.get(position - contactsStartRow);
|
||||
TLObject object = getObject(position);
|
||||
|
||||
Object oldObject = cell.getObject();
|
||||
int oldId;
|
||||
|
@ -509,7 +629,7 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
oldId = 0;
|
||||
}
|
||||
|
||||
cell.setObject(object, name, username, position != contactsEndRow);
|
||||
cell.setObject(object, null, null, position != contactsEndRow);
|
||||
int id;
|
||||
if (object instanceof TLRPC.User) {
|
||||
id = ((TLRPC.User) object).id;
|
||||
|
@ -785,7 +905,7 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
}
|
||||
emptyView.showProgress(true, false);
|
||||
Utilities.searchQueue.postRunnable(searchRunnable = () -> AndroidUtilities.runOnUIThread(() -> {
|
||||
searchAdapterHelper.queryServerSearch(query, true, false, true, false, false, 0, false, 0, 0);
|
||||
searchAdapterHelper.queryServerSearch(query, true, dialogsDelegate != null, true, dialogsDelegate != null, false, 0, false, 0, 0);
|
||||
Utilities.searchQueue.postRunnable(searchRunnable = () -> {
|
||||
String search1 = query.trim().toLowerCase();
|
||||
if (search1.length() == 0) {
|
||||
|
@ -897,7 +1017,6 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
|
||||
private boolean animationStarted;
|
||||
private ArrayList<Animator> animators = new ArrayList<>();
|
||||
private View addingSpan;
|
||||
private View removingSpan;
|
||||
private int animationIndex = -1;
|
||||
boolean addAnimation;
|
||||
|
@ -937,10 +1056,10 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
child.setTranslationY(allY);
|
||||
} else if (removingSpan != null) {
|
||||
if (child.getTranslationX() != x) {
|
||||
animators.add(ObjectAnimator.ofFloat(child, "translationX", x));
|
||||
animators.add(ObjectAnimator.ofFloat(child, View.TRANSLATION_X, x));
|
||||
}
|
||||
if (child.getTranslationY() != y) {
|
||||
animators.add(ObjectAnimator.ofFloat(child, "translationY", y));
|
||||
animators.add(ObjectAnimator.ofFloat(child, View.TRANSLATION_Y, y));
|
||||
}
|
||||
} else {
|
||||
child.setTranslationX(x);
|
||||
|
@ -956,9 +1075,14 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
int h = allY + AndroidUtilities.dp(32 + 10);
|
||||
int animateToH = y + AndroidUtilities.dp(32 + 10);
|
||||
|
||||
int newAdditionalH = Math.max(0, Math.min(maxSize, animateToH) - AndroidUtilities.dp(52));
|
||||
int newAdditionalH;
|
||||
if (dialogsDelegate != null) {
|
||||
newAdditionalH = spanEnter ? Math.min(maxSize, animateToH) : 0;
|
||||
} else {
|
||||
newAdditionalH = Math.max(0, Math.min(maxSize, animateToH) - AndroidUtilities.dp(52));
|
||||
}
|
||||
int oldSearchAdditionalH = searchAdditionalHeight;
|
||||
searchAdditionalHeight = (selectedContacts.size() > 0 ? AndroidUtilities.dp(56) : 0);
|
||||
searchAdditionalHeight = (dialogsDelegate == null && selectedContacts.size() > 0 ? AndroidUtilities.dp(56) : 0);
|
||||
if (newAdditionalH != additionalHeight || oldSearchAdditionalH != searchAdditionalHeight) {
|
||||
additionalHeight = newAdditionalH;
|
||||
if (listView.getAdapter() != null && listView.getAdapter().getItemCount() > 0) {
|
||||
|
@ -1021,9 +1145,8 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
}
|
||||
}
|
||||
|
||||
public void addSpan(final GroupCreateSpan span) {
|
||||
public void addSpan(final GroupCreateSpan span, boolean animated) {
|
||||
addAnimation = true;
|
||||
allSpans.add(span);
|
||||
selectedContacts.put(span.getUid(), span);
|
||||
|
||||
if (currentAnimation != null) {
|
||||
|
@ -1031,22 +1154,22 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
currentAnimation.cancel();
|
||||
}
|
||||
animationStarted = false;
|
||||
currentAnimation = new AnimatorSet();
|
||||
currentAnimation.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
addingSpan = null;
|
||||
currentAnimation = null;
|
||||
animationStarted = false;
|
||||
}
|
||||
});
|
||||
currentAnimation.setDuration(150);
|
||||
currentAnimation.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
||||
addingSpan = span;
|
||||
animators.clear();
|
||||
animators.add(ObjectAnimator.ofFloat(addingSpan, View.SCALE_X, 0.01f, 1.0f));
|
||||
animators.add(ObjectAnimator.ofFloat(addingSpan, View.SCALE_Y, 0.01f, 1.0f));
|
||||
animators.add(ObjectAnimator.ofFloat(addingSpan, View.ALPHA, 0.0f, 1.0f));
|
||||
if (animated) {
|
||||
currentAnimation = new AnimatorSet();
|
||||
currentAnimation.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
currentAnimation = null;
|
||||
animationStarted = false;
|
||||
}
|
||||
});
|
||||
currentAnimation.setDuration(150);
|
||||
currentAnimation.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
||||
animators.clear();
|
||||
animators.add(ObjectAnimator.ofFloat(span, View.SCALE_X, 0.01f, 1.0f));
|
||||
animators.add(ObjectAnimator.ofFloat(span, View.SCALE_Y, 0.01f, 1.0f));
|
||||
animators.add(ObjectAnimator.ofFloat(span, View.ALPHA, 0.0f, 1.0f));
|
||||
}
|
||||
addView(span);
|
||||
}
|
||||
|
||||
|
@ -1054,7 +1177,6 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
addAnimation = false;
|
||||
boolean ignoreScrollEvent = true;
|
||||
selectedContacts.remove(span.getUid());
|
||||
allSpans.remove(span);
|
||||
span.setOnClickListener(null);
|
||||
|
||||
if (currentAnimation != null) {
|
||||
|
@ -1164,8 +1286,15 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
searchAdapter.searchDialogs(text);
|
||||
}
|
||||
|
||||
public void setDelegate(GroupCreateActivity.ContactsAddActivityDelegate delegate) {
|
||||
this.delegate = delegate;
|
||||
public void setDelegate(GroupCreateActivity.ContactsAddActivityDelegate contactsAddActivityDelegate) {
|
||||
delegate = contactsAddActivityDelegate;
|
||||
}
|
||||
|
||||
public void setDelegate(InviteMembersBottomSheetDelegate inviteMembersBottomSheetDelegate, ArrayList<Long> selectedDialogs) {
|
||||
dialogsDelegate = inviteMembersBottomSheetDelegate;
|
||||
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.dialogsNeedReload);
|
||||
dialogsServerOnly = new ArrayList<>(MessagesController.getInstance(currentAccount).dialogsServerOnly);
|
||||
updateRows();
|
||||
}
|
||||
|
||||
private class ItemAnimator extends DefaultItemAnimator {
|
||||
|
@ -1202,7 +1331,7 @@ public class InviteMembersBottomSheet extends UsersAlertBase {
|
|||
}
|
||||
linkGenerating = true;
|
||||
TLRPC.TL_messages_exportChatInvite req = new TLRPC.TL_messages_exportChatInvite();
|
||||
//req.legacy_revoke_permanent = true; TODO layer 124
|
||||
req.legacy_revoke_permanent = true;
|
||||
req.peer = MessagesController.getInstance(currentAccount).getInputPeer(-chatId);
|
||||
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
if (error == null) {
|
||||
|
|
|
@ -6,16 +6,21 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -63,25 +68,31 @@ public class LinkActionView extends LinearLayout {
|
|||
private boolean permanent;
|
||||
boolean loadingImporters;
|
||||
private QRCodeBottomSheet qrCodeBottomSheet;
|
||||
private boolean isPublic;
|
||||
private boolean hideRevokeOption;
|
||||
private boolean canEdit = true;
|
||||
private boolean isChannel;
|
||||
|
||||
float[] point = new float[2];
|
||||
|
||||
public LinkActionView(Context context, BaseFragment fragment, BottomSheet bottomSheet, int chatId, boolean permanent) {
|
||||
public LinkActionView(Context context, BaseFragment fragment, BottomSheet bottomSheet, int chatId, boolean permanent, boolean isChannel) {
|
||||
super(context);
|
||||
this.fragment = fragment;
|
||||
this.permanent = permanent;
|
||||
this.isChannel = isChannel;
|
||||
|
||||
setOrientation(VERTICAL);
|
||||
frameLayout = new FrameLayout(context);
|
||||
linkView = new TextView(context);
|
||||
linkView.setPadding(AndroidUtilities.dp(20), AndroidUtilities.dp(18), AndroidUtilities.dp(40), AndroidUtilities.dp(18));
|
||||
linkView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||
linkView.setEllipsize(TextUtils.TruncateAt.MIDDLE);
|
||||
linkView.setSingleLine(true);
|
||||
|
||||
frameLayout.addView(linkView);
|
||||
optionsView = new ImageView(context);
|
||||
optionsView.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_ab_other));
|
||||
optionsView.setScaleType(ImageView.ScaleType.CENTER);
|
||||
frameLayout.addView(optionsView, LayoutHelper.createFrame(40, 48, Gravity.RIGHT | Gravity.CENTER_VERTICAL));
|
||||
frameLayout.addView(optionsView, LayoutHelper.createFrame(40, 48, Gravity.RIGHT | Gravity.CENTER_VERTICAL));
|
||||
addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 4, 0, 4, 0));
|
||||
|
||||
LinearLayout linearLayout = new LinearLayout(context);
|
||||
|
@ -92,13 +103,13 @@ public class LinkActionView extends LinearLayout {
|
|||
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
|
||||
spannableStringBuilder.append("..").setSpan(new ColoredImageSpan(ContextCompat.getDrawable(context, R.drawable.msg_copy_filled)), 0, 1, 0);
|
||||
spannableStringBuilder.setSpan(new DialogCell.FixedWidthSpan(AndroidUtilities.dp(8)), 1, 2, 0);
|
||||
spannableStringBuilder.append(LocaleController.getString("CopyLink", R.string.CopyLink));
|
||||
spannableStringBuilder.append(LocaleController.getString("LinkActionCopy", R.string.LinkActionCopy));
|
||||
spannableStringBuilder.append(".").setSpan(new DialogCell.FixedWidthSpan(AndroidUtilities.dp(5)), spannableStringBuilder.length() - 1, spannableStringBuilder.length(), 0);
|
||||
copyView.setText(spannableStringBuilder);
|
||||
copyView.setPadding(AndroidUtilities.dp(10), AndroidUtilities.dp(10), AndroidUtilities.dp(10), AndroidUtilities.dp(10));
|
||||
copyView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
copyView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
copyView.setLines(1);
|
||||
copyView.setSingleLine(true);
|
||||
linearLayout.addView(copyView, LayoutHelper.createLinear(0, 40, 1f, 0, 4, 0, 4, 0));
|
||||
|
||||
shareView = new TextView(context);
|
||||
|
@ -106,21 +117,21 @@ public class LinkActionView extends LinearLayout {
|
|||
spannableStringBuilder = new SpannableStringBuilder();
|
||||
spannableStringBuilder.append("..").setSpan(new ColoredImageSpan(ContextCompat.getDrawable(context, R.drawable.msg_share_filled)), 0, 1, 0);
|
||||
spannableStringBuilder.setSpan(new DialogCell.FixedWidthSpan(AndroidUtilities.dp(8)), 1, 2, 0);
|
||||
spannableStringBuilder.append(LocaleController.getString("ShareLink", R.string.ShareLink));
|
||||
spannableStringBuilder.append(LocaleController.getString("LinkActionShare", R.string.LinkActionShare));
|
||||
spannableStringBuilder.append(".").setSpan(new DialogCell.FixedWidthSpan(AndroidUtilities.dp(5)), spannableStringBuilder.length() - 1, spannableStringBuilder.length(), 0);
|
||||
shareView.setText(spannableStringBuilder);
|
||||
shareView.setPadding(AndroidUtilities.dp(10), AndroidUtilities.dp(10), AndroidUtilities.dp(10), AndroidUtilities.dp(10));
|
||||
|
||||
shareView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
shareView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
shareView.setLines(1);
|
||||
shareView.setSingleLine(true);
|
||||
linearLayout.addView(shareView, LayoutHelper.createLinear(0, 40, 1f, 4, 0, 4, 0));
|
||||
|
||||
|
||||
removeView = new TextView(context);
|
||||
removeView.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
spannableStringBuilder = new SpannableStringBuilder();
|
||||
spannableStringBuilder.append("..").setSpan(new ColoredImageSpan(ContextCompat.getDrawable(context, R.drawable.msg_delete)), 0, 1, 0);
|
||||
spannableStringBuilder.append("..").setSpan(new ColoredImageSpan(ContextCompat.getDrawable(context, R.drawable.msg_delete_filled)), 0, 1, 0);
|
||||
spannableStringBuilder.setSpan(new DialogCell.FixedWidthSpan(AndroidUtilities.dp(8)), 1, 2, 0);
|
||||
spannableStringBuilder.append(LocaleController.getString("DeleteLink", R.string.DeleteLink));
|
||||
spannableStringBuilder.append(".").setSpan(new DialogCell.FixedWidthSpan(AndroidUtilities.dp(5)), spannableStringBuilder.length() - 1, spannableStringBuilder.length(), 0);
|
||||
|
@ -128,15 +139,14 @@ public class LinkActionView extends LinearLayout {
|
|||
removeView.setPadding(AndroidUtilities.dp(10), AndroidUtilities.dp(10), AndroidUtilities.dp(10), AndroidUtilities.dp(10));
|
||||
removeView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
removeView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
removeView.setLines(1);
|
||||
removeView.setSingleLine(true);
|
||||
linearLayout.addView(removeView, LayoutHelper.createLinear(0, LayoutHelper.WRAP_CONTENT, 1f, 4, 0, 4, 0));
|
||||
removeView.setVisibility(View.GONE);
|
||||
|
||||
|
||||
addView(linearLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0 , 20, 0, 0));
|
||||
addView(linearLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 20, 0, 0));
|
||||
|
||||
avatarsContainer = new AvatarsContainer(context);
|
||||
addView(avatarsContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 28 + 16, 0 , 12, 0, 0));
|
||||
addView(avatarsContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 28 + 16, 0, 12, 0, 0));
|
||||
copyView.setOnClickListener(view -> {
|
||||
try {
|
||||
if (link == null) {
|
||||
|
@ -189,45 +199,43 @@ public class LinkActionView extends LinearLayout {
|
|||
});
|
||||
|
||||
optionsView.setOnClickListener(view -> {
|
||||
if (isPublic) {
|
||||
showQrCode();
|
||||
return;
|
||||
}
|
||||
if (actionBarPopupWindow != null) {
|
||||
return;
|
||||
}
|
||||
ActionBarPopupWindow.ActionBarPopupWindowLayout layout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(context);
|
||||
|
||||
ActionBarMenuSubItem subItem;
|
||||
if (!permanent) {
|
||||
if (!this.permanent && canEdit) {
|
||||
subItem = new ActionBarMenuSubItem(context, true, false);
|
||||
subItem.setTextAndIcon(LocaleController.getString("Edit", R.string.Edit), R.drawable.msg_edit);
|
||||
layout.addView(subItem, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));
|
||||
subItem.setOnClickListener(view12 -> {
|
||||
delegate.editLink();
|
||||
if (actionBarPopupWindow != null) {
|
||||
actionBarPopupWindow.dismiss();
|
||||
}
|
||||
delegate.editLink();
|
||||
});
|
||||
}
|
||||
|
||||
// subItem = new ActionBarMenuSubItem(context, true, false);
|
||||
// subItem.setTextAndIcon(LocaleController.getString("GetQRCode", R.string.GetQRCode), R.drawable.msg_qrcode);
|
||||
// layout.addView(subItem, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));
|
||||
// subItem.setOnClickListener(view12 -> {
|
||||
// showQrCode();
|
||||
// });
|
||||
|
||||
subItem = new ActionBarMenuSubItem(context, false, true);
|
||||
subItem.setTextAndIcon(LocaleController.getString("RevokeLink", R.string.RevokeLink), R.drawable.msg_delete);
|
||||
subItem.setColors(Theme.getColor(Theme.key_windowBackgroundWhiteRedText), Theme.getColor(Theme.key_windowBackgroundWhiteRedText));
|
||||
subItem.setOnClickListener(view1 -> {
|
||||
revokeLink();
|
||||
if (actionBarPopupWindow != null) {
|
||||
actionBarPopupWindow.dismiss();
|
||||
}
|
||||
});
|
||||
subItem = new ActionBarMenuSubItem(context, true, false);
|
||||
subItem.setTextAndIcon(LocaleController.getString("GetQRCode", R.string.GetQRCode), R.drawable.msg_qrcode);
|
||||
layout.addView(subItem, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));
|
||||
subItem.setOnClickListener(view12 -> {
|
||||
showQrCode();
|
||||
});
|
||||
|
||||
if (!hideRevokeOption) {
|
||||
subItem = new ActionBarMenuSubItem(context, false, true);
|
||||
subItem.setTextAndIcon(LocaleController.getString("RevokeLink", R.string.RevokeLink), R.drawable.msg_delete);
|
||||
subItem.setColors(Theme.getColor(Theme.key_windowBackgroundWhiteRedText), Theme.getColor(Theme.key_windowBackgroundWhiteRedText));
|
||||
subItem.setOnClickListener(view1 -> {
|
||||
if (actionBarPopupWindow != null) {
|
||||
actionBarPopupWindow.dismiss();
|
||||
}
|
||||
revokeLink();
|
||||
});
|
||||
layout.addView(subItem, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));
|
||||
}
|
||||
|
||||
FrameLayout container;
|
||||
if (bottomSheet == null) {
|
||||
|
@ -237,7 +245,6 @@ public class LinkActionView extends LinearLayout {
|
|||
}
|
||||
|
||||
|
||||
|
||||
if (container != null) {
|
||||
float x = 0;
|
||||
float y;
|
||||
|
@ -256,6 +263,7 @@ public class LinkActionView extends LinearLayout {
|
|||
frameLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
};
|
||||
container.addView(dimView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
||||
dimView.setAlpha(0);
|
||||
|
@ -263,10 +271,10 @@ public class LinkActionView extends LinearLayout {
|
|||
layout.measure(MeasureSpec.makeMeasureSpec(container.getMeasuredWidth(), MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(container.getMeasuredHeight(), MeasureSpec.UNSPECIFIED));
|
||||
|
||||
|
||||
actionBarPopupWindow = new ActionBarPopupWindow(layout, LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT) {
|
||||
actionBarPopupWindow = new ActionBarPopupWindow(layout, LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT);
|
||||
actionBarPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
||||
@Override
|
||||
public void dismiss() {
|
||||
super.dismiss();
|
||||
public void onDismiss() {
|
||||
actionBarPopupWindow = null;
|
||||
dimView.animate().cancel();
|
||||
dimView.animate().alpha(0).setDuration(150).setListener(new AnimatorListenerAdapter() {
|
||||
|
@ -278,14 +286,12 @@ public class LinkActionView extends LinearLayout {
|
|||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
actionBarPopupWindow.setOutsideTouchable(true);
|
||||
actionBarPopupWindow.setClippingEnabled(true);
|
||||
actionBarPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
actionBarPopupWindow.setAnimationStyle(R.style.PopupContextAnimation);
|
||||
actionBarPopupWindow.setFocusable(true);
|
||||
actionBarPopupWindow.setInputMethodMode(ActionBarPopupWindow.INPUT_METHOD_NOT_NEEDED);
|
||||
actionBarPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);
|
||||
actionBarPopupWindow.getContentView().setFocusableInTouchMode(true);
|
||||
|
||||
layout.setDispatchKeyEventListener(keyEvent -> {
|
||||
if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_BACK && keyEvent.getRepeatCount() == 0 && actionBarPopupWindow.isShowing()) {
|
||||
|
@ -333,7 +339,7 @@ public class LinkActionView extends LinearLayout {
|
|||
}
|
||||
|
||||
private void showQrCode() {
|
||||
qrCodeBottomSheet = new QRCodeBottomSheet(getContext(), link) {
|
||||
qrCodeBottomSheet = new QRCodeBottomSheet(getContext(), link, isChannel ? LocaleController.getString("QRCodeLinkHelpChannel", R.string.QRCodeLinkHelpChannel) : LocaleController.getString("QRCodeLinkHelpGroup", R.string.QRCodeLinkHelpGroup)) {
|
||||
@Override
|
||||
public void dismiss() {
|
||||
super.dismiss();
|
||||
|
@ -352,13 +358,13 @@ public class LinkActionView extends LinearLayout {
|
|||
removeView.setTextColor(Theme.getColor(Theme.key_featuredStickers_buttonText));
|
||||
copyView.setBackground(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(6), Theme.getColor(Theme.key_featuredStickers_addButton), Theme.getColor(Theme.key_featuredStickers_addButtonPressed)));
|
||||
shareView.setBackground(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(6), Theme.getColor(Theme.key_featuredStickers_addButton), Theme.getColor(Theme.key_featuredStickers_addButtonPressed)));
|
||||
removeView.setBackground(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(6), Theme.getColor(Theme.key_chat_attachAudioBackground), Theme.getColor(Theme.key_featuredStickers_addButtonPressed)));
|
||||
removeView.setBackground(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(6), Theme.getColor(Theme.key_chat_attachAudioBackground), ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_windowBackgroundWhite), 120)));
|
||||
frameLayout.setBackground(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(6), Theme.getColor(Theme.key_graySection), ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_listSelector), (int) (255 * 0.3f))));
|
||||
linkView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
optionsView.setColorFilter(Theme.getColor(Theme.key_dialogTextGray3));
|
||||
//optionsView.setBackground(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector), 1));
|
||||
avatarsContainer.countTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText));
|
||||
avatarsContainer.setBackground(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(6),0, ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText), (int) (255 * 0.3f))));
|
||||
avatarsContainer.setBackground(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(6), 0, ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText), (int) (255 * 0.3f))));
|
||||
|
||||
if (qrCodeBottomSheet != null) {
|
||||
qrCodeBottomSheet.updateColors();
|
||||
|
@ -396,16 +402,11 @@ public class LinkActionView extends LinearLayout {
|
|||
optionsView.setVisibility(b ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
public void setPublic(boolean b) {
|
||||
if (isPublic != b) {
|
||||
isPublic = b;
|
||||
if (isPublic) {
|
||||
optionsView.setVisibility(View.GONE);
|
||||
optionsView.setImageDrawable(ContextCompat.getDrawable(optionsView.getContext(), R.drawable.msg_qrcode));
|
||||
} else {
|
||||
optionsView.setVisibility(View.VISIBLE);
|
||||
optionsView.setImageDrawable(ContextCompat.getDrawable(optionsView.getContext(), R.drawable.ic_ab_other));
|
||||
}
|
||||
public void showRevokeOption(boolean b) {
|
||||
if (hideRevokeOption != b) {
|
||||
hideRevokeOption = b;
|
||||
optionsView.setVisibility(View.VISIBLE);
|
||||
optionsView.setImageDrawable(ContextCompat.getDrawable(optionsView.getContext(), R.drawable.ic_ab_other));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -420,7 +421,7 @@ public class LinkActionView extends LinearLayout {
|
|||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int N = Math.min(3, usersCount);
|
||||
int x = N == 0 ? 0 :(20 * (N - 1) + 24 + 8);
|
||||
int x = N == 0 ? 0 : (20 * (N - 1) + 24 + 8);
|
||||
super.onMeasure(MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(x), MeasureSpec.EXACTLY), heightMeasureSpec);
|
||||
}
|
||||
};
|
||||
|
@ -437,7 +438,7 @@ public class LinkActionView extends LinearLayout {
|
|||
linearLayout.addView(avatarsImageView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT));
|
||||
linearLayout.addView(countTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL));
|
||||
|
||||
setPadding(0, AndroidUtilities.dp(8), 0 ,AndroidUtilities.dp(8));
|
||||
setPadding(0, AndroidUtilities.dp(8), 0, AndroidUtilities.dp(8));
|
||||
avatarsImageView.commitTransition(false);
|
||||
}
|
||||
}
|
||||
|
@ -452,7 +453,7 @@ public class LinkActionView extends LinearLayout {
|
|||
}
|
||||
});
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
fragment.showDialog(builder.create());
|
||||
builder.show();
|
||||
}
|
||||
|
||||
public void setDelegate(Delegate delegate) {
|
||||
|
@ -518,12 +519,22 @@ public class LinkActionView extends LinearLayout {
|
|||
|
||||
public interface Delegate {
|
||||
void revokeLink();
|
||||
default void editLink() {}
|
||||
default void removeLink() {}
|
||||
default void showUsersForPermanentLink() {}
|
||||
|
||||
default void editLink() {
|
||||
}
|
||||
|
||||
default void removeLink() {
|
||||
}
|
||||
|
||||
default void showUsersForPermanentLink() {
|
||||
}
|
||||
}
|
||||
|
||||
public void setPermanent(boolean permanent) {
|
||||
this.permanent = permanent;
|
||||
}
|
||||
|
||||
public void setCanEdit(boolean canEdit) {
|
||||
this.canEdit = canEdit;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package org.telegram.ui.Components;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -15,8 +13,10 @@ import org.telegram.messenger.AndroidUtilities;
|
|||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.tgnet.ConnectionsManager;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.AlertDialog;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.BottomSheet;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
|
@ -31,27 +31,31 @@ public class PermanentLinkBottomSheet extends BottomSheet {
|
|||
RLottieDrawable linkIcon;
|
||||
private final TextView titleView;
|
||||
private final TextView subtitle;
|
||||
// private final TextView manage;
|
||||
private final TextView manage;
|
||||
private final RLottieImageView imageView;
|
||||
private final LinkActionView linkActionView;
|
||||
private int chatId;
|
||||
private BaseFragment fragment;
|
||||
private boolean isChannel;
|
||||
|
||||
public PermanentLinkBottomSheet(Context context, boolean needFocus, BaseFragment fragment, TLRPC.ChatFull info, int chatId) {
|
||||
public PermanentLinkBottomSheet(Context context, boolean needFocus, BaseFragment fragment, TLRPC.ChatFull info, int chatId, boolean isChannel) {
|
||||
super(context, needFocus);
|
||||
this.info = info;
|
||||
this.chatId = chatId;
|
||||
this.isChannel = isChannel;
|
||||
|
||||
setAllowNestedScroll(true);
|
||||
setApplyBottomPadding(false);
|
||||
|
||||
linkActionView = new LinkActionView(context, fragment, this, chatId, true);
|
||||
linkActionView = new LinkActionView(context, fragment, this, chatId, true, isChannel);
|
||||
linkActionView.setPermanent(true);
|
||||
imageView = new RLottieImageView(context);
|
||||
linkIcon = new RLottieDrawable(R.raw.shared_link_enter, "" + R.raw.shared_link_enter, AndroidUtilities.dp(90), AndroidUtilities.dp(90), false, null);
|
||||
linkIcon.setCustomEndFrame(42);
|
||||
imageView.setAnimation(linkIcon);
|
||||
linkActionView.setUsers(0, null);
|
||||
linkActionView.setPublic(true);
|
||||
linkActionView.showRevokeOption(true);
|
||||
linkActionView.setDelegate(() -> generateLink(true));
|
||||
|
||||
titleView = new TextView(context);
|
||||
titleView.setText(LocaleController.getString("InviteLink", R.string.InviteLink));
|
||||
|
@ -60,12 +64,11 @@ public class PermanentLinkBottomSheet extends BottomSheet {
|
|||
titleView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
|
||||
subtitle = new TextView(context);
|
||||
subtitle.setText(LocaleController.getString("LinkInfo", R.string.LinkInfo));
|
||||
subtitle.setText(isChannel ? LocaleController.getString("LinkInfoChannel", R.string.LinkInfoChannel) : LocaleController.getString("LinkInfo", R.string.LinkInfo));
|
||||
subtitle.setTextSize(14);
|
||||
subtitle.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
subtitle.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText));
|
||||
|
||||
/*
|
||||
manage = new TextView(context);
|
||||
manage.setText(LocaleController.getString("ManageInviteLinks", R.string.ManageInviteLinks));
|
||||
manage.setTextSize(14);
|
||||
|
@ -73,20 +76,20 @@ public class PermanentLinkBottomSheet extends BottomSheet {
|
|||
manage.setBackground(Theme.createRadSelectorDrawable(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText), (int) (255 * 0.3f)), AndroidUtilities.dp(4), AndroidUtilities.dp(4)));
|
||||
manage.setPadding(AndroidUtilities.dp(12), AndroidUtilities.dp(4), AndroidUtilities.dp(12), AndroidUtilities.dp(4));
|
||||
|
||||
manage.setOnClickListener(view -> {
|
||||
ManageLinksActivity manageFragment = new ManageLinksActivity(info.id);
|
||||
manage.setOnClickListener(view -> {
|
||||
ManageLinksActivity manageFragment = new ManageLinksActivity(info.id, 0, 0);
|
||||
manageFragment.setInfo(info, info.exported_invite);
|
||||
fragment.presentFragment(manageFragment);
|
||||
dismiss();
|
||||
});
|
||||
*/
|
||||
|
||||
LinearLayout linearLayout = new LinearLayout(context);
|
||||
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
linearLayout.addView(imageView, LayoutHelper.createLinear(90, 90, Gravity.CENTER_HORIZONTAL, 0, 24, 0, 0));
|
||||
linearLayout.addView(titleView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL, 60, 16, 60, 0));
|
||||
linearLayout.addView(subtitle, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL, 60, 16, 60, 0));
|
||||
linearLayout.addView(linkActionView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
// linearLayout.addView(manage, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL, 60, 26, 60, 26));
|
||||
linearLayout.addView(manage, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL, 60, 26, 60, 26));
|
||||
|
||||
NestedScrollView scrollView = new NestedScrollView(context);
|
||||
scrollView.setVerticalScrollBarEnabled(false);
|
||||
|
@ -94,10 +97,14 @@ public class PermanentLinkBottomSheet extends BottomSheet {
|
|||
|
||||
setCustomView(scrollView);
|
||||
|
||||
if (info != null && info.exported_invite != null) {
|
||||
TLRPC.Chat chat = MessagesController.getInstance(UserConfig.selectedAccount).getChat(chatId);
|
||||
if (chat != null && chat.username != null) {
|
||||
linkActionView.setLink("https://t.me/" + chat.username);
|
||||
manage.setVisibility(View.GONE);
|
||||
} else if (info != null && info.exported_invite != null) {
|
||||
linkActionView.setLink(info.exported_invite.link);
|
||||
} else {
|
||||
generateLink();
|
||||
generateLink(false);
|
||||
}
|
||||
|
||||
updateColors();
|
||||
|
@ -106,13 +113,13 @@ public class PermanentLinkBottomSheet extends BottomSheet {
|
|||
boolean linkGenerating;
|
||||
TLRPC.TL_chatInviteExported invite;
|
||||
|
||||
private void generateLink() {
|
||||
private void generateLink(boolean showDialog) {
|
||||
if (linkGenerating) {
|
||||
return;
|
||||
}
|
||||
linkGenerating = true;
|
||||
TLRPC.TL_messages_exportChatInvite req = new TLRPC.TL_messages_exportChatInvite();
|
||||
//req.legacy_revoke_permanent = true; TODO layer 124
|
||||
req.legacy_revoke_permanent = true;
|
||||
req.peer = MessagesController.getInstance(currentAccount).getInputPeer(-chatId);
|
||||
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
if (error == null) {
|
||||
|
@ -124,6 +131,14 @@ public class PermanentLinkBottomSheet extends BottomSheet {
|
|||
}
|
||||
|
||||
linkActionView.setLink(invite.link);
|
||||
|
||||
if (showDialog && fragment != null) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setMessage(LocaleController.getString("RevokeAlertNewLink", R.string.RevokeAlertNewLink));
|
||||
builder.setTitle(LocaleController.getString("RevokeLink", R.string.RevokeLink));
|
||||
builder.setNegativeButton(LocaleController.getString("OK", R.string.OK), null);
|
||||
fragment.showDialog(builder.create());
|
||||
}
|
||||
}
|
||||
linkGenerating = false;
|
||||
}));
|
||||
|
@ -145,7 +160,7 @@ public class PermanentLinkBottomSheet extends BottomSheet {
|
|||
};
|
||||
arrayList.add(new ThemeDescription(titleView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
||||
arrayList.add(new ThemeDescription(subtitle, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText));
|
||||
// arrayList.add(new ThemeDescription(manage, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlueText));
|
||||
arrayList.add(new ThemeDescription(manage, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlueText));
|
||||
arrayList.add(new ThemeDescription(null, 0, null, null, null, descriptionDelegate, Theme.key_featuredStickers_addButton));
|
||||
arrayList.add(new ThemeDescription(null, 0, null, null, null, descriptionDelegate, Theme.key_featuredStickers_buttonText));
|
||||
arrayList.add(new ThemeDescription(null, 0, null, null, null, descriptionDelegate, Theme.key_windowBackgroundWhiteBlueText));
|
||||
|
@ -154,7 +169,7 @@ public class PermanentLinkBottomSheet extends BottomSheet {
|
|||
|
||||
private void updateColors() {
|
||||
imageView.setBackground(Theme.createCircleDrawable(AndroidUtilities.dp(90), Theme.getColor(Theme.key_featuredStickers_addButton)));
|
||||
// manage.setBackground(Theme.createRadSelectorDrawable(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText), (int) (255 * 0.3f)), AndroidUtilities.dp(4), AndroidUtilities.dp(4)));
|
||||
manage.setBackground(Theme.createRadSelectorDrawable(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText), (int) (255 * 0.3f)), AndroidUtilities.dp(4), AndroidUtilities.dp(4)));
|
||||
int color = Theme.getColor(Theme.key_featuredStickers_buttonText);
|
||||
linkIcon.setLayerColor("Top.**", color);
|
||||
linkIcon.setLayerColor("Bottom.**", color);
|
||||
|
@ -162,4 +177,14 @@ public class PermanentLinkBottomSheet extends BottomSheet {
|
|||
linkActionView.updateColors();
|
||||
setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismissInternal() {
|
||||
super.dismissInternal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
super.dismiss();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import android.graphics.Rect;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Vibrator;
|
||||
import android.text.Editable;
|
||||
import android.text.InputFilter;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
|
@ -138,7 +137,7 @@ public class PhotoViewerCaptionEnterView extends FrameLayout implements Notifica
|
|||
emojiButton.setAlpha(0.58f);
|
||||
frameLayout.addView(emojiButton, LayoutHelper.createFrame(48, 48, Gravity.BOTTOM | Gravity.LEFT));
|
||||
emojiButton.setOnClickListener(view -> {
|
||||
if (keyboardVisible) {
|
||||
if (keyboardVisible || (AndroidUtilities.isInMultiwindow || AndroidUtilities.usingHardwareInput) && !isPopupShowing()) {
|
||||
showPopup(1, false);
|
||||
} else {
|
||||
openKeyboardInternal();
|
||||
|
@ -230,7 +229,7 @@ public class PhotoViewerCaptionEnterView extends FrameLayout implements Notifica
|
|||
});
|
||||
messageEditText.setOnClickListener(view -> {
|
||||
if (isPopupShowing()) {
|
||||
showPopup(AndroidUtilities.usingHardwareInput ? 0 : 2, false);
|
||||
showPopup(AndroidUtilities.isInMultiwindow || AndroidUtilities.usingHardwareInput ? 0 : 2, false);
|
||||
}
|
||||
});
|
||||
messageEditText.addTextChangedListener(new TextWatcher() {
|
||||
|
@ -713,7 +712,7 @@ public class PhotoViewerCaptionEnterView extends FrameLayout implements Notifica
|
|||
}
|
||||
|
||||
private void openKeyboardInternal() {
|
||||
showPopup(AndroidUtilities.usingHardwareInput ? 0 : 2, false);
|
||||
showPopup(AndroidUtilities.isInMultiwindow || AndroidUtilities.usingHardwareInput ? 0 : 2, false);
|
||||
openKeyboard();
|
||||
}
|
||||
|
||||
|
@ -753,7 +752,7 @@ public class PhotoViewerCaptionEnterView extends FrameLayout implements Notifica
|
|||
}
|
||||
|
||||
public boolean isKeyboardVisible() {
|
||||
return AndroidUtilities.usingHardwareInput && getTag() != null || keyboardVisible;
|
||||
return (AndroidUtilities.usingHardwareInput || AndroidUtilities.isInMultiwindow) && getTag() != null || keyboardVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.graphics.Paint;
|
|||
import android.graphics.PixelFormat;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
import android.view.animation.AnimationUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -24,6 +25,12 @@ public class PlayPauseDrawable extends Drawable {
|
|||
private float progress;
|
||||
private long lastUpdateTime;
|
||||
|
||||
private View parent;
|
||||
|
||||
private int alpha = 255;
|
||||
|
||||
float duration = 300f;
|
||||
|
||||
public PlayPauseDrawable(int size) {
|
||||
this.size = AndroidUtilities.dp(size);
|
||||
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
|
@ -39,22 +46,32 @@ public class PlayPauseDrawable extends Drawable {
|
|||
dt = 16;
|
||||
}
|
||||
if (pause && progress < 1f) {
|
||||
progress += dt / 300f;
|
||||
progress += dt / duration;
|
||||
if (progress >= 1f) {
|
||||
progress = 1f;
|
||||
} else {
|
||||
if (parent != null) {
|
||||
parent.invalidate();
|
||||
}
|
||||
invalidateSelf();
|
||||
}
|
||||
} else if (!pause && progress > 0f) {
|
||||
progress -= dt / 300f;
|
||||
progress -= dt / duration;
|
||||
if (progress <= 0f) {
|
||||
progress = 0f;
|
||||
} else {
|
||||
if (parent != null) {
|
||||
parent.invalidate();
|
||||
}
|
||||
invalidateSelf();
|
||||
}
|
||||
}
|
||||
final Rect bounds = getBounds();
|
||||
canvas.save();
|
||||
if (alpha == 255) {
|
||||
canvas.save();
|
||||
} else {
|
||||
canvas.saveLayerAlpha(bounds.left, bounds.top, bounds.right, bounds.bottom, alpha, Canvas.ALL_SAVE_FLAG);
|
||||
}
|
||||
canvas.translate(bounds.centerX() + AndroidUtilities.dp(1) * (1.0f - progress), bounds.centerY());
|
||||
final float ms = 500.0f * progress;
|
||||
final float rotation;
|
||||
|
@ -90,7 +107,7 @@ public class PlayPauseDrawable extends Drawable {
|
|||
|
||||
@Override
|
||||
public void setAlpha(int i) {
|
||||
paint.setAlpha(i);
|
||||
alpha = i;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -112,4 +129,12 @@ public class PlayPauseDrawable extends Drawable {
|
|||
public int getIntrinsicHeight() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setParent(View parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public void setDuration(int duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,23 +4,33 @@ import android.content.ActivityNotFoundException;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Outline;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewOutlineProvider;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.EncodeHintType;
|
||||
import com.google.zxing.qrcode.QRCodeWriter;
|
||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.BuildConfig;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
|
@ -29,6 +39,9 @@ import org.telegram.ui.ActionBar.Theme;
|
|||
import org.telegram.ui.ActionBar.ThemeDescription;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
@ -37,8 +50,10 @@ public class QRCodeBottomSheet extends BottomSheet {
|
|||
Bitmap qrCode;
|
||||
private final TextView help;
|
||||
private final TextView buttonTextView;
|
||||
|
||||
public QRCodeBottomSheet(Context context, String link) {
|
||||
int imageSize;
|
||||
RLottieImageView iconImage;
|
||||
|
||||
public QRCodeBottomSheet(Context context, String link, String helpMessage) {
|
||||
super(context, false);
|
||||
|
||||
setTitle(LocaleController.getString("InviteByQRCode", R.string.InviteByQRCode), true);
|
||||
|
@ -49,22 +64,54 @@ public class QRCodeBottomSheet extends BottomSheet {
|
|||
super.onMeasure(MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY));
|
||||
}
|
||||
};
|
||||
int p = AndroidUtilities.dp(54);
|
||||
imageView.setPadding(p, p, p, p);
|
||||
imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
imageView.setOutlineProvider(new ViewOutlineProvider() {
|
||||
@Override
|
||||
public void getOutline(View view, Outline outline) {
|
||||
outline.setRoundRect(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight(), AndroidUtilities.dp(12));
|
||||
}
|
||||
});
|
||||
imageView.setClipToOutline(true);
|
||||
}
|
||||
|
||||
LinearLayout linearLayout = new LinearLayout(context);
|
||||
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
linearLayout.setPadding(0, AndroidUtilities.dp(16), 0, 0);
|
||||
imageView.setImageBitmap(qrCode = createQR(context, link, qrCode));
|
||||
FrameLayout frameLayout = new FrameLayout(context);
|
||||
frameLayout.addView(imageView);
|
||||
linearLayout.addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 30, 0,30 ,0));
|
||||
|
||||
iconImage = new RLottieImageView(context);
|
||||
iconImage.setBackgroundColor(Color.WHITE);
|
||||
iconImage.setAutoRepeat(true);
|
||||
iconImage.setAnimation(R.raw.qr_code_logo, 60, 60);
|
||||
iconImage.playAnimation();
|
||||
|
||||
//iconImage.setPadding(-AndroidUtilities.dp(4), -AndroidUtilities.dp(4), -AndroidUtilities.dp(4), -AndroidUtilities.dp(4));
|
||||
|
||||
|
||||
FrameLayout frameLayout = new FrameLayout(context) {
|
||||
|
||||
float lastX;
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
float x = imageSize / 768f * imageView.getMeasuredHeight();
|
||||
if (lastX != x) {
|
||||
lastX = x;
|
||||
iconImage.getLayoutParams().height = iconImage.getLayoutParams().width = (int) x;
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
}
|
||||
};
|
||||
frameLayout.addView(imageView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
||||
frameLayout.addView(iconImage, LayoutHelper.createFrame(60, 60, Gravity.CENTER));
|
||||
linearLayout.addView(frameLayout, LayoutHelper.createLinear(220, 220, Gravity.CENTER_HORIZONTAL, 30, 0,30 ,0));
|
||||
|
||||
help = new TextView(context);
|
||||
help.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
help.setText(LocaleController.getString("QRCodeLinkHelp", R.string.QRCodeLinkHelp));
|
||||
help.setText(helpMessage);
|
||||
help.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
frameLayout.addView(help, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM,40, 0,40 ,8));
|
||||
linearLayout.addView(help, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 40, 8, 40, 8));
|
||||
|
||||
buttonTextView = new TextView(context);
|
||||
|
||||
|
@ -74,29 +121,51 @@ public class QRCodeBottomSheet extends BottomSheet {
|
|||
buttonTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
buttonTextView.setText(LocaleController.getString("ShareQrCode", R.string.ShareQrCode));
|
||||
buttonTextView.setOnClickListener(view -> {
|
||||
Intent i = new Intent(Intent.ACTION_SEND);
|
||||
|
||||
i.setType("image/*");
|
||||
i.putExtra(Intent.EXTRA_STREAM, getImageUri(context, qrCode));
|
||||
try {
|
||||
AndroidUtilities.findActivity(context).startActivityForResult(Intent.createChooser(i, LocaleController.getString("InviteByQRCode", R.string.InviteByQRCode)), 500);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
ex.printStackTrace();
|
||||
Uri uri = getImageUri(qrCode);
|
||||
if (uri != null) {
|
||||
Intent i = new Intent(Intent.ACTION_SEND);
|
||||
|
||||
i.setType("image/*");
|
||||
i.putExtra(Intent.EXTRA_STREAM, uri);
|
||||
try {
|
||||
AndroidUtilities.findActivity(context).startActivityForResult(Intent.createChooser(i, LocaleController.getString("InviteByQRCode", R.string.InviteByQRCode)), 500);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
linearLayout.addView(buttonTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM, 16, 15, 16, 16));
|
||||
|
||||
updateColors();
|
||||
setCustomView(linearLayout);
|
||||
ScrollView scrollView = new ScrollView(context);
|
||||
scrollView.addView(linearLayout);
|
||||
setCustomView(scrollView);
|
||||
}
|
||||
|
||||
public Uri getImageUri(Context inContext, Bitmap inImage) {
|
||||
public Uri getImageUri(Bitmap inImage) {
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
|
||||
|
||||
String path = MediaStore.Images.Media.insertImage(inContext.getContentResolver(), inImage, "group_invite_qr", null);
|
||||
return Uri.parse(path);
|
||||
File cachePath = AndroidUtilities.getCacheDir();
|
||||
if (!cachePath.isDirectory()) {
|
||||
try {
|
||||
cachePath.mkdirs();
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
File file = new File(cachePath, "qr_tmp.png");
|
||||
try (FileOutputStream out = new FileOutputStream(file)) {
|
||||
inImage.compress(Bitmap.CompressFormat.PNG, 100, out);
|
||||
out.close();
|
||||
return FileProvider.getUriForFile(ApplicationLoader.applicationContext, BuildConfig.APPLICATION_ID + ".provider", file);
|
||||
} catch (IOException e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Bitmap createQR(Context context, String key, Bitmap oldBitmap) {
|
||||
|
@ -104,7 +173,10 @@ public class QRCodeBottomSheet extends BottomSheet {
|
|||
HashMap<EncodeHintType, Object> hints = new HashMap<>();
|
||||
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
|
||||
hints.put(EncodeHintType.MARGIN, 0);
|
||||
return new QRCodeWriter().encode(key, BarcodeFormat.QR_CODE, 768, 768, hints, oldBitmap, context);
|
||||
QRCodeWriter writer = new QRCodeWriter();
|
||||
Bitmap bitmap = writer.encode(key, BarcodeFormat.QR_CODE, 768, 768, hints, oldBitmap, context);
|
||||
imageSize = writer.getImageSize();
|
||||
return bitmap;
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,148 @@
|
|||
/*
|
||||
* This is the source code of Telegram for Android v. 5.x.x.
|
||||
* It is licensed under GNU GPL v. 2 or later.
|
||||
* You should have received a copy of the license in this archive (see LICENSE).
|
||||
*
|
||||
* Copyright Nikolai Kudashov, 2013-2018.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Components;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.InputType;
|
||||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.ActionBar.BottomSheet;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
|
||||
public class ReportAlert extends BottomSheet {
|
||||
|
||||
private BottomSheetCell clearButton;
|
||||
private EditTextBoldCursor editText;
|
||||
private boolean compteled;
|
||||
|
||||
public static class BottomSheetCell extends FrameLayout {
|
||||
|
||||
private View background;
|
||||
private TextView textView;
|
||||
private LinearLayout linearLayout;
|
||||
|
||||
public BottomSheetCell(Context context) {
|
||||
super(context);
|
||||
|
||||
background = new View(context);
|
||||
background.setBackground(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(4), Theme.getColor(Theme.key_featuredStickers_addButton), Theme.getColor(Theme.key_featuredStickers_addButtonPressed)));
|
||||
addView(background, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0, 16, 16, 16, 16));
|
||||
|
||||
textView = new TextView(context);
|
||||
textView.setLines(1);
|
||||
textView.setSingleLine(true);
|
||||
textView.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
textView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
textView.setGravity(Gravity.CENTER);
|
||||
textView.setTextColor(Theme.getColor(Theme.key_featuredStickers_buttonText));
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(80), MeasureSpec.EXACTLY));
|
||||
}
|
||||
|
||||
public void setText(CharSequence text) {
|
||||
textView.setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
public ReportAlert(final Context context, int type) {
|
||||
super(context, true);
|
||||
setApplyBottomPadding(false);
|
||||
setApplyTopPadding(false);
|
||||
|
||||
FrameLayout frameLayout = new FrameLayout(context);
|
||||
setCustomView(frameLayout);
|
||||
|
||||
RLottieImageView imageView = new RLottieImageView(context);
|
||||
imageView.setAutoRepeat(true);
|
||||
imageView.setAnimation(R.raw.report_police, 120, 120);
|
||||
imageView.playAnimation();
|
||||
frameLayout.addView(imageView, LayoutHelper.createFrame(160, 160, Gravity.CENTER_HORIZONTAL | Gravity.TOP, 17, 14, 17, 0));
|
||||
|
||||
TextView percentTextView = new TextView(context);
|
||||
percentTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
percentTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 24);
|
||||
percentTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
|
||||
if (type == 0) {
|
||||
percentTextView.setText(LocaleController.getString("ReportTitleSpam", R.string.ReportTitleSpam));
|
||||
} else if (type == 1) {
|
||||
percentTextView.setText(LocaleController.getString("ReportTitleFake", R.string.ReportTitleFake));
|
||||
} else if (type == 2) {
|
||||
percentTextView.setText(LocaleController.getString("ReportTitleViolence", R.string.ReportTitleViolence));
|
||||
} else if (type == 3) {
|
||||
percentTextView.setText(LocaleController.getString("ReportTitleChild", R.string.ReportTitleChild));
|
||||
} else if (type == 4) {
|
||||
percentTextView.setText(LocaleController.getString("ReportTitlePornography", R.string.ReportTitlePornography));
|
||||
} else if (type == 5) {
|
||||
percentTextView.setText(LocaleController.getString("ReportChat", R.string.ReportChat));
|
||||
}
|
||||
frameLayout.addView(percentTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 17, 197, 17, 0));
|
||||
|
||||
TextView infoTextView = new TextView(context);
|
||||
infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
infoTextView.setTextColor(Theme.getColor(Theme.key_dialogTextGray3));
|
||||
infoTextView.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
infoTextView.setText(LocaleController.getString("ReportInfo", R.string.ReportInfo));
|
||||
frameLayout.addView(infoTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 30, 235, 30, 44));
|
||||
|
||||
editText = new EditTextBoldCursor(context);
|
||||
editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
||||
editText.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
|
||||
editText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
editText.setBackgroundDrawable(Theme.createEditTextDrawable(context, false));
|
||||
editText.setMaxLines(1);
|
||||
editText.setLines(1);
|
||||
editText.setPadding(0, 0, 0, 0);
|
||||
editText.setSingleLine(true);
|
||||
editText.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
|
||||
editText.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
|
||||
editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
editText.setHint(LocaleController.getString("ReportHint", R.string.ReportHint));
|
||||
editText.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
editText.setCursorSize(AndroidUtilities.dp(20));
|
||||
editText.setCursorWidth(1.5f);
|
||||
editText.setOnEditorActionListener((textView, i, keyEvent) -> {
|
||||
if (i == EditorInfo.IME_ACTION_DONE) {
|
||||
clearButton.background.callOnClick();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
frameLayout.addView(editText, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 36, Gravity.LEFT | Gravity.TOP, 17, 305, 17, 0));
|
||||
|
||||
clearButton = new BottomSheetCell(context);
|
||||
clearButton.setBackground(null);
|
||||
clearButton.setText(LocaleController.getString("ReportSend", R.string.ReportSend));
|
||||
clearButton.background.setOnClickListener(v -> {
|
||||
AndroidUtilities.hideKeyboard(editText);
|
||||
onSend(type, editText.getText().toString());
|
||||
dismiss();
|
||||
});
|
||||
frameLayout.addView(clearButton, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 50, Gravity.LEFT | Gravity.TOP, 0, 357, 0, 0));
|
||||
}
|
||||
|
||||
protected void onSend(int type, String message) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,312 @@
|
|||
package org.telegram.ui.Components;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.RectF;
|
||||
import android.text.Layout;
|
||||
import android.text.SpannableString;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.StaticLayout;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
|
||||
public class SearchCounterView extends View {
|
||||
|
||||
private final static int ANIMATION_TYPE_REPLACE = 2;
|
||||
|
||||
int animationType = -1;
|
||||
|
||||
TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||
RectF rectF = new RectF();
|
||||
|
||||
int currentCount;
|
||||
private boolean countAnimationIncrement;
|
||||
private ValueAnimator countAnimator;
|
||||
private float countChangeProgress = 1f;
|
||||
private StaticLayout countLayout;
|
||||
private StaticLayout countOldLayout;
|
||||
private StaticLayout countAnimationStableLayout;
|
||||
private StaticLayout countAnimationStableLayout2;
|
||||
private StaticLayout countAnimationInLayout;
|
||||
|
||||
private int countWidthOld;
|
||||
private int countWidth;
|
||||
|
||||
private int textColor;
|
||||
private String textColorKey = Theme.key_chat_searchPanelText;
|
||||
|
||||
int lastH;
|
||||
int gravity = Gravity.CENTER;
|
||||
float countLeft;
|
||||
float x;
|
||||
|
||||
public float horizontalPadding;
|
||||
|
||||
String currentString;
|
||||
|
||||
|
||||
public SearchCounterView(Context context) {
|
||||
super(context);
|
||||
textPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
textPaint.setTextSize(AndroidUtilities.dp(15));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
if (getMeasuredHeight() != lastH) {
|
||||
int count = currentCount;
|
||||
String str = currentString;
|
||||
currentString = null;
|
||||
setCount(str, count, false);
|
||||
lastH = getMeasuredHeight();
|
||||
}
|
||||
}
|
||||
|
||||
float dx = 0;
|
||||
|
||||
public void setCount(String newStr, int count, boolean animated) {
|
||||
if (currentString != null && currentString.equals(newStr)) {
|
||||
return;
|
||||
}
|
||||
if (countAnimator != null) {
|
||||
countAnimator.cancel();
|
||||
}
|
||||
if (currentCount == 0 || count <= 0 || newStr == null || LocaleController.isRTL || TextUtils.isEmpty(newStr)) {
|
||||
animated = false;
|
||||
}
|
||||
|
||||
if (animated && newStr != null && !newStr.contains("**")) {
|
||||
animated = false;
|
||||
}
|
||||
|
||||
if (!animated) {
|
||||
if (newStr != null) {
|
||||
newStr = newStr.replaceAll("\\*\\*", "");
|
||||
}
|
||||
currentCount = count;
|
||||
if (newStr == null) {
|
||||
countWidth = 0;
|
||||
countLayout = null;
|
||||
} else {
|
||||
countWidth = Math.max(AndroidUtilities.dp(12), (int) Math.ceil(textPaint.measureText(newStr)));
|
||||
countLayout = new StaticLayout(newStr, textPaint, countWidth, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
|
||||
dx = 0;
|
||||
if (animated) {
|
||||
if (countAnimator != null) {
|
||||
countAnimator.cancel();
|
||||
}
|
||||
countChangeProgress = 0f;
|
||||
countAnimator = ValueAnimator.ofFloat(0, 1f);
|
||||
countAnimator.addUpdateListener(valueAnimator -> {
|
||||
countChangeProgress = (float) valueAnimator.getAnimatedValue();
|
||||
invalidate();
|
||||
});
|
||||
countAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
animationType = -1;
|
||||
countChangeProgress = 1f;
|
||||
countOldLayout = null;
|
||||
countAnimationStableLayout = null;
|
||||
countAnimationInLayout = null;
|
||||
invalidate();
|
||||
}
|
||||
});
|
||||
|
||||
animationType = ANIMATION_TYPE_REPLACE;
|
||||
countAnimator.setDuration(200);
|
||||
countAnimator.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
||||
|
||||
if (countLayout != null) {
|
||||
String oldStr = currentString;
|
||||
|
||||
int countStartIndex = newStr.indexOf("**");
|
||||
if (countStartIndex >= 0) {
|
||||
newStr = newStr.replaceAll("\\*\\*", "");
|
||||
} else {
|
||||
countStartIndex = 0;
|
||||
}
|
||||
|
||||
SpannableStringBuilder oldSpannableStr = new SpannableStringBuilder(oldStr);
|
||||
SpannableStringBuilder newSpannableStr = new SpannableStringBuilder(newStr);
|
||||
SpannableStringBuilder stableStr = new SpannableStringBuilder(newStr);
|
||||
|
||||
boolean replaceAllDigits = Integer.toString(currentCount).length() != Integer.toString(count).length();
|
||||
boolean newEndReached = false;
|
||||
boolean oldEndReached = false;
|
||||
int n = Math.min(oldStr.length(), newStr.length());
|
||||
int cutIndexNew = 0;
|
||||
int cutIndexOld = 0;
|
||||
if (countStartIndex > 0) {
|
||||
oldSpannableStr.setSpan(new EmptyStubSpan(), 0, countStartIndex, SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
newSpannableStr.setSpan(new EmptyStubSpan(), 0, countStartIndex, SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
stableStr.setSpan(new EmptyStubSpan(), 0, countStartIndex, SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
for (int i = countStartIndex; i < n; i++) {
|
||||
if (!newEndReached && !oldEndReached) {
|
||||
if (replaceAllDigits) {
|
||||
stableStr.setSpan(new EmptyStubSpan(), i, i + 1, SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
} else if (oldStr.charAt(i) == newStr.charAt(i)) {
|
||||
oldSpannableStr.setSpan(new EmptyStubSpan(), i, i + 1, SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
newSpannableStr.setSpan(new EmptyStubSpan(), i, i + 1, SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
} else {
|
||||
stableStr.setSpan(new EmptyStubSpan(), i, i + 1, SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
}
|
||||
if (!Character.isDigit(newStr.charAt(i))) {
|
||||
newSpannableStr.setSpan(new EmptyStubSpan(), i, newStr.length(), SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
newEndReached = true;
|
||||
cutIndexNew = i;
|
||||
}
|
||||
|
||||
if (!Character.isDigit(oldStr.charAt(i))) {
|
||||
oldSpannableStr.setSpan(new EmptyStubSpan(), i, oldStr.length(), SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
oldEndReached = true;
|
||||
cutIndexOld = i;
|
||||
}
|
||||
}
|
||||
|
||||
int countOldWidth = Math.max(AndroidUtilities.dp(12), (int) Math.ceil(textPaint.measureText(oldStr)));
|
||||
int countNewWidth = Math.max(AndroidUtilities.dp(12), (int) Math.ceil(textPaint.measureText(newStr)));
|
||||
countOldLayout = new StaticLayout(oldSpannableStr, textPaint, countOldWidth, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
|
||||
countAnimationStableLayout = new StaticLayout(stableStr, textPaint, countNewWidth, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
|
||||
countAnimationInLayout = new StaticLayout(newSpannableStr, textPaint, countNewWidth, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
|
||||
|
||||
if (countStartIndex > 0) {
|
||||
SpannableStringBuilder stableString2 = new SpannableStringBuilder(newStr);
|
||||
stableString2.setSpan(new EmptyStubSpan(), countStartIndex, newStr.length(), 0);
|
||||
countAnimationStableLayout2 = new StaticLayout(stableString2, textPaint, countNewWidth, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
|
||||
} else {
|
||||
countAnimationStableLayout2 = null;
|
||||
}
|
||||
|
||||
dx = countOldLayout.getPrimaryHorizontal(cutIndexOld) - countAnimationStableLayout.getPrimaryHorizontal(cutIndexNew);
|
||||
}
|
||||
countWidthOld = countWidth;
|
||||
countAnimationIncrement = count < currentCount;
|
||||
countAnimator.start();
|
||||
}
|
||||
if (count > 0) {
|
||||
countWidth = Math.max(AndroidUtilities.dp(12), (int) Math.ceil(textPaint.measureText(newStr)));
|
||||
countLayout = new StaticLayout(newStr, textPaint, countWidth, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
|
||||
}
|
||||
|
||||
currentCount = count;
|
||||
invalidate();
|
||||
currentString = newStr;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
int textColor = Theme.getColor(textColorKey);
|
||||
|
||||
if (this.textColor != textColor) {
|
||||
this.textColor = textColor;
|
||||
textPaint.setColor(textColor);
|
||||
}
|
||||
|
||||
if (countChangeProgress != 1f) {
|
||||
|
||||
float countTop = (getMeasuredHeight() - AndroidUtilities.dp(23)) / 2f;
|
||||
float countWidth;
|
||||
if (this.countWidth == this.countWidthOld) {
|
||||
countWidth = this.countWidth;
|
||||
} else {
|
||||
countWidth = this.countWidth * countChangeProgress + this.countWidthOld * (1f - countChangeProgress);
|
||||
}
|
||||
updateX(countWidth);
|
||||
|
||||
rectF.set(x, countTop, x + countWidth + AndroidUtilities.dp(11), countTop + AndroidUtilities.dp(23));
|
||||
|
||||
boolean increment = countAnimationIncrement;
|
||||
if (countAnimationInLayout != null) {
|
||||
canvas.save();
|
||||
canvas.translate(countLeft, countTop + AndroidUtilities.dp(4) + (increment ? AndroidUtilities.dp(13) : -AndroidUtilities.dp(13)) * (1f - countChangeProgress));
|
||||
textPaint.setAlpha((int) (255 * countChangeProgress));
|
||||
countAnimationInLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
} else if (countLayout != null) {
|
||||
canvas.save();
|
||||
canvas.translate(countLeft, countTop + AndroidUtilities.dp(4) + (increment ? AndroidUtilities.dp(13) : -AndroidUtilities.dp(13)) * (1f - countChangeProgress));
|
||||
textPaint.setAlpha((int) (255 * countChangeProgress));
|
||||
countLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
if (countOldLayout != null) {
|
||||
canvas.save();
|
||||
canvas.translate(countLeft, countTop + AndroidUtilities.dp(4) + (increment ? -AndroidUtilities.dp(13) : AndroidUtilities.dp(13)) * (countChangeProgress));
|
||||
textPaint.setAlpha((int) (255 * (1f - countChangeProgress)));
|
||||
countOldLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
if (countAnimationStableLayout != null) {
|
||||
canvas.save();
|
||||
canvas.translate(countLeft + dx * (1f - countChangeProgress), countTop + AndroidUtilities.dp(4));
|
||||
textPaint.setAlpha(255);
|
||||
countAnimationStableLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
if (countAnimationStableLayout2 != null) {
|
||||
canvas.save();
|
||||
canvas.translate(countLeft, countTop + AndroidUtilities.dp(4));
|
||||
textPaint.setAlpha(255);
|
||||
countAnimationStableLayout2.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
textPaint.setAlpha(255);
|
||||
} else {
|
||||
drawInternal(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateX(float countWidth) {
|
||||
if (gravity == Gravity.RIGHT) {
|
||||
countLeft = getMeasuredWidth() - AndroidUtilities.dp(5.5f);
|
||||
if (horizontalPadding != 0) {
|
||||
countLeft -= Math.max(horizontalPadding + countWidth / 2f, countWidth);
|
||||
} else {
|
||||
countLeft -= countWidth;
|
||||
}
|
||||
} else if (gravity == Gravity.LEFT) {
|
||||
countLeft = AndroidUtilities.dp(5.5f);
|
||||
} else {
|
||||
countLeft = (int) ((getMeasuredWidth() - countWidth) / 2f);
|
||||
}
|
||||
x = countLeft - AndroidUtilities.dp(5.5f);
|
||||
}
|
||||
|
||||
private void drawInternal(Canvas canvas) {
|
||||
float countTop = (getMeasuredHeight() - AndroidUtilities.dp(23)) / 2f;
|
||||
updateX(countWidth);
|
||||
if (countLayout != null) {
|
||||
canvas.save();
|
||||
canvas.translate(countLeft, countTop + AndroidUtilities.dp(4));
|
||||
countLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
|
||||
public void setGravity(int gravity) {
|
||||
this.gravity = gravity;
|
||||
}
|
||||
|
||||
}
|
|
@ -49,10 +49,10 @@ import android.widget.TextView;
|
|||
import android.widget.Toast;
|
||||
|
||||
import org.telegram.SQLite.SQLiteCursor;
|
||||
import org.telegram.messenger.AccountInstance;
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.ChatObject;
|
||||
import org.telegram.messenger.ContactsController;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessageObject;
|
||||
|
@ -349,8 +349,8 @@ public class ShareAlert extends BottomSheet implements NotificationCenter.Notifi
|
|||
AdjustPanLayoutHelper adjustPanLayoutHelper = new AdjustPanLayoutHelper(this) {
|
||||
|
||||
@Override
|
||||
protected void onTransitionStart(boolean keyboardVisible) {
|
||||
super.onTransitionStart(keyboardVisible);
|
||||
protected void onTransitionStart(boolean keyboardVisible, int contentHeight) {
|
||||
super.onTransitionStart(keyboardVisible, contentHeight);
|
||||
if (previousScrollOffsetY > 0 && previousScrollOffsetY != scrollOffsetY && keyboardVisible) {
|
||||
fromScrollY = previousScrollOffsetY;
|
||||
toScrollY = scrollOffsetY;
|
||||
|
@ -1115,11 +1115,7 @@ public class ShareAlert extends BottomSheet implements NotificationCenter.Notifi
|
|||
|
||||
updateSelectedCount(0);
|
||||
|
||||
if (!DialogsActivity.dialogsLoaded[currentAccount]) {
|
||||
MessagesController.getInstance(currentAccount).loadDialogs(0, 0, 100, true);
|
||||
ContactsController.getInstance(currentAccount).checkInviteText();
|
||||
DialogsActivity.dialogsLoaded[currentAccount] = true;
|
||||
}
|
||||
DialogsActivity.loadDialogs(AccountInstance.getInstance(currentAccount));
|
||||
if (listAdapter.dialogs.isEmpty()) {
|
||||
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.dialogsNeedReload);
|
||||
}
|
||||
|
@ -1388,7 +1384,7 @@ public class ShareAlert extends BottomSheet implements NotificationCenter.Notifi
|
|||
dialogsMap.put(dialog.id, dialog);
|
||||
} else {
|
||||
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-lower_id);
|
||||
if (!(chat == null || ChatObject.isNotInChat(chat) || ChatObject.isChannel(chat) && !chat.creator && (chat.admin_rights == null || !chat.admin_rights.post_messages) && !chat.megagroup)) {
|
||||
if (!(chat == null || ChatObject.isNotInChat(chat) || chat.gigagroup && !ChatObject.hasAdminRights(chat) || ChatObject.isChannel(chat) && !chat.creator && (chat.admin_rights == null || !chat.admin_rights.post_messages) && !chat.megagroup)) {
|
||||
if (dialog.folder_id == 1) {
|
||||
archivedDialogs.add(dialog);
|
||||
} else {
|
||||
|
|
|
@ -3257,7 +3257,7 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
|
|||
case 2:
|
||||
FlickerLoadingView flickerLoadingView = new FlickerLoadingView(mContext);
|
||||
view = flickerLoadingView;
|
||||
if (currentType == MediaDataController.MEDIA_MUSIC) {
|
||||
if (currentType == 2) {
|
||||
flickerLoadingView.setViewType(FlickerLoadingView.AUDIO_TYPE);
|
||||
} else {
|
||||
flickerLoadingView.setViewType(FlickerLoadingView.FILES_TYPE);
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.telegram.ui.Components;
|
|||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.DashPathEffect;
|
||||
import android.graphics.Paint;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextPaint;
|
||||
|
@ -17,13 +18,17 @@ public class SlideChooseView extends View {
|
|||
private final SeekBarAccessibilityDelegate accessibilityDelegate;
|
||||
|
||||
private Paint paint;
|
||||
private Paint linePaint;
|
||||
private TextPaint textPaint;
|
||||
private int lastDash;
|
||||
|
||||
private int circleSize;
|
||||
private int gapSize;
|
||||
private int sideSide;
|
||||
private int lineSize;
|
||||
|
||||
private int dashedFrom = -1;
|
||||
|
||||
private boolean moving;
|
||||
private boolean startMoving;
|
||||
private float startX;
|
||||
|
@ -33,7 +38,7 @@ public class SlideChooseView extends View {
|
|||
private String[] optionsStr;
|
||||
private int[] optionsSizes;
|
||||
|
||||
int selectedIndex;
|
||||
private int selectedIndex;
|
||||
|
||||
private Callback callback;
|
||||
|
||||
|
@ -42,6 +47,9 @@ public class SlideChooseView extends View {
|
|||
|
||||
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||
linePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
linePaint.setStrokeWidth(AndroidUtilities.dp(2));
|
||||
linePaint.setStrokeCap(Paint.Cap.ROUND);
|
||||
textPaint.setTextSize(AndroidUtilities.dp(13));
|
||||
|
||||
accessibilityDelegate = new IntSeekBarAccessibilityDelegate() {
|
||||
|
@ -81,6 +89,9 @@ public class SlideChooseView extends View {
|
|||
requestLayout();
|
||||
}
|
||||
|
||||
public void setDashedFrom(int from) {
|
||||
dashedFrom = from;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
|
@ -130,6 +141,9 @@ public class SlideChooseView extends View {
|
|||
setOption(selectedIndex);
|
||||
}
|
||||
}
|
||||
if (callback != null) {
|
||||
callback.onTouchEnd();
|
||||
}
|
||||
startMoving = false;
|
||||
moving = false;
|
||||
}
|
||||
|
@ -162,21 +176,37 @@ public class SlideChooseView extends View {
|
|||
for (int a = 0; a < optionsStr.length; a++) {
|
||||
int cx = sideSide + (lineSize + gapSize * 2 + circleSize) * a + circleSize / 2;
|
||||
if (a <= selectedIndex) {
|
||||
paint.setColor(Theme.getColor(Theme.key_switchTrackChecked));
|
||||
int color = Theme.getColor(Theme.key_switchTrackChecked);
|
||||
paint.setColor(color);
|
||||
linePaint.setColor(color);
|
||||
} else {
|
||||
paint.setColor(Theme.getColor(Theme.key_switchTrack));
|
||||
int color = Theme.getColor(Theme.key_switchTrack);
|
||||
paint.setColor(color);
|
||||
linePaint.setColor(color);
|
||||
}
|
||||
canvas.drawCircle(cx, cy, a == selectedIndex ? AndroidUtilities.dp(6) : circleSize / 2, paint);
|
||||
if (a != 0) {
|
||||
int x = cx - circleSize / 2 - gapSize - lineSize;
|
||||
int width = lineSize;
|
||||
if (a == selectedIndex || a == selectedIndex + 1) {
|
||||
width -= AndroidUtilities.dp(3);
|
||||
}
|
||||
if (a == selectedIndex + 1) {
|
||||
if (dashedFrom != -1 && a - 1 >= dashedFrom) {
|
||||
x += AndroidUtilities.dp(3);
|
||||
width -= AndroidUtilities.dp(3);
|
||||
int dash = width / AndroidUtilities.dp(13);
|
||||
if (lastDash != dash) {
|
||||
float gap = (width - dash * AndroidUtilities.dp(8)) / (float) (dash - 1);
|
||||
linePaint.setPathEffect(new DashPathEffect(new float[]{AndroidUtilities.dp(6), gap}, 0));
|
||||
lastDash = dash;
|
||||
}
|
||||
canvas.drawLine(x + AndroidUtilities.dp(1), cy, x + width - AndroidUtilities.dp(1), cy, linePaint);
|
||||
} else {
|
||||
if (a == selectedIndex || a == selectedIndex + 1) {
|
||||
width -= AndroidUtilities.dp(3);
|
||||
}
|
||||
if (a == selectedIndex + 1) {
|
||||
x += AndroidUtilities.dp(3);
|
||||
}
|
||||
canvas.drawRect(x, cy - AndroidUtilities.dp(1), x + width, cy + AndroidUtilities.dp(1), paint);
|
||||
}
|
||||
canvas.drawRect(x, cy - AndroidUtilities.dp(1), x + width, cy + AndroidUtilities.dp(1), paint);
|
||||
}
|
||||
int size = optionsSizes[a];
|
||||
String text = optionsStr[a];
|
||||
|
@ -208,5 +238,9 @@ public class SlideChooseView extends View {
|
|||
|
||||
public interface Callback {
|
||||
void onOptionSelected(int index);
|
||||
|
||||
default void onTouchEnd() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,14 +22,20 @@ public class StickerSetBulletinLayout extends Bulletin.TwoLineLayout {
|
|||
public static final int TYPE_REMOVED = 0;
|
||||
public static final int TYPE_ARCHIVED = 1;
|
||||
public static final int TYPE_ADDED = 2;
|
||||
public static final int TYPE_REMOVED_FROM_RECENT = 3;
|
||||
public static final int TYPE_REMOVED_FROM_FAVORITES = 4;
|
||||
public static final int TYPE_ADDED_TO_FAVORITES = 5;
|
||||
|
||||
@IntDef(value = {TYPE_REMOVED, TYPE_ARCHIVED, TYPE_ADDED})
|
||||
public @interface Type {}
|
||||
|
||||
public StickerSetBulletinLayout(@NonNull Context context, TLObject setObject, @Type int type) {
|
||||
this(context, setObject, type, null);
|
||||
}
|
||||
|
||||
public StickerSetBulletinLayout(@NonNull Context context, TLObject setObject, @Type int type, TLRPC.Document sticker) {
|
||||
super(context);
|
||||
|
||||
final TLRPC.Document sticker;
|
||||
final TLRPC.StickerSet stickerSet;
|
||||
|
||||
if (setObject instanceof TLRPC.TL_messages_stickerSet) {
|
||||
|
@ -52,11 +58,15 @@ public class StickerSetBulletinLayout extends Bulletin.TwoLineLayout {
|
|||
sticker = null;
|
||||
}
|
||||
} else {
|
||||
stickerSet = null;
|
||||
}
|
||||
|
||||
if (sticker == null) {
|
||||
throw new IllegalArgumentException("Invalid type of the given setObject: " + setObject.getClass());
|
||||
}
|
||||
|
||||
if (sticker != null) {
|
||||
TLObject object = FileLoader.getClosestPhotoSizeWithSize(stickerSet.thumbs, 90);
|
||||
TLObject object = stickerSet == null ? null : FileLoader.getClosestPhotoSizeWithSize(stickerSet.thumbs, 90);
|
||||
if (object == null) {
|
||||
object = sticker;
|
||||
}
|
||||
|
@ -109,6 +119,18 @@ public class StickerSetBulletinLayout extends Bulletin.TwoLineLayout {
|
|||
subtitleTextView.setText(LocaleController.formatString("StickersArchivedInfo", R.string.StickersArchivedInfo, stickerSet.title));
|
||||
}
|
||||
break;
|
||||
case TYPE_REMOVED_FROM_FAVORITES:
|
||||
titleTextView.setText(LocaleController.getString("RemovedFromFavorites", R.string.RemovedFromFavorites));
|
||||
subtitleTextView.setVisibility(ViewPagerFixed.GONE);
|
||||
break;
|
||||
case TYPE_ADDED_TO_FAVORITES:
|
||||
titleTextView.setText(LocaleController.getString("AddedToFavorites", R.string.AddedToFavorites));
|
||||
subtitleTextView.setVisibility(ViewPagerFixed.GONE);
|
||||
break;
|
||||
case TYPE_REMOVED_FROM_RECENT:
|
||||
titleTextView.setText(LocaleController.getString("RemovedFromRecent", R.string.RemovedFromRecent));
|
||||
subtitleTextView.setVisibility(ViewPagerFixed.GONE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -711,6 +711,7 @@ public class TrendingStickersLayout extends FrameLayout implements NotificationC
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position, @NonNull List payloads) {
|
||||
if (payloads.contains(PAYLOAD_ANIMATED)) {
|
||||
|
|
|
@ -123,10 +123,21 @@ public class UndoView extends FrameLayout {
|
|||
|
||||
public final static int ACTION_PLAYBACK_SPEED_ENABLED = 50;
|
||||
public final static int ACTION_PLAYBACK_SPEED_DISABLED = 51;
|
||||
public final static int ACTION_TEXT_COPIED = 52;
|
||||
public final static int ACTION_MESSAGE_COPIED = 52;
|
||||
public final static int ACTION_FWD_MESSAGES = 53;
|
||||
public final static int ACTION_NOTIFY_ON = 54;
|
||||
public final static int ACTION_NOTIFY_OFF = 55;
|
||||
public final static int ACTION_USERNAME_COPIED = 56;
|
||||
public final static int ACTION_HASHTAG_COPIED = 57;
|
||||
public final static int ACTION_TEXT_COPIED = 58;
|
||||
public final static int ACTION_LINK_COPIED = 59;
|
||||
public static final int ACTION_PHONE_COPIED = 60;
|
||||
|
||||
public final static int ACTION_AUTO_DELETE_ON = 70;
|
||||
public final static int ACTION_AUTO_DELETE_OFF = 71;
|
||||
public final static int ACTION_REPORT_SENT = 74;
|
||||
public final static int ACTION_GIGAGROUP_CANCEL = 75;
|
||||
public final static int ACTION_GIGAGROUP_SUCCESS = 76;
|
||||
|
||||
private CharSequence infoText;
|
||||
|
||||
|
@ -257,17 +268,18 @@ public class UndoView extends FrameLayout {
|
|||
currentAction == ACTION_OWNER_TRANSFERED_GROUP || currentAction == ACTION_QUIZ_CORRECT || currentAction == ACTION_QUIZ_INCORRECT || currentAction == ACTION_CACHE_WAS_CLEARED ||
|
||||
currentAction == ACTION_ADDED_TO_FOLDER || currentAction == ACTION_REMOVED_FROM_FOLDER || currentAction == ACTION_PROFILE_PHOTO_CHANGED ||
|
||||
currentAction == ACTION_CHAT_UNARCHIVED || currentAction == ACTION_VOIP_MUTED || currentAction == ACTION_VOIP_UNMUTED || currentAction == ACTION_VOIP_REMOVED ||
|
||||
currentAction == ACTION_VOIP_LINK_COPIED || currentAction == ACTION_VOIP_INVITED || currentAction == ACTION_VOIP_MUTED_FOR_YOU || currentAction == ACTION_VOIP_UNMUTED_FOR_YOU;
|
||||
currentAction == ACTION_VOIP_LINK_COPIED || currentAction == ACTION_VOIP_INVITED || currentAction == ACTION_VOIP_MUTED_FOR_YOU || currentAction == ACTION_VOIP_UNMUTED_FOR_YOU ||
|
||||
currentAction == ACTION_REPORT_SENT;
|
||||
}
|
||||
|
||||
private boolean hasSubInfo() {
|
||||
return currentAction == ACTION_QR_SESSION_ACCEPTED || currentAction == ACTION_PROXIMITY_SET || currentAction == ACTION_ARCHIVE_HIDDEN || currentAction == ACTION_ARCHIVE_HINT || currentAction == ACTION_ARCHIVE_FEW_HINT ||
|
||||
currentAction == ACTION_QUIZ_CORRECT || currentAction == ACTION_QUIZ_INCORRECT ||
|
||||
currentAction == ACTION_ARCHIVE_PINNED && MessagesController.getInstance(currentAccount).dialogFilters.isEmpty();
|
||||
currentAction == ACTION_REPORT_SENT || currentAction == ACTION_ARCHIVE_PINNED && MessagesController.getInstance(currentAccount).dialogFilters.isEmpty();
|
||||
}
|
||||
|
||||
public boolean isMultilineSubInfo() {
|
||||
return currentAction == ACTION_THEME_CHANGED || currentAction == ACTION_FILTERS_AVAILABLE || currentAction == ACTION_PROXIMITY_SET;
|
||||
return currentAction == ACTION_THEME_CHANGED || currentAction == ACTION_FILTERS_AVAILABLE || currentAction == ACTION_PROXIMITY_SET || currentAction == ACTION_REPORT_SENT;
|
||||
}
|
||||
|
||||
public void setAdditionalTranslationY(float value) {
|
||||
|
@ -369,6 +381,7 @@ public class UndoView extends FrameLayout {
|
|||
infoTextView.setGravity(Gravity.LEFT | Gravity.TOP);
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) infoTextView.getLayoutParams();
|
||||
layoutParams.height = LayoutHelper.WRAP_CONTENT;
|
||||
layoutParams.topMargin = AndroidUtilities.dp(13);
|
||||
layoutParams.bottomMargin = 0;
|
||||
|
||||
leftImageView.setScaleType(ImageView.ScaleType.CENTER);
|
||||
|
@ -388,7 +401,14 @@ public class UndoView extends FrameLayout {
|
|||
int icon;
|
||||
int size = 36;
|
||||
boolean iconIsDrawable = false;
|
||||
if (action == ACTION_VOIP_INVITED) {
|
||||
|
||||
if (action == ACTION_REPORT_SENT) {
|
||||
subinfoTextView.setSingleLine(false);
|
||||
infoText = LocaleController.getString("ReportChatSent", R.string.ReportChatSent);
|
||||
subInfoText = LocaleController.formatString("ReportSentInfo", R.string.ReportSentInfo);
|
||||
icon = R.raw.ic_admin;
|
||||
timeLeft = 4000;
|
||||
} else if (action == ACTION_VOIP_INVITED) {
|
||||
TLRPC.User user = (TLRPC.User) infoObject;
|
||||
infoText = AndroidUtilities.replaceTags(LocaleController.formatString("VoipGroupInvitedUser", R.string.VoipGroupInvitedUser, UserObject.getFirstName(user)));
|
||||
subInfoText = null;
|
||||
|
@ -587,31 +607,71 @@ public class UndoView extends FrameLayout {
|
|||
|
||||
undoButton.setVisibility(GONE);
|
||||
} else if (currentAction == ACTION_IMPORT_NOT_MUTUAL || currentAction == ACTION_IMPORT_GROUP_NOT_ADMIN || currentAction == ACTION_IMPORT_INFO ||
|
||||
currentAction == ACTION_PLAYBACK_SPEED_DISABLED || currentAction == ACTION_PLAYBACK_SPEED_ENABLED || currentAction == ACTION_TEXT_COPIED ||
|
||||
currentAction == ACTION_FWD_MESSAGES || currentAction == ACTION_NOTIFY_ON || currentAction == ACTION_NOTIFY_OFF) {
|
||||
currentAction == ACTION_PLAYBACK_SPEED_DISABLED || currentAction == ACTION_PLAYBACK_SPEED_ENABLED || currentAction == ACTION_MESSAGE_COPIED ||
|
||||
currentAction == ACTION_FWD_MESSAGES || currentAction == ACTION_NOTIFY_ON || currentAction == ACTION_NOTIFY_OFF || currentAction == ACTION_USERNAME_COPIED ||
|
||||
currentAction == ACTION_HASHTAG_COPIED || currentAction == ACTION_TEXT_COPIED || currentAction == ACTION_LINK_COPIED || currentAction == ACTION_PHONE_COPIED ||
|
||||
currentAction == ACTION_AUTO_DELETE_OFF || currentAction == ACTION_AUTO_DELETE_ON || currentAction == ACTION_GIGAGROUP_CANCEL || currentAction == ACTION_GIGAGROUP_SUCCESS) {
|
||||
undoImageView.setVisibility(GONE);
|
||||
leftImageView.setVisibility(VISIBLE);
|
||||
|
||||
infoTextView.setTypeface(Typeface.DEFAULT);
|
||||
|
||||
if (currentAction == ACTION_IMPORT_NOT_MUTUAL) {
|
||||
if (currentAction == ACTION_GIGAGROUP_SUCCESS) {
|
||||
infoTextView.setText(LocaleController.getString("BroadcastGroupConvertSuccess", R.string.BroadcastGroupConvertSuccess));
|
||||
leftImageView.setAnimation(R.raw.gigagroup_convert, 36, 36);
|
||||
infoOnly = true;
|
||||
layoutParams.topMargin = AndroidUtilities.dp(9);
|
||||
infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
} else if (currentAction == ACTION_GIGAGROUP_CANCEL) {
|
||||
infoTextView.setText(LocaleController.getString("GigagroupConvertCancelHint", R.string.GigagroupConvertCancelHint));
|
||||
leftImageView.setAnimation(R.raw.chats_infotip, 36, 36);
|
||||
infoOnly = true;
|
||||
layoutParams.topMargin = AndroidUtilities.dp(9);
|
||||
infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
} else if (action == ACTION_AUTO_DELETE_ON) {
|
||||
TLRPC.User user = (TLRPC.User) infoObject;
|
||||
int ttl = (Integer) infoObject2;
|
||||
String time;
|
||||
subinfoTextView.setSingleLine(false);
|
||||
if (ttl > 24 * 60 * 60) {
|
||||
time = LocaleController.formatPluralString("Days", ttl / (24 * 60 * 60));
|
||||
} else if (ttl >= 60 * 60) {
|
||||
time = LocaleController.formatPluralString("Hours", ttl / (60 * 60));
|
||||
} else if (ttl >= 60) {
|
||||
time = LocaleController.formatPluralString("Minutes", ttl / 60);
|
||||
} else {
|
||||
time = LocaleController.formatPluralString("Seconds", ttl);
|
||||
}
|
||||
infoTextView.setText(LocaleController.formatString("AutoDeleteHintOnText", R.string.AutoDeleteHintOnText, time));
|
||||
leftImageView.setAnimation(R.raw.fire_on, 36, 36);
|
||||
layoutParams.topMargin = AndroidUtilities.dp(9);
|
||||
timeLeft = 4000;
|
||||
infoOnly = true;
|
||||
leftImageView.setPadding(0, 0, 0, AndroidUtilities.dp(3));
|
||||
} else if (currentAction == ACTION_AUTO_DELETE_OFF) {
|
||||
infoTextView.setText(LocaleController.getString("AutoDeleteHintOffText", R.string.AutoDeleteHintOffText));
|
||||
leftImageView.setAnimation(R.raw.fire_off, 36, 36);
|
||||
infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
timeLeft = 3000;
|
||||
leftImageView.setPadding(0, 0, 0, AndroidUtilities.dp(4));
|
||||
} else if (currentAction == ACTION_IMPORT_NOT_MUTUAL) {
|
||||
infoTextView.setText(LocaleController.getString("ImportMutualError", R.string.ImportMutualError));
|
||||
leftImageView.setAnimation(R.raw.error, 36, 36);
|
||||
infoOnly = true;
|
||||
layoutParams.topMargin = AndroidUtilities.dp(10);
|
||||
layoutParams.topMargin = AndroidUtilities.dp(9);
|
||||
infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
} else if (currentAction == ACTION_IMPORT_GROUP_NOT_ADMIN) {
|
||||
infoTextView.setText(LocaleController.getString("ImportNotAdmin", R.string.ImportNotAdmin));
|
||||
leftImageView.setAnimation(R.raw.error, 36, 36);
|
||||
infoOnly = true;
|
||||
layoutParams.topMargin = AndroidUtilities.dp(10);
|
||||
layoutParams.topMargin = AndroidUtilities.dp(9);
|
||||
infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
} else if (currentAction == ACTION_IMPORT_INFO) {
|
||||
infoTextView.setText(LocaleController.getString("ImportedInfo", R.string.ImportedInfo));
|
||||
leftImageView.setAnimation(R.raw.imported, 36, 36);
|
||||
leftImageView.setPadding(0, 0, 0, AndroidUtilities.dp(5));
|
||||
infoOnly = true;
|
||||
layoutParams.topMargin = AndroidUtilities.dp(10);
|
||||
layoutParams.topMargin = AndroidUtilities.dp(9);
|
||||
infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
} else if (currentAction == ACTION_PLAYBACK_SPEED_DISABLED) {
|
||||
infoTextView.setText(LocaleController.getString("AudioSpeedNormal", R.string.AudioSpeedNormal));
|
||||
|
@ -623,9 +683,23 @@ public class UndoView extends FrameLayout {
|
|||
leftImageView.setAnimation(R.raw.audio_speed, 36, 36);
|
||||
timeLeft = 3000;
|
||||
infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
|
||||
} else if (currentAction == ACTION_TEXT_COPIED) {
|
||||
infoTextView.setText(LocaleController.getString("MessageCopied", R.string.MessageCopied));
|
||||
leftImageView.setAnimation(R.raw.copy, 30, 30);
|
||||
} else if (currentAction == ACTION_MESSAGE_COPIED || currentAction == ACTION_USERNAME_COPIED || currentAction == ACTION_HASHTAG_COPIED || currentAction == ACTION_TEXT_COPIED || currentAction == ACTION_LINK_COPIED || currentAction == ACTION_PHONE_COPIED) {
|
||||
int iconRawId = R.raw.copy;
|
||||
if (currentAction == ACTION_PHONE_COPIED) {
|
||||
infoTextView.setText(LocaleController.getString("PhoneCopied", R.string.PhoneCopied));
|
||||
} else if (currentAction == ACTION_USERNAME_COPIED) {
|
||||
infoTextView.setText(LocaleController.getString("UsernameCopied", R.string.UsernameCopied));
|
||||
} else if (currentAction == ACTION_HASHTAG_COPIED) {
|
||||
infoTextView.setText(LocaleController.getString("HashtagCopied", R.string.HashtagCopied));
|
||||
} else if (currentAction == ACTION_MESSAGE_COPIED) {
|
||||
infoTextView.setText(LocaleController.getString("MessageCopied", R.string.MessageCopied));
|
||||
} else if (currentAction == ACTION_LINK_COPIED) {
|
||||
iconRawId = R.raw.voip_invite;
|
||||
infoTextView.setText(LocaleController.getString("LinkCopied", R.string.LinkCopied));
|
||||
} else {
|
||||
infoTextView.setText(LocaleController.getString("TextCopied", R.string.TextCopied));
|
||||
}
|
||||
leftImageView.setAnimation(iconRawId, 30, 30);
|
||||
timeLeft = 3000;
|
||||
infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
|
||||
} else if (currentAction == ACTION_NOTIFY_ON) {
|
||||
|
|
|
@ -23,7 +23,6 @@ import android.view.Gravity;
|
|||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.FrameLayout;
|
||||
|
@ -33,8 +32,6 @@ import androidx.annotation.NonNull;
|
|||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.exoplayer2.util.Log;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
|
@ -56,7 +53,7 @@ public class UsersAlertBase extends BottomSheet {
|
|||
protected AnimatorSet shadowAnimation;
|
||||
protected StickerEmptyView emptyView;
|
||||
protected FlickerLoadingView flickerLoadingView;
|
||||
private SearchField searchView;
|
||||
protected SearchField searchView;
|
||||
|
||||
private RectF rect = new RectF();
|
||||
|
||||
|
@ -195,13 +192,13 @@ public class UsersAlertBase extends BottomSheet {
|
|||
}
|
||||
|
||||
@SuppressWarnings("FieldCanBeLocal")
|
||||
private class SearchField extends FrameLayout {
|
||||
protected class SearchField extends FrameLayout {
|
||||
|
||||
private final View searchBackground;
|
||||
private final ImageView searchIconImageView;
|
||||
private final ImageView clearSearchImageView;
|
||||
private final CloseProgressDrawable2 progressDrawable;
|
||||
private EditTextBoldCursor searchEditText;
|
||||
protected EditTextBoldCursor searchEditText;
|
||||
|
||||
public SearchField(Context context) {
|
||||
super(context);
|
||||
|
@ -311,6 +308,11 @@ public class UsersAlertBase extends BottomSheet {
|
|||
onSearchViewTouched(ev, searchEditText);
|
||||
return super.onInterceptTouchEvent(ev);
|
||||
}
|
||||
|
||||
public void closeSearch() {
|
||||
clearSearchImageView.callOnClick();
|
||||
AndroidUtilities.hideKeyboard(searchEditText);
|
||||
}
|
||||
}
|
||||
|
||||
protected void onSearchViewTouched(MotionEvent ev, EditTextBoldCursor searchEditText) {
|
||||
|
|
|
@ -1107,7 +1107,7 @@ public class WebPlayerView extends ViewGroup implements VideoPlayer.VideoPlayerD
|
|||
}
|
||||
try {
|
||||
JSONObject json = new JSONObject(playerCode).getJSONObject("file_versions").getJSONObject("mobile");
|
||||
String video = decodeUrl(json.getString("gifv"));
|
||||
String video = json.getString("video");
|
||||
String audio = json.getJSONArray("audio").getString(0);
|
||||
if (video != null && audio != null) {
|
||||
results[0] = video;
|
||||
|
@ -2162,16 +2162,25 @@ public class WebPlayerView extends ViewGroup implements VideoPlayer.VideoPlayerD
|
|||
return false;
|
||||
}
|
||||
|
||||
public void willHandle() {
|
||||
controlsView.setVisibility(INVISIBLE);
|
||||
controlsView.show(false, false);
|
||||
showProgress(true, false);
|
||||
}
|
||||
|
||||
public boolean loadVideo(String url, TLRPC.Photo thumb, Object parentObject, String originalUrl, boolean autoplay) {
|
||||
String youtubeId = null;
|
||||
String vimeoId = null;
|
||||
String coubId = null;
|
||||
String coubId = getCoubId(url);
|
||||
if (coubId == null) {
|
||||
coubId = getCoubId(originalUrl);
|
||||
}
|
||||
String twitchClipId = null;
|
||||
String twitchStreamId = null;
|
||||
String mp4File = null;
|
||||
String aparatId = null;
|
||||
seekToTime = -1;
|
||||
if (url != null) {
|
||||
if (coubId == null && url != null) {
|
||||
if (url.endsWith(".mp4")) {
|
||||
mp4File = url;
|
||||
} else {
|
||||
|
@ -2364,6 +2373,25 @@ public class WebPlayerView extends ViewGroup implements VideoPlayer.VideoPlayerD
|
|||
return false;
|
||||
}
|
||||
|
||||
public String getCoubId(String url) {
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Matcher matcher = coubIdRegex.matcher(url);
|
||||
String id = null;
|
||||
if (matcher.find()) {
|
||||
id = matcher.group(1);
|
||||
}
|
||||
if (id != null) {
|
||||
return id;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public View getAspectRatioView() {
|
||||
return aspectRatioFrameLayout;
|
||||
}
|
||||
|
|
|
@ -89,6 +89,7 @@ import org.telegram.ui.Cells.ProfileSearchCell;
|
|||
import org.telegram.ui.Cells.TextCell;
|
||||
import org.telegram.ui.Cells.UserCell;
|
||||
import org.telegram.ui.Components.AlertsCreator;
|
||||
import org.telegram.ui.Components.BulletinFactory;
|
||||
import org.telegram.ui.Components.CombinedDrawable;
|
||||
import org.telegram.ui.Components.CubicBezierInterpolator;
|
||||
import org.telegram.ui.Components.EditTextBoldCursor;
|
||||
|
@ -665,7 +666,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||
if (user.bot) {
|
||||
if (user.bot_nochats) {
|
||||
try {
|
||||
Toast.makeText(getParentActivity(), LocaleController.getString("BotCantJoinGroups", R.string.BotCantJoinGroups), Toast.LENGTH_SHORT).show();
|
||||
BulletinFactory.of(this).createErrorBulletin(LocaleController.getString("BotCantJoinGroups", R.string.BotCantJoinGroups)).show();
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
|
@ -1008,7 +1009,11 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||
return null;
|
||||
}
|
||||
RLottieImageView previousFab = dialogsActivity.getFloatingButton();
|
||||
if (previousFab == null || floatingButtonContainer == null || previousFab.getVisibility() != View.VISIBLE || Math.abs(previousFab.getTranslationY()) > AndroidUtilities.dp(4) || Math.abs(floatingButtonContainer.getTranslationY()) > AndroidUtilities.dp(4)) {
|
||||
View previousFabContainer = null;
|
||||
if (previousFab.getParent() != null) {
|
||||
previousFabContainer = (View) previousFab.getParent();
|
||||
}
|
||||
if (previousFab == null || floatingButtonContainer == null || previousFabContainer == null || previousFab.getVisibility() != View.VISIBLE || Math.abs(previousFabContainer.getTranslationY()) > AndroidUtilities.dp(4) || Math.abs(floatingButtonContainer.getTranslationY()) > AndroidUtilities.dp(4)) {
|
||||
return null;
|
||||
}
|
||||
previousFab.setVisibility(View.GONE);
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
package org.telegram.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.appwidget.AppWidgetManager;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import org.telegram.messenger.AccountInstance;
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ShortcutWidgetProvider;
|
||||
|
||||
public class ShortcutWidgetConfigActivity extends ExternalActionActivity {
|
||||
public class ContactsWidgetConfigActivity extends ExternalActionActivity {
|
||||
|
||||
private int creatingAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
|
||||
|
||||
|
@ -29,16 +25,8 @@ public class ShortcutWidgetConfigActivity extends ExternalActionActivity {
|
|||
args.putBoolean("onlySelect", true);
|
||||
args.putInt("dialogsType", 10);
|
||||
args.putBoolean("allowSwitchAccount", true);
|
||||
DialogsActivity fragment = new DialogsActivity(args);
|
||||
fragment.setDelegate((fragment1, dids, message, param) -> {
|
||||
AccountInstance.getInstance(fragment1.getCurrentAccount()).getMessagesStorage().putWidgetDialogs(creatingAppWidgetId, dids);
|
||||
|
||||
SharedPreferences preferences = ShortcutWidgetConfigActivity.this.getSharedPreferences("shortcut_widget", Activity.MODE_PRIVATE);
|
||||
preferences.edit().putInt("account" + creatingAppWidgetId, fragment1.getCurrentAccount()).commit();
|
||||
|
||||
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(ShortcutWidgetConfigActivity.this);
|
||||
ShortcutWidgetProvider.updateWidget(ShortcutWidgetConfigActivity.this, appWidgetManager, creatingAppWidgetId);
|
||||
|
||||
EditWidgetActivity fragment = new EditWidgetActivity(EditWidgetActivity.TYPE_CONTACTS, creatingAppWidgetId, false);
|
||||
fragment.setDelegate(dialogs -> {
|
||||
Intent resultValue = new Intent();
|
||||
resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, creatingAppWidgetId);
|
||||
setResult(RESULT_OK, resultValue);
|
|
@ -887,7 +887,6 @@ public class DataAutoDownloadActivity extends BaseFragment {
|
|||
} else {
|
||||
presetsStr[i] = LocaleController.getString("AutoDownloadCustom", R.string.AutoDownloadCustom);
|
||||
}
|
||||
|
||||
}
|
||||
slideChooseView.setOptions(selectedPreset, presetsStr);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@ import android.os.Bundle;
|
|||
import android.os.Vibrator;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Property;
|
||||
import android.util.SparseArray;
|
||||
import android.util.StateSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
|
@ -163,6 +162,7 @@ import org.telegram.ui.Components.SizeNotifierFrameLayout;
|
|||
import org.telegram.ui.Components.StickersAlert;
|
||||
import org.telegram.ui.Components.UndoView;
|
||||
import org.telegram.ui.Components.ViewPagerFixed;
|
||||
import org.webrtc.RecyclerItemsEnterAnimator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -200,6 +200,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
|||
private FlickerLoadingView progressView;
|
||||
private int lastItemsCount;
|
||||
private DialogsItemAnimator dialogsItemAnimator;
|
||||
private RecyclerItemsEnterAnimator recyclerItemsEnterAnimator;
|
||||
|
||||
public ViewPage(Context context) {
|
||||
super(context);
|
||||
|
@ -243,6 +244,8 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
|||
|
||||
private int initialDialogsType;
|
||||
|
||||
private boolean checkingImportDialog;
|
||||
|
||||
private int messagesCount;
|
||||
private int hasPoll;
|
||||
|
||||
|
@ -399,7 +402,6 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
|||
private float filterTabsMoveFrom;
|
||||
private float tabsYOffset;
|
||||
private float scrollAdditionalOffset;
|
||||
private SparseArray<Float> listAlphaItems = new SparseArray<>();
|
||||
|
||||
public final Property<DialogsActivity, Float> SCROLL_Y = new AnimationProperties.FloatProperty<DialogsActivity>("animationValue") {
|
||||
@Override
|
||||
|
@ -1142,16 +1144,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
|||
|
||||
@Override
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
View child = getChildAt(i);
|
||||
int position = getChildAdapterPosition(child);
|
||||
Float alpha = listAlphaItems.get(position, null);
|
||||
if (alpha == null) {
|
||||
child.setAlpha(1f);
|
||||
} else {
|
||||
child.setAlpha(alpha);
|
||||
}
|
||||
}
|
||||
parentPage.recyclerItemsEnterAnimator.dispatchDraw();
|
||||
super.dispatchDraw(canvas);
|
||||
if (slidingView != null && pacmanAnimation != null) {
|
||||
pacmanAnimation.draw(canvas, slidingView.getTop() + slidingView.getMeasuredHeight() / 2);
|
||||
|
@ -1675,22 +1668,27 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
|||
|
||||
getNotificationCenter().addObserver(this, NotificationCenter.didClearDatabase);
|
||||
|
||||
loadDialogs(getAccountInstance());
|
||||
getMessagesController().loadPinnedDialogs(folderId, 0, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void loadDialogs(AccountInstance accountInstance) {
|
||||
int currentAccount = accountInstance.getCurrentAccount();
|
||||
if (!dialogsLoaded[currentAccount]) {
|
||||
MessagesController messagesController = getMessagesController();
|
||||
MessagesController messagesController = accountInstance.getMessagesController();
|
||||
messagesController.loadGlobalNotificationsSettings();
|
||||
messagesController.loadDialogs(folderId, 0, 100, true);
|
||||
messagesController.loadDialogs(0, 0, 100, true);
|
||||
messagesController.loadHintDialogs();
|
||||
messagesController.loadUserInfo(getUserConfig().getCurrentUser(), false, classGuid);
|
||||
getContactsController().checkInviteText();
|
||||
getMediaDataController().loadRecents(MediaDataController.TYPE_FAVE, false, true, false);
|
||||
getMediaDataController().checkFeaturedStickers();
|
||||
messagesController.loadUserInfo(accountInstance.getUserConfig().getCurrentUser(), false, 0);
|
||||
accountInstance.getContactsController().checkInviteText();
|
||||
accountInstance.getMediaDataController().loadRecents(MediaDataController.TYPE_FAVE, false, true, false);
|
||||
accountInstance.getMediaDataController().checkFeaturedStickers();
|
||||
for (String emoji : messagesController.diceEmojies) {
|
||||
getMediaDataController().loadStickersByEmojiOrName(emoji, true, true);
|
||||
accountInstance.getMediaDataController().loadStickersByEmojiOrName(emoji, true, true);
|
||||
}
|
||||
dialogsLoaded[currentAccount] = true;
|
||||
}
|
||||
getMessagesController().loadPinnedDialogs(folderId, 0, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1744,8 +1742,10 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
|||
|
||||
@Override
|
||||
public void setTranslationY(float translationY) {
|
||||
if (translationY != getTranslationY()) {
|
||||
fragmentView.invalidate();
|
||||
}
|
||||
super.setTranslationY(translationY);
|
||||
fragmentView.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1963,10 +1963,12 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
|||
|
||||
@Override
|
||||
public void setTranslationY(float translationY) {
|
||||
super.setTranslationY(translationY);
|
||||
updateContextViewPosition();
|
||||
if (fragmentView != null) {
|
||||
fragmentView.invalidate();
|
||||
if (getTranslationY() != translationY) {
|
||||
super.setTranslationY(translationY);
|
||||
updateContextViewPosition();
|
||||
if (fragmentView != null) {
|
||||
fragmentView.invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2613,6 +2615,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
|||
}
|
||||
});
|
||||
viewPage.swipeController = new SwipeController(viewPage);
|
||||
viewPage.recyclerItemsEnterAnimator = new RecyclerItemsEnterAnimator(viewPage.listView);
|
||||
|
||||
viewPage.itemTouchhelper = new ItemTouchHelper(viewPage.swipeController);
|
||||
viewPage.itemTouchhelper.attachToRecyclerView(viewPage.listView);
|
||||
|
@ -3674,7 +3677,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
|||
if (!afterSignup) {
|
||||
tosAccepted = getUserConfig().unacceptedTermsOfService == null;
|
||||
} else {
|
||||
tosAccepted = false;
|
||||
tosAccepted = true;
|
||||
afterSignup = false;
|
||||
}
|
||||
if (tosAccepted && checkPermission && !onlySelect && Build.VERSION.SDK_INT >= 23) {
|
||||
|
@ -4071,6 +4074,8 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
|||
fragmentView.requestLayout();
|
||||
}
|
||||
|
||||
setSearchAnimationProgress(show ? 1f : 0);
|
||||
|
||||
viewPages[0].listView.setVerticalScrollBarEnabled(true);
|
||||
searchViewPager.setBackground(null);
|
||||
searchAnimator = null;
|
||||
|
@ -5762,13 +5767,13 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
|||
viewPages[a].dialogsAdapter.notifyDataSetChanged();
|
||||
int newItemCount = viewPages[a].dialogsAdapter.getItemCount();
|
||||
if (newItemCount > oldItemCount && initialDialogsType != 11 && initialDialogsType != 12 && initialDialogsType != 13) {
|
||||
showItemsAnimated(viewPages[a].listView, oldItemCount);
|
||||
viewPages[a].recyclerItemsEnterAnimator.showItemsAnimated(oldItemCount);
|
||||
}
|
||||
} else {
|
||||
updateVisibleRows(MessagesController.UPDATE_MASK_NEW_MESSAGE);
|
||||
int newItemCount = viewPages[a].dialogsAdapter.getItemCount();
|
||||
if (newItemCount > oldItemCount && initialDialogsType != 11 && initialDialogsType != 12 && initialDialogsType != 13) {
|
||||
showItemsAnimated(viewPages[a].listView, oldItemCount);
|
||||
viewPages[a].recyclerItemsEnterAnimator.showItemsAnimated(oldItemCount);
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
@ -5915,81 +5920,12 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
|||
searchViewPager.messagesDeleted(channelId, markAsDeletedMessages);
|
||||
}
|
||||
} else if (id == NotificationCenter.didClearDatabase) {
|
||||
for (int a = 0; a < viewPages.length; a++) {
|
||||
viewPages[a].dialogsAdapter.didDatabaseCleared();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showItemsAnimated(RecyclerListView listView, int from) {
|
||||
int n = listView.getChildCount();
|
||||
View progressView = null;
|
||||
for (int i = 0; i < n; i++) {
|
||||
View child = listView.getChildAt(i);
|
||||
if (child instanceof FlickerLoadingView) {
|
||||
progressView = child;
|
||||
}
|
||||
}
|
||||
final View finalProgressView = progressView;
|
||||
if (progressView != null) {
|
||||
listView.removeView(progressView);
|
||||
from--;
|
||||
}
|
||||
int finalFrom = from;
|
||||
listView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
||||
@Override
|
||||
public boolean onPreDraw() {
|
||||
listView.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
int n = listView.getChildCount();
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
for (int i = 0; i < n; i++) {
|
||||
View child = listView.getChildAt(i);
|
||||
int position = listView.getChildAdapterPosition(child);
|
||||
if (child != finalProgressView && position >= finalFrom - 1 && listAlphaItems.get(position, null) == null) {
|
||||
listAlphaItems.put(position, 0f);
|
||||
child.setAlpha(0);
|
||||
int s = Math.min(listView.getMeasuredHeight(), Math.max(0, child.getTop()));
|
||||
int delay = (int) ((s / (float) listView.getMeasuredHeight()) * 100);
|
||||
ValueAnimator a = ValueAnimator.ofFloat(0, 1f);
|
||||
a.addUpdateListener(valueAnimator -> {
|
||||
Float alpha = (Float) valueAnimator.getAnimatedValue();
|
||||
listAlphaItems.put(position, alpha);
|
||||
listView.invalidate();
|
||||
});
|
||||
a.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
listAlphaItems.remove(position);
|
||||
listView.invalidate();
|
||||
}
|
||||
});
|
||||
a.setStartDelay(delay);
|
||||
a.setDuration(200);
|
||||
animatorSet.playTogether(a);
|
||||
}
|
||||
if (viewPages != null) {
|
||||
for (int a = 0; a < viewPages.length; a++) {
|
||||
viewPages[a].dialogsAdapter.didDatabaseCleared();
|
||||
}
|
||||
|
||||
if (finalProgressView != null && finalProgressView.getParent() == null) {
|
||||
listView.addView(finalProgressView);
|
||||
RecyclerView.LayoutManager layoutManager = listView.getLayoutManager();
|
||||
if (layoutManager != null) {
|
||||
layoutManager.ignoreView(finalProgressView);
|
||||
Animator animator = ObjectAnimator.ofFloat(finalProgressView, View.ALPHA, finalProgressView.getAlpha(), 0);
|
||||
animator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
finalProgressView.setAlpha(1f);
|
||||
layoutManager.stopIgnoringView(finalProgressView);
|
||||
listView.removeView(finalProgressView);
|
||||
}
|
||||
});
|
||||
animator.start();
|
||||
}
|
||||
}
|
||||
animatorSet.start();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private String showingSuggestion;
|
||||
|
@ -6009,7 +5945,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
|||
if (showingSuggestion == null) {
|
||||
return;
|
||||
}
|
||||
getMessagesController().removeSuggestion(showingSuggestion);
|
||||
getMessagesController().removeSuggestion(0, showingSuggestion);
|
||||
showingSuggestion = null;
|
||||
showNextSupportedSuggestion();
|
||||
}
|
||||
|
@ -6294,28 +6230,55 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
|||
}
|
||||
}
|
||||
if (initialDialogsType == 11 || initialDialogsType == 12 || initialDialogsType == 13) {
|
||||
int lower_part = (int) dialog_id;
|
||||
TLRPC.User user = null;
|
||||
TLRPC.Chat chat = null;
|
||||
if (lower_part > 0) {
|
||||
user = getMessagesController().getUser(lower_part);
|
||||
if (checkingImportDialog) {
|
||||
return;
|
||||
}
|
||||
int lowerId = (int) dialog_id;
|
||||
TLRPC.User user;
|
||||
TLRPC.Chat chat;
|
||||
if (lowerId > 0) {
|
||||
user = getMessagesController().getUser(lowerId);
|
||||
chat = null;
|
||||
if (!user.mutual_contact) {
|
||||
getUndoView().showWithAction(dialog_id, UndoView.ACTION_IMPORT_NOT_MUTUAL, null);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
chat = getMessagesController().getChat(-lower_part);
|
||||
user = null;
|
||||
chat = getMessagesController().getChat(-lowerId);
|
||||
if (!ChatObject.hasAdminRights(chat) || !ChatObject.canChangeChatInfo(chat)) {
|
||||
getUndoView().showWithAction(dialog_id, UndoView.ACTION_IMPORT_GROUP_NOT_ADMIN, null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
AlertsCreator.createImportDialogAlert(this, arguments.getString("importTitle"), user, chat, () -> {
|
||||
setDialogsListFrozen(true);
|
||||
ArrayList<Long> dids = new ArrayList<>();
|
||||
dids.add(dialog_id);
|
||||
delegate.didSelectDialogs(DialogsActivity.this, dids, null, param);
|
||||
});
|
||||
final AlertDialog progressDialog = new AlertDialog(getParentActivity(), 3);
|
||||
TLRPC.TL_messages_checkHistoryImportPeer req = new TLRPC.TL_messages_checkHistoryImportPeer();
|
||||
req.peer = getMessagesController().getInputPeer(lowerId);
|
||||
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
try {
|
||||
progressDialog.dismiss();
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
checkingImportDialog = false;
|
||||
if (response != null) {
|
||||
TLRPC.TL_messages_checkedHistoryImportPeer res = (TLRPC.TL_messages_checkedHistoryImportPeer) response;
|
||||
AlertsCreator.createImportDialogAlert(this, arguments.getString("importTitle"), res.confirm_text, user, chat, () -> {
|
||||
setDialogsListFrozen(true);
|
||||
ArrayList<Long> dids = new ArrayList<>();
|
||||
dids.add(dialog_id);
|
||||
delegate.didSelectDialogs(DialogsActivity.this, dids, null, param);
|
||||
});
|
||||
} else {
|
||||
AlertsCreator.processError(currentAccount, error, this, req);
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.historyImportProgressChanged, dialog_id, req, error);
|
||||
}
|
||||
}));
|
||||
try {
|
||||
progressDialog.showDelayed(300);
|
||||
} catch (Exception ignore) {
|
||||
|
||||
}
|
||||
} else if (useAlert && (selectAlertString != null && selectAlertStringGroup != null || addToGroupAlertString != null)) {
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -34,7 +34,7 @@ public class FeedWidgetConfigActivity extends ExternalActionActivity {
|
|||
fragment.setDelegate((fragment1, dids, message, param) -> {
|
||||
AccountInstance.getInstance(fragment1.getCurrentAccount()).getMessagesStorage().putWidgetDialogs(creatingAppWidgetId, dids);
|
||||
|
||||
SharedPreferences preferences = FeedWidgetConfigActivity.this.getSharedPreferences("feed_widget", Activity.MODE_PRIVATE);
|
||||
SharedPreferences preferences = FeedWidgetConfigActivity.this.getSharedPreferences("shortcut_widget", Activity.MODE_PRIVATE);
|
||||
preferences.edit().putInt("account" + creatingAppWidgetId, fragment1.getCurrentAccount()).commit();
|
||||
preferences.edit().putLong("dialogId" + creatingAppWidgetId, dids.get(0)).commit();
|
||||
|
||||
|
|
|
@ -792,7 +792,9 @@ public class GroupCallActivity extends BottomSheet implements NotificationCenter
|
|||
if (num == 6) {
|
||||
String text = (String) args[1];
|
||||
String error;
|
||||
if ("ANONYMOUS_CALLS_DISABLED".equals(text) || "GROUPCALL_ANONYMOUS_FORBIDDEN".equals(text)) {
|
||||
if ("GROUPCALL_PARTICIPANTS_TOO_MUCH".equals(text)) {
|
||||
error = LocaleController.getString("VoipGroupTooMuch", R.string.VoipGroupTooMuch);
|
||||
} else if ("ANONYMOUS_CALLS_DISABLED".equals(text) || "GROUPCALL_ANONYMOUS_FORBIDDEN".equals(text)) {
|
||||
error = LocaleController.getString("VoipGroupJoinAnonymousAdmin", R.string.VoipGroupJoinAnonymousAdmin);
|
||||
} else {
|
||||
error = LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred) + "\n" + text;
|
||||
|
@ -2831,7 +2833,7 @@ public class GroupCallActivity extends BottomSheet implements NotificationCenter
|
|||
items.add(LocaleController.getString("VoipGroupOpenProfile", R.string.VoipGroupOpenProfile));
|
||||
icons.add(R.drawable.msg_openprofile);
|
||||
options.add(6);
|
||||
if (!isAdmin) {
|
||||
if (!isAdmin && ChatObject.canBlockUsers(currentChat)) {
|
||||
items.add(LocaleController.getString("VoipGroupUserRemove", R.string.VoipGroupUserRemove));
|
||||
icons.add(R.drawable.msg_block2);
|
||||
options.add(2);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue