aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ChooseContactActivity.java172
-rw-r--r--src/main/res/drawable-hdpi/ic_forward_white_24dp.pngbin0 -> 193 bytes
-rw-r--r--src/main/res/drawable-mdpi/ic_forward_white_24dp.pngbin0 -> 125 bytes
-rw-r--r--src/main/res/drawable-xhdpi/ic_forward_white_24dp.pngbin0 -> 184 bytes
-rw-r--r--src/main/res/drawable-xxhdpi/ic_forward_white_24dp.pngbin0 -> 303 bytes
-rw-r--r--src/main/res/drawable-xxxhdpi/ic_forward_white_24dp.pngbin0 -> 306 bytes
-rw-r--r--src/main/res/drawable/list_item_background_dark.xml32
-rw-r--r--src/main/res/drawable/list_item_background_light.xml32
-rw-r--r--src/main/res/layout/contact.xml2
-rw-r--r--src/main/res/menu/select_multiple.xml10
-rw-r--r--src/main/res/values/attrs.xml2
-rw-r--r--src/main/res/values/colors.xml1
-rw-r--r--src/main/res/values/strings.xml5
-rw-r--r--src/main/res/values/themes.xml2
14 files changed, 165 insertions, 93 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ChooseContactActivity.java b/src/main/java/de/pixart/messenger/ui/ChooseContactActivity.java
index e79be5c4a..09a80ec1e 100644
--- a/src/main/java/de/pixart/messenger/ui/ChooseContactActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ChooseContactActivity.java
@@ -11,7 +11,6 @@ import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.ActionBar;
import android.view.ActionMode;
import android.view.Menu;
-import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
@@ -38,12 +37,14 @@ import de.pixart.messenger.ui.util.PendingItem;
import de.pixart.messenger.utils.XmppUri;
import rocks.xmpp.addr.Jid;
-public class ChooseContactActivity extends AbstractSearchableListItemActivity {
+public class ChooseContactActivity extends AbstractSearchableListItemActivity implements MultiChoiceModeListener {
public static final String EXTRA_TITLE_RES_ID = "extra_title_res_id";
private List<String> mActivatedAccounts = new ArrayList<>();
private Set<String> selected = new HashSet<>();
private Set<String> filterContacts;
+ private boolean showEnterJid = false;
+
private PendingItem<ActivityResult> postponedActivityResult = new PendingItem<>();
public static Intent create(Activity activity, Conversation conversation) {
@@ -78,81 +79,26 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity {
selected.addAll(Arrays.asList(selectedContacts));
}
}
+
String[] contacts = getIntent().getStringArrayExtra("filter_contacts");
if (contacts != null) {
Collections.addAll(filterContacts, contacts);
}
- if (getIntent().getBooleanExtra("multiple", false)) {
- getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
- getListView().setMultiChoiceModeListener(new MultiChoiceModeListener() {
-
- @Override
- public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
- return false;
- }
-
- @Override
- public boolean onCreateActionMode(ActionMode mode, Menu menu) {
- binding.fab.setVisibility(View.GONE);
- final View view = getSearchEditText();
- final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- if (view != null && imm != null) {
- imm.hideSoftInputFromWindow(getSearchEditText().getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
- }
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.select_multiple, menu);
- MenuItem selectButton = menu.findItem(R.id.selection_submit);
- String buttonText = getResources().getQuantityString(R.plurals.select_contact, selected.size(), selected.size());
- selectButton.setTitle(buttonText);
- return true;
- }
-
- @Override
- public void onDestroyActionMode(ActionMode mode) {
- binding.fab.setVisibility(View.VISIBLE);
- selected.clear();
- }
-
- @Override
- public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
- switch (item.getItemId()) {
- case R.id.selection_submit:
- final Intent request = getIntent();
- final Intent data = new Intent();
- data.putExtra("conversation",
- request.getStringExtra("conversation"));
- String[] selection = getSelectedContactJids();
- data.putExtra("contacts", selection);
- data.putExtra("multiple", true);
- data.putExtra(EXTRA_ACCOUNT, request.getStringExtra(EXTRA_ACCOUNT));
- data.putExtra("subject", request.getStringExtra("subject"));
- setResult(RESULT_OK, data);
- finish();
- return true;
- }
- return false;
- }
+ Intent intent = getIntent();
- @Override
- public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
- Contact item = (Contact) getListItems().get(position);
- if (checked) {
- selected.add(item.getJid().toString());
- } else {
- selected.remove(item.getJid().toString());
- }
- int numSelected = selected.size();
- MenuItem selectButton = mode.getMenu().findItem(R.id.selection_submit);
- String buttonText = getResources().getQuantityString(R.plurals.select_contact,
- numSelected, numSelected);
- selectButton.setTitle(buttonText);
- }
- });
+ final boolean multiple = intent.getBooleanExtra("multiple", false);
+ if (multiple) {
+ getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
+ getListView().setMultiChoiceModeListener(this);
}
-
getListView().setOnItemClickListener((parent, view, position, id) -> {
+ if (multiple) {
+ startActionMode(this);
+ getListView().setItemChecked(position, true);
+ return;
+ }
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getSearchEditText().getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
final Intent request = getIntent();
@@ -171,30 +117,101 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity {
finish();
});
final Intent i = getIntent();
- boolean showEnterJid = i != null && i.getBooleanExtra("show_enter_jid", false);
- if (showEnterJid) {
- this.binding.fab.setOnClickListener((v) -> showEnterJidDialog(null));
+ this.showEnterJid = i != null && i.getBooleanExtra("show_enter_jid", false);
+ this.binding.fab.setOnClickListener(this::onFabClicked);
+ if (this.showEnterJid) {
+ this.binding.fab.setVisibility(View.VISIBLE);
} else {
this.binding.fab.setVisibility(View.GONE);
}
}
+ private void onFabClicked(View v) {
+ if (selected.size() == 0) {
+ showEnterJidDialog(null);
+ } else {
+ submitSelection();
+ }
+ }
+
+ @Override
+ public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
+ return false;
+ }
+
+ @Override
+ public boolean onCreateActionMode(ActionMode mode, Menu menu) {
+ mode.setTitle(getTitleFromIntent());
+ binding.fab.setImageResource(R.drawable.ic_forward_white_24dp);
+ binding.fab.setVisibility(View.VISIBLE);
+ final View view = getSearchEditText();
+ final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ if (view != null && imm != null) {
+ imm.hideSoftInputFromWindow(getSearchEditText().getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
+ }
+ return true;
+ }
+
+ @Override
+ public void onDestroyActionMode(ActionMode mode) {
+ this.binding.fab.setImageResource(R.drawable.ic_person_add_white_24dp);
+ if (this.showEnterJid) {
+ this.binding.fab.setVisibility(View.VISIBLE);
+ } else {
+ this.binding.fab.setVisibility(View.GONE);
+ }
+ selected.clear();
+ }
+
+ @Override
+ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
+ return false;
+ }
+
+ private void submitSelection() {
+ final Intent request = getIntent();
+ final Intent data = new Intent();
+ data.putExtra("conversation", request.getStringExtra("conversation"));
+ String[] selection = getSelectedContactJids();
+ data.putExtra("contacts", selection);
+ data.putExtra("multiple", true);
+ data.putExtra(EXTRA_ACCOUNT, request.getStringExtra(EXTRA_ACCOUNT));
+ data.putExtra("subject", request.getStringExtra("subject"));
+ setResult(RESULT_OK, data);
+ finish();
+ }
+
+ @Override
+ public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
+ Contact item = (Contact) getListItems().get(position);
+ if (checked) {
+ selected.add(item.getJid().toString());
+ } else {
+ selected.remove(item.getJid().toString());
+ }
+ }
+
@Override
public void onStart() {
super.onStart();
- Intent intent = getIntent();
- @StringRes
- int res = intent != null ? intent.getIntExtra(EXTRA_TITLE_RES_ID, R.string.title_activity_choose_contact) : R.string.title_activity_choose_contact;
ActionBar bar = getSupportActionBar();
if (bar != null) {
try {
- bar.setTitle(res);
+ bar.setTitle(getTitleFromIntent());
} catch (Exception e) {
bar.setTitle(R.string.title_activity_choose_contact);
}
}
}
+ public @StringRes
+ int getTitleFromIntent() {
+ final Intent intent = getIntent();
+ boolean multiple = intent != null && intent.getBooleanExtra("multiple", false);
+ @StringRes int fallback = multiple ? R.string.title_activity_choose_contacts : R.string.title_activity_choose_contact;
+ return intent != null ? intent.getIntExtra(EXTRA_TITLE_RES_ID, fallback) : fallback;
+ }
+
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
super.onCreateOptionsMenu(menu);
@@ -264,7 +281,7 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity {
jid == null ? null : jid.asBareJid().toString(),
getIntent().getStringExtra(EXTRA_ACCOUNT),
true,
- xmppConnectionService.multipleAccounts()
+ true
);
dialog.setOnEnterJidDialogPositiveListener((accountJid, contactJid) -> {
@@ -309,7 +326,6 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity {
@Override
void onBackendConnected() {
filterContacts();
-
this.mActivatedAccounts.clear();
for (Account account : xmppConnectionService.getAccounts()) {
if (account.getStatus() != Account.State.DISABLED) {
@@ -334,4 +350,4 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity {
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
ScanActivity.onRequestPermissionResult(this, requestCode, grantResults);
}
-}
+} \ No newline at end of file
diff --git a/src/main/res/drawable-hdpi/ic_forward_white_24dp.png b/src/main/res/drawable-hdpi/ic_forward_white_24dp.png
new file mode 100644
index 000000000..b40c6b780
--- /dev/null
+++ b/src/main/res/drawable-hdpi/ic_forward_white_24dp.png
Binary files differ
diff --git a/src/main/res/drawable-mdpi/ic_forward_white_24dp.png b/src/main/res/drawable-mdpi/ic_forward_white_24dp.png
new file mode 100644
index 000000000..ec881edda
--- /dev/null
+++ b/src/main/res/drawable-mdpi/ic_forward_white_24dp.png
Binary files differ
diff --git a/src/main/res/drawable-xhdpi/ic_forward_white_24dp.png b/src/main/res/drawable-xhdpi/ic_forward_white_24dp.png
new file mode 100644
index 000000000..551baf53b
--- /dev/null
+++ b/src/main/res/drawable-xhdpi/ic_forward_white_24dp.png
Binary files differ
diff --git a/src/main/res/drawable-xxhdpi/ic_forward_white_24dp.png b/src/main/res/drawable-xxhdpi/ic_forward_white_24dp.png
new file mode 100644
index 000000000..6eadc2bbf
--- /dev/null
+++ b/src/main/res/drawable-xxhdpi/ic_forward_white_24dp.png
Binary files differ
diff --git a/src/main/res/drawable-xxxhdpi/ic_forward_white_24dp.png b/src/main/res/drawable-xxxhdpi/ic_forward_white_24dp.png
new file mode 100644
index 000000000..fae07bf4c
--- /dev/null
+++ b/src/main/res/drawable-xxxhdpi/ic_forward_white_24dp.png
Binary files differ
diff --git a/src/main/res/drawable/list_item_background_dark.xml b/src/main/res/drawable/list_item_background_dark.xml
new file mode 100644
index 000000000..eca985306
--- /dev/null
+++ b/src/main/res/drawable/list_item_background_dark.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright (c) 2018, Daniel Gultsch All rights reserved.
+ ~
+ ~ Redistribution and use in source and binary forms, with or without modification,
+ ~ are permitted provided that the following conditions are met:
+ ~
+ ~ 1. Redistributions of source code must retain the above copyright notice, this
+ ~ list of conditions and the following disclaimer.
+ ~
+ ~ 2. Redistributions in binary form must reproduce the above copyright notice,
+ ~ this list of conditions and the following disclaimer in the documentation and/or
+ ~ other materials provided with the distribution.
+ ~
+ ~ 3. Neither the name of the copyright holder nor the names of its contributors
+ ~ may be used to endorse or promote products derived from this software without
+ ~ specific prior written permission.
+ ~
+ ~ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ~ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ ~ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ ~ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ ~ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ ~ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ ~ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ ~ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ ~ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ ~ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ -->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:drawable="@color/grey700" android:state_activated="true" />
+</selector> \ No newline at end of file
diff --git a/src/main/res/drawable/list_item_background_light.xml b/src/main/res/drawable/list_item_background_light.xml
new file mode 100644
index 000000000..f064403da
--- /dev/null
+++ b/src/main/res/drawable/list_item_background_light.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright (c) 2018, Daniel Gultsch All rights reserved.
+ ~
+ ~ Redistribution and use in source and binary forms, with or without modification,
+ ~ are permitted provided that the following conditions are met:
+ ~
+ ~ 1. Redistributions of source code must retain the above copyright notice, this
+ ~ list of conditions and the following disclaimer.
+ ~
+ ~ 2. Redistributions in binary form must reproduce the above copyright notice,
+ ~ this list of conditions and the following disclaimer in the documentation and/or
+ ~ other materials provided with the distribution.
+ ~
+ ~ 3. Neither the name of the copyright holder nor the names of its contributors
+ ~ may be used to endorse or promote products derived from this software without
+ ~ specific prior written permission.
+ ~
+ ~ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ~ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ ~ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ ~ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ ~ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ ~ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ ~ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ ~ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ ~ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ ~ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ -->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:drawable="@color/grey300" android:state_activated="true" />
+</selector> \ No newline at end of file
diff --git a/src/main/res/layout/contact.xml b/src/main/res/layout/contact.xml
index c2e374356..0218e299b 100644
--- a/src/main/res/layout/contact.xml
+++ b/src/main/res/layout/contact.xml
@@ -5,7 +5,7 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:background="?android:attr/activatedBackgroundIndicator"
+ android:background="?attr/list_item_background"
android:padding="@dimen/list_padding">
<com.makeramen.roundedimageview.RoundedImageView
diff --git a/src/main/res/menu/select_multiple.xml b/src/main/res/menu/select_multiple.xml
deleted file mode 100644
index 51f05e21a..000000000
--- a/src/main/res/menu/select_multiple.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<menu xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto">
-
- <item
- android:id="@+id/selection_submit"
- android:title="@string/invite_contact"
- app:showAsAction="always" />
-
-</menu>
diff --git a/src/main/res/values/attrs.xml b/src/main/res/values/attrs.xml
index 10690b682..1925f8cfe 100644
--- a/src/main/res/values/attrs.xml
+++ b/src/main/res/values/attrs.xml
@@ -25,6 +25,8 @@
<attr name="activity_background_search" format="reference" />
<attr name="activity_background_no_results" format="reference" />
+ <attr name="list_item_background" format="reference" />
+
<attr name="TextColorOnline" format="reference|color" />
<attr name="TextColorError" format="reference|color" />
diff --git a/src/main/res/values/colors.xml b/src/main/res/values/colors.xml
index 56444212f..6ea10548f 100644
--- a/src/main/res/values/colors.xml
+++ b/src/main/res/values/colors.xml
@@ -22,6 +22,7 @@
<color name="grey200">#ffeeeeee</color>
<color name="grey300">#ffe0e0e0</color>
<color name="grey500">#ff9e9e9e</color>
+ <color name="grey700">#ff616161</color>
<color name="grey800">#ff424242</color>
<color name="grey900">#ff282828</color>
<color name="red800">#ffc62828</color>
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 57edf9ba6..8e2f3a313 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -21,6 +21,7 @@
<string name="title_activity_sharewith">Share with Conversation</string>
<string name="title_activity_start_conversation">Start Conversation</string>
<string name="title_activity_choose_contact">Choose contact</string>
+ <string name="title_activity_choose_contacts">Choose Contacts</string>
<string name="title_activity_block_list">Block list</string>
<string name="just_now">just now</string>
<string name="minute_ago">1 min ago</string>
@@ -426,10 +427,6 @@
<item quantity="one">%d certificate deleted</item>
<item quantity="other">%d certificates deleted</item>
</plurals>
- <plurals name="select_contact">
- <item quantity="one">Select %d contact</item>
- <item quantity="other">Select %d contacts</item>
- </plurals>
<string name="pref_quick_action_summary">Replace send button with quick action</string>
<string name="pref_quick_action">Quick Action</string>
<string name="none">None</string>
diff --git a/src/main/res/values/themes.xml b/src/main/res/values/themes.xml
index 6eef29072..f6114cc23 100644
--- a/src/main/res/values/themes.xml
+++ b/src/main/res/values/themes.xml
@@ -18,6 +18,7 @@
<item name="activity_background_search">@drawable/search_background_light</item>
<item name="activity_background_no_results">@drawable/no_results_background_light</item>
+ <item name="list_item_background">@drawable/list_item_background_light</item>
<item name="EmojiColor">@color/realblack</item>
@@ -152,6 +153,7 @@
<item name="activity_background_search">@drawable/search_background_dark</item>
<item name="activity_background_no_results">@drawable/no_results_background_dark</item>
+ <item name="list_item_background">@drawable/list_item_background_dark</item>
<item name="EmojiColor">@color/realwhite</item>