mirror of
https://codeberg.org/gitnex/GitNex.git
synced 2023-12-13 20:50:18 +01:00
98cf1a1976
Removing file size selection dialog in favor of hardcoded value. Adding warning to file size picker and minor improvements. Bump dependencies and gradle Merge branch 'master' of https://codeberg.org/gitnex/GitNex into improve-filetype-recognition Improving credits, adding symlink and submodule icons to FilesAdapter and removing unused libraries. Minor improvements and bug fixes. Add true progress indication routine for copying streams. Merge branch 'master' of https://codeberg.org/gitnex/GitNex into improve-filetype-recognition Performance and memory usage improvements Notification improvements Renaming StaticGlobalVariables to Constants Overall improvements and fixes. Merge branch 'master' of https://codeberg.org/gitnex/GitNex into improve-filetype-recognition Add additional image formats. Adding audio and video categories. Merge branch 'master' of https://codeberg.org/gitnex/GitNex into improve-filetype-recognition Improve file type handling. Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/841 Reviewed-by: M M Arif <mmarif@noreply.codeberg.org> Co-Authored-By: opyale <opyale@noreply.codeberg.org> Co-Committed-By: opyale <opyale@noreply.codeberg.org>
118 lines
4.1 KiB
Java
118 lines
4.1 KiB
Java
package org.mian.gitnex.activities;
|
|
|
|
import android.graphics.Color;
|
|
import android.os.Bundle;
|
|
import android.view.View;
|
|
import android.widget.NumberPicker;
|
|
import androidx.appcompat.app.AlertDialog;
|
|
import com.pes.androidmaterialcolorpickerdialog.ColorPicker;
|
|
import org.mian.gitnex.R;
|
|
import org.mian.gitnex.databinding.ActivitySettingsNotificationsBinding;
|
|
import org.mian.gitnex.helpers.Constants;
|
|
import org.mian.gitnex.helpers.Toasty;
|
|
import org.mian.gitnex.notifications.Notifications;
|
|
|
|
/**
|
|
* Template Author M M Arif
|
|
* Author opyale
|
|
*/
|
|
|
|
public class SettingsNotificationsActivity extends BaseActivity {
|
|
|
|
private ActivitySettingsNotificationsBinding viewBinding;
|
|
|
|
@Override
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
viewBinding = ActivitySettingsNotificationsBinding.inflate(getLayoutInflater());
|
|
setContentView(viewBinding.getRoot());
|
|
|
|
View.OnClickListener onClickListener = viewClose -> finish();
|
|
|
|
viewBinding.close.setOnClickListener(onClickListener);
|
|
|
|
viewBinding.pollingDelaySelected.setText(String.format(getString(R.string.pollingDelaySelectedText), tinyDB.getInt("pollingDelayMinutes", Constants.defaultPollingDelay)));
|
|
viewBinding.chooseColorState.setCardBackgroundColor(tinyDB.getInt("notificationsLightColor", Color.GREEN));
|
|
|
|
viewBinding.enableNotificationsMode.setChecked(tinyDB.getBoolean("notificationsEnabled", true));
|
|
viewBinding.enableLightsMode.setChecked(tinyDB.getBoolean("notificationsEnableLights", true));
|
|
viewBinding.enableVibrationMode.setChecked(tinyDB.getBoolean("notificationsEnableVibration", true));
|
|
|
|
viewBinding.enableNotificationsMode.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
|
|
|
tinyDB.putBoolean("notificationsEnabled", isChecked);
|
|
if(!isChecked) Notifications.stopWorker(ctx);
|
|
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
|
|
|
});
|
|
|
|
// polling delay
|
|
viewBinding.pollingDelayFrame.setOnClickListener(v -> {
|
|
|
|
NumberPicker numberPicker = new NumberPicker(ctx);
|
|
numberPicker.setMinValue(Constants.minimumPollingDelay);
|
|
numberPicker.setMaxValue(Constants.maximumPollingDelay);
|
|
numberPicker.setValue(tinyDB.getInt("pollingDelayMinutes", Constants.defaultPollingDelay));
|
|
numberPicker.setWrapSelectorWheel(true);
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
|
|
builder.setTitle(getString(R.string.pollingDelayDialogHeaderText));
|
|
builder.setMessage(getString(R.string.pollingDelayDialogDescriptionText));
|
|
|
|
builder.setCancelable(true);
|
|
builder.setPositiveButton(getString(R.string.okButton), (dialog, which) -> {
|
|
|
|
tinyDB.putInt("pollingDelayMinutes", numberPicker.getValue());
|
|
|
|
Notifications.stopWorker(ctx);
|
|
Notifications.startWorker(ctx);
|
|
|
|
viewBinding.pollingDelaySelected.setText(String.format(getString(R.string.pollingDelaySelectedText), numberPicker.getValue()));
|
|
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
|
});
|
|
|
|
builder.setNeutralButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss());
|
|
builder.setView(numberPicker);
|
|
builder.create().show();
|
|
|
|
});
|
|
|
|
// lights switcher
|
|
viewBinding.enableLightsMode.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
|
|
|
tinyDB.putBoolean("notificationsEnableLights", isChecked);
|
|
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
|
|
|
});
|
|
|
|
// lights color chooser
|
|
viewBinding.chooseColorFrame.setOnClickListener(v -> {
|
|
|
|
ColorPicker colorPicker = new ColorPicker(SettingsNotificationsActivity.this);
|
|
colorPicker.setColor(tinyDB.getInt("notificationsLightColor", Color.GREEN));
|
|
colorPicker.setCallback(color -> {
|
|
|
|
tinyDB.putInt("notificationsLightColor", color);
|
|
viewBinding.chooseColorState.setCardBackgroundColor(color);
|
|
colorPicker.dismiss();
|
|
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
|
});
|
|
|
|
colorPicker.show();
|
|
|
|
});
|
|
|
|
// vibration switcher
|
|
viewBinding.enableVibrationMode.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
|
|
|
tinyDB.putBoolean("notificationsEnableVibration", isChecked);
|
|
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|