New style ok button for edit dialogs

pull/14/head
Sam Bosley 12 years ago
parent 62ac52e740
commit f594ed9981

@ -173,15 +173,6 @@ public class EditPeopleControlSet extends PopupControlSet {
DisplayMetrics metrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
sharedWithDialog.setContentView(v, new LayoutParams(metrics.widthPixels - (int)(30 * metrics.density), LayoutParams.WRAP_CONTENT));
Button dismiss = (Button) v.findViewById(R.id.edit_dlg_ok);
if (dismiss != null) {
dismiss.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
DialogUtilities.dismissDialog(EditPeopleControlSet.this.activity, sharedWithDialog);
}
});
}
sharedWithDialog.setOwnerActivity(this.activity);
assignedCustom = (EditText) getView().findViewById(R.id.assigned_custom);
@ -199,6 +190,20 @@ public class EditPeopleControlSet extends PopupControlSet {
setUpListeners();
}
@Override
protected void setupOkButton(View v) {
super.setupOkButton(getSharedWithView());
Button dismiss = (Button) getSharedWithView().findViewById(R.id.edit_dlg_ok);
if (dismiss != null) {
dismiss.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
DialogUtilities.dismissDialog(EditPeopleControlSet.this.activity, sharedWithDialog);
}
});
}
}
@Override
public void readFromTask(Task sourceTask) {
setTask(sourceTask);

@ -6,13 +6,12 @@
-->
<Button xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/edit_dlg_ok"
android:layout_width="150dip"
android:layout_width="fill_parent"
android:layout_height="45dip"
android:layout_marginTop="5dip"
android:layout_marginBottom="5dip"
android:layout_weight="1"
android:layout_gravity="center_horizontal"
android:background="@drawable/footer_editbutton"
android:background="@null"
android:textStyle="bold"
android:textColor="@android:color/black"
android:layout_alignParentBottom="true"

@ -8,7 +8,9 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
android:orientation="vertical"
android:paddingLeft="5dip"
android:paddingRight="5dip">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
@ -16,9 +18,7 @@
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="9dip"
android:paddingRight="9dip">
android:layout_height="fill_parent">
<!-- Shared with -->
<TextView

@ -8,7 +8,9 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
android:layout_height="fill_parent"
android:paddingLeft="5dip"
android:paddingRight="5dip">
<!-- notes -->
<ScrollView

@ -8,14 +8,14 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
android:orientation="vertical"
android:paddingLeft="5dip"
android:paddingRight="5dip">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="100"
android:minWidth="320dip"
android:paddingLeft="5dip"
android:paddingRight="5dip">
android:minWidth="320dip">
<LinearLayout
android:id="@+id/reminders_body"
android:orientation="vertical"

@ -8,7 +8,9 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
android:layout_height="fill_parent"
android:paddingLeft="5dip"
android:paddingRight="5dip">
<LinearLayout
android:id="@+id/newTags"
@ -17,8 +19,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="2dip"
android:layout_marginBottom="5dip"
android:paddingLeft="5dip"
android:paddingRight="3dip"/>
/>
<View
android:layout_width="fill_parent"

@ -52,11 +52,6 @@
android:layout_width="fill_parent"
android:layout_height="250dip"
android:layout_weight="1" />
<View
android:id="@+id/TEA_Separator"
android:layout_width="fill_parent"
android:layout_height="1px"
style="@style/TEA_Separator" />
</LinearLayout>
</ScrollView>
</merge>

@ -6,10 +6,14 @@
package com.todoroo.astrid.helper;
import android.app.Activity;
import android.content.res.Resources.Theme;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import com.timsu.astrid.R;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.ui.EditDialogOkBackground;
// --- interface
@ -36,6 +40,7 @@ public abstract class TaskEditControlSet {
if (viewLayout != -1) {
view = LayoutInflater.from(activity).inflate(viewLayout, null);
afterInflate();
setupOkButton(view);
}
if (model != null)
readFromTaskOnInitialize();
@ -84,4 +89,16 @@ public abstract class TaskEditControlSet {
* Called when views need to be inflated
*/
protected abstract void afterInflate();
/**
* Sets up ok button background. Subclasses can override to customize look and feel
*/
protected void setupOkButton(View view) {
View ok = view.findViewById(R.id.edit_dlg_ok);
Theme theme = activity.getTheme();
TypedValue themeColor = new TypedValue();
theme.resolveAttribute(R.attr.asThemeTextColor, themeColor, false);
if (ok != null)
ok.setBackgroundDrawable(EditDialogOkBackground.getBg(activity.getResources().getColor(themeColor.data)));
}
}

@ -225,6 +225,12 @@ public class ThemeService {
switch(lightDrawable) {
case R.drawable.ic_menu_save:
return R.drawable.ic_menu_save;
case R.drawable.ic_menu_close:
return R.drawable.ic_menu_close;
case R.drawable.ic_menu_mic:
return R.drawable.ic_menu_mic;
case R.drawable.icn_menu_refresh:
return R.drawable.icn_menu_refresh_dark;
case R.drawable.icn_menu_filters:

@ -7,6 +7,8 @@ package com.todoroo.astrid.ui;
import android.app.Activity;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
@ -63,7 +65,18 @@ public class DeadlineControlSet extends PopupControlSet {
extras.addView(v, lp);
}
LinearLayout body = (LinearLayout) getView().findViewById(R.id.datetime_body);
body.setGravity(Gravity.CENTER_HORIZONTAL);
Button okButton = (Button) LayoutInflater.from(activity).inflate(R.layout.control_dialog_ok, null);
DisplayMetrics metrics = activity.getResources().getDisplayMetrics();
LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, (int) (45 * metrics.density));
body.addView(okButton, params);
}
@Override
protected void setupOkButton(View view) {
super.setupOkButton(view);
Button okButton = (Button) view.findViewById(R.id.edit_dlg_ok);
okButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
@ -71,8 +84,6 @@ public class DeadlineControlSet extends PopupControlSet {
DialogUtilities.dismissDialog(DeadlineControlSet.this.activity, DeadlineControlSet.this.dialog);
}
});
LinearLayout body = (LinearLayout) getView().findViewById(R.id.datetime_body);
body.addView(okButton);
}
@Override

@ -0,0 +1,49 @@
package com.todoroo.astrid.ui;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
public class EditDialogOkBackground {
public static StateListDrawable getBg(int colorValue) {
final Paint p = new Paint();
p.setColor(Color.GRAY);
Drawable d = new Drawable() {
@Override
public void setColorFilter(ColorFilter cf) {
//
}
@Override
public void setAlpha(int alpha) {
//
}
@Override
public int getOpacity() {
return PixelFormat.OPAQUE;
}
@Override
public void draw(Canvas canvas) {
Rect r = canvas.getClipBounds();
canvas.drawLine(r.left, r.top, r.right, r.top, p);
}
};
ColorDrawable color = new ColorDrawable(colorValue);
StateListDrawable stld = new StateListDrawable();
stld.addState(new int[] { android.R.attr.state_pressed }, color);
stld.addState(new int[] { android.R.attr.state_enabled }, d);
return stld;
}
}
Loading…
Cancel
Save