From 64adf81e1347329fbf36fcd7acfbadb2830c60d6 Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Sun, 11 Mar 2018 22:04:41 +0100 Subject: [PATCH] Add fancy spotlight for push-to-talk Signed-off-by: Mario Danic --- app/build.gradle | 2 + .../talk/activities/CallActivity.java | 37 ++++++++++++++++++- app/src/main/res/values/strings.xml | 2 + 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 8ade46c7c..356e4e9c0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -148,6 +148,8 @@ dependencies { implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.7' + implementation 'com.github.wooplr:Spotlight:1.2.3' + implementation 'com.github.Kennyc1012:BottomSheet:2.4.0' implementation 'eu.davidea:flipview:1.1.3' testImplementation 'junit:junit:4.12' diff --git a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java index 396e70c7e..b389c1eca 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java +++ b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java @@ -29,6 +29,7 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.annotation.SuppressLint; import android.content.res.Configuration; +import android.graphics.Color; import android.os.Bundle; import android.os.Handler; import android.support.annotation.NonNull; @@ -73,6 +74,7 @@ import com.nextcloud.talk.utils.database.user.UserUtils; import com.nextcloud.talk.webrtc.MagicAudioManager; import com.nextcloud.talk.webrtc.MagicPeerConnectionWrapper; import com.nextcloud.talk.webrtc.MagicWebRTCUtils; +import com.wooplr.spotlight.SpotlightView; import org.apache.commons.lang3.StringEscapeUtils; import org.greenrobot.eventbus.EventBus; @@ -205,6 +207,8 @@ public class CallActivity extends AppCompatActivity { private boolean initialPermissionsCheck = true; + private SpotlightView spotlightView; + private static int getSystemUiVisibility() { int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN; flags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; @@ -391,6 +395,28 @@ public class CallActivity extends AppCompatActivity { @OnClick(R.id.call_control_microphone) public void onMicrophoneClick() { if (EffortlessPermissions.hasPermissions(this, PERMISSIONS_MICROPHONE)) { + + spotlightView = new SpotlightView.Builder(this) + .introAnimationDuration(300) + .enableRevealAnimation(true) + .performClick(false) + .fadeinTextDuration(400) + .headingTvColor(getResources().getColor(R.color.colorPrimary)) + .headingTvSize(20) + .headingTvText(getString(R.string.nc_push_to_talk)) + .subHeadingTvColor(getResources().getColor(R.color.nc_white_color_complete)) + .subHeadingTvSize(16) + .subHeadingTvText(getString(R.string.nc_push_to_talk_desc)) + .maskColor(Color.parseColor("#dc000000")) + .target(microphoneControlButton) + .lineAnimDuration(400) + .lineAndArcColor(getResources().getColor(R.color.colorPrimary)) + .enableDismissAfterShown(true) + .dismissOnBackPress(true) + .usageId("pushToTalk") + .show(); + + if (!isPTTActive) { audioOn = !audioOn; @@ -1404,7 +1430,13 @@ public class CallActivity extends AppCompatActivity { callControls.setAlpha(0.0f); callControls.setVisibility(View.VISIBLE); } else { - handler.postDelayed(() -> animateCallControls(false, 0), 5000); + handler.postDelayed(new Runnable() { + @Override + public void run() { + animateCallControls(false, 0); + + } + }, 5000); return; } } else { @@ -1425,6 +1457,9 @@ public class CallActivity extends AppCompatActivity { if (callControls != null) { if (!show) { callControls.setVisibility(View.GONE); + if (spotlightView.getVisibility() != View.GONE) { + spotlightView.setVisibility(View.GONE); + } } else { handler.postDelayed(new Runnable() { @Override diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cdcae5689..4cdc07c27 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -132,6 +132,8 @@ + Push-to-talk + With microphone disabled, click&hold to use Push-to-talk Have private video calls and chat using your own server. Use Nextcloud Talk to have one-on-one or group audio or video calls, create or join web conferences and send chat messages. All communication is fully encrypted and mediated by your own server, providing the highest degree of privacy possible.