Skip to content

Commit

Permalink
Merge upstream 'v5.52.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
valldrac committed Oct 12, 2022
2 parents 66119e9 + db0bca0 commit 9a81693
Show file tree
Hide file tree
Showing 270 changed files with 9,692 additions and 3,272 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ ktlint {
version = "0.43.2"
}

def canonicalVersionCode = 1136
def canonicalVersionName = "5.51.7"
def canonicalVersionCode = 1142
def canonicalVersionName = "5.52.5"
def mollyRevision = 0

def postFixSize = 100
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,10 @@
android:theme="@style/Theme.Signal.DayNight.NoActionBar"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>

<activity android:name=".mediapreview.MediaPreviewV2Activity"
android:exported="false"
android:theme="@style/Theme.Signal.DayNight.NoActionBar" />

<service android:enabled="true" android:name=".service.webrtc.WebRtcCallService" android:foregroundServiceType="camera|microphone"/>
<service android:enabled="true" android:exported="false" android:name=".service.KeyCachingService"/>
<service android:enabled="true" android:exported="false" android:name=".service.WipeMemoryService"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord;
import org.thoughtcrime.securesms.database.loaders.PagingMediaLoader;
import org.thoughtcrime.securesms.mediaoverview.MediaOverviewActivity;
import org.thoughtcrime.securesms.mediapreview.MediaIntentFactory;
import org.thoughtcrime.securesms.mediapreview.MediaPreviewFragment;
import org.thoughtcrime.securesms.mediapreview.MediaPreviewViewModel;
import org.thoughtcrime.securesms.mediapreview.MediaRailAdapter;
Expand Down Expand Up @@ -98,18 +99,6 @@ public final class MediaPreviewActivity extends PassphraseRequiredActivity

private final static String TAG = Log.tag(MediaPreviewActivity.class);

private static final int NOT_IN_A_THREAD = -2;

public static final String THREAD_ID_EXTRA = "thread_id";
public static final String DATE_EXTRA = "date";
public static final String SIZE_EXTRA = "size";
public static final String CAPTION_EXTRA = "caption";
public static final String LEFT_IS_RECENT_EXTRA = "left_is_recent";
public static final String HIDE_ALL_MEDIA_EXTRA = "came_from_all_media";
public static final String SHOW_THREAD_EXTRA = "show_thread";
public static final String SORTING_EXTRA = "sorting";
public static final String IS_VIDEO_GIF = "is_video_gif";

private ViewPager mediaPager;
private View detailsContainer;
private TextView caption;
Expand All @@ -127,7 +116,7 @@ public final class MediaPreviewActivity extends PassphraseRequiredActivity
private ViewPagerListener viewPagerListener;

