Working map view with markers opening default, ugly, infowindow
This commit is contained in:
parent
ebbd4c823b
commit
d762ffe40a
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="CompilerConfiguration">
|
<component name="CompilerConfiguration">
|
||||||
<bytecodeTargetLevel target="11" />
|
<bytecodeTargetLevel target="17" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -1,17 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="deploymentTargetDropDown">
|
<component name="deploymentTargetDropDown">
|
||||||
<targetSelectedWithDropDown>
|
<value>
|
||||||
<Target>
|
<entry key="app">
|
||||||
<type value="QUICK_BOOT_TARGET" />
|
<State />
|
||||||
<deviceKey>
|
</entry>
|
||||||
<Key>
|
</value>
|
||||||
<type value="VIRTUAL_DEVICE_PATH" />
|
|
||||||
<value value="$USER_HOME$/.android/avd/Pixel_XL_Android_12.avd" />
|
|
||||||
</Key>
|
|
||||||
</deviceKey>
|
|
||||||
</Target>
|
|
||||||
</targetSelectedWithDropDown>
|
|
||||||
<timeTargetWasSelectedWithDropDown value="2024-02-16T05:59:01.340872Z" />
|
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
10
.idea/migrations.xml
Normal file
10
.idea/migrations.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectMigrations">
|
||||||
|
<option name="MigrateToGradleLocalJavaHome">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -26,5 +26,5 @@
|
|||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK" />
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK" />
|
||||||
</project>
|
</project>
|
@ -37,6 +37,9 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
|
// Flag to enable support for the new language APIs
|
||||||
|
coreLibraryDesugaringEnabled true
|
||||||
|
// Sets Java compatibility to Java 8
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
@ -55,6 +58,9 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||||
|
|
||||||
|
// Desugaring lib: see https://developer.android.com/studio/write/java8-support
|
||||||
|
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.3")
|
||||||
|
|
||||||
implementation 'com.android.support:design:34.0.0'
|
implementation 'com.android.support:design:34.0.0'
|
||||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||||
implementation 'androidx.recyclerview:recyclerview:1.3.2'
|
implementation 'androidx.recyclerview:recyclerview:1.3.2'
|
||||||
|
@ -18,33 +18,20 @@
|
|||||||
package it.danieleverducci.nextcloudmaps.activity.main;
|
package it.danieleverducci.nextcloudmaps.activity.main;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.appcompat.widget.AppCompatImageButton;
|
|
||||||
import androidx.appcompat.widget.AppCompatImageView;
|
|
||||||
import androidx.appcompat.widget.SearchView;
|
|
||||||
import androidx.appcompat.widget.Toolbar;
|
|
||||||
import androidx.core.view.GravityCompat;
|
import androidx.core.view.GravityCompat;
|
||||||
import androidx.drawerlayout.widget.DrawerLayout;
|
import androidx.drawerlayout.widget.DrawerLayout;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.fragment.app.FragmentTransaction;
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
|
||||||
import androidx.preference.PreferenceManager;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.google.android.material.card.MaterialCardView;
|
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
import com.nextcloud.android.sso.helper.SingleAccountHelper;
|
import com.nextcloud.android.sso.helper.SingleAccountHelper;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import it.danieleverducci.nextcloudmaps.R;
|
import it.danieleverducci.nextcloudmaps.R;
|
||||||
import it.danieleverducci.nextcloudmaps.activity.NextcloudMapsStyledActivity;
|
import it.danieleverducci.nextcloudmaps.activity.NextcloudMapsStyledActivity;
|
||||||
@ -52,23 +39,12 @@ import it.danieleverducci.nextcloudmaps.activity.about.AboutActivity;
|
|||||||
import it.danieleverducci.nextcloudmaps.activity.detail.GeofavoriteDetailActivity;
|
import it.danieleverducci.nextcloudmaps.activity.detail.GeofavoriteDetailActivity;
|
||||||
import it.danieleverducci.nextcloudmaps.activity.login.LoginActivity;
|
import it.danieleverducci.nextcloudmaps.activity.login.LoginActivity;
|
||||||
import it.danieleverducci.nextcloudmaps.activity.main.NavigationAdapter.NavigationItem;
|
import it.danieleverducci.nextcloudmaps.activity.main.NavigationAdapter.NavigationItem;
|
||||||
import it.danieleverducci.nextcloudmaps.activity.main.SortingOrderDialogFragment.OnSortingOrderListener;
|
|
||||||
import it.danieleverducci.nextcloudmaps.activity.mappicker.MapPickerActivity;
|
import it.danieleverducci.nextcloudmaps.activity.mappicker.MapPickerActivity;
|
||||||
import it.danieleverducci.nextcloudmaps.api.ApiProvider;
|
import it.danieleverducci.nextcloudmaps.api.ApiProvider;
|
||||||
import it.danieleverducci.nextcloudmaps.fragments.GeofavoriteListFragment;
|
import it.danieleverducci.nextcloudmaps.fragments.GeofavoriteListFragment;
|
||||||
import it.danieleverducci.nextcloudmaps.fragments.GeofavoriteMapFragment;
|
import it.danieleverducci.nextcloudmaps.fragments.GeofavoriteMapFragment;
|
||||||
import it.danieleverducci.nextcloudmaps.fragments.GeofavoritesFragment;
|
|
||||||
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
|
||||||
import it.danieleverducci.nextcloudmaps.utils.SettingsManager;
|
import it.danieleverducci.nextcloudmaps.utils.SettingsManager;
|
||||||
|
|
||||||
import static android.view.View.GONE;
|
|
||||||
import static android.view.View.VISIBLE;
|
|
||||||
import static it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter.*;
|
|
||||||
import static it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter.SORT_BY_CREATED;
|
|
||||||
import static it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter.SORT_BY_TITLE;
|
|
||||||
import androidx.lifecycle.Observer;
|
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
|
||||||
|
|
||||||
public class MainActivity extends NextcloudMapsStyledActivity {
|
public class MainActivity extends NextcloudMapsStyledActivity {
|
||||||
|
|
||||||
private static final String TAG = "MainActivity";
|
private static final String TAG = "MainActivity";
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package it.danieleverducci.nextcloudmaps.fragments;
|
package it.danieleverducci.nextcloudmaps.fragments;
|
||||||
|
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -7,27 +8,84 @@ import android.view.ViewGroup;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.content.res.AppCompatResources;
|
||||||
|
import androidx.core.graphics.drawable.DrawableCompat;
|
||||||
|
import androidx.lifecycle.Observer;
|
||||||
|
|
||||||
|
import org.osmdroid.util.GeoPoint;
|
||||||
|
import org.osmdroid.views.MapView;
|
||||||
|
import org.osmdroid.views.overlay.Marker;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import it.danieleverducci.nextcloudmaps.R;
|
import it.danieleverducci.nextcloudmaps.R;
|
||||||
import it.danieleverducci.nextcloudmaps.activity.main.MainActivity;
|
import it.danieleverducci.nextcloudmaps.activity.main.MainActivity;
|
||||||
|
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||||
|
import it.danieleverducci.nextcloudmaps.utils.MapUtils;
|
||||||
|
|
||||||
public class GeofavoriteMapFragment extends GeofavoritesFragment {
|
public class GeofavoriteMapFragment extends GeofavoritesFragment {
|
||||||
|
private MapView map;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
MapUtils.configOsmdroid(requireContext());
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
View v = inflater.inflate(R.layout.fragment_geofavorite_map, container, false);
|
View v = inflater.inflate(R.layout.fragment_geofavorite_map, container, false);
|
||||||
|
map = v.findViewById(R.id.map);
|
||||||
|
|
||||||
// Setup view listeners
|
// Setup view listeners
|
||||||
View showListButton = v.findViewById(R.id.view_mode_list);
|
View showListButton = v.findViewById(R.id.view_mode_list);
|
||||||
showListButton.setOnClickListener(View -> ((MainActivity)requireActivity()).showMap());
|
showListButton.setOnClickListener(View -> ((MainActivity)requireActivity()).showList());
|
||||||
|
|
||||||
|
View loadingWall = v.findViewById(R.id.loading_wall);
|
||||||
|
|
||||||
|
// Register for data source events
|
||||||
|
mGeofavoritesFragmentViewModel.getIsUpdating().observe(getViewLifecycleOwner(), new Observer<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(@Nullable Boolean changed) {
|
||||||
|
if(Boolean.TRUE.equals(changed)){
|
||||||
|
loadingWall.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
loadingWall.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mGeofavoritesFragmentViewModel.getGeofavorites().observe(getViewLifecycleOwner(), new Observer<List<Geofavorite>>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(List<Geofavorite> geofavorites) {
|
||||||
|
for(Geofavorite gf : geofavorites)
|
||||||
|
addMarker(gf);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSearch(String query) {
|
public void onSearch(String query) {
|
||||||
|
// TODO: filter
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addMarker(Geofavorite geofavorite){
|
||||||
|
GeoPoint pos = new GeoPoint(geofavorite.getLat(), geofavorite.getLng());
|
||||||
|
|
||||||
|
Drawable icon = DrawableCompat.wrap(AppCompatResources.getDrawable(requireContext(), R.drawable.ic_list_pin));
|
||||||
|
DrawableCompat.setTint(icon, geofavorite.categoryColor());
|
||||||
|
|
||||||
|
Marker m = new Marker(map);
|
||||||
|
m.setPosition(pos);
|
||||||
|
m.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
|
||||||
|
m.setIcon(icon);
|
||||||
|
m.setTitle(geofavorite.getName());
|
||||||
|
m.setSnippet(geofavorite.getComment());
|
||||||
|
m.setSubDescription(geofavorite.getCategory());
|
||||||
|
map.getOverlays().add(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,21 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/loading_wall"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/translucent"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:indeterminate="true"
|
||||||
|
android:layout_gravity="center"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
<org.osmdroid.views.MapView
|
<org.osmdroid.views.MapView
|
||||||
android:id="@+id/map"
|
android:id="@+id/map"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -22,17 +37,11 @@
|
|||||||
|
|
||||||
<include layout="@layout/app_toolbar"/>
|
<include layout="@layout/app_toolbar"/>
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:paddingTop="10dp">
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
android:id="@+id/view_mode_list"
|
android:id="@+id/view_mode_list"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="@dimen/floating_bar_height"
|
android:layout_height="@dimen/floating_bar_height"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_gravity="right"
|
||||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
android:contentDescription="@string/list_mode"
|
android:contentDescription="@string/list_mode"
|
||||||
android:paddingStart="@dimen/spacer_2x"
|
android:paddingStart="@dimen/spacer_2x"
|
||||||
@ -40,8 +49,6 @@
|
|||||||
android:tint="@color/text_color"
|
android:tint="@color/text_color"
|
||||||
android:src="@drawable/ic_view_list" />
|
android:src="@drawable/ic_view_list" />
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
@ -3,4 +3,5 @@
|
|||||||
<color name="text_color">#eee</color>
|
<color name="text_color">#eee</color>
|
||||||
<color name="disabled">#888</color>
|
<color name="disabled">#888</color>
|
||||||
<color name="defaultBackground">#000</color>
|
<color name="defaultBackground">#000</color>
|
||||||
|
<color name="translucent">#C000</color>
|
||||||
</resources>
|
</resources>
|
@ -20,6 +20,7 @@
|
|||||||
<!-- Generic Colors -->
|
<!-- Generic Colors -->
|
||||||
<color name="primary">#ffffff</color>
|
<color name="primary">#ffffff</color>
|
||||||
<color name="transparent">#00000000</color>
|
<color name="transparent">#00000000</color>
|
||||||
|
<color name="translucent">#CFFF</color>
|
||||||
<color name="defaultBrand">#0082C9</color>
|
<color name="defaultBrand">#0082C9</color>
|
||||||
<color name="defaultBrandAlpha">#550082C9</color>
|
<color name="defaultBrandAlpha">#550082C9</color>
|
||||||
<color name="disabled">#666</color>
|
<color name="disabled">#666</color>
|
||||||
|
@ -25,7 +25,7 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:7.4.0'
|
classpath 'com.android.tools.build:gradle:8.2.2'
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
@ -37,3 +37,6 @@ org.gradle.jvmargs=-Xmx2048m
|
|||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
# Automatically convert third-party libraries to use AndroidX
|
# Automatically convert third-party libraries to use AndroidX
|
||||||
android.enableJetifier=true
|
android.enableJetifier=true
|
||||||
|
android.defaults.buildfeatures.buildconfig=true
|
||||||
|
android.nonTransitiveRClass=false
|
||||||
|
android.nonFinalResIds=false
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
|||||||
#Sun Feb 20 08:50:37 CET 2022
|
#Sun Feb 20 08:50:37 CET 2022
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
Loading…
Reference in New Issue
Block a user