package com.myideaway.cordova.umeng.share;

import com.umeng.socialize.PlatformConfig;
import com.umeng.socialize.ShareAction;
import com.umeng.socialize.bean.SHARE_MEDIA;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.json.JSONArray;
import org.json.JSONException;

/**
 * Created by cdm on 1/5/16.
 */
public class UMengSharePlugin extends CordovaPlugin {
    @Override
    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
        if (action.equals("init")) {
            init(args, callbackContext);
        } else if (action.equals("share")) {
            share(args, callbackContext);
        }

        return false;
    }

    private void init(JSONArray args, CallbackContext callbackContext) {
        PlatformConfig.setWeixin("wx967daebe835fbeac", "5bb696d9ccd75a38c8a0bfe0675559b3");
        //微信 appid appsecret
        PlatformConfig.setSinaWeibo("3921700954", "04b48b094faeb16683c32669824ebdad");
        //新浪微博 appkey appsecret
        PlatformConfig.setQQZone("100424468", "c7394704798a158208a74ab60104f0ba");

        callbackContext.success();
    }

    private void share(JSONArray args, CallbackContext callbackContext) {
        String text = args.optString(0);
        String title = args.optString(1);
        String url = args.optString(2);

        final SHARE_MEDIA[] displaylist = new SHARE_MEDIA[]
                {
                        SHARE_MEDIA.WEIXIN,
                        SHARE_MEDIA.WEIXIN_CIRCLE,
                        SHARE_MEDIA.SINA,
                        SHARE_MEDIA.QQ, SHARE_MEDIA.QZONE
                };
        new ShareAction(cordova.getActivity()).setDisplayList(displaylist)
                .withText(text)
                .withTitle(title)
                .withTargetUrl(url)
                .open();

        callbackContext.success();
    }
}

@@ -29,21 +29,24 @@
 a.umeng.
-share
+feedback
 ;%0A%0Aimpor
@@ -61,117 +61,24 @@
 eng.
-socialize.PlatformConfig;%0Aimport com.umeng.socialize.ShareAction;%0Aimport com.umeng.socialize.bean.SHARE_MEDIA
+fb.FeedbackAgent
 ;%0A%0Ai
@@ -274,21 +274,24 @@
 ss UMeng
-Share
+Feedback
 Plugin e
@@ -309,24 +309,55 @@
 ovaPlugin %7B%0A
+    private FeedbackAgent fb;%0A%0A
     @Overrid
@@ -607,21 +607,24 @@
         
-share
+feedback
 (args, c
@@ -765,1090 +765,506 @@
     
-PlatformConfig.setWeixin(%22wx967daebe835fbeac%22, %225bb696d9ccd75a38c8a0bfe0675559b3%22);%0A        //%E5%BE%AE%E4%BF%A1 appid appsecret%0A        PlatformConfig.setSinaWeibo(%223921700954%22, %2204b48b094faeb16683c32669824ebdad%22);%0A        //%E6%96%B0%E6%B5%AA%E5%BE%AE%E5%8D%9A appkey appsecret%0A        PlatformConfig.setQQZone(%22100424468%22, %22c7394704798a158208a74ab60104f0ba%22);%0A%0A        callbackContext.success();%0A    %7D%0A%0A    private void share(JSONArray args, CallbackContext callbackContext) %7B%0A        String text = args.optString(0);%0A        String title = args.optString(1);%0A        String url = args.optString(2);%0A%0A        final SHARE_MEDIA%5B%5D displaylist = new SHARE_MEDIA%5B%5D%0A                %7B%0A                        SHARE_MEDIA.WEIXIN,%0A                        SHARE_MEDIA.WEIXIN_CIRCLE,%0A                        SHARE_MEDIA.SINA,%0A                        SHARE_MEDIA.QQ, SHARE_MEDIA.QZONE%0A                %7D
+fb = new FeedbackAgent(cordova.getActivity());%0A        // check if the app developer has replied to the feedback or not.%0A        fb.sync();%0A        fb.openAudioFeedback();%0A        fb.openFeedbackPush();%0A%0A        new Thread(new Runnable() %7B%0A            @Override%0A            public void run() %7B%0A                boolean result = fb.updateUserInfo();%0A            %7D%0A        %7D).start()
 ;%0A    
+%7D%0A%0A
     
-new ShareAction(cordova.getActivity()).setDisplayList(displaylist)%0A                .withText(text)%0A                .withTitle(title)%0A                .withTargetUrl(url)%0A                .open();%0A%0A        callbackContext.success
+private void feedback(JSONArray args, CallbackContext callbackContext) %7B%0A        fb.startFeedbackActivity
 ();%0A

fix code