mirror of
https://github.com/gsantner/dandelion
synced 2024-11-28 15:22:09 +01:00
Cleaned up and removed unused methods
This commit is contained in:
parent
a5669635e2
commit
8d8bbf4b50
5 changed files with 22 additions and 38 deletions
|
@ -21,7 +21,6 @@ import android.content.SharedPreferences;
|
||||||
import com.github.dfa.diaspora_android.R;
|
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;
|
||||||
import com.github.dfa.diaspora_android.data.DiasporaPodList.DiasporaPod.DiasporaPodUrl;
|
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 com.github.dfa.diaspora_android.util.ProxyHandler;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
@ -76,24 +75,24 @@ public class AppSettings {
|
||||||
setString(pref, keyRessourceId, sb.toString().replaceFirst("%%%", ""));
|
setString(pref, keyRessourceId, sb.toString().replaceFirst("%%%", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] getStringArray(SharedPreferences pref, int keyRessourceId) {
|
private String[] getStringArray(SharedPreferences pref, int keyResourceId) {
|
||||||
String value = pref.getString(context.getString(keyRessourceId), "%%%");
|
String value = pref.getString(context.getString(keyResourceId), "%%%");
|
||||||
if (value.equals("%%%")) {
|
if (value.equals("%%%")) {
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
return value.split("%%%");
|
return value.split("%%%");
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getString(SharedPreferences pref, int ressourceId, String defaultValue) {
|
private String getString(SharedPreferences pref, int resourceId, String defaultValue) {
|
||||||
return pref.getString(context.getString(ressourceId), defaultValue);
|
return pref.getString(context.getString(resourceId), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean getBoolean(SharedPreferences pref, int ressourceId, boolean defaultValue) {
|
private boolean getBoolean(SharedPreferences pref, int resourceId, boolean defaultValue) {
|
||||||
return pref.getBoolean(context.getString(ressourceId), defaultValue);
|
return pref.getBoolean(context.getString(resourceId), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getInt(SharedPreferences pref, int ressourceId, int defaultValue) {
|
private int getInt(SharedPreferences pref, int resourceId, int defaultValue) {
|
||||||
return pref.getInt(context.getString(ressourceId), 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);
|
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: ""
|
* Default value: ""
|
||||||
*
|
*
|
||||||
|
@ -434,12 +418,12 @@ public class AppSettings {
|
||||||
setBool(prefApp, R.string.pref_key__visibility_nav__profile, b);
|
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_base, base);
|
||||||
setInt(prefApp, R.string.pref_key__primary_color_shade, shade);
|
setInt(prefApp, R.string.pref_key__primary_color_shade, shade);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] getPrimaryColorSettings() {
|
public int[] getPrimaryColorPickerSettings() {
|
||||||
return new int[]{
|
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_base, context.getResources().getColor(R.color.md_blue_500)),
|
||||||
getInt(prefApp, R.string.pref_key__primary_color_shade, context.getResources().getColor(R.color.primary))
|
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));
|
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_base, base);
|
||||||
setInt(prefApp, R.string.pref_key__accent_color_shade, shade);
|
setInt(prefApp, R.string.pref_key__accent_color_shade, shade);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] getAccentColorSettings() {
|
public int[] getAccentColorPickerSettings() {
|
||||||
return new int[]{
|
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_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))
|
getInt(prefApp, R.string.pref_key__accent_color_shade, context.getResources().getColor(R.color.accent))
|
||||||
|
|
|
@ -105,18 +105,18 @@ public class HashtagListFragment extends CustomFragment {
|
||||||
private String[] followedTagsList;
|
private String[] followedTagsList;
|
||||||
private View.OnClickListener itemClickListener;
|
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
|
// each data item is just a string in this case
|
||||||
public TextView title;
|
public TextView title;
|
||||||
|
|
||||||
public ViewHolder(View v) {
|
ViewHolder(View v) {
|
||||||
super(v);
|
super(v);
|
||||||
title = (TextView) v.findViewById(R.id.recycler_view__list_item__text);
|
title = (TextView) v.findViewById(R.id.recycler_view__list_item__text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Provide a suitable constructor (depends on the kind of dataset)
|
// 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.followedTagsList = tags;
|
||||||
this.itemClickListener = itemClickListener;
|
this.itemClickListener = itemClickListener;
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,10 +106,6 @@ public class SettingsFragment__NavigationSlider extends ThemedSettingsFragment {
|
||||||
@BindView(R.id.settings_activity__navigation_slider_public_checkbox)
|
@BindView(R.id.settings_activity__navigation_slider_public_checkbox)
|
||||||
protected CheckBox checkboxPublic;
|
protected CheckBox checkboxPublic;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
AppLog.d(this, "onCreateView()");
|
AppLog.d(this, "onCreateView()");
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package com.github.dfa.diaspora_android.fragment;
|
package com.github.dfa.diaspora_android.fragment;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
@ -89,6 +90,7 @@ public class SettingsFragment__Proxy extends ThemedSettingsFragment {
|
||||||
optionProxyOrbotPreset.setVisibility(getAppSettings().isProxyEnabled() ? View.VISIBLE : View.GONE);
|
optionProxyOrbotPreset.setVisibility(getAppSettings().isProxyEnabled() ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
@Override
|
@Override
|
||||||
protected void applySettingsToViews() {
|
protected void applySettingsToViews() {
|
||||||
checkboxProxyActivated.setChecked(getAppSettings().isProxyEnabled());
|
checkboxProxyActivated.setChecked(getAppSettings().isProxyEnabled());
|
||||||
|
@ -108,6 +110,7 @@ public class SettingsFragment__Proxy extends ThemedSettingsFragment {
|
||||||
optionProxyOrbotPreset.setOnClickListener(this);
|
optionProxyOrbotPreset.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
switch (view.getId()) {
|
switch (view.getId()) {
|
||||||
|
@ -171,6 +174,7 @@ public class SettingsFragment__Proxy extends ThemedSettingsFragment {
|
||||||
}).setNegativeButton(android.R.string.cancel, null).show();
|
}).setNegativeButton(android.R.string.cancel, null).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
protected void showProxyPortDialog() {
|
protected void showProxyPortDialog() {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||||
final EditText input = (EditText) getLayoutInflater(null).inflate(R.layout.settings_activity__dialog_proxy, null, false);
|
final EditText input = (EditText) getLayoutInflater(null).inflate(R.layout.settings_activity__dialog_proxy, null, false);
|
||||||
|
|
|
@ -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.setText(type == 1 ? R.string.pref_title__primary_color : R.string.pref_title__accent_color);
|
||||||
title.setTextColor(getResources().getColor(R.color.white));
|
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.setColors((type == 1 ? ColorPalette.getBaseColors(context) : ColorPalette.getAccentColors(context)));
|
||||||
base.setSelectedColor(current[0]);
|
base.setSelectedColor(current[0]);
|
||||||
shade.setColors(ColorPalette.getColors(context, current[0]));
|
shade.setColors(ColorPalette.getColors(context, current[0]));
|
||||||
|
@ -178,13 +178,13 @@ public class SettingsFragment__ThemeColors extends ThemedSettingsFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
if (type == 1) {
|
if (type == 1) {
|
||||||
appSettings.setPrimaryColorSettings(base.getColor(), shade.getColor());
|
appSettings.setPrimaryColorPickerSettings(base.getColor(), shade.getColor());
|
||||||
if (Build.VERSION.SDK_INT >= 21) {
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
getActivity().getWindow().setStatusBarColor(ThemeHelper.getPrimaryDarkColor());
|
getActivity().getWindow().setStatusBarColor(ThemeHelper.getPrimaryDarkColor());
|
||||||
}
|
}
|
||||||
((ThemedActivity) getActivity()).applyColorToViews();
|
((ThemedActivity) getActivity()).applyColorToViews();
|
||||||
} else {
|
} else {
|
||||||
appSettings.setAccentColorSettings(base.getColor(), shade.getColor());
|
appSettings.setAccentColorPickerSettings(base.getColor(), shade.getColor());
|
||||||
}
|
}
|
||||||
applyColorToViews();
|
applyColorToViews();
|
||||||
applySettingsToViews();
|
applySettingsToViews();
|
||||||
|
|
Loading…
Reference in a new issue