Skip to content

Commit

Permalink
Merge pull request apptentive#109 from apptentive/ux-fix
Browse files Browse the repository at this point in the history
Ux fix
  • Loading branch information
barry-li committed Sep 2, 2015
2 parents 34b5c8b + 718e76c commit 08b1646
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 41 deletions.
Expand Up @@ -96,6 +96,7 @@ public class MessageCenterActivityContent extends InteractionView<MessageCenterI
private ListView messageCenterListView; // List of apptentive messages
private EditText messageEditText; // Composing area
private View fab;
private View profileButton;

// Data backing of the listview
private ArrayList<MessageCenterListItem> messages = new ArrayList<>();
Expand Down Expand Up @@ -334,6 +335,38 @@ public void onClick(View v) {
messageCenterListAdapter.notifyDataSetChanged();
}
});

profileButton = viewActivity.findViewById(R.id.profile);
if (profileButton != null) {
profileButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// Only allow profile editing when not already editing profile or in message composing
if (whoCardItem == null && composingItem == null) {
hideProfileButton();
SharedPreferences prefs = viewActivity.getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE);
boolean bWhoCardSet = prefs.getBoolean(Constants.PREF_KEY_MESSAGE_CENTER_WHO_CARD_SET, false);

JSONObject data = new JSONObject();
try {
data.put("required", interaction.getWhoCardRequired());
data.put("trigger", "button");
} catch (JSONException e) {
//
}
EngagementModule.engageInternal(viewActivity, interaction, MessageCenterInteraction.EVENT_NAME_PROFILE_OPEN, data.toString());

if (!bWhoCardSet) {
addWhoCard(WHO_CARD_MODE_INIT);
} else {
addWhoCard(WHO_CARD_MODE_EDIT);
}
messageCenterListAdapter.setForceShowKeyboard(true);
messageCenterListAdapter.notifyDataSetChanged();
}
}
});
}

if (messageCenterListAdapter == null) {
List<MessageCenterListItem> items = MessageManager.getMessageCenterListItems(viewActivity);
unsendMessagesCount = countUnsendOutgoingMessages(items);
Expand Down Expand Up @@ -369,7 +402,6 @@ else if (pendingWhoCardName != null || pendingWhoCardEmail != null || pendingWho
messageCenterListView.setAdapter(messageCenterListAdapter);
}


View attachButton = viewActivity.findViewById(R.id.attach);
if (attachButton != null && attachButton.getVisibility() == View.VISIBLE) {
// Android devices can't take screenshots until Android OS version 4+
Expand Down Expand Up @@ -397,36 +429,6 @@ public void onClick(View view) {
}
}

View profileButton = viewActivity.findViewById(R.id.profile);
if (profileButton != null) {
profileButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// Only allow profile editing when not already editing profile or in message composing
if (whoCardItem == null && composingItem == null) {
SharedPreferences prefs = viewActivity.getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE);
boolean bWhoCardSet = prefs.getBoolean(Constants.PREF_KEY_MESSAGE_CENTER_WHO_CARD_SET, false);

JSONObject data = new JSONObject();
try {
data.put("required", interaction.getWhoCardRequired());
data.put("trigger", "button");
} catch (JSONException e) {
//
}
EngagementModule.engageInternal(viewActivity, interaction, MessageCenterInteraction.EVENT_NAME_PROFILE_OPEN, data.toString());

if (!bWhoCardSet) {
addWhoCard(WHO_CARD_MODE_INIT);
} else {
addWhoCard(WHO_CARD_MODE_EDIT);
}
messageCenterListAdapter.setForceShowKeyboard(true);
messageCenterListAdapter.notifyDataSetChanged();
}
}
});
}

}

