Skip to content

Commit

Permalink
Merge pull request #153 from apptentive/branch_5.0.5
Browse files Browse the repository at this point in the history
Release 5.0.5
  • Loading branch information
weeeBox authored Apr 20, 2018
2 parents 23f733f + fadaf88 commit 321acac
Show file tree
Hide file tree
Showing 33 changed files with 1,192 additions and 921 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# 2018-04-19 - v5.0.5

#### Bugs Fixed

* Fix message polling issue.
* Fix UI-related crashes for logged-out conversation.
* Fix sending device diffs.

#### Improvements

* Overall stability improvements.

# 2018-02-08 - v5.0.4

#### Bugs Fixed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use your app, to talk to them at the right time, and in the right way.

##### [Release Notes](https://learn.apptentive.com/knowledge-base/android-sdk-release-notes/)

##### Binary releases are hosted for Maven [here](http://search.maven.org/#artifactdetails|com.apptentive|apptentive-android|5.0.4|aar)
##### Binary releases are hosted for Maven [here](http://search.maven.org/#artifactdetails|com.apptentive|apptentive-android|5.0.5|aar)

#### Reporting Bugs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;

Expand Down Expand Up @@ -79,6 +80,7 @@
import static com.apptentive.android.sdk.ApptentiveNotifications.NOTIFICATION_APP_ENTERED_BACKGROUND;
import static com.apptentive.android.sdk.ApptentiveNotifications.NOTIFICATION_APP_ENTERED_FOREGROUND;
import static com.apptentive.android.sdk.ApptentiveNotifications.NOTIFICATION_AUTHENTICATION_FAILED;
import static com.apptentive.android.sdk.ApptentiveNotifications.NOTIFICATION_CONVERSATION_STATE_DID_CHANGE;
import static com.apptentive.android.sdk.ApptentiveNotifications.NOTIFICATION_CONVERSATION_WILL_LOGOUT;
import static com.apptentive.android.sdk.ApptentiveNotifications.NOTIFICATION_INTERACTIONS_FETCHED;
import static com.apptentive.android.sdk.ApptentiveNotifications.NOTIFICATION_INTERACTIONS_SHOULD_DISMISS;
Expand Down Expand Up @@ -198,6 +200,7 @@ private ApptentiveInternal(Application application, String apptentiveKey, String

lifecycleCallbacks = new ApptentiveActivityLifecycleCallbacks();
ApptentiveNotificationCenter.defaultCenter()
.addObserver(NOTIFICATION_CONVERSATION_STATE_DID_CHANGE, this)
.addObserver(NOTIFICATION_CONVERSATION_WILL_LOGOUT, this)
.addObserver(NOTIFICATION_AUTHENTICATION_FAILED, this)
.addObserver(NOTIFICATION_INTERACTION_MANIFEST_FETCHED, this);
Expand Down Expand Up @@ -391,7 +394,7 @@ public Conversation getConversation() {
return conversationManager.getActiveConversation();
}

public ConversationProxy getConversationProxy() {
public @Nullable ConversationProxy getConversationProxy() {
return conversationManager.getActiveConversationProxy();
}

Expand Down Expand Up @@ -595,11 +598,6 @@ private boolean start() {
// Used for application theme inheritance if the theme is an AppCompat theme.
setApplicationDefaultTheme(ai.theme);

Conversation conversation = getConversation();
if (conversation != null) {
checkSendVersionChanges(conversation);
}

defaultAppDisplayName = packageManager.getApplicationLabel(packageManager.getApplicationInfo(packageInfo.packageName, 0)).toString();

// Prevent delayed run-time exception if the app upgrades from pre-2.0 and doesn't remove NetworkStateReceiver from manifest
Expand Down Expand Up @@ -1141,7 +1139,13 @@ protected void execute() {
public void onReceiveNotification(ApptentiveNotification notification) {
checkConversationQueue();

if (notification.hasName(NOTIFICATION_CONVERSATION_WILL_LOGOUT)) {
if (notification.hasName(NOTIFICATION_CONVERSATION_STATE_DID_CHANGE)) {
Conversation conversation = notification.getRequiredUserInfo(NOTIFICATION_KEY_CONVERSATION, Conversation.class);
if (conversation.hasActiveState()) {
checkSendVersionChanges(conversation);
}
}
else if (notification.hasName(NOTIFICATION_CONVERSATION_WILL_LOGOUT)) {
Conversation conversation = notification.getRequiredUserInfo(NOTIFICATION_KEY_CONVERSATION, Conversation.class);
conversation.addPayload(new LogoutPayload());
} else if (notification.hasName(NOTIFICATION_AUTHENTICATION_FAILED)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import com.apptentive.android.sdk.debug.Assert;
import com.apptentive.android.sdk.model.FragmentFactory;
import com.apptentive.android.sdk.module.engagement.interaction.fragment.ApptentiveBaseFragment;
import com.apptentive.android.sdk.module.metric.MetricModule;
import com.apptentive.android.sdk.notifications.ApptentiveNotification;
import com.apptentive.android.sdk.util.Constants;
import com.apptentive.android.sdk.util.StringUtils;
Expand Down Expand Up @@ -67,50 +66,50 @@ public class ApptentiveViewActivity extends ApptentiveBaseActivity implements Ap
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

if (!ApptentiveInternal.isApptentiveRegistered()) {
ApptentiveLog.e("Apptentive instance is not properly initialized. Finishing activity...");
finish();
return;
}

dispatchOnConversationQueue(new DispatchTask() {
@Override
protected void execute() {
Conversation conversation = notNull(ApptentiveInternal.getInstance().getConversation());
if (conversation == null) {
dispatchOnMainQueue(new DispatchTask() {
@Override
protected void execute() {
finish();
}
});
}
try {
if (!ApptentiveInternal.isApptentiveRegistered()) {
ApptentiveLog.e("Apptentive instance is not properly initialized. Finishing activity...");
finish();
return;
}
});

if (getIntent().getExtras() == null) {
ApptentiveLog.w("ApptentiveViewActivity was started without any extras, which isn't allowed. Finishing Activity.");
finish();
return;
}

Bundle bundle = FragmentFactory.addDisplayModeToFragmentBundle(getIntent().getExtras());
boolean isInteractionModal = bundle.getBoolean(Constants.FragmentConfigKeys.MODAL);
dispatchOnConversationQueue(new DispatchTask() {
@Override
protected void execute() {
Conversation conversation = notNull(ApptentiveInternal.getInstance().getConversation());
if (conversation == null) {
dispatchOnMainQueue(new DispatchTask() {
@Override
protected void execute() {
finish();
}
});
}
}
});

ApptentiveBaseFragment newFragment = null;
if (savedInstanceState != null) {
// retrieve the retained fragment after orientation change using saved tag
String savedFragmentTag = savedInstanceState.getString(FRAGMENT_TAG);
newFragment = (ApptentiveBaseFragment) getSupportFragmentManager().findFragmentByTag(savedFragmentTag);
/* Since we always store tags of fragments in the ViewPager upon orientation change,
* failure of retrieval indicate internal error
*/
if (newFragment == null) {
if (getIntent().getExtras() == null) {
ApptentiveLog.w("ApptentiveViewActivity was started without any extras, which isn't allowed. Finishing Activity.");
finish();
return;
}
}
try {

Bundle bundle = FragmentFactory.addDisplayModeToFragmentBundle(getIntent().getExtras());
boolean isInteractionModal = bundle.getBoolean(Constants.FragmentConfigKeys.MODAL);

ApptentiveBaseFragment newFragment = null;
if (savedInstanceState != null) {
// retrieve the retained fragment after orientation change using saved tag
String savedFragmentTag = savedInstanceState.getString(FRAGMENT_TAG);
newFragment = (ApptentiveBaseFragment) getSupportFragmentManager().findFragmentByTag(savedFragmentTag);
/* Since we always store tags of fragments in the ViewPager upon orientation change,
* failure of retrieval indicate internal error
*/
if (newFragment == null) {
finish();
return;
}
}
fragmentType = bundle.getInt(Constants.FragmentConfigKeys.TYPE, Constants.FragmentTypes.UNKNOWN);

if (fragmentType != Constants.FragmentTypes.UNKNOWN) {
Expand Down Expand Up @@ -138,105 +137,103 @@ protected void execute() {
finish();
return;
}

}
} catch (Exception e) {
ApptentiveLog.e(e, "Error creating ApptentiveViewActivity.");
MetricModule.sendError(e, null, null);
}

setContentView(R.layout.apptentive_viewactivity);

toolbar = (Toolbar) findViewById(R.id.apptentive_toolbar);
setSupportActionBar(toolbar);

/* Add top padding by the amount of Status Bar height to avoid toolbar being covered when
* status bar is translucent
*/
toolbar.setPadding(0, getToolbarHeightAdjustment(!isInteractionModal), 0, 0);
setContentView(R.layout.apptentive_viewactivity);

ActionBar actionBar = getSupportActionBar();
toolbar = (Toolbar) findViewById(R.id.apptentive_toolbar);
setSupportActionBar(toolbar);

if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
int navIconResId = newFragment.getToolbarNavigationIconResourceId(getTheme());
// Check if fragment may show an alternative navigation icon
if (navIconResId != 0) {
/* In order for the alternative icon has the same color used by toolbar icon,
* need to apply the same color in toolbar theme
* By default colorControlNormal has same value as textColorPrimary defined in toolbar theme overlay
*/
// Allows loading of vector drawable resources from XML
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
final Drawable alternateUpArrow = ResourcesCompat.getDrawable(getResources(),
navIconResId,
getTheme());

int colorControlNormal = Util.getThemeColor(ApptentiveInternal.getInstance().getApptentiveToolbarTheme(), R.attr.colorControlNormal);
alternateUpArrow.setColorFilter(colorControlNormal, PorterDuff.Mode.SRC_ATOP);
actionBar.setHomeAsUpIndicator(alternateUpArrow);
}
/* Add top padding by the amount of Status Bar height to avoid toolbar being covered when
* status bar is translucent
*/
toolbar.setPadding(0, getToolbarHeightAdjustment(!isInteractionModal), 0, 0);

ActionBar actionBar = getSupportActionBar();

if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
int navIconResId = newFragment.getToolbarNavigationIconResourceId(getTheme());
// Check if fragment may show an alternative navigation icon
if (navIconResId != 0) {
/* In order for the alternative icon has the same color used by toolbar icon,
* need to apply the same color in toolbar theme
* By default colorControlNormal has same value as textColorPrimary defined in toolbar theme overlay
*/
// Allows loading of vector drawable resources from XML
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
final Drawable alternateUpArrow = ResourcesCompat.getDrawable(getResources(),
navIconResId,
getTheme());

int colorControlNormal = Util.getThemeColor(ApptentiveInternal.getInstance().getApptentiveToolbarTheme(), R.attr.colorControlNormal);
alternateUpArrow.setColorFilter(colorControlNormal, PorterDuff.Mode.SRC_ATOP);
actionBar.setHomeAsUpIndicator(alternateUpArrow);
}

String contentDescription = newFragment.getToolbarNavigationContentDescription();
if (!StringUtils.isNullOrEmpty(contentDescription)) {
actionBar.setHomeActionContentDescription(contentDescription);
String contentDescription = newFragment.getToolbarNavigationContentDescription();
if (!StringUtils.isNullOrEmpty(contentDescription)) {
actionBar.setHomeActionContentDescription(contentDescription);
}
}
}

//current_tab = extra.getInt(SELECTED_TAB_EXTRA_KEY, 0);
current_tab = 0;
//current_tab = extra.getInt(SELECTED_TAB_EXTRA_KEY, 0);
current_tab = 0;

addFragmentToAdapter(newFragment, newFragment.getTitle());
addFragmentToAdapter(newFragment, newFragment.getTitle());

// Get the ViewPager and set it's PagerAdapter so that it can display items
viewPager = (ViewPager) findViewById(R.id.apptentive_vp);
viewPager.setAdapter(viewPager_Adapter);
// Get the ViewPager and set it's PagerAdapter so that it can display items
viewPager = (ViewPager) findViewById(R.id.apptentive_vp);
viewPager.setAdapter(viewPager_Adapter);


ViewPager.OnPageChangeListener pageChangeListener = new ViewPager.OnPageChangeListener() {
Boolean first = true;
ViewPager.OnPageChangeListener pageChangeListener = new ViewPager.OnPageChangeListener() {
Boolean first = true;

@Override
public void onPageSelected(int position) {
final ApptentiveBaseFragment currentFragment = (ApptentiveBaseFragment) viewPager_Adapter.getItem(viewPager.getCurrentItem());
// Set the Activity title for TalkBack support
final String title = currentFragment.getTitle();
if (currentFragment != null && currentFragment.getActivity() != null) {
currentFragment.getActivity().setTitle(title);
}
if (!currentFragment.isShownAsModalDialog()) {
toolbar.post(new Runnable() { // TODO: replace with DispatchQueue
@Override
public void run() {
toolbar.setVisibility(View.VISIBLE);
toolbar.setTitle(title);
}
});
} else {
toolbar.setVisibility(View.GONE);
@Override
public void onPageSelected(int position) {
final ApptentiveBaseFragment currentFragment = (ApptentiveBaseFragment) viewPager_Adapter.getItem(viewPager.getCurrentItem());
// Set the Activity title for TalkBack support
final String title = currentFragment.getTitle();
if (currentFragment != null && currentFragment.getActivity() != null) {
currentFragment.getActivity().setTitle(title);
}
if (!currentFragment.isShownAsModalDialog()) {
toolbar.post(new Runnable() { // TODO: replace with DispatchQueue
@Override
public void run() {
toolbar.setVisibility(View.VISIBLE);
toolbar.setTitle(title);
}
});
} else {
toolbar.setVisibility(View.GONE);
}
current_tab = position;
}
current_tab = position;
}

@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
if (first && positionOffset == 0 && positionOffsetPixels == 0) {
onPageSelected(current_tab);
first = false;
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
if (first && positionOffset == 0 && positionOffsetPixels == 0) {
onPageSelected(current_tab);
first = false;
}
}
}

@Override
public void onPageScrollStateChanged(int pos) {
// TODO Auto-generated method stub
}
};
@Override
public void onPageScrollStateChanged(int pos) {
// TODO Auto-generated method stub
}
};

viewPager.addOnPageChangeListener(pageChangeListener);
viewPager.addOnPageChangeListener(pageChangeListener);


// Needed to prevent the window from being panned up when the keyboard is opened.
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
// Needed to prevent the window from being panned up when the keyboard is opened.
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
} catch (Exception e) {
ApptentiveLog.e(e, "Exception in %s.onCreate()", ApptentiveViewActivity.class.getSimpleName());
}
}

public boolean onOptionsItemSelected(MenuItem item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public void setDevice(Device device) {
Assert.assertNotNull(device, "Device may not be null.");
this.device = device;
device.setDataChangedListener(this);
device.setDeviceDataChangedListener(this);
notifyDataChanged();
}

Expand All @@ -168,6 +169,7 @@ public void setPerson(Person person) {
Assert.assertNotNull(person, "Person may not be null.");
this.person = person;
this.person.setDataChangedListener(this);
this.person.setPersonDataChangedListener(this);
notifyDataChanged();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import android.content.Context;
import android.content.SharedPreferences;
import android.support.annotation.Nullable;

import com.apptentive.android.sdk.Apptentive;
import com.apptentive.android.sdk.Apptentive.LoginCallback;
Expand Down Expand Up @@ -1027,7 +1028,7 @@ private synchronized void setActiveConversation(Conversation conversation) {
this.activeConversationProxy = conversation != null ? new ConversationProxy(conversation) : null;
}

public synchronized ConversationProxy getActiveConversationProxy() {
public synchronized @Nullable ConversationProxy getActiveConversationProxy() {
return activeConversationProxy;
}

Expand Down
Loading

0 comments on commit 321acac

Please sign in to comment.