Commit 09147980 authored by Grigory Fedorov's avatar Grigory Fedorov

ConferenceAdd activity and fragment: "up" button intercepted, options menu iplemented in activity.

parent 43132231
...@@ -18,6 +18,8 @@ import android.content.Context; ...@@ -18,6 +18,8 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import com.xabber.android.R; import com.xabber.android.R;
import com.xabber.android.data.intent.AccountIntentBuilder; import com.xabber.android.data.intent.AccountIntentBuilder;
...@@ -25,7 +27,7 @@ import com.xabber.android.data.intent.EntityIntentBuilder; ...@@ -25,7 +27,7 @@ import com.xabber.android.data.intent.EntityIntentBuilder;
import com.xabber.android.ui.helper.BarPainter; import com.xabber.android.ui.helper.BarPainter;
import com.xabber.android.ui.helper.ManagedActivity; import com.xabber.android.ui.helper.ManagedActivity;
public class ConferenceAdd extends ManagedActivity { public class ConferenceAdd extends ManagedActivity implements Toolbar.OnMenuItemClickListener {
private static final String SAVED_ACCOUNT = "com.xabber.android.ui.MUCEditor.SAVED_ACCOUNT"; private static final String SAVED_ACCOUNT = "com.xabber.android.ui.MUCEditor.SAVED_ACCOUNT";
private static final String SAVED_ROOM = "com.xabber.android.ui.MUCEditor.SAVED_ROOM"; private static final String SAVED_ROOM = "com.xabber.android.ui.MUCEditor.SAVED_ROOM";
...@@ -56,9 +58,14 @@ public class ConferenceAdd extends ManagedActivity { ...@@ -56,9 +58,14 @@ public class ConferenceAdd extends ManagedActivity {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_default); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_default);
toolbar.setNavigationIcon(R.drawable.ic_clear_white_24dp); toolbar.setNavigationIcon(R.drawable.ic_clear_white_24dp);
setTitle(null); toolbar.inflateMenu(R.menu.add_conference);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
setSupportActionBar(toolbar); @Override
public void onClick(View v) {
finish();
}
});
toolbar.setOnMenuItemClickListener(this);
BarPainter barPainter = new BarPainter(this, toolbar); BarPainter barPainter = new BarPainter(this, toolbar);
barPainter.setDefaultColor(); barPainter.setDefaultColor();
...@@ -89,4 +96,16 @@ public class ConferenceAdd extends ManagedActivity { ...@@ -89,4 +96,16 @@ public class ConferenceAdd extends ManagedActivity {
outState.putString(SAVED_ACCOUNT, account); outState.putString(SAVED_ACCOUNT, account);
outState.putString(SAVED_ROOM, room); outState.putString(SAVED_ROOM, room);
} }
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_add_conference:
((ConferenceAddFragment)getFragmentManager().findFragmentById(R.id.fragment_container)).addConference();
return true;
default:
return false;
}
}
} }
...@@ -104,7 +104,7 @@ public class ConferenceAddFragment extends Fragment { ...@@ -104,7 +104,7 @@ public class ConferenceAddFragment extends Fragment {
} }
} }
private void addConference() { public void addConference() {
String nick = nickView.getText().toString(); String nick = nickView.getText().toString();
if ("".equals(nick)) { if ("".equals(nick)) {
Toast.makeText(getActivity(), getString(R.string.EMPTY_NICK_NAME), Toast.LENGTH_LONG).show(); Toast.makeText(getActivity(), getString(R.string.EMPTY_NICK_NAME), Toast.LENGTH_LONG).show();
...@@ -115,22 +115,4 @@ public class ConferenceAddFragment extends Fragment { ...@@ -115,22 +115,4 @@ public class ConferenceAddFragment extends Fragment {
MUCManager.getInstance().createRoom(account, conferenceJid, nick, password, join); MUCManager.getInstance().createRoom(account, conferenceJid, nick, password, join);
getActivity().finish(); getActivity().finish();
} }
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.add_conference, menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_add_conference:
addConference();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment