improving dm ui
This commit is contained in:
parent
8dbacf5528
commit
c5278f9000
|
@ -114,6 +114,9 @@ public class LinkHandlerActivity extends BaseAppCompatActivity implements System
|
|||
|
||||
@Override
|
||||
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;
|
||||
final String action = handler.getKeyAction(CONTEXT_TAG_NAVIGATION, keyCode, event);
|
||||
if (ACTION_NAVIGATION_BACK.equals(action)) {
|
||||
|
@ -123,8 +126,16 @@ public class LinkHandlerActivity extends BaseAppCompatActivity implements System
|
|||
return handler.handleKey(this, null, keyCode, event);
|
||||
}
|
||||
|
||||
private boolean shouldFragmentTakeAllKeyboardShortcuts() {
|
||||
final Fragment fragment = getCurrentVisibleFragment();
|
||||
return fragment instanceof KeyboardShortcutsHandler.TakeAllKeyboardShortcut;
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
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.content.CursorLoader;
|
||||
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.widget.FixedLinearLayoutManager;
|
||||
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.KeyboardShortcutsHandler;
|
||||
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.ParseUtils;
|
||||
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.view.StatusComposeEditText;
|
||||
import org.mariotaku.twidere.view.StatusTextCountView;
|
||||
import org.mariotaku.twidere.view.iface.IColorLabelView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -120,7 +118,7 @@ import static org.mariotaku.twidere.util.Utils.showOkMessage;
|
|||
|
||||
public class MessagesConversationFragment extends BaseSupportFragment implements
|
||||
LoaderCallbacks<Cursor>, OnClickListener, OnItemSelectedListener, MenuButtonClickListener,
|
||||
PopupMenu.OnMenuItemClickListener, KeyboardShortcutCallback {
|
||||
PopupMenu.OnMenuItemClickListener, KeyboardShortcutCallback, TakeAllKeyboardShortcut {
|
||||
|
||||
// Constants
|
||||
private static final int LOADER_ID_SEARCH_USERS = 1;
|
||||
|
@ -174,14 +172,12 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
|||
private ImageView mAddImageButton;
|
||||
private View mConversationContainer, mRecipientSelectorContainer;
|
||||
private Spinner mAccountSpinner;
|
||||
private ImageView mRecipientProfileImageView;
|
||||
private EditText mEditUserQuery;
|
||||
private View mUsersSearchProgress;
|
||||
private View mQueryButton;
|
||||
private View mUsersSearchEmpty;
|
||||
private TextView mUsersSearchEmptyText;
|
||||
private PopupMenu mPopupMenu;
|
||||
private IColorLabelView mProfileImageContainer;
|
||||
|
||||
// Adapters
|
||||
private MessageConversationAdapter mAdapter;
|
||||
|
@ -272,7 +268,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
|||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
final ParcelableAccount account = (ParcelableAccount) mAccountSpinner.getSelectedItem();
|
||||
showConversation(account, mUsersSearchAdapter.getItem(position));
|
||||
updateProfileImage();
|
||||
updateRecipientInfo();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -374,16 +370,12 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
|||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
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
|
||||
public void onPrepareOptionsMenu(Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
updateProfileImage();
|
||||
updateRecipientInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -419,8 +411,9 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
|||
final boolean isValid = accountId > 0 && recipientId > 0;
|
||||
mConversationContainer.setVisibility(isValid ? View.VISIBLE : View.GONE);
|
||||
mRecipientSelectorContainer.setVisibility(isValid ? View.GONE : View.VISIBLE);
|
||||
if (!isValid)
|
||||
if (!isValid) {
|
||||
return new CursorLoader(getActivity(), TwidereDataStore.CONTENT_URI_NULL, cols, null, null, null);
|
||||
}
|
||||
final Uri uri = buildDirectMessageConversationUri(accountId, recipientId, null);
|
||||
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);
|
||||
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: {
|
||||
final ParcelableAccount account = (ParcelableAccount) mAccountSpinner.getSelectedItem();
|
||||
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();
|
||||
if (account != null) {
|
||||
mAccount = account;
|
||||
updateProfileImage();
|
||||
updateRecipientInfo();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -560,7 +543,8 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
|||
}
|
||||
AsyncTaskUtils.executeTask(new SetReadStateTask(getActivity(), account, recipient));
|
||||
updateActionBar();
|
||||
updateProfileImage();
|
||||
updateRecipientInfo();
|
||||
mEditText.requestFocus();
|
||||
}
|
||||
|
||||
public boolean isShowingConversation() {
|
||||
|
@ -750,20 +734,11 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
|||
}
|
||||
}
|
||||
|
||||
private void updateProfileImage() {
|
||||
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);
|
||||
}
|
||||
private void updateRecipientInfo() {
|
||||
final FragmentActivity activity = getActivity();
|
||||
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 {
|
||||
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);
|
||||
}
|
||||
|
||||
public static interface TakeAllKeyboardShortcut {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/4/11.
|
||||
*/
|
||||
|
|
|
@ -25,34 +25,38 @@
|
|||
android:layout_height="match_parent"
|
||||
tools:context=".fragment.DirectMessagesConversationFragment">
|
||||
|
||||
<LinearLayout
|
||||
<RelativeLayout
|
||||
android:id="@+id/conversation_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:divider="?dividerVertical"
|
||||
android:orientation="vertical"
|
||||
android:showDividers="middle"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/list_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@+id/input_send_container">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
android:layout_height="match_parent"
|
||||
android:scrollbars="vertical" />
|
||||
|
||||
</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
|
||||
android:id="@+id/input_send_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="?android:colorBackground"
|
||||
android:gravity="bottom"
|
||||
android:orientation="horizontal"
|
||||
|
@ -89,7 +93,6 @@
|
|||
android:layout_gravity="right"
|
||||
android:layout_toLeftOf="@+id/send"
|
||||
android:layout_toRightOf="@+id/add_image"
|
||||
android:clickable="true"
|
||||
app:bubbleColor="?messageBubbleColor"
|
||||
app:caretHeight="8dp"
|
||||
app:caretPosition="topRight"
|
||||
|
@ -99,16 +102,17 @@
|
|||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="@dimen/element_size_normal"
|
||||
android:padding="@dimen/element_spacing_normal">
|
||||
|
||||
<org.mariotaku.twidere.view.StatusComposeEditText
|
||||
android:id="@+id/edit_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:background="@null"
|
||||
android:completionThreshold="1"
|
||||
android:focusable="true"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="left|center_vertical"
|
||||
android:hint="@string/type_to_compose"
|
||||
android:inputType="textShortMessage|textMultiLine"
|
||||
|
@ -136,7 +140,7 @@
|
|||
</org.mariotaku.messagebubbleview.library.MessageBubbleView>
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/recipient_selector_container"
|
||||
|
|
|
@ -20,9 +20,5 @@
|
|||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
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>
|
Loading…
Reference in New Issue