1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-11-24 21:32:07 +01:00

Cleaned up and removed unused methods

This commit is contained in:
vanitasvitae 2016-10-21 21:21:51 +02:00
parent a5669635e2
commit 8d8bbf4b50
Signed by: vanitasvitae
GPG key ID: DCCFB3302C9E4615
5 changed files with 22 additions and 38 deletions

View file

@ -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))

View file

@ -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;
}

View file

@ -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()");

View file

@ -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);

View file

@ -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();