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

Merged Master

This commit is contained in:
vanitasvitae 2016-10-22 23:36:10 +02:00
commit 4562bc26a5
Signed by: vanitasvitae
GPG key ID: DCCFB3302C9E4615
5 changed files with 93 additions and 13 deletions

View file

@ -22,6 +22,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
@ -51,6 +52,7 @@ import com.github.dfa.diaspora_android.ui.PodSelectionDialog;
import com.github.dfa.diaspora_android.util.AppLog;
import com.github.dfa.diaspora_android.util.DiasporaUrlHelper;
import com.github.dfa.diaspora_android.util.Helpers;
import com.github.dfa.diaspora_android.util.theming.ThemeHelper;
import org.json.JSONException;
import org.json.JSONObject;
@ -66,7 +68,7 @@ import butterknife.OnClick;
* Created by vanitas on 01.10.16.
*/
public class PodSelectionFragment extends CustomFragment implements SearchView.OnQueryTextListener, PodSelectionDialog.PodSelectionDialogResultListener {
public class PodSelectionFragment extends ThemedFragment implements SearchView.OnQueryTextListener, PodSelectionDialog.PodSelectionDialogResultListener {
public static final String TAG = "com.github.dfa.diaspora_android.PodSelectionFragment";
@BindView(R.id.podselection__fragment__listpods)
@ -155,6 +157,11 @@ public class PodSelectionFragment extends CustomFragment implements SearchView.O
}
};
@Override
protected void applyColorToViews() {
/* Not really anything to do. Maybe later */
}
@Override
public void onResume() {
super.onResume();

View file

@ -0,0 +1,27 @@
package com.github.dfa.diaspora_android.fragment;
import android.app.Dialog;
import android.os.Bundle;
import android.support.v7.app.AppCompatDialogFragment;
import com.github.dfa.diaspora_android.data.AppSettings;
import com.github.dfa.diaspora_android.util.theming.ThemeHelper;
/**
* Themed DialogFragment
* Created by vanitas on 22.10.16.
*/
public abstract class ThemedAppCompatDialogFragment extends AppCompatDialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
ThemeHelper.getInstance(getAppSettings());
return dialog;
}
protected abstract void applyColorsToViews();
protected abstract AppSettings getAppSettings();
}

View file

