mirror of
https://github.com/gsantner/dandelion
synced 2024-11-24 21:32:07 +01:00
Merged Master
This commit is contained in:
commit
4562bc26a5
5 changed files with 93 additions and 13 deletions
|
@ -22,6 +22,7 @@ import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.design.widget.Snackbar;
|
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.AppLog;
|
||||||
import com.github.dfa.diaspora_android.util.DiasporaUrlHelper;
|
import com.github.dfa.diaspora_android.util.DiasporaUrlHelper;
|
||||||
import com.github.dfa.diaspora_android.util.Helpers;
|
import com.github.dfa.diaspora_android.util.Helpers;
|
||||||
|
import com.github.dfa.diaspora_android.util.theming.ThemeHelper;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -66,7 +68,7 @@ import butterknife.OnClick;
|
||||||
* Created by vanitas on 01.10.16.
|
* 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";
|
public static final String TAG = "com.github.dfa.diaspora_android.PodSelectionFragment";
|
||||||
|
|
||||||
@BindView(R.id.podselection__fragment__listpods)
|
@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
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
|
@ -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.AppSettings;
|
||||||
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.fragment.ThemedAppCompatDialogFragment;
|
||||||
import com.github.dfa.diaspora_android.util.ProxyHandler;
|
import com.github.dfa.diaspora_android.util.ProxyHandler;
|
||||||
|
import com.github.dfa.diaspora_android.util.theming.ThemeHelper;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
|
||||||
|
@ -35,7 +37,7 @@ import butterknife.OnItemSelected;
|
||||||
/**
|
/**
|
||||||
* Created by gsantner (https://gsantner.github.io) on 06.10.16.
|
* 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 final String TAG = "com.github.dfa.diaspora_android.PodSelectionDialog";
|
||||||
|
|
||||||
public static interface PodSelectionDialogResultListener {
|
public static interface PodSelectionDialogResultListener {
|
||||||
|
@ -65,7 +67,7 @@ public class PodSelectionDialog extends AppCompatDialogFragment {
|
||||||
@BindView(R.id.podselection__dialog__edit_podaddress)
|
@BindView(R.id.podselection__dialog__edit_podaddress)
|
||||||
EditText editPodAddress;
|
EditText editPodAddress;
|
||||||
|
|
||||||
@BindView(R.id.podselection__dialog__edit_podname)
|
@BindView(R.id.podselection__dialog__edit_pod_name)
|
||||||
EditText editPodName;
|
EditText editPodName;
|
||||||
|
|
||||||
@BindView(R.id.podselection__dialog__radiogroup_protocol)
|
@BindView(R.id.podselection__dialog__radiogroup_protocol)
|
||||||
|
@ -83,6 +85,15 @@ public class PodSelectionDialog extends AppCompatDialogFragment {
|
||||||
@BindView(R.id.podselection__dialog__text_torpreset)
|
@BindView(R.id.podselection__dialog__text_torpreset)
|
||||||
TextView textTorPreset;
|
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 PodSelectionDialogResultListener resultListener;
|
||||||
private View root;
|
private View root;
|
||||||
private DiasporaPod pod = new DiasporaPod();
|
private DiasporaPod pod = new DiasporaPod();
|
||||||
|
@ -112,11 +123,31 @@ public class PodSelectionDialog extends AppCompatDialogFragment {
|
||||||
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
spinnerProfile.setAdapter(spinnerAdapter);
|
spinnerProfile.setAdapter(spinnerAdapter);
|
||||||
}
|
}
|
||||||
|
applyColorsToViews();
|
||||||
builder.setView(root);
|
builder.setView(root);
|
||||||
return builder.create();
|
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)
|
@OnItemSelected(R.id.podselection__dialog__spinner_profile)
|
||||||
public void spinnerItemSelected(Spinner spinner, int position) {
|
public void spinnerItemSelected(Spinner spinner, int position) {
|
||||||
uiLoadDiasporaUrl(position);
|
uiLoadDiasporaUrl(position);
|
||||||
|
|
|
@ -20,30 +20,27 @@
|
||||||
package com.github.dfa.diaspora_android.util.theming;
|
package com.github.dfa.diaspora_android.util.theming;
|
||||||
|
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Build;
|
||||||
import android.support.design.widget.TabLayout;
|
import android.support.design.widget.TabLayout;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v4.widget.CompoundButtonCompat;
|
import android.support.v4.widget.CompoundButtonCompat;
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.support.v7.widget.ActionMenuView;
|
import android.support.v7.widget.ActionMenuView;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.RadioButton;
|
||||||
|
import android.widget.RadioGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.github.dfa.diaspora_android.App;
|
|
||||||
import com.github.dfa.diaspora_android.R;
|
import com.github.dfa.diaspora_android.R;
|
||||||
import com.github.dfa.diaspora_android.data.AppSettings;
|
import com.github.dfa.diaspora_android.data.AppSettings;
|
||||||
import com.github.dfa.diaspora_android.util.AppLog;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Singleton that can be used to color views
|
* Singleton that can be used to color views
|
||||||
|
@ -74,6 +71,9 @@ public class ThemeHelper {
|
||||||
public static void updateEditTextColor(EditText editText) {
|
public static void updateEditTextColor(EditText editText) {
|
||||||
if (editText != null) {
|
if (editText != null) {
|
||||||
editText.setHighlightColor(getInstance().appSettings.getAccentColor());
|
editText.setHighlightColor(getInstance().appSettings.getAccentColor());
|
||||||
|
if(Build.VERSION.SDK_INT >= 21) {
|
||||||
|
editText.getBackground().mutate().setColorFilter(getAccentColor(), PorterDuff.Mode.SRC_ATOP);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,6 +163,18 @@ public class ThemeHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
public static void updatePrimaryColorPreview(ImageView imageView) {
|
||||||
if(imageView != null) {
|
if(imageView != null) {
|
||||||
Drawable circle = imageView.getDrawable();
|
Drawable circle = imageView.getDrawable();
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/podselection__dialog__text_pod_name"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="@dimen/activity_horizontal_margin_half"
|
android:layout_marginTop="@dimen/activity_horizontal_margin_half"
|
||||||
|
@ -37,7 +38,7 @@
|
||||||
android:textAppearance="@style/AppTheme.TextAppearance.Caption" />
|
android:textAppearance="@style/AppTheme.TextAppearance.Caption" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/podselection__dialog__edit_podname"
|
android:id="@+id/podselection__dialog__edit_pod_name"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="@dimen/activity_horizontal_margin_half"
|
android:layout_marginStart="@dimen/activity_horizontal_margin_half"
|
||||||
|
@ -48,6 +49,7 @@
|
||||||
tools:text="Geraspora" />
|
tools:text="Geraspora" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/podselection__dialog__text_pod_address"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="@dimen/activity_horizontal_margin_half"
|
android:layout_marginTop="@dimen/activity_horizontal_margin_half"
|
||||||
|
@ -66,6 +68,7 @@
|
||||||
tools:text="pod.geraspora.de" />
|
tools:text="pod.geraspora.de" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/podselection__dialog__text_protocol"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="@dimen/activity_horizontal_margin_half"
|
android:layout_marginTop="@dimen/activity_horizontal_margin_half"
|
||||||
|
|
Loading…
Reference in a new issue