diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6aae962..1eb0c52 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -49,8 +49,7 @@ + android:name=".activity.detail.GeofavoriteDetailActivity"> diff --git a/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/detail/GeofavoriteDetailActivity.java b/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/detail/GeofavoriteDetailActivity.java index 3147522..3dc86dd 100644 --- a/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/detail/GeofavoriteDetailActivity.java +++ b/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/detail/GeofavoriteDetailActivity.java @@ -58,6 +58,7 @@ import it.danieleverducci.nextcloudmaps.databinding.ActivityGeofavoriteDetailBin import it.danieleverducci.nextcloudmaps.model.Geofavorite; import it.danieleverducci.nextcloudmaps.utils.GeoUriParser; import it.danieleverducci.nextcloudmaps.utils.IntentGenerator; +import it.danieleverducci.nextcloudmaps.utils.MapUtils; public class GeofavoriteDetailActivity extends AppCompatActivity implements LocationListener, ActivityCompat.OnRequestPermissionsResultCallback { @@ -74,11 +75,7 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // OSMDroid config - IConfigurationProvider osmdroidConfig = Configuration.getInstance(); - osmdroidConfig.load(getApplicationContext(), - PreferenceManager.getDefaultSharedPreferences(getApplicationContext())); - osmdroidConfig.setUserAgentValue(BuildConfig.APPLICATION_ID); + MapUtils.configOsmdroid(this); mViewHolder = new ViewHolder(getLayoutInflater()); setContentView(mViewHolder.getRootView()); @@ -321,6 +318,7 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca // Set map properties this.binding.map.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.NEVER); this.binding.map.setMultiTouchControls(true); + MapUtils.setTheme(this.binding.map); // this.binding.map.setTilesScaledToDpi(true); // Create marker @@ -383,6 +381,7 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca public void hideAccuracy() { binding.accuracyTv.setVisibility(View.GONE); + binding.accuracyProgressContainer.setVisibility(View.GONE); } public void hideActions() { diff --git a/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/main/MainActivity.java b/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/main/MainActivity.java index e117dc9..76691e7 100644 --- a/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/main/MainActivity.java +++ b/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/main/MainActivity.java @@ -132,7 +132,7 @@ public class MainActivity extends AppCompatActivity implements OnSortingOrderLis } }; - geofavoriteAdapter = new GeofavoriteAdapter(getApplicationContext(), rvItemClickListener); + geofavoriteAdapter = new GeofavoriteAdapter(this, rvItemClickListener); recyclerView.setAdapter(geofavoriteAdapter); geofavoriteAdapter.setSortRule(sortRule); diff --git a/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/mappicker/MapPickerActivity.java b/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/mappicker/MapPickerActivity.java index acef7e5..4f4d6be 100644 --- a/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/mappicker/MapPickerActivity.java +++ b/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/mappicker/MapPickerActivity.java @@ -38,6 +38,7 @@ import it.danieleverducci.nextcloudmaps.R; import it.danieleverducci.nextcloudmaps.activity.detail.GeofavoriteDetailActivity; import it.danieleverducci.nextcloudmaps.databinding.ActivityMapPickerBinding; import it.danieleverducci.nextcloudmaps.utils.GeoUriParser; +import it.danieleverducci.nextcloudmaps.utils.MapUtils; public class MapPickerActivity extends AppCompatActivity { public static final String TAG = "MapPickerActivity"; @@ -50,11 +51,7 @@ public class MapPickerActivity extends AppCompatActivity { protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // OSMDroid config - IConfigurationProvider osmdroidConfig = Configuration.getInstance(); - osmdroidConfig.load(getApplicationContext(), - PreferenceManager.getDefaultSharedPreferences(getApplicationContext())); - osmdroidConfig.setUserAgentValue(BuildConfig.APPLICATION_ID); + MapUtils.configOsmdroid(this); mViewHolder = new MapPickerActivity.ViewHolder(getLayoutInflater()); mViewHolder.setViewEventListener(new ViewEventListener() { @@ -125,6 +122,7 @@ public class MapPickerActivity extends AppCompatActivity { this.map = this.binding.map; this.map.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.NEVER); this.map.setMultiTouchControls(true); + MapUtils.setTheme(this.map); this.map.addMapListener(new MapListener() { @Override public boolean onScroll(ScrollEvent event) { diff --git a/app/src/main/java/it/danieleverducci/nextcloudmaps/utils/MapUtils.java b/app/src/main/java/it/danieleverducci/nextcloudmaps/utils/MapUtils.java new file mode 100644 index 0000000..05ed323 --- /dev/null +++ b/app/src/main/java/it/danieleverducci/nextcloudmaps/utils/MapUtils.java @@ -0,0 +1,36 @@ +package it.danieleverducci.nextcloudmaps.utils; + +import android.content.Context; +import android.content.res.Configuration; + +import androidx.preference.PreferenceManager; + +import org.osmdroid.config.IConfigurationProvider; +import org.osmdroid.views.MapView; +import org.osmdroid.views.overlay.TilesOverlay; + +import it.danieleverducci.nextcloudmaps.BuildConfig; + +public class MapUtils { + + public static void configOsmdroid(Context context) { + IConfigurationProvider osmdroidConfig = org.osmdroid.config.Configuration.getInstance(); + osmdroidConfig.load(context, + PreferenceManager.getDefaultSharedPreferences(context)); + osmdroidConfig.setUserAgentValue(BuildConfig.APPLICATION_ID); + } + + public static void setTheme(MapView mapView) { + int currentNightMode = mapView.getContext().getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; + switch (currentNightMode) { + case Configuration.UI_MODE_NIGHT_NO: + // Night mode is not active, we're using the light theme + mapView.getOverlayManager().getTilesOverlay().setColorFilter(null); + break; + case Configuration.UI_MODE_NIGHT_YES: + // Night mode is active, we're using dark theme + mapView.getOverlayManager().getTilesOverlay().setColorFilter(TilesOverlay.INVERT_COLORS); + break; + } + } +} diff --git a/app/src/main/res/layout/activity_geofavorite_detail.xml b/app/src/main/res/layout/activity_geofavorite_detail.xml index 764bde9..040ff0d 100644 --- a/app/src/main/res/layout/activity_geofavorite_detail.xml +++ b/app/src/main/res/layout/activity_geofavorite_detail.xml @@ -91,6 +91,7 @@ android:padding="20dp"> @@ -65,7 +64,6 @@ android:layout_marginTop="@dimen/spacer_1hx" android:layout_marginEnd="@dimen/spacer_2x" android:layout_marginBottom="@dimen/spacer_1hx" - app:cardBackgroundColor="@color/appbar" app:cardCornerRadius="@dimen/spacer_1x" app:cardElevation="2dp" app:strokeWidth="0dp"> diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml new file mode 100644 index 0000000..1b9fcee --- /dev/null +++ b/app/src/main/res/values-night/colors.xml @@ -0,0 +1,5 @@ + + + #eee + #888 + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 90836a0..9a8cc18 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -23,13 +23,11 @@ #00000000 #0082C9 #550082C9 - @android:color/white - #202124 - #666666 + #666 - #333333 + #333 @color/disabled diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index bec7a76..74bbcc2 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -18,37 +18,20 @@ - - - -