update to 9.6.0
|
@ -435,7 +435,7 @@ target_include_directories(breakpad PUBLIC
|
|||
#voip
|
||||
include(${CMAKE_HOME_DIRECTORY}/voip/CMakeLists.txt)
|
||||
|
||||
set(NATIVE_LIB "tmessages.44")
|
||||
set(NATIVE_LIB "tmessages.45")
|
||||
|
||||
#tmessages
|
||||
add_library(${NATIVE_LIB} SHARED
|
||||
|
|
|
@ -40,6 +40,7 @@ static const std::string av_make_error_str(int errnum) {
|
|||
jclass jclass_AnimatedFileDrawableStream;
|
||||
jmethodID jclass_AnimatedFileDrawableStream_read;
|
||||
jmethodID jclass_AnimatedFileDrawableStream_cancel;
|
||||
jmethodID jclass_AnimatedFileDrawableStream_isCanceled;
|
||||
jmethodID jclass_AnimatedFileDrawableStream_isFinishedLoadingFile;
|
||||
jmethodID jclass_AnimatedFileDrawableStream_getFinishedFilePath;
|
||||
|
||||
|
@ -792,7 +793,7 @@ int readCallback(void *opaque, uint8_t *buf, int buf_size) {
|
|||
javaVm->DetachCurrentThread();
|
||||
}
|
||||
if (buf_size == 0) {
|
||||
return AVERROR_EOF;
|
||||
return AVERROR_EXIT;
|
||||
}
|
||||
int ret = (int) read(info->fd, buf, (size_t) buf_size);
|
||||
if (ret <= 0) {
|
||||
|
@ -1102,7 +1103,7 @@ extern "C" JNIEXPORT void JNICALL Java_org_telegram_ui_Components_AnimatedFileDr
|
|||
return;
|
||||
}
|
||||
int got_frame = 0;
|
||||
int32_t tries = 1000;
|
||||
int32_t tries = 100;
|
||||
while (tries > 0) {
|
||||
if (info->pkt.size == 0) {
|
||||
ret = av_read_frame(info->fmt_ctx, &info->pkt);
|
||||
|
@ -1235,6 +1236,26 @@ extern "C" JNIEXPORT int JNICALL Java_org_telegram_ui_Components_AnimatedFileDra
|
|||
int32_t tries = 1000;
|
||||
bool readNextPacket = true;
|
||||
while (tries > 0) {
|
||||
if (info->stream != nullptr) {
|
||||
JNIEnv *jniEnv = nullptr;
|
||||
JavaVMAttachArgs jvmArgs;
|
||||
jvmArgs.version = JNI_VERSION_1_6;
|
||||
|
||||
bool attached;
|
||||
if (JNI_EDETACHED == javaVm->GetEnv((void **) &jniEnv, JNI_VERSION_1_6)) {
|
||||
javaVm->AttachCurrentThread(&jniEnv, &jvmArgs);
|
||||
attached = true;
|
||||
} else {
|
||||
attached = false;
|
||||
}
|
||||
jboolean canceled = jniEnv->CallBooleanMethod(info->stream, jclass_AnimatedFileDrawableStream_isCanceled);
|
||||
if (attached) {
|
||||
javaVm->DetachCurrentThread();
|
||||
}
|
||||
if (canceled) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (info->pkt.size == 0 && readNextPacket) {
|
||||
ret = av_read_frame(info->fmt_ctx, &info->pkt);
|
||||
if (ret >= 0) {
|
||||
|
@ -1309,6 +1330,26 @@ extern "C" JNIEXPORT jint JNICALL Java_org_telegram_ui_Components_AnimatedFileDr
|
|||
int32_t triesCount = preview ? 50 : 6;
|
||||
//info->has_decoded_frames = false;
|
||||
while (!info->stopped && triesCount != 0) {
|
||||
if (info->stream != nullptr) {
|
||||
JNIEnv *jniEnv = nullptr;
|
||||
JavaVMAttachArgs jvmArgs;
|
||||
jvmArgs.version = JNI_VERSION_1_6;
|
||||
|
||||
bool attached;
|
||||
if (JNI_EDETACHED == javaVm->GetEnv((void **) &jniEnv, JNI_VERSION_1_6)) {
|
||||
javaVm->AttachCurrentThread(&jniEnv, &jvmArgs);
|
||||
attached = true;
|
||||
} else {
|
||||
attached = false;
|
||||
}
|
||||
jboolean canceled = jniEnv->CallBooleanMethod(info->stream, jclass_AnimatedFileDrawableStream_isCanceled);
|
||||
if (attached) {
|
||||
javaVm->DetachCurrentThread();
|
||||
}
|
||||
if (canceled) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (info->pkt.size == 0) {
|
||||
ret = av_read_frame(info->fmt_ctx, &info->pkt);
|
||||
if (ret >= 0) {
|
||||
|
@ -1400,6 +1441,10 @@ extern "C" jint videoOnJNILoad(JavaVM *vm, JNIEnv *env) {
|
|||
if (jclass_AnimatedFileDrawableStream_isFinishedLoadingFile == 0) {
|
||||
return JNI_FALSE;
|
||||
}
|
||||
jclass_AnimatedFileDrawableStream_isCanceled = env->GetMethodID(jclass_AnimatedFileDrawableStream, "isCanceled", "()Z");
|
||||
if (jclass_AnimatedFileDrawableStream_isCanceled == 0) {
|
||||
return JNI_FALSE;
|
||||
}
|
||||
jclass_AnimatedFileDrawableStream_getFinishedFilePath = env->GetMethodID(jclass_AnimatedFileDrawableStream, "getFinishedFilePath", "()Ljava/lang/String;");
|
||||
if (jclass_AnimatedFileDrawableStream_getFinishedFilePath == 0) {
|
||||
return JNI_FALSE;
|
||||
|
|
|
@ -1297,6 +1297,12 @@ void ConnectionsManager::processServerResponse(TLObject *message, int64_t messag
|
|||
request->serverFailureCount++;
|
||||
}
|
||||
discardResponse = true;
|
||||
} else if (error->error_code == -504) {
|
||||
discardResponse = (request->requestFlags & RequestFlagIgnoreFloodWait) == 0;
|
||||
request->failedByFloodWait = 2;
|
||||
request->startTime = 0;
|
||||
request->startTimeMillis = 0;
|
||||
request->minStartTime = (int32_t) (getCurrentTimeMonotonicMillis() / 1000 + 2);
|
||||
} else if (error->error_code == 420) {
|
||||
int32_t waitTime = 2;
|
||||
static std::string floodWait = "FLOOD_WAIT_";
|
||||
|
|
|
@ -79,7 +79,7 @@ avatar_actionBarSelectorGreen=-8684677
|
|||
chat_inLoaderSelected=-13394195
|
||||
chat_outLocationIcon=-452984833
|
||||
avatar_actionBarIconViolet=-8684677
|
||||
dialogTextRed=-1682082
|
||||
text_RedBold=-1682082
|
||||
chat_inBubbleShadow=1981626195
|
||||
chat_outAudioProgress=-10907938
|
||||
dialogProgressCircle=-12281108
|
||||
|
@ -308,7 +308,6 @@ chat_outMenu=-1862270977
|
|||
statisticChartActiveLine=335544320
|
||||
chats_secretName=-16734706
|
||||
chat_outReplyMediaMessageSelectedText=-1056964609
|
||||
chat_reportSpam=-704436
|
||||
avatar_subtitleInProfileCyan=-16777216
|
||||
chat_serviceText=-1
|
||||
chats_attachMessage=-13268780
|
||||
|
|
|
@ -118,7 +118,7 @@ avatar_actionBarSelectorGreen=-12758164
|
|||
chat_outLocationIcon=-1
|
||||
chat_inLoaderSelected=-10445358
|
||||
location_liveLocationProgress=-9919529
|
||||
dialogTextRed=-1152913
|
||||
text_RedBold=-1152913
|
||||
chat_inBubbleShadow=838860800
|
||||
chat_outAudioProgress=-1
|
||||
dialogProgressCircle=-10177041
|
||||
|
@ -132,9 +132,8 @@ dialogLineProgressBackground=-13548718
|
|||
chat_inReplyNameText=-8796932
|
||||
chat_outAudioPerfomerSelectedText=-4268038
|
||||
actionBarActionModeDefaultIcon=-1
|
||||
windowBackgroundWhiteRedText4=-3187617
|
||||
chat_goDownButtonIcon=-1
|
||||
windowBackgroundWhiteRedText5=-1152913
|
||||
text_RedRegular=-1152913
|
||||
chat_outAudioSelectedProgress=-1
|
||||
chat_messageTextOut=-328966
|
||||
chat_inInstant=-8796932
|
||||
|
@ -446,9 +445,7 @@ chats_secretName=-9316522
|
|||
chat_inMenu=2039722445
|
||||
chat_recordVoiceCancel=-9192978
|
||||
chat_outReplyMediaMessageSelectedText=-1
|
||||
chat_reportSpam=-1481631
|
||||
chat_messageTextIn=-328966
|
||||
dialogRedIcon=-554801041
|
||||
avatar_subtitleInProfileCyan=-7628894
|
||||
chats_attachMessage=-8548712
|
||||
chat_topPanelBackground=-14602949
|
||||
|
|
|
@ -83,7 +83,7 @@ avatar_actionBarSelectorGreen=-8684677
|
|||
chat_inLoaderSelected=-13394195
|
||||
chat_outLocationIcon=-452984833
|
||||
avatar_actionBarIconViolet=-8684677
|
||||
dialogTextRed=-1682082
|
||||
text_RedBold=-1682082
|
||||
chat_inBubbleShadow=1914707
|
||||
chat_outAudioProgress=-12155183
|
||||
dialogProgressCircle=-12281108
|
||||
|
@ -334,7 +334,6 @@ chat_outMenu=-6500865
|
|||
statisticChartActiveLine=335544320
|
||||
chats_secretName=-16734706
|
||||
chat_outReplyMediaMessageSelectedText=-3676417
|
||||
chat_reportSpam=-704436
|
||||
avatar_subtitleInProfileCyan=-16777216
|
||||
chat_serviceText=-13092808
|
||||
chats_attachMessage=-14321214
|
||||
|
|
BIN
TMessagesProj/src/main/assets/emoji/compound/0_-1_0.png
Normal file
After Width: | Height: | Size: 780 B |
BIN
TMessagesProj/src/main/assets/emoji/compound/0_-1_1.png
Normal file
After Width: | Height: | Size: 744 B |
BIN
TMessagesProj/src/main/assets/emoji/compound/0_0_0.png
Normal file
After Width: | Height: | Size: 754 B |
BIN
TMessagesProj/src/main/assets/emoji/compound/0_0_1.png
Normal file
After Width: | Height: | Size: 760 B |
BIN
TMessagesProj/src/main/assets/emoji/compound/0_1_0.png
Normal file
After Width: | Height: | Size: 744 B |
BIN
TMessagesProj/src/main/assets/emoji/compound/0_1_1.png
Normal file
After Width: | Height: | Size: 642 B |
BIN
TMessagesProj/src/main/assets/emoji/compound/0_2_0.png
Normal file
After Width: | Height: | Size: 664 B |
BIN
TMessagesProj/src/main/assets/emoji/compound/0_2_1.png
Normal file
After Width: | Height: | Size: 660 B |
BIN
TMessagesProj/src/main/assets/emoji/compound/0_3_0.png
Normal file
After Width: | Height: | Size: 596 B |
BIN
TMessagesProj/src/main/assets/emoji/compound/0_3_1.png
Normal file
After Width: | Height: | Size: 612 B |
BIN
TMessagesProj/src/main/assets/emoji/compound/0_4_0.png
Normal file
After Width: | Height: | Size: 561 B |
BIN
TMessagesProj/src/main/assets/emoji/compound/0_4_1.png
Normal file
After Width: | Height: | Size: 520 B |
|
@ -117,12 +117,11 @@ listSelector=771751936
|
|||
chat_outPreviewInstantText=-1
|
||||
chat_inMenuSelected=-1517440301
|
||||
avatar_backgroundOrange=-869276
|
||||
avatar_background2Orange=-1734333
|
||||
avatar_actionBarSelectorGreen=-12758164
|
||||
chat_outLocationIcon=-1
|
||||
chat_inLoaderSelected=-11297295
|
||||
location_liveLocationProgress=-9919529
|
||||
dialogTextRed=-1152913
|
||||
text_RedBold=-1152913
|
||||
chat_inBubbleShadow=838860800
|
||||
chat_outAudioProgress=-1
|
||||
dialogProgressCircle=-10177041
|
||||
|
@ -136,9 +135,8 @@ dialogLineProgressBackground=-12303292
|
|||
chat_inReplyNameText=-8796932
|
||||
chat_outAudioPerfomerSelectedText=-7023626
|
||||
actionBarActionModeDefaultIcon=-1
|
||||
windowBackgroundWhiteRedText4=-3187617
|
||||
chat_goDownButtonIcon=-1
|
||||
windowBackgroundWhiteRedText5=-1152913
|
||||
text_RedRegular=-1152913
|
||||
chats_onlineCircle=-13130503
|
||||
chat_outAudioSelectedProgress=-1
|
||||
chat_messageTextOut=-328966
|
||||
|
@ -185,7 +183,6 @@ calls_callReceivedGreenIcon=-12001930
|
|||
chats_pinnedOverlay=201326591
|
||||
windowBackgroundWhiteInputField=-11513776
|
||||
avatar_backgroundRed=-2326437
|
||||
avatar_background2Red=-2863816
|
||||
chat_emojiPanelBadgeBackground=-11291403
|
||||
chat_inForwardedNameText=-8930052
|
||||
chats_actionBackground=-10575653
|
||||
|
@ -473,9 +470,7 @@ chats_secretName=-9316522
|
|||
chat_inMenu=-10656924
|
||||
chat_recordVoiceCancel=-10638868
|
||||
chat_outReplyMediaMessageSelectedText=-7023626
|
||||
chat_reportSpam=-1481631
|
||||
chat_messageTextIn=-328966
|
||||
dialogRedIcon=-554801041
|
||||
avatar_subtitleInProfileCyan=-7628894
|
||||
chats_attachMessage=-8224126
|
||||
chat_topPanelBackground=-15066597
|
||||
|
|
|
@ -133,6 +133,7 @@ import org.telegram.ui.ActionBar.INavigationLayout;
|
|||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Cells.TextDetailSettingsCell;
|
||||
import org.telegram.ui.ChatActivity;
|
||||
import org.telegram.ui.ChatBackgroundDrawable;
|
||||
import org.telegram.ui.Components.AlertsCreator;
|
||||
import org.telegram.ui.Components.BackgroundGradientDrawable;
|
||||
import org.telegram.ui.Components.Bulletin;
|
||||
|
@ -217,6 +218,7 @@ public class AndroidUtilities {
|
|||
public static float density = 1;
|
||||
public static Point displaySize = new Point();
|
||||
public static float screenRefreshRate = 60;
|
||||
public static float screenRefreshTime = 1000 / screenRefreshRate;
|
||||
public static int roundMessageSize;
|
||||
public static int roundPlayingMessageSize;
|
||||
public static int roundMessageInset;
|
||||
|
@ -831,6 +833,10 @@ public class AndroidUtilities {
|
|||
}
|
||||
|
||||
public static int[] calcDrawableColor(Drawable drawable) {
|
||||
if (drawable instanceof ChatBackgroundDrawable) {
|
||||
ChatBackgroundDrawable chatBackgroundDrawable = (ChatBackgroundDrawable) drawable;
|
||||
return calcDrawableColor(chatBackgroundDrawable.getDrawable());
|
||||
}
|
||||
int bitmapColor = 0xff000000;
|
||||
int[] result = new int[4];
|
||||
try {
|
||||
|
@ -2070,6 +2076,7 @@ public class AndroidUtilities {
|
|||
display.getMetrics(displayMetrics);
|
||||
display.getSize(displaySize);
|
||||
screenRefreshRate = display.getRefreshRate();
|
||||
screenRefreshTime = 1000 / screenRefreshRate;
|
||||
}
|
||||
}
|
||||
if (configuration.screenWidthDp != Configuration.SCREEN_WIDTH_DP_UNDEFINED) {
|
||||
|
@ -3821,7 +3828,7 @@ public class AndroidUtilities {
|
|||
ConnectionsManager.getInstance(UserConfig.selectedAccount).checkProxy(address, Integer.parseInt(port), user, password, secret, time -> AndroidUtilities.runOnUIThread(() -> {
|
||||
if (time == -1) {
|
||||
cell.getTextView().setText(LocaleController.getString(R.string.Unavailable));
|
||||
cell.getTextView().setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText4));
|
||||
cell.getTextView().setTextColor(Theme.getColor(Theme.key_text_RedRegular));
|
||||
} else {
|
||||
cell.getTextView().setText(LocaleController.getString(R.string.Available) + ", " + LocaleController.formatString(R.string.Ping, time));
|
||||
cell.getTextView().setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGreenText));
|
||||
|
@ -3829,7 +3836,7 @@ public class AndroidUtilities {
|
|||
}));
|
||||
} catch (NumberFormatException ignored) {
|
||||
cell.getTextView().setText(LocaleController.getString(R.string.Unavailable));
|
||||
cell.getTextView().setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText4));
|
||||
cell.getTextView().setTextColor(Theme.getColor(Theme.key_text_RedRegular));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4413,6 +4420,9 @@ public class AndroidUtilities {
|
|||
}
|
||||
|
||||
public static void setNavigationBarColor(Window window, int color, boolean animated, IntColorCallback onUpdate) {
|
||||
if (window == null) {
|
||||
return;
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
if (navigationBarColorAnimators != null) {
|
||||
ValueAnimator animator = navigationBarColorAnimators.get(window);
|
||||
|
@ -4579,10 +4589,14 @@ public class AndroidUtilities {
|
|||
}
|
||||
|
||||
public static void updateViewVisibilityAnimated(View view, boolean show) {
|
||||
updateViewVisibilityAnimated(view, show, 1f, true);
|
||||
updateViewVisibilityAnimated(view, show, 1f, true, true);
|
||||
}
|
||||
|
||||
public static void updateViewVisibilityAnimated(View view, boolean show, float scaleFactor, boolean animated) {
|
||||
updateViewVisibilityAnimated(view, show, scaleFactor, true, animated);
|
||||
}
|
||||
|
||||
public static void updateViewVisibilityAnimated(View view, boolean show, float scaleFactor, boolean goneOnHide, boolean animated) {
|
||||
if (view == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -4592,7 +4606,7 @@ public class AndroidUtilities {
|
|||
|
||||
if (!animated) {
|
||||
view.animate().setListener(null).cancel();
|
||||
view.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
view.setVisibility(show ? View.VISIBLE : (goneOnHide ? View.GONE : View.INVISIBLE));
|
||||
view.setTag(show ? 1 : null);
|
||||
view.setAlpha(1f);
|
||||
view.setScaleX(1f);
|
||||
|
@ -4609,7 +4623,7 @@ public class AndroidUtilities {
|
|||
view.setTag(1);
|
||||
} else if (!show && view.getTag() != null) {
|
||||
view.animate().setListener(null).cancel();
|
||||
view.animate().alpha(0).scaleY(scaleFactor).scaleX(scaleFactor).setListener(new HideViewAfterAnimation(view)).setDuration(150).start();
|
||||
view.animate().alpha(0).scaleY(scaleFactor).scaleX(scaleFactor).setListener(new HideViewAfterAnimation(view, goneOnHide)).setDuration(150).start();
|
||||
view.setTag(null);
|
||||
}
|
||||
}
|
||||
|
@ -5061,4 +5075,16 @@ public class AndroidUtilities {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isActivityRunning(Activity activity) {
|
||||
if (activity == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
return !activity.isDestroyed() && !activity.isFinishing();
|
||||
} else {
|
||||
return !activity.isFinishing();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class AnimatedFileDrawableStream implements FileLoadOperationStream {
|
|||
synchronized (sync) {
|
||||
if (canceled) {
|
||||
debugCanceledCount++;
|
||||
if (!debugReportSend && debugCanceledCount > 100) {
|
||||
if (!debugReportSend && debugCanceledCount > 200) {
|
||||
debugReportSend = true;
|
||||
if (BuildVars.DEBUG_PRIVATE_VERSION) {
|
||||
throw new RuntimeException("infinity stream reading!!!");
|
||||
|
@ -167,4 +167,8 @@ public class AnimatedFileDrawableStream implements FileLoadOperationStream {
|
|||
countDownLatch.countDown();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCanceled() {
|
||||
return canceled;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,8 @@ public class BillingController implements PurchasesUpdatedListener, BillingClien
|
|||
|
||||
private static BillingController instance;
|
||||
|
||||
public static boolean billingClientEmpty;
|
||||
|
||||
private Map<String, Consumer<BillingResult>> resultListeners = new HashMap<>();
|
||||
private List<String> requestingTokens = new ArrayList<>();
|
||||
private String lastPremiumTransaction;
|
||||
|
@ -128,6 +130,14 @@ public class BillingController implements PurchasesUpdatedListener, BillingClien
|
|||
}
|
||||
}
|
||||
|
||||
private void switchToInvoice() {
|
||||
if (billingClientEmpty) {
|
||||
return;
|
||||
}
|
||||
billingClientEmpty = true;
|
||||
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.billingProductDetailsUpdated);
|
||||
}
|
||||
|
||||
private void parseCurrencies(JSONObject obj) {
|
||||
Iterator<String> it = obj.keys();
|
||||
while (it.hasNext()) {
|
||||
|
@ -318,18 +328,25 @@ public class BillingController implements PurchasesUpdatedListener, BillingClien
|
|||
FileLog.d("Billing setup finished with result " + setupBillingResult);
|
||||
if (setupBillingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
|
||||
queryProductDetails(Collections.singletonList(PREMIUM_PRODUCT), (billingResult, list) -> {
|
||||
FileLog.d("Query product details finished " + billingResult + ", " + list);
|
||||
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
|
||||
for (ProductDetails details : list) {
|
||||
if (details.getProductId().equals(PREMIUM_PRODUCT_ID)) {
|
||||
PREMIUM_PRODUCT_DETAILS = details;
|
||||
}
|
||||
}
|
||||
|
||||
AndroidUtilities.runOnUIThread(() -> NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.billingProductDetailsUpdated));
|
||||
if (PREMIUM_PRODUCT_DETAILS == null) {
|
||||
switchToInvoice();
|
||||
} else {
|
||||
AndroidUtilities.runOnUIThread(() -> NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.billingProductDetailsUpdated));
|
||||
}
|
||||
} else {
|
||||
switchToInvoice();
|
||||
}
|
||||
});
|
||||
|
||||
queryPurchases(BillingClient.ProductType.SUBS, this::onPurchasesUpdated);
|
||||
} else {
|
||||
switchToInvoice();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ public class BuildVars {
|
|||
public static boolean USE_CLOUD_STRINGS = true;
|
||||
public static boolean CHECK_UPDATES = true;
|
||||
public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29;
|
||||
public static int BUILD_VERSION = 3252;
|
||||
public static String BUILD_VERSION_STRING = "9.5.8";
|
||||
public static int BUILD_VERSION = 3319;
|
||||
public static String BUILD_VERSION_STRING = "9.6.0";
|
||||
public static int APP_ID = 4;
|
||||
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class BuildVars {
|
|||
}
|
||||
|
||||
public static boolean useInvoiceBilling() {
|
||||
return DEBUG_VERSION || isStandaloneApp() || isBetaApp() || isHuaweiStoreApp() || hasDirectCurrency();
|
||||
return BillingController.billingClientEmpty || DEBUG_VERSION || isStandaloneApp() || isBetaApp() || isHuaweiStoreApp() || hasDirectCurrency();
|
||||
}
|
||||
|
||||
private static boolean hasDirectCurrency() {
|
||||
|
|
|
@ -12,6 +12,8 @@ import org.telegram.tgnet.ResultCallback;
|
|||
import org.telegram.tgnet.SerializedData;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.EmojiThemes;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.ChatBackgroundDrawable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
@ -64,7 +66,7 @@ public class ChatThemeController extends BaseController {
|
|||
}
|
||||
|
||||
boolean needReload = System.currentTimeMillis() - lastReloadTimeMs > reloadTimeoutMs;
|
||||
if (allChatThemes == null || allChatThemes.isEmpty() || needReload) {
|
||||
if (true || allChatThemes == null || allChatThemes.isEmpty() || needReload) {
|
||||
TLRPC.TL_account_getChatThemes request = new TLRPC.TL_account_getChatThemes();
|
||||
request.hash = themesHash;
|
||||
ConnectionsManager.getInstance(UserConfig.selectedAccount).sendRequest(request, (response, error) -> chatThemeQueue.postRunnable(() -> {
|
||||
|
@ -93,7 +95,11 @@ public class ChatThemeController extends BaseController {
|
|||
}
|
||||
editor.apply();
|
||||
} else if (response instanceof TLRPC.TL_account_themesNotModified) {
|
||||
chatThemes = getAllChatThemesFromPrefs();
|
||||
// if (allChatThemes == null || allChatThemes.isEmpty()) {
|
||||
chatThemes = getAllChatThemesFromPrefs();
|
||||
// } else {
|
||||
// // return;
|
||||
// }
|
||||
} else {
|
||||
chatThemes = null;
|
||||
isError = true;
|
||||
|
@ -112,7 +118,8 @@ public class ChatThemeController extends BaseController {
|
|||
});
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
}
|
||||
if (allChatThemes != null && !allChatThemes.isEmpty()) {
|
||||
List<EmojiThemes> chatThemes = new ArrayList<>(allChatThemes);
|
||||
if (withDefault && !chatThemes.get(0).showAsDefaultStub) {
|
||||
chatThemes.add(0, EmojiThemes.createChatThemesDefault());
|
||||
|
@ -198,6 +205,19 @@ public class ChatThemeController extends BaseController {
|
|||
super(num);
|
||||
}
|
||||
|
||||
public static boolean equals(TLRPC.WallPaper wallPaper, TLRPC.WallPaper oldWallpaper) {
|
||||
if (wallPaper == null && oldWallpaper == null) {
|
||||
return true;
|
||||
}
|
||||
if (wallPaper != null && oldWallpaper != null) {
|
||||
if (wallPaper.uploadingImage != null) {
|
||||
return TextUtils.equals(oldWallpaper.uploadingImage, wallPaper.uploadingImage);
|
||||
}
|
||||
return wallPaper.id == oldWallpaper.id && TextUtils.equals(ChatBackgroundDrawable.hash(wallPaper.settings), ChatBackgroundDrawable.hash(oldWallpaper.settings));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setDialogTheme(long dialogId, String emoticon, boolean sendRequest) {
|
||||
String oldEmoticon = dialogEmoticonsMap.get(dialogId);
|
||||
if (TextUtils.equals(oldEmoticon, emoticon)) {
|
||||
|
@ -210,6 +230,20 @@ public class ChatThemeController extends BaseController {
|
|||
dialogEmoticonsMap.put(dialogId, emoticon);
|
||||
}
|
||||
|
||||
if (dialogId >= 0) {
|
||||
TLRPC.UserFull userFull = getMessagesController().getUserFull(dialogId);
|
||||
if (userFull != null) {
|
||||
userFull.theme_emoticon = emoticon;
|
||||
getMessagesStorage().updateUserInfo(userFull, true);
|
||||
}
|
||||
} else {
|
||||
TLRPC.ChatFull chatFull = getMessagesController().getChatFull(-dialogId);
|
||||
if (chatFull != null) {
|
||||
chatFull.theme_emoticon = emoticon;
|
||||
getMessagesStorage().updateChatInfo(chatFull, true);
|
||||
}
|
||||
}
|
||||
|
||||
getEmojiSharedPreferences().edit()
|
||||
.putString("chatTheme_" + currentAccount + "_" + dialogId, emoticon)
|
||||
.apply();
|
||||
|
@ -238,6 +272,45 @@ public class ChatThemeController extends BaseController {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void saveChatWallpaper(long dialogId, TLRPC.WallPaper wallPaper) {
|
||||
if (dialogId < 0) {
|
||||
return;
|
||||
}
|
||||
if (wallPaper != null) {
|
||||
SerializedData data = new SerializedData(wallPaper.getObjectSize());
|
||||
wallPaper.serializeToStream(data);
|
||||
String wallpaperString = Utilities.bytesToHex(data.toByteArray());
|
||||
|
||||
getEmojiSharedPreferences().edit()
|
||||
.putString("chatWallpaper_" + currentAccount + "_" + dialogId, wallpaperString)
|
||||
.apply();
|
||||
} else {
|
||||
getEmojiSharedPreferences().edit()
|
||||
.remove("chatWallpaper_" + currentAccount + "_" + dialogId)
|
||||
.apply();
|
||||
}
|
||||
}
|
||||
|
||||
public TLRPC.WallPaper getDialogWallpaper(long dialogId) {
|
||||
if (dialogId < 0) {
|
||||
return null;
|
||||
}
|
||||
TLRPC.UserFull userFull = getMessagesController().getUserFull(dialogId);
|
||||
if (userFull != null) {
|
||||
return userFull.wallpaper;
|
||||
}
|
||||
String wallpaperString = getEmojiSharedPreferences().getString("chatWallpaper_" + currentAccount + "_" + dialogId, null);
|
||||
if (wallpaperString != null) {
|
||||
SerializedData serializedData = new SerializedData(Utilities.hexToBytes(wallpaperString));
|
||||
try {
|
||||
return TLRPC.WallPaper.TLdeserialize(serializedData, serializedData.readInt32(true), true);
|
||||
} catch (Throwable e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void preloadAllWallpaperImages(boolean isDark) {
|
||||
for (EmojiThemes chatTheme : allChatThemes) {
|
||||
TLRPC.TL_theme theme = chatTheme.getTlTheme(isDark ? 1 : 0);
|
||||
|
@ -328,4 +401,135 @@ public class ChatThemeController extends BaseController {
|
|||
lastReloadTimeMs = 0;
|
||||
getSharedPreferences().edit().clear().apply();
|
||||
}
|
||||
|
||||
public void clearWallpaper(long dialogId) {
|
||||
TLRPC.TL_messages_setChatWallPaper req = new TLRPC.TL_messages_setChatWallPaper();
|
||||
if (dialogId > 0) {
|
||||
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(dialogId);
|
||||
req.peer = MessagesController.getInputPeer(user);
|
||||
TLRPC.UserFull userFull = getMessagesController().getUserFull(dialogId);
|
||||
if (userFull != null) {
|
||||
userFull.wallpaper = null;
|
||||
userFull.flags &= ~16777216;
|
||||
getMessagesStorage().updateUserInfo(userFull, false);
|
||||
}
|
||||
saveChatWallpaper(dialogId, null);
|
||||
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.userInfoDidLoad, dialogId, userFull);
|
||||
} else {
|
||||
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-dialogId);
|
||||
req.peer = MessagesController.getInputPeer(chat);
|
||||
}
|
||||
|
||||
getConnectionsManager().sendRequest(req, (response, error) -> {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public int setWallpaperToUser(long dialogId, String wallpaperLocalPath, Theme.OverrideWallpaperInfo wallpaperInfo, MessageObject serverWallpaper, Runnable callback) {
|
||||
TLRPC.TL_messages_setChatWallPaper req = new TLRPC.TL_messages_setChatWallPaper();
|
||||
if (dialogId > 0) {
|
||||
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(dialogId);
|
||||
req.peer = MessagesController.getInputPeer(user);
|
||||
} else {
|
||||
//chat not supported yet
|
||||
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-dialogId);
|
||||
req.peer = MessagesController.getInputPeer(chat);
|
||||
}
|
||||
boolean applyOnRequest = true;
|
||||
if (serverWallpaper != null && serverWallpaper.messageOwner.action instanceof TLRPC.TL_messageActionSetChatWallPaper) {
|
||||
applyOnRequest = false;
|
||||
req.flags |= 2;
|
||||
req.id = serverWallpaper.getId();
|
||||
|
||||
TLRPC.UserFull userFull = MessagesController.getInstance(currentAccount).getUserFull(dialogId);
|
||||
if (userFull != null) {
|
||||
TLRPC.TL_messageActionSetChatWallPaper action = (TLRPC.TL_messageActionSetChatWallPaper) serverWallpaper.messageOwner.action;
|
||||
TLRPC.WallPaper wallPaper = new TLRPC.TL_wallPaper();
|
||||
wallPaper.id = action.wallpaper.id;
|
||||
wallPaper.document = action.wallpaper.document;
|
||||
wallPaper.settings = new TLRPC.TL_wallPaperSettings();
|
||||
wallPaper.settings.intensity = (int) (wallpaperInfo.intensity * 100);
|
||||
wallPaper.settings.motion = wallpaperInfo.isMotion;
|
||||
wallPaper.settings.blur = wallpaperInfo.isBlurred;
|
||||
wallPaper.settings.background_color = wallpaperInfo.color;
|
||||
wallPaper.settings.second_background_color = wallpaperInfo.gradientColor1;
|
||||
wallPaper.settings.third_background_color = wallpaperInfo.gradientColor2;
|
||||
wallPaper.settings.fourth_background_color = wallpaperInfo.gradientColor3;
|
||||
wallPaper.settings.rotation = wallpaperInfo.rotation;
|
||||
wallPaper.uploadingImage = wallpaperLocalPath;
|
||||
if (userFull.wallpaper != null && userFull.wallpaper.uploadingImage != null && userFull.wallpaper.uploadingImage.equals(wallPaper.uploadingImage)) {
|
||||
wallPaper.stripedThumb = userFull.wallpaper.stripedThumb;
|
||||
}
|
||||
|
||||
wallPaper.settings.flags |= 1;
|
||||
wallPaper.settings.flags |= 8;
|
||||
wallPaper.settings.flags |= 16;
|
||||
wallPaper.settings.flags |= 32;
|
||||
wallPaper.settings.flags |= 64;
|
||||
|
||||
userFull.wallpaper = new TLRPC.TL_wallPaper();
|
||||
userFull.wallpaper.pattern = action.wallpaper.pattern;
|
||||
userFull.wallpaper.id = action.wallpaper.id;
|
||||
userFull.wallpaper.document = action.wallpaper.document;
|
||||
userFull.wallpaper.flags = action.wallpaper.flags;
|
||||
userFull.wallpaper.creator = action.wallpaper.creator;
|
||||
userFull.wallpaper.dark = action.wallpaper.dark;
|
||||
userFull.wallpaper.isDefault = action.wallpaper.isDefault;
|
||||
userFull.wallpaper.slug = action.wallpaper.slug;
|
||||
userFull.wallpaper.access_hash = action.wallpaper.access_hash;
|
||||
userFull.wallpaper.stripedThumb = action.wallpaper.stripedThumb;
|
||||
userFull.wallpaper.settings = wallPaper.settings;
|
||||
userFull.wallpaper.flags |= 4;
|
||||
userFull.flags |= 16777216;
|
||||
|
||||
getMessagesStorage().updateUserInfo(userFull, false);
|
||||
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.userInfoDidLoad, dialogId, userFull);
|
||||
if (callback != null) {
|
||||
callback.run();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
req.flags |= 1;
|
||||
req.wallpaper = MessagesController.getInputWallpaper(wallpaperInfo);
|
||||
}
|
||||
req.flags |= 4;
|
||||
req.settings = MessagesController.getWallpaperSetting(wallpaperInfo);
|
||||
|
||||
|
||||
boolean finalApplyOnRequest = applyOnRequest;
|
||||
return ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
if (response instanceof TLRPC.Updates) {
|
||||
TLRPC.Updates res = (TLRPC.Updates) response;
|
||||
TLRPC.UserFull userFull = MessagesController.getInstance(currentAccount).getUserFull(dialogId);
|
||||
if (userFull != null) {
|
||||
for (int i = 0; i < res.updates.size(); i++) {
|
||||
if (res.updates.get(i) instanceof TLRPC.TL_updateNewMessage) {
|
||||
TLRPC.Message message = ((TLRPC.TL_updateNewMessage) res.updates.get(i)).message;
|
||||
if (message.action instanceof TLRPC.TL_messageActionSetChatWallPaper) {
|
||||
if (finalApplyOnRequest) {
|
||||
TLRPC.TL_messageActionSetChatWallPaper actionSetChatWallPaper = (TLRPC.TL_messageActionSetChatWallPaper) message.action;
|
||||
actionSetChatWallPaper.wallpaper.uploadingImage = wallpaperLocalPath;
|
||||
if (userFull.wallpaper != null && userFull.wallpaper.uploadingImage != null && userFull.wallpaper.uploadingImage.equals(actionSetChatWallPaper.wallpaper.uploadingImage)) {
|
||||
actionSetChatWallPaper.wallpaper.stripedThumb = userFull.wallpaper.stripedThumb;
|
||||
}
|
||||
userFull.wallpaper = actionSetChatWallPaper.wallpaper;
|
||||
userFull.flags |= 16777216;
|
||||
|
||||
saveChatWallpaper(dialogId, userFull.wallpaper);
|
||||
getMessagesStorage().updateUserInfo(userFull, false);
|
||||
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.userInfoDidLoad, dialogId, userFull);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
MessagesController.getInstance(currentAccount).processUpdateArray(res.updates, res.users, res.chats, false, res.date);
|
||||
if (callback != null) {
|
||||
callback.run();
|
||||
}
|
||||
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.wallpaperSettedToUser);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,314 @@
|
|||
package org.telegram.messenger;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.Rect;
|
||||
import android.util.Pair;
|
||||
import android.util.SparseArray;
|
||||
import android.view.View;
|
||||
|
||||
import org.telegram.ui.Components.AnimatedFloat;
|
||||
import org.telegram.ui.Components.CubicBezierInterpolator;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
public class CompoundEmoji {
|
||||
|
||||
public static List<String> skinTones = Arrays.asList("🏻", "🏼", "🏽", "🏾", "🏿");
|
||||
|
||||
public static int getSkinTone(String string) {
|
||||
if (string == null) {
|
||||
return -1;
|
||||
}
|
||||
return skinTones.indexOf(string.substring(string.length() - 2));
|
||||
}
|
||||
|
||||
public static CompoundEmojiDrawable getCompoundEmojiDrawable(String string) {
|
||||
return getCompoundEmojiDrawable(string, null, null);
|
||||
}
|
||||
|
||||
public static CompoundEmojiDrawable getCompoundEmojiDrawable(String string, Integer overrideSkinTone1, Integer overrideSkinTone2) {
|
||||
if (string == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Pair<Integer, Integer> handshakeTones = isHandshake(string);
|
||||
if (handshakeTones != null) {
|
||||
return new CompoundEmojiDrawable(
|
||||
new DrawableInfo(0, overrideSkinTone1 != null ? overrideSkinTone1 : handshakeTones.first, 0),
|
||||
new DrawableInfo(0, overrideSkinTone2 != null ? overrideSkinTone2 : handshakeTones.second, 1)
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Pair<Integer, Integer> isHandshake(String code) {
|
||||
|
||||
int skinTone1 = -1, skinTone2 = -1;
|
||||
|
||||
// simple handshake 🤝
|
||||
if (
|
||||
code.startsWith("\uD83E\uDD1D") && // 🤝
|
||||
(code.length() == 2 || code.length() == 4 && (skinTone1 = getSkinTone(code)) >= 0)
|
||||
) {
|
||||
return new Pair(skinTone1, skinTone1);
|
||||
}
|
||||
|
||||
// compound handshake 🫱 + ZWJ + 🫲
|
||||
String[] parts = code.split("\u200D"); // ZWJ
|
||||
if (
|
||||
parts.length == 2 &&
|
||||
parts[0].startsWith("\uD83E\uDEF1") && // 🫱
|
||||
parts[1].startsWith("\uD83E\uDEF2") && // 🫲
|
||||
(parts[0].length() == 2 || parts[0].length() == 4 && (skinTone1 = getSkinTone(parts[0])) >= 0) &&
|
||||
(parts[1].length() == 2 || parts[1].length() == 4 && (skinTone2 = getSkinTone(parts[1])) >= 0)
|
||||
) {
|
||||
return new Pair(skinTone1, skinTone2);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String applyColor(String code, String color) {
|
||||
if (isHandshake(code) == null) {
|
||||
return code;
|
||||
}
|
||||
|
||||
if (color == null) {
|
||||
return "\uD83E\uDD1D";
|
||||
} else if (color.contains("\u200D")) {
|
||||
String[] parts = color.split("\u200D");
|
||||
return "\uD83E\uDEF1" + (parts.length >= 1 ? parts[0] : "") + "\u200D" + "\uD83E\uDEF2" + (parts.length >= 2 ? parts[1] : "");
|
||||
} else {
|
||||
return "\uD83E\uDD1D" + color;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isCompound(String string) {
|
||||
return getCompoundEmojiDrawable(string) != null;
|
||||
}
|
||||
|
||||
private static class DrawableInfo {
|
||||
|
||||
private static final SparseArray<Bitmap> bitmaps = new SparseArray<>();
|
||||
private static final ArrayList<Integer> loading = new ArrayList<>();
|
||||
|
||||
int emoji; // HANDSHAKE = 0
|
||||
int skin; // YELLOW = -1, TONES = 0...4
|
||||
int place; // LEFT = 0, RIGHT = 1
|
||||
int hash;
|
||||
|
||||
boolean placeholder;
|
||||
|
||||
public DrawableInfo(int emoji, int skin, int place) {
|
||||
if (skin == -2) {
|
||||
skin = -1;
|
||||
placeholder = true;
|
||||
}
|
||||
this.hash = Objects.hash(this.emoji = emoji, this.skin = skin, this.place = place);
|
||||
}
|
||||
|
||||
public DrawableInfo updateSkin(int newSkin) {
|
||||
if (skin == newSkin) {
|
||||
return this;
|
||||
}
|
||||
return new DrawableInfo(emoji, newSkin, place);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
public boolean isLoaded() {
|
||||
return bitmaps.indexOfKey(hash) >= 0;
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (isLoaded() || loading.contains(hash)) {
|
||||
return;
|
||||
}
|
||||
loading.add(hash);
|
||||
Utilities.globalQueue.postRunnable(() -> {
|
||||
final Bitmap bitmap = Emoji.loadBitmap("emoji/compound/" + emoji + "_" + skin + "_" + place + ".png");
|
||||
if (bitmap != null) {
|
||||
bitmaps.put(hash, bitmap);
|
||||
AndroidUtilities.cancelRunOnUIThread(Emoji.invalidateUiRunnable);
|
||||
AndroidUtilities.runOnUIThread(Emoji.invalidateUiRunnable);
|
||||
}
|
||||
loading.remove((Integer) hash);
|
||||
});
|
||||
}
|
||||
|
||||
public Bitmap getBitmap() {
|
||||
return bitmaps.get(hash);
|
||||
}
|
||||
}
|
||||
|
||||
private static Paint placeholderPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
|
||||
public static void setPlaceholderColor(int color) {
|
||||
placeholderPaint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
|
||||
}
|
||||
|
||||
public static class CompoundEmojiDrawable extends Emoji.EmojiDrawable {
|
||||
private DrawableInfo left, right;
|
||||
private static Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG);
|
||||
private static Rect rect = new Rect();
|
||||
|
||||
private View parent;
|
||||
private AnimatedFloat leftUpdateT, rightUpdateT;
|
||||
private DrawableInfo newLeft, newRight;
|
||||
|
||||
public CompoundEmojiDrawable(DrawableInfo left, DrawableInfo right) {
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
public Rect getDrawRect() {
|
||||
Rect original = getBounds();
|
||||
int cX = original.centerX(), cY = original.centerY();
|
||||
rect.left = cX - (fullSize ? Emoji.bigImgSize : Emoji.drawImgSize) / 2;
|
||||
rect.right = cX + (fullSize ? Emoji.bigImgSize : Emoji.drawImgSize) / 2;
|
||||
rect.top = cY - (fullSize ? Emoji.bigImgSize : Emoji.drawImgSize) / 2;
|
||||
rect.bottom = cY + (fullSize ? Emoji.bigImgSize : Emoji.drawImgSize) / 2;
|
||||
return rect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
if (!isLoaded()) {
|
||||
preload();
|
||||
Emoji.placeholderPaint.setColor(placeholderColor);
|
||||
Rect bounds = getBounds();
|
||||
canvas.drawCircle(bounds.centerX(), bounds.centerY(), bounds.width() * .4f, Emoji.placeholderPaint);
|
||||
return;
|
||||
}
|
||||
|
||||
Rect b;
|
||||
if (fullSize) {
|
||||
b = getDrawRect();
|
||||
} else {
|
||||
b = getBounds();
|
||||
}
|
||||
|
||||
if (!canvas.quickReject(b.left, b.top, b.right, b.bottom, Canvas.EdgeType.AA)) {
|
||||
if (newLeft != null) {
|
||||
if (leftUpdateT == null) {
|
||||
leftUpdateT = new AnimatedFloat(0, this::invalidate, 0, 320, CubicBezierInterpolator.EASE_OUT);
|
||||
}
|
||||
float t = leftUpdateT.set(1);
|
||||
|
||||
drawDrawableInfo(canvas, newLeft, b, Math.min(1, 1.5f * t));
|
||||
drawDrawableInfo(canvas, left, b, 1f - t);
|
||||
|
||||
if (t >= 1) {
|
||||
left = newLeft;
|
||||
newLeft = null;
|
||||
}
|
||||
} else {
|
||||
drawDrawableInfo(canvas, left, b, 1);
|
||||
}
|
||||
|
||||
if (newRight != null) {
|
||||
if (rightUpdateT == null) {
|
||||
rightUpdateT = new AnimatedFloat(0, this::invalidate, 0, 320, CubicBezierInterpolator.EASE_OUT);
|
||||
}
|
||||
float t = rightUpdateT.set(1);
|
||||
|
||||
drawDrawableInfo(canvas, newRight, b, Math.min(1, 1.5f * t));
|
||||
drawDrawableInfo(canvas, right, b, 1f - t);
|
||||
|
||||
if (t >= 1) {
|
||||
right = newRight;
|
||||
newRight = null;
|
||||
}
|
||||
} else {
|
||||
drawDrawableInfo(canvas, right, b, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void invalidate() {
|
||||
if (parent != null) {
|
||||
parent.invalidate();
|
||||
}
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
public void update(int skinTone1, int skinTone2) {
|
||||
if (left.skin != skinTone1) {
|
||||
if (newLeft != null) {
|
||||
left = newLeft;
|
||||
}
|
||||
newLeft = left.updateSkin(skinTone1);
|
||||
if (leftUpdateT != null) {
|
||||
leftUpdateT.set(0, true);
|
||||
}
|
||||
}
|
||||
if (right.skin != skinTone2) {
|
||||
if (newRight != null) {
|
||||
right = newRight;
|
||||
}
|
||||
newRight = right.updateSkin(skinTone2);
|
||||
if (rightUpdateT != null) {
|
||||
rightUpdateT.set(0, true);
|
||||
}
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
|
||||
private void drawDrawableInfo(Canvas canvas, DrawableInfo info, Rect bounds, float alpha) {
|
||||
final Bitmap leftBitmap = info.getBitmap();
|
||||
if (leftBitmap != null) {
|
||||
Paint currentPaint = info.placeholder ? placeholderPaint : paint;
|
||||
int wasAlpha = 0xFF;
|
||||
if (alpha < 1) {
|
||||
wasAlpha = currentPaint.getAlpha();
|
||||
currentPaint.setAlpha((int) (wasAlpha * alpha));
|
||||
}
|
||||
canvas.drawBitmap(leftBitmap, null, bounds, currentPaint);
|
||||
if (alpha < 1) {
|
||||
currentPaint.setAlpha(wasAlpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return PixelFormat.TRANSPARENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
paint.setAlpha(alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter cf) {}
|
||||
|
||||
@Override
|
||||
public boolean isLoaded() {
|
||||
return left.isLoaded() && right.isLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preload() {
|
||||
if (!isLoaded()) {
|
||||
left.load();
|
||||
right.load();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
package org.telegram.messenger;
|
||||
|
||||
import android.Manifest;
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.content.ContentProviderOperation;
|
||||
|
@ -1969,12 +1970,19 @@ public class ContactsController extends BaseController {
|
|||
return true;
|
||||
}
|
||||
|
||||
private boolean hasContactsWritePermission() {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
return ApplicationLoader.applicationContext.checkSelfPermission(Manifest.permission.WRITE_CONTACTS) == PackageManager.PERMISSION_GRANTED;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void performWriteContactsToPhoneBookInternal(ArrayList<TLRPC.TL_contact> contactsArray) {
|
||||
Cursor cursor = null;
|
||||
long time = System.currentTimeMillis();
|
||||
try {
|
||||
Account account = systemAccount;
|
||||
if (!hasContactsPermission() || account == null) {
|
||||
if (!hasContactsPermission() || account == null || !hasContactsWritePermission()) {
|
||||
return;
|
||||
}
|
||||
final SharedPreferences settings = MessagesController.getMainSettings(currentAccount);
|
||||
|
|
|
@ -1251,8 +1251,8 @@ public class DatabaseMigrationHelper {
|
|||
database.executeFast("CREATE INDEX IF NOT EXISTS idx_to_reply_messages_v2 ON messages_v2(reply_to_message_id, mid);").stepThis().dispose();
|
||||
database.executeFast("CREATE INDEX IF NOT EXISTS idx_to_reply_scheduled_messages_v2 ON scheduled_messages_v2(reply_to_message_id, mid);").stepThis().dispose();
|
||||
database.executeFast("CREATE INDEX IF NOT EXISTS idx_to_reply_messages_topics ON messages_topics(reply_to_message_id, mid);").stepThis().dispose();
|
||||
database.executeFast("PRAGMA user_version = 116").stepThis().dispose();
|
||||
version = 116;
|
||||
database.executeFast("PRAGMA user_version = 117").stepThis().dispose();
|
||||
version = 117;
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
|
|
@ -39,10 +39,10 @@ import java.util.Locale;
|
|||
public class Emoji {
|
||||
|
||||
private static HashMap<CharSequence, DrawableInfo> rects = new HashMap<>();
|
||||
private static int drawImgSize;
|
||||
private static int bigImgSize;
|
||||
public static int drawImgSize;
|
||||
public static int bigImgSize;
|
||||
private static boolean inited = false;
|
||||
private static Paint placeholderPaint;
|
||||
public static Paint placeholderPaint;
|
||||
private static int[] emojiCounts = new int[]{
|
||||
EmojiData.data[0].length,
|
||||
EmojiData.data[1].length,
|
||||
|
@ -60,7 +60,7 @@ public class Emoji {
|
|||
public static ArrayList<String> recentEmoji = new ArrayList<>();
|
||||
public static HashMap<String, String> emojiColor = new HashMap<>();
|
||||
private static boolean recentEmojiLoaded;
|
||||
private static Runnable invalidateUiRunnable = () -> NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.emojiLoaded);
|
||||
public static Runnable invalidateUiRunnable = () -> NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.emojiLoaded);
|
||||
public static float emojiDrawingYOffset;
|
||||
public static boolean emojiDrawingUseAlpha = true;
|
||||
|
||||
|
@ -107,13 +107,18 @@ public class Emoji {
|
|||
}
|
||||
loadingEmoji[page][page2] = true;
|
||||
Utilities.globalQueue.postRunnable(() -> {
|
||||
loadEmojiInternal(page, page2);
|
||||
final Bitmap bitmap = loadBitmap("emoji/" + String.format(Locale.US, "%d_%d.png", page, page2));
|
||||
if (bitmap != null) {
|
||||
emojiBmp[page][page2] = bitmap;
|
||||
AndroidUtilities.cancelRunOnUIThread(invalidateUiRunnable);
|
||||
AndroidUtilities.runOnUIThread(invalidateUiRunnable);
|
||||
}
|
||||
loadingEmoji[page][page2] = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static void loadEmojiInternal(final byte page, final short page2) {
|
||||
public static Bitmap loadBitmap(String path) {
|
||||
try {
|
||||
int imageResize;
|
||||
if (AndroidUtilities.density <= 1.0f) {
|
||||
|
@ -124,7 +129,7 @@ public class Emoji {
|
|||
|
||||
Bitmap bitmap = null;
|
||||
try {
|
||||
InputStream is = ApplicationLoader.applicationContext.getAssets().open("emoji/" + String.format(Locale.US, "%d_%d.png", page, page2));
|
||||
InputStream is = ApplicationLoader.applicationContext.getAssets().open(path);
|
||||
BitmapFactory.Options opts = new BitmapFactory.Options();
|
||||
opts.inJustDecodeBounds = false;
|
||||
opts.inSampleSize = imageResize;
|
||||
|
@ -133,16 +138,13 @@ public class Emoji {
|
|||
} catch (Throwable e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
|
||||
final Bitmap finalBitmap = bitmap;
|
||||
emojiBmp[page][page2] = finalBitmap;
|
||||
AndroidUtilities.cancelRunOnUIThread(invalidateUiRunnable);
|
||||
AndroidUtilities.runOnUIThread(invalidateUiRunnable);
|
||||
return bitmap;
|
||||
} catch (Throwable x) {
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
FileLog.e("Error loading emoji", x);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void invalidateAll(View view) {
|
||||
|
@ -190,9 +192,16 @@ public class Emoji {
|
|||
public static EmojiDrawable getEmojiDrawable(CharSequence code) {
|
||||
DrawableInfo info = getDrawableInfo(code);
|
||||
if (info == null) {
|
||||
if (code != null) {
|
||||
CompoundEmoji.CompoundEmojiDrawable compoundEmojiDrawable = CompoundEmoji.getCompoundEmojiDrawable(code.toString());
|
||||
if (compoundEmojiDrawable != null) {
|
||||
compoundEmojiDrawable.setBounds(0, 0, drawImgSize, drawImgSize);
|
||||
return compoundEmojiDrawable;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
EmojiDrawable ed = new EmojiDrawable(info);
|
||||
EmojiDrawable ed = new SimpleEmojiDrawable(info);
|
||||
ed.setBounds(0, 0, drawImgSize, drawImgSize);
|
||||
return ed;
|
||||
}
|
||||
|
@ -223,7 +232,15 @@ public class Emoji {
|
|||
}
|
||||
|
||||
public static Drawable getEmojiBigDrawable(String code) {
|
||||
EmojiDrawable ed = getEmojiDrawable(code);
|
||||
EmojiDrawable ed = null;
|
||||
CompoundEmoji.CompoundEmojiDrawable compoundEmojiDrawable = CompoundEmoji.getCompoundEmojiDrawable(code);
|
||||
if (compoundEmojiDrawable != null) {
|
||||
compoundEmojiDrawable.setBounds(0, 0, drawImgSize, drawImgSize);
|
||||
ed = compoundEmojiDrawable;
|
||||
}
|
||||
if (ed == null) {
|
||||
ed = getEmojiDrawable(code);
|
||||
}
|
||||
if (ed == null) {
|
||||
CharSequence newCode = EmojiData.emojiAliasMap.get(code);
|
||||
if (newCode != null) {
|
||||
|
@ -238,14 +255,22 @@ public class Emoji {
|
|||
return ed;
|
||||
}
|
||||
|
||||
public static class EmojiDrawable extends Drawable {
|
||||
public static abstract class EmojiDrawable extends Drawable {
|
||||
boolean fullSize = false;
|
||||
int placeholderColor = 0x10000000;
|
||||
|
||||
public boolean isLoaded() {
|
||||
return false;
|
||||
}
|
||||
public void preload() {}
|
||||
}
|
||||
|
||||
public static class SimpleEmojiDrawable extends EmojiDrawable {
|
||||
private DrawableInfo info;
|
||||
private boolean fullSize = false;
|
||||
private static Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG);
|
||||
private static Rect rect = new Rect();
|
||||
public int placeholderColor = 0x10000000;
|
||||
|
||||
public EmojiDrawable(DrawableInfo i) {
|
||||
public SimpleEmojiDrawable(DrawableInfo i) {
|
||||
info = i;
|
||||
}
|
||||
|
||||
|
@ -300,10 +325,12 @@ public class Emoji {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoaded() {
|
||||
return emojiBmp[info.page][info.page2] != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preload() {
|
||||
if (!isLoaded()) {
|
||||
loadEmoji(info.page, info.page2);
|
||||
|
@ -323,15 +350,6 @@ public class Emoji {
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean inArray(char c, char[] a) {
|
||||
for (char cc : a) {
|
||||
if (cc == c) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static class EmojiSpanRange {
|
||||
public EmojiSpanRange(int start, int end, CharSequence code) {
|
||||
this.start = start;
|
||||
|
@ -364,9 +382,10 @@ public class Emoji {
|
|||
int startLength = 0;
|
||||
int previousGoodIndex = 0;
|
||||
StringBuilder emojiCode = new StringBuilder(16);
|
||||
int length = cs.length();
|
||||
final int length = cs.length();
|
||||
boolean doneEmoji = false;
|
||||
boolean notOnlyEmoji;
|
||||
boolean resetStartIndex = false;
|
||||
|
||||
try {
|
||||
for (int i = 0; i < length; i++) {
|
||||
|
@ -375,17 +394,16 @@ public class Emoji {
|
|||
if (c >= 0xD83C && c <= 0xD83E || (buf != 0 && (buf & 0xFFFFFFFF00000000L) == 0 && (buf & 0xFFFF) == 0xD83C && (c >= 0xDDE6 && c <= 0xDDFF))) {
|
||||
if (startIndex == -1) {
|
||||
startIndex = i;
|
||||
} else if (resetStartIndex) {
|
||||
startIndex = i;
|
||||
startLength = 0;
|
||||
resetStartIndex = false;
|
||||
}
|
||||
emojiCode.append(c);
|
||||
startLength++;
|
||||
buf <<= 16;
|
||||
buf |= c;
|
||||
} else if (emojiCode.length() > 0 && (c == 0x2640 || c == 0x2642 || c == 0x2695)) {
|
||||
emojiCode.append(c);
|
||||
startLength++;
|
||||
buf = 0;
|
||||
doneEmoji = true;
|
||||
} else if (buf > 0 && (c & 0xF000) == 0xD000) {
|
||||
} else if (emojiCode.length() > 0 && (c == 0x2640 || c == 0x2642 || c == 0x2695) || buf > 0 && (c & 0xF000) == 0xD000) {
|
||||
emojiCode.append(c);
|
||||
startLength++;
|
||||
buf = 0;
|
||||
|
@ -399,11 +417,16 @@ public class Emoji {
|
|||
emojiCode.append(c2);
|
||||
emojiCode.append(c);
|
||||
doneEmoji = true;
|
||||
resetStartIndex = false;
|
||||
}
|
||||
}
|
||||
} else if ((c == 0x00A9 || c == 0x00AE || c >= 0x203C && c <= 0x3299) && EmojiData.dataCharsMap.containsKey(c)) {
|
||||
if (startIndex == -1) {
|
||||
startIndex = i;
|
||||
} else if (resetStartIndex) {
|
||||
startIndex = i;
|
||||
startLength = 0;
|
||||
resetStartIndex = false;
|
||||
}
|
||||
startLength++;
|
||||
emojiCode.append(c);
|
||||
|
@ -413,6 +436,7 @@ public class Emoji {
|
|||
startIndex = -1;
|
||||
startLength = 0;
|
||||
doneEmoji = false;
|
||||
resetStartIndex = false;
|
||||
} else if (c != 0xfe0f && c != '\n' && c != ' ' && c != '\t') {
|
||||
notOnlyEmoji = true;
|
||||
}
|
||||
|
@ -451,7 +475,17 @@ public class Emoji {
|
|||
startLength++;
|
||||
doneEmoji = false;
|
||||
}
|
||||
} else if (startIndex != -1 || prevCh == '*' || prevCh == '#' || prevCh >= '0' && prevCh <= '9') {
|
||||
} else if (prevCh == '*' || prevCh == '#' || prevCh >= '0' && prevCh <= '9') {
|
||||
if (c >= 0xFE00 && c <= 0xFE0F) {
|
||||
startIndex = previousGoodIndex;
|
||||
resetStartIndex = true;
|
||||
i++;
|
||||
startLength++;
|
||||
if (!doneEmoji) {
|
||||
doneEmoji = i + 1 >= length;
|
||||
}
|
||||
}
|
||||
} else if (startIndex != -1) {
|
||||
if (c >= 0xFE00 && c <= 0xFE0F) {
|
||||
i++;
|
||||
startLength++;
|
||||
|
@ -478,11 +512,14 @@ public class Emoji {
|
|||
if (emojiOnly != null) {
|
||||
emojiOnly[0]++;
|
||||
}
|
||||
emojis.add(new EmojiSpanRange(startIndex, startIndex + startLength, emojiCode.subSequence(0, emojiCode.length())));
|
||||
if (startIndex >= 0 && startIndex + startLength <= length) {
|
||||
emojis.add(new EmojiSpanRange(startIndex, startIndex + startLength, emojiCode.subSequence(0, emojiCode.length())));
|
||||
}
|
||||
startLength = 0;
|
||||
startIndex = -1;
|
||||
emojiCode.setLength(0);
|
||||
doneEmoji = false;
|
||||
resetStartIndex = false;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -18,6 +18,8 @@ import org.telegram.ui.Storage.CacheModel;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -807,7 +807,6 @@ public class FileLoader extends BaseController {
|
|||
queue.checkLoadingOperations();
|
||||
}
|
||||
});
|
||||
checkDownloadQueue(operation.getQueue(), fileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -833,7 +832,7 @@ public class FileLoader extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
checkDownloadQueue(operation.getQueue(), fileName);
|
||||
checkDownloadQueue(operation.getQueue(), fileName, 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -986,11 +985,15 @@ public class FileLoader extends BaseController {
|
|||
}
|
||||
|
||||
private void checkDownloadQueue(FileLoaderPriorityQueue queue, String fileName) {
|
||||
checkDownloadQueue(queue, fileName, 0);
|
||||
}
|
||||
|
||||
private void checkDownloadQueue(FileLoaderPriorityQueue queue, String fileName, long delay) {
|
||||
fileLoaderQueue.postRunnable(() -> {
|
||||
FileLoadOperation operation = loadOperationPaths.remove(fileName);
|
||||
queue.remove(operation);
|
||||
queue.checkLoadingOperations();
|
||||
});
|
||||
}, delay);
|
||||
}
|
||||
|
||||
public void setDelegate(FileLoaderDelegate fileLoaderDelegate) {
|
||||
|
|
|
@ -186,7 +186,7 @@ public class FileLog {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
}).create();
|
||||
}).registerTypeAdapterFactory(RuntimeClassNameTypeAdapterFactory.of(TLObject.class, "type_")).create();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ package org.telegram.messenger;
|
|||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.util.SparseArray;
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
|
@ -525,11 +524,15 @@ public class FileUploadOperation {
|
|||
} else {
|
||||
connectionType = ConnectionsManager.ConnectionTypeUpload | ((requestNumFinal % 4) << 16);
|
||||
}
|
||||
|
||||
int requestToken = ConnectionsManager.getInstance(currentAccount).sendRequest(finalRequest, (response, error) -> {
|
||||
long time = System.currentTimeMillis();
|
||||
int[] requestToken = new int[1];
|
||||
requestToken[0] = ConnectionsManager.getInstance(currentAccount).sendRequest(finalRequest, (response, error) -> {
|
||||
if (currentOperationGuid != operationGuid) {
|
||||
return;
|
||||
}
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
FileLog.d("debug_uploading: " + " response reqId " + requestToken[0] + " time" + uploadingFilePath);
|
||||
}
|
||||
int networkType = response != null ? response.networkType : ApplicationLoader.getCurrentNetworkType();
|
||||
if (currentType == ConnectionsManager.FileTypeAudio) {
|
||||
StatsController.getInstance(currentAccount).incrementSentBytesCount(networkType, StatsController.TYPE_AUDIOS, requestSize);
|
||||
|
@ -650,6 +653,9 @@ public class FileUploadOperation {
|
|||
startUploadRequest();
|
||||
}
|
||||
}), forceSmallFile ? ConnectionsManager.RequestFlagCanCompress : 0, ConnectionsManager.DEFAULT_DATACENTER_ID, connectionType, true);
|
||||
requestTokens.put(requestNumFinal, requestToken);
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
FileLog.d("debug_uploading: " + " send reqId " + requestToken + " " + uploadingFilePath);
|
||||
}
|
||||
requestTokens.put(requestNumFinal, requestToken[0]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,11 @@ import android.graphics.BitmapFactory;
|
|||
import android.graphics.Canvas;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
|
@ -31,6 +34,7 @@ import android.text.TextUtils;
|
|||
import android.util.SparseArray;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
import androidx.exifinterface.media.ExifInterface;
|
||||
|
||||
import org.json.JSONArray;
|
||||
|
@ -43,6 +47,8 @@ import org.telegram.tgnet.TLObject;
|
|||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.Cells.ChatMessageCell;
|
||||
import org.telegram.ui.Components.AnimatedFileDrawable;
|
||||
import org.telegram.ui.Components.BackgroundGradientDrawable;
|
||||
import org.telegram.ui.Components.MotionBackgroundDrawable;
|
||||
import org.telegram.ui.Components.Point;
|
||||
import org.telegram.ui.Components.RLottieDrawable;
|
||||
import org.telegram.ui.Components.SlotsDrawable;
|
||||
|
@ -866,6 +872,9 @@ public class ImageLoader {
|
|||
} catch (Throwable e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
if (bitmap != null && !TextUtils.isEmpty(cacheImage.filter) && cacheImage.filter.contains("wallpaper") && cacheImage.parentObject instanceof TLRPC.WallPaper) {
|
||||
bitmap = applyWallpaperSetting(bitmap, (TLRPC.WallPaper) cacheImage.parentObject);
|
||||
}
|
||||
onPostExecute(bitmap != null ? new BitmapDrawable(bitmap) : null);
|
||||
} else if (cacheImage.imageType == FileLoader.IMAGE_TYPE_LOTTIE) {
|
||||
int w = Math.min(512, AndroidUtilities.dp(170.6f));
|
||||
|
@ -1578,6 +1587,9 @@ public class ImageLoader {
|
|||
if (BuildVars.LOGS_ENABLED && inEncryptedFile) {
|
||||
FileLog.e("Image Loader image is empty = " + (image == null) + " " + cacheFileFinal);
|
||||
}
|
||||
if (image != null && !TextUtils.isEmpty(cacheImage.filter) && cacheImage.filter.contains("wallpaper") && cacheImage.parentObject instanceof TLRPC.WallPaper) {
|
||||
image = applyWallpaperSetting(image, (TLRPC.WallPaper) cacheImage.parentObject);
|
||||
}
|
||||
if (needInvert || orientation != 0) {
|
||||
onPostExecute(image != null ? new ExtendedBitmapDrawable(image, needInvert, orientation) : null);
|
||||
} else {
|
||||
|
@ -1586,6 +1598,51 @@ public class ImageLoader {
|
|||
}
|
||||
}
|
||||
|
||||
private Bitmap applyWallpaperSetting(Bitmap bitmap, TLRPC.WallPaper wallPaper) {
|
||||
if (!wallPaper.pattern || wallPaper.settings == null) {
|
||||
if (wallPaper.settings != null && wallPaper.settings.blur) {
|
||||
return Utilities.blurWallpaper(bitmap);
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
Bitmap finalBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(finalBitmap);
|
||||
int patternColor;
|
||||
|
||||
boolean applyPattern = true;
|
||||
if (wallPaper.settings.second_background_color == 0) { //one color
|
||||
patternColor = AndroidUtilities.getPatternColor(wallPaper.settings.background_color);
|
||||
canvas.drawColor(ColorUtils.setAlphaComponent(wallPaper.settings.background_color, 255));
|
||||
} else if (wallPaper.settings.third_background_color == 0) { //two color
|
||||
int color1 = ColorUtils.setAlphaComponent(wallPaper.settings.background_color, 255);
|
||||
int color2 = ColorUtils.setAlphaComponent(wallPaper.settings.second_background_color, 255);
|
||||
patternColor = AndroidUtilities.getAverageColor(color1, color2);
|
||||
GradientDrawable gradientDrawable = new GradientDrawable(BackgroundGradientDrawable.getGradientOrientation(wallPaper.settings.rotation), new int[]{color1, color2});
|
||||
gradientDrawable.setBounds(0, 0, finalBitmap.getWidth(), finalBitmap.getHeight());
|
||||
gradientDrawable.draw(canvas);
|
||||
} else {
|
||||
int color1 = ColorUtils.setAlphaComponent(wallPaper.settings.background_color, 255);
|
||||
int color2 = ColorUtils.setAlphaComponent(wallPaper.settings.second_background_color, 255);
|
||||
int color3 = ColorUtils.setAlphaComponent(wallPaper.settings.third_background_color, 255);
|
||||
int color4 = wallPaper.settings.fourth_background_color == 0 ? 0 : ColorUtils.setAlphaComponent(wallPaper.settings.fourth_background_color, 255);
|
||||
patternColor = MotionBackgroundDrawable.getPatternColor(color1, color2, color3, color4);
|
||||
MotionBackgroundDrawable motionBackgroundDrawable = new MotionBackgroundDrawable();
|
||||
motionBackgroundDrawable.setColors(color1, color2, color3, color4);
|
||||
motionBackgroundDrawable.setBounds(0, 0, finalBitmap.getWidth(), finalBitmap.getHeight());
|
||||
motionBackgroundDrawable.setPatternBitmap(wallPaper.settings.intensity, bitmap);
|
||||
motionBackgroundDrawable.draw(canvas);
|
||||
applyPattern = false;
|
||||
}
|
||||
|
||||
if (applyPattern) {
|
||||
Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG);
|
||||
paint.setColorFilter(new PorterDuffColorFilter(patternColor, PorterDuff.Mode.SRC_IN));
|
||||
paint.setAlpha((int) (wallPaper.settings.intensity / 100.0f * 255));
|
||||
canvas.drawBitmap(bitmap, 0, 0, paint);
|
||||
}
|
||||
return finalBitmap;
|
||||
}
|
||||
|
||||
private void loadLastFrame(RLottieDrawable lottieDrawable, int w, int h, boolean lastFrame, boolean reaction) {
|
||||
Bitmap bitmap;
|
||||
Canvas canvas;
|
||||
|
@ -2278,8 +2335,11 @@ public class ImageLoader {
|
|||
telegramPath = new File(newPath, "Telegram");
|
||||
} else {
|
||||
boolean isSdCard = !TextUtils.isEmpty(SharedConfig.storageCacheDir) && path.getAbsolutePath().startsWith(SharedConfig.storageCacheDir);
|
||||
if (!isSdCard && !(path.exists() ? path.isDirectory() : path.mkdirs()) || !path.canWrite()) {
|
||||
path = ApplicationLoader.applicationContext.getExternalFilesDir(null);
|
||||
if (!isSdCard) {
|
||||
if (!(path.exists() ? path.isDirectory() : path.mkdirs()) || !path.canWrite()) {
|
||||
FileLog.d("can't write to this directory = " + path + " use files dir");
|
||||
path = ApplicationLoader.applicationContext.getExternalFilesDir(null);
|
||||
}
|
||||
}
|
||||
telegramPath = new File(path, "Telegram");
|
||||
}
|
||||
|
|
|
@ -304,7 +304,10 @@ public class LiteMode {
|
|||
AnimatedEmojiDrawable.updateAll();
|
||||
}
|
||||
if ((changedFlags & FLAG_CHAT_BACKGROUND) > 0) {
|
||||
Theme.reloadWallpaper();
|
||||
SvgHelper.SvgDrawable.updateLiteValues();
|
||||
}
|
||||
if ((changedFlags & FLAG_CHAT_BACKGROUND) > 0) {
|
||||
Theme.reloadWallpaper(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.telegram.messenger.time.FastDateFormat;
|
|||
import org.telegram.tgnet.ConnectionsManager;
|
||||
import org.telegram.tgnet.TLObject;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.RestrictedLanguagesSelectActivity;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
|
@ -1028,6 +1029,7 @@ public class LocaleController {
|
|||
} else {
|
||||
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.reloadInterface);
|
||||
}
|
||||
RestrictedLanguagesSelectActivity.invalidateRestrictedLanguages();
|
||||
if (onDone != null) {
|
||||
onDone.run();
|
||||
}
|
||||
|
@ -2274,6 +2276,8 @@ public class LocaleController {
|
|||
config.locale = currentLocale;
|
||||
ApplicationLoader.applicationContext.getResources().updateConfiguration(config, ApplicationLoader.applicationContext.getResources().getDisplayMetrics());
|
||||
changingConfiguration = false;
|
||||
|
||||
RestrictedLanguagesSelectActivity.invalidateRestrictedLanguages();
|
||||
} else {
|
||||
FileLog.d("saveRemoteLocaleStrings: currentLocaleInfo != localeInfo, do nothing");
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
|||
|
||||
public static native int isOpusFile(String path);
|
||||
|
||||
public native byte[] getWaveform(String path);
|
||||
public static native byte[] getWaveform(String path);
|
||||
|
||||
public native byte[] getWaveform2(short[] array, int length);
|
||||
|
||||
|
|
|
@ -5982,6 +5982,9 @@ public class MediaDataController extends BaseController {
|
|||
newRun.flags = TextStyleSpan.FLAG_STYLE_URL;
|
||||
newRun.urlEntity = entity;
|
||||
}
|
||||
if (entity instanceof TLRPC.TL_messageEntityTextUrl) {
|
||||
newRun.flags |= TextStyleSpan.FLAG_STYLE_TEXT_URL;
|
||||
}
|
||||
|
||||
newRun.flags &= allowedFlags;
|
||||
|
||||
|
@ -7481,7 +7484,7 @@ public class MediaDataController extends BaseController {
|
|||
}
|
||||
for (int i = 0; i < len; ++i) {
|
||||
String emoji = result.get(i).emoji;
|
||||
if (emoji == null) {
|
||||
if (TextUtils.isEmpty(emoji)) {
|
||||
continue;
|
||||
}
|
||||
animatedEmoji.clear();
|
||||
|
@ -7491,8 +7494,9 @@ public class MediaDataController extends BaseController {
|
|||
try {
|
||||
long documentId = Long.parseLong(Emoji.recentEmoji.get(j).substring(9));
|
||||
TLRPC.Document document = AnimatedEmojiDrawable.findDocument(currentAccount, documentId);
|
||||
String emoticon = MessageObject.findAnimatedEmojiEmoticon(document, null);
|
||||
if (document != null &&
|
||||
emoji.equals(MessageObject.findAnimatedEmojiEmoticon(document, null)) &&
|
||||
emoticon != null && emoticon.contains(emoji) &&
|
||||
(isPremium || MessageObject.isFreeEmoji(document))
|
||||
) {
|
||||
animatedEmoji.add(document);
|
||||
|
@ -7508,7 +7512,39 @@ public class MediaDataController extends BaseController {
|
|||
if (animatedEmoji.size() < maxAnimatedPerEmoji && emojiPacks[0] != null) {
|
||||
for (int j = 0; j < emojiPacks[0].size(); ++j) {
|
||||
TLRPC.TL_messages_stickerSet set = emojiPacks[0].get(j);
|
||||
if (set != null && set.documents != null) {
|
||||
if (set != null && set.packs != null) {
|
||||
for (int k = 0; k < set.packs.size(); ++k) {
|
||||
TLRPC.TL_stickerPack pack = set.packs.get(k);
|
||||
if (pack != null && pack.emoticon != null && pack.emoticon.contains(emoji)) {
|
||||
for (int d = 0; d < pack.documents.size(); ++d) {
|
||||
long documentId = pack.documents.get(d);
|
||||
TLRPC.Document document = null;
|
||||
for (int d2 = 0; d2 < set.documents.size(); ++d2) {
|
||||
TLRPC.Document doc = set.documents.get(d2);
|
||||
if (doc != null && doc.id == documentId) {
|
||||
document = doc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (document != null && document.attributes != null && !animatedEmoji.contains(document)) {
|
||||
boolean duplicate = false;
|
||||
for (int l = 0; l < animatedEmoji.size(); ++l) {
|
||||
if (animatedEmoji.get(l).id == document.id) {
|
||||
duplicate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!duplicate) {
|
||||
animatedEmoji.add(document);
|
||||
if (animatedEmoji.size() >= maxAnimatedPerEmoji) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (set != null && set.documents != null) {
|
||||
for (int d = 0; d < set.documents.size(); ++d) {
|
||||
TLRPC.Document document = set.documents.get(d);
|
||||
if (document != null && document.attributes != null && !animatedEmoji.contains(document)) {
|
||||
|
@ -7521,7 +7557,7 @@ public class MediaDataController extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
if (attribute != null && emoji.equals(attribute.alt) && (isPremium || attribute.free || set.set != null && set.set.short_name != null && set.set.short_name.equals(topicIconsName))) {
|
||||
if (attribute != null && !TextUtils.isEmpty(attribute.alt) && attribute.alt.contains(emoji) && (isPremium || attribute.free || set.set != null && set.set.short_name != null && set.set.short_name.equals(topicIconsName))) {
|
||||
boolean duplicate = false;
|
||||
for (int l = 0; l < animatedEmoji.size(); ++l) {
|
||||
if (animatedEmoji.get(l).id == document.id) {
|
||||
|
@ -7566,7 +7602,7 @@ public class MediaDataController extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
if (attribute != null && emoji.equals(attribute.alt) && (isPremium || attribute.free || set.set != null && set.set.short_name != null && set.set.short_name.equals(topicIconsName))) {
|
||||
if (attribute != null && !TextUtils.isEmpty(attribute.alt) && attribute.alt.contains(emoji) && (isPremium || attribute.free || set.set != null && set.set.short_name != null && set.set.short_name.equals(topicIconsName))) {
|
||||
boolean duplicate = false;
|
||||
for (int l = 0; l < animatedEmoji.size(); ++l) {
|
||||
if (animatedEmoji.get(l).id == document.id) {
|
||||
|
@ -7713,7 +7749,7 @@ public class MediaDataController extends BaseController {
|
|||
final int type = 1; // default
|
||||
if (!emojiStatusesFromCacheFetched[type]) {
|
||||
fetchEmojiStatuses(type, true);
|
||||
} else if (/*emojiStatusesHash[type] == 0 || */emojiStatusesFetchDate[type] == null || (System.currentTimeMillis() / 1000 - emojiStatusesFetchDate[type]) > 60 * 30) {
|
||||
} else if (emojiStatuses[type] == null || emojiStatusesFetchDate[type] != null && (System.currentTimeMillis() / 1000 - emojiStatusesFetchDate[type]) > 60 * 30) {
|
||||
fetchEmojiStatuses(type, false);
|
||||
}
|
||||
return emojiStatuses[type];
|
||||
|
@ -7723,7 +7759,7 @@ public class MediaDataController extends BaseController {
|
|||
final int type = 0; // recent
|
||||
if (!emojiStatusesFromCacheFetched[type]) {
|
||||
fetchEmojiStatuses(type, true);
|
||||
} else if (/*emojiStatusesHash[type] == 0 || */emojiStatusesFetchDate[type] == null || (System.currentTimeMillis() / 1000 - emojiStatusesFetchDate[type]) > 60 * 30) {
|
||||
} else if (emojiStatuses[type] == null || emojiStatusesFetchDate[type] != null && (System.currentTimeMillis() / 1000 - emojiStatusesFetchDate[type]) > 60 * 30) {
|
||||
fetchEmojiStatuses(type, false);
|
||||
}
|
||||
return emojiStatuses[type];
|
||||
|
|
|
@ -101,6 +101,7 @@ public class MessageObject {
|
|||
public static final int TYPE_EMOJIS = 19;
|
||||
public static final int TYPE_EXTENDED_MEDIA_PREVIEW = 20;
|
||||
public static final int TYPE_SUGGEST_PHOTO = 21;
|
||||
public static final int TYPE_ACTION_WALLPAPER = 22;
|
||||
|
||||
public int localType;
|
||||
public String localName;
|
||||
|
@ -348,6 +349,10 @@ public class MessageObject {
|
|||
return SharedConfig.getDevicePerformanceClass() == SharedConfig.PERFORMANCE_CLASS_HIGH;
|
||||
}
|
||||
|
||||
public boolean isWallpaperAction() {
|
||||
return type == TYPE_ACTION_WALLPAPER || (messageOwner != null && messageOwner.action instanceof TLRPC.TL_messageActionSetSameChatWallPaper);
|
||||
}
|
||||
|
||||
public int getEmojiOnlyCount() {
|
||||
return emojiOnlyCount;
|
||||
}
|
||||
|
@ -357,14 +362,7 @@ public class MessageObject {
|
|||
}
|
||||
|
||||
public boolean shouldDrawReactionsInLayout() {
|
||||
if (getDialogId() < 0 || UserConfig.getInstance(currentAccount).isPremium()) {
|
||||
return true;
|
||||
}
|
||||
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(getDialogId());
|
||||
if (user != null && user.premium) {
|
||||
return true;
|
||||
}
|
||||
return false;//getDialogId() < 0 || UserConfig.getInstance(currentAccount).isPremium();
|
||||
return true;
|
||||
}
|
||||
|
||||
public TLRPC.MessagePeerReaction getRandomUnreadReaction() {
|
||||
|
@ -1177,7 +1175,9 @@ public class MessageObject {
|
|||
|
||||
updateMessageText(users, chats, sUsers, sChats);
|
||||
setType();
|
||||
updateTranslation(false);
|
||||
if (generateLayout) {
|
||||
updateTranslation(false);
|
||||
}
|
||||
measureInlineBotButtons();
|
||||
|
||||
Calendar rightNow = new GregorianCalendar();
|
||||
|
@ -2127,7 +2127,11 @@ public class MessageObject {
|
|||
}
|
||||
} 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);
|
||||
if (action.via_chatlist) {
|
||||
messageText = replaceWithLink(LocaleController.getString("ActionInviteUserFolder", R.string.ActionInviteUserFolder), "un1", fromUser);
|
||||
} else {
|
||||
messageText = replaceWithLink(LocaleController.getString("ActionInviteUser", R.string.ActionInviteUser), "un1", fromUser);
|
||||
}
|
||||
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionToggleNoForwards) {
|
||||
TLRPC.TL_channelAdminLogEventActionToggleNoForwards action = (TLRPC.TL_channelAdminLogEventActionToggleNoForwards) event.action;
|
||||
boolean isChannel = ChatObject.isChannel(chat) && !chat.megagroup;
|
||||
|
@ -2527,12 +2531,13 @@ public class MessageObject {
|
|||
public boolean translated = false;
|
||||
public boolean updateTranslation(boolean force) {
|
||||
boolean replyUpdated = replyMessageObject != null && replyMessageObject.updateTranslation(force);
|
||||
TranslateController translateController = MessagesController.getInstance(currentAccount).getTranslateController();
|
||||
if (
|
||||
TranslateController.isTranslatable(this) &&
|
||||
MessagesController.getInstance(currentAccount).getTranslateController().isTranslatingDialog(getDialogId()) &&
|
||||
translateController.isTranslatingDialog(getDialogId()) &&
|
||||
messageOwner != null &&
|
||||
messageOwner.translatedText != null &&
|
||||
TextUtils.equals(MessagesController.getInstance(currentAccount).getTranslateController().getDialogTranslateTo(getDialogId()), messageOwner.translatedToLanguage)
|
||||
TextUtils.equals(translateController.getDialogTranslateTo(getDialogId()), messageOwner.translatedToLanguage)
|
||||
) {
|
||||
if (translated) {
|
||||
return replyUpdated || false;
|
||||
|
@ -3042,6 +3047,10 @@ public class MessageObject {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean hasInlineBotButtons() {
|
||||
return !isRestrictedMessage && messageOwner != null && messageOwner.reply_markup instanceof TLRPC.TL_replyInlineMarkup && !messageOwner.reply_markup.rows.isEmpty();
|
||||
}
|
||||
|
||||
public void measureInlineBotButtons() {
|
||||
if (isRestrictedMessage) {
|
||||
return;
|
||||
|
@ -3056,7 +3065,7 @@ public class MessageObject {
|
|||
}
|
||||
}
|
||||
|
||||
if (messageOwner.reply_markup instanceof TLRPC.TL_replyInlineMarkup && !hasExtendedMedia()) {
|
||||
if (messageOwner.reply_markup instanceof TLRPC.TL_replyInlineMarkup && !hasExtendedMedia() && messageOwner.reply_markup.rows != null) {
|
||||
for (int a = 0; a < messageOwner.reply_markup.rows.size(); a++) {
|
||||
TLRPC.TL_keyboardButtonRow row = messageOwner.reply_markup.rows.get(a);
|
||||
int maxButtonSize = 0;
|
||||
|
@ -3136,7 +3145,41 @@ public class MessageObject {
|
|||
|
||||
if (messageOwner instanceof TLRPC.TL_messageService) {
|
||||
if (messageOwner.action != null) {
|
||||
if (messageOwner.action instanceof TLRPC.TL_messageActionGroupCallScheduled) {
|
||||
if (messageOwner.action instanceof TLRPC.TL_messageActionSetSameChatWallPaper) {
|
||||
contentType = 1;
|
||||
type = TYPE_TEXT;
|
||||
TLRPC.TL_messageActionSetSameChatWallPaper action = (TLRPC.TL_messageActionSetSameChatWallPaper) messageOwner.action;
|
||||
TLRPC.User user = getUser(users, sUsers, isOutOwner() ? 0 : getDialogId());
|
||||
photoThumbs = new ArrayList<>();
|
||||
if (action.wallpaper.document != null) {
|
||||
photoThumbs.addAll(action.wallpaper.document.thumbs);
|
||||
photoThumbsObject = action.wallpaper.document;
|
||||
}
|
||||
if (user != null) {
|
||||
if (user.id == UserConfig.getInstance(currentAccount).clientUserId) {
|
||||
messageText = LocaleController.formatString("ActionSetSameWallpaperForThisChatSelf", R.string.ActionSetSameWallpaperForThisChatSelf);
|
||||
} else {
|
||||
messageText = LocaleController.formatString("ActionSetSameWallpaperForThisChat", R.string.ActionSetSameWallpaperForThisChat, user.first_name);
|
||||
}
|
||||
}
|
||||
} else if (messageOwner.action instanceof TLRPC.TL_messageActionSetChatWallPaper) {
|
||||
contentType = 1;
|
||||
type = TYPE_ACTION_WALLPAPER;
|
||||
TLRPC.TL_messageActionSetChatWallPaper wallPaper = (TLRPC.TL_messageActionSetChatWallPaper) messageOwner.action;
|
||||
photoThumbs = new ArrayList<>();
|
||||
if (wallPaper.wallpaper.document != null) {
|
||||
photoThumbs.addAll(wallPaper.wallpaper.document.thumbs);
|
||||
photoThumbsObject = wallPaper.wallpaper.document;
|
||||
}
|
||||
TLRPC.User user = getUser(users, sUsers, isOutOwner() ? 0 : getDialogId());
|
||||
if (user != null) {
|
||||
if (user.id == UserConfig.getInstance(currentAccount).clientUserId) {
|
||||
messageText = LocaleController.formatString("ActionSetWallpaperForThisChatSelf", R.string.ActionSetWallpaperForThisChatSelf);
|
||||
} else {
|
||||
messageText = LocaleController.formatString("ActionSetWallpaperForThisChat", R.string.ActionSetWallpaperForThisChat, user.first_name);
|
||||
}
|
||||
}
|
||||
} else if (messageOwner.action instanceof TLRPC.TL_messageActionGroupCallScheduled) {
|
||||
TLRPC.TL_messageActionGroupCallScheduled action = (TLRPC.TL_messageActionGroupCallScheduled) messageOwner.action;
|
||||
if (messageOwner.peer_id instanceof TLRPC.TL_peerChat || isSupergroup()) {
|
||||
messageText = LocaleController.formatString("ActionGroupCallScheduled", R.string.ActionGroupCallScheduled, LocaleController.formatStartsTime(action.schedule_date, 3, false));
|
||||
|
@ -3951,7 +3994,19 @@ public class MessageObject {
|
|||
type = TYPE_TEXT;
|
||||
}
|
||||
} else if (messageOwner instanceof TLRPC.TL_messageService) {
|
||||
if (messageOwner.action instanceof TLRPC.TL_messageActionSuggestProfilePhoto) {
|
||||
if (messageOwner.action instanceof TLRPC.TL_messageActionSetSameChatWallPaper) {
|
||||
contentType = 1;
|
||||
type = TYPE_TEXT;
|
||||
} else if (messageOwner.action instanceof TLRPC.TL_messageActionSetChatWallPaper) {
|
||||
contentType = 1;
|
||||
type = TYPE_ACTION_WALLPAPER;
|
||||
TLRPC.TL_messageActionSetChatWallPaper wallPaper = (TLRPC.TL_messageActionSetChatWallPaper) messageOwner.action;
|
||||
photoThumbs = new ArrayList<>();
|
||||
if (wallPaper.wallpaper.document != null) {
|
||||
photoThumbs.addAll(wallPaper.wallpaper.document.thumbs);
|
||||
photoThumbsObject = wallPaper.wallpaper.document;
|
||||
}
|
||||
} else if (messageOwner.action instanceof TLRPC.TL_messageActionSuggestProfilePhoto) {
|
||||
contentType = 1;
|
||||
type = TYPE_SUGGEST_PHOTO;
|
||||
photoThumbs = new ArrayList<>();
|
||||
|
@ -5092,6 +5147,10 @@ public class MessageObject {
|
|||
}
|
||||
newRun.flags = TextStyleSpan.FLAG_STYLE_URL;
|
||||
newRun.urlEntity = entity;
|
||||
|
||||
if (entity instanceof TLRPC.TL_messageEntityTextUrl) {
|
||||
newRun.flags |= TextStyleSpan.FLAG_STYLE_TEXT_URL;
|
||||
}
|
||||
}
|
||||
|
||||
for (int b = 0, N2 = runs.size(); b < N2; b++) {
|
||||
|
@ -6314,6 +6373,10 @@ public class MessageObject {
|
|||
}
|
||||
|
||||
public static String findAnimatedEmojiEmoticon(TLRPC.Document document, String fallback) {
|
||||
return findAnimatedEmojiEmoticon(document, fallback, null);
|
||||
}
|
||||
|
||||
public static String findAnimatedEmojiEmoticon(TLRPC.Document document, String fallback, Integer currentAccountForFull) {
|
||||
if (document == null) {
|
||||
return fallback;
|
||||
}
|
||||
|
@ -6321,6 +6384,21 @@ public class MessageObject {
|
|||
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
|
||||
if (attribute instanceof TLRPC.TL_documentAttributeCustomEmoji ||
|
||||
attribute instanceof TLRPC.TL_documentAttributeSticker) {
|
||||
if (currentAccountForFull != null) {
|
||||
TLRPC.TL_messages_stickerSet set = MediaDataController.getInstance(currentAccountForFull).getStickerSet(attribute.stickerset, true);
|
||||
StringBuilder emoji = new StringBuilder("");
|
||||
if (set != null && set.packs != null) {
|
||||
for (int p = 0; p < set.packs.size(); ++p) {
|
||||
TLRPC.TL_stickerPack pack = set.packs.get(p);
|
||||
if (pack.documents.contains(document.id)) {
|
||||
emoji.append(pack.emoticon);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!TextUtils.isEmpty(emoji)) {
|
||||
return emoji.toString();
|
||||
}
|
||||
}
|
||||
return attribute.alt;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import android.os.SystemClock;
|
|||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Base64;
|
||||
import android.util.Pair;
|
||||
import android.util.SparseArray;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.util.SparseIntArray;
|
||||
|
@ -131,6 +132,20 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
public ConcurrentHashMap<Long, Integer> onlinePrivacy = new ConcurrentHashMap<>(20, 1.0f, 2);
|
||||
private LongSparseIntArray pendingUnreadCounter = new LongSparseIntArray();
|
||||
private int lastPrintingStringCount;
|
||||
private SparseArray<ChatlistUpdatesStat> chatlistFoldersUpdates = new SparseArray<>();
|
||||
|
||||
class ChatlistUpdatesStat {
|
||||
public ChatlistUpdatesStat() {
|
||||
this.loading = true;
|
||||
}
|
||||
public ChatlistUpdatesStat(TLRPC.TL_chatlists_chatlistUpdates value) {
|
||||
this.lastRequestTime = System.currentTimeMillis();
|
||||
this.lastValue = value;
|
||||
}
|
||||
boolean loading = false;
|
||||
long lastRequestTime;
|
||||
TLRPC.TL_chatlists_chatlistUpdates lastValue;
|
||||
}
|
||||
|
||||
private boolean dialogsInTransaction;
|
||||
|
||||
|
@ -162,6 +177,8 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
public SparseIntArray premiumFeaturesTypesToPosition = new SparseIntArray();
|
||||
|
||||
public ArrayList<DialogFilter> dialogFilters = new ArrayList<>();
|
||||
public ArrayList<DialogFilter> frozenDialogFilters = null;
|
||||
public ArrayList<Long> hiddenUndoChats = new ArrayList<>();
|
||||
public SparseArray<DialogFilter> dialogFiltersById = new SparseArray<>();
|
||||
private boolean loadingSuggestedFilters;
|
||||
private boolean loadingRemoteFilters;
|
||||
|
@ -281,11 +298,18 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
|
||||
private HashMap<String, Object> uploadingThemes = new HashMap<>();
|
||||
|
||||
private String uploadingWallpaper;
|
||||
private Theme.OverrideWallpaperInfo uploadingWallpaperInfo;
|
||||
public String uploadingWallpaper;
|
||||
public Theme.OverrideWallpaperInfo uploadingWallpaperInfo;
|
||||
|
||||
private UserNameResolver userNameResolver;
|
||||
|
||||
public ArrayList<DialogFilter> getDialogFilters() {
|
||||
if (frozenDialogFilters != null) {
|
||||
return frozenDialogFilters;
|
||||
}
|
||||
return dialogFilters;
|
||||
}
|
||||
|
||||
private boolean loadingAppConfig;
|
||||
private Fetcher<Integer, TLRPC.TL_help_appConfig> appConfigFetcher = new Fetcher<Integer, TLRPC.TL_help_appConfig>() {
|
||||
@Override
|
||||
|
@ -467,6 +491,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
public long telegramAntispamUserId;
|
||||
public int telegramAntispamGroupSizeMin;
|
||||
public int hiddenMembersGroupSizeMin;
|
||||
private int chatlistUpdatePeriod;
|
||||
|
||||
public int uploadMaxFileParts;
|
||||
public int uploadMaxFilePartsPremium;
|
||||
|
@ -496,6 +521,11 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
public boolean giftAttachMenuIcon;
|
||||
public boolean giftTextFieldIcon;
|
||||
|
||||
public int chatlistInvitesLimitDefault;
|
||||
public int chatlistInvitesLimitPremium;
|
||||
public int chatlistJoinedLimitDefault;
|
||||
public int chatlistJoinedLimitPremium;
|
||||
|
||||
public int checkResetLangpack;
|
||||
|
||||
public void getNextReactionMention(long dialogId, int topicId, int count, Consumer<Integer> callback) {
|
||||
|
@ -911,6 +941,9 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
public static int DIALOG_FILTER_FLAG_ONLY_ARCHIVED = 0x00000100;
|
||||
public static int DIALOG_FILTER_FLAG_ALL_CHATS = DIALOG_FILTER_FLAG_CONTACTS | DIALOG_FILTER_FLAG_NON_CONTACTS | DIALOG_FILTER_FLAG_GROUPS | DIALOG_FILTER_FLAG_CHANNELS | DIALOG_FILTER_FLAG_BOTS;
|
||||
|
||||
public static int DIALOG_FILTER_FLAG_CHATLIST = 0x00000200;
|
||||
public static int DIALOG_FILTER_FLAG_CHATLIST_ADMIN = 0x00000400;
|
||||
|
||||
public static class DialogFilter {
|
||||
public int id;
|
||||
public String name;
|
||||
|
@ -922,6 +955,9 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
public ArrayList<Long> neverShow = new ArrayList<>();
|
||||
public LongSparseIntArray pinnedDialogs = new LongSparseIntArray();
|
||||
public ArrayList<TLRPC.Dialog> dialogs = new ArrayList<>();
|
||||
public ArrayList<TLRPC.Dialog> dialogsForward = new ArrayList<>();
|
||||
|
||||
public ArrayList<TLRPC.TL_exportedChatlistInvite> invites = null;
|
||||
|
||||
private static int dialogFilterPointer = 10;
|
||||
public int localId = dialogFilterPointer++;
|
||||
|
@ -1010,6 +1046,14 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
public boolean isDefault() {
|
||||
return id == 0;
|
||||
}
|
||||
|
||||
public boolean isChatlist() {
|
||||
return (flags & DIALOG_FILTER_FLAG_CHATLIST) > 0;
|
||||
}
|
||||
|
||||
public boolean isMyChatlist() {
|
||||
return isChatlist() && (flags & DIALOG_FILTER_FLAG_CHATLIST_ADMIN) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
private DialogFilter sortingDialogFilter;
|
||||
|
@ -1152,6 +1196,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
MessagesController messagesController = getMessagesController();
|
||||
getNotificationCenter().addObserver(messagesController, NotificationCenter.fileUploaded);
|
||||
getNotificationCenter().addObserver(messagesController, NotificationCenter.fileUploadFailed);
|
||||
getNotificationCenter().addObserver(messagesController, NotificationCenter.fileUploadProgressChanged);
|
||||
getNotificationCenter().addObserver(messagesController, NotificationCenter.fileLoaded);
|
||||
getNotificationCenter().addObserver(messagesController, NotificationCenter.fileLoadFailed);
|
||||
getNotificationCenter().addObserver(messagesController, NotificationCenter.messageReceivedByServer);
|
||||
|
@ -1264,20 +1309,26 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
telegramAntispamUserId = mainPreferences.getLong("telegramAntispamUserId", -1);
|
||||
telegramAntispamGroupSizeMin = mainPreferences.getInt("telegramAntispamGroupSizeMin", 100);
|
||||
hiddenMembersGroupSizeMin = mainPreferences.getInt("hiddenMembersGroupSizeMin", 100);
|
||||
chatlistUpdatePeriod = mainPreferences.getInt("chatlistUpdatePeriod", 3600);
|
||||
uploadMarkupVideo = mainPreferences.getBoolean("uploadMarkupVideo", true);
|
||||
giftAttachMenuIcon = mainPreferences.getBoolean("giftAttachMenuIcon", false);
|
||||
giftTextFieldIcon = mainPreferences.getBoolean("giftTextFieldIcon", false);
|
||||
checkResetLangpack = mainPreferences.getInt("checkResetLangpack", 0);
|
||||
boolean isTest = ConnectionsManager.native_isTestBackend(currentAccount) != 0;
|
||||
chatlistInvitesLimitDefault = mainPreferences.getInt("chatlistInvitesLimitDefault", 3);
|
||||
chatlistInvitesLimitPremium = mainPreferences.getInt("chatlistInvitesLimitPremium", isTest ? 5 : 20);
|
||||
chatlistJoinedLimitDefault = mainPreferences.getInt("chatlistJoinedLimitDefault", 2);
|
||||
chatlistJoinedLimitPremium = mainPreferences.getInt("chatlistJoinedLimitPremium", isTest ? 5 : 20);
|
||||
BuildVars.GOOGLE_AUTH_CLIENT_ID = mainPreferences.getString("googleAuthClientId", BuildVars.GOOGLE_AUTH_CLIENT_ID);
|
||||
if (mainPreferences.contains("dcDomainName2")) {
|
||||
dcDomainName = mainPreferences.getString("dcDomainName2", "apv3.stel.com");
|
||||
} else {
|
||||
dcDomainName = ConnectionsManager.native_isTestBackend(currentAccount) != 0 ? "tapv3.stel.com" : "apv3.stel.com";
|
||||
dcDomainName = isTest ? "tapv3.stel.com" : "apv3.stel.com";
|
||||
}
|
||||
if (mainPreferences.contains("webFileDatacenterId")) {
|
||||
webFileDatacenterId = mainPreferences.getInt("webFileDatacenterId", 4);
|
||||
} else {
|
||||
webFileDatacenterId = ConnectionsManager.native_isTestBackend(currentAccount) != 0 ? 2 : 4;
|
||||
webFileDatacenterId = isTest ? 2 : 4;
|
||||
}
|
||||
|
||||
Set<String> currencySet = mainPreferences.getStringSet("directPaymentsCurrency", null);
|
||||
|
@ -1422,7 +1473,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
|
||||
|
||||
private void sendLoadPeersRequest(TLObject req, ArrayList<TLObject> requests, TLRPC.messages_Dialogs pinnedDialogs, TLRPC.messages_Dialogs pinnedRemoteDialogs, ArrayList<TLRPC.User> users, ArrayList<TLRPC.Chat> chats, ArrayList<DialogFilter> filtersToSave, SparseArray<DialogFilter> filtersToDelete, ArrayList<Integer> filtersOrder, HashMap<Integer, HashSet<Long>> filterDialogRemovals, HashSet<Integer> filtersUnreadCounterReset) {
|
||||
private void sendLoadPeersRequest(TLObject req, ArrayList<TLObject> requests, TLRPC.messages_Dialogs pinnedDialogs, TLRPC.messages_Dialogs pinnedRemoteDialogs, ArrayList<TLRPC.User> users, ArrayList<TLRPC.Chat> chats, ArrayList<DialogFilter> filtersToSave, SparseArray<DialogFilter> filtersToDelete, ArrayList<Integer> filtersOrder, HashMap<Integer, HashSet<Long>> filterDialogRemovals, HashSet<Integer> filtersUnreadCounterReset, Runnable onDone) {
|
||||
getConnectionsManager().sendRequest(req, (response, error) -> {
|
||||
if (response instanceof TLRPC.TL_messages_chats) {
|
||||
TLRPC.TL_messages_chats res = (TLRPC.TL_messages_chats) response;
|
||||
|
@ -1444,12 +1495,12 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
requests.remove(req);
|
||||
if (requests.isEmpty()) {
|
||||
getMessagesStorage().processLoadedFilterPeers(pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset);
|
||||
getMessagesStorage().processLoadedFilterPeers(pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset, onDone);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void loadFilterPeers(HashMap<Long, TLRPC.InputPeer> dialogsToLoadMap, HashMap<Long, TLRPC.InputPeer> usersToLoadMap, HashMap<Long, TLRPC.InputPeer> chatsToLoadMap, TLRPC.messages_Dialogs pinnedDialogs, TLRPC.messages_Dialogs pinnedRemoteDialogs, ArrayList<TLRPC.User> users, ArrayList<TLRPC.Chat> chats, ArrayList<DialogFilter> filtersToSave, SparseArray<DialogFilter> filtersToDelete, ArrayList<Integer> filtersOrder, HashMap<Integer, HashSet<Long>> filterDialogRemovals, HashSet<Integer> filtersUnreadCounterReset) {
|
||||
protected void loadFilterPeers(HashMap<Long, TLRPC.InputPeer> dialogsToLoadMap, HashMap<Long, TLRPC.InputPeer> usersToLoadMap, HashMap<Long, TLRPC.InputPeer> chatsToLoadMap, TLRPC.messages_Dialogs pinnedDialogs, TLRPC.messages_Dialogs pinnedRemoteDialogs, ArrayList<TLRPC.User> users, ArrayList<TLRPC.Chat> chats, ArrayList<DialogFilter> filtersToSave, SparseArray<DialogFilter> filtersToDelete, ArrayList<Integer> filtersOrder, HashMap<Integer, HashSet<Long>> filterDialogRemovals, HashSet<Integer> filtersUnreadCounterReset, Runnable onDone) {
|
||||
Utilities.stageQueue.postRunnable(() -> {
|
||||
ArrayList<TLObject> requests = new ArrayList<>();
|
||||
TLRPC.TL_users_getUsers req = null;
|
||||
|
@ -1460,12 +1511,12 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
req.id.add(getInputUser(entry.getValue()));
|
||||
if (req.id.size() == 100) {
|
||||
sendLoadPeersRequest(req, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset);
|
||||
sendLoadPeersRequest(req, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset, onDone);
|
||||
req = null;
|
||||
}
|
||||
}
|
||||
if (req != null) {
|
||||
sendLoadPeersRequest(req, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset);
|
||||
sendLoadPeersRequest(req, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset, onDone);
|
||||
}
|
||||
TLRPC.TL_messages_getChats req2 = null;
|
||||
TLRPC.TL_channels_getChannels req3 = null;
|
||||
|
@ -1478,7 +1529,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
req2.id.add(entry.getKey());
|
||||
if (req2.id.size() == 100) {
|
||||
sendLoadPeersRequest(req2, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset);
|
||||
sendLoadPeersRequest(req2, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset, onDone);
|
||||
req2 = null;
|
||||
}
|
||||
} else if (inputPeer.channel_id != 0) {
|
||||
|
@ -1488,16 +1539,16 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
req3.id.add(getInputChannel(inputPeer));
|
||||
if (req3.id.size() == 100) {
|
||||
sendLoadPeersRequest(req3, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset);
|
||||
sendLoadPeersRequest(req3, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset, onDone);
|
||||
req3 = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (req2 != null) {
|
||||
sendLoadPeersRequest(req2, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset);
|
||||
sendLoadPeersRequest(req2, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset, onDone);
|
||||
}
|
||||
if (req3 != null) {
|
||||
sendLoadPeersRequest(req3, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset);
|
||||
sendLoadPeersRequest(req3, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset, onDone);
|
||||
}
|
||||
|
||||
TLRPC.TL_messages_getPeerDialogs req4 = null;
|
||||
|
@ -1510,17 +1561,17 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
inputDialogPeer.peer = entry.getValue();
|
||||
req4.peers.add(inputDialogPeer);
|
||||
if (req4.peers.size() == 100) {
|
||||
sendLoadPeersRequest(req4, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset);
|
||||
sendLoadPeersRequest(req4, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset, onDone);
|
||||
req4 = null;
|
||||
}
|
||||
}
|
||||
if (req4 != null) {
|
||||
sendLoadPeersRequest(req4, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset);
|
||||
sendLoadPeersRequest(req4, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset, onDone);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void processLoadedDialogFilters(ArrayList<DialogFilter> filters, TLRPC.messages_Dialogs pinnedDialogs, TLRPC.messages_Dialogs pinnedRemoteDialogs, ArrayList<TLRPC.User> users, ArrayList<TLRPC.Chat> chats, ArrayList<TLRPC.EncryptedChat> encryptedChats, int remote) {
|
||||
protected void processLoadedDialogFilters(ArrayList<DialogFilter> filters, TLRPC.messages_Dialogs pinnedDialogs, TLRPC.messages_Dialogs pinnedRemoteDialogs, ArrayList<TLRPC.User> users, ArrayList<TLRPC.Chat> chats, ArrayList<TLRPC.EncryptedChat> encryptedChats, int remote, Runnable onDone) {
|
||||
Utilities.stageQueue.postRunnable(() -> {
|
||||
|
||||
LongSparseArray<TLRPC.Dialog> new_dialogs_dict = new LongSparseArray<>();
|
||||
|
@ -1727,7 +1778,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
}
|
||||
}
|
||||
getTranslateController().checkDialogMessages(key);
|
||||
getTranslateController().checkDialogMessage(key);
|
||||
} else {
|
||||
currentDialog.pinned = newDialog.pinned;
|
||||
currentDialog.pinnedNum = newDialog.pinnedNum;
|
||||
|
@ -1775,7 +1826,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
}
|
||||
}
|
||||
getTranslateController().checkDialogMessages(key);
|
||||
getTranslateController().checkDialogMessage(key);
|
||||
}
|
||||
} else {
|
||||
// if (newMsg == null || newMsg.messageOwner.date > oldMsg.messageOwner.date) {
|
||||
|
@ -1813,7 +1864,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
}
|
||||
}
|
||||
getTranslateController().checkDialogMessages(key);
|
||||
getTranslateController().checkDialogMessage(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1837,6 +1888,10 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
|
||||
lockFiltersInternal();
|
||||
|
||||
if (onDone != null) {
|
||||
onDone.run();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -1861,7 +1916,16 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}));
|
||||
}
|
||||
|
||||
private Utilities.Callback<Boolean> onLoadedRemoteFilters;
|
||||
|
||||
public void loadRemoteFilters(boolean force) {
|
||||
loadRemoteFilters(force, null);
|
||||
}
|
||||
|
||||
public void loadRemoteFilters(boolean force, Utilities.Callback<Boolean> whenDone) {
|
||||
if (whenDone != null) {
|
||||
onLoadedRemoteFilters = whenDone;
|
||||
}
|
||||
if (loadingRemoteFilters || !getUserConfig().isClientActivated() || !force && getUserConfig().filtersLoaded) {
|
||||
return;
|
||||
}
|
||||
|
@ -1872,9 +1936,20 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
TLRPC.TL_messages_getDialogFilters req = new TLRPC.TL_messages_getDialogFilters();
|
||||
getConnectionsManager().sendRequest(req, (response, error) -> {
|
||||
if (response instanceof TLRPC.Vector) {
|
||||
getMessagesStorage().checkLoadedRemoteFilters((TLRPC.Vector) response);
|
||||
getMessagesStorage().checkLoadedRemoteFilters((TLRPC.Vector) response, () -> {
|
||||
if (onLoadedRemoteFilters != null) {
|
||||
onLoadedRemoteFilters.run(true);
|
||||
onLoadedRemoteFilters = null;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
AndroidUtilities.runOnUIThread(() -> loadingRemoteFilters = false);
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
loadingRemoteFilters = false;
|
||||
if (onLoadedRemoteFilters != null) {
|
||||
onLoadedRemoteFilters.run(false);
|
||||
onLoadedRemoteFilters = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1926,6 +2001,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
if (selectedDialogFilter[index] == null) {
|
||||
if (prevFilter != null) {
|
||||
prevFilter.dialogs.clear();
|
||||
prevFilter.dialogsForward.clear();
|
||||
}
|
||||
} else {
|
||||
sortDialogs(null);
|
||||
|
@ -1949,7 +2025,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
order = Math.min(order, dialogFilters.get(a).order);
|
||||
}
|
||||
filter.order = order - 1;
|
||||
if (dialogFilters.get(0).isDefault() && !getUserConfig().isPremium()) {
|
||||
if (dialogFilters.get(0).isDefault()) {
|
||||
dialogFilters.add(1, filter);
|
||||
} else {
|
||||
dialogFilters.add(0, filter);
|
||||
|
@ -2976,6 +3052,17 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
break;
|
||||
}
|
||||
case "chatlist_update_period": {
|
||||
if (value.value instanceof TLRPC.TL_jsonNumber) {
|
||||
TLRPC.TL_jsonNumber number = (TLRPC.TL_jsonNumber) value.value;
|
||||
if (number.value != chatlistUpdatePeriod) {
|
||||
chatlistUpdatePeriod = (int) number.value;
|
||||
editor.putInt("chatlistUpdatePeriod", chatlistUpdatePeriod);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "android_collect_device_stats": {
|
||||
if (value.value instanceof TLRPC.TL_jsonBool) {
|
||||
TLRPC.TL_jsonBool bool = (TLRPC.TL_jsonBool) value.value;
|
||||
|
@ -2998,6 +3085,50 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
break;
|
||||
}
|
||||
case "chatlist_invites_limit_default": {
|
||||
if (value.value instanceof TLRPC.TL_jsonNumber) {
|
||||
TLRPC.TL_jsonNumber num = (TLRPC.TL_jsonNumber) value.value;
|
||||
if (num.value != chatlistInvitesLimitDefault) {
|
||||
chatlistInvitesLimitDefault = (int) num.value;
|
||||
editor.putInt("chatlistInvitesLimitDefault", chatlistInvitesLimitDefault);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "chatlist_invites_limit_premium": {
|
||||
if (value.value instanceof TLRPC.TL_jsonNumber) {
|
||||
TLRPC.TL_jsonNumber num = (TLRPC.TL_jsonNumber) value.value;
|
||||
if (num.value != chatlistInvitesLimitPremium) {
|
||||
chatlistInvitesLimitPremium = (int) num.value;
|
||||
editor.putInt("chatlistInvitesLimitPremium", chatlistInvitesLimitPremium);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "chatlists_joined_limit_default": {
|
||||
if (value.value instanceof TLRPC.TL_jsonNumber) {
|
||||
TLRPC.TL_jsonNumber num = (TLRPC.TL_jsonNumber) value.value;
|
||||
if (num.value != chatlistJoinedLimitDefault) {
|
||||
chatlistJoinedLimitDefault = (int) num.value;
|
||||
editor.putInt("chatlistJoinedLimitDefault", chatlistJoinedLimitDefault);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "chatlists_joined_limit_premium": {
|
||||
if (value.value instanceof TLRPC.TL_jsonNumber) {
|
||||
TLRPC.TL_jsonNumber num = (TLRPC.TL_jsonNumber) value.value;
|
||||
if (num.value != chatlistJoinedLimitPremium) {
|
||||
chatlistJoinedLimitPremium = (int) num.value;
|
||||
editor.putInt("chatlistJoinedLimitPremium", chatlistJoinedLimitPremium);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
|
@ -3443,11 +3574,14 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
req.file = file;
|
||||
req.mime_type = "image/jpeg";
|
||||
Theme.OverrideWallpaperInfo overrideWallpaperInfo = uploadingWallpaperInfo;
|
||||
String uploadingWallpaperFinal = uploadingWallpaper;
|
||||
TLRPC.TL_wallPaperSettings settings = new TLRPC.TL_wallPaperSettings();
|
||||
settings.blur = overrideWallpaperInfo.isBlurred;
|
||||
settings.motion = overrideWallpaperInfo.isMotion;
|
||||
req.settings = settings;
|
||||
getConnectionsManager().sendRequest(req, (response, error) -> {
|
||||
uploadingWallpaperInfo.uploadingProgress = 1f;
|
||||
uploadingWallpaperInfo.requestIds = new ArrayList<>();
|
||||
uploadingWallpaperInfo.requestIds.add(getConnectionsManager().sendRequest(req, (response, error) -> {
|
||||
TLRPC.WallPaper wallPaper = (TLRPC.WallPaper) response;
|
||||
File path = new File(ApplicationLoader.getFilesDirFixed(), overrideWallpaperInfo.originalFileName);
|
||||
if (wallPaper != null) {
|
||||
|
@ -3473,9 +3607,12 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
ImageLoader.getInstance().replaceImageInCache(oldKey, newKey, ImageLocation.getForDocument(image, wallPaper.document), false);
|
||||
}
|
||||
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.wallpapersNeedReload, wallPaper.slug);
|
||||
if (overrideWallpaperInfo.dialogId != 0) {
|
||||
uploadingWallpaperInfo.requestIds.add(ChatThemeController.getInstance(currentAccount).setWallpaperToUser(overrideWallpaperInfo.dialogId, uploadingWallpaperFinal, overrideWallpaperInfo, null, null));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}));
|
||||
} else {
|
||||
Object object = uploadingThemes.get(location);
|
||||
Theme.ThemeInfo themeInfo;
|
||||
|
@ -3675,6 +3812,13 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
getNotificationCenter().postNotificationName(NotificationCenter.themeUploadError, accent.parentTheme, accent);
|
||||
}
|
||||
}
|
||||
} if (id == NotificationCenter.fileUploadProgressChanged) {
|
||||
String location = (String) args[0];
|
||||
if (uploadingWallpaper != null && uploadingWallpaper.equals(location)) {
|
||||
Long loadedSize = (Long) args[1];
|
||||
Long totalSize = (Long) args[2];
|
||||
uploadingWallpaperInfo.uploadingProgress = loadedSize / (float) totalSize;
|
||||
}
|
||||
} else if (id == NotificationCenter.messageReceivedByServer) {
|
||||
Boolean scheduled = (Boolean) args[6];
|
||||
if (scheduled) {
|
||||
|
@ -4797,6 +4941,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
putChats(res.chats, false);
|
||||
res.full_user.user = getUser(res.full_user.id);
|
||||
getMessagesStorage().updateUserInfo(userFull, false);
|
||||
ChatThemeController.getInstance(currentAccount).saveChatWallpaper(res.full_user.id, res.full_user.wallpaper);
|
||||
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
savePeerSettings(userFull.user.id, userFull.settings, false);
|
||||
|
@ -5043,7 +5188,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
return;
|
||||
}
|
||||
SharedPreferences.Editor editor = notificationsPreferences.edit();
|
||||
boolean bar_hidden = !settings.report_spam && !settings.add_contact && !settings.block_contact && !settings.share_contact && !settings.report_geo && !settings.invite_members;
|
||||
boolean bar_hidden = settings.flags == 0;
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
FileLog.d("peer settings loaded for " + dialogId + " add = " + settings.add_contact + " block = " + settings.block_contact + " spam = " + settings.report_spam + " share = " + settings.share_contact + " geo = " + settings.report_geo + " hide = " + bar_hidden + " distance = " + settings.geo_distance + " invite = " + settings.invite_members);
|
||||
}
|
||||
|
@ -5776,40 +5921,8 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
uploadingWallpaperInfo = info;
|
||||
getFileLoader().uploadFile(uploadingWallpaper, false, true, ConnectionsManager.FileTypePhoto);
|
||||
} else if (!info.isDefault() && !info.isColor() && info.wallpaperId > 0 && !info.isTheme()) {
|
||||
TLRPC.InputWallPaper inputWallPaper;
|
||||
if (info.wallpaperId > 0) {
|
||||
TLRPC.TL_inputWallPaper inputWallPaperId = new TLRPC.TL_inputWallPaper();
|
||||
inputWallPaperId.id = info.wallpaperId;
|
||||
inputWallPaperId.access_hash = info.accessHash;
|
||||
inputWallPaper = inputWallPaperId;
|
||||
} else {
|
||||
TLRPC.TL_inputWallPaperSlug inputWallPaperSlug = new TLRPC.TL_inputWallPaperSlug();
|
||||
inputWallPaperSlug.slug = info.slug;
|
||||
inputWallPaper = inputWallPaperSlug;
|
||||
}
|
||||
|
||||
TLRPC.TL_wallPaperSettings settings = new TLRPC.TL_wallPaperSettings();
|
||||
settings.blur = info.isBlurred;
|
||||
settings.motion = info.isMotion;
|
||||
if (info.color != 0) {
|
||||
settings.background_color = info.color & 0x00ffffff;
|
||||
settings.flags |= 1;
|
||||
settings.intensity = (int) (info.intensity * 100);
|
||||
settings.flags |= 8;
|
||||
}
|
||||
if (info.gradientColor1 != 0) {
|
||||
settings.second_background_color = info.gradientColor1 & 0x00ffffff;
|
||||
settings.rotation = AndroidUtilities.getWallpaperRotation(info.rotation, true);
|
||||
settings.flags |= 16;
|
||||
}
|
||||
if (info.gradientColor2 != 0) {
|
||||
settings.third_background_color = info.gradientColor2 & 0x00ffffff;
|
||||
settings.flags |= 32;
|
||||
}
|
||||
if (info.gradientColor3 != 0) {
|
||||
settings.fourth_background_color = info.gradientColor3 & 0x00ffffff;
|
||||
settings.flags |= 64;
|
||||
}
|
||||
TLRPC.InputWallPaper inputWallPaper = getInputWallpaper(info);
|
||||
TLRPC.TL_wallPaperSettings settings = getWallpaperSetting(info);
|
||||
|
||||
TLObject req;
|
||||
if (install) {
|
||||
|
@ -5898,6 +6011,50 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
}
|
||||
|
||||
public static TLRPC.TL_wallPaperSettings getWallpaperSetting(Theme.OverrideWallpaperInfo info) {
|
||||
TLRPC.TL_wallPaperSettings settings = new TLRPC.TL_wallPaperSettings();
|
||||
settings.blur = info.isBlurred;
|
||||
settings.motion = info.isMotion;
|
||||
if (info.color != 0) {
|
||||
settings.background_color = info.color & 0x00ffffff;
|
||||
settings.flags |= 1;
|
||||
settings.intensity = (int) (info.intensity * 100);
|
||||
settings.flags |= 8;
|
||||
} else if (info.intensity > 0) {
|
||||
settings.intensity = (int) (info.intensity * 100);
|
||||
settings.flags |= 8;
|
||||
}
|
||||
if (info.gradientColor1 != 0) {
|
||||
settings.second_background_color = info.gradientColor1 & 0x00ffffff;
|
||||
settings.rotation = AndroidUtilities.getWallpaperRotation(info.rotation, true);
|
||||
settings.flags |= 16;
|
||||
}
|
||||
if (info.gradientColor2 != 0) {
|
||||
settings.third_background_color = info.gradientColor2 & 0x00ffffff;
|
||||
settings.flags |= 32;
|
||||
}
|
||||
if (info.gradientColor3 != 0) {
|
||||
settings.fourth_background_color = info.gradientColor3 & 0x00ffffff;
|
||||
settings.flags |= 64;
|
||||
}
|
||||
return settings;
|
||||
}
|
||||
|
||||
public static TLRPC.InputWallPaper getInputWallpaper(Theme.OverrideWallpaperInfo info) {
|
||||
TLRPC.InputWallPaper inputWallPaper;
|
||||
if (info.wallpaperId > 0) {
|
||||
TLRPC.TL_inputWallPaper inputWallPaperId = new TLRPC.TL_inputWallPaper();
|
||||
inputWallPaperId.id = info.wallpaperId;
|
||||
inputWallPaperId.access_hash = info.accessHash;
|
||||
inputWallPaper = inputWallPaperId;
|
||||
} else {
|
||||
TLRPC.TL_inputWallPaperSlug inputWallPaperSlug = new TLRPC.TL_inputWallPaperSlug();
|
||||
inputWallPaperSlug.slug = info.slug;
|
||||
inputWallPaper = inputWallPaperSlug;
|
||||
}
|
||||
return inputWallPaper;
|
||||
}
|
||||
|
||||
public void markDialogMessageAsDeleted(long dialogId, ArrayList<Integer> messages) {
|
||||
ArrayList<MessageObject> objs = dialogMessage.get(dialogId);
|
||||
if (objs != null) {
|
||||
|
@ -6262,6 +6419,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
for (int a = 0; a < selectedDialogFilter.length; a++) {
|
||||
if (selectedDialogFilter[a] != null) {
|
||||
selectedDialogFilter[a].dialogs.remove(dialog);
|
||||
selectedDialogFilter[a].dialogsForward.remove(dialog);
|
||||
}
|
||||
}
|
||||
dialogs_dict.remove(did);
|
||||
|
@ -7289,7 +7447,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
if (promoDialog.last_message_date == 0) {
|
||||
promoDialog.last_message_date = messageObject.messageOwner.date;
|
||||
}
|
||||
getTranslateController().checkDialogMessages(did);
|
||||
getTranslateController().checkDialogMessage(did);
|
||||
}
|
||||
sortDialogs(null);
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, true);
|
||||
|
@ -8171,7 +8329,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
});
|
||||
}
|
||||
|
||||
private TLRPC.TL_dialogFolder ensureFolderDialogExists(int folderId, boolean[] folderCreated) {
|
||||
public TLRPC.TL_dialogFolder ensureFolderDialogExists(int folderId, boolean[] folderCreated) {
|
||||
if (folderId == 0) {
|
||||
return null;
|
||||
}
|
||||
|
@ -8887,7 +9045,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
}
|
||||
}
|
||||
getTranslateController().checkDialogMessages(key);
|
||||
getTranslateController().checkDialogMessage(key);
|
||||
}
|
||||
|
||||
allDialogs.clear();
|
||||
|
@ -9416,6 +9574,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
|
||||
int archivedDialogsCount = 0;
|
||||
int lastDialogDate = migrate && !allDialogs.isEmpty() ? allDialogs.get(allDialogs.size() - 1).last_message_date : 0;
|
||||
final boolean translating = getTranslateController().isFeatureAvailable();
|
||||
for (int a = 0; a < new_dialogs_dict.size(); a++) {
|
||||
long key = new_dialogs_dict.keyAt(a);
|
||||
TLRPC.Dialog value = new_dialogs_dict.valueAt(a);
|
||||
|
@ -9448,7 +9607,9 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
}
|
||||
}
|
||||
getTranslateController().checkDialogMessages(key);
|
||||
if (translating) {
|
||||
getTranslateController().checkDialogMessageSure(key);
|
||||
}
|
||||
} else {
|
||||
if (loadType != DIALOGS_LOAD_TYPE_CACHE) {
|
||||
currentDialog.notify_settings = value.notify_settings;
|
||||
|
@ -9500,7 +9661,9 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
}
|
||||
}
|
||||
getTranslateController().checkDialogMessages(key);
|
||||
if (translating) {
|
||||
getTranslateController().checkDialogMessageSure(key);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// if (newMsg == null && oldMs.getId() > 0 || newMsg != null && newMsg.messageOwner.date > oldMsg.messageOwner.date)
|
||||
|
@ -9538,7 +9701,9 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
}
|
||||
}
|
||||
getTranslateController().checkDialogMessages(key);
|
||||
if (translating) {
|
||||
getTranslateController().checkDialogMessageSure(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9958,6 +10123,8 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
putUsers(dialogsRes.users, true);
|
||||
putChats(dialogsRes.chats, true);
|
||||
|
||||
final boolean translating = getTranslateController().isFeatureAvailable();
|
||||
|
||||
for (int a = 0; a < new_dialogs_dict.size(); a++) {
|
||||
long key = new_dialogs_dict.keyAt(a);
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
|
@ -9996,7 +10163,9 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
FileLog.d("processDialogsUpdate new message not null");
|
||||
}
|
||||
}
|
||||
getTranslateController().checkDialogMessages(key);
|
||||
if (translating) {
|
||||
getTranslateController().checkDialogMessageSure(key);
|
||||
}
|
||||
} else {
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
FileLog.d("processDialogsUpdate dialog not null");
|
||||
|
@ -10056,7 +10225,9 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
}
|
||||
}
|
||||
getTranslateController().checkDialogMessages(key);
|
||||
if (translating) {
|
||||
getTranslateController().checkDialogMessageSure(key);
|
||||
}
|
||||
}
|
||||
if (fromCache && newMsgs == null) {
|
||||
checkLastDialogMessage(value, null, 0);
|
||||
|
@ -10103,7 +10274,9 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
}
|
||||
}
|
||||
getTranslateController().checkDialogMessages(key);
|
||||
if (translating) {
|
||||
getTranslateController().checkDialogMessageSure(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12829,7 +13002,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
}
|
||||
}
|
||||
getTranslateController().checkDialogMessages(dialog.id);
|
||||
getTranslateController().checkDialogMessage(dialog.id);
|
||||
}
|
||||
|
||||
changed = true;
|
||||
|
@ -16576,6 +16749,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
for (int a = 0; a < selectedDialogFilter.length; a++) {
|
||||
if (selectedDialogFilter[a] != null) {
|
||||
selectedDialogFilter[a].dialogs.remove(dialog);
|
||||
selectedDialogFilter[a].dialogsForward.remove(dialog);
|
||||
}
|
||||
}
|
||||
dialogsUsersOnly.remove(dialog);
|
||||
|
@ -16663,7 +16837,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
}
|
||||
dialogMessage.put(dialogId, arrayList);
|
||||
getTranslateController().checkDialogMessages(dialogId);
|
||||
getTranslateController().checkDialogMessage(dialogId);
|
||||
changed = true;
|
||||
|
||||
if (filterDialogsChanged) {
|
||||
|
@ -16706,7 +16880,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
}
|
||||
dialogMessage.put(dialogId, arrayList);
|
||||
getTranslateController().checkDialogMessages(dialogId);
|
||||
getTranslateController().checkDialogMessage(dialogId);
|
||||
if (lastMessage.messageOwner.peer_id.channel_id == 0) {
|
||||
dialogMessagesByIds.put(lastMessage.getId(), lastMessage);
|
||||
if (lastMessage.messageOwner.random_id != 0) {
|
||||
|
@ -16768,6 +16942,63 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
return clearingHistoryDialogs.get(did) != null;
|
||||
}
|
||||
|
||||
public void updateFilterDialogs(DialogFilter filter) {
|
||||
if (filter == null) {
|
||||
return;
|
||||
}
|
||||
ArrayList<TLRPC.Dialog> dialogs = filter.dialogs;
|
||||
ArrayList<TLRPC.Dialog> dialogsForward = filter.dialogsForward;
|
||||
dialogs.clear();
|
||||
dialogsForward.clear();
|
||||
sortingDialogFilter = filter;
|
||||
try {
|
||||
Collections.sort(allDialogs, dialogDateComparator);
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
for (int a = 0, N = allDialogs.size(); a < N; a++) {
|
||||
TLRPC.Dialog d = allDialogs.get(a);
|
||||
if (d instanceof TLRPC.TL_dialog) {
|
||||
long dialogId = d.id;
|
||||
if (DialogObject.isEncryptedDialog(dialogId)) {
|
||||
TLRPC.EncryptedChat encryptedChat = getEncryptedChat(DialogObject.getEncryptedChatId(dialogId));
|
||||
if (encryptedChat != null) {
|
||||
dialogId = encryptedChat.user_id;
|
||||
}
|
||||
}
|
||||
if (filter.includesDialog(getAccountInstance(), dialogId, d)) {
|
||||
if (canAddToForward(d)) {
|
||||
dialogsForward.add(d);
|
||||
}
|
||||
dialogs.add(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
Collections.sort(allDialogs, dialogComparator);
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
|
||||
private boolean canAddToForward(TLRPC.Dialog d) {
|
||||
if (d == null) {
|
||||
return false;
|
||||
}
|
||||
if (DialogObject.isEncryptedDialog(d.id)) {
|
||||
return true;
|
||||
}
|
||||
boolean canAddToForward = true;
|
||||
if (DialogObject.isChannel(d)) {
|
||||
TLRPC.Chat chat = getChat(-d.id);
|
||||
if (chat != null && chat.megagroup) {
|
||||
canAddToForward = !chat.gigagroup || ChatObject.hasAdminRights(chat);
|
||||
} else {
|
||||
dialogsChannelsOnly.add(d);
|
||||
canAddToForward = ChatObject.hasAdminRights(chat) && ChatObject.canPost(chat);
|
||||
}
|
||||
}
|
||||
return canAddToForward;
|
||||
}
|
||||
|
||||
public void sortDialogs(LongSparseArray<TLRPC.Chat> chatsDict) {
|
||||
if (chatsDict == null && ApplicationLoader.mainInterfacePaused) {
|
||||
return;
|
||||
|
@ -16778,11 +17009,6 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
dialogsMyChannels.clear();
|
||||
dialogsChannelsOnly.clear();
|
||||
dialogsGroupsOnly.clear();
|
||||
for (int a = 0; a < selectedDialogFilter.length; a++) {
|
||||
if (selectedDialogFilter[a] != null) {
|
||||
selectedDialogFilter[a].dialogs.clear();
|
||||
}
|
||||
}
|
||||
dialogsUsersOnly.clear();
|
||||
dialogsForBlock.clear();
|
||||
dialogsForward.clear();
|
||||
|
@ -16801,13 +17027,15 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
if (sortingDialogFilter == null) {
|
||||
continue;
|
||||
}
|
||||
ArrayList<TLRPC.Dialog> dialogs = sortingDialogFilter.dialogs;
|
||||
ArrayList<TLRPC.Dialog> dialogsForward = sortingDialogFilter.dialogsForward;
|
||||
dialogs.clear();
|
||||
dialogsForward.clear();
|
||||
try {
|
||||
Collections.sort(allDialogs, dialogDateComparator);
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
ArrayList<TLRPC.Dialog> dialogsByFilter = sortingDialogFilter.dialogs;
|
||||
|
||||
for (int a = 0, N = allDialogs.size(); a < N; a++) {
|
||||
TLRPC.Dialog d = allDialogs.get(a);
|
||||
if (d instanceof TLRPC.TL_dialog) {
|
||||
|
@ -16819,7 +17047,10 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
}
|
||||
if (sortingDialogFilter.includesDialog(getAccountInstance(), dialogId, d)) {
|
||||
dialogsByFilter.add(d);
|
||||
if (canAddToForward(d)) {
|
||||
dialogsForward.add(d);
|
||||
}
|
||||
dialogs.add(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16828,9 +17059,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
|
||||
try {
|
||||
Collections.sort(allDialogs, dialogComparator);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
isLeftPromoChannel = true;
|
||||
if (promoDialog != null && promoDialog.id < 0) {
|
||||
TLRPC.Chat chat = getChat(-promoDialog.id);
|
||||
|
@ -16856,7 +17085,6 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
}
|
||||
}
|
||||
boolean canAddToForward = true;
|
||||
if (!DialogObject.isEncryptedDialog(d.id)) {
|
||||
dialogsServerOnly.add(d);
|
||||
if (DialogObject.isChannel(d)) {
|
||||
|
@ -16874,10 +17102,8 @@ 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);
|
||||
}
|
||||
} else if (d.id < 0) {
|
||||
if (chatsDict != null) {
|
||||
|
@ -16905,7 +17131,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
}
|
||||
}
|
||||
if (canAddToForward && d.folder_id == 0) {
|
||||
if (canAddToForward(d) && d.folder_id == 0) {
|
||||
if (d.id == selfId) {
|
||||
dialogsForward.add(0, d);
|
||||
selfAdded = true;
|
||||
|
@ -17621,4 +17847,133 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
public CacheByChatsController getCacheByChatsController() {
|
||||
return cacheByChatsController;
|
||||
}
|
||||
|
||||
public int getFilterIdByDialogsType(int dialogsType) {
|
||||
if (dialogsType != 7 && dialogsType != 8) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
DialogFilter filter = selectedDialogFilter[dialogsType - 7];
|
||||
if (filter == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return filter.id;
|
||||
}
|
||||
|
||||
public void invalidateChatlistFolderUpdate(int filterId) {
|
||||
chatlistFoldersUpdates.remove(filterId);
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.chatlistFolderUpdate, filterId);
|
||||
}
|
||||
|
||||
public void checkChatlistFolderUpdate(int filterId, boolean invalidate) {
|
||||
if (filterId < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ChatlistUpdatesStat stat = chatlistFoldersUpdates.get(filterId);
|
||||
if (stat == null || !stat.loading && (System.currentTimeMillis() - stat.lastRequestTime > 1000L * chatlistUpdatePeriod || invalidate)) {
|
||||
if (stat == null) {
|
||||
stat = new ChatlistUpdatesStat();
|
||||
chatlistFoldersUpdates.put(filterId, stat);
|
||||
}
|
||||
final ChatlistUpdatesStat finalStat = stat;
|
||||
finalStat.loading = false;
|
||||
TLRPC.TL_chatlists_getChatlistUpdates req = new TLRPC.TL_chatlists_getChatlistUpdates();
|
||||
req.chatlist = new TLRPC.TL_inputChatlistDialogFilter();
|
||||
req.chatlist.filter_id = filterId;
|
||||
getConnectionsManager().sendRequest(req, (res, err) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
if (res instanceof TLRPC.TL_chatlists_chatlistUpdates) {
|
||||
TLRPC.TL_chatlists_chatlistUpdates updates = (TLRPC.TL_chatlists_chatlistUpdates) res;
|
||||
putChats(updates.chats, false);
|
||||
putUsers(updates.users, false);
|
||||
chatlistFoldersUpdates.put(filterId, new ChatlistUpdatesStat(updates));
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.chatlistFolderUpdate, filterId);
|
||||
} else {
|
||||
finalStat.loading = false;
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
public TLRPC.TL_chatlists_chatlistUpdates getChatlistFolderUpdates(int filterId) {
|
||||
ChatlistUpdatesStat stat = chatlistFoldersUpdates.get(filterId);
|
||||
if (stat == null) {
|
||||
return null;
|
||||
}
|
||||
return stat.lastValue;
|
||||
}
|
||||
|
||||
public Pair<Runnable, Runnable> removeFolderTemporarily(final int filterId, final ArrayList<Long> chats) {
|
||||
|
||||
frozenDialogFilters = new ArrayList<>(dialogFilters);
|
||||
for (int i = 0; i < frozenDialogFilters.size(); ++i) {
|
||||
DialogFilter f = frozenDialogFilters.get(i);
|
||||
if (f.id == filterId) {
|
||||
frozenDialogFilters.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
hiddenUndoChats.clear();
|
||||
if (chats != null) {
|
||||
hiddenUndoChats.addAll(chats);
|
||||
}
|
||||
final boolean hidChats = !hiddenUndoChats.isEmpty();
|
||||
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.dialogFiltersUpdated);
|
||||
if (hidChats) {
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload);
|
||||
}
|
||||
|
||||
Runnable apply = () -> {
|
||||
for (int i = 0; i < dialogFilters.size(); ++i) {
|
||||
DialogFilter f = dialogFilters.get(i);
|
||||
if (f.id == filterId) {
|
||||
dialogFilters.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
frozenDialogFilters = null;
|
||||
hiddenUndoChats.clear();
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.dialogFiltersUpdated);
|
||||
if (hidChats) {
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload);
|
||||
}
|
||||
};
|
||||
Runnable undo = () -> {
|
||||
frozenDialogFilters = null;
|
||||
hiddenUndoChats.clear();
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.dialogFiltersUpdated);
|
||||
if (hidChats) {
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload);
|
||||
}
|
||||
};
|
||||
|
||||
return new Pair<>(apply, undo);
|
||||
}
|
||||
|
||||
public boolean isHiddenByUndo(long did) {
|
||||
return !hiddenUndoChats.isEmpty() && hiddenUndoChats.contains(did);
|
||||
}
|
||||
|
||||
public void cancelUploadWallpaper() {
|
||||
if (uploadingWallpaperInfo != null) {
|
||||
if (uploadingWallpaperInfo.requestIds != null) {
|
||||
for (int i = 0; i < uploadingWallpaperInfo.requestIds.size(); i++) {
|
||||
ConnectionsManager.getInstance(currentAccount).cancelRequest(uploadingWallpaperInfo.requestIds.get(i), true);
|
||||
}
|
||||
}
|
||||
FileLoader.getInstance(currentAccount).cancelFileUpload(uploadingWallpaper, false);
|
||||
if (uploadingWallpaperInfo.dialogId != 0) {
|
||||
TLRPC.UserFull userFull = getUserFull(uploadingWallpaperInfo.dialogId);
|
||||
if (userFull != null) {
|
||||
userFull.wallpaper = uploadingWallpaperInfo.prevUserWallpaper;
|
||||
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.userInfoDidLoad, uploadingWallpaperInfo.dialogId, userFull);
|
||||
}
|
||||
}
|
||||
uploadingWallpaperInfo = null;
|
||||
uploadingWallpaper = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ public class MessagesStorage extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
public final static int LAST_DB_VERSION = 116;
|
||||
public final static int LAST_DB_VERSION = 117;
|
||||
private boolean databaseMigrationInProgress;
|
||||
public boolean showClearDatabaseAlert;
|
||||
private LongSparseIntArray dialogIsForum = new LongSparseIntArray();
|
||||
|
@ -1815,7 +1815,7 @@ public class MessagesStorage extends BaseController {
|
|||
try {
|
||||
String topics = TextUtils.join(", ", topicIds);
|
||||
database.executeFast(String.format(Locale.US, "DELETE FROM topics WHERE did = %d AND topic_id IN (%s)", dialogId, topics)).stepThis().dispose();
|
||||
database.executeFast(String.format(Locale.US, "DELETE FROM messages_topics WHERE uid = %d AND topic_id = IN (%s)", dialogId, topics)).stepThis().dispose();
|
||||
database.executeFast(String.format(Locale.US, "DELETE FROM messages_topics WHERE uid = %d AND topic_id IN (%s)", dialogId, topics)).stepThis().dispose();
|
||||
} catch (SQLiteException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -2305,7 +2305,7 @@ public class MessagesStorage extends BaseController {
|
|||
getChatsInternal(TextUtils.join(",", chatsToLoad), chats);
|
||||
}
|
||||
|
||||
getMessagesController().processLoadedDialogFilters(new ArrayList<>(dialogFilters), dialogs, null, users, chats, encryptedChats, 0);
|
||||
getMessagesController().processLoadedDialogFilters(new ArrayList<>(dialogFilters), dialogs, null, users, chats, encryptedChats, 0, null);
|
||||
} catch (Exception e) {
|
||||
checkSQLException(e);
|
||||
} finally {
|
||||
|
@ -2727,7 +2727,11 @@ public class MessagesStorage extends BaseController {
|
|||
try {
|
||||
if (!dialogFilters.contains(filter)) {
|
||||
if (atBegin) {
|
||||
dialogFilters.add(0, filter);
|
||||
if (dialogFilters.get(0).isDefault()) {
|
||||
dialogFilters.add(1, filter);
|
||||
} else {
|
||||
dialogFilters.add(0, filter);
|
||||
}
|
||||
} else {
|
||||
dialogFilters.add(filter);
|
||||
}
|
||||
|
@ -2815,294 +2819,7 @@ public class MessagesStorage extends BaseController {
|
|||
return array;
|
||||
}
|
||||
|
||||
// public void checkLoadedRemoteFilter(TLRPC.DialogFilter newFilter) {
|
||||
// storageQueue.postRunnable(() -> {
|
||||
// try {
|
||||
// SparseArray<MessagesController.DialogFilter> filtersToDelete = new SparseArray<>();
|
||||
// for (int a = 0, N = dialogFilters.size(); a < N; a++) {
|
||||
// MessagesController.DialogFilter filter = dialogFilters.get(a);
|
||||
// filtersToDelete.put(filter.id, filter);
|
||||
// }
|
||||
// ArrayList<Integer> filtersOrder = new ArrayList<>();
|
||||
//
|
||||
// ArrayList<Long> usersToLoad = new ArrayList<>();
|
||||
// HashMap<Long, TLRPC.InputPeer> usersToLoadMap = new HashMap<>();
|
||||
// ArrayList<Long> chatsToLoad = new ArrayList<>();
|
||||
// HashMap<Long, TLRPC.InputPeer> chatsToLoadMap = new HashMap<>();
|
||||
// ArrayList<Long> dialogsToLoad = new ArrayList<>();
|
||||
// HashMap<Long, TLRPC.InputPeer> dialogsToLoadMap = new HashMap<>();
|
||||
//
|
||||
// ArrayList<MessagesController.DialogFilter> filtersToSave = new ArrayList<>();
|
||||
// HashMap<Integer, HashSet<Long>> filterDialogRemovals = new HashMap<>();
|
||||
// HashSet<Integer> filtersUnreadCounterReset = new HashSet<>();
|
||||
// for (int a = 0, N = vector.objects.size(); a < N; a++) {
|
||||
// TLRPC.DialogFilter newFilter = (TLRPC.DialogFilter) vector.objects.get(a);
|
||||
// filtersOrder.add(newFilter.id);
|
||||
// int newFlags = 0;
|
||||
// if (newFilter.contacts) {
|
||||
// newFlags |= MessagesController.DIALOG_FILTER_FLAG_CONTACTS;
|
||||
// }
|
||||
// if (newFilter.non_contacts) {
|
||||
// newFlags |= MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS;
|
||||
// }
|
||||
// if (newFilter.groups) {
|
||||
// newFlags |= MessagesController.DIALOG_FILTER_FLAG_GROUPS;
|
||||
// }
|
||||
// if (newFilter.broadcasts) {
|
||||
// newFlags |= MessagesController.DIALOG_FILTER_FLAG_CHANNELS;
|
||||
// }
|
||||
// if (newFilter.bots) {
|
||||
// newFlags |= MessagesController.DIALOG_FILTER_FLAG_BOTS;
|
||||
// }
|
||||
// if (newFilter.exclude_muted) {
|
||||
// newFlags |= MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED;
|
||||
// }
|
||||
// if (newFilter.exclude_read) {
|
||||
// newFlags |= MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_READ;
|
||||
// }
|
||||
// if (newFilter.exclude_archived) {
|
||||
// newFlags |= MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED;
|
||||
// }
|
||||
// if (newFilter instanceof TLRPC.TL_dialogFilterCommunity) {
|
||||
// newFlags |= MessagesController.DIALOG_FILTER_FLAG_COMMUNITY;
|
||||
// if (newFilter.community_can_admin) {
|
||||
// newFlags |= MessagesController.DIALOG_FILTER_FLAG_COMMUNITY_ADMIN;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// MessagesController.DialogFilter filter = dialogFiltersMap.get(newFilter.id);
|
||||
// if (filter != null) {
|
||||
// filtersToDelete.remove(newFilter.id);
|
||||
// boolean changed = false;
|
||||
// boolean unreadChanged = false;
|
||||
// if (!TextUtils.equals(filter.name, newFilter.title)) {
|
||||
// changed = true;
|
||||
// filter.name = newFilter.title;
|
||||
// }
|
||||
// if (filter.flags != newFlags) {
|
||||
// filter.flags = newFlags;
|
||||
// changed = true;
|
||||
// unreadChanged = true;
|
||||
// }
|
||||
//
|
||||
// HashSet<Long> existingIds = new HashSet<>(filter.alwaysShow);
|
||||
// existingIds.addAll(filter.neverShow);
|
||||
// HashSet<Long> existingDialogsIds = new HashSet<>();
|
||||
//
|
||||
// LinkedHashMap<Integer, Long> secretChatsMap = null;
|
||||
// if (filter.pinnedDialogs.size() != 0) {
|
||||
// ArrayList<Long> pinArray = new ArrayList<>();
|
||||
// boolean hasSecret = false;
|
||||
// for (int c = 0, N2 = filter.pinnedDialogs.size(); c < N2; c++) {
|
||||
// long did = filter.pinnedDialogs.keyAt(c);
|
||||
// if (DialogObject.isEncryptedDialog(did)) {
|
||||
// hasSecret = true;
|
||||
// }
|
||||
// pinArray.add(did);
|
||||
// }
|
||||
// if (hasSecret) {
|
||||
// secretChatsMap = new LinkedHashMap<>();
|
||||
// LongSparseIntArray pinnedDialogs = filter.pinnedDialogs;
|
||||
// Collections.sort(pinArray, (o1, o2) -> {
|
||||
// int idx1 = pinnedDialogs.get(o1);
|
||||
// int idx2 = pinnedDialogs.get(o2);
|
||||
// if (idx1 > idx2) {
|
||||
// return 1;
|
||||
// } else if (idx1 < idx2) {
|
||||
// return -1;
|
||||
// }
|
||||
// return 0;
|
||||
// });
|
||||
// for (int c = 0, N2 = pinArray.size(); c < N2; c++) {
|
||||
// long did = pinArray.get(c);
|
||||
// if (!DialogObject.isEncryptedDialog(did)) {
|
||||
// continue;
|
||||
// }
|
||||
// secretChatsMap.put(c, did);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// for (int c = 0, N2 = filter.pinnedDialogs.size(); c < N2; c++) {
|
||||
// long did = filter.pinnedDialogs.keyAt(c);
|
||||
// if (DialogObject.isEncryptedDialog(did)) {
|
||||
// continue;
|
||||
// }
|
||||
// existingDialogsIds.add(did);
|
||||
// existingIds.remove(did);
|
||||
// }
|
||||
//
|
||||
// filter.pinnedDialogs.clear();
|
||||
// for (int b = 0, N2 = newFilter.pinned_peers.size(); b < N2; b++) {
|
||||
// TLRPC.InputPeer peer = newFilter.pinned_peers.get(b);
|
||||
// Long id;
|
||||
// if (peer.user_id != 0) {
|
||||
// id = peer.user_id;
|
||||
// } else {
|
||||
// id = -(peer.chat_id != 0 ? peer.chat_id : peer.channel_id);
|
||||
// }
|
||||
// int index = filter.pinnedDialogs.size();
|
||||
// if (secretChatsMap != null) {
|
||||
// Long did;
|
||||
// while ((did = secretChatsMap.remove(index)) != null) {
|
||||
// filter.pinnedDialogs.put(did, index);
|
||||
// index++;
|
||||
// }
|
||||
// }
|
||||
// filter.pinnedDialogs.put(id, index);
|
||||
// existingIds.remove(id);
|
||||
// if (!existingDialogsIds.remove(id)) {
|
||||
// changed = true;
|
||||
// if (!dialogsToLoadMap.containsKey(id)) {
|
||||
// dialogsToLoad.add(id);
|
||||
// dialogsToLoadMap.put(id, peer);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (secretChatsMap != null) {
|
||||
// for (LinkedHashMap.Entry<Integer, Long> entry : secretChatsMap.entrySet()) {
|
||||
// filter.pinnedDialogs.put(entry.getValue(), filter.pinnedDialogs.size());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for (int c = 0; c < 2; c++) {
|
||||
// ArrayList<Long> fromArray = toPeerIds(c == 0 ? newFilter.include_peers : newFilter.exclude_peers);
|
||||
// ArrayList<Long> toArray = c == 0 ? filter.alwaysShow : filter.neverShow;
|
||||
//
|
||||
// if (c == 0) {
|
||||
// // put pinned_peers into include_peers (alwaysShow)
|
||||
// ArrayList<Long> pinnedArray = toPeerIds(newFilter.pinned_peers);
|
||||
// for (int i = 0; i < pinnedArray.size(); ++i) {
|
||||
// fromArray.remove(pinnedArray.get(i));
|
||||
// }
|
||||
// fromArray.addAll(0, pinnedArray);
|
||||
// }
|
||||
//
|
||||
// final int fromArrayCount = fromArray.size();
|
||||
// boolean isDifferent = fromArray.size() != toArray.size();
|
||||
// if (!isDifferent) {
|
||||
// for (int i = 0; i < fromArrayCount; ++i) {
|
||||
// if (!toArray.contains(fromArray.get(i))) {
|
||||
// isDifferent = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (isDifferent) {
|
||||
// unreadChanged = true;
|
||||
// changed = true;
|
||||
// if (c == 0) {
|
||||
// filter.alwaysShow = fromArray;
|
||||
// } else {
|
||||
// filter.neverShow = fromArray;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (!existingDialogsIds.isEmpty()) {
|
||||
// filterDialogRemovals.put(filter.id, existingDialogsIds);
|
||||
// changed = true;
|
||||
// }
|
||||
// if (changed) {
|
||||
// filtersToSave.add(filter);
|
||||
// }
|
||||
// if (unreadChanged) {
|
||||
// filtersUnreadCounterReset.add(filter.id);
|
||||
// }
|
||||
// } else {
|
||||
// filter = new MessagesController.DialogFilter();
|
||||
// filter.id = newFilter.id;
|
||||
// filter.flags = newFlags;
|
||||
// filter.name = newFilter.title;
|
||||
// filter.pendingUnreadCount = -1;
|
||||
// for (int c = 0; c < 2; c++) {
|
||||
// if (c == 0) {
|
||||
// for (int b = 0, N2 = newFilter.pinned_peers.size(); b < N2; b++) {
|
||||
// TLRPC.InputPeer peer = newFilter.pinned_peers.get(b);
|
||||
// Long id;
|
||||
// if (peer.user_id != 0) {
|
||||
// id = peer.user_id;
|
||||
// } else {
|
||||
// id = -(peer.chat_id != 0 ? peer.chat_id : peer.channel_id);
|
||||
// }
|
||||
// if (!filter.alwaysShow.contains(id)) {
|
||||
// filter.alwaysShow.add(id);
|
||||
// }
|
||||
// filter.pinnedDialogs.put(id, filter.pinnedDialogs.size() + 1);
|
||||
// if (!dialogsToLoadMap.containsKey(id)) {
|
||||
// dialogsToLoad.add(id);
|
||||
// dialogsToLoadMap.put(id, peer);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ArrayList<TLRPC.InputPeer> fromArray = c == 0 ? newFilter.include_peers : newFilter.exclude_peers;
|
||||
// ArrayList<Long> toArray = c == 0 ? filter.alwaysShow : filter.neverShow;
|
||||
// for (int b = 0, N2 = fromArray.size(); b < N2; b++) {
|
||||
// TLRPC.InputPeer peer = fromArray.get(b);
|
||||
// if (peer.user_id != 0) {
|
||||
// Long uid = peer.user_id;
|
||||
// if (!toArray.contains(uid)) {
|
||||
// toArray.add(uid);
|
||||
// }
|
||||
// if (!usersToLoadMap.containsKey(uid)) {
|
||||
// usersToLoad.add(uid);
|
||||
// usersToLoadMap.put(uid, peer);
|
||||
// }
|
||||
// } else {
|
||||
// Long chatId = peer.chat_id != 0 ? peer.chat_id : peer.channel_id;
|
||||
// Long dialogId = -chatId;
|
||||
// if (!toArray.contains(dialogId)) {
|
||||
// toArray.add(dialogId);
|
||||
// }
|
||||
// if (!chatsToLoadMap.containsKey(chatId)) {
|
||||
// chatsToLoad.add(chatId);
|
||||
// chatsToLoadMap.put(chatId, peer);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// filtersToSave.add(filter);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// TLRPC.messages_Dialogs dialogs;
|
||||
// if (!dialogsToLoad.isEmpty()) {
|
||||
// dialogs = loadDialogsByIds(TextUtils.join(",", dialogsToLoad), usersToLoad, chatsToLoad, new ArrayList<>());
|
||||
// for (int a = 0, N = dialogs.dialogs.size(); a < N; a++) {
|
||||
// TLRPC.Dialog dialog = dialogs.dialogs.get(a);
|
||||
// dialogsToLoadMap.remove(dialog.id);
|
||||
// }
|
||||
// } else {
|
||||
// dialogs = new TLRPC.TL_messages_dialogs();
|
||||
// }
|
||||
// ArrayList<TLRPC.User> users = new ArrayList<>();
|
||||
// if (!usersToLoad.isEmpty()) {
|
||||
// getUsersInternal(TextUtils.join(",", usersToLoad), users);
|
||||
// for (int a = 0, N = users.size(); a < N; a++) {
|
||||
// TLRPC.User user = users.get(a);
|
||||
// usersToLoadMap.remove(user.id);
|
||||
// }
|
||||
// }
|
||||
// ArrayList<TLRPC.Chat> chats = new ArrayList<>();
|
||||
// if (!chatsToLoad.isEmpty()) {
|
||||
// getChatsInternal(TextUtils.join(",", chatsToLoad), chats);
|
||||
// for (int a = 0, N = chats.size(); a < N; a++) {
|
||||
// TLRPC.Chat chat = chats.get(a);
|
||||
// chatsToLoadMap.remove(chat.id);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (usersToLoadMap.isEmpty() && chatsToLoadMap.isEmpty() && dialogsToLoadMap.isEmpty()) {
|
||||
// processLoadedFilterPeersInternal(dialogs, null, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset);
|
||||
// } else {
|
||||
// getMessagesController().loadFilterPeers(dialogsToLoadMap, usersToLoadMap, chatsToLoadMap, dialogs, new TLRPC.TL_messages_dialogs(), users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// checkSQLException(e);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
public void checkLoadedRemoteFilters(TLRPC.Vector vector) {
|
||||
public void checkLoadedRemoteFilters(TLRPC.Vector vector, Runnable onDone) {
|
||||
storageQueue.postRunnable(() -> {
|
||||
try {
|
||||
SparseArray<MessagesController.DialogFilter> filtersToDelete = new SparseArray<>();
|
||||
|
@ -3150,6 +2867,12 @@ public class MessagesStorage extends BaseController {
|
|||
if (newFilter.exclude_archived) {
|
||||
newFlags |= MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED;
|
||||
}
|
||||
if (newFilter instanceof TLRPC.TL_dialogFilterChatlist) {
|
||||
newFlags |= MessagesController.DIALOG_FILTER_FLAG_CHATLIST;
|
||||
if (newFilter.has_my_invites) {
|
||||
newFlags |= MessagesController.DIALOG_FILTER_FLAG_CHATLIST_ADMIN;
|
||||
}
|
||||
}
|
||||
|
||||
MessagesController.DialogFilter filter = dialogFiltersMap.get(newFilter.id);
|
||||
if (filter != null) {
|
||||
|
@ -3373,9 +3096,9 @@ public class MessagesStorage extends BaseController {
|
|||
}
|
||||
|
||||
if (usersToLoadMap.isEmpty() && chatsToLoadMap.isEmpty() && dialogsToLoadMap.isEmpty()) {
|
||||
processLoadedFilterPeersInternal(dialogs, null, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset);
|
||||
processLoadedFilterPeersInternal(dialogs, null, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset, onDone);
|
||||
} else {
|
||||
getMessagesController().loadFilterPeers(dialogsToLoadMap, usersToLoadMap, chatsToLoadMap, dialogs, new TLRPC.TL_messages_dialogs(), users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset);
|
||||
getMessagesController().loadFilterPeers(dialogsToLoadMap, usersToLoadMap, chatsToLoadMap, dialogs, new TLRPC.TL_messages_dialogs(), users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset, onDone);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
checkSQLException(e);
|
||||
|
@ -3383,7 +3106,7 @@ public class MessagesStorage extends BaseController {
|
|||
});
|
||||
}
|
||||
|
||||
private void processLoadedFilterPeersInternal(TLRPC.messages_Dialogs pinnedDialogs, TLRPC.messages_Dialogs pinnedRemoteDialogs, ArrayList<TLRPC.User> users, ArrayList<TLRPC.Chat> chats, ArrayList<MessagesController.DialogFilter> filtersToSave, SparseArray<MessagesController.DialogFilter> filtersToDelete, ArrayList<Integer> filtersOrder, HashMap<Integer, HashSet<Long>> filterDialogRemovals, HashSet<Integer> filtersUnreadCounterReset) {
|
||||
private void processLoadedFilterPeersInternal(TLRPC.messages_Dialogs pinnedDialogs, TLRPC.messages_Dialogs pinnedRemoteDialogs, ArrayList<TLRPC.User> users, ArrayList<TLRPC.Chat> chats, ArrayList<MessagesController.DialogFilter> filtersToSave, SparseArray<MessagesController.DialogFilter> filtersToDelete, ArrayList<Integer> filtersOrder, HashMap<Integer, HashSet<Long>> filterDialogRemovals, HashSet<Integer> filtersUnreadCounterReset, Runnable onDone) {
|
||||
boolean anythingChanged = false;
|
||||
putUsersAndChats(users, chats, true, false);
|
||||
for (int a = 0, N = filtersToDelete.size(); a < N; a++) {
|
||||
|
@ -3435,11 +3158,11 @@ public class MessagesStorage extends BaseController {
|
|||
}
|
||||
int remote = anythingChanged ? 1 : 2;
|
||||
calcUnreadCounters(true);
|
||||
getMessagesController().processLoadedDialogFilters(new ArrayList<>(dialogFilters), pinnedDialogs, pinnedRemoteDialogs, users, chats, null, remote);
|
||||
getMessagesController().processLoadedDialogFilters(new ArrayList<>(dialogFilters), pinnedDialogs, pinnedRemoteDialogs, users, chats, null, remote, onDone);
|
||||
}
|
||||
|
||||
protected void processLoadedFilterPeers(TLRPC.messages_Dialogs pinnedDialogs, TLRPC.messages_Dialogs pinnedRemoteDialogs, ArrayList<TLRPC.User> users, ArrayList<TLRPC.Chat> chats, ArrayList<MessagesController.DialogFilter> filtersToSave, SparseArray<MessagesController.DialogFilter> filtersToDelete, ArrayList<Integer> filtersOrder, HashMap<Integer, HashSet<Long>> filterDialogRemovals, HashSet<Integer> filtersUnreadCounterReset) {
|
||||
storageQueue.postRunnable(() -> processLoadedFilterPeersInternal(pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset));
|
||||
protected void processLoadedFilterPeers(TLRPC.messages_Dialogs pinnedDialogs, TLRPC.messages_Dialogs pinnedRemoteDialogs, ArrayList<TLRPC.User> users, ArrayList<TLRPC.Chat> chats, ArrayList<MessagesController.DialogFilter> filtersToSave, SparseArray<MessagesController.DialogFilter> filtersToDelete, ArrayList<Integer> filtersOrder, HashMap<Integer, HashSet<Long>> filterDialogRemovals, HashSet<Integer> filtersUnreadCounterReset, Runnable onDone) {
|
||||
storageQueue.postRunnable(() -> processLoadedFilterPeersInternal(pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset, onDone));
|
||||
}
|
||||
|
||||
private void deleteDialogFilterInternal(MessagesController.DialogFilter filter) {
|
||||
|
@ -4428,12 +4151,12 @@ public class MessagesStorage extends BaseController {
|
|||
}
|
||||
state.requery();
|
||||
int size = photo.getObjectSize();
|
||||
if (messages != null && messages.get(a) != null) {
|
||||
if (messages != null && a < messages.size() && messages.get(a) != null) {
|
||||
size += messages.get(a).getObjectSize();
|
||||
}
|
||||
NativeByteBuffer data = new NativeByteBuffer(size);
|
||||
photo.serializeToStream(data);
|
||||
if (messages != null && messages.get(a) != null) {
|
||||
if (messages != null && a < messages.size() && messages.get(a) != null) {
|
||||
messages.get(a).serializeToStream(data);
|
||||
}
|
||||
state.bindLong(1, did);
|
||||
|
@ -6441,11 +6164,12 @@ public class MessagesStorage extends BaseController {
|
|||
|
||||
public void updateUserInfo(TLRPC.UserFull info, boolean ifExist) {
|
||||
storageQueue.postRunnable(() -> {
|
||||
long id = info.user != null ? info.user.id : info.id;
|
||||
SQLiteCursor cursor = null;
|
||||
SQLitePreparedStatement state = null;
|
||||
try {
|
||||
if (ifExist) {
|
||||
cursor = database.queryFinalized("SELECT uid FROM user_settings WHERE uid = " + info.user.id);
|
||||
cursor = database.queryFinalized("SELECT uid FROM user_settings WHERE uid = " + id);
|
||||
boolean exist = cursor.next();
|
||||
cursor.dispose();
|
||||
cursor = null;
|
||||
|
@ -6456,7 +6180,7 @@ public class MessagesStorage extends BaseController {
|
|||
state = database.executeFast("REPLACE INTO user_settings VALUES(?, ?, ?)");
|
||||
NativeByteBuffer data = new NativeByteBuffer(info.getObjectSize());
|
||||
info.serializeToStream(data);
|
||||
state.bindLong(1, info.user.id);
|
||||
state.bindLong(1, id);
|
||||
state.bindByteBuffer(2, data);
|
||||
state.bindInteger(3, info.pinned_msg_id);
|
||||
state.step();
|
||||
|
@ -6466,7 +6190,7 @@ public class MessagesStorage extends BaseController {
|
|||
if ((info.flags & 2048) != 0) {
|
||||
state = database.executeFast("UPDATE dialogs SET folder_id = ? WHERE did = ?");
|
||||
state.bindInteger(1, info.folder_id);
|
||||
state.bindLong(2, info.user.id);
|
||||
state.bindLong(2, id);
|
||||
state.step();
|
||||
state.dispose();
|
||||
state = null;
|
||||
|
@ -6475,7 +6199,7 @@ public class MessagesStorage extends BaseController {
|
|||
if ((info.flags & 16384) != 0) {
|
||||
state = database.executeFast("UPDATE dialogs SET ttl_period = ? WHERE did = ?");
|
||||
state.bindInteger(1, info.ttl_period);
|
||||
state.bindLong(2, info.user.id);
|
||||
state.bindLong(2, id);
|
||||
state.step();
|
||||
state.dispose();
|
||||
state = null;
|
||||
|
@ -14940,12 +14664,16 @@ public class MessagesStorage extends BaseController {
|
|||
try {
|
||||
database.beginTransaction();
|
||||
state = database.executeFast("UPDATE dialogs SET folder_id = ?, pinned = ? WHERE did = ?");
|
||||
boolean hasFolderId1 = false;
|
||||
if (peers != null) {
|
||||
for (int a = 0, N = peers.size(); a < N; a++) {
|
||||
TLRPC.TL_folderPeer folderPeer = peers.get(a);
|
||||
long did = DialogObject.getPeerDialogId(folderPeer.peer);
|
||||
state.requery();
|
||||
state.bindInteger(1, folderPeer.folder_id);
|
||||
if (folderPeer.folder_id == 1) {
|
||||
hasFolderId1 = true;
|
||||
}
|
||||
state.bindInteger(2, 0);
|
||||
state.bindLong(3, did);
|
||||
state.step();
|
||||
|
@ -14957,6 +14685,9 @@ public class MessagesStorage extends BaseController {
|
|||
long did = DialogObject.getPeerDialogId(folderPeer.peer);
|
||||
state.requery();
|
||||
state.bindInteger(1, folderPeer.folder_id);
|
||||
if (folderPeer.folder_id == 1) {
|
||||
hasFolderId1 = true;
|
||||
}
|
||||
state.bindInteger(2, 0);
|
||||
state.bindLong(3, did);
|
||||
state.step();
|
||||
|
@ -14965,6 +14696,9 @@ public class MessagesStorage extends BaseController {
|
|||
} else {
|
||||
state.requery();
|
||||
state.bindInteger(1, folderId);
|
||||
if (folderId == 1) {
|
||||
hasFolderId1 = true;
|
||||
}
|
||||
state.bindInteger(2, 0);
|
||||
state.bindLong(3, dialogId);
|
||||
state.step();
|
||||
|
@ -14972,7 +14706,9 @@ public class MessagesStorage extends BaseController {
|
|||
state.dispose();
|
||||
state = null;
|
||||
database.commitTransaction();
|
||||
checkIfFolderEmptyInternal(1);
|
||||
if (!hasFolderId1) {
|
||||
checkIfFolderEmptyInternal(1);
|
||||
}
|
||||
resetAllUnreadCounters(false);
|
||||
} catch (Exception e) {
|
||||
checkSQLException(e);
|
||||
|
|
|
@ -22,13 +22,13 @@ import java.util.zip.ZipFile;
|
|||
|
||||
public class NativeLoader {
|
||||
|
||||
private final static int LIB_VERSION = 44;
|
||||
private final static int LIB_VERSION = 45;
|
||||
private final static String LIB_NAME = "tmessages." + LIB_VERSION;
|
||||
private final static String LIB_SO_NAME = "lib" + LIB_NAME + ".so";
|
||||
private final static String LOCALE_LIB_SO_NAME = "lib" + LIB_NAME + "loc.so";
|
||||
private String crashPath = "";
|
||||
|
||||
private static volatile boolean nativeLoaded = false;
|
||||
public static StringBuilder log = new StringBuilder();
|
||||
|
||||
private static File getNativeLibraryDir(Context context) {
|
||||
File f = null;
|
||||
|
@ -125,6 +125,7 @@ public class NativeLoader {
|
|||
return;
|
||||
} catch (Error e) {
|
||||
FileLog.e(e);
|
||||
log.append("129: ").append(e).append("\n");
|
||||
}
|
||||
|
||||
String folder = getAbiFolder();
|
||||
|
@ -156,6 +157,7 @@ public class NativeLoader {
|
|||
nativeLoaded = true;
|
||||
return;
|
||||
} catch (Error e) {
|
||||
log.append(e).append("\n");
|
||||
FileLog.e(e);
|
||||
}
|
||||
destLocalFile.delete();
|
||||
|
@ -163,6 +165,7 @@ public class NativeLoader {
|
|||
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
FileLog.e("Library not found, arch = " + folder);
|
||||
log.append("Library not found, arch = " + folder).append("\n");
|
||||
}
|
||||
|
||||
if (loadFromZip(context, destDir, destLocalFile, folder)) {
|
||||
|
@ -170,6 +173,7 @@ public class NativeLoader {
|
|||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
log.append("177: ").append(e).append("\n");
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -177,6 +181,7 @@ public class NativeLoader {
|
|||
nativeLoaded = true;
|
||||
} catch (Error e) {
|
||||
FileLog.e(e);
|
||||
log.append("185: ").append(e).append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import androidx.annotation.Nullable;
|
|||
import androidx.annotation.UiThread;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -278,6 +279,9 @@ public class NotificationCenter {
|
|||
public static int chatSwithcedToForum = totalEvents++;
|
||||
public static int didUpdateGlobalAutoDeleteTimer = totalEvents++;
|
||||
public static int onDatabaseReset = totalEvents++;
|
||||
public static int wallpaperSettedToUser = totalEvents++;
|
||||
|
||||
public static int chatlistFolderUpdate = totalEvents++;
|
||||
|
||||
public static boolean alreadyLogged;
|
||||
|
||||
|
@ -507,7 +511,11 @@ public class NotificationCenter {
|
|||
Integer flags = (Integer) args[0];
|
||||
currentHeavyOperationFlags |= flags;
|
||||
}
|
||||
postNotificationNameInternal(id, allowDuringAnimation, args);
|
||||
if (shouldDebounce(id, args) && BuildVars.DEBUG_VERSION) {
|
||||
postNotificationDebounced(id, args);
|
||||
} else {
|
||||
postNotificationNameInternal(id, allowDuringAnimation, args);
|
||||
}
|
||||
|
||||
if (expiredIndices != null) {
|
||||
for (int i = 0; i < expiredIndices.size(); i++) {
|
||||
|
@ -516,6 +524,26 @@ public class NotificationCenter {
|
|||
}
|
||||
}
|
||||
|
||||
SparseArray<Runnable> alreadyPostedRannubles = new SparseArray<>();
|
||||
|
||||
private void postNotificationDebounced(int id, Object[] args) {
|
||||
int hash = id + (Arrays.hashCode(args) << 16);
|
||||
if (alreadyPostedRannubles.indexOfKey(hash) >= 0) {
|
||||
//skip
|
||||
} else {
|
||||
Runnable runnable = () -> {
|
||||
postNotificationNameInternal(id, false, args);
|
||||
alreadyPostedRannubles.remove(hash);
|
||||
};
|
||||
alreadyPostedRannubles.put(hash, runnable);
|
||||
AndroidUtilities.runOnUIThread(runnable, 250);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldDebounce(int id, Object[] args) {
|
||||
return id == updateInterfaces;
|
||||
}
|
||||
|
||||
@UiThread
|
||||
public void postNotificationNameInternal(int id, boolean allowDuringAnimation, Object... args) {
|
||||
if (BuildVars.DEBUG_VERSION) {
|
||||
|
@ -707,6 +735,20 @@ public class NotificationCenter {
|
|||
});
|
||||
}
|
||||
|
||||
public void listenOnce(int id, Runnable callback) {
|
||||
final NotificationCenterDelegate[] observer = new NotificationCenterDelegate[1];
|
||||
observer[0] = (nid, account, args) -> {
|
||||
if (nid == id && observer[0] != null) {
|
||||
if (callback != null) {
|
||||
callback.run();
|
||||
}
|
||||
removeObserver(observer[0], id);
|
||||
observer[0] = null;
|
||||
}
|
||||
};
|
||||
addObserver(observer[0], id);
|
||||
}
|
||||
|
||||
private class UniqArrayList<T> extends ArrayList<T> {
|
||||
HashSet<T> set = new HashSet<>();
|
||||
|
||||
|
|
|
@ -1536,7 +1536,11 @@ public class NotificationsController extends BaseController {
|
|||
if (dialogPreviewEnabled && (chat_id == 0 && fromId != 0 && preferences.getBoolean("EnablePreviewAll", true) || chat_id != 0 && (!isChannel && preferences.getBoolean("EnablePreviewGroup", true) || isChannel && preferences.getBoolean("EnablePreviewChannel", true)))) {
|
||||
if (messageObject.messageOwner instanceof TLRPC.TL_messageService) {
|
||||
userName[0] = null;
|
||||
if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionGeoProximityReached) {
|
||||
if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionSetSameChatWallPaper) {
|
||||
return LocaleController.getString("WallpaperSameNotification", R.string.WallpaperSameNotification);
|
||||
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionSetChatWallPaper) {
|
||||
return LocaleController.getString("WallpaperNotification", R.string.WallpaperNotification);
|
||||
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionGeoProximityReached) {
|
||||
return messageObject.messageText.toString();
|
||||
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserJoined || messageObject.messageOwner.action instanceof TLRPC.TL_messageActionContactSignUp) {
|
||||
return LocaleController.formatString("NotificationContactJoined", R.string.NotificationContactJoined, name);
|
||||
|
@ -2093,7 +2097,11 @@ public class NotificationsController extends BaseController {
|
|||
if (chatId == 0 && fromId != 0) {
|
||||
if (dialogPreviewEnabled && preferences.getBoolean("EnablePreviewAll", true)) {
|
||||
if (messageObject.messageOwner instanceof TLRPC.TL_messageService) {
|
||||
if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionGeoProximityReached) {
|
||||
if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionSetSameChatWallPaper) {
|
||||
msg = LocaleController.getString("WallpaperSameNotification", R.string.WallpaperSameNotification);
|
||||
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionSetChatWallPaper) {
|
||||
msg = LocaleController.getString("WallpaperNotification", R.string.WallpaperNotification);
|
||||
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionGeoProximityReached) {
|
||||
msg = messageObject.messageText.toString();
|
||||
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserJoined || messageObject.messageOwner.action instanceof TLRPC.TL_messageActionContactSignUp) {
|
||||
msg = LocaleController.formatString("NotificationContactJoined", R.string.NotificationContactJoined, name);
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.telegram.messenger;
|
|||
import android.os.SystemClock;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
import android.util.SparseBooleanArray;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
|
@ -446,6 +445,16 @@ public class PushListenerController {
|
|||
messageText = getReactedText(loc_key, args);
|
||||
} else {
|
||||
switch (loc_key) {
|
||||
case "MESSAGE_SAME_WALLPAPER": {
|
||||
messageText = LocaleController.formatString("ActionSetSameWallpaperForThisChat", R.string.ActionSetSameWallpaperForThisChat, args[0]);
|
||||
message1 = LocaleController.getString("WallpaperSameNotification", R.string.WallpaperSameNotification);
|
||||
break;
|
||||
}
|
||||
case "MESSAGE_WALLPAPER": {
|
||||
messageText = LocaleController.formatString("ActionSetWallpaperForThisChat", R.string.ActionSetWallpaperForThisChat, args[0]);
|
||||
message1 = LocaleController.getString("WallpaperNotification", R.string.WallpaperNotification);
|
||||
break;
|
||||
}
|
||||
case "MESSAGE_RECURRING_PAY": {
|
||||
messageText = LocaleController.formatString("NotificationMessageRecurringPay", R.string.NotificationMessageRecurringPay, args[0], args[1]);
|
||||
message1 = LocaleController.getString("PaymentInvoice", R.string.PaymentInvoice);
|
||||
|
|
|
@ -0,0 +1,276 @@
|
|||
package org.telegram.messenger;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.internal.Streams;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Disclaimer: taken from here https://stackoverflow.com/a/40133286/285091 with some modifications
|
||||
* </p>
|
||||
*
|
||||
* Adapts values whose runtime type may differ from their declaration type. This
|
||||
* is necessary when a field's type is not the same type that GSON should create
|
||||
* when deserializing that field. For example, consider these types:
|
||||
* <pre> {@code
|
||||
* abstract class Shape {
|
||||
* int x;
|
||||
* int y;
|
||||
* }
|
||||
* class Circle extends Shape {
|
||||
* int radius;
|
||||
* }
|
||||
* class Rectangle extends Shape {
|
||||
* int width;
|
||||
* int height;
|
||||
* }
|
||||
* class Diamond extends Shape {
|
||||
* int width;
|
||||
* int height;
|
||||
* }
|
||||
* class Drawing {
|
||||
* Shape bottomShape;
|
||||
* Shape topShape;
|
||||
* }
|
||||
* }</pre>
|
||||
* <p>Without additional type information, the serialized JSON is ambiguous. Is
|
||||
* the bottom shape in this drawing a rectangle or a diamond? <pre> {@code
|
||||
* {
|
||||
* "bottomShape": {
|
||||
* "width": 10,
|
||||
* "height": 5,
|
||||
* "x": 0,
|
||||
* "y": 0
|
||||
* },
|
||||
* "topShape": {
|
||||
* "radius": 2,
|
||||
* "x": 4,
|
||||
* "y": 1
|
||||
* }
|
||||
* }}</pre>
|
||||
* This class addresses this problem by adding type information to the
|
||||
* serialized JSON and honoring that type information when the JSON is
|
||||
* deserialized: <pre> {@code
|
||||
* {
|
||||
* "bottomShape": {
|
||||
* "type": "Diamond",
|
||||
* "width": 10,
|
||||
* "height": 5,
|
||||
* "x": 0,
|
||||
* "y": 0
|
||||
* },
|
||||
* "topShape": {
|
||||
* "type": "Circle",
|
||||
* "radius": 2,
|
||||
* "x": 4,
|
||||
* "y": 1
|
||||
* }
|
||||
* }}</pre>
|
||||
* Both the type field name ({@code "type"}) and the type labels ({@code
|
||||
* "Rectangle"}) are configurable.
|
||||
* <p>
|
||||
* <h3>Registering Types</h3>
|
||||
* Create a {@code RuntimeTypeAdapterFactory} by passing the base type and type field
|
||||
* name to the {@link #of} factory method. If you don't supply an explicit type
|
||||
* field name, {@code "type"} will be used. <pre> {@code
|
||||
* RuntimeTypeAdapterFactory<Shape> shapeAdapterFactory
|
||||
* = RuntimeTypeAdapterFactory.of(Shape.class, "type");
|
||||
* }</pre>
|
||||
* Next register all of your subtypes. Every subtype must be explicitly
|
||||
* registered. This protects your application from injection attacks. If you
|
||||
* don't supply an explicit type label, the type's simple name will be used.
|
||||
* <pre> {@code
|
||||
* shapeAdapter.registerSubtype(Rectangle.class, "Rectangle");
|
||||
* shapeAdapter.registerSubtype(Circle.class, "Circle");
|
||||
* shapeAdapter.registerSubtype(Diamond.class, "Diamond");
|
||||
* }</pre>
|
||||
* Finally, register the type adapter factory in your application's GSON builder:
|
||||
* <pre> {@code
|
||||
* Gson gson = new GsonBuilder()
|
||||
* .registerTypeAdapterFactory(shapeAdapterFactory)
|
||||
* .create();
|
||||
* }</pre>
|
||||
* Like {@code GsonBuilder}, this API supports chaining: <pre> {@code
|
||||
* RuntimeTypeAdapterFactory<Shape> shapeAdapterFactory = RuntimeTypeAdapterFactory.of(Shape.class)
|
||||
* .registerSubtype(Rectangle.class)
|
||||
* .registerSubtype(Circle.class)
|
||||
* .registerSubtype(Diamond.class);
|
||||
* }</pre>
|
||||
*/
|
||||
public final class RuntimeClassNameTypeAdapterFactory<T> implements TypeAdapterFactory {
|
||||
private final Class<?> baseType;
|
||||
private final String typeFieldName;
|
||||
private final Map<String, Class<?>> labelToSubtype = new LinkedHashMap<String, Class<?>>();
|
||||
private final Map<Class<?>, String> subtypeToLabel = new LinkedHashMap<Class<?>, String>();
|
||||
|
||||
private RuntimeClassNameTypeAdapterFactory(Class<?> baseType, String typeFieldName) {
|
||||
if (typeFieldName == null || baseType == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
this.baseType = baseType;
|
||||
this.typeFieldName = typeFieldName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new runtime type adapter using for {@code baseType} using {@code
|
||||
* typeFieldName} as the type field name. Type field names are case sensitive.
|
||||
*/
|
||||
public static <T> RuntimeClassNameTypeAdapterFactory<T> of(Class<T> baseType, String typeFieldName) {
|
||||
return new RuntimeClassNameTypeAdapterFactory<T>(baseType, typeFieldName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new runtime type adapter for {@code baseType} using {@code "type"} as
|
||||
* the type field name.
|
||||
*/
|
||||
public static <T> RuntimeClassNameTypeAdapterFactory<T> of(Class<T> baseType) {
|
||||
return new RuntimeClassNameTypeAdapterFactory<T>(baseType, "class");
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers {@code type} identified by {@code label}. Labels are case
|
||||
* sensitive.
|
||||
*
|
||||
* @throws IllegalArgumentException if either {@code type} or {@code label}
|
||||
* have already been registered on this type adapter.
|
||||
*/
|
||||
public RuntimeClassNameTypeAdapterFactory<T> registerSubtype(Class<? extends T> type, String label) {
|
||||
if (type == null || label == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (subtypeToLabel.containsKey(type) || labelToSubtype.containsKey(label)) {
|
||||
throw new IllegalArgumentException("types and labels must be unique");
|
||||
}
|
||||
labelToSubtype.put(label, type);
|
||||
subtypeToLabel.put(type, label);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers {@code type} identified by its {@link Class#getSimpleName simple
|
||||
* name}. Labels are case sensitive.
|
||||
*
|
||||
* @throws IllegalArgumentException if either {@code type} or its simple name
|
||||
* have already been registered on this type adapter.
|
||||
*/
|
||||
public RuntimeClassNameTypeAdapterFactory<T> registerSubtype(Class<? extends T> type) {
|
||||
return registerSubtype(type, type.getSimpleName());
|
||||
}
|
||||
|
||||
public <R> TypeAdapter<R> create(Gson gson, TypeToken<R> type) {
|
||||
|
||||
final Map<String, TypeAdapter<?>> labelToDelegate
|
||||
= new LinkedHashMap<String, TypeAdapter<?>>();
|
||||
final Map<Class<?>, TypeAdapter<?>> subtypeToDelegate
|
||||
= new LinkedHashMap<Class<?>, TypeAdapter<?>>();
|
||||
|
||||
// && !String.class.isAssignableFrom(type.getRawType())
|
||||
|
||||
if (Object.class.isAssignableFrom(type.getRawType())) {
|
||||
TypeAdapter<?> delegate = gson.getDelegateAdapter(this, type);
|
||||
labelToDelegate.put(type.getRawType().getSimpleName(), delegate);
|
||||
subtypeToDelegate.put(type.getRawType(), delegate);
|
||||
}
|
||||
|
||||
// for (Map.Entry<String, Class<?>> entry : labelToSubtype.entrySet()) {
|
||||
// TypeAdapter<?> delegate = gson.getDelegateAdapter(this, TypeToken.get(entry.getValue()));
|
||||
// labelToDelegate.put(entry.getKey(), delegate);
|
||||
// subtypeToDelegate.put(entry.getValue(), delegate);
|
||||
// }
|
||||
|
||||
return new TypeAdapter<R>() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public R read(JsonReader in) throws IOException {
|
||||
JsonElement jsonElement = Streams.parse(in);
|
||||
if (jsonElement.isJsonObject()) {
|
||||
JsonElement labelJsonElement = jsonElement.getAsJsonObject().remove(typeFieldName);
|
||||
if (labelJsonElement == null) {
|
||||
throw new JsonParseException("cannot deserialize " + baseType
|
||||
+ " because it does not define a field named " + typeFieldName);
|
||||
}
|
||||
String label = labelJsonElement.getAsString();
|
||||
TypeAdapter<R> delegate = (TypeAdapter<R>) labelToDelegate.get(label);
|
||||
if (delegate == null) {
|
||||
Class<R> aClass;
|
||||
try {
|
||||
aClass = (Class<R>) Class.forName(label);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new JsonParseException("Cannot find class " + label, e);
|
||||
}
|
||||
|
||||
TypeToken<R> subClass = TypeToken.get(aClass);
|
||||
delegate = gson.getDelegateAdapter(RuntimeClassNameTypeAdapterFactory.this, subClass);
|
||||
if (delegate == null) {
|
||||
throw new JsonParseException("cannot deserialize " + baseType + " subtype named "
|
||||
+ label + "; did you forget to register a subtype?");
|
||||
}
|
||||
}
|
||||
return delegate.fromJsonTree(jsonElement);
|
||||
} else if (jsonElement.isJsonNull()) {
|
||||
return null;
|
||||
} else {
|
||||
TypeAdapter<R> delegate = gson.getDelegateAdapter(RuntimeClassNameTypeAdapterFactory.this, type);
|
||||
if (delegate == null) {
|
||||
throw new JsonParseException("cannot deserialize " + baseType + "; did you forget to register a subtype?");
|
||||
}
|
||||
return delegate.fromJsonTree(jsonElement);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(JsonWriter out, R value) throws IOException {
|
||||
Class<?> srcType = value.getClass();
|
||||
String label = srcType.getSimpleName();
|
||||
TypeAdapter<R> delegate = getDelegate(srcType);
|
||||
if (delegate == null) {
|
||||
throw new JsonParseException("cannot serialize " + srcType.getSimpleName()
|
||||
+ "; did you forget to register a subtype?");
|
||||
}
|
||||
JsonElement jsonTree = delegate.toJsonTree(value);
|
||||
if (!jsonTree.isJsonObject()) {
|
||||
Streams.write(jsonTree, out);
|
||||
} else {
|
||||
JsonObject jsonObject = jsonTree.getAsJsonObject();
|
||||
if (jsonObject.has(typeFieldName)) {
|
||||
throw new JsonParseException("cannot serialize " + srcType.getSimpleName()
|
||||
+ " because it already defines a field named " + typeFieldName);
|
||||
}
|
||||
JsonObject clone = new JsonObject();
|
||||
clone.add(typeFieldName, new JsonPrimitive(label));
|
||||
for (Map.Entry<String, JsonElement> e : jsonObject.entrySet()) {
|
||||
clone.add(e.getKey(), e.getValue());
|
||||
}
|
||||
Streams.write(clone, out);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private TypeAdapter<R> getDelegate(Class<?> srcType) {
|
||||
TypeAdapter<?> typeAdapter = subtypeToDelegate.get(srcType);
|
||||
if (typeAdapter != null) {
|
||||
return (TypeAdapter<R>) typeAdapter;
|
||||
}
|
||||
|
||||
for (Map.Entry<Class<?>, TypeAdapter<?>> classTypeAdapterEntry : subtypeToDelegate.entrySet()) {
|
||||
if (classTypeAdapterEntry.getKey().isAssignableFrom(srcType)) {
|
||||
return (TypeAdapter<R>) classTypeAdapterEntry.getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
|
@ -146,6 +146,7 @@ public class SharedConfig {
|
|||
public static boolean forwardingOptionsHintShown;
|
||||
public static boolean searchMessagesAsListUsed;
|
||||
public static boolean stickersReorderingHintUsed;
|
||||
public static int dayNightWallpaperSwitchHint;
|
||||
public static boolean disableVoiceAudioEffects;
|
||||
public static boolean forceDisableTabletMode;
|
||||
public static boolean updateStickersOrderOnSend = true;
|
||||
|
@ -167,6 +168,7 @@ public class SharedConfig {
|
|||
public static boolean chatBubbles = Build.VERSION.SDK_INT >= 30;
|
||||
public static boolean raiseToSpeak = false;
|
||||
public static boolean raiseToListen = true;
|
||||
public static boolean nextMediaTap = true;
|
||||
public static boolean recordViaSco = false;
|
||||
public static boolean customTabs = true;
|
||||
public static boolean directShare = true;
|
||||
|
@ -242,35 +244,6 @@ public class SharedConfig {
|
|||
-1853602818 // SDM439
|
||||
};
|
||||
|
||||
private static final int[] LOW_DEVICES = {
|
||||
1903542002, // XIAOMI NIKEL (Redmi Note 4)
|
||||
1904553494, // XIAOMI OLIVE (Redmi 8)
|
||||
1616144535, // OPPO CPH2273 (Oppo A54s)
|
||||
-713271737, // OPPO OP4F2F (Oppo A54)
|
||||
-1394191140, // SAMSUNG A12 (Galaxy A12)
|
||||
-270252297, // SAMSUNG A12S (Galaxy A12)
|
||||
-270251367, // SAMSUNG A21S (Galaxy A21s)
|
||||
-270252359 // SAMSUNG A10S (Galaxy A10s)
|
||||
};
|
||||
|
||||
private static final int[] AVERAGE_DEVICES = {
|
||||
812981419, // XIAOMI ANGELICA (Redmi 9C)
|
||||
-993913431 // XIAOMI DANDELION (Redmi 9A)
|
||||
};
|
||||
|
||||
private static final int[] HIGH_DEVICES = {
|
||||
1908570923, // XIAOMI SWEET (Redmi Note 10 Pro)
|
||||
-980514379, // XIAOMI SECRET (Redmi Note 10S)
|
||||
577463889, // XIAOMI JOYEUSE (Redmi Note 9 Pro)
|
||||
1764745014, // XIAOMI BEGONIA (Redmi Note 8 Pro)
|
||||
1908524435, // XIAOMI SURYA (Poco X3 NFC)
|
||||
-215787089, // XIAOMI KAMA (Poco X3)
|
||||
-215458996, // XIAOMI VAYU (Poco X3 Pro)
|
||||
-1394179578, // SAMSUNG M21
|
||||
220599115, // SAMSUNG J6LTE
|
||||
1737652784 // SAMSUNG J6PRIMELTE
|
||||
};
|
||||
|
||||
static {
|
||||
loadConfig();
|
||||
}
|
||||
|
@ -491,6 +464,7 @@ public class SharedConfig {
|
|||
mapPreviewType = preferences.getInt("mapPreviewType", 2);
|
||||
raiseToListen = preferences.getBoolean("raise_to_listen", true);
|
||||
raiseToSpeak = preferences.getBoolean("raise_to_speak", false);
|
||||
nextMediaTap = preferences.getBoolean("next_media_on_tap", true);
|
||||
recordViaSco = preferences.getBoolean("record_via_sco", false);
|
||||
customTabs = preferences.getBoolean("custom_tabs", true);
|
||||
directShare = preferences.getBoolean("direct_share", true);
|
||||
|
@ -547,6 +521,7 @@ public class SharedConfig {
|
|||
hasEmailLogin = preferences.getBoolean("hasEmailLogin", false);
|
||||
isFloatingDebugActive = preferences.getBoolean("floatingDebugActive", false);
|
||||
updateStickersOrderOnSend = preferences.getBoolean("updateStickersOrderOnSend", true);
|
||||
dayNightWallpaperSwitchHint = preferences.getInt("dayNightWallpaperSwitchHint", 0);
|
||||
bigCameraForRound = preferences.getBoolean("bigCameraForRound", false);
|
||||
|
||||
preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
|
@ -734,6 +709,7 @@ public class SharedConfig {
|
|||
messageSeenHintCount = 3;
|
||||
emojiInteractionsHintCount = 3;
|
||||
dayNightThemeSwitchHintCount = 3;
|
||||
dayNightWallpaperSwitchHint = 0;
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
|
@ -742,7 +718,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("suggestStickers", suggestStickers);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void setSearchMessagesAsListUsed(boolean value) {
|
||||
|
@ -750,7 +726,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("searchMessagesAsListUsed", searchMessagesAsListUsed);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void setStickersReorderingHintUsed(boolean value) {
|
||||
|
@ -758,28 +734,35 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("stickersReorderingHintUsed", stickersReorderingHintUsed);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void increaseTextSelectionHintShowed() {
|
||||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("textSelectionHintShows", ++textSelectionHintShows);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void increaseDayNightWallpaperSiwtchHint() {
|
||||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("dayNightWallpaperSwitchHint", ++dayNightWallpaperSwitchHint);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void removeTextSelectionHint() {
|
||||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("textSelectionHintShows", 3);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void increaseScheduledOrNoSuoundHintShowed() {
|
||||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("scheduledOrNoSoundHintShows", ++scheduledOrNoSoundHintShows);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void forwardingOptionsHintHintShowed() {
|
||||
|
@ -787,35 +770,35 @@ public class SharedConfig {
|
|||
SharedPreferences.Editor editor = preferences.edit();
|
||||
forwardingOptionsHintShown = true;
|
||||
editor.putBoolean("forwardingOptionsHintShown", forwardingOptionsHintShown);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void removeScheduledOrNoSoundHint() {
|
||||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("scheduledOrNoSoundHintShows", 3);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void increaseLockRecordAudioVideoHintShowed() {
|
||||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("lockRecordAudioVideoHint", ++lockRecordAudioVideoHint);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void removeLockRecordAudioVideoHint() {
|
||||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("lockRecordAudioVideoHint", 3);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void increaseSearchAsListHintShows() {
|
||||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("searchMessagesAsListHintShows", ++searchMessagesAsListHintShows);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void setKeepMedia(int value) {
|
||||
|
@ -823,14 +806,14 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("keep_media", keepMedia);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void toggleUpdateStickersOrderOnSend() {
|
||||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("updateStickersOrderOnSend", updateStickersOrderOnSend = !updateStickersOrderOnSend);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void checkLogsToDelete() {
|
||||
|
@ -856,7 +839,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("lastLogsCheckTime", lastLogsCheckTime);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -865,7 +848,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("disableVoiceAudioEffects", disableVoiceAudioEffects);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void toggleNoiseSupression() {
|
||||
|
@ -873,7 +856,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("noiseSupression", noiseSupression);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void toggleDebugWebView() {
|
||||
|
@ -896,7 +879,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("allowBigEmoji", allowBigEmoji);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void toggleSuggestAnimatedEmoji() {
|
||||
|
@ -904,7 +887,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("suggestAnimatedEmoji", suggestAnimatedEmoji);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void setPlaybackOrderType(int type) {
|
||||
|
@ -923,7 +906,7 @@ public class SharedConfig {
|
|||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("shuffleMusic", shuffleMusic);
|
||||
editor.putBoolean("playOrderReversed", playOrderReversed);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void setRepeatMode(int mode) {
|
||||
|
@ -934,11 +917,11 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("repeatMode", repeatMode);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void overrideDevicePerformanceClass(int performanceClass) {
|
||||
MessagesController.getGlobalMainSettings().edit().putInt("overrideDevicePerformanceClass", overrideDevicePerformanceClass = performanceClass).remove("lite_mode").commit();
|
||||
MessagesController.getGlobalMainSettings().edit().putInt("overrideDevicePerformanceClass", overrideDevicePerformanceClass = performanceClass).remove("lite_mode").apply();
|
||||
if (liteMode != null) {
|
||||
liteMode.loadPreference();
|
||||
}
|
||||
|
@ -953,7 +936,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("useThreeLinesLayout", useThreeLinesLayout);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.dialogsNeedReload, true);
|
||||
}
|
||||
|
||||
|
@ -962,7 +945,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("archiveHidden", archiveHidden);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void toggleAutoplayVideo() {
|
||||
|
@ -979,7 +962,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("mapPreviewType", mapPreviewType);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void setNoSoundHintShowed(boolean value) {
|
||||
|
@ -990,7 +973,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("noSoundHintShowed", noSoundHintShowed);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void toggleRaiseToSpeak() {
|
||||
|
@ -998,7 +981,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("raise_to_speak", raiseToSpeak);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void toggleRaiseToListen() {
|
||||
|
@ -1006,7 +989,15 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("raise_to_listen", raiseToListen);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void toggleNextMediaTap() {
|
||||
nextMediaTap = !nextMediaTap;
|
||||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("next_media_on_tap", nextMediaTap);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static boolean enabledRaiseTo(boolean speak) {
|
||||
|
@ -1018,7 +1009,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("custom_tabs", customTabs);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void toggleDirectShare() {
|
||||
|
@ -1026,7 +1017,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("direct_share", directShare);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
ShortcutManagerCompat.removeAllDynamicShortcuts(ApplicationLoader.applicationContext);
|
||||
MediaDataController.getInstance(UserConfig.selectedAccount).buildShortcuts();
|
||||
}
|
||||
|
@ -1036,7 +1027,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("streamMedia", streamMedia);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void toggleSortContactsByName() {
|
||||
|
@ -1044,7 +1035,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("sortContactsByName", sortContactsByName);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void toggleSortFilesByName() {
|
||||
|
@ -1052,7 +1043,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("sortFilesByName", sortFilesByName);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void toggleStreamAllVideo() {
|
||||
|
@ -1060,7 +1051,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("streamAllVideo", streamAllVideo);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void toggleStreamMkv() {
|
||||
|
@ -1068,7 +1059,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("streamMkv", streamMkv);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void toggleSaveStreamMedia() {
|
||||
|
@ -1076,7 +1067,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("saveStreamMedia", saveStreamMedia);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void togglePauseMusicOnRecord() {
|
||||
|
@ -1084,7 +1075,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("pauseMusicOnRecord", pauseMusicOnRecord);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void togglePauseMusicOnMedia() {
|
||||
|
@ -1092,7 +1083,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("pauseMusicOnMedia", pauseMusicOnMedia);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void toggleChatBlur() {
|
||||
|
@ -1104,7 +1095,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("forceDisableTabletMode", forceDisableTabletMode);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void toggleInappCamera() {
|
||||
|
@ -1112,7 +1103,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("inappCamera", inappCamera);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void toggleRoundCamera16to9() {
|
||||
|
@ -1120,7 +1111,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("roundCamera16to9", roundCamera16to9);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void setDistanceSystemType(int type) {
|
||||
|
@ -1128,7 +1119,7 @@ public class SharedConfig {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("distanceSystemType", distanceSystemType);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
LocaleController.resetImperialSystemType();
|
||||
}
|
||||
|
||||
|
@ -1232,7 +1223,7 @@ public class SharedConfig {
|
|||
serializedData.writeInt64(info.availableCheckTime);
|
||||
}
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
preferences.edit().putString("proxy_list", Base64.encodeToString(serializedData.toByteArray(), Base64.NO_WRAP)).commit();
|
||||
preferences.edit().putString("proxy_list", Base64.encodeToString(serializedData.toByteArray(), Base64.NO_WRAP)).apply();
|
||||
serializedData.cleanup();
|
||||
}
|
||||
|
||||
|
@ -1267,7 +1258,7 @@ public class SharedConfig {
|
|||
editor.putInt("proxy_port", 1080);
|
||||
editor.putBoolean("proxy_enabled", false);
|
||||
editor.putBoolean("proxy_enabled_calls", false);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
if (enabled) {
|
||||
ConnectionsManager.setProxySettings(false, "", 0, "", "", "");
|
||||
}
|
||||
|
@ -1372,25 +1363,6 @@ public class SharedConfig {
|
|||
int cpuCount = ConnectionsManager.CPU_COUNT;
|
||||
int memoryClass = ((ActivityManager) ApplicationLoader.applicationContext.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
|
||||
|
||||
if (Build.DEVICE != null && Build.MANUFACTURER != null) {
|
||||
int hash = (Build.MANUFACTURER + " " + Build.DEVICE).toUpperCase().hashCode();
|
||||
for (int i = 0; i < LOW_DEVICES.length; ++i) {
|
||||
if (LOW_DEVICES[i] == hash) {
|
||||
return PERFORMANCE_CLASS_LOW;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < AVERAGE_DEVICES.length; ++i) {
|
||||
if (AVERAGE_DEVICES[i] == hash) {
|
||||
return PERFORMANCE_CLASS_AVERAGE;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < HIGH_DEVICES.length; ++i) {
|
||||
if (HIGH_DEVICES[i] == hash) {
|
||||
return PERFORMANCE_CLASS_HIGH;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && Build.SOC_MODEL != null) {
|
||||
int hash = Build.SOC_MODEL.toUpperCase().hashCode();
|
||||
for (int i = 0; i < LOW_SOC.length; ++i) {
|
||||
|
|
|
@ -129,6 +129,11 @@ public class SvgHelper {
|
|||
private float crossfadeAlpha = 1.0f;
|
||||
SparseArray<Paint> overridePaintByPosition = new SparseArray<>();
|
||||
|
||||
private static boolean lite = LiteMode.isEnabled(LiteMode.FLAG_CHAT_BACKGROUND);
|
||||
public static void updateLiteValues() {
|
||||
lite = LiteMode.isEnabled(LiteMode.FLAG_CHAT_BACKGROUND);
|
||||
}
|
||||
|
||||
private boolean aspectFill = true;
|
||||
private boolean aspectCenter = false;
|
||||
|
||||
|
@ -166,7 +171,7 @@ public class SvgHelper {
|
|||
}
|
||||
|
||||
float scale = getScale((int) w, (int) h);
|
||||
if (placeholderGradient[threadIndex] != null && gradientWidth > 0 && LiteMode.isEnabled(LiteMode.FLAG_CHAT_BACKGROUND)) {
|
||||
if (placeholderGradient[threadIndex] != null && gradientWidth > 0 && lite) {
|
||||
if (drawInBackground) {
|
||||
long dt = time - lastUpdateTime;
|
||||
if (dt > 64) {
|
||||
|
@ -326,7 +331,7 @@ public class SvgHelper {
|
|||
currentColorKey = colorKey;
|
||||
currentColor[index] = color;
|
||||
gradientWidth = AndroidUtilities.displaySize.x * 2;
|
||||
if (!LiteMode.isEnabled(LiteMode.FLAG_CHAT_BACKGROUND)) {
|
||||
if (!lite) {
|
||||
int color2 = ColorUtils.setAlphaComponent(currentColor[index], 70);
|
||||
if (drawInBackground) {
|
||||
if (backgroundPaint == null) {
|
||||
|
|
|
@ -38,7 +38,7 @@ public class TranslateController extends BaseController {
|
|||
|
||||
private static final int MAX_SYMBOLS_PER_REQUEST = 25000;
|
||||
private static final int MAX_MESSAGES_PER_REQUEST = 20;
|
||||
private static final int GROUPING_TRANSLATIONS_TIMEOUT = 200;
|
||||
private static final int GROUPING_TRANSLATIONS_TIMEOUT = 80;
|
||||
|
||||
private final Set<Long> translatingDialogs = new HashSet<>();
|
||||
private final Set<Long> translatableDialogs = new HashSet<>();
|
||||
|
@ -48,7 +48,7 @@ public class TranslateController extends BaseController {
|
|||
private final HashMap<Long, HashMap<Integer, MessageObject>> keptReplyMessageObjects = new HashMap<>();
|
||||
private final Set<Long> hideTranslateDialogs = new HashSet<>();
|
||||
|
||||
class TranslatableDecision {
|
||||
static class TranslatableDecision {
|
||||
Set<Integer> certainlyTranslatable = new HashSet<>();
|
||||
Set<Integer> unknown = new HashSet<>();
|
||||
Set<Integer> certainlyNotTranslatable = new HashSet<>();
|
||||
|
@ -64,19 +64,32 @@ public class TranslateController extends BaseController {
|
|||
}
|
||||
|
||||
public boolean isFeatureAvailable() {
|
||||
return UserConfig.getInstance(currentAccount).isPremium() && isChatTranslateEnabled();
|
||||
return isChatTranslateEnabled() && UserConfig.getInstance(currentAccount).isPremium();
|
||||
}
|
||||
|
||||
private Boolean chatTranslateEnabled;
|
||||
private Boolean contextTranslateEnabled;
|
||||
|
||||
public boolean isChatTranslateEnabled() {
|
||||
return MessagesController.getMainSettings(currentAccount).getBoolean("translate_chat_button", true);
|
||||
if (chatTranslateEnabled == null) {
|
||||
chatTranslateEnabled = messagesController.getMainSettings().getBoolean("translate_chat_button", true);
|
||||
}
|
||||
return chatTranslateEnabled;
|
||||
}
|
||||
|
||||
public boolean isContextTranslateEnabled() {
|
||||
return MessagesController.getMainSettings(currentAccount).getBoolean("translate_button", MessagesController.getGlobalMainSettings().getBoolean("translate_button", false));
|
||||
if (contextTranslateEnabled == null) {
|
||||
contextTranslateEnabled = messagesController.getMainSettings().getBoolean("translate_button", MessagesController.getGlobalMainSettings().getBoolean("translate_button", false));
|
||||
}
|
||||
return contextTranslateEnabled;
|
||||
}
|
||||
|
||||
public void setContextTranslateEnabled(boolean enable) {
|
||||
MessagesController.getMainSettings(currentAccount).edit().putBoolean("translate_button", enable).apply();
|
||||
messagesController.getMainSettings().edit().putBoolean("translate_button", contextTranslateEnabled = enable).apply();
|
||||
}
|
||||
|
||||
public void setChatTranslateEnabled(boolean enable) {
|
||||
messagesController.getMainSettings().edit().putBoolean("translate_chat_button", chatTranslateEnabled = enable).apply();
|
||||
}
|
||||
|
||||
public static boolean isTranslatable(MessageObject messageObject) {
|
||||
|
@ -542,8 +555,14 @@ public class TranslateController extends BaseController {
|
|||
});
|
||||
}
|
||||
|
||||
public void checkDialogMessages(long dialogId) {
|
||||
if (!isFeatureAvailable()) {
|
||||
public void checkDialogMessage(long dialogId) {
|
||||
if (isFeatureAvailable()) {
|
||||
checkDialogMessageSure(dialogId);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkDialogMessageSure(long dialogId) {
|
||||
if (!translatingDialogs.contains(dialogId)) {
|
||||
return;
|
||||
}
|
||||
getMessagesStorage().getStorageQueue().postRunnable(() -> {
|
||||
|
@ -698,6 +717,7 @@ public class TranslateController extends BaseController {
|
|||
ArrayList<Utilities.Callback2<TLRPC.TL_textWithEntities, String>> callbacks = new ArrayList<>();
|
||||
String language;
|
||||
|
||||
int delay = GROUPING_TRANSLATIONS_TIMEOUT;
|
||||
int symbolsCount;
|
||||
|
||||
int reqId = -1;
|
||||
|
@ -742,6 +762,8 @@ public class TranslateController extends BaseController {
|
|||
|
||||
if (pendingTranslation.symbolsCount + messageSymbolsCount >= MAX_SYMBOLS_PER_REQUEST ||
|
||||
pendingTranslation.messageIds.size() + 1 >= MAX_MESSAGES_PER_REQUEST) {
|
||||
AndroidUtilities.cancelRunOnUIThread(pendingTranslation.runnable);
|
||||
AndroidUtilities.runOnUIThread(pendingTranslation.runnable); // without timeout
|
||||
dialogPendingTranslations.add(pendingTranslation = new PendingTranslation());
|
||||
}
|
||||
|
||||
|
@ -811,7 +833,8 @@ public class TranslateController extends BaseController {
|
|||
pendingTranslation1.reqId = reqId;
|
||||
}
|
||||
};
|
||||
AndroidUtilities.runOnUIThread(pendingTranslation.runnable, GROUPING_TRANSLATIONS_TIMEOUT);
|
||||
AndroidUtilities.runOnUIThread(pendingTranslation.runnable, pendingTranslation.delay);
|
||||
pendingTranslation.delay /= 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -237,10 +237,14 @@ public class Browser {
|
|||
}
|
||||
|
||||
public static void openUrl(final Context context, Uri uri, final boolean allowCustom, boolean tryTelegraph) {
|
||||
openUrl(context, uri, allowCustom, tryTelegraph, null);
|
||||
openUrl(context, uri, allowCustom, tryTelegraph, false, null);
|
||||
}
|
||||
|
||||
public static void openUrl(final Context context, Uri uri, final boolean allowCustom, boolean tryTelegraph, Progress inCaseLoading) {
|
||||
openUrl(context, uri, allowCustom, tryTelegraph, false, inCaseLoading);
|
||||
}
|
||||
|
||||
public static void openUrl(final Context context, Uri uri, final boolean allowCustom, boolean tryTelegraph, boolean forceNotInternalForApps, Progress inCaseLoading) {
|
||||
if (context == null || uri == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -412,6 +416,7 @@ public class Browser {
|
|||
intent.putExtra(android.provider.Browser.EXTRA_CREATE_NEW_TAB, true);
|
||||
intent.putExtra(android.provider.Browser.EXTRA_APPLICATION_ID, context.getPackageName());
|
||||
if (internalUri && context instanceof LaunchActivity) {
|
||||
intent.putExtra(LaunchActivity.EXTRA_FORCE_NOT_INTERNAL_APPS, forceNotInternalForApps);
|
||||
((LaunchActivity) context).onNewIntent(intent, inCaseLoading);
|
||||
} else {
|
||||
context.startActivity(intent);
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.telegram.messenger.Utilities;
|
|||
import org.telegram.messenger.VideoEditedInfo;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -80,6 +81,7 @@ public class MediaCodecVideoConvertor {
|
|||
MediaController.CropState cropState,
|
||||
boolean isRound) {
|
||||
|
||||
FileLog.d("convertVideoInternal original=" + originalWidth + "x" + originalHeight + " result=" + resultWidth + "x" + resultHeight + " " + avatarStartTime);
|
||||
long time = System.currentTimeMillis();
|
||||
boolean error = false;
|
||||
boolean repeatWithIncreasedTimeout = false;
|
||||
|
|
|
@ -44,13 +44,17 @@ import androidx.annotation.Keep;
|
|||
import androidx.core.graphics.ColorUtils;
|
||||
import androidx.core.math.MathUtils;
|
||||
|
||||
import com.google.android.exoplayer2.util.Log;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.BuildVars;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.ImageLoader;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.SharedConfig;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.ui.Components.BackButtonMenu;
|
||||
import org.telegram.ui.Components.Bulletin;
|
||||
import org.telegram.ui.Components.CubicBezierInterpolator;
|
||||
|
@ -351,6 +355,7 @@ public class ActionBarLayout extends FrameLayout implements INavigationLayout, F
|
|||
private ArrayList<ThemeDescription> presentingFragmentDescriptions;
|
||||
private ArrayList<ThemeDescription.ThemeDescriptionDelegate> themeAnimatorDelegate = new ArrayList<>();
|
||||
private AnimatorSet themeAnimatorSet;
|
||||
int animationIndex = -1;
|
||||
private float themeAnimationValue;
|
||||
private boolean animateThemeAfterAnimation;
|
||||
private Theme.ThemeInfo animateSetThemeAfterAnimation;
|
||||
|
@ -1182,6 +1187,9 @@ public class ActionBarLayout extends FrameLayout implements INavigationLayout, F
|
|||
if (fragment == null || checkTransitionAnimation() || delegate != null && check && !delegate.needPresentFragment(this, params) || !fragment.onFragmentCreate()) {
|
||||
return false;
|
||||
}
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
FileLog.d("present fragment " + fragment.getClass().getSimpleName());
|
||||
}
|
||||
if (inPreviewMode && transitionAnimationPreviewMode) {
|
||||
if (delayedOpenAnimationRunnable != null) {
|
||||
AndroidUtilities.cancelRunOnUIThread(delayedOpenAnimationRunnable);
|
||||
|
@ -1838,6 +1846,7 @@ public class ActionBarLayout extends FrameLayout implements INavigationLayout, F
|
|||
}
|
||||
}
|
||||
}
|
||||
currentFragment.onFragmentClosed();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2115,6 +2124,7 @@ public class ActionBarLayout extends FrameLayout implements INavigationLayout, F
|
|||
return;
|
||||
}
|
||||
Theme.setAnimatingColor(true);
|
||||
setThemeAnimationValue(0f);
|
||||
if (settings.beforeAnimationRunnable != null) {
|
||||
settings.beforeAnimationRunnable.run();
|
||||
}
|
||||
|
@ -2122,10 +2132,13 @@ public class ActionBarLayout extends FrameLayout implements INavigationLayout, F
|
|||
if (animationProgressListener != null) {
|
||||
animationProgressListener.setProgress(0);
|
||||
}
|
||||
int currentAccount = UserConfig.selectedAccount;
|
||||
animationIndex = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(animationIndex, null);
|
||||
themeAnimatorSet = new AnimatorSet();
|
||||
themeAnimatorSet.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
NotificationCenter.getInstance(currentAccount).onAnimationFinish(animationIndex);
|
||||
if (animation.equals(themeAnimatorSet)) {
|
||||
themeAnimatorDescriptions.clear();
|
||||
animateStartColors.clear();
|
||||
|
|
|
@ -10,6 +10,7 @@ package org.telegram.ui.ActionBar;
|
|||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
@ -564,4 +565,17 @@ public class ActionBarMenu extends LinearLayout {
|
|||
public void clearSearchFilters() {
|
||||
|
||||
}
|
||||
|
||||
private Runnable onLayoutListener;
|
||||
public void setOnLayoutListener(Runnable listener) {
|
||||
this.onLayoutListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
super.onLayout(changed, l, t, r, b);
|
||||
if (onLayoutListener != null) {
|
||||
onLayoutListener.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -199,7 +199,7 @@ public class AlertDialog extends Dialog implements Drawable.Callback, Notificati
|
|||
public void redPositive() {
|
||||
TextView button = (TextView) getButton(DialogInterface.BUTTON_POSITIVE);
|
||||
if (button != null) {
|
||||
button.setTextColor(getThemedColor(Theme.key_dialogTextRed));
|
||||
button.setTextColor(getThemedColor(Theme.key_text_RedBold));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import android.content.Intent;
|
|||
import android.content.SharedPreferences;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
@ -77,6 +78,7 @@ public abstract class BaseFragment {
|
|||
protected boolean fragmentBeginToShow;
|
||||
private boolean removingFromStack;
|
||||
private PreviewDelegate previewDelegate;
|
||||
private Theme.ResourcesProvider resourceProvider;
|
||||
|
||||
public BaseFragment() {
|
||||
classGuid = ConnectionsManager.generateClassGuid();
|
||||
|
@ -397,6 +399,10 @@ public abstract class BaseFragment {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isPaused() {
|
||||
return isPaused;
|
||||
}
|
||||
|
||||
public BaseFragment getFragmentForAlert(int offset) {
|
||||
if (parentLayout == null || parentLayout.getFragmentStack().size() <= 1 + offset) {
|
||||
return this;
|
||||
|
@ -743,20 +749,37 @@ public abstract class BaseFragment {
|
|||
}
|
||||
|
||||
public INavigationLayout[] showAsSheet(BaseFragment fragment) {
|
||||
return showAsSheet(fragment, null);
|
||||
}
|
||||
|
||||
public INavigationLayout[] showAsSheet(BaseFragment fragment, BottomSheetParams params) {
|
||||
if (getParentActivity() == null) {
|
||||
return null;
|
||||
}
|
||||
INavigationLayout[] actionBarLayout = new INavigationLayout[]{INavigationLayout.newLayout(getParentActivity())};
|
||||
BottomSheet bottomSheet = new BottomSheet(getParentActivity(), true) {
|
||||
BottomSheet[] bottomSheet = new BottomSheet[1];
|
||||
INavigationLayout[] actionBarLayout = new INavigationLayout[]{INavigationLayout.newLayout(getParentActivity(), () -> bottomSheet[0])};
|
||||
bottomSheet[0] = new BottomSheet(getParentActivity(), true, fragment.getResourceProvider()) {
|
||||
{
|
||||
drawNavigationBar = true;
|
||||
actionBarLayout[0].setFragmentStack(new ArrayList<>());
|
||||
actionBarLayout[0].addFragmentToStack(fragment);
|
||||
actionBarLayout[0].showLastFragment();
|
||||
actionBarLayout[0].getView().setPadding(backgroundPaddingLeft, 0, backgroundPaddingLeft, 0);
|
||||
containerView = actionBarLayout[0].getView();
|
||||
setApplyBottomPadding(false);
|
||||
setApplyBottomPadding(false);
|
||||
setOnDismissListener(dialog -> fragment.onFragmentDestroy());
|
||||
setOnDismissListener(dialog -> {
|
||||
fragment.onPause();
|
||||
fragment.onFragmentDestroy();
|
||||
if (params != null && params.onDismiss != null) {
|
||||
params.onDismiss.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
fixNavigationBar(Theme.getColor(Theme.key_dialogBackgroundGray, fragment.getResourceProvider()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -775,12 +798,29 @@ public abstract class BaseFragment {
|
|||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
if (!isDismissed()) {
|
||||
if (params != null && params.onPreFinished != null) {
|
||||
params.onPreFinished.run();
|
||||
}
|
||||
}
|
||||
super.dismiss();
|
||||
actionBarLayout[0] = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpenAnimationEnd() {
|
||||
if (params != null && params.onOpenAnimationFinished != null) {
|
||||
params.onOpenAnimationFinished.run();
|
||||
}
|
||||
}
|
||||
};
|
||||
fragment.setParentDialog(bottomSheet);
|
||||
bottomSheet.show();
|
||||
if (params != null) {
|
||||
bottomSheet[0].setAllowNestedScroll(params.allowNestedScroll);
|
||||
bottomSheet[0].transitionFromRight(params.transitionFromLeft);
|
||||
}
|
||||
fragment.setParentDialog(bottomSheet[0]);
|
||||
bottomSheet[0].show();
|
||||
|
||||
return actionBarLayout;
|
||||
}
|
||||
|
||||
|
@ -788,6 +828,11 @@ public abstract class BaseFragment {
|
|||
return Theme.getColor(key, getResourceProvider());
|
||||
}
|
||||
|
||||
public Paint getThemedPaint(String paintKey) {
|
||||
Paint paint = getResourceProvider() != null ? getResourceProvider().getPaint(paintKey) : null;
|
||||
return paint != null ? paint : Theme.getThemePaint(paintKey);
|
||||
}
|
||||
|
||||
public Drawable getThemedDrawable(String key) {
|
||||
return Theme.getThemeDrawable(key);
|
||||
}
|
||||
|
@ -800,7 +845,7 @@ public abstract class BaseFragment {
|
|||
}
|
||||
|
||||
public int getNavigationBarColor() {
|
||||
return Theme.getColor(Theme.key_windowBackgroundGray);
|
||||
return Theme.getColor(Theme.key_windowBackgroundGray, resourceProvider);
|
||||
}
|
||||
|
||||
public void setNavigationBarColor(int color) {
|
||||
|
@ -824,7 +869,7 @@ public abstract class BaseFragment {
|
|||
}
|
||||
|
||||
public Theme.ResourcesProvider getResourceProvider() {
|
||||
return null;
|
||||
return resourceProvider;
|
||||
}
|
||||
|
||||
protected boolean allowPresentFragment() {
|
||||
|
@ -885,9 +930,25 @@ public abstract class BaseFragment {
|
|||
}
|
||||
}
|
||||
|
||||
public void setResourceProvider(Theme.ResourcesProvider resourceProvider) {
|
||||
this.resourceProvider = resourceProvider;
|
||||
}
|
||||
|
||||
public void onFragmentClosed() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public interface PreviewDelegate {
|
||||
void finishFragment();
|
||||
}
|
||||
|
||||
public static class BottomSheetParams {
|
||||
public boolean transitionFromLeft;
|
||||
public boolean allowNestedScroll;
|
||||
public Runnable onDismiss;
|
||||
public Runnable onOpenAnimationFinished;
|
||||
public Runnable onPreFinished;
|
||||
}
|
||||
|
||||
}
|
|
@ -169,6 +169,7 @@ public class BottomSheet extends Dialog {
|
|||
protected Theme.ResourcesProvider resourcesProvider;
|
||||
protected boolean isPortrait;
|
||||
public boolean pauseAllHeavyOperations = true;
|
||||
private int animationIndex;
|
||||
|
||||
public void setDisableScroll(boolean b) {
|
||||
disableScroll = b;
|
||||
|
@ -181,6 +182,15 @@ public class BottomSheet extends Dialog {
|
|||
private float hideSystemVerticalInsetsProgress;
|
||||
public boolean useBackgroundTopPadding = true;
|
||||
protected int customViewGravity = Gravity.LEFT | Gravity.TOP;
|
||||
private boolean transitionFromRight;
|
||||
|
||||
public void transitionFromRight(boolean transitionFromRight) {
|
||||
this.transitionFromRight = transitionFromRight;
|
||||
}
|
||||
|
||||
public void onOpenAnimationEnd() {
|
||||
|
||||
}
|
||||
|
||||
public class ContainerView extends FrameLayout implements NestedScrollingParent {
|
||||
|
||||
|
@ -688,6 +698,9 @@ public class BottomSheet extends Dialog {
|
|||
} else {
|
||||
backgroundPaint.setColor(0xff000000);
|
||||
}
|
||||
if (transitionFromRight && containerView.getVisibility() != View.VISIBLE) {
|
||||
return;
|
||||
}
|
||||
if ((drawNavigationBar && bottomInset != 0) || currentPanTranslationY != 0) {
|
||||
float translation = 0;
|
||||
int navBarHeight = drawNavigationBar ? getBottomInset() : 0;
|
||||
|
@ -700,10 +713,14 @@ public class BottomSheet extends Dialog {
|
|||
}
|
||||
}
|
||||
int wasAlpha = backgroundPaint.getAlpha();
|
||||
if (transitionFromRight) {
|
||||
alpha *= containerView.getAlpha();
|
||||
}
|
||||
int left = transitionFromRight ? (int) containerView.getX() : containerView.getLeft();
|
||||
if (alpha < 1f) {
|
||||
backgroundPaint.setAlpha((int) (wasAlpha * alpha));
|
||||
}
|
||||
canvas.drawRect(containerView.getLeft() + backgroundPaddingLeft, getMeasuredHeight() - navBarHeight + translation - currentPanTranslationY, containerView.getRight() - backgroundPaddingLeft, getMeasuredHeight() + translation, backgroundPaint);
|
||||
canvas.drawRect(left + backgroundPaddingLeft, getMeasuredHeight() - navBarHeight + translation - currentPanTranslationY, containerView.getRight() - backgroundPaddingLeft, getMeasuredHeight() + translation, backgroundPaint);
|
||||
backgroundPaint.setAlpha(wasAlpha);
|
||||
|
||||
if (overlayDrawNavBarColor != 0) {
|
||||
|
@ -713,7 +730,7 @@ public class BottomSheet extends Dialog {
|
|||
backgroundPaint.setAlpha((int) (wasAlpha * alpha));
|
||||
translation = 0;
|
||||
}
|
||||
canvas.drawRect(containerView.getLeft() + backgroundPaddingLeft, getMeasuredHeight() - navBarHeight + translation - currentPanTranslationY, containerView.getRight() - backgroundPaddingLeft, getMeasuredHeight() + translation, backgroundPaint);
|
||||
canvas.drawRect(left + backgroundPaddingLeft, getMeasuredHeight() - navBarHeight + translation - currentPanTranslationY, containerView.getRight() - backgroundPaddingLeft, getMeasuredHeight() + translation, backgroundPaint);
|
||||
backgroundPaint.setAlpha(wasAlpha);
|
||||
}
|
||||
}
|
||||
|
@ -987,7 +1004,7 @@ public class BottomSheet extends Dialog {
|
|||
}
|
||||
|
||||
public void fixNavigationBar() {
|
||||
fixNavigationBar(getThemedColor(Theme.key_dialogBackground));
|
||||
fixNavigationBar(getThemedColor(Theme.key_windowBackgroundGray));
|
||||
}
|
||||
|
||||
public void fixNavigationBar(int bgColor) {
|
||||
|
@ -1208,26 +1225,22 @@ public class BottomSheet extends Dialog {
|
|||
return;
|
||||
}
|
||||
backDrawable.setAlpha(0);
|
||||
if (Build.VERSION.SDK_INT >= 18) {
|
||||
layoutCount = 2;
|
||||
containerView.setTranslationY((Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight * (1f - hideSystemVerticalInsetsProgress) : 0) + containerView.getMeasuredHeight() + (scrollNavBar ? getBottomInset() : 0));
|
||||
long delay = openNoDelay ? 0 : 150;
|
||||
if (waitingKeyboard) {
|
||||
delay = 500;
|
||||
}
|
||||
AndroidUtilities.runOnUIThread(startAnimationRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (startAnimationRunnable != this || dismissed) {
|
||||
return;
|
||||
}
|
||||
startAnimationRunnable = null;
|
||||
startOpenAnimation();
|
||||
}
|
||||
}, delay);
|
||||
} else {
|
||||
startOpenAnimation();
|
||||
layoutCount = 2;
|
||||
containerView.setTranslationY((Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight * (1f - hideSystemVerticalInsetsProgress) : 0) + containerView.getMeasuredHeight() + (scrollNavBar ? getBottomInset() : 0));
|
||||
long delay = openNoDelay ? 0 : 150;
|
||||
if (waitingKeyboard) {
|
||||
delay = 500;
|
||||
}
|
||||
AndroidUtilities.runOnUIThread(startAnimationRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (startAnimationRunnable != this || dismissed) {
|
||||
return;
|
||||
}
|
||||
startAnimationRunnable = null;
|
||||
startOpenAnimation();
|
||||
}
|
||||
}, delay);
|
||||
}
|
||||
|
||||
public ColorDrawable getBackDrawable() {
|
||||
|
@ -1335,7 +1348,13 @@ public class BottomSheet extends Dialog {
|
|||
if (Build.VERSION.SDK_INT >= 20 && useHardwareLayer) {
|
||||
container.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||
}
|
||||
containerView.setTranslationY(getContainerViewHeight() + container.keyboardHeight + AndroidUtilities.dp(10) + (scrollNavBar ? getBottomInset() : 0));
|
||||
if (transitionFromRight) {
|
||||
containerView.setTranslationX(AndroidUtilities.dp(48));
|
||||
containerView.setAlpha(0);
|
||||
containerView.setTranslationY(0);
|
||||
} else {
|
||||
containerView.setTranslationY(getContainerViewHeight() + container.keyboardHeight + AndroidUtilities.dp(10) + (scrollNavBar ? getBottomInset() : 0));
|
||||
}
|
||||
currentSheetAnimationType = 1;
|
||||
if (navigationBarAnimation != null) {
|
||||
navigationBarAnimation.cancel();
|
||||
|
@ -1349,19 +1368,30 @@ public class BottomSheet extends Dialog {
|
|||
});
|
||||
currentSheetAnimation = new AnimatorSet();
|
||||
currentSheetAnimation.playTogether(
|
||||
ObjectAnimator.ofFloat(containerView, View.TRANSLATION_X, 0),
|
||||
ObjectAnimator.ofFloat(containerView, View.ALPHA, 1f),
|
||||
ObjectAnimator.ofFloat(containerView, View.TRANSLATION_Y, 0),
|
||||
ObjectAnimator.ofInt(backDrawable, AnimationProperties.COLOR_DRAWABLE_ALPHA, dimBehind ? dimBehindAlpha : 0),
|
||||
navigationBarAnimation
|
||||
);
|
||||
currentSheetAnimation.setDuration(400);
|
||||
if (transitionFromRight) {
|
||||
currentSheetAnimation.setDuration(250);
|
||||
currentSheetAnimation.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
||||
} else {
|
||||
currentSheetAnimation.setDuration(400);
|
||||
currentSheetAnimation.setInterpolator(openInterpolator);
|
||||
}
|
||||
currentSheetAnimation.setStartDelay(waitingKeyboard ? 0 : 20);
|
||||
currentSheetAnimation.setInterpolator(openInterpolator);
|
||||
int finalAccount = currentAccount;
|
||||
animationIndex = NotificationCenter.getInstance(finalAccount).setAnimationInProgress(animationIndex, null);
|
||||
currentSheetAnimation.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) {
|
||||
currentSheetAnimation = null;
|
||||
currentSheetAnimationType = 0;
|
||||
onOpenAnimationEnd();
|
||||
if (delegate != null) {
|
||||
delegate.onOpenAnimationEnd();
|
||||
}
|
||||
|
@ -1378,6 +1408,7 @@ public class BottomSheet extends Dialog {
|
|||
if (pauseAllHeavyOperations) {
|
||||
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.startAllHeavyOperations, 512);
|
||||
}
|
||||
NotificationCenter.getInstance(finalAccount).onAnimationFinish(animationIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1553,20 +1584,24 @@ public class BottomSheet extends Dialog {
|
|||
currentSheetAnimation = new AnimatorSet();
|
||||
ArrayList<Animator> animators = new ArrayList<>();
|
||||
if (containerView != null) {
|
||||
animators.add(ObjectAnimator.ofFloat(containerView, View.TRANSLATION_Y, getContainerViewHeight() + container.keyboardHeight + AndroidUtilities.dp(10) + (scrollNavBar ? getBottomInset() : 0)));
|
||||
if (transitionFromRight) {
|
||||
animators.add(ObjectAnimator.ofFloat(containerView, View.TRANSLATION_X, AndroidUtilities.dp(48)));
|
||||
animators.add(ObjectAnimator.ofFloat(containerView, View.ALPHA, 0));
|
||||
} else {
|
||||
animators.add(ObjectAnimator.ofFloat(containerView, View.TRANSLATION_Y, getContainerViewHeight() + container.keyboardHeight + AndroidUtilities.dp(10) + (scrollNavBar ? getBottomInset() : 0)));
|
||||
}
|
||||
}
|
||||
animators.add(ObjectAnimator.ofInt(backDrawable, AnimationProperties.COLOR_DRAWABLE_ALPHA, 0));
|
||||
animators.add(navigationBarAnimation);
|
||||
currentSheetAnimation.playTogether(animators);
|
||||
// if (useFastDismiss) {
|
||||
// int height = containerView.getMeasuredHeight();
|
||||
// duration = Math.max(60, (int) (250 * (height - containerView.getTranslationY()) / (float) height));
|
||||
// currentSheetAnimation.setDuration(duration);
|
||||
// useFastDismiss = false;
|
||||
// } else {
|
||||
|
||||
if (transitionFromRight) {
|
||||
currentSheetAnimation.setDuration(200);
|
||||
currentSheetAnimation.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
||||
} else {
|
||||
currentSheetAnimation.setDuration(duration = 250);
|
||||
// }
|
||||
currentSheetAnimation.setInterpolator(CubicBezierInterpolator.EASE_OUT);
|
||||
currentSheetAnimation.setInterpolator(CubicBezierInterpolator.EASE_OUT);
|
||||
}
|
||||
currentSheetAnimation.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
|
|
|
@ -53,6 +53,7 @@ public class DrawerLayoutContainer extends FrameLayout {
|
|||
private static final int MIN_DRAWER_MARGIN = 64;
|
||||
|
||||
private FrameLayout drawerLayout;
|
||||
private View drawerListView;
|
||||
private INavigationLayout parentActionBarLayout;
|
||||
|
||||
private boolean maybeStartTracking;
|
||||
|
@ -176,13 +177,18 @@ public class DrawerLayoutContainer extends FrameLayout {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public void setDrawerLayout(FrameLayout layout) {
|
||||
public void setDrawerLayout(FrameLayout layout, View drawerListView) {
|
||||
drawerLayout = layout;
|
||||
this.drawerListView = drawerListView;
|
||||
addView(drawerLayout);
|
||||
drawerLayout.setVisibility(INVISIBLE);
|
||||
drawerListView.setVisibility(GONE);
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
drawerLayout.setFitsSystemWindows(true);
|
||||
}
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
drawerListView.setVisibility(View.VISIBLE);
|
||||
}, 2500);
|
||||
}
|
||||
|
||||
public void moveDrawerByX(float dx) {
|
||||
|
@ -201,6 +207,9 @@ public class DrawerLayoutContainer extends FrameLayout {
|
|||
drawerPosition = 0;
|
||||
}
|
||||
drawerLayout.setTranslationX(drawerPosition);
|
||||
if (drawerPosition > 0 && drawerListView != null && drawerListView.getVisibility() != View.VISIBLE) {
|
||||
drawerListView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
final int newVisibility = drawerPosition > 0 ? VISIBLE : INVISIBLE;
|
||||
if (drawerLayout.getVisibility() != newVisibility) {
|
||||
|
|
|
@ -29,6 +29,7 @@ public class EmojiThemes {
|
|||
|
||||
public boolean showAsDefaultStub;
|
||||
public String emoji;
|
||||
public TLRPC.WallPaper wallpaper;
|
||||
int currentIndex = 0;
|
||||
public ArrayList<ThemeItem> items = new ArrayList<>();
|
||||
|
||||
|
@ -43,7 +44,7 @@ public class EmojiThemes {
|
|||
Theme.key_chat_wallpaper_gradient_rotation
|
||||
};
|
||||
|
||||
private EmojiThemes() {
|
||||
public EmojiThemes() {
|
||||
}
|
||||
|
||||
public EmojiThemes(TLRPC.TL_theme chatThemeObject, boolean isDefault) {
|
||||
|
@ -361,9 +362,13 @@ public class EmojiThemes {
|
|||
}
|
||||
|
||||
long themeId = getTlTheme(index).id;
|
||||
ChatThemeController.getWallpaperBitmap(themeId, cachedBitmap -> {
|
||||
loadWallpaperImage(themeId, wallPaper, callback);
|
||||
}
|
||||
|
||||
public static void loadWallpaperImage(long hash, TLRPC.WallPaper wallPaper, ResultCallback<Pair<Long, Bitmap>> callback) {
|
||||
ChatThemeController.getWallpaperBitmap(hash, cachedBitmap -> {
|
||||
if (cachedBitmap != null && callback != null) {
|
||||
callback.onComplete(new Pair<>(themeId, cachedBitmap));
|
||||
callback.onComplete(new Pair<>(hash, cachedBitmap));
|
||||
return;
|
||||
}
|
||||
ImageLocation imageLocation = ImageLocation.getForDocument(wallPaper.document);
|
||||
|
@ -386,9 +391,9 @@ public class EmojiThemes {
|
|||
bitmap = ((BitmapDrawable) holder.drawable).getBitmap();
|
||||
}
|
||||
if (callback != null) {
|
||||
callback.onComplete(new Pair<>(themeId, bitmap));
|
||||
callback.onComplete(new Pair<>(hash, bitmap));
|
||||
}
|
||||
ChatThemeController.saveWallpaperBitmap(bitmap, themeId);
|
||||
ChatThemeController.saveWallpaperBitmap(bitmap, hash);
|
||||
});
|
||||
ImageLoader.getInstance().loadImageForImageReceiver(imageReceiver);
|
||||
});
|
||||
|
|
|
@ -8,8 +8,11 @@ import android.graphics.drawable.Drawable;
|
|||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.core.util.Supplier;
|
||||
|
||||
import org.telegram.ui.Components.BackButtonMenu;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -79,6 +82,15 @@ public interface INavigationLayout {
|
|||
return new ActionBarLayout(context);
|
||||
}
|
||||
|
||||
static INavigationLayout newLayout(Context context, Supplier<BottomSheet> supplier) {
|
||||
return new ActionBarLayout(context) {
|
||||
@Override
|
||||
public BottomSheet getBottomSheet() {
|
||||
return supplier.get();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
default void removeFragmentFromStack(BaseFragment fragment) {
|
||||
removeFragmentFromStack(fragment, false);
|
||||
}
|
||||
|
@ -254,6 +266,17 @@ public interface INavigationLayout {
|
|||
}
|
||||
}
|
||||
|
||||
default Window getWindow() {
|
||||
if (getParentActivity() != null) {
|
||||
return getParentActivity().getWindow();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
default BottomSheet getBottomSheet() {
|
||||
return null;
|
||||
}
|
||||
|
||||
interface INavigationLayoutDelegate {
|
||||
default boolean needPresentFragment(INavigationLayout layout, NavigationParams params) {
|
||||
return needPresentFragment(params.fragment, params.removeLast, params.noAnimation, layout);
|
||||
|
|
|
@ -610,14 +610,19 @@ public class SimpleTextView extends View implements Drawable.Callback {
|
|||
return false;
|
||||
}
|
||||
text = value;
|
||||
if (!(text == null && value == null || text != null && text.equals(value))) {
|
||||
scrollingOffset = 0;
|
||||
}
|
||||
currentScrollDelay = SCROLL_DELAY_MS;
|
||||
recreateLayoutMaybe();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void resetScrolling() {
|
||||
scrollingOffset = 0;
|
||||
}
|
||||
|
||||
public void copyScrolling(SimpleTextView textView) {
|
||||
scrollingOffset = textView.scrollingOffset;
|
||||
}
|
||||
|
||||
public void setDrawablePadding(int value) {
|
||||
if (drawablePadding == value) {
|
||||
return;
|
||||
|
@ -826,7 +831,7 @@ public class SimpleTextView extends View implements Drawable.Callback {
|
|||
}
|
||||
|
||||
if (layout != null) {
|
||||
if (rightDrawableOutside || ellipsizeByGradient) {
|
||||
if (rightDrawableOutside || ellipsizeByGradient || paddingRight > 0) {
|
||||
canvas.save();
|
||||
canvas.clipRect(0, 0, getMaxTextWidth() - paddingRight - AndroidUtilities.dp(rightDrawable != null && !(rightDrawable instanceof AnimatedEmojiDrawable.SwapAnimatedEmojiDrawable) && rightDrawableOutside ? 2 : 0), getMeasuredHeight());
|
||||
}
|
||||
|
@ -904,7 +909,7 @@ public class SimpleTextView extends View implements Drawable.Callback {
|
|||
}
|
||||
updateScrollAnimation();
|
||||
Emoji.emojiDrawingUseAlpha = true;
|
||||
if (rightDrawableOutside) {
|
||||
if (rightDrawableOutside || ellipsizeByGradient || paddingRight > 0) {
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,6 @@ import android.util.SparseArray;
|
|||
import android.util.StateSet;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
@ -99,6 +98,7 @@ import org.telegram.messenger.time.SunDate;
|
|||
import org.telegram.tgnet.ConnectionsManager;
|
||||
import org.telegram.tgnet.SerializedData;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ChatActivity;
|
||||
import org.telegram.ui.Components.AudioVisualizerDrawable;
|
||||
import org.telegram.ui.Components.BackgroundGradientDrawable;
|
||||
import org.telegram.ui.Components.Bulletin;
|
||||
|
@ -120,6 +120,7 @@ import org.telegram.ui.Components.SendingFileDrawable;
|
|||
import org.telegram.ui.Components.StatusDrawable;
|
||||
import org.telegram.ui.Components.ThemeEditorView;
|
||||
import org.telegram.ui.Components.TypingDotsDrawable;
|
||||
import org.telegram.ui.LaunchActivity;
|
||||
import org.telegram.ui.RoundVideoProgressShadow;
|
||||
import org.telegram.ui.ThemeActivity;
|
||||
|
||||
|
@ -151,6 +152,7 @@ public class Theme {
|
|||
public static final int MSG_OUT_COLOR_BLACK = 0xff212121;
|
||||
public static final int MSG_OUT_COLOR_WHITE = 0xffffffff;
|
||||
public static final int default_shadow_color = ColorUtils.setAlphaComponent(Color.BLACK, 27);
|
||||
public static boolean disallowChangeServiceMessageColor;
|
||||
|
||||
public static void applyDefaultShadow(Paint paint) {
|
||||
paint.setShadowLayer(dpf2(1), 0, dpf2(0.33f), default_shadow_color);
|
||||
|
@ -189,12 +191,13 @@ public class Theme {
|
|||
|
||||
private Rect backupRect = new Rect();
|
||||
|
||||
private final ResourcesProvider resourcesProvider;
|
||||
private ResourcesProvider resourcesProvider;
|
||||
private final boolean isOut;
|
||||
|
||||
private int topY;
|
||||
private boolean isTopNear;
|
||||
private boolean isBottomNear;
|
||||
private boolean botButtonsBottom;
|
||||
public boolean themePreview;
|
||||
|
||||
public static MotionBackgroundDrawable[] motionBackground = new MotionBackgroundDrawable[3];
|
||||
|
@ -206,11 +209,17 @@ public class Theme {
|
|||
|
||||
private int[][] currentBackgroundDrawableRadius = new int[][]{
|
||||
{-1, -1, -1, -1},
|
||||
{-1, -1, -1, -1}};
|
||||
private Drawable[][] backgroundDrawable = new Drawable[2][4];
|
||||
{-1, -1, -1, -1},
|
||||
{-1, -1, -1, -1},
|
||||
{-1, -1, -1, -1}
|
||||
};
|
||||
private Drawable[][] backgroundDrawable = new Drawable[4][4];
|
||||
private int[][] backgroundDrawableColor = new int[][]{
|
||||
{0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff},
|
||||
{0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}};
|
||||
{0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff},
|
||||
{0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff},
|
||||
{0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}
|
||||
};
|
||||
|
||||
public static final int TYPE_TEXT = 0;
|
||||
public static final int TYPE_MEDIA = 1;
|
||||
|
@ -299,6 +308,10 @@ public class Theme {
|
|||
return resourcesProvider != null ? resourcesProvider.getCurrentColor(key) : Theme.currentColors.get(key);
|
||||
}
|
||||
|
||||
public void setBotButtonsBottom(boolean botButtonsBottom) {
|
||||
this.botButtonsBottom = botButtonsBottom;
|
||||
}
|
||||
|
||||
public void setTop(int top, int backgroundWidth, int backgroundHeight, boolean topNear, boolean bottomNear) {
|
||||
setTop(top, backgroundWidth, backgroundHeight, backgroundHeight, 0, 0, topNear, bottomNear);
|
||||
}
|
||||
|
@ -468,7 +481,16 @@ public class Theme {
|
|||
} else {
|
||||
idx = 0;
|
||||
}
|
||||
int idx2 = isSelected ? 1 : 0;
|
||||
int idx2;
|
||||
if (isSelected && botButtonsBottom) {
|
||||
idx2 = 3;
|
||||
} else if (isSelected) {
|
||||
idx2 = 1;
|
||||
} else if (botButtonsBottom) {
|
||||
idx2 = 2;
|
||||
} else {
|
||||
idx2 = 0;
|
||||
}
|
||||
boolean forceSetColor = false;
|
||||
|
||||
boolean drawWithShadow = gradientShader == null && !isSelected && !isCrossfadeBackground;
|
||||
|
@ -768,13 +790,14 @@ public class Theme {
|
|||
}
|
||||
if (isOut) {
|
||||
if (drawFullBubble || currentType == TYPE_PREVIEW || paintToUse != null || drawFullBottom) {
|
||||
int radToUse = botButtonsBottom ? nearRad : rad;
|
||||
if (currentType == TYPE_MEDIA) {
|
||||
path.moveTo(bounds.right - dp(8) - rad, bounds.bottom - padding);
|
||||
path.moveTo(bounds.right - dp(8) - radToUse, bounds.bottom - padding);
|
||||
} else {
|
||||
path.moveTo(bounds.right - dp(2.6f), bounds.bottom - padding);
|
||||
}
|
||||
path.lineTo(bounds.left + padding + rad, bounds.bottom - padding);
|
||||
rect.set(bounds.left + padding, bounds.bottom - padding - rad * 2, bounds.left + padding + rad * 2, bounds.bottom - padding);
|
||||
path.lineTo(bounds.left + padding + radToUse, bounds.bottom - padding);
|
||||
rect.set(bounds.left + padding, bounds.bottom - padding - radToUse * 2, bounds.left + padding + radToUse * 2, bounds.bottom - padding);
|
||||
path.arcTo(rect, 90, 90, false);
|
||||
} else {
|
||||
path.moveTo(bounds.right - dp(8), top - topY + currentBackgroundHeight);
|
||||
|
@ -823,13 +846,15 @@ public class Theme {
|
|||
}
|
||||
} else {
|
||||
if (drawFullBubble || currentType == TYPE_PREVIEW || paintToUse != null || drawFullBottom) {
|
||||
int radToUse = botButtonsBottom ? nearRad : rad;
|
||||
|
||||
if (currentType == TYPE_MEDIA) {
|
||||
path.moveTo(bounds.left + dp(8) + rad, bounds.bottom - padding);
|
||||
path.moveTo(bounds.left + dp(8) + radToUse, bounds.bottom - padding);
|
||||
} else {
|
||||
path.moveTo(bounds.left + dp(2.6f), bounds.bottom - padding);
|
||||
}
|
||||
path.lineTo(bounds.right - padding - rad, bounds.bottom - padding);
|
||||
rect.set(bounds.right - padding - rad * 2, bounds.bottom - padding - rad * 2, bounds.right - padding, bounds.bottom - padding);
|
||||
path.lineTo(bounds.right - padding - radToUse, bounds.bottom - padding);
|
||||
rect.set(bounds.right - padding - radToUse * 2, bounds.bottom - padding - radToUse * 2, bounds.right - padding, bounds.bottom - padding);
|
||||
path.arcTo(rect, 90, -90, false);
|
||||
} else {
|
||||
path.moveTo(bounds.left + dp(8), top - topY + currentBackgroundHeight);
|
||||
|
@ -944,6 +969,10 @@ public class Theme {
|
|||
this.overrideRounding = rounding;
|
||||
}
|
||||
|
||||
public void setResourceProvider(ResourcesProvider resourcesProvider) {
|
||||
this.resourcesProvider = resourcesProvider;
|
||||
}
|
||||
|
||||
public static class PathDrawParams {
|
||||
Path path = new Path();
|
||||
Rect lastRect = new Rect();
|
||||
|
@ -1109,7 +1138,7 @@ public class Theme {
|
|||
private void checkCurrentWallpaperInternal(ArrayList<ThemeAccent> accents, boolean load) {
|
||||
if (accents != null && currentTheme.themeAccents != null && !currentTheme.themeAccents.isEmpty()) {
|
||||
if (accents.contains(currentTheme.getAccent(false))) {
|
||||
reloadWallpaper();
|
||||
reloadWallpaper(true);
|
||||
}
|
||||
}
|
||||
if (load) {
|
||||
|
@ -1926,9 +1955,13 @@ public class Theme {
|
|||
public float intensity;
|
||||
public long wallpaperId;
|
||||
public long accessHash;
|
||||
public long dialogId;
|
||||
|
||||
public ThemeInfo parentTheme;
|
||||
public ThemeAccent parentAccent;
|
||||
public float uploadingProgress;
|
||||
public ArrayList<Integer> requestIds;
|
||||
public TLRPC.WallPaper prevUserWallpaper;
|
||||
|
||||
public OverrideWallpaperInfo() {
|
||||
|
||||
|
@ -3210,7 +3243,6 @@ public class Theme {
|
|||
public static final String key_dialogTextBlack = "dialogTextBlack";
|
||||
public static final String key_dialogTextLink = "dialogTextLink";
|
||||
public static final String key_dialogLinkSelection = "dialogLinkSelection";
|
||||
public static final String key_dialogTextRed = "dialogTextRed";
|
||||
public static final String key_dialogTextBlue = "dialogTextBlue";
|
||||
public static final String key_dialogTextBlue2 = "dialogTextBlue2";
|
||||
public static final String key_dialogTextBlue4 = "dialogTextBlue4";
|
||||
|
@ -3235,7 +3267,6 @@ public class Theme {
|
|||
public static final String key_dialogButton = "dialogButton";
|
||||
public static final String key_dialogButtonSelector = "dialogButtonSelector";
|
||||
public static final String key_dialogIcon = "dialogIcon";
|
||||
public static final String key_dialogRedIcon = "dialogRedIcon";
|
||||
public static final String key_dialogGrayLine = "dialogGrayLine";
|
||||
public static final String key_dialogTopBackground = "dialogTopBackground";
|
||||
public static final String key_dialogCameraIcon = "dialogCameraIcon";
|
||||
|
@ -3274,11 +3305,6 @@ public class Theme {
|
|||
public static final String key_windowBackgroundWhiteBlueIcon = "windowBackgroundWhiteBlueIcon";
|
||||
public static final String key_windowBackgroundWhiteGreenText = "windowBackgroundWhiteGreenText";
|
||||
public static final String key_windowBackgroundWhiteGreenText2 = "windowBackgroundWhiteGreenText2";
|
||||
public static final String key_windowBackgroundWhiteRedText = "windowBackgroundWhiteRedText";
|
||||
public static final String key_windowBackgroundWhiteRedText2 = "windowBackgroundWhiteRedText2";
|
||||
public static final String key_windowBackgroundWhiteRedText3 = "windowBackgroundWhiteRedText3";
|
||||
public static final String key_windowBackgroundWhiteRedText4 = "windowBackgroundWhiteRedText4";
|
||||
public static final String key_windowBackgroundWhiteRedText5 = "windowBackgroundWhiteRedText5";
|
||||
public static final String key_windowBackgroundWhiteGrayText = "windowBackgroundWhiteGrayText";
|
||||
public static final String key_windowBackgroundWhiteGrayText2 = "windowBackgroundWhiteGrayText2";
|
||||
public static final String key_windowBackgroundWhiteGrayText3 = "windowBackgroundWhiteGrayText3";
|
||||
|
@ -3322,6 +3348,11 @@ public class Theme {
|
|||
public static final String key_fastScrollInactive = "fastScrollInactive";
|
||||
public static final String key_fastScrollText = "fastScrollText";
|
||||
|
||||
public static final String key_text_RedRegular = "text_RedRegular";
|
||||
public static final String key_text_RedBold = "text_RedBold";
|
||||
public static final String key_fill_RedNormal = "fill_RedNormal";
|
||||
public static final String key_fill_RedDark = "fill_RedDark";
|
||||
|
||||
public static final String key_inappPlayerPerformer = "inappPlayerPerformer";
|
||||
public static final String key_inappPlayerTitle = "inappPlayerTitle";
|
||||
public static final String key_inappPlayerBackground = "inappPlayerBackground";
|
||||
|
@ -3492,7 +3523,6 @@ public class Theme {
|
|||
public static final String key_chat_attachPollText = "chat_attachPollText";
|
||||
|
||||
public static final String key_chat_status = "chat_status";
|
||||
public static final String key_chat_inRedCall = "chat_inUpCall";
|
||||
public static final String key_chat_inGreenCall = "chat_inDownCall";
|
||||
public static final String key_chat_outGreenCall = "chat_outUpCall";
|
||||
public static final String key_chat_inBubble = "chat_inBubble";
|
||||
|
@ -3669,7 +3699,6 @@ public class Theme {
|
|||
public static final String key_chat_topPanelLine = "chat_topPanelLine";
|
||||
public static final String key_chat_topPanelTitle = "chat_topPanelTitle";
|
||||
public static final String key_chat_topPanelMessage = "chat_topPanelMessage";
|
||||
public static final String key_chat_reportSpam = "chat_reportSpam";
|
||||
public static final String key_chat_addContact = "chat_addContact";
|
||||
public static final String key_chat_inLoader = "chat_inLoader";
|
||||
public static final String key_chat_inLoaderSelected = "chat_inLoaderSelected";
|
||||
|
@ -4028,6 +4057,7 @@ public class Theme {
|
|||
public static final String key_paint_chatActionText2 = "paintChatActionText2";
|
||||
public static final String key_paint_chatBotButton = "paintChatBotButton";
|
||||
public static final String key_paint_chatComposeBackground = "paintChatComposeBackground";
|
||||
public static final String key_paint_divider = "paintDivider";
|
||||
public static final String key_paint_chatTimeBackground = "paintChatTimeBackground";
|
||||
private static final HashMap<String, Paint> defaultChatPaints = new HashMap<>();
|
||||
private static final HashMap<String, String> defaultChatPaintColors = new HashMap<>();
|
||||
|
@ -4058,7 +4088,6 @@ public class Theme {
|
|||
defaultColors.put(key_dialogTextBlack, 0xff222222);
|
||||
defaultColors.put(key_dialogTextLink, 0xff2678b6);
|
||||
defaultColors.put(key_dialogLinkSelection, 0x3362a9e3);
|
||||
defaultColors.put(key_dialogTextRed, 0xffcd5a5a);
|
||||
defaultColors.put(key_dialogTextBlue, 0xff2f8cc9);
|
||||
defaultColors.put(key_dialogTextBlue2, 0xff3a95d5);
|
||||
defaultColors.put(key_dialogTextBlue4, 0xff19a7e8);
|
||||
|
@ -4068,7 +4097,6 @@ public class Theme {
|
|||
defaultColors.put(key_dialogTextGray4, 0xffb3b3b3);
|
||||
defaultColors.put(key_dialogTextHint, 0xff979797);
|
||||
defaultColors.put(key_dialogIcon, 0xff676b70);
|
||||
defaultColors.put(key_dialogRedIcon, 0xffe14d4d);
|
||||
defaultColors.put(key_dialogGrayLine, 0xffd2d2d2);
|
||||
defaultColors.put(key_dialogTopBackground, 0xff6fb2e5);
|
||||
defaultColors.put(key_dialogInputField, 0xffdbdbdb);
|
||||
|
@ -4119,11 +4147,9 @@ public class Theme {
|
|||
defaultColors.put(key_windowBackgroundWhiteBlueIcon, 0xff379de5);
|
||||
defaultColors.put(key_windowBackgroundWhiteGreenText, 0xff26972c);
|
||||
defaultColors.put(key_windowBackgroundWhiteGreenText2, 0xff37a818);
|
||||
defaultColors.put(key_windowBackgroundWhiteRedText, 0xffcd5a5a);
|
||||
defaultColors.put(key_windowBackgroundWhiteRedText2, 0xffdb5151);
|
||||
defaultColors.put(key_windowBackgroundWhiteRedText3, 0xffd24949);
|
||||
defaultColors.put(key_windowBackgroundWhiteRedText4, 0xffcf3030);
|
||||
defaultColors.put(key_windowBackgroundWhiteRedText5, 0xffed3939);
|
||||
defaultColors.put(key_text_RedRegular, 0xffcc2929);
|
||||
defaultColors.put(key_text_RedBold, 0xffcc4747);
|
||||
defaultColors.put(key_fill_RedNormal, 0xffeb5e5e);
|
||||
defaultColors.put(key_windowBackgroundWhiteGrayText, 0xff838c96);
|
||||
defaultColors.put(key_windowBackgroundWhiteGrayText2, 0xff82868a);
|
||||
defaultColors.put(key_windowBackgroundWhiteGrayText3, 0xff999999);
|
||||
|
@ -4321,7 +4347,6 @@ public class Theme {
|
|||
|
||||
defaultColors.put(key_chat_status, 0xffd5e8f7);
|
||||
defaultColors.put(key_chat_inGreenCall, 0xff00c853);
|
||||
defaultColors.put(key_chat_inRedCall, 0xffff4848);
|
||||
defaultColors.put(key_chat_outGreenCall, 0xff00c853);
|
||||
defaultColors.put(key_chat_lockIcon, 0xffffffff);
|
||||
defaultColors.put(key_chat_muteIcon, 0xffb1cce3);
|
||||
|
@ -4541,7 +4566,6 @@ public class Theme {
|
|||
defaultColors.put(key_chat_topPanelLine, 0xff6c9fd2);
|
||||
defaultColors.put(key_chat_topPanelTitle, 0xff3a8ccf);
|
||||
defaultColors.put(key_chat_topPanelMessage, 0xff878e91);
|
||||
defaultColors.put(key_chat_reportSpam, 0xffcf5957);
|
||||
defaultColors.put(key_chat_addContact, 0xff4a82b5);
|
||||
defaultColors.put(key_chat_inLoader, 0xff72b5e8);
|
||||
defaultColors.put(key_chat_inLoaderSelected, 0xff65abe0);
|
||||
|
@ -4871,7 +4895,6 @@ public class Theme {
|
|||
fallbackKeys.put(key_checkboxDisabled, key_chats_unreadCounterMuted);
|
||||
fallbackKeys.put(key_chat_status, key_actionBarDefaultSubtitle);
|
||||
fallbackKeys.put(key_chat_inGreenCall, key_calls_callReceivedGreenIcon);
|
||||
fallbackKeys.put(key_chat_inRedCall, key_calls_callReceivedRedIcon);
|
||||
fallbackKeys.put(key_chat_outGreenCall, key_calls_callReceivedGreenIcon);
|
||||
fallbackKeys.put(key_actionBarTabActiveText, key_actionBarDefaultTitle);
|
||||
fallbackKeys.put(key_actionBarTabUnactiveText, key_actionBarDefaultSubtitle);
|
||||
|
@ -6681,7 +6704,7 @@ public class Theme {
|
|||
public static void resetCustomWallpaper(boolean temporary) {
|
||||
if (temporary) {
|
||||
isApplyingAccent = false;
|
||||
reloadWallpaper();
|
||||
reloadWallpaper(true);
|
||||
} else {
|
||||
currentTheme.setOverrideWallpaper(null);
|
||||
}
|
||||
|
@ -6860,7 +6883,7 @@ public class Theme {
|
|||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putString("theme", themeInfo.getKey());
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
String[] wallpaperLink = new String[1];
|
||||
if (themeInfo.assetName != null) {
|
||||
|
@ -7160,7 +7183,8 @@ public class Theme {
|
|||
shouldDrawGradientIcons = accent.fillAccentColors(currentColorsNoAccent, currentColors);
|
||||
}
|
||||
if (!messages) {
|
||||
reloadWallpaper();
|
||||
boolean async = !(LaunchActivity.getLastFragment() instanceof ChatActivity);
|
||||
reloadWallpaper(async);
|
||||
}
|
||||
applyCommonTheme();
|
||||
applyDialogsTheme();
|
||||
|
@ -9523,12 +9547,12 @@ public class Theme {
|
|||
}
|
||||
|
||||
setDrawableColorByKey(chat_msgCallUpGreenDrawable, key_chat_outGreenCall);
|
||||
setDrawableColorByKey(chat_msgCallDownRedDrawable, key_chat_inRedCall);
|
||||
setDrawableColorByKey(chat_msgCallDownRedDrawable, key_fill_RedNormal);
|
||||
setDrawableColorByKey(chat_msgCallDownGreenDrawable, key_chat_inGreenCall);
|
||||
|
||||
setDrawableColorByKey(calllog_msgCallUpRedDrawable, key_calls_callReceivedRedIcon);
|
||||
setDrawableColorByKey(calllog_msgCallUpRedDrawable, key_fill_RedNormal);
|
||||
setDrawableColorByKey(calllog_msgCallUpGreenDrawable, key_calls_callReceivedGreenIcon);
|
||||
setDrawableColorByKey(calllog_msgCallDownRedDrawable, key_calls_callReceivedRedIcon);
|
||||
setDrawableColorByKey(calllog_msgCallDownRedDrawable, key_fill_RedNormal);
|
||||
setDrawableColorByKey(calllog_msgCallDownGreenDrawable, key_calls_callReceivedGreenIcon);
|
||||
|
||||
for (int i = 0; i < chat_status_drawables.length; i++) {
|
||||
|
@ -9570,7 +9594,7 @@ public class Theme {
|
|||
|
||||
setDrawableColor(chat_attachEmptyDrawable, getColor(key_chat_attachEmptyImage));
|
||||
|
||||
if (!bg) {
|
||||
if (!bg && !disallowChangeServiceMessageColor) {
|
||||
applyChatServiceMessageColor();
|
||||
applyChatMessageSelectedBackgroundColor();
|
||||
}
|
||||
|
@ -9579,7 +9603,9 @@ public class Theme {
|
|||
}
|
||||
|
||||
public static void applyChatServiceMessageColor() {
|
||||
applyChatServiceMessageColor(null, null, wallpaper);
|
||||
if (wallpaper != null) {
|
||||
applyChatServiceMessageColor(null, null, wallpaper);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasGradientService() {
|
||||
|
@ -9587,7 +9613,12 @@ public class Theme {
|
|||
}
|
||||
|
||||
private static int[] viewPos = new int[2];
|
||||
|
||||
public static void applyServiceShaderMatrixForView(View view, View background) {
|
||||
applyServiceShaderMatrixForView(view, background, null);
|
||||
}
|
||||
|
||||
public static void applyServiceShaderMatrixForView(View view, View background, ResourcesProvider resourcesProvider) {
|
||||
if (view == null || background == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -9595,7 +9626,11 @@ public class Theme {
|
|||
int x = viewPos[0];
|
||||
int y = viewPos[1];
|
||||
background.getLocationOnScreen(viewPos);
|
||||
applyServiceShaderMatrix(background.getMeasuredWidth(), background.getMeasuredHeight(), x, y - viewPos[1]);
|
||||
if (resourcesProvider != null) {
|
||||
resourcesProvider.applyServiceShaderMatrix(background.getMeasuredWidth(), background.getMeasuredHeight(), x, y - viewPos[1]);
|
||||
} else {
|
||||
applyServiceShaderMatrix(background.getMeasuredWidth(), background.getMeasuredHeight(), x, y - viewPos[1]);
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyServiceShaderMatrix(int w, int h, float translationX, float translationY) {
|
||||
|
@ -10002,7 +10037,7 @@ public class Theme {
|
|||
case key_chat_wallpaper_gradient_to2:
|
||||
case key_chat_wallpaper_gradient_to3:
|
||||
case key_chat_wallpaper_gradient_rotation:
|
||||
reloadWallpaper();
|
||||
reloadWallpaper(true);
|
||||
break;
|
||||
case key_actionBarDefault:
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
@ -10040,7 +10075,7 @@ public class Theme {
|
|||
themedWallpaper = null;
|
||||
wallpaper = null;
|
||||
saveCurrentTheme(themeInfo, false, false, false);
|
||||
reloadWallpaper();
|
||||
reloadWallpaper(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10160,7 +10195,7 @@ public class Theme {
|
|||
return isCustomTheme;
|
||||
}
|
||||
|
||||
public static void reloadWallpaper() {
|
||||
public static void reloadWallpaper(boolean async) {
|
||||
if (backgroundGradientDisposable != null) {
|
||||
backgroundGradientDisposable.dispose();
|
||||
backgroundGradientDisposable = null;
|
||||
|
@ -10172,7 +10207,7 @@ public class Theme {
|
|||
}
|
||||
wallpaper = null;
|
||||
themedWallpaper = null;
|
||||
loadWallpaper();
|
||||
loadWallpaper(async);
|
||||
}
|
||||
|
||||
private static void calcBackgroundColor(Drawable drawable, int save) {
|
||||
|
@ -10190,7 +10225,7 @@ public class Theme {
|
|||
return serviceColor == null ? serviceMessageColor : serviceColor;
|
||||
}
|
||||
|
||||
public static void loadWallpaper() {
|
||||
public static void loadWallpaper(boolean async) {
|
||||
if (wallpaper != null) {
|
||||
return;
|
||||
}
|
||||
|
@ -10222,40 +10257,57 @@ public class Theme {
|
|||
}
|
||||
|
||||
TLRPC.Document finalWallpaperDocument = wallpaperDocument;
|
||||
Utilities.themeQueue.postRunnable(wallpaperLoadTask = () -> {
|
||||
BackgroundDrawableSettings settings = createBackgroundDrawable(
|
||||
currentTheme,
|
||||
overrideWallpaper,
|
||||
currentColors,
|
||||
wallpaperFile,
|
||||
themedWallpaperLink,
|
||||
themedWallpaperFileOffset,
|
||||
intensity,
|
||||
previousPhase,
|
||||
defaultTheme,
|
||||
hasPreviousTheme,
|
||||
isApplyingAccent,
|
||||
wallpaperMotion,
|
||||
finalWallpaperDocument
|
||||
);
|
||||
isWallpaperMotion = settings.isWallpaperMotion != null ? settings.isWallpaperMotion : isWallpaperMotion;
|
||||
isPatternWallpaper = settings.isPatternWallpaper != null ? settings.isPatternWallpaper : isPatternWallpaper;
|
||||
isCustomTheme = settings.isCustomTheme != null ? settings.isCustomTheme : isCustomTheme;
|
||||
patternIntensity = intensity;
|
||||
wallpaper = settings.wallpaper != null ? settings.wallpaper : wallpaper;
|
||||
Drawable drawable = settings.wallpaper;
|
||||
calcBackgroundColor(drawable, 1);
|
||||
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
wallpaperLoadTask = null;
|
||||
createCommonChatResources();
|
||||
if (async) {
|
||||
Utilities.themeQueue.postRunnable(wallpaperLoadTask = () -> {
|
||||
Drawable drawable = loadWallpaperInternal(overrideWallpaper, wallpaperFile, intensity, wallpaperMotion, finalWallpaperDocument, defaultTheme);
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
wallpaperLoadTask = null;
|
||||
createCommonChatResources();
|
||||
if (!disallowChangeServiceMessageColor) {
|
||||
applyChatServiceMessageColor(null, null, drawable);
|
||||
applyChatMessageSelectedBackgroundColor(null, drawable);
|
||||
}
|
||||
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didSetNewWallpapper);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
Drawable drawable = loadWallpaperInternal(overrideWallpaper, wallpaperFile, intensity, wallpaperMotion, finalWallpaperDocument, defaultTheme);
|
||||
createCommonChatResources();
|
||||
if (!disallowChangeServiceMessageColor) {
|
||||
applyChatServiceMessageColor(null, null, drawable);
|
||||
applyChatMessageSelectedBackgroundColor(null, drawable);
|
||||
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didSetNewWallpapper);
|
||||
});
|
||||
});
|
||||
}
|
||||
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didSetNewWallpapper);
|
||||
}
|
||||
}
|
||||
|
||||
private static Drawable loadWallpaperInternal(OverrideWallpaperInfo overrideWallpaper, File wallpaperFile, int intensity, boolean wallpaperMotion, TLRPC.Document finalWallpaperDocument, boolean defaultTheme) {
|
||||
BackgroundDrawableSettings settings = createBackgroundDrawable(
|
||||
currentTheme,
|
||||
overrideWallpaper,
|
||||
currentColors,
|
||||
wallpaperFile,
|
||||
themedWallpaperLink,
|
||||
themedWallpaperFileOffset,
|
||||
intensity,
|
||||
previousPhase,
|
||||
defaultTheme,
|
||||
hasPreviousTheme,
|
||||
isApplyingAccent,
|
||||
wallpaperMotion,
|
||||
finalWallpaperDocument
|
||||
);
|
||||
isWallpaperMotion = settings.isWallpaperMotion != null ? settings.isWallpaperMotion : isWallpaperMotion;
|
||||
isPatternWallpaper = settings.isPatternWallpaper != null ? settings.isPatternWallpaper : isPatternWallpaper;
|
||||
isCustomTheme = settings.isCustomTheme != null ? settings.isCustomTheme : isCustomTheme;
|
||||
patternIntensity = intensity;
|
||||
wallpaper = settings.wallpaper != null ? settings.wallpaper : wallpaper;
|
||||
Drawable drawable = settings.wallpaper;
|
||||
calcBackgroundColor(drawable, 1);
|
||||
return drawable;
|
||||
}
|
||||
|
||||
|
||||
public static BackgroundDrawableSettings createBackgroundDrawable(
|
||||
ThemeInfo currentTheme,
|
||||
HashMap<String, Integer> currentColors,
|
||||
|
@ -10423,6 +10475,16 @@ public class Theme {
|
|||
}
|
||||
}
|
||||
settings.wallpaper = motionBackgroundDrawable;
|
||||
} else if (settings.isPatternWallpaper) {
|
||||
File toFile = new File(ApplicationLoader.getFilesDirFixed(), overrideWallpaper.fileName);
|
||||
if (toFile.exists()) {
|
||||
Bitmap bitmap = loadScreenSizedBitmap(new FileInputStream(toFile), 0);
|
||||
if (bitmap != null) {
|
||||
settings.wallpaper = new BitmapDrawable(bitmap);
|
||||
settings.wallpaper.setFilterBitmap(true);
|
||||
settings.isCustomTheme = true;
|
||||
}
|
||||
}
|
||||
} else if (overrideWallpaper.gradientColor1 != 0) {
|
||||
final int[] colors = {selectedColor, overrideWallpaper.gradientColor1};
|
||||
final BackgroundGradientDrawable.Orientation orientation = BackgroundGradientDrawable.getGradientOrientation(overrideWallpaper.rotation);
|
||||
|
|
|
@ -49,6 +49,7 @@ import org.telegram.ui.Cells.ArchiveHintCell;
|
|||
import org.telegram.ui.Cells.DialogCell;
|
||||
import org.telegram.ui.Cells.DialogMeUrlCell;
|
||||
import org.telegram.ui.Cells.DialogsEmptyCell;
|
||||
import org.telegram.ui.Cells.DialogsHintCell;
|
||||
import org.telegram.ui.Cells.DialogsRequestedEmptyCell;
|
||||
import org.telegram.ui.Cells.HeaderCell;
|
||||
import org.telegram.ui.Cells.ProfileSearchCell;
|
||||
|
@ -88,7 +89,8 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
VIEW_TYPE_CONTACTS_FLICKER = 13,
|
||||
VIEW_TYPE_HEADER_2 = 14,
|
||||
VIEW_TYPE_REQUIREMENTS = 15,
|
||||
VIEW_TYPE_REQUIRED_EMPTY = 16;
|
||||
VIEW_TYPE_REQUIRED_EMPTY = 16,
|
||||
VIEW_TYPE_FOLDER_UPDATE_HINT = 17;
|
||||
|
||||
private Context mContext;
|
||||
private ArchiveHintCell archiveHintCell;
|
||||
|
@ -104,6 +106,7 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
private boolean isOnlySelect;
|
||||
private ArrayList<Long> selectedDialogs;
|
||||
private boolean hasHints;
|
||||
private boolean hasChatlistHint;
|
||||
private int currentAccount;
|
||||
private boolean dialogsListFrozen;
|
||||
private boolean showArchiveHint;
|
||||
|
@ -160,6 +163,9 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
}
|
||||
|
||||
public int fixPosition(int position) {
|
||||
if (hasChatlistHint) {
|
||||
position--;
|
||||
}
|
||||
if (hasHints) {
|
||||
position -= 2 + MessagesController.getInstance(currentAccount).hintDialogs.size();
|
||||
}
|
||||
|
@ -236,6 +242,13 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
boolean isForumCell;
|
||||
private boolean pinned;
|
||||
private boolean isFolder;
|
||||
TLRPC.TL_chatlists_chatlistUpdates chatlistUpdates;
|
||||
private int emptyType;
|
||||
|
||||
public ItemInternal(TLRPC.TL_chatlists_chatlistUpdates updates) {
|
||||
super(VIEW_TYPE_FOLDER_UPDATE_HINT, true);
|
||||
this.chatlistUpdates = updates;
|
||||
}
|
||||
|
||||
public ItemInternal(int viewType, TLRPC.Dialog dialog) {
|
||||
super(viewType, true);
|
||||
|
@ -259,6 +272,12 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
|
||||
public ItemInternal(int viewTypeEmpty) {
|
||||
super(viewTypeEmpty, true);
|
||||
this.emptyType = emptyType;
|
||||
}
|
||||
|
||||
public ItemInternal(int viewTypeEmpty, int emptyType) {
|
||||
super(viewTypeEmpty, true);
|
||||
this.emptyType = emptyType;
|
||||
}
|
||||
|
||||
public ItemInternal(int viewTypeUser, TLRPC.TL_contact tl_contact) {
|
||||
|
@ -285,6 +304,9 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
if (viewType == VIEW_TYPE_USER) {
|
||||
return contact != null && itemInternal.contact != null && contact.user_id == itemInternal.contact.user_id;
|
||||
}
|
||||
if (viewType == VIEW_TYPE_EMPTY) {
|
||||
return emptyType == itemInternal.emptyType;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -633,6 +655,9 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
view.setBackgroundDrawable(combinedDrawable);
|
||||
break;
|
||||
}
|
||||
case VIEW_TYPE_FOLDER_UPDATE_HINT:
|
||||
view = new DialogsHintCell(mContext);
|
||||
break;
|
||||
case VIEW_TYPE_TEXT:
|
||||
default: {
|
||||
view = new TextCell(mContext);
|
||||
|
@ -658,6 +683,8 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
} else {
|
||||
return DialogsEmptyCell.TYPE_FILTER_ADDING_CHATS;
|
||||
}
|
||||
} else if (folderId == 1) {
|
||||
return DialogsEmptyCell.TYPE_FILTER_NO_CHATS_TO_DISPLAY;
|
||||
} else {
|
||||
return onlineContacts != null ? DialogsEmptyCell.TYPE_WELCOME_WITH_CONTACTS : DialogsEmptyCell.TYPE_WELCOME_NO_CONTACTS;
|
||||
}
|
||||
|
@ -758,7 +785,7 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
case VIEW_TYPE_EMPTY: {
|
||||
DialogsEmptyCell cell = (DialogsEmptyCell) holder.itemView;
|
||||
int fromDialogsEmptyType = lastDialogsEmptyType;
|
||||
cell.setType(lastDialogsEmptyType = dialogsEmptyType());
|
||||
cell.setType(lastDialogsEmptyType = dialogsEmptyType(), isOnlySelect);
|
||||
if (dialogsType != 7 && dialogsType != 8) {
|
||||
cell.setOnUtyanAnimationEndListener(() -> parentFragment.setScrollDisabled(false));
|
||||
cell.setOnUtyanAnimationUpdateListener(progress -> parentFragment.setContactsAlpha(progress));
|
||||
|
@ -798,9 +825,9 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
case VIEW_TYPE_HEADER: {
|
||||
HeaderCell cell = (HeaderCell) holder.itemView;
|
||||
if (
|
||||
dialogsType == DialogsActivity.DIALOGS_TYPE_IMPORT_HISTORY_GROUPS ||
|
||||
dialogsType == DialogsActivity.DIALOGS_TYPE_IMPORT_HISTORY_USERS ||
|
||||
dialogsType == DialogsActivity.DIALOGS_TYPE_IMPORT_HISTORY
|
||||
dialogsType == DialogsActivity.DIALOGS_TYPE_IMPORT_HISTORY_GROUPS ||
|
||||
dialogsType == DialogsActivity.DIALOGS_TYPE_IMPORT_HISTORY_USERS ||
|
||||
dialogsType == DialogsActivity.DIALOGS_TYPE_IMPORT_HISTORY
|
||||
) {
|
||||
if (i == 0) {
|
||||
cell.setText(LocaleController.getString("ImportHeader", R.string.ImportHeader));
|
||||
|
@ -864,12 +891,37 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
cell.set(requestPeerType);
|
||||
break;
|
||||
}
|
||||
case VIEW_TYPE_FOLDER_UPDATE_HINT: {
|
||||
DialogsHintCell hintCell = (DialogsHintCell) holder.itemView;
|
||||
ItemInternal item = itemInternals.get(i);
|
||||
if (item.chatlistUpdates != null) {
|
||||
int count = item.chatlistUpdates.missing_peers.size();
|
||||
hintCell.setText(
|
||||
AndroidUtilities.replaceSingleTag(
|
||||
LocaleController.formatPluralString("FolderUpdatesTitle", count),
|
||||
Theme.key_windowBackgroundWhiteValueText,
|
||||
0,
|
||||
null
|
||||
),
|
||||
LocaleController.formatPluralString("FolderUpdatesSubtitle", count)
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i >= dialogsCount + 1) {
|
||||
holder.itemView.setAlpha(1f);
|
||||
}
|
||||
}
|
||||
|
||||
public TLRPC.TL_chatlists_chatlistUpdates getChatlistUpdate() {
|
||||
ItemInternal item = itemInternals.get(0);
|
||||
if (item != null && item.viewType == VIEW_TYPE_FOLDER_UPDATE_HINT) {
|
||||
return item.chatlistUpdates;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setForceUpdatingContacts(boolean forceUpdatingContacts) {
|
||||
this.forceUpdatingContacts = forceUpdatingContacts;
|
||||
}
|
||||
|
@ -1189,11 +1241,23 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
}
|
||||
}
|
||||
|
||||
hasChatlistHint = false;
|
||||
if (dialogsType == 7 || dialogsType == 8) {
|
||||
MessagesController.DialogFilter filter = messagesController.selectedDialogFilter[dialogsType - 7];
|
||||
if (filter != null && filter.isChatlist()) {
|
||||
messagesController.checkChatlistFolderUpdate(filter.id, false);
|
||||
TLRPC.TL_chatlists_chatlistUpdates updates = messagesController.getChatlistFolderUpdates(filter.id);
|
||||
if (updates != null && updates.missing_peers.size() > 0) {
|
||||
hasChatlistHint = true;
|
||||
itemInternals.add(new ItemInternal(updates));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (requestPeerType != null) {
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_REQUIREMENTS));
|
||||
}
|
||||
|
||||
boolean stopUpdate = false;
|
||||
if (collapsedView || isTransitionSupport) {
|
||||
for (int k = 0; k < array.size(); k++) {
|
||||
if (dialogsType == 2 && array.get(k) instanceof DialogsActivity.DialogsHeader) {
|
||||
|
@ -1205,16 +1269,25 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
return;
|
||||
}
|
||||
|
||||
boolean stopUpdate = false;
|
||||
if (dialogsCount == 0 && forceUpdatingContacts) {
|
||||
isEmpty = true;
|
||||
itemInternals.add(new ItemInternal(requestPeerType == null ? VIEW_TYPE_EMPTY : VIEW_TYPE_REQUIRED_EMPTY));
|
||||
if (requestPeerType != null) {
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_REQUIRED_EMPTY));
|
||||
} else {
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_EMPTY, dialogsEmptyType()));
|
||||
}
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_SHADOW));
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_HEADER));
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_CONTACTS_FLICKER));
|
||||
} else if (onlineContacts != null && !onlineContacts.isEmpty()) {
|
||||
} else if (onlineContacts != null && !onlineContacts.isEmpty() && dialogsType != 7 && dialogsType != 8) {
|
||||
if (dialogsCount == 0) {
|
||||
isEmpty = true;
|
||||
itemInternals.add(new ItemInternal(requestPeerType == null ? VIEW_TYPE_EMPTY : VIEW_TYPE_REQUIRED_EMPTY));
|
||||
if (requestPeerType != null) {
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_REQUIRED_EMPTY));
|
||||
} else {
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_EMPTY, dialogsEmptyType()));
|
||||
}
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_SHADOW));
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_HEADER));
|
||||
} else {
|
||||
|
@ -1265,7 +1338,11 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
}
|
||||
} else if (dialogsCount == 0) {
|
||||
isEmpty = true;
|
||||
itemInternals.add(new ItemInternal(requestPeerType == null ? VIEW_TYPE_EMPTY : VIEW_TYPE_REQUIRED_EMPTY));
|
||||
if (requestPeerType != null) {
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_REQUIRED_EMPTY));
|
||||
} else {
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_EMPTY, dialogsEmptyType()));
|
||||
}
|
||||
} else {
|
||||
if (folderId == 0 && dialogsCount > 10 && dialogsType == DialogsActivity.DIALOGS_TYPE_DEFAULT) {
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_NEW_CHAT_HINT));
|
||||
|
@ -1273,5 +1350,15 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
itemInternals.add(new ItemInternal(VIEW_TYPE_LAST_EMPTY));
|
||||
}
|
||||
}
|
||||
|
||||
if (!messagesController.hiddenUndoChats.isEmpty()) {
|
||||
for (int i = 0; i < itemInternals.size(); ++i) {
|
||||
ItemInternal item = itemInternals.get(i);
|
||||
if (item.viewType == VIEW_TYPE_DIALOG && item.dialog != null && messagesController.isHiddenByUndo(item.dialog.id)) {
|
||||
itemInternals.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -311,9 +311,9 @@ public class DrawerLayoutAdapter extends RecyclerListView.SelectionAdapter {
|
|||
UserConfig me = UserConfig.getInstance(UserConfig.selectedAccount);
|
||||
if (me != null && me.isPremium()) {
|
||||
if (me.getEmojiStatus() != null) {
|
||||
items.add(new Item(15, LocaleController.getString("ChangeEmojiStatus", R.string.ChangeEmojiStatus), 0, R.raw.emoji_status_change_to_set));
|
||||
items.add(new Item(15, LocaleController.getString("ChangeEmojiStatus", R.string.ChangeEmojiStatus), R.drawable.msg_status_edit));
|
||||
} else {
|
||||
items.add(new Item(15, LocaleController.getString("SetEmojiStatus", R.string.SetEmojiStatus), 0, R.raw.emoji_status_set_to_change));
|
||||
items.add(new Item(15, LocaleController.getString("SetEmojiStatus", R.string.SetEmojiStatus), R.drawable.msg_status_set));
|
||||
}
|
||||
items.add(null); // divider
|
||||
}
|
||||
|
@ -360,7 +360,6 @@ public class DrawerLayoutAdapter extends RecyclerListView.SelectionAdapter {
|
|||
|
||||
private static class Item {
|
||||
public int icon;
|
||||
public int lottieIcon;
|
||||
public String text;
|
||||
public int id;
|
||||
|
||||
|
@ -370,15 +369,8 @@ public class DrawerLayoutAdapter extends RecyclerListView.SelectionAdapter {
|
|||
this.text = text;
|
||||
}
|
||||
|
||||
public Item(int id, String text, int icon, int lottieIcon) {
|
||||
this.icon = icon;
|
||||
this.lottieIcon = lottieIcon;
|
||||
this.id = id;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public void bind(DrawerActionCell actionCell) {
|
||||
actionCell.setTextAndIcon(id, text, icon, lottieIcon);
|
||||
actionCell.setTextAndIcon(id, text, icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -689,7 +689,7 @@ public class MentionsAdapter extends RecyclerListView.SelectionAdapter implement
|
|||
if (foundContextBot != null) {
|
||||
return foundContextBot.bot_inline_placeholder;
|
||||
} else if (searchingContextUsername != null && searchingContextUsername.equals("gif")) {
|
||||
return "Search GIFs";
|
||||
return LocaleController.getString("SearchGifsTitle", R.string.SearchGifsTitle);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -740,9 +740,7 @@ public class MentionsAdapter extends RecyclerListView.SelectionAdapter implement
|
|||
if (searchResultBotContextSwitch == null) {
|
||||
searchResultBotContextSwitch = res.switch_pm;
|
||||
}
|
||||
if (searchResultBotWebViewSwitch == null) {
|
||||
searchResultBotWebViewSwitch = res.switch_webview;
|
||||
}
|
||||
searchResultBotWebViewSwitch = res.switch_webview;
|
||||
for (int a = 0; a < res.results.size(); a++) {
|
||||
TLRPC.BotInlineResult result = res.results.get(a);
|
||||
if (!(result.document instanceof TLRPC.TL_document) && !(result.photo instanceof TLRPC.TL_photo) && !"game".equals(result.type) && result.content == null && result.send_message instanceof TLRPC.TL_botInlineMessageMediaAuto) {
|
||||
|
@ -1112,14 +1110,27 @@ public class MentionsAdapter extends RecyclerListView.SelectionAdapter implement
|
|||
chat = null;
|
||||
threadId = 0;
|
||||
}
|
||||
TLRPC.User me = UserConfig.getInstance(currentAccount).getCurrentUser();
|
||||
if (chat != null && info != null && info.participants != null && (!ChatObject.isChannel(chat) || chat.megagroup)) {
|
||||
for (int a = (forSearch ? -1 : 0); a < info.participants.participants.size(); a++) {
|
||||
for (int a = -2; a < info.participants.participants.size(); a++) {
|
||||
String username;
|
||||
String firstName;
|
||||
String lastName;
|
||||
TLObject object;
|
||||
long id;
|
||||
if (a == -1) {
|
||||
if (a == -2) {
|
||||
if (me == null || !usernameOnly) {
|
||||
continue;
|
||||
}
|
||||
firstName = me.first_name;
|
||||
lastName = me.last_name;
|
||||
username = UserObject.getPublicUsername(me);
|
||||
object = me;
|
||||
id = me.id;
|
||||
} else if (a == -1) {
|
||||
if (!forSearch) {
|
||||
continue;
|
||||
}
|
||||
if (usernameString.length() == 0) {
|
||||
newResult.add(chat);
|
||||
continue;
|
||||
|
@ -1131,8 +1142,11 @@ public class MentionsAdapter extends RecyclerListView.SelectionAdapter implement
|
|||
id = -chat.id;
|
||||
} else {
|
||||
TLRPC.ChatParticipant chatParticipant = info.participants.participants.get(a);
|
||||
if (me != null && chatParticipant.user_id == me.id) {
|
||||
continue;
|
||||
}
|
||||
TLRPC.User user = messagesController.getUser(chatParticipant.user_id);
|
||||
if (user == null || !usernameOnly && UserObject.isUserSelf(user) || newResultsHashMap.indexOfKey(user.id) >= 0) {
|
||||
if (user == null || UserObject.isUserSelf(user) || newResultsHashMap.indexOfKey(user.id) >= 0) {
|
||||
continue;
|
||||
}
|
||||
if (usernameString.length() == 0) {
|
||||
|
|
|
@ -255,7 +255,7 @@ public class CacheChatsExceptionsFragment extends BaseFragment {
|
|||
case VIEW_TYPE_DELETE_ALL:
|
||||
textCell = new TextCell(parent.getContext());
|
||||
textCell.setText(LocaleController.getString("NotificationsDeleteAllException", R.string.NotificationsDeleteAllException), false);
|
||||
textCell.setColors(null, Theme.key_windowBackgroundWhiteRedText5);
|
||||
textCell.setColors(null, Theme.key_text_RedRegular);
|
||||
view = textCell;
|
||||
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
||||
break;
|
||||
|
|
|
@ -119,6 +119,7 @@ import java.util.Objects;
|
|||
|
||||
public class CacheControlActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
||||
private static final int VIEW_TYPE_TEXT_SETTINGS = 0;
|
||||
private static final int VIEW_TYPE_INFO = 1;
|
||||
private static final int VIEW_TYPE_STORAGE = 2;
|
||||
private static final int VIEW_TYPE_HEADER = 3;
|
||||
|
@ -126,12 +127,10 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
|
|||
private static final int VIEW_TYPE_CHAT = 5;
|
||||
private static final int VIEW_FLICKER_LOADING_DIALOG = 6;
|
||||
private static final int VIEW_TYPE_KEEP_MEDIA_CELL = 7;
|
||||
private static final int VIEW_TYPE_TEXT_SETTINGS = 0;
|
||||
private static final int VIEW_TYPE_CACHE_VIEW_PAGER = 8;
|
||||
|
||||
private static final int VIEW_TYPE_CHART = 9;
|
||||
private static final int VIEW_TYPE_CHART_HEADER = 10;
|
||||
public static final int VIEW_TYPE_SECTION = 11;
|
||||
private static final int VIEW_TYPE_SECTION = 11;
|
||||
private static final int VIEW_TYPE_SECTION_LOADING = 12;
|
||||
private static final int VIEW_TYPE_CLEAR_CACHE_BUTTON = 13;
|
||||
private static final int VIEW_TYPE_MAX_CACHE_SIZE = 14;
|
||||
|
@ -228,7 +227,7 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
|
|||
return;
|
||||
}
|
||||
}
|
||||
Utilities.globalQueue.postRunnable(() -> {
|
||||
Utilities.cacheClearQueue.postRunnable(() -> {
|
||||
canceled = false;
|
||||
long cacheSize = getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_CACHE), 5);
|
||||
long cacheTempSize = getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_CACHE), 4);
|
||||
|
@ -264,53 +263,56 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
|
|||
}
|
||||
return;
|
||||
}
|
||||
File path;
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
ArrayList<File> storageDirs = AndroidUtilities.getRootDirs();
|
||||
String dir = (path = storageDirs.get(0)).getAbsolutePath();
|
||||
if (!TextUtils.isEmpty(SharedConfig.storageCacheDir)) {
|
||||
for (int a = 0, N = storageDirs.size(); a < N; a++) {
|
||||
File file = storageDirs.get(a);
|
||||
if (file.getAbsolutePath().startsWith(SharedConfig.storageCacheDir) && file.canWrite()) {
|
||||
path = file;
|
||||
break;
|
||||
Utilities.cacheClearQueue.postRunnable(() -> {
|
||||
File path;
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
ArrayList<File> storageDirs = AndroidUtilities.getRootDirs();
|
||||
String dir = (path = storageDirs.get(0)).getAbsolutePath();
|
||||
if (!TextUtils.isEmpty(SharedConfig.storageCacheDir)) {
|
||||
for (int a = 0, N = storageDirs.size(); a < N; a++) {
|
||||
File file = storageDirs.get(a);
|
||||
if (file.getAbsolutePath().startsWith(SharedConfig.storageCacheDir) && file.canWrite()) {
|
||||
path = file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
path = new File(SharedConfig.storageCacheDir);
|
||||
}
|
||||
try {
|
||||
StatFs stat = new StatFs(path.getPath());
|
||||
long blockSize;
|
||||
long blockSizeExternal;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
blockSize = stat.getBlockSizeLong();
|
||||
} else {
|
||||
blockSize = stat.getBlockSize();
|
||||
}
|
||||
long availableBlocks;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
availableBlocks = stat.getAvailableBlocksLong();
|
||||
} else {
|
||||
availableBlocks = stat.getAvailableBlocks();
|
||||
}
|
||||
long blocksTotal;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
blocksTotal = stat.getBlockCountLong();
|
||||
} else {
|
||||
blocksTotal = stat.getBlockCount();
|
||||
path = new File(SharedConfig.storageCacheDir);
|
||||
}
|
||||
try {
|
||||
StatFs stat = new StatFs(path.getPath());
|
||||
long blockSize;
|
||||
long blockSizeExternal;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
blockSize = stat.getBlockSizeLong();
|
||||
} else {
|
||||
blockSize = stat.getBlockSize();
|
||||
}
|
||||
long availableBlocks;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
availableBlocks = stat.getAvailableBlocksLong();
|
||||
} else {
|
||||
availableBlocks = stat.getAvailableBlocks();
|
||||
}
|
||||
long blocksTotal;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
blocksTotal = stat.getBlockCountLong();
|
||||
} else {
|
||||
blocksTotal = stat.getBlockCount();
|
||||
}
|
||||
|
||||
lastDeviceTotalSize = blocksTotal * blockSize;
|
||||
lastDeviceTotalFreeSize = availableBlocks * blockSize;
|
||||
if (onDone != null) {
|
||||
onDone.run(lastDeviceTotalSize, lastDeviceTotalFreeSize);
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
lastDeviceTotalSize = blocksTotal * blockSize;
|
||||
lastDeviceTotalFreeSize = availableBlocks * blockSize;
|
||||
if (onDone != null) {
|
||||
onDone.run(lastDeviceTotalSize, lastDeviceTotalFreeSize);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1237,8 +1239,9 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
|
|||
|
||||
ActionBarMenuItem otherItem = actionBar.createMenu().addItem(other_id, R.drawable.ic_ab_other);
|
||||
clearDatabaseItem = otherItem.addSubItem(clear_database_id, R.drawable.msg_delete, LocaleController.getString("ClearLocalDatabase", R.string.ClearLocalDatabase));
|
||||
clearDatabaseItem.setIconColor(Theme.getColor(Theme.key_dialogRedIcon));
|
||||
clearDatabaseItem.setTextColor(Theme.getColor(Theme.key_dialogTextRed));
|
||||
clearDatabaseItem.setIconColor(Theme.getColor(Theme.key_text_RedRegular));
|
||||
clearDatabaseItem.setTextColor(Theme.getColor(Theme.key_text_RedBold));
|
||||
clearDatabaseItem.setSelectorColor(Theme.multAlpha(Theme.getColor(Theme.key_text_RedRegular), .12f));
|
||||
updateDatabaseItemSize();
|
||||
|
||||
listAdapter = new ListAdapter(context);
|
||||
|
@ -1379,7 +1382,7 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
|
|||
showDialog(dialog);
|
||||
TextView button = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE);
|
||||
if (button != null) {
|
||||
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed));
|
||||
button.setTextColor(Theme.getColor(Theme.key_text_RedBold));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1549,7 +1552,7 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
|
|||
showDialog(alertDialog);
|
||||
TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
|
||||
if (button != null) {
|
||||
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed));
|
||||
button.setTextColor(Theme.getColor(Theme.key_text_RedBold));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1906,50 +1909,71 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
|
|||
super(context);
|
||||
((MarginLayoutParams) button.getLayoutParams()).topMargin = AndroidUtilities.dp(5);
|
||||
button.setOnClickListener(e -> {
|
||||
BottomSheet bottomSheet = new BottomSheet(getContext(), false) {
|
||||
@Override
|
||||
protected boolean canDismissWithTouchOutside() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
bottomSheet.fixNavigationBar();
|
||||
bottomSheet.setCanDismissWithSwipe(false);
|
||||
bottomSheet.setCancelable(false);
|
||||
ClearingCacheView cacheView = new ClearingCacheView(getContext());
|
||||
bottomSheet.setCustomView(cacheView);
|
||||
|
||||
final boolean[] done = new boolean[] { false };
|
||||
final float[] progress = new float[] { 0 };
|
||||
final boolean[] nextSection = new boolean[] { false };
|
||||
Runnable updateProgress = () -> {
|
||||
cacheView.setProgress(progress[0]);
|
||||
if (nextSection[0]) {
|
||||
updateRows();
|
||||
}
|
||||
};
|
||||
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
if (!done[0]) {
|
||||
showDialog(bottomSheet);
|
||||
}
|
||||
}, 150);
|
||||
|
||||
cleanupFolders(
|
||||
(progressValue, next) -> {
|
||||
progress[0] = progressValue;
|
||||
nextSection[0] = next;
|
||||
AndroidUtilities.cancelRunOnUIThread(updateProgress);
|
||||
AndroidUtilities.runOnUIThread(updateProgress);
|
||||
},
|
||||
() -> AndroidUtilities.runOnUIThread(() -> {
|
||||
done[0] = true;
|
||||
cacheView.setProgress(1F);
|
||||
bottomSheet.dismiss();
|
||||
})
|
||||
);
|
||||
AlertDialog dialog = new AlertDialog.Builder(getContext())
|
||||
.setTitle(LocaleController.getString("ClearCache", R.string.ClearCache) + (TextUtils.isEmpty(valueTextView.getText()) ? "" : " (" + valueTextView.getText() + ")"))
|
||||
.setMessage(LocaleController.getString("StorageUsageInfo", R.string.StorageUsageInfo))
|
||||
.setPositiveButton(textView.getText(), (di, v) -> doClearCache())
|
||||
.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null)
|
||||
.create();
|
||||
showDialog(dialog);
|
||||
View clearButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||
if (clearButton instanceof TextView) {
|
||||
((TextView) clearButton).setTextColor(Theme.getColor(Theme.key_text_RedRegular));
|
||||
clearButton.setBackground(Theme.getRoundRectSelectorDrawable(AndroidUtilities.dp(6), Theme.multAlpha(Theme.getColor(Theme.key_text_RedRegular), .12f)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void doClearCache() {
|
||||
BottomSheet bottomSheet = new BottomSheet(getContext(), false) {
|
||||
@Override
|
||||
protected boolean canDismissWithTouchOutside() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
bottomSheet.fixNavigationBar();
|
||||
bottomSheet.setCanDismissWithSwipe(false);
|
||||
bottomSheet.setCancelable(false);
|
||||
ClearingCacheView cacheView = new ClearingCacheView(getContext());
|
||||
bottomSheet.setCustomView(cacheView);
|
||||
|
||||
final boolean[] done = new boolean[] { false };
|
||||
final float[] progress = new float[] { 0 };
|
||||
final boolean[] nextSection = new boolean[] { false };
|
||||
Runnable updateProgress = () -> {
|
||||
cacheView.setProgress(progress[0]);
|
||||
if (nextSection[0]) {
|
||||
updateRows();
|
||||
}
|
||||
};
|
||||
|
||||
final long[] start = new long[] { -1 };
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
if (!done[0]) {
|
||||
start[0] = System.currentTimeMillis();
|
||||
showDialog(bottomSheet);
|
||||
}
|
||||
}, 150);
|
||||
|
||||
cleanupFolders(
|
||||
(progressValue, next) -> {
|
||||
progress[0] = progressValue;
|
||||
nextSection[0] = next;
|
||||
AndroidUtilities.cancelRunOnUIThread(updateProgress);
|
||||
AndroidUtilities.runOnUIThread(updateProgress);
|
||||
},
|
||||
() -> AndroidUtilities.runOnUIThread(() -> {
|
||||
done[0] = true;
|
||||
cacheView.setProgress(1F);
|
||||
if (start[0] > 0) {
|
||||
AndroidUtilities.runOnUIThread(bottomSheet::dismiss, Math.max(0, 1000 - (System.currentTimeMillis() - start[0])));
|
||||
} else {
|
||||
bottomSheet.dismiss();
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
public void updateSize() {
|
||||
long size = (
|
||||
(selected[0] ? photoSize : 0) +
|
||||
|
@ -2514,7 +2538,7 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
|
|||
} else if (itemInners.get(position).keepMediaType == KEEP_MEDIA_TYPE_GROUP) {
|
||||
textCell2.setTextAndValueAndColorfulIcon(LocaleController.getString("GroupChats", R.string.GroupChats), value, true, R.drawable.msg_filled_menu_groups, getThemedColor(Theme.key_statisticChartLine_green), true);
|
||||
} else if (itemInners.get(position).keepMediaType == KEEP_MEDIA_TYPE_CHANNEL) {
|
||||
textCell2.setTextAndValueAndColorfulIcon(LocaleController.getString("CacheChannels", R.string.CacheChannels), value, true, R.drawable.msg_filled_menu_channels, getThemedColor(Theme.key_statisticChartLine_golden), true);
|
||||
textCell2.setTextAndValueAndColorfulIcon(LocaleController.getString("CacheChannels", R.string.CacheChannels), value, true, R.drawable.msg_filled_menu_channels, getThemedColor(Theme.key_statisticChartLine_golden), false);
|
||||
}
|
||||
textCell2.setSubtitle(subtitle);
|
||||
break;
|
||||
|
|
|
@ -336,9 +336,9 @@ public class CalendarActivity extends BaseFragment {
|
|||
|
||||
|
||||
selectDaysButton.setBackground(Theme.createSelectorDrawable(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_chat_fieldOverlayText), (int) (0.2f * 255)), 2));
|
||||
removeDaysButton.setBackground(Theme.createSelectorDrawable(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_dialogTextRed), (int) (0.2f * 255)), 2));
|
||||
removeDaysButton.setBackground(Theme.createSelectorDrawable(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_text_RedBold), (int) (0.2f * 255)), 2));
|
||||
selectDaysButton.setTextColor(Theme.getColor(Theme.key_chat_fieldOverlayText));
|
||||
removeDaysButton.setTextColor(Theme.getColor(Theme.key_dialogTextRed));
|
||||
removeDaysButton.setTextColor(Theme.getColor(Theme.key_text_RedBold));
|
||||
}
|
||||
|
||||
return fragmentView;
|
||||
|
|
|
@ -420,7 +420,7 @@ public class CallLogActivity extends BaseFragment implements NotificationCenter.
|
|||
iconIn = new ImageSpan(greenDrawable2, ImageSpan.ALIGN_BOTTOM);
|
||||
redDrawable = getParentActivity().getResources().getDrawable(R.drawable.ic_call_received_green_18dp).mutate();
|
||||
redDrawable.setBounds(0, 0, redDrawable.getIntrinsicWidth(), redDrawable.getIntrinsicHeight());
|
||||
redDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_calls_callReceivedRedIcon), PorterDuff.Mode.MULTIPLY));
|
||||
redDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_fill_RedNormal), PorterDuff.Mode.MULTIPLY));
|
||||
iconMissed = new ImageSpan(redDrawable, ImageSpan.ALIGN_BOTTOM);
|
||||
|
||||
actionBar.setBackButtonDrawable(new BackDrawable(false));
|
||||
|
@ -625,7 +625,7 @@ public class CallLogActivity extends BaseFragment implements NotificationCenter.
|
|||
showDialog(alertDialog);
|
||||
TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
|
||||
if (button != null) {
|
||||
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed));
|
||||
button.setTextColor(Theme.getColor(Theme.key_text_RedBold));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1248,7 +1248,7 @@ public class CallLogActivity extends BaseFragment implements NotificationCenter.
|
|||
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundPink));
|
||||
|
||||
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{View.class}, null, new Drawable[]{greenDrawable, greenDrawable2, Theme.calllog_msgCallUpRedDrawable, Theme.calllog_msgCallDownRedDrawable}, null, Theme.key_calls_callReceivedGreenIcon));
|
||||
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{View.class}, null, new Drawable[]{redDrawable, Theme.calllog_msgCallUpGreenDrawable, Theme.calllog_msgCallDownGreenDrawable}, null, Theme.key_calls_callReceivedRedIcon));
|
||||
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{View.class}, null, new Drawable[]{redDrawable, Theme.calllog_msgCallUpGreenDrawable, Theme.calllog_msgCallDownGreenDrawable}, null, Theme.key_fill_RedNormal));
|
||||
themeDescriptions.add(new ThemeDescription(flickerLoadingView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite));
|
||||
|
||||
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{ShadowSectionCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow));
|
||||
|
|
|
@ -26,18 +26,28 @@ import org.telegram.ui.Components.SeekBarView;
|
|||
|
||||
public class BrightnessControlCell extends FrameLayout {
|
||||
|
||||
public static final int TYPE_DEFAULT = 0;
|
||||
public static final int TYPE_WALLPAPER_DIM = 1;
|
||||
private final int size;
|
||||
private ImageView leftImageView;
|
||||
private ImageView rightImageView;
|
||||
private SeekBarView seekBarView;
|
||||
public final SeekBarView seekBarView;
|
||||
private int type;
|
||||
Theme.ResourcesProvider resourcesProvider;
|
||||
|
||||
public BrightnessControlCell(Context context) {
|
||||
public BrightnessControlCell(Context context, int type) {
|
||||
this(context, type, null);
|
||||
}
|
||||
|
||||
public BrightnessControlCell(Context context, int type, Theme.ResourcesProvider resourcesProvider) {
|
||||
super(context);
|
||||
this.type = type;
|
||||
this.resourcesProvider = resourcesProvider;
|
||||
|
||||
leftImageView = new ImageView(context);
|
||||
leftImageView.setImageResource(R.drawable.msg_brightness_low);
|
||||
addView(leftImageView, LayoutHelper.createFrame(24, 24, Gravity.LEFT | Gravity.TOP, 17, 12, 0, 0));
|
||||
|
||||
seekBarView = new SeekBarView(context, /* inPercents = */ true, null) {
|
||||
seekBarView = new SeekBarView(context, /* inPercents = */ true, resourcesProvider) {
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
|
@ -66,15 +76,23 @@ public class BrightnessControlCell extends FrameLayout {
|
|||
addView(seekBarView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 38, Gravity.TOP | Gravity.LEFT, 54, 5, 54, 0));
|
||||
|
||||
rightImageView = new ImageView(context);
|
||||
rightImageView.setImageResource(R.drawable.msg_brightness_high);
|
||||
addView(rightImageView, LayoutHelper.createFrame(24, 24, Gravity.RIGHT | Gravity.TOP, 0, 12, 17, 0));
|
||||
if (type == TYPE_DEFAULT) {
|
||||
leftImageView.setImageResource(R.drawable.msg_brightness_low);
|
||||
rightImageView.setImageResource(R.drawable.msg_brightness_high);
|
||||
size = 48;
|
||||
} else {
|
||||
leftImageView.setImageResource(R.drawable.msg_brightness_high);
|
||||
rightImageView.setImageResource(R.drawable.msg_brightness_low);
|
||||
size = 43;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
leftImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteGrayIcon), PorterDuff.Mode.MULTIPLY));
|
||||
rightImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteGrayIcon), PorterDuff.Mode.MULTIPLY));
|
||||
leftImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteGrayIcon, resourcesProvider), PorterDuff.Mode.MULTIPLY));
|
||||
rightImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteGrayIcon, resourcesProvider), PorterDuff.Mode.MULTIPLY));
|
||||
}
|
||||
|
||||
protected void didChangedValue(float value) {
|
||||
|
@ -83,7 +101,7 @@ public class BrightnessControlCell extends FrameLayout {
|
|||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(48), MeasureSpec.EXACTLY));
|
||||
super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(size), MeasureSpec.EXACTLY));
|
||||
}
|
||||
|
||||
public void setProgress(float value) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import android.annotation.SuppressLint;
|
|||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.Rect;
|
||||
|
@ -61,6 +62,7 @@ import org.telegram.tgnet.TLRPC;
|
|||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.ChatBackgroundDrawable;
|
||||
import org.telegram.ui.Components.AnimatedEmojiDrawable;
|
||||
import org.telegram.ui.Components.AnimatedEmojiSpan;
|
||||
import org.telegram.ui.Components.AvatarDrawable;
|
||||
|
@ -98,6 +100,9 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
monthsToEmoticon.put(24, 5 + "\u20E3");
|
||||
}
|
||||
|
||||
private int backgroundRectHeight;
|
||||
private int backgroundButtonTop;
|
||||
|
||||
@Override
|
||||
public void didReceivedNotification(int id, int account, Object... args) {
|
||||
if (id == NotificationCenter.startSpoilers) {
|
||||
|
@ -132,6 +137,10 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
invalidateWithParent = viewToInvalidate;
|
||||
}
|
||||
|
||||
public boolean hasButton() {
|
||||
return currentMessageObject != null && isButtonLayout(currentMessageObject) && giftPremiumButtonLayout != null;
|
||||
}
|
||||
|
||||
public interface ChatActionCellDelegate {
|
||||
default void didClickImage(ChatActionCell cell) {
|
||||
}
|
||||
|
@ -243,6 +252,10 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
private StaticLayout giftPremiumTitleLayout;
|
||||
private StaticLayout giftPremiumSubtitleLayout;
|
||||
private StaticLayout giftPremiumButtonLayout;
|
||||
TextPaint settingWallpaperPaint;
|
||||
private StaticLayout settingWallpaperLayout;
|
||||
private float settingWallpaperProgress;
|
||||
private StaticLayout settingWallpaperProgressTextLayout;
|
||||
private float giftPremiumButtonWidth;
|
||||
|
||||
private TextPaint giftTitlePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||
|
@ -404,7 +417,33 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
|
||||
previousWidth = 0;
|
||||
imageReceiver.setAutoRepeatCount(0);
|
||||
if (messageObject.type == MessageObject.TYPE_SUGGEST_PHOTO) {
|
||||
if (messageObject.type == MessageObject.TYPE_ACTION_WALLPAPER) {
|
||||
TLRPC.PhotoSize strippedPhotoSize = null;
|
||||
if (messageObject.strippedThumb == null) {
|
||||
for (int a = 0, N = messageObject.photoThumbs.size(); a < N; a++) {
|
||||
TLRPC.PhotoSize photoSize = messageObject.photoThumbs.get(a);
|
||||
if (photoSize instanceof TLRPC.TL_photoStrippedSize) {
|
||||
strippedPhotoSize = photoSize;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
TLRPC.MessageAction action = messageObject.messageOwner.action;
|
||||
if (action.wallpaper.uploadingImage != null) {
|
||||
imageReceiver.setImage(ImageLocation.getForPath(action.wallpaper.uploadingImage), "150_150_wallpaper" + action.wallpaper.id + ChatBackgroundDrawable.hash(action.wallpaper.settings), null, null, ChatBackgroundDrawable.createThumb(action.wallpaper), 0, null, action.wallpaper, 1);
|
||||
} else {
|
||||
imageReceiver.setImage(ImageLocation.getForDocument((TLRPC.Document) messageObject.photoThumbsObject), "150_150_wallpaper" + action.wallpaper.id + ChatBackgroundDrawable.hash(action.wallpaper.settings), null, null, ChatBackgroundDrawable.createThumb(action.wallpaper), 0, null, action.wallpaper, 1);
|
||||
}
|
||||
imageReceiver.setRoundRadius((int) (stickerSize / 2f));
|
||||
|
||||
float uploadingInfoProgress = getUploadingInfoProgress(messageObject);
|
||||
if (uploadingInfoProgress == 1f) {
|
||||
radialProgress.setProgress(1f, !messageIdChanged);
|
||||
radialProgress.setIcon(MediaActionDrawable.ICON_NONE, !messageIdChanged, !messageIdChanged);
|
||||
} else {
|
||||
radialProgress.setIcon(MediaActionDrawable.ICON_CANCEL, !messageIdChanged, !messageIdChanged);
|
||||
}
|
||||
} else if (messageObject.type == MessageObject.TYPE_SUGGEST_PHOTO) {
|
||||
imageReceiver.setRoundRadius((int) (stickerSize / 2f));
|
||||
imageReceiver.setAllowStartLottieAnimation(true);
|
||||
imageReceiver.setDelegate(null);
|
||||
|
@ -582,6 +621,16 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
requestLayout();
|
||||
}
|
||||
|
||||
private float getUploadingInfoProgress(MessageObject messageObject) {
|
||||
if (messageObject != null && messageObject.type == MessageObject.TYPE_ACTION_WALLPAPER) {
|
||||
MessagesController messagesController = MessagesController.getInstance(currentAccount);
|
||||
if (messagesController.uploadingWallpaper != null && TextUtils.equals(messageObject.messageOwner.action.wallpaper.uploadingImage, messagesController.uploadingWallpaper)) {
|
||||
return messagesController.uploadingWallpaperInfo.uploadingProgress;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public MessageObject getMessageObject() {
|
||||
return currentMessageObject;
|
||||
}
|
||||
|
@ -669,7 +718,7 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
imagePressed = true;
|
||||
result = true;
|
||||
}
|
||||
if (messageObject.type == MessageObject.TYPE_SUGGEST_PHOTO && backroundRect.contains(x, y)) {
|
||||
if (radialProgress.getIcon() == MediaActionDrawable.ICON_NONE && (messageObject.type == MessageObject.TYPE_SUGGEST_PHOTO || messageObject.type == MessageObject.TYPE_ACTION_WALLPAPER) && backroundRect.contains(x, y)) {
|
||||
imagePressed = true;
|
||||
result = true;
|
||||
}
|
||||
|
@ -692,10 +741,15 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
if (messageObject.type == MessageObject.TYPE_GIFT_PREMIUM) {
|
||||
openPremiumGiftPreview();
|
||||
} else if (delegate != null) {
|
||||
ImageUpdater imageUpdater = MessagesController.getInstance(currentAccount).photoSuggestion.get(messageObject.messageOwner.local_id);
|
||||
if (imageUpdater != null) {
|
||||
imageUpdater.cancel();
|
||||
} else {
|
||||
boolean consumed = false;
|
||||
if (messageObject.type == MessageObject.TYPE_SUGGEST_PHOTO) {
|
||||
ImageUpdater imageUpdater = MessagesController.getInstance(currentAccount).photoSuggestion.get(messageObject.messageOwner.local_id);
|
||||
if (imageUpdater != null) {
|
||||
consumed = true;
|
||||
imageUpdater.cancel();
|
||||
}
|
||||
}
|
||||
if (!consumed) {
|
||||
delegate.didClickImage(this);
|
||||
playSoundEffect(SoundEffectConstants.CLICK);
|
||||
}
|
||||
|
@ -705,7 +759,7 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
imagePressed = false;
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
if (messageObject.type == MessageObject.TYPE_SUGGEST_PHOTO) {
|
||||
if (messageObject.type == MessageObject.TYPE_SUGGEST_PHOTO || messageObject.type == MessageObject.TYPE_ACTION_WALLPAPER) {
|
||||
if (!backroundRect.contains(x, y)) {
|
||||
imagePressed = false;
|
||||
}
|
||||
|
@ -903,7 +957,7 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
if (isButtonLayout(messageObject)) {
|
||||
giftRectSize = Math.min((int) (AndroidUtilities.isTablet() ? AndroidUtilities.getMinTabletSide() * 0.6f : AndroidUtilities.displaySize.x * 0.6f), AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight() - AndroidUtilities.statusBarHeight - AndroidUtilities.dp(64));
|
||||
stickerSize = giftRectSize - AndroidUtilities.dp(106);
|
||||
if (messageObject.type == MessageObject.TYPE_SUGGEST_PHOTO) {
|
||||
if (messageObject.type == MessageObject.TYPE_SUGGEST_PHOTO || messageObject.type == MessageObject.TYPE_ACTION_WALLPAPER) {
|
||||
imageReceiver.setRoundRadius(stickerSize / 2);
|
||||
} else {
|
||||
imageReceiver.setRoundRadius(0);
|
||||
|
@ -924,12 +978,15 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
}
|
||||
}
|
||||
|
||||
int exactlyHeight = 0;
|
||||
if (isButtonLayout(messageObject)) {
|
||||
int imageSize = stickerSize;
|
||||
if (messageObject.type == MessageObject.TYPE_SUGGEST_PHOTO) {
|
||||
imageSize = (int) (stickerSize * 0.7f);
|
||||
int imageSize = getImageSize(messageObject);
|
||||
float y;
|
||||
if (messageObject.type == MessageObject.TYPE_ACTION_WALLPAPER) {
|
||||
y = textY + textHeight + AndroidUtilities.dp(12) + AndroidUtilities.dp(16) * 2 + imageSize + giftPremiumSubtitleLayout.getHeight() + AndroidUtilities.dp(4);
|
||||
} else {
|
||||
y = textY + textHeight + giftRectSize * 0.075f + imageSize + AndroidUtilities.dp(4) + AndroidUtilities.dp(4) + giftPremiumSubtitleLayout.getHeight();
|
||||
}
|
||||
float y = textY + textHeight + giftRectSize * 0.075f + imageSize + AndroidUtilities.dp(4) + AndroidUtilities.dp(4) + giftPremiumSubtitleLayout.getHeight();
|
||||
giftPremiumAdditionalHeight = 0;
|
||||
if (giftPremiumTitleLayout != null) {
|
||||
y += giftPremiumTitleLayout.getHeight();
|
||||
|
@ -948,10 +1005,14 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
|
||||
int h = textHeight + additionalHeight + AndroidUtilities.dp(14);
|
||||
|
||||
y += (h - y - giftPremiumButtonLayout.getHeight() - AndroidUtilities.dp(8)) / 2f;
|
||||
float rectX = (previousWidth - giftPremiumButtonWidth) / 2f;
|
||||
giftButtonRect.set(rectX - AndroidUtilities.dp(18), y - AndroidUtilities.dp(8), rectX + giftPremiumButtonWidth + AndroidUtilities.dp(18), y + giftPremiumButtonLayout.getHeight() + AndroidUtilities.dp(8));
|
||||
|
||||
if (giftPremiumButtonLayout != null) {
|
||||
y += (h - y - (giftPremiumButtonLayout != null ? giftPremiumButtonLayout.getHeight() : 0) - AndroidUtilities.dp(8)) / 2f;
|
||||
float rectX = (previousWidth - giftPremiumButtonWidth) / 2f;
|
||||
giftButtonRect.set(rectX - AndroidUtilities.dp(18), y - AndroidUtilities.dp(8), rectX + giftPremiumButtonWidth + AndroidUtilities.dp(18), y + (giftPremiumButtonLayout != null ? giftPremiumButtonLayout.getHeight() : 0) + AndroidUtilities.dp(8));
|
||||
} else {
|
||||
additionalHeight -= AndroidUtilities.dp(40);
|
||||
giftPremiumAdditionalHeight -= AndroidUtilities.dp(40);
|
||||
}
|
||||
int sizeInternal = getMeasuredWidth() << 16 + getMeasuredHeight();
|
||||
starParticlesDrawable.rect.set(giftButtonRect);
|
||||
starParticlesDrawable.rect2.set(giftButtonRect);
|
||||
|
@ -960,11 +1021,35 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
starParticlesDrawable.resetPositions();
|
||||
}
|
||||
|
||||
|
||||
if (messageObject.type == MessageObject.TYPE_ACTION_WALLPAPER) {
|
||||
exactlyHeight = textY + textHeight + AndroidUtilities.dp(12);
|
||||
backgroundRectHeight = 0;
|
||||
backgroundRectHeight += AndroidUtilities.dp(16) * 2 + imageSize;
|
||||
backgroundRectHeight += giftPremiumSubtitleLayout.getHeight();
|
||||
if (giftPremiumButtonLayout != null) {
|
||||
backgroundButtonTop = exactlyHeight + backgroundRectHeight + AndroidUtilities.dp(10);
|
||||
float rectX = (previousWidth - giftPremiumButtonWidth) / 2f;
|
||||
giftButtonRect.set(rectX - AndroidUtilities.dp(18), backgroundButtonTop, rectX + giftPremiumButtonWidth + AndroidUtilities.dp(18), backgroundButtonTop + giftPremiumButtonLayout.getHeight() + AndroidUtilities.dp(8) * 2);
|
||||
backgroundRectHeight += AndroidUtilities.dp(10) + giftButtonRect.height();
|
||||
}
|
||||
backgroundRectHeight += AndroidUtilities.dp(16);
|
||||
exactlyHeight += backgroundRectHeight;
|
||||
exactlyHeight += AndroidUtilities.dp(14);
|
||||
}
|
||||
}
|
||||
if (messageObject != null && messageObject.type == MessageObject.TYPE_ACTION_WALLPAPER) {
|
||||
setMeasuredDimension(width, exactlyHeight);
|
||||
} else {
|
||||
setMeasuredDimension(width, textHeight + additionalHeight + AndroidUtilities.dp(14));
|
||||
}
|
||||
}
|
||||
|
||||
setMeasuredDimension(width, textHeight + additionalHeight + AndroidUtilities.dp(14));
|
||||
|
||||
private int getImageSize(MessageObject messageObject) {
|
||||
int imageSize = stickerSize;
|
||||
if (messageObject.type == MessageObject.TYPE_SUGGEST_PHOTO || messageObject.type == MessageObject.TYPE_ACTION_WALLPAPER) {
|
||||
imageSize = (int) (stickerSize * 0.7f);
|
||||
}
|
||||
return imageSize;
|
||||
}
|
||||
|
||||
private void buildLayout() {
|
||||
|
@ -1026,6 +1111,20 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
textLayout = null;
|
||||
textHeight = 0;
|
||||
textY = 0;
|
||||
} else if (messageObject.type == MessageObject.TYPE_ACTION_WALLPAPER) {
|
||||
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(messageObject.isOutOwner() ? 0 : messageObject.getDialogId());
|
||||
CharSequence description;
|
||||
String action = null;
|
||||
if (user.id == UserConfig.getInstance(currentAccount).clientUserId) {
|
||||
description = messageObject.messageText;
|
||||
} else {
|
||||
description = messageObject.messageText;
|
||||
action = LocaleController.getString("ViewWallpaperAction", R.string.ViewWallpaperAction);
|
||||
}
|
||||
createGiftPremiumLayouts(null, description, action, giftRectSize);
|
||||
textLayout = null;
|
||||
textHeight = 0;
|
||||
textY = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1045,10 +1144,15 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
giftSubtitlePaint.setTextSize(AndroidUtilities.dp(15));
|
||||
}
|
||||
giftPremiumSubtitleLayout = new StaticLayout(subtitle, giftSubtitlePaint, width, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
|
||||
SpannableStringBuilder buttonBuilder = SpannableStringBuilder.valueOf(button);
|
||||
buttonBuilder.setSpan(new TypefaceSpan(AndroidUtilities.getTypeface(AndroidUtilities.TYPEFACE_ROBOTO_MEDIUM)), 0, buttonBuilder.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
giftPremiumButtonLayout = new StaticLayout(buttonBuilder, (TextPaint) getThemedPaint(Theme.key_paint_chatActionText), width, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
|
||||
giftPremiumButtonWidth = measureLayoutWidth(giftPremiumButtonLayout);
|
||||
if (button != null) {
|
||||
SpannableStringBuilder buttonBuilder = SpannableStringBuilder.valueOf(button);
|
||||
buttonBuilder.setSpan(new TypefaceSpan(AndroidUtilities.getTypeface(AndroidUtilities.TYPEFACE_ROBOTO_MEDIUM)), 0, buttonBuilder.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
giftPremiumButtonLayout = new StaticLayout(buttonBuilder, (TextPaint) getThemedPaint(Theme.key_paint_chatActionText), width, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
|
||||
giftPremiumButtonWidth = measureLayoutWidth(giftPremiumButtonLayout);
|
||||
} else {
|
||||
giftPremiumButtonLayout = null;
|
||||
giftPremiumButtonWidth = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private float measureLayoutWidth(Layout layout) {
|
||||
|
@ -1072,17 +1176,22 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
int imageSize = stickerSize;
|
||||
if (isButtonLayout(messageObject)) {
|
||||
stickerSize = giftRectSize - AndroidUtilities.dp(106);
|
||||
if (messageObject.type == MessageObject.TYPE_ACTION_PHOTO) {
|
||||
if (messageObject.type == MessageObject.TYPE_ACTION_WALLPAPER) {
|
||||
imageSize = getImageSize(messageObject);
|
||||
int top = textY + textHeight + AndroidUtilities.dp(12) + AndroidUtilities.dp(16);
|
||||
imageReceiver.setImageCoords((previousWidth - imageSize) / 2f, top, imageSize, imageSize);
|
||||
} else if (messageObject.type == MessageObject.TYPE_ACTION_PHOTO) {
|
||||
imageReceiver.setImageCoords((previousWidth - stickerSize) / 2f, textY + textHeight + giftRectSize * 0.075f, stickerSize, stickerSize);
|
||||
} else {
|
||||
imageSize = (int) (stickerSize * 0.7f);
|
||||
imageReceiver.setImageCoords((previousWidth - imageSize) / 2f, textY + textHeight + giftRectSize * 0.075f + AndroidUtilities.dp(8), imageSize, imageSize);
|
||||
}
|
||||
if (textPaint != null && giftTitlePaint != null && giftSubtitlePaint != null) {
|
||||
if (giftTitlePaint.getColor() != textPaint.getColor()) {
|
||||
textPaint = (TextPaint) getThemedPaint(Theme.key_paint_chatActionText);
|
||||
if (textPaint != null) {
|
||||
if (giftTitlePaint != null && giftTitlePaint.getColor() != textPaint.getColor()) {
|
||||
giftTitlePaint.setColor(textPaint.getColor());
|
||||
}
|
||||
if (giftSubtitlePaint.getColor() != textPaint.getColor()) {
|
||||
if (giftSubtitlePaint != null && giftSubtitlePaint.getColor() != textPaint.getColor()) {
|
||||
giftSubtitlePaint.setColor(textPaint.getColor());
|
||||
}
|
||||
}
|
||||
|
@ -1112,6 +1221,18 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
}
|
||||
}
|
||||
radialProgress.draw(canvas);
|
||||
} else if (messageObject.type == MessageObject.TYPE_ACTION_WALLPAPER) {
|
||||
float progress = getUploadingInfoProgress(messageObject);
|
||||
radialProgress.setProgress(progress, true);
|
||||
radialProgress.setCircleRadius(AndroidUtilities.dp(26));
|
||||
radialProgress.setMaxIconSize(AndroidUtilities.dp(24));
|
||||
radialProgress.setColors(Theme.key_chat_mediaLoaderPhoto, Theme.key_chat_mediaLoaderPhotoSelected, Theme.key_chat_mediaLoaderPhotoIcon, Theme.key_chat_mediaLoaderPhotoIconSelected);
|
||||
if (progress == 1f) {
|
||||
radialProgress.setIcon(MediaActionDrawable.ICON_NONE, true, true);
|
||||
} else {
|
||||
radialProgress.setIcon(MediaActionDrawable.ICON_CANCEL, true, true);
|
||||
}
|
||||
radialProgress.draw(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1139,10 +1260,21 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
|
||||
if (isButtonLayout(messageObject)) {
|
||||
canvas.save();
|
||||
float x = (previousWidth - giftRectSize) / 2f + AndroidUtilities.dp(8), y = textY + textHeight + giftRectSize * 0.075f + (messageObject.type == MessageObject.TYPE_SUGGEST_PHOTO ? imageSize : stickerSize) + AndroidUtilities.dp(4);
|
||||
if (messageObject.type == MessageObject.TYPE_SUGGEST_PHOTO) {
|
||||
y += +AndroidUtilities.dp(16);
|
||||
float x = (previousWidth - giftRectSize) / 2f + AndroidUtilities.dp(8);
|
||||
float y;
|
||||
if (messageObject.type == MessageObject.TYPE_ACTION_WALLPAPER) {
|
||||
float top = backroundRect != null ? backroundRect.top : (textY + textHeight + AndroidUtilities.dp(12));
|
||||
y = top + AndroidUtilities.dp(16) * 2 + imageSize;
|
||||
} else {
|
||||
y = textY + textHeight + giftRectSize * 0.075f + (messageObject.type == MessageObject.TYPE_SUGGEST_PHOTO ? imageSize : stickerSize) + AndroidUtilities.dp(4);
|
||||
if (messageObject.type == MessageObject.TYPE_SUGGEST_PHOTO) {
|
||||
y += AndroidUtilities.dp(16);
|
||||
}
|
||||
if (giftPremiumButtonLayout == null) {
|
||||
y -= AndroidUtilities.dp(24);
|
||||
}
|
||||
}
|
||||
|
||||
canvas.translate(x, y);
|
||||
if (giftPremiumTitleLayout != null) {
|
||||
giftPremiumTitleLayout.draw(canvas);
|
||||
|
@ -1155,7 +1287,60 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
y += AndroidUtilities.dp(4);
|
||||
canvas.save();
|
||||
canvas.translate(x, y);
|
||||
giftPremiumSubtitleLayout.draw(canvas);
|
||||
if (messageObject.type == MessageObject.TYPE_ACTION_WALLPAPER) {
|
||||
if (radialProgress.getTransitionProgress() != 1f || radialProgress.getIcon() != MediaActionDrawable.ICON_NONE) {
|
||||
if (settingWallpaperLayout == null) {
|
||||
settingWallpaperPaint = new TextPaint();
|
||||
settingWallpaperPaint.setTextSize(AndroidUtilities.dp(13));
|
||||
settingWallpaperLayout = new StaticLayout("Setting new wallpaper...", settingWallpaperPaint, giftPremiumSubtitleLayout.getWidth(), Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
|
||||
}
|
||||
float progressLocal = getUploadingInfoProgress(messageObject);
|
||||
if (settingWallpaperProgressTextLayout == null || settingWallpaperProgress != progressLocal) {
|
||||
settingWallpaperProgress = progressLocal;
|
||||
settingWallpaperProgressTextLayout = new StaticLayout((int) (progressLocal * 100) + "%", giftSubtitlePaint, giftPremiumSubtitleLayout.getWidth(), Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
|
||||
}
|
||||
|
||||
settingWallpaperPaint.setColor(giftSubtitlePaint.getColor());
|
||||
if (radialProgress.getIcon() == MediaActionDrawable.ICON_NONE) {
|
||||
float p = radialProgress.getTransitionProgress();
|
||||
int oldColor = giftSubtitlePaint.getColor();
|
||||
settingWallpaperPaint.setAlpha((int) (Color.alpha(oldColor) * (1f - p)));
|
||||
giftSubtitlePaint.setAlpha((int) (Color.alpha(oldColor) * p));
|
||||
|
||||
float s = 0.8f + 0.2f * p;
|
||||
canvas.save();
|
||||
canvas.scale(s, s, giftPremiumSubtitleLayout.getWidth() / 2f, giftPremiumSubtitleLayout.getHeight() / 2f);
|
||||
giftPremiumSubtitleLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
|
||||
giftSubtitlePaint.setAlpha((int) (Color.alpha(oldColor) * (1f - p)));
|
||||
s = 0.8f + 0.2f * (1f - p);
|
||||
canvas.save();
|
||||
canvas.scale(s, s, settingWallpaperLayout.getWidth() / 2f, settingWallpaperLayout.getHeight() / 2f);
|
||||
settingWallpaperLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
|
||||
canvas.save();
|
||||
canvas.translate(0, settingWallpaperLayout.getHeight() + AndroidUtilities.dp(4));
|
||||
canvas.scale(s, s, settingWallpaperProgressTextLayout.getWidth() / 2f, settingWallpaperProgressTextLayout.getHeight() / 2f);
|
||||
settingWallpaperProgressTextLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
|
||||
|
||||
giftSubtitlePaint.setColor(oldColor);
|
||||
} else {
|
||||
settingWallpaperLayout.draw(canvas);
|
||||
canvas.save();
|
||||
canvas.translate(0, settingWallpaperLayout.getHeight() + AndroidUtilities.dp(4));
|
||||
settingWallpaperProgressTextLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
} else {
|
||||
giftPremiumSubtitleLayout.draw(canvas);
|
||||
}
|
||||
} else {
|
||||
giftPremiumSubtitleLayout.draw(canvas);
|
||||
}
|
||||
canvas.restore();
|
||||
|
||||
if (giftPremiumTitleLayout == null) {
|
||||
|
@ -1163,34 +1348,39 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
}
|
||||
|
||||
y += giftPremiumSubtitleLayout.getHeight();
|
||||
y += (getHeight() - y - giftPremiumButtonLayout.getHeight() - AndroidUtilities.dp(8)) / 2f;
|
||||
int buttonH = giftPremiumButtonLayout != null ? giftPremiumButtonLayout.getHeight() : 0;
|
||||
y += (getHeight() - y - buttonH - AndroidUtilities.dp(8)) / 2f;
|
||||
|
||||
if (themeDelegate != null) {
|
||||
themeDelegate.applyServiceShaderMatrix(getMeasuredWidth(), backgroundHeight, 0, viewTop + AndroidUtilities.dp(4));
|
||||
} else {
|
||||
Theme.applyServiceShaderMatrix(getMeasuredWidth(), backgroundHeight, 0, viewTop + AndroidUtilities.dp(4));
|
||||
}
|
||||
Paint backgroundPaint = getThemedPaint(Theme.key_paint_chatActionBackground);
|
||||
canvas.drawRoundRect(giftButtonRect, AndroidUtilities.dp(16), AndroidUtilities.dp(16), backgroundPaint);
|
||||
|
||||
if (hasGradientService()) {
|
||||
canvas.drawRoundRect(giftButtonRect, AndroidUtilities.dp(16), AndroidUtilities.dp(16), Theme.chat_actionBackgroundGradientDarkenPaint);
|
||||
}
|
||||
if (giftPremiumButtonLayout != null) {
|
||||
Paint backgroundPaint = getThemedPaint(Theme.key_paint_chatActionBackground);
|
||||
canvas.drawRoundRect(giftButtonRect, AndroidUtilities.dp(16), AndroidUtilities.dp(16), backgroundPaint);
|
||||
|
||||
starsPath.rewind();
|
||||
starsPath.addRoundRect(giftButtonRect, AndroidUtilities.dp(16), AndroidUtilities.dp(16), Path.Direction.CW);
|
||||
canvas.save();
|
||||
canvas.clipPath(starsPath);
|
||||
if (getMessageObject().type != MessageObject.TYPE_SUGGEST_PHOTO) {
|
||||
starParticlesDrawable.onDraw(canvas);
|
||||
if (!starParticlesDrawable.paused) {
|
||||
if (hasGradientService()) {
|
||||
canvas.drawRoundRect(giftButtonRect, AndroidUtilities.dp(16), AndroidUtilities.dp(16), Theme.chat_actionBackgroundGradientDarkenPaint);
|
||||
}
|
||||
|
||||
if (getMessageObject().type != MessageObject.TYPE_SUGGEST_PHOTO && getMessageObject().type != MessageObject.TYPE_ACTION_WALLPAPER) {
|
||||
starsPath.rewind();
|
||||
starsPath.addRoundRect(giftButtonRect, AndroidUtilities.dp(16), AndroidUtilities.dp(16), Path.Direction.CW);
|
||||
canvas.save();
|
||||
canvas.clipPath(starsPath);
|
||||
|
||||
starParticlesDrawable.onDraw(canvas);
|
||||
if (!starParticlesDrawable.paused) {
|
||||
invalidate();
|
||||
}
|
||||
canvas.restore();
|
||||
} else {
|
||||
//TODO optimize
|
||||
invalidate();
|
||||
}
|
||||
} else {
|
||||
//TODO optimize
|
||||
invalidate();
|
||||
}
|
||||
canvas.restore();
|
||||
|
||||
if (messageObject.settingAvatar && progressToProgress != 1f) {
|
||||
progressToProgress += 16 / 150f;
|
||||
|
@ -1206,15 +1396,15 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
canvas.save();
|
||||
canvas.scale(progressToProgress, progressToProgress, giftButtonRect.centerX(), giftButtonRect.centerY());
|
||||
progressView.setSize(rad);
|
||||
progressView.setProgressColor(Theme.getColor(Theme.key_chat_serviceText));
|
||||
progressView.setProgressColor(Theme.getColor(Theme.key_chat_serviceText));
|
||||
progressView.draw(canvas, giftButtonRect.centerX(), giftButtonRect.centerY());
|
||||
canvas.restore();
|
||||
}
|
||||
if (progressToProgress != 1f){
|
||||
if (progressToProgress != 1f && giftPremiumButtonLayout != null) {
|
||||
canvas.save();
|
||||
float s = 1f - progressToProgress;
|
||||
canvas.scale(s, s, giftButtonRect.centerX(), giftButtonRect.centerY());
|
||||
canvas.translate(x, y);
|
||||
canvas.translate(x, giftButtonRect.top + AndroidUtilities.dp(8));
|
||||
giftPremiumButtonLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
@ -1398,8 +1588,13 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
|
||||
MessageObject messageObject = currentMessageObject;
|
||||
if (isButtonLayout(messageObject)) {
|
||||
float x = (getWidth() - giftRectSize) / 2f, y = textY + textHeight + AndroidUtilities.dp(12);
|
||||
AndroidUtilities.rectTmp.set(x, y, x + giftRectSize, y + giftRectSize + giftPremiumAdditionalHeight);
|
||||
float x = (getWidth() - giftRectSize) / 2f;
|
||||
float y = textY + textHeight + AndroidUtilities.dp(12);
|
||||
if (messageObject.type == MessageObject.TYPE_ACTION_WALLPAPER) {
|
||||
AndroidUtilities.rectTmp.set(x, y, x + giftRectSize, y + backgroundRectHeight);
|
||||
} else {
|
||||
AndroidUtilities.rectTmp.set(x, y, x + giftRectSize, y + giftRectSize + giftPremiumAdditionalHeight);
|
||||
}
|
||||
if (backroundRect == null) {
|
||||
backroundRect = new RectF();
|
||||
}
|
||||
|
@ -1522,7 +1717,7 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
}
|
||||
|
||||
private boolean isButtonLayout(MessageObject messageObject) {
|
||||
return messageObject != null && (messageObject.type == MessageObject.TYPE_GIFT_PREMIUM || messageObject.type == MessageObject.TYPE_SUGGEST_PHOTO);
|
||||
return messageObject != null && (messageObject.type == MessageObject.TYPE_GIFT_PREMIUM || messageObject.type == MessageObject.TYPE_SUGGEST_PHOTO || messageObject.type == MessageObject.TYPE_ACTION_WALLPAPER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -82,7 +82,6 @@ import org.telegram.PhoneFormat.PhoneFormat;
|
|||
import org.telegram.messenger.AccountInstance;
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.BuildVars;
|
||||
import org.telegram.messenger.ChatObject;
|
||||
import org.telegram.messenger.ContactsController;
|
||||
import org.telegram.messenger.DialogObject;
|
||||
|
@ -588,6 +587,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
private int y;
|
||||
private int width;
|
||||
private int height;
|
||||
private int positionFlags;
|
||||
private StaticLayout title;
|
||||
private TLRPC.KeyboardButton button;
|
||||
private TLRPC.TL_reactionCount reaction;
|
||||
|
@ -632,6 +632,10 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
}
|
||||
}
|
||||
|
||||
public boolean hasPositionFlag(int flag) {
|
||||
return (positionFlags & flag) == flag;
|
||||
}
|
||||
|
||||
private float getPressScale() {
|
||||
if (pressed && pressT != 1f) {
|
||||
pressT += (float) Math.min(40, 1000f / AndroidUtilities.screenRefreshRate) / 100f;
|
||||
|
@ -952,6 +956,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
private boolean autoPlayingMedia;
|
||||
|
||||
private ArrayList<BotButton> botButtons = new ArrayList<>();
|
||||
private Path botButtonPath = new Path();
|
||||
private float[] botButtonRadii = new float[8];
|
||||
private HashMap<String, BotButton> botButtonsByData = new HashMap<>();
|
||||
private HashMap<String, BotButton> botButtonsByPosition = new HashMap<>();
|
||||
private String botButtonsLayout;
|
||||
|
@ -4412,27 +4418,6 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
messageObject.reactionsChanged = false;
|
||||
if (currentPosition == null || ((currentPosition.flags & MessageObject.POSITION_FLAG_BOTTOM) != 0)) {
|
||||
boolean isSmall = !messageObject.shouldDrawReactionsInLayout();
|
||||
if (isSmall && messageObject.messageOwner != null && messageObject.messageOwner.reactions != null && messageObject.messageOwner.reactions.results != null) {
|
||||
int userCount = 0;
|
||||
int user2Count = 0;
|
||||
for (int i = 0; i < messageObject.messageOwner.reactions.results.size(); i++) {
|
||||
TLRPC.ReactionCount reactionCount = messageObject.messageOwner.reactions.results.get(i);
|
||||
if (reactionCount.count == 2) {
|
||||
userCount++;
|
||||
user2Count++;
|
||||
} else {
|
||||
if (reactionCount.chosen) {
|
||||
userCount++;
|
||||
} else {
|
||||
user2Count++;
|
||||
}
|
||||
}
|
||||
if (user2Count >= 2 || userCount >= 2) {
|
||||
isSmall = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentPosition != null) {
|
||||
reactionsLayoutInBubble.setMessage(groupedMessages.findPrimaryMessageObject(), !messageObject.shouldDrawReactionsInLayout(), resourcesProvider);
|
||||
} else {
|
||||
|
@ -4621,6 +4606,12 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
} else if ("telegram_message".equals(webpageType) || "photo".equals(webpageType) && webpage != null && webpage.url != null && Browser.isInternalUri(Uri.parse(webpage.url), null)) {
|
||||
drawInstantView = true;
|
||||
drawInstantViewType = 3;
|
||||
} else if ("telegram_community".equals(webpageType) || "telegram_chatlist".equals(webpageType)) {
|
||||
drawInstantView = true;
|
||||
drawInstantViewType = 14;
|
||||
} else if ("telegram_botapp".equals(webpageType)) {
|
||||
drawInstantView = true;
|
||||
drawInstantViewType = 15;
|
||||
} else if ("telegram_theme".equals(webpageType)) {
|
||||
for (int b = 0, N2 = MessageObject.getMedia(messageObject.messageOwner).webpage.attributes.size(); b < N2; b++) {
|
||||
TLRPC.TL_webPageAttributeTheme attribute = MessageObject.getMedia(messageObject.messageOwner).webpage.attributes.get(b);
|
||||
|
@ -7547,14 +7538,14 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
}
|
||||
botButtonsByData.clear();
|
||||
if (messageObject.messageOwner.reply_markup instanceof TLRPC.TL_replyInlineMarkup) {
|
||||
for (int a = 0; a < rows; a++) {
|
||||
TLRPC.TL_keyboardButtonRow row = messageObject.messageOwner.reply_markup.rows.get(a);
|
||||
int buttonsCount = row.buttons.size();
|
||||
for (int row = 0; row < rows; row++) {
|
||||
TLRPC.TL_keyboardButtonRow buttonRow = messageObject.messageOwner.reply_markup.rows.get(row);
|
||||
int buttonsCount = buttonRow.buttons.size();
|
||||
if (buttonsCount == 0) {
|
||||
continue;
|
||||
}
|
||||
int buttonWidth = (widthForButtons - AndroidUtilities.dp(5) * (buttonsCount - 1) - AndroidUtilities.dp(2)) / buttonsCount;
|
||||
for (int b = 0; b < row.buttons.size(); b++) {
|
||||
for (int column = 0; column < buttonRow.buttons.size(); column++) {
|
||||
BotButton botButton = new BotButton();
|
||||
TLRPC.TL_keyboardButtonRequestPeer button = new TLRPC.TL_keyboardButtonRequestPeer();
|
||||
button.button_id = 0;
|
||||
|
@ -7569,9 +7560,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
// ((TLRPC.TL_requestPeerTypeChat) button.peer_type).user_admin_rights.post_messages = true;
|
||||
// ((TLRPC.TL_requestPeerTypeChat) button.peer_type).premium = false;
|
||||
// botButton.button = button;
|
||||
botButton.button = row.buttons.get(b);
|
||||
botButton.button = buttonRow.buttons.get(column);
|
||||
String key = Utilities.bytesToHex(botButton.button.data);
|
||||
String position = a + "" + b;
|
||||
String position = buttonRow + "" + column;
|
||||
BotButton oldButton;
|
||||
if (oldByPosition != null) {
|
||||
oldButton = oldByPosition.get(position);
|
||||
|
@ -7587,10 +7578,22 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
}
|
||||
botButtonsByData.put(key, botButton);
|
||||
botButtonsByPosition.put(position, botButton);
|
||||
botButton.x = b * (buttonWidth + AndroidUtilities.dp(5));
|
||||
botButton.y = a * AndroidUtilities.dp(44 + 4) + AndroidUtilities.dp(2.5f);
|
||||
botButton.x = column * (buttonWidth + AndroidUtilities.dp(5));
|
||||
botButton.y = row * AndroidUtilities.dp(44 + 4) + AndroidUtilities.dp(2.5f);
|
||||
botButton.width = buttonWidth;
|
||||
botButton.height = AndroidUtilities.dp(44);
|
||||
if (column == 0) {
|
||||
botButton.positionFlags |= MessageObject.POSITION_FLAG_LEFT;
|
||||
}
|
||||
if (column == buttonRow.buttons.size() - 1) {
|
||||
botButton.positionFlags |= MessageObject.POSITION_FLAG_RIGHT;
|
||||
}
|
||||
if (row == 0) {
|
||||
botButton.positionFlags |= MessageObject.POSITION_FLAG_TOP;
|
||||
}
|
||||
if (row == rows - 1) {
|
||||
botButton.positionFlags |= MessageObject.POSITION_FLAG_BOTTOM;
|
||||
}
|
||||
CharSequence buttonText;
|
||||
TextPaint botButtonPaint = (TextPaint) getThemedPaint(Theme.key_paint_chatBotButton);
|
||||
if (botButton.button instanceof TLRPC.TL_keyboardButtonBuy && (MessageObject.getMedia(messageObject.messageOwner).flags & 4) != 0) {
|
||||
|
@ -7602,7 +7605,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
}
|
||||
botButton.title = new StaticLayout(buttonText, botButtonPaint, buttonWidth - AndroidUtilities.dp(10), Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
|
||||
botButtons.add(botButton);
|
||||
if (b == row.buttons.size() - 1) {
|
||||
if (column == buttonRow.buttons.size() - 1) {
|
||||
maxButtonsWidth = Math.max(maxButtonsWidth, botButton.x + botButton.width);
|
||||
}
|
||||
if (messageObject.isFromUser() && botButton.button instanceof TLRPC.TL_keyboardButtonUrl) {
|
||||
|
@ -7701,7 +7704,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
if (forwardedNameLayout[0] != null || replyNameLayout != null || drawNameLayout) {
|
||||
tl = tr = minRad;
|
||||
}
|
||||
if (captionLayout != null || drawCommentButton) {
|
||||
if (captionLayout != null || drawCommentButton || botButtons != null && !botButtons.isEmpty()) {
|
||||
bl = br = minRad;
|
||||
}
|
||||
if (documentAttachType == DOCUMENT_ATTACH_TYPE_DOCUMENT) {
|
||||
|
@ -8793,6 +8796,10 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
} else {
|
||||
str = LocaleController.getString("VoipGroupJoinAsLinstener", R.string.VoipGroupJoinAsLinstener);
|
||||
}
|
||||
} else if (drawInstantViewType == 14) {
|
||||
str = LocaleController.getString("ViewChatList", R.string.ViewChatList).toUpperCase();
|
||||
} else if (drawInstantViewType == 15) {
|
||||
str = LocaleController.getString(R.string.BotWebAppInstantViewOpen).toUpperCase();
|
||||
} else {
|
||||
str = LocaleController.getString("InstantView", R.string.InstantView);
|
||||
}
|
||||
|
@ -10627,7 +10634,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
invalidate();
|
||||
}
|
||||
float scale = 0.98f + 0.02f * (1f - instantButtonPressProgress);
|
||||
if (scale != 1) {
|
||||
boolean scaleRestore = scale != 1;
|
||||
if (scaleRestore) {
|
||||
canvas.save();
|
||||
canvas.scale(scale, scale, instantButtonRect.centerX(), instantButtonRect.centerY());
|
||||
}
|
||||
|
@ -10653,7 +10661,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
instantViewLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
if (scale != 1) {
|
||||
if (scaleRestore) {
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
|
@ -10697,15 +10705,28 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
canvas.scale(s, s, rect.centerX(), rect.centerY());
|
||||
}
|
||||
applyServiceShaderMatrix();
|
||||
canvas.drawRoundRect(rect, AndroidUtilities.dp(6), AndroidUtilities.dp(6), getThemedPaint(Theme.key_paint_chatActionBackground));
|
||||
Arrays.fill(botButtonRadii, AndroidUtilities.dp(Math.min(6.75f, SharedConfig.bubbleRadius)));
|
||||
if (button.hasPositionFlag(MessageObject.POSITION_FLAG_LEFT | MessageObject.POSITION_FLAG_BOTTOM)) {
|
||||
botButtonRadii[6] = botButtonRadii[7] = AndroidUtilities.dp(SharedConfig.bubbleRadius);
|
||||
}
|
||||
if (button.hasPositionFlag(MessageObject.POSITION_FLAG_RIGHT | MessageObject.POSITION_FLAG_BOTTOM)) {
|
||||
botButtonRadii[4] = botButtonRadii[5] = AndroidUtilities.dp(SharedConfig.bubbleRadius);
|
||||
}
|
||||
|
||||
botButtonPath.rewind();
|
||||
botButtonPath.addRoundRect(rect, botButtonRadii, Path.Direction.CW);
|
||||
|
||||
canvas.drawPath(botButtonPath, getThemedPaint(Theme.key_paint_chatActionBackground));
|
||||
if (hasGradientService()) {
|
||||
canvas.drawRoundRect(rect, AndroidUtilities.dp(6), AndroidUtilities.dp(6), Theme.chat_actionBackgroundGradientDarkenPaint);
|
||||
canvas.drawPath(botButtonPath, Theme.chat_actionBackgroundGradientDarkenPaint);
|
||||
}
|
||||
|
||||
boolean drawProgress = (button.button instanceof TLRPC.TL_keyboardButtonCallback || button.button instanceof TLRPC.TL_keyboardButtonGame || button.button instanceof TLRPC.TL_keyboardButtonBuy || button.button instanceof TLRPC.TL_keyboardButtonUrlAuth) && SendMessagesHelper.getInstance(currentAccount).isSendingCallback(currentMessageObject, button.button) ||
|
||||
button.button instanceof TLRPC.TL_keyboardButtonRequestGeoLocation && SendMessagesHelper.getInstance(currentAccount).isSendingCurrentLocation(currentMessageObject, button.button) ||
|
||||
button.button instanceof TLRPC.TL_keyboardButtonUrl && delegate != null && delegate.isProgressLoading(this, ChatActivity.PROGRESS_BOT_BUTTON) && delegate.getProgressLoadingBotButtonUrl(this) == button.button.url;
|
||||
|
||||
canvas.save();
|
||||
canvas.clipPath(botButtonPath);
|
||||
if (drawProgress) {
|
||||
if (button.loadingDrawable == null) {
|
||||
button.loadingDrawable = new LoadingDrawable();
|
||||
|
@ -10722,6 +10743,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
|
||||
if (button.loadingDrawable != null && (drawProgress || button.loadingDrawable.isDisappearing())) {
|
||||
rect.inset(AndroidUtilities.dpf2(.625f), AndroidUtilities.dpf2(.625f));
|
||||
button.loadingDrawable.setRadii(botButtonRadii);
|
||||
button.loadingDrawable.setBounds(rect);
|
||||
button.loadingDrawable.setColors(
|
||||
Theme.multAlpha(Theme.getColor(Theme.key_chat_serviceBackgroundSelector, resourcesProvider), 1f),
|
||||
|
@ -10739,6 +10761,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
button.selectorDrawable.setAlpha(0xFF);
|
||||
button.selectorDrawable.draw(canvas);
|
||||
}
|
||||
canvas.restore();
|
||||
|
||||
canvas.save();
|
||||
canvas.translate(button.x + addX + AndroidUtilities.dp(5), y + (AndroidUtilities.dp(44) - button.title.getLineBottom(button.title.getLineCount() - 1)) / 2);
|
||||
|
@ -13028,6 +13051,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
}
|
||||
}
|
||||
drawable.setTop((int) ((fromParent ? getY() : getTop()) + parentViewTopOffset), w, h, (int) parentViewTopOffset, blurredViewTopOffset, blurredViewBottomOffset, pinnedTop, pinnedBottom || transitionParams.changePinnedBottomProgress != 1);
|
||||
drawable.setBotButtonsBottom(currentMessageObject != null && currentMessageObject.hasInlineBotButtons());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13045,6 +13069,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
}
|
||||
}
|
||||
drawable.setTop((int) (parentViewTopOffset + offset), w, h, (int) parentViewTopOffset, blurredViewTopOffset, blurredViewBottomOffset, pinnedTop, pinnedBottom || transitionParams.changePinnedBottomProgress != 1);
|
||||
drawable.setBotButtonsBottom(currentMessageObject != null && currentMessageObject.hasInlineBotButtons());
|
||||
}
|
||||
|
||||
float transitionYOffsetForDrawables;
|
||||
|
@ -13627,6 +13652,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
}
|
||||
}
|
||||
drawable.setTop((int) (getY() + parentViewTopOffset), w, h, (int) parentViewTopOffset, blurredViewTopOffset, blurredViewBottomOffset, pinnedTop, pinnedBottom);
|
||||
drawable.setBotButtonsBottom(currentMessageObject != null && currentMessageObject.hasInlineBotButtons());
|
||||
float alpha = !mediaBackground && !pinnedBottom ? transitionParams.changePinnedBottomProgress : (1f - transitionParams.changePinnedBottomProgress);
|
||||
drawable.setAlpha((int) (255 * alpha));
|
||||
drawable.draw(canvas);
|
||||
|
@ -14230,6 +14256,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
|
||||
if (currentBackgroundDrawable != null) {
|
||||
currentBackgroundDrawable.setTop(keyboardHeight, w, h, (int) parentViewTopOffset, blurredViewTopOffset, blurredViewBottomOffset, pinnedTop, pinnedBottom);
|
||||
currentBackgroundDrawable.setBotButtonsBottom(currentMessageObject != null && currentMessageObject.hasInlineBotButtons());
|
||||
Drawable currentBackgroundShadowDrawable = currentBackgroundDrawable.getShadowDrawable();
|
||||
if (currentBackgroundShadowDrawable != null) {
|
||||
currentBackgroundShadowDrawable.setAlpha((int) (getAlpha() * 255));
|
||||
|
@ -19051,10 +19078,14 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
}
|
||||
}
|
||||
if (replyTextLayout != lastDrawnReplyTextLayout) {
|
||||
animateReplyTextLayout = lastDrawnReplyTextLayout;
|
||||
animateReplyTextOffset = lastReplyTextXOffset;
|
||||
animateOutAnimateEmojiReply = AnimatedEmojiSpan.update(AnimatedEmojiDrawable.CACHE_TYPE_MESSAGES, ChatMessageCell.this, false, animateOutAnimateEmojiReply, true, lastDrawnReplyTextLayout);
|
||||
changed = true;
|
||||
CharSequence newText = replyTextLayout != null ? replyTextLayout.getText() : null;
|
||||
CharSequence oldText = lastDrawnReplyTextLayout != null ? lastDrawnReplyTextLayout.getText() : null;
|
||||
if (!TextUtils.equals(newText, oldText)) {
|
||||
animateReplyTextLayout = lastDrawnReplyTextLayout;
|
||||
animateReplyTextOffset = lastReplyTextXOffset;
|
||||
animateOutAnimateEmojiReply = AnimatedEmojiSpan.update(AnimatedEmojiDrawable.CACHE_TYPE_MESSAGES, ChatMessageCell.this, false, animateOutAnimateEmojiReply, true, lastDrawnReplyTextLayout);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (edited && !lastDrawingEdited && timeLayout != null) {
|
||||
String editedStr = LocaleController.getString("EditedMessage", R.string.EditedMessage);
|
||||
|
@ -19323,6 +19354,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
animateDrawingTimeAlpha = false;
|
||||
transitionBotButtons.clear();
|
||||
animateButton = false;
|
||||
animateReplyTextLayout = null;
|
||||
|
||||
animateReplies = false;
|
||||
animateRepliesLayout = null;
|
||||
|
|
|
@ -610,7 +610,7 @@ public class DialogCell extends BaseCell {
|
|||
private void checkChatTheme() {
|
||||
if (message != null && message.messageOwner != null && message.messageOwner.action instanceof TLRPC.TL_messageActionSetChatTheme && lastUnreadState) {
|
||||
TLRPC.TL_messageActionSetChatTheme setThemeAction = (TLRPC.TL_messageActionSetChatTheme) message.messageOwner.action;
|
||||
ChatThemeController.getInstance(currentAccount).setDialogTheme(currentDialogId, setThemeAction.emoticon, false);
|
||||
ChatThemeController.getInstance(currentAccount).setDialogTheme(currentDialogId, setThemeAction.emoticon,false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -808,23 +808,27 @@ public class DialogCell extends BaseCell {
|
|||
}
|
||||
|
||||
private CharSequence formatArchivedDialogNames() {
|
||||
ArrayList<TLRPC.Dialog> dialogs = MessagesController.getInstance(currentAccount).getDialogs(currentDialogFolderId);
|
||||
final MessagesController messagesController = MessagesController.getInstance(currentAccount);
|
||||
ArrayList<TLRPC.Dialog> dialogs = messagesController.getDialogs(currentDialogFolderId);
|
||||
currentDialogFolderDialogsCount = dialogs.size();
|
||||
SpannableStringBuilder builder = new SpannableStringBuilder();
|
||||
for (int a = 0, N = dialogs.size(); a < N; a++) {
|
||||
TLRPC.Dialog dialog = dialogs.get(a);
|
||||
TLRPC.User currentUser = null;
|
||||
TLRPC.Chat currentChat = null;
|
||||
if (messagesController.isHiddenByUndo(dialog.id)) {
|
||||
continue;
|
||||
}
|
||||
if (DialogObject.isEncryptedDialog(dialog.id)) {
|
||||
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance(currentAccount).getEncryptedChat(DialogObject.getEncryptedChatId(dialog.id));
|
||||
TLRPC.EncryptedChat encryptedChat = messagesController.getEncryptedChat(DialogObject.getEncryptedChatId(dialog.id));
|
||||
if (encryptedChat != null) {
|
||||
currentUser = MessagesController.getInstance(currentAccount).getUser(encryptedChat.user_id);
|
||||
currentUser = messagesController.getUser(encryptedChat.user_id);
|
||||
}
|
||||
} else {
|
||||
if (DialogObject.isUserDialog(dialog.id)) {
|
||||
currentUser = MessagesController.getInstance(currentAccount).getUser(dialog.id);
|
||||
currentUser = messagesController.getUser(dialog.id);
|
||||
} else {
|
||||
currentChat = MessagesController.getInstance(currentAccount).getChat(-dialog.id);
|
||||
currentChat = messagesController.getChat(-dialog.id);
|
||||
}
|
||||
}
|
||||
String title;
|
||||
|
@ -2367,7 +2371,7 @@ public class DialogCell extends BaseCell {
|
|||
|
||||
if (!MessagesController.getInstance(currentAccount).getTopicsController().endIsReached(chat.id)) {
|
||||
MessagesController.getInstance(currentAccount).getTopicsController().preloadTopics(chat.id);
|
||||
return "Loading...";
|
||||
return LocaleController.getString("Loading", R.string.Loading);
|
||||
} else {
|
||||
return "no created topics";
|
||||
}
|
||||
|
@ -4811,6 +4815,7 @@ public class DialogCell extends BaseCell {
|
|||
|
||||
public long lastDrawnDialogId;
|
||||
public long lastDrawnMessageId;
|
||||
public boolean lastDrawnTranslated;
|
||||
public boolean lastDrawnDialogIsFolder;
|
||||
public long lastDrawnReadState;
|
||||
public int lastDrawnDraftHash;
|
||||
|
@ -4870,8 +4875,10 @@ public class DialogCell extends BaseCell {
|
|||
}
|
||||
int draftHash = draftMessage == null ? 0 : draftMessage.message.hashCode() + (draftMessage.reply_to_msg_id << 16);
|
||||
boolean hasCall = chat != null && chat.call_active && chat.call_not_empty;
|
||||
boolean translated = MessagesController.getInstance(currentAccount).getTranslateController().isTranslatingDialog(currentDialogId);
|
||||
if (lastDrawnSizeHash == sizeHash &&
|
||||
lastDrawnMessageId == messageHash &&
|
||||
lastDrawnTranslated == translated &&
|
||||
lastDrawnDialogId == currentDialogId &&
|
||||
lastDrawnDialogIsFolder == dialog.isFolder &&
|
||||
lastDrawnReadState == readHash &&
|
||||
|
@ -4914,6 +4921,7 @@ public class DialogCell extends BaseCell {
|
|||
lastTopicsCount = topicCount;
|
||||
lastDrawnPinned = drawPin;
|
||||
lastDrawnHasCall = hasCall;
|
||||
lastDrawnTranslated = translated;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ public class DialogsEmptyCell extends LinearLayout {
|
|||
this.onUtyanAnimationUpdateListener = onUtyanAnimationUpdateListener;
|
||||
}
|
||||
|
||||
public void setType(@EmptyType int value) {
|
||||
public void setType(@EmptyType int value, boolean forward) {
|
||||
if (currentType == value) {
|
||||
return;
|
||||
}
|
||||
|
@ -142,8 +142,13 @@ public class DialogsEmptyCell extends LinearLayout {
|
|||
case TYPE_FILTER_NO_CHATS_TO_DISPLAY:
|
||||
imageView.setAutoRepeat(false);
|
||||
icon = R.raw.filter_no_chats;
|
||||
help = LocaleController.getString("FilterNoChatsToDisplayInfo", R.string.FilterNoChatsToDisplayInfo);
|
||||
titleView.setText(LocaleController.getString("FilterNoChatsToDisplay", R.string.FilterNoChatsToDisplay));
|
||||
if (forward) {
|
||||
titleView.setText(LocaleController.getString("FilterNoChatsToForward", R.string.FilterNoChatsToForward));
|
||||
help = LocaleController.getString("FilterNoChatsToForwardInfo", R.string.FilterNoChatsToForwardInfo);
|
||||
} else {
|
||||
titleView.setText(LocaleController.getString("FilterNoChatsToDisplay", R.string.FilterNoChatsToDisplay));
|
||||
help = LocaleController.getString("FilterNoChatsToDisplayInfo", R.string.FilterNoChatsToDisplayInfo);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
case TYPE_FILTER_ADDING_CHATS:
|
||||
|
|
|
@ -62,7 +62,6 @@ public class DialogsHintCell extends FrameLayout {
|
|||
public void updateColors() {
|
||||
titleView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
messageView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText));
|
||||
setBackground(Theme.AdaptiveRipple.filledRect());
|
||||
}
|
||||
|
||||
public void setText(CharSequence title, CharSequence subtitle) {
|
||||
|
|
|
@ -134,7 +134,7 @@ public class DialogsRequestedEmptyCell extends LinearLayout implements Notificat
|
|||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.diceStickersDidLoad);
|
||||
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.diceStickersDidLoad);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.graphics.Canvas;
|
|||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.RectF;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.widget.FrameLayout;
|
||||
|
@ -34,11 +35,9 @@ import java.util.Set;
|
|||
public class DrawerActionCell extends FrameLayout {
|
||||
|
||||
private ImageView imageView;
|
||||
private RLottieImageView lottieImageView;
|
||||
private AnimatedTextView textView;
|
||||
private TextView textView;
|
||||
private int currentId;
|
||||
private RectF rect = new RectF();
|
||||
private int currentLottieId;
|
||||
|
||||
public DrawerActionCell(Context context) {
|
||||
super(context);
|
||||
|
@ -48,18 +47,11 @@ public class DrawerActionCell extends FrameLayout {
|
|||
addView(imageView, LayoutHelper.createFrame(24, 24, Gravity.LEFT | Gravity.TOP, 19, 12, 0, 0));
|
||||
// addView(imageView, LayoutHelper.createFrame(24, 24, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 19, 12, LocaleController.isRTL ? 19 : 0, 0));
|
||||
|
||||
lottieImageView = new RLottieImageView(context);
|
||||
lottieImageView.setAutoRepeat(false);
|
||||
lottieImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_menuItemIcon), PorterDuff.Mode.SRC_IN));
|
||||
addView(lottieImageView, LayoutHelper.createFrame(28, 28, Gravity.LEFT | Gravity.TOP, 17, 10, 0, 0));
|
||||
// addView(lottieImageView, LayoutHelper.createFrame(28, 28, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 17, 10, LocaleController.isRTL ? 17 : 0, 0));
|
||||
|
||||
textView = new AnimatedTextView(context, true, true, true);
|
||||
textView.setAnimationProperties(.6f, 0, 350, CubicBezierInterpolator.EASE_OUT_QUINT);
|
||||
textView = new TextView(context);
|
||||
textView.setTextColor(Theme.getColor(Theme.key_chats_menuItemText));
|
||||
textView.setTextSize(AndroidUtilities.dp(15));
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
|
||||
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
textView.setIgnoreRTL(true);
|
||||
textView.setGravity(Gravity.CENTER_VERTICAL);
|
||||
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 19 + 24 + 29, 0, 16, 0));
|
||||
// addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 16 : 62, 0, LocaleController.isRTL ? 62 : 16, 0));
|
||||
|
||||
|
@ -101,36 +93,20 @@ public class DrawerActionCell extends FrameLayout {
|
|||
textView.setTextColor(Theme.getColor(Theme.key_chats_menuItemText));
|
||||
}
|
||||
|
||||
public void setTextAndIcon(int id, String text, int resId, int lottieId) {
|
||||
public void setTextAndIcon(int id, String text, int resId) {
|
||||
currentId = id;
|
||||
try {
|
||||
textView.setText(text, false);
|
||||
if (lottieId != 0) {
|
||||
imageView.setImageDrawable(null);
|
||||
lottieImageView.setAnimation(currentLottieId = lottieId, 28, 28);
|
||||
} else {
|
||||
imageView.setImageResource(resId);
|
||||
lottieImageView.clearAnimationDrawable();
|
||||
currentLottieId = 0;
|
||||
}
|
||||
textView.setText(text);
|
||||
imageView.setImageResource(resId);
|
||||
} catch (Throwable e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateText(String text) {
|
||||
textView.setText(text);
|
||||
}
|
||||
|
||||
public void updateIcon(int lottieId) {
|
||||
public void updateTextAndIcon(String text, int resId) {
|
||||
try {
|
||||
if (lottieId != currentLottieId) {
|
||||
lottieImageView.setOnAnimationEndListener(() -> {
|
||||
lottieImageView.setAnimation(currentLottieId = lottieId, 28, 28);
|
||||
lottieImageView.setOnAnimationEndListener(null);
|
||||
});
|
||||
lottieImageView.playAnimation();
|
||||
}
|
||||
textView.setText(text);
|
||||
imageView.setImageResource(resId);
|
||||
} catch (Throwable e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
|
|
|
@ -135,6 +135,14 @@ public class GroupCreateUserCell extends FrameLayout {
|
|||
update(0);
|
||||
}
|
||||
|
||||
public void setForbiddenCheck(boolean forbidden) {
|
||||
checkBox.setForbidden(forbidden);
|
||||
}
|
||||
|
||||
public CheckBox2 getCheckBox() {
|
||||
return checkBox;
|
||||
}
|
||||
|
||||
public void setChecked(boolean checked, boolean animated) {
|
||||
if (checkBox != null) {
|
||||
checkBox.setChecked(checked, animated);
|
||||
|
@ -266,9 +274,9 @@ public class GroupCreateUserCell extends FrameLayout {
|
|||
if (checkBox != null) {
|
||||
((LayoutParams) checkBox.getLayoutParams()).topMargin = AndroidUtilities.dp(29) + padding;
|
||||
if (LocaleController.isRTL) {
|
||||
((LayoutParams) checkBox.getLayoutParams()).rightMargin = AndroidUtilities.dp(39) + padding;
|
||||
((LayoutParams) checkBox.getLayoutParams()).rightMargin = AndroidUtilities.dp(40) + padding;
|
||||
} else {
|
||||
((LayoutParams) checkBox.getLayoutParams()).leftMargin = AndroidUtilities.dp(45) + padding;
|
||||
((LayoutParams) checkBox.getLayoutParams()).leftMargin = AndroidUtilities.dp(40) + padding;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,9 @@ public class MemberRequestCell extends FrameLayout {
|
|||
avatarImageView.setForUserOrChat(user, avatarDrawable);
|
||||
nameTextView.setText(UserObject.getUserName(user));
|
||||
String dateText = LocaleController.formatDateAudio(importer.date, false);
|
||||
if (importer.approved_by == 0) {
|
||||
if (importer.via_chatlist) {
|
||||
statusTextView.setText(LocaleController.getString("JoinedViaFolder", R.string.JoinedViaFolder));
|
||||
} else if (importer.approved_by == 0) {
|
||||
statusTextView.setText(LocaleController.formatString("RequestedToJoinAt", R.string.RequestedToJoinAt, dateText));
|
||||
} else {
|
||||
TLRPC.User approvedByUser = users.get(importer.approved_by);
|
||||
|
|
|
@ -32,7 +32,7 @@ public class NotificationsCheckCell extends FrameLayout {
|
|||
private TextView textView;
|
||||
private TextView valueTextView;
|
||||
@SuppressWarnings("FieldCanBeLocal")
|
||||
private ImageView moveImageView;
|
||||
private ImageView imageView;
|
||||
private Switch checkBox;
|
||||
private boolean needDivider;
|
||||
private boolean drawLine = true;
|
||||
|
@ -49,24 +49,22 @@ public class NotificationsCheckCell extends FrameLayout {
|
|||
this(context, 21, 70, false, resourcesProvider);
|
||||
}
|
||||
|
||||
public NotificationsCheckCell(Context context, int padding, int height, boolean reorder) {
|
||||
this(context, padding, height, reorder, null);
|
||||
public NotificationsCheckCell(Context context, int padding, int height, boolean withImage) {
|
||||
this(context, padding, height, withImage, null);
|
||||
}
|
||||
|
||||
public NotificationsCheckCell(Context context, int padding, int height, boolean reorder, Theme.ResourcesProvider resourcesProvider) {
|
||||
public NotificationsCheckCell(Context context, int padding, int height, boolean withImage, Theme.ResourcesProvider resourcesProvider) {
|
||||
super(context);
|
||||
this.resourcesProvider = resourcesProvider;
|
||||
|
||||
setWillNotDraw(false);
|
||||
currentHeight = height;
|
||||
|
||||
if (reorder) {
|
||||
moveImageView = new ImageView(context);
|
||||
moveImageView.setFocusable(false);
|
||||
moveImageView.setScaleType(ImageView.ScaleType.CENTER);
|
||||
moveImageView.setImageResource(R.drawable.poll_reorder);
|
||||
moveImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteGrayIcon, resourcesProvider), PorterDuff.Mode.MULTIPLY));
|
||||
addView(moveImageView, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, 6, 0, 6, 0));
|
||||
if (withImage) {
|
||||
imageView = new ImageView(context);
|
||||
imageView.setFocusable(false);
|
||||
imageView.setScaleType(ImageView.ScaleType.CENTER);
|
||||
addView(imageView, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, 8, 0, 8, 0));
|
||||
}
|
||||
|
||||
textView = new TextView(context);
|
||||
|
@ -77,7 +75,7 @@ public class NotificationsCheckCell extends FrameLayout {
|
|||
textView.setSingleLine(true);
|
||||
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
|
||||
textView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 80 : (reorder ? 64 : padding), 13 + (currentHeight - 70) / 2, LocaleController.isRTL ? (reorder ? 64 : padding) : 80, 0));
|
||||
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 80 : (withImage ? 64 : padding), 13 + (currentHeight - 70) / 2, LocaleController.isRTL ? (withImage ? 64 : padding) : 80, 0));
|
||||
|
||||
valueTextView = new TextView(context);
|
||||
valueTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2, resourcesProvider));
|
||||
|
@ -88,7 +86,7 @@ public class NotificationsCheckCell extends FrameLayout {
|
|||
valueTextView.setSingleLine(true);
|
||||
valueTextView.setPadding(0, 0, 0, 0);
|
||||
valueTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 80 : (reorder ? 64 : padding), 38 + (currentHeight - 70) / 2, LocaleController.isRTL ? (reorder ? 64 : padding) : 80, 0));
|
||||
addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 80 : (withImage ? 64 : padding), 38 - (withImage ? 2 : 0) + (currentHeight - 70) / 2, LocaleController.isRTL ? (withImage ? 64 : padding) : 80, 0));
|
||||
|
||||
checkBox = new Switch(context, resourcesProvider);
|
||||
checkBox.setColors(Theme.key_switchTrack, Theme.key_switchTrackChecked, Theme.key_windowBackgroundWhite, Theme.key_windowBackgroundWhite);
|
||||
|
@ -114,13 +112,20 @@ public class NotificationsCheckCell extends FrameLayout {
|
|||
}
|
||||
|
||||
public void setTextAndValueAndCheck(String text, CharSequence value, boolean checked, int iconType, boolean multiline, boolean divider) {
|
||||
setTextAndValueAndIconAndCheck(text, value, 0, checked, iconType, multiline, divider);
|
||||
}
|
||||
|
||||
public void setTextAndValueAndIconAndCheck(String text, CharSequence value, int iconResId, boolean checked, int iconType, boolean multiline, boolean divider) {
|
||||
textView.setText(text);
|
||||
valueTextView.setText(value);
|
||||
if (imageView != null) {
|
||||
imageView.setImageResource(iconResId);
|
||||
imageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogIcon), PorterDuff.Mode.MULTIPLY));
|
||||
}
|
||||
checkBox.setChecked(checked, iconType, animationsEnabled);
|
||||
valueTextView.setVisibility(VISIBLE);
|
||||
needDivider = divider;
|
||||
isMultiline = multiline;
|
||||
|
||||
if (multiline) {
|
||||
valueTextView.setLines(0);
|
||||
valueTextView.setMaxLines(0);
|
||||
|
@ -156,7 +161,13 @@ public class NotificationsCheckCell extends FrameLayout {
|
|||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (needDivider) {
|
||||
canvas.drawLine(LocaleController.isRTL ? 0 : AndroidUtilities.dp(20), getMeasuredHeight() - 1, getMeasuredWidth() - (LocaleController.isRTL ? AndroidUtilities.dp(20) : 0), getMeasuredHeight() - 1, Theme.dividerPaint);
|
||||
canvas.drawLine(
|
||||
LocaleController.isRTL ? 0 : AndroidUtilities.dp(imageView != null ? 64 : 20),
|
||||
getMeasuredHeight() - 1,
|
||||
getMeasuredWidth() - (LocaleController.isRTL ? AndroidUtilities.dp(imageView != null ? 64 : 20) : 0),
|
||||
getMeasuredHeight() - 1,
|
||||
Theme.dividerPaint
|
||||
);
|
||||
}
|
||||
if (drawLine) {
|
||||
int x = LocaleController.isRTL ? AndroidUtilities.dp(76) : getMeasuredWidth() - AndroidUtilities.dp(76) - 1;
|
||||
|
|
|
@ -43,8 +43,8 @@ public class TextCell extends FrameLayout {
|
|||
private ImageView valueImageView;
|
||||
private int leftPadding;
|
||||
private boolean needDivider;
|
||||
private int offsetFromImage = 71;
|
||||
public int heightDp = 48;
|
||||
public int offsetFromImage = 71;
|
||||
public int heightDp = 50;
|
||||
public int imageLeft = 21;
|
||||
private boolean inDialogs;
|
||||
private boolean prioritizeTitleOverValue;
|
||||
|
@ -193,7 +193,7 @@ public class TextCell extends FrameLayout {
|
|||
if (checkBox != null) {
|
||||
checkBox.measure(MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(37), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(20), MeasureSpec.EXACTLY));
|
||||
}
|
||||
setMeasuredDimension(width, AndroidUtilities.dp(50) + (needDivider ? 1 : 0));
|
||||
setMeasuredDimension(width, height + (needDivider ? 1 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -224,16 +224,17 @@ public class TextCell extends FrameLayout {
|
|||
viewLeft = AndroidUtilities.dp(imageView.getVisibility() == VISIBLE ? offsetFromImage : leftPadding);
|
||||
}
|
||||
if (subtitleView.getVisibility() == View.VISIBLE) {
|
||||
viewTop = (height - textView.getTextHeight() - subtitleView.getTextHeight() - AndroidUtilities.dp(2)) / 2;
|
||||
int margin = heightDp > 50 ? 4 : 2;
|
||||
viewTop = (height - textView.getTextHeight() - subtitleView.getTextHeight() - AndroidUtilities.dp(margin)) / 2;
|
||||
textView.layout(viewLeft, viewTop, viewLeft + textView.getMeasuredWidth(), viewTop + textView.getMeasuredHeight());
|
||||
viewTop = viewTop + textView.getTextHeight() + AndroidUtilities.dp(2);
|
||||
viewTop = viewTop + textView.getTextHeight() + AndroidUtilities.dp(margin);
|
||||
subtitleView.layout(viewLeft, viewTop, viewLeft + subtitleView.getMeasuredWidth(), viewTop + subtitleView.getMeasuredHeight());
|
||||
} else {
|
||||
viewTop = (height - textView.getTextHeight()) / 2;
|
||||
textView.layout(viewLeft, viewTop, viewLeft + textView.getMeasuredWidth(), viewTop + textView.getMeasuredHeight());
|
||||
}
|
||||
if (imageView.getVisibility() == VISIBLE) {
|
||||
viewTop = AndroidUtilities.dp(5);
|
||||
viewTop = AndroidUtilities.dp(heightDp > 50 ? 0 : 2) + (height - imageView.getMeasuredHeight()) / 2 - imageView.getPaddingTop();
|
||||
viewLeft = !LocaleController.isRTL ? AndroidUtilities.dp(imageLeft) : width - imageView.getMeasuredWidth() - AndroidUtilities.dp(imageLeft);
|
||||
imageView.layout(viewLeft, viewTop, viewLeft + imageView.getMeasuredWidth(), viewTop + imageView.getMeasuredHeight());
|
||||
}
|
||||
|
@ -279,7 +280,7 @@ public class TextCell extends FrameLayout {
|
|||
|
||||
public void setTextAndIcon(String text, int resId, boolean divider) {
|
||||
imageLeft = 21;
|
||||
offsetFromImage = 71;
|
||||
offsetFromImage = getOffsetFromImage(false);
|
||||
textView.setText(text);
|
||||
valueTextView.setText(valueText = null, false);
|
||||
imageView.setImageResource(resId);
|
||||
|
@ -337,7 +338,7 @@ public class TextCell extends FrameLayout {
|
|||
|
||||
public void setTextAndValue(String text, String value, boolean animated, boolean divider) {
|
||||
imageLeft = 21;
|
||||
offsetFromImage = 71;
|
||||
offsetFromImage = getOffsetFromImage(false);
|
||||
textView.setText(text);
|
||||
valueTextView.setText(TextUtils.ellipsize(valueText = value, valueTextView.getPaint(), AndroidUtilities.displaySize.x / 2.5f, TextUtils.TruncateAt.END), animated);
|
||||
valueTextView.setVisibility(VISIBLE);
|
||||
|
@ -353,7 +354,7 @@ public class TextCell extends FrameLayout {
|
|||
|
||||
public void setTextAndValueAndColorfulIcon(String text, CharSequence value, boolean animated, int resId, int color, boolean divider) {
|
||||
imageLeft = 21;
|
||||
offsetFromImage = 71;
|
||||
offsetFromImage = getOffsetFromImage(false);
|
||||
textView.setText(text);
|
||||
valueTextView.setText(TextUtils.ellipsize(valueText = value, valueTextView.getPaint(), AndroidUtilities.displaySize.x / 2.5f, TextUtils.TruncateAt.END), animated);
|
||||
valueTextView.setVisibility(VISIBLE);
|
||||
|
@ -369,7 +370,7 @@ public class TextCell extends FrameLayout {
|
|||
|
||||
public void setTextAndSpoilersValueAndIcon(String text, CharSequence value, int resId, boolean divider) {
|
||||
imageLeft = 21;
|
||||
offsetFromImage = 71;
|
||||
offsetFromImage = getOffsetFromImage(false);
|
||||
textView.setText(text);
|
||||
valueSpoilersTextView.setVisibility(VISIBLE);
|
||||
valueSpoilersTextView.setText(value);
|
||||
|
@ -389,7 +390,7 @@ public class TextCell extends FrameLayout {
|
|||
|
||||
public void setTextAndSpoilersValueAndColorfulIcon(String text, CharSequence value, int resId, int color, boolean divider) {
|
||||
imageLeft = 21;
|
||||
offsetFromImage = 71;
|
||||
offsetFromImage = getOffsetFromImage(false);
|
||||
textView.setText(text);
|
||||
valueSpoilersTextView.setVisibility(VISIBLE);
|
||||
valueSpoilersTextView.setText(value);
|
||||
|
@ -409,7 +410,7 @@ public class TextCell extends FrameLayout {
|
|||
|
||||
public void setTextAndValueAndIcon(String text, String value, boolean animated, int resId, boolean divider) {
|
||||
imageLeft = 21;
|
||||
offsetFromImage = 71;
|
||||
offsetFromImage = getOffsetFromImage(false);
|
||||
textView.setText(text);
|
||||
valueTextView.setText(TextUtils.ellipsize(valueText = value, valueTextView.getPaint(), AndroidUtilities.displaySize.x / 2.5f, TextUtils.TruncateAt.END), animated);
|
||||
valueTextView.setVisibility(VISIBLE);
|
||||
|
@ -428,11 +429,10 @@ public class TextCell extends FrameLayout {
|
|||
}
|
||||
|
||||
public void setColorfulIcon(int color, int resId) {
|
||||
offsetFromImage = 65;
|
||||
offsetFromImage = getOffsetFromImage(true);
|
||||
imageView.setVisibility(VISIBLE);
|
||||
imageView.setPadding(AndroidUtilities.dp(2), AndroidUtilities.dp(2), AndroidUtilities.dp(2), AndroidUtilities.dp(2));
|
||||
imageView.setTranslationX(AndroidUtilities.dp(LocaleController.isRTL ? 0 : -3));
|
||||
imageView.setTranslationY(AndroidUtilities.dp(6));
|
||||
imageView.setImageResource(resId);
|
||||
imageView.setColorFilter(new PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN));
|
||||
imageView.setBackground(Theme.createRoundRectDrawable(AndroidUtilities.dp(9), color));
|
||||
|
@ -440,7 +440,7 @@ public class TextCell extends FrameLayout {
|
|||
|
||||
public void setTextAndCheck(CharSequence text, boolean checked, boolean divider) {
|
||||
imageLeft = 21;
|
||||
offsetFromImage = 71;
|
||||
offsetFromImage = getOffsetFromImage(false);
|
||||
textView.setText(text);
|
||||
imageView.setVisibility(GONE);
|
||||
valueImageView.setVisibility(GONE);
|
||||
|
@ -455,7 +455,7 @@ public class TextCell extends FrameLayout {
|
|||
|
||||
public void setTextAndCheckAndIcon(CharSequence text, boolean checked, int resId, boolean divider) {
|
||||
imageLeft = 21;
|
||||
offsetFromImage = 71;
|
||||
offsetFromImage = getOffsetFromImage(false);
|
||||
textView.setText(text);
|
||||
valueTextView.setVisibility(GONE);
|
||||
valueSpoilersTextView.setVisibility(GONE);
|
||||
|
@ -473,7 +473,7 @@ public class TextCell extends FrameLayout {
|
|||
|
||||
public void setTextAndCheckAndIcon(String text, boolean checked, Drawable resDrawable, boolean divider) {
|
||||
imageLeft = 21;
|
||||
offsetFromImage = 71;
|
||||
offsetFromImage = getOffsetFromImage(false);
|
||||
textView.setText(text);
|
||||
valueTextView.setVisibility(GONE);
|
||||
valueSpoilersTextView.setVisibility(GONE);
|
||||
|
@ -491,7 +491,7 @@ public class TextCell extends FrameLayout {
|
|||
|
||||
public void setTextAndValueDrawable(String text, Drawable drawable, boolean divider) {
|
||||
imageLeft = 21;
|
||||
offsetFromImage = 71;
|
||||
offsetFromImage = getOffsetFromImage(false);
|
||||
textView.setText(text);
|
||||
valueTextView.setText(valueText = null, false);
|
||||
valueImageView.setVisibility(VISIBLE);
|
||||
|
@ -507,6 +507,10 @@ public class TextCell extends FrameLayout {
|
|||
}
|
||||
}
|
||||
|
||||
protected int getOffsetFromImage(boolean colourful) {
|
||||
return colourful ? 65 : 71;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (needDivider) {
|
||||
|
|
|
@ -116,7 +116,7 @@ public class TextCheckCell extends FrameLayout {
|
|||
valueTextView.setSingleLine(true);
|
||||
valueTextView.setPadding(0, 0, 0, 0);
|
||||
valueTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 64 : padding, 36, LocaleController.isRTL ? padding : 64, 0));
|
||||
addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 70 : padding, 35, LocaleController.isRTL ? padding : 70, 0));
|
||||
|
||||
checkBox = new Switch(context, resourcesProvider);
|
||||
checkBox.setColors(Theme.key_switchTrack, Theme.key_switchTrackChecked, Theme.key_windowBackgroundWhite, Theme.key_windowBackgroundWhite);
|
||||
|
@ -160,6 +160,7 @@ public class TextCheckCell extends FrameLayout {
|
|||
public void setTextAndCheck(String text, boolean checked, boolean divider) {
|
||||
textView.setText(text);
|
||||
isMultiline = false;
|
||||
checkBox.setVisibility(View.VISIBLE);
|
||||
checkBox.setChecked(checked, attached);
|
||||
needDivider = divider;
|
||||
valueTextView.setVisibility(GONE);
|
||||
|
@ -217,6 +218,7 @@ public class TextCheckCell extends FrameLayout {
|
|||
public void setTextAndValueAndCheck(String text, String value, boolean checked, boolean multiline, boolean divider) {
|
||||
textView.setText(text);
|
||||
valueTextView.setText(value);
|
||||
checkBox.setVisibility(View.VISIBLE);
|
||||
checkBox.setChecked(checked, false);
|
||||
needDivider = divider;
|
||||
valueTextView.setVisibility(VISIBLE);
|
||||
|
@ -241,6 +243,33 @@ public class TextCheckCell extends FrameLayout {
|
|||
setWillNotDraw(!divider);
|
||||
}
|
||||
|
||||
public void setTextAndValue(String text, String value, boolean multiline, boolean divider) {
|
||||
textView.setText(text);
|
||||
valueTextView.setText(value);
|
||||
checkBox.setVisibility(View.GONE);
|
||||
needDivider = divider;
|
||||
valueTextView.setVisibility(VISIBLE);
|
||||
isMultiline = multiline;
|
||||
if (multiline) {
|
||||
valueTextView.setLines(0);
|
||||
valueTextView.setMaxLines(0);
|
||||
valueTextView.setSingleLine(false);
|
||||
valueTextView.setEllipsize(null);
|
||||
valueTextView.setPadding(0, 0, 0, AndroidUtilities.dp(11));
|
||||
} else {
|
||||
valueTextView.setLines(1);
|
||||
valueTextView.setMaxLines(1);
|
||||
valueTextView.setSingleLine(true);
|
||||
valueTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
valueTextView.setPadding(0, 0, 0, 0);
|
||||
}
|
||||
LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams();
|
||||
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.topMargin = AndroidUtilities.dp(10);
|
||||
textView.setLayoutParams(layoutParams);
|
||||
setWillNotDraw(!divider);
|
||||
}
|
||||
|
||||
public void setEnabled(boolean value, ArrayList<Animator> animators) {
|
||||
super.setEnabled(value);
|
||||
if (animators != null) {
|
||||
|
|
|
@ -61,7 +61,7 @@ public class TooManyCommunitiesHintCell extends FrameLayout {
|
|||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
paint.setColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText));
|
||||
paint.setColor(Theme.getColor(Theme.key_text_RedRegular));
|
||||
|
||||
canvas.save();
|
||||
canvas.translate(getMeasuredWidth() - textPaint.measureText(s) - AndroidUtilities.dp(8), AndroidUtilities.dpf2(7f));
|
||||
|
|
|
@ -44,7 +44,10 @@ import org.telegram.ui.WallpapersListActivity;
|
|||
|
||||
public class WallpaperCell extends FrameLayout {
|
||||
|
||||
private class WallpaperView extends FrameLayout {
|
||||
int size;
|
||||
public boolean drawStubBackground = true;
|
||||
|
||||
public class WallpaperView extends FrameLayout {
|
||||
|
||||
private BackupImageView imageView;
|
||||
private ImageView imageView2;
|
||||
|
@ -290,7 +293,7 @@ public class WallpaperCell extends FrameLayout {
|
|||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (checkBox.isChecked() || !imageView.getImageReceiver().hasBitmapImage() || imageView.getImageReceiver().getCurrentAlpha() != 1.0f) {
|
||||
if (drawStubBackground && checkBox.isChecked() || !imageView.getImageReceiver().hasBitmapImage() || imageView.getImageReceiver().getCurrentAlpha() != 1.0f) {
|
||||
canvas.drawRect(0, 0, getMeasuredWidth(), getMeasuredHeight(), backgroundPaint);
|
||||
}
|
||||
}
|
||||
|
@ -307,9 +310,13 @@ public class WallpaperCell extends FrameLayout {
|
|||
private Drawable checkDrawable;
|
||||
|
||||
public WallpaperCell(Context context) {
|
||||
this(context, 5);
|
||||
}
|
||||
|
||||
public WallpaperCell(Context context, int size) {
|
||||
super(context);
|
||||
|
||||
wallpaperViews = new WallpaperView[5];
|
||||
wallpaperViews = new WallpaperView[size];
|
||||
for (int a = 0; a < wallpaperViews.length; a++) {
|
||||
WallpaperView wallpaperView = wallpaperViews[a] = new WallpaperView(context);
|
||||
int num = a;
|
||||
|
@ -339,6 +346,11 @@ public class WallpaperCell extends FrameLayout {
|
|||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
if (spanCount == 1) {
|
||||
super.onMeasure(MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(size + AndroidUtilities.dp(6), MeasureSpec.EXACTLY));
|
||||
setPadding(0, 0, 0, AndroidUtilities.dp(6));
|
||||
return;
|
||||
}
|
||||
int width = MeasureSpec.getSize(widthMeasureSpec);
|
||||
int availableWidth = width - AndroidUtilities.dp(14 * 2 + 6 * (spanCount - 1));
|
||||
int itemWidth = availableWidth / spanCount;
|
||||
|
@ -353,6 +365,10 @@ public class WallpaperCell extends FrameLayout {
|
|||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
if (spanCount == 1) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
return;
|
||||
}
|
||||
int l = AndroidUtilities.dp(14);
|
||||
int t = isTop ? AndroidUtilities.dp(14) : 0;
|
||||
for (int a = 0; a < spanCount; a++) {
|
||||
|
@ -394,4 +410,11 @@ public class WallpaperCell extends FrameLayout {
|
|||
wallpaperViews[a].invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setSize(int itemSize) {
|
||||
if (size != itemSize) {
|
||||
this.size = itemSize;
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ public class ChangeBioActivity extends BaseFragment {
|
|||
firstNameField.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
|
||||
firstNameField.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
firstNameField.setBackgroundDrawable(null);
|
||||
firstNameField.setLineColors(getThemedColor(Theme.key_windowBackgroundWhiteInputField), getThemedColor(Theme.key_windowBackgroundWhiteInputFieldActivated), getThemedColor(Theme.key_windowBackgroundWhiteRedText3));
|
||||
firstNameField.setLineColors(getThemedColor(Theme.key_windowBackgroundWhiteInputField), getThemedColor(Theme.key_windowBackgroundWhiteInputFieldActivated), getThemedColor(Theme.key_text_RedRegular));
|
||||
firstNameField.setMaxLines(4);
|
||||
firstNameField.setPadding(AndroidUtilities.dp(LocaleController.isRTL ? 24 : 0), 0, AndroidUtilities.dp(LocaleController.isRTL ? 0 : 24), AndroidUtilities.dp(6));
|
||||
firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
|
||||
|
|
|
@ -96,7 +96,7 @@ public class ChangeNameActivity extends BaseFragment {
|
|||
firstNameField.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText, resourcesProvider));
|
||||
firstNameField.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText, resourcesProvider));
|
||||
firstNameField.setBackgroundDrawable(null);
|
||||
firstNameField.setLineColors(getThemedColor(Theme.key_windowBackgroundWhiteInputField), getThemedColor(Theme.key_windowBackgroundWhiteInputFieldActivated), getThemedColor(Theme.key_windowBackgroundWhiteRedText3));
|
||||
firstNameField.setLineColors(getThemedColor(Theme.key_windowBackgroundWhiteInputField), getThemedColor(Theme.key_windowBackgroundWhiteInputFieldActivated), getThemedColor(Theme.key_text_RedRegular));
|
||||
firstNameField.setMaxLines(1);
|
||||
firstNameField.setLines(1);
|
||||
firstNameField.setSingleLine(true);
|
||||
|
@ -127,7 +127,7 @@ public class ChangeNameActivity extends BaseFragment {
|
|||
lastNameField.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText, resourcesProvider));
|
||||
lastNameField.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText, resourcesProvider));
|
||||
lastNameField.setBackgroundDrawable(null);
|
||||
lastNameField.setLineColors(getThemedColor(Theme.key_windowBackgroundWhiteInputField), getThemedColor(Theme.key_windowBackgroundWhiteInputFieldActivated), getThemedColor(Theme.key_windowBackgroundWhiteRedText3));
|
||||
lastNameField.setLineColors(getThemedColor(Theme.key_windowBackgroundWhiteInputField), getThemedColor(Theme.key_windowBackgroundWhiteInputFieldActivated), getThemedColor(Theme.key_text_RedRegular));
|
||||
lastNameField.setMaxLines(1);
|
||||
lastNameField.setLines(1);
|
||||
lastNameField.setSingleLine(true);
|
||||
|
|
|
@ -19,6 +19,7 @@ import android.graphics.Paint;
|
|||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.Selection;
|
||||
|
@ -63,6 +64,7 @@ import org.telegram.messenger.UserConfig;
|
|||
import org.telegram.messenger.UserObject;
|
||||
import org.telegram.messenger.browser.Browser;
|
||||
import org.telegram.tgnet.ConnectionsManager;
|
||||
import org.telegram.tgnet.TLObject;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
|
@ -84,6 +86,7 @@ import org.telegram.ui.Components.LayoutHelper;
|
|||
import org.telegram.ui.Components.LinkSpanDrawable;
|
||||
import org.telegram.ui.Components.RecyclerListView;
|
||||
import org.telegram.ui.Components.TypefaceSpan;
|
||||
import org.telegram.ui.Components.URLSpanNoUnderline;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -111,6 +114,8 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
private ArrayList<TLRPC.TL_username> usernames = new ArrayList<>();
|
||||
private ArrayList<String> loadingUsernames = new ArrayList<>();
|
||||
|
||||
private long botId;
|
||||
|
||||
private final static int done_button = 1;
|
||||
|
||||
public class LinkSpan extends ClickableSpan {
|
||||
|
@ -157,6 +162,26 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
}
|
||||
}
|
||||
|
||||
public ChangeUsernameActivity() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public ChangeUsernameActivity(Bundle args) {
|
||||
super(args);
|
||||
|
||||
if (args != null) {
|
||||
botId = args.getLong("bot_id");
|
||||
}
|
||||
}
|
||||
|
||||
private long getUserId() {
|
||||
return botId != 0 ? botId : UserConfig.getInstance(currentAccount).getClientUserId();
|
||||
}
|
||||
|
||||
private TLRPC.User getUser() {
|
||||
return botId != 0 ? MessagesController.getInstance(currentAccount).getUser(botId) : UserConfig.getInstance(currentAccount).getCurrentUser();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView(Context context) {
|
||||
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
|
@ -177,9 +202,9 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
ActionBarMenu menu = actionBar.createMenu();
|
||||
doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_ab_done, AndroidUtilities.dp(56), LocaleController.getString("Done", R.string.Done));
|
||||
|
||||
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());
|
||||
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(getUserId());
|
||||
if (user == null) {
|
||||
user = UserConfig.getInstance(currentAccount).getCurrentUser();
|
||||
user = getUser();
|
||||
}
|
||||
|
||||
if (user != null) {
|
||||
|
@ -269,6 +294,10 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
return;
|
||||
}
|
||||
if (username.editable) {
|
||||
if (botId != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
listView.smoothScrollToPosition(0);
|
||||
focusUsernameField(true);
|
||||
return;
|
||||
|
@ -277,30 +306,40 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
.setTitle(username.active ? LocaleController.getString("UsernameDeactivateLink", R.string.UsernameDeactivateLink) : LocaleController.getString("UsernameActivateLink", R.string.UsernameActivateLink))
|
||||
.setMessage(username.active ? LocaleController.getString("UsernameDeactivateLinkProfileMessage", R.string.UsernameDeactivateLinkProfileMessage) : LocaleController.getString("UsernameActivateLinkProfileMessage", R.string.UsernameActivateLinkProfileMessage))
|
||||
.setPositiveButton(username.active ? LocaleController.getString("Hide", R.string.Hide) : LocaleController.getString("Show", R.string.Show), (di, e) -> {
|
||||
boolean wasActive = username.active;
|
||||
String reqUsername = username.username;
|
||||
boolean reqActive = !username.active;
|
||||
TLObject req;
|
||||
if (botId == 0) {
|
||||
TLRPC.TL_account_toggleUsername toggle = new TLRPC.TL_account_toggleUsername();
|
||||
toggle.username = reqUsername;
|
||||
toggle.active = reqActive;
|
||||
req = toggle;
|
||||
} else {
|
||||
TLRPC.TL_bots_toggleUsername toggle = new TLRPC.TL_bots_toggleUsername();
|
||||
toggle.bot = MessagesController.getInstance(currentAccount).getInputUser(botId);
|
||||
toggle.username = reqUsername;
|
||||
toggle.active = reqActive;
|
||||
req = toggle;
|
||||
}
|
||||
|
||||
TLRPC.TL_account_toggleUsername req = new TLRPC.TL_account_toggleUsername();
|
||||
req.username = username.username;
|
||||
final boolean wasActive = username.active;
|
||||
req.active = !username.active;
|
||||
getConnectionsManager().sendRequest(req, (res, err) -> {
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
loadingUsernames.remove(req.username);
|
||||
loadingUsernames.remove(reqUsername);
|
||||
if (res instanceof TLRPC.TL_boolTrue) {
|
||||
toggleUsername(position, req.active);
|
||||
toggleUsername(position, reqActive);
|
||||
} else if (err != null && "USERNAMES_ACTIVE_TOO_MUCH".equals(err.text)) {
|
||||
username.active = req.active;
|
||||
username.active = reqActive;
|
||||
toggleUsername(position, username.active);
|
||||
new AlertDialog.Builder(getContext(), getResourceProvider())
|
||||
.setTitle(LocaleController.getString("UsernameActivateErrorTitle", R.string.UsernameActivateErrorTitle))
|
||||
.setMessage(LocaleController.getString("UsernameActivateErrorMessage", R.string.UsernameActivateErrorMessage))
|
||||
.setPositiveButton(LocaleController.getString("OK", R.string.OK), (d, v) -> {
|
||||
toggleUsername(username, wasActive, true);
|
||||
})
|
||||
.setPositiveButton(LocaleController.getString("OK", R.string.OK), (d, v) -> toggleUsername(username, wasActive, true))
|
||||
.show();
|
||||
} else {
|
||||
toggleUsername(username, wasActive, true);
|
||||
}
|
||||
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());
|
||||
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(getUserId());
|
||||
getMessagesController().updateUsernameActiveness(user, username.username, username.active);
|
||||
});
|
||||
});
|
||||
|
@ -462,7 +501,7 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
ignoreCheck = false;
|
||||
break;
|
||||
case VIEW_TYPE_HEADER:
|
||||
((HeaderCell) holder.itemView).setText(position == 0 ? LocaleController.getString("SetUsernameHeader", R.string.SetUsernameHeader) : LocaleController.getString("UsernamesProfileHeader", R.string.UsernamesProfileHeader));
|
||||
((HeaderCell) holder.itemView).setText(position == 0 ? LocaleController.getString(botId != 0 ? R.string.BotSetPublicLinkHeader : R.string.SetUsernameHeader) : LocaleController.getString("UsernamesProfileHeader", R.string.UsernamesProfileHeader));
|
||||
break;
|
||||
case VIEW_TYPE_USERNAME:
|
||||
TLRPC.TL_username username = usernames.get(position - 4);
|
||||
|
@ -472,12 +511,12 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
} else if (editableUsernameCell == cell) {
|
||||
editableUsernameCell = null;
|
||||
}
|
||||
cell.set(username, position < getItemCount() - 2, false);
|
||||
cell.set(username, position < getItemCount() - 2, false, botId);
|
||||
break;
|
||||
case VIEW_TYPE_HELP1:
|
||||
break;
|
||||
case VIEW_TYPE_HELP2:
|
||||
((TextInfoPrivacyCell) holder.itemView).setText(LocaleController.getString("UsernamesProfileHelp", R.string.UsernamesProfileHelp));
|
||||
((TextInfoPrivacyCell) holder.itemView).setText(LocaleController.getString(botId != 0 ? R.string.BotUsernamesHelp : R.string.UsernamesProfileHelp));
|
||||
((TextInfoPrivacyCell) holder.itemView).setBackgroundDrawable(Theme.getThemedDrawable(getContext(), R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
|
||||
break;
|
||||
}
|
||||
|
@ -560,7 +599,6 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
return;
|
||||
}
|
||||
needReorder = false;
|
||||
TLRPC.TL_account_reorderUsernames req = new TLRPC.TL_account_reorderUsernames();
|
||||
ArrayList<String> usernames = new ArrayList<>();
|
||||
for (int i = 0; i < notEditableUsernames.size(); ++i) {
|
||||
if (notEditableUsernames.get(i).active)
|
||||
|
@ -570,7 +608,18 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
if (this.usernames.get(i).active)
|
||||
usernames.add(this.usernames.get(i).username);
|
||||
}
|
||||
req.order = usernames;
|
||||
|
||||
TLObject req;
|
||||
if (botId == 0) {
|
||||
TLRPC.TL_account_reorderUsernames reorder = new TLRPC.TL_account_reorderUsernames();
|
||||
reorder.order = usernames;
|
||||
req = reorder;
|
||||
} else {
|
||||
TLRPC.TL_bots_reorderUsernames reorder = new TLRPC.TL_bots_reorderUsernames();
|
||||
reorder.bot = MessagesController.getInstance(currentAccount).getInputUser(botId);
|
||||
reorder.order = usernames;
|
||||
req = reorder;
|
||||
}
|
||||
getConnectionsManager().sendRequest(req, (res, err) -> {
|
||||
if (res instanceof TLRPC.TL_boolTrue) {}
|
||||
});
|
||||
|
@ -582,7 +631,7 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
newUsernames.addAll(notEditableUsernames);
|
||||
newUsernames.addAll(usernames);
|
||||
|
||||
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());
|
||||
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(getUserId());
|
||||
user.usernames = newUsernames;
|
||||
MessagesController.getInstance(currentAccount).putUser(user, false, true);
|
||||
}
|
||||
|
@ -592,7 +641,7 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
|
||||
private class UsernameHelpCell extends FrameLayout {
|
||||
|
||||
private TextView text1View;
|
||||
private LinkSpanDrawable.LinksTextView text1View;
|
||||
private LinkSpanDrawable.LinksTextView text2View;
|
||||
|
||||
public UsernameHelpCell(Context context) {
|
||||
|
@ -604,7 +653,7 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
|
||||
setClipChildren(false);
|
||||
|
||||
text1View = new TextView(context);
|
||||
text1View = new LinkSpanDrawable.LinksTextView(context);
|
||||
text1View.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
|
||||
text1View.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText8));
|
||||
text1View.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
|
||||
|
@ -620,7 +669,7 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
int index = tagsString.toString().indexOf('\n');
|
||||
if (index >= 0) {
|
||||
tagsString.replace(index, index + 1, " ");
|
||||
tagsString.setSpan(new ForegroundColorSpan(getThemedColor(Theme.key_windowBackgroundWhiteRedText4)), 0, index, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
tagsString.setSpan(new ForegroundColorSpan(getThemedColor(Theme.key_text_RedRegular)), 0, index, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
TypefaceSpan[] spans = tagsString.getSpans(0, tagsString.length(), TypefaceSpan.class);
|
||||
for (int i = 0; i < spans.length; ++i) {
|
||||
|
@ -658,7 +707,20 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
addView(text1View, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP));
|
||||
addView(text2View, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP));
|
||||
|
||||
text1View.setText(AndroidUtilities.replaceTags(LocaleController.getString("UsernameHelp", R.string.UsernameHelp)));
|
||||
if (botId != 0) {
|
||||
String str = LocaleController.getString(R.string.BotUsernameHelp);
|
||||
SpannableStringBuilder text = new SpannableStringBuilder(str);
|
||||
int index1 = str.indexOf('*');
|
||||
int index2 = str.lastIndexOf('*');
|
||||
if (index1 != -1 && index2 != -1 && index1 != index2) {
|
||||
text.replace(index2, index2 + 1, "");
|
||||
text.replace(index1, index1 + 1, "");
|
||||
text.setSpan(new URLSpanNoUnderline("https://fragment.com"), index1, index2 - 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
text1View.setText(text);
|
||||
} else {
|
||||
text1View.setText(AndroidUtilities.replaceTags(LocaleController.getString(R.string.UsernameHelp)));
|
||||
}
|
||||
}
|
||||
|
||||
private Integer height;
|
||||
|
@ -710,7 +772,7 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
field.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
|
||||
field.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
field.setBackgroundDrawable(null);
|
||||
// field.setLineColors(getThemedColor(Theme.key_windowBackgroundWhiteInputField), getThemedColor(Theme.key_windowBackgroundWhiteInputFieldActivated), getThemedColor(Theme.key_windowBackgroundWhiteRedText3));
|
||||
// field.setLineColors(getThemedColor(Theme.key_windowBackgroundWhiteInputField), getThemedColor(Theme.key_windowBackgroundWhiteInputFieldActivated), getThemedColor(Theme.key_text_RedRegular));
|
||||
field.setMaxLines(1);
|
||||
field.setLines(1);
|
||||
field.setPadding(0, 0, 0, 0);
|
||||
|
@ -774,6 +836,9 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
}
|
||||
}
|
||||
});
|
||||
if (botId != 0) {
|
||||
field.setEnabled(false);
|
||||
}
|
||||
tme = new TextView(getContext());
|
||||
tme.setMaxLines(1);
|
||||
tme.setLines(1);
|
||||
|
@ -788,6 +853,11 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
content.addView(field, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, 1, Gravity.CENTER_VERTICAL, 0, 15, 21, 15));
|
||||
addView(content, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP));
|
||||
setBackgroundColor(getThemedColor(Theme.key_windowBackgroundWhite));
|
||||
|
||||
if (botId != 0) {
|
||||
field.setAlpha(0.6f);
|
||||
tme.setAlpha(0.6f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -883,6 +953,7 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
|
||||
public TLRPC.TL_username currentUsername;
|
||||
private boolean useDivider;
|
||||
private long botId;
|
||||
private AnimatedFloat useDividerAlpha = new AnimatedFloat(this, 300, CubicBezierInterpolator.DEFAULT);
|
||||
|
||||
private float activeViewTextColorT;
|
||||
|
@ -893,8 +964,13 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
private AnimatedFloat activeFloat = new AnimatedFloat(this, 400, CubicBezierInterpolator.EASE_OUT_QUINT);
|
||||
|
||||
public void set(TLRPC.TL_username username, boolean useDivider, boolean animated) {
|
||||
set(username, useDivider, animated, 0);
|
||||
}
|
||||
|
||||
public void set(TLRPC.TL_username username, boolean useDivider, boolean animated, long botId) {
|
||||
currentUsername = username;
|
||||
this.useDivider = useDivider;
|
||||
this.botId = botId;
|
||||
invalidate();
|
||||
if (currentUsername == null) {
|
||||
active = false;
|
||||
|
@ -903,7 +979,7 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
}
|
||||
|
||||
active = username.active;
|
||||
editable = username.editable;
|
||||
editable = botId == 0 && username.editable;
|
||||
updateUsername(username.username);
|
||||
if (isProfile) {
|
||||
activeView.setText(editable ? LocaleController.getString("UsernameProfileLinkEditable", R.string.UsernameProfileLinkEditable) : (active ? LocaleController.getString("UsernameProfileLinkActive", R.string.UsernameProfileLinkActive) : LocaleController.getString("UsernameProfileLinkInactive", R.string.UsernameProfileLinkInactive)), animated, !active);
|
||||
|
@ -968,7 +1044,7 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
|
||||
public void update() {
|
||||
if (currentUsername != null) {
|
||||
set(currentUsername, useDivider, true);
|
||||
set(currentUsername, useDivider, true, botId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1118,8 +1194,8 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
if (name.startsWith("_") || name.endsWith("_")) {
|
||||
if (statusTextView != null) {
|
||||
statusTextView.setText(LocaleController.getString("UsernameInvalid", R.string.UsernameInvalid));
|
||||
statusTextView.setTag(Theme.key_windowBackgroundWhiteRedText4);
|
||||
statusTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText4));
|
||||
statusTextView.setTag(Theme.key_text_RedRegular);
|
||||
statusTextView.setTextColor(Theme.getColor(Theme.key_text_RedRegular));
|
||||
if (helpCell != null) {
|
||||
helpCell.update();
|
||||
}
|
||||
|
@ -1134,8 +1210,8 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
} else {
|
||||
if (statusTextView != null) {
|
||||
statusTextView.setText(LocaleController.getString("UsernameInvalidStartNumber", R.string.UsernameInvalidStartNumber));
|
||||
statusTextView.setTag(Theme.key_windowBackgroundWhiteRedText4);
|
||||
statusTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText4));
|
||||
statusTextView.setTag(Theme.key_text_RedRegular);
|
||||
statusTextView.setTextColor(Theme.getColor(Theme.key_text_RedRegular));
|
||||
if (helpCell != null) {
|
||||
helpCell.update();
|
||||
}
|
||||
|
@ -1149,8 +1225,8 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
} else {
|
||||
if (statusTextView != null) {
|
||||
statusTextView.setText(LocaleController.getString("UsernameInvalid", R.string.UsernameInvalid));
|
||||
statusTextView.setTag(Theme.key_windowBackgroundWhiteRedText4);
|
||||
statusTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText4));
|
||||
statusTextView.setTag(Theme.key_text_RedRegular);
|
||||
statusTextView.setTextColor(Theme.getColor(Theme.key_text_RedRegular));
|
||||
if (helpCell != null) {
|
||||
helpCell.update();
|
||||
}
|
||||
|
@ -1166,8 +1242,8 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
} else {
|
||||
if (statusTextView != null) {
|
||||
statusTextView.setText(LocaleController.getString("UsernameInvalidShort", R.string.UsernameInvalidShort));
|
||||
statusTextView.setTag(Theme.key_windowBackgroundWhiteRedText4);
|
||||
statusTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText4));
|
||||
statusTextView.setTag(Theme.key_text_RedRegular);
|
||||
statusTextView.setTextColor(Theme.getColor(Theme.key_text_RedRegular));
|
||||
if (helpCell != null) {
|
||||
helpCell.update();
|
||||
}
|
||||
|
@ -1181,8 +1257,8 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
} else {
|
||||
if (statusTextView != null) {
|
||||
statusTextView.setText(LocaleController.getString("UsernameInvalidLong", R.string.UsernameInvalidLong));
|
||||
statusTextView.setTag(Theme.key_windowBackgroundWhiteRedText4);
|
||||
statusTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText4));
|
||||
statusTextView.setTag(Theme.key_text_RedRegular);
|
||||
statusTextView.setTextColor(Theme.getColor(Theme.key_text_RedRegular));
|
||||
if (helpCell != null) {
|
||||
helpCell.update();
|
||||
}
|
||||
|
@ -1192,7 +1268,7 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
}
|
||||
|
||||
if (!alert) {
|
||||
String currentName = UserConfig.getInstance(currentAccount).getCurrentUser().username;
|
||||
String currentName = getUser().username;
|
||||
if (currentName == null) {
|
||||
currentName = "";
|
||||
}
|
||||
|
@ -1238,8 +1314,8 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
if (statusTextView != null) {
|
||||
if (error != null && "USERNAME_INVALID".equals(error.text) && req.username.length() == 4) {
|
||||
statusTextView.setText(LocaleController.getString("UsernameInvalidShort", R.string.UsernameInvalidShort));
|
||||
statusTextView.setTag(Theme.key_windowBackgroundWhiteRedText4);
|
||||
statusTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText4));
|
||||
statusTextView.setTag(Theme.key_text_RedRegular);
|
||||
statusTextView.setTextColor(Theme.getColor(Theme.key_text_RedRegular));
|
||||
} else if (error != null && "USERNAME_PURCHASE_AVAILABLE".equals(error.text)) {
|
||||
if (req.username.length() == 4) {
|
||||
statusTextView.setText(LocaleController.getString("UsernameInvalidShortPurchase", R.string.UsernameInvalidShortPurchase));
|
||||
|
@ -1250,8 +1326,8 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
statusTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText8));
|
||||
} else {
|
||||
statusTextView.setText(LocaleController.getString("UsernameInUse", R.string.UsernameInUse));
|
||||
statusTextView.setTag(Theme.key_windowBackgroundWhiteRedText4);
|
||||
statusTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText4));
|
||||
statusTextView.setTag(Theme.key_text_RedRegular);
|
||||
statusTextView.setTextColor(Theme.getColor(Theme.key_text_RedRegular));
|
||||
}
|
||||
if (helpCell != null) {
|
||||
helpCell.update();
|
||||
|
@ -1268,6 +1344,10 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
}
|
||||
|
||||
private void saveName() {
|
||||
if (botId != 0) {
|
||||
finishFragment();
|
||||
return;
|
||||
}
|
||||
if (username.startsWith("@")) {
|
||||
username = username.substring(1);
|
||||
}
|
||||
|
@ -1275,7 +1355,7 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
shakeIfOff();
|
||||
return;
|
||||
}
|
||||
TLRPC.User user = UserConfig.getInstance(currentAccount).getCurrentUser();
|
||||
TLRPC.User user = getUser();
|
||||
if (getParentActivity() == null || user == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -1389,7 +1469,7 @@ public class ChangeUsernameActivity extends BaseFragment {
|
|||
|
||||
// themeDescriptions.add(new ThemeDescription(helpTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText8));
|
||||
//
|
||||
// themeDescriptions.add(new ThemeDescription(checkTextView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, null, null, null, null, Theme.key_windowBackgroundWhiteRedText4));
|
||||
// themeDescriptions.add(new ThemeDescription(checkTextView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, null, null, null, null, Theme.key_text_RedRegular));
|
||||
// themeDescriptions.add(new ThemeDescription(checkTextView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, null, null, null, null, Theme.key_windowBackgroundWhiteGreenText));
|
||||
// themeDescriptions.add(new ThemeDescription(checkTextView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText8));
|
||||
|
||||
|
|
|
@ -3118,7 +3118,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, Theme.chat_msgInCallDrawable, null, Theme.key_chat_inInstant));
|
||||
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, Theme.chat_msgInCallSelectedDrawable, null, Theme.key_chat_inInstantSelected));
|
||||
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgCallUpGreenDrawable}, null, Theme.key_chat_outGreenCall));
|
||||
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgCallDownRedDrawable}, null, Theme.key_chat_inRedCall));
|
||||
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgCallDownRedDrawable}, null, Theme.key_fill_RedNormal));
|
||||
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgCallDownGreenDrawable}, null, Theme.key_chat_inGreenCall));
|
||||
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, Theme.chat_msgErrorPaint, null, null, Theme.key_chat_sentError));
|
||||
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgErrorDrawable}, null, Theme.key_chat_sentErrorIcon));
|
||||
|
|
|
@ -666,7 +666,7 @@ public class ChannelCreateActivity extends BaseFragment implements NotificationC
|
|||
descriptionTextView.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
|
||||
descriptionTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
descriptionTextView.setBackgroundDrawable(null);
|
||||
descriptionTextView.setLineColors(getThemedColor(Theme.key_windowBackgroundWhiteInputField), getThemedColor(Theme.key_windowBackgroundWhiteInputFieldActivated), getThemedColor(Theme.key_windowBackgroundWhiteRedText3));
|
||||
descriptionTextView.setLineColors(getThemedColor(Theme.key_windowBackgroundWhiteInputField), getThemedColor(Theme.key_windowBackgroundWhiteInputFieldActivated), getThemedColor(Theme.key_text_RedRegular));
|
||||
descriptionTextView.setPadding(0, 0, 0, AndroidUtilities.dp(6));
|
||||
descriptionTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
|
||||
descriptionTextView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
|
||||
|
@ -861,7 +861,7 @@ public class ChannelCreateActivity extends BaseFragment implements NotificationC
|
|||
int index = tagsString.toString().indexOf('\n');
|
||||
if (index >= 0) {
|
||||
tagsString.replace(index, index + 1, " ");
|
||||
tagsString.setSpan(new ForegroundColorSpan(getThemedColor(Theme.key_windowBackgroundWhiteRedText4)), 0, index, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
tagsString.setSpan(new ForegroundColorSpan(getThemedColor(Theme.key_text_RedRegular)), 0, index, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
TypefaceSpan[] spans = tagsString.getSpans(0, tagsString.length(), TypefaceSpan.class);
|
||||
final String username = descriptionTextView == null || descriptionTextView.getText() == null ? "" : descriptionTextView.getText().toString();
|
||||
|
@ -953,8 +953,8 @@ public class ChannelCreateActivity extends BaseFragment implements NotificationC
|
|||
}
|
||||
if (!isPrivate && !canCreatePublic) {
|
||||
typeInfoCell.setText(LocaleController.getString("ChangePublicLimitReached", R.string.ChangePublicLimitReached));
|
||||
typeInfoCell.setTag(Theme.key_windowBackgroundWhiteRedText4);
|
||||
typeInfoCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText4));
|
||||
typeInfoCell.setTag(Theme.key_text_RedRegular);
|
||||
typeInfoCell.setTextColor(Theme.getColor(Theme.key_text_RedRegular));
|
||||
linkContainer.setVisibility(View.GONE);
|
||||
sectionCell.setVisibility(View.GONE);
|
||||
if (loadingAdminedChannels) {
|
||||
|
@ -1273,36 +1273,36 @@ public class ChannelCreateActivity extends BaseFragment implements NotificationC
|
|||
if (name != null) {
|
||||
if (name.startsWith("_") || name.endsWith("_")) {
|
||||
checkTextView.setText(LocaleController.getString("LinkInvalid", R.string.LinkInvalid));
|
||||
checkTextView.setTag(Theme.key_windowBackgroundWhiteRedText4);
|
||||
checkTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText4));
|
||||
checkTextView.setTag(Theme.key_text_RedRegular);
|
||||
checkTextView.setTextColor(Theme.getColor(Theme.key_text_RedRegular));
|
||||
return false;
|
||||
}
|
||||
for (int a = 0; a < name.length(); a++) {
|
||||
char ch = name.charAt(a);
|
||||
if (a == 0 && ch >= '0' && ch <= '9') {
|
||||
checkTextView.setText(LocaleController.getString("LinkInvalidStartNumber", R.string.LinkInvalidStartNumber));
|
||||
checkTextView.setTag(Theme.key_windowBackgroundWhiteRedText4);
|
||||
checkTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText4));
|
||||
checkTextView.setTag(Theme.key_text_RedRegular);
|
||||
checkTextView.setTextColor(Theme.getColor(Theme.key_text_RedRegular));
|
||||
return false;
|
||||
}
|
||||
if (!(ch >= '0' && ch <= '9' || ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || ch == '_')) {
|
||||
checkTextView.setText(LocaleController.getString("LinkInvalid", R.string.LinkInvalid));
|
||||
checkTextView.setTag(Theme.key_windowBackgroundWhiteRedText4);
|
||||
checkTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText4));
|
||||
checkTextView.setTag(Theme.key_text_RedRegular);
|
||||
checkTextView.setTextColor(Theme.getColor(Theme.key_text_RedRegular));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (name == null || name.length() < 4) {
|
||||
checkTextView.setText(LocaleController.getString("LinkInvalidShort", R.string.LinkInvalidShort));
|
||||
checkTextView.setTag(Theme.key_windowBackgroundWhiteRedText4);
|
||||
checkTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText4));
|
||||
checkTextView.setTag(Theme.key_text_RedRegular);
|
||||
checkTextView.setTextColor(Theme.getColor(Theme.key_text_RedRegular));
|
||||
return false;
|
||||
}
|
||||
if (name.length() > 32) {
|
||||
checkTextView.setText(LocaleController.getString("LinkInvalidLong", R.string.LinkInvalidLong));
|
||||
checkTextView.setTag(Theme.key_windowBackgroundWhiteRedText4);
|
||||
checkTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText4));
|
||||
checkTextView.setTag(Theme.key_text_RedRegular);
|
||||
checkTextView.setTextColor(Theme.getColor(Theme.key_text_RedRegular));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1325,7 +1325,7 @@ public class ChannelCreateActivity extends BaseFragment implements NotificationC
|
|||
} else {
|
||||
if (error != null && "USERNAME_INVALID".equals(error.text) && req.username.length() == 4) {
|
||||
checkTextView.setText(LocaleController.getString("UsernameInvalidShort", R.string.UsernameInvalidShort));
|
||||
checkTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText4));
|
||||
checkTextView.setTextColor(Theme.getColor(Theme.key_text_RedRegular));
|
||||
} else if (error != null && "USERNAME_PURCHASE_AVAILABLE".equals(error.text)) {
|
||||
if (req.username.length() == 4) {
|
||||
checkTextView.setText(LocaleController.getString("UsernameInvalidShortPurchase", R.string.UsernameInvalidShortPurchase));
|
||||
|
@ -1334,11 +1334,11 @@ public class ChannelCreateActivity extends BaseFragment implements NotificationC
|
|||
}
|
||||
checkTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText8));
|
||||
} else if (error != null && "CHANNELS_ADMIN_PUBLIC_TOO_MUCH".equals(error.text)) {
|
||||
checkTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText4));
|
||||
checkTextView.setTextColor(Theme.getColor(Theme.key_text_RedRegular));
|
||||
canCreatePublic = false;
|
||||
showPremiumIncreaseLimitDialog();
|
||||
} else {
|
||||
checkTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText4));
|
||||
checkTextView.setTextColor(Theme.getColor(Theme.key_text_RedRegular));
|
||||
checkTextView.setText(LocaleController.getString("LinkInUse", R.string.LinkInUse));
|
||||
}
|
||||
lastNameAvailable = false;
|
||||
|
@ -1425,13 +1425,13 @@ public class ChannelCreateActivity extends BaseFragment implements NotificationC
|
|||
themeDescriptions.add(new ThemeDescription(headerCell2, 0, new Class[]{HeaderCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlueHeader));
|
||||
themeDescriptions.add(new ThemeDescription(editText, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
||||
themeDescriptions.add(new ThemeDescription(editText, ThemeDescription.FLAG_HINTTEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteHintText));
|
||||
themeDescriptions.add(new ThemeDescription(checkTextView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, null, null, null, null, Theme.key_windowBackgroundWhiteRedText4));
|
||||
themeDescriptions.add(new ThemeDescription(checkTextView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, null, null, null, null, Theme.key_text_RedRegular));
|
||||
themeDescriptions.add(new ThemeDescription(checkTextView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText8));
|
||||
themeDescriptions.add(new ThemeDescription(checkTextView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, null, null, null, null, Theme.key_windowBackgroundWhiteGreenText));
|
||||
|
||||
themeDescriptions.add(new ThemeDescription(typeInfoCell, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{TextInfoPrivacyCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow));
|
||||
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(typeInfoCell, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_text_RedRegular));
|
||||
|
||||
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));
|
||||
|
|
|
@ -113,6 +113,7 @@ import androidx.viewpager.widget.PagerAdapter;
|
|||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
||||
import com.google.android.exoplayer2.util.Log;
|
||||
import com.google.zxing.common.detector.MathUtils;
|
||||
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
|
@ -736,6 +737,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
private Matrix skeletonOutlineMatrix = new Matrix();
|
||||
private LinearGradient skeletonOutlineGradient;
|
||||
private boolean chatListViewAttached;
|
||||
public boolean forceDisallowApplyWallpeper;
|
||||
public boolean forceDisallowRedrawThemeDescriptions;
|
||||
|
||||
{
|
||||
skeletonOutlinePaint.setStyle(Paint.Style.STROKE);
|
||||
|
@ -1157,6 +1160,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
}
|
||||
|
||||
public ThemeDelegate createThemeDelegate() {
|
||||
return new ThemeDelegate();
|
||||
}
|
||||
|
||||
private interface ChatActivityDelegate {
|
||||
default void openReplyMessage(int mid) {
|
||||
|
||||
|
@ -1296,7 +1303,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
wasManualScroll = true;
|
||||
boolean result = true;
|
||||
if (!actionBar.isActionModeShowed() && (reportType < 0 || (view instanceof ChatActionCell && (((ChatActionCell) view).getMessageObject().messageOwner.action instanceof TLRPC.TL_messageActionSetMessagesTTL) || ((view instanceof ChatActionCell) && ((ChatActionCell) view).getMessageObject().type == MessageObject.TYPE_SUGGEST_PHOTO)))) {
|
||||
boolean showMenu = true;
|
||||
if (view instanceof ChatActionCell) {
|
||||
ChatActionCell actionCell = (ChatActionCell) view;
|
||||
showMenu = actionCell.getMessageObject().messageOwner.action instanceof TLRPC.TL_messageActionSetMessagesTTL || actionCell.getMessageObject().type == MessageObject.TYPE_SUGGEST_PHOTO || actionCell.getMessageObject().isWallpaperAction();
|
||||
}
|
||||
if (!actionBar.isActionModeShowed() && (reportType < 0 || showMenu)) {
|
||||
result = createMenu(view, false, true, x, y);
|
||||
} else {
|
||||
boolean outside = false;
|
||||
|
@ -1433,6 +1445,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
presentFragment(calendarActivity);
|
||||
return;
|
||||
}
|
||||
if (view instanceof ChatActionCell && ((ChatActionCell) view).getMessageObject() != null && ((ChatActionCell) view).getMessageObject().messageOwner.action instanceof TLRPC.TL_messageActionSetSameChatWallPaper) {
|
||||
int messageId = ((ChatActionCell) view).getMessageObject().getReplyMsgId();
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
scrollToMessageId(messageId, 0, true, 0, true, 0);
|
||||
}, 16);
|
||||
return;
|
||||
}
|
||||
if (actionBar.isActionModeShowed() || reportType >= 0) {
|
||||
boolean outside = false;
|
||||
if (view instanceof ChatMessageCell) {
|
||||
|
@ -2372,7 +2391,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
|
||||
if (chatMode == 0) {
|
||||
if (userId != 0 && currentUser.bot) {
|
||||
getMediaDataController().loadBotInfo(userId, userId, true, classGuid);
|
||||
AndroidUtilities.runOnUIThread(()-> getMediaDataController().loadBotInfo(userId, userId, true, classGuid));
|
||||
} else if (chatInfo instanceof TLRPC.TL_chatFull) {
|
||||
for (int a = 0; a < chatInfo.participants.participants.size(); a++) {
|
||||
TLRPC.ChatParticipant participant = chatInfo.participants.participants.get(a);
|
||||
|
@ -3306,12 +3325,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (currentChat != null && !isTopic) {
|
||||
viewAsTopics = headerItem.lazilyAddSubItem(view_as_topics, R.drawable.msg_topics, LocaleController.getString("TopicViewAsTopics", R.string.TopicViewAsTopics));
|
||||
}
|
||||
if (themeDelegate.isThemeChangeAvailable()) {
|
||||
headerItem.lazilyAddSubItem(change_colors, R.drawable.msg_colors, LocaleController.getString("SetWallpapers", R.string.SetWallpapers));
|
||||
}
|
||||
if (!isTopic) {
|
||||
clearHistoryItem = headerItem.lazilyAddSubItem(clear_history, R.drawable.msg_clear, LocaleController.getString("ClearHistory", R.string.ClearHistory));
|
||||
}
|
||||
if (themeDelegate.isThemeChangeAvailable()) {
|
||||
headerItem.lazilyAddSubItem(change_colors, R.drawable.msg_colors, LocaleController.getString("ChangeColors", R.string.ChangeColors));
|
||||
}
|
||||
boolean addedSettings = false;
|
||||
if (!isTopic) {
|
||||
if (ChatObject.isChannel(currentChat) && !currentChat.creator) {
|
||||
|
@ -3328,7 +3347,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
} else if (currentUser != null && currentUser.bot) {
|
||||
headerItem.lazilyAddSubItem(bot_settings, R.drawable.msg_settings_old, LocaleController.getString("BotSettings", R.string.BotSettings));
|
||||
addedSettings = true;
|
||||
headerItem.lazilyAddSubItem(delete_chat, R.drawable.msg_block2, LocaleController.getString(R.string.DeleteAndBlock)).setColors(getThemedColor(Theme.key_dialogTextRed), getThemedColor(Theme.key_dialogTextRed));
|
||||
headerItem.lazilyAddSubItem(delete_chat, R.drawable.msg_block2, LocaleController.getString(R.string.DeleteAndBlock)).setColors(getThemedColor(Theme.key_text_RedRegular), getThemedColor(Theme.key_text_RedRegular));
|
||||
} else {
|
||||
headerItem.lazilyAddSubItem(delete_chat, R.drawable.msg_delete, LocaleController.getString("DeleteChatUser", R.string.DeleteChatUser));
|
||||
}
|
||||
|
@ -3400,7 +3419,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
contentView.setOccupyStatusBar(false);
|
||||
}
|
||||
|
||||
contentView.setBackgroundImage(Theme.getCachedWallpaper(), Theme.isWallpaperMotion());
|
||||
updateBackground();
|
||||
|
||||
emptyViewContainer = null;
|
||||
|
||||
|
@ -5004,19 +5023,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
return super.createAccessibilityNodeInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
if (invalidated && slidingView == null) {
|
||||
return;
|
||||
}
|
||||
invalidated = true;
|
||||
super.invalidate();
|
||||
contentView.invalidateBlur();
|
||||
if (selectionReactionsOverlay != null && selectionReactionsOverlay.isVisible()) {
|
||||
selectionReactionsOverlay.invalidatePosition();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
|
@ -6703,6 +6709,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
bottomOverlayStartButton.setOnClickListener(v -> bottomOverlayChatText.callOnClick());
|
||||
bottomOverlayChat.addView(bottomOverlayStartButton, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.CENTER, 8, 8, 8, 8));
|
||||
|
||||
if (currentUser != null && currentUser.bot && !UserObject.isReplyUser(currentUser) && !isInScheduleMode()) {
|
||||
bottomOverlayStartButton.setVisibility(View.VISIBLE);
|
||||
bottomOverlayChat.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
bottomOverlayChatText = new UnreadCounterTextView(context) {
|
||||
@Override
|
||||
protected void updateCounter() {
|
||||
|
@ -7212,11 +7223,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
contentView.addView(topChatPanelView, index, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 50, Gravity.TOP | Gravity.LEFT));
|
||||
|
||||
reportSpamButton = new TextView(getContext());
|
||||
reportSpamButton.setTextColor(getThemedColor(Theme.key_chat_reportSpam));
|
||||
reportSpamButton.setTextColor(getThemedColor(Theme.key_text_RedBold));
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
reportSpamButton.setBackground(Theme.createSelectorDrawable(getThemedColor(Theme.key_chat_reportSpam) & 0x19ffffff, 3));
|
||||
reportSpamButton.setBackground(Theme.createSelectorDrawable(getThemedColor(Theme.key_text_RedBold) & 0x19ffffff, 3));
|
||||
}
|
||||
reportSpamButton.setTag(Theme.key_chat_reportSpam);
|
||||
reportSpamButton.setTag(Theme.key_text_RedBold);
|
||||
reportSpamButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
reportSpamButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
reportSpamButton.setSingleLine(true);
|
||||
|
@ -7383,6 +7394,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
|
||||
createTopPanel();
|
||||
if (topChatPanelView == null) {
|
||||
return;
|
||||
}
|
||||
translateButton = new TranslateButton(getContext(), this, themeDelegate) {
|
||||
@Override
|
||||
protected void onButtonClick() {
|
||||
|
@ -8449,7 +8463,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
showDialog(dialog);
|
||||
TextView button = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE);
|
||||
if (button != null) {
|
||||
button.setTextColor(getThemedColor(Theme.key_dialogTextRed));
|
||||
button.setTextColor(getThemedColor(Theme.key_text_RedBold));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8623,11 +8637,19 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
|
||||
boolean animateProgressViewTo;
|
||||
|
||||
private Boolean liteModeChat;
|
||||
private boolean getLiteModeChat() {
|
||||
if (liteModeChat == null) {
|
||||
liteModeChat = LiteMode.isEnabled(LiteMode.FLAGS_CHAT);
|
||||
}
|
||||
return liteModeChat;
|
||||
}
|
||||
|
||||
private void showProgressView(boolean show) {
|
||||
if (progressView == null) {
|
||||
return;
|
||||
}
|
||||
if (DISABLE_PROGRESS_VIEW && !AndroidUtilities.isTablet() && !isComments && currentUser == null && LiteMode.isEnabled(LiteMode.FLAGS_CHAT)) {
|
||||
if (DISABLE_PROGRESS_VIEW && !AndroidUtilities.isTablet() && !isComments && currentUser == null && getLiteModeChat()) {
|
||||
animateProgressViewTo = show;
|
||||
return;
|
||||
}
|
||||
|
@ -9330,7 +9352,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
return;
|
||||
}
|
||||
if (chatAttachAlert == null) {
|
||||
chatAttachAlert = new ChatAttachAlert(getParentActivity(), this, false, false, themeDelegate) {
|
||||
chatAttachAlert = new ChatAttachAlert(getParentActivity(), this, false, false, true, themeDelegate) {
|
||||
@Override
|
||||
public void dismissInternal() {
|
||||
if (chatAttachAlert != null && chatAttachAlert.isShowing()) {
|
||||
|
@ -10555,7 +10577,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
|
||||
@Override
|
||||
public boolean dismissDialogOnPause(Dialog dialog) {
|
||||
return dialog != chatAttachAlert && super.dismissDialogOnPause(dialog);
|
||||
return dialog != chatAttachAlert && dialog != chatThemeBottomSheet && super.dismissDialogOnPause(dialog);
|
||||
}
|
||||
|
||||
private void searchLinks(final CharSequence charSequence, final boolean force) {
|
||||
|
@ -12014,13 +12036,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
inlineUpdate2();
|
||||
}
|
||||
getMessagesController().markDialogAsRead(dialog_id, minMessageId[0], minMessageId[0], maxDate[0], false, threadId, 0, true, scheduledRead);
|
||||
if (isTopic) {
|
||||
if (isTopic && replyOriginalChat != null) {
|
||||
getMessagesStorage().updateRepliesMaxReadId(replyOriginalChat.id, replyOriginalMessageId, Math.max(maxPositiveUnreadId, replyMaxReadId), 0, true);
|
||||
}
|
||||
firstUnreadSent = true;
|
||||
}
|
||||
}
|
||||
if (threadId != 0 && maxPositiveUnreadId > 0 && replyMaxReadId != maxPositiveUnreadId) {
|
||||
if (threadId != 0 && maxPositiveUnreadId > 0 && replyMaxReadId != maxPositiveUnreadId && replyOriginalChat != null) {
|
||||
replyMaxReadId = maxPositiveUnreadId;
|
||||
getMessagesStorage().updateRepliesMaxReadId(replyOriginalChat.id, replyOriginalMessageId, replyMaxReadId, newUnreadMessageCount, true);
|
||||
if (!isTopic) {
|
||||
|
@ -12178,7 +12200,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
for (int i = chatLayoutManager.findFirstVisibleItemPosition(); i <= end; i++) {
|
||||
if (i >= chatAdapter.messagesStartRow && i < chatAdapter.messagesEndRow) {
|
||||
MessageObject messageObject = messages.get(i - chatAdapter.messagesStartRow);
|
||||
if (messageObject.getId() == 0) {
|
||||
if (messageObject.getId() == 0 || messageObject.isSponsored()) {
|
||||
continue;
|
||||
}
|
||||
scrollFromIndex = i - chatAdapter.messagesStartRow;
|
||||
|
@ -13711,6 +13733,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
Drawable drawable = themeDelegate.getWallpaperDrawable();
|
||||
return drawable != null ? drawable : super.getNewDrawable();
|
||||
}
|
||||
|
||||
protected boolean getNewDrawableMotion() {
|
||||
if (themeDelegate.wallpaper == null) {
|
||||
return super.getNewDrawableMotion();
|
||||
}
|
||||
return themeDelegate.wallpaper.settings != null && themeDelegate.wallpaper.settings.motion;
|
||||
}
|
||||
};
|
||||
|
||||
private void updateSecretStatus() {
|
||||
|
@ -13792,8 +13821,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (mentionContainer != null && mentionContainer.getAdapter() != null) {
|
||||
mentionContainer.getAdapter().onRequestPermissionsResultFragment(requestCode, permissions, grantResults);
|
||||
}
|
||||
if (requestCode == BasePermissionsActivity.REQUEST_CODE_EXTERNAL_STORAGE && chatAttachAlert != null) {
|
||||
chatAttachAlert.getPhotoLayout().checkStorage();
|
||||
if (requestCode == BasePermissionsActivity.REQUEST_CODE_EXTERNAL_STORAGE) {
|
||||
if (chatAttachAlert != null) {
|
||||
chatAttachAlert.getPhotoLayout().checkStorage();
|
||||
}
|
||||
if (chatThemeBottomSheet != null && chatThemeBottomSheet.chatAttachAlert != null) {
|
||||
chatThemeBottomSheet.chatAttachAlert.getPhotoLayout().checkStorage();
|
||||
}
|
||||
} else if ((requestCode == BasePermissionsActivity.REQUEST_CODE_ATTACH_CONTACT || requestCode == 30) && chatAttachAlert != null) {
|
||||
chatAttachAlert.onRequestPermissionsResultFragment(requestCode, permissions, grantResults);
|
||||
} else if ((requestCode == 17 || requestCode == 18) && chatAttachAlert != null) {
|
||||
|
@ -13902,7 +13936,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
return 2;
|
||||
} else if (messageObject.type == 6) {
|
||||
return -1;
|
||||
} else if (messageObject.type == 10 || messageObject.type == MessageObject.TYPE_ACTION_PHOTO || messageObject.type == MessageObject.TYPE_SUGGEST_PHOTO) {
|
||||
} else if (messageObject.type == 10 || messageObject.type == MessageObject.TYPE_ACTION_PHOTO || messageObject.type == MessageObject.TYPE_SUGGEST_PHOTO || messageObject.isWallpaperAction()) {
|
||||
if (messageObject.getId() == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -14406,7 +14440,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
|
||||
int type = getMessageType(message);
|
||||
|
||||
if (type < 2 || type == 20 || type == MessageObject.TYPE_SUGGEST_PHOTO) {
|
||||
if (type < 2 || type == 20 || type == MessageObject.TYPE_SUGGEST_PHOTO || (message != null && message.isWallpaperAction())) {
|
||||
return;
|
||||
}
|
||||
addToSelectedMessages(message, outside);
|
||||
|
@ -15045,7 +15079,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
|
||||
private boolean isSkeletonVisible() {
|
||||
if (justCreatedTopic || justCreatedChat || currentUser != null || chatListView == null || !SharedConfig.animationsEnabled() || !LiteMode.isEnabled(LiteMode.FLAGS_CHAT)) {
|
||||
if (justCreatedTopic || justCreatedChat || currentUser != null || chatListView == null || !SharedConfig.animationsEnabled() || !getLiteModeChat()) {
|
||||
return false;
|
||||
}
|
||||
int childHeight = 0;
|
||||
|
@ -16175,6 +16209,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
|
||||
bottomOverlayChat.setVisibility(View.GONE);
|
||||
chatActivityEnterView.setVisibility(View.VISIBLE);
|
||||
chatActivityEnterView.setBotInfo(botInfo);
|
||||
}
|
||||
}
|
||||
} else if (id == NotificationCenter.invalidateMotionBackground) {
|
||||
|
@ -16840,7 +16875,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
}
|
||||
checkGroupCallJoin((Boolean) args[3]);
|
||||
checkThemeEmoticon();
|
||||
checkThemeEmoticonOrWallpaper();
|
||||
if (pendingRequestsDelegate != null) {
|
||||
pendingRequestsDelegate.setChatInfo(chatInfo, true);
|
||||
}
|
||||
|
@ -17908,7 +17943,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
Long uid = (Long) args[0];
|
||||
if (currentUser != null && currentUser.id == uid) {
|
||||
userInfo = (TLRPC.UserFull) args[1];
|
||||
checkThemeEmoticon();
|
||||
checkThemeEmoticonOrWallpaper();
|
||||
if (chatActivityEnterView != null) {
|
||||
chatActivityEnterView.checkChannelRights();
|
||||
chatActivityEnterView.updateGiftButton(true);
|
||||
|
@ -17952,7 +17987,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
} else if (id == NotificationCenter.didSetNewWallpapper) {
|
||||
if (fragmentView != null) {
|
||||
contentView.setBackgroundImage(Theme.getCachedWallpaper(), Theme.isWallpaperMotion());
|
||||
updateBackground();
|
||||
progressView2.invalidate();
|
||||
if (emptyView != null) {
|
||||
emptyView.invalidate();
|
||||
|
@ -18097,7 +18132,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (chatThemeBottomSheet != null) {
|
||||
chatThemeBottomSheet.setupLightDarkTheme(theme.isDark());
|
||||
} else {
|
||||
themeDelegate.setCurrentTheme(themeDelegate.chatTheme, true, theme.isDark());
|
||||
themeDelegate.setCurrentTheme(themeDelegate.chatTheme, themeDelegate.wallpaper, true, null);
|
||||
}
|
||||
}
|
||||
} else if (id == NotificationCenter.chatAvailableReactionsUpdated) {
|
||||
|
@ -18797,10 +18832,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
|
||||
private void rotateMotionBackgroundDrawable() {
|
||||
if (themeDelegate == null) {
|
||||
return;
|
||||
}
|
||||
Drawable wallpaper = themeDelegate.getWallpaperDrawable();
|
||||
if (fragmentView != null) {
|
||||
wallpaper = ((SizeNotifierFrameLayout) fragmentView).getBackgroundImage();
|
||||
}
|
||||
if (wallpaper instanceof ChatBackgroundDrawable) {
|
||||
wallpaper = ((ChatBackgroundDrawable) wallpaper).getDrawable();
|
||||
}
|
||||
if (wallpaper instanceof MotionBackgroundDrawable) {
|
||||
((MotionBackgroundDrawable) wallpaper).switchToNextPosition();
|
||||
}
|
||||
|
@ -18831,15 +18872,19 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (!isAd) {
|
||||
isAd = messageObject.isSponsored();
|
||||
}
|
||||
if (messageObject.getId() > 0 && messageObject.type == MessageObject.TYPE_SUGGEST_PHOTO) {
|
||||
if (messageObject.getId() > 0 && (messageObject.type == MessageObject.TYPE_SUGGEST_PHOTO || messageObject.type == MessageObject.TYPE_ACTION_WALLPAPER)) {
|
||||
for (int i = 0; i < messages.size(); i++) {
|
||||
if (messages.get(i).type == MessageObject.TYPE_SUGGEST_PHOTO && messages.get(i).getId() < 0) {
|
||||
int type = messageObject.type;
|
||||
if (messages.get(i).type == type && messages.get(i).getId() < 0) {
|
||||
messagesDict[0].remove(messages.get(i).getId());
|
||||
messagesDict[0].put(messageObject.getId(), messageObject);
|
||||
messageObject.stableId = messages.get(i).stableId;
|
||||
PhotoUtilities.replacePhotoImagesInCache(currentAccount, messages.get(i).messageOwner.action.photo, messageObject.messageOwner.action.photo);
|
||||
if (type == MessageObject.TYPE_ACTION_WALLPAPER) {
|
||||
messageObject.messageOwner.action.wallpaper = messages.get(i).messageOwner.action.wallpaper;
|
||||
} else if (type == MessageObject.TYPE_SUGGEST_PHOTO) {
|
||||
PhotoUtilities.replacePhotoImagesInCache(currentAccount, messages.get(i).messageOwner.action.photo, messageObject.messageOwner.action.photo);
|
||||
}
|
||||
messages.set(i, messageObject);
|
||||
|
||||
chatAdapter.notifyItemChanged(chatAdapter.messagesStartRow + i);
|
||||
break;
|
||||
}
|
||||
|
@ -20535,6 +20580,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
} else {
|
||||
showBottomOverlayProgress(false, true);
|
||||
if (userBlocked) {
|
||||
bottomOverlayStartButton.setVisibility(View.GONE);
|
||||
if (currentUser.bot) {
|
||||
bottomOverlayChatText.setText(LocaleController.getString("BotUnblock", R.string.BotUnblock));
|
||||
} else {
|
||||
|
@ -20745,6 +20791,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
|
||||
bottomOverlayChat.setVisibility(View.GONE);
|
||||
chatActivityEnterView.setVisibility(View.VISIBLE);
|
||||
chatActivityEnterView.setBotInfo(botInfo);
|
||||
}
|
||||
checkRaiseSensors();
|
||||
}
|
||||
|
@ -20799,7 +20846,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
alertView.setVisibility(View.GONE);
|
||||
alertView.setBackgroundResource(R.drawable.blockpanel);
|
||||
alertView.getBackground().setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_topPanelBackground), PorterDuff.Mode.MULTIPLY));
|
||||
contentView.addView(alertView, 9, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 50, Gravity.TOP | Gravity.LEFT));
|
||||
int index = 9;
|
||||
if (topChatPanelView != null && topChatPanelView.getParent() == contentView) {
|
||||
index = Math.max(index, contentView.indexOfChild(topChatPanelView) + 1);
|
||||
}
|
||||
if (pinnedMessageView != null && pinnedMessageView.getParent() == contentView) {
|
||||
index = Math.max(index, contentView.indexOfChild(pinnedMessageView) + 1);
|
||||
}
|
||||
contentView.addView(alertView, index, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 50, Gravity.TOP | Gravity.LEFT));
|
||||
|
||||
alertNameTextView = new TextView(getContext());
|
||||
alertNameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
|
@ -21988,11 +22042,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
if (reportSpamButton != null) {
|
||||
reportSpamButton.setTag(R.id.object_tag, null);
|
||||
reportSpamButton.setTextColor(getThemedColor(Theme.key_chat_reportSpam));
|
||||
reportSpamButton.setTextColor(getThemedColor(Theme.key_text_RedBold));
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
Theme.setSelectorDrawableColor(reportSpamButton.getBackground(), getThemedColor(Theme.key_chat_reportSpam) & 0x19ffffff, true);
|
||||
Theme.setSelectorDrawableColor(reportSpamButton.getBackground(), getThemedColor(Theme.key_text_RedBold) & 0x19ffffff, true);
|
||||
}
|
||||
reportSpamButton.setTag(Theme.key_chat_reportSpam);
|
||||
reportSpamButton.setTag(Theme.key_text_RedBold);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23119,7 +23173,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
selectedMessagesIds[a].clear();
|
||||
}
|
||||
hideActionMode();
|
||||
updatePinnedMessageView(true);
|
||||
// updatePinnedMessageView(true);
|
||||
|
||||
MessageObject.GroupedMessages groupedMessages;
|
||||
if (searchGroup) {
|
||||
|
@ -23559,7 +23613,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
if (!selectedObject.isSponsored() && chatMode != MODE_SCHEDULED && (!selectedObject.needDrawBluredPreview() || selectedObject.hasExtendedMediaPreview()) &&
|
||||
!selectedObject.isLiveLocation() && selectedObject.type != MessageObject.TYPE_PHONE_CALL && !noforwards &&
|
||||
selectedObject.type != MessageObject.TYPE_GIFT_PREMIUM && selectedObject.type != MessageObject.TYPE_SUGGEST_PHOTO) {
|
||||
selectedObject.type != MessageObject.TYPE_GIFT_PREMIUM && selectedObject.type != MessageObject.TYPE_SUGGEST_PHOTO && !selectedObject.isWallpaperAction()) {
|
||||
items.add(LocaleController.getString("Forward", R.string.Forward));
|
||||
options.add(OPTION_FORWARD);
|
||||
icons.add(R.drawable.msg_forward);
|
||||
|
@ -23726,7 +23780,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
} else {
|
||||
isReactionsAvailable = !message.isSecretMedia() && !isSecretChat() && !isInScheduleMode() && message.isReactionsAvailable() && (chatInfo != null && !(chatInfo.available_reactions instanceof TLRPC.TL_chatReactionsNone) || (chatInfo == null && !ChatObject.isChannel(currentChat)) || currentUser != null) && !availableReacts.isEmpty();
|
||||
}
|
||||
boolean showMessageSeen = !isReactionsViewAvailable && !isInScheduleMode() && currentChat != null && message.isOutOwner() && message.isSent() && !message.isEditing() && !message.isSending() && !message.isSendError() && !message.isContentUnread() && !message.isUnread() && (ConnectionsManager.getInstance(currentAccount).getCurrentTime() - message.messageOwner.date < getMessagesController().chatReadMarkExpirePeriod) && (ChatObject.isMegagroup(currentChat) || !ChatObject.isChannel(currentChat)) && !ChatObject.isForum(currentChat) && chatInfo != null && chatInfo.participants_count <= getMessagesController().chatReadMarkSizeThreshold && !(message.messageOwner.action instanceof TLRPC.TL_messageActionChatJoinedByRequest) && (v instanceof ChatMessageCell);
|
||||
boolean showMessageSeen = !isReactionsViewAvailable && !isInScheduleMode() && currentChat != null && message.isOutOwner() && message.isSent() && !message.isEditing() && !message.isSending() && !message.isSendError() && !message.isContentUnread() && !message.isUnread() && (ConnectionsManager.getInstance(currentAccount).getCurrentTime() - message.messageOwner.date < getMessagesController().chatReadMarkExpirePeriod) && (ChatObject.isMegagroup(currentChat) || !ChatObject.isChannel(currentChat)) && chatInfo != null && chatInfo.participants_count <= getMessagesController().chatReadMarkSizeThreshold && !(message.messageOwner.action instanceof TLRPC.TL_messageActionChatJoinedByRequest) && (v instanceof ChatMessageCell);
|
||||
boolean showSponsorInfo = selectedObject != null && selectedObject.isSponsored() && (selectedObject.sponsoredInfo != null || selectedObject.sponsoredAdditionalInfo != null);
|
||||
|
||||
int flags = 0;
|
||||
|
@ -24184,7 +24238,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
popupLayout.addView(rateTranscriptionLayout, rateTranscriptionLayoutParams);
|
||||
}
|
||||
|
||||
final boolean translateButtonEnabled = MessagesController.getInstance(currentAccount).getTranslateController().isContextTranslateEnabled();
|
||||
if (selectedObject != null && selectedObject.isSponsored()) {
|
||||
if (selectedObject.sponsoredInfo != null || selectedObject.sponsoredAdditionalInfo != null) {
|
||||
LinearLayout linearLayout = new LinearLayout(getParentActivity());
|
||||
|
@ -24325,6 +24378,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
processSelectedOption(options.get(i));
|
||||
});
|
||||
if (option == OPTION_TRANSLATE) {
|
||||
final boolean translateEnabled = getMessagesController().getTranslateController().isContextTranslateEnabled();
|
||||
String toLangDefault = LocaleController.getInstance().getCurrentLocale().getLanguage();
|
||||
String toLang = TranslateAlert2.getToLanguage();
|
||||
final CharSequence finalMessageText = messageTextToTranslate;
|
||||
|
@ -24333,7 +24387,33 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
return true;
|
||||
};
|
||||
TLRPC.InputPeer inputPeer = selectedObject != null && (selectedObject.isPoll() || selectedObject.isVoiceTranscriptionOpen() || selectedObject.isSponsored()) ? null : getMessagesController().getInputPeer(dialog_id);
|
||||
if (LanguageDetector.hasSupport()) {
|
||||
if (selectedObject != null && selectedObject.messageOwner != null && selectedObject.messageOwner.originalLanguage != null) {
|
||||
waitForLangDetection.set(false);
|
||||
String fromLang = selectedObject.messageOwner.originalLanguage;
|
||||
cell.setVisibility(
|
||||
fromLang != null && (!fromLang.equals(toLang) || !fromLang.equals(toLangDefault) || fromLang.equals(TranslateController.UNKNOWN_LANGUAGE)) && (
|
||||
translateEnabled && !RestrictedLanguagesSelectActivity.getRestrictedLanguages().contains(fromLang) ||
|
||||
(currentChat != null && (currentChat.has_link || ChatObject.isPublic(currentChat)) || selectedObject.messageOwner.fwd_from != null) && ("uk".equals(fromLang) || "ru".equals(fromLang))
|
||||
) ? View.VISIBLE : View.GONE
|
||||
);
|
||||
cell.setOnClickListener(e -> {
|
||||
if (selectedObject == null || i >= options.size() || getParentActivity() == null) {
|
||||
return;
|
||||
}
|
||||
String toLangValue = fromLang != null && fromLang.equals(toLang) ? toLangDefault : toLang;
|
||||
ArrayList<TLRPC.MessageEntity> entities = selectedObject != null && selectedObject.messageOwner != null ? selectedObject.messageOwner.entities : null;
|
||||
TranslateAlert2 alert = TranslateAlert2.showAlert(getParentActivity(), this, currentAccount, inputPeer, messageIdToTranslate[0], fromLang, toLangValue, finalMessageText, entities, noforwards, onLinkPress, () -> dimBehindView(false));
|
||||
alert.setDimBehind(false);
|
||||
closeMenu(false);
|
||||
|
||||
int hintCount = MessagesController.getNotificationsSettings(currentAccount).getInt("dialog_show_translate_count" + getDialogId(), 5);
|
||||
if (hintCount > 0) {
|
||||
hintCount--;
|
||||
MessagesController.getNotificationsSettings(currentAccount).edit().putInt("dialog_show_translate_count" + getDialogId(), hintCount).apply();
|
||||
updateTopPanel(true);
|
||||
}
|
||||
});
|
||||
} else if (LanguageDetector.hasSupport()) {
|
||||
final String[] fromLang = {null};
|
||||
cell.setVisibility(View.GONE);
|
||||
waitForLangDetection.set(true);
|
||||
|
@ -24342,7 +24422,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
(String lang) -> {
|
||||
fromLang[0] = lang;
|
||||
if (fromLang[0] != null && (!fromLang[0].equals(toLang) || !fromLang[0].equals(toLangDefault) || fromLang[0].equals(TranslateController.UNKNOWN_LANGUAGE)) && (
|
||||
translateButtonEnabled && !RestrictedLanguagesSelectActivity.getRestrictedLanguages().contains(fromLang[0]) ||
|
||||
translateEnabled && !RestrictedLanguagesSelectActivity.getRestrictedLanguages().contains(fromLang[0]) ||
|
||||
(currentChat != null && (currentChat.has_link || ChatObject.isPublic(currentChat)) || selectedObject.messageOwner.fwd_from != null) && ("uk".equals(fromLang[0]) || "ru".equals(fromLang[0]))
|
||||
)) {
|
||||
cell.setVisibility(View.VISIBLE);
|
||||
|
@ -24384,7 +24464,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
onLangDetectionDone.getAndSet(null).run();
|
||||
}
|
||||
}, 250);
|
||||
} else if (translateButtonEnabled) {
|
||||
} else if (translateEnabled) {
|
||||
cell.setOnClickListener(e -> {
|
||||
if (selectedObject == null || i >= options.size() || getParentActivity() == null) {
|
||||
return;
|
||||
|
@ -24669,7 +24749,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
scrimPopupContainerLayout.setMaxHeight(totalHeight - popupY);
|
||||
ReactionsContainerLayout finalReactionsLayout = reactionsLayout;
|
||||
Runnable showMenu = () -> {
|
||||
if (scrimPopupWindow == null || fragmentView == null || scrimPopupWindow.isShowing()) {
|
||||
if (scrimPopupWindow == null || fragmentView == null || scrimPopupWindow.isShowing() || !AndroidUtilities.isActivityRunning(getParentActivity())) {
|
||||
return;
|
||||
}
|
||||
scrimPopupWindow.showAtLocation(chatListView, Gravity.LEFT | Gravity.TOP, finalPopupX, finalPopupY);
|
||||
|
@ -27095,7 +27175,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
if (forceAlert || AndroidUtilities.shouldShowUrlInAlert(url)) {
|
||||
if (type == 0 || type == 2) {
|
||||
AlertsCreator.showOpenUrlAlert(ChatActivity.this, url, true, true, true, makeProgressForLink(cell, span), themeDelegate);
|
||||
boolean forceNotInternalForApps = false;
|
||||
if (span instanceof URLSpanReplacement && (((URLSpanReplacement) span).getTextStyleRun().flags & TextStyleSpan.FLAG_STYLE_TEXT_URL) != 0) {
|
||||
forceNotInternalForApps = true;
|
||||
}
|
||||
AlertsCreator.showOpenUrlAlert(ChatActivity.this, url, true, true, true, forceNotInternalForApps, makeProgressForLink(cell, span), themeDelegate);
|
||||
} else if (type == 1) {
|
||||
AlertsCreator.showOpenUrlAlert(ChatActivity.this, url, true, true, false, makeProgressForLink(cell, span), themeDelegate);
|
||||
}
|
||||
|
@ -27572,6 +27656,21 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
TLRPC.PhotoSize photoSize = FileLoader.getClosestPhotoSizeWithSize(message.photoThumbs, 640);
|
||||
TLRPC.VideoSize videoSize = null;
|
||||
TLRPC.VideoSize emojiMarkup = null;
|
||||
if (cell.getMessageObject().type == MessageObject.TYPE_ACTION_WALLPAPER) {
|
||||
|
||||
MessagesController messagesController = MessagesController.getInstance(currentAccount);
|
||||
if (message.getId() < 0 && messagesController.uploadingWallpaper != null && TextUtils.equals(message.messageOwner.action.wallpaper.uploadingImage, messagesController.uploadingWallpaper)) {
|
||||
messagesController.cancelUploadWallpaper();
|
||||
removeMessageObject(message);
|
||||
return;
|
||||
}
|
||||
if (cell.hasButton()) {
|
||||
ThemePreviewActivity.showFor(ChatActivity.this, message);
|
||||
} else {
|
||||
showChatThemeBottomSheet();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (message.messageOwner.action.photo.video_sizes != null && !message.messageOwner.action.photo.video_sizes.isEmpty()) {
|
||||
videoSize = FileLoader.getClosestVideoSizeWithSize(message.messageOwner.action.photo.video_sizes, 1000);
|
||||
emojiMarkup = FileLoader.getEmojiMarkup(message.messageOwner.action.photo.video_sizes);
|
||||
|
@ -29621,19 +29720,23 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
showDialog(new JoinGroupAlert(getContext(), messageObject.sponsoredChatInvite, messageObject.sponsoredChatInviteHash, ChatActivity.this, themeDelegate));
|
||||
} else {
|
||||
long peerId = MessageObject.getPeerId(messageObject.messageOwner.from_id);
|
||||
if (peerId < 0) {
|
||||
args.putLong("chat_id", -peerId);
|
||||
if (peerId == getDialogId() && messageObject.sponsoredChannelPost != 0) {
|
||||
scrollToMessageId(messageObject.sponsoredChannelPost, 0, true, 0, false, 0);
|
||||
} else {
|
||||
args.putLong("user_id", peerId);
|
||||
}
|
||||
if (messageObject.sponsoredChannelPost != 0) {
|
||||
args.putInt("message_id", messageObject.sponsoredChannelPost);
|
||||
}
|
||||
if (messageObject.botStartParam != null) {
|
||||
args.putString("inline_query", messageObject.botStartParam);
|
||||
}
|
||||
if (getMessagesController().checkCanOpenChat(args, ChatActivity.this)) {
|
||||
presentFragment(new ChatActivity(args));
|
||||
if (peerId < 0) {
|
||||
args.putLong("chat_id", -peerId);
|
||||
} else {
|
||||
args.putLong("user_id", peerId);
|
||||
}
|
||||
if (messageObject.sponsoredChannelPost != 0) {
|
||||
args.putInt("message_id", messageObject.sponsoredChannelPost);
|
||||
}
|
||||
if (messageObject.botStartParam != null) {
|
||||
args.putString("inline_query", messageObject.botStartParam);
|
||||
}
|
||||
if (getMessagesController().checkCanOpenChat(args, ChatActivity.this)) {
|
||||
presentFragment(new ChatActivity(args));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (messageObject.messageOwner.media != null && messageObject.messageOwner.media.webpage != null) {
|
||||
|
@ -30006,6 +30109,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
|
||||
@Override
|
||||
public ArrayList<ThemeDescription> getThemeDescriptions() {
|
||||
if (forceDisallowRedrawThemeDescriptions) {
|
||||
return null;
|
||||
}
|
||||
if (isPauseOnThemePreview) {
|
||||
isPauseOnThemePreview = false;
|
||||
return null;
|
||||
|
@ -30078,6 +30184,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
if (contentView != null) {
|
||||
contentView.invalidateBlurredViews();
|
||||
contentView.invalidateBackground();
|
||||
}
|
||||
if (parentLayout != null && parentLayout.getDrawerLayoutContainer() != null) {
|
||||
parentLayout.getDrawerLayoutContainer().setBehindKeyboardColor(getThemedColor(Theme.key_windowBackgroundWhite));
|
||||
|
@ -30085,6 +30192,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (suggestEmojiPanel != null) {
|
||||
suggestEmojiPanel.updateColors();
|
||||
}
|
||||
if (avatarContainer != null && avatarContainer.getTimeItem() != null) {
|
||||
avatarContainer.getTimeItem().invalidate();
|
||||
}
|
||||
if (translateButton != null) {
|
||||
translateButton.updateColors();
|
||||
}
|
||||
};
|
||||
ArrayList<ThemeDescription> themeDescriptions = new ArrayList<>();
|
||||
|
||||
|
@ -30213,7 +30326,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, Theme.chat_msgInCallDrawable, null, Theme.key_chat_inInstant));
|
||||
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, Theme.chat_msgInCallSelectedDrawable, null, Theme.key_chat_inInstantSelected));
|
||||
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgCallUpGreenDrawable}, null, Theme.key_chat_outGreenCall));
|
||||
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgCallDownRedDrawable}, null, Theme.key_chat_inRedCall));
|
||||
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgCallDownRedDrawable}, null, Theme.key_fill_RedNormal));
|
||||
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgCallDownGreenDrawable}, null, Theme.key_chat_inGreenCall));
|
||||
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, Theme.chat_msgErrorPaint, null, null, Theme.key_chat_sentError));
|
||||
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgErrorDrawable}, null, Theme.key_chat_sentErrorIcon));
|
||||
|
@ -30477,7 +30590,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
themeDescriptions.add(new ThemeDescription(alertView, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_chat_topPanelBackground));
|
||||
themeDescriptions.add(new ThemeDescription(pinnedMessageView, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_chat_topPanelBackground));
|
||||
themeDescriptions.add(new ThemeDescription(addToContactsButton, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_addContact));
|
||||
themeDescriptions.add(new ThemeDescription(reportSpamButton, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, null, null, null, null, Theme.key_chat_reportSpam));
|
||||
themeDescriptions.add(new ThemeDescription(reportSpamButton, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, null, null, null, null, Theme.key_text_RedBold));
|
||||
themeDescriptions.add(new ThemeDescription(reportSpamButton, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, null, null, null, null, Theme.key_chat_addContact));
|
||||
|
||||
themeDescriptions.add(new ThemeDescription(replyLineView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_chat_replyPanelLine));
|
||||
|
@ -30853,29 +30966,37 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
}
|
||||
|
||||
private void checkThemeEmoticon() {
|
||||
if (!fragmentOpened) {
|
||||
return;
|
||||
}
|
||||
String emoticon = null;
|
||||
if (userInfo != null) {
|
||||
emoticon = userInfo.theme_emoticon;
|
||||
}
|
||||
if (emoticon == null && chatInfo != null) {
|
||||
emoticon = chatInfo.theme_emoticon;
|
||||
}
|
||||
setChatThemeEmoticon(emoticon);
|
||||
private void checkThemeEmoticonOrWallpaper() {
|
||||
getNotificationCenter().doOnIdle(() -> {
|
||||
String emoticon = null;
|
||||
if (userInfo != null) {
|
||||
emoticon = userInfo.theme_emoticon;
|
||||
}
|
||||
if (emoticon == null && chatInfo != null) {
|
||||
emoticon = chatInfo.theme_emoticon;
|
||||
}
|
||||
setChatThemeEmoticon(emoticon);
|
||||
});
|
||||
}
|
||||
|
||||
private void setChatThemeEmoticon(final String emoticon) {
|
||||
if (themeDelegate == null) {
|
||||
return;
|
||||
}
|
||||
ChatThemeController.getInstance(currentAccount).setDialogTheme(dialog_id, emoticon, false);
|
||||
if (!TextUtils.isEmpty(emoticon)) {
|
||||
ChatThemeController.requestChatTheme(emoticon, result -> {
|
||||
themeDelegate.setCurrentTheme(result, openAnimationStartTime != 0, null);
|
||||
themeDelegate.setCurrentTheme(result, themeDelegate.wallpaper,openAnimationStartTime != 0, null);
|
||||
});
|
||||
} else {
|
||||
themeDelegate.setCurrentTheme(null, openAnimationStartTime != 0, null);
|
||||
}
|
||||
TLRPC.WallPaper wallPaper = null;
|
||||
if (dialog_id >= 0) {
|
||||
TLRPC.UserFull userFull = getMessagesController().getUserFull(dialog_id);
|
||||
if (userFull != null) {
|
||||
wallPaper = userFull.wallpaper;
|
||||
}
|
||||
}
|
||||
themeDelegate.setCurrentTheme(themeDelegate.chatTheme, wallPaper, openAnimationStartTime != 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30895,7 +31016,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
return drawable != null ? drawable : super.getThemedDrawable(drawableKey);
|
||||
}
|
||||
|
||||
private Paint getThemedPaint(String paintKey) {
|
||||
@Override
|
||||
public Paint getThemedPaint(String paintKey) {
|
||||
Paint paint = themeDelegate.getPaint(paintKey);
|
||||
return paint != null ? paint : Theme.getThemePaint(paintKey);
|
||||
}
|
||||
|
@ -30923,6 +31045,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
private HashMap<String, Integer> currentColors = new HashMap<>();
|
||||
private HashMap<String, Integer> animatingColors;
|
||||
private EmojiThemes chatTheme;
|
||||
private TLRPC.WallPaper wallpaper;
|
||||
private Drawable backgroundDrawable;
|
||||
private ValueAnimator patternIntensityAnimator;
|
||||
private Bitmap serviceBitmap;
|
||||
|
@ -30945,9 +31068,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
boolean setup = false;
|
||||
if (isThemeChangeAvailable()) {
|
||||
chatTheme = ChatThemeController.getInstance(currentAccount).getDialogTheme(dialog_id);
|
||||
if (chatTheme != null) {
|
||||
wallpaper = ChatThemeController.getInstance(currentAccount).getDialogWallpaper(dialog_id);
|
||||
if (chatTheme != null || wallpaper != null) {
|
||||
setup = true;
|
||||
setupChatTheme(chatTheme, false, true);
|
||||
setupChatTheme(chatTheme, wallpaper, false, true);
|
||||
}
|
||||
}
|
||||
if (!setup && ThemeEditorView.getInstance() == null) {
|
||||
|
@ -30967,15 +31091,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
|
||||
@Override
|
||||
public Integer getColor(String key) {
|
||||
if (chatTheme == null) {
|
||||
return Theme.getColor(key);
|
||||
}
|
||||
if (animatingColors != null) {
|
||||
Integer color = animatingColors.get(key);
|
||||
if (color != null) {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
if (chatTheme == null && backgroundDrawable == null) {
|
||||
return Theme.getColor(key);
|
||||
}
|
||||
Integer color = currentColors.get(key);
|
||||
if (color == null) {
|
||||
if (Theme.key_chat_outBubbleGradient1.equals(key) || Theme.key_chat_outBubbleGradient2.equals(key) || Theme.key_chat_outBubbleGradient3.equals(key)) {
|
||||
|
@ -30994,6 +31118,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
}
|
||||
}
|
||||
if (color == null && chatTheme == null) {
|
||||
return Theme.getColor(key);
|
||||
}
|
||||
if (color == null) {
|
||||
if (chatTheme != null) {
|
||||
color = Theme.getDefaultColor(key);
|
||||
|
@ -31008,7 +31135,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
|
||||
public Integer getCurrentColor(String key, boolean ignoreAnimation) {
|
||||
if (chatTheme == null) {
|
||||
if (chatTheme == null && backgroundDrawable == null) {
|
||||
return Theme.getColorOrNull(key);
|
||||
}
|
||||
Integer color = null;
|
||||
|
@ -31018,6 +31145,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (color == null) {
|
||||
color = currentColors.get(key);
|
||||
}
|
||||
if (color == null && chatTheme == null) {
|
||||
return Theme.getColorOrNull(key);
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
|
@ -31030,7 +31160,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
|
||||
@Override
|
||||
public void applyServiceShaderMatrix(int w, int h, float translationX, float translationY) {
|
||||
if (chatTheme == null || serviceBitmap == null || serviceShader == null) {
|
||||
if (backgroundDrawable == null || serviceBitmap == null || serviceShader == null) {
|
||||
ChatActionCell.ThemeDelegate.super.applyServiceShaderMatrix(w, h, translationX, translationY);
|
||||
} else {
|
||||
if (useSourceShader) {
|
||||
|
@ -31043,12 +31173,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
|
||||
@Override
|
||||
public int getCurrentColor() {
|
||||
return chatTheme != null ? currentColor : Theme.currentColor;
|
||||
return backgroundDrawable != null ? currentColor : Theme.currentColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGradientService() {
|
||||
return chatTheme != null ? serviceShader != null : Theme.hasGradientService();
|
||||
return backgroundDrawable != null ? serviceShader != null : Theme.hasGradientService();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -31058,7 +31188,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
|
||||
@Override
|
||||
public Paint getPaint(String paintKey) {
|
||||
return chatTheme != null ? currentPaints.get(paintKey) : null;
|
||||
return chatTheme != null || backgroundDrawable != null ? currentPaints.get(paintKey) : null;
|
||||
}
|
||||
|
||||
public boolean isThemeChangeAvailable() {
|
||||
|
@ -31079,23 +31209,28 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
return chatTheme != null ? false : Theme.isWallpaperMotion();
|
||||
}
|
||||
|
||||
public void setCurrentTheme(final EmojiThemes chatTheme, boolean animated, Boolean forceDark) {
|
||||
public void setCurrentTheme(final EmojiThemes chatTheme, TLRPC.WallPaper newWallpaper, boolean animated, Boolean forceDark) {
|
||||
setCurrentTheme(chatTheme, newWallpaper, animated, forceDark, false);
|
||||
}
|
||||
public void setCurrentTheme(final EmojiThemes chatTheme, TLRPC.WallPaper newWallpaper, boolean animated, Boolean forceDark, boolean force) {
|
||||
if (parentLayout == null) {
|
||||
return;
|
||||
}
|
||||
final EmojiThemes prevTheme = this.chatTheme;
|
||||
boolean newIsDark = forceDark != null ? forceDark : Theme.getActiveTheme().isDark();
|
||||
boolean newIsDark = forceDark != null ? forceDark : this.isDark;//Theme.getActiveTheme().isDark();
|
||||
String newEmoticon = chatTheme != null ? chatTheme.getEmoticon() : null;
|
||||
String oldEmoticon = this.chatTheme != null ? this.chatTheme.getEmoticon() : null;
|
||||
if (!isThemeChangeAvailable() || (TextUtils.equals(oldEmoticon, newEmoticon) && this.isDark == newIsDark)) {
|
||||
TLRPC.WallPaper oldWallpaper = this.wallpaper;
|
||||
if (!force && (!isThemeChangeAvailable() || (TextUtils.equals(oldEmoticon, newEmoticon) && this.isDark == newIsDark && ChatThemeController.equals(newWallpaper, oldWallpaper)))) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.isDark = newIsDark;
|
||||
|
||||
Theme.ThemeInfo currentTheme = newIsDark ? Theme.getCurrentNightTheme() : Theme.getCurrentTheme();
|
||||
ActionBarLayout.ThemeAnimationSettings animationSettings = new ActionBarLayout.ThemeAnimationSettings(currentTheme, currentTheme.currentAccentId, currentTheme.isDark(), !animated);
|
||||
|
||||
if (this.chatTheme == null) {
|
||||
if (this.chatTheme == null && wallpaper == null) {
|
||||
Drawable background = Theme.getCachedWallpaperNonBlocking();
|
||||
drawServiceGradient = background instanceof MotionBackgroundDrawable;
|
||||
initServiceMessageColors(background);
|
||||
|
@ -31103,8 +31238,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
startServiceLinkColor = drawServiceGradient ? 0xffffffff : Theme.getColor(Theme.key_chat_serviceLink);
|
||||
startServiceButtonColor = drawServiceGradient ? 0xffffffff : Theme.getColor(Theme.key_chat_serviceLink);
|
||||
startServiceIconColor = drawServiceGradient ? 0xffffffff : Theme.getColor(Theme.key_chat_serviceIcon);
|
||||
} else if (drawServiceGradient) {
|
||||
} else if (drawServiceGradient && backgroundDrawable instanceof MotionBackgroundDrawable) {
|
||||
startServiceBitmap = ((MotionBackgroundDrawable) backgroundDrawable).getBitmap();
|
||||
} else if (backgroundDrawable != null){
|
||||
initServiceMessageColors(backgroundDrawable);
|
||||
}
|
||||
startServiceColor = currentServiceColor;
|
||||
startServiceTextColor = drawServiceGradient ? 0xffffffff : getCurrentColorOrDefault(Theme.key_chat_serviceText, true);
|
||||
|
@ -31112,7 +31249,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
startServiceButtonColor = drawServiceGradient ? 0xffffffff : getCurrentColorOrDefault(Theme.key_chat_serviceLink, true);
|
||||
startServiceIconColor = drawServiceGradient ? 0xffffffff : getCurrentColorOrDefault(Theme.key_chat_serviceIcon, true);
|
||||
|
||||
if (chatTheme != null) {
|
||||
if (chatTheme != null || newWallpaper != null) {
|
||||
int[] colors = AndroidUtilities.calcDrawableColor(backgroundDrawable);
|
||||
currentColor = colors[0];
|
||||
initDrawables();
|
||||
|
@ -31121,8 +31258,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
|
||||
animationSettings.applyTheme = false;
|
||||
animationSettings.afterStartDescriptionsAddedRunnable = () -> {
|
||||
setupChatTheme(chatTheme, animated, false);
|
||||
setupChatTheme(chatTheme, newWallpaper, animated, true);
|
||||
initServiceMessageColors(backgroundDrawable);
|
||||
//updateBackground();
|
||||
contentView.invalidateBackground();
|
||||
};
|
||||
if (animated) {
|
||||
animationSettings.animationProgress = new ActionBarLayout.ThemeAnimationSettings.onAnimationProgress() {
|
||||
|
@ -31153,8 +31292,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
};
|
||||
} else {
|
||||
if (contentView != null) {
|
||||
contentView.setBackgroundImage(Theme.getCachedWallpaper(), Theme.isWallpaperMotion());
|
||||
updateBackground();
|
||||
}
|
||||
animationSettings.afterStartDescriptionsAddedRunnable.run();
|
||||
}
|
||||
animationSettings.onlyTopFragment = true;
|
||||
animationSettings.resourcesProvider = this;
|
||||
|
@ -31165,8 +31305,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
}
|
||||
|
||||
private void setupChatTheme(EmojiThemes chatTheme, boolean withAnimation, boolean createNewResources) {
|
||||
private void setupChatTheme(EmojiThemes chatTheme, TLRPC.WallPaper wallPaper, boolean withAnimation, boolean createNewResources) {
|
||||
this.chatTheme = chatTheme;
|
||||
this.wallpaper = wallPaper;
|
||||
|
||||
Drawable prevDrawable = null;
|
||||
if (fragmentView != null) {
|
||||
|
@ -31175,18 +31316,18 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
final MotionBackgroundDrawable prevMotionDrawable = (prevDrawable instanceof MotionBackgroundDrawable) ? (MotionBackgroundDrawable) prevDrawable : null;
|
||||
final int prevPhase = prevMotionDrawable != null ? prevMotionDrawable.getPhase() : 0;
|
||||
|
||||
if (chatTheme == null || chatTheme.showAsDefaultStub) {
|
||||
if ((chatTheme == null || chatTheme.showAsDefaultStub) && wallPaper == null) {
|
||||
currentColor = Theme.getServiceMessageColor();
|
||||
}
|
||||
if (chatTheme == null) {
|
||||
if (chatTheme == null && wallPaper == null) {
|
||||
currentColors = new HashMap<>();
|
||||
currentPaints.clear();
|
||||
currentDrawables.clear();
|
||||
Drawable wallpaper = Theme.getCachedWallpaperNonBlocking();
|
||||
if (wallpaper instanceof MotionBackgroundDrawable) {
|
||||
((MotionBackgroundDrawable) wallpaper).setPhase(prevPhase);
|
||||
Drawable wallpaperDrawable = Theme.getCachedWallpaperNonBlocking();
|
||||
if (wallpaperDrawable instanceof MotionBackgroundDrawable) {
|
||||
((MotionBackgroundDrawable) wallpaperDrawable).setPhase(prevPhase);
|
||||
}
|
||||
backgroundDrawable = null;
|
||||
backgroundDrawable = null;//wallpaperDrawable;
|
||||
|
||||
Theme.ThemeInfo activeTheme;
|
||||
if (Theme.getActiveTheme().isDark() == isDark) {
|
||||
|
@ -31205,12 +31346,21 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
|
||||
Theme.applyTheme(activeTheme, false, isDark);
|
||||
initServiceMessageColors(backgroundDrawable);
|
||||
} else {
|
||||
if (ApplicationLoader.applicationContext != null) {
|
||||
Theme.createChatResources(ApplicationLoader.applicationContext, false);
|
||||
}
|
||||
currentColors = chatTheme.createColors(currentAccount, isDark ? 1 : 0);
|
||||
backgroundDrawable = getBackgroundDrawableFromTheme(chatTheme, prevPhase);
|
||||
if (chatTheme == null) {
|
||||
currentColors = new HashMap<>();
|
||||
} else {
|
||||
currentColors = chatTheme.createColors(currentAccount, isDark ? 1 : 0);
|
||||
}
|
||||
if (wallPaper != null) {
|
||||
backgroundDrawable = ChatBackgroundDrawable.getOrCreate(backgroundDrawable, wallPaper, isDark);
|
||||
} else {
|
||||
backgroundDrawable = getBackgroundDrawableFromTheme(chatTheme, prevPhase);
|
||||
}
|
||||
|
||||
if (patternAlphaAnimator != null) {
|
||||
patternAlphaAnimator.cancel();
|
||||
|
@ -31248,6 +31398,25 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
patternAlphaAnimator.start();
|
||||
}
|
||||
|
||||
if (chatTheme == null) {
|
||||
Theme.ThemeInfo activeTheme;
|
||||
if (Theme.getActiveTheme().isDark() == isDark) {
|
||||
activeTheme = Theme.getActiveTheme();
|
||||
} else {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("themeconfig", Activity.MODE_PRIVATE);
|
||||
String dayThemeName = preferences.getString("lastDayTheme", "Blue");
|
||||
if (Theme.getTheme(dayThemeName) == null || Theme.getTheme(dayThemeName).isDark()) {
|
||||
dayThemeName = "Blue";
|
||||
}
|
||||
String nightThemeName = preferences.getString("lastDarkTheme", "Dark Blue");
|
||||
if (Theme.getTheme(nightThemeName) == null || !Theme.getTheme(nightThemeName).isDark()) {
|
||||
nightThemeName = "Dark Blue";
|
||||
}
|
||||
activeTheme = isDark ? Theme.getTheme(nightThemeName) : Theme.getTheme(dayThemeName);
|
||||
}
|
||||
|
||||
Theme.applyTheme(activeTheme, false, isDark);
|
||||
}
|
||||
if (createNewResources) {
|
||||
int[] colors = AndroidUtilities.calcDrawableColor(backgroundDrawable);
|
||||
currentColor = colors[0];
|
||||
|
@ -31360,11 +31529,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
Integer serviceColor = getCurrentColor(Theme.key_chat_serviceBackground);
|
||||
Integer selectedBackgroundColor = getCurrentColor(Theme.key_chat_selectedBackground);
|
||||
Integer serviceColor2 = serviceColor;
|
||||
if (serviceColor == null) {
|
||||
if (serviceColor == null || wallpaper != null) {
|
||||
serviceColor = currentServiceMessageColor;
|
||||
}
|
||||
currentServiceColor = serviceColor;
|
||||
|
||||
if (backgroundDrawable instanceof ChatBackgroundDrawable) {
|
||||
backgroundDrawable = ((ChatBackgroundDrawable) backgroundDrawable).getDrawable();
|
||||
}
|
||||
drawServiceGradient = backgroundDrawable instanceof MotionBackgroundDrawable && SharedConfig.getDevicePerformanceClass() != SharedConfig.PERFORMANCE_CLASS_LOW;
|
||||
drawSelectedGradient = drawServiceGradient;
|
||||
|
||||
|
@ -31379,6 +31551,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
} else {
|
||||
serviceBitmap = null;
|
||||
serviceShader = null;
|
||||
serviceBitmapSource = null;
|
||||
serviceCanvas = null;
|
||||
useSourceShader = false;
|
||||
}
|
||||
|
||||
Paint actionBackgroundPaint = getPaint(Theme.key_paint_chatActionBackground);
|
||||
|
@ -31559,6 +31734,22 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
public TLRPC.WallPaper getCurrentWallpaper() {
|
||||
return wallpaper;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateBackground() {
|
||||
if (contentView == null) {
|
||||
return;
|
||||
}
|
||||
if (themeDelegate.backgroundDrawable != null && contentView.getBackgroundImage() != null) {
|
||||
return;
|
||||
}
|
||||
if (contentView.getBackgroundImage() == null) {
|
||||
contentView.setBackgroundImage(Theme.getCachedWallpaper(), Theme.isWallpaperMotion());
|
||||
}
|
||||
}
|
||||
|
||||
private void updateBotHelpCellClick(BotHelpCell cell) {
|
||||
|
|
|
@ -0,0 +1,261 @@
|
|||
package org.telegram.ui;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
|
||||
import com.google.android.exoplayer2.util.Log;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ImageLoader;
|
||||
import org.telegram.messenger.ImageLocation;
|
||||
import org.telegram.messenger.ImageReceiver;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.EmojiThemes;
|
||||
import org.telegram.ui.Components.BackgroundGradientDrawable;
|
||||
import org.telegram.ui.Components.MotionBackgroundDrawable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class ChatBackgroundDrawable extends Drawable {
|
||||
|
||||
private final boolean themeIsDark;
|
||||
boolean isPattern;
|
||||
View parent;
|
||||
int alpha = 255;
|
||||
float dimAmount;
|
||||
ImageReceiver imageReceiver = new ImageReceiver() {
|
||||
@Override
|
||||
public void invalidate() {
|
||||
if (parent != null) {
|
||||
parent.invalidate();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MotionBackgroundDrawable motionBackgroundDrawable;
|
||||
final TLRPC.WallPaper wallpaper;
|
||||
private boolean colorFilterSetted;
|
||||
|
||||
public static Drawable getOrCreate(Drawable backgroundDrawable, TLRPC.WallPaper wallpaper, boolean themeIsDark) {
|
||||
if (backgroundDrawable instanceof ChatBackgroundDrawable) {
|
||||
ChatBackgroundDrawable chatBackgroundDrawable = (ChatBackgroundDrawable) backgroundDrawable;
|
||||
if (wallpaper.uploadingImage != null) {
|
||||
if (wallpaper.uploadingImage.equals(chatBackgroundDrawable.wallpaper.uploadingImage)) {
|
||||
if (wallpaper.settings != null && chatBackgroundDrawable.wallpaper.settings != null && wallpaper.settings.intensity > 0) {
|
||||
if (chatBackgroundDrawable.themeIsDark == themeIsDark) {
|
||||
return chatBackgroundDrawable;
|
||||
}
|
||||
} else {
|
||||
return chatBackgroundDrawable;
|
||||
}
|
||||
}
|
||||
} else if (wallpaper.id == chatBackgroundDrawable.wallpaper.id && TextUtils.equals(hash(wallpaper.settings), hash(chatBackgroundDrawable.wallpaper.settings))) {
|
||||
if (wallpaper.document != null && !wallpaper.pattern && wallpaper.settings != null && wallpaper.settings.intensity > 0) {
|
||||
if (chatBackgroundDrawable.themeIsDark == themeIsDark) {
|
||||
return chatBackgroundDrawable;
|
||||
}
|
||||
} else {
|
||||
return chatBackgroundDrawable;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ChatBackgroundDrawable(wallpaper, themeIsDark, false);
|
||||
}
|
||||
|
||||
public void setParent(View parent) {
|
||||
this.parent = parent;
|
||||
if (motionBackgroundDrawable != null) {
|
||||
motionBackgroundDrawable.setParentView(parent);
|
||||
}
|
||||
}
|
||||
|
||||
public ChatBackgroundDrawable(TLRPC.WallPaper wallPaper) {
|
||||
this(wallPaper, false, false);
|
||||
}
|
||||
|
||||
public ChatBackgroundDrawable(TLRPC.WallPaper wallPaper, boolean themeIsDark, boolean preview) {
|
||||
imageReceiver.setInvalidateAll(true);
|
||||
isPattern = wallPaper.pattern;
|
||||
this.wallpaper = wallPaper;
|
||||
this.themeIsDark = themeIsDark;
|
||||
if (themeIsDark && (wallpaper.document != null || wallpaper.uploadingImage != null) && !wallpaper.pattern && wallpaper.settings != null) {
|
||||
dimAmount = wallpaper.settings.intensity / 100f;
|
||||
// imageReceiver.setColorFilter(new PorterDuffColorFilter(ColorUtils.setAlphaComponent(Color.BLACK, (int) (dimAmount * 255)), PorterDuff.Mode.DARKEN));
|
||||
}
|
||||
if ((isPattern || wallPaper.document == null) && wallPaper.settings != null && wallPaper.settings.second_background_color != 0 && wallPaper.settings.third_background_color != 0) {
|
||||
motionBackgroundDrawable = new MotionBackgroundDrawable();
|
||||
motionBackgroundDrawable.setColors(
|
||||
wallPaper.settings.background_color,
|
||||
wallPaper.settings.second_background_color,
|
||||
wallPaper.settings.third_background_color,
|
||||
wallPaper.settings.fourth_background_color
|
||||
);
|
||||
EmojiThemes.loadWallpaperImage(wallPaper.id, wallPaper, result -> {
|
||||
motionBackgroundDrawable.setPatternBitmap(wallPaper.settings.intensity, result.second);
|
||||
if (parent != null) {
|
||||
parent.invalidate();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
String imageFilter;
|
||||
int w = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y);
|
||||
int h = Math.max(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y);
|
||||
if (preview) {
|
||||
imageFilter = "150_150_wallpaper";
|
||||
} else {
|
||||
imageFilter = (int) (w / AndroidUtilities.density) + "_" + (int) (h / AndroidUtilities.density) + "_wallpaper";
|
||||
}
|
||||
imageFilter += wallPaper.id;
|
||||
imageFilter += hash(wallPaper.settings);
|
||||
|
||||
Drawable thumb = createThumb(wallPaper);
|
||||
if (wallPaper.uploadingImage != null) {
|
||||
imageReceiver.setImage(ImageLocation.getForPath(wallPaper.uploadingImage), imageFilter, thumb, null, wallPaper, 1);
|
||||
} else if (wallPaper.document != null) {
|
||||
imageReceiver.setImage(ImageLocation.getForDocument(wallPaper.document), imageFilter, thumb, null, wallPaper, 1);
|
||||
} else {
|
||||
imageReceiver.setImageBitmap(thumb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Drawable createThumb(TLRPC.WallPaper wallPaper) {
|
||||
Drawable thumb = null;
|
||||
if (wallPaper.stripedThumb != null) {
|
||||
return new BitmapDrawable(wallPaper.stripedThumb);
|
||||
}
|
||||
if (wallPaper.pattern && wallPaper.settings == null) {
|
||||
return new ColorDrawable(Color.BLACK);
|
||||
}
|
||||
if (wallPaper.document != null) {
|
||||
for (int i = 0; i < wallPaper.document.thumbs.size(); i++) {
|
||||
if (wallPaper.document.thumbs.get(i) instanceof TLRPC.TL_photoStrippedSize) {
|
||||
thumb = new BitmapDrawable(ImageLoader.getStrippedPhotoBitmap(wallPaper.document.thumbs.get(i).bytes, "b"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (wallPaper.settings.intensity < 0) {
|
||||
thumb = bitmapDrawableOf(new ColorDrawable(Color.BLACK));
|
||||
} else {
|
||||
if (wallPaper.settings.second_background_color == 0) { //one color
|
||||
thumb = bitmapDrawableOf(new ColorDrawable(ColorUtils.setAlphaComponent(wallPaper.settings.background_color, 255)));
|
||||
} else if (wallPaper.settings.third_background_color == 0) { //two color
|
||||
int color1 = ColorUtils.setAlphaComponent(wallPaper.settings.background_color, 255);
|
||||
int color2 = ColorUtils.setAlphaComponent(wallPaper.settings.second_background_color, 255);
|
||||
thumb = bitmapDrawableOf(new GradientDrawable(BackgroundGradientDrawable.getGradientOrientation(wallPaper.settings.rotation), new int[]{color1, color2}));
|
||||
} else {
|
||||
int color1 = ColorUtils.setAlphaComponent(wallPaper.settings.background_color, 255);
|
||||
int color2 = ColorUtils.setAlphaComponent(wallPaper.settings.second_background_color, 255);
|
||||
int color3 = ColorUtils.setAlphaComponent(wallPaper.settings.third_background_color, 255);
|
||||
int color4 = wallPaper.settings.fourth_background_color == 0 ? 0 : ColorUtils.setAlphaComponent(wallPaper.settings.fourth_background_color, 255);
|
||||
MotionBackgroundDrawable motionBackgroundDrawable = new MotionBackgroundDrawable();
|
||||
motionBackgroundDrawable.setColors(color1, color2, color3, color4);
|
||||
thumb = new BitmapDrawable(motionBackgroundDrawable.getBitmap());
|
||||
}
|
||||
}
|
||||
}
|
||||
return thumb;
|
||||
}
|
||||
|
||||
private static Drawable bitmapDrawableOf(Drawable drawable) {
|
||||
Bitmap bitmap = Bitmap.createBitmap(20, 20, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
drawable.setBounds(0, 0, 20, 20);
|
||||
drawable.draw(canvas);
|
||||
return new BitmapDrawable(bitmap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(@NonNull Canvas canvas) {
|
||||
if (motionBackgroundDrawable != null) {
|
||||
motionBackgroundDrawable.setBounds(getBounds());
|
||||
motionBackgroundDrawable.setAlpha(alpha);
|
||||
motionBackgroundDrawable.draw(canvas);
|
||||
} else {
|
||||
boolean drawDim = false;
|
||||
if (!imageReceiver.hasImageLoaded() || imageReceiver.getCurrentAlpha() != 1f) {
|
||||
drawDim = true;
|
||||
} else if (!colorFilterSetted) {
|
||||
colorFilterSetted = true;
|
||||
imageReceiver.setColorFilter(new PorterDuffColorFilter(ColorUtils.setAlphaComponent(Color.BLACK, (int) (dimAmount * 255)), PorterDuff.Mode.DARKEN));
|
||||
}
|
||||
imageReceiver.setImageCoords(getBounds());
|
||||
imageReceiver.setAlpha(alpha / 255f);
|
||||
imageReceiver.draw(canvas);
|
||||
if (drawDim && dimAmount != 0) {
|
||||
canvas.drawColor(ColorUtils.setAlphaComponent(Color.BLACK, (int) (dimAmount * 255)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
if (this.alpha != alpha) {
|
||||
this.alpha = alpha;
|
||||
invalidateSelf();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(@Nullable ColorFilter colorFilter) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
boolean attached;
|
||||
|
||||
public void onAttachedToWindow() {
|
||||
if (attached) {
|
||||
return;
|
||||
}
|
||||
attached = true;
|
||||
imageReceiver.onAttachedToWindow();
|
||||
}
|
||||
|
||||
public void onDetachedFromWindow() {
|
||||
if (!attached) {
|
||||
return;
|
||||
}
|
||||
attached = false;
|
||||
imageReceiver.onDetachedFromWindow();
|
||||
}
|
||||
|
||||
public Drawable getDrawable() {
|
||||
if (motionBackgroundDrawable != null) {
|
||||
return motionBackgroundDrawable;
|
||||
}
|
||||
if (imageReceiver.getStaticThumb() != null) {
|
||||
return imageReceiver.getStaticThumb();
|
||||
} else if (imageReceiver.getThumb() != null) {
|
||||
return imageReceiver.getThumb();
|
||||
} else {
|
||||
return imageReceiver.getDrawable();
|
||||
}
|
||||
}
|
||||
|
||||
public static String hash(TLRPC.WallPaperSettings settings) {
|
||||
if (settings == null) {
|
||||
return "";
|
||||
}
|
||||
return String.valueOf(Objects.hash(settings.blur, settings.motion, settings.intensity, settings.background_color, settings.second_background_color, settings.third_background_color, settings.fourth_background_color));
|
||||
}
|
||||
}
|
|
@ -479,7 +479,7 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
|
|||
int index = tagsString.toString().indexOf('\n');
|
||||
if (index >= 0) {
|
||||
tagsString.replace(index, index + 1, " ");
|
||||
tagsString.setSpan(new ForegroundColorSpan(getThemedColor(Theme.key_windowBackgroundWhiteRedText4)), 0, index, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
tagsString.setSpan(new ForegroundColorSpan(getThemedColor(Theme.key_text_RedRegular)), 0, index, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
TypefaceSpan[] spans = tagsString.getSpans(0, tagsString.length(), TypefaceSpan.class);
|
||||
final String username = usernameTextView == null || usernameTextView.getText() == null ? "" : usernameTextView.getText().toString();
|
||||
|
@ -1296,8 +1296,8 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
|
|||
}
|
||||
if (!isPrivate && !canCreatePublic && getUserConfig().isPremium()) {
|
||||
typeInfoCell.setText(LocaleController.getString("ChangePublicLimitReached", R.string.ChangePublicLimitReached));
|
||||
typeInfoCell.setTag(Theme.key_windowBackgroundWhiteRedText4);
|
||||
typeInfoCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText4));
|
||||
typeInfoCell.setTag(Theme.key_text_RedRegular);
|
||||
typeInfoCell.setTextColor(Theme.getColor(Theme.key_text_RedRegular));
|
||||
linkContainer.setVisibility(View.GONE);
|
||||
checkTextView.setVisibility(View.GONE);
|
||||
sectionCell2.setVisibility(View.GONE);
|
||||
|
@ -1405,7 +1405,7 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
|
|||
if (name != null) {
|
||||
if (name.startsWith("_") || name.endsWith("_")) {
|
||||
checkTextView.setText(LocaleController.getString("LinkInvalid", R.string.LinkInvalid));
|
||||
checkTextView.setTextColor(Theme.key_windowBackgroundWhiteRedText4);
|
||||
checkTextView.setTextColor(Theme.key_text_RedRegular);
|
||||
return false;
|
||||
}
|
||||
for (int a = 0; a < name.length(); a++) {
|
||||
|
@ -1416,12 +1416,12 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
|
|||
} else {
|
||||
checkTextView.setText(LocaleController.getString("LinkInvalidStartNumberMega", R.string.LinkInvalidStartNumberMega));
|
||||
}
|
||||
checkTextView.setTextColor(Theme.key_windowBackgroundWhiteRedText4);
|
||||
checkTextView.setTextColor(Theme.key_text_RedRegular);
|
||||
return false;
|
||||
}
|
||||
if (!(ch >= '0' && ch <= '9' || ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || ch == '_')) {
|
||||
checkTextView.setText(LocaleController.getString("LinkInvalid", R.string.LinkInvalid));
|
||||
checkTextView.setTextColor(Theme.key_windowBackgroundWhiteRedText4);
|
||||
checkTextView.setTextColor(Theme.key_text_RedRegular);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1432,12 +1432,12 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
|
|||
} else {
|
||||
checkTextView.setText(LocaleController.getString("LinkInvalidShortMega", R.string.LinkInvalidShortMega));
|
||||
}
|
||||
checkTextView.setTextColor(Theme.key_windowBackgroundWhiteRedText4);
|
||||
checkTextView.setTextColor(Theme.key_text_RedRegular);
|
||||
return false;
|
||||
}
|
||||
if (name.length() > 32) {
|
||||
checkTextView.setText(LocaleController.getString("LinkInvalidLong", R.string.LinkInvalidLong));
|
||||
checkTextView.setTextColor(Theme.key_windowBackgroundWhiteRedText4);
|
||||
checkTextView.setTextColor(Theme.key_text_RedRegular);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1458,7 +1458,7 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
|
|||
} else {
|
||||
if (error != null && "USERNAME_INVALID".equals(error.text) && req.username.length() == 4) {
|
||||
checkTextView.setText(LocaleController.getString("UsernameInvalidShort", R.string.UsernameInvalidShort));
|
||||
checkTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText4));
|
||||
checkTextView.setTextColor(Theme.getColor(Theme.key_text_RedRegular));
|
||||
} else if (error != null && "USERNAME_PURCHASE_AVAILABLE".equals(error.text)) {
|
||||
if (req.username.length() == 4) {
|
||||
checkTextView.setText(LocaleController.getString("UsernameInvalidShortPurchase", R.string.UsernameInvalidShortPurchase));
|
||||
|
@ -1471,7 +1471,7 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
|
|||
showPremiumIncreaseLimitDialog();
|
||||
} else {
|
||||
checkTextView.setText(LocaleController.getString("LinkInUse", R.string.LinkInUse));
|
||||
checkTextView.setTextColor(Theme.key_windowBackgroundWhiteRedText4);
|
||||
checkTextView.setTextColor(Theme.key_text_RedRegular);
|
||||
}
|
||||
lastNameAvailable = false;
|
||||
}
|
||||
|
@ -1547,7 +1547,7 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
|
|||
themeDescriptions.add(new ThemeDescription(infoCell, 0, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText4));
|
||||
|
||||
themeDescriptions.add(new ThemeDescription(textCell, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector));
|
||||
themeDescriptions.add(new ThemeDescription(textCell, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{TextSettingsCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteRedText5));
|
||||
themeDescriptions.add(new ThemeDescription(textCell, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{TextSettingsCell.class}, new String[]{"textView"}, null, null, null, Theme.key_text_RedRegular));
|
||||
themeDescriptions.add(new ThemeDescription(textCell2, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector));
|
||||
themeDescriptions.add(new ThemeDescription(textCell2, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{TextSettingsCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
||||
|
||||
|
@ -1567,21 +1567,21 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
|
|||
themeDescriptions.add(new ThemeDescription(saveRestrictCell, 0, new Class[]{TextCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrack));
|
||||
themeDescriptions.add(new ThemeDescription(saveRestrictCell, 0, new Class[]{TextCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrackChecked));
|
||||
|
||||
themeDescriptions.add(new ThemeDescription(checkTextView, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteRedText4));
|
||||
themeDescriptions.add(new ThemeDescription(checkTextView, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_text_RedRegular));
|
||||
themeDescriptions.add(new ThemeDescription(checkTextView, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText8));
|
||||
themeDescriptions.add(new ThemeDescription(checkTextView, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteGreenText));
|
||||
|
||||
themeDescriptions.add(new ThemeDescription(typeInfoCell, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{TextInfoPrivacyCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow));
|
||||
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(typeInfoCell, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_text_RedRegular));
|
||||
|
||||
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_CHECKTAG, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_text_RedRegular));
|
||||
|
||||
themeDescriptions.add(new ThemeDescription(saveRestrictInfoCell, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{TextInfoPrivacyCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow));
|
||||
themeDescriptions.add(new ThemeDescription(saveRestrictInfoCell, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText4));
|
||||
themeDescriptions.add(new ThemeDescription(saveRestrictInfoCell, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteRedText4));
|
||||
themeDescriptions.add(new ThemeDescription(saveRestrictInfoCell, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_text_RedRegular));
|
||||
|
||||
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));
|
||||
|
|
|
@ -465,7 +465,7 @@ public class ChatLinkActivity extends BaseFragment implements NotificationCenter
|
|||
showDialog(dialog);
|
||||
TextView button = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE);
|
||||
if (button != null) {
|
||||
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed));
|
||||
button.setTextColor(Theme.getColor(Theme.key_text_RedBold));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -986,14 +986,14 @@ public class ChatLinkActivity extends BaseFragment implements NotificationCenter
|
|||
ManageChatTextCell actionCell = (ManageChatTextCell) holder.itemView;
|
||||
if (isChannel) {
|
||||
if (info.linked_chat_id != 0) {
|
||||
actionCell.setColors(Theme.key_windowBackgroundWhiteRedText5, Theme.key_windowBackgroundWhiteRedText5);
|
||||
actionCell.setColors(Theme.key_text_RedRegular, Theme.key_text_RedRegular);
|
||||
actionCell.setText(LocaleController.getString("DiscussionUnlinkGroup", R.string.DiscussionUnlinkGroup), null, R.drawable.msg_remove, false);
|
||||
} else {
|
||||
actionCell.setColors(Theme.key_windowBackgroundWhiteBlueIcon, Theme.key_windowBackgroundWhiteBlueButton);
|
||||
actionCell.setText(LocaleController.getString("DiscussionCreateGroup", R.string.DiscussionCreateGroup), null, R.drawable.msg_groups, true);
|
||||
}
|
||||
} else {
|
||||
actionCell.setColors(Theme.key_windowBackgroundWhiteRedText5, Theme.key_windowBackgroundWhiteRedText5);
|
||||
actionCell.setColors(Theme.key_text_RedRegular, Theme.key_text_RedRegular);
|
||||
actionCell.setText(LocaleController.getString("DiscussionUnlinkChannel", R.string.DiscussionUnlinkChannel), null, R.drawable.msg_remove, false);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -365,7 +365,7 @@ public class ChatReactionsEditActivity extends BaseFragment implements Notificat
|
|||
Theme.key_listSelector,
|
||||
Theme.key_windowBackgroundGray,
|
||||
Theme.key_windowBackgroundWhiteGrayText4,
|
||||
Theme.key_windowBackgroundWhiteRedText4,
|
||||
Theme.key_text_RedRegular,
|
||||
Theme.key_windowBackgroundChecked,
|
||||
Theme.key_windowBackgroundCheckText,
|
||||
Theme.key_switchTrackBlue,
|
||||
|
|
|
@ -1377,7 +1377,7 @@ public class ChatRightsEditActivity extends BaseFragment {
|
|||
if (left <= MAX_RANK_LENGTH - MAX_RANK_LENGTH * 0.7f) {
|
||||
headerCell.setText2(String.format("%d", left));
|
||||
SimpleTextView textView = headerCell.getTextView2();
|
||||
String key = left < 0 ? Theme.key_windowBackgroundWhiteRedText5 : Theme.key_windowBackgroundWhiteGrayText3;
|
||||
String key = left < 0 ? Theme.key_text_RedRegular : Theme.key_windowBackgroundWhiteGrayText3;
|
||||
textView.setTextColor(Theme.getColor(key));
|
||||
textView.setTag(key);
|
||||
} else {
|
||||
|
@ -1665,8 +1665,8 @@ public class ChatRightsEditActivity extends BaseFragment {
|
|||
case VIEW_TYPE_TRANSFER_CELL:
|
||||
TextSettingsCell actionCell = (TextSettingsCell) holder.itemView;
|
||||
if (position == removeAdminRow) {
|
||||
actionCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText5));
|
||||
actionCell.setTag(Theme.key_windowBackgroundWhiteRedText5);
|
||||
actionCell.setTextColor(Theme.getColor(Theme.key_text_RedRegular));
|
||||
actionCell.setTag(Theme.key_text_RedRegular);
|
||||
if (currentType == TYPE_ADMIN) {
|
||||
actionCell.setText(LocaleController.getString("EditAdminRemoveAdmin", R.string.EditAdminRemoveAdmin), false);
|
||||
} else if (currentType == TYPE_BANNED) {
|
||||
|
@ -2108,7 +2108,7 @@ public class ChatRightsEditActivity extends BaseFragment {
|
|||
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{TextInfoPrivacyCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow));
|
||||
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText4));
|
||||
|
||||
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextSettingsCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteRedText5));
|
||||
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextSettingsCell.class}, new String[]{"textView"}, null, null, null, Theme.key_text_RedRegular));
|
||||
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextSettingsCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
||||
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextSettingsCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteValueText));
|
||||
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextSettingsCell.class}, new String[]{"valueImageView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayIcon));
|
||||
|
@ -2124,7 +2124,7 @@ public class ChatRightsEditActivity extends BaseFragment {
|
|||
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{ShadowSectionCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow));
|
||||
|
||||
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{HeaderCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlueHeader));
|
||||
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_CHECKTAG, new Class[]{HeaderCell.class}, new String[]{"textView2"}, null, null, null, Theme.key_windowBackgroundWhiteRedText5));
|
||||
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_CHECKTAG, new Class[]{HeaderCell.class}, new String[]{"textView2"}, null, null, null, Theme.key_text_RedRegular));
|
||||
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_CHECKTAG, new Class[]{HeaderCell.class}, new String[]{"textView2"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText3));
|
||||
|
||||
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{PollEditTextCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
||||
|
|
|
@ -14,6 +14,7 @@ import android.animation.AnimatorSet;
|
|||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
|
@ -69,6 +70,7 @@ import org.telegram.ui.Components.BulletinFactory;
|
|||
import org.telegram.ui.Components.CubicBezierInterpolator;
|
||||
import org.telegram.ui.Components.FlickerLoadingView;
|
||||
import org.telegram.ui.Components.GigagroupConvertAlert;
|
||||
import org.telegram.ui.Components.ItemOptions;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.RadialProgressView;
|
||||
import org.telegram.ui.Components.RecyclerListView;
|
||||
|
@ -446,9 +448,11 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
loadingUserCellRow = rowCount++;
|
||||
}
|
||||
} else if (type == TYPE_USERS) {
|
||||
if (!ChatObject.isChannelAndNotMegaGroup(currentChat) && !needOpenSearch) {
|
||||
hideMembersRow = rowCount++;
|
||||
hideMembersInfoRow = rowCount++;
|
||||
if (ChatObject.isChannel(currentChat)) {
|
||||
if (!ChatObject.isChannelAndNotMegaGroup(currentChat) && !needOpenSearch) {
|
||||
hideMembersRow = rowCount++;
|
||||
hideMembersInfoRow = rowCount++;
|
||||
}
|
||||
}
|
||||
if (selectType == SELECT_TYPE_MEMBERS && ChatObject.canAddUsers(currentChat)) {
|
||||
addNewRow = rowCount++;
|
||||
|
@ -901,7 +905,7 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
return;
|
||||
} else if (position == antiSpamRow) {
|
||||
final TextCell textCell = (TextCell) view;
|
||||
if (info != null && !info.antispam && info.participants_count < getMessagesController().telegramAntispamGroupSizeMin) {
|
||||
if (info != null && !info.antispam && getParticipantsCount() < getMessagesController().telegramAntispamGroupSizeMin) {
|
||||
BulletinFactory.of(this).createSimpleBulletin(R.raw.msg_antispam, AndroidUtilities.replaceTags(LocaleController.formatPluralString("ChannelAntiSpamForbidden", getMessagesController().telegramAntispamGroupSizeMin))).show();
|
||||
} else if (info != null && ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_DELETE_MESSAGES) && !antiSpamToggleLoading) {
|
||||
antiSpamToggleLoading = true;
|
||||
|
@ -909,7 +913,7 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
TLRPC.TL_channels_toggleAntiSpam req = new TLRPC.TL_channels_toggleAntiSpam();
|
||||
req.channel = getMessagesController().getInputChannel(chatId);
|
||||
textCell.setChecked(req.enabled = (info.antispam = !info.antispam));
|
||||
textCell.getCheckBox().setIcon(ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_DELETE_MESSAGES) && (info == null || info.antispam || info.participants_count >= getMessagesController().telegramAntispamGroupSizeMin) ? 0 : R.drawable.permission_locked);
|
||||
textCell.getCheckBox().setIcon(ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_DELETE_MESSAGES) && (info == null || info.antispam || getParticipantsCount() >= getMessagesController().telegramAntispamGroupSizeMin) ? 0 : R.drawable.permission_locked);
|
||||
getConnectionsManager().sendRequest(req, (res, err) -> {
|
||||
if (res != null) {
|
||||
getMessagesController().processUpdates((TLRPC.Updates) res, false);
|
||||
|
@ -921,7 +925,7 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
return;
|
||||
}
|
||||
textCell.setChecked(info.antispam = wasAntispam);
|
||||
textCell.getCheckBox().setIcon(ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_DELETE_MESSAGES) && (info == null || !info.antispam || info.participants_count >= getMessagesController().telegramAntispamGroupSizeMin) ? 0 : R.drawable.permission_locked);
|
||||
textCell.getCheckBox().setIcon(ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_DELETE_MESSAGES) && (info == null || !info.antispam || getParticipantsCount() >= getMessagesController().telegramAntispamGroupSizeMin) ? 0 : R.drawable.permission_locked);
|
||||
BulletinFactory.of(ChatUsersActivity.this).createSimpleBulletin(R.raw.error, LocaleController.getString("UnknownError", R.string.UnknownError)).show();
|
||||
});
|
||||
}
|
||||
|
@ -931,7 +935,7 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
return;
|
||||
} else if (position == hideMembersRow) {
|
||||
final TextCell textCell = (TextCell) view;
|
||||
if (info != null && !info.participants_hidden && info.participants_count < getMessagesController().hiddenMembersGroupSizeMin) {
|
||||
if (getParticipantsCount() < getMessagesController().hiddenMembersGroupSizeMin) {
|
||||
BulletinFactory.of(this).createSimpleBulletin(R.raw.contacts_sync_off, AndroidUtilities.replaceTags(LocaleController.formatPluralString("ChannelHiddenMembersForbidden", getMessagesController().hiddenMembersGroupSizeMin))).show();
|
||||
} else if (info != null && ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_BLOCK_USERS) && !hideMembersToggleLoading) {
|
||||
hideMembersToggleLoading = true;
|
||||
|
@ -939,7 +943,7 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
TLRPC.TL_channels_toggleParticipantsHidden req = new TLRPC.TL_channels_toggleParticipantsHidden();
|
||||
req.channel = getMessagesController().getInputChannel(chatId);
|
||||
textCell.setChecked(req.enabled = (info.participants_hidden = !info.participants_hidden));
|
||||
textCell.getCheckBox().setIcon(ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_BLOCK_USERS) && (info == null || info.participants_hidden || info.participants_count >= getMessagesController().hiddenMembersGroupSizeMin) ? 0 : R.drawable.permission_locked);
|
||||
textCell.getCheckBox().setIcon(ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_BLOCK_USERS) && (info == null || info.participants_hidden || getParticipantsCount() >= getMessagesController().hiddenMembersGroupSizeMin) ? 0 : R.drawable.permission_locked);
|
||||
getConnectionsManager().sendRequest(req, (res, err) -> {
|
||||
if (res != null) {
|
||||
getMessagesController().processUpdates((TLRPC.Updates) res, false);
|
||||
|
@ -951,7 +955,7 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
return;
|
||||
}
|
||||
textCell.setChecked(info.participants_hidden = wasParticipantsHidden);
|
||||
textCell.getCheckBox().setIcon(ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_BLOCK_USERS) && (info == null || !info.participants_hidden || info.participants_count >= getMessagesController().hiddenMembersGroupSizeMin) ? 0 : R.drawable.permission_locked);
|
||||
textCell.getCheckBox().setIcon(ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_BLOCK_USERS) && (info == null || !info.participants_hidden || getParticipantsCount() >= getMessagesController().hiddenMembersGroupSizeMin) ? 0 : R.drawable.permission_locked);
|
||||
BulletinFactory.of(ChatUsersActivity.this).createSimpleBulletin(R.raw.error, LocaleController.getString("UnknownError", R.string.UnknownError)).show();
|
||||
});
|
||||
}
|
||||
|
@ -1216,7 +1220,12 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
}
|
||||
});
|
||||
|
||||
listView.setOnItemLongClickListener((view, position) -> !(getParentActivity() == null || listView.getAdapter() != listViewAdapter) && createMenuForParticipant(listViewAdapter.getItem(position), false));
|
||||
listView.setOnItemLongClickListener((view, position) -> {
|
||||
if (getParentActivity() != null && listView.getAdapter() == listViewAdapter) {
|
||||
return createMenuForParticipant(listViewAdapter.getItem(position), false, view);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (searchItem != null) {
|
||||
listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
|
@ -1248,6 +1257,17 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
return fragmentView;
|
||||
}
|
||||
|
||||
private int getParticipantsCount() {
|
||||
if (info == null) {
|
||||
return 0;
|
||||
}
|
||||
int count = info.participants_count;
|
||||
if (info.participants != null && info.participants.participants != null) {
|
||||
count = Math.max(count, info.participants.participants.size());
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
private void setBannedRights(TLRPC.TL_chatBannedRights defaultBannedRights) {
|
||||
if (defaultBannedRights != null) {
|
||||
this.defaultBannedRights = defaultBannedRights;
|
||||
|
@ -1643,7 +1663,7 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
}
|
||||
}
|
||||
|
||||
private boolean createMenuForParticipant(final TLObject participant, boolean resultOnly) {
|
||||
private boolean createMenuForParticipant(final TLObject participant, boolean resultOnly, View view) {
|
||||
if (participant == null || selectType != SELECT_TYPE_MEMBERS) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1685,132 +1705,84 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
boolean allowSetAdmin = ChatObject.canAddAdmins(currentChat) && (participant instanceof TLRPC.TL_channelParticipant || participant instanceof TLRPC.TL_channelParticipantBanned || participant instanceof TLRPC.TL_chatParticipant || canEdit);
|
||||
boolean canEditAdmin = !(participant instanceof TLRPC.TL_channelParticipantAdmin || participant instanceof TLRPC.TL_channelParticipantCreator || participant instanceof TLRPC.TL_chatParticipantCreator || participant instanceof TLRPC.TL_chatParticipantAdmin) || canEdit;
|
||||
boolean editingAdmin = participant instanceof TLRPC.TL_channelParticipantAdmin || participant instanceof TLRPC.TL_chatParticipantAdmin;
|
||||
boolean canChangePermission = ChatObject.canBlockUsers(currentChat) && canEditAdmin && !isChannel && ChatObject.isChannel(currentChat) && !currentChat.gigagroup;
|
||||
|
||||
if (selectType == SELECT_TYPE_MEMBERS) {
|
||||
allowSetAdmin &= !UserObject.isDeleted(user);
|
||||
}
|
||||
|
||||
final ArrayList<String> items;
|
||||
final ArrayList<Integer> actions;
|
||||
final ArrayList<Integer> icons;
|
||||
if (!resultOnly) {
|
||||
items = new ArrayList<>();
|
||||
actions = new ArrayList<>();
|
||||
icons = new ArrayList<>();
|
||||
} else {
|
||||
items = null;
|
||||
actions = null;
|
||||
icons = null;
|
||||
boolean result = allowSetAdmin || (ChatObject.canBlockUsers(currentChat) && canEditAdmin);
|
||||
if (resultOnly || !result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (allowSetAdmin) {
|
||||
if (resultOnly) {
|
||||
return true;
|
||||
}
|
||||
items.add(editingAdmin ? LocaleController.getString("EditAdminRights", R.string.EditAdminRights) : LocaleController.getString("SetAsAdmin", R.string.SetAsAdmin));
|
||||
icons.add(R.drawable.msg_admins);
|
||||
actions.add(0);
|
||||
}
|
||||
boolean hasRemove = false;
|
||||
if (ChatObject.canBlockUsers(currentChat) && canEditAdmin) {
|
||||
if (resultOnly) {
|
||||
return true;
|
||||
}
|
||||
if (!isChannel) {
|
||||
if (ChatObject.isChannel(currentChat) && !currentChat.gigagroup) {
|
||||
items.add(LocaleController.getString("ChangePermissions", R.string.ChangePermissions));
|
||||
icons.add(R.drawable.msg_permissions);
|
||||
actions.add(1);
|
||||
Utilities.Callback<Integer> openRightsFor = action ->
|
||||
openRightsEdit2(peerId, date, participant, adminRights, bannedRights, rank, canEditAdmin, action, false);
|
||||
|
||||
ItemOptions.makeOptions(this, view)
|
||||
.setScrimViewBackground(new ColorDrawable(Theme.getColor(Theme.key_windowBackgroundWhite)))
|
||||
.addIf(allowSetAdmin, R.drawable.msg_admins, editingAdmin ? LocaleController.getString("EditAdminRights", R.string.EditAdminRights) : LocaleController.getString("SetAsAdmin", R.string.SetAsAdmin), () -> openRightsFor.run(0))
|
||||
.addIf(canChangePermission, R.drawable.msg_permissions, LocaleController.getString("ChangePermissions", R.string.ChangePermissions), () -> {
|
||||
if (participant instanceof TLRPC.TL_channelParticipantAdmin || participant instanceof TLRPC.TL_chatParticipantAdmin) {
|
||||
showDialog(
|
||||
new AlertDialog.Builder(getParentActivity())
|
||||
.setTitle(LocaleController.getString("AppName", R.string.AppName))
|
||||
.setMessage(LocaleController.formatString("AdminWillBeRemoved", R.string.AdminWillBeRemoved, UserObject.getUserName(user)))
|
||||
.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialog, which) -> openRightsFor.run(1))
|
||||
.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null)
|
||||
.create()
|
||||
);
|
||||
} else {
|
||||
openRightsFor.run(1);
|
||||
}
|
||||
items.add(LocaleController.getString("KickFromGroup", R.string.KickFromGroup));
|
||||
} else {
|
||||
items.add(LocaleController.getString("ChannelRemoveUser", R.string.ChannelRemoveUser));
|
||||
}
|
||||
icons.add(R.drawable.msg_remove);
|
||||
actions.add(2);
|
||||
hasRemove = true;
|
||||
}
|
||||
if (actions == null || actions.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setItems(items.toArray(new CharSequence[actions.size()]), AndroidUtilities.toIntArray(icons), (dialogInterface, i) -> {
|
||||
if (actions.get(i) == 2) {
|
||||
})
|
||||
.addIf(ChatObject.canBlockUsers(currentChat) && canEditAdmin, R.drawable.msg_remove, isChannel ? LocaleController.getString("ChannelRemoveUser", R.string.ChannelRemoveUser) : LocaleController.getString("KickFromGroup", R.string.KickFromGroup), true, () -> {
|
||||
getMessagesController().deleteParticipantFromChat(chatId, user);
|
||||
removeParticipants(peerId);
|
||||
if (currentChat != null && user != null && BulletinFactory.canShowBulletin(this)) {
|
||||
BulletinFactory.createRemoveFromChatBulletin(this, user, currentChat.title).show();
|
||||
}
|
||||
} else {
|
||||
if (actions.get(i) == 1 && canEditAdmin && (participant instanceof TLRPC.TL_channelParticipantAdmin || participant instanceof TLRPC.TL_chatParticipantAdmin)) {
|
||||
AlertDialog.Builder builder2 = new AlertDialog.Builder(getParentActivity());
|
||||
builder2.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||
builder2.setMessage(LocaleController.formatString("AdminWillBeRemoved", R.string.AdminWillBeRemoved, UserObject.getUserName(user)));
|
||||
builder2.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialog, which) -> openRightsEdit2(peerId, date, participant, adminRights, bannedRights, rank, canEditAdmin, actions.get(i), false));
|
||||
builder2.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
showDialog(builder2.create());
|
||||
} else {
|
||||
openRightsEdit2(peerId, date, participant, adminRights, bannedRights, rank, canEditAdmin, actions.get(i), false);
|
||||
}
|
||||
}
|
||||
});
|
||||
AlertDialog alertDialog = builder.create();
|
||||
showDialog(alertDialog);
|
||||
if (hasRemove) {
|
||||
alertDialog.setItemColor(items.size() - 1, Theme.getColor(Theme.key_dialogTextRed), Theme.getColor(Theme.key_dialogRedIcon));
|
||||
}
|
||||
})
|
||||
.setMinWidth(190)
|
||||
.show();
|
||||
} else {
|
||||
CharSequence[] items;
|
||||
int[] icons;
|
||||
|
||||
ItemOptions options = ItemOptions.makeOptions(this, view);
|
||||
|
||||
if (type == TYPE_KICKED && ChatObject.canBlockUsers(currentChat)) {
|
||||
if (resultOnly) {
|
||||
return true;
|
||||
}
|
||||
items = new CharSequence[]{
|
||||
LocaleController.getString("ChannelEditPermissions", R.string.ChannelEditPermissions),
|
||||
LocaleController.getString("ChannelDeleteFromList", R.string.ChannelDeleteFromList)};
|
||||
icons = new int[]{
|
||||
R.drawable.msg_permissions,
|
||||
R.drawable.msg_delete};
|
||||
options.add(R.drawable.msg_permissions, LocaleController.getString("ChannelEditPermissions", R.string.ChannelEditPermissions), () -> {
|
||||
ChatRightsEditActivity fragment = new ChatRightsEditActivity(peerId, chatId, null, defaultBannedRights, bannedRights, rank, ChatRightsEditActivity.TYPE_BANNED, true, false, null);
|
||||
fragment.setDelegate(new ChatRightsEditActivity.ChatRightsEditActivityDelegate() {
|
||||
@Override
|
||||
public void didSetRights(int rights, TLRPC.TL_chatAdminRights rightsAdmin, TLRPC.TL_chatBannedRights rightsBanned, String rank) {
|
||||
if (participant instanceof TLRPC.ChannelParticipant) {
|
||||
TLRPC.ChannelParticipant channelParticipant = (TLRPC.ChannelParticipant) participant;
|
||||
channelParticipant.admin_rights = rightsAdmin;
|
||||
channelParticipant.banned_rights = rightsBanned;
|
||||
channelParticipant.rank = rank;
|
||||
updateParticipantWithRights(channelParticipant, rightsAdmin, rightsBanned, 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didChangeOwner(TLRPC.User user) {
|
||||
onOwnerChaged(user);
|
||||
}
|
||||
});
|
||||
presentFragment(fragment);
|
||||
});
|
||||
options.add(R.drawable.msg_delete, LocaleController.getString("ChannelDeleteFromList", R.string.ChannelDeleteFromList), true, () -> deletePeer(peerId));
|
||||
} else if (type == TYPE_BANNED && ChatObject.canBlockUsers(currentChat)) {
|
||||
if (resultOnly) {
|
||||
return true;
|
||||
if (ChatObject.canAddUsers(currentChat) && peerId > 0) {
|
||||
options.add(R.drawable.msg_contact_add, isChannel ? LocaleController.getString("ChannelAddToChannel", R.string.ChannelAddToChannel) : LocaleController.getString("ChannelAddToGroup", R.string.ChannelAddToGroup), () -> {
|
||||
TLRPC.User user = getMessagesController().getUser(peerId);
|
||||
getMessagesController().addUserToChat(chatId, user, 0, null, ChatUsersActivity.this, null);
|
||||
});
|
||||
}
|
||||
items = new CharSequence[]{
|
||||
ChatObject.canAddUsers(currentChat) && peerId > 0 ? (isChannel ? LocaleController.getString("ChannelAddToChannel", R.string.ChannelAddToChannel) : LocaleController.getString("ChannelAddToGroup", R.string.ChannelAddToGroup)) : null,
|
||||
LocaleController.getString("ChannelDeleteFromList", R.string.ChannelDeleteFromList)};
|
||||
icons = new int[]{
|
||||
R.drawable.msg_contact_add,
|
||||
R.drawable.msg_delete};
|
||||
options.add(R.drawable.msg_delete, LocaleController.getString("ChannelDeleteFromList", R.string.ChannelDeleteFromList), true, () -> deletePeer(peerId));
|
||||
} else if (type == TYPE_ADMIN && ChatObject.canAddAdmins(currentChat) && canEdit) {
|
||||
if (resultOnly) {
|
||||
return true;
|
||||
}
|
||||
if (currentChat.creator || !(participant instanceof TLRPC.TL_channelParticipantCreator) && canEdit) {
|
||||
items = new CharSequence[]{
|
||||
LocaleController.getString("EditAdminRights", R.string.EditAdminRights),
|
||||
LocaleController.getString("ChannelRemoveUserAdmin", R.string.ChannelRemoveUserAdmin)};
|
||||
icons = new int[]{
|
||||
R.drawable.msg_admins,
|
||||
R.drawable.msg_remove};
|
||||
} else {
|
||||
items = new CharSequence[]{
|
||||
LocaleController.getString("ChannelRemoveUserAdmin", R.string.ChannelRemoveUserAdmin)};
|
||||
icons = new int[]{
|
||||
R.drawable.msg_remove};
|
||||
}
|
||||
} else {
|
||||
items = null;
|
||||
icons = null;
|
||||
}
|
||||
if (items == null) {
|
||||
return false;
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setItems(items, icons, (dialogInterface, i) -> {
|
||||
if (type == TYPE_ADMIN) {
|
||||
if (i == 0 && items.length == 2) {
|
||||
if (currentChat.creator || !(participant instanceof TLRPC.TL_channelParticipantCreator)) {
|
||||
options.add(R.drawable.msg_admins, LocaleController.getString("EditAdminRights", R.string.EditAdminRights), () -> {
|
||||
ChatRightsEditActivity fragment = new ChatRightsEditActivity(peerId, chatId, adminRights, null, null, rank, ChatRightsEditActivity.TYPE_ADMIN, true, false, null);
|
||||
fragment.setDelegate(new ChatRightsEditActivity.ChatRightsEditActivityDelegate() {
|
||||
@Override
|
||||
|
@ -1830,83 +1802,46 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
}
|
||||
});
|
||||
presentFragment(fragment);
|
||||
} else {
|
||||
getMessagesController().setUserAdminRole(chatId, getMessagesController().getUser(peerId), new TLRPC.TL_chatAdminRights(), "", !isChannel, ChatUsersActivity.this, false, false, null, null);
|
||||
removeParticipants(peerId);
|
||||
}
|
||||
} else if (type == TYPE_BANNED || type == TYPE_KICKED) {
|
||||
if (i == 0) {
|
||||
if (type == TYPE_KICKED) {
|
||||
ChatRightsEditActivity fragment = new ChatRightsEditActivity(peerId, chatId, null, defaultBannedRights, bannedRights, rank, ChatRightsEditActivity.TYPE_BANNED, true, false, null);
|
||||
fragment.setDelegate(new ChatRightsEditActivity.ChatRightsEditActivityDelegate() {
|
||||
@Override
|
||||
public void didSetRights(int rights, TLRPC.TL_chatAdminRights rightsAdmin, TLRPC.TL_chatBannedRights rightsBanned, String rank) {
|
||||
if (participant instanceof TLRPC.ChannelParticipant) {
|
||||
TLRPC.ChannelParticipant channelParticipant = (TLRPC.ChannelParticipant) participant;
|
||||
channelParticipant.admin_rights = rightsAdmin;
|
||||
channelParticipant.banned_rights = rightsBanned;
|
||||
channelParticipant.rank = rank;
|
||||
updateParticipantWithRights(channelParticipant, rightsAdmin, rightsBanned, 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didChangeOwner(TLRPC.User user) {
|
||||
onOwnerChaged(user);
|
||||
}
|
||||
});
|
||||
presentFragment(fragment);
|
||||
} else if (type == TYPE_BANNED) {
|
||||
if (peerId > 0) {
|
||||
TLRPC.User user = getMessagesController().getUser(peerId);
|
||||
getMessagesController().addUserToChat(chatId, user, 0, null, ChatUsersActivity.this, null);
|
||||
}
|
||||
}
|
||||
} else if (i == 1) {
|
||||
TLRPC.TL_channels_editBanned req = new TLRPC.TL_channels_editBanned();
|
||||
req.participant = getMessagesController().getInputPeer(peerId);
|
||||
req.channel = getMessagesController().getInputChannel(chatId);
|
||||
req.banned_rights = new TLRPC.TL_chatBannedRights();
|
||||
getConnectionsManager().sendRequest(req, (response, error) -> {
|
||||
if (response != null) {
|
||||
final TLRPC.Updates updates = (TLRPC.Updates) response;
|
||||
getMessagesController().processUpdates(updates, false);
|
||||
if (!updates.chats.isEmpty()) {
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
TLRPC.Chat chat = updates.chats.get(0);
|
||||
getMessagesController().loadFullChat(chat.id, 0, true);
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (i == 0 && type == TYPE_BANNED || i == 1) {
|
||||
removeParticipants(participant);
|
||||
}
|
||||
} else {
|
||||
if (i == 0) {
|
||||
TLRPC.User user;
|
||||
TLRPC.Chat chat;
|
||||
if (peerId > 0) {
|
||||
user = getMessagesController().getUser(peerId);
|
||||
chat = null;
|
||||
} else {
|
||||
user = null;
|
||||
chat = getMessagesController().getChat(-peerId);
|
||||
}
|
||||
getMessagesController().deleteParticipantFromChat(chatId, user, chat, false, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
AlertDialog alertDialog = builder.create();
|
||||
showDialog(alertDialog);
|
||||
if (type == TYPE_ADMIN) {
|
||||
alertDialog.setItemColor(items.length - 1, Theme.getColor(Theme.key_dialogTextRed), Theme.getColor(Theme.key_dialogRedIcon));
|
||||
options.add(R.drawable.msg_remove, LocaleController.getString("ChannelRemoveUserAdmin", R.string.ChannelRemoveUserAdmin), true, () -> {
|
||||
getMessagesController().setUserAdminRole(chatId, getMessagesController().getUser(peerId), new TLRPC.TL_chatAdminRights(), "", !isChannel, ChatUsersActivity.this, false, false, null, null);
|
||||
removeParticipants(peerId);
|
||||
});
|
||||
}
|
||||
|
||||
options.setScrimViewBackground(new ColorDrawable(Theme.getColor(Theme.key_windowBackgroundWhite)));
|
||||
options.setMinWidth(190);
|
||||
|
||||
boolean result = options.getItemsCount() > 0;
|
||||
if (resultOnly || !result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
options.show();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void deletePeer(long peerId) {
|
||||
TLRPC.TL_channels_editBanned req = new TLRPC.TL_channels_editBanned();
|
||||
req.participant = getMessagesController().getInputPeer(peerId);
|
||||
req.channel = getMessagesController().getInputChannel(chatId);
|
||||
req.banned_rights = new TLRPC.TL_chatBannedRights();
|
||||
getConnectionsManager().sendRequest(req, (response, error) -> {
|
||||
if (response != null) {
|
||||
final TLRPC.Updates updates = (TLRPC.Updates) response;
|
||||
getMessagesController().processUpdates(updates, false);
|
||||
if (!updates.chats.isEmpty()) {
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
TLRPC.Chat chat = updates.chats.get(0);
|
||||
getMessagesController().loadFullChat(chat.id, 0, true);
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didReceivedNotification(int id, int account, Object... args) {
|
||||
if (id == NotificationCenter.chatInfoDidLoad) {
|
||||
|
@ -2825,7 +2760,7 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
TLObject object = getItem((Integer) cell.getTag());
|
||||
if (object instanceof TLRPC.ChannelParticipant) {
|
||||
TLRPC.ChannelParticipant participant = (TLRPC.ChannelParticipant) object;
|
||||
return createMenuForParticipant(participant, !click);
|
||||
return createMenuForParticipant(participant, !click, cell);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -3044,7 +2979,7 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
manageChatUserCell.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
||||
manageChatUserCell.setDelegate((cell, click) -> {
|
||||
TLObject participant = listViewAdapter.getItem((Integer) cell.getTag());
|
||||
return createMenuForParticipant(participant, !click);
|
||||
return createMenuForParticipant(participant, !click, cell);
|
||||
});
|
||||
view = manageChatUserCell;
|
||||
break;
|
||||
|
@ -3427,10 +3362,10 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
case 12:
|
||||
TextCell textCell = (TextCell) holder.itemView;
|
||||
if (position == antiSpamRow) {
|
||||
textCell.getCheckBox().setIcon(ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_DELETE_MESSAGES) && (info == null || info.antispam || info.participants_count >= getMessagesController().telegramAntispamGroupSizeMin) ? 0 : R.drawable.permission_locked);
|
||||
textCell.getCheckBox().setIcon(ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_DELETE_MESSAGES) && (info == null || info.antispam || getParticipantsCount() >= getMessagesController().telegramAntispamGroupSizeMin) ? 0 : R.drawable.permission_locked);
|
||||
textCell.setTextAndCheckAndIcon(LocaleController.getString("ChannelAntiSpam", R.string.ChannelAntiSpam), info != null && info.antispam, R.drawable.msg_policy, false);
|
||||
} else if (position == hideMembersRow) {
|
||||
textCell.getCheckBox().setIcon(ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_BLOCK_USERS) && (info == null || info.participants_hidden || info.participants_count >= getMessagesController().hiddenMembersGroupSizeMin) ? 0 : R.drawable.permission_locked);
|
||||
textCell.getCheckBox().setIcon(ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_BLOCK_USERS) && (info == null || info.participants_hidden || getParticipantsCount() >= getMessagesController().hiddenMembersGroupSizeMin) ? 0 : R.drawable.permission_locked);
|
||||
textCell.setTextAndCheck(LocaleController.getString("ChannelHideMembers", R.string.ChannelHideMembers), info != null && info.participants_hidden, false);
|
||||
}
|
||||
break;
|
||||
|
|