Skip to content

Commit cb6b656

Browse files
committed
Project Refactored
1 parent 9413ea2 commit cb6b656

33 files changed

+50
-292
lines changed

.resources/images/ic_launcher.png

1.62 KB
Loading

app/build.gradle

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,29 @@ apply plugin: 'com.android.application'
22

33
android {
44
compileSdkVersion 29
5-
// buildToolsVersion '33.0.0 rc1'
65
defaultConfig {
76
applicationId "com.ratul.topactivity"
8-
minSdkVersion 24
9-
targetSdkVersion 33
7+
minSdkVersion 21
8+
targetSdkVersion 25
109
versionCode 15
1110
versionName "1.5.5"
1211
}
1312

1413
buildTypes {
1514
release {
16-
debuggable false
1715
minifyEnabled true
1816
shrinkResources true
1917
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
2018
}
2119
debug {
2220
debuggable true
23-
minifyEnabled false
24-
shrinkResources false
21+
minifyEnabled true
22+
shrinkResources true
2523
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
2624
}
2725
}
2826
}
2927

3028
dependencies {
31-
// todo : use AndroidX
3229
implementation 'com.android.support:support-v4:25.4.0'
3330
}

app/proguard-rules.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1+
# Use Deafult

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
android:name=".AccessibilityWatcher"
7272
android:label="@string/app_name"
7373
android:description="@string/accessibility_permission"
74-
android:enabled="@bool/use_accessibility_service"
74+
android:enabled="true"
7575
android:exported="false"
7676
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
7777
<intent-filter>
@@ -85,7 +85,7 @@
8585
<service
8686
android:name=".QuickSettingsService"
8787
android:enabled="@bool/quick_settings_availability"
88-
android:icon="@drawable/ic_shortcut"
88+
android:icon="@drawable/ic_launcher_foreground"
8989
android:label="@string/app_name"
9090
android:exported="false"
9191
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">

app/src/main/java/com/ratul/fancy/ColorSetup.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
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-
*/
171
package com.ratul.fancy;
182

193
import android.content.*;

app/src/main/java/com/ratul/fancy/FancyDialog.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
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-
*/
171
package com.ratul.fancy;
182

193
import android.content.*;

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
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-
*/
171
package com.ratul.topactivity;
182

193
import android.accessibilityservice.AccessibilityService;

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
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-
*/
171
package com.ratul.topactivity;
182

193
import android.annotation.TargetApi;

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

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
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-
*/
171
package com.ratul.topactivity;
182

193
import android.app.*;
@@ -40,7 +24,6 @@
4024
* Created by Wen on 16/02/2017.
4125
* Refactored by Ratul on 04/05/2022.
4226
*/
43-
4427
public class MainActivity extends Activity implements OnCheckedChangeListener {
4528
public static final String EXTRA_FROM_QS_TILE = "from_qs_tile";
4629
public static final String ACTION_STATE_CHANGED = "com.ratul.topactivity.ACTION_STATE_CHANGED";
@@ -87,10 +70,6 @@ protected void onCreate(Bundle savedInstanceState) {
8770
findViewById(R.id.useNotificationPref).setVisibility(View.GONE);
8871
findViewById(R.id.divider_useNotificationPref).setVisibility(View.GONE);
8972
}
90-
if (Build.VERSION.SDK_INT < 21) {
91-
findViewById(R.id.useAccessibility).setVisibility(View.GONE);
92-
findViewById(R.id.divider_useAccess).setVisibility(View.GONE);
93-
}
9473
mNotificationSwitch = findViewById(R.id.sw_notification);
9574
if (mNotificationSwitch != null) {
9675
mNotificationSwitch.setOnCheckedChangeListener(this);
@@ -133,10 +112,8 @@ protected void onPause() {
133112

134113
private void refreshWindowSwitch() {
135114
mWindowSwitch.setChecked(SharedPrefsUtil.isShowWindow(this));
136-
if (getResources().getBoolean(R.bool.use_accessibility_service)) {
137-
if (SharedPrefsUtil.hasAccess(this) && AccessibilityWatcher.getInstance() == null) {
138-
mWindowSwitch.setChecked(false);
139-
}
115+
if (SharedPrefsUtil.hasAccess(this) && AccessibilityWatcher.getInstance() == null) {
116+
mWindowSwitch.setChecked(false);
140117
}
141118
}
142119

@@ -185,7 +162,7 @@ public void onClick(View v) {
185162
@Override
186163
public void onClick(View v) {
187164
fancy.dismiss();
188-
startActivity(new Intent().setAction(Intent.ACTION_VIEW).setData(Uri.parse("https://github.com/RatulHasan8/Current-Activity")));
165+
startActivity(new Intent().setAction(Intent.ACTION_VIEW).setData(Uri.parse("https://github.com/ratulhasanrahat/Current-Activity")));
189166
}
190167
});
191168
fancy.setNegativeButton("No", new View.OnClickListener() {
@@ -214,7 +191,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
214191
startService(new Intent().setClass(this, AccessibilityWatcher.class));
215192
return;
216193
}
217-
if (isChecked && buttonView == mWindowSwitch && Build.VERSION.SDK_INT >= 21) {
194+
if (isChecked && buttonView == mWindowSwitch) {
218195
if (Build.VERSION.SDK_INT >= 29 && !((PowerManager) getSystemService("power")).isIgnoringBatteryOptimizations(getPackageName())) {
219196
setupBattery();
220197
SharedPrefsUtil.setHasBattery(this, true);

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

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
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-
*/
171
package com.ratul.topactivity;
182

193
import android.annotation.*;
@@ -38,7 +22,6 @@ public class MonitoringService extends Service {
3822
public static MonitoringService INSTANCE;
3923
private UsageStatsManager usageStats;
4024
public Handler mHandler = new Handler();
41-
private ActivityManager mActivityManager;
4225
private String text;
4326
private String text1;
4427

@@ -48,10 +31,7 @@ public void onCreate() {
4831
INSTANCE = this;
4932

5033
serviceAlive = true;
51-
mActivityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
52-
if (Build.VERSION.SDK_INT >= 21) {
53-
usageStats = (UsageStatsManager) getSystemService(Context.USAGE_STATS_SERVICE);
54-
}
34+
usageStats = (UsageStatsManager) getSystemService(Context.USAGE_STATS_SERVICE);
5535
}
5636

5737
@Override
@@ -61,12 +41,6 @@ public void onDestroy() {
6141
}
6242

6343
public void getActivityInfo() {
64-
if (Build.VERSION.SDK_INT < 21) {
65-
List<ActivityManager.RunningTaskInfo> runningTasks = mActivityManager.getRunningTasks(1);
66-
text = runningTasks.get(0).topActivity.getPackageName();
67-
text1 = runningTasks.get(0).topActivity.getClassName();
68-
return;
69-
}
7044
long currentTimeMillis = System.currentTimeMillis();
7145
UsageEvents queryEvents = usageStats.queryEvents(currentTimeMillis - (firstRun ? 600000 : 60000), currentTimeMillis);
7246
while (queryEvents.hasNextEvent()) {

0 commit comments

Comments
 (0)