Pārlūkot izejas kodu

分享功能依赖包

1712772270@qq.com 8 gadi atpakaļ
vecāks
revīzija
8daafa0660

BIN
ipu-share/.DS_Store


+ 9 - 0
ipu-share/.classpath

@ -0,0 +1,9 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
5
	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
6
	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
7
	<classpathentry kind="src" path="gen"/>
8
	<classpathentry kind="output" path="bin/classes"/>
9
</classpath>

+ 33 - 0
ipu-share/.project

@ -0,0 +1,33 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>ipu-share</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
		<buildCommand>
19
			<name>org.eclipse.jdt.core.javabuilder</name>
20
			<arguments>
21
			</arguments>
22
		</buildCommand>
23
		<buildCommand>
24
			<name>com.android.ide.eclipse.adt.ApkBuilder</name>
25
			<arguments>
26
			</arguments>
27
		</buildCommand>
28
	</buildSpec>
29
	<natures>
30
		<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
31
		<nature>org.eclipse.jdt.core.javanature</nature>
32
	</natures>
33
</projectDescription>

+ 2 - 0
ipu-share/.settings/org.eclipse.core.resources.prefs

@ -0,0 +1,2 @@
1
eclipse.preferences.version=1
2
encoding/<project>=UTF-8

+ 11 - 0
ipu-share/.settings/org.eclipse.jdt.core.prefs

@ -0,0 +1,11 @@
1
eclipse.preferences.version=1
2
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
4
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5
org.eclipse.jdt.core.compiler.compliance=1.6
6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11
org.eclipse.jdt.core.compiler.source=1.6

+ 34 - 0
ipu-share/AndroidManifest.xml

@ -0,0 +1,34 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
    package="com.ai.ipu.share"
4
    android:versionCode="1"
5
    android:versionName="1.0" >
6
7
    <uses-sdk
8
        android:minSdkVersion="8"
9
        android:targetSdkVersion="15" />
10
    
11
   <uses-permission android:name="android.permission.INTERNET"/>
12
    <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
13
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
14
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
15
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
16
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
17
    
18
    <application 
19
        android:allowBackup="true"
20
        android:icon="@drawable/ic_launcher"
21
        android:label="@string/app_name"
22
        android:theme="@style/AppTheme">
23
        <activity 
24
            android:name=".MainActivity">
25
            <intent-filter>
26
                <action android:name="android.intent.action.MAIN" />
27
                <category android:name="android.intent.category.LAUNCHER" />
28
            </intent-filter>
29
        </activity>
30
        
31
    </application>
32
    
33
  
34
</manifest>

BIN
ipu-share/assets/.DS_Store


BIN
ipu-share/assets/img.png


BIN
ipu-share/assets/music.mp3


+ 1 - 0
ipu-share/assets/test.txt

@ -0,0 +1 @@
1
hahahhahahahahahahah

BIN
ipu-share/assets/video.mp4


+ 34 - 0
ipu-share/bin/AndroidManifest.xml

@ -0,0 +1,34 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
    package="com.ai.ipu.share"
4
    android:versionCode="1"
5
    android:versionName="1.0" >
6
7
    <uses-sdk
8
        android:minSdkVersion="8"
9
        android:targetSdkVersion="15" />
10
    
11
   <uses-permission android:name="android.permission.INTERNET"/>
12
    <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
13
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
14
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
15
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
16
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
17
    
18
    <application 
19
        android:allowBackup="true"
20
        android:icon="@drawable/ic_launcher"
21
        android:label="@string/app_name"
22
        android:theme="@style/AppTheme">
23
        <activity 
24
            android:name=".MainActivity">
25
            <intent-filter>
26
                <action android:name="android.intent.action.MAIN" />
27
                <category android:name="android.intent.category.LAUNCHER" />
28
            </intent-filter>
29
        </activity>
30
        
31
    </application>
32
    
33
  
34
</manifest>

+ 80 - 0
ipu-share/bin/R.txt

