Commit change color dialog
This commit is contained in:
parent
658de3c710
commit
8e79a46beb
5 changed files with 77 additions and 15 deletions
|
@ -1,7 +1,44 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent" >
|
||||
<Spinner android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/Format" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" ></Spinner>
|
||||
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="7dp"
|
||||
android:paddingRight="7dp"
|
||||
android:stretchColumns="1" >
|
||||
|
||||
</LinearLayout>
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/visible_element" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/Visibility"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
/>
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/osmo_edit_color" >
|
||||
</TextView>
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/ColorSpinner"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp" >
|
||||
</Spinner>
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
|
@ -9,7 +9,7 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
|
||||
<string name="visible_element">Visible</string>
|
||||
<string name="show_zoom_buttons_navigation_descr">Show zoom buttons during navigation</string>
|
||||
<string name="show_zoom_buttons_navigation">Show zoom buttons</string>
|
||||
<string name="save_as_favorites_points">Save as group of favorites</string>
|
||||
|
|
|
@ -249,7 +249,7 @@ public class FavouritesDbHelper {
|
|||
pt.getExtensionsToWrite().put(HIDDEN, "true");
|
||||
}
|
||||
if(p.getColor() != 0) {
|
||||
pt.getColor(p.getColor());
|
||||
pt.setColor(p.getColor());
|
||||
}
|
||||
pt.name = p.getName();
|
||||
if (p.getCategory().length() > 0)
|
||||
|
@ -346,6 +346,24 @@ public class FavouritesDbHelper {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void editFavouriteGroup(FavoriteGroup group, int color, boolean visible) {
|
||||
if(color != 0 && group.color != color) {
|
||||
FavoriteGroup gr = flatGroups.get(group.name);
|
||||
group.color = color;
|
||||
for(FavouritePoint p : gr.points) {
|
||||
p.setColor(color);
|
||||
}
|
||||
}
|
||||
if(group.visible != visible) {
|
||||
FavoriteGroup gr = flatGroups.get(group.name);
|
||||
group.visible = visible;
|
||||
for(FavouritePoint p : gr.points) {
|
||||
p.setVisible(visible);
|
||||
}
|
||||
}
|
||||
saveCurrentPointsIntoFile();
|
||||
}
|
||||
|
||||
protected void createDefaultCategories() {
|
||||
addEmptyCategory(context.getString(R.string.favorite_home_category));
|
||||
|
@ -553,4 +571,7 @@ public class FavouritesDbHelper {
|
|||
return singleFavourite;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import android.app.AlertDialog.Builder;
|
|||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.text.Spannable;
|
||||
|
@ -42,7 +43,6 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.CheckBox;
|
||||
|
@ -54,7 +54,6 @@ import android.widget.ImageView;
|
|||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.AdapterView.OnItemSelectedListener;
|
||||
|
||||
import com.actionbarsherlock.view.ActionMode;
|
||||
import com.actionbarsherlock.view.ActionMode.Callback;
|
||||
|
@ -455,14 +454,15 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
|
|||
|
||||
}
|
||||
|
||||
protected void openChangeGroupDialog(FavoriteGroup group) {
|
||||
protected void openChangeGroupDialog(final FavoriteGroup group) {
|
||||
Builder bld = new AlertDialog.Builder(getActivity());
|
||||
View favEdit = getActivity().getLayoutInflater().inflate(R.layout.fav_group_edit, null);
|
||||
final Spinner colorSpinner = (Spinner) favEdit.findViewById(R.id.ColorSpinner);
|
||||
final TIntArrayList list = new TIntArrayList();
|
||||
ColorDialogs.setupColorSpinner(getActivity(), group.color, colorSpinner, list);
|
||||
final int intColor = group.color == 0? getResources().getColor(R.color.color_favorite) : group.color;
|
||||
ColorDialogs.setupColorSpinner(getActivity(), intColor, colorSpinner, list);
|
||||
|
||||
CheckBox checkBox = (CheckBox) favEdit.findViewById(R.id.Visibility);
|
||||
final CheckBox checkBox = (CheckBox) favEdit.findViewById(R.id.Visibility);
|
||||
checkBox.setChecked(group.visible);
|
||||
bld.setView(favEdit);
|
||||
bld.setNegativeButton(R.string.default_buttons_cancel, null);
|
||||
|
@ -470,7 +470,11 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
|
|||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
list.get(colorSpinner.getSelectedItemPosition());
|
||||
int clr = list.get(colorSpinner.getSelectedItemPosition());
|
||||
if(clr != intColor || group.visible != checkBox.isChecked()) {
|
||||
getMyApplication().getFavorites().editFavouriteGroup(group, clr, checkBox.isChecked());
|
||||
favouritesAdapter.notifyDataSetInvalidated();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -741,6 +745,7 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
|
|||
lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude()));
|
||||
String distance = OsmAndFormatter.getFormattedDistance(dist, getMyApplication()) + " ";
|
||||
label.setText(distance + model.getName(), TextView.BufferType.SPANNABLE);
|
||||
label.setTypeface(Typeface.DEFAULT, model.isVisible() ? Typeface.NORMAL : Typeface.ITALIC);
|
||||
((Spannable) label.getText()).setSpan(
|
||||
new ForegroundColorSpan(getResources().getColor(R.color.color_distance)), 0, distance.length() - 1,
|
||||
0);
|
||||
|
|
|
@ -80,8 +80,7 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.I
|
|||
// request to load
|
||||
final QuadRect latLonBounds = tileBox.getLatLonBounds();
|
||||
for (FavouritePoint o : favorites.getFavouritePoints()) {
|
||||
|
||||
if (o.getLatitude() >= latLonBounds.bottom && o.getLatitude() <= latLonBounds.top && o.getLongitude() >= latLonBounds.left
|
||||
if (o.isVisible() && o.getLatitude() >= latLonBounds.bottom && o.getLatitude() <= latLonBounds.top && o.getLongitude() >= latLonBounds.left
|
||||
&& o.getLongitude() <= latLonBounds.right ) {
|
||||
cache.add(o);
|
||||
int x = (int) tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
|
||||
|
|
Loading…
Reference in a new issue