WIP Dark theme

This commit is contained in:
Daniele Verducci (Slimpenguin) 2022-01-15 12:29:17 +01:00
parent 6336c4d61b
commit b9980206f5
10 changed files with 54 additions and 37 deletions

View File

@ -49,8 +49,7 @@
</activity> </activity>
<activity <activity
android:name=".activity.detail.GeofavoriteDetailActivity" android:name=".activity.detail.GeofavoriteDetailActivity">
android:theme="@style/AppTheme">
<!-- standard "geo" scheme --> <!-- standard "geo" scheme -->
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW"/> <action android:name="android.intent.action.VIEW"/>

View File

@ -58,6 +58,7 @@ import it.danieleverducci.nextcloudmaps.databinding.ActivityGeofavoriteDetailBin
import it.danieleverducci.nextcloudmaps.model.Geofavorite; import it.danieleverducci.nextcloudmaps.model.Geofavorite;
import it.danieleverducci.nextcloudmaps.utils.GeoUriParser; import it.danieleverducci.nextcloudmaps.utils.GeoUriParser;
import it.danieleverducci.nextcloudmaps.utils.IntentGenerator; import it.danieleverducci.nextcloudmaps.utils.IntentGenerator;
import it.danieleverducci.nextcloudmaps.utils.MapUtils;
public class GeofavoriteDetailActivity extends AppCompatActivity implements LocationListener, ActivityCompat.OnRequestPermissionsResultCallback { 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) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// OSMDroid config MapUtils.configOsmdroid(this);
IConfigurationProvider osmdroidConfig = Configuration.getInstance();
osmdroidConfig.load(getApplicationContext(),
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()));
osmdroidConfig.setUserAgentValue(BuildConfig.APPLICATION_ID);
mViewHolder = new ViewHolder(getLayoutInflater()); mViewHolder = new ViewHolder(getLayoutInflater());
setContentView(mViewHolder.getRootView()); setContentView(mViewHolder.getRootView());
@ -321,6 +318,7 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
// Set map properties // Set map properties
this.binding.map.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.NEVER); this.binding.map.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.NEVER);
this.binding.map.setMultiTouchControls(true); this.binding.map.setMultiTouchControls(true);
MapUtils.setTheme(this.binding.map);
// this.binding.map.setTilesScaledToDpi(true); // this.binding.map.setTilesScaledToDpi(true);
// Create marker // Create marker
@ -383,6 +381,7 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
public void hideAccuracy() { public void hideAccuracy() {
binding.accuracyTv.setVisibility(View.GONE); binding.accuracyTv.setVisibility(View.GONE);
binding.accuracyProgressContainer.setVisibility(View.GONE);
} }
public void hideActions() { public void hideActions() {

View File

@ -132,7 +132,7 @@ public class MainActivity extends AppCompatActivity implements OnSortingOrderLis
} }
}; };
geofavoriteAdapter = new GeofavoriteAdapter(getApplicationContext(), rvItemClickListener); geofavoriteAdapter = new GeofavoriteAdapter(this, rvItemClickListener);
recyclerView.setAdapter(geofavoriteAdapter); recyclerView.setAdapter(geofavoriteAdapter);
geofavoriteAdapter.setSortRule(sortRule); geofavoriteAdapter.setSortRule(sortRule);

View File

