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 501df77c..70bf8c77 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 @@ -24,8 +24,6 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.CheckBox; -import android.widget.RelativeLayout; import android.widget.TextView; import com.github.dfa.diaspora_android.R; @@ -84,8 +82,6 @@ public class SettingsFragment__Debugging extends ThemedSettingsFragment { @Override public void onClick(View view) { - switch (view.getId()) { - } } } 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 a2061eb5..cc855dfb 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 @@ -24,8 +24,6 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.CheckBox; -import android.widget.RelativeLayout; import android.widget.TextView; import com.github.dfa.diaspora_android.R; @@ -40,7 +38,7 @@ import butterknife.ButterKnife; * Created by vanitas on 16.10.16. */ -public class SettingsFragment__NavigationSlider extends ThemedFragment { +public class SettingsFragment__NavigationSlider extends ThemedSettingsFragment { public static final String TAG = "com.github.dfa.diaspora_android.SettingsFragment__NavigationSlider"; @BindView(R.id.settings_activity__header_appearance__nav_slider) @@ -73,4 +71,16 @@ public class SettingsFragment__NavigationSlider extends ThemedFragment { public boolean onBackPressed() { return false; } + + @Override + protected void applySettingsToViews() { + } + + @Override + protected void setOnClickListenersOnViews() { + } + + @Override + public void onClick(View view) { + } } 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 440309dc..80ca76a4 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 @@ -19,23 +19,20 @@ 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; -import android.text.InputType; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CompoundButton; -import android.widget.EditText; -import android.widget.RelativeLayout; import android.widget.TextView; +import android.widget.Toast; import com.github.dfa.diaspora_android.R; import com.github.dfa.diaspora_android.ui.ThemedCheckBoxPreference; import com.github.dfa.diaspora_android.ui.ThemedIntEditTextPreference; +import com.github.dfa.diaspora_android.ui.ThemedPreference; import com.github.dfa.diaspora_android.ui.ThemedStringEditTextPreference; import com.github.dfa.diaspora_android.util.AppLog; import com.github.dfa.diaspora_android.util.theming.ThemeHelper; @@ -64,7 +61,7 @@ public class SettingsFragment__Proxy extends ThemedSettingsFragment { protected ThemedIntEditTextPreference editTextProxyPort; @BindView(R.id.settings_activity__proxy_orbot_preset) - protected RelativeLayout optionProxyOrbotPreset; + protected ThemedPreference optionProxyOrbotPreset; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -83,7 +80,6 @@ public class SettingsFragment__Proxy extends ThemedSettingsFragment { @Override protected void applySettingsToViews() { boolean enabled = getAppSettings().isProxyHttpEnabled(); - editTextProxyHost.setVisibility(enabled ? View.VISIBLE : View.GONE); editTextProxyHost.setEnabled(enabled); editTextProxyPort.setVisibility(enabled ? View.VISIBLE : View.GONE); @@ -112,6 +108,7 @@ public class SettingsFragment__Proxy extends ThemedSettingsFragment { AppLog.d(this, "Clicked: Proxy Preset"); editTextProxyHost.setValue("localhost"); editTextProxyPort.setValue(8118); + Toast.makeText(getContext(), R.string.toast__proxy_orbot_preset_set, Toast.LENGTH_SHORT).show(); break; } } 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 2ba8bcb3..2af9be37 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 @@ -38,20 +38,20 @@ public class ThemedCheckBoxPreference extends RelativeLayout implements ThemedPr public ThemedCheckBoxPreference(Context context) { super(context); - init(context, null); + init(context, null, 0); } public ThemedCheckBoxPreference(Context context, AttributeSet attrs) { super(context, attrs); - init(context, attrs); + init(context, attrs, 0); } public ThemedCheckBoxPreference(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); - init(context, attrs); + init(context, attrs, defStyle); } - protected void init(Context context, AttributeSet attrs) { + protected void init(Context context, AttributeSet attrs, int defStyle) { appSettings = new AppSettings(context.getApplicationContext()); View.inflate(context, R.layout.preference__themed_checkbox, this); ButterKnife.bind(this); @@ -68,10 +68,7 @@ public class ThemedCheckBoxPreference extends RelativeLayout implements ThemedPr String titleText = ""; String summaryText = ""; - TypedArray a = context.getTheme().obtainStyledAttributes( - attrs, - R.styleable.ThemedCheckBoxPreference, - 0, 0); + TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ThemedCheckBoxPreference, defStyle, 0); try { titleText = a.getString(R.styleable.ThemedCheckBoxPreference_titleText); summaryText = a.getString(R.styleable.ThemedCheckBoxPreference_summaryText); diff --git a/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedIntEditTextPreference.java b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedIntEditTextPreference.java index 691b94bc..50fc7e44 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedIntEditTextPreference.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedIntEditTextPreference.java @@ -62,10 +62,7 @@ public class ThemedIntEditTextPreference extends LinearLayout implements ThemedP String titleText = ""; String summaryText = ""; - TypedArray a = context.obtainStyledAttributes( - attrs, - R.styleable.ThemedIntEditTextPreference, - defStyle, 0); + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ThemedIntEditTextPreference, defStyle, 0); try { titleText = a.getString(R.styleable.ThemedIntEditTextPreference_titleText); summaryText = a.getString(R.styleable.ThemedIntEditTextPreference_summaryText); diff --git a/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedPreference.java b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedPreference.java index 5d838fbb..710ef7fb 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedPreference.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedPreference.java @@ -2,9 +2,11 @@ package com.github.dfa.diaspora_android.ui; import android.content.Context; import android.content.res.TypedArray; +import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.view.View; -import android.widget.LinearLayout; +import android.widget.ImageView; +import android.widget.RelativeLayout; import android.widget.TextView; import com.github.dfa.diaspora_android.R; @@ -18,12 +20,14 @@ import butterknife.ButterKnife; * Created by vanitas on 23.10.16. */ -public class ThemedPreference extends LinearLayout implements ThemedPreferenceObject { +public class ThemedPreference extends RelativeLayout implements ThemedPreferenceObject { @BindView(R.id.preference__themed_preference_title) protected TextView title; @BindView(R.id.preference__themed_preference_summary) protected TextView summary; + @BindView(R.id.preference__themed_preference_image) + protected ImageView image; protected String prefKey; @@ -48,11 +52,13 @@ public class ThemedPreference extends LinearLayout implements ThemedPreferenceOb if (attrs != null) { String titleText = ""; String summaryText = ""; + Drawable imageDrawable = null; TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ThemedPreference, defStyle, 0); try { titleText = a.getString(R.styleable.ThemedPreference_titleText); summaryText = a.getString(R.styleable.ThemedPreference_summaryText); prefKey = a.getString(R.styleable.ThemedPreference_prefKey); + imageDrawable = a.getDrawable(R.styleable.ThemedPreference_image); } catch (Exception e) { AppLog.e(this, "There was an error loading attributes."); } finally { @@ -60,6 +66,7 @@ public class ThemedPreference extends LinearLayout implements ThemedPreferenceOb } setTitleText(titleText); setSummaryText(summaryText); + setImageDrawable(imageDrawable); } } @@ -88,6 +95,16 @@ public class ThemedPreference extends LinearLayout implements ThemedPreferenceOb } } + public void setImageDrawable(Drawable drawable) { + if(drawable != null) { + image.setImageDrawable(drawable); + image.setVisibility(VISIBLE); + } else { + image.setImageDrawable(null); + image.setVisibility(GONE); + } + } + @Override public Void getDefaultValue() { return null; diff --git a/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedPreferenceObject.java b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedPreferenceObject.java index 23a9090f..a0218fcb 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedPreferenceObject.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedPreferenceObject.java @@ -1,6 +1,7 @@ package com.github.dfa.diaspora_android.ui; /** + * Basic methods a ThemedPreference class should implement * Created by vanitas on 23.10.16. */ diff --git a/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedStringEditTextPreference.java b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedStringEditTextPreference.java index 58eb93cc..39686dbe 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedStringEditTextPreference.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/ThemedStringEditTextPreference.java @@ -62,10 +62,7 @@ public class ThemedStringEditTextPreference extends LinearLayout implements Them String titleText = ""; String summaryText = ""; - TypedArray a = context.obtainStyledAttributes( - attrs, - R.styleable.ThemedStringEditTextPreference, - defStyle, 0); + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ThemedStringEditTextPreference, defStyle, 0); try { titleText = a.getString(R.styleable.ThemedStringEditTextPreference_titleText); summaryText = a.getString(R.styleable.ThemedStringEditTextPreference_summaryText); diff --git a/app/src/main/res/layout/preference__themed_preference.xml b/app/src/main/res/layout/preference__themed_preference.xml index 1c0296e2..6df4399d 100644 --- a/app/src/main/res/layout/preference__themed_preference.xml +++ b/app/src/main/res/layout/preference__themed_preference.xml @@ -1,18 +1,31 @@ - - - - \ No newline at end of file + android:layout_alignParentStart="true" + android:layout_marginEnd="@dimen/activity_horizontal_margin" + android:layout_centerVertical="true" /> + + + + + \ No newline at end of file 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 ce9f6589..c6abf4fa 100644 --- a/app/src/main/res/layout/settings_activity__subsection_proxy.xml +++ b/app/src/main/res/layout/settings_activity__subsection_proxy.xml @@ -59,38 +59,13 @@ app:prefKey="@string/pref_key__http_proxy_port"/> - - - - - - - + app:titleText="@string/pref_title__http_proxy_load_tor_preset" + app:summaryText="@string/pref_desc__http_proxy_load_tor_preset" + app:image="@drawable/tor_onion"/> diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 9d7f9e2a..0f94c192 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -32,5 +32,6 @@ + \ No newline at end of file diff --git a/app/src/main/res/values/strings-preferences.xml b/app/src/main/res/values/strings-preferences.xml index dafbf2ff..c72c60ea 100644 --- a/app/src/main/res/values/strings-preferences.xml +++ b/app/src/main/res/values/strings-preferences.xml @@ -112,6 +112,7 @@ Port HTTP SOCKS5 + Orbot proxy settings applied