diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-04-23 21:13:12 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-04-23 21:13:12 +0200 |
commit | 80064f6040cab219702d8221a052eace5f47661c (patch) | |
tree | 67c0676deebe0a6f899989eac3a96db5f4f2a167 /src/main/java/de/pixart/messenger/ui | |
parent | 44cf4a0ecbfef6303872316d20e4b18444f6932f (diff) |
support contact shortcuts
* support contact shortcuts
* make ShortcutActivity extends AbstractSearchableListItemActivity
* Draw the app icon in the corner of the icon and modify the name of the widget
* updated label and icon size
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ShortcutActivity.java | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ShortcutActivity.java b/src/main/java/de/pixart/messenger/ui/ShortcutActivity.java new file mode 100644 index 000000000..52f87c5a3 --- /dev/null +++ b/src/main/java/de/pixart/messenger/ui/ShortcutActivity.java @@ -0,0 +1,68 @@ +package de.pixart.messenger.ui; + +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.support.v7.app.ActionBar; +import android.view.View; +import android.view.inputmethod.InputMethodManager; + +import java.util.Collections; + +import de.pixart.messenger.R; +import de.pixart.messenger.entities.Account; +import de.pixart.messenger.entities.Contact; +import de.pixart.messenger.entities.ListItem; + +public class ShortcutActivity extends AbstractSearchableListItemActivity { + + @Override + protected void refreshUiReal() { + + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + getListView().setOnItemClickListener((parent, view, position, id) -> { + final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(getSearchEditText().getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY); + + ListItem listItem = getListItems().get(position); + Intent shortcut = xmppConnectionService.getShortcutService().createShortcut(((Contact) listItem)); + setResult(RESULT_OK, shortcut); + finish(); + }); + binding.fab.setVisibility(View.GONE); + } + + @Override + protected void onStart() { + super.onStart(); + ActionBar bar = getSupportActionBar(); + if (bar != null) { + bar.setTitle(R.string.create_shortcut); + } + } + + @Override + protected void filterContacts(String needle) { + getListItems().clear(); + if (xmppConnectionService == null) { + getListItemAdapter().notifyDataSetChanged(); + return; + } + for (final Account account : xmppConnectionService.getAccounts()) { + if (account.getStatus() != Account.State.DISABLED) { + for (final Contact contact : account.getRoster().getContacts()) { + if (contact.showInRoster() + && contact.match(this, needle)) { + getListItems().add(contact); + } + } + } + } + Collections.sort(getListItems()); + getListItemAdapter().notifyDataSetChanged(); + } +}
\ No newline at end of file |