@ -38,6 +38,7 @@ import it.danieleverducci.nextcloudmaps.R;
import it.danieleverducci.nextcloudmaps.activity.detail.GeofavoriteDetailActivity; import it.danieleverducci.nextcloudmaps.activity.detail.GeofavoriteDetailActivity;
import it.danieleverducci.nextcloudmaps.databinding.ActivityMapPickerBinding; import it.danieleverducci.nextcloudmaps.databinding.ActivityMapPickerBinding;
import it.danieleverducci.nextcloudmaps.utils.GeoUriParser; import it.danieleverducci.nextcloudmaps.utils.GeoUriParser;
import it.danieleverducci.nextcloudmaps.utils.MapUtils;
public class MapPickerActivity extends AppCompatActivity { public class MapPickerActivity extends AppCompatActivity {
public static final String TAG = "MapPickerActivity"; public static final String TAG = "MapPickerActivity";
@ -50,11 +51,7 @@ public class MapPickerActivity extends AppCompatActivity {
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// OSMDroid config MapUtils.configOsmdroid(this);
IConfigurationProvider osmdroidConfig = Configuration.getInstance();
osmdroidConfig.load(getApplicationContext(),
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()));
osmdroidConfig.setUserAgentValue(BuildConfig.APPLICATION_ID);
mViewHolder = new MapPickerActivity.ViewHolder(getLayoutInflater()); mViewHolder = new MapPickerActivity.ViewHolder(getLayoutInflater());
mViewHolder.setViewEventListener(new ViewEventListener() { mViewHolder.setViewEventListener(new ViewEventListener() {
@ -125,6 +122,7 @@ public class MapPickerActivity extends AppCompatActivity {
this.map = this.binding.map; this.map = this.binding.map;
this.map.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.NEVER); this.map.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.NEVER);
this.map.setMultiTouchControls(true); this.map.setMultiTouchControls(true);
MapUtils.setTheme(this.map);
this.map.addMapListener(new MapListener() { this.map.addMapListener(new MapListener() {
@Override @Override
public boolean onScroll(ScrollEvent event) { public boolean onScroll(ScrollEvent event) {

View File

@ -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;
}
}
}

View File

@ -91,6 +91,7 @@
android:padding="20dp"> android:padding="20dp">
<LinearLayout <LinearLayout
android:id="@+id/accuracy_progress_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="10dp" android:layout_margin="10dp"

View File

@ -21,7 +21,6 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_list_view" android:id="@+id/activity_list_view"
android:background="@color/primary"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@ -65,7 +64,6 @@
android:layout_marginTop="@dimen/spacer_1hx" android:layout_marginTop="@dimen/spacer_1hx"
android:layout_marginEnd="@dimen/spacer_2x" android:layout_marginEnd="@dimen/spacer_2x"
android:layout_marginBottom="@dimen/spacer_1hx" android:layout_marginBottom="@dimen/spacer_1hx"
app:cardBackgroundColor="@color/appbar"
app:cardCornerRadius="@dimen/spacer_1x" app:cardCornerRadius="@dimen/spacer_1x"
app:cardElevation="2dp" app:cardElevation="2dp"
app:strokeWidth="0dp"> app:strokeWidth="0dp">

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="text_color">#eee</color>
<color name="disabled">#888</color>
</resources>

View File

@ -23,13 +23,11 @@
<color name="transparent">#00000000</color> <color name="transparent">#00000000</color>
<color name="defaultBrand">#0082C9</color> <color name="defaultBrand">#0082C9</color>
<color name="defaultBrandAlpha">#550082C9</color> <color name="defaultBrandAlpha">#550082C9</color>
<color name="appbar">@android:color/white</color> <color name="disabled">#666</color>
<color name="defaultTint">#202124</color>
<color name="disabled">#666666</color>
<!-- List Colors --> <!-- List Colors -->
<color name="text_color">#333333</color> <color name="text_color">#333</color>
<color name="secondary_text_color">@color/disabled</color> <color name="secondary_text_color">@color/disabled</color>
<!-- Selectors text/tint colors --> <!-- Selectors text/tint colors -->

View File

@ -18,37 +18,20 @@
<resources> <resources>
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="BaseTheme" parent="Theme.AppCompat.DayNight.NoActionBar"> <style name="BaseTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/primary</item>
<!-- <item name="android:textColorPrimary">@color/white</item>-->
<item name="colorPrimaryDark">@color/primary</item>
<item name="colorAccent">@color/defaultBrand</item> <item name="colorAccent">@color/defaultBrand</item>
<item name="android:actionModeBackground">?attr/colorPrimary</item>
<item name="colorControlNormal">?attr/colorAccent</item> <item name="colorControlNormal">?attr/colorAccent</item>
<item name="windowActionModeOverlay">true</item> <item name="windowActionModeOverlay">true</item>
<item name="toolbarStyle">@style/toolbarStyle</item>
</style> </style>
<style name="AppTheme" parent="BaseTheme"/> <style name="AppTheme" parent="BaseTheme"/>
<style name="EditorTheme" parent="Theme.AppCompat.DayNight.DarkActionBar"> <style name="SplashTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@android:color/transparent</item>
<item name="colorPrimaryDark">@color/accent</item>
<item name="colorAccent">@color/accent</item>
</style>
<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. --> <!-- Customize your theme here. -->
<item name="windowActionBar">false</item> <item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item> <item name="windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item> <item name="android:windowFullscreen">true</item>
</style> </style>
<style name="toolbarStyle" parent="@style/Widget.AppCompat.Toolbar">
<item name="android:background">?attr/colorPrimary</item>
</style>
<!-- Geofavorite detail text appearances --> <!-- Geofavorite detail text appearances -->
<style name="TextAppearance.GeofavoriteDetail.Header.Expanded" parent="TextAppearance.Design.CollapsingToolbar.Expanded"> <style name="TextAppearance.GeofavoriteDetail.Header.Expanded" parent="TextAppearance.Design.CollapsingToolbar.Expanded">