2222import androidx .annotation .NonNull ;
2323import androidx .annotation .Nullable ;
2424import androidx .appcompat .app .ActionBar ;
25+ import androidx .appcompat .view .ContextThemeWrapper ;
2526
2627import com .google .android .material .card .MaterialCardView ;
2728import com .google .android .material .dialog .MaterialAlertDialogBuilder ;
@@ -87,12 +88,13 @@ public interface onPurchasedListener {
8788 MaterialCardView InfoPreferences ;
8889
8990 SharedPreferences .OnSharedPreferenceChangeListener prefsListener = (p , k ) -> {
90- if (k .equals ("serviceToggle" )) {
91- ServiceToggle .setChecked (prefs .getBoolean ("serviceToggle" , false ));
92- } else if (k .equals ("UID" )) {
93- updateProfileImage ();
94- } else if (k .equals ("NewCardRadius" ) && !Application .isTablet ()) {
95- setCardViewRadius ();
91+ if (k != null ) switch (k ) {
92+ case "serviceToggle" ->
93+ ServiceToggle .setChecked (prefs .getBoolean ("serviceToggle" , false ));
94+ case "UID" -> updateProfileImage ();
95+ case "NewCardRadius" -> {
96+ if (!Application .isTablet ()) setCardViewRadius ();
97+ }
9698 }
9799 };
98100
@@ -293,7 +295,7 @@ protected void onCreate(Bundle savedInstanceState) {
293295 }
294296 }
295297
296- if (!prefs .getBoolean ("IsFcmTopicSubscribed" , false ) && !(mAuth .getUid () == null ? "" : mAuth .getUid ()).isEmpty ()) {
298+ if (!prefs .getBoolean ("IsFcmTopicSubscribed" , false ) && !(mAuth .getUid () == null ? "" : mAuth .getUid ()).isEmpty ()) {
297299 FirebaseMessaging .getInstance ().subscribeToTopic (Objects .requireNonNull (mAuth .getUid ()));
298300 }
299301
@@ -317,6 +319,27 @@ protected void onCreate(Bundle savedInstanceState) {
317319 if (mBillingHelper .isSubscribed ()) {
318320 new RegisterForPushNotificationsAsync (this ).execute ();
319321 }
322+
323+ showSupportDialog ();
324+ }
325+
326+ protected void showSupportDialog () {
327+ long dismissTime = prefs .getLong ("SupportMessageDismiss" , 0 );
328+ if (BuildConfig .DEBUG || (dismissTime != 0 && System .currentTimeMillis () - dismissTime <= (259200000 /* 3 Days */ ))) {
329+ return ;
330+ }
331+
332+ new MaterialAlertDialogBuilder (new ContextThemeWrapper (SettingsActivity .this , R .style .Theme_App_Palette_Dialog ))
333+ .setTitle ("Please Support Us!" )
334+ .setMessage ("NotiSender is currently running at a loss to maintain its servers, despite virtually no revenue." +
335+ "\n Please help us maintain this open source project!" )
336+ .setPositiveButton ("Support" , (dialog , which ) ->
337+ startActivity (new Intent (Intent .ACTION_VIEW , Uri .parse ("https://github.com/sponsors/choiman1559" ))))
338+ .setNegativeButton ("Close" , (dialog , which ) -> {
339+ })
340+ .setNeutralButton ("Do not show for 3 days" , (dialog , which ) -> prefs .edit ().putLong ("SupportMessageDismiss" , System .currentTimeMillis ()).apply ())
341+ .setCancelable (false )
342+ .show ();
320343 }
321344
322345 public static void getAPIKeyFromCloud (Activity mContext ) {
@@ -334,7 +357,7 @@ public static void getAPIKeyFromCloud(Activity mContext) {
334357 .apply ();
335358 }
336359
337- if (mBillingHelper != null ) mBillingHelper .Destroy ();
360+ if (mBillingHelper != null ) mBillingHelper .Destroy ();
338361 mBillingHelper = BillingHelper .initialize (mContext );
339362 } else {
340363 new MaterialAlertDialogBuilder (mContext )
0 commit comments