From 1ac1cec634a9696cff025b43931e2b96c212b50a Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Thu, 19 Jul 2012 15:16:07 -0700 Subject: [PATCH] Update look for RecipientsPanel. 1) Make the "add contacts" graphic more holo-ific. 2) Adjust the graphic position on holo-themed devices. --- .../ic_menu_add_field_holo_light.png | Bin 0 -> 1354 bytes .../ic_menu_add_field_holo_light.png | Bin 0 -> 909 bytes .../ic_menu_add_field_holo_light.png | Bin 0 -> 1787 bytes res/layout/recipients_panel.xml | 16 ++-- .../securesms/components/RecipientsPanel.java | 73 ++++++++++-------- 5 files changed, 47 insertions(+), 42 deletions(-) create mode 100644 res/drawable-hdpi/ic_menu_add_field_holo_light.png create mode 100644 res/drawable-mdpi/ic_menu_add_field_holo_light.png create mode 100644 res/drawable-xhdpi/ic_menu_add_field_holo_light.png diff --git a/res/drawable-hdpi/ic_menu_add_field_holo_light.png b/res/drawable-hdpi/ic_menu_add_field_holo_light.png new file mode 100644 index 0000000000000000000000000000000000000000..4ef604aa36d285e1a4fc47b2a595b08545eee2c7 GIT binary patch literal 1354 zcmV-Q1-1H#P)hm0g*f}ZT5dI?%G zD0?Z0dg>u6Ov(rQUuJ}&=|h;i)xHF!X4|g0Gxz>_xOZk}W@mOQ>!th+4EO%-Ip=%+ z{mwZ*&aeOcie@IMOw!h=gOEQAo*O_zbS#z%xxh-!m&jx@!$dO*Ph^F@b1cw1?bs($x)H8NZ+A;X& z02<;`i#%t8Ao8QVK6l)&xX@y&tZ}IzvdhDUCEXyRX~YkB%_TVOX}g`S3n(b&S?@8+ zal*ac?FJEb6~Ec5%0@lzMQ7!i6dGK42KCtL33E-j&+DBb;tp<0q;B-GvJnGzs7gdK zHEHpy$wU%WI}8|6_L5an$qX^5gRl*Jb8vIas%Qw;_pjh?^~FEde#G#QVnbtgcKd z5X%bfV?>QFxziHAd0)Skg_Mo}kzkHxIMfJZHYGw-5eBnK#!8;p--P5x&gpN$~alP&GxBFRSVbTrMYa6Q0!zb zaM*RK;1tT{`=OhQawjw&l}L|RxvgTA8&4TcUjstD0d)chIBi17{9@;f+m(wr#Ll?J zORDbiy`IMISfM``W5O?5&U3p3C!8?H;v&eYFB^f3i`JRiZ$vcMB%}y(KTb5<+r@%$ zM_q1t5oF>IE;UWR1kg3f|>7YJ55iN^167XN_KCqUL0*)P0`+XDweMsb05Y ze<7u@T1!QScU1LTkEFG#bY7L*I_|Jo>OExLOGSpSe1r!T$7%{hm?A!>+=>r;fvkJ6 z%XN7Ht8Eo>2R4yMT3S@4?%3b~s|(I#`i7H=yya~?X@y!FM9rwtdiiLGuUX+KyzMPf z`#I>`G8frvk#DT^eM`$s^a{or6)JC;3+-{0A-5Tx+A=#$6?xO&qt`KaIV=`6#>ZyP zSddxn4NHt!>$AK9&pcJ65}(;(!crgEW|mYCD@lr9Ni0asvdxE_5NE^t%afRvt z^S3U6=hy#W{Q>1Ho4aiD(Aoe103~!qSaf7zbY(hYa%Ew3WdJfTF)%GLF)cDOR53R? zF)}(eGc7PUIxsNQf@ZA%001R)MObuXVRU6WZEs|0W_bWIFflMKF)=MNGE^})Ix#Xj zH8U+RI65#erQhBW0000PbVXQnQ*UN;cVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBUy M07*qoM6N<$g0I16!2kdN literal 0 HcmV?d00001 diff --git a/res/drawable-mdpi/ic_menu_add_field_holo_light.png b/res/drawable-mdpi/ic_menu_add_field_holo_light.png new file mode 100644 index 0000000000000000000000000000000000000000..fbb1a7a95a1b5b14a37fd8bd17acafd0e4283240 GIT binary patch literal 909 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE0wix1Z>k4UOiAAEE)4(M`_JqL@;D1TB8!2v z2N=7Z%(epwmK8Xr18D^?ZvQoBE>PQ4PZ!4!kK;$L`ew+6im-pUKi7Qeqh+;IHQZt| zS2)GKIA$O)Wf6Db(g%LAyR>yBw=`)+Tyk<)wq?ha-b=k4UDD!8f!d!Q`NehwISMRV z@SywtmdfJw-81)?>wD(DTvqW2??2s}_s~oF>9)$!w+w5u)F!L2IEs|F zbMDsqu2QHJXV&1jS6JmuK>oSMb^bHVo8#C1Ja9edX2@H<3#-zzxZ}PGwACG2W4G@^ z)A=t)GCOi+TX{ZhYWA~AIks?{{mTX1tENrnJNnbiZ<4v~YhCwTj!>r3pS|I8O3y8l zJntL7+uSvH)0+-qvDiu6u3C9opOTg=e;)sSrR?PBsh+I|zleTuY1gehthqBmO6)iy+8Ri=6swTBlBC`ueaDa zT|{n5%2SpFS^xSU#=1oQHqFcZ<)gMus9$OIG98Z@<|TrjYZgVhg!G3mYUyr!Hu03E zx!Rei?VYpt#@3DXOz`}6>xSY@ zMvfmhmA~Eivc1*Ib3)C_a{kvVZ;O80aryXUl^aTi3BLDZCi|skusXedk*1n(t}dJ7 zvWi+>$P_ka5-ddPAgTP*x5 zEF+oW-86y`Xr_u4P@@)4xYbBFCJiBB{xV!=^(+*p{{}I+ZuiEzQiofTyma6e> z%er*c>z38KANwbjZCzBQUAObtBCEC?|2EmN7S-~f=9^Kt`_kpI$G7Wkgun3ISij&4 zFr})NxJHzuB$lLFB^RXvDF!10LjzqyLtP`I5JPh-LnA9wV_gFaD+7ZoO=)XUH00)| zWTsW(*0A*cJwc!bNstY}`DrEPiAAXljw$&`sS2LCiRr09sfj6-g(p*OfQlGAUHx3v IIVCg!0Be_sSpWb4 literal 0 HcmV?d00001 diff --git a/res/drawable-xhdpi/ic_menu_add_field_holo_light.png b/res/drawable-xhdpi/ic_menu_add_field_holo_light.png new file mode 100644 index 0000000000000000000000000000000000000000..13282900c94f42edd74eb0258bfa6566a921fdc5 GIT binary patch literal 1787 zcmZ{lSvcDX7smgp8q27iqEsnuheTqlrAuO8rYIuztrFYBn#R^OMp0`^hzv6Z6?;|H zUa>bsWe8QIsIjy{r7f|WPkZ-W%*Ffuo^zh_KIiV76nk3>VL>@T004xoEKMDb2>&kr z<3|qov>=cCn4gV>De!Mn<`DI$5(u|+jXI*`519{yT>aj}ha&=x2>+p#Z`(cqaDv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5$(!UEnq3JpRz|%zyc5dYyx&}EzR1dKrDMk-y*uix%C+Y`pz-R@4@a1_nNtHF zt((|;5B8~tzOWy+SN}jH$jP8Fmw)N|Ur@!Fx#0YLacIMvk?11;T2L4a4Alc`={v!o zhPwKOFfB0jk|7k@oV#uDe*tWme-I}2zXJnw_})=K_WK6MFbpo*HxdmX{KNdvN>*6k a0JH - + - + android:layout_width="fill_parent"/> + - + \ No newline at end of file diff --git a/src/org/thoughtcrime/securesms/components/RecipientsPanel.java b/src/org/thoughtcrime/securesms/components/RecipientsPanel.java index 23a46ac91..a9f1c49f8 100644 --- a/src/org/thoughtcrime/securesms/components/RecipientsPanel.java +++ b/src/org/thoughtcrime/securesms/components/RecipientsPanel.java @@ -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 . */ 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 recipientList = recipients.getRecipientsList(); Iterator 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); }