favorite changes

This commit is contained in:
simon 2020-08-20 10:23:35 +03:00
parent c757ef3a0b
commit 1c1a60863c
8 changed files with 659 additions and 595 deletions

View file

@ -16,12 +16,13 @@ public class AFavorite extends AidlParams {
private String color; private String color;
private boolean visible; private boolean visible;
public AFavorite(double lat, double lon, String name, String description, public AFavorite(double lat, double lon, String name, String description, String address,
String category, String color, boolean visible) { String category, String color, boolean visible) {
this.lat = lat; this.lat = lat;
this.lon = lon; this.lon = lon;
this.name = name; this.name = name;
this.description = description; this.description = description;
this.address = address;
this.category = category; this.category = category;
this.color = color; this.color = color;
this.visible = visible; this.visible = visible;
@ -59,7 +60,7 @@ public class AFavorite extends AidlParams {
return description; return description;
} }
public String getAddress() { return description; } public String getAddress() { return address; }
public String getCategory() { public String getCategory() {
return category; return category;

View file

@ -542,6 +542,7 @@ dependencies {
//implementation 'com.atilika.kuromoji:kuromoji-ipadic:0.9.0' //implementation 'com.atilika.kuromoji:kuromoji-ipadic:0.9.0'
implementation 'com.squareup.picasso:picasso:2.71828' implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'me.zhanghai.android.materialprogressbar:library:1.4.2' implementation 'me.zhanghai.android.materialprogressbar:library:1.4.2'
implementation 'org.nanohttpd:nanohttpd:2.2.0'
// JS core // JS core
implementation group: 'org.mozilla', name: 'rhino', version: '1.7.9' implementation group: 'org.mozilla', name: 'rhino', version: '1.7.9'
// size restrictions // size restrictions

View file

@ -128,8 +128,8 @@
android:layout_marginRight="@dimen/content_padding" android:layout_marginRight="@dimen/content_padding"
android:layout_weight="1" android:layout_weight="1"
android:hint="@string/shared_string_address" android:hint="@string/shared_string_address"
app:hintAnimationEnabled="false" app:boxBackgroundColor="@color/material_text_input_layout_bg"
app:boxBackgroundColor="@color/material_text_input_layout_bg"> app:hintAnimationEnabled="false">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
android:id="@+id/address_edit" android:id="@+id/address_edit"
@ -149,11 +149,12 @@
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/address_button" android:id="@+id/address_button"
android:layout_marginTop="@dimen/content_padding_small"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="@dimen/context_menu_buttons_bottom_height" android:layout_height="@dimen/context_menu_buttons_bottom_height"
android:layout_marginStart="@dimen/content_padding_half" android:layout_marginStart="@dimen/content_padding_half"
android:layout_marginLeft="@dimen/content_padding_half" android:layout_marginLeft="@dimen/content_padding_half"
android:layout_marginTop="@dimen/content_padding_small"
android:drawablePadding="8dp"
android:duplicateParentState="true" android:duplicateParentState="true"
android:gravity="center" android:gravity="center"
android:paddingStart="@dimen/content_padding_half" android:paddingStart="@dimen/content_padding_half"
@ -161,7 +162,6 @@
android:paddingEnd="@dimen/content_padding_half" android:paddingEnd="@dimen/content_padding_half"
android:paddingRight="@dimen/content_padding_half" android:paddingRight="@dimen/content_padding_half"
android:text="@string/add_address" android:text="@string/add_address"
android:drawablePadding="8dp"
android:textSize="@dimen/default_desc_text_size" android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium" osmand:typeface="@string/font_roboto_medium"
tools:text="@string/add_address" /> tools:text="@string/add_address" />
@ -183,8 +183,8 @@
android:layout_marginRight="@dimen/content_padding" android:layout_marginRight="@dimen/content_padding"
android:layout_weight="1" android:layout_weight="1"
android:hint="@string/shared_string_description" android:hint="@string/shared_string_description"
app:hintAnimationEnabled="false" app:boxBackgroundColor="@color/material_text_input_layout_bg"
app:boxBackgroundColor="@color/material_text_input_layout_bg"> app:hintAnimationEnabled="false">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
android:id="@+id/description_edit" android:id="@+id/description_edit"
@ -209,13 +209,13 @@
android:layout_height="@dimen/context_menu_buttons_bottom_height" android:layout_height="@dimen/context_menu_buttons_bottom_height"
android:layout_marginStart="@dimen/content_padding_half" android:layout_marginStart="@dimen/content_padding_half"
android:layout_marginLeft="@dimen/content_padding_half" android:layout_marginLeft="@dimen/content_padding_half"
android:drawablePadding="8dp"
android:duplicateParentState="true" android:duplicateParentState="true"
android:gravity="center" android:gravity="center"
android:paddingStart="@dimen/content_padding_half" android:paddingStart="@dimen/content_padding_half"
android:paddingLeft="@dimen/content_padding_half" android:paddingLeft="@dimen/content_padding_half"
android:paddingEnd="@dimen/content_padding_half" android:paddingEnd="@dimen/content_padding_half"
android:paddingRight="@dimen/content_padding_half" android:paddingRight="@dimen/content_padding_half"
android:drawablePadding="8dp"
android:text="@string/add_description" android:text="@string/add_description"
android:textSize="@dimen/default_desc_text_size" android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium" osmand:typeface="@string/font_roboto_medium"

View file

@ -0,0 +1,59 @@
package androidhttpweb;
import android.net.TrafficStats;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import net.osmand.plus.R;
public class ServerActivity extends AppCompatActivity {
private boolean initialized = false;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.server_activity);
findViewById(R.id.Button01).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!initialized) {
((TextView) findViewById(R.id.TextView02)).setText("Click second button to deactivate server");
initServer();
}
}
});
findViewById(R.id.Button03).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (initialized) {
((TextView) findViewById(R.id.TextView02)).setText("Click first button to activate server");
deInitServer();
}
}
});
}
private void initServer() {
final String ip = "localhost";
final int port = 24990;
final int THREAD_ID = 10000;
TrafficStats.setThreadStatsTag(THREAD_ID);
TinyWebServer.startServer(ip, port, "/web/public_html");
TinyWebServer.object = ServerActivity.this;
}
private void deInitServer() {
TinyWebServer.stopServer();
initialized = false;
}
@Override
protected void onDestroy() {
deInitServer();
super.onDestroy();
}
}

