Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into cust_remove_call_…
Browse files Browse the repository at this point in the history
…confirm
  • Loading branch information
simonsso committed Jan 26, 2021
2 parents 0dad625 + 9099969 commit 65d45da
Show file tree
Hide file tree
Showing 25 changed files with 394 additions and 196 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ protobuf {
}
}

def canonicalVersionCode = 778
def canonicalVersionName = "5.3.5"
def canonicalVersionCode = 779
def canonicalVersionName = "5.3.6"

def postFixSize = 100
def abiPostFix = ['universal' : 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2950,6 +2950,7 @@ public void onRecorderStarted() {
@Override
public void onRecorderLocked() {
updateToggleButtonState();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}

@Override
Expand Down Expand Up @@ -3014,6 +3015,7 @@ public void onRecorderCanceled() {
vibrator.vibrate(50);

getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);

ListenableFuture<Pair<Uri, Long>> future = audioRecorder.stopRecording();
future.addListener(new ListenableFuture.Listener<Pair<Uri, Long>>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,7 @@ private static boolean shouldCollapse(@NonNull MessageRecord current, @NonNull O

/** After a short delay, if the main data hasn't shown yet, then a loading message is displayed. */
private @NonNull LiveData<Spannable> loading(@NonNull LiveData<Spannable> string) {
// TODO [greyson] This sometimes isn't working and can instead get stuck on 'loading'.
return string;
// return LiveDataUtil.until(string, LiveDataUtil.delay(250, new SpannableString(getContext().getString(R.string.ConversationUpdateItem_loading))));
return LiveDataUtil.until(string, LiveDataUtil.delay(250, new SpannableString(getContext().getString(R.string.ConversationUpdateItem_loading))));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.thoughtcrime.securesms.util.AppSignatureUtil;
import org.thoughtcrime.securesms.util.ByteUnit;
import org.thoughtcrime.securesms.util.CensorshipUtil;
import org.thoughtcrime.securesms.util.DeviceProperties;
import org.thoughtcrime.securesms.util.ServiceUtil;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.util.Util;
Expand Down Expand Up @@ -54,6 +55,7 @@ public class LogSectionSystemInfo implements LogSection {
builder.append("ABIs : ").append(TextUtils.join(", ", getSupportedAbis())).append("\n");
builder.append("Memory : ").append(getMemoryUsage()).append("\n");
builder.append("Memclass : ").append(getMemoryClass(context)).append("\n");
builder.append("MemInfo : ").append(getMemoryInfo(context)).append("\n");
builder.append("OS Host : ").append(Build.HOST).append("\n");
builder.append("Censored : ").append(CensorshipUtil.isCensored(context)).append("\n");
builder.append("Play Services : ").append(getPlayServicesString(context)).append("\n");
Expand Down Expand Up @@ -102,6 +104,12 @@ public class LogSectionSystemInfo implements LogSection {
return activityManager.getMemoryClass() + lowMem;
}

private static @NonNull String getMemoryInfo(Context context) {
ActivityManager.MemoryInfo info = DeviceProperties.getMemoryInfo(context);
return String.format(Locale.US, "availMem: %d mb, totalMem: %d mb, threshold: %d mb, lowMemory: %b",
ByteUnit.BYTES.toMegabytes(info.availMem), ByteUnit.BYTES.toMegabytes(info.totalMem), ByteUnit.BYTES.toMegabytes(info.threshold), info.lowMemory);
}

private static @NonNull Iterable<String> getSupportedAbis() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return Arrays.asList(Build.SUPPORTED_ABIS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public final class LiveRecipient {
private final GroupDatabase groupDatabase;
private final MutableLiveData<Object> refreshForceNotify;

LiveRecipient(@NonNull Context context, @NonNull MutableLiveData<Recipient> liveData, @NonNull Recipient defaultRecipient) {
LiveRecipient(@NonNull Context context, @NonNull Recipient defaultRecipient) {
this.context = context.getApplicationContext();
this.liveData = liveData;
this.liveData = new MutableLiveData<>(defaultRecipient);
this.recipient = new AtomicReference<>(defaultRecipient);
this.recipientDatabase = DatabaseFactory.getRecipientDatabase(context);
this.groupDatabase = DatabaseFactory.getGroupDatabase(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
import androidx.annotation.AnyThread;
import androidx.annotation.GuardedBy;
import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.annimon.stream.Stream;

import org.signal.core.util.concurrent.SignalExecutors;
import org.signal.core.util.logging.Log;
Expand All @@ -22,7 +19,6 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.UUID;
Expand Down Expand Up @@ -50,7 +46,7 @@ public LiveRecipientCache(@NonNull Context context) {
this.context = context.getApplicationContext();
this.recipientDatabase = DatabaseFactory.getRecipientDatabase(context);
this.recipients = new LRUCache<>(CACHE_MAX);
this.unknown = new LiveRecipient(context, new MutableLiveData<>(), Recipient.UNKNOWN);
this.unknown = new LiveRecipient(context, Recipient.UNKNOWN);
}

@AnyThread
Expand All @@ -60,7 +56,7 @@ public LiveRecipientCache(@NonNull Context context) {
LiveRecipient live = recipients.get(id);

if (live == null) {
final LiveRecipient newLive = new LiveRecipient(context, new MutableLiveData<>(), new Recipient(id));
final LiveRecipient newLive = new LiveRecipient(context, new Recipient(id));

recipients.put(id, newLive);

Expand Down Expand Up @@ -93,7 +89,7 @@ public synchronized void addToCache(@NonNull Collection<Recipient> newRecipients
boolean needsResolve = false;

if (live == null) {
live = new LiveRecipient(context, new MutableLiveData<>(), recipient);
live = new LiveRecipient(context, recipient);
recipients.put(recipient.getId(), live);
needsResolve = recipient.isResolving();
} else if (live.get().isResolving() || !recipient.isResolving()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.thoughtcrime.securesms.util;

import android.app.ActivityManager;
import android.app.ActivityManager.MemoryInfo;
import android.content.Context;
import android.os.Build;

import androidx.annotation.NonNull;

Expand All @@ -15,7 +17,17 @@ public final class DeviceProperties {
* large numbers of APNGs simultaneously.
*/
public static boolean shouldAllowApngStickerAnimation(@NonNull Context context) {
return !isLowMemoryDevice(context) && getMemoryClass(context) >= FeatureFlags.animatedStickerMinimumMemory();
if (Build.VERSION.SDK_INT < 26) {
return false;
}

MemoryInfo memoryInfo = getMemoryInfo(context);
int memoryMb = (int) ByteUnit.BYTES.toMegabytes(memoryInfo.totalMem);

return !isLowMemoryDevice(context) &&
!memoryInfo.lowMemory &&
(memoryMb >= FeatureFlags.animatedStickerMinimumTotalMemoryMb() ||
getMemoryClass(context) >= FeatureFlags.animatedStickerMinimumMemoryClass());
}

public static boolean isLowMemoryDevice(@NonNull Context context) {
Expand All @@ -27,4 +39,13 @@ public static int getMemoryClass(@NonNull Context context) {
ActivityManager activityManager = ServiceUtil.getActivityManager(context);
return activityManager.getMemoryClass();
}

public static @NonNull MemoryInfo getMemoryInfo(@NonNull Context context) {
MemoryInfo info = new MemoryInfo();
ActivityManager activityManager = ServiceUtil.getActivityManager(context);

activityManager.getMemoryInfo(info);

return info;
}
}
64 changes: 36 additions & 28 deletions app/src/main/java/org/thoughtcrime/securesms/util/FeatureFlags.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,31 @@ public final class FeatureFlags {

private static final long FETCH_INTERVAL = TimeUnit.HOURS.toMillis(2);

private static final String USERNAMES = "android.usernames";
private static final String GROUPS_V2_RECOMMENDED_LIMIT = "global.groupsv2.maxGroupSize";
private static final String GROUPS_V2_HARD_LIMIT = "global.groupsv2.groupSizeHardLimit";
private static final String GROUP_NAME_MAX_LENGTH = "global.groupsv2.maxNameLength";
private static final String INTERNAL_USER = "android.internalUser";
private static final String VERIFY_V2 = "android.verifyV2";
private static final String PHONE_NUMBER_PRIVACY_VERSION = "android.phoneNumberPrivacyVersion";
private static final String CLIENT_EXPIRATION = "android.clientExpiration";
public static final String RESEARCH_MEGAPHONE_1 = "research.megaphone.1";
public static final String DONATE_MEGAPHONE = "android.donate";
private static final String VIEWED_RECEIPTS = "android.viewed.receipts";
private static final String GROUP_CALLING = "android.groupsv2.calling.2";
private static final String GV1_MANUAL_MIGRATE = "android.groupsV1Migration.manual";
private static final String GV1_FORCED_MIGRATE = "android.groupsV1Migration.forced";
private static final String GV1_MIGRATION_JOB = "android.groupsV1Migration.job";
private static final String SEND_VIEWED_RECEIPTS = "android.sendViewedReceipts";
private static final String CUSTOM_VIDEO_MUXER = "android.customVideoMuxer";
private static final String CDS_REFRESH_INTERVAL = "cds.syncInterval.seconds";
private static final String AUTOMATIC_SESSION_RESET = "android.automaticSessionReset.2";
private static final String AUTOMATIC_SESSION_INTERVAL = "android.automaticSessionResetInterval";
private static final String DEFAULT_MAX_BACKOFF = "android.defaultMaxBackoff";
private static final String OKHTTP_AUTOMATIC_RETRY = "android.okhttpAutomaticRetry";
private static final String SHARE_SELECTION_LIMIT = "android.share.limit";
private static final String ANIMATED_STICKER_MIN_MEMORY = "android.animatedStickerMinMemory";
private static final String USERNAMES = "android.usernames";
private static final String GROUPS_V2_RECOMMENDED_LIMIT = "global.groupsv2.maxGroupSize";
private static final String GROUPS_V2_HARD_LIMIT = "global.groupsv2.groupSizeHardLimit";
private static final String GROUP_NAME_MAX_LENGTH = "global.groupsv2.maxNameLength";
private static final String INTERNAL_USER = "android.internalUser";
private static final String VERIFY_V2 = "android.verifyV2";
private static final String PHONE_NUMBER_PRIVACY_VERSION = "android.phoneNumberPrivacyVersion";
private static final String CLIENT_EXPIRATION = "android.clientExpiration";
public static final String RESEARCH_MEGAPHONE_1 = "research.megaphone.1";
public static final String DONATE_MEGAPHONE = "android.donate";
private static final String VIEWED_RECEIPTS = "android.viewed.receipts";
private static final String GROUP_CALLING = "android.groupsv2.calling.2";
private static final String GV1_MANUAL_MIGRATE = "android.groupsV1Migration.manual";
private static final String GV1_FORCED_MIGRATE = "android.groupsV1Migration.forced";
private static final String GV1_MIGRATION_JOB = "android.groupsV1Migration.job";
private static final String SEND_VIEWED_RECEIPTS = "android.sendViewedReceipts";
private static final String CUSTOM_VIDEO_MUXER = "android.customVideoMuxer";
private static final String CDS_REFRESH_INTERVAL = "cds.syncInterval.seconds";
private static final String AUTOMATIC_SESSION_RESET = "android.automaticSessionReset.2";
private static final String AUTOMATIC_SESSION_INTERVAL = "android.automaticSessionResetInterval";
private static final String DEFAULT_MAX_BACKOFF = "android.defaultMaxBackoff";
private static final String OKHTTP_AUTOMATIC_RETRY = "android.okhttpAutomaticRetry";
private static final String SHARE_SELECTION_LIMIT = "android.share.limit";
private static final String ANIMATED_STICKER_MIN_MEMORY = "android.animatedStickerMinMemory";
private static final String ANIMATED_STICKER_MIN_TOTAL_MEMORY = "android.animatedStickerMinTotalMemory";

/**
* We will only store remote values for flags in this set. If you want a flag to be controllable
Expand Down Expand Up @@ -102,7 +103,8 @@ public final class FeatureFlags {
DEFAULT_MAX_BACKOFF,
OKHTTP_AUTOMATIC_RETRY,
SHARE_SELECTION_LIMIT,
ANIMATED_STICKER_MIN_MEMORY
ANIMATED_STICKER_MIN_MEMORY,
ANIMATED_STICKER_MIN_TOTAL_MEMORY
);

@VisibleForTesting
Expand Down Expand Up @@ -142,7 +144,8 @@ public final class FeatureFlags {
DEFAULT_MAX_BACKOFF,
OKHTTP_AUTOMATIC_RETRY,
SHARE_SELECTION_LIMIT,
ANIMATED_STICKER_MIN_MEMORY
ANIMATED_STICKER_MIN_MEMORY,
ANIMATED_STICKER_MIN_TOTAL_MEMORY
);

/**
Expand Down Expand Up @@ -327,11 +330,16 @@ public static boolean okHttpAutomaticRetry() {
return getBoolean(OKHTTP_AUTOMATIC_RETRY, false);
}

/** The minimum amount of memory required for rendering animated stickers in the keyboard and such */
public static int animatedStickerMinimumMemory() {
/** The minimum memory class required for rendering animated stickers in the keyboard and such */
public static int animatedStickerMinimumMemoryClass() {
return getInteger(ANIMATED_STICKER_MIN_MEMORY, 193);
}

/** The minimum total memory for rendering animated stickers in the keyboard and such */
public static int animatedStickerMinimumTotalMemoryMb() {
return getInteger(ANIMATED_STICKER_MIN_TOTAL_MEMORY, (int) ByteUnit.GIGABYTES.toMegabytes(3));
}

/** Only for rendering debug info. */
public static synchronized @NonNull Map<String, Object> getMemoryValues() {
return new TreeMap<>(REMOTE_VALUES);
Expand Down
20 changes: 10 additions & 10 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,7 @@
<string name="DeviceProvisioningActivity_content_progress_key_error">الرمز باطل.</string>
<string name="DeviceProvisioningActivity_sorry_you_have_too_many_devices_linked_already">عذرا، لديك عدة أجهزة مرتبطة. يرجى إزالة بعضها</string>
<string name="DeviceActivity_sorry_this_is_not_a_valid_device_link_qr_code">عذرا، الرابط غير صحيح.</string>
<string name="DeviceProvisioningActivity_link_a_signal_device">الربط بجهاز Signal؟</string>
<string name="DeviceProvisioningActivity_link_a_signal_device">ربط جهاز Signal آخر ؟</string>
<string name="DeviceProvisioningActivity_it_looks_like_youre_trying_to_link_a_signal_device_using_a_3rd_party_scanner">يبدو أنك تحاول ربط جهاز Signal باستخدام ماسح ضوئي من طرف ثالث. الرجاء مسح الرمز مرّة أخرى باستخدام Signal من أجل حمايتك.</string>
<string name="DeviceActivity_signal_needs_the_camera_permission_in_order_to_scan_a_qr_code">يحتاج Signal إلى إذن الوصول إلى الكاميرا من أجل مسح الرمز المربع ضوئيا ولكن رُفض الإذن على نحو دائم، الرجاء زيارة إعدادات التطبيق، ثم اختيار « الصلاحيات »، ثم تفعيل « الكاميرا ».</string>
<string name="DeviceActivity_unable_to_scan_a_qr_code_without_the_camera_permission">لا يمكن مسح رمز الاستجابة السريع بدون منح إذن الوصول إلى الكاميرا</string>
Expand Down Expand Up @@ -1753,7 +1753,7 @@
<string name="WebRtcCallScreen__answer_without_video">أجب بدون فيديو</string>
<!--WebRtcAudioOutputToggle-->
<string name="WebRtcAudioOutputToggle__audio_output">مخرج الصوت</string>
<string name="WebRtcAudioOutputToggle__phone_earpiece">سماعة الهاتف الأذنية</string>
<string name="WebRtcAudioOutputToggle__phone_earpiece">سماعة أذن الهاتف</string>
<string name="WebRtcAudioOutputToggle__speaker">مكبر الصوت</string>
<string name="WebRtcAudioOutputToggle__bluetooth">بلوتوث</string>
<string name="WebRtcCallControls_answer_call_description">الرد على المكالمة</string>
Expand Down Expand Up @@ -1989,11 +1989,11 @@
<string name="EditAboutFragment_count">%d/%d</string>
<string name="EditAboutFragment_speak_freely">ما عليك إلا التحدث بكل حرية</string>
<string name="EditAboutFragment_encrypted">مُعمَّى</string>
<string name="EditAboutFragment_be_kind">كن لطيفاً</string>
<string name="EditAboutFragment_coffee_lover">محب للقهوة</string>
<string name="EditAboutFragment_free_to_chat">لديّ وقت للتحدث</string>
<string name="EditAboutFragment_taking_a_break">آخذ استراحة</string>
<string name="EditAboutFragment_working_on_something_new">أعمل على شيء جديد</string>
<string name="EditAboutFragment_be_kind">كن لطيفا</string>
<string name="EditAboutFragment_coffee_lover">من عشاق القهوة</string>
<string name="EditAboutFragment_free_to_chat">لدي الوقت للتحدث</string>
<string name="EditAboutFragment_taking_a_break">أنا في استراحة</string>
<string name="EditAboutFragment_working_on_something_new">أعمل حاليا على شيء جديد</string>
<!--EditProfileFragment-->
<string name="EditProfileFragment__edit_group_name_and_photo">عدّل اسم المجموعة وصورتها</string>
<string name="EditProfileFragment__group_name">اسم المجموعة</string>
Expand Down Expand Up @@ -2725,10 +2725,10 @@
<string name="ChatWallpaperFragment__set_wallpaper">ضبط الخلفية</string>
<string name="ChatWallpaperFragment__dark_theme_dims_wallpaper">إن النمط الداكن يجعل الخلفية معتمة</string>
<string name="ChatWallpaperFragment__clear_wallpaper">محو الخلفية</string>
<string name="ChatWallpaperFragment__clear_wallpaper_for_this_chat">مسح الخلفية لهذه المُحادثة؟</string>
<string name="ChatWallpaperFragment__clear_wallpaper_this_will_not">مسح الخلفية؟ هذا لن يؤدي إلى مسح الخلفيات المُخصصة التي قد قمت بتعيينها لمُحادثاتك.</string>
<string name="ChatWallpaperFragment__clear_wallpaper_for_this_chat">محو الخلفية لهذه المُحادثة ؟</string>
<string name="ChatWallpaperFragment__clear_wallpaper_this_will_not">أأمحو الخلفية ؟ لن يؤدي هذا إلى محو الخلفيات المخصصة التي قد قمت بضبطها لمحادثاتك.</string>
<string name="ChatWallpaperFragment__reset_all_wallpapers">إعادة التعيين كل الخلفيات</string>
<string name="ChatWallpaperFragment__reset_all_wallpapers_including_custom">إعادة تعيين جميع الخلفيات، بما في ذلك الخلفيات المُخصصة التي قد قمت بتعيينها لمُحادثاتك؟</string>
<string name="ChatWallpaperFragment__reset_all_wallpapers_including_custom">أأعيد تعيين جميع الخلفيات، بما في ذلك الخلفيات المخصصة التي قد قمت بضبطها لمحادثاتك ؟</string>
<string name="ChatWallpaperFragment__contact_name">اسم جهة الاتصال</string>
<string name="ChatWallpaperFragment__reset">إعادة التعيين</string>
<string name="ChatWallpaperFragment__clear">محو</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-cy/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,7 @@ Send neges heb ei ddiogelu?</string>
<string name="EditAboutFragment_about">Ynghylch</string>
<string name="EditAboutFragment_write_a_few_words_about_yourself">Ysgrifennwch ychydig o eiriau amdanoch…</string>
<string name="EditAboutFragment_count">%d/%d</string>
<string name="EditAboutFragment_encrypted">Amgryptiedig</string>
<string name="EditAboutFragment_be_kind">Byddwch yn garedig</string>
<string name="EditAboutFragment_coffee_lover">Carwr Coffi</string>
<string name="EditAboutFragment_free_to_chat">Ar gael i sgwrsio</string>
Expand Down
Loading

0 comments on commit 65d45da

Please sign in to comment.