aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-05-22 18:20:57 +0200
committerDaniel Gultsch <daniel@gultsch.de>2016-05-22 18:20:57 +0200
commitabbdf232c6f27a00edaa9af5937f9d022ad15f65 (patch)
tree5fbff83eb2892a5cdacff353ac3ebabde88f347c
parentd84cf4e6d1e94225df877a3c99e80742b295f3a8 (diff)
show hint in subject quick edit. only show subject as preset
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java5
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java2
-rw-r--r--src/main/java/eu/siacs/conversations/ui/XmppActivity.java24
3 files changed, 20 insertions, 11 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
index 2e4b94e58..541306ad3 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
@@ -252,6 +252,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
@Override
public void onClick(View v) {
quickEdit(mConversation.getMucOptions().getActualNick(),
+ 0,
new OnValueEdited() {
@Override
@@ -278,7 +279,9 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
break;
case R.id.action_edit_subject:
if (mConversation != null) {
- quickEdit(mConversation.getName(),this.onSubjectEdited);
+ quickEdit(mConversation.getMucOptions().getSubject(),
+ R.string.action_edit_subject,
+ this.onSubjectEdited);
}
break;
case R.id.action_share:
diff --git a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
index 76dc306d7..f8f8fc590 100644
--- a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
@@ -243,7 +243,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
break;
case R.id.action_edit_contact:
if (contact.getSystemAccount() == null) {
- quickEdit(contact.getDisplayName(), new OnValueEdited() {
+ quickEdit(contact.getDisplayName(), 0, new OnValueEdited() {
@Override
public void onValueEdited(String value) {
diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
index 858806e3e..f1cf873ec 100644
--- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
@@ -662,18 +662,19 @@ public abstract class XmppActivity extends Activity {
builder.create().show();
}
- protected void quickEdit(String previousValue, OnValueEdited callback) {
- quickEdit(previousValue, callback, false);
+ protected void quickEdit(String previousValue, int hint, OnValueEdited callback) {
+ quickEdit(previousValue, callback, hint, false);
}
- protected void quickPasswordEdit(String previousValue,
- OnValueEdited callback) {
- quickEdit(previousValue, callback, true);
+ protected void quickPasswordEdit(String previousValue, OnValueEdited callback) {
+ quickEdit(previousValue, callback, R.string.password, true);
}
@SuppressLint("InflateParams")
private void quickEdit(final String previousValue,
- final OnValueEdited callback, boolean password) {
+ final OnValueEdited callback,
+ final int hint,
+ boolean password) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
View view = getLayoutInflater().inflate(R.layout.quickedit, null);
final EditText editor = (EditText) view.findViewById(R.id.editor);
@@ -682,7 +683,7 @@ public abstract class XmppActivity extends Activity {
@Override
public void onClick(DialogInterface dialog, int which) {
String value = editor.getText().toString();
- if (!previousValue.equals(value) && value.trim().length() > 0) {
+ if (!value.equals(previousValue) && value.trim().length() > 0) {
callback.onValueEdited(value);
}
}
@@ -690,13 +691,18 @@ public abstract class XmppActivity extends Activity {
if (password) {
editor.setInputType(InputType.TYPE_CLASS_TEXT
| InputType.TYPE_TEXT_VARIATION_PASSWORD);
- editor.setHint(R.string.password);
builder.setPositiveButton(R.string.accept, mClickListener);
} else {
builder.setPositiveButton(R.string.edit, mClickListener);
}
+ if (hint != 0) {
+ editor.setHint(hint);
+ }
editor.requestFocus();
- editor.setText(previousValue);
+ editor.setText("");
+ if (previousValue != null) {
+ editor.getText().append(previousValue);
+ }
builder.setView(view);
builder.setNegativeButton(R.string.cancel, null);
builder.create().show();