From 3e2bdacf896c4944ae8cd8a4543030a538414a9b Mon Sep 17 00:00:00 2001 From: str4d <str4d@mail.i2p> Date: Sun, 9 Nov 2014 12:13:32 +0000 Subject: [PATCH] Material design: I2PTunnel list --- .../i2p/android/i2ptunnel/TunnelEntry.java | 25 ++++-- .../android/i2ptunnel/TunnelEntryAdapter.java | 14 ++-- .../drawable-hdpi/ic_schedule_black_24dp.png | Bin 0 -> 650 bytes .../drawable-mdpi/ic_schedule_black_24dp.png | Bin 0 -> 454 bytes .../drawable-xhdpi/ic_schedule_black_24dp.png | Bin 0 -> 832 bytes .../ic_schedule_black_24dp.png | Bin 0 -> 1183 bytes .../main/res/layout/listitem_i2ptunnel.xml | 74 +++++++++++------- app/src/main/res/values/dimens.xml | 11 ++- app/src/main/res/values/styles.xml | 10 +++ 9 files changed, 90 insertions(+), 44 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/ic_schedule_black_24dp.png create mode 100644 app/src/main/res/drawable-mdpi/ic_schedule_black_24dp.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_schedule_black_24dp.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_schedule_black_24dp.png diff --git a/app/src/main/java/net/i2p/android/i2ptunnel/TunnelEntry.java b/app/src/main/java/net/i2p/android/i2ptunnel/TunnelEntry.java index ab00a64cf..d2e1d982d 100644 --- a/app/src/main/java/net/i2p/android/i2ptunnel/TunnelEntry.java +++ b/app/src/main/java/net/i2p/android/i2ptunnel/TunnelEntry.java @@ -209,16 +209,29 @@ public class TunnelEntry { public Drawable getStatusIcon() { switch (getStatus()) { case STANDBY: - case STARTING: return mContext.getResources() - .getDrawable(R.drawable.local_inprogress); + .getDrawable(R.drawable.ic_schedule_black_24dp); + case STARTING: case RUNNING: - return mContext.getResources() - .getDrawable(R.drawable.local_up); case NOT_RUNNING: default: - return mContext.getResources() - .getDrawable(R.drawable.local_down); + return null; + } + } + + public Drawable getStatusBackground() { + switch (getStatus()) { + case STANDBY: + case STARTING: + return mContext.getResources() + .getDrawable(R.drawable.tunnel_yellow); + case RUNNING: + return mContext.getResources() + .getDrawable(R.drawable.tunnel_green); + case NOT_RUNNING: + default: + return mContext.getResources() + .getDrawable(R.drawable.tunnel_red); } } } diff --git a/app/src/main/java/net/i2p/android/i2ptunnel/TunnelEntryAdapter.java b/app/src/main/java/net/i2p/android/i2ptunnel/TunnelEntryAdapter.java index fe8461723..b1139969d 100644 --- a/app/src/main/java/net/i2p/android/i2ptunnel/TunnelEntryAdapter.java +++ b/app/src/main/java/net/i2p/android/i2ptunnel/TunnelEntryAdapter.java @@ -33,21 +33,19 @@ public class TunnelEntryAdapter extends ArrayAdapter<TunnelEntry> { View v = mInflater.inflate(R.layout.listitem_i2ptunnel, parent, false); TunnelEntry tunnel = getItem(position); + ImageView status = (ImageView) v.findViewById(R.id.tunnel_status); + status.setImageDrawable(tunnel.getStatusIcon()); + status.setBackground(tunnel.getStatusBackground()); + TextView name = (TextView) v.findViewById(R.id.tunnel_name); name.setText(tunnel.getName()); - TextView type = (TextView) v.findViewById(R.id.tunnel_type); - type.setText(tunnel.getType()); + TextView type = (TextView) v.findViewById(R.id.tunnel_description); + type.setText(tunnel.getDescription()); TextView ifacePort = (TextView) v.findViewById(R.id.tunnel_interface_port); ifacePort.setText(tunnel.getIfacePort()); - TextView details = (TextView) v.findViewById(R.id.tunnel_details); - details.setText(tunnel.getDetails()); - - ImageView status = (ImageView) v.findViewById(R.id.tunnel_status); - status.setImageDrawable(tunnel.getStatusIcon()); - return v; } } diff --git a/app/src/main/res/drawable-hdpi/ic_schedule_black_24dp.png b/app/src/main/res/drawable-hdpi/ic_schedule_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..3bc6860f5bb9046462cbb220edb9ab6ce42e42e8 GIT binary patch literal 650 zcmV;50(Jd~P)<h;3K|Lk000e1NJLTq001Na001Ni1ONa4O9@aD0000WV@Og>004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00002VoOIv0RM-N%)bBt010qN zS#tmY3ljhU3ljkVnw%H_00II@L_t(Y$K_T@FGEoj{_;8qYFLqO_ycxU7E-AxK}jvF z{0E^Cq9MixJ86@KNW|U(weSm2B-O#v(BOYKy**yM_wIeemUA~R=X~eOxo5f$_=gg} zC{nmW8C5zZ<gkSy_`Q*|VF}OplAJOY(BhV6n&4kH=Ls=q5<m8JhZ~BkA02eb06OVw z8F#vE2R=I*AC4J#i*aZcyGF6(8F6Swwa1_XG%7JoNHZ#>g2WlH;+TLnM#kioDsePM z=|ciD7IcQwE~(%m=f-@g1ZmGK=w{pt{JgdOD#9>fagh@NQ`}dk79HV&Yp#hjuHT?h zy(5%M5(gC#s3<j`O`|d=l>MHFBEsjwsH|74!xK?h_!N!Gs!#?z5e0?MyBDHI^tdIe zU#(LDAIB?MKCp{+H&;_98|cQVuvRc@XpaF|vbTkDSvg%p)MGWoHF|YjQfM}ez+s`h zlQiUyG|)J_5ayHP_VJKJ%_CA)&$BLFIH8!dU%R4Y-Qo#h$kV>Dm-@VisFF4OoD5JD zrnIZQo)y>v5lSS+>uS}JW}T5^DnN<>8QM2032`)*aWyXgBL>~mzR@K1I35_0wW+Xx z?&?oYo)$%f`Zq`?OzoHCg4d(boD(_8X;+<sIyYu%rDl-7wnZv<$lLqxr?J?=CAq%i kjoyoM8iuIXpNKyp-$)w-VQk%E@&Et;07*qoM6N<$f@!`I3;+NC literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/ic_schedule_black_24dp.png b/app/src/main/res/drawable-mdpi/ic_schedule_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..b3e28319cc01a64f3671839e5da44c702ec5ee5e GIT binary patch literal 454 zcmV;%0XhDOP)<h;3K|Lk000e1NJLTq000;O000;W1ONa4N`Cco0000WV@Og>004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00002VoOIv0RM-N%)bBt010qN zS#tmY3ljhU3ljkVnw%H_00BNpL_t(I%e~aWPE$b?#_``JwC;Qa69^=}fx$H!jYd*g zXwn9F1mhEkfv|N+CGj;R4O_tqnz(OEO}_VVq2~79Tkn!Ht8-@lXTF&^XSi#-XV;l; z=H|W{>glvC-|<6g<Jz<3i&vb8IM=tPqhsB`NW_tqCU7DqUe}_9zNt8BiiwFwOZVO~ zm8!6=?^4MgZx_6QxL!Q|t~jq`tpbIS=#_yp(Qg6R6T{LSi?vo@LtK^aTxt(g2fE_6 z9r*0w|ADbsuK?S=_~pI(fBj8ySx$cxgGN=oG4azYa3D_0$(LfJXgt{ipL{^!LhLLm zylGtQKU>AV7*|jETuf~(MIM`pr}gl$nCjPr752@<;j;2R7BRACLs!?P0~aFREi3Oo w!fqN3H1?#e=el}^uH2frbn1oGyZ$A915c!L>(^_ok^lez07*qoM6N<$f^Qwh7XSbN literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_schedule_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_schedule_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..8902009996b9fe081580701e115e72f4f54de538 GIT binary patch literal 832 zcmV-G1Hb%<P)<h;3K|Lk000e1NJLTq001xm001xu1ONa4{R=S+0000WV@Og>004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00002VoOIv0RM-N%)bBt010qN zS#tmY3ljhU3ljkVnw%H_00Ov4L_t(o!|j(#PZLoXh97$YY2u}&X}m00DlyRtiNC<O zF(E8W2u&BRBvi^q6TGoeVv3iQflwsTl*IpFYH^{Is3=jWSXA0t`#)T8<}h{U%$#XA zns8>-zVCUzIp6Jk1AFU#Sbq8$XMxw0s8OTD5>FZ9EWY-|k2A>{4aKv{O^&oK9_0}= zrMU4_$q;Tu{t}z6;>NSVfH&~~kDCO_%#a{Xm>@wS#7Qtqxrvh@perBZg=ym(hS+b* z>tdK?6EmmaS>AqE{wE_Y?-gK_ZIcO&Q|vnDEhn^2+)L5qDA&*$)R%O7$hW-QH{eX% zlyBedF{O=DtaDgRdniah6wcW}RgN-ZabI1vMp=z07)}NtCGd)>y6?!u3^*A0?T}H1 zn{L>_K0XO}NGaiL01`ss1N*FCzW~2El#82z5L-eeZUx5$G~*!9ph4X+o92Ydm=#(O zP@*jZNue@tg_hKZYclZ5(LkS2DOjPBfWmDVh{|%aETaa3Z5im0*HFs_>YQoKfZ?Ku zi-87p9w=E3F476|d0DGpxs2aikaf}&I=LpBTAp)W(ljlgS=ZLwLr!-8C&ZettoZ+` z`fz2sH2VJqRwVz5sa1SeJKD!b0S;?jF`Zl&&YH3~=)GODgWCdL)*e85$g#!&@hd1( zV8Wh$OxD7vhs!c%iDKoixR_Q(jw>fUPlBhYh~4+pq=+oHB2iEBF&XqP9C9KK$^^`N zFcIUG+;`E9JT0k3dNrN1BKJ(`jE;+vzD>#{qk^QR?;AX~Z67v6?V@R<Es`LlxPg<V zp|Qa;z2SG~6w^(k`4)2|=_5)99YpCPNmf>^kvo2GX*bA*_6Nvk_t4s{Fd3?@;uY?4 zu=Ve>qugRuDgKTLb=B%GA92#mQ(%KC71k+`CB<p`mbSP4we<%TtIujgEy>aV0000< KMNUMnLSTZVXLR=f literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_schedule_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_schedule_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..4485fdba622d7bf850320632bcf152e371037aaa GIT binary patch literal 1183 zcmV;Q1YrA#P)<h;3K|Lk000e1NJLTq002k;002k`1ONa4|Kxkj0000WV@Og>004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00002VoOIv0RM-N%)bBt010qN zS#tmY3ljhU3ljkVnw%H_00b9FL_t(&-tC!NPgGYF$A6+TIE*F~3(*G)FFsVGNVFHV z0+}{7Q6K6zFbLYJRBe++4Y7?zBsEdA(x5>xUZM$t7sSNNlM*RvG!`bUF(Me}d-&p{ zd+jsloPEwdr}1Idewxg>{Lfx%ueJ8tP^2Oi=|iP78Fp}-As&%sib=AJGDs(_)RX!@ zp;Yk$*O?;cu_o!KnK|);`HBm?@r0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 z2365z0p=}7<9MN7Dax+->NBrd!D$8Od|vEjn&@E}u~Q{23^3^lWr997hJQN@Ln#_) xrISJaVw_1{GsXzlIl@*}QA&}DRHP4--T?y-5*Tr)>(BrI002ovPDHLkV1oAA8;k$| literal 0 HcmV?d00001 diff --git a/app/src/main/res/layout/listitem_i2ptunnel.xml b/app/src/main/res/layout/listitem_i2ptunnel.xml index 529bd69f5..afb819226 100644 --- a/app/src/main/res/layout/listitem_i2ptunnel.xml +++ b/app/src/main/res/layout/listitem_i2ptunnel.xml @@ -1,49 +1,65 @@ <?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="wrap_content" - android:padding="5dp" > + android:layout_height="@dimen/listitem_height_two_lines" + android:paddingEnd="@dimen/listitem_horizontal_margin" + android:paddingRight="@dimen/listitem_horizontal_margin"> - <!-- The name of the tunnel --> - <TextView android:id="@+id/tunnel_name" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:padding="3dp" - android:textSize="16sp" + <!-- Tunnel status --> + <ImageView + android:id="@+id/tunnel_status" + android:layout_width="@dimen/listitem_icon_size" + android:layout_height="@dimen/listitem_icon_size" android:layout_alignParentLeft="true" - android:layout_marginRight="5dp" - android:text="Tunnel name" /> - - <!-- The type of tunnel --> - <TextView android:id="@+id/tunnel_type" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:layout_below="@id/tunnel_name" - android:text="Tunnel type" /> + android:layout_alignParentStart="true" + android:layout_centerVertical="true" + android:layout_marginLeft="@dimen/listitem_horizontal_margin" + android:layout_marginStart="@dimen/listitem_horizontal_margin" + android:contentDescription="Status" /> - <!-- Additional tunnel details --> - <TextView android:id="@+id/tunnel_details" + <!-- The name of the tunnel --> + <TextView + android:id="@+id/tunnel_name" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_below="@id/tunnel_type" - android:text="Tunnel details" /> + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" + android:layout_marginLeft="@dimen/listitem_text_left_margin" + android:layout_marginStart="@dimen/listitem_text_left_margin" + android:layout_marginTop="@dimen/listitem_text_top_margin_two_lines" + android:text="Tunnel name" + android:textAppearance="@style/TextAppearance.AppCompat.Primary" /> <!-- Interface:port the tunnel listens on or points to --> - <TextView android:id="@+id/tunnel_interface_port" + <TextView + android:id="@+id/tunnel_interface_port" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_toRightOf="@id/tunnel_name" + android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_alignTop="@id/tunnel_name" + android:layout_marginLeft="4dp" + android:layout_marginStart="4dp" + android:layout_toEndOf="@id/tunnel_name" + android:layout_toRightOf="@id/tunnel_name" + android:ellipsize="start" android:gravity="right" - android:text="Interface:port" /> + android:maxLines="1" + android:text="Interface:port" + android:textAppearance="@style/TextAppearance.AppCompat.Secondary" /> - <!-- Status star --> - <ImageView android:id="@+id/tunnel_status" + <!-- The tunnel description --> + <TextView + android:id="@+id/tunnel_description" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_alignParentRight="true" - android:layout_centerVertical="true" - android:contentDescription="Status" /> + android:layout_alignLeft="@+id/tunnel_name" + android:layout_alignParentBottom="true" + android:layout_alignStart="@+id/tunnel_name" + android:layout_marginBottom="@dimen/listitem_text_bottom_margin_two_lines" + android:ellipsize="end" + android:maxLines="1" + android:text="Tunnel description" + android:textAppearance="@style/TextAppearance.AppCompat.Secondary" /> </RelativeLayout> diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 519f42f86..e3b9befac 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -6,13 +6,22 @@ <dimen name="nav_horizontal_margin">16dp</dimen> <dimen name="nav_entry_height">48dp</dimen> + <dimen name="text_size_primary">16sp</dimen> + <dimen name="text_size_secondary">14sp</dimen> + <dimen name="list_vertical_padding">8dp</dimen> - <dimen name="listitem_height_one_line">56dp</dimen> <dimen name="listitem_horizontal_margin">16dp</dimen> <dimen name="listitem_picture_size">40dp</dimen> + <dimen name="listitem_icon_size">24dp</dimen> <dimen name="listitem_text_left_margin">72dp</dimen> <dimen name="listitem_icon_left_margin">8dp</dimen> + <dimen name="listitem_height_one_line">56dp</dimen> + + <dimen name="listitem_height_two_lines">72dp</dimen> + <dimen name="listitem_text_top_margin_two_lines">16dp</dimen> + <dimen name="listitem_text_bottom_margin_two_lines">18dp</dimen> + <dimen name="tunnel_indicator">20dp</dimen> <dimen name="step_pager_tab_width">32dp</dimen> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 67eaeb7fe..693c62875 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -19,6 +19,16 @@ <!-- The rest of your attributes --> </style> + <style name="TextAppearance.AppCompat.Primary" parent="TextAppearance.AppCompat.Body1"> + <item name="android:textColor">@color/primary_text_default_material_dark</item> + <item name="android:textSize">@dimen/text_size_primary</item> + </style> + + <style name="TextAppearance.AppCompat.Secondary" parent="TextAppearance.AppCompat.Body1"> + <item name="android:textColor">@color/secondary_text_default_material_dark</item> + <item name="android:textSize">@dimen/text_size_secondary</item> + </style> + <style name="WizardPageContainer"> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">match_parent</item> -- GitLab