Update look of contact selection activities.
// FREEBIE
@ -201,8 +201,7 @@
|
|||||||
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
|
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
|
||||||
|
|
||||||
<activity android:name=".NewConversationActivity"
|
<activity android:name=".NewConversationActivity"
|
||||||
android:label="@string/AndroidManifest__select_contacts"
|
android:theme="@style/TextSecure.LightNoActionBar"
|
||||||
android:windowSoftInputMode="stateVisible"
|
|
||||||
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
|
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
|
||||||
|
|
||||||
<activity android:name=".PushContactSelectionActivity"
|
<activity android:name=".PushContactSelectionActivity"
|
||||||
|
BIN
res/drawable-hdpi/ic_dialpad_white_24dp.png
Normal file
After Width: | Height: | Size: 359 B |
Before Width: | Height: | Size: 429 B After Width: | Height: | Size: 281 B |
BIN
res/drawable-mdpi/ic_dialpad_white_24dp.png
Normal file
After Width: | Height: | Size: 252 B |
Before Width: | Height: | Size: 340 B After Width: | Height: | Size: 210 B |
BIN
res/drawable-xhdpi/ic_dialpad_white_24dp.png
Normal file
After Width: | Height: | Size: 375 B |
Before Width: | Height: | Size: 440 B After Width: | Height: | Size: 333 B |
BIN
res/drawable-xxhdpi/ic_dialpad_white_24dp.png
Normal file
After Width: | Height: | Size: 463 B |
BIN
res/drawable-xxxhdpi/ic_dialpad_white_24dp.png
Normal file
After Width: | Height: | Size: 493 B |
BIN
res/drawable-xxxhdpi/ic_keyboard_white_24dp.png
Normal file
After Width: | Height: | Size: 502 B |
92
res/layout/contact_selection_activity.xml
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout android:layout_gravity="center"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<android.support.v7.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:minHeight="?attr/actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
android:theme="@style/TextSecure.LightActionBar">
|
||||||
|
|
||||||
|
<LinearLayout android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<ImageView android:id="@+id/action_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:clickable="true"
|
||||||
|
android:background="@drawable/circle_touch_highlight_background"
|
||||||
|
android:src="@drawable/ic_search_white_24dp" />
|
||||||
|
|
||||||
|
<EditText android:id="@+id/search_view"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="0px"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:hint="Enter name or number"
|
||||||
|
android:inputType="textPersonName"
|
||||||
|
android:theme="@style/TextSecure.TitleTextStyle"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:gravity="center_vertical"/>
|
||||||
|
|
||||||
|
<org.thoughtcrime.securesms.components.AnimatingToggle
|
||||||
|
android:id="@+id/button_toggle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
|
<ImageView android:id="@+id/search_dialpad"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:clickable="true"
|
||||||
|
android:background="@drawable/circle_touch_highlight_background"
|
||||||
|
android:src="@drawable/ic_dialpad_white_24dp" />
|
||||||
|
|
||||||
|
<ImageView android:id="@+id/search_keyboard"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:clickable="true"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:background="@drawable/circle_touch_highlight_background"
|
||||||
|
android:src="@drawable/ic_keyboard_white_24dp" />
|
||||||
|
|
||||||
|
|
||||||
|
<ImageView android:id="@+id/search_clear"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:clickable="true"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:background="@drawable/circle_touch_highlight_background"
|
||||||
|
android:src="@drawable/ic_clear_white_24dp" />
|
||||||
|
|
||||||
|
</org.thoughtcrime.securesms.components.AnimatingToggle>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</android.support.v7.widget.Toolbar>
|
||||||
|
|
||||||
|
<fragment
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/contact_selection_list_fragment"
|
||||||
|
android:name="org.thoughtcrime.securesms.ContactSelectionListFragment">
|
||||||
|
</fragment>
|
||||||
|
|
||||||
|
</LinearLayout>
|
26
res/layout/contact_selection_list_fragment.xml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<android.support.v4.widget.SwipeRefreshLayout
|
||||||
|
android:id="@+id/swipe_refresh"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<se.emilsjolander.stickylistheaders.StickyListHeadersListView
|
||||||
|
android:id="@android:id/list"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<TextView android:id="@android:id/empty"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center|center_vertical"
|
||||||
|
android:layout_marginTop="15dp"
|
||||||
|
android:text="@string/contact_selection_group_activity__finding_contacts"
|
||||||
|
android:textSize="20sp" />
|
||||||
|
|
||||||
|
</android.support.v4.widget.SwipeRefreshLayout>
|
||||||
|
</LinearLayout>
|
@ -14,12 +14,7 @@
|
|||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:textSize="15sp"
|
android:textSize="15sp"
|
||||||
android:textColor="?conversation_selection_header_text"
|
android:textColor="?contact_selection_header_text"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<View android:layout_width="match_parent"
|
|
||||||
android:layout_height="3dp"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_marginTop="2dp"
|
|
||||||
android:background="?conversation_selection_header_text" />
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
@ -1,16 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout android:layout_gravity="center"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
|
|
||||||
<fragment
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:id="@+id/contact_selection_list_fragment"
|
|
||||||
android:name="org.thoughtcrime.securesms.PushContactSelectionListFragment">
|
|
||||||
</fragment>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@ -1,16 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout android:layout_gravity="center"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
|
|
||||||
<fragment
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:id="@+id/contact_selection_list_fragment"
|
|
||||||
android:name="org.thoughtcrime.securesms.PushContactSelectionListFragment">
|
|
||||||
</fragment>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@ -1,27 +0,0 @@
|
|||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<EditText android:id="@+id/filter"
|
|
||||||
android:inputType="textPersonName"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="45sp"
|
|
||||||
android:hint="@string/recipients_panel__to"
|
|
||||||
android:textColor="?conversation_editor_text_color" />
|
|
||||||
|
|
||||||
<se.emilsjolander.stickylistheaders.StickyListHeadersListView
|
|
||||||
android:id="@android:id/list"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent" />
|
|
||||||
|
|
||||||
<TextView android:id="@android:id/empty"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="center|center_vertical"
|
|
||||||
android:layout_marginTop="15dp"
|
|
||||||
android:text="@string/contact_selection_group_activity__finding_contacts"
|
|
||||||
android:textSize="20sp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
9
res/menu/new_conversation_activity_number_pad.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?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:title="Number pad"
|
||||||
|
android:id="@+id/menu_number_pad"
|
||||||
|
android:icon="@drawable/ic_dialpad_white_24dp"
|
||||||
|
app:showAsAction="always"/>
|
||||||
|
</menu>
|
11
res/menu/new_conversation_activity_search.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?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:title="Search contacts"
|
||||||
|
android:id="@+id/menu_search"
|
||||||
|
android:icon="?attr/menu_search_icon"
|
||||||
|
app:actionViewClass="android.support.v7.widget.SearchView"
|
||||||
|
app:showAsAction="always|collapseActionView" />
|
||||||
|
|
||||||
|
</menu>
|
10
res/menu/new_conversation_activity_text_pad.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?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:title="Text input"
|
||||||
|
android:id="@+id/menu_text_pad"
|
||||||
|
android:icon="@drawable/ic_keyboard_white_24dp"
|
||||||
|
app:showAsAction="always"/>
|
||||||
|
|
||||||
|
</menu>
|
@ -4,6 +4,6 @@
|
|||||||
<item android:title="@string/push_directory__menu_refresh"
|
<item android:title="@string/push_directory__menu_refresh"
|
||||||
android:id="@+id/menu_refresh_directory"
|
android:id="@+id/menu_refresh_directory"
|
||||||
android:icon="?menu_refresh_directory"
|
android:icon="?menu_refresh_directory"
|
||||||
app:showAsAction="ifRoom"
|
app:showAsAction="always"
|
||||||
/>
|
/>
|
||||||
</menu>
|
</menu>
|
@ -72,7 +72,7 @@
|
|||||||
<attr name="contact_selection_push_user" format="reference|color" />
|
<attr name="contact_selection_push_user" format="reference|color" />
|
||||||
<attr name="contact_selection_lay_user" format="reference|color" />
|
<attr name="contact_selection_lay_user" format="reference|color" />
|
||||||
<attr name="contact_selection_label_text" format="reference|color" />
|
<attr name="contact_selection_label_text" format="reference|color" />
|
||||||
<attr name="conversation_selection_header_text" format="reference|color" />
|
<attr name="contact_selection_header_text" format="reference|color" />
|
||||||
|
|
||||||
<attr name="import_export_item_background_color" format="reference|color" />
|
<attr name="import_export_item_background_color" format="reference|color" />
|
||||||
<attr name="import_export_item_background_shadow_color" format="reference|color" />
|
<attr name="import_export_item_background_shadow_color" format="reference|color" />
|
||||||
|
@ -58,6 +58,7 @@
|
|||||||
|
|
||||||
<style name="TextSecure.TitleTextStyle" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
|
<style name="TextSecure.TitleTextStyle" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
|
||||||
<item name="android:textColor">@color/white</item>
|
<item name="android:textColor">@color/white</item>
|
||||||
|
<item name="android:textColorHint">#BFffffff</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="TextSecure.SubtitleTextStyle" parent="TextAppearance.AppCompat.Widget.ActionBar.Subtitle">
|
<style name="TextSecure.SubtitleTextStyle" parent="TextAppearance.AppCompat.Widget.ActionBar.Subtitle">
|
||||||
|
@ -9,7 +9,12 @@
|
|||||||
<item name="colorPrimary">@color/textsecure_primary</item>
|
<item name="colorPrimary">@color/textsecure_primary</item>
|
||||||
<item name="colorPrimaryDark">@color/textsecure_primary_dark</item>
|
<item name="colorPrimaryDark">@color/textsecure_primary_dark</item>
|
||||||
<item name="colorAccent">@color/textsecure_primary_dark</item>
|
<item name="colorAccent">@color/textsecure_primary_dark</item>
|
||||||
|
|
||||||
<item name="recipient_preference_blocked">#8e0000</item>
|
<item name="recipient_preference_blocked">#8e0000</item>
|
||||||
|
<item name="contact_selection_label_text">#66000000</item>
|
||||||
|
<item name="contact_selection_push_user">#ff000000</item>
|
||||||
|
<item name="contact_selection_lay_user">#a0000000</item>
|
||||||
|
<item name="contact_selection_header_text">@color/textsecure_primary_dark</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="TextSecure.DarkNoActionBar" parent="@style/Theme.AppCompat.NoActionBar">
|
<style name="TextSecure.DarkNoActionBar" parent="@style/Theme.AppCompat.NoActionBar">
|
||||||
@ -17,7 +22,12 @@
|
|||||||
<item name="actionBarStyle">@style/TextSecure.DarkActionBar</item>
|
<item name="actionBarStyle">@style/TextSecure.DarkActionBar</item>
|
||||||
<item name="actionBarTabBarStyle">@style/TextSecure.DarkActionBar.TabBar</item>
|
<item name="actionBarTabBarStyle">@style/TextSecure.DarkActionBar.TabBar</item>
|
||||||
<item name="actionBarPopupTheme">@style/ThemeOverlay.AppCompat.Dark</item>
|
<item name="actionBarPopupTheme">@style/ThemeOverlay.AppCompat.Dark</item>
|
||||||
|
|
||||||
<item name="recipient_preference_blocked">#d00000</item>
|
<item name="recipient_preference_blocked">#d00000</item>
|
||||||
|
<item name="contact_selection_label_text">#66eeeeee</item>
|
||||||
|
<item name="contact_selection_push_user">#ffeeeeee</item>
|
||||||
|
<item name="contact_selection_lay_user">#afeeeeee</item>
|
||||||
|
<item name="contact_selection_header_text">#66eeeeee</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="TextSecure.LightIntroTheme" parent="@style/Theme.AppCompat.Light">
|
<style name="TextSecure.LightIntroTheme" parent="@style/Theme.AppCompat.Light">
|
||||||
@ -82,11 +92,6 @@
|
|||||||
|
|
||||||
<item name="conversation_group_member_name">#99000000</item>
|
<item name="conversation_group_member_name">#99000000</item>
|
||||||
|
|
||||||
<item name="contact_selection_push_user">#ff000000</item>
|
|
||||||
<item name="contact_selection_lay_user">#a0000000</item>
|
|
||||||
<item name="contact_selection_label_text">#66000000</item>
|
|
||||||
<item name="conversation_selection_header_text">#44000000</item>
|
|
||||||
|
|
||||||
<item name="conversation_background">#eeeeee</item>
|
<item name="conversation_background">#eeeeee</item>
|
||||||
<item name="conversation_editor_background">#22000000</item>
|
<item name="conversation_editor_background">#22000000</item>
|
||||||
<item name="conversation_editor_text_color">#ff111111</item>
|
<item name="conversation_editor_text_color">#ff111111</item>
|
||||||
@ -196,11 +201,6 @@
|
|||||||
|
|
||||||
<item name="conversation_group_member_name">#99ffffff</item>
|
<item name="conversation_group_member_name">#99ffffff</item>
|
||||||
|
|
||||||
<item name="contact_selection_push_user">#ffeeeeee</item>
|
|
||||||
<item name="contact_selection_lay_user">#afeeeeee</item>
|
|
||||||
<item name="contact_selection_label_text">#66eeeeee</item>
|
|
||||||
<item name="conversation_selection_header_text">#66eeeeee</item>
|
|
||||||
|
|
||||||
<item name="conversation_item_background">@drawable/conversation_item_background_dark</item>
|
<item name="conversation_item_background">@drawable/conversation_item_background_dark</item>
|
||||||
<item name="conversation_item_bubble_background">#ff333333</item>
|
<item name="conversation_item_bubble_background">#ff333333</item>
|
||||||
<item name="conversation_item_sent_text_primary_color">#ffffffff</item>
|
<item name="conversation_item_sent_text_primary_color">#ffffffff</item>
|
||||||
|
198
src/org/thoughtcrime/securesms/ContactSelectionActivity.java
Normal file
@ -0,0 +1,198 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (C) 2015 Open Whisper Systems
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.thoughtcrime.securesms;
|
||||||
|
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
|
import android.support.v7.widget.Toolbar;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.InputType;
|
||||||
|
import android.text.TextWatcher;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.components.AnimatingToggle;
|
||||||
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||||
|
import org.thoughtcrime.securesms.util.DirectoryHelper;
|
||||||
|
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
||||||
|
import org.thoughtcrime.securesms.util.DynamicNoActionBarTheme;
|
||||||
|
import org.thoughtcrime.securesms.util.DynamicTheme;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base activity container for selecting a list of contacts.
|
||||||
|
*
|
||||||
|
* @author Moxie Marlinspike
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public abstract class ContactSelectionActivity extends PassphraseRequiredActionBarActivity
|
||||||
|
implements SwipeRefreshLayout.OnRefreshListener,
|
||||||
|
ContactSelectionListFragment.OnContactSelectedListener
|
||||||
|
{
|
||||||
|
private static final String TAG = ContactSelectionActivity.class.getSimpleName();
|
||||||
|
public final static String PUSH_ONLY_EXTRA = "push_only";
|
||||||
|
|
||||||
|
private final DynamicTheme dynamicTheme = new DynamicNoActionBarTheme();
|
||||||
|
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
|
||||||
|
|
||||||
|
protected ContactSelectionListFragment contactsFragment;
|
||||||
|
|
||||||
|
private Toolbar toolbar;
|
||||||
|
private EditText searchText;
|
||||||
|
private AnimatingToggle toggle;
|
||||||
|
protected ImageView action;
|
||||||
|
private ImageView keyboardToggle;
|
||||||
|
private ImageView dialpadToggle;
|
||||||
|
private ImageView clearToggle;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPreCreate() {
|
||||||
|
dynamicTheme.onCreate(this);
|
||||||
|
dynamicLanguage.onCreate(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle icicle, @NonNull MasterSecret masterSecret) {
|
||||||
|
setContentView(R.layout.contact_selection_activity);
|
||||||
|
|
||||||
|
initializeToolbar();
|
||||||
|
initializeResources();
|
||||||
|
initializeSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
dynamicTheme.onResume(this);
|
||||||
|
dynamicLanguage.onResume(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeToolbar() {
|
||||||
|
this.toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
||||||
|
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeResources() {
|
||||||
|
this.action = (ImageView) findViewById(R.id.action_icon);
|
||||||
|
this.searchText = (EditText) findViewById(R.id.search_view);
|
||||||
|
this.toggle = (AnimatingToggle) findViewById(R.id.button_toggle);
|
||||||
|
this.keyboardToggle = (ImageView) findViewById(R.id.search_keyboard);
|
||||||
|
this.dialpadToggle = (ImageView) findViewById(R.id.search_dialpad);
|
||||||
|
this.clearToggle = (ImageView) findViewById(R.id.search_clear);
|
||||||
|
|
||||||
|
contactsFragment = (ContactSelectionListFragment) getSupportFragmentManager().findFragmentById(R.id.contact_selection_list_fragment);
|
||||||
|
contactsFragment.setOnContactSelectedListener(this);
|
||||||
|
contactsFragment.setOnRefreshListener(this);
|
||||||
|
|
||||||
|
this.keyboardToggle.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
searchText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
|
||||||
|
toggle.display(dialpadToggle);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.dialpadToggle.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
searchText.setInputType(InputType.TYPE_CLASS_PHONE);
|
||||||
|
toggle.display(keyboardToggle);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.clearToggle.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
searchText.setText("");
|
||||||
|
|
||||||
|
if (SearchUtil.isTextInput(searchText)) toggle.display(dialpadToggle);
|
||||||
|
else toggle.display(keyboardToggle);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeSearch() {
|
||||||
|
this.searchText.addTextChangedListener(new TextWatcher() {
|
||||||
|
@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) {
|
||||||
|
if (!SearchUtil.isEmpty(searchText)) toggle.display(clearToggle);
|
||||||
|
else if (SearchUtil.isTextInput(searchText)) toggle.display(dialpadToggle);
|
||||||
|
else if (SearchUtil.isPhoneInput(searchText)) toggle.display(keyboardToggle);
|
||||||
|
|
||||||
|
contactsFragment.setQueryFilter(searchText.getText().toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRefresh() {
|
||||||
|
new AsyncTask<Void, Void, Void>() {
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... params) {
|
||||||
|
try {
|
||||||
|
DirectoryHelper.refreshDirectory(ContactSelectionActivity.this);
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.w(TAG, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Void result) {
|
||||||
|
searchText.setText("");
|
||||||
|
contactsFragment.resetQueryFilter();
|
||||||
|
}
|
||||||
|
}.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onContactSelected(String number) {}
|
||||||
|
|
||||||
|
private static class SearchUtil {
|
||||||
|
|
||||||
|
public static boolean isTextInput(EditText editText) {
|
||||||
|
return (editText.getInputType() & 0x0000000F) == InputType.TYPE_CLASS_TEXT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isPhoneInput(EditText editText) {
|
||||||
|
return (editText.getInputType() & 0x0000000F) == InputType.TYPE_CLASS_PHONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isEmpty(EditText editText) {
|
||||||
|
return editText.getText().length() <= 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2011 Whisper Systems
|
* Copyright (C) 2015 Open Whisper Systems
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -23,13 +23,11 @@ import android.support.v4.app.Fragment;
|
|||||||
import android.support.v4.app.LoaderManager;
|
import android.support.v4.app.LoaderManager;
|
||||||
import android.support.v4.content.Loader;
|
import android.support.v4.content.Loader;
|
||||||
import android.support.v4.widget.CursorAdapter;
|
import android.support.v4.widget.CursorAdapter;
|
||||||
import android.text.Editable;
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
import android.text.TextWatcher;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.contacts.ContactSelectionListAdapter;
|
import org.thoughtcrime.securesms.contacts.ContactSelectionListAdapter;
|
||||||
@ -49,17 +47,17 @@ import se.emilsjolander.stickylistheaders.StickyListHeadersListView;
|
|||||||
* @author Moxie Marlinspike
|
* @author Moxie Marlinspike
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
public class ContactSelectionListFragment extends Fragment
|
||||||
public class PushContactSelectionListFragment extends Fragment
|
implements LoaderManager.LoaderCallbacks<Cursor>
|
||||||
implements LoaderManager.LoaderCallbacks<Cursor>
|
|
||||||
{
|
{
|
||||||
private static final String TAG = "ContactSelectFragment";
|
private static final String TAG = ContactSelectionListFragment.class.getSimpleName();
|
||||||
|
|
||||||
private TextView emptyText;
|
private TextView emptyText;
|
||||||
|
|
||||||
private Map<Long, String> selectedContacts;
|
private Map<Long, String> selectedContacts;
|
||||||
private OnContactSelectedListener onContactSelectedListener;
|
private OnContactSelectedListener onContactSelectedListener;
|
||||||
private StickyListHeadersListView listView;
|
private StickyListHeadersListView listView;
|
||||||
|
private SwipeRefreshLayout swipeRefresh;
|
||||||
private String cursorFilter;
|
private String cursorFilter;
|
||||||
|
|
||||||
private boolean multi = false;
|
private boolean multi = false;
|
||||||
@ -67,7 +65,6 @@ public class PushContactSelectionListFragment extends Fragment
|
|||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(Bundle icicle) {
|
public void onActivityCreated(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
initializeResources();
|
|
||||||
initializeCursor();
|
initializeCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +80,17 @@ public class PushContactSelectionListFragment extends Fragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
return inflater.inflate(R.layout.push_contact_selection_list_activity, container, false);
|
View view = inflater.inflate(R.layout.contact_selection_list_fragment, container, false);
|
||||||
|
|
||||||
|
this.emptyText = (TextView) view.findViewById(android.R.id.empty);
|
||||||
|
swipeRefresh = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh);
|
||||||
|
listView = (StickyListHeadersListView) view.findViewById(android.R.id.list);
|
||||||
|
listView.setFocusable(true);
|
||||||
|
listView.setFastScrollEnabled(true);
|
||||||
|
listView.setDrawingListUnderStickyHeader(false);
|
||||||
|
listView.setOnItemClickListener(new ListClickListener());
|
||||||
|
|
||||||
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getSelectedContacts() {
|
public List<String> getSelectedContacts() {
|
||||||
@ -106,42 +113,19 @@ public class PushContactSelectionListFragment extends Fragment
|
|||||||
this.getLoaderManager().initLoader(0, null, this);
|
this.getLoaderManager().initLoader(0, null, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeResources() {
|
public void setQueryFilter(String filter) {
|
||||||
emptyText = (TextView) getView().findViewById(android.R.id.empty);
|
this.cursorFilter = filter;
|
||||||
listView = (StickyListHeadersListView) getView().findViewById(android.R.id.list);
|
this.getLoaderManager().restartLoader(0, null, this);
|
||||||
listView.setFocusable(true);
|
|
||||||
listView.setFastScrollEnabled(true);
|
|
||||||
listView.setDrawingListUnderStickyHeader(false);
|
|
||||||
listView.setOnItemClickListener(new ListClickListener());
|
|
||||||
|
|
||||||
EditText filterEditText = (EditText) getView().findViewById(R.id.filter);
|
|
||||||
filterEditText.addTextChangedListener(new TextWatcher() {
|
|
||||||
@Override
|
|
||||||
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
|
||||||
cursorFilter = charSequence.toString();
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterTextChanged(Editable editable) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
cursorFilter = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
public void resetQueryFilter() {
|
||||||
this.getLoaderManager().restartLoader(0, null, this);
|
setQueryFilter(null);
|
||||||
|
swipeRefresh.setRefreshing(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||||
boolean pushOnly = getActivity().getIntent().getBooleanExtra(PushContactSelectionActivity.PUSH_ONLY_EXTRA, false);
|
boolean pushOnly = getActivity().getIntent().getBooleanExtra(ContactSelectionActivity.PUSH_ONLY_EXTRA, false);
|
||||||
boolean supportsSms = TextSecurePreferences.isSmsEnabled(getActivity());
|
boolean supportsSms = TextSecurePreferences.isSmsEnabled(getActivity());
|
||||||
|
|
||||||
return new ContactsCursorLoader(getActivity(), !pushOnly && supportsSms, cursorFilter);
|
return new ContactsCursorLoader(getActivity(), !pushOnly && supportsSms, cursorFilter);
|
||||||
@ -178,6 +162,10 @@ public class PushContactSelectionListFragment extends Fragment
|
|||||||
this.onContactSelectedListener = onContactSelectedListener;
|
this.onContactSelectedListener = onContactSelectedListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOnRefreshListener(SwipeRefreshLayout.OnRefreshListener onRefreshListener) {
|
||||||
|
this.swipeRefresh.setOnRefreshListener(onRefreshListener);
|
||||||
|
}
|
||||||
|
|
||||||
public interface OnContactSelectedListener {
|
public interface OnContactSelectedListener {
|
||||||
public void onContactSelected(String number);
|
public void onContactSelected(String number);
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2011 Whisper Systems
|
* Copyright (C) 2015 Open Whisper Systems
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -17,99 +17,26 @@
|
|||||||
package org.thoughtcrime.securesms;
|
package org.thoughtcrime.securesms;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipients;
|
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||||
import org.thoughtcrime.securesms.util.DirectoryHelper;
|
|
||||||
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
|
||||||
import org.thoughtcrime.securesms.util.DynamicTheme;
|
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activity container for selecting a list of contacts.
|
* Activity container for starting a new conversation.
|
||||||
*
|
*
|
||||||
* @author Moxie Marlinspike
|
* @author Moxie Marlinspike
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class NewConversationActivity extends PassphraseRequiredActionBarActivity {
|
public class NewConversationActivity extends ContactSelectionActivity {
|
||||||
|
|
||||||
private static final String TAG = NewConversationActivity.class.getSimpleName();
|
private static final String TAG = NewConversationActivity.class.getSimpleName();
|
||||||
|
|
||||||
private final DynamicTheme dynamicTheme = new DynamicTheme ();
|
|
||||||
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
|
|
||||||
|
|
||||||
private PushContactSelectionListFragment contactsFragment;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreCreate() {
|
public void onContactSelected(String number) {
|
||||||
dynamicTheme.onCreate(this);
|
Recipients recipients = RecipientFactory.getRecipientsFromString(this, number, true);
|
||||||
dynamicLanguage.onCreate(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle icicle, @NonNull MasterSecret masterSecret) {
|
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
|
||||||
setContentView(R.layout.new_conversation_activity);
|
|
||||||
initializeResources();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
dynamicTheme.onResume(this);
|
|
||||||
dynamicLanguage.onResume(this);
|
|
||||||
getSupportActionBar().setTitle(R.string.AndroidManifest__select_contacts);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
|
||||||
MenuInflater inflater = this.getMenuInflater();
|
|
||||||
menu.clear();
|
|
||||||
|
|
||||||
if (TextSecurePreferences.isPushRegistered(this)) inflater.inflate(R.menu.push_directory, menu);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
super.onOptionsItemSelected(item);
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.menu_refresh_directory: handleDirectoryRefresh(); return true;
|
|
||||||
case android.R.id.home: finish(); return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initializeResources() {
|
|
||||||
contactsFragment = (PushContactSelectionListFragment) getSupportFragmentManager().findFragmentById(R.id.contact_selection_list_fragment);
|
|
||||||
contactsFragment.setOnContactSelectedListener(new PushContactSelectionListFragment.OnContactSelectedListener() {
|
|
||||||
@Override
|
|
||||||
public void onContactSelected(String number) {
|
|
||||||
Log.i(TAG, "Choosing contact from list.");
|
|
||||||
Recipients recipients = RecipientFactory.getRecipientsFromString(NewConversationActivity.this, number, true);
|
|
||||||
openNewConversation(recipients);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleDirectoryRefresh() {
|
|
||||||
DirectoryHelper.refreshDirectoryWithProgressDialog(this, new DirectoryHelper.DirectoryUpdateFinishedListener() {
|
|
||||||
@Override
|
|
||||||
public void onUpdateFinished() {
|
|
||||||
contactsFragment.update();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openNewConversation(Recipients recipients) {
|
|
||||||
if (recipients != null) {
|
if (recipients != null) {
|
||||||
Intent intent = new Intent(this, ConversationActivity.class);
|
Intent intent = new Intent(this, ConversationActivity.class);
|
||||||
intent.putExtra(ConversationActivity.RECIPIENTS_EXTRA, recipients.getIds());
|
intent.putExtra(ConversationActivity.RECIPIENTS_EXTRA, recipients.getIds());
|
||||||
@ -117,11 +44,14 @@ public class NewConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
intent.putExtra(ConversationActivity.DRAFT_AUDIO_EXTRA, getIntent().getParcelableExtra(ConversationActivity.DRAFT_AUDIO_EXTRA));
|
intent.putExtra(ConversationActivity.DRAFT_AUDIO_EXTRA, getIntent().getParcelableExtra(ConversationActivity.DRAFT_AUDIO_EXTRA));
|
||||||
intent.putExtra(ConversationActivity.DRAFT_VIDEO_EXTRA, getIntent().getParcelableExtra(ConversationActivity.DRAFT_VIDEO_EXTRA));
|
intent.putExtra(ConversationActivity.DRAFT_VIDEO_EXTRA, getIntent().getParcelableExtra(ConversationActivity.DRAFT_VIDEO_EXTRA));
|
||||||
intent.putExtra(ConversationActivity.DRAFT_IMAGE_EXTRA, getIntent().getParcelableExtra(ConversationActivity.DRAFT_IMAGE_EXTRA));
|
intent.putExtra(ConversationActivity.DRAFT_IMAGE_EXTRA, getIntent().getParcelableExtra(ConversationActivity.DRAFT_IMAGE_EXTRA));
|
||||||
|
|
||||||
long existingThread = DatabaseFactory.getThreadDatabase(this).getThreadIdIfExistsFor(recipients);
|
long existingThread = DatabaseFactory.getThreadDatabase(this).getThreadIdIfExistsFor(recipients);
|
||||||
|
|
||||||
intent.putExtra(ConversationActivity.THREAD_ID_EXTRA, existingThread);
|
intent.putExtra(ConversationActivity.THREAD_ID_EXTRA, existingThread);
|
||||||
intent.putExtra(ConversationActivity.DISTRIBUTION_TYPE_EXTRA, ThreadDatabase.DistributionTypes.DEFAULT);
|
intent.putExtra(ConversationActivity.DISTRIBUTION_TYPE_EXTRA, ThreadDatabase.DistributionTypes.DEFAULT);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,12 @@ import android.support.annotation.NonNull;
|
|||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||||
import org.thoughtcrime.securesms.util.DirectoryHelper;
|
import org.thoughtcrime.securesms.util.DirectoryHelper;
|
||||||
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
||||||
|
import org.thoughtcrime.securesms.util.DynamicNoActionBarTheme;
|
||||||
import org.thoughtcrime.securesms.util.DynamicTheme;
|
import org.thoughtcrime.securesms.util.DynamicTheme;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
|
|
||||||
@ -38,81 +40,28 @@ import java.util.List;
|
|||||||
* @author Moxie Marlinspike
|
* @author Moxie Marlinspike
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PushContactSelectionActivity extends PassphraseRequiredActionBarActivity {
|
public class PushContactSelectionActivity extends ContactSelectionActivity {
|
||||||
private final static String TAG = "ContactSelectActivity";
|
|
||||||
public final static String PUSH_ONLY_EXTRA = "push_only";
|
|
||||||
|
|
||||||
private final DynamicTheme dynamicTheme = new DynamicTheme ();
|
private final static String TAG = PushContactSelectionActivity.class.getSimpleName();
|
||||||
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
|
|
||||||
|
|
||||||
private PushContactSelectionListFragment contactsFragment;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPreCreate() {
|
|
||||||
dynamicTheme.onCreate(this);
|
|
||||||
dynamicLanguage.onCreate(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle icicle, @NonNull MasterSecret masterSecret) {
|
protected void onCreate(Bundle icicle, @NonNull MasterSecret masterSecret) {
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
super.onCreate(icicle, masterSecret);
|
||||||
|
|
||||||
setContentView(R.layout.push_contact_selection_activity);
|
|
||||||
initializeResources();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
dynamicTheme.onResume(this);
|
|
||||||
dynamicLanguage.onResume(this);
|
|
||||||
getSupportActionBar().setTitle(R.string.AndroidManifest__select_contacts);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
|
||||||
MenuInflater inflater = this.getMenuInflater();
|
|
||||||
menu.clear();
|
|
||||||
|
|
||||||
if (TextSecurePreferences.isPushRegistered(this)) inflater.inflate(R.menu.push_directory, menu);
|
|
||||||
|
|
||||||
inflater.inflate(R.menu.contact_selection, menu);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
super.onOptionsItemSelected(item);
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.menu_refresh_directory: handleDirectoryRefresh(); return true;
|
|
||||||
case R.id.menu_selection_finished: handleSelectionFinished(); return true;
|
|
||||||
case android.R.id.home: finish(); return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initializeResources() {
|
|
||||||
contactsFragment = (PushContactSelectionListFragment) getSupportFragmentManager().findFragmentById(R.id.contact_selection_list_fragment);
|
|
||||||
contactsFragment.setMultiSelect(true);
|
contactsFragment.setMultiSelect(true);
|
||||||
}
|
|
||||||
|
|
||||||
private void handleSelectionFinished() {
|
action.setImageDrawable(getResources().getDrawable(R.drawable.ic_check_white_24dp));
|
||||||
Intent resultIntent = getIntent();
|
action.setOnClickListener(new View.OnClickListener() {
|
||||||
List<String> selectedContacts = contactsFragment.getSelectedContacts();
|
|
||||||
|
|
||||||
if (selectedContacts != null) {
|
|
||||||
resultIntent.putStringArrayListExtra("contacts", new ArrayList<>(selectedContacts));
|
|
||||||
}
|
|
||||||
|
|
||||||
setResult(RESULT_OK, resultIntent);
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleDirectoryRefresh() {
|
|
||||||
DirectoryHelper.refreshDirectoryWithProgressDialog(this, new DirectoryHelper.DirectoryUpdateFinishedListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdateFinished() {
|
public void onClick(View v) {
|
||||||
contactsFragment.update();
|
Intent resultIntent = getIntent();
|
||||||
|
List<String> selectedContacts = contactsFragment.getSelectedContacts();
|
||||||
|
|
||||||
|
if (selectedContacts != null) {
|
||||||
|
resultIntent.putStringArrayListExtra("contacts", new ArrayList<>(selectedContacts));
|
||||||
|
}
|
||||||
|
|
||||||
|
setResult(RESULT_OK, resultIntent);
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ public class ContactSelectionListAdapter extends CursorAdapter
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View newView(Context context, Cursor cursor, ViewGroup parent) {
|
public View newView(Context context, Cursor cursor, ViewGroup parent) {
|
||||||
return li.inflate(R.layout.push_contact_selection_list_item, parent, false);
|
return li.inflate(R.layout.contact_selection_list_item, parent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -96,7 +96,7 @@ public class ContactSelectionListAdapter extends CursorAdapter
|
|||||||
|
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
holder = new HeaderViewHolder();
|
holder = new HeaderViewHolder();
|
||||||
convertView = li.inflate(R.layout.push_contact_selection_list_header, viewGroup, false);
|
convertView = li.inflate(R.layout.contact_selection_list_header, viewGroup, false);
|
||||||
holder.text = (TextView) convertView.findViewById(R.id.text);
|
holder.text = (TextView) convertView.findViewById(R.id.text);
|
||||||
convertView.setTag(holder);
|
convertView.setTag(holder);
|
||||||
} else {
|
} else {
|
||||||
|
@ -149,7 +149,7 @@ public class ContactsDatabase {
|
|||||||
.withSelection(BaseColumns._ID + " = ?", new String[] {String.valueOf(rowId)})
|
.withSelection(BaseColumns._ID + " = ?", new String[] {String.valueOf(rowId)})
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NonNull Cursor querySystemContacts(String filter) {
|
public @NonNull Cursor querySystemContacts(String filter) {
|
||||||
Uri uri;
|
Uri uri;
|
||||||
|
|
||||||
|