@ -21,7 +21,9 @@ import com.github.dfa.diaspora_android.R;
import com.github.dfa.diaspora_android.data.AppSettings;
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.fragment.ThemedAppCompatDialogFragment;
import com.github.dfa.diaspora_android.util.ProxyHandler;
import com.github.dfa.diaspora_android.util.theming.ThemeHelper;
import org.json.JSONException;
@ -35,7 +37,7 @@ import butterknife.OnItemSelected;
/**
* Created by gsantner (https://gsantner.github.io) on 06.10.16.
*/
public class PodSelectionDialog extends AppCompatDialogFragment {
public class PodSelectionDialog extends ThemedAppCompatDialogFragment {
public static final String TAG = "com.github.dfa.diaspora_android.PodSelectionDialog";
public static interface PodSelectionDialogResultListener {
@ -65,7 +67,7 @@ public class PodSelectionDialog extends AppCompatDialogFragment {
@BindView(R.id.podselection__dialog__edit_podaddress)
EditText editPodAddress;
@BindView(R.id.podselection__dialog__edit_podname)
@BindView(R.id.podselection__dialog__edit_pod_name)
EditText editPodName;
@BindView(R.id.podselection__dialog__radiogroup_protocol)
@ -83,6 +85,15 @@ public class PodSelectionDialog extends AppCompatDialogFragment {
@BindView(R.id.podselection__dialog__text_torpreset)
TextView textTorPreset;
@BindView(R.id.podselection__dialog__text_pod_name)
TextView textPodName;
@BindView(R.id.podselection__dialog__text_pod_address)
TextView textPodAddress;
@BindView(R.id.podselection__dialog__text_protocol)
TextView textProtocol;
private PodSelectionDialogResultListener resultListener;
private View root;
private DiasporaPod pod = new DiasporaPod();
@ -112,11 +123,31 @@ public class PodSelectionDialog extends AppCompatDialogFragment {
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerProfile.setAdapter(spinnerAdapter);
}
applyColorsToViews();
builder.setView(root);
return builder.create();
}
protected void applyColorsToViews() {
ThemeHelper.getInstance(app.getSettings());
ThemeHelper.updateTitleColor(textPodAddress);
ThemeHelper.updateTitleColor(textPodName);
ThemeHelper.updateTitleColor(textProfile);
ThemeHelper.updateTitleColor(textProtocol);
ThemeHelper.updateTitleColor(textTorPreset);
ThemeHelper.updateEditTextColor(editPodAddress);
ThemeHelper.updateEditTextColor(editPodName);
ThemeHelper.updateCheckBoxColor(checkboxTorPreset);
ThemeHelper.updateRadioGroupColor(radiogrpProtocol);
}
@Override
protected AppSettings getAppSettings() {
return app.getSettings();
}
@OnItemSelected(R.id.podselection__dialog__spinner_profile)
public void spinnerItemSelected(Spinner spinner, int position) {
uiLoadDiasporaUrl(position);

View file

@ -20,30 +20,27 @@
package com.github.dfa.diaspora_android.util.theming;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.design.widget.TabLayout;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.CompoundButtonCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.ActionMenuView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import com.github.dfa.diaspora_android.App;
import com.github.dfa.diaspora_android.R;
import com.github.dfa.diaspora_android.data.AppSettings;
import com.github.dfa.diaspora_android.util.AppLog;
/**
* Singleton that can be used to color views
@ -74,6 +71,9 @@ public class ThemeHelper {
public static void updateEditTextColor(EditText editText) {
if (editText != null) {
editText.setHighlightColor(getInstance().appSettings.getAccentColor());
if(Build.VERSION.SDK_INT >= 21) {
editText.getBackground().mutate().setColorFilter(getAccentColor(), PorterDuff.Mode.SRC_ATOP);
}
}
}
@ -154,15 +154,27 @@ public class ThemeHelper {
}
public static void updateAccentColorPreview(ImageView imageView) {
if(imageView != null) {
if (imageView != null) {
Drawable circle = imageView.getDrawable();
if(circle != null) {
if (circle != null) {
circle.setColorFilter(getAccentColor(), PorterDuff.Mode.SRC_ATOP);
imageView.setImageDrawable(circle);
}
}
}
public static void updateRadioGroupColor(RadioGroup radioGroup) {
if(radioGroup != null && Build.VERSION.SDK_INT >= 21) {
for (int i = 0; i < radioGroup.getChildCount(); ++i) {
RadioButton btn = ((RadioButton) radioGroup.getChildAt(i));
btn.setButtonTintList(new ColorStateList(
new int[][]{ new int[]{-android.R.attr.state_enabled}, new int[]{android.R.attr.state_enabled} },
new int[] { Color.BLACK ,ThemeHelper.getAccentColor() }));
btn.invalidate();
}
}
}
public static void updatePrimaryColorPreview(ImageView imageView) {
if(imageView != null) {
Drawable circle = imageView.getDrawable();

View file

@ -30,6 +30,7 @@
android:visibility="gone" />
<TextView
android:id="@+id/podselection__dialog__text_pod_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_horizontal_margin_half"
@ -37,7 +38,7 @@
android:textAppearance="@style/AppTheme.TextAppearance.Caption" />
<EditText
android:id="@+id/podselection__dialog__edit_podname"
android:id="@+id/podselection__dialog__edit_pod_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/activity_horizontal_margin_half"
@ -48,6 +49,7 @@
tools:text="Geraspora" />
<TextView
android:id="@+id/podselection__dialog__text_pod_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_horizontal_margin_half"
@ -66,6 +68,7 @@
tools:text="pod.geraspora.de" />
<TextView
android:id="@+id/podselection__dialog__text_protocol"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_horizontal_margin_half"