From b4067b6056a819ebe1db6902d0fce483a6881937 Mon Sep 17 00:00:00 2001 From: vanitasvitae Date: Sun, 23 Oct 2016 04:26:00 +0200 Subject: [PATCH] Introduced ThemedCheckboxPreference --- .../activity/MainActivity.java | 6 + .../fragment/SettingsFragment__Debugging.java | 31 +-- .../SettingsFragment__NavigationSlider.java | 156 +----------- .../fragment/SettingsFragment__Overview.java | 78 ------ .../fragment/SettingsFragment__Proxy.java | 37 ++- .../SettingsFragment__ThemeColors.java | 4 +- .../ui/ThemedCheckBoxPreference.java | 37 ++- .../layout/preference__themed_checkbox.xml | 5 +- .../layout/preference__themed_checkbox2.xml | 27 -- .../layout/preference__themed_edittext.xml | 19 ++ .../settings_activity__section_appearance.xml | 134 ++-------- .../settings_activity__section_network.xml | 37 +-- ...ettings_activity__subsection_debugging.xml | 64 +---- ...ttings_activity__subsection_nav_slider.xml | 230 +++--------------- .../settings_activity__subsection_proxy.xml | 34 +-- 15 files changed, 150 insertions(+), 749 deletions(-) delete mode 100644 app/src/main/res/layout/preference__themed_checkbox2.xml create mode 100644 app/src/main/res/layout/preference__themed_edittext.xml diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java index 7bbeff79..c5fe362a 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java @@ -25,6 +25,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; +import android.content.res.AssetManager; import android.graphics.drawable.LayerDrawable; import android.net.Uri; import android.os.Bundle; @@ -536,6 +537,11 @@ public class MainActivity extends ThemedActivity } } + @Override + public AssetManager getAssets() { + return getResources().getAssets(); + } + @Override protected void onStart() { super.onStart(); diff --git a/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Debugging.java b/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Debugging.java index 4b82f2b3..501df77c 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Debugging.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Debugging.java @@ -46,18 +46,6 @@ public class SettingsFragment__Debugging extends ThemedSettingsFragment { @BindView(R.id.settings_activity__header_more__debugging) protected TextView titleDebugging; - @BindView(R.id.settings_activity__debugging_activated) - protected RelativeLayout optionDebuggingActivated; - - @BindView(R.id.settings_activity__debugging_activated_checkbox) - protected CheckBox checkboxDebuggingActivated; - - @BindView(R.id.settings_activity__debugging_verbose) - protected RelativeLayout optionDebuggingVerbose; - - @BindView(R.id.settings_activity__debugging_verbose_checkbox) - protected CheckBox checkboxDebuggingVerbose; - @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { AppLog.d(this, "onCreateView()"); @@ -69,22 +57,14 @@ public class SettingsFragment__Debugging extends ThemedSettingsFragment { @Override protected void applyColorToViews() { ThemeHelper.updateTitleColor(titleDebugging); - ThemeHelper.updateCheckBoxColor(checkboxDebuggingActivated); - ThemeHelper.updateCheckBoxColor(checkboxDebuggingVerbose); } @Override protected void applySettingsToViews() { - checkboxDebuggingActivated.setChecked(getAppSettings().isLoggingEnabled()); - checkboxDebuggingVerbose.setChecked(getAppSettings().isLoggingSpamEnabled()); } @Override protected void setOnClickListenersOnViews() { - optionDebuggingActivated.setOnClickListener(this); - checkboxDebuggingActivated.setOnClickListener(this); - optionDebuggingVerbose.setOnClickListener(this); - checkboxDebuggingVerbose.setOnClickListener(this); } @Override @@ -105,16 +85,7 @@ public class SettingsFragment__Debugging extends ThemedSettingsFragment { @Override public void onClick(View view) { switch (view.getId()) { - case R.id.settings_activity__debugging_activated: - case R.id.settings_activity__debugging_activated_checkbox: - checkboxDebuggingActivated.setChecked(!getAppSettings().isLoggingEnabled()); - getAppSettings().setLoggingEnabled(!getAppSettings().isLoggingEnabled()); - break; - case R.id.settings_activity__debugging_verbose: - case R.id.settings_activity__debugging_verbose_checkbox: - checkboxDebuggingVerbose.setChecked(!getAppSettings().isLoggingSpamEnabled()); - getAppSettings().setLoggingSpamEnabled(!getAppSettings().isLoggingSpamEnabled()); - break; + } } } diff --git a/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__NavigationSlider.java b/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__NavigationSlider.java index f1532e3f..a2061eb5 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__NavigationSlider.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__NavigationSlider.java @@ -40,72 +40,12 @@ import butterknife.ButterKnife; * Created by vanitas on 16.10.16. */ -public class SettingsFragment__NavigationSlider extends ThemedSettingsFragment { +public class SettingsFragment__NavigationSlider extends ThemedFragment { public static final String TAG = "com.github.dfa.diaspora_android.SettingsFragment__NavigationSlider"; @BindView(R.id.settings_activity__header_appearance__nav_slider) protected TextView titleNavSlider; - @BindView(R.id.settings_activity__navigation_slider_about) - protected RelativeLayout optionAbout; - - @BindView(R.id.settings_activity__navigation_slider_activities) - protected RelativeLayout optionActivities; - - @BindView(R.id.settings_activity__navigation_slider_aspects) - protected RelativeLayout optionAspects; - - @BindView(R.id.settings_activity__navigation_slider_commented) - protected RelativeLayout optionCommented; - - @BindView(R.id.settings_activity__navigation_slider_exit) - protected RelativeLayout optionExit; - - @BindView(R.id.settings_activity__navigation_slider_followed) - protected RelativeLayout optionFollowed; - - @BindView(R.id.settings_activity__navigation_slider_liked) - protected RelativeLayout optionLiked; - - @BindView(R.id.settings_activity__navigation_slider_mentions) - protected RelativeLayout optionMentions; - - @BindView(R.id.settings_activity__navigation_slider_profile) - protected RelativeLayout optionProfile; - - @BindView(R.id.settings_activity__navigation_slider_public) - protected RelativeLayout optionPublic; - - @BindView(R.id.settings_activity__navigation_slider_about_checkbox) - protected CheckBox checkboxAbout; - - @BindView(R.id.settings_activity__navigation_slider_activities_checkbox) - protected CheckBox checkboxActivities; - - @BindView(R.id.settings_activity__navigation_slider_aspects_checkbox) - protected CheckBox checkboxAspects; - - @BindView(R.id.settings_activity__navigation_slider_commented_checkbox) - protected CheckBox checkboxCommented; - - @BindView(R.id.settings_activity__navigation_slider_exit_checkbox) - protected CheckBox checkboxExit; - - @BindView(R.id.settings_activity__navigation_slider_followed_checkbox) - protected CheckBox checkboxFollowed; - - @BindView(R.id.settings_activity__navigation_slider_liked_checkbox) - protected CheckBox checkboxLiked; - - @BindView(R.id.settings_activity__navigation_slider_mentions_checkbox) - protected CheckBox checkboxMentions; - - @BindView(R.id.settings_activity__navigation_slider_profile_checkbox) - protected CheckBox checkboxProfile; - - @BindView(R.id.settings_activity__navigation_slider_public_checkbox) - protected CheckBox checkboxPublic; - @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { AppLog.d(this, "onCreateView()"); @@ -117,100 +57,6 @@ public class SettingsFragment__NavigationSlider extends ThemedSettingsFragment { @Override protected void applyColorToViews() { ThemeHelper.updateTitleColor(titleNavSlider); - ThemeHelper.updateCheckBoxColor(checkboxAbout); - ThemeHelper.updateCheckBoxColor(checkboxActivities); - ThemeHelper.updateCheckBoxColor(checkboxAspects); - ThemeHelper.updateCheckBoxColor(checkboxCommented); - ThemeHelper.updateCheckBoxColor(checkboxExit); - ThemeHelper.updateCheckBoxColor(checkboxFollowed); - ThemeHelper.updateCheckBoxColor(checkboxLiked); - ThemeHelper.updateCheckBoxColor(checkboxMentions); - ThemeHelper.updateCheckBoxColor(checkboxProfile); - ThemeHelper.updateCheckBoxColor(checkboxPublic); - } - - @Override - protected void applySettingsToViews() { - checkboxAbout.setChecked(getAppSettings().isVisibleInNavHelp_license()); - checkboxActivities.setChecked(getAppSettings().isVisibleInNavActivities()); - checkboxAspects.setChecked(getAppSettings().isVisibleInNavAspects()); - checkboxCommented.setChecked(getAppSettings().isVisibleInNavCommented()); - checkboxExit.setChecked(getAppSettings().isVisibleInNavExit()); - checkboxFollowed.setChecked(getAppSettings().isVisibleInNavFollowed_tags()); - checkboxLiked.setChecked(getAppSettings().isVisibleInNavLiked()); - checkboxMentions.setChecked(getAppSettings().isVisibleInNavMentions()); - checkboxProfile.setChecked(getAppSettings().isVisibleInNavProfile()); - checkboxPublic.setChecked(getAppSettings().isVisibleInNavPublic_activities()); - } - - @Override - protected void setOnClickListenersOnViews() { - checkboxAbout.setOnClickListener(this); - checkboxActivities.setOnClickListener(this); - checkboxAspects.setOnClickListener(this); - checkboxCommented.setOnClickListener(this); - checkboxExit.setOnClickListener(this); - checkboxFollowed.setOnClickListener(this); - checkboxLiked.setOnClickListener(this); - checkboxMentions.setOnClickListener(this); - checkboxProfile.setOnClickListener(this); - checkboxPublic.setOnClickListener(this); - } - - @Override - public void onClick(View view) { - switch (view.getId()) { - case R.id.settings_activity__navigation_slider_about: - case R.id.settings_activity__navigation_slider_about_checkbox: - checkboxAbout.setChecked(!getAppSettings().isVisibleInNavHelp_license()); - getAppSettings().setVisibleInNavHelp_license(!getAppSettings().isVisibleInNavHelp_license()); - break; - case R.id.settings_activity__navigation_slider_activities: - case R.id.settings_activity__navigation_slider_activities_checkbox: - checkboxActivities.setChecked(!getAppSettings().isVisibleInNavActivities()); - getAppSettings().setVisibleInNavActivities(!getAppSettings().isVisibleInNavActivities()); - break; - case R.id.settings_activity__navigation_slider_aspects: - case R.id.settings_activity__navigation_slider_aspects_checkbox: - checkboxAspects.setChecked(!getAppSettings().isVisibleInNavAspects()); - getAppSettings().setVisibleInNavAspects(!getAppSettings().isVisibleInNavAspects()); - break; - case R.id.settings_activity__navigation_slider_commented: - case R.id.settings_activity__navigation_slider_commented_checkbox: - checkboxCommented.setChecked(!getAppSettings().isVisibleInNavCommented()); - getAppSettings().setVisibleInNavCommented(!getAppSettings().isVisibleInNavCommented()); - break; - case R.id.settings_activity__navigation_slider_exit: - case R.id.settings_activity__navigation_slider_exit_checkbox: - checkboxExit.setChecked(!getAppSettings().isVisibleInNavExit()); - getAppSettings().setVisibleInNavExit(!getAppSettings().isVisibleInNavExit()); - break; - case R.id.settings_activity__navigation_slider_followed: - case R.id.settings_activity__navigation_slider_followed_checkbox: - checkboxFollowed.setChecked(!getAppSettings().isVisibleInNavFollowed_tags()); - getAppSettings().setVisibleInNavFollowedTags(!getAppSettings().isVisibleInNavFollowed_tags()); - break; - case R.id.settings_activity__navigation_slider_liked: - case R.id.settings_activity__navigation_slider_liked_checkbox: - checkboxLiked.setChecked(!getAppSettings().isVisibleInNavLiked()); - getAppSettings().setVisibleInNavLiked(!getAppSettings().isVisibleInNavLiked()); - break; - case R.id.settings_activity__navigation_slider_mentions: - case R.id.settings_activity__navigation_slider_mentions_checkbox: - checkboxMentions.setChecked(!getAppSettings().isVisibleInNavMentions()); - getAppSettings().setVisibleInNavMentions(!getAppSettings().isVisibleInNavMentions()); - break; - case R.id.settings_activity__navigation_slider_profile: - case R.id.settings_activity__navigation_slider_profile_checkbox: - checkboxProfile.setChecked(!getAppSettings().isVisibleInNavProfile()); - getAppSettings().setVisibleInNavProfile(!getAppSettings().isVisibleInNavProfile()); - break; - case R.id.settings_activity__navigation_slider_public: - case R.id.settings_activity__navigation_slider_public_checkbox: - checkboxPublic.setChecked(!getAppSettings().isVisibleInNavPublic_activities()); - getAppSettings().setVisibleInNavPublic_activities(!getAppSettings().isVisibleInNavPublic_activities()); - break; - } } @Override diff --git a/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Overview.java b/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Overview.java index 3fe1d5a6..04e74da6 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Overview.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Overview.java @@ -28,10 +28,8 @@ import android.view.MenuInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; -import android.widget.CheckBox; import android.widget.LinearLayout; import android.widget.ListView; -import android.widget.RelativeLayout; import android.widget.TextView; import com.github.dfa.diaspora_android.R; @@ -64,33 +62,9 @@ public class SettingsFragment__Overview extends ThemedSettingsFragment { @BindView(R.id.settings_activity__font_size) protected LinearLayout optionFontSize; - //@BindView(R.id.settings_activity__intellihide_toolbars) - protected RelativeLayout optionIntellihideToolbars; - - @BindView(R.id.settings_activity__extended_notifications) - protected RelativeLayout optionExtendedNotifications; - - @BindView(R.id.settings_activity__append_shared_via_app) - protected RelativeLayout optionAppendSharedViaApp; - - @BindView(R.id.settings_activity__chrome_custom_tabs) - protected RelativeLayout optionCustomTabs; - @BindView(R.id.settings_activity__font_size_hint) protected TextView hintFontSize; - //@BindView(R.id.settings_activity__intellihide_toolbars_checkbox) - protected CheckBox checkboxIntellihide; - - @BindView(R.id.settings_activity__extended_notifications_checkbox) - protected CheckBox checkboxExtendedNotifications; - - @BindView(R.id.settings_activity__append_shared_via_app_checkbox) - protected CheckBox checkboxAppendSharedViaApp; - - @BindView(R.id.settings_activity__chrome_custom_tabs_checkbox) - protected CheckBox checkboxCustomTabs; - //Pod Settings @BindView(R.id.settings_activity__header_pod_settings) protected TextView titlePodSettings; @@ -111,18 +85,12 @@ public class SettingsFragment__Overview extends ThemedSettingsFragment { @BindView(R.id.settings_activity__header_network) protected TextView titleNetwork; - @BindView(R.id.settings_activity__load_images) - protected RelativeLayout optionLoadImages; - @BindView(R.id.settings_activity__clear_cache) protected LinearLayout optionClearCache; @BindView(R.id.settings_activity__proxy_settings) protected LinearLayout optionProxySettings; - @BindView(R.id.settings_activity__load_images_checkbox) - protected CheckBox checkboxLoadImages; - //More @BindView(R.id.settings_activity__header_more) protected TextView titleMore; @@ -148,11 +116,6 @@ public class SettingsFragment__Overview extends ThemedSettingsFragment { protected void applySettingsToViews() { hintFontSize.setText(getAppSettings().getMinimumFontSizeString()); - //checkboxIntellihide.setChecked(getAppSettings().isIntellihideToolbars()); - checkboxExtendedNotifications.setChecked(getAppSettings().isExtendedNotifications()); - checkboxAppendSharedViaApp.setChecked(getAppSettings().isAppendSharedViaApp()); - checkboxCustomTabs.setChecked(getAppSettings().isChromeCustomTabsEnabled()); - checkboxLoadImages.setChecked(getAppSettings().isLoadImages()); } protected void setOnClickListenersOnViews() { @@ -160,22 +123,12 @@ public class SettingsFragment__Overview extends ThemedSettingsFragment { optionThemeColors.setOnClickListener(this); optionNavigationSlider.setOnClickListener(this); optionFontSize.setOnClickListener(this); - //optionIntellihideToolbars.setOnClickListener(this); - //checkboxIntellihide.setOnClickListener(this); - optionExtendedNotifications.setOnClickListener(this); - checkboxExtendedNotifications.setOnClickListener(this); - optionAppendSharedViaApp.setOnClickListener(this); - checkboxAppendSharedViaApp.setOnClickListener(this); - optionCustomTabs.setOnClickListener(this); - checkboxCustomTabs.setOnClickListener(this); /** Pod Settings */ optionPersonalSettings.setOnClickListener(this); optionManageTags.setOnClickListener(this); optionManageContacts.setOnClickListener(this); optionChangeAccount.setOnClickListener(this); /** Network */ - optionLoadImages.setOnClickListener(this); - checkboxLoadImages.setOnClickListener(this); optionClearCache.setOnClickListener(this); optionProxySettings.setOnClickListener(this); /** More */ @@ -191,12 +144,6 @@ public class SettingsFragment__Overview extends ThemedSettingsFragment { ThemeHelper.updateTitleColor(titlePodSettings); ThemeHelper.updateTitleColor(titleNetwork); ThemeHelper.updateTitleColor(titleMore); - //Checkboxes - //ThemeHelper.updateCheckBoxColor(checkboxIntellihide); - ThemeHelper.updateCheckBoxColor(checkboxExtendedNotifications); - ThemeHelper.updateCheckBoxColor(checkboxAppendSharedViaApp); - ThemeHelper.updateCheckBoxColor(checkboxCustomTabs); - ThemeHelper.updateCheckBoxColor(checkboxLoadImages); } protected void showFontSizeDialog() { @@ -248,26 +195,6 @@ public class SettingsFragment__Overview extends ThemedSettingsFragment { case R.id.settings_activity__font_size: showFontSizeDialog(); break; - //case R.id.settings_activity__intellihide_toolbars: - //case R.id.settings_activity__intellihide_toolbars_checkbox: - // checkboxIntellihide.setChecked(!getAppSettings().isIntellihideToolbars()); - // getAppSettings().setIntellihideToolbars(!getAppSettings().isIntellihideToolbars()); - // break; - case R.id.settings_activity__extended_notifications: - case R.id.settings_activity__extended_notifications_checkbox: - checkboxExtendedNotifications.setChecked(!getAppSettings().isExtendedNotifications()); - getAppSettings().setExtendedNotifications(!getAppSettings().isExtendedNotifications()); - break; - case R.id.settings_activity__append_shared_via_app: - case R.id.settings_activity__append_shared_via_app_checkbox: - checkboxAppendSharedViaApp.setChecked(!getAppSettings().isAppendSharedViaApp()); - getAppSettings().setAppendSharedViaApp(!getAppSettings().isAppendSharedViaApp()); - break; - case R.id.settings_activity__chrome_custom_tabs: - case R.id.settings_activity__chrome_custom_tabs_checkbox: - checkboxCustomTabs.setChecked(!getAppSettings().isChromeCustomTabsEnabled()); - getAppSettings().setChromeCustomTabsEnabled(!getAppSettings().isChromeCustomTabsEnabled()); - break; /** Pod Settings */ case R.id.settings_activity__personal_settings: { Intent intent = new Intent(getActivity(), MainActivity.class); @@ -310,11 +237,6 @@ public class SettingsFragment__Overview extends ThemedSettingsFragment { .show(); } /** Network */ - case R.id.settings_activity__load_images: - case R.id.settings_activity__load_images_checkbox: - checkboxLoadImages.setChecked(!getAppSettings().isLoadImages()); - getAppSettings().setLoadImages(!getAppSettings().isLoadImages()); - break; case R.id.settings_activity__clear_cache: { Intent intent = new Intent(getActivity(), MainActivity.class); intent.setAction(MainActivity.ACTION_CLEAR_CACHE); diff --git a/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Proxy.java b/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Proxy.java index 0accff24..d57a43ea 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Proxy.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__Proxy.java @@ -28,13 +28,14 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.CheckBox; +import android.widget.CompoundButton; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; import com.github.dfa.diaspora_android.R; +import com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference; import com.github.dfa.diaspora_android.util.AppLog; import com.github.dfa.diaspora_android.util.theming.ThemeHelper; @@ -52,11 +53,8 @@ public class SettingsFragment__Proxy extends ThemedSettingsFragment { @BindView(R.id.settings_activity__header_network__proxy) protected TextView titleProxy; - @BindView(R.id.settings_activity__proxy_activated) - protected RelativeLayout optionProxyActivated; - - @BindView(R.id.settings_activity__proxy_activated_checkbox) - protected CheckBox checkboxProxyActivated; + @BindView(R.id.settings_activity__proxy_enabled) + protected ThemedCheckBoxPreference checkboxProxyEna; @BindView(R.id.settings_activity__proxy_host) protected LinearLayout optionProxyHost; @@ -84,7 +82,6 @@ public class SettingsFragment__Proxy extends ThemedSettingsFragment { @Override protected void applyColorToViews() { ThemeHelper.updateTitleColor(titleProxy); - ThemeHelper.updateCheckBoxColor(checkboxProxyActivated); optionProxyHost.setVisibility(getAppSettings().isProxyHttpEnabled() ? View.VISIBLE : View.GONE); optionProxyPort.setVisibility(getAppSettings().isProxyHttpEnabled() ? View.VISIBLE : View.GONE); optionProxyOrbotPreset.setVisibility(getAppSettings().isProxyHttpEnabled() ? View.VISIBLE : View.GONE); @@ -93,7 +90,6 @@ public class SettingsFragment__Proxy extends ThemedSettingsFragment { @SuppressLint("SetTextI18n") @Override protected void applySettingsToViews() { - checkboxProxyActivated.setChecked(getAppSettings().isProxyHttpEnabled()); optionProxyHost.setEnabled(getAppSettings().isProxyHttpEnabled()); hintProxyHost.setText(getAppSettings().getProxyHttpHost()); optionProxyPort.setEnabled(getAppSettings().isProxyHttpEnabled()); @@ -103,8 +99,17 @@ public class SettingsFragment__Proxy extends ThemedSettingsFragment { @Override protected void setOnClickListenersOnViews() { - optionProxyActivated.setOnClickListener(this); - checkboxProxyActivated.setOnClickListener(this); + checkboxProxyEna.setOnCheckedChangedListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + optionProxyHost.setEnabled(b); + optionProxyPort.setEnabled(b); + optionProxyOrbotPreset.setEnabled(b); + optionProxyHost.setVisibility(b ? View.VISIBLE : View.GONE); + optionProxyPort.setVisibility(b ? View.VISIBLE : View.GONE); + optionProxyOrbotPreset.setVisibility(b ? View.VISIBLE : View.GONE); + } + }); optionProxyHost.setOnClickListener(this); optionProxyPort.setOnClickListener(this); optionProxyOrbotPreset.setOnClickListener(this); @@ -114,18 +119,6 @@ public class SettingsFragment__Proxy extends ThemedSettingsFragment { @Override public void onClick(View view) { switch (view.getId()) { - case R.id.settings_activity__proxy_activated: - case R.id.settings_activity__proxy_activated_checkbox: - boolean proxyEnabled = !getAppSettings().isProxyHttpEnabled(); - checkboxProxyActivated.setChecked(proxyEnabled); - getAppSettings().setProxyHttpEnabled(proxyEnabled); - optionProxyHost.setEnabled(proxyEnabled); - optionProxyPort.setEnabled(proxyEnabled); - optionProxyOrbotPreset.setEnabled(proxyEnabled); - optionProxyHost.setVisibility(getAppSettings().isProxyHttpEnabled() ? View.VISIBLE : View.GONE); - optionProxyPort.setVisibility(getAppSettings().isProxyHttpEnabled() ? View.VISIBLE : View.GONE); - optionProxyOrbotPreset.setVisibility(getAppSettings().isProxyHttpEnabled() ? View.VISIBLE : View.GONE); - break; case R.id.settings_activity__proxy_host: showProxyHostDialog(); break; diff --git a/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__ThemeColors.java b/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__ThemeColors.java index 004297d8..804d129e 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__ThemeColors.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/fragment/SettingsFragment__ThemeColors.java @@ -177,13 +177,13 @@ public class SettingsFragment__ThemeColors extends ThemedSettingsFragment { .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { - if (type == 1) { + if (type == 1) { //Primary Color appSettings.setPrimaryColorPickerSettings(base.getColor(), shade.getColor()); if (Build.VERSION.SDK_INT >= 21) { getActivity().getWindow().setStatusBarColor(ThemeHelper.getPrimaryDarkColor()); } ((ThemedActivity) getActivity()).applyColorToViews(); - } else { + } else { //Accent Color appSettings.setAccentColorPickerSettings(base.getColor(), shade.getColor()); } applyColorToViews(); diff --git a/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedCheckBoxPreference.java b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedCheckBoxPreference.java index cfe237da..b46c7d71 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedCheckBoxPreference.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedCheckBoxPreference.java @@ -2,9 +2,7 @@ package com.github.dfa.diaspora_android.ui; import android.content.Context; import android.content.res.TypedArray; -import android.graphics.Rect; import android.util.AttributeSet; -import android.view.MotionEvent; import android.view.View; import android.widget.CheckBox; import android.widget.CompoundButton; @@ -14,6 +12,7 @@ import android.widget.TextView; import com.github.dfa.diaspora_android.R; import com.github.dfa.diaspora_android.data.AppSettings; import com.github.dfa.diaspora_android.util.AppLog; +import com.github.dfa.diaspora_android.util.theming.ThemeHelper; import butterknife.BindView; import butterknife.ButterKnife; @@ -34,6 +33,8 @@ public class ThemedCheckBoxPreference extends RelativeLayout { protected String prefKey; protected boolean defaultValue; + protected AppSettings appSettings; + protected CompoundButton.OnCheckedChangeListener externalOnCheckedChangedListener; public ThemedCheckBoxPreference(Context context) { super(context); @@ -51,6 +52,7 @@ public class ThemedCheckBoxPreference extends RelativeLayout { } protected void init(Context context, AttributeSet attrs) { + appSettings = new AppSettings(context.getApplicationContext()); View.inflate(context, R.layout.preference__themed_checkbox, this); ButterKnife.bind(this); setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS); @@ -63,14 +65,13 @@ public class ThemedCheckBoxPreference extends RelativeLayout { // Assign custom attributes if (attrs != null) { + String titleText = ""; + String summaryText = ""; + TypedArray a = context.getTheme().obtainStyledAttributes( attrs, R.styleable.ThemedCheckBoxPreference, 0, 0); - - String titleText = ""; - String summaryText = ""; - try { titleText = a.getString(R.styleable.ThemedCheckBoxPreference_titleText); summaryText = a.getString(R.styleable.ThemedCheckBoxPreference_summaryText); @@ -82,20 +83,33 @@ public class ThemedCheckBoxPreference extends RelativeLayout { a.recycle(); } - final AppSettings appSettings = new AppSettings(context); - setTitleText(titleText); + if(titleText == null || titleText.equals("")) { + title.setVisibility(GONE); + } setSummaryText(summaryText); + if(summaryText == null || summaryText.equals("")) { + summary.setVisibility(GONE); + } setChecked(appSettings.getThemedCheckboxPreferenceBoolean(this)); - setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { appSettings.setThemedCheckboxPreferenceBoolean(ThemedCheckBoxPreference.this, b); + if(externalOnCheckedChangedListener != null) { + externalOnCheckedChangedListener.onCheckedChanged(compoundButton, b); + } } }); + applyColor(); } } + public void applyColor() { + ThemeHelper.getInstance(appSettings); + ThemeHelper.updateCheckBoxColor(checkBox); + } + public void setTitleText(String text) { title.setText(text); } @@ -108,9 +122,8 @@ public class ThemedCheckBoxPreference extends RelativeLayout { checkBox.setChecked(checked); } - - public void setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener listener) { - checkBox.setOnCheckedChangeListener(listener); + public void setOnCheckedChangedListener(CompoundButton.OnCheckedChangeListener listener) { + externalOnCheckedChangedListener = listener; } public String getPrefKey() { diff --git a/app/src/main/res/layout/preference__themed_checkbox.xml b/app/src/main/res/layout/preference__themed_checkbox.xml index f9602416..19b8dac9 100644 --- a/app/src/main/res/layout/preference__themed_checkbox.xml +++ b/app/src/main/res/layout/preference__themed_checkbox.xml @@ -1,4 +1,3 @@ - + android:layout_height="wrap_content" + android:minHeight="0dp"/> - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/preference__themed_edittext.xml b/app/src/main/res/layout/preference__themed_edittext.xml new file mode 100644 index 00000000..3794dc53 --- /dev/null +++ b/app/src/main/res/layout/preference__themed_edittext.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/settings_activity__section_appearance.xml b/app/src/main/res/layout/settings_activity__section_appearance.xml index 7b61a7f7..6ab9039f 100644 --- a/app/src/main/res/layout/settings_activity__section_appearance.xml +++ b/app/src/main/res/layout/settings_activity__section_appearance.xml @@ -79,134 +79,32 @@ app:titleText="@string/pref_title__intellihide_toolbars" app:summaryText="@string/pref_desc__intellihide_toolbars" app:prefKey="@string/pref_key__intellihide_toolbars" - app:defaultValue="true"/> - - - + app:defaultValue="true" /> - - - - - - - + app:titleText="@string/pref_title__extended_notifications" + app:summaryText="@string/pref_desc__extended_notifications" + app:prefKey="@string/pref_key__extended_notifications" + app:defaultValue="false" /> - - - - - - - + app:titleText="@string/pref_title__append_shared_via_app" + app:summaryText="@string/pref_desc__append_shared_via_app" + app:prefKey="@string/pref_key__append_shared_via_app" + app:defaultValue="true" /> - - - - - - - + app:titleText="@string/pref_title__chrome_custom_tabs_enabled" + app:summaryText="@string/pref_desc__chrome_custom_tabs_enabled" + app:prefKey="@string/pref_key__chrome_custom_tabs_enabled" + app:defaultValue="true" /> \ No newline at end of file diff --git a/app/src/main/res/layout/settings_activity__section_network.xml b/app/src/main/res/layout/settings_activity__section_network.xml index 10f8bd17..1c16a904 100644 --- a/app/src/main/res/layout/settings_activity__section_network.xml +++ b/app/src/main/res/layout/settings_activity__section_network.xml @@ -1,6 +1,8 @@ - - - - - - - + app:titleText="@string/pref_title__load_images" + app:summaryText="@string/pref_desc__load_images" + app:prefKey="@string/pref_key__load_images" + app:defaultValue="true" /> - - - - - - - + app:titleText="@string/pref_title__logging_enabled" + app:prefKey="@string/pref_key__logging_enabled" + app:defaultValue="true"/> - - - - - - - + app:titleText="@string/pref_title__logging_spam_enabled" + app:prefKey="@string/pref_key__logging_spam_enabled" + app:defaultValue="true"/> diff --git a/app/src/main/res/layout/settings_activity__subsection_nav_slider.xml b/app/src/main/res/layout/settings_activity__subsection_nav_slider.xml index 21a25606..8a3468fe 100644 --- a/app/src/main/res/layout/settings_activity__subsection_nav_slider.xml +++ b/app/src/main/res/layout/settings_activity__subsection_nav_slider.xml @@ -31,234 +31,84 @@ - - - - + app:titleText="@string/nav_profile" + app:prefKey="@string/pref_key__visibility_nav__profile" + app:defaultValue="true"/> - - - - + app:titleText="@string/nav_followed_tags" + app:prefKey="@string/pref_key__visibility_nav__followed_tags" + app:defaultValue="true"/> - - - - + app:titleText="@string/nav_aspects" + app:prefKey="@string/pref_key__visibility_nav__aspects" + app:defaultValue="true"/> - - - - + app:titleText="@string/nav_activities" + app:prefKey="@string/pref_key__visibility_nav__activities" + app:defaultValue="false"/> - - - - + app:titleText="@string/nav_liked" + app:prefKey="@string/pref_key__visibility_nav__liked" + app:defaultValue="true"/> - - - - + app:titleText="@string/nav_commented" + app:prefKey="@string/pref_key__visibility_nav__commented" + app:defaultValue="true"/> - - - - + app:titleText="@string/nav_mentions" + app:prefKey="@string/pref_key__visibility_nav__mentions" + app:defaultValue="false"/> - - - - + app:titleText="@string/nav_public_activities" + app:prefKey="@string/pref_key__visibility_nav__public_activities" + app:defaultValue="false"/> - - - - + app:titleText="@string/action_exit_app" + app:prefKey="@string/pref_key__visibility_nav__exit" + app:defaultValue="false"/> - - - - + app:titleText="@string/nav_help_license" + app:prefKey="@string/pref_key__visibility_nav__help_license" + app:defaultValue="true"/> diff --git a/app/src/main/res/layout/settings_activity__subsection_proxy.xml b/app/src/main/res/layout/settings_activity__subsection_proxy.xml index fcc10b4a..5fb9be04 100644 --- a/app/src/main/res/layout/settings_activity__subsection_proxy.xml +++ b/app/src/main/res/layout/settings_activity__subsection_proxy.xml @@ -29,36 +29,14 @@ android:text="@string/pref_title__sub_proxy"/> - - - - - - - + app:titleText="@string/pref_title__proxy_enabled" + app:summaryText="@string/pref_desc__http_proxy_enabled" + app:prefKey="@string/pref_key__http_proxy_enabled" + app:defaultValue="false" />