@ -0,0 +1,80 @@
1
int anim hyperspace_in 0x7f040000
2
int anim hyperspace_out 0x7f040001
3
int anim push_left_in 0x7f040002
4
int anim push_left_out 0x7f040003
5
int anim push_right_in 0x7f040004
6
int anim push_right_out 0x7f040005
7
int anim scale_action 0x7f040006
8
int anim shut_open_in 0x7f040007
9
int anim shut_open_out 0x7f040008
10
int dimen activity_horizontal_margin 0x7f080000
11
int dimen activity_vertical_margin 0x7f080001
12
int drawable audio_activity_dialog 0x7f020000
13
int drawable ic_launcher 0x7f020001
14
int drawable keyboard_key 0x7f020002
15
int drawable keyboard_normal_bg 0x7f020003
16
int drawable keyboard_normal_hl_bg 0x7f020004
17
int drawable keyboard_qwerty 0x7f020005
18
int drawable keyboard_sym_delete 0x7f020006
19
int drawable keyboard_sym_shift 0x7f020007
20
int drawable keyboard_sym_space 0x7f020008
21
int drawable keyboard_symbols 0x7f020009
22
int drawable nfc_bg 0x7f02000a
23
int drawable record_mic_normal 0x7f02000b
24
int drawable record_mic_press 0x7f02000c
25
int drawable screenlock_arrow 0x7f02000d
26
int drawable screenlock_line 0x7f02000e
27
int drawable screenlock_line_error 0x7f02000f
28
int drawable screenlock_line_semicircle 0x7f020010
29
int drawable screenlock_line_semicircle_error 0x7f020011
30
int drawable screenlock_round_click 0x7f020012
31
int drawable screenlock_round_click_error 0x7f020013
32
int drawable screenlock_round_original 0x7f020014
33
int drawable screenlock_welcome_bg 0x7f020015
34
int drawable share_apk_activity_dialog 0x7f020016
35
int id btn_qq_file 0x7f090002
36
int id btn_qq_text 0x7f090000
37
int id btn_wechat_file 0x7f090003
38
int id btn_wechat_text 0x7f090001
39
int id deviceListView 0x7f09000c
40
int id deviceNameTV 0x7f09000f
41
int id exit 0x7f09000d
42
int id forget_btn 0x7f090009
43
int id keyboard_view 0x7f090006
44
int id lock_view 0x7f090007
45
int id macAddressTV 0x7f090010
46
int id micButton 0x7f090005
47
int id notify 0x7f090008
48
int id recordLabel 0x7f090004
49
int id reset_btn 0x7f09000a
50
int id search 0x7f09000e
51
int id share 0x7f09000b
52
int layout activity_share 0x7f030000
53
int layout audio_recorder 0x7f030001
54
int layout keyboard 0x7f030002
55
int layout nfcard 0x7f030003
56
int layout screenlock_login_layout2 0x7f030004
57
int layout screenlock_reset_lock_layout 0x7f030005
58
int layout share_apk_activity 0x7f030006
59
int layout share_apk_device_list_item 0x7f030007
60
int raw beep 0x7f050000
61
int string action_settings 0x7f06000d
62
int string app_name 0x7f060000
63
int string hello_world 0x7f06000c
64
int string imgContentDesc 0x7f060003
65
int string pressTip 0x7f060002
66
int string recording 0x7f060001
67
int string sa_confirm_share 0x7f06000a
68
int string sa_exit 0x7f060009
69
int string sa_mac_address 0x7f060006
70
int string sa_search 0x7f060007
71
int string sa_searching 0x7f060008
72
int string sa_share 0x7f060005
73
int string sa_tip 0x7f06000b
74
int string tips 0x7f060004
75
int style AppBaseTheme 0x7f070004
76
int style AppTheme 0x7f070005
77
int style AudioDialogTheme 0x7f070000
78
int style CustomDialogTheme 0x7f070001
79
int style ShareApkDialogTheme 0x7f070002
80
int style SlidingMenuTheme 0x7f070003

BIN
ipu-share/bin/ipu-share.jar


+ 3 - 0
ipu-share/bin/jarlist.cache

@ -0,0 +1,3 @@
1
# cache for current jar dependency. DO NOT EDIT.
2
# format is <lastModified> <length> <SHA-1> <path>
3
# Encoding is UTF-8

BIN
ipu-share/bin/res/crunch/drawable-mdpi/ic_launcher.png


+ 6 - 0
ipu-share/gen/com/ai/ipu/share/BuildConfig.java

@ -0,0 +1,6 @@
1
/** Automatically generated file. DO NOT MODIFY */
2
package com.ai.ipu.share;
3
4
public final class BuildConfig {
5
    public final static boolean DEBUG = true;
6
}

+ 162 - 0
ipu-share/gen/com/ai/ipu/share/R.java

@ -0,0 +1,162 @@
1
/* AUTO-GENERATED FILE.  DO NOT MODIFY.
2
 *
3
 * This class was automatically generated by the
4
 * aapt tool from the resource data it found.  It
5
 * should not be modified by hand.
6
 */
