diff --git a/.gitmodules b/.gitmodules
index ffb05f1f8..5f06f37d6 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -4,12 +4,6 @@
[submodule "libraries/DragSortListView"]
path = libraries/DragSortListView
url = https://github.com/mariotaku/DragSortListView-Gradle
-[submodule "libraries/RefreshNow"]
- path = libraries/RefreshNow
- url = https://github.com/mariotaku/RefreshNow-Android
-[submodule "libraries/PullToRefresh"]
- path = libraries/PullToRefresh
- url = https://github.com/mariotaku/Android-PullToRefresh-Gradle.git
[submodule "libraries/MessageBubbleView"]
path = libraries/MessageBubbleView
url = https://github.com/mariotaku/MessageBubbleView.git
diff --git a/gradle.properties b/gradle.properties
index 5d08ba75b..c9604fccb 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -10,9 +10,9 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
-# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
+org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
\ No newline at end of file
+org.gradle.parallel=true
\ No newline at end of file
diff --git a/libraries/PullToRefresh b/libraries/PullToRefresh
deleted file mode 160000
index 38b56f5c8..000000000
--- a/libraries/PullToRefresh
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 38b56f5c8f692967428af3454ab17e055ea03727
diff --git a/libraries/RefreshNow b/libraries/RefreshNow
deleted file mode 160000
index f4e2d5afb..000000000
--- a/libraries/RefreshNow
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit f4e2d5afba10ae45528d43dce3629a5db7f2738e
diff --git a/settings.gradle b/settings.gradle
index cf0e6c347..057603cf4 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -12,11 +12,9 @@ include ':twidere.component.nyan'
include ':twidere.extension.streaming'
include ':twidere.extension.twitlonger'
include ':twidere.extension.push.xiaomi'
-include ':SlidingMenu', ':DragSortListView', ':RefreshNow', ':PullToRefresh', ':MessageBubbleView', ':ColorPicker'
+include ':SlidingMenu', ':DragSortListView', ':MessageBubbleView', ':ColorPicker'
project(':SlidingMenu').projectDir = file('libraries/SlidingMenu/library')
project(':DragSortListView').projectDir = file('libraries/DragSortListView/library')
-project(':RefreshNow').projectDir = file('libraries/RefreshNow/library')
-project(':PullToRefresh').projectDir = file('libraries/PullToRefresh/library')
project(':MessageBubbleView').projectDir = file('libraries/MessageBubbleView/library')
project(':ColorPicker').projectDir = file('libraries/ColorPicker/library')
\ No newline at end of file
diff --git a/twidere/src/main/AndroidManifest.xml b/twidere/src/main/AndroidManifest.xml
index 01a36fb5b..4e982e934 100644
--- a/twidere/src/main/AndroidManifest.xml
+++ b/twidere/src/main/AndroidManifest.xml
@@ -45,12 +45,15 @@
android:label="@string/app_name"/>
diff --git a/twidere/src/main/java/edu/ucdavis/earlybird/UploadTask.java b/twidere/src/main/java/edu/ucdavis/earlybird/UploadTask.java
index c8705f8ea..b8ce3f4e7 100644
--- a/twidere/src/main/java/edu/ucdavis/earlybird/UploadTask.java
+++ b/twidere/src/main/java/edu/ucdavis/earlybird/UploadTask.java
@@ -5,6 +5,8 @@ import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.provider.Settings.Secure;
+import org.mariotaku.twidere.util.Utils;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -25,7 +27,7 @@ public class UploadTask extends AsyncTask {
private final String device_id;
private final Context context;
- private final HttpClientWrapper client = new HttpClientWrapper();
+ private final HttpClientWrapper client;
private static final String PROFILE_SERVER_URL = "http://weik.metaisle.com/profiles";
@@ -34,6 +36,7 @@ public class UploadTask extends AsyncTask {
public UploadTask(final Context context) {
this.context = context;
+ this.client = Utils.getDefaultHttpClient(context);
device_id = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
}
diff --git a/twidere/src/main/java/org/mariotaku/twidere/adapter/AccountsAdapter.java b/twidere/src/main/java/org/mariotaku/twidere/adapter/AccountsAdapter.java
index 29fab43e3..58d52f3b4 100644
--- a/twidere/src/main/java/org/mariotaku/twidere/adapter/AccountsAdapter.java
+++ b/twidere/src/main/java/org/mariotaku/twidere/adapter/AccountsAdapter.java
@@ -43,8 +43,6 @@ public class AccountsAdapter extends SimpleDragSortCursorAdapter implements Cons
private final ImageLoaderWrapper mImageLoader;
private final SharedPreferences mPreferences;
- private long mDefaultAccountId;
-
private boolean mDisplayProfileImage;
private int mChoiceMode;
private boolean mSortEnabled;
@@ -70,7 +68,6 @@ public class AccountsAdapter extends SimpleDragSortCursorAdapter implements Cons
final AccountViewHolder holder = (AccountViewHolder) view.getTag();
holder.screen_name.setText("@" + cursor.getString(mIndices.screen_name));
holder.setAccountColor(color);
- holder.setIsDefault(mDefaultAccountId != -1 && mDefaultAccountId == cursor.getLong(mIndices.account_id));
if (mDisplayProfileImage) {
mImageLoader.displayProfileImage(holder.profile_image, cursor.getString(mIndices.profile_image_url));
} else {
@@ -127,12 +124,6 @@ public class AccountsAdapter extends SimpleDragSortCursorAdapter implements Cons
return false;
}
- @Override
- public void notifyDataSetChanged() {
- mDefaultAccountId = mPreferences.getLong(KEY_DEFAULT_ACCOUNT_ID, -1);
- super.notifyDataSetChanged();
- }
-
@Override
public void setDisplayNameFirst(boolean nameFirst) {
diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AccountsDashboardFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AccountsDashboardFragment.java
index ce6e3875a..987c4181a 100644
--- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AccountsDashboardFragment.java
+++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AccountsDashboardFragment.java
@@ -29,6 +29,7 @@ import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.content.SharedPreferences.Editor;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.res.Resources;
import android.database.Cursor;
@@ -490,6 +491,9 @@ public class AccountsDashboardFragment extends BaseSupportListFragment implement
}
private void finishAnimation() {
+ final Editor editor = mPreferences.edit();
+ editor.putLong(KEY_DEFAULT_ACCOUNT_ID, account.account_id);
+ editor.apply();
mAccountsAdapter.setSelectedAccountId(account.account_id);
updateAccountOptionsSeparatorLabel(clickedDrawable);
snapshotView.setVisibility(View.INVISIBLE);
diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AccountsManagerFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AccountsManagerFragment.java
index 1b5ff3307..c74d107bf 100644
--- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AccountsManagerFragment.java
+++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AccountsManagerFragment.java
@@ -9,7 +9,6 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
-import android.content.SharedPreferences.Editor;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.database.Cursor;
import android.graphics.Color;
@@ -98,9 +97,9 @@ public class AccountsManagerFragment extends BaseSupportFragment implements Load
return;
final ContentValues values = new ContentValues();
values.put(Accounts.COLOR, data.getIntExtra(EXTRA_COLOR, Color.WHITE));
- final String where = Accounts.ACCOUNT_ID + " = " + mSelectedAccount.account_id;
+ final Expression where = Expression.equals(Accounts.ACCOUNT_ID, mSelectedAccount.account_id);
final ContentResolver cr = getContentResolver();
- cr.update(Accounts.CONTENT_URI, values, where, null);
+ cr.update(Accounts.CONTENT_URI, values, where.getSQL(), null);
return;
}
}
@@ -120,12 +119,6 @@ public class AccountsManagerFragment extends BaseSupportFragment implements Load
mSelectedAccount = mAdapter.getAccount(info.position);
if (mSelectedAccount == null) return false;
switch (item.getItemId()) {
- case MENU_SET_AS_DEFAULT: {
- final Editor editor = mPreferences.edit();
- editor.putLong(KEY_DEFAULT_ACCOUNT_ID, mSelectedAccount.account_id);
- editor.apply();
- return true;
- }
case MENU_SET_COLOR: {
final Intent intent = new Intent(getActivity(), ColorPickerDialogActivity.class);
intent.putExtra(EXTRA_COLOR, mSelectedAccount.color);
@@ -203,8 +196,6 @@ public class AccountsManagerFragment extends BaseSupportFragment implements Load
menu.setHeaderTitle(account.name);
final MenuInflater inflater = new MenuInflater(v.getContext());
inflater.inflate(R.menu.action_manager_account, menu);
- final boolean isDefault = Utils.getDefaultAccountId(getActivity()) == account.account_id;
- Utils.setMenuItemAvailability(menu, MENU_SET_AS_DEFAULT, !isDefault);
}
@Override
diff --git a/twidere/src/main/java/org/mariotaku/twidere/preference/TrendsLocationPreference.java b/twidere/src/main/java/org/mariotaku/twidere/preference/TrendsLocationPreference.java
index 0add6d1ff..af5256231 100644
--- a/twidere/src/main/java/org/mariotaku/twidere/preference/TrendsLocationPreference.java
+++ b/twidere/src/main/java/org/mariotaku/twidere/preference/TrendsLocationPreference.java
@@ -81,7 +81,7 @@ public class TrendsLocationPreference extends Preference implements Constants, O
final Location item = mAdapter.getItem(which);
if (item != null) {
editor.putInt(KEY_LOCAL_TRENDS_WOEID, item.getWoeid());
- editor.commit();
+ editor.apply();
}
if (mDialog != null && mDialog.isShowing()) {
mDialog.dismiss();
diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/PositionManager.java b/twidere/src/main/java/org/mariotaku/twidere/util/PositionManager.java
index 2c84ffb28..e8feeb4f8 100644
--- a/twidere/src/main/java/org/mariotaku/twidere/util/PositionManager.java
+++ b/twidere/src/main/java/org/mariotaku/twidere/util/PositionManager.java
@@ -27,10 +27,11 @@ import org.mariotaku.twidere.Constants;
public class PositionManager implements Constants {
- private final SharedPreferences mPreferences;
+ private final SharedPreferencesWrapper mPreferences;
public PositionManager(final Context context) {
- mPreferences = context.getSharedPreferences(TIMELINE_POSITIONS_PREFERENCES_NAME, Context.MODE_PRIVATE);
+ mPreferences = SharedPreferencesWrapper.getInstance(context,
+ TIMELINE_POSITIONS_PREFERENCES_NAME, Context.MODE_PRIVATE);
}
public long getPosition(final String key) {
diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/Utils.java b/twidere/src/main/java/org/mariotaku/twidere/util/Utils.java
index 82c312861..df764e7a4 100644
--- a/twidere/src/main/java/org/mariotaku/twidere/util/Utils.java
+++ b/twidere/src/main/java/org/mariotaku/twidere/util/Utils.java
@@ -1795,8 +1795,10 @@ public final class Utils implements Constants, TwitterConstants {
return child.getTop();
}
+
public static HttpClientWrapper getHttpClient(final Context context, final int timeoutMillis,
- final boolean ignoreSslError, final Proxy proxy, final HostAddressResolverFactory resolverFactory,
+ final boolean ignoreSslError, final Proxy proxy,
+ final HostAddressResolverFactory resolverFactory,
final String userAgent, final boolean twitterClientHeader) {
final ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setHttpConnectionTimeout(timeoutMillis);
@@ -1817,6 +1819,17 @@ public final class Utils implements Constants, TwitterConstants {
return new HttpClientWrapper(cb.build());
}
+ public static HttpClientWrapper getDefaultHttpClient(final Context context) {
+ if (context == null) return null;
+ final SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
+ final int timeoutMillis = prefs.getInt(KEY_CONNECTION_TIMEOUT, 10000) * 1000;
+ final Proxy proxy = getProxy(context);
+ final String userAgent = generateBrowserUserAgent();
+ final HostAddressResolverFactory resolverFactory = new TwidereHostResolverFactory(
+ TwidereApplication.getInstance(context));
+ return getHttpClient(context, timeoutMillis, true, proxy, resolverFactory, userAgent, false);
+ }
+
public static HttpClientWrapper getImageLoaderHttpClient(final Context context) {
if (context == null) return null;
final SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
diff --git a/twidere/src/main/java/org/mariotaku/twidere/view/HomeActionButton.java b/twidere/src/main/java/org/mariotaku/twidere/view/HomeActionButton.java
index 710ddab9e..8f62af3c1 100644
--- a/twidere/src/main/java/org/mariotaku/twidere/view/HomeActionButton.java
+++ b/twidere/src/main/java/org/mariotaku/twidere/view/HomeActionButton.java
@@ -22,13 +22,16 @@ package org.mariotaku.twidere.view;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.ColorStateList;
+import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
+import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
+import android.util.Property;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
@@ -39,13 +42,33 @@ import org.mariotaku.twidere.util.ThemeUtils;
import org.mariotaku.twidere.util.accessor.ViewAccessor;
import org.mariotaku.twidere.util.accessor.ViewAccessor.OutlineCompat;
import org.mariotaku.twidere.util.accessor.ViewAccessor.ViewOutlineProviderCompat;
-import org.mariotaku.twidere.view.helper.PressElevateViewHelper;
import org.mariotaku.twidere.view.iface.IHomeActionButton;
+import me.uucky.colorpicker.internal.EffectViewHelper;
+
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public class HomeActionButton extends FrameLayout implements IHomeActionButton {
- private final PressElevateViewHelper mHelper;
+ private static class PressElevationProperty extends Property {
+ private final float mElevation;
+
+ public PressElevationProperty(float elevation) {
+ super(Float.TYPE, null);
+ mElevation = elevation;
+ }
+
+ @Override
+ public void set(View object, Float value) {
+ ViewCompat.setTranslationZ(object, mElevation * value);
+ }
+
+ @Override
+ public Float get(View object) {
+ return ViewCompat.getTranslationZ(object) / mElevation;
+ }
+ }
+
+ private final EffectViewHelper mHelper;
private final ImageView mIconView;
private final ProgressBar mProgressBar;
@@ -59,7 +82,9 @@ public class HomeActionButton extends FrameLayout implements IHomeActionButton {
public HomeActionButton(final Context context, final AttributeSet attrs, final int defStyle) {
super(context, attrs, defStyle);
- mHelper = new PressElevateViewHelper(this);
+ final Resources resources = context.getResources();
+ final float elevation = resources.getDisplayMetrics().density * 4;
+ mHelper = new EffectViewHelper(this, new PressElevationProperty(elevation), 200);
inflate(ThemeUtils.getActionBarContext(context), R.layout.action_item_home_actions, this);
mIconView = (ImageView) findViewById(android.R.id.icon);
mProgressBar = (ProgressBar) findViewById(android.R.id.progress);
@@ -112,11 +137,8 @@ public class HomeActionButton extends FrameLayout implements IHomeActionButton {
@Override
public void setPressed(boolean pressed) {
- final boolean oldState = mHelper.getState();
super.setPressed(pressed);
- final boolean state = mHelper.getState();
- if (oldState == state) return;
- mHelper.updateButtonState();
+ mHelper.setState(pressed);
}
private static class HomeActionButtonOutlineProvider extends ViewOutlineProviderCompat {
diff --git a/twidere/src/main/java/org/mariotaku/twidere/view/holder/AccountViewHolder.java b/twidere/src/main/java/org/mariotaku/twidere/view/holder/AccountViewHolder.java
index 09bbd284b..764c647ad 100644
--- a/twidere/src/main/java/org/mariotaku/twidere/view/holder/AccountViewHolder.java
+++ b/twidere/src/main/java/org/mariotaku/twidere/view/holder/AccountViewHolder.java
@@ -33,7 +33,6 @@ public class AccountViewHolder {
public final TextView name, screen_name;
public final CheckBox checkbox;
private final ColorLabelRelativeLayout content;
- private final View default_indicator;
private final View drag_handle;
public AccountViewHolder(final View view) {
@@ -41,7 +40,6 @@ public class AccountViewHolder {
name = (TextView) view.findViewById(android.R.id.text1);
screen_name = (TextView) view.findViewById(android.R.id.text2);
profile_image = (ImageView) view.findViewById(android.R.id.icon);
- default_indicator = view.findViewById(R.id.default_indicator);
checkbox = (CheckBox) view.findViewById(android.R.id.checkbox);
drag_handle = view.findViewById(R.id.drag_handle);
}
@@ -50,10 +48,6 @@ public class AccountViewHolder {
content.drawEnd(color);
}
- public void setIsDefault(final boolean is_default) {
- default_indicator.setVisibility(is_default ? View.VISIBLE : View.GONE);
- }
-
public void setSortEnabled(boolean enabled) {
drag_handle.setVisibility(enabled ? View.VISIBLE : View.GONE);
}
diff --git a/twidere/src/main/res/layout/list_item_account.xml b/twidere/src/main/res/layout/list_item_account.xml
index 6811bb254..3c9b45003 100644
--- a/twidere/src/main/res/layout/list_item_account.xml
+++ b/twidere/src/main/res/layout/list_item_account.xml
@@ -56,33 +56,21 @@
android:orientation="vertical"
android:padding="@dimen/element_spacing_normal">
-
-
-
-
-
-
+ android:singleLine="true"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="?android:textColorPrimary"/>
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textColor="?android:textColorSecondary"/>