11package com .parishod .watomatic .fragment ;
22
33import android .app .Activity ;
4- import android .app .ActivityManager ;
54import android .content .ActivityNotFoundException ;
65import android .content .ComponentName ;
76import android .content .Context ;
2019import android .view .View ;
2120import android .view .ViewGroup ;
2221import android .widget .Button ;
23- import android .widget .ImageButton ;
24- import android .widget .ImageView ;
2522import android .widget .LinearLayout ;
2623import android .widget .TextView ;
2724import android .widget .Toast ;
2825
2926import androidx .annotation .NonNull ;
3027import androidx .annotation .Nullable ;
31- import androidx .appcompat .widget .Toolbar ;
3228import androidx .core .app .ActivityCompat ;
3329import androidx .core .content .ContextCompat ;
3430import androidx .fragment .app .Fragment ;
4238import com .parishod .watomatic .activity .about .AboutActivity ;
4339import com .parishod .watomatic .activity .contactselector .ContactSelectorActivity ;
4440import com .parishod .watomatic .activity .customreplyeditor .CustomReplyEditorActivity ;
45- import com .parishod .watomatic .activity .enabledapps .EnabledAppsActivity ;
4641import com .parishod .watomatic .activity .main .MainActivity ;
4742import com .parishod .watomatic .activity .settings .SettingsActivity ;
4843import com .parishod .watomatic .model .App ;
@@ -86,7 +81,7 @@ public class MainFragment extends Fragment implements DialogActionListener {
8681 BottomNavigationView bottomNav ;
8782 Button editButton ;
8883 private int gitHubReleaseNotesId = -1 ;
89- private int selectedCooldownTime ;
84+ private int selectedCooldownTime = - 1 ;
9085 private TextView replyCooldownDescription , messageTypeDescription ;
9186 private LinearLayout contactsFilterLL , messagesTypeLL , supportedAppsLL , replyCooldownLL ;
9287 private TextView enabledAppsCount ;
@@ -630,7 +625,6 @@ private void showAppsDialog() {
630625 R .drawable .ic_android_default_round ,
631626 app .getName (),
632627 app .getPackageName (),
633- "Auto-reply disabled" , // or make this dynamic
634628 app .getPackageName ().equals ("com.whatsapp" ) ? true : false
635629 );
636630 appItems .add (item );
@@ -639,7 +633,7 @@ private void showAppsDialog() {
639633 DialogConfig config = new DialogConfig (
640634 DialogType .APPS ,
641635 "Apps" ,
642- "" , // description not needed for this dialog
636+ "Select the apps you want to enable auto-reply for. " , // description not needed for this dialog
643637 false , // showSearch
644638 "Search" ,
645639 "" ,
@@ -687,7 +681,7 @@ private void showCooldownDialog() {
687681 "This prevents sending multiple replies in quick succession." ,
688682 false , // showSearch not needed
689683 "" , // searchHint not needed
690- "" ,
684+ "Save " ,
691685 cooldownOptions
692686 );
693687
@@ -699,9 +693,13 @@ private void showCooldownDialog() {
699693 @ Override
700694 public void onSaveClicked (DialogType dialogType ) {
701695 if (dialogType == DialogType .COOLDOWN ) {
702- long cooldownInMillis = selectedCooldownTime * 60 * 1000L ;
703- preferencesManager .setAutoReplyDelay (cooldownInMillis );
704- Toast .makeText (mActivity , "Cooldown settings saved" , Toast .LENGTH_SHORT ).show ();
696+ if (selectedCooldownTime != -1 ) {
697+ long cooldownInMillis = selectedCooldownTime * 60 * 1000L ;
698+ preferencesManager .setAutoReplyDelay (cooldownInMillis );
699+ updateCooldownFilterDisplay ();
700+ Toast .makeText (mActivity , "Cooldown settings saved" , Toast .LENGTH_SHORT ).show ();
701+ }
702+ selectedCooldownTime = -1 ;//reset so that no accidental cahnges on going back to cooldown page
705703 }
706704 }
707705
@@ -730,9 +728,9 @@ public void onSearchQuery(String query) {
730728 @ Override
731729 public void onCooldownChanged (int totalMinutes ) {
732730 selectedCooldownTime = totalMinutes ;
733- long cooldownInMillis = selectedCooldownTime * 60 * 1000L ;
731+ /* long cooldownInMillis = selectedCooldownTime * 60 * 1000L;
734732 preferencesManager.setAutoReplyDelay(cooldownInMillis);
735- updateCooldownFilterDisplay ();
733+ updateCooldownFilterDisplay();*/
736734 Log .d ("Dialog" , "Total cooldown time: " + totalMinutes );
737735 }
738736}
0 commit comments