diff --git a/build.gradle b/build.gradle
index 28c6ab9c6..dc6d16cec 100644
--- a/build.gradle
+++ b/build.gradle
@@ -78,7 +78,6 @@ dependencies {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
compile 'org.whispersystems:signal-service-android:2.7.6'
- compile 'org.whispersystems:webrtc-android:M68'
compile 'com.journeyapps:zxing-android-embedded:3.4.0'
@@ -165,7 +164,6 @@ dependencyVerification {
'com.google.android.exoplayer:exoplayer:955085aa611a8f7cf6c61b88ae03d1a392f4ad94c9bfbc153f3dedb9ffb14718',
'org.whispersystems:libpastelog:fe56b4db9ec743c8b565e3e4caa9228fafe132dc0bf82000d6e359b97a81177c',
'org.whispersystems:signal-service-android:823eed29e64fb0aa30d2078cb5ec0245e2a0713a4028121329c5c28788ef27f8',
- 'org.whispersystems:webrtc-android:66cb312eb024eaf6aa93e662d37d0c46632e049d47a2dcc9c291207589ee7a43',
'me.leolin:ShortcutBadger:e3cb3e7625892129b0c92dd5e4bc649faffdd526d5af26d9c45ee31ff8851774',
'se.emilsjolander:stickylistheaders:a08ca948aa6b220f09d82f16bbbac395f6b78897e9eeac6a9f0b0ba755928eeb',
'com.jpardogo.materialtabstrip:library:c6ef812fba4f74be7dc4a905faa4c2908cba261a94c13d4f96d5e67e4aad4aaa',
@@ -295,7 +293,6 @@ android {
'proguard-glide.pro',
'proguard-shortcutbadger.pro',
'proguard-retrofit.pro',
- 'proguard-webrtc.pro',
'proguard-klinker.pro',
'proguard-retrolambda.pro',
'proguard-okhttp.pro',
diff --git a/proguard-webrtc.pro b/proguard-webrtc.pro
deleted file mode 100644
index 7a1e3dea5..000000000
--- a/proguard-webrtc.pro
+++ /dev/null
@@ -1,3 +0,0 @@
--dontwarn org.webrtc.NetworkMonitorAutoDetect
--dontwarn android.net.Network
--keep class org.webrtc.** { *; }
diff --git a/res/layout/create_passphrase_activity.xml b/res/layout/create_passphrase_activity.xml
deleted file mode 100644
index fbffc4842..000000000
--- a/res/layout/create_passphrase_activity.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/res/layout/database_migration_activity.xml b/res/layout/database_migration_activity.xml
deleted file mode 100644
index 87bc8ebe0..000000000
--- a/res/layout/database_migration_activity.xml
+++ /dev/null
@@ -1,121 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/res/layout/database_upgrade_activity.xml b/res/layout/database_upgrade_activity.xml
deleted file mode 100644
index 8f797c9b2..000000000
--- a/res/layout/database_upgrade_activity.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/res/layout/enter_backup_passphrase_dialog.xml b/res/layout/enter_backup_passphrase_dialog.xml
deleted file mode 100644
index 0ace5eb07..000000000
--- a/res/layout/enter_backup_passphrase_dialog.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/res/layout/experience_upgrade_activity.xml b/res/layout/experience_upgrade_activity.xml
deleted file mode 100644
index 684572165..000000000
--- a/res/layout/experience_upgrade_activity.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/res/layout/experience_upgrade_preference_fragment.xml b/res/layout/experience_upgrade_preference_fragment.xml
deleted file mode 100644
index 28669bd0f..000000000
--- a/res/layout/experience_upgrade_preference_fragment.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/res/layout/key_caching_notification.xml b/res/layout/key_caching_notification.xml
deleted file mode 100644
index f5d62019d..000000000
--- a/res/layout/key_caching_notification.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/res/layout/prompt_passphrase_activity.xml b/res/layout/prompt_passphrase_activity.xml
deleted file mode 100644
index ca8b673ac..000000000
--- a/res/layout/prompt_passphrase_activity.xml
+++ /dev/null
@@ -1,147 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/res/layout/registration_call_me_view.xml b/res/layout/registration_call_me_view.xml
deleted file mode 100644
index a31bb286f..000000000
--- a/res/layout/registration_call_me_view.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/res/layout/registration_lock_dialog_view.xml b/res/layout/registration_lock_dialog_view.xml
deleted file mode 100644
index eb93f6642..000000000
--- a/res/layout/registration_lock_dialog_view.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/res/layout/registration_lock_reminder_view.xml b/res/layout/registration_lock_reminder_view.xml
deleted file mode 100644
index 9006a95ea..000000000
--- a/res/layout/registration_lock_reminder_view.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/res/layout/registration_unlock_dialog_view.xml b/res/layout/registration_unlock_dialog_view.xml
deleted file mode 100644
index f261f63d1..000000000
--- a/res/layout/registration_unlock_dialog_view.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/res/layout/unknown_sender_view.xml b/res/layout/unknown_sender_view.xml
deleted file mode 100644
index 9756e5a2a..000000000
--- a/res/layout/unknown_sender_view.xml
+++ /dev/null
@@ -1,95 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/res/layout/unverified_banner_view.xml b/res/layout/unverified_banner_view.xml
deleted file mode 100644
index 846f821c6..000000000
--- a/res/layout/unverified_banner_view.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/res/layout/verification_code_view.xml b/res/layout/verification_code_view.xml
deleted file mode 100644
index 4c395cfed..000000000
--- a/res/layout/verification_code_view.xml
+++ /dev/null
@@ -1,154 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/res/layout/verification_pin_keyboard_view.xml b/res/layout/verification_pin_keyboard_view.xml
deleted file mode 100644
index c02ef3447..000000000
--- a/res/layout/verification_pin_keyboard_view.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/res/layout/verify_display_fragment.xml b/res/layout/verify_display_fragment.xml
deleted file mode 100644
index 2c94a73ef..000000000
--- a/res/layout/verify_display_fragment.xml
+++ /dev/null
@@ -1,188 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/res/layout/verify_scan_fragment.xml b/res/layout/verify_scan_fragment.xml
deleted file mode 100644
index d379c6002..000000000
--- a/res/layout/verify_scan_fragment.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/res/layout/webrtc_answer_decline_button.xml b/res/layout/webrtc_answer_decline_button.xml
deleted file mode 100644
index de80ede2b..000000000
--- a/res/layout/webrtc_answer_decline_button.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/res/layout/webrtc_call_activity.xml b/res/layout/webrtc_call_activity.xml
deleted file mode 100644
index 6611afd96..000000000
--- a/res/layout/webrtc_call_activity.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/res/layout/webrtc_call_controls.xml b/res/layout/webrtc_call_controls.xml
deleted file mode 100644
index 45615de8f..000000000
--- a/res/layout/webrtc_call_controls.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/res/layout/webrtc_call_screen.xml b/res/layout/webrtc_call_screen.xml
deleted file mode 100644
index 6c78a9f07..000000000
--- a/res/layout/webrtc_call_screen.xml
+++ /dev/null
@@ -1,236 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/res/menu/verify_display_fragment_context_menu.xml b/res/menu/verify_display_fragment_context_menu.xml
deleted file mode 100644
index db095c5b9..000000000
--- a/res/menu/verify_display_fragment_context_menu.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
diff --git a/res/menu/verify_identity.xml b/res/menu/verify_identity.xml
deleted file mode 100644
index 6163830bf..000000000
--- a/res/menu/verify_identity.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
diff --git a/res/raw/censorship_fronting.store b/res/raw/censorship_fronting.store
deleted file mode 100644
index 88b3f4376..000000000
Binary files a/res/raw/censorship_fronting.store and /dev/null differ
diff --git a/src/org/thoughtcrime/securesms/ApplicationContext.java b/src/org/thoughtcrime/securesms/ApplicationContext.java
index ce53a47d0..7115c334c 100644
--- a/src/org/thoughtcrime/securesms/ApplicationContext.java
+++ b/src/org/thoughtcrime/securesms/ApplicationContext.java
@@ -21,10 +21,8 @@ import android.arch.lifecycle.DefaultLifecycleObserver;
import android.arch.lifecycle.LifecycleOwner;
import android.arch.lifecycle.ProcessLifecycleOwner;
import android.content.Context;
-import android.os.Build;
import android.support.annotation.NonNull;
import android.support.multidex.MultiDexApplication;
-import android.util.Log;
import com.b44t.messenger.DcContext;
import com.b44t.messenger.DcEventCenter;
@@ -36,16 +34,9 @@ import org.thoughtcrime.securesms.jobmanager.persistence.JavaJobSerializer;
import org.thoughtcrime.securesms.notifications.MessageNotifier;
import org.thoughtcrime.securesms.util.ScreenLockUtil;
import org.thoughtcrime.securesms.util.Util;
-import org.webrtc.PeerConnectionFactory;
-import org.webrtc.PeerConnectionFactory.InitializationOptions;
-import org.webrtc.voiceengine.WebRtcAudioManager;
-import org.webrtc.voiceengine.WebRtcAudioUtils;
import org.whispersystems.libsignal.logging.SignalProtocolLoggerProvider;
import org.thoughtcrime.securesms.util.AndroidSignalProtocolLogger;
-import java.util.HashSet;
-import java.util.Set;
-
/**
* Will be called once when the TextSecure process is created.
*
@@ -78,9 +69,7 @@ public class ApplicationContext extends MultiDexApplication implements DefaultLi
initializeRandomNumberFix();
initializeLogging();
initializeJobManager();
- //initializeSignedPreKeyCheck(); -- keys are generated in the core, however, not sure if this is needed for the lock screen
initializePeriodicTasks();
- initializeWebRtc();
initializeIncomingMessageNotifier();
ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
}
@@ -152,38 +141,4 @@ public class ApplicationContext extends MultiDexApplication implements DefaultLi
// UpdateApkRefreshListener.schedule(this);
//}
}
-
- private void initializeWebRtc() {
- try {
- Set HARDWARE_AEC_BLACKLIST = new HashSet() {{
- add("Pixel");
- add("Pixel XL");
- add("Moto G5");
- add("Moto G (5S) Plus");
- add("Moto G4");
- add("TA-1053");
- add("Mi A1");
- add("E5823"); // Sony z5 compact
- }};
-
- Set OPEN_SL_ES_WHITELIST = new HashSet() {{
- add("Pixel");
- add("Pixel XL");
- }};
-
- if (HARDWARE_AEC_BLACKLIST.contains(Build.MODEL)) {
- WebRtcAudioUtils.setWebRtcBasedAcousticEchoCanceler(true);
- }
-
- if (!OPEN_SL_ES_WHITELIST.contains(Build.MODEL)) {
- WebRtcAudioManager.setBlacklistDeviceForOpenSLESUsage(true);
- }
-
- PeerConnectionFactory.initialize(InitializationOptions.builder(this)
- .setEnableVideoHwAcceleration(true)
- .createInitializationOptions());
- } catch (UnsatisfiedLinkError e) {
- Log.w(TAG, e);
- }
- }
}
diff --git a/src/org/thoughtcrime/securesms/components/webrtc/PercentFrameLayout.java b/src/org/thoughtcrime/securesms/components/webrtc/PercentFrameLayout.java
deleted file mode 100644
index 9011d07b6..000000000
--- a/src/org/thoughtcrime/securesms/components/webrtc/PercentFrameLayout.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright 2015 The WebRTC Project Authors. All rights reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-package org.thoughtcrime.securesms.components.webrtc;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.PorterDuff;
-import android.graphics.PorterDuffXfermode;
-import android.graphics.Xfermode;
-import android.graphics.drawable.Drawable;
-import android.support.annotation.NonNull;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.ViewGroup;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Simple container that confines the children to a subrectangle specified as percentage values of
- * the container size. The children are centered horizontally and vertically inside the confined
- * space.
- */
-public class PercentFrameLayout extends ViewGroup {
- private int xPercent = 0;
- private int yPercent = 0;
- private int widthPercent = 100;
- private int heightPercent = 100;
-
- private boolean square = false;
- private boolean hidden = false;
-
- public PercentFrameLayout(Context context) {
- super(context);
- }
-
- public PercentFrameLayout(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public PercentFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- }
-
- public void setSquare(boolean square) {
- this.square = square;
- }
-
- public void setHidden(boolean hidden) {
- this.hidden = hidden;
- }
-
- public boolean isHidden() {
- return this.hidden;
- }
-
- public void setPosition(int xPercent, int yPercent, int widthPercent, int heightPercent) {
- this.xPercent = xPercent;
- this.yPercent = yPercent;
- this.widthPercent = widthPercent;
- this.heightPercent = heightPercent;
- }
-
- @Override
- public boolean shouldDelayChildPressedState() {
- return false;
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- final int width = getDefaultSize(Integer.MAX_VALUE, widthMeasureSpec);
- final int height = getDefaultSize(Integer.MAX_VALUE, heightMeasureSpec);
-
- setMeasuredDimension(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
- MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
-
- int childWidth = width * widthPercent / 100;
- int childHeight = height * heightPercent / 100;
-
- if (square) {
- if (width > height) childWidth = childHeight;
- else childHeight = childWidth;
- }
-
- if (hidden) {
- childWidth = 1;
- childHeight = 1;
- }
-
- int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.AT_MOST);
- int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(childHeight, MeasureSpec.AT_MOST);
-
- for (int i = 0; i < getChildCount(); ++i) {
- final View child = getChildAt(i);
- if (child.getVisibility() != GONE) {
- child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
- }
- }
- }
-
- @Override
- protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
- final int width = right - left;
- final int height = bottom - top;
- // Sub-rectangle specified by percentage values.
- final int subWidth = width * widthPercent / 100;
- final int subHeight = height * heightPercent / 100;
- final int subLeft = left + width * xPercent / 100;
- final int subTop = top + height * yPercent / 100;
-
-
- for (int i = 0; i < getChildCount(); ++i) {
- final View child = getChildAt(i);
- if (child.getVisibility() != GONE) {
- final int childWidth = child.getMeasuredWidth();
- final int childHeight = child.getMeasuredHeight();
- // Center child both vertically and horizontally.
- int childLeft = subLeft + (subWidth - childWidth) / 2;
- int childTop = subTop + (subHeight - childHeight) / 2;
-
- if (hidden) {
- childLeft = 0;
- childTop = 0;
- }
-
- child.layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight);
- }
- }
- }
-}
diff --git a/src/org/thoughtcrime/securesms/components/webrtc/WebRtcAnswerDeclineButton.java b/src/org/thoughtcrime/securesms/components/webrtc/WebRtcAnswerDeclineButton.java
deleted file mode 100644
index 54753935e..000000000
--- a/src/org/thoughtcrime/securesms/components/webrtc/WebRtcAnswerDeclineButton.java
+++ /dev/null
@@ -1,312 +0,0 @@
-package org.thoughtcrime.securesms.components.webrtc;
-
-
-import android.animation.Animator;
-import android.animation.AnimatorSet;
-import android.animation.ArgbEvaluator;
-import android.animation.ObjectAnimator;
-import android.content.Context;
-import android.graphics.Color;
-import android.os.Build;
-import android.support.annotation.Nullable;
-import android.support.annotation.RequiresApi;
-import android.util.AttributeSet;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.animation.AccelerateInterpolator;
-import android.view.animation.DecelerateInterpolator;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import org.thoughtcrime.securesms.R;
-import org.thoughtcrime.securesms.util.ViewUtil;
-
-public class WebRtcAnswerDeclineButton extends LinearLayout implements View.OnTouchListener {
-
- @SuppressWarnings("unused")
- private static final String TAG = WebRtcAnswerDeclineButton.class.getSimpleName();
-
- private static final int TOTAL_TIME = 1000;
- private static final int SHAKE_TIME = 200;
-
- private static final int UP_TIME = (TOTAL_TIME - SHAKE_TIME) / 2;
- private static final int DOWN_TIME = (TOTAL_TIME - SHAKE_TIME) / 2;
- private static final int FADE_OUT_TIME = 300;
- private static final int FADE_IN_TIME = 100;
- private static final int SHIMMER_TOTAL = UP_TIME + SHAKE_TIME;
-
- private static final int ANSWER_THRESHOLD = 112;
- private static final int DECLINE_THRESHOLD = 56;
-
- private TextView swipeUpText;
- private ImageView fab;
- private TextView swipeDownText;
-
- private ImageView arrowOne;
- private ImageView arrowTwo;
- private ImageView arrowThree;
- private ImageView arrowFour;
-
- private float lastY;
-
- private boolean animating = false;
- private boolean complete = false;
-
- private AnimatorSet animatorSet;
- private AnswerDeclineListener listener;
-
- public WebRtcAnswerDeclineButton(Context context) {
- super(context);
- initialize();
- }
-
- public WebRtcAnswerDeclineButton(Context context, @Nullable AttributeSet attrs) {
- super(context, attrs);
- initialize();
- }
-
- public WebRtcAnswerDeclineButton(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- initialize();
- }
-
- @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
- public WebRtcAnswerDeclineButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
- super(context, attrs, defStyleAttr, defStyleRes);
- initialize();
- }
-
- private void initialize() {
- setOrientation(LinearLayout.VERTICAL);
- setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
-
- inflate(getContext(), R.layout.webrtc_answer_decline_button, this);
-
- this.swipeUpText = findViewById(R.id.swipe_up_text);
- this.fab = findViewById(R.id.answer);
- this.swipeDownText = findViewById(R.id.swipe_down_text);
-
- this.arrowOne = findViewById(R.id.arrow_one);
- this.arrowTwo = findViewById(R.id.arrow_two);
- this.arrowThree = findViewById(R.id.arrow_three);
- this.arrowFour = findViewById(R.id.arrow_four);
-
- this.fab.setOnTouchListener(this);
- }
-
- public void startRingingAnimation() {
- if (!animating) {
- animating = true;
- animateElements(0);
- }
- }
-
- public void stopRingingAnimation() {
- if (animating) {
- animating = false;
- resetElements();
- }
- }
-
- public void setAnswerDeclineListener(AnswerDeclineListener listener) {
- this.listener = listener;
- }
-
- @Override
- public boolean onTouch(View v, MotionEvent event) {
-
- switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- resetElements();
- swipeUpText.animate().alpha(0).setDuration(200).start();
- swipeDownText.animate().alpha(0).setDuration(200).start();
- lastY = event.getRawY();
- break;
- case MotionEvent.ACTION_CANCEL:
- case MotionEvent.ACTION_UP:
- swipeUpText.clearAnimation();
- swipeDownText.clearAnimation();
- swipeUpText.setAlpha(1);
- swipeDownText.setAlpha(1);
- fab.setRotation(0);
-
- if (Build.VERSION.SDK_INT >= 21) {
- fab.getDrawable().setTint(getResources().getColor(R.color.green_600));
- fab.getBackground().setTint(Color.WHITE);
- }
-
- animating = true;
- animateElements(0);
- break;
- case MotionEvent.ACTION_MOVE:
- float difference = event.getRawY() - lastY;
-
- float differenceThreshold;
- float percentageToThreshold;
- int backgroundColor;
- int foregroundColor;
-
- if (difference <= 0) {
- differenceThreshold = ViewUtil.dpToPx(getContext(), ANSWER_THRESHOLD);
- percentageToThreshold = Math.min(1, (difference * -1) / differenceThreshold);
- backgroundColor = (int) new ArgbEvaluator().evaluate(percentageToThreshold, getResources().getColor(R.color.green_100), getResources().getColor(R.color.green_600));
-
- if (percentageToThreshold > 0.5) {
- foregroundColor = Color.WHITE;
- } else {
- foregroundColor = getResources().getColor(R.color.green_600);
- }
-
- fab.setTranslationY(difference);
-
- if (percentageToThreshold == 1 && listener != null) {
- fab.setVisibility(View.INVISIBLE);
- lastY = event.getRawY();
- if (!complete) {
- complete = true;
- listener.onAnswered();
- }
- }
- } else {
- differenceThreshold = ViewUtil.dpToPx(getContext(), DECLINE_THRESHOLD);
- percentageToThreshold = Math.min(1, difference / differenceThreshold);
- backgroundColor = (int) new ArgbEvaluator().evaluate(percentageToThreshold, getResources().getColor(R.color.red_100), getResources().getColor(R.color.red_600));
-
- if (percentageToThreshold > 0.5) {
- foregroundColor = Color.WHITE;
- } else {
- foregroundColor = getResources().getColor(R.color.green_600);
- }
-
- fab.setRotation(135 * percentageToThreshold);
-
- if (percentageToThreshold == 1 && listener != null) {
- fab.setVisibility(View.INVISIBLE);
- lastY = event.getRawY();
-
- if (!complete) {
- complete = true;
- listener.onDeclined();
- }
- }
- }
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- fab.getBackground().setTint(backgroundColor);
- fab.getDrawable().setTint(foregroundColor);
- }
-
- break;
- }
-
- return true;
- }
-
- private void animateElements(int delay) {
- ObjectAnimator fabUp = getUpAnimation(fab);
- ObjectAnimator fabDown = getDownAnimation(fab);
- ObjectAnimator fabShake = getShakeAnimation(fab);
-
- animatorSet = new AnimatorSet();
- animatorSet.play(fabUp).with(getUpAnimation(swipeUpText));
- animatorSet.play(fabShake).after(fabUp);
- animatorSet.play(fabDown).with(getDownAnimation(swipeUpText)).after(fabShake);
-
- animatorSet.play(getFadeOut(swipeDownText)).with(fabUp);
- animatorSet.play(getFadeIn(swipeDownText)).after(fabDown);
-
- animatorSet.play(getShimmer(arrowFour, arrowThree, arrowTwo, arrowOne));
-
- animatorSet.addListener(new Animator.AnimatorListener() {
- @Override
- public void onAnimationStart(Animator animation) {
- }
-
- @Override
- public void onAnimationEnd(Animator animation) {
- if (animating) animateElements(1000);
- }
-
- @Override
- public void onAnimationCancel(Animator animation) {}
- @Override
- public void onAnimationRepeat(Animator animation) {}
- });
-
- animatorSet.setStartDelay(delay);
- animatorSet.start();
- }
-
- private Animator getShimmer(View... targets) {
- AnimatorSet animatorSet = new AnimatorSet();
- int evenDuration = SHIMMER_TOTAL / targets.length;
- int interval = 75;
-
- for (int i=0;i extends LinkedBlockingDeque {
- @Override
- public void put(E runnable) throws InterruptedException {
- super.putFirst(runnable);
- }
-
- @Override
- public boolean add(E runnable) {
- super.addFirst(runnable);
- return true;
- }
-
- @Override
- public boolean offer(E runnable) {
- super.addFirst(runnable);
- return true;
- }
-}