Skip to content

Commit

Permalink
[HeadsUp] Redesign notification widget
Browse files Browse the repository at this point in the history
  • Loading branch information
AChep committed Sep 12, 2014
1 parent 9a658ab commit 3d7e905
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
public class NotificationWidget extends RelativeLayout implements NotificationView {

private NotificationIcon mIcon;
private NotificationIcon mSmallIcon;
private TextView mTitleTextView;
private TextView mMessageTextView;
private TextView mWhenTextView;
Expand Down Expand Up @@ -150,6 +151,7 @@ protected void onFinishInflate() {

mContent = (ViewGroup) findViewById(R.id.content);
mIcon = (NotificationIcon) findViewById(R.id.icon);
mSmallIcon = (NotificationIcon) findViewById(R.id.icon_small);
mTitleTextView = (TextView) findViewById(R.id.title);
mMessageTextView = (TextView) findViewById(R.id.message);
mWhenTextView = (TextView) findViewById(R.id.when);
Expand Down Expand Up @@ -208,8 +210,17 @@ public void setNotification(OpenNotification osbn) {
// and set large icon.
mIcon.setNotification(null);
mIcon.setImageBitmap(bitmap);
if (mSmallIcon != null) {
mSmallIcon.setNotificationIndicateReadStateEnabled(false);
mSmallIcon.setNotification(osbn);
mSmallIcon.setVisibility(View.VISIBLE);
}
} else {
mIcon.setNotification(osbn);
if (mSmallIcon != null) {
mSmallIcon.setNotification(null);
mSmallIcon.setVisibility(View.GONE);
}
}

updateActionButtons(osbn);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions project/app/src/main/res/drawable/bg_heads_up_icon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
~ Copyright (C) 2014 AChep@xda <[email protected]>
~
~ 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 2
~ 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, write to the Free Software
~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
~ MA 02110-1301, USA.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">

<solid android:color="#ccc" />
</shape>
82 changes: 47 additions & 35 deletions project/app/src/main/res/layout/heads_up_notification.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,65 +30,77 @@
android:divider="?android:dividerVertical"
android:dividerPadding="12dp"
android:orientation="horizontal"
android:visibility="gone"
android:showDividers="middle" />

<RelativeLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/actions"
android:background="?android:listChoiceBackgroundIndicator"
android:orientation="vertical"
android:padding="8dp">
android:minHeight="72dp">

<TextView
android:id="@+id/subtext"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="gone" />

<com.achep.acdisplay.widgets.NotificationIcon
android:id="@+id/icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginEnd="4dp"
android:layout_marginRight="4dp"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="16dp"
android:scaleType="centerInside" />

<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="-3dp"
android:layout_marginTop="-2dp"
android:layout_toEndOf="@id/icon"
android:layout_toRightOf="@id/icon"
android:minHeight="24dp"
style="@style/HeadsUp_Notification_Title"
android:text="Title text"
android:textAlignment="viewStart" />
<com.achep.acdisplay.widgets.NotificationIcon
android:id="@+id/icon_small"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignBottom="@+id/icon"
android:layout_alignEnd="@+id/icon"
android:layout_alignRight="@+id/icon"
android:layout_marginBottom="-6dp"
android:layout_marginEnd="-6dp"
android:layout_marginRight="-6dp"
android:padding="4dp"
android:background="@drawable/bg_heads_up_icon"
android:scaleType="centerInside" />

<TextView
android:id="@+id/when"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:layout_toEndOf="@id/icon"
android:layout_toRightOf="@id/icon"
style="@style/HeadsUp_Notification_Subtext"
android:text="Title text" />
android:layout_height="36dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:paddingBottom="4dp"
android:gravity="bottom"
style="@style/HeadsUp_Notification_Subtext" />

<TextView
android:id="@+id/subtext"
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_toEndOf="@id/when"
android:layout_toRightOf="@id/when"
style="@style/HeadsUp_Notification_Subtext" />
android:layout_height="36dp"
android:layout_toEndOf="@id/icon"
android:layout_toRightOf="@id/icon"
android:layout_toStartOf="@id/when"
android:layout_toLeftOf="@id/when"
android:textAlignment="viewStart"
android:gravity="bottom"
style="@style/HeadsUp_Notification_Title" />

<TextView
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/when"
android:layout_marginTop="4dp"
android:layout_below="@id/title"
android:layout_toEndOf="@id/icon"
android:layout_toRightOf="@id/icon"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:textAlignment="viewStart"
style="@style/HeadsUp_Notification_Message"/>

Expand Down
11 changes: 8 additions & 3 deletions project/app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@
<color name="primary_color_600">#546e7a</color>
<color name="primary_color_900">#263238</color>

<!-- Material design: text colors -->
<color name="material_primary_text_color_dark">#DD000000</color>
<color name="material_secondary_text_color_dark">#89000000</color>
<color name="material_hint_text_color_dark">#42000000</color>

<!-- Heads-up -->
<color name="heads_up_primary_text_color">#000</color>
<color name="heads_up_secondary_text_color">#333</color>
<color name="heads_up_third_text_color">#555</color>
<color name="heads_up_primary_text_color">@color/material_primary_text_color_dark</color>
<color name="heads_up_secondary_text_color">@color/material_primary_text_color_dark</color>
<color name="heads_up_third_text_color">@color/material_secondary_text_color_dark</color>
</resources>
6 changes: 4 additions & 2 deletions project/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
<item name="android:fontFamily">sans-serif-condensed</item>
<item name="android:textAppearance">?android:textAppearanceLarge</item>
<item name="android:textColor">@color/heads_up_primary_text_color</item>
<item name="android:maxLines">2</item>
<item name="android:maxLines">1</item>
<item name="android:ellipsize">end</item>
</style>

<style name="HeadsUp_Notification_Subtext">
Expand All @@ -53,7 +54,8 @@

<style name="HeadsUp_Notification_Message">
<item name="android:textColor">@color/heads_up_secondary_text_color</item>
<item name="android:maxLines">3</item>
<item name="android:maxLines">4</item>
<item name="android:ellipsize">end</item>
</style>

</resources>

0 comments on commit 3d7e905

Please sign in to comment.