7
8
package com.ai.ipu.share;
9
10
public final class R {
11
    public static final class anim {
12
        public static int hyperspace_in=0x7f040000;
13
        public static int hyperspace_out=0x7f040001;
14
        public static int push_left_in=0x7f040002;
15
        public static int push_left_out=0x7f040003;
16
        public static int push_right_in=0x7f040004;
17
        public static int push_right_out=0x7f040005;
18
        public static int scale_action=0x7f040006;
19
        public static int shut_open_in=0x7f040007;
20
        public static int shut_open_out=0x7f040008;
21
    }
22
    public static final class attr {
23
    }
24
    public static final class dimen {
25
        /**  Default screen margins, per the Android Design guidelines. 
26
27
         Example customization of dimensions originally defined in res/values/dimens.xml
28
         (such as screen margins) for screens with more than 820dp of available width. This
29
         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).
30
    
31
         */
32
        public static int activity_horizontal_margin=0x7f080000;
33
        public static int activity_vertical_margin=0x7f080001;
34
    }
35
    public static final class drawable {
36
        public static int audio_activity_dialog=0x7f020000;
37
        public static int ic_launcher=0x7f020001;
38
        public static int keyboard_key=0x7f020002;
39
        public static int keyboard_normal_bg=0x7f020003;
40
        public static int keyboard_normal_hl_bg=0x7f020004;
41
        public static int keyboard_qwerty=0x7f020005;
42
        public static int keyboard_sym_delete=0x7f020006;
43
        public static int keyboard_sym_shift=0x7f020007;
44
        public static int keyboard_sym_space=0x7f020008;
45
        public static int keyboard_symbols=0x7f020009;
46
        public static int nfc_bg=0x7f02000a;
47
        public static int record_mic_normal=0x7f02000b;
48
        public static int record_mic_press=0x7f02000c;
49
        public static int screenlock_arrow=0x7f02000d;
50
        public static int screenlock_line=0x7f02000e;
51
        public static int screenlock_line_error=0x7f02000f;
52
        public static int screenlock_line_semicircle=0x7f020010;
53
        public static int screenlock_line_semicircle_error=0x7f020011;
54
        public static int screenlock_round_click=0x7f020012;
55
        public static int screenlock_round_click_error=0x7f020013;
56
        public static int screenlock_round_original=0x7f020014;
57
        public static int screenlock_welcome_bg=0x7f020015;
58
        public static int share_apk_activity_dialog=0x7f020016;
59
    }
60
    public static final class id {
61
        public static int btn_qq_file=0x7f090002;
62
        public static int btn_qq_text=0x7f090000;
63
        public static int btn_wechat_file=0x7f090003;
64
        public static int btn_wechat_text=0x7f090001;
65
        public static int deviceListView=0x7f09000c;
66
        public static int deviceNameTV=0x7f09000f;
67
        public static int exit=0x7f09000d;
68
        public static int forget_btn=0x7f090009;
69
        public static int keyboard_view=0x7f090006;
70
        public static int lock_view=0x7f090007;
71
        public static int macAddressTV=0x7f090010;
72
        public static int micButton=0x7f090005;
73
        public static int notify=0x7f090008;
74
        public static int recordLabel=0x7f090004;
75
        public static int reset_btn=0x7f09000a;
76
        public static int search=0x7f09000e;
77
        public static int share=0x7f09000b;
78
    }
79
    public static final class layout {
80
        public static int activity_share=0x7f030000;
81
        public static int audio_recorder=0x7f030001;
82
        public static int keyboard=0x7f030002;
83
        public static int nfcard=0x7f030003;
84
        public static int screenlock_login_layout2=0x7f030004;
85
        public static int screenlock_reset_lock_layout=0x7f030005;
86
        public static int share_apk_activity=0x7f030006;
87
        public static int share_apk_device_list_item=0x7f030007;
88
    }
89
    public static final class raw {
90
        public static int beep=0x7f050000;
91
    }
92
    public static final class string {
93
        public static int action_settings=0x7f06000d;
94
        public static int app_name=0x7f060000;
95
        public static int hello_world=0x7f06000c;
96
        public static int imgContentDesc=0x7f060003;
97
        public static int pressTip=0x7f060002;
98
        public static int recording=0x7f060001;
99
        public static int sa_confirm_share=0x7f06000a;
100
        public static int sa_exit=0x7f060009;
101
        public static int sa_mac_address=0x7f060006;
102
        public static int sa_search=0x7f060007;
103
        public static int sa_searching=0x7f060008;
104
        public static int sa_share=0x7f060005;
105
        public static int sa_tip=0x7f06000b;
106
        public static int tips=0x7f060004;
107
    }
108
    public static final class style {
109
        /** 
110
        Base application theme, dependent on API level. This theme is replaced
111
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
112
    
113
114
            Theme customizations available in newer API levels can go in
115
            res/values-vXX/styles.xml, while customizations related to
116
            backward-compatibility can go here.
117
        
118
119
        Base application theme for API 11+. This theme completely replaces
120
        AppBaseTheme from res/values/styles.xml on API 11+ devices.
121
    
122
 API 11 theme customizations can go here. 
123
124
        Base application theme for API 14+. This theme completely replaces
125
        AppBaseTheme from BOTH res/values/styles.xml and
126
        res/values-v11/styles.xml on API 14+ devices.
127
    
128
 API 14 theme customizations can go here. 
129
130
        Base application theme, dependent on API level. This theme is replaced
131
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
132
    
133
134
            Theme customizations available in newer API levels can go in
135
            res/values-vXX/styles.xml, while customizations related to
136
            backward-compatibility can go here.
137
        
138
139
        Base application theme for API 11+. This theme completely replaces
140
        AppBaseTheme from res/values/styles.xml on API 11+ devices.
141
    
142
 API 11 theme customizations can go here. 
143
144
        Base application theme for API 14+. This theme completely replaces
145
        AppBaseTheme from BOTH res/values/styles.xml and
146
        res/values-v11/styles.xml on API 14+ devices.
147
    
148
 API 14 theme customizations can go here. 
149
         */
150
        public static int AppBaseTheme=0x7f070004;
151
        /**  Application theme. 
152
 All customizations that are NOT specific to a particular API-level can go here. 
153
 Application theme. 
154
 All customizations that are NOT specific to a particular API-level can go here. 
155
         */
156
        public static int AppTheme=0x7f070005;
157
        public static int AudioDialogTheme=0x7f070000;
158
        public static int CustomDialogTheme=0x7f070001;
159
        public static int ShareApkDialogTheme=0x7f070002;
160
        public static int SlidingMenuTheme=0x7f070003;
161
    }
162
}

