Search in sources :

Example 1 with IconDrawable

use of com.joanzapata.iconify.IconDrawable in project AntennaPod by AntennaPod.

the class MediaplayerActivity method onPrepareOptionsMenu.

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    if (controller == null) {
        return false;
    }
    Playable media = controller.getMedia();
    menu.findItem(R.id.support_item).setVisible(media != null && media.getPaymentLink() != null && (media instanceof FeedMedia) && ((FeedMedia) media).getItem() != null && ((FeedMedia) media).getItem().getFlattrStatus().flattrable());
    boolean hasWebsiteLink = media != null && media.getWebsiteLink() != null;
    menu.findItem(R.id.visit_website_item).setVisible(hasWebsiteLink);
    boolean isItemAndHasLink = media != null && (media instanceof FeedMedia) && ((FeedMedia) media).getItem() != null && ((FeedMedia) media).getItem().getLink() != null;
    menu.findItem(R.id.share_link_item).setVisible(isItemAndHasLink);
    menu.findItem(R.id.share_link_with_position_item).setVisible(isItemAndHasLink);
    boolean isItemHasDownloadLink = media != null && (media instanceof FeedMedia) && ((FeedMedia) media).getDownload_url() != null;
    menu.findItem(R.id.share_download_url_item).setVisible(isItemHasDownloadLink);
    menu.findItem(R.id.share_download_url_with_position_item).setVisible(isItemHasDownloadLink);
    menu.findItem(R.id.share_item).setVisible(hasWebsiteLink || isItemAndHasLink || isItemHasDownloadLink);
    menu.findItem(R.id.add_to_favorites_item).setVisible(false);
    menu.findItem(R.id.remove_from_favorites_item).setVisible(false);
    if (media != null && media instanceof FeedMedia) {
        menu.findItem(R.id.add_to_favorites_item).setVisible(!isFavorite);
        menu.findItem(R.id.remove_from_favorites_item).setVisible(isFavorite);
    }
    boolean sleepTimerSet = controller.sleepTimerActive();
    boolean sleepTimerNotSet = controller.sleepTimerNotActive();
    menu.findItem(R.id.set_sleeptimer_item).setVisible(sleepTimerNotSet);
    menu.findItem(R.id.disable_sleeptimer_item).setVisible(sleepTimerSet);
    if (this instanceof AudioplayerActivity) {
        int[] attrs = { R.attr.action_bar_icon_color };
        TypedArray ta = obtainStyledAttributes(UserPreferences.getTheme(), attrs);
        int textColor = ta.getColor(0, Color.GRAY);
        ta.recycle();
        menu.findItem(R.id.audio_controls).setIcon(new IconDrawable(this, FontAwesomeIcons.fa_sliders).color(textColor).actionBarSize());
    } else {
        menu.findItem(R.id.audio_controls).setVisible(false);
    }
    return true;
}
Also used : Playable(de.danoeh.antennapod.core.util.playback.Playable) FeedMedia(de.danoeh.antennapod.core.feed.FeedMedia) TypedArray(android.content.res.TypedArray) IconDrawable(com.joanzapata.iconify.IconDrawable)

Example 2 with IconDrawable

use of com.joanzapata.iconify.IconDrawable in project AntennaPod by AntennaPod.

the class ItemlistFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if (!isAdded()) {
        return;
    }
    super.onCreateOptionsMenu(menu, inflater);
    if (itemsLoaded) {
        FeedMenuHandler.onCreateOptionsMenu(inflater, menu);
        MenuItem searchItem = menu.findItem(R.id.action_search);
        final SearchView sv = (SearchView) MenuItemCompat.getActionView(searchItem);
        MenuItemUtils.adjustTextColor(getActivity(), sv);
        sv.setQueryHint(getString(R.string.search_hint));
        sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

            @Override
            public boolean onQueryTextSubmit(String s) {
                sv.clearFocus();
                if (itemsLoaded) {
                    ((MainActivity) getActivity()).loadChildFragment(SearchFragment.newInstance(s, feed.getId()));
                }
                return true;
            }

            @Override
            public boolean onQueryTextChange(String s) {
                return false;
            }
        });
        if (feed == null || feed.getLink() == null) {
            menu.findItem(R.id.share_link_item).setVisible(false);
            menu.findItem(R.id.visit_website_item).setVisible(false);
        }
        int[] attrs = { R.attr.action_bar_icon_color };
        TypedArray ta = getActivity().obtainStyledAttributes(UserPreferences.getTheme(), attrs);
        int textColor = ta.getColor(0, Color.GRAY);
        ta.recycle();
        menu.findItem(R.id.episode_actions).setIcon(new IconDrawable(getActivity(), FontAwesomeIcons.fa_gears).color(textColor).actionBarSize());
        isUpdatingFeed = MenuItemUtils.updateRefreshMenuItem(menu, R.id.refresh_item, updateRefreshMenuItemChecker);
    }
}
Also used : SearchView(android.support.v7.widget.SearchView) TypedArray(android.content.res.TypedArray) IconDrawable(com.joanzapata.iconify.IconDrawable) MenuItem(android.view.MenuItem) SuppressLint(android.annotation.SuppressLint)

Example 3 with IconDrawable

use of com.joanzapata.iconify.IconDrawable in project AntennaPod by AntennaPod.

the class CompletedDownloadsFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if (!isAdded()) {
        return;
    }
    super.onCreateOptionsMenu(menu, inflater);
    if (items != null) {
        inflater.inflate(R.menu.downloads_completed, menu);
        MenuItem episodeActions = menu.findItem(R.id.episode_actions);
        if (items.size() > 0) {
            int[] attrs = { R.attr.action_bar_icon_color };
            TypedArray ta = getActivity().obtainStyledAttributes(UserPreferences.getTheme(), attrs);
            int textColor = ta.getColor(0, Color.GRAY);
            ta.recycle();
            episodeActions.setIcon(new IconDrawable(getActivity(), FontAwesomeIcons.fa_gears).color(textColor).actionBarSize());
            episodeActions.setVisible(true);
        } else {
            episodeActions.setVisible(false);
        }
    }
}
Also used : TypedArray(android.content.res.TypedArray) IconDrawable(com.joanzapata.iconify.IconDrawable) MenuItem(android.view.MenuItem)

Aggregations

TypedArray (android.content.res.TypedArray)3 IconDrawable (com.joanzapata.iconify.IconDrawable)3 MenuItem (android.view.MenuItem)2 SuppressLint (android.annotation.SuppressLint)1 SearchView (android.support.v7.widget.SearchView)1 FeedMedia (de.danoeh.antennapod.core.feed.FeedMedia)1 Playable (de.danoeh.antennapod.core.util.playback.Playable)1