improving dm ui
This commit is contained in:
parent
8dbacf5528
commit
c5278f9000
|
@ -114,6 +114,9 @@ public class LinkHandlerActivity extends BaseAppCompatActivity implements System
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handleKeyboardShortcutSingle(@NonNull KeyboardShortcutsHandler handler, int keyCode, @NonNull KeyEvent event) {
|
public boolean handleKeyboardShortcutSingle(@NonNull KeyboardShortcutsHandler handler, int keyCode, @NonNull KeyEvent event) {
|
||||||
|
if (shouldFragmentTakeAllKeyboardShortcuts()) {
|
||||||
|
return handleFragmentKeyboardShortcutSingle(handler, keyCode, event);
|
||||||
|
}
|
||||||
if (handleFragmentKeyboardShortcutSingle(handler, keyCode, event)) return true;
|
if (handleFragmentKeyboardShortcutSingle(handler, keyCode, event)) return true;
|
||||||
final String action = handler.getKeyAction(CONTEXT_TAG_NAVIGATION, keyCode, event);
|
final String action = handler.getKeyAction(CONTEXT_TAG_NAVIGATION, keyCode, event);
|
||||||
if (ACTION_NAVIGATION_BACK.equals(action)) {
|
if (ACTION_NAVIGATION_BACK.equals(action)) {
|
||||||
|
@ -123,8 +126,16 @@ public class LinkHandlerActivity extends BaseAppCompatActivity implements System
|
||||||
return handler.handleKey(this, null, keyCode, event);
|
return handler.handleKey(this, null, keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean shouldFragmentTakeAllKeyboardShortcuts() {
|
||||||
|
final Fragment fragment = getCurrentVisibleFragment();
|
||||||
|
return fragment instanceof KeyboardShortcutsHandler.TakeAllKeyboardShortcut;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handleKeyboardShortcutRepeat(@NonNull KeyboardShortcutsHandler handler, int keyCode, int repeatCount, @NonNull KeyEvent event) {
|
public boolean handleKeyboardShortcutRepeat(@NonNull KeyboardShortcutsHandler handler, int keyCode, int repeatCount, @NonNull KeyEvent event) {
|
||||||
|
if (shouldFragmentTakeAllKeyboardShortcuts()) {
|
||||||
|
handleFragmentKeyboardShortcutRepeat(handler, keyCode, repeatCount, event);
|
||||||
|
}
|
||||||
if (handleFragmentKeyboardShortcutRepeat(handler, keyCode, repeatCount, event)) return true;
|
if (handleFragmentKeyboardShortcutRepeat(handler, keyCode, repeatCount, event)) return true;
|
||||||
return super.handleKeyboardShortcutRepeat(handler, keyCode, repeatCount, event);
|
return super.handleKeyboardShortcutRepeat(handler, keyCode, repeatCount, event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,6 @@ import android.support.v4.app.LoaderManager;
|
||||||
import android.support.v4.app.LoaderManager.LoaderCallbacks;
|
import android.support.v4.app.LoaderManager.LoaderCallbacks;
|
||||||
import android.support.v4.content.CursorLoader;
|
import android.support.v4.content.CursorLoader;
|
||||||
import android.support.v4.content.Loader;
|
import android.support.v4.content.Loader;
|
||||||
import android.support.v4.util.Pair;
|
|
||||||
import android.support.v4.view.MenuItemCompat;
|
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.widget.FixedLinearLayoutManager;
|
import android.support.v7.widget.FixedLinearLayoutManager;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
@ -98,6 +96,7 @@ import org.mariotaku.twidere.util.EditTextEnterHandler;
|
||||||
import org.mariotaku.twidere.util.EditTextEnterHandler.EnterListener;
|
import org.mariotaku.twidere.util.EditTextEnterHandler.EnterListener;
|
||||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler;
|
import org.mariotaku.twidere.util.KeyboardShortcutsHandler;
|
||||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallback;
|
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallback;
|
||||||
|
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.TakeAllKeyboardShortcut;
|
||||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||||
import org.mariotaku.twidere.util.ParseUtils;
|
import org.mariotaku.twidere.util.ParseUtils;
|
||||||
import org.mariotaku.twidere.util.ReadStateManager;
|
import org.mariotaku.twidere.util.ReadStateManager;
|
||||||
|
@ -108,7 +107,6 @@ import org.mariotaku.twidere.util.Utils;
|
||||||
import org.mariotaku.twidere.util.message.TaskStateChangedEvent;
|
import org.mariotaku.twidere.util.message.TaskStateChangedEvent;
|
||||||
import org.mariotaku.twidere.view.StatusComposeEditText;
|
import org.mariotaku.twidere.view.StatusComposeEditText;
|
||||||
import org.mariotaku.twidere.view.StatusTextCountView;
|
import org.mariotaku.twidere.view.StatusTextCountView;
|
||||||
import org.mariotaku.twidere.view.iface.IColorLabelView;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -120,7 +118,7 @@ import static org.mariotaku.twidere.util.Utils.showOkMessage;
|
||||||
|
|
||||||
public class MessagesConversationFragment extends BaseSupportFragment implements
|
public class MessagesConversationFragment extends BaseSupportFragment implements
|
||||||
LoaderCallbacks<Cursor>, OnClickListener, OnItemSelectedListener, MenuButtonClickListener,
|
LoaderCallbacks<Cursor>, OnClickListener, OnItemSelectedListener, MenuButtonClickListener,
|
||||||
PopupMenu.OnMenuItemClickListener, KeyboardShortcutCallback {
|
PopupMenu.OnMenuItemClickListener, KeyboardShortcutCallback, TakeAllKeyboardShortcut {
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
private static final int LOADER_ID_SEARCH_USERS = 1;
|
private static final int LOADER_ID_SEARCH_USERS = 1;
|
||||||
|
@ -174,14 +172,12 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
||||||
private ImageView mAddImageButton;
|
private ImageView mAddImageButton;
|
||||||
private View mConversationContainer, mRecipientSelectorContainer;
|
private View mConversationContainer, mRecipientSelectorContainer;
|
||||||
private Spinner mAccountSpinner;
|
private Spinner mAccountSpinner;
|
||||||
private ImageView mRecipientProfileImageView;
|
|
||||||
private EditText mEditUserQuery;
|
private EditText mEditUserQuery;
|
||||||
private View mUsersSearchProgress;
|
private View mUsersSearchProgress;
|
||||||
private View mQueryButton;
|
private View mQueryButton;
|
||||||
private View mUsersSearchEmpty;
|
private View mUsersSearchEmpty;
|
||||||
private TextView mUsersSearchEmptyText;
|
private TextView mUsersSearchEmptyText;
|
||||||
private PopupMenu mPopupMenu;
|
private PopupMenu mPopupMenu;
|
||||||
private IColorLabelView mProfileImageContainer;
|
|
||||||
|
|
||||||
// Adapters
|
// Adapters
|
||||||
private MessageConversationAdapter mAdapter;
|
private MessageConversationAdapter mAdapter;
|
||||||
|
@ -272,7 +268,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
final ParcelableAccount account = (ParcelableAccount) mAccountSpinner.getSelectedItem();
|
final ParcelableAccount account = (ParcelableAccount) mAccountSpinner.getSelectedItem();
|
||||||
showConversation(account, mUsersSearchAdapter.getItem(position));
|
showConversation(account, mUsersSearchAdapter.getItem(position));
|
||||||
updateProfileImage();
|
updateRecipientInfo();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -374,16 +370,12 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
inflater.inflate(R.menu.menu_direct_messages_conversation, menu);
|
inflater.inflate(R.menu.menu_direct_messages_conversation, menu);
|
||||||
final View profileImageItemView = MenuItemCompat.getActionView(menu.findItem(R.id.item_profile_image));
|
|
||||||
profileImageItemView.setOnClickListener(this);
|
|
||||||
mProfileImageContainer = (IColorLabelView) profileImageItemView;
|
|
||||||
mRecipientProfileImageView = (ImageView) profileImageItemView.findViewById(R.id.recipient_profile_image);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPrepareOptionsMenu(Menu menu) {
|
public void onPrepareOptionsMenu(Menu menu) {
|
||||||
super.onPrepareOptionsMenu(menu);
|
super.onPrepareOptionsMenu(menu);
|
||||||
updateProfileImage();
|
updateRecipientInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -419,8 +411,9 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
||||||
final boolean isValid = accountId > 0 && recipientId > 0;
|
final boolean isValid = accountId > 0 && recipientId > 0;
|
||||||
mConversationContainer.setVisibility(isValid ? View.VISIBLE : View.GONE);
|
mConversationContainer.setVisibility(isValid ? View.VISIBLE : View.GONE);
|
||||||
mRecipientSelectorContainer.setVisibility(isValid ? View.GONE : View.VISIBLE);
|
mRecipientSelectorContainer.setVisibility(isValid ? View.GONE : View.VISIBLE);
|
||||||
if (!isValid)
|
if (!isValid) {
|
||||||
return new CursorLoader(getActivity(), TwidereDataStore.CONTENT_URI_NULL, cols, null, null, null);
|
return new CursorLoader(getActivity(), TwidereDataStore.CONTENT_URI_NULL, cols, null, null, null);
|
||||||
|
}
|
||||||
final Uri uri = buildDirectMessageConversationUri(accountId, recipientId, null);
|
final Uri uri = buildDirectMessageConversationUri(accountId, recipientId, null);
|
||||||
return new CursorLoader(getActivity(), uri, cols, null, null, Conversation.DEFAULT_SORT_ORDER);
|
return new CursorLoader(getActivity(), uri, cols, null, null, Conversation.DEFAULT_SORT_ORDER);
|
||||||
}
|
}
|
||||||
|
@ -437,16 +430,6 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
||||||
startActivityForResult(intent, REQUEST_PICK_IMAGE);
|
startActivityForResult(intent, REQUEST_PICK_IMAGE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case R.id.item_profile_image: {
|
|
||||||
final ParcelableUser recipient = mRecipient;
|
|
||||||
if (recipient == null) return;
|
|
||||||
final Bundle options = Utils.makeSceneTransitionOption(getActivity(),
|
|
||||||
new Pair<View, String>(mRecipientProfileImageView,
|
|
||||||
UserFragment.TRANSITION_NAME_PROFILE_IMAGE));
|
|
||||||
Utils.openUserProfile(getActivity(), recipient.account_id, recipient.id,
|
|
||||||
recipient.screen_name, options);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case R.id.query_button: {
|
case R.id.query_button: {
|
||||||
final ParcelableAccount account = (ParcelableAccount) mAccountSpinner.getSelectedItem();
|
final ParcelableAccount account = (ParcelableAccount) mAccountSpinner.getSelectedItem();
|
||||||
searchUsers(account.account_id, ParseUtils.parseString(mEditUserQuery.getText()), false);
|
searchUsers(account.account_id, ParseUtils.parseString(mEditUserQuery.getText()), false);
|
||||||
|
@ -460,7 +443,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
||||||
final ParcelableAccount account = (ParcelableAccount) mAccountSpinner.getSelectedItem();
|
final ParcelableAccount account = (ParcelableAccount) mAccountSpinner.getSelectedItem();
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
mAccount = account;
|
mAccount = account;
|
||||||
updateProfileImage();
|
updateRecipientInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,7 +543,8 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
||||||
}
|
}
|
||||||
AsyncTaskUtils.executeTask(new SetReadStateTask(getActivity(), account, recipient));
|
AsyncTaskUtils.executeTask(new SetReadStateTask(getActivity(), account, recipient));
|
||||||
updateActionBar();
|
updateActionBar();
|
||||||
updateProfileImage();
|
updateRecipientInfo();
|
||||||
|
mEditText.requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShowingConversation() {
|
public boolean isShowingConversation() {
|
||||||
|
@ -750,20 +734,11 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateProfileImage() {
|
private void updateRecipientInfo() {
|
||||||
if (mProfileImageContainer == null || mRecipientProfileImageView == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mProfileImageContainer.setVisibility(mRecipient != null ? View.VISIBLE : View.GONE);
|
|
||||||
if (mAccount != null && mRecipient != null) {
|
|
||||||
mImageLoader.displayProfileImage(mRecipientProfileImageView, mRecipient.profile_image_url);
|
|
||||||
mProfileImageContainer.drawEnd(mAccount.color);
|
|
||||||
} else {
|
|
||||||
mImageLoader.cancelDisplayTask(mRecipientProfileImageView);
|
|
||||||
}
|
|
||||||
final FragmentActivity activity = getActivity();
|
final FragmentActivity activity = getActivity();
|
||||||
if (mRecipient != null) {
|
if (mRecipient != null) {
|
||||||
activity.setTitle(mUserColorNameManager.getDisplayName(mRecipient, mPreferences.getBoolean(KEY_NAME_FIRST), true));
|
activity.setTitle(mUserColorNameManager.getDisplayName(mRecipient,
|
||||||
|
mPreferences.getBoolean(KEY_NAME_FIRST), true));
|
||||||
} else {
|
} else {
|
||||||
activity.setTitle(R.string.direct_messages);
|
activity.setTitle(R.string.direct_messages);
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,6 +248,10 @@ public class KeyboardShortcutsHandler implements Constants, KeyboardShortcutCons
|
||||||
boolean handleKeyboardShortcutSingle(@NonNull KeyboardShortcutsHandler handler, int keyCode, @NonNull KeyEvent event);
|
boolean handleKeyboardShortcutSingle(@NonNull KeyboardShortcutsHandler handler, int keyCode, @NonNull KeyEvent event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static interface TakeAllKeyboardShortcut {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mariotaku on 15/4/11.
|
* Created by mariotaku on 15/4/11.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -25,34 +25,38 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".fragment.DirectMessagesConversationFragment">
|
tools:context=".fragment.DirectMessagesConversationFragment">
|
||||||
|
|
||||||
<LinearLayout
|
<RelativeLayout
|
||||||
android:id="@+id/conversation_container"
|
android:id="@+id/conversation_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:divider="?dividerVertical"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:showDividers="middle"
|
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible">
|
tools:visibility="visible">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/list_container"
|
android:id="@+id/list_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1">
|
android:layout_above="@+id/input_send_container">
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<android.support.v7.widget.RecyclerView
|
||||||
android:id="@+id/recycler_view"
|
android:id="@+id/recycler_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent"
|
||||||
|
android:scrollbars="vertical" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/element_spacing_small"
|
||||||
|
android:layout_above="@+id/input_send_container"
|
||||||
|
android:background="@drawable/shadow_top" />
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/input_send_container"
|
android:id="@+id/input_send_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="0"
|
android:layout_alignParentBottom="true"
|
||||||
android:background="?android:colorBackground"
|
android:background="?android:colorBackground"
|
||||||
android:gravity="bottom"
|
android:gravity="bottom"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
@ -89,7 +93,6 @@
|
||||||
android:layout_gravity="right"
|
android:layout_gravity="right"
|
||||||
android:layout_toLeftOf="@+id/send"
|
android:layout_toLeftOf="@+id/send"
|
||||||
android:layout_toRightOf="@+id/add_image"
|
android:layout_toRightOf="@+id/add_image"
|
||||||
android:clickable="true"
|
|
||||||
app:bubbleColor="?messageBubbleColor"
|
app:bubbleColor="?messageBubbleColor"
|
||||||
app:caretHeight="8dp"
|
app:caretHeight="8dp"
|
||||||
app:caretPosition="topRight"
|
app:caretPosition="topRight"
|
||||||
|
@ -99,16 +102,17 @@
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="@dimen/element_size_normal"
|
||||||
android:padding="@dimen/element_spacing_normal">
|
android:padding="@dimen/element_spacing_normal">
|
||||||
|
|
||||||
<org.mariotaku.twidere.view.StatusComposeEditText
|
<org.mariotaku.twidere.view.StatusComposeEditText
|
||||||
android:id="@+id/edit_text"
|
android:id="@+id/edit_text"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
android:background="@null"
|
android:background="@null"
|
||||||
android:completionThreshold="1"
|
android:completionThreshold="1"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:layout_gravity="center"
|
|
||||||
android:gravity="left|center_vertical"
|
android:gravity="left|center_vertical"
|
||||||
android:hint="@string/type_to_compose"
|
android:hint="@string/type_to_compose"
|
||||||
android:inputType="textShortMessage|textMultiLine"
|
android:inputType="textShortMessage|textMultiLine"
|
||||||
|
@ -136,7 +140,7 @@
|
||||||
</org.mariotaku.messagebubbleview.library.MessageBubbleView>
|
</org.mariotaku.messagebubbleview.library.MessageBubbleView>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</LinearLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/recipient_selector_container"
|
android:id="@+id/recipient_selector_container"
|
||||||
|
|
|
@ -20,9 +20,5 @@
|
||||||
|
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
<item
|
|
||||||
android:id="@+id/item_profile_image"
|
|
||||||
android:title="@string/user"
|
|
||||||
app:actionLayout="@layout/action_item_messages_conversation_profile_image"
|
|
||||||
app:showAsAction="always"/>
|
|
||||||
</menu>
|
</menu>
|
Loading…
Reference in New Issue