improved preference category

This commit is contained in:
Mariotaku Lee 2017-02-05 13:03:18 +08:00
parent ca1ccec481
commit 6d13d5dd7f
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
19 changed files with 114 additions and 46 deletions

View File

@ -62,6 +62,7 @@ import android.support.v7.view.menu.MenuBuilder;
import android.text.TextUtils;
import android.text.format.DateFormat;
import android.text.format.DateUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
@ -70,6 +71,7 @@ import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.widget.Toast;
@ -1213,4 +1215,12 @@ public final class Utils implements Constants {
return true;
}
public static boolean isDeviceTablet(@NonNull Context context) {
DisplayMetrics metrics = new DisplayMetrics();
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
wm.getDefaultDisplay().getMetrics(metrics);
final float mw = Math.min(metrics.widthPixels / metrics.density, metrics.heightPixels / metrics.density);
return mw >= 600;
}
}

View File

@ -47,6 +47,7 @@ import org.mariotaku.twidere.constant.KeyboardShortcutConstants.CONTEXT_TAG_NAVI
import org.mariotaku.twidere.fragment.*
import org.mariotaku.twidere.util.KeyboardShortcutsHandler
import org.mariotaku.twidere.util.ThemeUtils
import org.mariotaku.twidere.util.Utils
import java.util.*
class SettingsActivity : BaseActivity(), OnItemClickListener, OnPreferenceStartFragmentCallback {
@ -185,6 +186,10 @@ class SettingsActivity : BaseActivity(), OnItemClickListener, OnPreferenceStartF
R.xml.preferences_theme)
entriesAdapter.addPreference("cards", R.drawable.ic_action_card, getString(R.string.cards),
R.xml.preferences_cards)
if (Utils.isDeviceTablet(this)) {
entriesAdapter.addPreference("tablet_mode", R.drawable.ic_action_tablet, getString(R.string.preference_title_tablet_mode),
R.xml.preferences_tablet_mode)
}
entriesAdapter.addHeader(getString(R.string.function))
entriesAdapter.addPreference("tabs", R.drawable.ic_action_tab, getString(R.string.tabs),

View File

@ -30,7 +30,6 @@ import org.mariotaku.microblog.library.twitter.model.Paging
import org.mariotaku.microblog.library.twitter.model.SearchQuery
import org.mariotaku.microblog.library.twitter.model.Status
import org.mariotaku.twidere.annotation.AccountType
import org.mariotaku.twidere.extension.model.isOfficial
import org.mariotaku.twidere.model.AccountDetails
import org.mariotaku.twidere.model.ParcelableStatus
import org.mariotaku.twidere.model.util.ParcelableStatusUtils
@ -63,7 +62,7 @@ class ConversationLoader(
canLoadAllReplies = false
when (details.type) {
AccountType.TWITTER -> {
val isOfficial = details.isOfficial(context)
val isOfficial = false
canLoadAllReplies = isOfficial
if (isOfficial) {
return microBlog.showConversation(status.id, paging)

View File

@ -0,0 +1,22 @@
package org.mariotaku.twidere.preference
import android.content.Context
import android.support.v7.preference.PreferenceCategory
import android.support.v7.preference.PreferenceViewHolder
import android.util.AttributeSet
import android.widget.TextView
import org.mariotaku.chameleon.Chameleon
import org.mariotaku.chameleon.ChameleonUtils
/**
* Created by mariotaku on 2017/2/5.
*/
class TintedPreferenceCategory(context: Context, attrs: AttributeSet? = null) : PreferenceCategory(context, attrs) {
override fun onBindViewHolder(holder: PreferenceViewHolder) {
super.onBindViewHolder(holder)
val theme = Chameleon.getOverrideTheme(context, ChameleonUtils.getActivity(context))
val textView = holder.findViewById(android.R.id.title) as? TextView
textView?.setTextColor(theme.colorAccent)
}
}

View File

@ -879,7 +879,11 @@
<string name="preference_title_filter_subscriptions">Filter subscriptions</string>
<string name="preference_title_light_font">Light font</string>
<string name="preference_title_media_preload_non_metered_network">Preload on free network</string>
<string name="preference_title_multi_column_tabs">Multi column tabs</string>
<string name="preference_title_portrait">Portrait</string>
<string name="preference_title_landscape">Landscape</string>
<string name="preference_title_storage">Storage</string>
<string name="preference_title_tablet_mode">Tablet mode</string>
<string name="preference_title_translate">Translate</string>
<string name="preload_wifi_only">Preload using Wi-Fi only</string>

View File

@ -4,7 +4,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/title_about">
<PreferenceCategory
<org.mariotaku.twidere.preference.TintedPreferenceCategory
android:key="cat_about"
android:title="@string/title_about">
<org.mariotaku.twidere.preference.AppVersionPreference/>
@ -23,8 +23,8 @@
android:action="android.intent.action.VIEW"
android:data="twidere://user?user_key=57610574@twitter.com&amp;account_host=twitter.com&amp;finish_only=true"/>
</Preference>
</PreferenceCategory>
<PreferenceCategory
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
<org.mariotaku.twidere.preference.TintedPreferenceCategory
android:key="cat_translate"
android:title="@string/preference_title_translate">
<Preference android:title="@string/preference_title_translate">
@ -39,8 +39,8 @@
android:action="android.intent.action.VIEW"
android:data="twidere://user_list_members?list_id=99024901&amp;user_key=583328497@twitter.com&amp;account_host=twitter.com&amp;finish_only=true"/>
</Preference>
</PreferenceCategory>
<PreferenceCategory android:title="@string/special_thanks_to">
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
<org.mariotaku.twidere.preference.TintedPreferenceCategory android:title="@string/special_thanks_to">
<Preference
android:summary="Icon designer for 0.0.6 version"
android:title="Rieya">
@ -104,8 +104,8 @@
android:action="android.intent.action.VIEW"
android:data="twidere://user?user_key=7758552@twitter.com&amp;account_host=twitter.com&amp;finish_only=true"/>
</Preference>
</PreferenceCategory>
<PreferenceCategory android:title="@string/sponsored_by">
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
<org.mariotaku.twidere.preference.TintedPreferenceCategory android:title="@string/sponsored_by">
<Preference
android:icon="@mipmap/ic_launcher_hondajojo"
android:title="@string/kuma_union">
@ -113,6 +113,6 @@
android:action="android.intent.action.VIEW"
android:data="twidere://user?user_key=514378421@twitter.com&amp;account_host=twitter.com&amp;finish_only=true"/>
</Preference>
</PreferenceCategory>
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
</PreferenceScreen>

View File

@ -21,7 +21,7 @@
android:title="@string/notification_light_color"
app:defaultColor="@color/branding_color"/>
<PreferenceCategory
<org.mariotaku.twidere.preference.TintedPreferenceCategory
android:key="cat_notifications_type"
android:title="@string/notifications_type">
<org.mariotaku.twidere.preference.NotificationTypePreference
@ -45,8 +45,8 @@
app:dependencyValueDefault="false"
app:dependencyValues="@array/dependency_values_true"
app:notificationType="ringtone|vibration|light"/>
</PreferenceCategory>
<PreferenceCategory
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
<org.mariotaku.twidere.preference.TintedPreferenceCategory
android:key="cat_other_settings"
android:title="@string/other_settings">
<SwitchPreferenceCompat
@ -58,6 +58,6 @@
android:defaultValue="false"
android:key="notification_mentions_only"
android:title="@string/mentions_only"/>
</PreferenceCategory>
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
</PreferenceScreen>

View File

@ -4,7 +4,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/auto_refresh">
<PreferenceCategory
<org.mariotaku.twidere.preference.TintedPreferenceCategory
android:key="cat_refresh_content"
android:title="@string/content_to_refresh">
<SwitchPreferenceCompat
@ -23,9 +23,9 @@
android:defaultValue="false"
android:key="auto_refresh_trends"
android:title="@string/trends"/>
</PreferenceCategory>
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
<!--<PreferenceCategory-->
<!--<org.mariotaku.twidere.preference.TintedPreferenceCategory-->
<!--android:enabled="false"-->
<!--android:key="cat_streaming"-->
<!--android:title="@string/streaming">-->
@ -34,6 +34,6 @@
<!--android:key="enable_streaming"-->
<!--android:title="@string/enable_streaming"/>-->
<!--</PreferenceCategory>-->
<!--</org.mariotaku.twidere.preference.TintedPreferenceCategory>-->
</PreferenceScreen>

View File

@ -36,7 +36,7 @@
android:summary="@string/custom_host_mapping_summary"
android:title="@string/custom_host_mapping"/>
<PreferenceCategory
<org.mariotaku.twidere.preference.TintedPreferenceCategory
android:key="category_proxy"
android:title="@string/proxy">
<SwitchPreferenceCompat
@ -76,9 +76,9 @@
android:key="proxy_password"
android:singleLine="true"
android:title="@string/proxy_password"/>
</PreferenceCategory>
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
<PreferenceCategory
<org.mariotaku.twidere.preference.TintedPreferenceCategory
android:key="category_tumbor"
android:title="@string/thumbor_integration">
@ -98,6 +98,6 @@
android:inputType="textVisiblePassword"
android:key="thumbor_security_key"
android:title="@string/security_key"/>
</PreferenceCategory>
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
</PreferenceScreen>

View File

@ -5,13 +5,13 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:title="@string/cards">
<PreferenceCategory
<org.mariotaku.twidere.preference.TintedPreferenceCategory
android:key="cat_card_preview"
android:order="11"
android:title="@string/preview">
<org.mariotaku.twidere.preference.CardPreviewPreference
android:key="card_preview"/>
</PreferenceCategory>
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
<org.mariotaku.twidere.preference.SeekBarDialogPreference
android:defaultValue="@integer/default_text_size"

View File

@ -6,7 +6,7 @@
android:key="settings_content"
android:title="@string/content_and_storage">
<PreferenceCategory
<org.mariotaku.twidere.preference.TintedPreferenceCategory
android:key="category_content"
android:title="@string/content">
@ -72,9 +72,9 @@
android:summary="@string/preference_summary_chrome_custom_tab"
android:title="@string/preference_title_chrome_custom_tab"/>
</PreferenceCategory>
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
<PreferenceCategory
<org.mariotaku.twidere.preference.TintedPreferenceCategory
android:key="category_safety"
android:title="@string/safety">
<SwitchPreferenceCompat
@ -92,6 +92,6 @@
android:key="randomize_account_name"
android:summary="@string/preference_randomize_account_name_summary"
android:title="@string/preference_randomize_account_name"/>
</PreferenceCategory>
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
</PreferenceScreen>

View File

@ -10,7 +10,7 @@
android:defaultValue="false"
android:key="filter_possibility_sensitive_statuses"
android:title="@string/preference_filter_possibility_sensitive_statuses"/>
<PreferenceCategory android:title="@string/preference_title_filter_subscriptions">
<org.mariotaku.twidere.preference.TintedPreferenceCategory android:title="@string/preference_title_filter_subscriptions">
<org.mariotaku.twidere.preference.PremiumEntryPreference
android:key="manage_filter_subscriptions"
android:title="@string/preference_title_filter_manage_subscriptions"
@ -20,5 +20,5 @@
android:targetClass="org.mariotaku.twidere.activity.LinkHandlerActivity"
android:targetPackage="org.mariotaku.twidere"/>
</org.mariotaku.twidere.preference.PremiumEntryPreference>
</PreferenceCategory>
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
</PreferenceScreen>

View File

@ -3,7 +3,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/keyboard_shortcuts">
<PreferenceCategory
<org.mariotaku.twidere.preference.TintedPreferenceCategory
android:key="cat_general"
android:title="@string/general">
<org.mariotaku.twidere.preference.KeyboardShortcutPreference
@ -15,18 +15,18 @@
<org.mariotaku.twidere.preference.KeyboardShortcutPreference
android:action="message"
android:title="@string/direct_messages"/>
</PreferenceCategory>
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
<PreferenceCategory
<org.mariotaku.twidere.preference.TintedPreferenceCategory
android:key="cat_home"
android:title="@string/title_home">
<org.mariotaku.twidere.preference.KeyboardShortcutPreference
android:action="home.accounts_dashboard"
android:tag="home"
android:title="@string/open_accounts_dashboard"/>
</PreferenceCategory>
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
<PreferenceCategory
<org.mariotaku.twidere.preference.TintedPreferenceCategory
android:key="cat_navigation"
android:title="@string/navigation">
<org.mariotaku.twidere.preference.KeyboardShortcutPreference
@ -65,9 +65,9 @@
android:action="navigation.top"
android:tag="navigation"
android:title="@string/jump_to_top"/>
</PreferenceCategory>
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
<PreferenceCategory
<org.mariotaku.twidere.preference.TintedPreferenceCategory
android:key="cat_statuses"
android:title="@string/title_statuses">
<org.mariotaku.twidere.preference.KeyboardShortcutPreference
@ -82,5 +82,5 @@
android:action="status.favorite"
android:tag="status"
android:title="@string/action_favorite"/>
</PreferenceCategory>
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
</PreferenceScreen>

View File

@ -11,7 +11,7 @@
app:switchDefault="true"
app:switchKey="notification"/>
<PreferenceCategory
<org.mariotaku.twidere.preference.TintedPreferenceCategory
android:key="cat_general"
android:title="@string/general">
@ -27,6 +27,6 @@
android:key="pebble_notifications"
android:summary="@string/pebble_notifications_summary"
android:title="@string/pebble_notifications"/>
</PreferenceCategory>
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
</PreferenceScreen>

View File

@ -11,7 +11,7 @@
app:switchDefault="true"
app:switchKey="auto_refresh"/>
<PreferenceCategory
<org.mariotaku.twidere.preference.TintedPreferenceCategory
android:key="cat_general"
android:title="@string/general">
<org.mariotaku.twidere.preference.EntrySummaryListPreference
@ -40,6 +40,6 @@
android:key="refresh_after_tweet"
android:summary="@string/refresh_after_status_updated_summary"
android:title="@string/refresh_after_status_updated"/>
</PreferenceCategory>
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
</PreferenceScreen>

View File

@ -6,7 +6,7 @@
android:key="settings_storage"
android:title="@string/preference_title_storage">
<PreferenceCategory
<org.mariotaku.twidere.preference.TintedPreferenceCategory
android:key="category_storage"
android:title="@string/preference_title_storage">
@ -42,6 +42,6 @@
android:summary="@string/clear_databases_summary"
android:title="@string/clear_databases"/>
</PreferenceCategory>
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
</PreferenceScreen>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!--suppress AndroidElementNotAllowed -->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<org.mariotaku.twidere.preference.TintedPreferenceCategory android:title="@string/preference_title_multi_column_tabs">
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="multi_column_tabs_portrait"
android:title="@string/preference_title_portrait"/>
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="multi_column_tabs_landscape"
android:title="@string/preference_title_landscape"/>
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
</PreferenceScreen>

View File

@ -41,7 +41,7 @@
<Preference
android:layout="@layout/header_usage_statistics"
android:order="20"/>
<PreferenceCategory
<org.mariotaku.twidere.preference.TintedPreferenceCategory
android:order="21"
android:title="@string/projects_we_took_part">
@ -50,6 +50,6 @@
android:action="android.intent.action.VIEW"
android:data="http://spice.hot-mobile.org/"/>
</Preference>
</PreferenceCategory>
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
</PreferenceScreen>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="32px" height="32px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 42 (36781) - http://www.bohemiancoding.com/sketch -->
<title>ic_action_tablet-mdpi</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Action-Icons" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="ic_action_tablet-mdpi">
<polygon id="Shape" points="4 4 28 4 28 28 4 28"></polygon>
<path d="M25,8 L7,8 C5.9,8 5,8.9 5,10 L5,22 C5,23.1 5.9,24 7,24 L25,24 C26.1,24 26.99,23.1 26.99,22 L27,10 C27,8.9 26.1,8 25,8 Z M23,22 L9,22 L9,10 L23,10 L23,22 Z" id="Shape" fill="#FFFFFF" fill-rule="nonzero"></path>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 821 B