+ 3 - 0
ipu-share/lint.xml

@ -0,0 +1,3 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<lint>
3
</lint>

+ 20 - 0
ipu-share/proguard-project.txt

@ -0,0 +1,20 @@
1
# To enable ProGuard in your project, edit project.properties
2
# to define the proguard.config property as described in that file.
3
#
4
# Add project specific ProGuard rules here.
5
# By default, the flags in this file are appended to flags specified
6
# in ${sdk.dir}/tools/proguard/proguard-android.txt
7
# You can edit the include path and order by changing the ProGuard
8
# include property in project.properties.
9
#
10
# For more details, see
11
#   http://developer.android.com/guide/developing/tools/proguard.html
12
13
# Add any project specific keep options here:
14
15
# If your project uses WebView with JS, uncomment the following
16
# and specify the fully qualified class name to the JavaScript interface
17
# class:
18
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19
#   public *;
20
#}

+ 17 - 0
ipu-share/project.properties

@ -0,0 +1,17 @@
1
# This file is automatically generated by Android Tools.
2
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3
#
4
# This file must be checked in Version Control Systems.
5
#
6
# To customize properties used by the Ant build system edit
7
# "ant.properties", and override values to adapt the script to your
8
# project structure.
9
#
10
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12
13
# Project target.
14
target=android-21
15
android.library=true
16
android.library.reference.1=../../androidshare0905/wade-mobile-common
17
android.library.reference.2=../../androidshare/android-share-master/wade-mobile-lib

BIN
ipu-share/res/drawable-mdpi/ic_launcher.png


+ 32 - 0
ipu-share/res/layout/activity_share.xml

@ -0,0 +1,32 @@
1
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2
    xmlns:tools="http://schemas.android.com/tools"
3
    android:layout_width="match_parent"
4
    android:layout_height="match_parent"
5
    android:orientation="vertical"
6
    tools:context="com.ai.ipu.share.MainActivity" >
7
8
    <Button
9
        android:id="@+id/btn_qq_text"
10
        android:layout_width="wrap_content"
11
        android:layout_height="wrap_content"
12
        android:text="qq_text" />
13
14
    <Button
15
        android:id="@+id/btn_wechat_text"
16
        android:layout_width="wrap_content"
17
        android:layout_height="wrap_content"
18
        android:text="wechat_text" />
19
20
    <Button
21
        android:id="@+id/btn_qq_file"
22
        android:layout_width="wrap_content"
23
        android:layout_height="wrap_content"
24
        android:text="qq_file" />
25
26
    <Button
27
        android:id="@+id/btn_wechat_file"
28
        android:layout_width="wrap_content"
29
        android:layout_height="wrap_content"
30
        android:text="wechat_file" />
31
32
</LinearLayout>

+ 11 - 0
ipu-share/res/values-v11/styles.xml

@ -0,0 +1,11 @@
1
<resources>
2
3
    <!--
4
        Base application theme for API 11+. This theme completely replaces
5
        AppBaseTheme from res/values/styles.xml on API 11+ devices.
6
    -->
7
    <style name="AppBaseTheme" parent="@android:style/Theme.Light.NoTitleBar">
8
        <!-- API 11 theme customizations can go here. -->
9
    </style>
10
11
</resources>

+ 12 - 0
ipu-share/res/values-v14/styles.xml

@ -0,0 +1,12 @@
1
<resources>
2
3
    <!--
4
        Base application theme for API 14+. This theme completely replaces
5
        AppBaseTheme from BOTH res/values/styles.xml and
6
        res/values-v11/styles.xml on API 14+ devices.
7
    -->
8
    <style name="AppBaseTheme" parent="@android:style/Theme.Light.NoTitleBar">
9
        <!-- API 14 theme customizations can go here. -->
10
    </style>
11
12
</resources>

+ 10 - 0
ipu-share/res/values-w820dp/dimens.xml

@ -0,0 +1,10 @@
1
<resources>
2
3
    <!--
4
         Example customization of dimensions originally defined in res/values/dimens.xml
5
         (such as screen margins) for screens with more than 820dp of available width. This
6
         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).
7
    -->
8
    <dimen name="activity_horizontal_margin">64dp</dimen>
