open/close soft keyboard in quick edit
This commit is contained in:
parent
64aa238d57
commit
1b0e9f2f0d
|
@ -13,7 +13,9 @@ import android.os.AsyncTask;
|
|||
import android.os.Bundle;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.Editable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -48,13 +50,14 @@ import eu.siacs.conversations.services.XmppConnectionService.OnConversationUpdat
|
|||
import eu.siacs.conversations.services.XmppConnectionService.OnMucRosterUpdate;
|
||||
import eu.siacs.conversations.ui.util.MenuDoubleTabUtil;
|
||||
import eu.siacs.conversations.ui.util.MyLinkify;
|
||||
import eu.siacs.conversations.ui.util.SoftKeyboardUtils;
|
||||
import eu.siacs.conversations.utils.UIHelper;
|
||||
import eu.siacs.conversations.utils.XmppUri;
|
||||
import rocks.xmpp.addr.Jid;
|
||||
|
||||
import static eu.siacs.conversations.entities.Bookmark.printableValue;
|
||||
|
||||
public class ConferenceDetailsActivity extends XmppActivity implements OnConversationUpdate, OnMucRosterUpdate, XmppConnectionService.OnAffiliationChanged, XmppConnectionService.OnRoleChanged, XmppConnectionService.OnConfigurationPushed {
|
||||
public class ConferenceDetailsActivity extends XmppActivity implements OnConversationUpdate, OnMucRosterUpdate, XmppConnectionService.OnAffiliationChanged, XmppConnectionService.OnRoleChanged, XmppConnectionService.OnConfigurationPushed, TextWatcher {
|
||||
public static final String ACTION_VIEW_MUC = "view_muc";
|
||||
|
||||
private static final float INACTIVE_ALPHA = 0.4684f; //compromise between dark and light theme
|
||||
|
@ -260,6 +263,8 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
|||
startActivity(intent);
|
||||
});
|
||||
this.binding.editMucNameButton.setOnClickListener(this::onMucEditButtonClicked);
|
||||
this.binding.mucEditTitle.addTextChangedListener(this);
|
||||
this.binding.mucEditSubject.addTextChangedListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -310,7 +315,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
|||
final MucOptions mucOptions = mConversation.getMucOptions();
|
||||
this.binding.mucEditor.setVisibility(View.VISIBLE);
|
||||
this.binding.mucDisplay.setVisibility(View.GONE);
|
||||
this.binding.editMucNameButton.setImageResource(getThemeResource(R.attr.icon_save, R.drawable.ic_save_black_24dp));
|
||||
this.binding.editMucNameButton.setImageResource(getThemeResource(R.attr.icon_cancel, R.drawable.ic_cancel_black_24dp));
|
||||
final String name = mucOptions.getName();
|
||||
this.binding.mucEditTitle.setText("");
|
||||
final boolean owner = mucOptions.getSelf().getAffiliation().ranks(MucOptions.Affiliation.OWNER);
|
||||
|
@ -332,11 +337,11 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
|||
if (!owner) {
|
||||
this.binding.mucEditSubject.requestFocus();
|
||||
}
|
||||
this.binding.yourPhoto.setVisibility(View.GONE);
|
||||
} else {
|
||||
String subject = this.binding.mucEditSubject.isEnabled() ? this.binding.mucEditSubject.getEditableText().toString().trim() : null;
|
||||
String name = this.binding.mucEditTitle.isEnabled() ? this.binding.mucEditTitle.getEditableText().toString().trim() : null;
|
||||
onMucInfoUpdated(subject, name);
|
||||
SoftKeyboardUtils.hideSoftKeyboard(this);
|
||||
hideEditor();
|
||||
}
|
||||
}
|
||||
|
@ -345,21 +350,18 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
|||
this.binding.mucEditor.setVisibility(View.GONE);
|
||||
this.binding.mucDisplay.setVisibility(View.VISIBLE);
|
||||
this.binding.editMucNameButton.setImageResource(getThemeResource(R.attr.icon_edit_body, R.drawable.ic_edit_black_24dp));
|
||||
this.binding.yourPhoto.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void onMucInfoUpdated(String subject, String name) {
|
||||
final MucOptions mucOptions = mConversation.getMucOptions();
|
||||
if (mucOptions.canChangeSubject() && !blankOnNull(mucOptions.getSubject()).equals(subject)) {
|
||||
Log.d(Config.LOGTAG,"subject changed");
|
||||
if (mucOptions.canChangeSubject() && changed(mucOptions.getSubject(), subject)) {
|
||||
xmppConnectionService.pushSubjectToConference(mConversation, subject);
|
||||
}
|
||||
if (mucOptions.getSelf().getAffiliation().ranks(MucOptions.Affiliation.OWNER) && !blankOnNull(mucOptions.getName()).equals(name)) {
|
||||
Log.d(Config.LOGTAG,"name changed");
|
||||
if (mucOptions.getSelf().getAffiliation().ranks(MucOptions.Affiliation.OWNER) && changed(mucOptions.getName(), name)) {
|
||||
Bundle options = new Bundle();
|
||||
options.putString("muc#roomconfig_persistentroom", "1");
|
||||
options.putString("muc#roomconfig_roomname", name);
|
||||
xmppConnectionService.pushConferenceConfiguration(mConversation, options, null);
|
||||
xmppConnectionService.pushConferenceConfiguration(mConversation, options, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -367,6 +369,10 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
|||
return input == null ? "" : input;
|
||||
}
|
||||
|
||||
private static boolean changed(String one, String two) {
|
||||
return !blankOnNull(one).equals(blankOnNull(two));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getShareableUri(boolean http) {
|
||||
if (mConversation != null) {
|
||||
|
@ -793,6 +799,30 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
|||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
final MucOptions mucOptions = mConversation.getMucOptions();
|
||||
if (this.binding.mucEditor.getVisibility() == View.VISIBLE) {
|
||||
boolean subjectChanged = changed(binding.mucEditSubject.getEditableText().toString(), mucOptions.getSubject());
|
||||
boolean nameChanged = changed(binding.mucEditTitle.getEditableText().toString(), mucOptions.getName());
|
||||
if (subjectChanged || nameChanged) {
|
||||
this.binding.editMucNameButton.setImageResource(getThemeResource(R.attr.icon_save, R.drawable.ic_save_black_24dp));
|
||||
} else {
|
||||
this.binding.editMucNameButton.setImageResource(getThemeResource(R.attr.icon_cancel, R.drawable.ic_cancel_black_24dp));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class AsyncDrawable extends BitmapDrawable {
|
||||
private final WeakReference<BitmapWorkerTask> bitmapWorkerTaskReference;
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer
|
|||
if (intent == null) {
|
||||
return;
|
||||
}
|
||||
this.mReturnToPrevious = getPreferences().getBoolean("return_to_previous", getResources().getBoolean(R.bool.return_to_previous));
|
||||
this.mReturnToPrevious = getBooleanPreference("return_to_previous", R.bool.return_to_previous);
|
||||
final String type = intent.getType();
|
||||
final String action = intent.getAction();
|
||||
Log.d(Config.LOGTAG, "action: "+action+ ", type:"+type);
|
||||
|
|
|
@ -984,7 +984,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
|||
jid.setError(getString(R.string.bookmark_already_exists));
|
||||
} else {
|
||||
final Bookmark bookmark = new Bookmark(account, conferenceJid.asBareJid());
|
||||
bookmark.setAutojoin(getPreferences().getBoolean("autojoin", getResources().getBoolean(R.bool.autojoin)));
|
||||
bookmark.setAutojoin(getBooleanPreference("autojoin", R.bool.autojoin));
|
||||
String nick = conferenceJid.getResource();
|
||||
if (nick != null && !nick.isEmpty()) {
|
||||
bookmark.setNick(nick);
|
||||
|
|
|
@ -72,6 +72,7 @@ import eu.siacs.conversations.services.XmppConnectionService;
|
|||
import eu.siacs.conversations.services.XmppConnectionService.XmppConnectionBinder;
|
||||
import eu.siacs.conversations.ui.util.MenuDoubleTabUtil;
|
||||
import eu.siacs.conversations.ui.util.PresenceSelector;
|
||||
import eu.siacs.conversations.ui.util.SoftKeyboardUtils;
|
||||
import eu.siacs.conversations.utils.ExceptionHelper;
|
||||
import eu.siacs.conversations.utils.ThemeHelper;
|
||||
import eu.siacs.conversations.xmpp.OnKeyStatusUpdated;
|
||||
|
@ -95,7 +96,6 @@ public abstract class XmppActivity extends ActionBarActivity {
|
|||
|
||||
private boolean isCameraFeatureAvailable = false;
|
||||
|
||||
protected boolean mUseSubject = true;
|
||||
protected int mTheme;
|
||||
protected boolean mUsingEnterKey = false;
|
||||
protected Toast mToast;
|
||||
|
@ -402,7 +402,6 @@ public abstract class XmppActivity extends ActionBarActivity {
|
|||
setTheme(this.mTheme);
|
||||
|
||||
this.mUsingEnterKey = usingEnterKey();
|
||||
mUseSubject = getBooleanPreference("use_subject", R.bool.use_subject);
|
||||
}
|
||||
|
||||
protected boolean isCameraFeatureAvailable() {
|
||||
|
@ -445,7 +444,7 @@ public abstract class XmppActivity extends ActionBarActivity {
|
|||
}
|
||||
|
||||
protected boolean usingEnterKey() {
|
||||
return getPreferences().getBoolean("display_enter_key", getResources().getBoolean(R.bool.display_enter_key));
|
||||
return getBooleanPreference("display_enter_key", R.bool.display_enter_key);
|
||||
}
|
||||
|
||||
protected SharedPreferences getPreferences() {
|
||||
|
@ -456,10 +455,6 @@ public abstract class XmppActivity extends ActionBarActivity {
|
|||
return getPreferences().getBoolean(name, getResources().getBoolean(res));
|
||||
}
|
||||
|
||||
public boolean useSubjectToIdentifyConference() {
|
||||
return mUseSubject;
|
||||
}
|
||||
|
||||
public void switchToConversation(Conversation conversation) {
|
||||
switchToConversation(conversation, null, false);
|
||||
}
|
||||
|
@ -723,6 +718,7 @@ public abstract class XmppActivity extends ActionBarActivity {
|
|||
builder.setView(binding.getRoot());
|
||||
builder.setNegativeButton(R.string.cancel, null);
|
||||
final AlertDialog dialog = builder.create();
|
||||
dialog.setOnShowListener(d -> SoftKeyboardUtils.showKeyboard(binding.inputEditText));
|
||||
dialog.show();
|
||||
View.OnClickListener clickListener = v -> {
|
||||
String value = binding.inputEditText.getText().toString();
|
||||
|
@ -733,9 +729,17 @@ public abstract class XmppActivity extends ActionBarActivity {
|
|||
return;
|
||||
}
|
||||
}
|
||||
SoftKeyboardUtils.hideSoftKeyboard(binding.inputEditText);
|
||||
dialog.dismiss();
|
||||
};
|
||||
dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(clickListener);
|
||||
dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setOnClickListener((v -> {
|
||||
SoftKeyboardUtils.hideSoftKeyboard(binding.inputEditText);
|
||||
dialog.dismiss();
|
||||
}));
|
||||
dialog.setOnDismissListener(dialog1 -> {
|
||||
SoftKeyboardUtils.hideSoftKeyboard(binding.inputEditText);
|
||||
});
|
||||
}
|
||||
|
||||
protected boolean hasStoragePermission(int requestCode) {
|
||||
|
@ -790,7 +794,7 @@ public abstract class XmppActivity extends ActionBarActivity {
|
|||
}
|
||||
|
||||
protected boolean manuallyChangePresence() {
|
||||
return getPreferences().getBoolean(SettingsActivity.MANUALLY_CHANGE_PRESENCE, getResources().getBoolean(R.bool.manually_change_presence));
|
||||
return getBooleanPreference(SettingsActivity.MANUALLY_CHANGE_PRESENCE, R.bool.manually_change_presence);
|
||||
}
|
||||
|
||||
protected String getShareableUri() {
|
||||
|
|
|
@ -84,15 +84,11 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
|
|||
if (conversation == null) {
|
||||
return;
|
||||
}
|
||||
if (conversation.getMode() == Conversation.MODE_SINGLE || activity.useSubjectToIdentifyConference()) {
|
||||
CharSequence name = conversation.getName();
|
||||
if (name instanceof Jid) {
|
||||
viewHolder.name.setText(IrregularUnicodeDetector.style(activity, (Jid) name));
|
||||
} else {
|
||||
viewHolder.name.setText(EmojiWrapper.transform(name));
|
||||
}
|
||||
CharSequence name = conversation.getName();
|
||||
if (name instanceof Jid) {
|
||||
viewHolder.name.setText(IrregularUnicodeDetector.style(activity, (Jid) name));
|
||||
} else {
|
||||
viewHolder.name.setText(conversation.getJid().asBareJid().toString());
|
||||
viewHolder.name.setText(EmojiWrapper.transform(name));
|
||||
}
|
||||
|
||||
viewHolder.frame.setBackgroundColor(Color.get(activity, conversation == ConversationFragment.getConversation(activity) ? R.attr.color_background_secondary : R.attr.color_background_primary));
|
||||
|
|
|
@ -31,6 +31,7 @@ package eu.siacs.conversations.ui.util;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
|
@ -48,7 +49,15 @@ public class SoftKeyboardUtils {
|
|||
if (view == null) {
|
||||
view = new View(activity);
|
||||
}
|
||||
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||
imm.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
|
||||
}
|
||||
|
||||
public static void hideSoftKeyboard(@NonNull final EditText editText) {
|
||||
InputMethodManager imm = (InputMethodManager) editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (imm == null) {
|
||||
return;
|
||||
}
|
||||
imm.hideSoftInputFromWindow(editText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
|
||||
}
|
||||
|
||||
public static void showKeyboard(EditText editText) {
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 397 B |
Binary file not shown.
After Width: | Height: | Size: 291 B |
Binary file not shown.
After Width: | Height: | Size: 517 B |
Binary file not shown.
After Width: | Height: | Size: 721 B |
Binary file not shown.
After Width: | Height: | Size: 963 B |
|
@ -43,7 +43,7 @@
|
|||
android:layout_width="72dp"
|
||||
android:layout_height="72dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginRight="@dimen/avatar_item_distance"
|
||||
android:contentDescription="@string/account_image_description"
|
||||
app:riv_corner_radius="2dp"/>
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
<integer name="auto_accept_filesize">524288</integer>
|
||||
<string name="picture_compression">auto</string>
|
||||
<string name="theme">light</string>
|
||||
<bool name="use_subject">true</bool>
|
||||
<bool name="use_green_background">true</bool>
|
||||
<bool name="send_button_status">false</bool>
|
||||
<string name="quick_action">recent</string>
|
||||
|
|
|
@ -277,8 +277,6 @@
|
|||
<string name="pref_use_indicate_received_summary">Received messages will be marked with a green tick if supported</string>
|
||||
<string name="pref_use_send_button_to_indicate_status_summary">Colorize send button to indicate contact status</string>
|
||||
<string name="pref_expert_options_other">Other</string>
|
||||
<string name="pref_conference_name">Group chat name</string>
|
||||
<string name="pref_conference_name_summary">Use subject instead of JID to identify group chats</string>
|
||||
<string name="pref_autojoin">Automatically join group chats</string>
|
||||
<string name="pref_autojoin_summary">Respect the autojoin flag in group chat bookmarks</string>
|
||||
<string name="toast_message_omemo_fingerprint">OMEMO fingerprint copied to clipboard!</string>
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
|
||||
<item type="reference" name="icon_add_group">@drawable/ic_group_add_white_24dp</item>
|
||||
<item type="reference" name="icon_add_person">@drawable/ic_person_add_white_24dp</item>
|
||||
<item type="reference" name="icon_cancel">@drawable/ic_cancel_white_24dp</item>
|
||||
<item type="reference" name="icon_cancel">@drawable/ic_cancel_black_24dp</item>
|
||||
<item type="reference" name="icon_copy">@drawable/ic_content_copy_black_24dp</item>
|
||||
<item type="reference" name="icon_discard">@drawable/ic_delete_white_24dp</item>
|
||||
<item type="reference" name="icon_download">@drawable/ic_file_download_white_24dp</item>
|
||||
|
|
|
@ -169,11 +169,6 @@
|
|||
android:key="font_size"
|
||||
android:summary="@string/pref_font_size_summary"
|
||||
android:title="@string/pref_font_size"/>
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="@bool/use_subject"
|
||||
android:key="use_subject"
|
||||
android:summary="@string/pref_conference_name_summary"
|
||||
android:title="@string/pref_conference_name"/>
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="@bool/send_button_status"
|
||||
android:key="send_button_status"
|
||||
|
|
Loading…
Reference in New Issue