Skip to content

Commit d538da4

Browse files
authored
Merge pull request #334 from Iterable/MOB-2770-Release-SDK-3.2.12
MOB 2770 release sdk 3.2.12
2 parents 47398cc + 067ea58 commit d538da4

23 files changed

+330
-155
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,7 @@ google-services.json
5454
# Freeline
5555
freeline.py
5656
freeline/
57-
freeline_project_description.json
57+
freeline_project_description.json
58+
59+
# MacOS generated files
60+
.DS_Store

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1515
#### Fixed
1616
- nothing yet
1717

18+
## [3.2.12](https://github.com/Iterable/iterable-android-sdk/releases/tag/3.2.12)
19+
#### Added
20+
- Support for the display of a custom message (title and body) in an empty mobile inbox.
21+
For more details, see [Customizing Mobile Inbox on Android](https://iterable.zendesk.com/hc/articles/360039189931#empty-state)
22+
- Support for syncing in-app message read state across multiple devices:
23+
- When the SDK fetches in-app messages from Iterable, it examines each message's `read` field to determine if it has already been read.
24+
- 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).
25+
1826
## [3.2.11](https://github.com/Iterable/iterable-android-sdk/releases/tag/3.2.11)
1927
#### Changed
2028
- Changed the timeout for GET calls (`/inApp/getMessages` in particular) from 3 to 10 seconds.

app/src/androidTest/java/com/iterable/iterableapi/MainActivityTest.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,18 @@ public void testSwipeToDeleteInApp() throws Exception {
233233
onView(withText("Tips and tricks 2")).check(doesNotExist());
234234
}
235235

236+
@Test
237+
public void testNoMessagesTitleAndText() throws Exception {
238+
Intent intent = new Intent();
239+
String noMessageTitle = "OOPSY";
240+
String noMessageBody = "No messages for you";
241+
intent.putExtra(IterableConstants.NO_MESSAGES_TITLE, noMessageTitle);
242+
intent.putExtra(IterableConstants.NO_MESSAGES_BODY, noMessageBody);
243+
rule.launchActivity(intent);
244+
onView(withText(noMessageTitle)).check(matches(isDisplayed()));
245+
onView(withText(noMessageBody)).check(matches(isDisplayed()));
246+
}
247+
236248

237249
static class Matchers{
238250
public static Matcher<View> withListSize (final int size) {
@@ -283,4 +295,4 @@ static void waitFor(int ms) {
283295
Assert.fail(e.getMessage());
284296
}
285297
}
286-
}
298+
}

app/src/androidTest/java/com/iterable/iterableapi/testapp/InboxUITest.java

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ protected void beforeActivityLaunched() {
3030

3131
@Test
3232
public void basicTest() {
33-
onView(withId(R.id.list)).perform(click());
3433
assertNotNull(rule.getActivity());
3534
}
3635
}

app/src/test/java/com/iterable/iterableapi/InboxUITest.java

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ protected void beforeActivityLaunched() {
2929

3030
@Test
3131
public void basicTest() {
32-
onView(withId(R.id.list)).perform(click());
3332
assertNotNull(rule.getActivity());
3433
}
3534
}

