Open chat after adding a new contact.

This commit is contained in:
Felix Ableitner 2015-07-28 01:16:20 +02:00
parent ee621a7d78
commit 38db151d8c
2 changed files with 11 additions and 3 deletions

View file

@ -66,9 +66,11 @@ class MainActivity extends EnsichatActivity {
.add(android.R.id.content, contactsFragment)
.commit()
}
}
if (getIntent.getAction == MainActivity.ActionOpenChat)
openChat(new Address(getIntent.getStringExtra(MainActivity.ExtraAddress)))
override def onNewIntent(intent: Intent): Unit = {
if (intent.getAction == MainActivity.ActionOpenChat)
openChat(new Address(intent.getStringExtra(MainActivity.ExtraAddress)))
}
/**

View file

@ -7,7 +7,7 @@ import android.support.v4.app.NotificationCompat
import android.util.Log
import android.widget.Toast
import com.nutomic.ensichat.R
import com.nutomic.ensichat.activities.ConfirmAddContactActivity
import com.nutomic.ensichat.activities.{MainActivity, ConfirmAddContactActivity}
import com.nutomic.ensichat.protocol.body.{RequestAddContact, ResultAddContact}
import com.nutomic.ensichat.protocol.{Address, Message, User}
@ -93,6 +93,12 @@ class AddContactsHandler(context: Context, getUser: (Address) => User, localAddr
Log.i(Tag, "Adding new contact " + user.toString)
database.addContact(user)
showToast(context.getString(R.string.contact_added, user.name), Toast.LENGTH_SHORT)
val intent = new Intent(context, classOf[MainActivity])
intent.setAction(MainActivity.ActionOpenChat)
intent.putExtra(MainActivity.ExtraAddress, address.toString)
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP)
context.startActivity(intent)
currentlyAdding -= address
}
}