mirror of https://github.com/tasks/tasks
Added basic popover views for new user help
parent
00fe08c5e0
commit
201f4218c4
@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/gdi_header"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/gdi_arrow_up"
|
||||
android:layout_marginTop="-1px"
|
||||
android:background="@drawable/gd_quick_action_top_frame" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gdi_message"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/gdi_header"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:gravity="center"
|
||||
android:textColor="@android:color/black"
|
||||
android:background="#ffffffff"
|
||||
android:fadingEdgeLength="0dp"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/gdi_footer"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/gdi_message"
|
||||
android:background="@drawable/gd_quick_action_bar_bottom_frame" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/gdi_arrow_up"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/gd_quick_action_arrow_up" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/gdi_arrow_down"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="-1px"
|
||||
android:layout_below="@id/gdi_footer"
|
||||
android:src="@drawable/gd_quick_action_bar_arrow_down" />
|
||||
|
||||
</RelativeLayout>
|
||||
@ -0,0 +1,61 @@
|
||||
package com.todoroo.astrid.welcome;
|
||||
|
||||
import greendroid.widget.QuickAction;
|
||||
import greendroid.widget.QuickActionWidget;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
import android.view.View.MeasureSpec;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.timsu.astrid.R;
|
||||
|
||||
public class HelpInfoPopover extends QuickActionWidget {
|
||||
|
||||
public static void showPopover(final Activity activity, final View parent, final int textId) {
|
||||
parent.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
HelpInfoPopover toShow = new HelpInfoPopover(activity, textId);
|
||||
toShow.show(parent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public HelpInfoPopover(Context context, int textId) {
|
||||
super(context);
|
||||
setContentView(R.layout.help_popover);
|
||||
TextView message = (TextView)getContentView().findViewById(R.id.gdi_message);
|
||||
message.setText(textId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateQuickActions(List<QuickAction> quickActions) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasureAndLayout(Rect anchorRect, View contentView) {
|
||||
contentView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
contentView.measure(MeasureSpec.makeMeasureSpec(getScreenWidth(), MeasureSpec.EXACTLY),
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
|
||||
int rootHeight = contentView.getMeasuredHeight();
|
||||
|
||||
int offsetY = getArrowOffsetY();
|
||||
int dyTop = anchorRect.top;
|
||||
int dyBottom = getScreenHeight() - anchorRect.bottom;
|
||||
|
||||
boolean onTop = (dyTop > dyBottom);
|
||||
int popupY = (onTop) ? anchorRect.top - rootHeight + offsetY : anchorRect.bottom - offsetY;
|
||||
|
||||
setWidgetSpecs(popupY, onTop);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue