mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-18 21:06:44 -06:00
[UI/Settings] Add grades config dialog to settings fragment.
This commit is contained in:
parent
7d8caa8df7
commit
d48c7844a4
@ -17,6 +17,7 @@ import pl.szczodrzynski.edziennik.setOnSelectedListener
|
||||
|
||||
class GradesConfigDialog(
|
||||
val activity: AppCompatActivity,
|
||||
private val reloadOnDismiss: Boolean = true,
|
||||
val onShowListener: ((tag: String) -> Unit)? = null,
|
||||
val onDismissListener: ((tag: String) -> Unit)? = null
|
||||
) {
|
||||
@ -39,9 +40,10 @@ class GradesConfigDialog(
|
||||
dialog = MaterialAlertDialogBuilder(activity)
|
||||
.setTitle(R.string.menu_grades_config)
|
||||
.setView(b.root)
|
||||
.setPositiveButton(R.string.ok) { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
(activity as? MainActivity)?.reloadTarget()
|
||||
.setPositiveButton(R.string.ok) { dialog, _ -> dialog.dismiss() }
|
||||
.setOnDismissListener {
|
||||
onDismissListener?.invoke(TAG)
|
||||
if (reloadOnDismiss) (activity as? MainActivity)?.reloadTarget()
|
||||
}
|
||||
.create()
|
||||
initView()
|
||||
|
@ -132,7 +132,7 @@ public class GradesFragment extends Fragment {
|
||||
.withIcon(CommunityMaterial.Icon2.cmd_settings_outline)
|
||||
.withOnClickListener(v3 -> {
|
||||
activity.getBottomSheet().close();
|
||||
new GradesConfigDialog(activity, null, null);
|
||||
new GradesConfigDialog(activity, true, null, null);
|
||||
}),
|
||||
new BottomSheetSeparatorItem(true),
|
||||
new BottomSheetPrimaryItem(true)
|
||||
|
@ -52,6 +52,7 @@ import pl.szczodrzynski.edziennik.network.NetworkUtils;
|
||||
import pl.szczodrzynski.edziennik.sync.SyncWorker;
|
||||
import pl.szczodrzynski.edziennik.sync.UpdateWorker;
|
||||
import pl.szczodrzynski.edziennik.ui.dialogs.changelog.ChangelogDialog;
|
||||
import pl.szczodrzynski.edziennik.ui.dialogs.settings.GradesConfigDialog;
|
||||
import pl.szczodrzynski.edziennik.ui.dialogs.settings.ProfileRemoveDialog;
|
||||
import pl.szczodrzynski.edziennik.utils.Themes;
|
||||
import pl.szczodrzynski.edziennik.utils.Utils;
|
||||
@ -858,47 +859,20 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
private MaterialAboutActionItem registerCardAverageModeItem;
|
||||
|
||||
private MaterialAboutSwitchItem registerCardAllowRegistrationItem;
|
||||
private MaterialAboutActionItem registerCardBellSyncItem;
|
||||
private ArrayList<MaterialAboutItem> getRegisterCard(boolean expandedOnly) {
|
||||
ArrayList<MaterialAboutItem> items = new ArrayList<>();
|
||||
if (!expandedOnly) {
|
||||
|
||||
registerCardAverageModeItem = new MaterialAboutActionItem(
|
||||
getString(R.string.settings_register_avg_mode_text),
|
||||
getRegisterCardAverageModeSubText(),
|
||||
items.add(new MaterialAboutActionItem(
|
||||
getString(R.string.menu_grades_config),
|
||||
null,
|
||||
new IconicsDrawable(activity)
|
||||
.icon(CommunityMaterial.Icon2.cmd_scale_balance)
|
||||
.icon(CommunityMaterial.Icon2.cmd_numeric_5_box_outline)
|
||||
.size(IconicsSize.dp(iconSizeDp))
|
||||
.color(IconicsColor.colorInt(iconColor))
|
||||
);
|
||||
registerCardAverageModeItem.setOnClickAction(() -> {
|
||||
List<CharSequence> modeNames = new ArrayList<>();
|
||||
modeNames.add(getString(R.string.settings_register_avg_mode_4));
|
||||
modeNames.add(getString(R.string.settings_register_avg_mode_0));
|
||||
modeNames.add(getString(R.string.settings_register_avg_mode_1));
|
||||
modeNames.add(getString(R.string.settings_register_avg_mode_2));
|
||||
modeNames.add(getString(R.string.settings_register_avg_mode_3));
|
||||
List<Integer> modeIds = new ArrayList<>();
|
||||
modeIds.add(YEAR_ALL_GRADES);
|
||||
modeIds.add(YEAR_1_AVG_2_AVG);
|
||||
modeIds.add(YEAR_1_SEM_2_AVG);
|
||||
modeIds.add(YEAR_1_AVG_2_SEM);
|
||||
modeIds.add(YEAR_1_SEM_2_SEM);
|
||||
new MaterialDialog.Builder(activity)
|
||||
.title(getString(R.string.settings_register_avg_mode_dialog_title))
|
||||
.content(getString(R.string.settings_register_avg_mode_dialog_text))
|
||||
.items(modeNames)
|
||||
.itemsCallbackSingleChoice(modeIds.indexOf(app.getConfig().forProfile().getGrades().getYearAverageMode()), (dialog, itemView, which, text) -> {
|
||||
app.getConfig().forProfile().getGrades().setYearAverageMode(modeIds.get(which));
|
||||
registerCardAverageModeItem.setSubText(getRegisterCardAverageModeSubText());
|
||||
refreshMaterialAboutList();
|
||||
return true;
|
||||
})
|
||||
.show();
|
||||
});
|
||||
items.add(registerCardAverageModeItem);
|
||||
).setOnClickAction(() -> new GradesConfigDialog(activity, false, null, null)));
|
||||
|
||||
registerCardAllowRegistrationItem = new MaterialAboutSwitchItem(
|
||||
getString(R.string.settings_register_allow_registration_text),
|
||||
@ -960,7 +934,6 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
||||
items.add(getMoreItem(() -> addCardItems(CARD_REGISTER, getRegisterCard(true))));
|
||||
}
|
||||
else {
|
||||
|
||||
registerCardBellSyncItem = new MaterialAboutActionItem(
|
||||
getString(R.string.settings_register_bell_sync_text),
|
||||
getRegisterCardBellSyncSubText(),
|
||||
@ -1030,22 +1003,6 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
||||
});
|
||||
items.add(registerCardBellSyncItem);
|
||||
|
||||
items.add(
|
||||
new MaterialAboutSwitchItem(
|
||||
getString(R.string.settings_register_dont_count_zero_text),
|
||||
null,
|
||||
new IconicsDrawable(activity)
|
||||
.icon(CommunityMaterial.Icon2.cmd_numeric_0_box_outline)
|
||||
.size(IconicsSize.dp(iconSizeDp))
|
||||
.color(IconicsColor.colorInt(iconColor))
|
||||
)
|
||||
.setChecked(!app.getConfig().getFor(app.getProfileId()).getGrades().getCountZeroToAvg())
|
||||
.setOnChangeAction((isChecked, tag) -> {
|
||||
app.getConfig().getFor(app.getProfileId()).getGrades().setCountZeroToAvg(!isChecked);
|
||||
return true;
|
||||
})
|
||||
);
|
||||
|
||||
items.add(
|
||||
new MaterialAboutSwitchItem(
|
||||
getString(R.string.settings_register_count_in_seconds_text),
|
||||
|
@ -958,5 +958,5 @@
|
||||
<string name="dialog_grades_config_color_from_eregister">From e-register</string>
|
||||
<string name="dialog_grades_config_color_by_value">By grade\'s value</string>
|
||||
<string name="other">Other</string>
|
||||
<string name="menu_grades_config">Grades view config</string>
|
||||
<string name="menu_grades_config">Grades settings</string>
|
||||
</resources>
|
||||
|
@ -1172,5 +1172,5 @@
|
||||
<string name="dialog_grades_config_color_from_eregister">Wg e-dziennika</string>
|
||||
<string name="dialog_grades_config_color_by_value">Wg wartości oceny</string>
|
||||
<string name="other">Inne</string>
|
||||
<string name="menu_grades_config">Ustawienia widoku ocen</string>
|
||||
<string name="menu_grades_config">Ustawienia ocen</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user