Update look for RecipientsPanel.

1) Make the "add contacts" graphic more holo-ific.
2) Adjust the graphic position on holo-themed devices.
This commit is contained in:
Moxie Marlinspike 2012-07-19 15:16:07 -07:00
parent b377fe84df
commit 1ac1cec634
5 changed files with 47 additions and 42 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 909 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -10,7 +10,7 @@
android:paddingRight="5dip"
android:background="@drawable/white_background"
android:orientation="vertical" >
<org.thoughtcrime.securesms.contacts.RecipientsEditor android:id="@+id/recipients_text"
android:layout_height="wrap_content"
android:capitalize="sentences"
@ -18,17 +18,17 @@
android:singleLine="true"
android:hint="To"
android:paddingRight="45dip"
android:layout_width="fill_parent"/>
android:layout_width="fill_parent"/>
<ImageButton android:id="@+id/contacts_button"
android:background="#00000000"
android:layout_width="40dip"
android:layout_height="35dip"
android:background="#00000000"
android:layout_width="40dip"
android:layout_height="35dip"
android:layout_marginRight="5dip"
android:layout_marginTop="4dip"
android:src="@drawable/ic_add"
android:src="@drawable/ic_menu_add_field_holo_light"
android:layout_alignRight="@id/recipients_text"
android:maxWidth="32dip"
android:maxHeight="32dip" />
</RelativeLayout>

View File

@ -1,6 +1,6 @@
/**
/**
* Copyright (C) 2011 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
@ -10,15 +10,18 @@
* 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.components;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RelativeLayout;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.contacts.RecipientsAdapter;
@ -28,27 +31,24 @@ import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.recipients.RecipientFormattingException;
import org.thoughtcrime.securesms.recipients.Recipients;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RelativeLayout;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
/**
* Panel component combining both an editable field with a button for
* Panel component combining both an editable field with a button for
* a list-based contact selector.
*
*
* @author Moxie Marlinspike
*/
public class RecipientsPanel extends RelativeLayout {
public class RecipientsPanel extends RelativeLayout {
private RecipientsPanelChangedListener panelChangeListener;
private RecipientsEditor recipientsText;
private View panel;
private static final int RECIPIENTS_MAX_LENGTH = 312;
public RecipientsPanel(Context context) {
super(context);
initialize();
@ -63,37 +63,37 @@ public class RecipientsPanel extends RelativeLayout {
super(context, attrs, defStyle);
initialize();
}
public void addRecipient(String name, String number) {
if (name != null) recipientsText.append(name + "< " + number + ">, ");
else recipientsText.append(number + ", ");
}
public void addRecipients(Recipients recipients) {
List<Recipient> recipientList = recipients.getRecipientsList();
Iterator<Recipient> iterator = recipientList.iterator();
while (iterator.hasNext()) {
Recipient recipient = iterator.next();
addRecipient(recipient.getName(), recipient.getNumber());
}
}
public Recipients getRecipients() throws RecipientFormattingException {
String rawText = recipientsText.getText().toString();
Recipients recipients = RecipientFactory.getRecipientsFromString(getContext(), rawText);
if (recipients.isEmpty())
throw new RecipientFormattingException("Recipient List Is Empty!");
return recipients;
return recipients;
}
public void disable() {
recipientsText.setText("");
panel.setVisibility(View.GONE);
panel.setVisibility(View.GONE);
}
public void setPanelChangeListener(RecipientsPanelChangedListener panelChangeListener) {
this.panelChangeListener = panelChangeListener;
}
@ -101,15 +101,20 @@ public class RecipientsPanel extends RelativeLayout {
private void initialize() {
LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.recipients_panel, this, true);
panel = findViewById(R.id.recipients_panel);
initRecipientsEditor();
View imageButton = findViewById(R.id.contacts_button);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
((MarginLayoutParams) imageButton.getLayoutParams()).topMargin = 0;
panel = findViewById(R.id.recipients_panel);
initRecipientsEditor();
}
private void initRecipientsEditor() {
Recipients recipients = null;
recipientsText = (RecipientsEditor)findViewById(R.id.recipients_text);
try {
recipients = getRecipients();
} catch (RecipientFormattingException e) {
@ -120,7 +125,7 @@ public class RecipientsPanel extends RelativeLayout {
recipientsText.populate(recipients);
recipientsText.setOnFocusChangeListener(new FocusChangedListener());
}
private class FocusChangedListener implements View.OnFocusChangeListener {
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus && (panelChangeListener != null)) {
@ -132,7 +137,7 @@ public class RecipientsPanel extends RelativeLayout {
}
}
}
public interface RecipientsPanelChangedListener {
public void onRecipientsPanelUpdate(Recipients recipients);
}