Skip to content

Commit

Permalink
Merge pull request #19 from rapidpro/hotfix/2.5.1
Browse files Browse the repository at this point in the history
Updates and bug fixes
  • Loading branch information
johncordeiro authored Dec 5, 2016
2 parents e365c2e + 8fb2112 commit 072fe03
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/in/ureport/activities/ChatRoomActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package in.ureport.activities;

import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
Expand Down Expand Up @@ -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);
Expand Down
16 changes: 15 additions & 1 deletion app/src/main/java/in/ureport/activities/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -13,6 +14,8 @@

import com.firebase.client.DataSnapshot;

import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
2 changes: 1 addition & 1 deletion flow-runner

0 comments on commit 072fe03

Please sign in to comment.