Added tich delegation to the map button, to make them easier to click
Change-Id: Ia43fa2a13af68c5e81f6023a8948d4d851479f21 Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
Binary file not shown.
@@ -3,91 +3,92 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/distance_background"
|
android:background="@drawable/distance_background"
|
||||||
|
android:baselineAligned="false"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginBottom="10dip"
|
|
||||||
android:layout_marginTop="10dip"
|
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="vertical" >
|
android:paddingBottom="10dip"
|
||||||
|
android:paddingTop="10dip" >
|
||||||
|
|
||||||
<ImageButton
|
<com.TwentyCodes.android.FindMyCarLib.UI.DelegatedImageButton
|
||||||
android:id="@+id/my_location"
|
android:id="@+id/my_location"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:background="@drawable/my_location_action_bar"
|
android:background="@drawable/my_location_action_bar"
|
||||||
android:contentDescription="@string/my_location" />
|
android:contentDescription="@string/my_location"
|
||||||
|
android:duplicateParentState="true" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginBottom="10dip"
|
|
||||||
android:layout_marginTop="10dip"
|
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="vertical" >
|
android:paddingBottom="10dip"
|
||||||
|
android:paddingTop="10dip" >
|
||||||
|
|
||||||
<ImageButton
|
<com.TwentyCodes.android.FindMyCarLib.UI.DelegatedImageButton
|
||||||
android:id="@+id/mark_my_location"
|
android:id="@+id/mark_my_location"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:background="@drawable/mark_my_location_action_bar"
|
android:background="@drawable/mark_my_location_action_bar"
|
||||||
android:contentDescription="@string/mark_car" />
|
android:contentDescription="@string/mark_car"
|
||||||
|
android:duplicateParentState="true" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginBottom="10dip"
|
|
||||||
android:layout_marginTop="10dip"
|
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="vertical" >
|
android:paddingBottom="10dip"
|
||||||
|
android:paddingTop="10dip" >
|
||||||
|
|
||||||
<ImageButton
|
<com.TwentyCodes.android.FindMyCarLib.UI.DelegatedImageButton
|
||||||
android:id="@+id/show_both"
|
android:id="@+id/show_both"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:background="@drawable/car_action_bar" />
|
android:background="@drawable/car_action_bar"
|
||||||
|
android:duplicateParentState="true" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginBottom="10dip"
|
|
||||||
android:layout_marginTop="10dip"
|
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="vertical" >
|
android:paddingBottom="10dip"
|
||||||
|
android:paddingTop="10dip" >
|
||||||
|
|
||||||
<ImageButton
|
<com.TwentyCodes.android.FindMyCarLib.UI.DelegatedImageButton
|
||||||
android:id="@+id/parking_timer"
|
android:id="@+id/parking_timer"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:background="@drawable/time_action_bar"
|
android:background="@drawable/time_action_bar"
|
||||||
android:contentDescription="@string/parking_timer" />
|
android:contentDescription="@string/parking_timer"
|
||||||
|
android:duplicateParentState="true" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginBottom="10dip"
|
|
||||||
android:layout_marginTop="10dip"
|
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="vertical" >
|
android:paddingBottom="10dip"
|
||||||
|
android:paddingTop="10dip" >
|
||||||
|
|
||||||
<ImageButton
|
<com.TwentyCodes.android.FindMyCarLib.UI.DelegatedImageButton
|
||||||
android:id="@+id/directions"
|
android:id="@+id/directions"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:background="@drawable/nav_action_bar"
|
android:background="@drawable/nav_action_bar"
|
||||||
android:contentDescription="@string/directions" />
|
android:contentDescription="@string/directions"
|
||||||
|
android:duplicateParentState="true" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -1,14 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<declare-styleable name="com.admob.android.ads.AdView">
|
|
||||||
<attr format="color" name="backgroundColor" />
|
|
||||||
<attr format="color" name="primaryTextColor" />
|
|
||||||
<attr format="color" name="secondaryTextColor" />
|
|
||||||
<attr format="string" name="keywords" />
|
|
||||||
<attr format="integer" name="refreshInterval" />
|
|
||||||
</declare-styleable>
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Copyright (C) 2011 Patrik Åkerfeldt
|
Copyright (C) 2011 Patrik Åkerfeldt
|
||||||
Copyright (C) 2011 Jake Wharton
|
Copyright (C) 2011 Jake Wharton
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
/**
|
||||||
|
* DelegatedImageButton.java
|
||||||
|
* @date Mar 9, 2012
|
||||||
|
* @author ricky barrette
|
||||||
|
* @author Twenty Codes, LLC
|
||||||
|
*/
|
||||||
|
package com.TwentyCodes.android.FindMyCarLib.UI;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Rect;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.TouchDelegate;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnAttachStateChangeListener;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This button is a simple image button that extends it's touch hit rect
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
public class DelegatedImageButton extends LinearLayout implements OnAttachStateChangeListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param context
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
public DelegatedImageButton(Context context) {
|
||||||
|
super(context);
|
||||||
|
this.addOnAttachStateChangeListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param context
|
||||||
|
* @param attrs
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
public DelegatedImageButton(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
this.addOnAttachStateChangeListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param context
|
||||||
|
* @param attrs
|
||||||
|
* @param defStyle
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
public DelegatedImageButton(Context context, AttributeSet attrs, int defStyle) {
|
||||||
|
super(context, attrs, defStyle);
|
||||||
|
this.addOnAttachStateChangeListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initDelegate(){
|
||||||
|
final View parent = (View) this.getParent();
|
||||||
|
parent.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Rect bounds = new Rect();
|
||||||
|
DelegatedImageButton.this.getHitRect(bounds);
|
||||||
|
bounds.top -= 40;
|
||||||
|
bounds.left -= 40;
|
||||||
|
bounds.bottom += 40;
|
||||||
|
bounds.right += 40;
|
||||||
|
TouchDelegate touchDelegate = new TouchDelegate(bounds, DelegatedImageButton.this);
|
||||||
|
|
||||||
|
if (View.class.isInstance(DelegatedImageButton.this.getParent())) {
|
||||||
|
((View) DelegatedImageButton.this.getParent()).setTouchDelegate(touchDelegate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewAttachedToWindow(View v) {
|
||||||
|
initDelegate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewDetachedFromWindow(View v) {
|
||||||
|
// UNUSED
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user