List of usage examples for android.graphics.drawable Drawable setColorFilter
public void setColorFilter(@ColorInt int color, @NonNull PorterDuff.Mode mode)
From source file:com.oprisnik.navdrawer.NavDrawerActivity.java
public void showUpNavigation(boolean show) { mUpNavigation = show;/*from w w w.j a va 2 s.c o m*/ getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); Drawable drawable = getResources().getDrawable(show ? R.drawable.ic_back : R.drawable.ic_menu); int colorControlNormal = Utils.getAttrColor(R.attr.colorControlNormal, getSupportActionBar().getThemedContext()); drawable.setColorFilter(colorControlNormal, PorterDuff.Mode.SRC_IN); getSupportActionBar().setHomeAsUpIndicator(drawable); }
From source file:cw.kop.autobackground.tutorial.ButtonFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = AppSettings.getTheme().equals(AppSettings.APP_LIGHT_THEME) ? inflater.inflate(R.layout.tutorial_button_fragment, container, false) : inflater.inflate(R.layout.tutorial_button_fragment_dark, container, false); int colorFilterInt = AppSettings.getColorFilterInt(appContext); ImageView deleteButton = (ImageView) view.findViewById(R.id.source_delete_button); ImageView viewButton = (ImageView) view.findViewById(R.id.source_view_image_button); ImageView editButton = (ImageView) view.findViewById(R.id.source_edit_button); Drawable deleteDrawable = getResources().getDrawable(R.drawable.ic_delete_white_24dp); Drawable viewDrawable = getResources().getDrawable(R.drawable.ic_photo_white_24dp); Drawable editDrawable = getResources().getDrawable(R.drawable.ic_edit_white_24dp); deleteDrawable.setColorFilter(colorFilterInt, PorterDuff.Mode.MULTIPLY); viewDrawable.setColorFilter(colorFilterInt, PorterDuff.Mode.MULTIPLY); editDrawable.setColorFilter(colorFilterInt, PorterDuff.Mode.MULTIPLY); deleteButton.setImageDrawable(deleteDrawable); viewButton.setImageDrawable(viewDrawable); editButton.setImageDrawable(editDrawable); deleteButton.setOnClickListener(null); viewButton.setOnClickListener(null); editButton.setOnClickListener(null); TextView addTitleText = (TextView) view.findViewById(R.id.add_title_text); addTitleText.setTextColor(colorFilterInt); addTitleText.setText("Adding new sources"); TextView addTutorialText = (TextView) view.findViewById(R.id.add_tutorial_text); addTutorialText.setTextColor(colorFilterInt); addTutorialText.setText("Easily add a new source from a variety of different places."); TextView buttonTitleText = (TextView) view.findViewById(R.id.button_title_text); buttonTitleText.setTextColor(colorFilterInt); buttonTitleText.setText("Source actions"); TextView buttonTutorialText = (TextView) view.findViewById(R.id.button_tutorial_text); buttonTutorialText.setTextColor(colorFilterInt); buttonTutorialText.setText("Delete, view, and edit each source."); return view;//from w w w. j a v a 2s.c o m }
From source file:cw.kop.autobackground.tutorial.ActionBarFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.tutorial_action_bar_fragment, container, false); int colorFilterInt = AppSettings.getColorFilterInt(appContext); Toolbar buttonToolbar = (Toolbar) view.findViewById(R.id.button_toolbar); buttonToolbar.setTitleTextAppearance(appContext, R.style.ToolbarTitle); buttonToolbar.inflateMenu(R.menu.source_list_menu); Menu menu = buttonToolbar.getMenu(); Drawable refreshIcon = getResources().getDrawable(R.drawable.ic_refresh_white_24dp); Drawable downloadIcon = getResources().getDrawable(R.drawable.ic_file_download_white_24dp); Drawable storageIcon = getResources().getDrawable(R.drawable.ic_sort_white_24dp); refreshIcon.setColorFilter(colorFilterInt, PorterDuff.Mode.MULTIPLY); downloadIcon.setColorFilter(colorFilterInt, PorterDuff.Mode.MULTIPLY); storageIcon.setColorFilter(colorFilterInt, PorterDuff.Mode.MULTIPLY); menu.getItem(0).setIcon(refreshIcon); menu.getItem(1).setIcon(downloadIcon); menu.getItem(2).setIcon(storageIcon); TextView buttonTitleText = (TextView) view.findViewById(R.id.button_title_text); buttonTitleText.setTextColor(colorFilterInt); buttonTitleText.setText("ActionBar buttons"); TextView buttonTutorialText = (TextView) view.findViewById(R.id.button_tutorial_text); buttonTutorialText.setTextColor(colorFilterInt); buttonTutorialText.setText("Cycle wallpaper, download new images, and sort sources. " + "Hit download after adding some sources to fetch the images."); Toolbar settingToolbar = (Toolbar) view.findViewById(R.id.setting_toolbar); Drawable navIcon = getResources().getDrawable(R.drawable.drawer_menu_white); navIcon.setColorFilter(colorFilterInt, PorterDuff.Mode.MULTIPLY); settingToolbar.setNavigationIcon(navIcon); TextView settingTitleText = (TextView) view.findViewById(R.id.setting_title_text); settingTitleText.setTextColor(colorFilterInt); settingTitleText.setText("More settings"); TextView settingTutorialText = (TextView) view.findViewById(R.id.setting_tutorial_text); settingTutorialText.setTextColor(colorFilterInt); settingTutorialText.setText("Open the drawer to access additional settings."); return view;//from w w w . j av a 2s. c om }
From source file:com.wojtechnology.sunami.NavigationDrawerFragment.java
public void updateChoices(int state) { ImageView songIcon = (ImageView) getActivity().findViewById(R.id.by_song_icon); ImageView artistIcon = (ImageView) getActivity().findViewById(R.id.by_artist_icon); Drawable songD; Drawable artistD;// w w w .ja va 2s . com if (state == MainActivity.STATE_SONGS) { songD = getActivity().getResources().getDrawable(R.drawable.ic_my_library_music_white_36dp); songD.setColorFilter(0xffffab40, PorterDuff.Mode.MULTIPLY); artistD = getActivity().getResources().getDrawable(R.drawable.ic_recent_actors_grey600_36dp); } else { songD = getActivity().getResources().getDrawable(R.drawable.ic_my_library_music_grey600_36dp); artistD = getActivity().getResources().getDrawable(R.drawable.ic_recent_actors_white_36dp); artistD.setColorFilter(0xffffab40, PorterDuff.Mode.MULTIPLY); } songIcon.setImageDrawable(songD); artistIcon.setImageDrawable(artistD); }
From source file:com.geecko.QuickLyric.AboutActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); int[] themes = new int[] { R.style.Theme_QuickLyric, R.style.Theme_QuickLyric_Red, R.style.Theme_QuickLyric_Purple, R.style.Theme_QuickLyric_Indigo, R.style.Theme_QuickLyric_Green, R.style.Theme_QuickLyric_Lime, R.style.Theme_QuickLyric_Brown, R.style.Theme_QuickLyric_Dark }; int themeNum = Integer.valueOf(sharedPref.getString("pref_theme", "0")); boolean nightMode = sharedPref.getBoolean("pref_night_mode", false); if (nightMode && NightTimeVerifier.check(this)) setTheme(R.style.Theme_QuickLyric_Night); else/*w ww .j a v a2 s.c om*/ setTheme(themes[themeNum]); TypedValue primaryColor = new TypedValue(); getTheme().resolveAttribute(R.attr.colorPrimary, primaryColor, true); setStatusBarColor(null); LinearLayout linearLayout = new LinearLayout(this); linearLayout.setOrientation(LinearLayout.VERTICAL); Toolbar toolbar = new Toolbar(this); toolbar.setTitle(R.string.pref_about); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) toolbar.setElevation(8f); toolbar.setBackgroundColor(primaryColor.data); toolbar.setTitleTextColor(Color.WHITE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription(null, null, primaryColor.data); this.setTaskDescription(taskDescription); } View.OnClickListener productTourAction = new View.OnClickListener() { @Override public void onClick(View v) { setupDemoScreen(); } }; Element productTourElement = new Element().setTitle(getString(R.string.about_product_tour)); productTourElement.setOnClickListener(productTourAction); Element crowdinElement = new Element().setTitle(getString(R.string.about_crowdin)); crowdinElement .setIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("https://crowdin.com/project/quicklyric"))); Element ossLicensesElement = new Element().setTitle("Open Source Licenses"); ossLicensesElement.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { WebView webView = new WebView(AboutActivity.this); String data = getResources().getString(R.string.open_source_librairies_licenses); webView.loadData(data, "text/html; charset=utf-8", "UTF-8"); new AlertDialog.Builder(AboutActivity.this).setView(webView).show(); } }); Element tosElement = new Element().setTitle(getString(R.string.about_read_ToS)); tosElement.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { WebView webView = new WebView(AboutActivity.this); String data = getResources().getString(R.string.QL_EULA); webView.loadData(data, "text/html; charset=utf-8", "UTF-8"); new AlertDialog.Builder(AboutActivity.this).setView(webView).show(); } }); Element cookElement = new Element().setTitle("Icon Designer"); cookElement.setIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("https://cookicons.co/"))); View aboutView = new AboutPage(this).setDescription("QuickLyric is made with love in Brussels, Belgium.") // FixMe .addEmail("contact@QuickLyric.be").addFacebook("QuickLyric").addGitHub("geecko86/QuickLyric") .addPlayStore("test").addTwitter("QuickLyric").addWebsite("http://www.quicklyric.be") .setImage(R.drawable.icon).addItem(productTourElement).addItem(crowdinElement).addItem(cookElement) .addItem(ossLicensesElement).addItem(tosElement).create(); aboutView.setLayoutParams(new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); linearLayout.addView(toolbar); linearLayout.addView(aboutView); setContentView(linearLayout); final Drawable upArrow; if (Build.VERSION.SDK_INT >= 21) { upArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_material); upArrow.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP); } else upArrow = getResources().getDrawable(R.drawable.ic_arrow_back); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeAsUpIndicator(upArrow); }
From source file:com.mooo.ziggypop.candconline.SettingsActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.settings_layout); mToolBar = (Toolbar) findViewById(R.id.settings_toolbar); mToolBar.setTitle(R.string.settings); Drawable backButton = ContextCompat.getDrawable(getApplicationContext(), R.mipmap.my_abc_ic_ab_back_mtrl_am_alpha); backButton.setColorFilter(getResources().getColor(R.color.black), PorterDuff.Mode.MULTIPLY); mToolBar.setNavigationIcon(backButton); mToolBar.setNavigationOnClickListener(new View.OnClickListener() { @Override/* w w w .j a va2 s.c o m*/ public void onClick(View v) { finish(); } }); setSupportActionBar(mToolBar); assert getSupportActionBar() != null; // I'm only doing this to make the IDE stop yelling at me, I know its not null, I just set it... getSupportActionBar().setDefaultDisplayHomeAsUpEnabled(true); //set the bar colors if (getIntent().getExtras() != null) { // set the color of the toolbar based on the current game. currentGame = getIntent().getExtras().getInt("current_game"); switch (currentGame) { case 1: setBarColors(R.color.kw_red); break; case 2: setBarColors(R.color.cnc3_green); break; case 3: setBarColors(R.color.generals_yellow); break; case 4: setBarColors(R.color.zh_orange); break; case 5: setBarColors(R.color.ra3_red); break; } } dbViewIntent = new Intent(getApplicationContext(), PlayerDatabaseViewerActivity.class); dbViewIntent.putExtra("current_game", currentGame); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); Log.v(TAG, "Current interval = " + preferences.getString("time_interval_pref", "15")); //swap in the settings fragment getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new SettingsFragment()) .commit(); }
From source file:de.vanita5.twittnuker.util.ThemeUtils.java
public static void applyColorFilterToMenuIcon(final Menu menu, final int color, final int popupColor, final int highlightColor, final Mode mode, final int... excludedGroups) { for (int i = 0, j = menu.size(); i < j; i++) { final MenuItem item = menu.getItem(i); final Drawable icon = item.getIcon(); final ContextMenuInfo info = item.getMenuInfo(); if (icon != null && !ArrayUtils.contains(excludedGroups, item.getGroupId())) { icon.mutate();/*from w w w .ja va2s . c o m*/ if (info instanceof TwidereMenuInfo) { final TwidereMenuInfo sInfo = (TwidereMenuInfo) info; icon.setColorFilter(sInfo.isHighlight() ? sInfo.getHighlightColor(highlightColor) : color, mode); } else { icon.setColorFilter(color, mode); } } if (item.hasSubMenu()) { // SubMenu item is always in popup applyColorFilterToMenuIcon(item.getSubMenu(), popupColor, popupColor, highlightColor, mode, excludedGroups); } } }
From source file:org.vshgap.ui.Components.PagerSlidingTabStrip.java
private void paintTabIcons(int position) { SharedPreferences themePrefs = ApplicationLoader.applicationContext .getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); int tabColor = themePrefs.getInt("chatEmojiViewTabColor", AndroidUtilities.getIntDarkerColor("themeColor", -0x15)); Drawable icon = getResources().getDrawable(icons[position]); icon.setColorFilter(tabColor, PorterDuff.Mode.SRC_IN); }
From source file:com.joaquimley.faboptions.FabOptions.java
private void setBackgroundColor(Context context, @ColorInt int backgroundColor) { Drawable backgroundShape = ContextCompat.getDrawable(context, R.drawable.faboptions_background); backgroundShape.setColorFilter(backgroundColor, PorterDuff.Mode.ADD); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { mBackground.setBackground(backgroundShape); } else {//from w w w.ja v a 2s . c o m mBackground.setBackgroundDrawable(backgroundShape); } }
From source file:com.mk4droid.IMC_Activities.Fragment_Comments.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { vfrag_comments = inflater.inflate(R.layout.fragment_comments, container, false); mfrag_comments = this; ctx = vfrag_comments.getContext();//from w ww. j a va 2s . c o m resources = setResources(); //------------ Title --------- TextView tvTitle = (TextView) vfrag_comments.findViewById(R.id.tv_Comments_GrandTitle); tvTitle.setText(issueTitle); //------- no comments tv-------- tvNoCom = (TextView) vfrag_comments.findViewById(R.id.tvnoComments); // Comments added from a new thread so as to avoid delays TabComments = (TableLayout) vfrag_comments.findViewById(R.id.tlComments); lparams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); //-------- Enable send Comment button Button btComment = (Button) vfrag_comments.findViewById(R.id.btAddComment); // -------- Enable Commenting EditText EditText etComment = (EditText) vfrag_comments.findViewById(R.id.etComment); if (AuthFlag && InternetConnCheck.getInstance(ctx).isOnline(ctx)) { etComment.setEnabled(true); // Make icon drawable more vivid Drawable dr = resources.getDrawable(R.drawable.ic_send_holo_light); dr.setColorFilter(resources.getColor(R.color.orange), android.graphics.PorterDuff.Mode.SRC_ATOP); btComment.setCompoundDrawablesWithIntrinsicBounds(null, dr, null, null); btComment.setCompoundDrawablePadding(-40); } else { etComment.setEnabled(false); } btComment.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { //================ SEND COMMENT TO DB =============== EditText etComment = (EditText) vfrag_comments.findViewById(R.id.etComment); CommSTR = etComment.getText().toString(); if (CommSTR.length() > 0 && InternetConnCheck.getInstance(ctx).isOnline(ctx) && AuthFlag) { new AsynchTask_SendComment().execute(); } else if (!InternetConnCheck.getInstance(ctx).isOnline(ctx)) { Toast.makeText(ctx, resources.getString(R.string.NoInternet), Toast.LENGTH_SHORT).show(); } else if (!AuthFlag) { Toast.makeText(ctx, resources.getString(R.string.OnlyRegistered), Toast.LENGTH_SHORT).show(); } //=================================================== } }); return vfrag_comments; }