improved in_reply_to information for quote status
optimized some bitmaps
|
@ -45,6 +45,7 @@ public interface TwidereConstants extends SharedPreferenceConstants, IntentConst
|
|||
public static final String SILENT_NOTIFICATIONS_PREFERENCE_NAME = "silent_notifications";
|
||||
public static final String TIMELINE_POSITIONS_PREFERENCES_NAME = "timeline_positions";
|
||||
public static final String ACCOUNT_PREFERENCES_NAME_PREFIX = "account_preferences_";
|
||||
public static final String KEYBOARD_SHORTCUTS_PREFERENCES_NAME = "keyboard_shortcuts_preferences";
|
||||
|
||||
public static final String TWITTER_CONSUMER_KEY = "uAFVpMhBntJutfVj6abfA";
|
||||
public static final String TWITTER_CONSUMER_SECRET = "JARXkJTfxo0F8MyctYy9bUmrLISjo8vXAHsZHYuk2E";
|
||||
|
|
|
@ -25,6 +25,7 @@ public interface IntentConstants {
|
|||
|
||||
public static final String INTENT_ACTION_HOME = INTENT_PACKAGE_PREFIX + "HOME";
|
||||
public static final String INTENT_ACTION_COMPOSE = INTENT_PACKAGE_PREFIX + "COMPOSE";
|
||||
public static final String INTENT_ACTION_QUICK_SEARCH = INTENT_PACKAGE_PREFIX + "QUICK_SEARCH";
|
||||
public static final String INTENT_ACTION_REPLY = INTENT_PACKAGE_PREFIX + "REPLY";
|
||||
public static final String INTENT_ACTION_QUOTE = INTENT_PACKAGE_PREFIX + "QUOTE";
|
||||
public static final String INTENT_ACTION_EDIT_DRAFT = INTENT_PACKAGE_PREFIX + "EDIT_DRAFT";
|
||||
|
|
|
@ -401,10 +401,10 @@ public class ParcelableStatus implements TwidereParcelable, Comparable<Parcelabl
|
|||
favorite_count = status.getFavoriteCount();
|
||||
reply_count = status.getReplyCount();
|
||||
descendent_reply_count = status.getDescendentReplyCount();
|
||||
in_reply_to_name = TwitterContentUtils.getInReplyToName(status);
|
||||
in_reply_to_screen_name = status.getInReplyToScreenName();
|
||||
in_reply_to_status_id = status.getInReplyToStatusId();
|
||||
in_reply_to_user_id = status.getInReplyToUserId();
|
||||
in_reply_to_name = TwitterContentUtils.getInReplyToName(retweeted != null ? retweeted : orig);
|
||||
in_reply_to_screen_name = (retweeted != null ? retweeted : orig).getInReplyToScreenName();
|
||||
in_reply_to_status_id = (retweeted != null ? retweeted : orig).getInReplyToStatusId();
|
||||
in_reply_to_user_id = (retweeted != null ? retweeted : orig).getInReplyToUserId();
|
||||
source = status.getSource();
|
||||
location = ParcelableLocation.fromGeoLocation(status.getGeoLocation());
|
||||
is_favorite = status.isFavorited();
|
||||
|
|
|
@ -355,6 +355,17 @@ public final class ContentValuesCreator implements TwidereConstants {
|
|||
values.put(Statuses.MY_RETWEET_ID, orig.getCurrentUserRetweet());
|
||||
status = orig;
|
||||
}
|
||||
if (orig.isRetweet()) {
|
||||
values.put(Statuses.IN_REPLY_TO_STATUS_ID, status.getInReplyToStatusId());
|
||||
values.put(Statuses.IN_REPLY_TO_USER_ID, status.getInReplyToUserId());
|
||||
values.put(Statuses.IN_REPLY_TO_USER_NAME, TwitterContentUtils.getInReplyToName(status));
|
||||
values.put(Statuses.IN_REPLY_TO_USER_SCREEN_NAME, status.getInReplyToScreenName());
|
||||
} else {
|
||||
values.put(Statuses.IN_REPLY_TO_STATUS_ID, orig.getInReplyToStatusId());
|
||||
values.put(Statuses.IN_REPLY_TO_USER_ID, orig.getInReplyToUserId());
|
||||
values.put(Statuses.IN_REPLY_TO_USER_NAME, TwitterContentUtils.getInReplyToName(orig));
|
||||
values.put(Statuses.IN_REPLY_TO_USER_SCREEN_NAME, orig.getInReplyToScreenName());
|
||||
}
|
||||
final User user = status.getUser();
|
||||
final long userId = user.getId();
|
||||
final String profileImageUrl = (user.getProfileImageUrlHttps());
|
||||
|
@ -374,10 +385,6 @@ public final class ContentValuesCreator implements TwidereConstants {
|
|||
values.put(Statuses.REPLY_COUNT, status.getReplyCount());
|
||||
values.put(Statuses.FAVORITE_COUNT, status.getFavoriteCount());
|
||||
values.put(Statuses.DESCENDENT_REPLY_COUNT, status.getDescendentReplyCount());
|
||||
values.put(Statuses.IN_REPLY_TO_STATUS_ID, status.getInReplyToStatusId());
|
||||
values.put(Statuses.IN_REPLY_TO_USER_ID, status.getInReplyToUserId());
|
||||
values.put(Statuses.IN_REPLY_TO_USER_NAME, TwitterContentUtils.getInReplyToName(status));
|
||||
values.put(Statuses.IN_REPLY_TO_USER_SCREEN_NAME, status.getInReplyToScreenName());
|
||||
values.put(Statuses.SOURCE, status.getSource());
|
||||
values.put(Statuses.IS_POSSIBLY_SENSITIVE, status.isPossiblySensitive());
|
||||
final GeoLocation location = status.getGeoLocation();
|
||||
|
|
Before Width: | Height: | Size: 729 B After Width: | Height: | Size: 140 B |
|
@ -23,6 +23,8 @@ import android.annotation.SuppressLint;
|
|||
import android.content.Intent;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
|
@ -31,6 +33,7 @@ import org.mariotaku.twidere.app.TwidereApplication;
|
|||
import org.mariotaku.twidere.fragment.iface.IBaseFragment.SystemWindowsInsetsCallback;
|
||||
import org.mariotaku.twidere.fragment.iface.IBasePullToRefreshFragment;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler;
|
||||
import org.mariotaku.twidere.util.MessagesManager;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.view.iface.IExtendedView.OnFitSystemWindowsListener;
|
||||
|
@ -50,6 +53,13 @@ public class BaseActionBarActivity extends ThemedActionBarActivity implements Co
|
|||
return getTwidereApplication() != null ? getTwidereApplication().getMessagesManager() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getSystemWindowsInsets(Rect insets) {
|
||||
if (mSystemWindowsInsets == null) return false;
|
||||
insets.set(mSystemWindowsInsets);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getThemeColor() {
|
||||
return ThemeUtils.getUserAccentColor(this);
|
||||
|
@ -76,6 +86,18 @@ public class BaseActionBarActivity extends ThemedActionBarActivity implements Co
|
|||
return mIsVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFitSystemWindows(Rect insets) {
|
||||
mSystemWindowsInsets = new Rect(insets);
|
||||
notifyControlBarOffsetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) {
|
||||
if (handleKeyboardShortcut(keyCode, event)) return true;
|
||||
return super.onKeyUp(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
|
@ -92,15 +114,14 @@ public class BaseActionBarActivity extends ThemedActionBarActivity implements Co
|
|||
super.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivityForResult(final Intent intent, final int requestCode) {
|
||||
super.startActivityForResult(intent, requestCode);
|
||||
}
|
||||
|
||||
protected IBasePullToRefreshFragment getCurrentPullToRefreshFragment() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected boolean handleKeyboardShortcut(int keyCode,@NonNull KeyEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean isStateSaved() {
|
||||
return mInstanceStateSaved;
|
||||
}
|
||||
|
@ -110,25 +131,6 @@ public class BaseActionBarActivity extends ThemedActionBarActivity implements Co
|
|||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
mIsOnTop = false;
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mInstanceStateSaved = false;
|
||||
mIsOnTop = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(final Bundle outState) {
|
||||
mInstanceStateSaved = true;
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
@ -139,6 +141,30 @@ public class BaseActionBarActivity extends ThemedActionBarActivity implements Co
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mInstanceStateSaved = false;
|
||||
mIsOnTop = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
mIsOnTop = false;
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(final Bundle outState) {
|
||||
mInstanceStateSaved = true;
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivityForResult(final Intent intent, final int requestCode) {
|
||||
super.startActivityForResult(intent, requestCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
mIsVisible = false;
|
||||
|
@ -149,20 +175,6 @@ public class BaseActionBarActivity extends ThemedActionBarActivity implements Co
|
|||
super.onStop();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getSystemWindowsInsets(Rect insets) {
|
||||
if (mSystemWindowsInsets == null) return false;
|
||||
insets.set(mSystemWindowsInsets);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFitSystemWindows(Rect insets) {
|
||||
mSystemWindowsInsets = new Rect(insets);
|
||||
notifyControlBarOffsetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlBarOffset(float offset) {
|
||||
|
||||
|
|
|
@ -50,7 +50,9 @@ import android.view.View;
|
|||
import android.widget.AbsListView.MultiChoiceModeListener;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.mariotaku.querybuilder.Columns.Column;
|
||||
import org.mariotaku.querybuilder.Expression;
|
||||
|
@ -80,11 +82,27 @@ public class DraftsActivity extends BaseActionBarActivity implements LoaderCallb
|
|||
private SharedPreferences mPreferences;
|
||||
|
||||
private DraftsAdapter mAdapter;
|
||||
private ListView mListView;
|
||||
|
||||
private ListView mListView;
|
||||
private View mEmptyView;
|
||||
private TextView mEmptyText;
|
||||
private ImageView mEmptyIcon;
|
||||
private View mListContainer, mProgressContainer;
|
||||
|
||||
private float mTextSize;
|
||||
|
||||
@Override
|
||||
public boolean onCreateActionMode(final ActionMode mode, final Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.action_multi_select_drafts, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareActionMode(final ActionMode mode, final Menu menu) {
|
||||
updateTitle(mode);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
|
@ -123,9 +141,8 @@ public class DraftsActivity extends BaseActionBarActivity implements LoaderCallb
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateActionMode(final ActionMode mode, final Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.action_multi_select_drafts, menu);
|
||||
return true;
|
||||
public void onDestroyActionMode(final ActionMode mode) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -137,8 +154,14 @@ public class DraftsActivity extends BaseActionBarActivity implements LoaderCallb
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyActionMode(final ActionMode mode) {
|
||||
public void onLoadFinished(final Loader<Cursor> loader, final Cursor cursor) {
|
||||
mAdapter.swapCursor(cursor);
|
||||
setListShown(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(final Loader<Cursor> loader) {
|
||||
mAdapter.swapCursor(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -157,16 +180,6 @@ public class DraftsActivity extends BaseActionBarActivity implements LoaderCallb
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(final Loader<Cursor> loader) {
|
||||
mAdapter.swapCursor(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(final Loader<Cursor> loader, final Cursor cursor) {
|
||||
mAdapter.swapCursor(cursor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
|
@ -178,30 +191,27 @@ public class DraftsActivity extends BaseActionBarActivity implements LoaderCallb
|
|||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareActionMode(final ActionMode mode, final Menu menu) {
|
||||
updateTitle(mode);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mResolver = getContentResolver();
|
||||
mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
mTextSize = mPreferences.getInt(KEY_TEXT_SIZE, getDefaultTextSize(this));
|
||||
setContentView(R.layout.activity_drafts);
|
||||
setContentView(R.layout.layout_list_with_empty_view);
|
||||
final ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
mAdapter = new DraftsAdapter(this);
|
||||
mListView = (ListView) findViewById(android.R.id.list);
|
||||
mListView.setAdapter(mAdapter);
|
||||
mListView.setEmptyView(mEmptyView);
|
||||
mListView.setOnItemClickListener(this);
|
||||
mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
|
||||
mListView.setMultiChoiceModeListener(this);
|
||||
mEmptyIcon.setImageResource(R.drawable.ic_info_drafts);
|
||||
mEmptyText.setText(R.string.drafts_hint_messages);
|
||||
getSupportLoaderManager().initLoader(0, null, this);
|
||||
setListShown(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -229,6 +239,22 @@ public class DraftsActivity extends BaseActionBarActivity implements LoaderCallb
|
|||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSupportContentChanged() {
|
||||
super.onSupportContentChanged();
|
||||
mListView = (ListView) findViewById(android.R.id.list);
|
||||
mEmptyView = findViewById(android.R.id.empty);
|
||||
mEmptyText = (TextView) findViewById(R.id.empty_text);
|
||||
mEmptyIcon = (ImageView) findViewById(R.id.empty_icon);
|
||||
mProgressContainer = findViewById(R.id.progress_container);
|
||||
mListContainer = findViewById(R.id.list_container);
|
||||
}
|
||||
|
||||
public void setListShown(boolean listShown) {
|
||||
mListContainer.setVisibility(listShown ? View.VISIBLE : View.GONE);
|
||||
mProgressContainer.setVisibility(listShown ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
private void editDraft(final DraftItem draft) {
|
||||
final Intent intent = new Intent(INTENT_ACTION_EDIT_DRAFT);
|
||||
final Bundle bundle = new Bundle();
|
||||
|
@ -332,19 +358,6 @@ public class DraftsActivity extends BaseActionBarActivity implements LoaderCallb
|
|||
return resolver.delete(Drafts.CONTENT_URI, where.getSQL(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final Integer result) {
|
||||
super.onPostExecute(result);
|
||||
final Fragment f = mActivity.getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG_DELETING_DRAFTS);
|
||||
if (f instanceof DialogFragment) {
|
||||
((DialogFragment) f).dismiss();
|
||||
}
|
||||
for (long id : mIds) {
|
||||
final String tag = Uri.withAppendedPath(Drafts.CONTENT_URI, String.valueOf(id)).toString();
|
||||
mNotificationManager.cancel(tag, NOTIFICATION_ID_DRAFTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
|
@ -357,5 +370,18 @@ public class DraftsActivity extends BaseActionBarActivity implements LoaderCallb
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final Integer result) {
|
||||
super.onPostExecute(result);
|
||||
final Fragment f = mActivity.getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG_DELETING_DRAFTS);
|
||||
if (f instanceof DialogFragment) {
|
||||
((DialogFragment) f).dismiss();
|
||||
}
|
||||
for (long id : mIds) {
|
||||
final String tag = Uri.withAppendedPath(Drafts.CONTENT_URI, String.valueOf(id)).toString();
|
||||
mNotificationManager.cancel(tag, NOTIFICATION_ID_DRAFTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
|||
import org.mariotaku.twidere.util.ColorUtils;
|
||||
import org.mariotaku.twidere.util.CustomTabUtils;
|
||||
import org.mariotaku.twidere.util.FlymeUtils;
|
||||
import org.mariotaku.twidere.util.HotKeyHandler;
|
||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler;
|
||||
import org.mariotaku.twidere.util.MathUtils;
|
||||
import org.mariotaku.twidere.util.MultiSelectEventHandler;
|
||||
import org.mariotaku.twidere.util.ParseUtils;
|
||||
|
@ -149,8 +149,8 @@ public class HomeActivity extends BaseActionBarActivity implements OnClickListen
|
|||
private NotificationManager mNotificationManager;
|
||||
|
||||
private MultiSelectEventHandler mMultiSelectHandler;
|
||||
private HotKeyHandler mHotKeyHandler;
|
||||
private ReadStateManager mReadStateManager;
|
||||
private KeyboardShortcutsHandler mKeyboardShortcutsHandler;
|
||||
|
||||
private SupportTabsAdapter mPagerAdapter;
|
||||
|
||||
|
@ -169,7 +169,6 @@ public class HomeActivity extends BaseActionBarActivity implements OnClickListen
|
|||
private UpdateUnreadCountTask mUpdateUnreadCountTask;
|
||||
|
||||
private int mTabDisplayOption;
|
||||
private float mPagerPosition;
|
||||
private Toolbar mActionBar;
|
||||
|
||||
private OnSharedPreferenceChangeListener mReadStateChangeListener = new OnSharedPreferenceChangeListener() {
|
||||
|
@ -279,6 +278,12 @@ public class HomeActivity extends BaseActionBarActivity implements OnClickListen
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean handleKeyboardShortcut(int keyCode, @NonNull KeyEvent event) {
|
||||
mKeyboardShortcutsHandler.handleKey(null, keyCode, event);
|
||||
return super.handleKeyboardShortcut(keyCode, event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the context is first created.
|
||||
*/
|
||||
|
@ -299,7 +304,7 @@ public class HomeActivity extends BaseActionBarActivity implements OnClickListen
|
|||
mReadStateManager = TwidereApplication.getInstance(this).getReadStateManager();
|
||||
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
mMultiSelectHandler = new MultiSelectEventHandler(this);
|
||||
mHotKeyHandler = new HotKeyHandler(this);
|
||||
mKeyboardShortcutsHandler = new KeyboardShortcutsHandler(this);
|
||||
mMultiSelectHandler.dispatchOnCreate();
|
||||
final long[] accountIds = getAccountIds(this);
|
||||
if (accountIds.length == 0) {
|
||||
|
@ -358,7 +363,6 @@ public class HomeActivity extends BaseActionBarActivity implements OnClickListen
|
|||
openAccountsDrawer();
|
||||
}
|
||||
}
|
||||
mPagerPosition = Float.NaN;
|
||||
setupHomeTabs();
|
||||
|
||||
final int initialTabPosition = handleIntent(intent, savedInstanceState == null);
|
||||
|
@ -491,9 +495,6 @@ public class HomeActivity extends BaseActionBarActivity implements OnClickListen
|
|||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
if (mHotKeyHandler.handleKey(keyCode, event)) return true;
|
||||
}
|
||||
}
|
||||
return super.onKeyUp(keyCode, event);
|
||||
}
|
||||
|
|
|
@ -224,7 +224,7 @@ public class CustomTabsFragment extends BaseFragment implements LoaderCallbacks<
|
|||
|
||||
@Override
|
||||
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_list_with_empty_view, container, false);
|
||||
return inflater.inflate(R.layout.layout_draggable_list_with_empty_view, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.fragment;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/4/10.
|
||||
*/
|
||||
public class KeyboardShortcutsFragment extends BaseListFragment {
|
||||
}
|
|
@ -227,7 +227,7 @@ public class AccountsManagerFragment extends BaseSupportFragment implements Load
|
|||
|
||||
@Override
|
||||
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_list_with_empty_view, container, false);
|
||||
return inflater.inflate(R.layout.layout_draggable_list_with_empty_view, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
package org.mariotaku.twidere.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
|
||||
public class HotKeyHandler implements Constants {
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
public HotKeyHandler(final Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public boolean handleKey(final int keyCode, final KeyEvent event) {
|
||||
switch (keyCode) {
|
||||
case KeyEvent.KEYCODE_N: {
|
||||
mContext.startActivity(new Intent(INTENT_ACTION_COMPOSE));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
package org.mariotaku.twidere.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.activity.support.ComposeActivity;
|
||||
import org.mariotaku.twidere.activity.support.QuickSearchBarActivity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
public class KeyboardShortcutsHandler implements Constants {
|
||||
|
||||
private static final HashMap<String, Integer> sActionLabelMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
sActionLabelMap.put("compose", R.string.compose);
|
||||
sActionLabelMap.put("search", R.string.search);
|
||||
}
|
||||
|
||||
private static final String KEYCODE_STRING_PREFIX = "KEYCODE_";
|
||||
private final Context mContext;
|
||||
private final SharedPreferencesWrapper mPreferences;
|
||||
|
||||
public KeyboardShortcutsHandler(final Context context) {
|
||||
mContext = context;
|
||||
mPreferences = SharedPreferencesWrapper.getInstance(context, KEYBOARD_SHORTCUTS_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
public static String getActionLabel(Context context, String action) {
|
||||
if (!sActionLabelMap.containsKey(action)) return null;
|
||||
final int labelRes = sActionLabelMap.get(action);
|
||||
return context.getString(labelRes);
|
||||
}
|
||||
|
||||
public static Set<String> getActions() {
|
||||
return sActionLabelMap.keySet();
|
||||
}
|
||||
|
||||
public static String getKeyEventKey(String contextTag, int keyCode, KeyEvent event) {
|
||||
final StringBuilder keyNameBuilder = new StringBuilder();
|
||||
if (!TextUtils.isEmpty(contextTag)) {
|
||||
keyNameBuilder.append(contextTag);
|
||||
keyNameBuilder.append("_");
|
||||
}
|
||||
if (event.isCtrlPressed()) {
|
||||
keyNameBuilder.append("ctrl_");
|
||||
}
|
||||
if (event.isAltPressed()) {
|
||||
keyNameBuilder.append("alt_");
|
||||
}
|
||||
if (event.isShiftPressed()) {
|
||||
keyNameBuilder.append("shift_");
|
||||
}
|
||||
final String keyCodeString = KeyEvent.keyCodeToString(keyCode);
|
||||
if (keyCodeString.startsWith(KEYCODE_STRING_PREFIX)) {
|
||||
keyNameBuilder.append(keyCodeString.substring(KEYCODE_STRING_PREFIX.length()).toLowerCase(Locale.US));
|
||||
}
|
||||
return keyNameBuilder.toString();
|
||||
}
|
||||
|
||||
public boolean handleKey(final String contextTag, final int keyCode, final KeyEvent event) {
|
||||
if (!isValidForHotkey(keyCode, event)) return false;
|
||||
final String key = getKeyEventKey(contextTag, keyCode, event);
|
||||
final String action = mPreferences.getString(key, null);
|
||||
if (action == null) return false;
|
||||
switch (action) {
|
||||
case "compose": {
|
||||
mContext.startActivity(new Intent(mContext, ComposeActivity.class).setAction(INTENT_ACTION_COMPOSE));
|
||||
return true;
|
||||
}
|
||||
case "search": {
|
||||
mContext.startActivity(new Intent(mContext, QuickSearchBarActivity.class).setAction(INTENT_ACTION_QUICK_SEARCH));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isValidForHotkey(int keyCode, KeyEvent event) {
|
||||
return !event.isSystem() && !KeyEvent.isModifierKey(keyCode) && keyCode != KeyEvent.KEYCODE_UNKNOWN;
|
||||
}
|
||||
|
||||
}
|
|
@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
|
|||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
|
@ -20,8 +21,6 @@ import org.mariotaku.twidere.activity.support.HomeActivity;
|
|||
*/
|
||||
public class HomeSlidingMenu extends SlidingMenu implements Constants {
|
||||
|
||||
private final HomeActivity mActivity;
|
||||
|
||||
public HomeSlidingMenu(final Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
@ -32,7 +31,6 @@ public class HomeSlidingMenu extends SlidingMenu implements Constants {
|
|||
|
||||
public HomeSlidingMenu(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
mActivity = (HomeActivity) context;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -49,7 +47,9 @@ public class HomeSlidingMenu extends SlidingMenu implements Constants {
|
|||
|
||||
@Override
|
||||
protected boolean fitSystemWindows(Rect insets) {
|
||||
mActivity.setSystemWindowInsets(insets);
|
||||
if (isInEditMode()) return false;
|
||||
final HomeActivity activity = (HomeActivity) getContext();
|
||||
activity.setSystemWindowInsets(insets);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -59,9 +59,12 @@ public class HomeSlidingMenu extends SlidingMenu implements Constants {
|
|||
return new MyCustomViewBehind(context, this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ViewPager getViewPager() {
|
||||
if (mActivity == null) return null;
|
||||
return mActivity.getViewPager();
|
||||
if (isInEditMode()) return null;
|
||||
final HomeActivity activity = (HomeActivity) getContext();
|
||||
if (activity == null) return null;
|
||||
return activity.getViewPager();
|
||||
}
|
||||
|
||||
private boolean isTouchingMargin(final MotionEvent e) {
|
||||
|
|
Before Width: | Height: | Size: 639 B After Width: | Height: | Size: 322 B |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 945 B |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 828 B |
Before Width: | Height: | Size: 454 B After Width: | Height: | Size: 251 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 882 B |
After Width: | Height: | Size: 682 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 725 B |
Before Width: | Height: | Size: 967 B After Width: | Height: | Size: 460 B |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 474 B |
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 1.8 KiB |
|
@ -1,29 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
~ Twidere - Twitter client for Android
|
||||
~
|
||||
~ Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<include layout="@android:layout/list_content"/>r
|
||||
</FrameLayout>
|
|
@ -20,23 +20,21 @@
|
|||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:animateLayoutChanges="true"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
android:animateLayoutChanges="true">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/list_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/list_container">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.mobeta.android.dslv.DragSortListView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:collapsed_height="2dp"
|
||||
tools:visibility="gone"
|
||||
app:drag_enabled="true"
|
||||
app:drag_handle_id="@+id/drag_handle"
|
||||
app:drag_scroll_start="0.33"
|
||||
|
@ -46,9 +44,10 @@
|
|||
app:remove_enabled="false"
|
||||
app:slide_shuffle_speed="0.3"
|
||||
app:sort_enabled="true"
|
||||
app:track_drag_sort="true"
|
||||
app:track_drag_sort="false"
|
||||
app:use_default_controller="true"
|
||||
tools:context=".fragment.CustomTabsFragment"/>
|
||||
tools:context=".fragment.CustomTabsFragment"
|
||||
tools:visibility="gone"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@android:id/empty"
|
||||
|
@ -59,8 +58,8 @@
|
|||
tools:visibility="visible">
|
||||
|
||||
<org.mariotaku.twidere.view.ActionIconView
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/empty_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:color="?android:textColorSecondary"/>
|
||||
|
||||
|
@ -76,14 +75,14 @@
|
|||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/progress_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/progress_container">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@android:id/progress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@android:id/progress"
|
||||
android:layout_gravity="center"/>
|
||||
</FrameLayout>
|
||||
</FrameLayout>
|
|
@ -0,0 +1,75 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Twidere - Twitter client for Android
|
||||
~
|
||||
~ Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:animateLayoutChanges="true">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/list_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ListView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:visibility="gone"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@android:id/empty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
tools:visibility="visible">
|
||||
|
||||
<org.mariotaku.twidere.view.ActionIconView
|
||||
android:id="@+id/empty_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:color="?android:textColorSecondary"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/empty_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="@dimen/element_spacing_normal"
|
||||
android:gravity="center"
|
||||
android:textAppearance="?android:textAppearanceMedium"/>
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/progress_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@android:id/progress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"/>
|
||||
</FrameLayout>
|
||||
</FrameLayout>
|
|
@ -736,5 +736,7 @@
|
|||
<string name="N_statuses_quantity_other"><xliff:g id="count">%d</xliff:g> tweets</string>
|
||||
<string name="N_favorites_quantity_one"><xliff:g id="count">%d</xliff:g> favorites</string>
|
||||
<string name="N_favorites_quantity_other"><xliff:g id="count">%d</xliff:g> favorites</string>
|
||||
<string name="drafts_hint_messages">Your unsent tweets will goes here</string>
|
||||
<string name="keyboard_shortcuts">Keyboard shortcuts</string>
|
||||
|
||||
</resources>
|
|
@ -46,4 +46,8 @@
|
|||
android:title="@string/import_export_settings"
|
||||
android:key="import_export_settings"/>
|
||||
|
||||
<Preference
|
||||
android:title="@string/keyboard_shortcuts"
|
||||
android:fragment="org.mariotaku.twidere.fragment.KeyboardShortcutsFragment"/>
|
||||
|
||||
</PreferenceScreen>
|