9
10
</resources>

+ 7 - 0
ipu-share/res/values/dimens.xml

@ -0,0 +1,7 @@
1
<resources>
2
3
    <!-- Default screen margins, per the Android Design guidelines. -->
4
    <dimen name="activity_horizontal_margin">16dp</dimen>
5
    <dimen name="activity_vertical_margin">16dp</dimen>
6
7
</resources>

+ 8 - 0
ipu-share/res/values/strings.xml

@ -0,0 +1,8 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<resources>
3
4
    <string name="app_name">ipu-share</string>
5
    <string name="hello_world">Hello world!</string>
6
    <string name="action_settings">Settings</string>
7
8
</resources>

+ 20 - 0
ipu-share/res/values/styles.xml

@ -0,0 +1,20 @@
1
<resources>
2
3
    <!--
4
        Base application theme, dependent on API level. This theme is replaced
5
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
6
    -->
7
    <style name="AppBaseTheme" parent="@android:style/Theme.Light.NoTitleBar">
8
        <!--
9
            Theme customizations available in newer API levels can go in
10
            res/values-vXX/styles.xml, while customizations related to
11
            backward-compatibility can go here.
12
        -->
13
    </style>
14
15
    <!-- Application theme. -->
16
    <style name="AppTheme" parent="AppBaseTheme">
17
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
18
    </style>
19
20
</resources>

+ 148 - 0
ipu-share/src/com/ai/ipu/share/MainActivity.java

@ -0,0 +1,148 @@
1
package com.ai.ipu.share;
2
3
import java.io.File;
4
import java.io.InputStream;
5
6
import javax.mail.event.TransportEvent;
7
8
import com.ai.ipu.mobile.app.ApplicationManager;
9
import com.ai.ipu.mobile.res.assets.AssetsUtil;
10
import com.ai.ipu.share.R;
11
import com.ai.ipu.share.util.ShareUtil;
12
import android.annotation.SuppressLint;
13
import android.app.Activity;
14
import android.app.AlertDialog;
15
import android.content.Intent;
16
import android.content.SharedPreferences;
17
import android.content.res.AssetManager;
18
import android.graphics.BitmapFactory;
19
import android.net.Uri;
20
import android.os.Bundle;
21
import android.os.Environment;
22
import android.text.TextUtils;
23
import android.view.View;
24
import android.view.View.OnClickListener;
25
import android.widget.Button;
26
import android.widget.EditText;
27
import android.widget.Toast;
28
29
public class MainActivity extends Activity implements OnClickListener{
30
	private Button btnQQtext, btnWechatText, btnQQFile, btnWechatFile;
31
	private ShareUtil shareUtil;
32
	private int i = 0;
33
	String filePath;
34
	private Button btnMailFile;
35
36
	private static final int SELECT_PIC_KITAAT = 1;
37
	private static final int SELECT_PIC = 0;
38
	//
39
	// private String username = "18570657653@163.com";
40
	// private String password = "zhanglei123";
41
42
	private SharedPreferences mPref;
43
	private EditText etReceiver;
44
	private Button btnSelectImg;
45
	private EditText etImgpath;
46
47
	@Override
48
	protected void onCreate(Bundle savedInstanceState) {
49
		super.onCreate(savedInstanceState);
50
		ApplicationManager.initApplication(getApplication());
51
		setContentView(R.layout.activity_share);
52
		shareUtil = new ShareUtil(this);
53
54
		mPref = getSharedPreferences("config", MODE_PRIVATE);
55
		// copyFile();
56
		btnQQtext = (Button) this.findViewById(R.id.btn_qq_text);
57
		btnQQFile = (Button) this.findViewById(R.id.btn_qq_file);
58
		btnWechatText = (Button) this.findViewById(R.id.btn_wechat_text);
59
		btnWechatFile = (Button) this.findViewById(R.id.btn_wechat_file);
60
61
		etReceiver.setText(mPref.getString("mailreceiver", null));
62
63
		btnQQtext.setOnClickListener(this);
64
		btnQQFile.setOnClickListener(this);
65
		btnWechatText.setOnClickListener(this);
66
		btnWechatFile.setOnClickListener(this);
67
		btnMailFile.setOnClickListener(this);
68
		btnSelectImg.setOnClickListener(this);
69
70
	}
71
72
	@Override
73
	public void onClick(View v) {
74
		String text = "this is a test demo!";
75
		String imgPath = "file:///android_asset/img.png";
76
		String musicPath = "file:///android_asset/music.mp3";
77
		String videoPath = "file:///android_asset/video.mp4";
78
		String txtPath = "file:///android_asset/test.txt";
79
80
		// switch (v.getId()) {
81
		// case R.id.btn_qq_text:
82
		// shareUtil.shareTextQQFriend(text);
83
		// break;
84
		// case R.id.btn_qq_file:
85
		// shareUtil.shareFileQQFriend(chooseFile());
86
		// break;
87
		// case R.id.btn_wechat_text:
88
		// shareUtil.shareTextWeChatFriend(text);
89
		// break;
90
		// case R.id.btn_wechat_file:
91
		// shareUtil.shareFileWeChatFriend(chooseFile());
92
		// break;
93
		// case R.id.btn_mail_file:
94
		// // 弹出对话框输入邮箱用户名和密码
95
		// showPasswordDialog();
96
		// break;
97
		// }
98
99
	}
100
	
101
102
	private void copyFile() {
103
		try {
104
			// File dir = new File("/storage/emulated/legacy/share");
105
			// if(!dir.exists()){
106
			// dir.mkdirs();
107
			// }
108
			// AssetsUtil.copyAssetsDir("", "/storage/emulated/legacy/share");
109
			// AssetsUtil.copyAssetsFile("img.png",
110
			// "/storage/emulated/legacy/share/");
111
			// AssetsUtil.copyAssetsFile("music.mp3",
112
			// "/storage/emulated/legacy/share/");
113
			// AssetsUtil.copyAssetsFile("video.mp4",
114
			// "/storage/emulated/legacy/share/");
115
			AssetsUtil.copyAssetsDir("assets/" + "ipu-share/",
116
					"/storage/emulated/legacy/share/");
117
			// AssetManager am = getAssets();
118
			// InputStream inputStream = am.open(fileName);
119
			// String path = "/storage/emulated/legacy/share/" + fileName;
120
			// FileUtil.writeFile(inputStream, path);
121
		} catch (Exception e) {
122
			e.printStackTrace();
123
		}
124
	}
125
126
	private File chooseFile() {
127
		if (i % 3 == 0) {
128
			i++;
129
			filePath = "/storage/emulated/legacy/share/img.png";
130
			// filePath = "assets/img.png";
131
			// filePath = "file:///android_asset/img.png";
132
		} else if (i % 3 == 1) {
133
			i++;
134
			filePath = "/storage/emulated/legacy/share/music.mp3";
135
			// filePath = "file:///android_asset/music.mp3";
136
		} else if (i % 3 == 2) {
137
			i++;
138
			filePath = "/storage/emulated/legacy/share/video.mp4";
139
			// filePath = "file:///android_asset/video.mp4";
140
		}
141
		return new File(filePath);
142
	}
143
144
	private void copyAssets() {
145
146
	}
147
148
}