private int restartItem = -1;
private long threadId = NOT_IN_A_THREAD;
private long threadId = MediaIntentFactory.NOT_IN_A_THREAD;
private boolean cameFromAllMedia;
private boolean showThread;
private MediaDatabase.Sorting sorting;
Expand All @@ -143,12 +132,12 @@ public final class MediaPreviewActivity extends PassphraseRequiredActivity
{
DatabaseAttachment attachment = Objects.requireNonNull(mediaRecord.getAttachment());
Intent intent = new Intent(context, MediaPreviewActivity.class);
intent.putExtra(MediaPreviewActivity.THREAD_ID_EXTRA, mediaRecord.getThreadId());
intent.putExtra(MediaPreviewActivity.DATE_EXTRA, mediaRecord.getDate());
intent.putExtra(MediaPreviewActivity.SIZE_EXTRA, attachment.getSize());
intent.putExtra(MediaPreviewActivity.CAPTION_EXTRA, attachment.getCaption());
intent.putExtra(MediaPreviewActivity.LEFT_IS_RECENT_EXTRA, leftIsRecent);
intent.putExtra(MediaPreviewActivity.IS_VIDEO_GIF, attachment.isVideoGif());
intent.putExtra(MediaIntentFactory.THREAD_ID_EXTRA, mediaRecord.getThreadId());
intent.putExtra(MediaIntentFactory.DATE_EXTRA, mediaRecord.getDate());
intent.putExtra(MediaIntentFactory.SIZE_EXTRA, attachment.getSize());
intent.putExtra(MediaIntentFactory.CAPTION_EXTRA, attachment.getCaption());
intent.putExtra(MediaIntentFactory.LEFT_IS_RECENT_EXTRA, leftIsRecent);
intent.putExtra(MediaIntentFactory.IS_VIDEO_GIF, attachment.isVideoGif());
intent.setDataAndType(attachment.getUri(), mediaRecord.getContentType());
return intent;
}
Expand Down Expand Up @@ -305,17 +294,17 @@ private void initializeViews() {
private void initializeResources() {
Intent intent = getIntent();

threadId = intent.getLongExtra(THREAD_ID_EXTRA, NOT_IN_A_THREAD);
cameFromAllMedia = intent.getBooleanExtra(HIDE_ALL_MEDIA_EXTRA, false);
showThread = intent.getBooleanExtra(SHOW_THREAD_EXTRA, false);
sorting = MediaDatabase.Sorting.values()[intent.getIntExtra(SORTING_EXTRA, 0)];
threadId = intent.getLongExtra(MediaIntentFactory.THREAD_ID_EXTRA, MediaIntentFactory.NOT_IN_A_THREAD);
cameFromAllMedia = intent.getBooleanExtra(MediaIntentFactory.HIDE_ALL_MEDIA_EXTRA, false);
showThread = intent.getBooleanExtra(MediaIntentFactory.SHOW_THREAD_EXTRA, false);
sorting = MediaDatabase.Sorting.values()[intent.getIntExtra(MediaIntentFactory.SORTING_EXTRA, 0)];

initialMediaUri = intent.getData();
initialMediaType = intent.getType();
initialMediaSize = intent.getLongExtra(SIZE_EXTRA, 0);
initialCaption = intent.getStringExtra(CAPTION_EXTRA);
leftIsRecent = intent.getBooleanExtra(LEFT_IS_RECENT_EXTRA, false);
initialMediaIsVideoGif = intent.getBooleanExtra(IS_VIDEO_GIF, false);
initialMediaSize = intent.getLongExtra(MediaIntentFactory.SIZE_EXTRA, 0);
initialCaption = intent.getStringExtra(MediaIntentFactory.CAPTION_EXTRA);
leftIsRecent = intent.getBooleanExtra(MediaIntentFactory.LEFT_IS_RECENT_EXTRA, false);
initialMediaIsVideoGif = intent.getBooleanExtra(MediaIntentFactory.IS_VIDEO_GIF, false);
restartItem = -1;
}

Expand Down Expand Up @@ -533,7 +522,7 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
}

private boolean isMediaInDb() {
return threadId != NOT_IN_A_THREAD;
return threadId != MediaIntentFactory.NOT_IN_A_THREAD;
}