@Override
Expand Down Expand Up @@ -548,6 +550,7 @@ public void addContextualMessage() {

public void addComposingArea() {
hideFab();
hideProfileButton();
clearStatus();
actionBarItem = interaction.getComposerBar();
messages.add(actionBarItem);
Expand All @@ -567,6 +570,7 @@ private boolean addWhoCardInitIfRequired() {
}

public void addWhoCard(int mode) {
hideProfileButton();
if (!interaction.getWhoCardRequestEnabled()) {
return;
}
Expand Down Expand Up @@ -788,7 +792,18 @@ public void beforeComposingTextChanged(CharSequence str) {

@Override
public void onComposingTextChanged(CharSequence str) {
if (!TextUtils.isEmpty(str)) {
}

@Override
public void afterComposingTextChanged(String str) {
if (str == null || str.trim().isEmpty()) {
MessageCenterComposingActionBarView barView = messageCenterListAdapter.getComposingActionBarView();
if (barView != null) {
barView.sendButton.setEnabled(false);
barView.sendButton.setColorFilter(R.color.apptentive_material_disabled_text);
barView.showConfirmation = false;
}
} else {
MessageCenterComposingActionBarView barView = messageCenterListAdapter.getComposingActionBarView();
if (barView != null) {
barView.sendButton.setEnabled(true);
Expand All @@ -799,11 +814,6 @@ public void onComposingTextChanged(CharSequence str) {
}
}

@Override
public void afterComposingTextChanged(String str) {

}

@Override
public void onCancelComposing() {
messageCenterListAdapter.setForceShowKeyboard(false);
Expand Down Expand Up @@ -842,6 +852,7 @@ public void onAnimationEnd(Animator animation) {
messageCenterListAdapter.clearComposing();
messageCenterListAdapter.notifyDataSetChanged();
showFab();
showProfileButton();
// messageEditText has been set to null, pending composing message will reset
saveOrClearPendingComposingMessage();
}
Expand Down Expand Up @@ -893,6 +904,7 @@ public void onAnimationEnd(Animator animation) {
messageText), DEFAULT_DELAYMILLIS);
}
showFab();
showProfileButton();
}

@Override
Expand Down Expand Up @@ -964,6 +976,7 @@ public void onAnimationEnd(Animator animation) {
messageCenterViewHandler.sendEmptyMessageDelayed(MSG_MESSAGE_NOTIFY_UPDATE, DEFAULT_DELAYMILLIS);
} else {
showFab();
showProfileButton();
}
}

Expand Down Expand Up @@ -1112,4 +1125,12 @@ private void hideFab() {
AnimationUtil.scaleFadeOutGone(fab);
}

private void showProfileButton() {
AnimationUtil.fadeIn(profileButton, null);
}

private void hideProfileButton() {
AnimationUtil.fadeOutGone(profileButton);
}

}
Expand Up @@ -49,6 +49,7 @@ public void onTextChanged(CharSequence charSequence, int start, int before, int

@Override
public void afterTextChanged(Editable editable) {
listener.afterComposingTextChanged(editable.toString());
}
});

Expand Down
Expand Up @@ -318,8 +318,7 @@ public void setAdapter(ListAdapter adapter) {
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
if (stickyWrapper != null) {
int parentWidth = r - l - getPaddingLeft() - getPaddingRight() -
stickyWrapper.additionalIndent * 2;
int parentWidth = r - l - getPaddingLeft() - getPaddingRight();
int shadowWidth = stickyWrapper.view.getWidth();
if (parentWidth != shadowWidth) {
recreateStickyShadow();
Expand All @@ -336,6 +335,7 @@ protected void dispatchDraw(Canvas canvas) {
int pLeft = getListPaddingLeft();
int pTop = getListPaddingTop();
View view = stickyWrapper.view;
int headerTop = view.getTop();
pLeft += stickyWrapper.additionalIndent;
// draw child
canvas.save();
Expand All @@ -344,7 +344,7 @@ protected void dispatchDraw(Canvas canvas) {
(shadowDrawable == null ? 0 : shadowHeight);
canvas.clipRect(pLeft, pTop, pLeft + view.getWidth() - 2 * stickyWrapper.additionalIndent, pTop + clipHeight);

canvas.translate(pLeft - stickyWrapper.additionalIndent, pTop);
canvas.translate(pLeft - stickyWrapper.additionalIndent, pTop - headerTop);
drawChild(canvas, stickyWrapper.view, getDrawingTime());

if (shadowDrawable != null) {
Expand Down
Expand Up @@ -92,14 +92,17 @@ public static void fadeIn(final View view, final Animator.AnimatorListener al) {

ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(view, "alpha", ALPHA_DEFAULT);

alphaAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
if (al != null) {
alphaAnimator.addListener(al);
}
alphaAnimator.start();
}

private static void fadeOut(final View view, final int endVisibility) {
if (view.getAlpha() == 0 || view.getVisibility() == endVisibility) {
return;
}

ObjectAnimator animation = ObjectAnimator.ofFloat(view, "alpha", ALPHA_MIN);

animation.setDuration(ANIMATION_DURATION);
Expand Down

0 comments on commit 08b1646

Please sign in to comment.