From 7b5e831b66d35375e39e903a9e0d18e46f1cb0a6 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 4 Aug 2014 18:53:26 -0400 Subject: [PATCH] darken category menu button on the dark theme to match the theme This commit uses alpha to make the category menu button appear darker to match the rest of the dark theme. Since the background is black, the alpha makes it darker. It is only used on the dark theme since alpha would lighten the menu button on the light themes, and that would make it a worse match. --- .../views/fragments/AvailableAppsFragment.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/org/fdroid/fdroid/views/fragments/AvailableAppsFragment.java b/src/org/fdroid/fdroid/views/fragments/AvailableAppsFragment.java index 6d43781b5..e8325ecd4 100644 --- a/src/org/fdroid/fdroid/views/fragments/AvailableAppsFragment.java +++ b/src/org/fdroid/fdroid/views/fragments/AvailableAppsFragment.java @@ -6,10 +6,13 @@ import android.content.SharedPreferences; import android.content.res.Resources; import android.database.ContentObserver; import android.database.Cursor; +import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build; import android.os.Bundle; +import android.preference.PreferenceManager; import android.support.v4.app.LoaderManager; +import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -97,8 +100,7 @@ public class AvailableAppsFragment extends AppListFragment implements // attempt to translate category names with fallback to default name List translatedCategories = new ArrayList(categories.size()); Resources res = getResources(); - for (String category : categories) - { + for (String category : categories) { int id = res.getIdentifier(category.replace(" & ", "_"), "string", getActivity().getPackageName()); translatedCategories.add(id == 0 ? category : getString(id)); } @@ -108,8 +110,15 @@ public class AvailableAppsFragment extends AppListFragment implements // functionality do its stuff. categorySpinner.setId(R.id.categorySpinner); // with holo, the menu gets lost since it looks the same as an app list item - if (Build.VERSION.SDK_INT >= 14) - categorySpinner.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.btn_dropdown)); + if (Build.VERSION.SDK_INT >= 14) { + Drawable menuButton = getResources().getDrawable(android.R.drawable.btn_dropdown); + if (TextUtils.equals("dark", + PreferenceManager.getDefaultSharedPreferences(getActivity()) + .getString(Preferences.PREF_THEME, "dark"))) { + menuButton.setAlpha(32); // make it darker via alpha + } + categorySpinner.setBackgroundDrawable(menuButton); + } ArrayAdapter adapter = new ArrayAdapter( getActivity(), android.R.layout.simple_spinner_item, translatedCategories);