Colors refactoring
This commit is contained in:
parent
f0f4f445e3
commit
577d7a3a44
2 changed files with 63 additions and 43 deletions
|
@ -9,33 +9,43 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingLeft="26dp"
|
android:paddingTop="@dimen/content_padding"
|
||||||
android:paddingRight="16dp"
|
|
||||||
android:paddingTop="18dp"
|
|
||||||
android:paddingBottom="16dp"
|
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
|
||||||
android:id="@+id/title"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
|
||||||
android:textSize="@dimen/dialog_header_text_size"
|
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
|
||||||
tools:text="Food"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/description"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
|
||||||
android:text="@string/subcategories"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="16dp"
|
android:paddingLeft="@dimen/card_content_padding_large"
|
||||||
|
android:paddingRight="@dimen/content_padding"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:textSize="@dimen/dialog_header_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
tools:text="Food"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/description"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
android:text="@string/subcategories"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/buttonContainer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="@dimen/card_content_padding_large"
|
||||||
|
android:paddingRight="@dimen/content_padding"
|
||||||
|
android:paddingTop="@dimen/content_padding_half"
|
||||||
|
android:paddingBottom="@dimen/content_padding_half"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
|
@ -23,9 +23,9 @@ import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import net.osmand.osm.PoiCategory;
|
import net.osmand.osm.PoiCategory;
|
||||||
import net.osmand.osm.PoiType;
|
import net.osmand.osm.PoiType;
|
||||||
|
import net.osmand.plus.DialogListItemAdapter;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
@ -59,8 +59,7 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
||||||
private TextView barTitle;
|
private TextView barTitle;
|
||||||
private TextView barButton;
|
private TextView barButton;
|
||||||
private boolean editMode;
|
private boolean editMode;
|
||||||
private boolean isLightTheme;
|
private boolean nightMode;
|
||||||
|
|
||||||
|
|
||||||
public QuickSearchCustomPoiFragment() {
|
public QuickSearchCustomPoiFragment() {
|
||||||
}
|
}
|
||||||
|
@ -72,10 +71,8 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
isLightTheme =
|
this.nightMode = getMyApplication().getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_DARK_THEME;
|
||||||
getMyApplication().getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
|
setStyle(STYLE_NO_FRAME, nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme);
|
||||||
int themeId = isLightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
|
|
||||||
setStyle(STYLE_NO_FRAME, themeId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -101,7 +98,7 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
||||||
|
|
||||||
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
|
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
|
||||||
Drawable icClose = app.getUIUtilities().getIcon(R.drawable.ic_action_remove_dark,
|
Drawable icClose = app.getUIUtilities().getIcon(R.drawable.ic_action_remove_dark,
|
||||||
isLightTheme ? R.color.active_buttons_and_links_text_light : R.color.active_buttons_and_links_text_dark);
|
nightMode ? R.color.active_buttons_and_links_text_dark : R.color.active_buttons_and_links_text_light);
|
||||||
toolbar.setNavigationIcon(icClose);
|
toolbar.setNavigationIcon(icClose);
|
||||||
toolbar.setNavigationContentDescription(R.string.shared_string_close);
|
toolbar.setNavigationContentDescription(R.string.shared_string_close);
|
||||||
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -110,8 +107,8 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
toolbar.setBackgroundColor(ContextCompat.getColor(app, isLightTheme ? R.color.app_bar_color_light : R.color.app_bar_color_dark));
|
toolbar.setBackgroundColor(ContextCompat.getColor(app, nightMode ? R.color.app_bar_color_dark : R.color.app_bar_color_light));
|
||||||
toolbar.setTitleTextColor(ContextCompat.getColor(app, isLightTheme ? R.color.active_buttons_and_links_text_light : R.color.active_buttons_and_links_text_dark));
|
toolbar.setTitleTextColor(ContextCompat.getColor(app, nightMode ? R.color.active_buttons_and_links_text_dark : R.color.active_buttons_and_links_text_light));
|
||||||
|
|
||||||
TextView title = (TextView) view.findViewById(R.id.title);
|
TextView title = (TextView) view.findViewById(R.id.title);
|
||||||
if (editMode) {
|
if (editMode) {
|
||||||
|
@ -254,6 +251,7 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
||||||
AppCompatTextView titleView = (AppCompatTextView) row.findViewById(R.id.title);
|
AppCompatTextView titleView = (AppCompatTextView) row.findViewById(R.id.title);
|
||||||
AppCompatTextView descView = (AppCompatTextView) row.findViewById(R.id.description);
|
AppCompatTextView descView = (AppCompatTextView) row.findViewById(R.id.description);
|
||||||
SwitchCompat check = (SwitchCompat) row.findViewById(R.id.toggle_item);
|
SwitchCompat check = (SwitchCompat) row.findViewById(R.id.toggle_item);
|
||||||
|
UiUtilities.setupCompoundButton(check, nightMode, UiUtilities.CompoundButtonType.GLOBAL);
|
||||||
|
|
||||||
boolean categorySelected = filter.isTypeAccepted(category);
|
boolean categorySelected = filter.isTypeAccepted(category);
|
||||||
UiUtilities ic = app.getUIUtilities();
|
UiUtilities ic = app.getUIUtilities();
|
||||||
|
@ -268,8 +266,8 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
||||||
iconView.setImageDrawable(null);
|
iconView.setImageDrawable(null);
|
||||||
}
|
}
|
||||||
secondaryIconView.setImageDrawable(
|
secondaryIconView.setImageDrawable(
|
||||||
ic.getIcon(R.drawable.ic_action_additional_option,
|
ic.getIcon(R.drawable.ic_action_additional_option, nightMode
|
||||||
app.getSettings().isLightContent() ? R.color.icon_color_default_dark : 0));
|
? R.color.icon_color_default_dark : R.color.icon_color_default_light));
|
||||||
check.setOnCheckedChangeListener(null);
|
check.setOnCheckedChangeListener(null);
|
||||||
check.setChecked(filter.isTypeAccepted(category));
|
check.setChecked(filter.isTypeAccepted(category));
|
||||||
String textString = category.getTranslation();
|
String textString = category.getTranslation();
|
||||||
|
@ -388,8 +386,16 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
||||||
.inflate(R.layout.subcategories_dialog_title, null);
|
.inflate(R.layout.subcategories_dialog_title, null);
|
||||||
TextView titleTextView = (TextView) titleView.findViewById(R.id.title);
|
TextView titleTextView = (TextView) titleView.findViewById(R.id.title);
|
||||||
titleTextView.setText(poiCategory.getTranslation());
|
titleTextView.setText(poiCategory.getTranslation());
|
||||||
SwitchCompat check = (SwitchCompat) titleView.findViewById(R.id.check);
|
View toggleButtonContainer = titleView.findViewById(R.id.buttonContainer);
|
||||||
check.setChecked(allSelected);
|
final CompoundButton selectAllToggle = (CompoundButton) toggleButtonContainer.findViewById(R.id.check);
|
||||||
|
UiUtilities.setupCompoundButton(selectAllToggle, nightMode, UiUtilities.CompoundButtonType.GLOBAL);
|
||||||
|
toggleButtonContainer.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
selectAllToggle.setChecked(!selectAllToggle.isChecked());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
selectAllToggle.setChecked(allSelected);
|
||||||
builder.setCustomTitle(titleView);
|
builder.setCustomTitle(titleView);
|
||||||
|
|
||||||
builder.setCancelable(true);
|
builder.setCancelable(true);
|
||||||
|
@ -424,17 +430,20 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
||||||
listView.setSelectionFromTop(index, top);
|
listView.setSelectionFromTop(index, top);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
int activeColor = ContextCompat.getColor(getMyApplication(), nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light);
|
||||||
builder.setMultiChoiceItems(visibleNames, selected,
|
int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
new DialogInterface.OnMultiChoiceClickListener() {
|
final DialogListItemAdapter adapter = DialogListItemAdapter.createMultiChoiceAdapter(visibleNames,
|
||||||
|
nightMode, selected, getMyApplication(), activeColor, themeRes, new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int item, boolean isChecked) {
|
public void onClick(View v) {
|
||||||
selected[item] = isChecked;
|
int which = (int) v.getTag();
|
||||||
|
selected[which] = !selected[which];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
builder.setAdapter(adapter, null);
|
||||||
final AlertDialog dialog = builder.show();
|
final AlertDialog dialog = builder.show();
|
||||||
check.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
adapter.setDialog(dialog);
|
||||||
|
selectAllToggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
|
@ -445,6 +454,7 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
||||||
for (int i = 0; i < selected.length; i++) {
|
for (int i = 0; i < selected.length; i++) {
|
||||||
dialog.getListView().setItemChecked(i, selected[i]);
|
dialog.getListView().setItemChecked(i, selected[i]);
|
||||||
}
|
}
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue