1
0
mirror of https://github.com/TwidereProject/Twidere-Android synced 2025-02-13 10:10:47 +01:00

improved theme settings

moved some unused settings
bug fixes
This commit is contained in:
Mariotaku Lee 2015-06-16 12:09:48 +08:00
parent a65de0cdbc
commit 9d6a0e4558
10 changed files with 85 additions and 21 deletions

View File

@ -34,6 +34,7 @@ import org.mariotaku.twidere.api.twitter.model.IDs;
import org.mariotaku.twidere.api.twitter.model.PageableResponseList; import org.mariotaku.twidere.api.twitter.model.PageableResponseList;
import org.mariotaku.twidere.api.twitter.model.Paging; import org.mariotaku.twidere.api.twitter.model.Paging;
import org.mariotaku.twidere.api.twitter.model.ProfileUpdate; import org.mariotaku.twidere.api.twitter.model.ProfileUpdate;
import org.mariotaku.twidere.api.twitter.model.ResponseCode;
import org.mariotaku.twidere.api.twitter.model.ResponseList; import org.mariotaku.twidere.api.twitter.model.ResponseList;
import org.mariotaku.twidere.api.twitter.model.SettingsUpdate; import org.mariotaku.twidere.api.twitter.model.SettingsUpdate;
import org.mariotaku.twidere.api.twitter.model.User; import org.mariotaku.twidere.api.twitter.model.User;
@ -103,7 +104,7 @@ public interface UsersResources {
@POST("/account/remove_profile_banner.json") @POST("/account/remove_profile_banner.json")
@Body(BodyType.FORM) @Body(BodyType.FORM)
void removeProfileBannerImage() throws TwitterException; ResponseCode removeProfileBannerImage() throws TwitterException;
@GET("/users/search.json") @GET("/users/search.json")
ResponseList<User> searchUsers(@Query("q") String query, @Query Paging paging) throws TwitterException; ResponseList<User> searchUsers(@Query("q") String query, @Query Paging paging) throws TwitterException;
@ -132,14 +133,14 @@ public interface UsersResources {
@POST("/account/update_profile_banner.json") @POST("/account/update_profile_banner.json")
@Body(BodyType.MULTIPART) @Body(BodyType.MULTIPART)
void updateProfileBannerImage(@Part("image") FileTypedData data, @Part("width") int width, ResponseCode updateProfileBannerImage(@Part("image") FileTypedData data, @Part("width") int width,
@Part("height") int height, @Part("offset_left") int offsetLeft, @Part("height") int height, @Part("offset_left") int offsetLeft,
@Part("offset_top") int offsetTop) @Part("offset_top") int offsetTop)
throws TwitterException; throws TwitterException;
@POST("/account/update_profile_banner.json") @POST("/account/update_profile_banner.json")
@Body(BodyType.MULTIPART) @Body(BodyType.MULTIPART)
void updateProfileBannerImage(@Part("image") FileTypedData data) throws TwitterException; ResponseCode updateProfileBannerImage(@Part("image") FileTypedData data) throws TwitterException;
@POST("/account/update_profile_image.json") @POST("/account/update_profile_image.json")
@Body(BodyType.MULTIPART) @Body(BodyType.MULTIPART)

View File

@ -0,0 +1,43 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.restfu.http.RestHttpResponse;
/**
* Created by mariotaku on 15/6/15.
*/
public class ResponseCode {
private final int responseCode;
public ResponseCode(RestHttpResponse response) {
responseCode = response.getStatus();
}
public int getResponseCode() {
return responseCode;
}
public boolean isSuccessful() {
return responseCode >= 200 && responseCode < 300;
}
}

View File

@ -48,6 +48,7 @@ import org.mariotaku.twidere.api.twitter.model.PageableResponseList;
import org.mariotaku.twidere.api.twitter.model.Place; import org.mariotaku.twidere.api.twitter.model.Place;
import org.mariotaku.twidere.api.twitter.model.QueryResult; import org.mariotaku.twidere.api.twitter.model.QueryResult;
import org.mariotaku.twidere.api.twitter.model.Relationship; import org.mariotaku.twidere.api.twitter.model.Relationship;
import org.mariotaku.twidere.api.twitter.model.ResponseCode;
import org.mariotaku.twidere.api.twitter.model.ResponseList; import org.mariotaku.twidere.api.twitter.model.ResponseList;
import org.mariotaku.twidere.api.twitter.model.SavedSearch; import org.mariotaku.twidere.api.twitter.model.SavedSearch;
import org.mariotaku.twidere.api.twitter.model.Status; import org.mariotaku.twidere.api.twitter.model.Status;
@ -194,6 +195,8 @@ public class TwitterConverter implements Converter {
} catch (ParseException e) { } catch (ParseException e) {
throw new IOException(e); throw new IOException(e);
} }
} else if (ResponseCode.class.isAssignableFrom(cls)) {
return new ResponseCode(response);
} }
final Object object = parseOrThrow(response, stream, cls); final Object object = parseOrThrow(response, stream, cls);
checkResponse(cls, object, response); checkResponse(cls, object, response);
@ -226,7 +229,11 @@ public class TwitterConverter implements Converter {
private static <T> T parseOrThrow(RestHttpResponse resp, InputStream stream, Class<T> cls) throws IOException, TwitterException { private static <T> T parseOrThrow(RestHttpResponse resp, InputStream stream, Class<T> cls) throws IOException, TwitterException {
try { try {
return LoganSquare.parse(stream, cls); final T parse = LoganSquare.parse(stream, cls);
if (TwitterException.class.isAssignableFrom(cls) && parse == null) {
throw new TwitterException();
}
return parse;
} catch (JsonParseException e) { } catch (JsonParseException e) {
throw new TwitterException("Malformed JSON Data", resp); throw new TwitterException("Malformed JSON Data", resp);
} }

View File

@ -210,6 +210,7 @@ public interface IntentConstants {
String EXTRA_MY_FOLLOWING_ONLY = "my_following_only"; String EXTRA_MY_FOLLOWING_ONLY = "my_following_only";
String EXTRA_CHANGED = "changed"; String EXTRA_CHANGED = "changed";
String EXTRA_NOTIFY_CHANGE = "notify_change"; String EXTRA_NOTIFY_CHANGE = "notify_change";
String EXTRA_RESTART_ACTIVITY = "restart_activity";
String EXTRA_FROM_USER = "from_user"; String EXTRA_FROM_USER = "from_user";
String EXTRA_SHOW_MEDIA_PREVIEW = "show_media_preview"; String EXTRA_SHOW_MEDIA_PREVIEW = "show_media_preview";
String EXTRA_SHOW_EXTRA_TYPE = "show_extra_type"; String EXTRA_SHOW_EXTRA_TYPE = "show_extra_type";

View File

@ -19,6 +19,7 @@
package org.mariotaku.twidere.fragment; package org.mariotaku.twidere.fragment;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@ -95,8 +96,14 @@ public class SettingsDetailsFragment extends BasePreferenceFragment implements S
final Preference preference = findPreference(key); final Preference preference = findPreference(key);
if (preference == null) return; if (preference == null) return;
final Bundle extras = preference.getExtras(); final Bundle extras = preference.getExtras();
if (extras != null && extras.containsKey(EXTRA_NOTIFY_CHANGE)) { if (extras != null) {
SettingsActivity.setShouldNotifyChange(getActivity()); final Activity activity = getActivity();
if (extras.containsKey(EXTRA_NOTIFY_CHANGE)) {
SettingsActivity.setShouldNotifyChange(activity);
}
if (extras.containsKey(EXTRA_RESTART_ACTIVITY)) {
Utils.restartActivity(activity);
}
} }
} }
} }

