mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-27 16:33:47 +00:00
Added day scheduling
This commit is contained in:
parent
75ce2a4250
commit
57a142b3cb
2 changed files with 94 additions and 10 deletions
|
@ -32,6 +32,7 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
@ -45,6 +46,7 @@ import androidx.fragment.app.DialogFragment;
|
|||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import java.text.DateFormatSymbols;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
|
@ -52,9 +54,10 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
|
|||
private SwitchCompat swEnabled;
|
||||
private Spinner spPollInterval;
|
||||
private SwitchCompat swSchedule;
|
||||
private TextView tvSchedulePro;
|
||||
private TextView tvScheduleStart;
|
||||
private TextView tvScheduleEnd;
|
||||
private TextView tvSchedulePro;
|
||||
private CheckBox[] cbDay;
|
||||
private SwitchCompat swUnseen;
|
||||
private SwitchCompat swFlagged;
|
||||
private SwitchCompat swDeleteUnseen;
|
||||
|
@ -83,9 +86,18 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
|
|||
swEnabled = view.findViewById(R.id.swEnabled);
|
||||
spPollInterval = view.findViewById(R.id.spPollInterval);
|
||||
swSchedule = view.findViewById(R.id.swSchedule);
|
||||
tvSchedulePro = view.findViewById(R.id.tvSchedulePro);
|
||||
tvScheduleStart = view.findViewById(R.id.tvScheduleStart);
|
||||
tvScheduleEnd = view.findViewById(R.id.tvScheduleEnd);
|
||||
tvSchedulePro = view.findViewById(R.id.tvSchedulePro);
|
||||
cbDay = new CheckBox[]{
|
||||
view.findViewById(R.id.cbDay0),
|
||||
view.findViewById(R.id.cbDay1),
|
||||
view.findViewById(R.id.cbDay2),
|
||||
view.findViewById(R.id.cbDay3),
|
||||
view.findViewById(R.id.cbDay4),
|
||||
view.findViewById(R.id.cbDay5),
|
||||
view.findViewById(R.id.cbDay6)
|
||||
};
|
||||
swUnseen = view.findViewById(R.id.swUnseen);
|
||||
swFlagged = view.findViewById(R.id.swFlagged);
|
||||
swDeleteUnseen = view.findViewById(R.id.swDeleteUnseen);
|
||||
|
@ -144,6 +156,8 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
|
|||
}
|
||||
});
|
||||
|
||||
Helper.linkPro(tvSchedulePro);
|
||||
|
||||
tvScheduleStart.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -166,7 +180,18 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
|
|||
}
|
||||
});
|
||||
|
||||
Helper.linkPro(tvSchedulePro);
|
||||
String[] daynames = new DateFormatSymbols().getWeekdays();
|
||||
for (int i = 0; i < 7; i++) {
|
||||
final int day = i;
|
||||
cbDay[i].setText(daynames[i + 1]);
|
||||
cbDay[i].setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
prefs.edit().putBoolean("schedule_day" + day, isChecked).apply();
|
||||
ServiceSynchronize.reschedule(getContext());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
swUnseen.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
|
@ -294,6 +319,8 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
|
|||
swSchedule.setEnabled(pro);
|
||||
tvScheduleStart.setText(formatHour(getContext(), prefs.getInt("schedule_start", 0)));
|
||||
tvScheduleEnd.setText(formatHour(getContext(), prefs.getInt("schedule_end", 0)));
|
||||
for (int i = 0; i < 7; i++)
|
||||
cbDay[i].setChecked(prefs.getBoolean("schedule_day" + i, true));
|
||||
|
||||
swUnseen.setChecked(prefs.getBoolean("sync_unseen", false));
|
||||
swFlagged.setChecked(prefs.getBoolean("sync_flagged", false));
|
||||
|
|
|
@ -107,6 +107,16 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/tvPollHint"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvSchedulePro"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/title_pro_feature"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textColor="?android:attr/textColorLink"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swSchedule" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvScheduleStart"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -116,7 +126,7 @@
|
|||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swSchedule" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tvSchedulePro" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvScheduleSeparator"
|
||||
|
@ -152,16 +162,63 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvScheduleStart" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvSchedulePro"
|
||||
<CheckBox
|
||||
android:id="@+id/cbDay0"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/title_pro_feature"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textColor="?android:attr/textColorLink"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="Sunday"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvScheduleHint" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbDay1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Monday"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbDay0" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbDay2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Tuesday"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbDay1" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbDay3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Wednesday"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbDay2" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbDay4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Thursday"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbDay3" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbDay5"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Friday"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbDay4" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbDay6"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Saturday"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbDay5" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swUnseen"
|
||||
android:layout_width="0dp"
|
||||
|
@ -170,7 +227,7 @@
|
|||
android:text="@string/title_advanced_unseen"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvSchedulePro"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbDay6"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<TextView
|
||||
|
|
Loading…
Reference in a new issue