Skip to content

Commit

Permalink
Apptentive Android SDK 5.8.4 (#239)
Browse files Browse the repository at this point in the history
5.8.4 release
  • Loading branch information
ChaseApptentive authored Sep 26, 2022
1 parent a236246 commit 91aebf3
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 18 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 2022-09-26 - v5.8.4

#### Fixes

* Support Message Center Push Notifications for Android 13

# 2022-03-16 - v5.8.3

#### Fixes
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.8.3|aar)
##### Binary releases are hosted for Maven [here](http://search.maven.org/#artifactdetails|com.apptentive|apptentive-android|5.8.4|aar)

#### Reporting Bugs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -921,8 +921,13 @@ public static PendingIntent prepareMessageCenterPendingIntent(Context context, C
} else {
intent = MessageCenterInteraction.generateMessageCenterErrorIntent(context);
}
return (intent != null) ? PendingIntent.getActivity(context, 0, intent,
PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT) : null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return PendingIntent.getActivity(context, 0, intent,
PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
} else {
return PendingIntent.getActivity(context, 0, intent,
PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
package com.apptentive.android.sdk.module.engagement.interaction.fragment;


import static com.apptentive.android.sdk.ApptentiveHelper.dispatchConversationTask;
import static com.apptentive.android.sdk.ApptentiveLogTag.MESSAGES;
import static com.apptentive.android.sdk.debug.Assert.assertMainThread;
import static com.apptentive.android.sdk.debug.Assert.assertNotNull;
import static com.apptentive.android.sdk.module.messagecenter.model.MessageCenterListItem.MESSAGE_COMPOSER;
import static com.apptentive.android.sdk.module.messagecenter.model.MessageCenterListItem.MESSAGE_CONTEXT;
import static com.apptentive.android.sdk.module.messagecenter.model.MessageCenterListItem.MESSAGE_OUTGOING;
import static com.apptentive.android.sdk.module.messagecenter.model.MessageCenterListItem.STATUS;
import static com.apptentive.android.sdk.module.messagecenter.model.MessageCenterListItem.WHO_CARD;
import static com.apptentive.android.sdk.util.Util.guarded;
import static com.apptentive.android.sdk.util.Util.hasPermission;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
Expand All @@ -19,8 +31,6 @@
import android.os.Handler;
import android.os.Message;
import android.os.Parcelable;
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import android.text.Editable;
import android.text.TextUtils;
import android.view.LayoutInflater;
Expand All @@ -33,10 +43,13 @@
import android.widget.AbsListView;
import android.widget.EditText;

import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.apptentive.android.sdk.Apptentive;
import com.apptentive.android.sdk.ApptentiveInternal;
import com.apptentive.android.sdk.ApptentiveLog;
Expand All @@ -62,6 +75,7 @@
import com.apptentive.android.sdk.module.messagecenter.view.holder.MessageComposerHolder;
import com.apptentive.android.sdk.util.AnimationUtil;
import com.apptentive.android.sdk.util.Constants;
import com.apptentive.android.sdk.util.RuntimeUtils;
import com.apptentive.android.sdk.util.StringUtils;
import com.apptentive.android.sdk.util.Util;
import com.apptentive.android.sdk.util.image.ApptentiveAttachmentLoader;
Expand All @@ -84,17 +98,6 @@
import java.util.ListIterator;
import java.util.Set;

import static com.apptentive.android.sdk.ApptentiveHelper.dispatchConversationTask;
import static com.apptentive.android.sdk.debug.Assert.assertMainThread;
import static com.apptentive.android.sdk.debug.Assert.assertNotNull;
import static com.apptentive.android.sdk.ApptentiveLogTag.MESSAGES;
import static com.apptentive.android.sdk.module.messagecenter.model.MessageCenterListItem.MESSAGE_COMPOSER;
import static com.apptentive.android.sdk.module.messagecenter.model.MessageCenterListItem.MESSAGE_CONTEXT;
import static com.apptentive.android.sdk.module.messagecenter.model.MessageCenterListItem.MESSAGE_OUTGOING;
import static com.apptentive.android.sdk.module.messagecenter.model.MessageCenterListItem.STATUS;
import static com.apptentive.android.sdk.module.messagecenter.model.MessageCenterListItem.WHO_CARD;
import static com.apptentive.android.sdk.util.Util.guarded;

public class MessageCenterFragment extends ApptentiveBaseFragment<MessageCenterInteraction> implements
OnListviewItemActionListener,
MessageManager.AfterSendMessageListener,
Expand Down Expand Up @@ -255,6 +258,8 @@ protected boolean execute(Conversation conversation) {

// Needed to prevent the window from being pushed up when a text input area is focused.
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

getPushNotificationPermission();
}

private void fetchMessages(final FetchCallback callback) {
Expand Down Expand Up @@ -382,6 +387,9 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {

break;
}
case Constants.REQUEST_POST_NOTIFICATION_PERMISSION: {
break;
}
default:
break;
}
Expand Down Expand Up @@ -1067,7 +1075,7 @@ public void onScrollStateChanged(AbsListView view, int scrollState) {
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
boolean bCanScrollUp;
if (android.os.Build.VERSION.SDK_INT < 14) {
if (Build.VERSION.SDK_INT < 14) {
bCanScrollUp = view.getChildCount() > 0
&& (view.getFirstVisiblePosition() > 0 ||
view.getChildAt(0).getTop() < view.getPaddingTop());
Expand Down Expand Up @@ -1669,4 +1677,22 @@ public String getToolbarNavigationContentDescription() {
private interface FetchCallback {
void onFetchFinish(@Nullable List<MessageCenterListItem> items);
}

//region push notifications
private void getPushNotificationPermission() {
String POST_NOTIFICATIONS = "android.permission.POST_NOTIFICATIONS";

SharedPreferences prefs = ApptentiveInternal.getInstance().getGlobalSharedPrefs();

boolean hasPushSetUp = prefs != null && prefs.getInt(Constants.PREF_KEY_PUSH_PROVIDER, -1) != -1 &&
prefs.getString(Constants.PREF_KEY_PUSH_TOKEN, null) != null;

if (hasPushSetUp &&
Build.VERSION.SDK_INT >= 33 &&
!hasPermission(requireContext(), POST_NOTIFICATIONS) &&
RuntimeUtils.getApplicationInfo(requireContext()).getTargetSdkVersion() >= 33) {
requestPermissions(new String[]{POST_NOTIFICATIONS}, Constants.REQUEST_POST_NOTIFICATION_PERMISSION);
}
}
//endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public class Constants {

public static final int API_VERSION = 10;
private static final String APPTENTIVE_SDK_VERSION = "5.8.3";
private static final String APPTENTIVE_SDK_VERSION = "5.8.4";

public static final int DEFAULT_CONNECT_TIMEOUT_MILLIS = 45000;
public static final int DEFAULT_READ_TIMEOUT_MILLIS = 45000;
Expand All @@ -18,6 +18,7 @@ public class Constants {
public static final int REQUEST_CODE_CLOSE_COMPOSING_CONFIRMATION = 20;

public final static int REQUEST_READ_STORAGE_PERMISSION = 1;
public final static int REQUEST_POST_NOTIFICATION_PERMISSION = 2;

public static final String PREF_NAME = "APPTENTIVE";

Expand Down

0 comments on commit 91aebf3

Please sign in to comment.