View File

@ -567,7 +567,7 @@ public class BackgroundOperationService extends IntentService implements Constan
status.possiblySensitive(statusUpdate.is_possibly_sensitive); status.possiblySensitive(statusUpdate.is_possibly_sensitive);
if (twitter == null) { if (twitter == null) {
results.add(new SingleResponse<ParcelableStatus>(null, new NullPointerException())); results.add(SingleResponse.<ParcelableStatus>getInstance(new NullPointerException()));
continue; continue;
} }
try { try {
@ -588,7 +588,7 @@ public class BackgroundOperationService extends IntentService implements Constan
} }
} }
final ParcelableStatus result = new ParcelableStatus(resultStatus, account.account_id, false); final ParcelableStatus result = new ParcelableStatus(resultStatus, account.account_id, false);
results.add(new SingleResponse<>(result, null)); results.add(SingleResponse.getInstance(result));
} catch (final TwitterException e) { } catch (final TwitterException e) {
final SingleResponse<ParcelableStatus> response = SingleResponse.getInstance(e); final SingleResponse<ParcelableStatus> response = SingleResponse.getInstance(e);
results.add(response); results.add(response);

View File

@ -113,6 +113,7 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
profileImageView.setImageResource(R.mipmap.ic_launcher); profileImageView.setImageResource(R.mipmap.ic_launcher);
nameView.setName(TWIDERE_PREVIEW_NAME); nameView.setName(TWIDERE_PREVIEW_NAME);
nameView.setScreenName("@" + TWIDERE_PREVIEW_SCREEN_NAME); nameView.setScreenName("@" + TWIDERE_PREVIEW_SCREEN_NAME);
nameView.updateText();
if (adapter.getLinkHighlightingStyle() == VALUE_LINK_HIGHLIGHT_OPTION_CODE_NONE) { if (adapter.getLinkHighlightingStyle() == VALUE_LINK_HIGHLIGHT_OPTION_CODE_NONE) {
textView.setText(Html.fromHtml(TWIDERE_PREVIEW_TEXT_HTML)); textView.setText(Html.fromHtml(TWIDERE_PREVIEW_TEXT_HTML));
adapter.getTwidereLinkify().applyAllLinks(textView, -1, -1, false, adapter.getLinkHighlightingStyle()); adapter.getTwidereLinkify().applyAllLinks(textView, -1, -1, false, adapter.getLinkHighlightingStyle());

View File

@ -82,10 +82,6 @@
android:summaryOff="@string/read_from_bottom_summary_off" android:summaryOff="@string/read_from_bottom_summary_off"
android:summaryOn="@string/read_from_bottom_summary_on" android:summaryOn="@string/read_from_bottom_summary_on"
android:title="@string/read_from_bottom"/> android:title="@string/read_from_bottom"/>
<CheckBoxPreference
android:defaultValue="false"
android:key="sort_timeline_by_id"
android:title="@string/sort_timeline_by_id"/>
<org.mariotaku.twidere.preference.TrendsLocationPreference <org.mariotaku.twidere.preference.TrendsLocationPreference
android:key="trends_location" android:key="trends_location"

View File

@ -94,4 +94,8 @@
android:key="leftside_compose_button" android:key="leftside_compose_button"
android:summary="@string/leftside_compose_button_summary" android:summary="@string/leftside_compose_button_summary"
android:title="@string/leftside_compose_button" /> android:title="@string/leftside_compose_button" />
<CheckBoxPreference
android:defaultValue="false"
android:key="sort_timeline_by_id"
android:title="@string/sort_timeline_by_id"/>
</PreferenceScreen> </PreferenceScreen>

View File

@ -4,14 +4,6 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:title="@string/theme"> android:title="@string/theme">
<PreferenceCategory
android:key="cat_theme_preview"
android:order="11"
android:title="@string/preview">
<org.mariotaku.twidere.preference.ThemePreviewPreference
android:key="theme_preview"/>
</PreferenceCategory>
<org.mariotaku.twidere.preference.DarkLightThemeTogglePreference <org.mariotaku.twidere.preference.DarkLightThemeTogglePreference
android:key="theme" android:key="theme"
android:order="21" android:order="21"
@ -19,6 +11,9 @@
<extra <extra
android:name="notify_change" android:name="notify_change"
android:value="true"/> android:value="true"/>
<extra
android:name="restart_activity"
android:value="true"/>
</org.mariotaku.twidere.preference.DarkLightThemeTogglePreference> </org.mariotaku.twidere.preference.DarkLightThemeTogglePreference>
<org.mariotaku.twidere.preference.ThemeBackgroundPreference <org.mariotaku.twidere.preference.ThemeBackgroundPreference
@ -28,6 +23,9 @@
<extra <extra
android:name="notify_change" android:name="notify_change"
android:value="true"/> android:value="true"/>
<extra
android:name="restart_activity"
android:value="true"/>
</org.mariotaku.twidere.preference.ThemeBackgroundPreference> </org.mariotaku.twidere.preference.ThemeBackgroundPreference>
<org.mariotaku.twidere.preference.ColorPickerPreference <org.mariotaku.twidere.preference.ColorPickerPreference
@ -38,6 +36,9 @@
<extra <extra
android:name="notify_change" android:name="notify_change"
android:value="true"/> android:value="true"/>
<extra
android:name="restart_activity"
android:value="true"/>
</org.mariotaku.twidere.preference.ColorPickerPreference> </org.mariotaku.twidere.preference.ColorPickerPreference>
<org.mariotaku.twidere.preference.ThemeFontFamilyPreference <org.mariotaku.twidere.preference.ThemeFontFamilyPreference
@ -45,10 +46,13 @@
android:enabled="@bool/has_font_family" android:enabled="@bool/has_font_family"
android:key="theme_font_family" android:key="theme_font_family"
android:order="24" android:order="24"
android:title="@string/style"> android:title="@string/font_family">
<extra <extra
android:name="notify_change" android:name="notify_change"
android:value="true"/> android:value="true"/>
<extra
android:name="restart_activity"
android:value="true"/>
</org.mariotaku.twidere.preference.ThemeFontFamilyPreference> </org.mariotaku.twidere.preference.ThemeFontFamilyPreference>