From 8d8bbf4b502ff1709d0a3f16f540cca840aa6371 Mon Sep 17 00:00:00 2001 From: vanitasvitae Date: Fri, 21 Oct 2016 21:21:51 +0200 Subject: [PATCH] Cleaned up and removed unused methods --- .../diaspora_android/data/AppSettings.java | 40 ++++++------------- .../fragment/HashtagListFragment.java | 6 +-- .../SettingsFragment__NavigationSlider.java | 4 -- .../fragment/SettingsFragment__Proxy.java | 4 ++ .../SettingsFragment__ThemeColors.java | 6 +-- 5 files changed, 22 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/com/github/dfa/diaspora_android/data/AppSettings.java b/app/src/main/java/com/github/dfa/diaspora_android/data/AppSettings.java index 5aad5ab5..94923caf 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/data/AppSettings.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/data/AppSettings.java @@ -21,7 +21,6 @@ import android.content.SharedPreferences; import com.github.dfa.diaspora_android.R; import com.github.dfa.diaspora_android.data.DiasporaPodList.DiasporaPod; import com.github.dfa.diaspora_android.data.DiasporaPodList.DiasporaPod.DiasporaPodUrl; -import com.github.dfa.diaspora_android.util.AppLog; import com.github.dfa.diaspora_android.util.ProxyHandler; import org.json.JSONException; @@ -76,24 +75,24 @@ public class AppSettings { setString(pref, keyRessourceId, sb.toString().replaceFirst("%%%", "")); } - private String[] getStringArray(SharedPreferences pref, int keyRessourceId) { - String value = pref.getString(context.getString(keyRessourceId), "%%%"); + private String[] getStringArray(SharedPreferences pref, int keyResourceId) { + String value = pref.getString(context.getString(keyResourceId), "%%%"); if (value.equals("%%%")) { return new String[0]; } return value.split("%%%"); } - private String getString(SharedPreferences pref, int ressourceId, String defaultValue) { - return pref.getString(context.getString(ressourceId), defaultValue); + private String getString(SharedPreferences pref, int resourceId, String defaultValue) { + return pref.getString(context.getString(resourceId), defaultValue); } - private boolean getBoolean(SharedPreferences pref, int ressourceId, boolean defaultValue) { - return pref.getBoolean(context.getString(ressourceId), defaultValue); + private boolean getBoolean(SharedPreferences pref, int resourceId, boolean defaultValue) { + return pref.getBoolean(context.getString(resourceId), defaultValue); } - private int getInt(SharedPreferences pref, int ressourceId, int defaultValue) { - return pref.getInt(context.getString(ressourceId), defaultValue); + private int getInt(SharedPreferences pref, int resourceId, int defaultValue) { + return pref.getInt(context.getString(resourceId), defaultValue); } @@ -277,21 +276,6 @@ public class AppSettings { return getBoolean(prefApp, R.string.pref_key__http_proxy_enabled, false); } - public boolean wasProxyEnabled() { - return getBoolean(prefApp, R.string.pref_key__proxy_was_enabled, false); - } - - /** - * Needed in order to determine, whether the proxy has just been disabled (trigger app restart) - * or if proxy was disabled before (do not restart app) - * - * @param b new value - */ - @SuppressLint("CommitPrefEdits") - public void setProxyWasEnabled(boolean b) { - prefApp.edit().putBoolean(context.getString(R.string.pref_key__proxy_was_enabled), b).commit(); - } - /** * Default value: "" * @@ -434,12 +418,12 @@ public class AppSettings { setBool(prefApp, R.string.pref_key__visibility_nav__profile, b); } - public void setPrimaryColorSettings(int base, int shade) { + public void setPrimaryColorPickerSettings(int base, int shade) { setInt(prefApp, R.string.pref_key__primary_color_base, base); setInt(prefApp, R.string.pref_key__primary_color_shade, shade); } - public int[] getPrimaryColorSettings() { + public int[] getPrimaryColorPickerSettings() { return new int[]{ getInt(prefApp, R.string.pref_key__primary_color_base, context.getResources().getColor(R.color.md_blue_500)), getInt(prefApp, R.string.pref_key__primary_color_shade, context.getResources().getColor(R.color.primary)) @@ -450,12 +434,12 @@ public class AppSettings { return getInt(prefApp, R.string.pref_key__primary_color_shade, context.getResources().getColor(R.color.primary)); } - public void setAccentColorSettings(int base, int shade) { + public void setAccentColorPickerSettings(int base, int shade) { setInt(prefApp, R.string.pref_key__accent_color_base, base); setInt(prefApp, R.string.pref_key__accent_color_shade, shade); } - public int[] getAccentColorSettings() { + public int[] getAccentColorPickerSettings() { return new int[]{ getInt(prefApp, R.string.pref_key__accent_color_base, context.getResources().getColor(R.color.md_deep_orange_500)), getInt(prefApp, R.string.pref_key__accent_color_shade, context.getResources().getColor(R.color.accent)) diff --git a/app/src/main/java/com/github/dfa/diaspora_android/fragment/HashtagListFragment.java b/app/src/main/java/com/github/dfa/diaspora_android/fragment/HashtagListFragment.java index 6c32d6b9..d63253b4 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/fragment/HashtagListFragment.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/fragment/HashtagListFragment.java @@ -105,18 +105,18 @@ public class HashtagListFragment extends CustomFragment { private String[] followedTagsList; private View.OnClickListener itemClickListener; - public static class ViewHolder extends RecyclerView.ViewHolder { + static class ViewHolder extends RecyclerView.ViewHolder { // each data item is just a string in this case public TextView title; - public ViewHolder(View v) { + ViewHolder(View v) { super(v); title = (TextView) v.findViewById(R.id.recycler_view__list_item__text); } } // Provide a suitable constructor (depends on the kind of dataset) - public FollowedTagsAdapter(String[] tags, View.OnClickListener itemClickListener) { + FollowedTagsAdapter(String[] tags, View.OnClickListener itemClickListener) { this.followedTagsList = tags; this.itemClickListener = itemClickListener; } 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 e5852816..f1532e3f 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 @@ -106,10 +106,6 @@ public class SettingsFragment__NavigationSlider extends ThemedSettingsFragment { @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()"); 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 739d872a..86d8245a 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 @@ -18,6 +18,7 @@ */ package com.github.dfa.diaspora_android.fragment; +import android.annotation.SuppressLint; import android.content.DialogInterface; import android.os.Bundle; import android.support.v7.app.AlertDialog; @@ -89,6 +90,7 @@ public class SettingsFragment__Proxy extends ThemedSettingsFragment { optionProxyOrbotPreset.setVisibility(getAppSettings().isProxyEnabled() ? View.VISIBLE : View.GONE); } + @SuppressLint("SetTextI18n") @Override protected void applySettingsToViews() { checkboxProxyActivated.setChecked(getAppSettings().isProxyEnabled()); @@ -108,6 +110,7 @@ public class SettingsFragment__Proxy extends ThemedSettingsFragment { optionProxyOrbotPreset.setOnClickListener(this); } + @SuppressLint("SetTextI18n") @Override public void onClick(View view) { switch (view.getId()) { @@ -171,6 +174,7 @@ public class SettingsFragment__Proxy extends ThemedSettingsFragment { }).setNegativeButton(android.R.string.cancel, null).show(); } + @SuppressLint("SetTextI18n") protected void showProxyPortDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); final EditText input = (EditText) getLayoutInflater(null).inflate(R.layout.settings_activity__dialog_proxy, null, false); 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 a8604a41..004297d8 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 @@ -144,7 +144,7 @@ public class SettingsFragment__ThemeColors extends ThemedSettingsFragment { title.setText(type == 1 ? R.string.pref_title__primary_color : R.string.pref_title__accent_color); title.setTextColor(getResources().getColor(R.color.white)); - final int[] current = (type == 1 ? appSettings.getPrimaryColorSettings() : appSettings.getAccentColorSettings()); + final int[] current = (type == 1 ? appSettings.getPrimaryColorPickerSettings() : appSettings.getAccentColorPickerSettings()); base.setColors((type == 1 ? ColorPalette.getBaseColors(context) : ColorPalette.getAccentColors(context))); base.setSelectedColor(current[0]); shade.setColors(ColorPalette.getColors(context, current[0])); @@ -178,13 +178,13 @@ public class SettingsFragment__ThemeColors extends ThemedSettingsFragment { @Override public void onClick(DialogInterface dialogInterface, int i) { if (type == 1) { - appSettings.setPrimaryColorSettings(base.getColor(), shade.getColor()); + appSettings.setPrimaryColorPickerSettings(base.getColor(), shade.getColor()); if (Build.VERSION.SDK_INT >= 21) { getActivity().getWindow().setStatusBarColor(ThemeHelper.getPrimaryDarkColor()); } ((ThemedActivity) getActivity()).applyColorToViews(); } else { - appSettings.setAccentColorSettings(base.getColor(), shade.getColor()); + appSettings.setAccentColorPickerSettings(base.getColor(), shade.getColor()); } applyColorToViews(); applySettingsToViews();