From 39afb636c916901a9e165d424f05ac0de9eace6b Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Fri, 18 Mar 2016 10:45:43 +0800 Subject: [PATCH] dm crash fixes --- .../twidere/app/TwidereApplication.java | 32 +++++++++++++++---- .../support/MessagesConversationFragment.java | 15 ++++++--- .../fragment/support/StatusFragment.java | 18 ++++++----- .../layout_actionbar_message_user_picker.xml | 13 +++++--- 4 files changed, 55 insertions(+), 23 deletions(-) diff --git a/twidere/src/main/java/org/mariotaku/twidere/app/TwidereApplication.java b/twidere/src/main/java/org/mariotaku/twidere/app/TwidereApplication.java index fa741701a..dac5c6c0d 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/app/TwidereApplication.java +++ b/twidere/src/main/java/org/mariotaku/twidere/app/TwidereApplication.java @@ -42,6 +42,7 @@ import android.support.v7.app.AppCompatDelegate; import android.support.v7.widget.ActionBarContextView; import com.afollestad.appthemeengine.ATE; +import com.afollestad.appthemeengine.Config; import org.apache.commons.lang3.ArrayUtils; import org.mariotaku.twidere.BuildConfig; @@ -134,9 +135,15 @@ public class TwidereApplication extends Application implements Constants, if (!ATE.config(this, null).isConfigured()) { final int themeColor = preferences.getInt(KEY_THEME_COLOR, ContextCompat.getColor(this, R.color.branding_color)); - ATE.config(this, "light").primaryColor(themeColor).accentColor(themeColor).coloredActionBar(true).commit(); - ATE.config(this, "dark").accentColor(themeColor).coloredActionBar(false).commit(); - ATE.config(this, null).primaryColor(themeColor).accentColor(themeColor).commit(); + ATE.config(this, VALUE_THEME_NAME_LIGHT) + .primaryColor(themeColor) + .accentColor(themeColor) + .coloredActionBar(true) + .commit(); + ATE.config(this, VALUE_THEME_NAME_DARK) + .accentColor(themeColor) + .coloredActionBar(false) + .commit(); } resetTheme(preferences); super.onCreate(); @@ -277,12 +284,25 @@ public class TwidereApplication extends Application implements Constants, } case KEY_THEME: { resetTheme(preferences); + Config.markChanged(this, VALUE_THEME_NAME_LIGHT, VALUE_THEME_NAME_DARK); + break; + } + case KEY_THEME_BACKGROUND: { + Config.markChanged(this, VALUE_THEME_NAME_LIGHT, VALUE_THEME_NAME_DARK); break; } case KEY_THEME_COLOR: { - final int themeColor = preferences.getInt(key, ContextCompat.getColor(this, R.color.branding_color)); - ATE.config(this, "light").primaryColor(themeColor).accentColor(themeColor).coloredActionBar(true).commit(); - ATE.config(this, "dark").accentColor(themeColor).coloredActionBar(false).commit(); + final int themeColor = preferences.getInt(key, ContextCompat.getColor(this, + R.color.branding_color)); + ATE.config(this, VALUE_THEME_NAME_LIGHT) + .primaryColor(themeColor) + .accentColor(themeColor) + .coloredActionBar(true) + .commit(); + ATE.config(this, VALUE_THEME_NAME_DARK) + .accentColor(themeColor) + .coloredActionBar(false) + .commit(); break; } } diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/MessagesConversationFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/MessagesConversationFragment.java index 578269d36..428107f81 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/MessagesConversationFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/MessagesConversationFragment.java @@ -303,7 +303,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements if (args.containsKey(EXTRA_ACCOUNT)) { account = args.getParcelable(EXTRA_ACCOUNT); recipient = args.getParcelable(EXTRA_USER); - } else if (args.containsKey(EXTRA_ACCOUNT_KEY)) { + } else if (args.containsKey(EXTRA_ACCOUNT_KEY) && args.containsKey(EXTRA_RECIPIENT_ID)) { final UserKey accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY); if (accountKey == null) { getActivity().finish(); @@ -314,9 +314,16 @@ public class MessagesConversationFragment extends BaseSupportFragment implements mAccountSpinner.setSelection(accountPos); } final String userId = args.getString(EXTRA_RECIPIENT_ID); - account = accountPos >= 0 ? accountsSpinnerAdapter.getItem(accountPos) : - ParcelableCredentialsUtils.getCredentials(activity, accountKey); - recipient = Utils.getUserForConversation(activity, accountKey, userId); + if (accountPos >= 0) { + account = accountsSpinnerAdapter.getItem(accountPos); + } else { + account = ParcelableCredentialsUtils.getCredentials(activity, accountKey); + } + if (userId != null) { + recipient = Utils.getUserForConversation(activity, accountKey, userId); + } else { + recipient = null; + } } else { account = null; recipient = null; diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusFragment.java index 6722ee845..8c3a8279b 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusFragment.java @@ -2485,18 +2485,20 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac countValues.put(Statuses.RETWEET_COUNT, activitySummary.retweetCount); final ContentResolver cr = context.getContentResolver(); - final Expression statusWhere = Expression.or( + final Expression statusWhere = Expression.and( Expression.equalsArgs(Statuses.ACCOUNT_KEY), - Expression.equalsArgs(Statuses.STATUS_ID), - Expression.equalsArgs(Statuses.RETWEET_ID) - ); + Expression.or( + Expression.equalsArgs(Statuses.STATUS_ID), + Expression.equalsArgs(Statuses.RETWEET_ID) + )); final String[] statusWhereArgs = {mAccountKey.toString(), mStatusId, mStatusId}; cr.update(Statuses.CONTENT_URI, countValues, statusWhere.getSQL(), statusWhereArgs); - final Expression activityWhere = Expression.or( + final Expression activityWhere = Expression.and( Expression.equalsArgs(Activities.ACCOUNT_KEY), - Expression.equalsArgs(Activities.STATUS_ID), - Expression.equalsArgs(Activities.STATUS_RETWEET_ID) - ); + Expression.or( + Expression.equalsArgs(Activities.STATUS_ID), + Expression.equalsArgs(Activities.STATUS_RETWEET_ID) + )); final ParcelableStatus pStatus = ParcelableStatusUtils.fromStatus(status, mAccountKey, false); diff --git a/twidere/src/main/res/layout/layout_actionbar_message_user_picker.xml b/twidere/src/main/res/layout/layout_actionbar_message_user_picker.xml index 4fc1d3afe..b57318fb0 100644 --- a/twidere/src/main/res/layout/layout_actionbar_message_user_picker.xml +++ b/twidere/src/main/res/layout/layout_actionbar_message_user_picker.xml @@ -17,7 +17,8 @@ ~ along with this program. If not, see . --> - + android:tag="tint|primary_color_dependent" + tools:listitem="@layout/spinner_item_account_icon"/> + android:inputType="textPersonName|textMultiLine" + android:tag="background|primary_color_dependent"> - + + android:src="@drawable/ic_action_search"/> \ No newline at end of file