Skip to content

Commit

Permalink
single contact selection
Browse files Browse the repository at this point in the history
  • Loading branch information
mcginty committed Feb 15, 2014
1 parent 9438973 commit 9b41675
Show file tree
Hide file tree
Showing 14 changed files with 576 additions and 50 deletions.
4 changes: 4 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@
android:windowSoftInputMode="stateHidden"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>

<activity android:name=".SingleContactSelectionActivity"
android:label="@string/AndroidManifest__select_contact"
android:windowSoftInputMode="stateHidden"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>

<activity android:name=".PushContactSelectionActivity"
android:label="@string/AndroidManifest__select_contacts"
Expand Down
8 changes: 8 additions & 0 deletions res/drawable/thin_border.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#00ffffff" />
<stroke android:width="1px" android:color="#22000000" />
<corners android:radius="4dp"/>
<padding android:left="4dp" android:top="4dp" android:right="4dp" android:bottom="4dp" />
</shape>
20 changes: 12 additions & 8 deletions res/layout/group_create_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,24 @@
android:layout_height="106dp"
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingLeft="18dp"
android:paddingLeft="14dp"
android:paddingRight="18dp"
android:paddingTop="18dp">
android:paddingTop="14dp">

<ImageView
android:id="@+id/avatar"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginRight="10dp"
android:background="@drawable/thin_border"
android:src="@drawable/icon"/>

<EditText
android:id="@+id/group_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:hint="Group name"
android:hint="@string/GroupCreateActivity_group_name_hint"
android:layout_gravity="center_vertical" />
</LinearLayout>

Expand Down Expand Up @@ -68,8 +69,9 @@
<RelativeLayout
android:id="@+id/push_disabled"
android:layout_width="fill_parent"
android:layout_height="106dp"
android:background="#dd555555"
android:layout_height="wrap_content"
android:minHeight="106dp"
android:background="#aa000000"
android:gravity="center_vertical|center_horizontal"
android:padding="15dp"
android:visibility="gone">
Expand All @@ -78,11 +80,11 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#ff444444"
android:background="#dd222222"
android:textColor="#ffeeeeee"
android:fontFamily="sans-serif-light"
android:padding="8dp"
android:textSize="16dp"
android:textSize="16sp"
android:text="@string/GroupCreateActivity_contacts_dont_support_push" />

</RelativeLayout>
Expand All @@ -91,7 +93,9 @@
<org.thoughtcrime.securesms.components.PushRecipientsPanel
android:id="@+id/recipients"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:paddingLeft="15dp"
android:paddingRight="15dp" />

<ListView
android:id="@+id/selected_contacts_list"
Expand Down
16 changes: 16 additions & 0 deletions res/layout/single_contact_selection_activity.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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="wrap_content"
android:id="@+id/contact_selection_list_fragment"
android:name="org.thoughtcrime.securesms.SingleContactSelectionListFragment">
</fragment>

</LinearLayout>
29 changes: 29 additions & 0 deletions res/layout/single_contact_selection_list_activity.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<EditText android:id="@+id/filter"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Type a name to filter..."
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="7dp"
android:layout_marginBottom="7dp" />

<ListView android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fastScrollEnabled="true" />

<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__no_contacts"
android:textSize="20sp" />

</LinearLayout>
53 changes: 53 additions & 0 deletions res/layout/single_contact_selection_list_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:paddingRight="25dip">

<TextView android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="8dip"
android:layout_marginTop="-8dip"
android:layout_marginLeft="14dip"
android:singleLine="true"
android:ellipsize="marquee"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold"
android:visibility = "gone"
/>

<TextView android:id="@+id/number"
android:visibility = "visible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dip"
android:layout_marginTop="-8dip"
android:layout_marginLeft="14dip"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:singleLine="true"
android:ellipsize="marquee"
android:textAppearance="?android:attr/textAppearanceSmall"
android:fontFamily="sans-serif-light"
/>

<TextView android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/number"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="1dip"
android:layout_marginLeft="14dip"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:singleLine="true"
android:ellipsize="marquee"
android:gravity="center_vertical|left"
android:textAppearance="?android:attr/textAppearanceMedium"
/>

</RelativeLayout>
11 changes: 7 additions & 4 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,9 @@

<!-- GroupCreateActivity -->
<string name="GroupCreateActivity_actionbar_title">New Group</string>
<string name="GroupCreateActivity_group_name_hint">Group Name</string>
<string name="GroupCreateActivity_actionbar_mms_title">New MMS Group</string>
<string name="GroupCreateActivity_contacts_dont_support_push">You have selected contacts that
don\'t support TextSecure groups, so this will be an unencrypted MMS group.
</string>
<string name="GroupCreateActivity_contacts_dont_support_push">You have selected a contact that doesn\'t support TextSecure groups, so this group will be MMS.</string>

