1414 * You should have received a copy of the GNU General Public License
1515 * along with this program. If not, see <https://www.gnu.org/licenses/>.
1616 */
17- package com .willme .topactivity ;
17+ package com .ratul .topactivity ;
1818
1919import android .app .*;
2020import android .content .*;
4343
4444public class MainActivity extends Activity implements OnCheckedChangeListener {
4545 public static final String EXTRA_FROM_QS_TILE = "from_qs_tile" ;
46- public static final String ACTION_STATE_CHANGED = "com.willme .topactivity.ACTION_STATE_CHANGED" ;
46+ public static final String ACTION_STATE_CHANGED = "com.ratul .topactivity.ACTION_STATE_CHANGED" ;
4747 CompoundButton mWindowSwitch , mNotificationSwitch , mAccessibilitySwitch ;
4848 private BroadcastReceiver mReceiver ;
4949 private int theme ;
@@ -53,13 +53,14 @@ public class MainActivity extends Activity implements OnCheckedChangeListener {
5353 protected void onPostCreate (Bundle savedInstanceState ) {
5454 super .onPostCreate (savedInstanceState );
5555 INSTANCE = this ;
56- if (WatchingAccessibilityService .getInstance () == null && SPHelper .hasAccess (this ))
57- startService (new Intent ().setClass (this , WatchingAccessibilityService .class ));
56+ if (AccessibilityWatcher .getInstance () == null && SharedPrefsUtil .hasAccess (this ))
57+ startService (new Intent ().setClass (this , AccessibilityWatcher .class ));
5858 }
5959
6060 @ Override
6161 protected void onCreate (Bundle savedInstanceState ) {
6262 super .onCreate (savedInstanceState );
63+
6364 setContentView (R .layout .activity_main );
6465 theme = FancyDialog .DARK_THEME ;
6566 ColorSetup .setupColors (this , theme );
@@ -80,22 +81,21 @@ protected void onCreate(Bundle savedInstanceState) {
8081 showWindow .setTextColor (ColorSetup .messageColor );
8182 disableNltification .setTextColor (ColorSetup .messageColor );
8283
83- mWindowSwitch = ( CompoundButton ) findViewById (R .id .sw_window );
84+ mWindowSwitch = findViewById (R .id .sw_window );
8485 mWindowSwitch .setOnCheckedChangeListener (this );
8586 if (Build .VERSION .SDK_INT < 24 ) {
8687 findViewById (R .id .useNotificationPref ).setVisibility (View .GONE );
8788 findViewById (R .id .divider_useNotificationPref ).setVisibility (View .GONE );
8889 }
8990 if (Build .VERSION .SDK_INT < 21 ) {
90- SPHelper .setHasAccess (this , false );
9191 findViewById (R .id .useAccessibility ).setVisibility (View .GONE );
9292 findViewById (R .id .divider_useAccess ).setVisibility (View .GONE );
9393 }
94- mNotificationSwitch = ( CompoundButton ) findViewById (R .id .sw_notification );
94+ mNotificationSwitch = findViewById (R .id .sw_notification );
9595 if (mNotificationSwitch != null ) {
9696 mNotificationSwitch .setOnCheckedChangeListener (this );
9797 }
98- mAccessibilitySwitch = ( CompoundButton ) findViewById (R .id .sw_accessibility );
98+ mAccessibilitySwitch = findViewById (R .id .sw_accessibility );
9999 if (mAccessibilitySwitch != null ) {
100100 mAccessibilitySwitch .setOnCheckedChangeListener (this );
101101 }
@@ -120,35 +120,35 @@ protected void onResume() {
120120 refreshWindowSwitch ();
121121 refreshNotificationSwitch ();
122122 refreshAccessibilitySwitch ();
123- NotificationActionReceiver .cancelNotification (this );
123+ NotificationMonitor .cancelNotification (this );
124124 }
125125
126126 @ Override
127127 protected void onPause () {
128128 super .onPause ();
129- if (SPHelper .isShowWindow (this )) {
130- NotificationActionReceiver .showNotification (this , false );
129+ if (SharedPrefsUtil .isShowWindow (this )) {
130+ NotificationMonitor .showNotification (this , false );
131131 }
132132 }
133133
134134 private void refreshWindowSwitch () {
135- mWindowSwitch .setChecked (SPHelper .isShowWindow (this ));
135+ mWindowSwitch .setChecked (SharedPrefsUtil .isShowWindow (this ));
136136 if (getResources ().getBoolean (R .bool .use_accessibility_service )) {
137- if (SPHelper .hasAccess (this ) && WatchingAccessibilityService .getInstance () == null ) {
137+ if (SharedPrefsUtil .hasAccess (this ) && AccessibilityWatcher .getInstance () == null ) {
138138 mWindowSwitch .setChecked (false );
139139 }
140140 }
141141 }
142142
143143 private void refreshAccessibilitySwitch () {
144144 if (mAccessibilitySwitch != null ) {
145- mAccessibilitySwitch .setChecked (SPHelper .hasAccess (this ));
145+ mAccessibilitySwitch .setChecked (SharedPrefsUtil .hasAccess (this ));
146146 }
147147 }
148148
149149 private void refreshNotificationSwitch () {
150150 if (mNotificationSwitch != null ) {
151- mNotificationSwitch .setChecked (!SPHelper .isNotificationToggleEnabled (this ));
151+ mNotificationSwitch .setChecked (!SharedPrefsUtil .isNotificationToggleEnabled (this ));
152152 }
153153 }
154154
@@ -180,7 +180,7 @@ public void onClick(View v) {
180180 fancy .show ();
181181 } else if (title .equals ("GitHub Repo" )) {
182182 fancy .setTitle ("GitHub Repo" );
183- fancy .setMessage ("Would you like to visit the official github repo of this app" );
183+ fancy .setMessage ("It is an open source project. Would you like to visit the official github repo of this app" );
184184 fancy .setPositiveButton ("Yes" , new View .OnClickListener () {
185185 @ Override
186186 public void onClick (View v ) {
@@ -203,21 +203,21 @@ public void onClick(View v) {
203203 @ Override
204204 public void onCheckedChanged (CompoundButton buttonView , boolean isChecked ) {
205205 if (buttonView == mNotificationSwitch ) {
206- SPHelper .setNotificationToggleEnabled (this , !isChecked );
206+ SharedPrefsUtil .setNotificationToggleEnabled (this , !isChecked );
207207 buttonView .setChecked (isChecked );
208208 return ;
209209 }
210210 if (buttonView == mAccessibilitySwitch ) {
211- SPHelper .setHasAccess (this , isChecked );
211+ SharedPrefsUtil .setHasAccess (this , isChecked );
212212 buttonView .setChecked (isChecked );
213- if (isChecked && WatchingAccessibilityService .getInstance () == null )
214- startService (new Intent ().setClass (this , WatchingAccessibilityService .class ));
213+ if (isChecked && AccessibilityWatcher .getInstance () == null )
214+ startService (new Intent ().setClass (this , AccessibilityWatcher .class ));
215215 return ;
216216 }
217217 if (isChecked && buttonView == mWindowSwitch && Build .VERSION .SDK_INT >= 21 ) {
218218 if (Build .VERSION .SDK_INT >= 29 && !((PowerManager ) getSystemService ("power" )).isIgnoringBatteryOptimizations (getPackageName ())) {
219219 setupBattery ();
220- SPHelper .setHasBattery (this , true );
220+ SharedPrefsUtil .setHasBattery (this , true );
221221 return ;
222222 }
223223 if (Build .VERSION .SDK_INT >= 23 && !Settings .canDrawOverlays (this )) {
@@ -244,7 +244,7 @@ public void onClick(View view) {
244244 onCheckedChanged (buttonView , false );
245245 return ;
246246 }
247- if (SPHelper .hasAccess (this ) && WatchingAccessibilityService .getInstance () == null ) {
247+ if (SharedPrefsUtil .hasAccess (this ) && AccessibilityWatcher .getInstance () == null ) {
248248 final FancyDialog fancy = new FancyDialog (MainActivity .this , theme );
249249 fancy .setTitle ("Accessibility Permission" );
250250 fancy .setMessage ("Enable my Accessibility Service in order to get current activity info" );
@@ -261,15 +261,15 @@ public void onClick(View view) {
261261 fancy .setNegativeButton ("Close" , new View .OnClickListener () {
262262 @ Override
263263 public void onClick (View view ) {
264- SPHelper .setHasAccess (MainActivity .this , false );
264+ SharedPrefsUtil .setHasAccess (MainActivity .this , false );
265265 fancy .dismiss ();
266266 }
267267 });
268268 fancy .show ();
269269 onCheckedChanged (buttonView , false );
270270 return ;
271271 }
272- if (!usageStats (MainActivity .this ) && getResources (). getBoolean ( R . bool . use_watching_service ) ) {
272+ if (!usageStats (MainActivity .this )) {
273273 final FancyDialog fancy = new FancyDialog (MainActivity .this , theme );
274274 fancy .setTitle ("Usage Access" );
275275 fancy .setMessage ("Enable my Usage Access permission in order to get current activity info" );
@@ -295,13 +295,13 @@ public void onClick(View view) {
295295 }
296296 }
297297 if (buttonView == mWindowSwitch ) {
298- SPHelper .setAppInitiated (this , true );
299- SPHelper .setIsShowWindow (this , isChecked );
298+ SharedPrefsUtil .setAppInitiated (this , true );
299+ SharedPrefsUtil .setIsShowWindow (this , isChecked );
300300 if (!isChecked ) {
301- TasksWindow .dismiss (this );
301+ WindowUtility .dismiss (this );
302302 } else {
303- TasksWindow .show (this , getPackageName (), getClass ().getName ());
304- startService (new Intent (this , WatchingService .class ));
303+ WindowUtility .show (this , getPackageName (), getClass ().getName ());
304+ startService (new Intent (this , MonitoringService .class ));
305305 }
306306 }
307307 }
0 commit comments