+ 115 - 0
ipu-share/src/com/ai/ipu/share/func/MobileShareByApp.java

@ -0,0 +1,115 @@
1
package com.ai.ipu.share.func;
2
3
import java.io.File;
4
5
import org.json.JSONArray;
6
import org.json.JSONException;
7
8
import com.ai.ipu.mobile.app.AppInfoUtil;
9
import com.ai.ipu.share.util.ShareUtil;
10
import com.wade.mobile.app.IpuAppInfo;
11
import com.wade.mobile.frame.IWadeMobile;
12
import com.wade.mobile.frame.plugin.Plugin;
13
14
public class MobileShareByApp extends Plugin{
15
	ShareUtil shareUtil;
16
	
17
	String imgPath = AppInfoUtil.getSdcardPath() + "/share/img.png";
18
	String musicPath = AppInfoUtil.getSdcardPath() + "/share/music.mp3";
19
	String videoPath =  AppInfoUtil.getSdcardPath() + "/share/video.mp4";
20
21
	public MobileShareByApp(IWadeMobile wademobile) {
22
		super(wademobile);
23
		shareUtil = new ShareUtil(context);
24
		shareUtil.copyAsset();
25
	}
26
	
27
	/**
28
	 * 分享文本给QQ好友
29
	 */
30
	public void shareTextQQFriend(JSONArray params) throws Exception{
31
		String text = params.getString(0);
32
		shareUtil.shareTextQQFriend(text);
33
	}
34
	
35
	/**
36
	 * 更多分享&文本
37
	 * @throws Exception 
38
	 */
39
	public void shareTextMore(JSONArray params) throws Exception{
40
		String text = params.getString(0);
41
		shareUtil.shareTextMore(text);
42
	}
43
	/**
44
	 * 更多分享&图片,音频,视频
45
	 * @throws Exception 
46
	 */
47
	public void shareFileMore(JSONArray params) throws Exception{
48
		int fileType = params.getInt(0);
49
		String filePath = null;
50
		switch (fileType) {
51
		case 0://img
52
			filePath = imgPath;
53
			break;
54
		case 1://music
55
			filePath = musicPath;
56
			break;
57
		case 2://video
58
			filePath = videoPath;
59
			break;
60
		}
61
		File file = new File(filePath);
62
		shareUtil.shareFileMore(file);
63
	}
64
	
65
	/** 
66
	 * 分享文本给微信好友 
67
	 */
68
	public void shareTextWeChatFriend(JSONArray params) throws Exception{
69
		String text = params.getString(0);
70
		shareUtil.shareTextWeChatFriend(text);
71
	}
72
	
73
	/**
74
	 * 分享文件资源给QQ好友
75
	 */
76
	public void shareFileQQFriend(JSONArray params) throws Exception{
77
		int fileType = params.getInt(0);
78
		String filePath = null;
79
		switch (fileType) {
80
		case 0://img
81
			filePath = imgPath;
82
			break;
83
		case 1://music
84
			filePath = musicPath;
85
			break;
86
		case 2://video
87
			filePath = videoPath;
88
			break;
89
		}
90
		File file = new File(filePath);
91
		shareUtil.shareFileQQFriend(file);
92
	}
93
	
94
	/**
95
	 * 分享文件资源给微信好友
96
	 */
97
	public void shareFileWeChatFriend(JSONArray params) throws Exception{
98
		int fileType = params.getInt(0);
99
		String filePath = null;
100
		switch (fileType) {
101
		case 0://img
102
			filePath = imgPath;
103
			break;
104
		case 1://music
105
			filePath = musicPath;
106
			break;
107
		case 2://video
108
			filePath = videoPath;
109
			break;
110
		}
111
		File file = new File(filePath);
112
		shareUtil.shareFileWeChatFriend(file);
113
	}
114
115
}

