Calculator Overlay
This commit is contained in:
parent
eb07c9410a
commit
64b01cb22a
@ -6,6 +6,11 @@
|
|||||||
|
|
||||||
<include layout="@layout/overlay_header"/>
|
<include layout="@layout/overlay_header"/>
|
||||||
|
|
||||||
|
<LinearLayout a:id="@+id/overlay_content"
|
||||||
|
a:orientation="vertical"
|
||||||
|
a:layout_width="match_parent"
|
||||||
|
a:layout_height="match_parent">
|
||||||
|
|
||||||
<include layout="@layout/widget_editor"
|
<include layout="@layout/widget_editor"
|
||||||
a:layout_weight="2"
|
a:layout_weight="2"
|
||||||
a:layout_width="match_parent"
|
a:layout_width="match_parent"
|
||||||
@ -32,6 +37,7 @@
|
|||||||
a:layout_weight="5"
|
a:layout_weight="5"
|
||||||
a:layout_width="match_parent"
|
a:layout_width="match_parent"
|
||||||
a:layout_height="0dp"/>
|
a:layout_height="0dp"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<include layout="@layout/overlay_footer"/>
|
<include layout="@layout/overlay_footer"/>
|
||||||
|
|
||||||
|
@ -64,6 +64,44 @@ public class CalculatorOverlayService extends Service implements ExternalCalcula
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
final int initialWindowWidth = Math.max(wm.getDefaultDisplay().getWidth() / 2, 300);
|
||||||
|
final int initialWindowHeight = Math.max(wm.getDefaultDisplay().getHeight() / 2, 450);
|
||||||
|
|
||||||
|
final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
|
||||||
|
initialWindowWidth,
|
||||||
|
initialWindowHeight,
|
||||||
|
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
|
||||||
|
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL|WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
|
||||||
|
PixelFormat.TRANSLUCENT);
|
||||||
|
|
||||||
|
final View overlayContent = onscreenView.findViewById(R.id.overlay_content);
|
||||||
|
final View overlayHideButton = onscreenView.findViewById(R.id.overlay_hide_button);
|
||||||
|
overlayHideButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
|
private boolean hidden = false;
|
||||||
|
|
||||||
|
private int windowHeight = initialWindowHeight;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
final WindowManager.LayoutParams params = (WindowManager.LayoutParams) onscreenView.getLayoutParams();
|
||||||
|
if (hidden) {
|
||||||
|
overlayContent.setVisibility(View.VISIBLE);
|
||||||
|
params.height = windowHeight;
|
||||||
|
} else {
|
||||||
|
windowHeight = params.height;
|
||||||
|
overlayContent.setVisibility(View.GONE);
|
||||||
|
params.height = overlayHideButton.getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
wm.updateViewLayout(onscreenView, params);
|
||||||
|
|
||||||
|
hidden = !hidden;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
onscreenView.findViewById(R.id.overlay_close_button).setOnClickListener(new View.OnClickListener() {
|
onscreenView.findViewById(R.id.overlay_close_button).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@ -71,14 +109,6 @@ public class CalculatorOverlayService extends Service implements ExternalCalcula
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
|
|
||||||
Math.max(wm.getDefaultDisplay().getWidth() / 2, 300),
|
|
||||||
Math.max(wm.getDefaultDisplay().getHeight() / 2, 450),
|
|
||||||
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
|
|
||||||
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL|WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
|
|
||||||
PixelFormat.TRANSLUCENT);
|
|
||||||
|
|
||||||
final TextView overlayTitleTextView = (TextView) onscreenView.findViewById(R.id.overlay_title);
|
final TextView overlayTitleTextView = (TextView) onscreenView.findViewById(R.id.overlay_title);
|
||||||
overlayTitleTextView.setOnTouchListener(new View.OnTouchListener() {
|
overlayTitleTextView.setOnTouchListener(new View.OnTouchListener() {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user