New classes for supporting Astrid speech bubble dialogs. We should use it elsewhere too for cleaner code

pull/14/head
Sam Bosley 12 years ago
parent 2efbef4220
commit 0619a3b2a0

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
** Copyright (c) 2012 Todoroo Inc
**
** See the file "LICENSE" for the full license governing this code.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/dialog_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dip"
android:layout_marginRight="15dip"
android:orientation="horizontal">
<LinearLayout
android:layout_width="260dip"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="5dip"
android:layout_marginRight="5dip"
android:layout_marginBottom="20dip"
android:layout_marginLeft="10dip">
<TextView
android:id="@+id/dialog_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textColor="@android:color/white"
android:layout_weight="1"/>
</LinearLayout>
<include layout="@layout/astrid_speech_bubble"/>
</LinearLayout>
<LinearLayout
android:layout_width="170dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="vertical">
<ImageView
android:id="@+id/dismiss"
android:layout_width="25dip"
android:layout_height="25dip"
android:scaleType="fitCenter"
android:layout_gravity="right"
android:layout_marginBottom="10dip"
android:src="@drawable/ic_menu_close"/>
<Button
android:id="@+id/button0"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginBottom="10dip"
android:textColor="@android:color/white"
android:textSize="20sp"
android:visibility="gone"
android:background="?attr/asThemeTextColor"/>
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginBottom="10dip"
android:textColor="@android:color/white"
android:textSize="20sp"
android:visibility="gone"
android:background="?attr/asThemeTextColor"/>
<Button
android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginBottom="10dip"
android:textColor="@android:color/white"
android:textSize="20sp"
android:visibility="gone"
android:background="?attr/asThemeTextColor"/>
</LinearLayout>
</LinearLayout>

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
** Copyright (c) 2012 Todoroo Inc
**
** See the file "LICENSE" for the full license governing this code.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/dialog_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="5dip"
android:layout_marginRight="5dip"
android:layout_marginBottom="20dip"
android:layout_marginLeft="5dip">
<TextView
android:id="@+id/dialog_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textColor="@android:color/white"
android:layout_weight="1"/>
<ImageView
android:id="@+id/dismiss"
android:layout_width="25dip"
android:layout_height="25dip"
android:scaleType="fitCenter"
android:src="@drawable/ic_menu_close"/>
</LinearLayout>
<include layout="@layout/astrid_speech_bubble"/>
<Button
android:id="@+id/button0"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginBottom="10dip"
android:textColor="@android:color/white"
android:visibility="gone"
android:textSize="20sp"
android:background="?attr/asThemeTextColor"/>
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginBottom="10dip"
android:textColor="@android:color/white"
android:textSize="20sp"
android:visibility="gone"
android:background="?attr/asThemeTextColor"/>
<Button
android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginBottom="10dip"
android:textColor="@android:color/white"
android:textSize="20sp"
android:visibility="gone"
android:background="?attr/asThemeTextColor"/>
</LinearLayout>

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
** Copyright (c) 2012 Todoroo Inc
**
** See the file "LICENSE" for the full license governing this code.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/dialog_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="5dip"
android:layout_marginRight="5dip"
android:layout_marginBottom="20dip"
android:layout_marginLeft="5dip">
<TextView
android:id="@+id/dialog_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textColor="@android:color/white"
android:layout_weight="1"/>
<ImageView
android:id="@+id/dismiss"
android:layout_width="25dip"
android:layout_height="25dip"
android:scaleType="fitCenter"
android:src="@drawable/ic_menu_close"/>
</LinearLayout>
<include layout="@layout/astrid_speech_bubble"/>
<Button
android:id="@+id/button0"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginBottom="10dip"
android:textColor="@android:color/white"
android:textSize="20sp"
android:visibility="gone"
android:background="?attr/asThemeTextColor"/>
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginBottom="10dip"
android:textColor="@android:color/white"
android:textSize="20sp"
android:visibility="gone"
android:background="?attr/asThemeTextColor"/>
<Button
android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginBottom="10dip"
android:textColor="@android:color/white"
android:textSize="20sp"
android:visibility="gone"
android:background="?attr/asThemeTextColor"/>
</LinearLayout>

@ -0,0 +1,83 @@
package com.todoroo.astrid.ui;
import android.app.Dialog;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.timsu.astrid.R;
import com.todoroo.astrid.activity.AstridActivity;
public class AstridDialog extends Dialog {
private final Button[] buttons;
private final TextView title;
private final TextView message;
private final LinearLayout root;
public AstridDialog(AstridActivity activity, boolean forcePortrait) {
super(activity, R.style.ReminderDialog);
setContentView(forcePortrait ? R.layout.astrid_dialog_view_portrait : R.layout.astrid_dialog_view);
buttons = new Button[2];
buttons[0] = (Button) findViewById(R.id.button0);
buttons[1] = (Button) findViewById(R.id.button1);
buttons[2] = (Button) findViewById(R.id.button2);
title = (TextView) findViewById(R.id.dialog_title);
message = (TextView) findViewById(R.id.reminder_message);
root = (LinearLayout) findViewById(R.id.dialog_root);
findViewById(R.id.dismiss).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
setOwnerActivity(activity);
}
public AstridDialog setButtonText(int resId, int buttonIndex) {
buttons[buttonIndex].setText(resId);
buttons[buttonIndex].setVisibility(View.VISIBLE);
return this;
}
public AstridDialog setButtonColor(int color, int buttonIndex) {
buttons[buttonIndex].setBackgroundColor(color);
return this;
}
public AstridDialog setButtonListener(View.OnClickListener listener, int buttonIndex) {
buttons[buttonIndex].setOnClickListener(listener);
return this;
}
public AstridDialog setButtonListeners(View.OnClickListener... listeners) {
int index = 0;
for (View.OnClickListener l : listeners) {
buttons[index].setOnClickListener(l);
index++;
if (index >= buttons.length)
break;
}
return this;
}
public AstridDialog setAstridText(int resId) {
message.setText(resId);
return this;
}
public AstridDialog setAstridTitle(int resId) {
title.setText(resId);
return this;
}
public AstridDialog addView(View v, int index) {
root.addView(v, index);
return this;
}
}
Loading…
Cancel
Save