switched implementation to ussing attr
This commit is contained in:
parent
fd83665970
commit
a80435a03b
@ -8,6 +8,7 @@ import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -34,7 +35,6 @@ import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.core.feed.Feed;
|
||||
import de.danoeh.antennapod.core.glide.ApGlideSettings;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.util.ThemeUtils;
|
||||
import de.danoeh.antennapod.fragment.AddFeedFragment;
|
||||
import de.danoeh.antennapod.fragment.AllEpisodesFragment;
|
||||
import de.danoeh.antennapod.fragment.DownloadsFragment;
|
||||
@ -215,12 +215,25 @@ public class NavListAdapter extends BaseAdapter
|
||||
}
|
||||
if (v != null && viewType != VIEW_TYPE_SECTION_DIVIDER) {
|
||||
TextView txtvTitle = v.findViewById(R.id.txtvTitle);
|
||||
TypedValue typedValue = new TypedValue();
|
||||
|
||||
if (position == itemAccess.getSelectedItemIndex()) {
|
||||
txtvTitle.setTypeface(null, Typeface.BOLD);
|
||||
v.setBackgroundResource(ThemeUtils.getSelectionDrawerActivatedColor());
|
||||
v.getContext().getTheme().resolveAttribute(de.danoeh.antennapod.core.R.attr.drawer_activated_color, typedValue, true);
|
||||
int[] attribute = new int[] { de.danoeh.antennapod.core.R.attr.drawer_activated_color };
|
||||
TypedArray array = v.getContext().obtainStyledAttributes(typedValue.resourceId, attribute);
|
||||
int backgroundResource = array.getColor(0, 0);
|
||||
array.recycle();
|
||||
v.setBackgroundColor(backgroundResource);
|
||||
|
||||
} else {
|
||||
txtvTitle.setTypeface(null, Typeface.NORMAL);
|
||||
v.setBackgroundResource(ThemeUtils.getSelectionDrawerNotActivatedColor());
|
||||
v.getContext().getTheme().resolveAttribute(de.danoeh.antennapod.core.R.attr.nav_drawer_background, typedValue, true);
|
||||
int[] attribute = new int[] { de.danoeh.antennapod.core.R.attr.nav_drawer_background};
|
||||
TypedArray array = v.getContext().obtainStyledAttributes(typedValue.resourceId, attribute);
|
||||
int backgroundResource = array.getColor(0, 0);
|
||||
array.recycle();
|
||||
v.setBackgroundColor(backgroundResource);
|
||||
}
|
||||
}
|
||||
return v;
|
||||
|
@ -29,38 +29,6 @@ public class ThemeUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static int getSelectionDrawerActivatedColor() {
|
||||
int theme = UserPreferences.getTheme();
|
||||
if (theme == R.style.Theme_AntennaPod_Dark) {
|
||||
return R.color.overlay_dark;
|
||||
} else if (theme == R.style.Theme_AntennaPod_TrueBlack){
|
||||
return R.color.highlight_trueblack;
|
||||
} else if (theme == R.style.Theme_AntennaPod_Light) {
|
||||
return R.color.highlight_light;
|
||||
} else {
|
||||
Log.e(TAG,
|
||||
"getSelectionDrawerActivatedColor could not match the current theme to any color!");
|
||||
return R.color.highlight_light;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int getSelectionDrawerNotActivatedColor() {
|
||||
int theme = UserPreferences.getTheme();
|
||||
if (theme == R.style.Theme_AntennaPod_Dark) {
|
||||
return R.color.darktheme_drawer;
|
||||
} else if (theme == R.style.Theme_AntennaPod_TrueBlack){
|
||||
return R.color.black;
|
||||
} else if (theme == R.style.Theme_AntennaPod_Light) {
|
||||
return R.color.primary_light;
|
||||
} else {
|
||||
Log.e(TAG,
|
||||
"getSelectionDrawerNotActivatedColor could not match the current theme to any color!");
|
||||
return R.color.highlight_light;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static @ColorInt int getColorFromAttr(Context context, @AttrRes int attr) {
|
||||
TypedValue typedValue = new TypedValue();
|
||||
context.getTheme().resolveAttribute(attr, typedValue, true);
|
||||
|
@ -67,6 +67,7 @@
|
||||
<attr name="overlay_background" format="color"/>
|
||||
|
||||
<attr name="nav_drawer_background" format="color"/>
|
||||
<attr name="drawer_activated_color" format="color"/>
|
||||
|
||||
<attr name="about_screen_background" format="color"/>
|
||||
<attr name="about_screen_card_background" format="color"/>
|
||||
|
@ -29,8 +29,8 @@
|
||||
<!-- Theme colors -->
|
||||
<color name="primary_light">#FFFFFF</color>
|
||||
<color name="primary_darktheme">#212121</color>
|
||||
<color name="darktheme_drawer">#3B3B3B</color>
|
||||
|
||||
<color name="nav_drawer_background_dark">#3B3B3B</color>
|
||||
<color name="nav_drawer_highlighted_dark">#212121</color>
|
||||
<color name="highlight_light">#DDDDDD</color>
|
||||
<color name="highlight_dark">#414141</color>
|
||||
<color name="highlight_trueblack">#414141</color>
|
||||
|
@ -43,6 +43,7 @@
|
||||
<item type="attr" name="dragview_background">@drawable/ic_drag_vertical_grey600_48dp</item>
|
||||
<item type="attr" name="dragview_float_background">@color/white</item>
|
||||
<item type="attr" name="nav_drawer_background">@color/white</item>
|
||||
<item type="attr" name="drawer_activated_color">@color/highlight_light</item>
|
||||
<item type="attr" name="ic_new">@drawable/ic_new_releases_grey600_24dp</item>
|
||||
<item type="attr" name="ic_history">@drawable/ic_history_grey600_24dp</item>
|
||||
<item type="attr" name="ic_folder">@drawable/ic_folder_grey600_24dp</item>
|
||||
@ -125,7 +126,8 @@
|
||||
<item type="attr" name="overlay_drawable">@drawable/overlay_drawable_dark</item>
|
||||
<item type="attr" name="dragview_background">@drawable/ic_drag_vertical_white_48dp</item>
|
||||
<item type="attr" name="dragview_float_background">@color/black</item>
|
||||
<item type="attr" name="nav_drawer_background">#3B3B3B</item>
|
||||
<item type="attr" name="nav_drawer_background">@color/nav_drawer_background_dark</item>
|
||||
<item type="attr" name="drawer_activated_color">@color/nav_drawer_highlighted_dark</item>
|
||||
<item type="attr" name="ic_new">@drawable/ic_new_releases_white_24dp</item>
|
||||
<item type="attr" name="ic_history">@drawable/ic_history_white_24dp</item>
|
||||
<item type="attr" name="ic_folder">@drawable/ic_folder_white_24dp</item>
|
||||
@ -175,6 +177,7 @@
|
||||
<item type="attr" name="dragview_background">@drawable/ic_drag_vertical_white_48dp</item>
|
||||
<item type="attr" name="dragview_float_background">@color/black</item>
|
||||
<item type="attr" name="nav_drawer_background">@color/black</item>
|
||||
<item type="attr" name="drawer_activated_color">@color/highlight_trueblack</item>
|
||||
<item name="android:textColorPrimary">@color/white</item>
|
||||
<item name="android:color">@color/white</item>
|
||||
<item name="android:colorBackground">@color/black</item>
|
||||
@ -228,6 +231,7 @@
|
||||
<item type="attr" name="dragview_background">@drawable/ic_drag_vertical_grey600_48dp</item>
|
||||
<item type="attr" name="dragview_float_background">@color/white</item>
|
||||
<item type="attr" name="nav_drawer_background">@color/white</item>
|
||||
<item type="attr" name="drawer_activated_color">@color/highlight_light</item>
|
||||
<item type="attr" name="ic_new">@drawable/ic_new_releases_grey600_24dp</item>
|
||||
<item type="attr" name="ic_history">@drawable/ic_history_grey600_24dp</item>
|
||||
<item type="attr" name="ic_folder">@drawable/ic_folder_grey600_24dp</item>
|
||||
@ -309,7 +313,8 @@
|
||||
<item type="attr" name="overlay_drawable">@drawable/overlay_drawable_dark</item>
|
||||
<item type="attr" name="dragview_background">@drawable/ic_drag_vertical_white_48dp</item>
|
||||
<item type="attr" name="dragview_float_background">@color/black</item>
|
||||
<item type="attr" name="nav_drawer_background">#3B3B3B</item>
|
||||
<item type="attr" name="nav_drawer_background">@color/nav_drawer_background_dark</item>
|
||||
<item type="attr" name="drawer_activated_color">@color/nav_drawer_highlighted_dark</item>
|
||||
<item type="attr" name="ic_new">@drawable/ic_new_releases_white_24dp</item>
|
||||
<item type="attr" name="ic_history">@drawable/ic_history_white_24dp</item>
|
||||
<item type="attr" name="ic_folder">@drawable/ic_folder_white_24dp</item>
|
||||
@ -359,6 +364,7 @@
|
||||
<item type="attr" name="dragview_background">@drawable/ic_drag_vertical_white_48dp</item>
|
||||
<item type="attr" name="dragview_float_background">@color/black</item>
|
||||
<item type="attr" name="nav_drawer_background">@color/black</item>
|
||||
<item type="attr" name="drawer_activated_color">@color/highlight_trueblack</item>
|
||||
<item type="attr" name="currently_playing_background">@color/highlight_trueblack</item>
|
||||
<item name="android:textColorPrimary">@color/white</item>
|
||||
<item name="android:color">@color/white</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user