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

File diff suppressed because it is too large Load diff

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);