use of de.pixart.messenger.entities.PresenceTemplate in project Pix-Art-Messenger by kriztan.
the class DatabaseBackend method getPresenceTemplates.
public List<PresenceTemplate> getPresenceTemplates() {
ArrayList<PresenceTemplate> templates = new ArrayList<>();
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(PresenceTemplate.TABELNAME, null, null, null, null, null, PresenceTemplate.LAST_USED + " desc");
while (cursor.moveToNext()) {
templates.add(PresenceTemplate.fromCursor(cursor));
}
cursor.close();
return templates;
}
use of de.pixart.messenger.entities.PresenceTemplate in project Pix-Art-Messenger by kriztan.
the class EditAccountActivity method changePresence.
private void changePresence() {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
boolean manualStatus = sharedPreferences.getBoolean(SettingsActivity.MANUALLY_CHANGE_PRESENCE, getResources().getBoolean(R.bool.manually_change_presence));
AlertDialog.Builder builder = new AlertDialog.Builder(this);
final DialogPresenceBinding binding = DataBindingUtil.inflate(getLayoutInflater(), R.layout.dialog_presence, null, false);
String current = mAccount.getPresenceStatusMessage();
if (current != null && !current.trim().isEmpty()) {
binding.statusMessage.append(current);
}
setAvailabilityRadioButton(mAccount.getPresenceStatus(), binding);
binding.show.setVisibility(manualStatus ? View.VISIBLE : View.GONE);
List<PresenceTemplate> templates = xmppConnectionService.getPresenceTemplates(mAccount);
PresenceTemplateAdapter presenceTemplateAdapter = new PresenceTemplateAdapter(this, R.layout.simple_list_item, templates);
binding.statusMessage.setAdapter(presenceTemplateAdapter);
binding.statusMessage.setOnItemClickListener((parent, view, position, id) -> {
PresenceTemplate template = (PresenceTemplate) parent.getItemAtPosition(position);
setAvailabilityRadioButton(template.getStatus(), binding);
});
builder.setTitle(R.string.edit_status_message_title);
builder.setView(binding.getRoot());
builder.setNegativeButton(R.string.cancel, null);
builder.setPositiveButton(R.string.confirm, (dialog, which) -> {
PresenceTemplate template = new PresenceTemplate(getAvailabilityRadioButton(binding), binding.statusMessage.getText().toString().trim());
if (mAccount.getPgpId() != 0 && hasPgp()) {
generateSignature(null, template);
} else {
xmppConnectionService.changeStatus(mAccount, template, null);
}
});
builder.create().show();
}
Aggregations