fixed some lint errors

made 'hit enter to send' fully work
This commit is contained in:
Mariotaku Lee 2015-04-21 11:29:05 +08:00
parent 7d71142987
commit 9336704677
45 changed files with 375 additions and 419 deletions

View File

@ -352,6 +352,7 @@ public class StatusClusterRenderer implements ClusterRenderer<ClusterStatus> {
this.mSphericalMercatorProjection = new SphericalMercatorProjection(256 * Math.pow(2, Math.min(zoom, mZoom)));
}
@Override
@SuppressLint("NewApi")
public void run() {
if (clusters.equals(StatusClusterRenderer.this.mClusters)) {

View File

@ -70,6 +70,7 @@ public class DraggableArrayAdapter<T> extends ArrayAdapter<T> implements Draggab
return true;
}
@Override
public void removeAt(final int position) {
super.removeAt(position);
rebuildIdMap();

View File

@ -24,148 +24,147 @@ import java.util.ArrayList;
public class JSONFileIO extends JSONSerializer {
public static final String JSON_CACHE_DIR = "json_cache";
private static final String KEY_OBJECT = "object";
public static final String JSON_CACHE_DIR = "json_cache";
private static final String KEY_OBJECT = "object";
private static final String KEY_CLASS = "class";
private static final String KEY_CLASS = "class";
public static JSONArray convertJSONArray(final InputStream stream) throws IOException {
final String string = convertString(stream);
try {
return new JSONArray(string);
} catch (final JSONException e) {
throw new IOException(e);
}
}
public static JSONArray convertJSONArray(final InputStream stream) throws IOException {
final String string = convertString(stream);
try {
return new JSONArray(string);
} catch (final JSONException e) {
throw new IOException(e);
}
}
public static JSONObject convertJSONObject(final InputStream stream) throws IOException {
final String string = convertString(stream);
try {
return new JSONObject(string);
} catch (final JSONException e) {
throw new IOException(e);
}
}
public static JSONObject convertJSONObject(final InputStream stream) throws IOException {
final String string = convertString(stream);
try {
return new JSONObject(string);
} catch (final JSONException e) {
throw new IOException(e);
}
}
public static String convertString(final InputStream stream) throws IOException {
if (stream == null) throw new FileNotFoundException();
final BufferedReader reader = new BufferedReader(new InputStreamReader(stream, Charset.defaultCharset()));
final StringBuffer buf = new StringBuffer();
String line = null;
while ((line = reader.readLine()) != null) {
buf.append(line);
buf.append('\n');
}
reader.close();
return buf.toString();
}
public static String convertString(final InputStream stream) throws IOException {
if (stream == null) throw new FileNotFoundException();
final BufferedReader reader = new BufferedReader(new InputStreamReader(stream, Charset.defaultCharset()));
final StringBuilder buf = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
buf.append(line);
buf.append('\n');
}
reader.close();
return buf.toString();
}
public static File getSerializationFile(final Context context, final Object... args) throws IOException {
if (context == null || args == null || args.length == 0) return null;
final File cache_dir = Utils.getBestCacheDir(context, JSON_CACHE_DIR);
if (!cache_dir.exists()) {
cache_dir.mkdirs();
}
final String filename = Utils.encodeQueryParams(TwidereArrayUtils.toString(args, '.', false));
final File cache_file = new File(cache_dir, filename + ".json");
return cache_file;
}
public static File getSerializationFile(final Context context, final Object... args) throws IOException {
if (context == null || args == null || args.length == 0) return null;
final File cache_dir = Utils.getBestCacheDir(context, JSON_CACHE_DIR);
if (!cache_dir.exists()) {
cache_dir.mkdirs();
}
final String filename = Utils.encodeQueryParams(TwidereArrayUtils.toString(args, '.', false));
return new File(cache_dir, filename + ".json");
}
public static <T extends JSONParcelable> T[] readArray(final File file) throws IOException {
if (file == null) throw new FileNotFoundException();
return readArray(new FileInputStream(file));
}
public static <T extends JSONParcelable> T[] readArray(final File file) throws IOException {
if (file == null) throw new FileNotFoundException();
return readArray(new FileInputStream(file));
}
public static <T extends JSONParcelable> T[] readArray(final InputStream stream) throws IOException {
try {
final JSONObject json = new JSONObject(convertString(stream));
final JSONParcelable.Creator<T> creator = getCreator(json.getString(KEY_CLASS));
return createArray(creator, json.getJSONArray(KEY_OBJECT));
} catch (final JSONException e) {
throw new IOException(e);
}
}
public static <T extends JSONParcelable> T[] readArray(final InputStream stream) throws IOException {
try {
final JSONObject json = new JSONObject(convertString(stream));
final JSONParcelable.Creator<T> creator = getCreator(json.getString(KEY_CLASS));
return createArray(creator, json.getJSONArray(KEY_OBJECT));
} catch (final JSONException e) {
throw new IOException(e);
}
}
public static <T extends JSONParcelable> ArrayList<T> readArrayList(final File file) throws IOException {
if (file == null) throw new FileNotFoundException();
return readArrayList(new FileInputStream(file));
}
public static <T extends JSONParcelable> ArrayList<T> readArrayList(final File file) throws IOException {
if (file == null) throw new FileNotFoundException();
return readArrayList(new FileInputStream(file));
}
public static <T extends JSONParcelable> ArrayList<T> readArrayList(final InputStream stream) throws IOException {
try {
final JSONObject json = new JSONObject(convertString(stream));
final JSONParcelable.Creator<T> creator = getCreator(json.getString(KEY_CLASS));
return createArrayList(creator, json.getJSONArray(KEY_OBJECT));
} catch (final JSONException e) {
throw new IOException(e);
}
}
public static <T extends JSONParcelable> ArrayList<T> readArrayList(final InputStream stream) throws IOException {
try {
final JSONObject json = new JSONObject(convertString(stream));
final JSONParcelable.Creator<T> creator = getCreator(json.getString(KEY_CLASS));
return createArrayList(creator, json.getJSONArray(KEY_OBJECT));
} catch (final JSONException e) {
throw new IOException(e);
}
}
public static <T extends JSONParcelable> T readObject(final File file) throws IOException {
if (file == null) throw new FileNotFoundException();
return readObject(new FileInputStream(file));
}
public static <T extends JSONParcelable> T readObject(final File file) throws IOException {
if (file == null) throw new FileNotFoundException();
return readObject(new FileInputStream(file));
}
public static <T extends JSONParcelable> T readObject(final InputStream stream) throws IOException {
try {
final JSONObject json = new JSONObject(convertString(stream));
final JSONParcelable.Creator<T> creator = getCreator(json.optString(KEY_CLASS));
return createObject(creator, json.optJSONObject(KEY_OBJECT));
} catch (final JSONException e) {
throw new IOException(e);
}
}
public static <T extends JSONParcelable> T readObject(final InputStream stream) throws IOException {
try {
final JSONObject json = new JSONObject(convertString(stream));
final JSONParcelable.Creator<T> creator = getCreator(json.optString(KEY_CLASS));
return createObject(creator, json.optJSONObject(KEY_OBJECT));
} catch (final JSONException e) {
throw new IOException(e);
}
}
public static <T extends JSONParcelable> void writeArray(final File file, final T[] array) throws IOException {
writeArray(new FileOutputStream(file), array);
}
public static <T extends JSONParcelable> void writeArray(final File file, final T[] array) throws IOException {
writeArray(new FileOutputStream(file), array);
}
public static <T extends JSONParcelable> void writeArray(final OutputStream stream, final T[] array)
throws IOException {
if (stream == null || array == null) return;
final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stream, Charset.defaultCharset()));
final JSONObject json = new JSONObject();
try {
json.put(KEY_CLASS, array.getClass().getComponentType().getName());
json.put(KEY_OBJECT, toJSONArray(array));
writer.write(jsonToString(json));
writer.flush();
} catch (final JSONException e) {
throw new IOException(e);
} finally {
writer.close();
}
}
public static <T extends JSONParcelable> void writeArray(final OutputStream stream, final T[] array)
throws IOException {
if (stream == null || array == null) return;
final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stream, Charset.defaultCharset()));
final JSONObject json = new JSONObject();
try {
json.put(KEY_CLASS, array.getClass().getComponentType().getName());
json.put(KEY_OBJECT, toJSONArray(array));
writer.write(jsonToString(json));
writer.flush();
} catch (final JSONException e) {
throw new IOException(e);
} finally {
writer.close();
}
}
public static <T extends JSONParcelable> void writeObject(final File file, final T parcelable) throws IOException {
writeObject(new FileOutputStream(file), parcelable);
}
public static <T extends JSONParcelable> void writeObject(final File file, final T parcelable) throws IOException {
writeObject(new FileOutputStream(file), parcelable);
}
public static <T extends JSONParcelable> void writeObject(final OutputStream stream, final T parcelable)
throws IOException {
if (stream == null || parcelable == null) return;
final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stream, Charset.defaultCharset()));
final JSONObject json = new JSONObject();
try {
json.put(KEY_CLASS, parcelable.getClass().getName());
json.put(KEY_OBJECT, toJSONObject(parcelable));
writer.write(jsonToString(json));
writer.flush();
} catch (final JSONException e) {
throw new IOException(e);
} finally {
Utils.closeSilently(writer);
}
}
public static <T extends JSONParcelable> void writeObject(final OutputStream stream, final T parcelable)
throws IOException {
if (stream == null || parcelable == null) return;
final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stream, Charset.defaultCharset()));
final JSONObject json = new JSONObject();
try {
json.put(KEY_CLASS, parcelable.getClass().getName());
json.put(KEY_OBJECT, toJSONObject(parcelable));
writer.write(jsonToString(json));
writer.flush();
} catch (final JSONException e) {
throw new IOException(e);
} finally {
Utils.closeSilently(writer);
}
}
@SuppressWarnings("unchecked")
private static <T extends JSONParcelable> JSONParcelable.Creator<T> getCreator(final String name)
throws IOException {
try {
final Class<?> cls = Class.forName(name);
return (JSONParcelable.Creator<T>) cls.getField("JSON_CREATOR").get(null);
} catch (final Exception e) {
throw new IOException(e);
}
}
@SuppressWarnings("unchecked")
private static <T extends JSONParcelable> JSONParcelable.Creator<T> getCreator(final String name)
throws IOException {
try {
final Class<?> cls = Class.forName(name);
return (JSONParcelable.Creator<T>) cls.getField("JSON_CREATOR").get(null);
} catch (final Exception e) {
throw new IOException(e);
}
}
}

