use of mobi.upod.timedurationpicker.TimeDurationPickerDialog in project PhoneProfilesPlus by henrichg.
the class DurationDialogPreference method showDialog.
@SuppressLint("SetTextI18n")
@Override
protected void showDialog(Bundle state) {
MaterialDialog.Builder mBuilder = new MaterialDialog.Builder(getContext()).title(getDialogTitle()).icon(getDialogIcon()).positiveText(getPositiveButtonText()).negativeText(getNegativeButtonText()).content(getDialogMessage()).customView(R.layout.activity_duration_pref_dialog, true).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
int hours = mSeekBarHours.getProgress();
int minutes = mSeekBarMinutes.getProgress();
int seconds = mSeekBarSeconds.getProgress();
int iValue = (hours * 3600 + minutes * 60 + seconds);
if (iValue < mMin)
iValue = mMin;
if (iValue > mMax)
iValue = mMax;
value = String.valueOf(iValue);
if (callChangeListener(value)) {
// persistInt(mNumberPicker.getValue());
persistString(value);
setSummaryDDP();
}
}
});
mDialog = mBuilder.build();
View layout = mDialog.getCustomView();
// noinspection ConstantConditions
TextView mTextViewRange = layout.findViewById(R.id.duration_pref_dlg_range);
mValue = layout.findViewById(R.id.duration_pref_dlg_value);
mSeekBarHours = layout.findViewById(R.id.duration_pref_dlg_hours);
mSeekBarMinutes = layout.findViewById(R.id.duration_pref_dlg_minutes);
mSeekBarSeconds = layout.findViewById(R.id.duration_pref_dlg_seconds);
// mSeekBarHours.setRotation(180);
// mSeekBarMinutes.setRotation(180);
// mSeekBarSeconds.setRotation(180);
// Initialize state
int hours;
int minutes;
int seconds;
hours = mMax / 3600;
minutes = (mMax % 3600) / 60;
seconds = mMax % 60;
final String sMax = GlobalGUIRoutines.getDurationString(mMax);
mSeekBarHours.setMax(hours);
if (hours == 0)
mSeekBarMinutes.setMax(minutes);
else
mSeekBarMinutes.setMax(59);
if ((hours == 0) && (minutes == 0))
mSeekBarSeconds.setMax(seconds);
else
mSeekBarSeconds.setMax(59);
final String sMin = GlobalGUIRoutines.getDurationString(mMin);
int iValue = Integer.valueOf(value);
hours = iValue / 3600;
minutes = (iValue % 3600) / 60;
seconds = iValue % 60;
mSeekBarHours.setProgress(hours);
mSeekBarMinutes.setProgress(minutes);
mSeekBarSeconds.setProgress(seconds);
mValue.setText(GlobalGUIRoutines.getDurationString(iValue));
mValueDialog = new TimeDurationPickerDialog(context, new TimeDurationPickerDialog.OnDurationSetListener() {
@Override
public void onDurationSet(TimeDurationPicker view, long duration) {
int iValue = (int) duration / 1000;
if (iValue < mMin)
iValue = mMin;
if (iValue > mMax)
iValue = mMax;
mValue.setText(GlobalGUIRoutines.getDurationString(iValue));
int hours = iValue / 3600;
int minutes = (iValue % 3600) / 60;
int seconds = iValue % 60;
mSeekBarHours.setProgress(hours);
mSeekBarMinutes.setProgress(minutes);
mSeekBarSeconds.setProgress(seconds);
}
}, iValue * 1000, TimeDurationPicker.HH_MM_SS);
mValue.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int hours = mSeekBarHours.getProgress();
int minutes = mSeekBarMinutes.getProgress();
int seconds = mSeekBarSeconds.getProgress();
int iValue = (hours * 3600 + minutes * 60 + seconds);
if (iValue < mMin)
iValue = mMin;
if (iValue > mMax)
iValue = mMax;
mValueDialog.setDuration(iValue * 1000);
mValueDialog.show();
}
});
mSeekBarHours.setOnSeekBarChangeListener(this);
mSeekBarMinutes.setOnSeekBarChangeListener(this);
mSeekBarSeconds.setOnSeekBarChangeListener(this);
mTextViewRange.setText(sMin + " - " + sMax);
GlobalGUIRoutines.registerOnActivityDestroyListener(this, this);
if (state != null)
mDialog.onRestoreInstanceState(state);
mDialog.setOnDismissListener(this);
mDialog.show();
}
use of mobi.upod.timedurationpicker.TimeDurationPickerDialog in project PhoneProfilesPlus by henrichg.
the class MobileCellsRegistrationDialogPreference method showDialog.
@SuppressLint("SetTextI18n")
@Override
protected void showDialog(Bundle state) {
MaterialDialog.Builder mBuilder = new MaterialDialog.Builder(getContext()).title(getDialogTitle()).icon(getDialogIcon()).positiveText(R.string.mobile_cells_registration_pref_dlg_start_button).negativeText(getNegativeButtonText()).content(getDialogMessage()).customView(R.layout.activity_mobile_cells_registration_pref_dialog, true).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
int hours = mSeekBarHours.getProgress();
int minutes = mSeekBarMinutes.getProgress();
int seconds = mSeekBarSeconds.getProgress();
int iValue = (hours * 3600 + minutes * 60 + seconds);
if (iValue < mMin)
iValue = mMin;
if (iValue > mMax)
iValue = mMax;
// Log.d("MobileCellsRegistrationDialogPreference.onPositive","iValue="+iValue);
// Log.d("MobileCellsRegistrationDialogPreference.onPositive","is started");
MobileCellsRegistrationService.setMobileCellsAutoRegistrationRemainingDuration(context, iValue);
PhoneStateScanner.durationForAutoRegistration = iValue;
PhoneStateScanner.cellsNameForAutoRegistration = mCellsName.getText().toString();
PhoneStateScanner.enabledAutoRegistration = true;
MobileCellsRegistrationService.setMobileCellsAutoRegistration(context, false);
PhoneStateScanner.startAutoRegistration(context);
value = String.valueOf(iValue);
setSummaryDDP(0);
/*
value = String.valueOf(iValue);
if (callChangeListener(value)) {
//persistInt(mNumberPicker.getValue());
persistString(value);
}
*/
}
});
mBuilder.showListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
updateInterface(0, false);
}
});
mDialog = mBuilder.build();
View layout = mDialog.getCustomView();
// noinspection ConstantConditions
TextView mTextViewRange = layout.findViewById(R.id.duration_pref_dlg_range);
// noinspection ConstantConditions
mValue = layout.findViewById(R.id.duration_pref_dlg_value);
// noinspection ConstantConditions
mSeekBarHours = layout.findViewById(R.id.duration_pref_dlg_hours);
// noinspection ConstantConditions
mSeekBarMinutes = layout.findViewById(R.id.duration_pref_dlg_minutes);
// noinspection ConstantConditions
mSeekBarSeconds = layout.findViewById(R.id.duration_pref_dlg_seconds);
// noinspection ConstantConditions
mCellsName = layout.findViewById(R.id.mobile_cells_registration_cells_name);
// noinspection ConstantConditions
mStatus = layout.findViewById(R.id.mobile_cells_registration_status);
// noinspection ConstantConditions
mRemainingTime = layout.findViewById(R.id.mobile_cells_registration_remaining_time);
mCellsName.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
String value = mCellsName.getText().toString();
MDButton button = mDialog.getActionButton(DialogAction.POSITIVE);
button.setEnabled(!value.isEmpty());
}
});
// mSeekBarHours.setRotation(180);
// mSeekBarMinutes.setRotation(180);
// mSeekBarSeconds.setRotation(180);
// Initialize state
int hours;
int minutes;
int seconds;
hours = mMax / 3600;
minutes = (mMax % 3600) / 60;
seconds = mMax % 60;
final String sMax = GlobalGUIRoutines.getDurationString(mMax);
mSeekBarHours.setMax(hours);
if (hours == 0)
mSeekBarMinutes.setMax(minutes);
else
mSeekBarMinutes.setMax(59);
if ((hours == 0) && (minutes == 0))
mSeekBarSeconds.setMax(seconds);
else
mSeekBarSeconds.setMax(59);
final String sMin = GlobalGUIRoutines.getDurationString(mMin);
int iValue = Integer.valueOf(value);
hours = iValue / 3600;
minutes = (iValue % 3600) / 60;
seconds = iValue % 60;
mSeekBarHours.setProgress(hours);
mSeekBarMinutes.setProgress(minutes);
mSeekBarSeconds.setProgress(seconds);
mValue.setText(GlobalGUIRoutines.getDurationString(iValue));
mValueDialog = new TimeDurationPickerDialog(context, new TimeDurationPickerDialog.OnDurationSetListener() {
@Override
public void onDurationSet(TimeDurationPicker view, long duration) {
int iValue = (int) duration / 1000;
if (iValue < mMin)
iValue = mMin;
if (iValue > mMax)
iValue = mMax;
mValue.setText(GlobalGUIRoutines.getDurationString(iValue));
int hours = iValue / 3600;
int minutes = (iValue % 3600) / 60;
int seconds = iValue % 60;
mSeekBarHours.setProgress(hours);
mSeekBarMinutes.setProgress(minutes);
mSeekBarSeconds.setProgress(seconds);
}
}, iValue * 1000, TimeDurationPicker.HH_MM_SS);
mValue.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int hours = mSeekBarHours.getProgress();
int minutes = mSeekBarMinutes.getProgress();
int seconds = mSeekBarSeconds.getProgress();
int iValue = (hours * 3600 + minutes * 60 + seconds);
if (iValue < mMin)
iValue = mMin;
if (iValue > mMax)
iValue = mMax;
mValueDialog.setDuration(iValue * 1000);
mValueDialog.show();
}
});
mMobileCellNamesDialog = new MobileCellNamesDialog(context, this, false);
mCellsName.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mMobileCellNamesDialog.show();
}
});
mSeekBarHours.setOnSeekBarChangeListener(this);
mSeekBarMinutes.setOnSeekBarChangeListener(this);
mSeekBarSeconds.setOnSeekBarChangeListener(this);
mTextViewRange.setText(sMin + " - " + sMax);
stopButton = layout.findViewById(R.id.mobile_cells_registration_stop_button);
stopButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateInterface(0, true);
MobileCellsRegistrationService.setMobileCellsAutoRegistrationRemainingDuration(context, 0);
// PPApplication.phoneProfilesService.phoneStateScanner.durationForAutoRegistration = 0;
// PPApplication.phoneProfilesService.phoneStateScanner.cellsNameForAutoRegistration = "";
PhoneStateScanner.enabledAutoRegistration = false;
MobileCellsRegistrationService.setMobileCellsAutoRegistration(context, false);
setSummaryDDP(0);
PhoneStateScanner.stopAutoRegistration(context);
}
});
GlobalGUIRoutines.registerOnActivityDestroyListener(this, this);
if (state != null)
mDialog.onRestoreInstanceState(state);
mDialog.setOnDismissListener(this);
String value = mCellsName.getText().toString();
MDButton button = mDialog.getActionButton(DialogAction.POSITIVE);
button.setEnabled(!value.isEmpty());
mDialog.show();
}
use of mobi.upod.timedurationpicker.TimeDurationPickerDialog in project krypton-android by kryptco.
the class HomeFragment method updateUI.
private void updateUI(Sigchain.TeamHomeData teamHomeData) {
swipeRefreshLayout.setRefreshing(false);
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
teamName.setText(teamHomeData.name);
email.setText(teamHomeData.email);
if (teamHomeData.is_admin) {
adminText.setAlpha(1);
tempApprovalButton.setVisibility(View.VISIBLE);
inviteButton.setVisibility(View.VISIBLE);
} else {
adminText.setAlpha(0);
tempApprovalButton.setVisibility(View.INVISIBLE);
inviteButton.setVisibility(View.GONE);
}
teamName.setEnabled(teamHomeData.is_admin);
tempApprovalButton.setEnabled(teamHomeData.is_admin);
auditLoggingSwitch.setEnabled(teamHomeData.is_admin);
inviteButton.setEnabled(teamHomeData.is_admin);
if (teamHomeData.nOpenInvites > 0 && teamHomeData.is_admin) {
cancelInvitesButton.setVisibility(View.VISIBLE);
cancelInvitesButton.setEnabled(true);
cancelInvitesButton.setText("Close " + teamHomeData.nOpenInvites + " Active Invitations");
} else {
cancelInvitesButton.setVisibility(View.GONE);
cancelInvitesButton.setEnabled(false);
}
int activeMemberCount = 0;
for (Sigchain.Member member : teamHomeData.members) {
if (!member.is_removed) {
activeMemberCount++;
}
}
membersText.setText(activeMemberCount + " members");
pinnedHostsText.setText(teamHomeData.pinnedHosts.length + " pinned hosts");
activityText.setText(teamHomeData.nBlocks + " events");
teamName.setSingleLine();
teamName.setOnEditorActionListener((v, actionId, event) -> {
teamName.clearFocus();
if (imm != null) {
imm.hideSoftInputFromWindow(teamName.getWindowToken(), 0);
}
if (v.getText().toString().equals(teamHomeData.name)) {
return true;
}
Sigchain.RequestableTeamOperation request = Sigchain.RequestableTeamOperation.setTeamInfo(new Sigchain.TeamInfo(v.getText().toString()));
EventBus.getDefault().post(new TeamService.RequestTeamOperation(request, C.withConfirmStatusCallback(getActivity(), r -> EventBus.getDefault().post(new TeamService.UpdateTeamHomeData(getContext())))));
return true;
});
if (teamHomeData.temporaryApprovalSeconds != null) {
if (teamHomeData.temporaryApprovalSeconds == 0) {
tempApprovalText.setText("Disabled");
} else {
tempApprovalText.setText(TimeUtils.formatDurationSeconds(teamHomeData.temporaryApprovalSeconds));
}
} else {
tempApprovalText.setText("Unrestricted");
}
Runnable editTempApproval = () -> {
new TimeDurationPickerDialog(getContext(), (v_, d) -> {
new Thread(() -> {
EventBus.getDefault().post(new TeamService.RequestTeamOperation(new Sigchain.RequestableTeamOperation(new Sigchain.Policy(d / 1000)), C.withConfirmStatus(getActivity())));
scheduleUpdate(getContext());
}).start();
}, (Policy.temporaryApprovalSeconds(getContext(), Approval.ApprovalType.SSH_USER_HOST)) * 1000).show();
};
if (teamHomeData.is_admin) {
tempApprovalButton.setOnClickListener(v -> editTempApproval.run());
tempApprovalText.setOnClickListener(v -> editTempApproval.run());
} else {
tempApprovalButton.setOnClickListener(null);
tempApprovalText.setOnClickListener(null);
}
auditLoggingSwitch.setChecked(teamHomeData.auditLogsEnabled);
if (teamHomeData.auditLogsEnabled) {
auditLoggingText.setText("Enabled");
} else {
auditLoggingText.setText("Disabled");
}
inviteButton.setOnClickListener(v -> {
getFragmentManager().beginTransaction().setCustomAnimations(R.anim.fade_in, R.anim.fade_out, R.anim.fade_in, R.anim.fade_out).replace(R.id.fragmentOverlay, CreateInviteDialogFragment.newInstance(teamHomeData.name, teamHomeData.email)).addToBackStack(null).commitAllowingStateLoss();
});
}
use of mobi.upod.timedurationpicker.TimeDurationPickerDialog in project PhoneProfiles by henrichg.
the class DurationDialogPreference method showDialog.
@SuppressLint("SetTextI18n")
@Override
protected void showDialog(Bundle state) {
MaterialDialog.Builder mBuilder = new MaterialDialog.Builder(getContext()).title(getDialogTitle()).icon(getDialogIcon()).positiveText(getPositiveButtonText()).negativeText(getNegativeButtonText()).content(getDialogMessage()).customView(R.layout.activity_duration_pref_dialog, true).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
int hours = mSeekBarHours.getProgress();
int minutes = mSeekBarMinutes.getProgress();
int seconds = mSeekBarSeconds.getProgress();
int iValue = (hours * 3600 + minutes * 60 + seconds);
if (iValue < mMin)
iValue = mMin;
if (iValue > mMax)
iValue = mMax;
value = String.valueOf(iValue);
if (callChangeListener(value)) {
// persistInt(mNumberPicker.getValue());
persistString(value);
setSummaryDDP();
}
}
});
mDialog = mBuilder.build();
View layout = mDialog.getCustomView();
// noinspection ConstantConditions
TextView mTextViewRange = layout.findViewById(R.id.duration_pref_dlg_range);
// noinspection ConstantConditions
mValue = layout.findViewById(R.id.duration_pref_dlg_value);
// noinspection ConstantConditions
mSeekBarHours = layout.findViewById(R.id.duration_pref_dlg_hours);
// noinspection ConstantConditions
mSeekBarMinutes = layout.findViewById(R.id.duration_pref_dlg_minutes);
// noinspection ConstantConditions
mSeekBarSeconds = layout.findViewById(R.id.duration_pref_dlg_seconds);
// mSeekBarHours.setRotation(180);
// mSeekBarMinutes.setRotation(180);
// mSeekBarSeconds.setRotation(180);
// Initialize state
int hours;
int minutes;
int seconds;
hours = mMax / 3600;
minutes = (mMax % 3600) / 60;
seconds = mMax % 60;
final String sMax = GlobalGUIRoutines.getDurationString(mMax);
mSeekBarHours.setMax(hours);
if (hours == 0)
mSeekBarMinutes.setMax(minutes);
else
mSeekBarMinutes.setMax(59);
if ((hours == 0) && (minutes == 0))
mSeekBarSeconds.setMax(seconds);
else
mSeekBarSeconds.setMax(59);
final String sMin = GlobalGUIRoutines.getDurationString(mMin);
int iValue = Integer.valueOf(value);
hours = iValue / 3600;
minutes = (iValue % 3600) / 60;
seconds = iValue % 60;
mSeekBarHours.setProgress(hours);
mSeekBarMinutes.setProgress(minutes);
mSeekBarSeconds.setProgress(seconds);
mValue.setText(GlobalGUIRoutines.getDurationString(iValue));
mValueDialog = new TimeDurationPickerDialog(context, new TimeDurationPickerDialog.OnDurationSetListener() {
@Override
public void onDurationSet(TimeDurationPicker view, long duration) {
int iValue = (int) duration / 1000;
if (iValue < mMin)
iValue = mMin;
if (iValue > mMax)
iValue = mMax;
mValue.setText(GlobalGUIRoutines.getDurationString(iValue));
int hours = iValue / 3600;
int minutes = (iValue % 3600) / 60;
int seconds = iValue % 60;
mSeekBarHours.setProgress(hours);
mSeekBarMinutes.setProgress(minutes);
mSeekBarSeconds.setProgress(seconds);
}
}, iValue * 1000, TimeDurationPicker.HH_MM_SS);
mValue.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int hours = mSeekBarHours.getProgress();
int minutes = mSeekBarMinutes.getProgress();
int seconds = mSeekBarSeconds.getProgress();
int iValue = (hours * 3600 + minutes * 60 + seconds);
if (iValue < mMin)
iValue = mMin;
if (iValue > mMax)
iValue = mMax;
mValueDialog.setDuration(iValue * 1000);
mValueDialog.show();
}
});
mSeekBarHours.setOnSeekBarChangeListener(this);
mSeekBarMinutes.setOnSeekBarChangeListener(this);
mSeekBarSeconds.setOnSeekBarChangeListener(this);
mTextViewRange.setText(sMin + " - " + sMax);
GlobalGUIRoutines.registerOnActivityDestroyListener(this, this);
if (state != null)
mDialog.onRestoreInstanceState(state);
mDialog.setOnDismissListener(this);
mDialog.show();
}
Aggregations