[android] Proper usage of dark theme
Signed-off-by: Andrei Shkrob <github@shkrob.dev>
@@ -89,6 +89,7 @@
|
||||
<!-- Allows for config and orientation change without killing/restarting main activity -->
|
||||
<activity
|
||||
android:name="app.organicmaps.SplashActivity"
|
||||
android:theme="@style/MwmTheme.Splash"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|uiMode|keyboard|keyboardHidden|navigation"
|
||||
android:screenOrientation="fullUser"
|
||||
android:exported="true">
|
||||
@@ -349,6 +350,7 @@
|
||||
|
||||
<activity
|
||||
android:name="app.organicmaps.DownloadResourcesLegacyActivity"
|
||||
android:theme="@style/MwmTheme.DownloadResourcesLegacy"
|
||||
android:configChanges="orientation|screenLayout|screenSize"
|
||||
android:screenOrientation="fullUser"/>
|
||||
|
||||
@@ -365,6 +367,7 @@
|
||||
|
||||
<activity
|
||||
android:name="app.organicmaps.MwmActivity"
|
||||
android:theme="@style/MwmTheme.MainActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:configChanges="uiMode"
|
||||
android:screenOrientation="fullUser"
|
||||
@@ -386,6 +389,7 @@
|
||||
|
||||
<activity
|
||||
android:name="app.organicmaps.search.SearchActivity"
|
||||
android:theme="@style/MwmTheme.CardBg"
|
||||
android:configChanges="orientation|screenLayout|screenSize"
|
||||
android:screenOrientation="fullUser"
|
||||
android:label="@string/search_map"
|
||||
@@ -412,6 +416,7 @@
|
||||
|
||||
<activity
|
||||
android:name="app.organicmaps.bookmarks.BookmarkCategoriesActivity"
|
||||
android:theme="@style/MwmTheme.WindowBg"
|
||||
android:configChanges="orientation|screenLayout|screenSize"
|
||||
android:screenOrientation="fullUser"
|
||||
android:label="@string/bookmarks_and_tracks"
|
||||
@@ -420,6 +425,7 @@
|
||||
|
||||
<activity
|
||||
android:name="app.organicmaps.bookmarks.BookmarkListActivity"
|
||||
android:theme="@style/MwmTheme.CardBg"
|
||||
android:configChanges="orientation|screenLayout|screenSize"
|
||||
android:screenOrientation="fullUser"
|
||||
android:label="@string/bookmarks"
|
||||
|
||||
@@ -24,7 +24,6 @@ import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.annotation.StyleRes;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import app.organicmaps.base.BaseMwmFragmentActivity;
|
||||
import app.organicmaps.downloader.MapManagerHelper;
|
||||
@@ -438,11 +437,4 @@ public class DownloadResourcesLegacyActivity extends BaseMwmFragmentActivity
|
||||
.setOnDismissListener(dialog -> mAlertDialog = null)
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
@StyleRes
|
||||
public int getThemeResourceId(@NonNull String theme)
|
||||
{
|
||||
return R.style.MwmTheme_DownloadResourcesLegacy;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,19 +455,6 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@StyleRes
|
||||
protected int getThemeResourceId(@NonNull String theme)
|
||||
{
|
||||
if (Config.UiTheme.isDefault(theme))
|
||||
return R.style.MwmTheme_MainActivity;
|
||||
|
||||
if (Config.UiTheme.isNight(theme))
|
||||
return R.style.MwmTheme_Night_MainActivity;
|
||||
|
||||
return super.getThemeResourceId(theme);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisplayChangedToCar(@NonNull Runnable onTaskFinishedCallback)
|
||||
{
|
||||
|
||||
@@ -56,15 +56,6 @@ public class SplashActivity extends AppCompatActivity
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final String theme = Config.UiTheme.getCurrent();
|
||||
if (Config.UiTheme.isDefault(theme))
|
||||
setTheme(R.style.MwmTheme_Splash);
|
||||
else if (Config.UiTheme.isNight(theme))
|
||||
setTheme(R.style.MwmTheme_Night_Splash);
|
||||
else
|
||||
throw new IllegalArgumentException("Attempt to apply unsupported theme: " + theme);
|
||||
|
||||
UiThread.cancelDelayedTasks(mInitCoreDelayedTask);
|
||||
setContentView(R.layout.activity_splash);
|
||||
|
||||
|
||||
@@ -8,14 +8,13 @@ import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StyleRes;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import app.organicmaps.R;
|
||||
import app.organicmaps.util.ThemeUtils;
|
||||
|
||||
public class BaseMwmDialogFragment extends DialogFragment
|
||||
{
|
||||
@StyleRes
|
||||
protected final int getFullscreenTheme()
|
||||
{
|
||||
return ThemeUtils.isNightTheme() ? getFullscreenDarkTheme() : getFullscreenLightTheme();
|
||||
return R.style.MwmTheme_DialogFragment_Fullscreen;
|
||||
}
|
||||
|
||||
protected int getStyle()
|
||||
@@ -23,7 +22,8 @@ public class BaseMwmDialogFragment extends DialogFragment
|
||||
return STYLE_NORMAL;
|
||||
}
|
||||
|
||||
protected @StyleRes int getCustomTheme()
|
||||
@StyleRes
|
||||
protected int getCustomTheme()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -40,18 +40,6 @@ public class BaseMwmDialogFragment extends DialogFragment
|
||||
setStyle(style, theme);
|
||||
}
|
||||
|
||||
@StyleRes
|
||||
protected int getFullscreenLightTheme()
|
||||
{
|
||||
return R.style.MwmTheme_DialogFragment_Fullscreen;
|
||||
}
|
||||
|
||||
@StyleRes
|
||||
protected int getFullscreenDarkTheme()
|
||||
{
|
||||
return R.style.MwmTheme_DialogFragment_Fullscreen_Night;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
protected Application getAppContextOrThrow()
|
||||
{
|
||||
|
||||
@@ -11,7 +11,6 @@ import androidx.activity.SystemBarStyle;
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StyleRes;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentFactory;
|
||||
@@ -20,7 +19,6 @@ import app.organicmaps.MwmApplication;
|
||||
import app.organicmaps.R;
|
||||
import app.organicmaps.SplashActivity;
|
||||
import app.organicmaps.sdk.util.Config;
|
||||
import app.organicmaps.sdk.util.concurrency.UiThread;
|
||||
import app.organicmaps.sdk.util.log.Logger;
|
||||
import app.organicmaps.util.RtlUtils;
|
||||
import com.google.android.material.appbar.MaterialToolbar;
|
||||
@@ -32,24 +30,9 @@ public abstract class BaseMwmFragmentActivity extends AppCompatActivity
|
||||
|
||||
private boolean mSafeCreated;
|
||||
|
||||
@NonNull
|
||||
private String mThemeName;
|
||||
|
||||
@StyleRes
|
||||
protected int getThemeResourceId(@NonNull String theme)
|
||||
{
|
||||
if (Config.UiTheme.isDefault(theme))
|
||||
return R.style.MwmTheme;
|
||||
|
||||
if (Config.UiTheme.isNight(theme))
|
||||
return R.style.MwmTheme_Night;
|
||||
|
||||
throw new IllegalArgumentException("Attempt to apply unsupported theme: " + theme);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows splash screen and initializes the core in case when it was not initialized.
|
||||
*
|
||||
* <p>
|
||||
* Do not override this method!
|
||||
* Use {@link #onSafeCreate(Bundle savedInstanceState)}
|
||||
*/
|
||||
@@ -58,8 +41,6 @@ public abstract class BaseMwmFragmentActivity extends AppCompatActivity
|
||||
protected final void onCreate(@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
mThemeName = Config.UiTheme.getCurrent();
|
||||
setTheme(getThemeResourceId(mThemeName));
|
||||
EdgeToEdge.enable(this, SystemBarStyle.dark(Color.TRANSPARENT));
|
||||
RtlUtils.manageRtl(this);
|
||||
if (!MwmApplication.from(this).getOrganicMaps().arePlatformAndCoreInitialized())
|
||||
@@ -113,18 +94,6 @@ public abstract class BaseMwmFragmentActivity extends AppCompatActivity
|
||||
mSafeCreated = false;
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
@Override
|
||||
public void onPostResume()
|
||||
{
|
||||
super.onPostResume();
|
||||
if (!mThemeName.equals(Config.UiTheme.getCurrent()))
|
||||
{
|
||||
// Workaround described in https://code.google.com/p/android/issues/detail?id=93731
|
||||
UiThread.runLater(this::recreate);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item)
|
||||
{
|
||||
|
||||
@@ -6,13 +6,11 @@ import android.os.Bundle;
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StyleRes;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import app.organicmaps.R;
|
||||
import app.organicmaps.base.BaseToolbarActivity;
|
||||
import app.organicmaps.sdk.bookmarks.data.BookmarkCategory;
|
||||
import app.organicmaps.sdk.bookmarks.data.BookmarkManager;
|
||||
import app.organicmaps.util.ThemeUtils;
|
||||
|
||||
public class BookmarkCategoriesActivity extends BaseToolbarActivity
|
||||
{
|
||||
@@ -38,13 +36,6 @@ public class BookmarkCategoriesActivity extends BaseToolbarActivity
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
@StyleRes
|
||||
public int getThemeResourceId(@NonNull String theme)
|
||||
{
|
||||
return ThemeUtils.getWindowBgThemeResourceId(theme);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends Fragment> getFragmentClass()
|
||||
{
|
||||
|
||||
@@ -5,13 +5,11 @@ import android.os.Bundle;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StyleRes;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import app.organicmaps.R;
|
||||
import app.organicmaps.base.BaseToolbarActivity;
|
||||
import app.organicmaps.sdk.bookmarks.data.BookmarkCategory;
|
||||
import app.organicmaps.sdk.bookmarks.data.BookmarkManager;
|
||||
import app.organicmaps.util.ThemeUtils;
|
||||
|
||||
public class BookmarkListActivity extends BaseToolbarActivity
|
||||
{
|
||||
@@ -37,13 +35,6 @@ public class BookmarkListActivity extends BaseToolbarActivity
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
@StyleRes
|
||||
public int getThemeResourceId(@NonNull String theme)
|
||||
{
|
||||
return ThemeUtils.getCardBgThemeResourceId(theme);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends Fragment> getFragmentClass()
|
||||
{
|
||||
|
||||
@@ -18,23 +18,22 @@ import app.organicmaps.R;
|
||||
import app.organicmaps.car.SurfaceRenderer;
|
||||
import app.organicmaps.car.screens.base.BaseMapScreen;
|
||||
import app.organicmaps.car.screens.search.SearchOnMapScreen;
|
||||
import app.organicmaps.car.util.ThemeUtils;
|
||||
import app.organicmaps.car.util.UiHelpers;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CategoriesScreen extends BaseMapScreen
|
||||
{
|
||||
private record CategoryData(@StringRes int nameResId, @DrawableRes int iconResId, @DrawableRes int iconNightResId) {}
|
||||
private record CategoryData(@StringRes int nameResId, @DrawableRes int iconResId) {}
|
||||
|
||||
private static final List<CategoryData> CATEGORIES = Arrays.asList(
|
||||
new CategoryData(R.string.category_fuel, R.drawable.ic_category_fuel, R.drawable.ic_category_fuel_night),
|
||||
new CategoryData(R.string.category_parking, R.drawable.ic_category_parking, R.drawable.ic_category_parking_night),
|
||||
new CategoryData(R.string.category_eat, R.drawable.ic_category_eat, R.drawable.ic_category_eat_night),
|
||||
new CategoryData(R.string.category_food, R.drawable.ic_category_food, R.drawable.ic_category_food_night),
|
||||
new CategoryData(R.string.category_hotel, R.drawable.ic_category_hotel, R.drawable.ic_category_hotel_night),
|
||||
new CategoryData(R.string.category_toilet, R.drawable.ic_category_toilet, R.drawable.ic_category_toilet_night),
|
||||
new CategoryData(R.string.category_rv, R.drawable.ic_category_rv, R.drawable.ic_category_rv_night));
|
||||
private static final List<CategoryData> CATEGORIES =
|
||||
Arrays.asList(new CategoryData(R.string.category_fuel, R.drawable.ic_category_fuel),
|
||||
new CategoryData(R.string.category_parking, R.drawable.ic_category_parking),
|
||||
new CategoryData(R.string.category_eat, R.drawable.ic_category_eat),
|
||||
new CategoryData(R.string.category_food, R.drawable.ic_category_food),
|
||||
new CategoryData(R.string.category_hotel, R.drawable.ic_category_hotel),
|
||||
new CategoryData(R.string.category_toilet, R.drawable.ic_category_toilet),
|
||||
new CategoryData(R.string.category_rv, R.drawable.ic_category_rv));
|
||||
|
||||
private final int MAX_CATEGORIES_SIZE;
|
||||
|
||||
@@ -67,7 +66,6 @@ public class CategoriesScreen extends BaseMapScreen
|
||||
@NonNull
|
||||
private GridTemplate createCategoriesListTemplate()
|
||||
{
|
||||
final boolean isNightMode = ThemeUtils.isNightMode(getCarContext());
|
||||
final ItemList.Builder builder = new ItemList.Builder();
|
||||
final int categoriesSize = Math.min(CATEGORIES.size(), MAX_CATEGORIES_SIZE);
|
||||
for (int i = 0; i < categoriesSize; ++i)
|
||||
@@ -75,7 +73,7 @@ public class CategoriesScreen extends BaseMapScreen
|
||||
final GridItem.Builder itemBuilder = new GridItem.Builder();
|
||||
final String title = getCarContext().getString(CATEGORIES.get(i).nameResId);
|
||||
@DrawableRes
|
||||
final int iconResId = isNightMode ? CATEGORIES.get(i).iconNightResId : CATEGORIES.get(i).iconResId;
|
||||
final int iconResId = CATEGORIES.get(i).iconResId;
|
||||
|
||||
itemBuilder.setTitle(title);
|
||||
itemBuilder.setImage(new CarIcon.Builder(IconCompat.createWithResource(getCarContext(), iconResId)).build());
|
||||
|
||||
@@ -13,7 +13,6 @@ import android.widget.TextView;
|
||||
import android.widget.TimePicker;
|
||||
import androidx.annotation.IntRange;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StyleRes;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
@@ -21,7 +20,6 @@ import app.organicmaps.R;
|
||||
import app.organicmaps.base.BaseMwmDialogFragment;
|
||||
import app.organicmaps.sdk.editor.data.HoursMinutes;
|
||||
import app.organicmaps.sdk.util.DateUtils;
|
||||
import app.organicmaps.util.ThemeUtils;
|
||||
import app.organicmaps.util.Utils;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
@@ -79,10 +77,8 @@ public class HoursMinutesPickerFragment extends BaseMwmDialogFragment
|
||||
// noinspection ConstantConditions
|
||||
mTabs.getTabAt(mSelectedTab).select();
|
||||
|
||||
@StyleRes
|
||||
final int theme = ThemeUtils.isNightTheme() ? R.style.MwmMain_DialogFragment_TimePicker_Night
|
||||
: R.style.MwmMain_DialogFragment_TimePicker;
|
||||
final AlertDialog dialog = new MaterialAlertDialogBuilder(requireActivity(), theme)
|
||||
final AlertDialog dialog =
|
||||
new MaterialAlertDialogBuilder(requireActivity(), R.style.MwmMain_DialogFragment_TimePicker)
|
||||
.setView(root)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
@@ -141,9 +137,8 @@ public class HoursMinutesPickerFragment extends BaseMwmDialogFragment
|
||||
mTabs = root.findViewById(R.id.tabs);
|
||||
MaterialTextView tabView = (MaterialTextView) inflater.inflate(R.layout.tab_timepicker, mTabs, false);
|
||||
tabView.setText(getResources().getString(R.string.editor_time_from));
|
||||
final ColorStateList textColor = AppCompatResources.getColorStateList(
|
||||
requireContext(),
|
||||
ThemeUtils.isNightTheme() ? R.color.accent_color_selector_night : R.color.accent_color_selector);
|
||||
final ColorStateList textColor =
|
||||
AppCompatResources.getColorStateList(requireContext(), R.color.accent_color_selector);
|
||||
tabView.setTextColor(textColor);
|
||||
mTabs.addTab(mTabs.newTab().setCustomView(tabView), true);
|
||||
tabView = (MaterialTextView) inflater.inflate(R.layout.tab_timepicker, mTabs, false);
|
||||
|
||||
@@ -2,6 +2,7 @@ package app.organicmaps.maplayer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import androidx.annotation.AttrRes;
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StringRes;
|
||||
@@ -33,31 +34,29 @@ public class LayerBottomSheetItem
|
||||
public static LayerBottomSheetItem create(@NonNull Context mContext, Mode mode,
|
||||
@NonNull OnItemClickListener<LayerBottomSheetItem> layerItemClickListener)
|
||||
{
|
||||
@AttrRes
|
||||
int drawableRes = 0;
|
||||
@DrawableRes
|
||||
int drawableResId = 0;
|
||||
@StringRes
|
||||
int buttonTextResource = R.string.layers_title;
|
||||
switch (mode)
|
||||
{
|
||||
case OUTDOORS:
|
||||
drawableRes = R.attr.outdoorsMenuIcon;
|
||||
drawableResId = R.drawable.ic_layers_outdoors;
|
||||
buttonTextResource = R.string.button_layer_outdoor;
|
||||
break;
|
||||
case SUBWAY:
|
||||
drawableRes = R.attr.subwayMenuIcon;
|
||||
drawableResId = R.drawable.ic_layers_subway;
|
||||
buttonTextResource = R.string.button_layer_subway;
|
||||
break;
|
||||
case ISOLINES:
|
||||
drawableRes = R.attr.isolinesMenuIcon;
|
||||
drawableResId = R.drawable.ic_layers_isoline;
|
||||
buttonTextResource = R.string.button_layer_isolines;
|
||||
break;
|
||||
case TRAFFIC:
|
||||
drawableRes = R.attr.trafficMenuIcon;
|
||||
drawableResId = R.drawable.ic_layers_traffic;
|
||||
buttonTextResource = R.string.button_layer_traffic;
|
||||
break;
|
||||
}
|
||||
@DrawableRes
|
||||
final int drawableResId = ThemeUtils.getResource(mContext, drawableRes);
|
||||
return new LayerBottomSheetItem(drawableResId, buttonTextResource, mode, layerItemClickListener);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,20 +43,19 @@ public class TrafficButton
|
||||
void turnOff()
|
||||
{
|
||||
stopWaitingAnimation();
|
||||
mButton.setImageResource(ThemeUtils.isNightTheme() ? R.drawable.ic_traffic_on_night : R.drawable.ic_traffic_on);
|
||||
mButton.setImageResource(R.drawable.ic_traffic_on);
|
||||
}
|
||||
|
||||
void turnOn()
|
||||
{
|
||||
stopWaitingAnimation();
|
||||
mButton.setImageResource(ThemeUtils.isNightTheme() ? R.drawable.ic_traffic_on_night : R.drawable.ic_traffic_on);
|
||||
mButton.setImageResource(R.drawable.ic_traffic_on);
|
||||
}
|
||||
|
||||
void markAsOutdated()
|
||||
{
|
||||
stopWaitingAnimation();
|
||||
mButton.setImageResource(ThemeUtils.isNightTheme() ? R.drawable.ic_traffic_outdated_night
|
||||
: R.drawable.ic_traffic_outdated);
|
||||
mButton.setImageResource(R.drawable.ic_traffic_outdated);
|
||||
}
|
||||
|
||||
void startWaitingAnimation()
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.google.android.material.textview.MaterialTextView;
|
||||
import app.organicmaps.R;
|
||||
import app.organicmaps.sdk.search.DisplayedCategories;
|
||||
import app.organicmaps.sdk.util.Language;
|
||||
import app.organicmaps.util.ThemeUtils;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.Locale;
|
||||
@@ -91,11 +90,7 @@ class CategoriesAdapter extends RecyclerView.Adapter<CategoriesAdapter.ViewHolde
|
||||
@DrawableRes
|
||||
private static int getDrawableResIdByKey(@NonNull Context context, @NonNull String packageName, @NonNull String key)
|
||||
{
|
||||
final boolean isNightTheme = ThemeUtils.isNightTheme();
|
||||
String iconId = "ic_" + key;
|
||||
if (isNightTheme)
|
||||
iconId = iconId + "_night";
|
||||
return context.getResources().getIdentifier(iconId, "drawable", packageName);
|
||||
return context.getResources().getIdentifier("ic_" + key, "drawable", packageName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,13 +33,6 @@ public class SearchActivity extends BaseMwmFragmentActivity
|
||||
activity.startActivity(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@StyleRes
|
||||
public int getThemeResourceId(@NonNull String theme)
|
||||
{
|
||||
return ThemeUtils.getCardBgThemeResourceId(theme);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends Fragment> getFragmentClass()
|
||||
{
|
||||
|
||||
@@ -12,7 +12,6 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import app.organicmaps.R;
|
||||
import app.organicmaps.util.ThemeUtils;
|
||||
import app.organicmaps.util.Utils;
|
||||
import app.organicmaps.util.WindowInsetUtils.ScrollableContentInsetsListener;
|
||||
|
||||
@@ -35,24 +34,17 @@ abstract class BaseXmlSettingsFragment extends PreferenceFragmentCompat
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context)
|
||||
public void onAttach(@NonNull Context context)
|
||||
{
|
||||
super.onAttach(context);
|
||||
Utils.detachFragmentIfCoreNotInitialized(context, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
int color;
|
||||
if (ThemeUtils.isDefaultTheme())
|
||||
color = ContextCompat.getColor(requireContext(), R.color.bg_cards);
|
||||
else
|
||||
color = ContextCompat.getColor(requireContext(), R.color.bg_cards_night);
|
||||
view.setBackgroundColor(color);
|
||||
|
||||
view.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.bg_cards));
|
||||
RecyclerView recyclerView = getListView();
|
||||
ViewCompat.setOnApplyWindowInsetsListener(recyclerView, new ScrollableContentInsetsListener(recyclerView));
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class SettingsPrefsFragment extends BaseXmlSettingsFragment implements La
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ public class VoiceInstructionsSettingsFragment extends BaseXmlSettingsFragment
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ public enum ThemeSwitcher
|
||||
String oldTheme = Config.UiTheme.getCurrent();
|
||||
|
||||
MapStyle style;
|
||||
if (ThemeUtils.isNightTheme())
|
||||
if (Config.UiTheme.isNight(theme))
|
||||
{
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
|
||||
uiModeManager.setApplicationNightMode(UiModeManager.MODE_NIGHT_YES);
|
||||
|
||||
@@ -6,8 +6,6 @@ import android.util.TypedValue;
|
||||
import androidx.annotation.AttrRes;
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StyleRes;
|
||||
import app.organicmaps.R;
|
||||
import app.organicmaps.sdk.util.Config;
|
||||
|
||||
public final class ThemeUtils
|
||||
@@ -64,28 +62,4 @@ public final class ThemeUtils
|
||||
{
|
||||
return Config.UiTheme.isNavAuto(Config.UiTheme.getUiThemeSettings());
|
||||
}
|
||||
|
||||
@StyleRes
|
||||
public static int getCardBgThemeResourceId(@NonNull String theme)
|
||||
{
|
||||
if (Config.UiTheme.isDefault(theme))
|
||||
return R.style.MwmTheme_CardBg;
|
||||
|
||||
if (Config.UiTheme.isNight(theme))
|
||||
return R.style.MwmTheme_Night_CardBg;
|
||||
|
||||
throw new IllegalArgumentException("Attempt to apply unsupported theme: " + theme);
|
||||
}
|
||||
|
||||
@StyleRes
|
||||
public static int getWindowBgThemeResourceId(@NonNull String theme)
|
||||
{
|
||||
if (Config.UiTheme.isDefault(theme))
|
||||
return R.style.MwmTheme_WindowBg;
|
||||
|
||||
if (Config.UiTheme.isNight(theme))
|
||||
return R.style.MwmTheme_Night_WindowBg;
|
||||
|
||||
throw new IllegalArgumentException("Attempt to apply unsupported theme: " + theme);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,9 +35,8 @@ public class RoutingToolbarButton extends AppCompatRadioButton
|
||||
|
||||
private void initView()
|
||||
{
|
||||
final boolean isNightTheme = ThemeUtils.isNightTheme();
|
||||
setBackgroundResource(isNightTheme ? R.drawable.routing_toolbar_button_night : R.drawable.routing_toolbar_button);
|
||||
setButtonTintList(isNightTheme ? R.color.routing_toolbar_icon_tint_night : R.color.routing_toolbar_icon_tint);
|
||||
setBackgroundResource(R.drawable.routing_toolbar_button);
|
||||
setButtonTintList(R.color.routing_toolbar_icon_tint);
|
||||
}
|
||||
|
||||
public void progress()
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item android:color="@color/base_accent_night"
|
||||
android:state_selected="true"/>
|
||||
|
||||
<item android:color="@color/base_accent_night"
|
||||
android:state_checked="true"/>
|
||||
|
||||
<item android:color="@color/base_accent_night"
|
||||
app:layers_enabled="true"/>
|
||||
|
||||
<item android:color="@color/white_secondary"/>
|
||||
</selector>
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="@color/button_accent_normal_night"
|
||||
android:state_enabled="true"/>
|
||||
|
||||
<item android:color="@color/button_accent_disabled_night"/>
|
||||
</selector>
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="@color/button_normal_night"
|
||||
android:state_enabled="true"/>
|
||||
|
||||
<item android:color="@color/button_disabled_night"/>
|
||||
</selector>
|
||||
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:state_activated="true"
|
||||
android:color="@color/routing_button_activated_tint_night"/>
|
||||
<item
|
||||
android:state_pressed="true"
|
||||
android:color="@color/routing_button_pressed_tint"/>
|
||||
<item
|
||||
android:color="@color/routing_button_tint"/>
|
||||
</selector>
|
||||
|
Before Width: | Height: | Size: 702 B After Width: | Height: | Size: 702 B |
|
Before Width: | Height: | Size: 702 B After Width: | Height: | Size: 702 B |
|
Before Width: | Height: | Size: 718 B After Width: | Height: | Size: 718 B |
|
Before Width: | Height: | Size: 716 B After Width: | Height: | Size: 716 B |
|
Before Width: | Height: | Size: 722 B After Width: | Height: | Size: 722 B |
|
Before Width: | Height: | Size: 712 B After Width: | Height: | Size: 712 B |
|
Before Width: | Height: | Size: 712 B After Width: | Height: | Size: 712 B |
|
Before Width: | Height: | Size: 714 B After Width: | Height: | Size: 714 B |
|
Before Width: | Height: | Size: 718 B After Width: | Height: | Size: 718 B |
|
Before Width: | Height: | Size: 706 B After Width: | Height: | Size: 706 B |
|
Before Width: | Height: | Size: 714 B After Width: | Height: | Size: 714 B |
|
Before Width: | Height: | Size: 714 B After Width: | Height: | Size: 714 B |
|
Before Width: | Height: | Size: 722 B After Width: | Height: | Size: 722 B |
|
Before Width: | Height: | Size: 714 B After Width: | Height: | Size: 714 B |
|
Before Width: | Height: | Size: 712 B After Width: | Height: | Size: 712 B |
|
Before Width: | Height: | Size: 718 B After Width: | Height: | Size: 718 B |
|
Before Width: | Height: | Size: 720 B After Width: | Height: | Size: 720 B |
|
Before Width: | Height: | Size: 708 B After Width: | Height: | Size: 708 B |
|
Before Width: | Height: | Size: 440 B After Width: | Height: | Size: 440 B |
|
Before Width: | Height: | Size: 440 B After Width: | Height: | Size: 440 B |
|
Before Width: | Height: | Size: 442 B After Width: | Height: | Size: 442 B |
|
Before Width: | Height: | Size: 440 B After Width: | Height: | Size: 440 B |
|
Before Width: | Height: | Size: 448 B After Width: | Height: | Size: 448 B |
|
Before Width: | Height: | Size: 454 B After Width: | Height: | Size: 454 B |
|
Before Width: | Height: | Size: 440 B After Width: | Height: | Size: 440 B |
|
Before Width: | Height: | Size: 444 B After Width: | Height: | Size: 444 B |
|
Before Width: | Height: | Size: 448 B After Width: | Height: | Size: 448 B |
|
Before Width: | Height: | Size: 440 B After Width: | Height: | Size: 440 B |
|
Before Width: | Height: | Size: 442 B After Width: | Height: | Size: 442 B |
|
Before Width: | Height: | Size: 440 B After Width: | Height: | Size: 440 B |
|
Before Width: | Height: | Size: 448 B After Width: | Height: | Size: 448 B |
|
Before Width: | Height: | Size: 454 B After Width: | Height: | Size: 454 B |
|
Before Width: | Height: | Size: 442 B After Width: | Height: | Size: 442 B |
|
Before Width: | Height: | Size: 446 B After Width: | Height: | Size: 446 B |
|
Before Width: | Height: | Size: 448 B After Width: | Height: | Size: 448 B |
|
Before Width: | Height: | Size: 442 B After Width: | Height: | Size: 442 B |
|
Before Width: | Height: | Size: 458 B After Width: | Height: | Size: 458 B |
|
Before Width: | Height: | Size: 410 B After Width: | Height: | Size: 410 B |
|
Before Width: | Height: | Size: 454 B After Width: | Height: | Size: 454 B |
|
Before Width: | Height: | Size: 388 B After Width: | Height: | Size: 388 B |
|
Before Width: | Height: | Size: 378 B After Width: | Height: | Size: 378 B |
|
Before Width: | Height: | Size: 86 B After Width: | Height: | Size: 86 B |
|
Before Width: | Height: | Size: 86 B After Width: | Height: | Size: 86 B |
|
Before Width: | Height: | Size: 346 B After Width: | Height: | Size: 346 B |
|
Before Width: | Height: | Size: 322 B After Width: | Height: | Size: 322 B |
|
Before Width: | Height: | Size: 346 B After Width: | Height: | Size: 346 B |
|
Before Width: | Height: | Size: 314 B After Width: | Height: | Size: 314 B |
|
Before Width: | Height: | Size: 298 B After Width: | Height: | Size: 298 B |
|
Before Width: | Height: | Size: 72 B After Width: | Height: | Size: 72 B |
|
Before Width: | Height: | Size: 68 B After Width: | Height: | Size: 68 B |
|
Before Width: | Height: | Size: 522 B After Width: | Height: | Size: 522 B |
|
Before Width: | Height: | Size: 478 B After Width: | Height: | Size: 478 B |
|
Before Width: | Height: | Size: 528 B After Width: | Height: | Size: 528 B |
|
Before Width: | Height: | Size: 494 B After Width: | Height: | Size: 494 B |
|
Before Width: | Height: | Size: 474 B After Width: | Height: | Size: 474 B |
|
Before Width: | Height: | Size: 94 B After Width: | Height: | Size: 94 B |
|
Before Width: | Height: | Size: 92 B After Width: | Height: | Size: 92 B |
|
Before Width: | Height: | Size: 798 B After Width: | Height: | Size: 798 B |
|
Before Width: | Height: | Size: 762 B After Width: | Height: | Size: 762 B |
|
Before Width: | Height: | Size: 802 B After Width: | Height: | Size: 802 B |
|
Before Width: | Height: | Size: 704 B After Width: | Height: | Size: 704 B |
|
Before Width: | Height: | Size: 678 B After Width: | Height: | Size: 678 B |
|
Before Width: | Height: | Size: 130 B After Width: | Height: | Size: 130 B |
|
Before Width: | Height: | Size: 112 B After Width: | Height: | Size: 112 B |
|
Before Width: | Height: | Size: 738 B After Width: | Height: | Size: 738 B |
|
Before Width: | Height: | Size: 734 B After Width: | Height: | Size: 734 B |
|
Before Width: | Height: | Size: 670 B After Width: | Height: | Size: 670 B |
|
Before Width: | Height: | Size: 870 B After Width: | Height: | Size: 870 B |
|
Before Width: | Height: | Size: 828 B After Width: | Height: | Size: 828 B |
|
Before Width: | Height: | Size: 134 B After Width: | Height: | Size: 134 B |
|
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 110 B |