Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Kontalk devteam committed Dec 9, 2016
2 parents 454dc04 + 75db026 commit 890ef73
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which)
.show();
}

private void addUsers() {
void addUsers() {
chooseContact();
}

Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/org/kontalk/ui/GroupInfoActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.Menu;
import android.view.MenuItem;

import org.kontalk.R;
Expand All @@ -35,6 +36,9 @@
*/
public class GroupInfoActivity extends ToolbarActivity implements GroupInfoFragment.GroupInfoParent {

static final int RESULT_PRIVATE_CHAT = RESULT_FIRST_USER;
static final int RESULT_ADD_USERS = RESULT_FIRST_USER + 1;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -66,9 +70,18 @@ protected void onResume() {
MessageCenterService.hold(this, true);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.group_info_menu, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_invite:
setResult(GroupInfoActivity.RESULT_ADD_USERS, null);
// go on with the finish
case android.R.id.home:
finish();
return true;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/kontalk/ui/GroupInfoFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ void openChat(String jid) {
Intent i = new Intent();
i.setData(MyMessages.Threads.getUri(jid));
Activity parent = getActivity();
parent.setResult(Activity.RESULT_OK, i);
parent.setResult(GroupInfoActivity.RESULT_PRIVATE_CHAT, i);
parent.finish();
}

Expand Down
20 changes: 13 additions & 7 deletions app/src/main/java/org/kontalk/ui/GroupMessageFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
public class GroupMessageFragment extends AbstractComposeFragment {
private static final String TAG = ComposeMessage.TAG;

private static final int REQUEST_PRIVATE_CHAT = REQUEST_FIRST_CHILD + 1;
private static final int REQUEST_GROUP_INFO = REQUEST_FIRST_CHILD + 1;

/** The virtual or real group JID. */
private String mGroupJID;
Expand Down Expand Up @@ -456,20 +456,26 @@ public void viewGroupInfo() {
int membership = mConversation != null ? mConversation.getGroupMembership() : Groups.MEMBERSHIP_PARTED;
if (membership == Groups.MEMBERSHIP_MEMBER || membership == Groups.MEMBERSHIP_OBSERVER) {
if (Kontalk.hasTwoPanesUI(getContext())) {
GroupInfoDialog.start(getContext(), this, getThreadId(), REQUEST_PRIVATE_CHAT);
GroupInfoDialog.start(getContext(), this, getThreadId(), REQUEST_GROUP_INFO);
}
else {
GroupInfoActivity.start(getContext(), this, getThreadId(), REQUEST_PRIVATE_CHAT);
GroupInfoActivity.start(getContext(), this, getThreadId(), REQUEST_GROUP_INFO);
}
}
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_PRIVATE_CHAT) {
if (resultCode == Activity.RESULT_OK) {
((ComposeMessageParent) getActivity())
.loadConversation(data.getData());
if (requestCode == REQUEST_GROUP_INFO) {
switch (resultCode) {
case GroupInfoActivity.RESULT_PRIVATE_CHAT:
((ComposeMessageParent) getActivity())
.loadConversation(data.getData());
break;

case GroupInfoActivity.RESULT_ADD_USERS:
addUsers();
break;
}
}
else {
Expand Down
25 changes: 25 additions & 0 deletions app/src/main/res/menu/group_info_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Kontalk Android client
Copyright (C) 2016 Kontalk Devteam <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<!-- actions -->
<item android:icon="@drawable/ic_menu_invite" android:title="@string/menu_invite_group" android:id="@+id/menu_invite" app:showAsAction="always"/>

</menu>

0 comments on commit 890ef73

Please sign in to comment.