Skip to content

Commit

Permalink
- improved quick add dialog theming
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias committed Feb 26, 2015
1 parent d76ae5b commit 1602ba6
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 54 deletions.
48 changes: 6 additions & 42 deletions res/layout/fragment_quick_add_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,15 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@android:color/white"
android:orientation="vertical"
android:padding="0dp" >

<LinearLayout
android:id="@+id/color_background"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<TextView
android:id="@android:id/title"
style="@style/dialog_text_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:gravity="center_vertical"
android:padding="8dp"
android:text="@string/menu_add_task"
android:textColor="@android:color/white" />

<ImageView
android:id="@android:id/edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:padding="8dp"
android:src="@drawable/content_edit" />
</LinearLayout>

<Spinner
android:id="@+id/task_list_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:spinnerMode="dropdown" />
</LinearLayout>
<FrameLayout
android:id="@+id/header_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</FrameLayout>

<FrameLayout
android:layout_width="match_parent"
Expand Down
44 changes: 44 additions & 0 deletions res/layout/fragment_quick_add_dialog_header.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/color_background"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<TextView
android:id="@android:id/title"
style="@style/dialog_text_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:gravity="center_vertical"
android:padding="8dp"
android:text="@string/menu_add_task"
android:textColor="@android:color/white" />

<ImageView
android:id="@android:id/edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:padding="8dp"
android:src="@drawable/content_edit" />
</LinearLayout>

<Spinner
android:id="@+id/task_list_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:spinnerMode="dropdown" />

</LinearLayout>
1 change: 1 addition & 0 deletions res/layout/list_spinner_item_dropdown.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@android:color/white"
android:padding="5sp" >

<View
Expand Down
9 changes: 0 additions & 9 deletions res/values-v11/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,6 @@
<item name="android:textColor">#90000000</item>
</style>

<style name="dialog_button_stacked_primary" parent="dialog_button_primary">
<item name="android:gravity">right</item>
<item name="android:padding">8dp</item>
</style>

<style name="dialog_button_stacked_secondary" parent="dialog_button_stacked_primary">
<item name="android:textColor">#90000000</item>
</style>

<style name="actionColorBar">
<item name="android:layout_height">@dimen/abc_action_bar_default_height_material</item>
</style>
Expand Down
14 changes: 12 additions & 2 deletions res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
<style name="btn_remove">
<item name="android:layout_marginTop">5dp</item>
<item name="android:src">@drawable/content_remove</item>
<item name="android:padding">8dp</item>
<item name="android:padding">8dp</item>
</style>

<style name="widget_header_divider">
Expand All @@ -182,9 +182,10 @@
<item name="android:paddingBottom">4dp</item>
</style>

<style name="dialog_button_primary" parent="android:Widget.Button">
<style name="dialog_button_primary" parent="@style/Base.TextAppearance.AppCompat">
<item name="android:textAppearance">@android:style/TextAppearance.Medium</item>
<item name="android:textSize">16sp</item>
<item name="android:textColor">@color/accent_material_light</item>
<item name="android:padding">8dp</item>
<item name="android:clickable">true</item>
<item name="android:focusable">true</item>
Expand All @@ -196,6 +197,15 @@
<style name="dialog_button_secondary" parent="dialog_button_primary">
<item name="android:textColor">#90000000</item>
</style>

<style name="dialog_button_stacked_primary" parent="dialog_button_primary">
<item name="android:gravity">right</item>
<item name="android:padding">8dp</item>
</style>

<style name="dialog_button_stacked_secondary" parent="dialog_button_stacked_primary">
<item name="android:textColor">#90000000</item>
</style>

<style name="checklist_checked_item_text">
<item name="android:textColor">#ff808080</item>
Expand Down
13 changes: 12 additions & 1 deletion src/org/dmfs/tasks/QuickAddDialogFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import android.support.v4.content.Loader;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -202,7 +203,17 @@ public Dialog onCreateDialog(Bundle savedInstanceState)
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = inflater.inflate(R.layout.fragment_quick_add_dialog, container);

// create ContextThemeWrapper from the original Activity Context with the custom theme
final Context contextThemeWrapperLight = new ContextThemeWrapper(getActivity(), R.style.ThemeOverlay_AppCompat_Light);
final Context contextThemeWrapperDark = new ContextThemeWrapper(getActivity(), R.style.Base_Theme_AppCompat);

LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapperLight);
View view = localInflater.inflate(R.layout.fragment_quick_add_dialog, container);

ViewGroup headerContainer = (ViewGroup) view.findViewById(R.id.header_container);
localInflater = inflater.cloneInContext(contextThemeWrapperDark);
View header = localInflater.inflate(R.layout.fragment_quick_add_dialog_header, headerContainer);

if (savedInstanceState == null)
{
Expand Down

0 comments on commit 1602ba6

Please sign in to comment.