diff --git a/art/ic_search_black.svg b/art/ic_search_black.svg
new file mode 100644
index 000000000..e3d0e8096
--- /dev/null
+++ b/art/ic_search_black.svg
@@ -0,0 +1,54 @@
+
+
diff --git a/art/ic_search_white.svg b/art/ic_search_white.svg
new file mode 100644
index 000000000..7186d8e23
--- /dev/null
+++ b/art/ic_search_white.svg
@@ -0,0 +1,54 @@
+
+
diff --git a/art/render.rb b/art/render.rb
index 9513e5584..8634d9b37 100755
--- a/art/render.rb
+++ b/art/render.rb
@@ -14,6 +14,8 @@ images = {
'ic_launcher.svg' => ['ic_launcher', 48],
'main_logo.svg' => ['main_logo', 200],
'main_logo.svg' => ['splash_logo', 144],
+ 'ic_search_black.svg' => ['ic_search_background_black', 144],
+ 'ic_search_white.svg' => ['ic_search_background_white', 144],
'play_video.svg' => ['play_video', 128],
'play_gif.svg' => ['play_gif', 128],
'conversations_mono.svg' => ['ic_notification', 24],
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index f3bfdc7eb..a014f717c 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -60,6 +60,9 @@
+
StartConversationActivity.launch(getActivity()));
@@ -257,6 +266,11 @@ public class ConversationsOverviewFragment extends XmppFragment {
return binding.getRoot();
}
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {
+ menuInflater.inflate(R.menu.fragment_conversations_overview, menu);
+ }
+
@Override
public void onBackendConnected() {
refresh();
@@ -300,6 +314,19 @@ public class ConversationsOverviewFragment extends XmppFragment {
Log.d(Config.LOGTAG, "ConversationsOverviewFragment.onResume()");
}
+ @Override
+ public boolean onOptionsItemSelected(final MenuItem item) {
+ if (MenuDoubleTabUtil.shouldIgnoreTap()) {
+ return false;
+ }
+ switch (item.getItemId()) {
+ case R.id.action_search:
+ startActivity(new Intent(getActivity(), SearchActivity.class));
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
@Override
void refresh() {
if (this.binding == null || this.activity == null) {
diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
index 88d970e25..3e74201db 100644
--- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
@@ -64,6 +64,7 @@ import eu.siacs.conversations.ui.adapter.KnownHostsAdapter;
import eu.siacs.conversations.ui.adapter.PresenceTemplateAdapter;
import eu.siacs.conversations.ui.util.MenuDoubleTabUtil;
import eu.siacs.conversations.ui.util.PendingItem;
+import eu.siacs.conversations.ui.util.SoftKeyboardUtils;
import eu.siacs.conversations.utils.CryptoHelper;
import eu.siacs.conversations.utils.UIHelper;
import eu.siacs.conversations.utils.XmppUri;
@@ -389,7 +390,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
protected void finishInitialSetup(final Avatar avatar) {
runOnUiThread(() -> {
- hideKeyboard();
+ SoftKeyboardUtils.hideSoftKeyboard(EditAccountActivity.this);
final Intent intent;
final XmppConnection connection = mAccount.getXmppConnection();
final boolean wasFirstAccount = xmppConnectionService != null && xmppConnectionService.getAccounts().size() == 1;
diff --git a/src/main/java/eu/siacs/conversations/ui/SearchActivity.java b/src/main/java/eu/siacs/conversations/ui/SearchActivity.java
new file mode 100644
index 000000000..873518731
--- /dev/null
+++ b/src/main/java/eu/siacs/conversations/ui/SearchActivity.java
@@ -0,0 +1,114 @@
+/*
+ * 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.
+ */
+
+package eu.siacs.conversations.ui;
+
+import android.databinding.DataBindingUtil;
+import android.os.Bundle;
+import android.support.v7.widget.Toolbar;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.EditText;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import eu.siacs.conversations.Config;
+import eu.siacs.conversations.R;
+import eu.siacs.conversations.databinding.ActivitySearchBinding;
+import eu.siacs.conversations.entities.Message;
+import eu.siacs.conversations.ui.adapter.MessageAdapter;
+
+import static eu.siacs.conversations.ui.util.SoftKeyboardUtils.hideSoftKeyboard;
+import static eu.siacs.conversations.ui.util.SoftKeyboardUtils.showKeyboard;
+
+public class SearchActivity extends XmppActivity implements TextWatcher {
+
+ private ActivitySearchBinding binding;
+ private MessageAdapter messageListAdapter;
+ private final List messages = new ArrayList<>();
+
+ @Override
+ public void onCreate(final Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ this.binding = DataBindingUtil.setContentView(this, R.layout.activity_search);
+ setSupportActionBar((Toolbar) this.binding.toolbar);
+ configureActionBar(getSupportActionBar());
+ this.messageListAdapter = new MessageAdapter(this, this.messages);
+ this.binding.searchResults.setAdapter(messageListAdapter);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(final Menu menu) {
+ getMenuInflater().inflate(R.menu.activity_search, menu);
+ MenuItem searchActionMenuItem = menu.findItem(R.id.action_search);
+ EditText searchField = searchActionMenuItem.getActionView().findViewById(R.id.search_field);
+ searchField.addTextChangedListener(this);
+ searchField.setHint(R.string.search_messages);
+ showKeyboard(searchField);
+ return super.onCreateOptionsMenu(menu);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == android.R.id.home) {
+ hideSoftKeyboard(this);
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ @Override
+ protected void refreshUiReal() {
+
+ }
+
+ @Override
+ void onBackendConnected() {
+
+ }
+
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ Log.d(Config.LOGTAG,"searching for "+s);
+ }
+
+}
diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
index 48a513dec..bd157a132 100644
--- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
@@ -72,6 +72,7 @@ import eu.siacs.conversations.ui.interfaces.OnBackendConnected;
import eu.siacs.conversations.ui.service.EmojiService;
import eu.siacs.conversations.ui.util.MenuDoubleTabUtil;
import eu.siacs.conversations.ui.util.PendingItem;
+import eu.siacs.conversations.ui.util.SoftKeyboardUtils;
import eu.siacs.conversations.utils.XmppUri;
import eu.siacs.conversations.xmpp.OnUpdateBlocklist;
import eu.siacs.conversations.xmpp.XmppConnection;
@@ -116,7 +117,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
- hideKeyboard();
+ SoftKeyboardUtils.hideSoftKeyboard(StartConversationActivity.this);
mSearchEditText.setText("");
filter(null);
return true;
@@ -186,7 +187,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
return true;
}
}
- hideKeyboard();
+ SoftKeyboardUtils.hideSoftKeyboard(StartConversationActivity.this);
mListPagerAdapter.requestFocus(pos);
return true;
}
@@ -343,6 +344,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
protected void openConversationForContact(Contact contact) {
Conversation conversation = xmppConnectionService.findOrCreateConversation(contact.getAccount(), contact.getJid(), false, true);
+ SoftKeyboardUtils.hideSoftKeyboard(this);
switchToConversation(conversation);
}
@@ -384,6 +386,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
bookmark.setAutojoin(true);
xmppConnectionService.pushBookmarks(bookmark.getAccount());
}
+ SoftKeyboardUtils.hideSoftKeyboard(this);
switchToConversation(conversation);
}
diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
index 8684d8580..4673580b5 100644
--- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
@@ -248,13 +248,6 @@ public abstract class XmppActivity extends ActionBarActivity {
}
}
- protected void hideKeyboard() {
- final InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- View focus = getCurrentFocus();
- if (focus != null && inputManager != null) {
- inputManager.hideSoftInputFromWindow(focus.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
- }
- }
public boolean hasPgp() {
return xmppConnectionService.getPgpEngine() != null;
diff --git a/src/main/java/eu/siacs/conversations/ui/util/SoftKeyboardUtils.java b/src/main/java/eu/siacs/conversations/ui/util/SoftKeyboardUtils.java
new file mode 100644
index 000000000..4b5045241
--- /dev/null
+++ b/src/main/java/eu/siacs/conversations/ui/util/SoftKeyboardUtils.java
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+package eu.siacs.conversations.ui.util;
+
+import android.app.Activity;
+import android.content.Context;
+import android.view.View;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
+
+
+
+public class SoftKeyboardUtils {
+
+ public static void hideSoftKeyboard(final Activity activity) {
+ InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
+ if (imm == null) {
+ return;
+ }
+ View view = activity.getCurrentFocus();
+ if (view == null) {
+ view = new View(activity);
+ }
+ imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
+ }
+
+ public static void showKeyboard(EditText editText) {
+ editText.requestFocus();
+ InputMethodManager inputMethodManager = (InputMethodManager) editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
+ if (inputMethodManager != null) {
+ inputMethodManager.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
+ }
+ }
+}
diff --git a/src/main/res/drawable-hdpi/ic_search_background_black.png b/src/main/res/drawable-hdpi/ic_search_background_black.png
new file mode 100644
index 000000000..f3d154295
Binary files /dev/null and b/src/main/res/drawable-hdpi/ic_search_background_black.png differ
diff --git a/src/main/res/drawable-hdpi/ic_search_background_white.png b/src/main/res/drawable-hdpi/ic_search_background_white.png
new file mode 100644
index 000000000..d12f12442
Binary files /dev/null and b/src/main/res/drawable-hdpi/ic_search_background_white.png differ
diff --git a/src/main/res/drawable-mdpi/ic_search_background_black.png b/src/main/res/drawable-mdpi/ic_search_background_black.png
new file mode 100644
index 000000000..29f321b42
Binary files /dev/null and b/src/main/res/drawable-mdpi/ic_search_background_black.png differ
diff --git a/src/main/res/drawable-mdpi/ic_search_background_white.png b/src/main/res/drawable-mdpi/ic_search_background_white.png
new file mode 100644
index 000000000..df5571175
Binary files /dev/null and b/src/main/res/drawable-mdpi/ic_search_background_white.png differ
diff --git a/src/main/res/drawable-xhdpi/ic_search_background_black.png b/src/main/res/drawable-xhdpi/ic_search_background_black.png
new file mode 100644
index 000000000..50219e359
Binary files /dev/null and b/src/main/res/drawable-xhdpi/ic_search_background_black.png differ
diff --git a/src/main/res/drawable-xhdpi/ic_search_background_white.png b/src/main/res/drawable-xhdpi/ic_search_background_white.png
new file mode 100644
index 000000000..62d0fe923
Binary files /dev/null and b/src/main/res/drawable-xhdpi/ic_search_background_white.png differ
diff --git a/src/main/res/drawable-xxhdpi/ic_search_background_black.png b/src/main/res/drawable-xxhdpi/ic_search_background_black.png
new file mode 100644
index 000000000..9ce02844f
Binary files /dev/null and b/src/main/res/drawable-xxhdpi/ic_search_background_black.png differ
diff --git a/src/main/res/drawable-xxhdpi/ic_search_background_white.png b/src/main/res/drawable-xxhdpi/ic_search_background_white.png
new file mode 100644
index 000000000..080ca7c0e
Binary files /dev/null and b/src/main/res/drawable-xxhdpi/ic_search_background_white.png differ
diff --git a/src/main/res/drawable-xxxhdpi/ic_search_background_black.png b/src/main/res/drawable-xxxhdpi/ic_search_background_black.png
new file mode 100644
index 000000000..240fe2e4e
Binary files /dev/null and b/src/main/res/drawable-xxxhdpi/ic_search_background_black.png differ
diff --git a/src/main/res/drawable-xxxhdpi/ic_search_background_white.png b/src/main/res/drawable-xxxhdpi/ic_search_background_white.png
new file mode 100644
index 000000000..b295b0266
Binary files /dev/null and b/src/main/res/drawable-xxxhdpi/ic_search_background_white.png differ
diff --git a/src/main/res/drawable/search_background_dark.xml b/src/main/res/drawable/search_background_dark.xml
new file mode 100644
index 000000000..e2aa24725
--- /dev/null
+++ b/src/main/res/drawable/search_background_dark.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+ -
+
+
+
diff --git a/src/main/res/drawable/search_background_light.xml b/src/main/res/drawable/search_background_light.xml
new file mode 100644
index 000000000..fd1735c03
--- /dev/null
+++ b/src/main/res/drawable/search_background_light.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+ -
+
+
+
diff --git a/src/main/res/drawable/white_cursor.xml b/src/main/res/drawable/white_cursor.xml
new file mode 100644
index 000000000..a15fe9729
--- /dev/null
+++ b/src/main/res/drawable/white_cursor.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/res/layout/activity_search.xml b/src/main/res/layout/activity_search.xml
index b234ad7be..bce914b16 100644
--- a/src/main/res/layout/activity_search.xml
+++ b/src/main/res/layout/activity_search.xml
@@ -44,7 +44,7 @@
android:id="@+id/search_results"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="?attr/color_background_secondary"
+ android:background="?attr/activity_background_search"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"/>
diff --git a/src/main/res/menu/activity_conversations.xml b/src/main/res/menu/activity_conversations.xml
index 7c22f56d7..2a0ce4b33 100644
--- a/src/main/res/menu/activity_conversations.xml
+++ b/src/main/res/menu/activity_conversations.xml
@@ -4,6 +4,7 @@
android:id="@+id/action_scan_qr_code"
android:title="@string/scan_qr_code"
app:showAsAction="always"
+ android:orderInCategory="10"
android:visible="@bool/show_qr_code_scan"
android:icon="?attr/icon_scan_qr_code"/>
-
+
+
+
\ No newline at end of file
diff --git a/src/main/res/menu/fragment_conversations_overview.xml b/src/main/res/menu/fragment_conversations_overview.xml
new file mode 100644
index 000000000..fe4cd62f1
--- /dev/null
+++ b/src/main/res/menu/fragment_conversations_overview.xml
@@ -0,0 +1,37 @@
+
+
+
\ No newline at end of file
diff --git a/src/main/res/values/attrs.xml b/src/main/res/values/attrs.xml
index 871c6a46d..cbf50c40d 100644
--- a/src/main/res/values/attrs.xml
+++ b/src/main/res/values/attrs.xml
@@ -17,6 +17,8 @@
+
+
diff --git a/src/main/res/values/colors.xml b/src/main/res/values/colors.xml
index 21b8214d8..57c8ef239 100644
--- a/src/main/res/values/colors.xml
+++ b/src/main/res/values/colors.xml
@@ -11,6 +11,7 @@
#42000000
#1f000000
#ffffffff
+ #deffffff
#b2ffffff
#1fffffff
#fffafafa
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index a0338a4f0..2dc483c49 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -703,4 +703,6 @@
Unable to start recording
Please wait…
Conversations needs access to the microphone
+ Search
+ Search messages
diff --git a/src/main/res/values/styles.xml b/src/main/res/values/styles.xml
index 3a163b9a8..da37f6a3f 100644
--- a/src/main/res/values/styles.xml
+++ b/src/main/res/values/styles.xml
@@ -36,6 +36,7 @@
- @color/white70
- @android:color/transparent
- 18sp
+ - @drawable/white_cursor