forked from organicmaps/organicmaps
[android] Review fixes.
This commit is contained in:
parent
deeee25526
commit
44121ab3f3
9 changed files with 44 additions and 32 deletions
|
@ -10,6 +10,7 @@ import android.os.Build;
|
|||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.StyleRes;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
@ -381,7 +382,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getThemeResourceId(String theme)
|
||||
@StyleRes
|
||||
public int getThemeResourceId(@NonNull String theme)
|
||||
{
|
||||
if (ThemeUtils.isDefaultTheme(theme))
|
||||
return R.style.MwmTheme_MainActivity;
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package com.mapswithme.maps.base;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.StyleRes;
|
||||
|
||||
public interface BaseActivity
|
||||
{
|
||||
Activity get();
|
||||
int getThemeResourceId(String theme);
|
||||
@StyleRes
|
||||
int getThemeResourceId(@NonNull String theme);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.media.AudioManager;
|
|||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.StyleRes;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
|
@ -31,7 +32,8 @@ public class BaseMwmFragmentActivity extends AppCompatActivity
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getThemeResourceId(String theme)
|
||||
@StyleRes
|
||||
public int getThemeResourceId(@NonNull String theme)
|
||||
{
|
||||
if (ThemeUtils.isDefaultTheme(theme))
|
||||
return R.style.MwmTheme;
|
||||
|
|
|
@ -1,23 +1,19 @@
|
|||
package com.mapswithme.maps.bookmarks;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.StyleRes;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.BaseToolbarActivity;
|
||||
import com.mapswithme.util.ThemeUtils;
|
||||
|
||||
public class BookmarkCategoriesActivity extends BaseToolbarActivity
|
||||
{
|
||||
@Override
|
||||
public int getThemeResourceId(String theme)
|
||||
@StyleRes
|
||||
public int getThemeResourceId(@NonNull String theme)
|
||||
{
|
||||
if (ThemeUtils.isDefaultTheme(theme))
|
||||
return R.style.MwmTheme_CardBg;
|
||||
|
||||
if (ThemeUtils.isNightTheme(theme))
|
||||
return R.style.MwmTheme_Night_CardBg;
|
||||
|
||||
throw new IllegalArgumentException("Attempt to apply unsupported theme: " + theme);
|
||||
return ThemeUtils.getCardBgThemeResourceId(theme);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,23 +1,19 @@
|
|||
package com.mapswithme.maps.bookmarks;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.StyleRes;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.BaseToolbarActivity;
|
||||
import com.mapswithme.util.ThemeUtils;
|
||||
|
||||
public class BookmarkListActivity extends BaseToolbarActivity
|
||||
{
|
||||
@Override
|
||||
public int getThemeResourceId(String theme)
|
||||
@StyleRes
|
||||
public int getThemeResourceId(@NonNull String theme)
|
||||
{
|
||||
if (ThemeUtils.isDefaultTheme(theme))
|
||||
return R.style.MwmTheme_CardBg;
|
||||
|
||||
if (ThemeUtils.isNightTheme(theme))
|
||||
return R.style.MwmTheme_Night_CardBg;
|
||||
|
||||
throw new IllegalArgumentException("Attempt to apply unsupported theme: " + theme);
|
||||
return ThemeUtils.getCardBgThemeResourceId(theme);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.graphics.Bitmap;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.StyleRes;
|
||||
import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
|
||||
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
|
||||
import android.support.v4.view.ViewPager;
|
||||
|
@ -95,7 +96,8 @@ public class FullScreenGalleryActivity extends BaseMwmFragmentActivity
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getThemeResourceId(String theme)
|
||||
@StyleRes
|
||||
public int getThemeResourceId(@NonNull String theme)
|
||||
{
|
||||
if (ThemeUtils.isDefaultTheme(theme))
|
||||
return R.style.MwmTheme_FullScreenGalleryActivity;
|
||||
|
|
|
@ -2,11 +2,12 @@ package com.mapswithme.maps.search;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.StyleRes;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.NavUtils;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.activity.CustomNavigateUpListener;
|
||||
import com.mapswithme.maps.base.BaseMwmFragmentActivity;
|
||||
import com.mapswithme.maps.base.OnBackPressListener;
|
||||
|
@ -24,15 +25,10 @@ public class SearchActivity extends BaseMwmFragmentActivity implements CustomNav
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getThemeResourceId(String theme)
|
||||
@StyleRes
|
||||
public int getThemeResourceId(@NonNull String theme)
|
||||
{
|
||||
if (ThemeUtils.isDefaultTheme(theme))
|
||||
return R.style.MwmTheme_CardBg;
|
||||
|
||||
if (ThemeUtils.isNightTheme(theme))
|
||||
return R.style.MwmTheme_Night_CardBg;
|
||||
|
||||
throw new IllegalArgumentException("Attempt to apply unsupported theme: " + theme);
|
||||
return ThemeUtils.getCardBgThemeResourceId(theme);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,6 +9,7 @@ import android.os.Bundle;
|
|||
import android.preference.PreferenceActivity;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.annotation.StyleRes;
|
||||
import android.support.v7.app.AppCompatDelegate;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -49,7 +50,8 @@ public class SettingsActivity extends PreferenceActivity
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getThemeResourceId(String theme)
|
||||
@StyleRes
|
||||
public int getThemeResourceId(@NonNull String theme)
|
||||
{
|
||||
if (ThemeUtils.isDefaultTheme(theme))
|
||||
return R.style.MwmTheme_Settings;
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.content.res.TypedArray;
|
||||
import android.support.annotation.AttrRes;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.StyleRes;
|
||||
import android.support.v7.internal.view.ContextThemeWrapper;
|
||||
import android.util.TypedValue;
|
||||
|
@ -91,4 +92,16 @@ public final class ThemeUtils
|
|||
return (THEME_DEFAULT.equals(theme) ||
|
||||
THEME_NIGHT.equals(theme));
|
||||
}
|
||||
|
||||
@StyleRes
|
||||
public static int getCardBgThemeResourceId(@NonNull String theme)
|
||||
{
|
||||
if (isDefaultTheme(theme))
|
||||
return R.style.MwmTheme_CardBg;
|
||||
|
||||
if (isNightTheme(theme))
|
||||
return R.style.MwmTheme_Night_CardBg;
|
||||
|
||||
throw new IllegalArgumentException("Attempt to apply unsupported theme: " + theme);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue