Skip to content

Commit f5be407

Browse files
committed
Project Refactored
1 parent cb6b656 commit f5be407

32 files changed

+827
-369
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ android {
2626
}
2727

2828
dependencies {
29-
implementation 'com.android.support:support-v4:25.4.0'
29+
implementation 'com.android.support:support-v4:26.0.1'
3030
}

app/proguard-rules.pro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
# Use Deafult
1+
-keep public class android.view.** {
2+
public private protected *;
3+
}

app/src/main/AndroidManifest.xml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,23 @@
1212
<!-- Prevent phone from sleeping -->
1313
<uses-permission android:name="android.permission.WAKE_LOCK" />
1414
<application
15-
android:name="crash.App"
15+
android:name=".App"
1616
android:label="@string/app_name"
1717
android:icon="@drawable/ic_launcher"
18+
android:theme="@style/AppTheme"
1819
android:allowBackup="true"
20+
android:supportsPictureInPicture="true"
1921
android:resizeableActivity="true"
2022
android:roundIcon="@drawable/ic_launcher_round">
2123
<activity
22-
android:name=".MainActivity"
24+
android:name=".ui.MainActivity"
2325
android:label="@string/app_name"
2426
android:exported="true"
25-
android:theme="@style/AppTheme"
2627
android:configChanges="orientation|screenSize|keyboardHidden|smallestScreenSize|screenLayout"
2728
android:hardwareAccelerated="true"
28-
android:supportsPictureInPicture="true"
2929
android:screenOrientation="portrait"
30-
android:launchMode="singleTask">
30+
android:launchMode="singleTask"
31+
android:maxRecents="1">
3132
<intent-filter>
3233
<action android:name="android.intent.action.MAIN"/>
3334
<category android:name="android.intent.category.LAUNCHER"/>
@@ -38,37 +39,36 @@
3839
</activity>
3940

4041
<activity
41-
android:theme="@style/AppTheme"
4242
android:configChanges="orientation|screenSize|keyboardHidden|smallestScreenSize|screenLayout"
4343
android:hardwareAccelerated="true"
44-
android:supportsPictureInPicture="true"
4544
android:screenOrientation="portrait"
4645
android:launchMode="singleTask"
47-
android:name="crash.CrashActivity"
46+
android:name=".ui.CrashActivity"
47+
android:maxRecents="1"
4848
android:label="@string/app_name"
4949
android:exported="true" />
5050

5151
<activity
52-
android:name=".ShortcutHandlerActivity"
52+
android:name=".ui.ShortcutHandlerActivity"
5353
android:excludeFromRecents="true"
5454
android:enabled="true"
5555
android:exported="true"
5656
android:theme="@style/TransparentTheme"/>
5757

5858
<activity
59-
android:name=".BackgroundActivity"
59+
android:name=".ui.BackgroundActivity"
6060
android:excludeFromRecents="true"
6161
android:enabled="true"
6262
android:exported="true"
6363
android:theme="@style/TransparentTheme"/>
6464

6565
<service
66-
android:name=".MonitoringService"
66+
android:name=".service.MonitoringService"
6767
android:enabled="true"
6868
android:exported="false"/>
6969

7070
<service
71-
android:name=".AccessibilityWatcher"
71+
android:name=".service.AccessibilityMonitoringService"
7272
android:label="@string/app_name"
7373
android:description="@string/accessibility_permission"
7474
android:enabled="true"
@@ -83,7 +83,7 @@
8383
android:resource="@xml/accessibility"/>
8484
</service>
8585
<service
86-
android:name=".QuickSettingsService"
86+
android:name=".service.QuickSettingsService"
8787
android:enabled="@bool/quick_settings_availability"
8888
android:icon="@drawable/ic_launcher_foreground"
8989
android:label="@string/app_name"
@@ -99,7 +99,7 @@
9999
</service>
100100

101101
<receiver
102-
android:name=".NotificationMonitor"
102+
android:name=".model.NotificationMonitor"
103103
android:exported="false"
104104
android:enabled="true">
105105
<intent-filter>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (C) 2022 Ratul Hasan
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
package android.view;
18+
19+
import android.content.Context;
20+
import android.graphics.Canvas;
21+
import android.graphics.Typeface;
22+
import android.util.AttributeSet;
23+
import android.widget.TextView;
24+
25+
public class BoldTextView extends TextView {
26+
public void setBoldFont(Context context) {
27+
Typeface face = Typeface.createFromAsset(context.getAssets(), "fonts/google_sans_bold.ttf");
28+
super.setTypeface(face);
29+
}
30+
31+
public BoldTextView(Context context) {
32+
super(context);
33+
setBoldFont(context);
34+
}
35+
36+
public BoldTextView(Context context, AttributeSet attrs) {
37+
super(context, attrs);
38+
setBoldFont(context);
39+
}
40+
41+
public BoldTextView(Context context, AttributeSet attrs, int defStyle) {
42+
super(context, attrs, defStyle);
43+
setBoldFont(context);
44+
}
45+
46+
protected void onDraw (Canvas canvas) {
47+
super.onDraw(canvas);
48+
}
49+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (C) 2022 Ratul Hasan
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
package android.view;
18+
19+
import android.content.Context;
20+
import android.graphics.Canvas;
21+
import android.graphics.Typeface;
22+
import android.util.AttributeSet;
23+
import android.widget.TextView;
24+
import android.widget.Toast;
25+
26+
public class NormalTextView extends TextView {
27+
public void setRegularFont(Context context) {
28+
Typeface face = Typeface.createFromAsset(context.getAssets(), "fonts/google_sans_regular.ttf");
29+
super.setTypeface(face);
30+
}
31+
32+
public NormalTextView(Context context) {
33+
super(context);
34+
setRegularFont(context);
35+
}
36+
37+
public NormalTextView(Context context, AttributeSet attrs) {
38+
super(context, attrs);
39+
setRegularFont(context);
40+
}
41+
42+
public NormalTextView(Context context, AttributeSet attrs, int defStyle) {
43+
super(context, attrs, defStyle);
44+
setRegularFont(context);
45+
}
46+
47+
protected void onDraw (Canvas canvas) {
48+
super.onDraw(canvas);
49+
}
50+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (C) 2022 Ratul Hasan
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
package android.view;
18+
19+
import android.content.Context;
20+
import android.graphics.Canvas;
21+
import android.graphics.Typeface;
22+
import android.util.AttributeSet;
23+
import android.widget.TextView;
24+
import android.widget.Toast;
25+
26+
public class RegularTextView extends TextView {
27+
public void setRegularFont(Context context) {
28+
Typeface face = Typeface.createFromAsset(context.getAssets(), "fonts/google_sans_regular.ttf");
29+
super.setTypeface(face, 1);
30+
}
31+
32+
public RegularTextView(Context context) {
33+
super(context);
34+
setRegularFont(context);
35+
}
36+
37+
public RegularTextView(Context context, AttributeSet attrs) {
38+
super(context, attrs);
39+
setRegularFont(context);
40+
}
41+
42+
public RegularTextView(Context context, AttributeSet attrs, int defStyle) {
43+
super(context, attrs, defStyle);
44+
setRegularFont(context);
45+
}
46+
47+
protected void onDraw (Canvas canvas) {
48+
super.onDraw(canvas);
49+
}
50+
}

app/src/main/java/com/ratul/topactivity/AccessibilityWatcher.java

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright (C) 2022 Ratul Hasan
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
package com.ratul.topactivity;
18+
19+
import android.app.Application;
20+
import com.ratul.topactivity.R;
21+
import com.ratul.topactivity.model.CrashHandler;
22+
import android.content.Context;
23+
import java.io.File;
24+
import android.app.Activity;
25+
import com.ratul.topactivity.ui.MainActivity;
26+
import android.content.Intent;
27+
import com.ratul.topactivity.ui.CrashActivity;
28+
import android.widget.Toast;
29+
30+
public class App extends Application {
31+
private static App sApp;
32+
private Thread.UncaughtExceptionHandler getHandler = Thread.getDefaultUncaughtExceptionHandler();
33+
34+
@Override
35+
protected void attachBaseContext(Context base) {
36+
super.attachBaseContext(base);
37+
CrashHandler handleCrash = new CrashHandler(this, getHandler);
38+
handleCrash.init(this.getFilesDir());
39+
}
40+
41+
public void gotoCrashActivity(Exception ex) {
42+
if (ex == null) {
43+
return;
44+
}
45+
Intent intent = new Intent(this, CrashActivity.class);
46+
intent.putExtra(CrashActivity.EXTRA_CRASH_INFO, ex.toString());
47+
startActivity(intent);
48+
}
49+
50+
public void setSafeContentView(Activity activity, int layout) {
51+
try {
52+
activity.setContentView(layout);
53+
} catch (Exception e) {
54+
Toast.makeText(this, "Saving crash log", 0).show();
55+
gotoCrashActivity(e);
56+
}
57+
}
58+
59+
@Override
60+
public void onCreate() {
61+
super.onCreate();
62+
sApp = this;
63+
}
64+
65+
public static App getApp() {
66+
return sApp;
67+
}
68+
69+
}

0 commit comments

Comments
 (0)