iterableapi-ui/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ ext {
5252
siteUrl = 'https://github.com/Iterable/iterable-android-sdk'
5353
gitUrl = 'https://github.com/Iterable/iterable-android-sdk.git'
5454

55-
libraryVersion = '3.2.11'
55+
libraryVersion = '3.2.12'
5656

5757
developerId = 'davidtruong'
5858
developerName = 'David Truong'

iterableapi-ui/src/main/java/com/iterable/iterableapi/ui/inbox/IterableInboxActivity.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import androidx.annotation.Nullable;
66
import androidx.appcompat.app.AppCompatActivity;
77

8+
import com.iterable.iterableapi.IterableConstants;
89
import com.iterable.iterableapi.IterableLogger;
910
import com.iterable.iterableapi.ui.R;
1011

@@ -37,7 +38,14 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
3738
if (inboxModeExtra instanceof InboxMode) {
3839
inboxMode = (InboxMode) inboxModeExtra;
3940
}
40-
inboxFragment = IterableInboxFragment.newInstance(inboxMode, itemLayoutId);
41+
String noMessageTitle = null;
42+
String noMessageBody = null;
43+
Bundle extraBundle = getIntent().getExtras();
44+
if (extraBundle != null) {
45+
noMessageTitle = extraBundle.getString(IterableConstants.NO_MESSAGES_TITLE, null);
46+
noMessageBody = extraBundle.getString(IterableConstants.NO_MESSAGES_BODY, null);
47+
}
48+
inboxFragment = IterableInboxFragment.newInstance(inboxMode, itemLayoutId, noMessageTitle, noMessageBody);
4149

4250
if (intent.getStringExtra(ACTIVITY_TITLE) != null) {
4351
setTitle(intent.getStringExtra(ACTIVITY_TITLE));

iterableapi-ui/src/main/java/com/iterable/iterableapi/ui/inbox/IterableInboxFragment.java

+43-6
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@
1212
import android.view.LayoutInflater;
1313
import android.view.View;
1414
import android.view.ViewGroup;
15+
import android.widget.RelativeLayout;
16+
import android.widget.TextView;
1517

1618
import com.iterable.iterableapi.IterableActivityMonitor;
1719
import com.iterable.iterableapi.IterableApi;
20+
import com.iterable.iterableapi.IterableConstants;
1821
import com.iterable.iterableapi.IterableInAppDeleteActionType;
1922
import com.iterable.iterableapi.IterableInAppLocation;
2023
import com.iterable.iterableapi.IterableInAppManager;
@@ -45,6 +48,11 @@ public class IterableInboxFragment extends Fragment implements IterableInAppMana
4548

4649
private InboxMode inboxMode = InboxMode.POPUP;
4750
private @LayoutRes int itemLayoutId = R.layout.iterable_inbox_item;
51+
private String noMessagesTitle;
52+
private String noMessagesBody;
53+
TextView noMessagesTitleTextView;
54+
TextView noMessagesBodyTextView;
55+
RecyclerView recyclerView;
4856

4957
private final SessionManager sessionManager = new SessionManager();
5058
private IterableInboxAdapterExtension adapterExtension = new DefaultAdapterExtension();
@@ -72,10 +80,16 @@ public class IterableInboxFragment extends Fragment implements IterableInAppMana
7280
* @return {@link IterableInboxFragment} instance
7381
*/
7482
@NonNull public static IterableInboxFragment newInstance(@NonNull InboxMode inboxMode, @LayoutRes int itemLayoutId) {
83+
return newInstance(inboxMode, itemLayoutId, null, null);
84+
}
85+
86+
@NonNull public static IterableInboxFragment newInstance(@NonNull InboxMode inboxMode, @LayoutRes int itemLayoutId, @Nullable String noMessagesTitle, @Nullable String noMessagesBody) {
7587
IterableInboxFragment inboxFragment = new IterableInboxFragment();
7688
Bundle bundle = new Bundle();
7789
bundle.putSerializable(INBOX_MODE, inboxMode);
7890
bundle.putInt(ITEM_LAYOUT_ID, itemLayoutId);
91+
bundle.putString(IterableConstants.NO_MESSAGES_TITLE, noMessagesTitle);
92+
bundle.putString(IterableConstants.NO_MESSAGES_BODY, noMessagesBody);
7993
inboxFragment.setArguments(bundle);
8094

8195
return inboxFragment;
@@ -153,15 +167,26 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
153167
if (arguments.getInt(ITEM_LAYOUT_ID, 0) != 0) {
154168
itemLayoutId = arguments.getInt(ITEM_LAYOUT_ID);
155169
}
170+
if (arguments.getString(IterableConstants.NO_MESSAGES_TITLE) != null) {
171+
noMessagesTitle = arguments.getString(IterableConstants.NO_MESSAGES_TITLE);
172+
}
173+
if (arguments.getString(IterableConstants.NO_MESSAGES_BODY) != null) {
174+
noMessagesBody = arguments.getString(IterableConstants.NO_MESSAGES_BODY);
175+
}
156176
}
157177

158-
RecyclerView view = (RecyclerView) inflater.inflate(R.layout.iterable_inbox_fragment, container, false);
159-
view.setLayoutManager(new LinearLayoutManager(getContext()));
178+
RelativeLayout relativeLayout = (RelativeLayout) inflater.inflate(R.layout.iterable_inbox_fragment, container, false);
179+
recyclerView = relativeLayout.findViewById(R.id.list);
180+
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
160181
IterableInboxAdapter adapter = new IterableInboxAdapter(IterableApi.getInstance().getInAppManager().getInboxMessages(), IterableInboxFragment.this, adapterExtension, comparator, filter, dateMapper);
161-
view.setAdapter(adapter);
182+
recyclerView.setAdapter(adapter);
183+
noMessagesTitleTextView = relativeLayout.findViewById(R.id.emptyInboxTitle);
184+
noMessagesBodyTextView = relativeLayout.findViewById(R.id.emptyInboxMessage);
185+
noMessagesTitleTextView.setText(noMessagesTitle);
186+
noMessagesBodyTextView.setText(noMessagesBody);
162187
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new IterableInboxTouchHelper(getContext(), adapter));
163-
itemTouchHelper.attachToRecyclerView(view);
164-
return view;
188+
itemTouchHelper.attachToRecyclerView(recyclerView);
189+
return relativeLayout;
165190
}
166191

167192
@Override
@@ -213,9 +238,21 @@ private void stopSession() {
213238
}
214239

215240
private void updateList() {
216-
RecyclerView recyclerView = (RecyclerView) getView();
217241
IterableInboxAdapter adapter = (IterableInboxAdapter) recyclerView.getAdapter();
218242
adapter.setInboxItems(IterableApi.getInstance().getInAppManager().getInboxMessages());
243+
handleEmptyInbox(adapter);
244+
}
245+
246+
private void handleEmptyInbox(IterableInboxAdapter adapter) {
247+
if (adapter.getItemCount() == 0) {
248+
noMessagesTitleTextView.setVisibility(View.VISIBLE);
249+
noMessagesBodyTextView.setVisibility(View.VISIBLE);
250+
recyclerView.setVisibility(View.INVISIBLE);
251+
} else {
252+
noMessagesTitleTextView.setVisibility(View.INVISIBLE);
253+
noMessagesBodyTextView.setVisibility(View.INVISIBLE);
254+
recyclerView.setVisibility(View.VISIBLE);
255+
}
219256
}
220257

221258
@Override
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,34 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:app="http://schemas.android.com/apk/res-auto"
2+
3+
<RelativeLayout xmlns:app="http://schemas.android.com/apk/res-auto"
44
xmlns:tools="http://schemas.android.com/tools"
5-
android:id="@+id/list"
5+
xmlns:android="http://schemas.android.com/apk/res/android"
6+
android:id="@+id/inboxFragmentLayout"
67
android:name="com.iterable.iterableapi.ui.InboxFragment"
7-
android:layout_width="match_parent"
88
android:layout_height="match_parent"
9-
app:layoutManager="LinearLayoutManager"
10-
tools:context=".inbox.IterableInboxFragment"
11-
tools:listitem="@layout/iterable_inbox_item" />
9+
android:layout_width="match_parent"
10+
tools:context=".inbox.IterableInboxFragment">
11+
12+
<androidx.recyclerview.widget.RecyclerView
13+
android:id="@+id/list"
14+
android:layout_width="match_parent"
15+
android:layout_height="match_parent"
16+
app:layoutManager="LinearLayoutManager"
17+
tools:listitem="@layout/iterable_inbox_item" />
18+
19+
<TextView
20+
android:id="@+id/emptyInboxTitle"
21+
android:layout_width="match_parent"
22+
android:layout_height="wrap_content"
23+
android:layout_centerInParent="true"
24+
android:gravity="center"
25+
android:textSize="18sp"
26+
android:textStyle="bold" />
27+
28+
<TextView
29+
android:layout_below="@id/emptyInboxTitle"
30+
android:id="@+id/emptyInboxMessage"
31+
android:layout_width="match_parent"
32+
android:layout_height="wrap_content"
33+
android:gravity="center" />
34+
</RelativeLayout>

iterableapi/build.gradle

+2-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ android {
1010
minSdkVersion 15
1111
targetSdkVersion 27
1212

13-
buildConfigField "String", "ITERABLE_SDK_VERSION", "\"3.2.11\""
13+
buildConfigField "String", "ITERABLE_SDK_VERSION", "\"3.2.12\""
1414

1515
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1616
}
@@ -47,10 +47,6 @@ dependencies {
4747
testImplementation 'org.robolectric:robolectric:4.4'
4848
testImplementation 'org.robolectric:shadows-playservices:4.4'
4949
testImplementation 'org.khronos:opengl-api:gl1.1-android-2.1_r1'
50-
testImplementation "org.powermock:powermock-module-junit4:2.0.9"
51-
testImplementation "org.powermock:powermock-module-junit4-rule:2.0.9"
52-
testImplementation "org.powermock:powermock-api-mockito2:2.0.9"
53-
testImplementation "org.powermock:powermock-classloading-xstream:2.0.9"
5450
testImplementation 'com.squareup.okhttp3:mockwebserver:4.2.2'
5551
testImplementation 'org.skyscreamer:jsonassert:1.5.0'
5652
androidTestImplementation 'androidx.test:runner:1.3.0'
@@ -76,7 +72,7 @@ ext {
7672
siteUrl = 'https://github.com/Iterable/iterable-android-sdk'
7773
gitUrl = 'https://github.com/Iterable/iterable-android-sdk.git'
7874

79-
libraryVersion = '3.2.11'
75+
libraryVersion = '3.2.12'
8076

8177
developerId = 'davidtruong'
8278
developerName = 'David Truong'

0 commit comments

Comments
 (0)