diff --git a/app/build.gradle b/app/build.gradle index cd5ec12..626210a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -35,8 +35,8 @@ android { applicationId "in.ureport" minSdkVersion 10 targetSdkVersion 23 - versionCode 39 - versionName "2.5.0" + versionCode 40 + versionName "2.5.1" multiDexEnabled true } buildTypes { diff --git a/app/src/main/java/in/ureport/activities/ChatRoomActivity.java b/app/src/main/java/in/ureport/activities/ChatRoomActivity.java index df00766..51a411c 100644 --- a/app/src/main/java/in/ureport/activities/ChatRoomActivity.java +++ b/app/src/main/java/in/ureport/activities/ChatRoomActivity.java @@ -1,5 +1,6 @@ package in.ureport.activities; +import android.content.Context; import android.content.Intent; import android.os.Build; import android.os.Bundle; @@ -37,6 +38,13 @@ public class ChatRoomActivity extends AppCompatActivity implements ChatRoomFragm private ChatRoomFragment chatRoomFragment; + public static Intent createIntent(Context context, String chatKey) { + Intent openChatIntent = new Intent(context, ChatRoomActivity.class); + openChatIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + openChatIntent.putExtra(ChatRoomActivity.EXTRA_CHAT_ROOM_KEY, chatKey); + return openChatIntent; + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/app/src/main/java/in/ureport/activities/MainActivity.java b/app/src/main/java/in/ureport/activities/MainActivity.java index 2bc3936..a1d61a0 100644 --- a/app/src/main/java/in/ureport/activities/MainActivity.java +++ b/app/src/main/java/in/ureport/activities/MainActivity.java @@ -5,6 +5,7 @@ import android.support.annotation.NonNull; import android.support.v4.view.MenuItemCompat; import android.support.v4.view.ViewPager; +import android.text.TextUtils; import android.util.Log; import android.view.Menu; import android.view.MenuItem; @@ -13,6 +14,8 @@ import com.firebase.client.DataSnapshot; +import org.json.JSONObject; + import java.util.ArrayList; import java.util.List; @@ -256,13 +259,24 @@ private void handleTypeNotification() { case Rapidpro: pager.setCurrentItem(POSITION_POLLS_FRAGMENT); break; case Chat: - pager.setCurrentItem(POSITION_CHAT_FRAGMENT); + JSONObject chatJson = new JSONObject(getIntent().getExtras().getString("chatRoom")); + if (chatJson.has("key")) { + startChatActivity(chatJson.getString("key")); + } else { + pager.setCurrentItem(POSITION_CHAT_FRAGMENT); + } } } catch(Exception exception) { Log.e(TAG, "checkIntentNotifications: ", exception); } } + private void startChatActivity(String chatKey) { + CountryProgramManager.switchToUserCountryProgram(); + Intent chatIntent = ChatRoomActivity.createIntent(this, chatKey); + startActivity(chatIntent); + } + @Override public void setUser(final User user) { super.setUser(user); diff --git a/app/src/main/java/in/ureport/managers/NotificationListManager.java b/app/src/main/java/in/ureport/managers/NotificationListManager.java index e9ba415..233c7b5 100644 --- a/app/src/main/java/in/ureport/managers/NotificationListManager.java +++ b/app/src/main/java/in/ureport/managers/NotificationListManager.java @@ -185,10 +185,9 @@ public OnChatNotificationSelectedListener(ChatNotification chatNotification) { public void onNotificationSelected(Notification notification) { CountryProgramManager.switchToUserCountryProgram(); - Intent openChatIntent = new Intent(context.getApplicationContext(), ChatRoomActivity.class); - openChatIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - openChatIntent.putExtra(ChatRoomActivity.EXTRA_CHAT_ROOM_KEY, chatNotification.getChatRoomId()); - context.getApplicationContext().startActivity(openChatIntent); + Intent chatIntent = ChatRoomActivity.createIntent(context.getApplicationContext() + , chatNotification.getChatRoomId()); + context.getApplicationContext().startActivity(chatIntent); } } } diff --git a/flow-runner b/flow-runner index 39a3113..8322b18 160000 --- a/flow-runner +++ b/flow-runner @@ -1 +1 @@ -Subproject commit 39a3113c4c790429d1c48bf90fd92d220520ecf5 +Subproject commit 8322b18a7fc96402e703471b54332aa25300eb52