use of com.xabber.android.data.message.phrase.Phrase in project xabber-android by redsolution.
the class PhraseEditorFragment method setValues.
@Override
protected boolean setValues(Map<String, Object> source, Map<String, Object> result) {
String text = getString(result, R.string.phrase_text_key);
String user = getString(result, R.string.phrase_user_key);
String group = getString(result, R.string.phrase_group_key);
boolean regexp = getBoolean(result, R.string.phrase_regexp_key);
Log.i("PhraseEditorFragment", "setValues. text: " + text);
if (regexp) {
try {
Phrase.compile(text);
Phrase.compile(user);
Phrase.compile(group);
} catch (PatternSyntaxException e) {
Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show();
return false;
}
}
Phrase phrase = mListener.getPhrase();
if (phrase == null && "".equals(text) && "".equals(user) && "".equals(group)) {
Toast.makeText(getActivity(), R.string.events_phrases_error, Toast.LENGTH_LONG).show();
return false;
}
Log.i("PhraseEditorFragment", "updateOrCreatePhrase");
PhraseManager.getInstance().updateOrCreatePhrase(phrase, text, user, group, regexp, null);
mListener.setPhrase(phrase);
return true;
}
use of com.xabber.android.data.message.phrase.Phrase in project xabber-android by redsolution.
the class PhraseEditorFragment method getValues.
@Override
protected Map<String, Object> getValues() {
Phrase phrase = mListener.getPhrase();
Map<String, Object> source = new HashMap<>();
putValue(source, R.string.phrase_text_key, phrase == null ? "" : phrase.getText());
putValue(source, R.string.phrase_user_key, phrase == null ? "" : phrase.getUser());
putValue(source, R.string.phrase_group_key, phrase == null ? "" : phrase.getGroup());
putValue(source, R.string.phrase_regexp_key, phrase != null && phrase.isRegexp());
return source;
}
use of com.xabber.android.data.message.phrase.Phrase in project xabber-android by redsolution.
the class PhraseEditor method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
index = getPhraseIndex(getIntent());
if (index == null) {
finish();
return;
}
Phrase phrase = PhraseManager.getInstance().getPhrase(index);
if (phrase == null) {
finish();
return;
}
setPhrase(phrase);
String title = phrase.getText();
if ("".equals(title))
title = Application.getInstance().getString(R.string.phrase_empty);
Toolbar toolbar = ToolbarHelper.setUpDefaultToolbar(this, title);
toolbar.inflateMenu(R.menu.toolbar_delete);
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
return onOptionsItemSelected(item);
}
});
BarPainter barPainter = new BarPainter(this, toolbar);
barPainter.setDefaultColor();
}
use of com.xabber.android.data.message.phrase.Phrase in project xabber-android by redsolution.
the class Key method generatePhraseName.
public String generatePhraseName(Context context, Long id) {
Phrase phrase = PhraseManager.getInstance().getPhrase(id);
String result = context.getString(R.string.events_phrase);
if (phrase != null) {
if (phrase.getText() != null && !phrase.getText().isEmpty())
result += ": " + phrase.getText();
else if (phrase.getUser() != null && !phrase.getUser().isEmpty())
result += ": " + phrase.getUser();
else if (phrase.getGroup() != null && !phrase.getGroup().isEmpty())
result += ": " + phrase.getGroup();
}
return result;
}
use of com.xabber.android.data.message.phrase.Phrase in project xabber-android by redsolution.
the class PhraseEditorFragment method onResume.
@Override
public void onResume() {
super.onResume();
Phrase phrase = mListener.getPhrase();
Preference notificationPref = findPreference("notification_settings");
if (phrase != null) {
notificationPref.setIntent(CustomNotifySettings.createIntent(getActivity(), phrase.getId()));
notificationPref.setEnabled(true);
} else {
notificationPref.setEnabled(false);
notificationPref.setSummary(R.string.events_use_custom_not_allowed_summary);
}
}
Aggregations