| skipped 14 lines |
15 | 15 | | import tigase.jaxmpp.core.client.xmpp.modules.chat.MessageModule.MessageEvent; |
16 | 16 | | import tigase.jaxmpp.j2se.connectors.socket.SocketConnector; |
17 | 17 | | import android.app.Activity; |
| 18 | + | import android.app.Dialog; |
18 | 19 | | import android.content.BroadcastReceiver; |
19 | 20 | | import android.content.Context; |
20 | 21 | | import android.content.Intent; |
| skipped 13 lines |
34 | 35 | | import android.view.MenuInflater; |
35 | 36 | | import android.view.MenuItem; |
36 | 37 | | import android.view.View; |
| 38 | + | import android.view.View.OnClickListener; |
| 39 | + | import android.widget.Button; |
37 | 40 | | |
38 | 41 | | public class TigaseMobileMessengerActivity extends FragmentActivity { |
39 | 42 | | |
| skipped 115 lines |
155 | 158 | | } |
156 | 159 | | } |
157 | 160 | | |
| 161 | + | private final static int ABOUT_DIALOG = 1; |
| 162 | + | |
158 | 163 | | public static final String CLIENT_FOCUS_MSG = "org.tigase.mobile.CLIENT_FOCUS_MSG"; |
159 | 164 | | |
160 | 165 | | private static final boolean DEBUG = false; |
161 | 166 | | |
162 | 167 | | public static final int REQUEST_CHAT = 1; |
163 | 168 | | |
164 | | - | public static final String ROSTER_CLICK_MSG = "org.tigase.mobile.ROSTER_CLICK_MSG"; |
165 | | - | |
166 | 169 | | // private ListView rosterList; |
| 170 | + | |
| 171 | + | public static final String ROSTER_CLICK_MSG = "org.tigase.mobile.ROSTER_CLICK_MSG"; |
167 | 172 | | |
168 | 173 | | private static final String TAG = "tigase"; |
169 | 174 | | |
| skipped 178 lines |
348 | 353 | | } |
349 | 354 | | |
350 | 355 | | @Override |
| 356 | + | protected Dialog onCreateDialog(int id) { |
| 357 | + | switch (id) { |
| 358 | + | case ABOUT_DIALOG: { |
| 359 | + | |
| 360 | + | final Dialog dialog = new Dialog(this); |
| 361 | + | dialog.setCancelable(true); |
| 362 | + | dialog.setCanceledOnTouchOutside(true); |
| 363 | + | |
| 364 | + | dialog.setContentView(R.layout.about_dialog); |
| 365 | + | dialog.setTitle(getString(R.string.aboutButton)); |
| 366 | + | |
| 367 | + | Button okButton = (Button) dialog.findViewById(R.id.okButton); |
| 368 | + | okButton.setOnClickListener(new OnClickListener() { |
| 369 | + | |
| 370 | + | @Override |
| 371 | + | public void onClick(View v) { |
| 372 | + | dialog.cancel(); |
| 373 | + | } |
| 374 | + | }); |
| 375 | + | return dialog; |
| 376 | + | } |
| 377 | + | default: |
| 378 | + | return null; |
| 379 | + | } |
| 380 | + | } |
| 381 | + | |
| 382 | + | @Override |
351 | 383 | | public boolean onCreateOptionsMenu(Menu menu) { |
352 | 384 | | MenuInflater inflater = getMenuInflater(); |
353 | 385 | | inflater.inflate(R.menu.main_menu, menu); |
| skipped 27 lines |
381 | 413 | | MenuItem closeChat = menu.findItem(R.id.closeChatButton); |
382 | 414 | | closeChat.setVisible(currentPage != 0); |
383 | 415 | | |
| 416 | + | MenuItem about = menu.findItem(R.id.aboutButton); |
| 417 | + | about.setVisible(currentPage == 0); |
| 418 | + | |
384 | 419 | | return super.onMenuOpened(featureId, menu); |
385 | 420 | | } |
386 | 421 | | |
| skipped 13 lines |
400 | 435 | | viewPager.post(action); |
401 | 436 | | } |
402 | 437 | | |
| 438 | + | // @Override |
| 439 | + | // protected void onActivityResult(int requestCode, int resultCode, Intent |
| 440 | + | // data) { |
| 441 | + | // super.onActivityResult(requestCode, resultCode, data); |
| 442 | + | // |
| 443 | + | // if(DEBUG)Log.i(TAG, "Sprawdzamy extrasy..."); |
| 444 | + | // if (getIntent() != null && getIntent().getExtras() != null) { |
| 445 | + | // if(DEBUG)Log.i(TAG, "Mamy extrasy"); |
| 446 | + | // if (getIntent().getExtras().containsKey("chatId")) { |
| 447 | + | // long chatId = getIntent().getLongExtra("chatId", -1); |
| 448 | + | // getIntent().removeExtra("chatId"); |
| 449 | + | // |
| 450 | + | // List<Chat> l = getChatList(); |
| 451 | + | // for (int i = 0; i < l.size(); i++) { |
| 452 | + | // Chat chh = l.get(i); |
| 453 | + | // if (chh.getId() == chatId) { |
| 454 | + | // final int x = i + 1; |
| 455 | + | // viewSwitcher.post(new Runnable() { |
| 456 | + | // |
| 457 | + | // @Override |
| 458 | + | // public void run() { |
| 459 | + | // if(DEBUG)Log.i(TAG, "Switch chats to " + x); |
| 460 | + | // |
| 461 | + | // viewSwitcher.setCurrentItem(x); |
| 462 | + | // } |
| 463 | + | // }); |
| 464 | + | // |
| 465 | + | // } |
| 466 | + | // } |
| 467 | + | // } |
| 468 | + | // |
| 469 | + | // } |
| 470 | + | // } |
| 471 | + | |
403 | 472 | | @Override |
404 | 473 | | protected void onNewIntent(Intent intent) { |
405 | 474 | | super.onNewIntent(intent); |
| skipped 5 lines |
411 | 480 | | @Override |
412 | 481 | | public boolean onOptionsItemSelected(MenuItem item) { |
413 | 482 | | switch (item.getItemId()) { |
| 483 | + | case R.id.aboutButton: |
| 484 | + | showDialog(ABOUT_DIALOG); |
| 485 | + | break; |
414 | 486 | | case R.id.showChatsButton: |
415 | 487 | | Intent chatListActivity = new Intent(this, ChatListActivity.class); |
416 | 488 | | this.startActivityForResult(chatListActivity, REQUEST_CHAT); |
| skipped 43 lines |
460 | 532 | | } |
461 | 533 | | return true; |
462 | 534 | | } |
463 | | - | |
464 | | - | // @Override |
465 | | - | // protected void onActivityResult(int requestCode, int resultCode, Intent |
466 | | - | // data) { |
467 | | - | // super.onActivityResult(requestCode, resultCode, data); |
468 | | - | // |
469 | | - | // if(DEBUG)Log.i(TAG, "Sprawdzamy extrasy..."); |
470 | | - | // if (getIntent() != null && getIntent().getExtras() != null) { |
471 | | - | // if(DEBUG)Log.i(TAG, "Mamy extrasy"); |
472 | | - | // if (getIntent().getExtras().containsKey("chatId")) { |
473 | | - | // long chatId = getIntent().getLongExtra("chatId", -1); |
474 | | - | // getIntent().removeExtra("chatId"); |
475 | | - | // |
476 | | - | // List<Chat> l = getChatList(); |
477 | | - | // for (int i = 0; i < l.size(); i++) { |
478 | | - | // Chat chh = l.get(i); |
479 | | - | // if (chh.getId() == chatId) { |
480 | | - | // final int x = i + 1; |
481 | | - | // viewSwitcher.post(new Runnable() { |
482 | | - | // |
483 | | - | // @Override |
484 | | - | // public void run() { |
485 | | - | // if(DEBUG)Log.i(TAG, "Switch chats to " + x); |
486 | | - | // |
487 | | - | // viewSwitcher.setCurrentItem(x); |
488 | | - | // } |
489 | | - | // }); |
490 | | - | // |
491 | | - | // } |
492 | | - | // } |
493 | | - | // } |
494 | | - | // |
495 | | - | // } |
496 | | - | // } |
497 | 535 | | |
498 | 536 | | @Override |
499 | 537 | | protected void onPause() { |
| skipped 93 lines |