View File

@ -20,13 +20,10 @@
package org.mariotaku.twidere.activity;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.support.v4.view.ViewPager;
import android.support.v4.view.WindowCompat;
import android.view.MenuItem;
import android.view.WindowManager.LayoutParams;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.activity.support.BaseDialogWhenLargeActivity;

View File

@ -24,12 +24,8 @@ import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.widget.ActionMenuView;
import android.support.v7.widget.Toolbar;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import org.mariotaku.twidere.Constants;
import org.mariotaku.twidere.activity.iface.IControlBarActivity;
@ -38,7 +34,6 @@ import org.mariotaku.twidere.fragment.iface.IBaseFragment.SystemWindowsInsetsCal
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.ShortcutCallback;
import org.mariotaku.twidere.util.ThemeUtils;
import org.mariotaku.twidere.util.ViewUtils;
import org.mariotaku.twidere.view.iface.IExtendedView.OnFitSystemWindowsListener;
import java.util.ArrayList;

View File

@ -45,7 +45,6 @@ import org.mariotaku.twidere.provider.TwidereDataStore.Accounts;
import org.mariotaku.twidere.util.AsyncTaskUtils;
import org.mariotaku.twidere.util.OAuthPasswordAuthenticator;
import org.mariotaku.twidere.util.ParseUtils;
import org.mariotaku.twidere.util.TwitterContentUtils;
import org.mariotaku.twidere.util.Utils;
import org.mariotaku.twidere.util.net.OkHttpClientFactory;
import org.mariotaku.twidere.util.net.TwidereHostResolverFactory;

View File

@ -61,6 +61,7 @@ import android.support.v7.widget.RecyclerView.ItemDecoration;
import android.support.v7.widget.RecyclerView.State;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.text.Editable;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
@ -74,6 +75,7 @@ import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.view.Window;
@ -135,8 +137,8 @@ import java.util.Collections;
import java.util.List;
import java.util.TreeSet;
public class ComposeActivity extends ThemedFragmentActivity implements TextWatcher, LocationListener,
OnMenuItemClickListener, OnClickListener, OnEditorActionListener, OnLongClickListener, Callback {
public class ComposeActivity extends ThemedFragmentActivity implements LocationListener, OnMenuItemClickListener,
OnClickListener, OnLongClickListener, Callback {
private static final String FAKE_IMAGE_LINK = "https://www.example.com/fake_image.jpg";
private static final String EXTRA_IS_POSSIBLY_SENSITIVE = "is_possibly_sensitive";
@ -178,10 +180,6 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
private TextView mLocationText;
private SupportMenuInflater mMenuInflater;
@Override
public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {
}
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
@ -216,17 +214,6 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
contentView.getPaddingRight(), contentView.getPaddingBottom());
}
@Override
public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {
setMenu();
updateTextCount();
}
@Override
public void afterTextChanged(final Editable s) {
}
@Override
public int getThemeColor() {
return ThemeUtils.getUserAccentColor(this);
@ -370,13 +357,24 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
mAccountSelectorContainer.setVisibility(visible ? View.VISIBLE : View.GONE);
}
@Override
public boolean onEditorAction(final TextView view, final int actionId, final KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEND) {
updateStatus();
return true;
public static boolean isFinishedComposing(CharSequence text) {
if (!(text instanceof Spanned)) return true;
final Spanned spanned = (Spanned) text;
try {
final Class<?> cls = Class.forName("android.text.style.SpellCheckSpan");
if (spanned.getSpans(0, spanned.length(), cls).length > 0) return false;
} catch (Exception ignored) {
}
return false;
try {
final Class<?> cls = Class.forName("android.view.inputmethod.ComposingText");
if (spanned.getSpans(0, spanned.length(), cls).length > 0) return false;
} catch (Exception ignored) {
}
// if (spanned.getSpans(0, spanned.length(), SpanWatcher.class).length > 0) return false;
return true;
}
@Override
@ -600,18 +598,53 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
finish();
return;
}
// mMenuBar.setIsBottomBar(true);
mMenuBar.setOnMenuItemClickListener(this);
boolean quickSend = mPreferences.getBoolean(KEY_QUICK_SEND);
if (quickSend) {
mEditText.setImeOptions(EditorInfo.IME_ACTION_SEND);
mEditText.setComposeInputSingleLine(true);
} else {
mEditText.setImeOptions(EditorInfo.IME_ACTION_UNSPECIFIED);
mEditText.setComposeInputSingleLine(false);
}
mEditText.setOnEditorActionListener(this);
mEditText.addTextChangedListener(this);
final boolean sendByEnter = mPreferences.getBoolean(KEY_QUICK_SEND);
mEditText.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_ENTER && sendByEnter && event.getAction() == KeyEvent.ACTION_DOWN) {
updateStatus();
return true;
}
return false;
}
});
mEditText.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(final TextView view, final int actionId, final KeyEvent event) {
if (sendByEnter) {
if (event != null && actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_DOWN) {
updateStatus();
return true;
}
}
return false;
}
});
mEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {
}
@Override
public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {
setMenu();
updateTextCount();
}
@Override
public void afterTextChanged(final Editable s) {
final int length = s.length();
if (sendByEnter && length > 0 && s.charAt(length - 1) == '\n') {
s.delete(length - 1, length);
updateStatus();
}
}
});
mEditText.setCustomSelectionActionModeCallback(this);
mAccountSelectorContainer.setOnClickListener(this);
mAccountSelectorButton.setOnClickListener(this);

View File