+ 249 - 0
ipu-share/src/com/ai/ipu/share/util/ShareUtil.java

@ -0,0 +1,249 @@
1
package com.ai.ipu.share.util;
2
3
import java.io.File;
4
5
import com.ai.ipu.basic.file.FileUtil;
6
import com.ai.ipu.mobile.app.AppInfoUtil;
7
import com.ai.ipu.mobile.res.assets.AssetsUtil;
8
import com.ai.ipu.mobile.ui.HintUtil;
9
import com.ai.ipu.share.R;
10
import com.wade.mobile.app.AppRecord;
11
12
import android.app.Activity;
13
import android.content.ComponentName;
14
import android.content.Context;
15
import android.content.Intent;
16
import android.content.pm.PackageManager;
17
import android.content.pm.PackageManager.NameNotFoundException;
18
import android.net.Uri;
19
20
public class ShareUtil {
21
	
22
	private Context context;
23
24
	public static final String QQ_PACKAGENAME = "com.tencent.mobileqq";// QQapp唯一包名;
25
	public static final String WECHAT_PACKAGENAME = "com.tencent.mm";// 微信app包名;
26
27
	public static final String QQ_FRIEND_CLASSNAME = "com.tencent.mobileqq.activity.JumpActivity";// QQapp分享到好友类名
28
	public static final String WECHAT_FRIEND_CLASSNAME = "com.tencent.mm.ui.tools.ShareImgUI";// 微信app分享到好友类名
29
30
	public String password;
31
32
	public ShareUtil(Context context) {
33
		this.context = context;
34
	}
35
36
	/**
37
	 * 检查是否安装指定app
38
	 * 
39
	 * @param packageName
40
	 * @return
41
	 */
42
	public boolean checkInstall(String packageName) {
43
		try {
44
			context.getPackageManager().getPackageInfo(packageName,
45
					PackageManager.GET_ACTIVITIES);
46
			return true;
47
		} catch (NameNotFoundException e) {
48
			e.printStackTrace();
49
			HintUtil.tip((Activity) context, "请先安装应用app");
50
			return false;
51
		}
52
	}
53
54
	/**
55
	 * 跳转到指定的app下载网页
56
	 * 
57
	 * @param url
58
	 */
59
	public void toAppWeb(String url) {
60
		Intent intent = new Intent("android.intent.action.View");
61
		intent.setData(Uri.parse(url));
62
		context.startActivity(intent);
63
	}
64
65
	/**
66
	 * 跳转到指定app的应用商店
67
	 * 
68
	 * @param packageName
69
	 */
70
	public void toAppStore(String packageName) {
71
		String marketAddress = "market://details?id=" + packageName;
72
		Intent intent = new Intent("android.intent.action.View");
73
		intent.setData(Uri.parse(marketAddress));
74
		context.startActivity(intent);
75
	}
76
77
	/**
78
	 * 设置分享类型
79
	 */
80
	public void setShareType(Intent intent, String type) {
81
		intent.setType(type);
82
	}
83
84
	/**
85
	 * 根据file文件得到type
86
	 * 
87
	 * @param file
88
	 * @return
89
	 */
90
	private String getFileType(File file) {
91
		return FileUtil.getMimeType(file);
92
	}
93
94
	/**
95
	 * 配置指定分享平台
96
	 * 
97
	 * @param intent
98
	 */
99
	public void setShareAppPkg(Intent intent, String packageName) {
100
		if (isStrNotEmpty(packageName)) {
101
			intent.setPackage(packageName);
102
		}
103
	}
104
105
	/**
106
	 * 配置指定平台,指定分享界面
107
	 */
108
	public void setShareAppcls(Intent intent, String packageName,
109
			String className) {
110
		if (isStrNotEmpty(className) && isStrNotEmpty(packageName)) {
111
			ComponentName componentName = new ComponentName(packageName,
112
					className);
113
			intent.setComponent(componentName);
114
		} else if (isStrNotEmpty(className)) {
115
			intent.setPackage(packageName);
116
		}
117
	}
118
119
	/**
120
	 * 设置分享共有属性
121
	 * 
122
	 * @param intent
123
	 */
124
	public void initIntent(Intent intent) {
125
		intent.setAction(Intent.ACTION_SEND);
126
		intent.putExtra(Intent.EXTRA_TITLE, "分享到:");
127
	}
128
129
	/**
130
	 * 生成分享选择
131
	 */
132
	public Intent createChooseIntent(Intent intent, String title) {
133
		return Intent.createChooser(intent, title);
134
	}
135
136
	// 文本
137
	/**
138
	 * 分享文本或网址QQ好友
139
	 */
140
	public void shareTextQQFriend(String text) {
141
		Intent shareIntent = new Intent();
142
		initIntent(shareIntent);
143
		setShareAppcls(shareIntent, QQ_PACKAGENAME, QQ_FRIEND_CLASSNAME);
144
		setShareType(shareIntent, "text/plain");
145
		shareIntent.putExtra(Intent.EXTRA_TEXT, text);
146
		context.startActivity(createChooseIntent(shareIntent, "分享到:"));
147
	}
148
	
149
	/**
150
	 * 更多分享&文本
151
	 */
152
	public void shareTextMore(String text){
153
		Intent shareIntent = new Intent();
154
		initIntent(shareIntent);
155
		setShareAppcls(shareIntent, null, null);
156
		setShareType(shareIntent, "text/plain");
157
		shareIntent.putExtra(Intent.EXTRA_TEXT, text);
158
		context.startActivity(createChooseIntent(shareIntent, "分享到:"));
159
	}
160
	
161
	/**
162
	 * 分享文本或网址到微信好友
163
	 */
164
	public void shareTextWeChatFriend(String text) {
165
		Intent shareIntent = new Intent();
166
		initIntent(shareIntent);
167
		setShareAppcls(shareIntent, WECHAT_PACKAGENAME, WECHAT_FRIEND_CLASSNAME);
168
		setShareType(shareIntent, "text/plain");
169
		shareIntent.putExtra(Intent.EXTRA_TEXT, text);
170
		context.startActivity(createChooseIntent(shareIntent, "分享到:"));
171
	}
172
173
	// 文件资源类型
174
175
	/**
176
	 * 分享文件资源到QQ好友
177
	 */
178
	public void shareFileQQFriend(File file) {
179
		Intent shareIntent = new Intent();
180
		initIntent(shareIntent);
181
		setShareAppcls(shareIntent, QQ_PACKAGENAME, QQ_FRIEND_CLASSNAME);
182
		if (file.exists()) {
183
			setShareType(shareIntent, getFileType(file));
184
			shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
185
			context.startActivity(createChooseIntent(shareIntent, "分享到:"));
186
		} else {
187
			HintUtil.tip((Activity) context, "文件不存在");
188
		}
189
	}
190
	
191
	/**
192
	 * 更多分享&图片,音频,视频
193
	 */
194
	public void shareFileMore(File file){
195
		Intent shareIntent = new Intent();
196
		initIntent(shareIntent);
197
		setShareAppcls(shareIntent, null, null);
198
		if (file.exists()) {
199
			setShareType(shareIntent, getFileType(file));
200
			shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
201
			context.startActivity(createChooseIntent(shareIntent, "分享到:"));
202
		} else {
203
			HintUtil.tip((Activity) context, "文件不存在");
204
		}
205
	}
206
	
207
	
208
209
	/**
210
	 * 分享文件资源到微信好友
211
	 * 
212
	 * @param file
213
	 */
214
	public void shareFileWeChatFriend(File file) {
215
		Intent shareIntent = new Intent();
216
		initIntent(shareIntent);
217
		setShareAppcls(shareIntent, WECHAT_PACKAGENAME, WECHAT_FRIEND_CLASSNAME);
218
		if (file.exists()) {
219
			setShareType(shareIntent, getFileType(file));
220
			shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
221
			context.startActivity(createChooseIntent(shareIntent, "分享到:"));
222
		} else {
223
			HintUtil.tip((Activity) context, "文件不存在");
224
		}
225
	}
226
227
	public static boolean isStrNotEmpty(String str) {
228
		if (null != str && str.trim().length() > 0) {
229
			return true;
230
		} else {
231
			return false;
232
		}
233
	}
234
235
	public static void copyAsset() {
236
		if (AppRecord.isFirst()) {
237
			String shareDir = AppInfoUtil.getSdcardPath() + "/share";
238
			File file = new File(shareDir);
239
			if (!file.exists()) {
240
				file.mkdirs();
241
			}
242
			try {
243
				AssetsUtil.copyAssetsDir("share", shareDir);
244
			} catch (Exception e) {
245
				e.printStackTrace();
246
			}
247
		}
248
	}
249
}