├── sample ├── .gitignore ├── src │ ├── main │ │ ├── ic_launcher-web.png │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── layout │ │ │ │ └── activity_main.xml │ │ ├── java │ │ │ └── cn │ │ │ │ └── itguy │ │ │ │ └── allshare │ │ │ │ └── sample │ │ │ │ ├── SampleApplication.java │ │ │ │ └── MainActivity.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── cn │ │ │ └── itguy │ │ │ └── allshare │ │ │ └── sample │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── cn │ │ └── itguy │ │ └── allshare │ │ └── sample │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── allshare ├── .gitignore ├── libs │ ├── libammsdk.jar │ └── open_sdk_r5509_lite.jar ├── src │ └── main │ │ ├── java │ │ └── cn │ │ │ └── itguy │ │ │ └── allshare │ │ │ ├── Callback.java │ │ │ ├── Constants.java │ │ │ ├── Share.java │ │ │ ├── Content.java │ │ │ ├── platform │ │ │ ├── qq │ │ │ │ ├── QQShare.java │ │ │ │ ├── QQContent.java │ │ │ │ └── QQEnrtyActivity.java │ │ │ └── wx │ │ │ │ ├── WXShare.java │ │ │ │ ├── WXContent.java │ │ │ │ └── WXEntryActivity.java │ │ │ ├── AllShare.java │ │ │ └── LogUtils.java │ │ ├── res │ │ └── values │ │ │ └── strings.xml │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── LICENSE ├── gradlew.bat ├── README.md └── gradlew /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /allshare/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':sample' 2 | include ':allshare' 3 | -------------------------------------------------------------------------------- /allshare/libs/libammsdk.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/szitguy/Allshare/HEAD/allshare/libs/libammsdk.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/szitguy/Allshare/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /sample/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/szitguy/Allshare/HEAD/sample/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /allshare/libs/open_sdk_r5509_lite.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/szitguy/Allshare/HEAD/allshare/libs/open_sdk_r5509_lite.jar -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | AllShare Demo 3 | 4 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/szitguy/Allshare/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/szitguy/Allshare/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/szitguy/Allshare/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/szitguy/Allshare/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/szitguy/Allshare/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /allshare/src/main/java/cn/itguy/allshare/Callback.java: -------------------------------------------------------------------------------- 1 | package cn.itguy.allshare; 2 | 3 | public interface Callback { 4 | 5 | void onSuccess(); 6 | 7 | void onFailed(); 8 | 9 | void onCanceled(); 10 | } -------------------------------------------------------------------------------- /sample/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Mar 14 14:15:55 CST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip 7 | -------------------------------------------------------------------------------- /allshare/src/main/java/cn/itguy/allshare/Constants.java: -------------------------------------------------------------------------------- 1 | package cn.itguy.allshare; 2 | 3 | /** 4 | * Created by yelongfei490 on 2016/11/26. 5 | */ 6 | 7 | public class Constants { 8 | 9 | public static final String KEY_SHARE_LISTENER = "listener"; 10 | public static final String KEY_SHARE_CONTENT = "content"; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /allshare/src/main/java/cn/itguy/allshare/Share.java: -------------------------------------------------------------------------------- 1 | package cn.itguy.allshare; 2 | 3 | /** 4 | * Created by yelongfei490 on 2016/11/25. 5 | */ 6 | 7 | public interface Share { 8 | 9 | int RESULT_FAILED = 0; 10 | 11 | int RESULT_SUCCESS = 1; 12 | 13 | int RESULT_CANCELD = 2; 14 | 15 | void share(Content content, Callback callback); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /sample/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /allshare/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | AllShare 3 | 分享失败 4 | 5 | 6 | qqAppId 7 | 8 | 9 | wxAppId 10 | 11 | wbAppId 12 | 13 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /sample/src/test/java/cn/itguy/allshare/sample/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package cn.itguy.allshare.sample; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test public void addition_isCorrect() throws Exception { 14 | assertEquals(4, 2 + 2); 15 | } 16 | } -------------------------------------------------------------------------------- /sample/src/main/java/cn/itguy/allshare/sample/SampleApplication.java: -------------------------------------------------------------------------------- 1 | package cn.itguy.allshare.sample; 2 | 3 | import android.app.Application; 4 | import cn.itguy.allshare.AllShare; 5 | 6 | /** 7 | * Created by yelongfei490 on 2016/11/28. 8 | */ 9 | public class SampleApplication extends Application { 10 | 11 | public static SampleApplication instance; 12 | 13 | @Override public void onCreate() { 14 | super.onCreate(); 15 | instance = this; 16 | 17 | // 初始化Allshare 18 | AllShare.init(this); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/workspace.xml 38 | 39 | # Keystore files 40 | *.jks 41 | 42 | .idea/ 43 | -------------------------------------------------------------------------------- /sample/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/yelongfei490/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | 13 | # When configured, Gradle will run in incubating parallel mode. 14 | # This option should only be used with decoupled projects. More details, visit 15 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 16 | # org.gradle.parallel=true 17 | 18 | BINTRAY_API_KEY=BINTRAY_API_KEY 19 | BINTRAY_USER=BINTRAY_USER 20 | -------------------------------------------------------------------------------- /allshare/src/main/java/cn/itguy/allshare/Content.java: -------------------------------------------------------------------------------- 1 | package cn.itguy.allshare; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | /** 7 | * Created by yelongfei490 on 2016/11/25. 8 | */ 9 | 10 | public abstract class Content implements Parcelable { 11 | 12 | public interface Type { 13 | 14 | int TEXT = 0; 15 | 16 | int IMAGE = 1; 17 | 18 | int LINK = 2; 19 | } 20 | 21 | private int type; 22 | 23 | public int getType() { 24 | return type; 25 | } 26 | 27 | public void setType(int type) { 28 | this.type = type; 29 | } 30 | 31 | @Override public void writeToParcel(Parcel dest, int flags) { 32 | dest.writeInt(this.type); 33 | } 34 | 35 | public Content() { 36 | } 37 | 38 | protected Content(Parcel in) { 39 | this.type = in.readInt(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /sample/src/androidTest/java/cn/itguy/allshare/sample/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package cn.itguy.allshare.sample; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) public class ExampleInstrumentedTest { 18 | @Test public void useAppContext() throws Exception { 19 | // Context of the app under test. 20 | Context appContext = InstrumentationRegistry.getTargetContext(); 21 | 22 | assertEquals("cn.itguy.allshare.sample", appContext.getPackageName()); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /allshare/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/yelongfei490/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | -keep public class * extends android.app.Activity 20 | 21 | # 能够调起微信到选择好友列表,但是点击发送后无响应,请检查是否加了proguard配置,参考:https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419318060&token=eaabee8240cd2cfbc27bdf99e9b26507ba735023&lang=zh_CN 22 | # 微信分享库混淆配置 23 | -keep class com.tencent.mm.sdk.** { 24 | *; 25 | } 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Martin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'allshare' 3 | 4 | def _applicationId = 'cn.itguy.allshare.sample' 5 | def _applicationIdBeta = 'cn.itguy.allshare.sample.beta' 6 | 7 | // 分享appId配置,package:appId对应配置,package不能用变量名来获取,只能写实际内容 8 | AllSharePlugin { 9 | qqAppIdMap = [ 10 | "cn.itguy.allshare.sample": "qqAppId", 11 | "cn.itguy.allshare.sample.beta": "qqAppIdBeta" 12 | ] 13 | 14 | wxAppIdMap = [ 15 | "cn.itguy.allshare.sample": "wxAppId", 16 | "cn.itguy.allshare.sample.beta": "wxAppIdBeta" 17 | ] 18 | } 19 | 20 | android { 21 | compileSdkVersion 25 22 | buildToolsVersion "25.0.2" 23 | 24 | defaultConfig { 25 | applicationId _applicationId 26 | minSdkVersion 14 27 | targetSdkVersion 25 28 | versionCode 1 29 | versionName "1.0" 30 | 31 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 32 | } 33 | 34 | productFlavors { 35 | 36 | common { 37 | } 38 | 39 | beta { 40 | applicationId _applicationIdBeta 41 | } 42 | } 43 | 44 | buildTypes { 45 | 46 | release { 47 | minifyEnabled true 48 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 49 | } 50 | } 51 | 52 | } 53 | 54 | dependencies { 55 | compile fileTree(dir: 'libs', include: ['*.jar']) 56 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 57 | exclude group: 'com.android.support', module: 'support-annotations' 58 | }) 59 | compile 'com.android.support:appcompat-v7:25.3.1' 60 | testCompile 'junit:junit:4.12' 61 | 62 | // compile project(':allshare') 63 | } 64 | -------------------------------------------------------------------------------- /allshare/src/main/java/cn/itguy/allshare/platform/qq/QQShare.java: -------------------------------------------------------------------------------- 1 | package cn.itguy.allshare.platform.qq; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.os.ResultReceiver; 7 | import cn.itguy.allshare.Callback; 8 | import cn.itguy.allshare.Constants; 9 | import cn.itguy.allshare.Content; 10 | import cn.itguy.allshare.Share; 11 | import java.lang.ref.WeakReference; 12 | 13 | /** 14 | * Created by yelongfei490 on 2016/11/25. 15 | */ 16 | 17 | public class QQShare extends ResultReceiver implements Share { 18 | 19 | private WeakReference contextWeakRef; 20 | private Callback callback; 21 | 22 | public QQShare(Context context) { 23 | super(null); 24 | contextWeakRef = new WeakReference<>(context); 25 | } 26 | 27 | @Override public void share(Content content, Callback callback) { 28 | this.callback = callback; 29 | Context context = contextWeakRef.get(); 30 | if (context != null) { 31 | context.startActivity(new Intent(context, QQEnrtyActivity.class) 32 | .putExtra(Constants.KEY_SHARE_CONTENT, content) 33 | .putExtra(Constants.KEY_SHARE_LISTENER, this)); 34 | } 35 | } 36 | 37 | @Override protected void onReceiveResult(int resultCode, Bundle resultData) { 38 | if (resultCode == Share.RESULT_SUCCESS) { 39 | if (callback != null) { 40 | callback.onSuccess(); 41 | } 42 | } else if (resultCode == Share.RESULT_CANCELD) { 43 | if (callback != null) { 44 | callback.onCanceled(); 45 | } 46 | } else { 47 | if (callback != null) { 48 | callback.onFailed(); 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /allshare/src/main/java/cn/itguy/allshare/platform/wx/WXShare.java: -------------------------------------------------------------------------------- 1 | package cn.itguy.allshare.platform.wx; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.os.ResultReceiver; 7 | import cn.itguy.allshare.Callback; 8 | import cn.itguy.allshare.Constants; 9 | import cn.itguy.allshare.Content; 10 | import cn.itguy.allshare.Share; 11 | import java.lang.ref.WeakReference; 12 | 13 | /** 14 | * Created by yelongfei490 on 2016/11/25. 15 | */ 16 | 17 | public class WXShare extends ResultReceiver implements Share { 18 | 19 | private WeakReference contextWeakRef; 20 | private Callback callback; 21 | 22 | public WXShare(Context context) { 23 | super(null); 24 | contextWeakRef = new WeakReference<>(context); 25 | } 26 | 27 | @Override public void share(Content content, Callback callback) { 28 | this.callback = callback; 29 | Context context = contextWeakRef.get(); 30 | if (context != null) { 31 | context.startActivity(new Intent(context, WXEntryActivity.class) 32 | .putExtra(Constants.KEY_SHARE_CONTENT, content) 33 | .putExtra(Constants.KEY_SHARE_LISTENER, this)); 34 | } 35 | } 36 | 37 | @Override protected void onReceiveResult(int resultCode, Bundle resultData) { 38 | if (resultCode == Share.RESULT_SUCCESS) { 39 | if (callback != null) { 40 | callback.onSuccess(); 41 | } 42 | } else if (resultCode == Share.RESULT_CANCELD) { 43 | if (callback != null) { 44 | callback.onCanceled(); 45 | } 46 | } else { 47 | if (callback != null) { 48 | callback.onFailed(); 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /allshare/src/main/java/cn/itguy/allshare/AllShare.java: -------------------------------------------------------------------------------- 1 | package cn.itguy.allshare; 2 | 3 | import android.content.Context; 4 | import android.content.res.Resources; 5 | import android.util.Log; 6 | import cn.itguy.allshare.platform.qq.QQContent; 7 | import cn.itguy.allshare.platform.qq.QQShare; 8 | import cn.itguy.allshare.platform.wx.WXContent; 9 | import cn.itguy.allshare.platform.wx.WXShare; 10 | 11 | /** 12 | * 分享sdk入口 13 | * 14 | * Created by yelongfei490 on 2016/11/25. 15 | */ 16 | public class AllShare { 17 | 18 | private static String wxId; 19 | private static String qqId; 20 | private static String weiboId; 21 | 22 | public static void init(Context context) { 23 | Resources res = context.getResources(); 24 | String packageName = context.getPackageName(); 25 | wxId = context.getString(res.getIdentifier("all_share_wx_app_id", "string", packageName)); 26 | qqId = context.getString(res.getIdentifier("all_share_qq_app_id", "string", packageName)).replace("tencent", ""); 27 | weiboId = context.getString(res.getIdentifier("all_share_wb_app_id", "string", packageName)); 28 | 29 | Log.i("AllShare", "Got wxId: " + wxId + " qqId: " + qqId + " weiboId: " + weiboId); 30 | } 31 | 32 | public static String getWxId() { 33 | return wxId; 34 | } 35 | 36 | public static String getQqId() { 37 | return qqId; 38 | } 39 | 40 | public static String getWeiboId() { 41 | return weiboId; 42 | } 43 | 44 | public static void share(Context context, Content content, Callback callback) { 45 | Share share = getShare(context, content); 46 | if (share != null) { 47 | share.share(content, callback); 48 | } 49 | } 50 | 51 | private static Share getShare(Context context, Content content) { 52 | if (content != null) { 53 | if (content instanceof QQContent) { 54 | return new QQShare(context); 55 | } else if (content instanceof WXContent) { 56 | return new WXShare(context); 57 | } 58 | } 59 | return null; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /allshare/src/main/java/cn/itguy/allshare/platform/qq/QQContent.java: -------------------------------------------------------------------------------- 1 | package cn.itguy.allshare.platform.qq; 2 | 3 | import android.os.Parcel; 4 | import cn.itguy.allshare.Content; 5 | 6 | /** 7 | * Created by yelongfei490 on 2016/11/25. 8 | */ 9 | 10 | public class QQContent extends Content { 11 | 12 | private boolean qzone; 13 | private String title; 14 | private String targetUrl; 15 | private String summary; 16 | private String imageUrl; 17 | 18 | public boolean isQzone() { 19 | return qzone; 20 | } 21 | 22 | public void setQzone(boolean qzone) { 23 | this.qzone = qzone; 24 | } 25 | 26 | public String getTitle() { 27 | return title; 28 | } 29 | 30 | public void setTitle(String title) { 31 | this.title = title; 32 | } 33 | 34 | public String getTargetUrl() { 35 | return targetUrl; 36 | } 37 | 38 | public void setTargetUrl(String targetUrl) { 39 | this.targetUrl = targetUrl; 40 | } 41 | 42 | public String getSummary() { 43 | return summary; 44 | } 45 | 46 | public void setSummary(String summary) { 47 | this.summary = summary; 48 | } 49 | 50 | public String getImageUrl() { 51 | return imageUrl; 52 | } 53 | 54 | public void setImageUrl(String imageUrl) { 55 | this.imageUrl = imageUrl; 56 | } 57 | 58 | @Override public int describeContents() { 59 | return 0; 60 | } 61 | 62 | @Override public void writeToParcel(Parcel dest, int flags) { 63 | super.writeToParcel(dest, flags); 64 | dest.writeByte(this.qzone ? (byte) 1 : (byte) 0); 65 | dest.writeString(this.title); 66 | dest.writeString(this.targetUrl); 67 | dest.writeString(this.summary); 68 | dest.writeString(this.imageUrl); 69 | } 70 | 71 | public QQContent() { 72 | } 73 | 74 | protected QQContent(Parcel in) { 75 | super(in); 76 | this.qzone = in.readByte() != 0; 77 | this.title = in.readString(); 78 | this.targetUrl = in.readString(); 79 | this.summary = in.readString(); 80 | this.imageUrl = in.readString(); 81 | } 82 | 83 | public static final Creator CREATOR = new Creator() { 84 | @Override public QQContent createFromParcel(Parcel source) { 85 | return new QQContent(source); 86 | } 87 | 88 | @Override public QQContent[] newArray(int size) { 89 | return new QQContent[size]; 90 | } 91 | }; 92 | } 93 | -------------------------------------------------------------------------------- /allshare/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 14 | 15 | 20 | 21 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 39 | 40 | 46 | 47 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /allshare/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | apply plugin: 'com.jfrog.bintray' 4 | 5 | def _versionName = '1.0.5' 6 | 7 | android { 8 | compileSdkVersion 25 9 | buildToolsVersion "25.0.2" 10 | 11 | defaultConfig { 12 | minSdkVersion 14 13 | targetSdkVersion 25 14 | versionCode 1 15 | versionName _versionName 16 | 17 | consumerProguardFiles 'proguard-rules.pro' 18 | 19 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 20 | 21 | } 22 | buildTypes { 23 | release { 24 | minifyEnabled false 25 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 26 | } 27 | } 28 | } 29 | 30 | dependencies { 31 | compile fileTree(dir: 'libs', include: ['*.jar']) 32 | } 33 | 34 | group = "cn.itguy.allshare" 35 | version = _versionName 36 | 37 | def siteUrl = 'https://github.com/szitguy/Allshare' 38 | def gitUrl = 'https://github.com/szitguy/Allshare' 39 | 40 | 41 | install { 42 | repositories.mavenInstaller { 43 | // This generates POM.xml with proper parameters 44 | pom { 45 | project { 46 | packaging 'aar' 47 | 48 | name 'An android library aims to integrate all share platforms for more convenient using.' 49 | url siteUrl 50 | 51 | licenses { 52 | license { 53 | name 'The MIT License (MIT)' 54 | url 'http://opensource.org/licenses/MIT' 55 | } 56 | } 57 | developers { 58 | developer { 59 | id 'szitguy' 60 | name 'Martin' 61 | email 'luohuafengyue@163.com' 62 | } 63 | } 64 | scm { 65 | connection gitUrl 66 | developerConnection gitUrl 67 | url siteUrl 68 | 69 | } 70 | } 71 | } 72 | } 73 | } 74 | 75 | task sourcesJar(type: Jar) { 76 | from android.sourceSets.main.java.srcDirs 77 | classifier = 'sources' 78 | } 79 | 80 | task javadoc(type: Javadoc) { 81 | source = android.sourceSets.main.java.srcDirs 82 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 83 | } 84 | 85 | task javadocJar(type: Jar, dependsOn: javadoc) { 86 | classifier = 'javadoc' 87 | from javadoc.destinationDir 88 | } 89 | artifacts { 90 | archives javadocJar 91 | archives sourcesJar 92 | } 93 | 94 | bintray { 95 | user = BINTRAY_USER 96 | // if (project.hasProperty("KEY")) { 97 | // key = KEY 98 | // } 99 | key = BINTRAY_API_KEY 100 | 101 | configurations = ['archives'] 102 | pkg { 103 | repo = "maven" 104 | name = "allshare" 105 | websiteUrl = siteUrl 106 | vcsUrl = gitUrl 107 | licenses = ["MIT"] 108 | publish = true 109 | } 110 | } -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 20 | 21 | 27 | 28 | 33 |