<!-- ImportFragment -->
<string name="ImportFragment_import_system_sms_database">Import System SMS Database?</string>
Expand Down Expand Up @@ -377,7 +376,10 @@
<!-- contact_selection_group_activity -->
<!-- contact_selection_list_activity -->
<string name="contact_selection_group_activity__no_contacts">No contacts.</string>
<string name="contact_selection_group_activity__finding_contacts">Finding contacts...</string>
<string name="contact_selection_group_activity__finding_contacts">Finding contacts&#8230;</string>

<!-- single_contact_selection_activity -->
<string name="single_contact_selection_group_activity__filter">Type a name to filter&#8230;</string>

<!-- ContactSelectionListFragment-->
<string name="ContactSelectionlistFragment_select_for">Select for</string>
Expand Down Expand Up @@ -569,6 +571,7 @@
<string name="AndroidManifest__create_passphrase">Create Passphrase</string>
<string name="AndroidManifest__enter_passphrase">Enter Passphrase</string>
<string name="AndroidManifest__select_contacts">Select Contacts</string>
<string name="AndroidManifest__select_contact">Select Contact</string>
<string name="AndroidManifest__textsecure_detected">TextSecure Detected</string>
<string name="AndroidManifest__public_identity_key">Public Identity Key</string>
<string name="AndroidManifest__change_passphrase">Change Passphrase</string>
Expand Down
46 changes: 20 additions & 26 deletions src/org/thoughtcrime/securesms/ConversationActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.thoughtcrime.securesms;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
Expand Down Expand Up @@ -167,13 +166,13 @@ protected void onCreate(Bundle state) {
@Override
protected void onStart() {
super.onStart();

if (!isExistingConversation())
initializeRecipientsInput();
}

@Override
protected void onResume() {
if (recipients == null || recipients.isEmpty())
initializeRecipientsInput();

super.onResume();
dynamicTheme.onResume(this);
dynamicLanguage.onResume(this);
Expand Down Expand Up @@ -207,28 +206,30 @@ public void onActivityResult(int reqCode, int resultCode, Intent data) {
Log.w("ComposeMessageActivity", "onActivityResult called: " + resultCode + " , " + data);
super.onActivityResult(reqCode, resultCode, data);

if (data == null || resultCode != Activity.RESULT_OK)
return;

switch (reqCode) {
case PICK_CONTACT:
List<ContactData> contacts = data.getParcelableArrayListExtra("contacts");

if (contacts != null)
recipientsPanel.addContacts(contacts);

if (resultCode == RESULT_OK) {
List<ContactData> contacts = data.getParcelableArrayListExtra("contacts");
if (contacts != null) {
recipientsPanel.addContacts(contacts);
this.recipients = getRecipients();
}
} else {

This comment has been minimized.

Copy link
@moxie0

moxie0 Feb 15, 2014

Contributor

when can this happen?

This comment has been minimized.

Copy link
@mcginty

mcginty Feb 17, 2014

Author Contributor

Taking care of this today, it's a TODO on my list

Log.w("ConversationActivity", "gonna have a bad time.");
finish();
}
break;
case PICK_IMAGE:
addAttachmentImage(data.getData());
if (data != null && resultCode == RESULT_OK) addAttachmentImage(data.getData());
break;
case PICK_VIDEO:
addAttachmentVideo(data.getData());
if (data != null && resultCode == RESULT_OK) addAttachmentVideo(data.getData());
break;
case PICK_AUDIO:
addAttachmentAudio(data.getData());
if (data != null && resultCode == RESULT_OK) addAttachmentAudio(data.getData());
break;
case PICK_CONTACT_INFO:
addContactInfo(data.getData());
if (data != null && resultCode == RESULT_OK) addContactInfo(data.getData());
break;
}
}
Expand Down Expand Up @@ -649,16 +650,9 @@ private void initializeResources() {
}

private void initializeRecipientsInput() {
recipientsPanel.setVisibility(View.VISIBLE);

if (this.recipients != null) {
recipientsPanel.addRecipients(this.recipients);
} else {
InputMethodManager input = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
input.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0);
}
Intent intent = new Intent(ConversationActivity.this, SingleContactSelectionActivity.class);
startActivityForResult(intent, PICK_CONTACT);
}

private void initializeReceivers() {
securityUpdateReceiver = new BroadcastReceiver() {
@Override
Expand Down Expand Up @@ -846,7 +840,7 @@ private Recipients getRecipients() {
if (isExistingConversation()) return this.recipients;
else return recipientsPanel.getRecipients();
} catch (RecipientFormattingException rfe) {
Log.w("ConversationActivity", rfe);
Log.d("ConversationActivity", "Empty list of recipients retrieved from RecipientsPanel.");
return null;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/org/thoughtcrime/securesms/GroupCreateActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { }
@Override
public void afterTextChanged(Editable editable) {
if (editable.length() > 0)
getSupportActionBar().setTitle(editable);
getSupportActionBar().setTitle(getString(R.string.GroupCreateActivity_actionbar_title) + ": " + editable.toString());
else
getSupportActionBar().setTitle(R.string.GroupCreateActivity_actionbar_title);
}
Expand Down

0 comments on commit 9b41675

Please sign in to comment.