View file

@ -78,10 +78,10 @@ public class AFavorite implements Parcelable {
out.writeDouble(lon); out.writeDouble(lon);
out.writeString(name); out.writeString(name);
out.writeString(description); out.writeString(description);
out.writeString(address);
out.writeString(category); out.writeString(category);
out.writeString(color); out.writeString(color);
out.writeByte((byte) (visible ? 1 : 0)); out.writeByte((byte) (visible ? 1 : 0));
out.writeString(address);
} }
private void readFromParcel(Parcel in) { private void readFromParcel(Parcel in) {
@ -89,10 +89,10 @@ public class AFavorite implements Parcelable {
lon = in.readDouble(); lon = in.readDouble();
name = in.readString(); name = in.readString();
description = in.readString(); description = in.readString();
address = in.readString();
category = in.readString(); category = in.readString();
color = in.readString(); color = in.readString();
visible = in.readByte() != 0; visible = in.readByte() != 0;
address = in.readString();
} }
@Override @Override

View file

@ -1828,14 +1828,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
String groupName = convertDisplayNameToGroupIdName(requireContext(), String groupName = convertDisplayNameToGroupIdName(requireContext(),
menu.getTypeStr()); menu.getTypeStr());
if (menu.getMyApplication() != null){ if (menu.getMyApplication() != null){
FavouritesDbHelper helper = menu.getMyApplication().getFavorites();
if (helper != null && helper.getGroup(groupName) != null){
Drawable line2icon = helper.getColoredIconForGroup(groupName);
GravityDrawable line2GravityDrawable =
new GravityDrawable(line2icon);
line2.setCompoundDrawablesWithIntrinsicBounds(
line2GravityDrawable, null, null, null);
}
} }
line2.setCompoundDrawablePadding(dpToPx(5f)); line2.setCompoundDrawablePadding(dpToPx(5f));
} }

View file

@ -11,6 +11,7 @@ import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.data.TransportStop; import net.osmand.data.TransportStop;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -23,6 +24,7 @@ import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragment;
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragmentNew; import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragmentNew;
import net.osmand.plus.transport.TransportStopRoute; import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.util.OpeningHoursParser; import net.osmand.util.OpeningHoursParser;
import net.osmand.view.GravityDrawable;
import java.util.List; import java.util.List;
@ -158,6 +160,14 @@ public class FavouritePointMenuController extends MenuController {
@Override @Override
public Drawable getSecondLineTypeIcon() { public Drawable getSecondLineTypeIcon() {
FavouritesDbHelper helper = menu.getMyApplication().getFavorites();
if (helper != null && helper.getGroup(groupName) != null) {
Drawable line2icon = helper.getColoredIconForGroup(groupName);
GravityDrawable line2GravityDrawable =
new GravityDrawable(line2icon);
}
return getIcon(R.drawable.ic_action_group_name_16, isLight() ? R.color.icon_color_default_light : R.color.ctx_menu_bottom_view_icon_dark); return getIcon(R.drawable.ic_action_group_name_16, isLight() ? R.color.icon_color_default_light : R.color.ctx_menu_bottom_view_icon_dark);
} }

View file

@ -62,7 +62,7 @@ public class FavoritePointEditor extends PointEditor {
favorite = new FavouritePoint(latLon.getLatitude(), latLon.getLongitude(), title, categoryName); favorite = new FavouritePoint(latLon.getLatitude(), latLon.getLongitude(), title, categoryName);
favorite.setDescription(""); favorite.setDescription("");
favorite.setAddress(title); favorite.setAddress("");
favorite.setOriginObjectName(originObjectName); favorite.setOriginObjectName(originObjectName);
FavoritePointEditorFragmentNew.showAutoFillInstance(mapActivity, autoFill); FavoritePointEditorFragmentNew.showAutoFillInstance(mapActivity, autoFill);