mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 23:29:52 +01:00
Revert to using a fixed delay for the onboarding.
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package org.briarproject.briar.android.conversation;
|
package org.briarproject.briar.android.conversation;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.arch.lifecycle.MutableLiveData;
|
|
||||||
import android.arch.lifecycle.Observer;
|
import android.arch.lifecycle.Observer;
|
||||||
import android.arch.lifecycle.ViewModelProvider;
|
import android.arch.lifecycle.ViewModelProvider;
|
||||||
import android.arch.lifecycle.ViewModelProviders;
|
import android.arch.lifecycle.ViewModelProviders;
|
||||||
@@ -11,7 +10,6 @@ import android.net.Uri;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.annotation.RequiresApi;
|
|
||||||
import android.support.annotation.UiThread;
|
import android.support.annotation.UiThread;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v4.app.ActivityCompat;
|
import android.support.v4.app.ActivityCompat;
|
||||||
@@ -145,6 +143,9 @@ public class ConversationActivity extends BriarActivity
|
|||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
Logger.getLogger(ConversationActivity.class.getName());
|
Logger.getLogger(ConversationActivity.class.getName());
|
||||||
|
|
||||||
|
private static final int TRANSITION_DURATION_MS = 500;
|
||||||
|
private static final int ONBOARDING_DELAY_MS = 250;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
AndroidNotificationManager notificationManager;
|
AndroidNotificationManager notificationManager;
|
||||||
@Inject
|
@Inject
|
||||||
@@ -178,8 +179,6 @@ public class ConversationActivity extends BriarActivity
|
|||||||
volatile GroupInvitationManager groupInvitationManager;
|
volatile GroupInvitationManager groupInvitationManager;
|
||||||
|
|
||||||
private final Map<MessageId, String> textCache = new ConcurrentHashMap<>();
|
private final Map<MessageId, String> textCache = new ConcurrentHashMap<>();
|
||||||
private final MutableLiveData<Boolean> canShowOnboarding =
|
|
||||||
new MutableLiveData<>();
|
|
||||||
private final Observer<String> contactNameObserver = name -> {
|
private final Observer<String> contactNameObserver = name -> {
|
||||||
requireNonNull(name);
|
requireNonNull(name);
|
||||||
loadMessages();
|
loadMessages();
|
||||||
@@ -208,6 +207,7 @@ public class ConversationActivity extends BriarActivity
|
|||||||
// Spurious lint warning - using END causes a crash
|
// Spurious lint warning - using END causes a crash
|
||||||
@SuppressLint("RtlHardcoded")
|
@SuppressLint("RtlHardcoded")
|
||||||
Transition slide = new Slide(RIGHT);
|
Transition slide = new Slide(RIGHT);
|
||||||
|
slide.setDuration(TRANSITION_DURATION_MS);
|
||||||
setSceneTransitionAnimation(slide, null, slide);
|
setSceneTransitionAnimation(slide, null, slide);
|
||||||
}
|
}
|
||||||
super.onCreate(state);
|
super.onCreate(state);
|
||||||
@@ -242,8 +242,8 @@ public class ConversationActivity extends BriarActivity
|
|||||||
requireNonNull(deleted);
|
requireNonNull(deleted);
|
||||||
if (deleted) finish();
|
if (deleted) finish();
|
||||||
});
|
});
|
||||||
viewModel.getAddedPrivateMessage()
|
viewModel.getAddedPrivateMessage().observe(this,
|
||||||
.observe(this, this::onAddedPrivateMessage);
|
this::onAddedPrivateMessage);
|
||||||
|
|
||||||
setTransitionName(toolbarAvatar, getAvatarTransitionName(contactId));
|
setTransitionName(toolbarAvatar, getAvatarTransitionName(contactId));
|
||||||
setTransitionName(toolbarStatus, getBulbTransitionName(contactId));
|
setTransitionName(toolbarStatus, getBulbTransitionName(contactId));
|
||||||
@@ -723,51 +723,68 @@ public class ConversationActivity extends BriarActivity
|
|||||||
|
|
||||||
private void showImageOnboarding(@Nullable Boolean show) {
|
private void showImageOnboarding(@Nullable Boolean show) {
|
||||||
if (show == null || !show) return;
|
if (show == null || !show) return;
|
||||||
// show onboarding only after the enter transition has ended
|
if (SDK_INT >= 21) {
|
||||||
// otherwise the tap target animation won't play
|
// show onboarding only after the enter transition has ended
|
||||||
observeOnce(canShowOnboarding, this, canShow -> {
|
// otherwise the tap target animation won't play
|
||||||
// remove cast when removing FEATURE_FLAG_IMAGE_ATTACHMENTS
|
textInputView.postDelayed(this::showImageOnboarding,
|
||||||
((TextAttachmentController) sendController)
|
TRANSITION_DURATION_MS + ONBOARDING_DELAY_MS);
|
||||||
.showImageOnboarding(this, () ->
|
} else {
|
||||||
viewModel.onImageOnboardingSeen());
|
showImageOnboarding();
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showImageOnboarding() {
|
||||||
|
// remove cast when removing FEATURE_FLAG_IMAGE_ATTACHMENTS
|
||||||
|
((TextAttachmentController) sendController)
|
||||||
|
.showImageOnboarding(this, () ->
|
||||||
|
viewModel.onImageOnboardingSeen());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showIntroductionOnboarding(@Nullable Boolean show) {
|
private void showIntroductionOnboarding(@Nullable Boolean show) {
|
||||||
if (show == null || !show) return;
|
if (show == null || !show) return;
|
||||||
// show onboarding only after the enter transition has ended
|
if (SDK_INT >= 21) {
|
||||||
// otherwise the tap target animation won't play
|
// show onboarding only after the enter transition has ended
|
||||||
observeOnce(canShowOnboarding, this, canShow -> {
|
// otherwise the tap target animation won't play
|
||||||
// find view of overflow icon
|
textInputView.postDelayed(this::showIntroductionOnboarding,
|
||||||
View target = null;
|
TRANSITION_DURATION_MS + ONBOARDING_DELAY_MS);
|
||||||
for (int i = 0; i < toolbar.getChildCount(); i++) {
|
} else {
|
||||||
if (toolbar.getChildAt(i) instanceof ActionMenuView) {
|
showIntroductionOnboarding();
|
||||||
ActionMenuView menu =
|
}
|
||||||
(ActionMenuView) toolbar.getChildAt(i);
|
}
|
||||||
target = menu.getChildAt(menu.getChildCount() - 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (target == null) {
|
|
||||||
LOG.warning("No Overflow Icon found!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PromptStateChangeListener listener = (prompt, state) -> {
|
private void showIntroductionOnboarding() {
|
||||||
if (state == STATE_DISMISSED || state == STATE_FINISHED) {
|
// find view of overflow icon
|
||||||
viewModel.onIntroductionOnboardingSeen();
|
View target = null;
|
||||||
}
|
for (int i = 0; i < toolbar.getChildCount(); i++) {
|
||||||
};
|
if (toolbar.getChildAt(i) instanceof ActionMenuView) {
|
||||||
new MaterialTapTargetPrompt.Builder(ConversationActivity.this,
|
ActionMenuView menu = (ActionMenuView) toolbar.getChildAt(i);
|
||||||
R.style.OnboardingDialogTheme).setTarget(target)
|
// The overflow icon should be the last child of the menu
|
||||||
.setPrimaryText(R.string.introduction_onboarding_title)
|
target = menu.getChildAt(menu.getChildCount() - 1);
|
||||||
.setSecondaryText(R.string.introduction_onboarding_text)
|
// If the menu hasn't been populated yet, use the menu itself
|
||||||
.setIcon(R.drawable.ic_more_vert_accent)
|
// as the target
|
||||||
.setBackgroundColour(
|
if (target == null) target = menu;
|
||||||
ContextCompat.getColor(this, R.color.briar_primary))
|
break;
|
||||||
.setPromptStateChangeListener(listener)
|
}
|
||||||
.show();
|
}
|
||||||
});
|
if (target == null) {
|
||||||
|
LOG.warning("No Overflow Icon found!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PromptStateChangeListener listener = (prompt, state) -> {
|
||||||
|
if (state == STATE_DISMISSED || state == STATE_FINISHED) {
|
||||||
|
viewModel.onIntroductionOnboardingSeen();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
new MaterialTapTargetPrompt.Builder(ConversationActivity.this,
|
||||||
|
R.style.OnboardingDialogTheme).setTarget(target)
|
||||||
|
.setPrimaryText(R.string.introduction_onboarding_title)
|
||||||
|
.setSecondaryText(R.string.introduction_onboarding_text)
|
||||||
|
.setIcon(R.drawable.ic_more_vert_accent)
|
||||||
|
.setBackgroundColour(
|
||||||
|
ContextCompat.getColor(this, R.color.briar_primary))
|
||||||
|
.setPromptStateChangeListener(listener)
|
||||||
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -919,39 +936,4 @@ public class ConversationActivity extends BriarActivity
|
|||||||
return attachments;
|
return attachments;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@RequiresApi(api = 21)
|
|
||||||
public void setSceneTransitionAnimation(
|
|
||||||
@Nullable Transition enterTransition,
|
|
||||||
@Nullable Transition exitTransition,
|
|
||||||
@Nullable Transition returnTransition) {
|
|
||||||
super.setSceneTransitionAnimation(enterTransition, exitTransition,
|
|
||||||
returnTransition);
|
|
||||||
// workaround for MaterialTapTargetPrompt bug:
|
|
||||||
// https://github.com/sjwall/MaterialTapTargetPrompt/issues/147
|
|
||||||
getWindow().getEnterTransition().addListener(
|
|
||||||
new Transition.TransitionListener() {
|
|
||||||
@Override
|
|
||||||
public void onTransitionStart(Transition transition) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTransitionEnd(Transition transition) {
|
|
||||||
canShowOnboarding.setValue(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTransitionCancel(Transition transition) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTransitionPause(Transition transition) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTransitionResume(Transition transition) {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -231,8 +231,7 @@ public class TextAttachmentController extends TextSendController
|
|||||||
R.style.OnboardingDialogTheme).setTarget(imageButton)
|
R.style.OnboardingDialogTheme).setTarget(imageButton)
|
||||||
.setPrimaryText(R.string.dialog_title_image_support)
|
.setPrimaryText(R.string.dialog_title_image_support)
|
||||||
.setSecondaryText(R.string.dialog_message_image_support)
|
.setSecondaryText(R.string.dialog_message_image_support)
|
||||||
.setBackgroundColour(
|
.setBackgroundColour(getColor(activity, R.color.briar_primary))
|
||||||
getColor(activity, R.color.briar_primary))
|
|
||||||
.setIcon(R.drawable.ic_image)
|
.setIcon(R.drawable.ic_image)
|
||||||
.setIconDrawableColourFilter(color)
|
.setIconDrawableColourFilter(color)
|
||||||
.setPromptStateChangeListener(listener)
|
.setPromptStateChangeListener(listener)
|
||||||
|
|||||||
Reference in New Issue
Block a user