mirror of
https://github.com/M66B/NetGuard.git
synced 2024-12-25 01:07:52 +00:00
Use touch delegates to enlarge touch area
This commit is contained in:
parent
3e922a9975
commit
c75973207f
2 changed files with 53 additions and 16 deletions
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.content.SharedPreferences;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Rect;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.preference.PreferenceManager;
|
||||
|
@ -11,6 +12,7 @@ import android.support.v4.content.ContextCompat;
|
|||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.TouchDelegate;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
|
@ -77,6 +79,32 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
cbUsing = (CheckBox) itemView.findViewById(R.id.cbUsing);
|
||||
cbRoaming = (CheckBox) itemView.findViewById(R.id.cbRoaming);
|
||||
btnLaunch = (Button) itemView.findViewById(R.id.btnLaunch);
|
||||
|
||||
final View wifiParent = (View) cbWifi.getParent();
|
||||
wifiParent.post(new Runnable() {
|
||||
public void run() {
|
||||
Rect rect = new Rect();
|
||||
cbWifi.getHitRect(rect);
|
||||
rect.bottom += rect.top;
|
||||
rect.right += rect.left;
|
||||
rect.top = 0;
|
||||
rect.left = 0;
|
||||
wifiParent.setTouchDelegate(new TouchDelegate(rect, cbWifi));
|
||||
}
|
||||
});
|
||||
|
||||
final View otherParent = (View) cbOther.getParent();
|
||||
otherParent.post(new Runnable() {
|
||||
public void run() {
|
||||
Rect rect = new Rect();
|
||||
cbOther.getHitRect(rect);
|
||||
rect.bottom += rect.top;
|
||||
rect.right += rect.left;
|
||||
rect.top = 0;
|
||||
rect.left = 0;
|
||||
otherParent.setTouchDelegate(new TouchDelegate(rect, cbOther));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,28 +41,36 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
|
||||
</LinearLayout>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbWifi"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="12dp"
|
||||
android:button="@drawable/wifi" />
|
||||
<RelativeLayout
|
||||
android:layout_width="?android:attr/listPreferredItemHeightSmall"
|
||||
android:layout_height="?android:attr/listPreferredItemHeightSmall">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbOther"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="12dp"
|
||||
android:button="@drawable/other" />
|
||||
<CheckBox
|
||||
android:id="@+id/cbWifi"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:button="@drawable/wifi" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="?android:attr/listPreferredItemHeightSmall"
|
||||
android:layout_height="?android:attr/listPreferredItemHeightSmall">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbOther"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:button="@drawable/other" />
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/llAttributes"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginStart="4dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
|
@ -79,7 +87,8 @@
|
|||
android:layout_gravity="center_horizontal"
|
||||
android:text="R"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textColor="@color/colorAccent" />
|
||||
android:textColor="@color/colorAccent"
|
||||
android:textSize="12dp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
|
Loading…
Reference in a new issue