Git Product home page Git Product logo

android-shareeverywhere's Introduction

Android-ShareEverywhere

This project is the tribute to my favorite Android Widget: the Share button. Share ALL THE THINGS!

screenshot

Summary

You may know about the ShareActionProvider that was introduced in API 14. This project extends the ShareActionProvider in a few very important ways:

  1. It breaks the Widget free of the ActionBar. It can be used as a standalone View in any layout.
  2. It allows you to specify multiple share intents, which will be combined when displayed.
  3. Its default sorting function also uses alphabetical order.
  4. It can be used (with ActionBarSherlock) on versions of android prior to API 14.

Usage

As a View

Using this view in a layout is simple:

<com.dgmltn.shareeverywhere.ShareView
    android:id="@+id/share_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

Then give it an intent (or multiple intents) in your Activity or Fragment:

    ShareView shareView = (ShareView) findViewById(R.id.share_view);
    shareView.setShareIntent(emailIntent, txtIntent);

In the ActionBar

Its use in the actionbar is the same as http://developer.android.com/reference/android/widget/ShareActionProvider.html

In your menu.xml:

<item
    android:id="@+id/action_share"
    android:actionProviderClass="com.dgmltn.shareeverywhere.ShareActionProvider"
    android:showAsAction="always"
    android:title="Share" />

Then in your Activity/Fragment:

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);

        MenuItem item = menu.findItem(R.id.action_share);
        ShareActionProvider shareActionProvider 
            = (ShareActionProvider) item.getActionProvider();
        shareActionProvider.setShareIntent(mSharedIntents);
        return true;
    }

Style

ShareEverywhere is quite styleable, most things that may want to be styled, can. Set this in your theme.xml:

<style name="AppTheme">
    ...
    <item name="shareViewStyle">@style/Widget.ShareView.Dark</item>
</style>

Or, style your view explicitly:

<com.dgmltn.shareeverywhere.ShareView
    style="@style/Widget.ShareView.Light"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

Create your own style. Styleable elements can be found in res/values/styles.xml.

<style name="Widget.ShareView.Custom" parent="Widget.ShareView">
    <item name="sv_buttonDrawable">@drawable/my_share_button</item>
    <item name="sv_buttonBackground">@drawable/my_list_selector</item>
    <item name="sv_popupTextColor">#f3f3f3</item>
</style>

Obtaining

Include in your android project from jcenter, using Gradle:

compile 'com.dgmltn:share-everywhere:1.0.1'

Requirements

License

Copyright 2013 Doug Melton

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.