Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,7 @@ google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
freeline_project_description.json

# MacOS generated files
.DS_Store
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).
#### Fixed
- nothing yet

## [3.2.12](https://github.com/Iterable/iterable-android-sdk/releases/tag/3.2.12)
#### Added
- Support for the display of a custom message (title and body) in an empty mobile inbox.
For more details, see [Customizing Mobile Inbox on Android](https://iterable.zendesk.com/hc/articles/360039189931#empty-state)
- Support for syncing in-app message read state across multiple devices:
- When the SDK fetches in-app messages from Iterable, it examines each message's `read` field to determine if it has already been read.
- The SDK's default implementation no longer automatically displays in-app messages that have already been seen on another device (even if those messages were _not_ configured to go directly to the inbox).

## [3.2.11](https://github.com/Iterable/iterable-android-sdk/releases/tag/3.2.11)
#### Changed
- Changed the timeout for GET calls (`/inApp/getMessages` in particular) from 3 to 10 seconds.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,18 @@ public void testSwipeToDeleteInApp() throws Exception {
onView(withText("Tips and tricks 2")).check(doesNotExist());
}

@Test
public void testNoMessagesTitleAndText() throws Exception {
Intent intent = new Intent();
String noMessageTitle = "OOPSY";
String noMessageBody = "No messages for you";
intent.putExtra(IterableConstants.NO_MESSAGES_TITLE, noMessageTitle);
intent.putExtra(IterableConstants.NO_MESSAGES_BODY, noMessageBody);
rule.launchActivity(intent);
onView(withText(noMessageTitle)).check(matches(isDisplayed()));
onView(withText(noMessageBody)).check(matches(isDisplayed()));
}


static class Matchers{
public static Matcher<View> withListSize (final int size) {
Expand Down Expand Up @@ -283,4 +295,4 @@ static void waitFor(int ms) {
Assert.fail(e.getMessage());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ protected void beforeActivityLaunched() {

@Test
public void basicTest() {
onView(withId(R.id.list)).perform(click());
assertNotNull(rule.getActivity());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ protected void beforeActivityLaunched() {

@Test
public void basicTest() {
onView(withId(R.id.list)).perform(click());
assertNotNull(rule.getActivity());
}
}
2 changes: 1 addition & 1 deletion iterableapi-ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ ext {
siteUrl = 'https://github.com/Iterable/iterable-android-sdk'
gitUrl = 'https://github.com/Iterable/iterable-android-sdk.git'

libraryVersion = '3.2.11'
libraryVersion = '3.2.12'

developerId = 'davidtruong'
developerName = 'David Truong'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.iterable.iterableapi.IterableConstants;
import com.iterable.iterableapi.IterableLogger;
import com.iterable.iterableapi.ui.R;

Expand Down Expand Up @@ -37,7 +38,14 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
if (inboxModeExtra instanceof InboxMode) {
inboxMode = (InboxMode) inboxModeExtra;
}
inboxFragment = IterableInboxFragment.newInstance(inboxMode, itemLayoutId);
String noMessageTitle = null;
String noMessageBody = null;
Bundle extraBundle = getIntent().getExtras();
if (extraBundle != null) {
noMessageTitle = extraBundle.getString(IterableConstants.NO_MESSAGES_TITLE, null);
noMessageBody = extraBundle.getString(IterableConstants.NO_MESSAGES_BODY, null);
}
inboxFragment = IterableInboxFragment.newInstance(inboxMode, itemLayoutId, noMessageTitle, noMessageBody);

if (intent.getStringExtra(ACTIVITY_TITLE) != null) {
setTitle(intent.getStringExtra(ACTIVITY_TITLE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.iterable.iterableapi.IterableActivityMonitor;
import com.iterable.iterableapi.IterableApi;
import com.iterable.iterableapi.IterableConstants;
import com.iterable.iterableapi.IterableInAppDeleteActionType;
import com.iterable.iterableapi.IterableInAppLocation;
import com.iterable.iterableapi.IterableInAppManager;
Expand Down Expand Up @@ -45,6 +48,11 @@ public class IterableInboxFragment extends Fragment implements IterableInAppMana

private InboxMode inboxMode = InboxMode.POPUP;
private @LayoutRes int itemLayoutId = R.layout.iterable_inbox_item;
private String noMessagesTitle;
private String noMessagesBody;
TextView noMessagesTitleTextView;
TextView noMessagesBodyTextView;
RecyclerView recyclerView;

private final SessionManager sessionManager = new SessionManager();
private IterableInboxAdapterExtension adapterExtension = new DefaultAdapterExtension();
Expand Down Expand Up @@ -72,10 +80,16 @@ public class IterableInboxFragment extends Fragment implements IterableInAppMana
* @return {@link IterableInboxFragment} instance
*/
@NonNull public static IterableInboxFragment newInstance(@NonNull InboxMode inboxMode, @LayoutRes int itemLayoutId) {
return newInstance(inboxMode, itemLayoutId, null, null);
}

@NonNull public static IterableInboxFragment newInstance(@NonNull InboxMode inboxMode, @LayoutRes int itemLayoutId, @Nullable String noMessagesTitle, @Nullable String noMessagesBody) {
IterableInboxFragment inboxFragment = new IterableInboxFragment();
Bundle bundle = new Bundle();
bundle.putSerializable(INBOX_MODE, inboxMode);
bundle.putInt(ITEM_LAYOUT_ID, itemLayoutId);
bundle.putString(IterableConstants.NO_MESSAGES_TITLE, noMessagesTitle);
bundle.putString(IterableConstants.NO_MESSAGES_BODY, noMessagesBody);
inboxFragment.setArguments(bundle);

return inboxFragment;
Expand Down Expand Up @@ -153,15 +167,26 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
if (arguments.getInt(ITEM_LAYOUT_ID, 0) != 0) {
itemLayoutId = arguments.getInt(ITEM_LAYOUT_ID);
}
if (arguments.getString(IterableConstants.NO_MESSAGES_TITLE) != null) {
noMessagesTitle = arguments.getString(IterableConstants.NO_MESSAGES_TITLE);
}
if (arguments.getString(IterableConstants.NO_MESSAGES_BODY) != null) {
noMessagesBody = arguments.getString(IterableConstants.NO_MESSAGES_BODY);
}
}

RecyclerView view = (RecyclerView) inflater.inflate(R.layout.iterable_inbox_fragment, container, false);
view.setLayoutManager(new LinearLayoutManager(getContext()));
RelativeLayout relativeLayout = (RelativeLayout) inflater.inflate(R.layout.iterable_inbox_fragment, container, false);
recyclerView = relativeLayout.findViewById(R.id.list);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
IterableInboxAdapter adapter = new IterableInboxAdapter(IterableApi.getInstance().getInAppManager().getInboxMessages(), IterableInboxFragment.this, adapterExtension, comparator, filter, dateMapper);
view.setAdapter(adapter);
recyclerView.setAdapter(adapter);
noMessagesTitleTextView = relativeLayout.findViewById(R.id.emptyInboxTitle);
noMessagesBodyTextView = relativeLayout.findViewById(R.id.emptyInboxMessage);
noMessagesTitleTextView.setText(noMessagesTitle);
noMessagesBodyTextView.setText(noMessagesBody);
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new IterableInboxTouchHelper(getContext(), adapter));
itemTouchHelper.attachToRecyclerView(view);
return view;
itemTouchHelper.attachToRecyclerView(recyclerView);
return relativeLayout;
}

@Override
Expand Down Expand Up @@ -213,9 +238,21 @@ private void stopSession() {
}

private void updateList() {
RecyclerView recyclerView = (RecyclerView) getView();
IterableInboxAdapter adapter = (IterableInboxAdapter) recyclerView.getAdapter();
adapter.setInboxItems(IterableApi.getInstance().getInAppManager().getInboxMessages());
handleEmptyInbox(adapter);
}

private void handleEmptyInbox(IterableInboxAdapter adapter) {
if (adapter.getItemCount() == 0) {
noMessagesTitleTextView.setVisibility(View.VISIBLE);
noMessagesBodyTextView.setVisibility(View.VISIBLE);
recyclerView.setVisibility(View.INVISIBLE);
} else {
noMessagesTitleTextView.setVisibility(View.INVISIBLE);
noMessagesBodyTextView.setVisibility(View.INVISIBLE);
recyclerView.setVisibility(View.VISIBLE);
}
}

@Override
Expand Down
37 changes: 30 additions & 7 deletions iterableapi-ui/src/main/res/layout/iterable_inbox_fragment.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"

<RelativeLayout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/list"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/inboxFragmentLayout"
android:name="com.iterable.iterableapi.ui.InboxFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="LinearLayoutManager"
tools:context=".inbox.IterableInboxFragment"
tools:listitem="@layout/iterable_inbox_item" />
android:layout_width="match_parent"
tools:context=".inbox.IterableInboxFragment">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="LinearLayoutManager"
tools:listitem="@layout/iterable_inbox_item" />

<TextView
android:id="@+id/emptyInboxTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:textSize="18sp"
android:textStyle="bold" />

<TextView
android:layout_below="@id/emptyInboxTitle"
android:id="@+id/emptyInboxMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" />
</RelativeLayout>
8 changes: 2 additions & 6 deletions iterableapi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {
minSdkVersion 15
targetSdkVersion 27

buildConfigField "String", "ITERABLE_SDK_VERSION", "\"3.2.11\""
buildConfigField "String", "ITERABLE_SDK_VERSION", "\"3.2.12\""

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -47,10 +47,6 @@ dependencies {
testImplementation 'org.robolectric:robolectric:4.4'
testImplementation 'org.robolectric:shadows-playservices:4.4'
testImplementation 'org.khronos:opengl-api:gl1.1-android-2.1_r1'
testImplementation "org.powermock:powermock-module-junit4:2.0.9"
testImplementation "org.powermock:powermock-module-junit4-rule:2.0.9"
testImplementation "org.powermock:powermock-api-mockito2:2.0.9"
testImplementation "org.powermock:powermock-classloading-xstream:2.0.9"
testImplementation 'com.squareup.okhttp3:mockwebserver:4.2.2'
testImplementation 'org.skyscreamer:jsonassert:1.5.0'
androidTestImplementation 'androidx.test:runner:1.3.0'
Expand All @@ -76,7 +72,7 @@ ext {
siteUrl = 'https://github.com/Iterable/iterable-android-sdk'
gitUrl = 'https://github.com/Iterable/iterable-android-sdk.git'

libraryVersion = '3.2.11'
libraryVersion = '3.2.12'

developerId = 'davidtruong'
developerName = 'David Truong'
Expand Down
Loading