Skip to content

Commit 6296873

Browse files
committed
Fix Bugs
1 parent 37c5714 commit 6296873

File tree

5 files changed

+41
-15
lines changed

5 files changed

+41
-15
lines changed

app/src/main/java/io/github/ratul/topactivity/utils/WindowUtil.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import io.github.ratul.topactivity.service.AccessibilityMonitoringService;
4242
import android.content.pm.PackageInfo;
4343
import android.content.pm.PackageManager;
44+
import io.github.ratul.topactivity.App;
4445

4546
/**
4647
* Created by Ratul on 04/05/2022.
@@ -87,21 +88,24 @@ public void onClick(View v) {
8788
}
8889
});
8990

90-
appName.setOnClickListener(new View.OnClickListener() {
91-
public void onClick(View v) {
91+
appName.setOnLongClickListener(new View.OnLongClickListener() {
92+
public boolean onLongClick(View v) {
9293
copyString(context, text, "App name copied");
94+
return true;
9395
}
9496
});
9597

96-
packageName.setOnClickListener(new View.OnClickListener() {
97-
public void onClick(View v) {
98+
packageName.setOnLongClickListener(new View.OnLongClickListener() {
99+
public boolean onLongClick(View v) {
98100
copyString(context, text, "Package name copied");
101+
return true;
99102
}
100103
});
101104

102-
className.setOnClickListener(new View.OnClickListener() {
103-
public void onClick(View v) {
105+
className.setOnLongClickListener(new View.OnLongClickListener() {
106+
public boolean onLongClick(View v) {
104107
copyString(context, text1, "Class name copied");
108+
return true;
105109
}
106110
});
107111

@@ -120,7 +124,8 @@ public boolean onTouch(View view, MotionEvent event) {
120124
yInitCord = yCord;
121125
xInitMargin = layoutParams.x;
122126
yInitMargin = layoutParams.y;
123-
} else if (action == MotionEvent.ACTION_MOVE) {
127+
}
128+
else if (action == MotionEvent.ACTION_MOVE) {
124129
int xDiffMove = xCord - xInitCord;
125130
int yDiffMove = yCord - yInitCord;
126131
xCordDestination = xInitMargin + xDiffMove;
@@ -144,14 +149,15 @@ private static void copyString(Context context, String str, String msg) {
144149
new Intent(context, BackgroundActivity.class).putExtra(BackgroundActivity.STRING_COPY, str)
145150
.putExtra(BackgroundActivity.COPY_MSG, msg).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
146151
}
152+
App.showToast(msg, 0);
147153
}
148154

149155
public static String getAppName(Context context, String pkg) {
150156
try {
151157
PackageManager pm = context.getPackageManager();
152158
return pm.getApplicationLabel(pm.getApplicationInfo(pkg, 0)).toString();
153159
} catch (Exception e) {
154-
return "";
160+
return "Unknown";
155161
}
156162
}
157163

app/src/main/java/io/github/ratul/topactivity/view/BoldTextView.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ public BoldTextView(Context context, AttributeSet attrs, int defStyle) {
4242
super(context, attrs, defStyle);
4343
setBoldFont(context);
4444
}
45+
46+
public BoldTextView(Context context, AttributeSet attrs, int defStyle, int res) {
47+
super(context, attrs, defStyle, res);
48+
setBoldFont(context);
49+
}
4550

4651
protected void onDraw(Canvas canvas) {
4752
super.onDraw(canvas);

app/src/main/java/io/github/ratul/topactivity/view/NormalTextView.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ public NormalTextView(Context context, AttributeSet attrs, int defStyle) {
4242
super(context, attrs, defStyle);
4343
setRegularFont(context);
4444
}
45+
46+
public NormalTextView(Context context, AttributeSet attrs, int defStyle, int res) {
47+
super(context, attrs, defStyle, res);
48+
setRegularFont(context);
49+
}
4550

4651
protected void onDraw (Canvas canvas) {
4752
super.onDraw(canvas);

app/src/main/java/io/github/ratul/topactivity/view/RegularTextView.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ public RegularTextView(Context context, AttributeSet attrs, int defStyle) {
4242
super(context, attrs, defStyle);
4343
setRegularFont(context);
4444
}
45+
46+
public RegularTextView(Context context, AttributeSet attrs, int defStyle, int res) {
47+
super(context, attrs, defStyle, res);
48+
setRegularFont(context);
49+
}
4550

4651
protected void onDraw(Canvas canvas) {
4752
super.onDraw(canvas);

app/src/main/res/layout/window_tasks.xml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,33 @@
1515
android:layout_height="wrap_content"
1616
android:orientation="horizontal" >
1717

18-
<io.github.ratul.topactivity.view.NormalTextView
18+
<io.github.ratul.topactivity.view.BoldTextView
1919
android:id="@+id/text"
20-
android:layout_width="match_parent"
21-
android:layout_height="match_parent"
20+
android:layout_width="wrap_content"
21+
android:layout_height="wrap_content"
2222
android:layout_marginTop="1dp"
2323
android:background="#60111111"
2424
android:clickable="true"
2525
android:padding="8dp"
26-
android:singleLine="false"
26+
android:singleLine="true"
27+
android:ellipsize="end"
2728
android:textColor="#FFFFFF"
2829
android:textSize="13sp" />
2930

30-
<io.github.ratul.topactivity.view.BoldTextView
31+
<io.github.ratul.topactivity.view.RegularTextView
3132
android:id="@+id/title"
3233
android:layout_width="wrap_content"
3334
android:layout_height="wrap_content"
34-
android:ellipsize="end"
3535
android:gravity="center_vertical"
3636
android:padding="8dp"
37-
android:text="-Info"
37+
android:text="-Activity Info"
3838
android:textColor="#FFFFFF"
3939
android:textSize="12sp" />
40+
41+
<TextView
42+
android:layout_width="wrap_content"
43+
android:layout_height="wrap_content"
44+
android:layout_weight="1"/>
4045

4146
<com.google.android.material.imageview.ShapeableImageView
4247
android:id="@+id/closeBtn"

0 commit comments

Comments
 (0)