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 Feb 13, 2021
2 parents db2465d + 60b9811 commit b075366
Show file tree
Hide file tree
Showing 28 changed files with 252 additions and 106 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ protobuf {
}
}

def canonicalVersionCode = 788
def canonicalVersionName = "5.4.2"
def canonicalVersionCode = 790
def canonicalVersionName = "5.4.4"

def postFixSize = 100
def abiPostFix = ['universal' : 0,
Expand Down Expand Up @@ -335,7 +335,7 @@ dependencies {
implementation project(':video')

implementation 'org.signal:zkgroup-android:0.7.0'
implementation 'org.whispersystems:signal-client-android:0.2.3'
implementation 'org.whispersystems:signal-client-android:0.1.5'
implementation 'com.google.protobuf:protobuf-javalite:3.10.0'
implementation 'org.signal:argon2:13.1@aar'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public void onCreate() {
Log.i(TAG, "onCreate()");
})
.addBlocking("crash-handling", this::initializeCrashHandling)
.addBlocking("notification-channels", () -> NotificationChannels.create(this))
.addBlocking("eat-db", () -> DatabaseFactory.getInstance(this))
.addBlocking("app-dependencies", this::initializeAppDependencies)
.addBlocking("first-launch", this::initializeFirstEverAppLaunch)
Expand Down Expand Up @@ -158,7 +159,6 @@ public void onCreate() {
.addNonBlocking(() -> ApplicationDependencies.getJobManager().beginJobLoop())
.addPostRender(this::initializeExpiringMessageManager)
.addPostRender(this::initializeBlobProvider)
.addPostRender(() -> NotificationChannels.create(this))
.execute();

Log.d(TAG, "onCreate() took " + (System.currentTimeMillis() - startTime) + " ms");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ public class ZoomingImageView extends FrameLayout {
private static final int ZOOM_TRANSITION_DURATION = 300;

private static final float ZOOM_LEVEL_MIN = 1.0f;
private static final float ZOOM_LEVEL_MID = 1.5f;
private static final float ZOOM_LEVEL_MAX = 2.0f;

private static final float LARGE_IMAGES_ZOOM_LEVEL_MID = 1.5f;
private static final float LARGE_IMAGES_ZOOM_LEVEL_MAX = 2.0f;

private static final float SMALL_IMAGES_ZOOM_LEVEL_MID = 3.0f;
private static final float SMALL_IMAGES_ZOOM_LEVEL_MAX = 8.0f;

private final PhotoView photoView;
private final SubsamplingScaleImageView subsamplingImageView;
Expand All @@ -65,10 +69,11 @@ public ZoomingImageView(Context context, AttributeSet attrs, int defStyleAttr) {
this.subsamplingImageView.setOrientation(SubsamplingScaleImageView.ORIENTATION_USE_EXIF);

this.photoView.setZoomTransitionDuration(ZOOM_TRANSITION_DURATION);
this.photoView.setScaleLevels(ZOOM_LEVEL_MIN, ZOOM_LEVEL_MID, ZOOM_LEVEL_MAX);
this.photoView.setScaleLevels(ZOOM_LEVEL_MIN, SMALL_IMAGES_ZOOM_LEVEL_MID, SMALL_IMAGES_ZOOM_LEVEL_MAX);

this.subsamplingImageView.setDoubleTapZoomDuration(ZOOM_TRANSITION_DURATION);
this.subsamplingImageView.setDoubleTapZoomScale(ZOOM_LEVEL_MID);
this.subsamplingImageView.setDoubleTapZoomScale(LARGE_IMAGES_ZOOM_LEVEL_MID);
this.subsamplingImageView.setMaxScale(LARGE_IMAGES_ZOOM_LEVEL_MAX);

this.photoView.setOnClickListener(v -> ZoomingImageView.this.callOnClick());
this.subsamplingImageView.setOnClickListener(v -> ZoomingImageView.this.callOnClick());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2003,7 +2003,9 @@ private void updateWallpaper(@Nullable ChatWallpaper chatWallpaper) {

int toolbarColor = getResources().getColor(R.color.conversation_toolbar_color_wallpaper);
toolbar.setBackgroundColor(toolbarColor);
WindowUtil.setStatusBarColor(getWindow(), toolbarColor);
if (Build.VERSION.SDK_INT > 21) {
WindowUtil.setStatusBarColor(getWindow(), toolbarColor);
}
} else {
wallpaper.setImageDrawable(null);
wallpaperDim.setVisibility(View.GONE);
Expand All @@ -2014,7 +2016,9 @@ private void updateWallpaper(@Nullable ChatWallpaper chatWallpaper) {

int toolbarColor = getResources().getColor(R.color.conversation_toolbar_color);
toolbar.setBackgroundColor(toolbarColor);
WindowUtil.setStatusBarColor(getWindow(), toolbarColor);
if (Build.VERSION.SDK_INT > 21) {
WindowUtil.setStatusBarColor(getWindow(), toolbarColor);
}
}
fragment.onWallpaperChanged(chatWallpaper);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,41 @@ public void setListVerticalTranslation(float translationY) {
maskView.setTargetParentTranslationY(translationY);
}

private OnLayoutChangeListener createUpdateViewPositionsOnLayoutChangeListener(@NonNull View maskTarget,
int maskPaddingBottom,
@NonNull PointF lastSeenDownPoint)
{
return new OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {

final float scrubberTranslationY = Math.max(-scrubberDistanceFromTouchDown + actionBarHeight,
lastSeenDownPoint.y - scrubberHeight - scrubberDistanceFromTouchDown - statusBarHeight);

final float halfWidth = scrubberWidth / 2f + scrubberHorizontalMargin;
final float screenWidth = getResources().getDisplayMetrics().widthPixels;
final float downX = ViewUtil.isLtr(ConversationReactionOverlay.this) ? lastSeenDownPoint.x : screenWidth - lastSeenDownPoint.x;
final float scrubberTranslationX = Util.clamp(downX - halfWidth,
scrubberHorizontalMargin,
screenWidth + scrubberHorizontalMargin - halfWidth * 2) * (ViewUtil.isLtr(ConversationReactionOverlay.this) ? 1 : -1);

backgroundView.setTranslationX(scrubberTranslationX);
backgroundView.setTranslationY(scrubberTranslationY);

foregroundView.setTranslationX(scrubberTranslationX);
foregroundView.setTranslationY(scrubberTranslationY);

verticalScrubBoundary.update(lastSeenDownPoint.y - distanceFromTouchDownPointToTopOfScrubberDeadZone,
lastSeenDownPoint.y + distanceFromTouchDownPointToBottomOfScrubberDeadZone);

maskView.setPadding(0, 0, 0, maskPaddingBottom);
maskView.setTarget(maskTarget);

removeOnLayoutChangeListener(this);
}
};
}

public void show(@NonNull Activity activity,
@NonNull View maskTarget,
@NonNull Recipient conversationRecipient,
Expand Down Expand Up @@ -171,27 +206,7 @@ public void show(@NonNull Activity activity,
statusBarHeight = ViewUtil.getStatusBarHeight(this);
}

final float scrubberTranslationY = Math.max(-scrubberDistanceFromTouchDown + actionBarHeight,
lastSeenDownPoint.y - scrubberHeight - scrubberDistanceFromTouchDown - statusBarHeight);

final float halfWidth = scrubberWidth / 2f + scrubberHorizontalMargin;
final float screenWidth = getResources().getDisplayMetrics().widthPixels;
final float downX = ViewUtil.isLtr(this) ? lastSeenDownPoint.x : screenWidth - lastSeenDownPoint.x;
final float scrubberTranslationX = Util.clamp(downX - halfWidth,
scrubberHorizontalMargin,
screenWidth + scrubberHorizontalMargin - halfWidth * 2) * (ViewUtil.isLtr(this) ? 1 : -1);

backgroundView.setTranslationX(scrubberTranslationX);
backgroundView.setTranslationY(scrubberTranslationY);

foregroundView.setTranslationX(scrubberTranslationX);
foregroundView.setTranslationY(scrubberTranslationY);

verticalScrubBoundary.update(lastSeenDownPoint.y - distanceFromTouchDownPointToTopOfScrubberDeadZone,
lastSeenDownPoint.y + distanceFromTouchDownPointToBottomOfScrubberDeadZone);

maskView.setPadding(0, 0, 0, maskPaddingBottom);
maskView.setTarget(maskTarget);
addOnLayoutChangeListener(createUpdateViewPositionsOnLayoutChangeListener(maskTarget, maskPaddingBottom, lastSeenDownPoint));

hideAnimatorSet.end();
toolbar.setVisibility(VISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public boolean containsSession(SignalProtocolAddress address) {
SessionRecord sessionRecord = DatabaseFactory.getSessionDatabase(context).load(recipientId, address.getDeviceId());

return sessionRecord != null &&
sessionRecord.hasSenderChain() &&
sessionRecord.getSessionVersion() == CiphertextMessage.CURRENT_VERSION;
sessionRecord.getSessionState().hasSenderChain() &&
sessionRecord.getSessionState().getSessionVersion() == CiphertextMessage.CURRENT_VERSION;
} else {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.database.SessionDatabase;
import org.whispersystems.libsignal.state.SessionRecord;
import org.whispersystems.libsignal.state.SessionState;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;

import java.io.File;
Expand Down Expand Up @@ -63,7 +64,9 @@ static void migrateSessions(Context context, SQLiteDatabase database) {

if (versionMarker == SINGLE_STATE_VERSION) {
Log.i(TAG, "Migrating single state version: " + sessionFile.getAbsolutePath());
sessionRecord = SessionRecord.fromSingleSessionState(serialized);
SessionState sessionState = new SessionState(serialized);

sessionRecord = new SessionRecord(sessionState);
} else if (versionMarker >= ARCHIVE_STATES_VERSION) {
Log.i(TAG, "Migrating session: " + sessionFile.getAbsolutePath());
sessionRecord = new SessionRecord(serialized);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.thoughtcrime.securesms.recipients.RecipientId;
import org.thoughtcrime.securesms.util.BottomSheetUtil;
import org.thoughtcrime.securesms.util.ThemeUtil;
import org.thoughtcrime.securesms.util.ViewUtil;
import org.thoughtcrime.securesms.util.views.SimpleProgressDialog;

/**
Expand All @@ -38,6 +39,8 @@ public final class GroupsV1MigrationInitiationBottomSheetDialogFragment extends
private GroupMemberListView ineligibleList;
private TextView ineligibleTitle;
private View ineligibleContainer;
private View upgradeButton;
private View spinner;

public static void showForInitiation(@NonNull FragmentManager manager, @NonNull RecipientId groupRecipientId) {
Bundle args = new Bundle();
Expand Down Expand Up @@ -71,6 +74,8 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
this.ineligibleContainer = view.findViewById(R.id.gv1_migrate_ineligible_container);
this.ineligibleTitle = view.findViewById(R.id.gv1_migrate_ineligible_title);
this.ineligibleList = view.findViewById(R.id.gv1_migrate_ineligible_list);
this.upgradeButton = view.findViewById(R.id.gv1_migrate_upgrade_button);
this.spinner = view.findViewById(R.id.gv1_migrate_spinner);

inviteList.setNestedScrollingEnabled(false);
ineligibleList.setNestedScrollingEnabled(false);
Expand All @@ -82,8 +87,9 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
viewModel = ViewModelProviders.of(this, new GroupsV1MigrationInitiationViewModel.Factory(groupRecipientId)).get(GroupsV1MigrationInitiationViewModel.class);
viewModel.getMigrationState().observe(getViewLifecycleOwner(), this::onMigrationStateChanged);

upgradeButton.setEnabled(false);
upgradeButton.setOnClickListener(v -> onUpgradeClicked());
view.findViewById(R.id.gv1_migrate_cancel_button).setOnClickListener(v -> dismiss());
view.findViewById(R.id.gv1_migrate_upgrade_button).setOnClickListener(v -> onUpgradeClicked());
}

@Override
Expand All @@ -107,6 +113,9 @@ private void onMigrationStateChanged(@NonNull MigrationState migrationState) {
} else {
ineligibleContainer.setVisibility(View.GONE);
}

upgradeButton.setEnabled(true);
spinner.setVisibility(View.GONE);
}

private void onUpgradeClicked() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.thoughtcrime.securesms.recipients.RecipientId;
import org.thoughtcrime.securesms.recipients.RecipientUtil;
import org.thoughtcrime.securesms.transport.RetryLaterException;
import org.thoughtcrime.securesms.util.Util;

import java.io.IOException;
import java.util.Collections;
Expand Down Expand Up @@ -83,7 +84,11 @@ private MigrationState getMigrationState(@NonNull RecipientId groupRecipientId)
}

try {
RecipientUtil.ensureUuidsAreAvailable(ApplicationDependencies.getApplication(), group.getParticipants());
List<Recipient> registered = Stream.of(group.getParticipants())
.filter(Recipient::isRegistered)
.toList();

RecipientUtil.ensureUuidsAreAvailable(ApplicationDependencies.getApplication(), registered);
} catch (IOException e) {
Log.w(TAG, "Failed to refresh UUIDs!", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;

import androidx.annotation.NonNull;
Expand Down Expand Up @@ -44,15 +46,15 @@ public void onReceive(@NonNull Context context, @NonNull Intent intent) {
} else if (BROADCAST_ACTION.equals(intent.getAction())) {
PendingResult pendingResult = goAsync();

new Handler(Looper.getMainLooper()).postDelayed(pendingResult::finish, JOB_TIMEOUT);

SignalExecutors.BOUNDED.submit(() -> {
Log.i(TAG, "Running PushNotificationReceiveJob");

Optional<JobTracker.JobState> jobState = ApplicationDependencies.getJobManager()
.runSynchronously(PushNotificationReceiveJob.withDelayedForegroundService(FOREGROUND_DELAY), JOB_TIMEOUT);

Log.i(TAG, "PushNotificationReceiveJob ended: " + (jobState.isPresent() ? jobState.get().toString() : "Job did not complete"));

pendingResult.finish();
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ public void updateNotification(@NonNull Context context,
int reminderCount,
@NonNull BubbleUtil.BubbleState defaultBubbleState)
{
if (!TextSecurePreferences.isNotificationsEnabled(context)) {
return;
}

boolean isReminder = reminderCount > 0;
Cursor telcoCursor = null;
Cursor pushCursor = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ public class NotificationChannels {
private static class Version {
static final int MESSAGES_CATEGORY = 2;
static final int CALLS_PRIORITY_BUMP = 3;
static final int VIBRATE_OFF_OTHER = 4;
}

private static final int VERSION = 3;
private static final int VERSION = 4;

private static final String CATEGORY_MESSAGES = "messages";
private static final String CONTACT_PREFIX = "contact_";
Expand All @@ -57,7 +58,7 @@ private static class Version {
public static final String APP_UPDATES = "app_updates";
public static final String BACKUPS = "backups_v2";
public static final String LOCKED_STATUS = "locked_status_v2";
public static final String OTHER = "other_v2";
public static final String OTHER = "other_v3";
public static final String VOICE_NOTES = "voice_notes";

/**
Expand Down Expand Up @@ -462,6 +463,8 @@ private static void onCreate(@NonNull Context context, @NonNull NotificationMana
backups.setShowBadge(false);
lockedStatus.setShowBadge(false);
other.setShowBadge(false);
other.setVibrationPattern(new long[]{0});
other.enableVibration(true);
voiceNotes.setShowBadge(false);

notificationManager.createNotificationChannels(Arrays.asList(messages, calls, failures, backups, lockedStatus, other, voiceNotes));
Expand Down Expand Up @@ -489,6 +492,10 @@ private static void onUpgrade(@NonNull NotificationManager notificationManager,
if (oldVersion < Version.CALLS_PRIORITY_BUMP) {
notificationManager.deleteNotificationChannel("calls_v2");
}

if (oldVersion < Version.VIBRATE_OFF_OTHER) {
notificationManager.deleteNotificationChannel("other_v2");
}
}

@TargetApi(26)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.view.View;
import android.view.ViewOutlineProvider;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
Expand All @@ -26,9 +27,7 @@
/**
* Banner displayed within a conversation when a review is suggested.
*/
public class ReviewBannerView extends ConstraintLayout {

private static final @Px int ELEVATION = ViewUtil.dpToPx(4);
public class ReviewBannerView extends LinearLayout {

private ImageView bannerIcon;
private TextView bannerMessage;
Expand Down Expand Up @@ -62,16 +61,6 @@ protected void onFinishInflate() {
bottomRightAvatar.setFallbackPhotoProvider(provider);

bannerClose.setOnClickListener(v -> setVisibility(GONE));

if (Build.VERSION.SDK_INT >= 21) {
setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
outline.setRect(-100, -100, view.getWidth() + 100, view.getHeight() + ELEVATION);
}
});
setElevation(ELEVATION);
}
}

public void setBannerMessage(@Nullable CharSequence charSequence) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ private void postObligatoryForegroundNotification(@NonNull Entry active) {
.setContentTitle(active.title)
.setProgress(active.progressMax, active.progress, active.indeterminate)
.setContentIntent(PendingIntent.getActivity(this, 0, MainActivity.clearTop(this), 0))
.setVibrate(new long[]{0})
.build());
}

Expand Down
Loading

0 comments on commit b075366

Please sign in to comment.