diff --git a/OsmAnd/res/layout/dashboard_settings_dialog_item_1.xml b/OsmAnd/res/layout/dashboard_settings_dialog_item_1.xml
index 244299b809..527597e6ad 100644
--- a/OsmAnd/res/layout/dashboard_settings_dialog_item_1.xml
+++ b/OsmAnd/res/layout/dashboard_settings_dialog_item_1.xml
@@ -4,21 +4,22 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="vertical"
- android:paddingLeft="@dimen/dialog_content_margin"
- android:paddingRight="@dimen/dialog_content_margin">
+ android:orientation="vertical">
+ android:layout_height="wrap_content"
+ android:gravity="top">
+ android:layout_marginLeft="@dimen/dialog_content_margin"
+ tools:text="@string/number_of_rows_in_dash"
+ android:layout_gravity="top"/>
+ android:gravity="center_horizontal"
+ android:text="-"/>
+ android:gravity="center_horizontal"
+ android:text="+"/>
diff --git a/OsmAnd/res/layout/dashboard_toolbar.xml b/OsmAnd/res/layout/dashboard_toolbar.xml
index 28b85ac22c..bf35bfdbbf 100644
--- a/OsmAnd/res/layout/dashboard_toolbar.xml
+++ b/OsmAnd/res/layout/dashboard_toolbar.xml
@@ -33,7 +33,7 @@
android:id="@+id/toolbar_settings"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
- android:layout_gravity="left"
+ android:layout_gravity="right"
android:background="@drawable/dashboard_button_light"
android:scaleType="center"
android:src="@drawable/ic_action_settings"/>
diff --git a/OsmAnd/res/values/attrs.xml b/OsmAnd/res/values/attrs.xml
index 942d4497f2..c7138ef1e3 100644
--- a/OsmAnd/res/values/attrs.xml
+++ b/OsmAnd/res/values/attrs.xml
@@ -32,6 +32,8 @@
+
+
diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml
index 6a18d33ced..22a4b13827 100644
--- a/OsmAnd/res/values/colors.xml
+++ b/OsmAnd/res/values/colors.xml
@@ -157,4 +157,5 @@
#ccc
#2f7af5
+ #78909c
\ No newline at end of file
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 08f4560761..bd60143fcb 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -2254,4 +2254,5 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
Description
Add opening hours
POI Type
+ Number of rows in dash %1$s
diff --git a/OsmAnd/res/values/styles.xml b/OsmAnd/res/values/styles.xml
index af343d5137..7eca519580 100644
--- a/OsmAnd/res/values/styles.xml
+++ b/OsmAnd/res/values/styles.xml
@@ -103,6 +103,8 @@
- @drawable/ic_action_mode_back
- @style/WhiteActionMode
- @color/color_white
+
+ - @color/icon_color_light
diff --git a/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java
index e86fd8da18..801c9127b1 100644
--- a/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java
@@ -1,13 +1,15 @@
package net.osmand.plus.dashboard.tools;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
+import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
+import android.support.v7.app.AlertDialog;
+import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -29,9 +31,12 @@ import java.util.List;
public class DashboardSettingsDialogFragment extends DialogFragment {
private static final String CHECKED_ITEMS = "checked_items";
+ private static final String NUMBER_OF_ROWS_ARRAY = "number_of_rows_array";
private MapActivity mapActivity;
private ArrayList mFragmentsData;
private DashFragmentAdapter mAdapter;
+ private int textColorPrimary;
+ private int textColorSecondary;
@Override
public void onAttach(Activity activity) {
@@ -48,6 +53,13 @@ public class DashboardSettingsDialogFragment extends DialogFragment {
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
+ TypedValue typedValue = new TypedValue();
+ Resources.Theme theme = getActivity().getTheme();
+ theme.resolveAttribute(android.R.attr.textColorPrimary, typedValue, true);
+ textColorPrimary = typedValue.data;
+ theme.resolveAttribute(R.attr.dialog_inactive_text_color, typedValue, true);
+ textColorSecondary = typedValue.data;
+
final OsmandSettings settings = mapActivity.getMyApplication().getSettings();
View view = LayoutInflater.from(getActivity()).inflate(
@@ -58,12 +70,13 @@ public class DashboardSettingsDialogFragment extends DialogFragment {
settings.registerBooleanPreference(MapActivity.SHOULD_SHOW_DASHBOARD_ON_START, true);
final CompoundButton compoundButton = (CompoundButton) view.findViewById(R.id.check_item);
compoundButton.setChecked(shouldShowDashboardOnStart.get());
- textView.setTextColor(shouldShowDashboardOnStart.get() ? 0xFF212121 : 0xFF8c8c8c);
+ textView.setTextColor(shouldShowDashboardOnStart.get() ? textColorPrimary
+ : textColorSecondary);
compoundButton.setOnCheckedChangeListener(
new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
- textView.setTextColor(b ? 0xFF212121 : 0xFF8c8c8c);
+ textView.setTextColor(b ? textColorPrimary : textColorSecondary);
}
});
@@ -71,7 +84,7 @@ public class DashboardSettingsDialogFragment extends DialogFragment {
if (savedInstanceState != null && savedInstanceState.containsKey(CHECKED_ITEMS)) {
mAdapter = new DashFragmentAdapter(getActivity(), mFragmentsData,
savedInstanceState.getBooleanArray(CHECKED_ITEMS),
- new int[mFragmentsData.size()]);
+ savedInstanceState.getIntArray(NUMBER_OF_ROWS_ARRAY));
} else {
mAdapter = new DashFragmentAdapter(getActivity(), mFragmentsData,
settings);
@@ -82,10 +95,15 @@ public class DashboardSettingsDialogFragment extends DialogFragment {
@Override
public void onClick(DialogInterface dialogInterface, int type) {
boolean[] shouldShow = mAdapter.getCheckedItems();
+ int[] numberOfRows = mAdapter.getNumbersOfRows();
for (int i = 0; i < shouldShow.length; i++) {
settings.registerBooleanPreference(
DashboardOnMap.SHOULD_SHOW + mFragmentsData.get(i).tag, true)
.makeGlobal().set(shouldShow[i]);
+ if (mFragmentsData.get(i).rowNumberTag != null) {
+ settings.registerIntPreference(mFragmentsData.get(i).rowNumberTag, 5)
+ .makeGlobal().set(numberOfRows[i]);
+ }
}
mapActivity.getDashboard().refreshDashboardFragments();
shouldShowDashboardOnStart.set(compoundButton.isChecked());
@@ -102,28 +120,36 @@ public class DashboardSettingsDialogFragment extends DialogFragment {
@Override
public void onSaveInstanceState(Bundle outState) {
outState.putBooleanArray(CHECKED_ITEMS, mAdapter.getCheckedItems());
+ outState.putIntArray(NUMBER_OF_ROWS_ARRAY, mAdapter.getNumbersOfRows());
super.onSaveInstanceState(outState);
}
- private static class DashFragmentAdapter extends ArrayAdapter {
+ private class DashFragmentAdapter extends ArrayAdapter {
private final boolean[] checkedItems;
private final int[] numbersOfRows;
- public DashFragmentAdapter(Context context, List objects,
- boolean[] checkedItems, int[] numbersOfRows) {
+ public DashFragmentAdapter(@NonNull Context context,
+ @NonNull List objects,
+ @NonNull boolean[] checkedItems,
+ @NonNull int[] numbersOfRows) {
super(context, 0, objects);
this.checkedItems = checkedItems;
this.numbersOfRows = numbersOfRows;
}
- public DashFragmentAdapter(Context context, List objects,
- OsmandSettings settings) {
+ public DashFragmentAdapter(@NonNull Context context,
+ @NonNull List objects,
+ @NonNull OsmandSettings settings) {
super(context, 0, objects);
numbersOfRows = new int[objects.size()];
checkedItems = new boolean[objects.size()];
for (int i = 0; i < objects.size(); i++) {
checkedItems[i] = settings.registerBooleanPreference(
DashboardOnMap.SHOULD_SHOW + objects.get(i).tag, true).makeGlobal().get();
+ if (objects.get(i).tag != null) {
+ numbersOfRows[i] = settings.registerIntPreference(objects.get(i).rowNumberTag, 5)
+ .makeGlobal().get();
+ }
}
}
@@ -140,8 +166,8 @@ public class DashboardSettingsDialogFragment extends DialogFragment {
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
DashFragmentData dashFragmentData = getItem(position);
- DashViewHolder viewHolder;
- boolean hasRows = false;//getItemViewType(position) == 1;
+ final DashViewHolder viewHolder;
+ boolean hasRows = getItemViewType(position) == 1;
if (convertView == null) {
viewHolder = new DashViewHolder();
if (hasRows) {
@@ -164,18 +190,48 @@ public class DashboardSettingsDialogFragment extends DialogFragment {
DashViewHolder localViewHolder = (DashViewHolder) compoundButton.getTag();
checkedItems[localViewHolder.position] = b;
localViewHolder.textView.setTextColor(
- checkedItems[localViewHolder.position] ? 0xFF212121
- : 0xFF8c8c8c);
+ checkedItems[localViewHolder.position] ? textColorPrimary
+ : textColorSecondary);
}
});
} else {
viewHolder = (DashViewHolder) convertView.getTag();
}
+ if (hasRows) {
+ viewHolder.incrementButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ DashViewHolder localViewHolder = (DashViewHolder) v.getTag();
+ numbersOfRows[localViewHolder.position]++;
+ viewHolder.numberOfRowsTextView.setText(
+ getString(R.string.number_of_rows_in_dash,
+ numbersOfRows[localViewHolder.position]));
+ }
+ });
+ viewHolder.incrementButton.setTag(viewHolder);
+ viewHolder.decrementButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ DashViewHolder localViewHolder = (DashViewHolder) v.getTag();
+ if (numbersOfRows[localViewHolder.position] > 1) {
+ numbersOfRows[localViewHolder.position]--;
+ }
+ viewHolder.numberOfRowsTextView.setText(
+ getString(R.string.number_of_rows_in_dash,
+ numbersOfRows[localViewHolder.position]));
+ }
+ });
+ viewHolder.decrementButton.setTag(viewHolder);
+ viewHolder.numberOfRowsTextView.setText(
+ getString(R.string.number_of_rows_in_dash,
+ numbersOfRows[position]));
+ }
viewHolder.position = position;
viewHolder.compoundButton.setTag(viewHolder);
viewHolder.compoundButton.setChecked(checkedItems[position]);
viewHolder.textView.setText(dashFragmentData.title);
- viewHolder.textView.setTextColor(checkedItems[position] ? 0xFF212121 : 0xFF8c8c8c);
+ viewHolder.textView.setTextColor(checkedItems[position] ? textColorPrimary :
+ textColorSecondary);
convertView.setTag(viewHolder);
return convertView;
}
@@ -184,6 +240,10 @@ public class DashboardSettingsDialogFragment extends DialogFragment {
return checkedItems;
}
+ public int[] getNumbersOfRows() {
+ return numbersOfRows;
+ }
+
private class DashViewHolder {
TextView textView;
CompoundButton compoundButton;