@ -29,10 +29,8 @@ import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.graphics.Rect;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
@ -42,7 +40,6 @@ import android.support.v4.app.FragmentActivity;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.support.v4.view.WindowCompat;
import android.support.v7.app.ActionBar;
import android.util.Log;
import android.util.SparseBooleanArray;
@ -50,7 +47,6 @@ import android.view.ActionMode;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager.LayoutParams;
import android.widget.AbsListView.MultiChoiceModeListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
@ -72,7 +68,6 @@ import org.mariotaku.twidere.provider.TwidereDataStore.Drafts;
import org.mariotaku.twidere.util.AsyncTaskUtils;
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
import org.mariotaku.twidere.util.ThemeUtils;
import org.mariotaku.twidere.view.TintedStatusFrameLayout;
import java.io.File;
import java.util.ArrayList;

View File

@ -107,12 +107,15 @@ public abstract class AbsActivitiesAdapter<Data> extends Adapter<ViewHolder> imp
mStatusAdapterDelegate = new DummyStatusHolderAdapter(context);
}
@Override
public abstract ParcelableActivity getActivity(int position);
@Override
public abstract int getActivityCount();
public abstract Data getData();
@Override
public abstract void setData(Data data);
@Override
@ -189,6 +192,7 @@ public abstract class AbsActivitiesAdapter<Data> extends Adapter<ViewHolder> imp
return mNameFirst;
}
@Override
public boolean isProfileImageEnabled() {
return mDisplayProfileImage;
}
@ -334,6 +338,7 @@ public abstract class AbsActivitiesAdapter<Data> extends Adapter<ViewHolder> imp
return ITEM_VIEW_TYPE_STUB;
}
@Override
public final int getItemCount() {
return getActivityCount() + (mLoadMoreIndicatorVisible ? 1 : 0);
}

View File

@ -91,6 +91,7 @@ public abstract class AbsStatusesAdapter<D> extends LoadMoreSupportAdapter<ViewH
public abstract D getData();
@Override
public abstract void setData(D data);
@Override

View File

@ -302,6 +302,7 @@ public class ArrayAdapter<T> extends BaseAdapter implements Filterable {
/**
* {@inheritDoc}
*/
@Override
public int getCount() {
return mObjects.size();
}
@ -309,6 +310,7 @@ public class ArrayAdapter<T> extends BaseAdapter implements Filterable {
/**
* {@inheritDoc}
*/
@Override
public T getItem(int position) {
return mObjects.get(position);
}
@ -326,6 +328,7 @@ public class ArrayAdapter<T> extends BaseAdapter implements Filterable {
/**
* {@inheritDoc}
*/
@Override
public long getItemId(int position) {
return position;
}
@ -333,6 +336,7 @@ public class ArrayAdapter<T> extends BaseAdapter implements Filterable {
/**
* {@inheritDoc}
*/
@Override
public View getView(int position, View convertView, ViewGroup parent) {
return createViewFromResource(position, convertView, parent, mResource);
}
@ -387,6 +391,7 @@ public class ArrayAdapter<T> extends BaseAdapter implements Filterable {
/**
* {@inheritDoc}
*/
@Override
public Filter getFilter() {
if (mFilter == null) {
mFilter = new ArrayFilter();

View File

@ -93,6 +93,7 @@ public class MessageEntriesAdapter extends Adapter<ViewHolder> implements Consta
};
}
@Override
public Context getContext() {
return mContext;
}
@ -124,6 +125,7 @@ public class MessageEntriesAdapter extends Adapter<ViewHolder> implements Consta
return new DirectMessageEntry(c);
}
@Override
public MediaLoaderWrapper getMediaLoader() {
return mImageLoader;
}

View File

@ -72,6 +72,7 @@ public class ParcelableActivitiesAdapter extends AbsActivitiesAdapter<List<Parce
}
@Override
public void setData(List<ParcelableActivity> data) {
mData = data;
notifyDataSetChanged();

View File

@ -54,11 +54,13 @@ public class ParcelableStatusesAdapter extends AbsStatusesAdapter<List<Parcelabl
return mData.get(position).id;
}
@Override
public void setData(List<ParcelableStatus> data) {
mData = data;
notifyDataSetChanged();
}
@Override
public List<ParcelableStatus> getData() {
return mData;
}

View File

@ -20,8 +20,6 @@
package org.mariotaku.twidere.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.View;
import org.mariotaku.twidere.model.ParcelableUser;
import org.mariotaku.twidere.view.holder.UserViewHolder;

View File

@ -38,6 +38,7 @@ public interface IActivitiesAdapter<Data> extends IContentCardAdapter, IGapSuppo
@PreviewStyle
int getMediaPreviewStyle();
@Override
MediaLoaderWrapper getMediaLoader();
MediaLoadingHandler getMediaLoadingHandler();

View File

@ -1,7 +1,6 @@
package org.mariotaku.twidere.adapter.iface;
import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.util.MediaLoaderWrapper;
import org.mariotaku.twidere.util.MediaLoadingHandler;
import org.mariotaku.twidere.util.TwidereLinkify;
import org.mariotaku.twidere.view.CardMediaContainer.PreviewStyle;

View File

@ -38,6 +38,7 @@ public interface IUsersAdapter<Data> extends IContentCardAdapter, UserClickListe
boolean shouldShowAccountsColor();
@Override
MediaLoaderWrapper getMediaLoader();
}

View File

@ -146,7 +146,7 @@ public class TwidereApplication extends MultiDexApplication implements Constants
if (mKeyboardShortcutsHandler.isEmpty()
&& !preferences.getBoolean(KEY_KEYBOARD_SHORTCUT_INITIALIZED, false)) {
mKeyboardShortcutsHandler.reset();
preferences.edit().putBoolean(KEY_KEYBOARD_SHORTCUT_INITIALIZED, true);
preferences.edit().putBoolean(KEY_KEYBOARD_SHORTCUT_INITIALIZED, true).apply();
}
return mKeyboardShortcutsHandler;
}

View File

@ -58,7 +58,6 @@ import org.mariotaku.querybuilder.Columns.Column;
import org.mariotaku.querybuilder.Expression;
import org.mariotaku.querybuilder.RawItemArray;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.activity.iface.IThemedActivity;
import org.mariotaku.twidere.activity.support.UserListSelectorActivity;
import org.mariotaku.twidere.adapter.SourceAutoCompleteAdapter;
import org.mariotaku.twidere.adapter.UserHashtagAutoCompleteAdapter;

View File

@ -68,18 +68,22 @@ public abstract class AbsContentListFragment<A extends IContentCardAdapter> exte
private A mAdapter;
private ContentListScrollListener mScrollListener;
@Override
public boolean canScroll(float dy) {
return mDrawerCallback.canScroll(dy);
}
@Override
public void cancelTouch() {
mDrawerCallback.cancelTouch();
}
@Override
public void fling(float velocity) {
mDrawerCallback.fling(velocity);
}
@Override
public boolean isScrollContent(float x, float y) {
return mDrawerCallback.isScrollContent(x, y);
}
@ -95,6 +99,7 @@ public abstract class AbsContentListFragment<A extends IContentCardAdapter> exte
triggerRefresh();
}
@Override
public void scrollBy(float dy) {
mDrawerCallback.scrollBy(dy);
}
@ -107,6 +112,7 @@ public abstract class AbsContentListFragment<A extends IContentCardAdapter> exte
return true;
}
@Override
public void setControlVisible(boolean visible) {
final FragmentActivity activity = getActivity();
if (activity instanceof BaseActionBarActivity) {
@ -114,18 +120,22 @@ public abstract class AbsContentListFragment<A extends IContentCardAdapter> exte
}
}
@Override
public boolean shouldLayoutHeaderBottom() {
return mDrawerCallback.shouldLayoutHeaderBottom();
}
@Override
public void topChanged(int offset) {
mDrawerCallback.topChanged(offset);
}
@Override
public A getAdapter() {
return mAdapter;
}
@Override
public abstract boolean isRefreshing();
public LinearLayoutManager getLayoutManager() {
@ -138,6 +148,7 @@ public abstract class AbsContentListFragment<A extends IContentCardAdapter> exte
mSwipeRefreshLayout.setRefreshing(refreshing && !mAdapter.isLoadMoreIndicatorVisible());
}
@Override
public void onLoadMoreContents() {
setLoadMoreIndicatorVisible(true);
setRefreshEnabled(false);

View File

@ -344,6 +344,7 @@ public class DirectMessagesFragment extends BaseSupportFragment implements Loade
mSwipeRefreshLayout.setRefreshing(refreshing && !mAdapter.isLoadMoreIndicatorVisible());
}
@Override
public boolean isRefreshing() {
if (mSwipeRefreshLayout == null || mAdapter == null) return false;
return mSwipeRefreshLayout.isRefreshing() || mAdapter.isLoadMoreIndicatorVisible();
@ -394,6 +395,7 @@ public class DirectMessagesFragment extends BaseSupportFragment implements Loade
});
}
@Override
public MessageEntriesAdapter getAdapter() {
return mAdapter;
}

View File

@ -1107,6 +1107,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
return RecyclerView.NO_POSITION;
}
@Override
public Context getContext() {
return mContext;
}
@ -1116,6 +1117,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
return mProfileImageStyle;
}
@Override
public float getTextSize() {
return mTextSize;
}
@ -1131,6 +1133,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
return mDisplayProfileImage;
}
@Override
public MediaLoaderWrapper getMediaLoader() {
return mImageLoader;
}
@ -1189,6 +1192,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
return mDisplayMediaPreview;
}
@Override
public boolean isNameFirst() {
return mNameFirst;
}

View File

@ -99,6 +99,7 @@ class DrawableWrapper extends Drawable implements Drawable.Callback {
return mDrawable.getState();
}
@Override
public void jumpToCurrentState() {
DrawableCompat.jumpToCurrentState(mDrawable);
}
@ -151,6 +152,7 @@ class DrawableWrapper extends Drawable implements Drawable.Callback {
/**
* {@inheritDoc}
*/
@Override
public void invalidateDrawable(Drawable who) {
invalidateSelf();
}
@ -158,6 +160,7 @@ class DrawableWrapper extends Drawable implements Drawable.Callback {
/**
* {@inheritDoc}
*/
@Override
public void scheduleDrawable(Drawable who, Runnable what, long when) {
scheduleSelf(what, when);
}
@ -165,6 +168,7 @@ class DrawableWrapper extends Drawable implements Drawable.Callback {
/**
* {@inheritDoc}
*/
@Override
public void unscheduleDrawable(Drawable who, Runnable what) {
unscheduleSelf(what);
}

View File

@ -1,113 +0,0 @@
/*
* 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/>.
*/
package org.mariotaku.twidere.graphic;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BlurMaskFilter;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import org.mariotaku.twidere.util.Utils;
public final class DropShadowDrawable extends BitmapDrawable {
private final Bitmap dropShadow, dropShadowMask;
public DropShadowDrawable(final Resources resources, final Bitmap bitmap, final float shadowRadius,
final int shadowColor) {
this(resources, bitmap, shadowRadius, shadowColor, Color.TRANSPARENT);
}
public DropShadowDrawable(final Resources resources, final Bitmap bitmap, final float shadowRadius,
final int shadowColor, final int shadowMaskColor) {
super(resources, bitmap);
final float density = resources.getDisplayMetrics().density;
final int shadowAlpha = Color.alpha(shadowColor), shadowMaskAlpha = Color.alpha(shadowMaskColor);
final boolean hasShadow = shadowRadius != 0 && shadowAlpha != 0;
dropShadow = hasShadow ? createDropShadow(bitmap, shadowRadius * density, shadowColor) : null;
dropShadowMask = shadowMaskAlpha != 0 ? createDropShadowMask(bitmap, shadowMaskColor) : null;
}
public DropShadowDrawable(final Resources resources, final Drawable drawable, final float shadowRadius,
final int shadowColor) {
this(resources, drawable, shadowRadius, shadowColor, Color.TRANSPARENT);
}
public DropShadowDrawable(final Resources resources, final Drawable drawable, final float shadowRadius,
final int shadowColor, final int shadowMaskColor) {
this(resources, Utils.getBitmap(drawable), shadowRadius, shadowColor, shadowMaskColor);
}
public DropShadowDrawable(final Resources resources, final int res, final float shadowRadius, final int shadowColor) {
this(resources, res, shadowRadius, shadowColor, Color.TRANSPARENT);
}
public DropShadowDrawable(final Resources resources, final int res, final float shadowRadius,
final int shadowColor, final int shadowMaskColor) {
this(resources, Utils.getBitmap(resources.getDrawable(res)), shadowRadius, shadowColor, shadowMaskColor);
}
@Override
public void draw(final Canvas canvas) {
final Rect bounds = getBounds();
if (dropShadow != null) {
canvas.drawBitmap(dropShadow, bounds.left, bounds.top, null);
}
if (dropShadowMask != null) {
canvas.drawBitmap(dropShadowMask, bounds.left, bounds.top, null);
}
super.draw(canvas);
}
private static Bitmap createDropShadow(final Bitmap src, final float radius, final int color) {
if (src == null) return null;
final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
final int width = src.getWidth(), height = src.getHeight();
final Bitmap dest = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
final Canvas canvas = new Canvas(dest);
// Create background
final Bitmap alpha = src.extractAlpha();
paint.setColor(color);
canvas.drawBitmap(alpha, 0, 0, paint);
// Create outer blur
final BlurMaskFilter filter = new BlurMaskFilter(radius, BlurMaskFilter.Blur.OUTER);
paint.setMaskFilter(filter);
canvas.drawBitmap(alpha, 0, 0, paint);
return dest;
}
private static Bitmap createDropShadowMask(final Bitmap src, final int color) {
if (src == null) return null;
final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
final int width = src.getWidth(), height = src.getHeight();
final Bitmap dest = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
final Canvas canvas = new Canvas(dest);
// Create background
final Bitmap alpha = src.extractAlpha();
paint.setColor(color);
canvas.drawBitmap(alpha, 0, 0, paint);
return dest;
}
}

View File

@ -31,49 +31,49 @@ import org.mariotaku.twidere.activity.NyanActivity;
public class AppVersionPreference extends Preference {
public Handler mHandler = new Handler();
protected int mClickCount;
public Handler mHandler = new Handler();
protected int mClickCount;
private final Runnable mResetCounterRunnable = new Runnable() {
private final Runnable mResetCounterRunnable = new Runnable() {
@Override
public void run() {
mClickCount = 0;
}
};
@Override
public void run() {
mClickCount = 0;
}
};
public AppVersionPreference(final Context context) {
this(context, null);
}
public AppVersionPreference(final Context context) {
this(context, null);
}
public AppVersionPreference(final Context context, final AttributeSet attrs) {
this(context, attrs, android.R.attr.preferenceStyle);
}
public AppVersionPreference(final Context context, final AttributeSet attrs) {
this(context, attrs, android.R.attr.preferenceStyle);
}
public AppVersionPreference(final Context context, final AttributeSet attrs, final int defStyle) {
super(context, attrs, defStyle);
final PackageManager pm = context.getPackageManager();
try {
final PackageInfo info = pm.getPackageInfo(context.getPackageName(), 0);
setTitle(info.applicationInfo.loadLabel(pm));
setSummary(info.versionName);
} catch (final PackageManager.NameNotFoundException e) {
public AppVersionPreference(final Context context, final AttributeSet attrs, final int defStyle) {
super(context, attrs, defStyle);
final PackageManager pm = context.getPackageManager();
try {
final PackageInfo info = pm.getPackageInfo(context.getPackageName(), 0);
setTitle(info.applicationInfo.loadLabel(pm));
setSummary(info.versionName);
} catch (final PackageManager.NameNotFoundException e) {
throw new AssertionError(e);
}
}
}
}
@Override
protected void onClick() {
mHandler.removeCallbacks(mResetCounterRunnable);
mClickCount++;
if (mClickCount >= 7) {
final Context context = getContext();
if (context != null) {
mClickCount = 0;
context.startActivity(new Intent(context, NyanActivity.class));
}
}
mHandler.postDelayed(mResetCounterRunnable, 3000);
}
@Override
protected void onClick() {
mHandler.removeCallbacks(mResetCounterRunnable);
mClickCount++;
if (mClickCount >= 7) {
final Context context = getContext();
if (context != null) {
mClickCount = 0;
context.startActivity(new Intent(context, NyanActivity.class));
}
}
mHandler.postDelayed(mResetCounterRunnable, 3000);
}
}

View File

@ -843,6 +843,7 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
filteredSelection, null, null, null, Statuses.SORT_ORDER_TIMESTAMP_DESC);
final Cursor userCursor = mDatabaseWrapper.query(Statuses.TABLE_NAME, userProjection,
filteredSelection, null, Statuses.USER_ID, null, Statuses.SORT_ORDER_TIMESTAMP_DESC);
//noinspection TryFinallyCanBeTryWithResources
try {
final int usersCount = userCursor.getCount();
final int statusesCount = statusCursor.getCount();
@ -917,6 +918,7 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
filteredSelection, null, null, null, Statuses.SORT_ORDER_TIMESTAMP_DESC);
final Cursor userCursor = mDatabaseWrapper.query(Mentions.TABLE_NAME, userProjection,
filteredSelection, null, Statuses.USER_ID, null, Statuses.SORT_ORDER_TIMESTAMP_DESC);
//noinspection TryFinallyCanBeTryWithResources
try {
final int usersCount = userCursor.getCount();
final int statusesCount = statusCursor.getCount();
@ -1097,6 +1099,7 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
filteredSelection, null, null, null, DirectMessages.DEFAULT_SORT_ORDER);
final Cursor userCursor = mDatabaseWrapper.query(DirectMessages.Inbox.TABLE_NAME, userProjection,
filteredSelection, null, DirectMessages.SENDER_ID, null, DirectMessages.DEFAULT_SORT_ORDER);
//noinspection TryFinallyCanBeTryWithResources
try {
final int usersCount = userCursor.getCount();
final int messagesCount = messageCursor.getCount();

View File

@ -181,7 +181,7 @@ public class BackgroundOperationService extends IntentService implements Constan
mHandler.post(new Runnable() {
@Override
public void run() {
Toast.makeText(BackgroundOperationService.this, message, longMessage ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT);
Toast.makeText(BackgroundOperationService.this, message, longMessage ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT).show();
}
});
}

View File

@ -38,6 +38,7 @@ public class DirectMessageOnLinkClickHandler extends OnLinkClickHandler {
super(context, manager);
}
@Override
protected boolean isPrivateData() {
return true;
}

View File

@ -46,8 +46,8 @@ public class LongSparseArrayUtils {
*/
public static <E> void setValues(final LongSparseArray<E> array, final long[] keys, final E uniqueValue) {
final int length = keys.length;
for (int i = 0; i < length; i++) {
array.put(keys[i], uniqueValue);
}
for (long key : keys) {
array.put(key, uniqueValue);
}
}
}

View File

@ -73,10 +73,10 @@ public final class TwidereLinkify implements Constants {
public static final int[] ALL_LINK_TYPES = new int[]{LINK_TYPE_LINK, LINK_TYPE_MENTION, LINK_TYPE_HASHTAG,
LINK_TYPE_STATUS, LINK_TYPE_CASHTAG};
public static final String AVAILABLE_URL_SCHEME_PREFIX = "(https?:\\/\\/)?";
public static final String AVAILABLE_URL_SCHEME_PREFIX = "(https?://)?";
public static final String TWITTER_PROFILE_IMAGES_AVAILABLE_SIZES = "(bigger|normal|mini|reasonably_small)";
private static final String STRING_PATTERN_TWITTER_PROFILE_IMAGES_NO_SCHEME = "(twimg[\\d\\w\\-]+\\.akamaihd\\.net|[\\w\\d]+\\.twimg\\.com)\\/profile_images\\/([\\d\\w\\-_]+)\\/([\\d\\w\\-_]+)_"
private static final String STRING_PATTERN_TWITTER_PROFILE_IMAGES_NO_SCHEME = "(twimg[\\d\\w\\-]+\\.akamaihd\\.net|[\\w\\d]+\\.twimg\\.com)/profile_images/([\\d\\w\\-_]+)/([\\d\\w\\-_]+)_"
+ TWITTER_PROFILE_IMAGES_AVAILABLE_SIZES + "(\\.?" + AVAILABLE_IMAGE_SHUFFIX + ")?";
private static final String STRING_PATTERN_TWITTER_PROFILE_IMAGES = AVAILABLE_URL_SCHEME_PREFIX
+ STRING_PATTERN_TWITTER_PROFILE_IMAGES_NO_SCHEME;
@ -87,12 +87,12 @@ public final class TwidereLinkify implements Constants {
public static final int GROUP_ID_TWITTER_STATUS_STATUS_ID = 6;
public static final int GROUP_ID_TWITTER_LIST_SCREEN_NAME = 4;
public static final int GROUP_ID_TWITTER_LIST_LIST_NAME = 5;
private static final String STRING_PATTERN_TWITTER_STATUS_NO_SCHEME = "((mobile|www)\\.)?twitter\\.com\\/(?:#!\\/)?(\\w+)\\/status(es)?\\/(\\d+)(\\/photo\\/\\d)?\\/?";
private static final String STRING_PATTERN_TWITTER_STATUS_NO_SCHEME = "((mobile|www)\\.)?twitter\\.com/(?:#!/)?(\\w+)/status(es)?/(\\d+)(/photo/\\d)?/?";
private static final String STRING_PATTERN_TWITTER_STATUS = AVAILABLE_URL_SCHEME_PREFIX
+ STRING_PATTERN_TWITTER_STATUS_NO_SCHEME;
public static final Pattern PATTERN_TWITTER_STATUS = Pattern.compile(STRING_PATTERN_TWITTER_STATUS,
Pattern.CASE_INSENSITIVE);
private static final String STRING_PATTERN_TWITTER_LIST_NO_SCHEME = "((mobile|www)\\.)?twitter\\.com\\/(?:#!\\/)?(\\w+)\\/lists\\/(.+)\\/?";
private static final String STRING_PATTERN_TWITTER_LIST_NO_SCHEME = "((mobile|www)\\.)?twitter\\.com/(?:#!/)?(\\w+)/lists/(.+)/?";
private static final String STRING_PATTERN_TWITTER_LIST = AVAILABLE_URL_SCHEME_PREFIX
+ STRING_PATTERN_TWITTER_LIST_NO_SCHEME;
public static final Pattern PATTERN_TWITTER_LIST = Pattern.compile(STRING_PATTERN_TWITTER_LIST,

View File

@ -1874,12 +1874,15 @@ public final class Utils implements Constants, TwitterConstants {
@HighlightStyle
public static int getLinkHighlightingStyleInt(final String option) {
if (VALUE_LINK_HIGHLIGHT_OPTION_BOTH.equals(option))
return VALUE_LINK_HIGHLIGHT_OPTION_CODE_BOTH;
else if (VALUE_LINK_HIGHLIGHT_OPTION_HIGHLIGHT.equals(option))
return VALUE_LINK_HIGHLIGHT_OPTION_CODE_HIGHLIGHT;
else if (VALUE_LINK_HIGHLIGHT_OPTION_UNDERLINE.equals(option))
return VALUE_LINK_HIGHLIGHT_OPTION_CODE_UNDERLINE;
if (option == null) return VALUE_LINK_HIGHLIGHT_OPTION_CODE_NONE;
switch (option) {
case VALUE_LINK_HIGHLIGHT_OPTION_BOTH:
return VALUE_LINK_HIGHLIGHT_OPTION_CODE_BOTH;
case VALUE_LINK_HIGHLIGHT_OPTION_HIGHLIGHT:
return VALUE_LINK_HIGHLIGHT_OPTION_CODE_HIGHLIGHT;
case VALUE_LINK_HIGHLIGHT_OPTION_UNDERLINE:
return VALUE_LINK_HIGHLIGHT_OPTION_CODE_UNDERLINE;
}
return VALUE_LINK_HIGHLIGHT_OPTION_CODE_NONE;
}
@ -2800,6 +2803,7 @@ public final class Utils implements Constants, TwitterConstants {
final String[] projection = {Accounts.CONSUMER_KEY, Accounts.CONSUMER_SECRET};
final String selection = Expression.equals(Accounts.ACCOUNT_ID, accountId).getSQL();
final Cursor c = context.getContentResolver().query(Accounts.CONTENT_URI, projection, selection, null, null);
//noinspection TryFinallyCanBeTryWithResources
try {
if (c.moveToPosition(0))
return TwitterContentUtils.isOfficialKey(context, c.getString(0), c.getString(1));
@ -4106,6 +4110,7 @@ public final class Utils implements Constants, TwitterConstants {
final ContentResolver cr = context.getContentResolver();
final Expression where = Expression.equals(Users.USER_ID, userId);
final Cursor c = cr.query(Users.CONTENT_URI, new String[0], where.getSQL(), null, null);
//noinspection TryFinallyCanBeTryWithResources
try {
return c.getCount() > 0;
} finally {
@ -4119,6 +4124,7 @@ public final class Utils implements Constants, TwitterConstants {
final Expression where = Expression.and(Expression.equals(ConversationEntries.ACCOUNT_ID, accountId),
Expression.equals(ConversationEntries.CONVERSATION_ID, conversationId));
final Cursor c = cr.query(ConversationEntries.CONTENT_URI, null, where.getSQL(), null, null);
//noinspection TryFinallyCanBeTryWithResources
try {
if (c.moveToFirst()) return ParcelableUser.fromDirectMessageConversationEntry(c);
} finally {

View File

@ -149,10 +149,12 @@ public class ActivityAccessor {
public static final Creator<TaskDescriptionCompat> CREATOR
= new Creator<TaskDescriptionCompat>() {
@Override
public TaskDescriptionCompat createFromParcel(Parcel source) {
return new TaskDescriptionCompat(source);
}
@Override
public TaskDescriptionCompat[] newArray(int size) {
return new TaskDescriptionCompat[size];
}

View File

@ -34,7 +34,7 @@ public class BackStackEntryAccessor {
final Field fragmentField = mHead.getClass().getField("fragment");
final Object fragment = fragmentField.get(mHead);
if (fragment instanceof Fragment) return (Fragment) fragment;
} catch (final NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
} catch (final NoSuchFieldException | IllegalArgumentException | IllegalAccessException ignored) {
}
return null;
}

View File

@ -100,14 +100,16 @@ public class CompactHashSet<E> extends java.util.AbstractSet<E> {
* @return an Iterator over the elements in this set.
* @see ConcurrentModificationException
*/
@Override
@NonNull
public Iterator<E> iterator() {
return new CompactHashIterator<E>();
return new CompactHashIterator<>();
}
/**
* Returns the number of elements in this set (its cardinality).
*/
@Override
public int size() {
return elements;
}
@ -115,6 +117,7 @@ public class CompactHashSet<E> extends java.util.AbstractSet<E> {
/**
* Returns <tt>true</tt> if this set contains no elements.
*/
@Override
public boolean isEmpty() {
return elements == 0;
}
@ -125,6 +128,7 @@ public class CompactHashSet<E> extends java.util.AbstractSet<E> {
* @param o element whose presence in this set is to be tested.
* @return <tt>true</tt> if this set contains the specified element.
*/
@Override
public boolean contains(Object o) {
if (o == null) o = nullObject;
@ -154,6 +158,7 @@ public class CompactHashSet<E> extends java.util.AbstractSet<E> {
* @return <tt>true</tt> if the set did not already contain the specified
* element.
*/
@Override
@SuppressWarnings("unchecked")
public boolean add(Object o) {
if (o == null) o = nullObject;
@ -208,6 +213,7 @@ public class CompactHashSet<E> extends java.util.AbstractSet<E> {
/**
* Removes the specified element from the set.
*/
@Override
@SuppressWarnings("unchecked")
public boolean remove(Object o) {
if (o == null) o = nullObject;
@ -244,6 +250,7 @@ public class CompactHashSet<E> extends java.util.AbstractSet<E> {
/**
* Removes all of the elements from this set.
*/
@Override
public void clear() {
elements = 0;
for (int ix = 0; ix < objects.length; ix++)
@ -252,23 +259,25 @@ public class CompactHashSet<E> extends java.util.AbstractSet<E> {
modCount++;
}
@Override
@NonNull
public Object[] toArray() {
Object[] result = new Object[elements];
Object[] objects = this.objects;
int pos = 0;
for (int i = 0; i < objects.length; i++)
if (objects[i] != null && objects[i] != deletedObject) {
if (objects[i] == nullObject)
for (Object object : objects)
if (object != null && object != deletedObject) {
if (object == nullObject)
result[pos++] = null;
else
result[pos++] = objects[i];
result[pos++] = object;
}
// unchecked because it should only contain E
return result;
}
// not sure if this needs to have generics
@Override
@NonNull
@SuppressWarnings("unchecked")
public <T> T[] toArray(@NonNull T[] a) {
@ -278,12 +287,12 @@ public class CompactHashSet<E> extends java.util.AbstractSet<E> {
a.getClass().getComponentType(), size);
E[] objects = this.objects;
int pos = 0;
for (int i = 0; i < objects.length; i++)
if (objects[i] != null && objects[i] != deletedObject) {
if (objects[i] == nullObject)
for (E object : objects)
if (object != null && object != deletedObject) {
if (object == nullObject)
a[pos++] = null;
else
a[pos++] = (T) objects[i];
a[pos++] = (T) object;
}
return a;
}
@ -330,8 +339,7 @@ public class CompactHashSet<E> extends java.util.AbstractSet<E> {
@SuppressWarnings("unchecked")
E[] newObjects = (E[]) new Object[newCapacity];
for (int ix = 0; ix < oldCapacity; ix++) {
Object o = objects[ix];
for (E o : objects) {
if (o == null || o == deletedObject)
continue;
@ -377,10 +385,12 @@ public class CompactHashSet<E> extends java.util.AbstractSet<E> {
expectedModCount = modCount;
}
@Override
public boolean hasNext() {
return index < objects.length;
}
@Override
@SuppressWarnings({"empty-statement", "unchecked"})
public T next() {
if (modCount != expectedModCount)
@ -402,6 +412,7 @@ public class CompactHashSet<E> extends java.util.AbstractSet<E> {
return (T) objects[lastReturned];
}
@Override
@SuppressWarnings("unchecked")
public void remove() {
if (modCount != expectedModCount)

View File

@ -117,8 +117,7 @@ public class TwidereImageDownloader extends BaseImageDownloader implements Const
if (statusCode != -1 && isTwitterProfileImage(uriString) && !uriString.contains("_normal.")) {
try {
return getStreamFromNetworkInternal(getNormalTwitterProfileImage(uriString), extras);
} catch (final TwitterException e2) {
} catch (final TwitterException ignored) {
}
}
throw new IOException(String.format(Locale.US, "Error downloading image %s, error code: %d", uriString,

View File

@ -24,16 +24,16 @@ import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
public class URLFileNameGenerator implements FileNameGenerator {
private final Md5FileNameGenerator mGenerator;
private final Md5FileNameGenerator mGenerator;
public URLFileNameGenerator() {
mGenerator = new Md5FileNameGenerator();
}
public URLFileNameGenerator() {
mGenerator = new Md5FileNameGenerator();
}
@Override
public String generate(final String imageUri) {
if (imageUri == null) return null;
return mGenerator.generate(imageUri.replaceFirst("https?:\\/\\/", ""));
}
@Override
public String generate(final String imageUri) {
if (imageUri == null) return null;
return mGenerator.generate(imageUri.replaceFirst("https?://", ""));
}
}

View File

@ -27,6 +27,7 @@ import android.util.Log;
import org.apache.http.conn.util.InetAddressUtils;
import org.mariotaku.twidere.Constants;
import org.mariotaku.twidere.util.HostsFileParser;
import org.mariotaku.twidere.util.UriUtils;
import org.mariotaku.twidere.util.Utils;
import org.xbill.DNS.AAAARecord;
import org.xbill.DNS.ARecord;

View File

@ -20,8 +20,6 @@
package org.mariotaku.twidere.view;
import android.content.Context;
import android.graphics.Rect;
import android.support.annotation.NonNull;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
@ -48,9 +46,4 @@ public class ExtendedViewPager extends ViewPager {
return super.onTouchEvent(event);
}
@Override
protected boolean fitSystemWindows(@NonNull Rect insets) {
return super.fitSystemWindows(insets);
}
}

View File

@ -82,14 +82,17 @@ public class HomeActionButtonCompat extends FrameLayout implements IHomeActionBu
}
@Override
public void setIcon(final Bitmap bm) {
mIconView.setImageBitmap(bm);
}
@Override
public void setIcon(final Drawable drawable) {
mIconView.setImageDrawable(drawable);
}
@Override
public void setIcon(final int resId) {
mIconView.setImageResource(resId);
}
@ -99,15 +102,18 @@ public class HomeActionButtonCompat extends FrameLayout implements IHomeActionBu
mIconView.setColorFilter(color, mode);
}
@Override
public void setShowProgress(final boolean showProgress) {
mProgressBar.setVisibility(showProgress ? View.VISIBLE : View.GONE);
mIconView.setVisibility(showProgress ? View.GONE : View.VISIBLE);
}
@Override
public void setTitle(final CharSequence title) {
setContentDescription(title);
}
@Override
public void setTitle(final int title) {
setTitle(getResources().getText(title));
}

View File

@ -35,7 +35,6 @@ public class StatusComposeEditText extends ThemedMultiAutoCompleteTextView imple
private UserHashtagAutoCompleteAdapter mAdapter;
private long mAccountId;
private boolean mInputSingleLine;
public StatusComposeEditText(final Context context) {
this(context, null);
@ -49,22 +48,15 @@ public class StatusComposeEditText extends ThemedMultiAutoCompleteTextView imple
super(context, attrs, defStyle);
setTokenizer(new ScreenNameTokenizer());
setMovementMethod(ArrowKeyMovementMethod.getInstance());
updateComposeInputType();
setupComposeInputType();
}
private void updateComposeInputType() {
private void setupComposeInputType() {
int rawInputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
if (!mInputSingleLine) {
rawInputType |= InputType.TYPE_TEXT_FLAG_MULTI_LINE;
}
rawInputType |= InputType.TYPE_TEXT_FLAG_MULTI_LINE;
setRawInputType(rawInputType);
}
public void setComposeInputSingleLine(boolean singleLine) {
mInputSingleLine = singleLine;
updateComposeInputType();
}
@Override
protected int computeVerticalScrollRange() {
return super.computeVerticalScrollRange();

View File

@ -61,6 +61,7 @@ public class TintedStatusFrameLayout extends ExtendedFrameLayout {
mBlackPaint.setColor(Color.BLACK);
mShadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mColorPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
a.recycle();
setWillNotDraw(false);
setFactor(1);
}

View File

@ -40,6 +40,6 @@ public class GapViewHolder extends RecyclerView.ViewHolder implements OnClickLis
@Override
public void onClick(View v) {
adapter.onGapClick(this, getPosition());
adapter.onGapClick(this, getLayoutPosition());
}
}

View File

@ -19,10 +19,10 @@
-->
<LinearLayout
android:id="@+id/compose_activity"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:id="@+id/compose_activity"
android:layout_height="wrap_content"
android:minWidth="@dimen/compose_min_width"
android:orientation="vertical">
@ -62,7 +62,6 @@
android:completionThreshold="1"
android:gravity="top"
android:hint="@string/status_hint"
android:imeOptions="actionDone"
android:minLines="6"
android:padding="@dimen/element_spacing_normal"
android:scrollbars="vertical"/>
@ -79,8 +78,8 @@
android:padding="@dimen/element_spacing_normal">
<org.mariotaku.twidere.view.ActionIconView
android:layout_width="@dimen/element_size_small"
android:id="@+id/location_icon"
android:layout_width="@dimen/element_size_small"
android:layout_height="@dimen/element_size_small"
android:layout_marginLeft="@dimen/element_spacing_normal"
android:layout_marginRight="@dimen/element_spacing_normal"
@ -88,8 +87,8 @@
android:src="@drawable/ic_action_location"/>
<org.mariotaku.twidere.view.themed.ThemedTextView
android:layout_width="match_parent"
android:id="@+id/location_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/element_spacing_normal"/>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<resources xmlns:tools="http://schemas.android.com/tools" xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="compose">Compose</string>
<string name="add_account">Add account</string>
@ -90,8 +90,8 @@
<string name="name_retweeted"><xliff:g id="user_name">%s</xliff:g> retweeted</string>
<string name="name_and_another_retweeted"><xliff:g id="user_name">%1$s</xliff:g> and another retweeted</string>
<string name="name_and_count_retweeted"><xliff:g id="user_name">%1$s</xliff:g> and <xliff:g id="retweet_count">%2$d</xliff:g> others retweeted</string>
<string name="N_retweeted_quantity_one"><xliff:g id="retweet_count">%d</xliff:g> retweet</string>
<string name="N_retweeted_quantity_other"><xliff:g id="retweet_count">%d</xliff:g> retweets</string>
<string name="N_retweeted_quantity_one" tools:ignore="PluralsCandidate"><xliff:g id="retweet_count">%d</xliff:g> retweet</string>
<string name="N_retweeted_quantity_other" tools:ignore="PluralsCandidate"><xliff:g id="retweet_count">%d</xliff:g> retweets</string>
<string name="retweeted_by_name">Retweeted by <xliff:g id="user_name">%s</xliff:g></string>
<string name="retweeted_by_name_with_count">Retweeted by <xliff:g id="user_name">%1$s</xliff:g> and <xliff:g id="retweet_count">%2$d</xliff:g> others</string>
<string name="retweeted_by_count">Retweeted by <xliff:g id="retweet_count">%d</xliff:g> users</string>
@ -255,8 +255,8 @@
<string name="quick_send">Hit \"Enter\" to Send</string>
<string name="quick_send_summary">Send tweet when hit \"Enter\".</string>
<string name="discard">Discard</string>
<string name="Nitems_selected_quantity_one">1 item selected</string>
<string name="Nitems_selected_quantity_other"><xliff:g id="items">%d</xliff:g> items selected</string>
<string name="Nitems_selected_quantity_one" tools:ignore="PluralsCandidate">1 item selected</string>
<string name="Nitems_selected_quantity_other" tools:ignore="PluralsCandidate"><xliff:g id="items">%d</xliff:g> items selected</string>
<string name="custom_host_mapping">Custom host mapping</string>
<string name="custom_host_mapping_summary">Host mapping like /etc/hosts, but does not require any additional permissions.</string>
<string name="host_mapping_host">Host</string>
@ -420,15 +420,15 @@
<string name="updated_list_details">Updated list \"<xliff:g id="list">%s</xliff:g>\"\'s details.</string>
<string name="subscribed_to_list">Subscribed to list \"<xliff:g id="list">%s</xliff:g>\".</string>
<string name="unsubscribed_from_list">Unsubscribed from list \"<xliff:g id="list">%s</xliff:g>\".</string>
<string name="added_N_users_to_list_quantity_one">Added <xliff:g id="items">%1$d</xliff:g> user to list \"<xliff:g id="list">%2$s</xliff:g>\".</string>
<string name="added_N_users_to_list_quantity_other">Added <xliff:g id="items">%1$d</xliff:g> users to list \"<xliff:g id="list">%2$s</xliff:g>\".</string>
<string name="added_N_users_to_list_quantity_one" tools:ignore="PluralsCandidate">Added <xliff:g id="items">%1$d</xliff:g> user to list \"<xliff:g id="list">%2$s</xliff:g>\".</string>
<string name="added_N_users_to_list_quantity_other" tools:ignore="PluralsCandidate">Added <xliff:g id="items">%1$d</xliff:g> users to list \"<xliff:g id="list">%2$s</xliff:g>\".</string>
<string name="added_user_to_list">Added <xliff:g id="user">%1$s</xliff:g> to list \"<xliff:g id="list">%2$s</xliff:g>\".</string>
<string name="deleted_user_from_list">Deleted <xliff:g id="user">%1$s</xliff:g> from list \"<xliff:g id="list">%2$s</xliff:g>\".</string>
<string name="deleted_N_users_from_list_quantity_one">Deleted <xliff:g id="items">%1$d</xliff:g> user from list \"<xliff:g id="list">%2$s</xliff:g>\".</string>
<string name="deleted_N_users_from_list_quantity_other">Deleted <xliff:g id="items">%1$d</xliff:g> users from list \"<xliff:g id="list">%2$s</xliff:g>\".</string>
<string name="deleted_N_users_from_list_quantity_one" tools:ignore="PluralsCandidate">Deleted <xliff:g id="items">%1$d</xliff:g> user from list \"<xliff:g id="list">%2$s</xliff:g>\".</string>
<string name="deleted_N_users_from_list_quantity_other" tools:ignore="PluralsCandidate">Deleted <xliff:g id="items">%1$d</xliff:g> users from list \"<xliff:g id="list">%2$s</xliff:g>\".</string>
<string name="delete_user_from_list_confirm">Delete <xliff:g id="user">%1$s</xliff:g> from list \"<xliff:g id="list">%2$s</xliff:g>\"?</string>
<string name="delete_N_users_from_list_confirm_quantity_one">Delete <xliff:g id="items">%1$d</xliff:g> user from list \"<xliff:g id="list">%2$s</xliff:g>\"?</string>
<string name="delete_N_users_from_list_confirm_quantity_other">Delete <xliff:g id="items">%1$d</xliff:g> users from list \"<xliff:g id="list">%2$s</xliff:g>\"?</string>
<string name="delete_N_users_from_list_confirm_quantity_one" tools:ignore="PluralsCandidate">Delete <xliff:g id="items">%1$d</xliff:g> user from list \"<xliff:g id="list">%2$s</xliff:g>\"?</string>
<string name="delete_N_users_from_list_confirm_quantity_other" tools:ignore="PluralsCandidate">Delete <xliff:g id="items">%1$d</xliff:g> users from list \"<xliff:g id="list">%2$s</xliff:g>\"?</string>
<string name="subscribe">Subscribe</string>
<string name="unsubscribe">Unsubscribe</string>
<string name="background_toast_notification">Background Toast notification</string>
@ -439,8 +439,8 @@
<string name="no_close_after_status_updated_summary">A little gift for chatterbox</string>
<string name="status_saved_to_draft">Tweet saved to draft.</string>
<string name="default_account">Default account</string>
<string name="created_at_with_N_tweets_per_day_quantity_one"><xliff:g id="created_at">%1$s</xliff:g> (<xliff:g id="daily_tweet">%2$d</xliff:g> tweet per day)</string>
<string name="created_at_with_N_tweets_per_day_quantity_other"><xliff:g id="created_at">%1$s</xliff:g> (<xliff:g id="daily_tweet">%2$d</xliff:g> tweets per day)</string>
<string name="created_at_with_N_tweets_per_day_quantity_one" tools:ignore="PluralsCandidate"><xliff:g id="created_at">%1$s</xliff:g> (<xliff:g id="daily_tweet">%2$d</xliff:g> tweet per day)</string>
<string name="created_at_with_N_tweets_per_day_quantity_other" tools:ignore="PluralsCandidate"><xliff:g id="created_at">%1$s</xliff:g> (<xliff:g id="daily_tweet">%2$d</xliff:g> tweets per day)</string>
<string name="empty_content">Empty content</string>
<string name="fast_image_loading">Fast image loading</string>
<string name="fast_image_loading_summary">Enable to make images load faster, disable this if some image can\'t be displayed.</string>
@ -540,12 +540,12 @@
<string name="view_replies">View Replies</string>
<string name="compact_cards">Compact cards</string>
<string name="compact_cards_summary">Display more cards on screen</string>
<string name="N_new_statuses_quantity_one"><xliff:g id="items">%d</xliff:g> new tweet</string>
<string name="N_new_statuses_quantity_other"><xliff:g id="items">%d</xliff:g> new tweets</string>
<string name="N_new_mentions_quantity_one"><xliff:g id="items">%d</xliff:g> new mention</string>
<string name="N_new_mentions_quantity_other"><xliff:g id="items">%d</xliff:g> new mentions</string>
<string name="N_new_messages_quantity_one"><xliff:g id="items">%d</xliff:g> new conversation</string>
<string name="N_new_messages_quantity_other"><xliff:g id="items">%d</xliff:g> new conversations</string>
<string name="N_new_statuses_quantity_one" tools:ignore="PluralsCandidate"><xliff:g id="items">%d</xliff:g> new tweet</string>
<string name="N_new_statuses_quantity_other" tools:ignore="PluralsCandidate"><xliff:g id="items">%d</xliff:g> new tweets</string>
<string name="N_new_mentions_quantity_one" tools:ignore="PluralsCandidate"><xliff:g id="items">%d</xliff:g> new mention</string>
<string name="N_new_mentions_quantity_other" tools:ignore="PluralsCandidate"><xliff:g id="items">%d</xliff:g> new mentions</string>
<string name="N_new_messages_quantity_one" tools:ignore="PluralsCandidate"><xliff:g id="items">%d</xliff:g> new conversation</string>
<string name="N_new_messages_quantity_other" tools:ignore="PluralsCandidate"><xliff:g id="items">%d</xliff:g> new conversations</string>
<string name="status_share_subject_format_with_time">Tweet from <xliff:g id="name">%1$s</xliff:g> (@<xliff:g id="screen_name">%2$s</xliff:g>), at <xliff:g id="time">%3$s</xliff:g></string>
<string name="status_share_text_format_with_link"><xliff:g id="text">%1$s</xliff:g>\n\n<xliff:g id="link">%2$s</xliff:g></string>
<string name="rate_limit">Rate limit</string>
@ -606,8 +606,8 @@
<string name="want_old_icon_back">Want old icon back?</string>
<string name="icon_restored_message">Icon restored!</string>
<string name="add">Add</string>
<string name="N_media_quantity_one"><xliff:g id="items">%d</xliff:g> media</string>
<string name="N_media_quantity_other"><xliff:g id="items">%d</xliff:g> media</string>
<string name="N_media_quantity_one" tools:ignore="PluralsCandidate"><xliff:g id="items">%d</xliff:g> media</string>
<string name="N_media_quantity_other" tools:ignore="PluralsCandidate"><xliff:g id="items">%d</xliff:g> media</string>
<string name="delete_drafts_confirm">Delete selcted drafts?</string>
<string name="extra_configurations">Extra configurations</string>
<string name="click_item_to_config">Click an item to config</string>
@ -662,8 +662,8 @@
<string name="media_preview_style">Media preview style</string>
<string name="draft_saved">Draft saved</string>
<string name="open_twitter_links">Open Twitter links</string>
<string name="N_others_quantity_one">another</string>
<string name="N_others_quantity_other"><xliff:g id="count">%d</xliff:g> others</string>
<string name="N_others_quantity_one" tools:ignore="PluralsCandidate">another</string>
<string name="N_others_quantity_other" tools:ignore="PluralsCandidate"><xliff:g id="count">%d</xliff:g> others</string>
<string name="type_name_to_search">Type name to search</string>
<string name="no_user_found">No user found</string>
<string name="members">Members</string>
@ -718,10 +718,10 @@
<string name="server_address">Server address</string>
<string name="security_key">Security key</string>
<string name="hide_card_actions">Hide card actions</string>
<string name="N_statuses_quantity_one"><xliff:g id="count">%d</xliff:g> tweet</string>
<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="N_statuses_quantity_one" tools:ignore="PluralsCandidate"><xliff:g id="count">%d</xliff:g> tweet</string>
<string name="N_statuses_quantity_other" tools:ignore="PluralsCandidate"><xliff:g id="count">%d</xliff:g> tweets</string>
<string name="N_favorites_quantity_one" tools:ignore="PluralsCandidate"><xliff:g id="count">%d</xliff:g> favorites</string>
<string name="N_favorites_quantity_other" tools:ignore="PluralsCandidate"><xliff:g id="count">%d</xliff:g> favorites</string>
<string name="drafts_hint_messages">Your unsent tweets will save here</string>
<string name="keyboard_shortcuts">Keyboard shortcuts</string>
<string name="keyboard_shortcut_hint">Press keys</string>