private @Nullable MediaItem getCurrentMediaItem() {
Expand Down Expand Up @@ -789,7 +778,7 @@ public Fragment getItem(int position) {

cursor.moveToPosition(cursorPosition);

MediaDatabase.MediaRecord mediaRecord = MediaDatabase.MediaRecord.from(context, cursor);
MediaDatabase.MediaRecord mediaRecord = MediaDatabase.MediaRecord.from(cursor);
DatabaseAttachment attachment = Objects.requireNonNull(mediaRecord.getAttachment());
MediaPreviewFragment fragment = MediaPreviewFragment.newInstance(attachment, autoPlay);

Expand Down Expand Up @@ -819,7 +808,7 @@ public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Obj

cursor.moveToPosition(cursorPosition);

MediaRecord mediaRecord = MediaRecord.from(context, cursor);
MediaRecord mediaRecord = MediaRecord.from(cursor);
DatabaseAttachment attachment = Objects.requireNonNull(mediaRecord.getAttachment());
RecipientId recipientId = mediaRecord.getRecipientId();
RecipientId threadRecipientId = mediaRecord.getThreadRecipientId();
Expand Down Expand Up @@ -890,4 +879,4 @@ interface MediaItemAdapter {
@Nullable View getPlaybackControls(int position);
boolean hasFragmentFor(int position);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

import androidx.annotation.NonNull;
import androidx.viewpager.widget.ViewPager;
import androidx.viewpager2.widget.ViewPager2;

/**
* Based on https://developer.android.com/training/animation/screen-slide#depth-page
*/
public final class DepthPageTransformer implements ViewPager.PageTransformer {
public final class DepthPageTransformer implements ViewPager.PageTransformer, ViewPager2.PageTransformer {
private static final float MIN_SCALE = 0.75f;

public void transformPage(@NonNull View view, float position) {
Expand Down
55 changes: 55 additions & 0 deletions app/src/main/java/org/thoughtcrime/securesms/color/ViewColorSet.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package org.thoughtcrime.securesms.color

import android.content.Context
import android.os.Parcelable
import androidx.annotation.ColorInt
import androidx.annotation.ColorRes
import androidx.core.content.ContextCompat
import kotlinx.parcelize.Parcelize
import org.thoughtcrime.securesms.R

/**
* Represents a set of colors to be applied to the foreground and background of a view.
*
* Supports mixing color ints and color resource ids.
*/
@Parcelize
data class ViewColorSet(
val foreground: ViewColor,
val background: ViewColor
) : Parcelable {
companion object {
val PRIMARY = ViewColorSet(
foreground = ViewColor.ColorResource(R.color.signal_colorOnPrimary),
background = ViewColor.ColorResource(R.color.signal_colorPrimary)
)

fun forCustomColor(@ColorInt customColor: Int): ViewColorSet {
return ViewColorSet(
foreground = ViewColor.ColorResource(R.color.signal_colorOnCustom),
background = ViewColor.ColorValue(customColor)
)
}
}

@Parcelize
sealed class ViewColor : Parcelable {

@ColorInt
abstract fun resolve(context: Context): Int

@Parcelize
data class ColorValue(@ColorInt val colorInt: Int) : ViewColor() {
override fun resolve(context: Context): Int {
return colorInt
}
}

@Parcelize
data class ColorResource(@ColorRes val colorRes: Int) : ViewColor() {
override fun resolve(context: Context): Int {
return ContextCompat.getColor(context, colorRes)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.thoughtcrime.securesms.components

import androidx.fragment.app.DialogFragment
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner

/**
* Manages the lifecycle of displaying a dialog fragment. Will automatically close and nullify the reference
* if the bound lifecycle is destroyed, and handles repeat calls to show such that no more than one dialog is
* displayed.
*/
class DialogFragmentDisplayManager(private val builder: () -> DialogFragment) : DefaultLifecycleObserver {

private var dialogFragment: DialogFragment? = null

fun show(lifecycleOwner: LifecycleOwner, fragmentManager: FragmentManager, tag: String? = null) {
val fragment = dialogFragment ?: builder()
if (fragment.dialog?.isShowing != true) {
fragment.show(fragmentManager, tag)
dialogFragment = fragment
lifecycleOwner.lifecycle.addObserver(this)
}
}

fun hide() {
dialogFragment?.dismissNow()
dialogFragment = null
}

override fun onDestroy(owner: LifecycleOwner) {
owner.lifecycle.removeObserver(this)
hide()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;

import org.signal.core.util.BreakIteratorCompat;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.components.emoji.SimpleEmojiTextView;
Expand All @@ -19,6 +20,7 @@
import org.thoughtcrime.securesms.util.SpanUtil;
import org.thoughtcrime.securesms.util.ViewUtil;

import java.util.Iterator;
import java.util.Objects;

public class FromTextView extends SimpleEmojiTextView {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.thoughtcrime.securesms.components

import android.app.Dialog
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import androidx.fragment.app.DialogFragment
import org.thoughtcrime.securesms.R

/**
* Displays a small progress spinner in a card view, as a non-cancellable dialog fragment.
*/
class ProgressCardDialogFragment : DialogFragment(R.layout.progress_card_dialog) {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
isCancelable = false
return super.onCreateDialog(savedInstanceState).apply {
this.window!!.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,11 @@ private void setQuoteText(@Nullable CharSequence body,
missingStoryReaction.setVisibility(View.GONE);
}

boolean isTextStory = !attachments.containsMediaSlide() && isStoryReply();

StoryTextPostModel textPostModel = isStoryReply() ? getStoryTextPost(body) : null;
if (!TextUtils.isEmpty(body) || !attachments.containsMediaSlide()) {
if (isTextStory && body != null) {
if (textPostModel != null) {
try {
bodyView.setText(getStoryTextPost(body).getText());
bodyView.setText(textPostModel.getText());
} catch (Exception e) {
Log.w(TAG, "Could not parse body of text post.", e);
bodyView.setText("");
Expand Down Expand Up @@ -364,8 +363,8 @@ private void setQuoteAttachment(@NonNull GlideRequests glideRequests, @NonNull C
mainView.setMinimumHeight(isStoryReply() && originalMissing ? 0 : thumbHeight);
thumbnailView.setPadding(0, 0, 0, 0);

if (!attachments.containsMediaSlide() && isStoryReply()) {
StoryTextPostModel model = getStoryTextPost(body);
StoryTextPostModel model = isStoryReply() ? getStoryTextPost(body) : null;
if (model != null) {
attachmentVideoOverlayView.setVisibility(GONE);
attachmentContainerView.setVisibility(GONE);
thumbnailView.setVisibility(VISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public ThreadPhotoViewHolder onCreateItemViewHolder(ViewGroup parent, int viewTy
@Override
public void onBindItemViewHolder(ThreadPhotoViewHolder viewHolder, @NonNull Cursor cursor) {
ThumbnailView imageView = viewHolder.imageView;
MediaDatabase.MediaRecord mediaRecord = MediaDatabase.MediaRecord.from(getContext(), cursor);
MediaDatabase.MediaRecord mediaRecord = MediaDatabase.MediaRecord.from(cursor);
Slide slide = MediaUtil.getSlideForAttachment(getContext(), mediaRecord.getAttachment());

if (slide != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ sealed class DSLSettingsText {
}

object TitleLargeModifier : TextAppearanceModifier(R.style.Signal_Text_TitleLarge)
object TitleMediumModifier : TextAppearanceModifier(R.style.Signal_Text_TitleMedium)
object Body1BoldModifier : TextAppearanceModifier(R.style.TextAppearance_Signal_Body1_Bold)

open class TextAppearanceModifier(@StyleRes private val textAppearance: Int) : Modifier {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import org.thoughtcrime.securesms.util.navigation.safeNavigate
import java.util.Optional
import java.util.concurrent.TimeUnit
import kotlin.math.max
import kotlin.time.Duration.Companion.seconds

class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__internal_preferences) {

Expand Down Expand Up @@ -190,6 +191,25 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter

sectionHeaderPref(R.string.preferences__internal_network)

switchPref(
title = DSLSettingsText.from("Force websocket mode"),
summary = DSLSettingsText.from("Pretend you have no Play Services. Ignores websocket messages and keeps the websocket open in a foreground service. You have to manually force-stop the app for changes to take effect."),
isChecked = state.forceWebsocketMode,
onClick = {
viewModel.setForceWebsocketMode(!state.forceWebsocketMode)
SimpleTask.run({
val jobState = ApplicationDependencies.getJobManager().runSynchronously(RefreshAttributesJob(), 10.seconds.inWholeMilliseconds)
return@run jobState.isPresent && jobState.get().isComplete
}, { success ->
if (success) {
Toast.makeText(context, "Successfully refreshed attributes. Force-stop the app for changes to take effect.", Toast.LENGTH_SHORT).show()
} else {
Toast.makeText(context, "Failed to refresh attributes.", Toast.LENGTH_SHORT).show()
}
})
}
)

switchPref(
title = DSLSettingsText.from(R.string.preferences__internal_allow_censorship_toggle),
summary = DSLSettingsText.from(R.string.preferences__internal_allow_censorship_toggle_description),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ data class InternalSettingsState(
val gv2ignoreServerChanges: Boolean,
val gv2ignoreP2PChanges: Boolean,
val allowCensorshipSetting: Boolean,
val forceWebsocketMode: Boolean,
val callingServer: String,
val callingAudioProcessingMethod: CallManager.AudioProcessingMethod,
val callingBandwidthMode: CallManager.BandwidthMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ class InternalSettingsViewModel(private val repository: InternalSettingsReposito
refresh()
}

fun setForceWebsocketMode(enabled: Boolean) {
preferenceDataStore.putBoolean(InternalValues.FORCE_WEBSOCKET_MODE, enabled)
refresh()
}

fun setUseBuiltInEmoji(enabled: Boolean) {
preferenceDataStore.putBoolean(InternalValues.FORCE_BUILT_IN_EMOJI, enabled)
refresh()
Expand Down Expand Up @@ -103,6 +108,7 @@ class InternalSettingsViewModel(private val repository: InternalSettingsReposito
gv2ignoreServerChanges = SignalStore.internalValues().gv2IgnoreServerChanges(),
gv2ignoreP2PChanges = SignalStore.internalValues().gv2IgnoreP2PChanges(),
allowCensorshipSetting = SignalStore.internalValues().allowChangingCensorshipSetting(),
forceWebsocketMode = SignalStore.internalValues().isWebsocketModeForced,
callingServer = SignalStore.internalValues().groupCallingServer(),
callingAudioProcessingMethod = SignalStore.internalValues().callingAudioProcessingMethod(),
callingBandwidthMode = SignalStore.internalValues().callingBandwidthMode(),
Expand Down
Loading

0 comments on commit 9a81693

Please sign in to comment.