dm crash fixes

This commit is contained in:
Mariotaku Lee 2016-03-18 10:45:43 +08:00
parent a5901eaab8
commit 39afb636c9
4 changed files with 55 additions and 23 deletions

View File

@ -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;
}
}

View File

@ -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);
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;

View File

@ -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.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.or(
Expression.equalsArgs(Activities.STATUS_ID),
Expression.equalsArgs(Activities.STATUS_RETWEET_ID)
);
));
final ParcelableStatus pStatus = ParcelableStatusUtils.fromStatus(status,
mAccountKey, false);

View File

@ -17,7 +17,8 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -30,7 +31,8 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="@dimen/element_spacing_small"
tools:listitem="@layout/spinner_item_account_icon" />
android:tag="tint|primary_color_dependent"
tools:listitem="@layout/spinner_item_account_icon"/>
<FrameLayout
android:layout_width="match_parent"
@ -46,9 +48,10 @@
android:layout_marginLeft="@dimen/element_spacing_normal"
android:layout_marginRight="@dimen/element_spacing_normal"
android:gravity="bottom"
android:inputType="textPersonName|textMultiLine">
android:inputType="textPersonName|textMultiLine"
android:tag="background|primary_color_dependent">
<requestFocus />
<requestFocus/>
</EditText>
<org.mariotaku.twidere.view.themed.BackgroundTintImageButton
@ -60,7 +63,7 @@
android:color="?android:textColorPrimary"
android:padding="@dimen/element_spacing_normal"
android:scaleType="centerInside"
android:src="@drawable/ic_action_search" />
android:src="@drawable/ic_action_search"/>
</FrameLayout>
</RelativeLayout>