├── .gitignore
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── mega4tech
│ │ └── whatsappapi
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── mega4tech
│ │ │ └── whatsappapi
│ │ │ ├── ContactCardRecyclerViewAdapter.java
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── drawable
│ │ └── ic_backspace_black_24dp.xml
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ └── contact_card.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
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── mega4tech
│ └── whatsappapi
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── whatsappapilibrary
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
├── androidTest
└── java
│ └── com
│ └── mega4tech
│ └── whatsappapilibrary
│ └── ExampleInstrumentedTest.java
├── main
├── AndroidManifest.xml
├── java
│ └── com
│ │ ├── mega4tech
│ │ └── whatsappapilibrary
│ │ │ ├── Utils.java
│ │ │ ├── WhatsappApi.java
│ │ │ ├── exception
│ │ │ ├── RootNotAvailableException.java
│ │ │ └── WhatsappNotInstalledException.java
│ │ │ ├── liseteners
│ │ │ ├── GetContactsListener.java
│ │ │ └── SendMessageListener.java
│ │ │ └── model
│ │ │ ├── WContact.java
│ │ │ └── WMessage.java
│ │ └── whatsapp
│ │ └── MediaData.java
└── res
│ └── values
│ └── strings.xml
└── test
└── java
└── com
└── mega4tech
└── whatsappapilibrary
└── ExampleUnitTest.java
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | .idea
4 | /local.properties
5 | /.idea/workspace.xml
6 | /.idea/vcs.xml
7 | *.apk
8 | /app/fabric.properties
9 | /.idea/libraries
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 |
9 | This version of the GNU Lesser General Public License incorporates
10 | the terms and conditions of version 3 of the GNU General Public
11 | License, supplemented by the additional permissions listed below.
12 |
13 | 0. Additional Definitions.
14 |
15 | As used herein, "this License" refers to version 3 of the GNU Lesser
16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
17 | General Public License.
18 |
19 | "The Library" refers to a covered work governed by this License,
20 | other than an Application or a Combined Work as defined below.
21 |
22 | An "Application" is any work that makes use of an interface provided
23 | by the Library, but which is not otherwise based on the Library.
24 | Defining a subclass of a class defined by the Library is deemed a mode
25 | of using an interface provided by the Library.
26 |
27 | A "Combined Work" is a work produced by combining or linking an
28 | Application with the Library. The particular version of the Library
29 | with which the Combined Work was made is also called the "Linked
30 | Version".
31 |
32 | The "Minimal Corresponding Source" for a Combined Work means the
33 | Corresponding Source for the Combined Work, excluding any source code
34 | for portions of the Combined Work that, considered in isolation, are
35 | based on the Application, and not on the Linked Version.
36 |
37 | The "Corresponding Application Code" for a Combined Work means the
38 | object code and/or source code for the Application, including any data
39 | and utility programs needed for reproducing the Combined Work from the
40 | Application, but excluding the System Libraries of the Combined Work.
41 |
42 | 1. Exception to Section 3 of the GNU GPL.
43 |
44 | You may convey a covered work under sections 3 and 4 of this License
45 | without being bound by section 3 of the GNU GPL.
46 |
47 | 2. Conveying Modified Versions.
48 |
49 | If you modify a copy of the Library, and, in your modifications, a
50 | facility refers to a function or data to be supplied by an Application
51 | that uses the facility (other than as an argument passed when the
52 | facility is invoked), then you may convey a copy of the modified
53 | version:
54 |
55 | a) under this License, provided that you make a good faith effort to
56 | ensure that, in the event an Application does not supply the
57 | function or data, the facility still operates, and performs
58 | whatever part of its purpose remains meaningful, or
59 |
60 | b) under the GNU GPL, with none of the additional permissions of
61 | this License applicable to that copy.
62 |
63 | 3. Object Code Incorporating Material from Library Header Files.
64 |
65 | The object code form of an Application may incorporate material from
66 | a header file that is part of the Library. You may convey such object
67 | code under terms of your choice, provided that, if the incorporated
68 | material is not limited to numerical parameters, data structure
69 | layouts and accessors, or small macros, inline functions and templates
70 | (ten or fewer lines in length), you do both of the following:
71 |
72 | a) Give prominent notice with each copy of the object code that the
73 | Library is used in it and that the Library and its use are
74 | covered by this License.
75 |
76 | b) Accompany the object code with a copy of the GNU GPL and this license
77 | document.
78 |
79 | 4. Combined Works.
80 |
81 | You may convey a Combined Work under terms of your choice that,
82 | taken together, effectively do not restrict modification of the
83 | portions of the Library contained in the Combined Work and reverse
84 | engineering for debugging such modifications, if you also do each of
85 | the following:
86 |
87 | a) Give prominent notice with each copy of the Combined Work that
88 | the Library is used in it and that the Library and its use are
89 | covered by this License.
90 |
91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 | document.
93 |
94 | c) For a Combined Work that displays copyright notices during
95 | execution, include the copyright notice for the Library among
96 | these notices, as well as a reference directing the user to the
97 | copies of the GNU GPL and this license document.
98 |
99 | d) Do one of the following:
100 |
101 | 0) Convey the Minimal Corresponding Source under the terms of this
102 | License, and the Corresponding Application Code in a form
103 | suitable for, and under terms that permit, the user to
104 | recombine or relink the Application with a modified version of
105 | the Linked Version to produce a modified Combined Work, in the
106 | manner specified by section 6 of the GNU GPL for conveying
107 | Corresponding Source.
108 |
109 | 1) Use a suitable shared library mechanism for linking with the
110 | Library. A suitable mechanism is one that (a) uses at run time
111 | a copy of the Library already present on the user's computer
112 | system, and (b) will operate properly with a modified version
113 | of the Library that is interface-compatible with the Linked
114 | Version.
115 |
116 | e) Provide Installation Information, but only if you would otherwise
117 | be required to provide such information under section 6 of the
118 | GNU GPL, and only to the extent that such information is
119 | necessary to install and execute a modified version of the
120 | Combined Work produced by recombining or relinking the
121 | Application with a modified version of the Linked Version. (If
122 | you use option 4d0, the Installation Information must accompany
123 | the Minimal Corresponding Source and Corresponding Application
124 | Code. If you use option 4d1, you must provide the Installation
125 | Information in the manner specified by section 6 of the GNU GPL
126 | for conveying Corresponding Source.)
127 |
128 | 5. Combined Libraries.
129 |
130 | You may place library facilities that are a work based on the
131 | Library side by side in a single library together with other library
132 | facilities that are not Applications and are not covered by this
133 | License, and convey such a combined library under terms of your
134 | choice, if you do both of the following:
135 |
136 | a) Accompany the combined library with a copy of the same work based
137 | on the Library, uncombined with any other library facilities,
138 | conveyed under the terms of this License.
139 |
140 | b) Give prominent notice with the combined library that part of it
141 | is a work based on the Library, and explaining where to find the
142 | accompanying uncombined form of the same work.
143 |
144 | 6. Revised Versions of the GNU Lesser General Public License.
145 |
146 | The Free Software Foundation may publish revised and/or new versions
147 | of the GNU Lesser General Public License from time to time. Such new
148 | versions will be similar in spirit to the present version, but may
149 | differ in detail to address new problems or concerns.
150 |
151 | Each version is given a distinguishing version number. If the
152 | Library as you received it specifies that a certain numbered version
153 | of the GNU Lesser General Public License "or any later version"
154 | applies to it, you have the option of following the terms and
155 | conditions either of that published version or of any later version
156 | published by the Free Software Foundation. If the Library as you
157 | received it does not specify a version number of the GNU Lesser
158 | General Public License, you may choose any version of the GNU Lesser
159 | General Public License ever published by the Free Software Foundation.
160 |
161 | If the Library as you received it specifies that a proxy can decide
162 | whether future versions of the GNU Lesser General Public License shall
163 | apply, that proxy's public statement of acceptance of any version is
164 | permanent authorization for you to choose that version for the
165 | Library.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Whatsapp-API
2 |
3 | An Android Library with demo application, to send media and text messages via Whatsapp on rooted device
4 |
5 | ## Installation
6 |
7 | Add it in your root build.gradle at the end of repositories:
8 |
9 | ```
10 | allprojects {
11 | repositories {
12 | ...
13 | maven { url 'https://jitpack.io' }
14 | }
15 | }
16 | ```
17 | Add the dependency
18 | ```
19 | dependencies {
20 | compile 'com.github.omegaes:Whatsapp-API:1.0.3'
21 | }
22 | ````
23 |
24 |
25 | ## Usage
26 |
27 | Check if device has whatsapp version
28 |
29 | ```
30 | WhatsappApi.getInstance().isWhatsappInstalled() -> boolean
31 | ```
32 |
33 | Check if device has root privilege
34 |
35 | ```
36 | WhatsappApi.getInstance().isRootAvailable() -> boolean
37 | ```
38 |
39 | Get list of whatsapp contacts, from whatsapp database
40 |
41 | ```
42 | WhatsappApi.getInstance().getContacts(Context, GetContactsListener) -> void
43 | ```
44 |
45 | Send message to one contact or list of contacts, create WMessage and WContact objects !
46 | ```
47 | WhatsappApi.getInstance().sendMessage(List, WMessage, Context, SendMessageListener) -> void
48 | ```
49 |
50 |
51 | ## Contributing
52 |
53 | 1. Fork it!
54 | 2. Create your feature branch: `git checkout -b my-new-feature`
55 | 3. Commit your changes: `git commit -am 'Add some feature'`
56 | 4. Push to the branch: `git push origin my-new-feature`
57 | 5. Submit a pull request :D
58 |
59 | ## History
60 |
61 | Not yet
62 |
63 | ## Author
64 |
65 | * **Abdulrahman Babil** - *Software engineer* - [Mega4Tech](http://mega4tech.com)
66 |
67 | ## License
68 |
69 | This project is licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 - see the [LICENSE](LICENSE) file for details
70 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.0"
6 | defaultConfig {
7 | applicationId "com.mega4tech.whatsappapi"
8 | minSdkVersion 16
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:25.2.0'
28 | testCompile 'junit:junit:4.12'
29 | compile project(':whatsappapilibrary')
30 | compile 'com.miguelgaeta.android-media-picker:media-picker:1.5.0'
31 | compile 'org.apache.commons:commons-lang3:3.4'
32 | compile "commons-io:commons-io:2.4"
33 | compile 'com.android.support:design:25.2.0'
34 | compile 'com.android.support:recyclerview-v7:25.2.0'
35 | compile 'gun0912.ted:tedpermission:1.0.3'
36 |
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/app/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/aboodba/Library/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 | -keepattributes *Annotation*
20 | -keepclassmembers class ** {
21 | @com.squareup.otto.Subscribe public *;
22 | @com.squareup.otto.Produce public *;
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/mega4tech/whatsappapi/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.mega4tech.whatsappapi;
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)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.mega4tech.whatsappapi", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mega4tech/whatsappapi/ContactCardRecyclerViewAdapter.java:
--------------------------------------------------------------------------------
1 | package com.mega4tech.whatsappapi;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.util.Log;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ImageView;
10 | import android.widget.TextView;
11 |
12 | import com.mega4tech.whatsappapilibrary.model.WContact;
13 |
14 | import java.util.HashMap;
15 | import java.util.LinkedList;
16 | import java.util.List;
17 |
18 | public class ContactCardRecyclerViewAdapter extends RecyclerView.Adapter {
19 | private RecycleItemClickListener mItemClickListener;
20 | private List mObjects = new LinkedList<>();
21 | HashMap mDictionary;
22 | private Context mContext;
23 | private LayoutInflater layoutInflater;
24 | String[] mContacts;
25 | boolean[] mSelectedContacts;
26 |
27 | public ContactCardRecyclerViewAdapter(Context context,List items, String[] contacts, boolean[] selectedContacts, HashMap dictionary) {
28 | this.mObjects = items;
29 | this.mContext = context;
30 | this.layoutInflater = LayoutInflater.from(context);
31 | mContacts = contacts;
32 | mSelectedContacts = selectedContacts;
33 | mDictionary = dictionary;
34 | }
35 |
36 |
37 | @Override
38 | public int getItemCount() {
39 | return this.mObjects.size();
40 | }
41 |
42 | @Override
43 | public void onBindViewHolder(ContactCardRecyclerViewAdapter.ViewHolder holder, int position) {
44 |
45 | WContact item = this.mObjects.get(position);
46 | Log.d("ABDULL55", item.toString());
47 |
48 | holder.contactNameTv.setText(item.getName());
49 | holder.contactRemoveIv.setTag(item);
50 | holder.contactRemoveIv.setOnClickListener(new View.OnClickListener() {
51 | @Override
52 | public void onClick(View v) {
53 | WContact contact = (WContact) v.getTag();
54 | if(mDictionary.containsKey(contact))
55 | mSelectedContacts[mDictionary.get(contact)] = false;
56 | mObjects.remove(contact);
57 | mDictionary.remove(contact);
58 | notifyDataSetChanged();
59 | }
60 | });
61 | Log.d("ABDULL!", item.toString());
62 |
63 | }
64 |
65 |
66 | @Override
67 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
68 | final LayoutInflater mInflater = LayoutInflater.from(parent.getContext());
69 | final View sView = mInflater.inflate(R.layout.contact_card, parent, false);
70 | return new ContactCardRecyclerViewAdapter.ViewHolder(sView, mItemClickListener);
71 | }
72 |
73 | class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
74 | private RecycleItemClickListener mItemClickListener;
75 | private TextView contactNameTv;
76 | private ImageView contactRemoveIv;
77 |
78 |
79 | public ViewHolder(View view, RecycleItemClickListener itemClickListener) {
80 | super(view);
81 | contactNameTv = (TextView) view.findViewById(R.id.contact_name_tv);
82 | contactRemoveIv = (ImageView) view.findViewById(R.id.contact_remove_iv);
83 | mItemClickListener = itemClickListener;
84 | view.setOnClickListener(this);
85 | }
86 |
87 | @Override
88 | public void onClick(View v) {
89 | if (mItemClickListener != null) {
90 | mItemClickListener.onItemClick(v, getPosition());
91 | }
92 | }
93 | }
94 |
95 | public void setOnItemClickListener(RecycleItemClickListener listener) {
96 | this.mItemClickListener = listener;
97 | }
98 |
99 | public interface RecycleItemClickListener {
100 | public void onItemClick(View view, int position);
101 | }
102 |
103 | public void setmObjects(List mObjects) {
104 | this.mObjects = mObjects;
105 | notifyDataSetChanged();
106 |
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mega4tech/whatsappapi/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.mega4tech.whatsappapi;
2 |
3 | import android.Manifest;
4 | import android.content.Context;
5 | import android.content.DialogInterface;
6 | import android.content.Intent;
7 | import android.os.Bundle;
8 | import android.support.v7.app.AlertDialog;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.support.v7.widget.DefaultItemAnimator;
11 | import android.support.v7.widget.LinearLayoutManager;
12 | import android.support.v7.widget.RecyclerView;
13 | import android.text.TextUtils;
14 | import android.util.Log;
15 | import android.view.View;
16 | import android.widget.Button;
17 | import android.widget.EditText;
18 | import android.widget.TextView;
19 | import android.widget.Toast;
20 |
21 | import com.gun0912.tedpermission.PermissionListener;
22 | import com.gun0912.tedpermission.TedPermission;
23 | import com.mega4tech.whatsappapilibrary.WhatsappApi;
24 | import com.mega4tech.whatsappapilibrary.exception.WhatsappNotInstalledException;
25 | import com.mega4tech.whatsappapilibrary.liseteners.GetContactsListener;
26 | import com.mega4tech.whatsappapilibrary.liseteners.SendMessageListener;
27 | import com.mega4tech.whatsappapilibrary.model.WContact;
28 | import com.mega4tech.whatsappapilibrary.model.WMessage;
29 | import com.miguelgaeta.media_picker.MediaPicker;
30 | import com.miguelgaeta.media_picker.RequestType;
31 |
32 | import java.io.File;
33 | import java.io.IOException;
34 | import java.util.ArrayList;
35 | import java.util.HashMap;
36 | import java.util.LinkedList;
37 | import java.util.List;
38 |
39 | public class MainActivity extends AppCompatActivity implements View.OnClickListener, MediaPicker.Provider, MediaPicker.OnError {
40 |
41 | String[] mContacts;
42 | boolean[] mSelectedContacts;
43 |
44 | HashMap mDictionary;
45 | List mAllContacts;
46 | List mReceivers;
47 | File attachmentFile;
48 |
49 |
50 | private RecyclerView mContactsRv;
51 | private Button mAddContactsBtn;
52 | private EditText mMessageTextTv;
53 | private Button mSendMsgBtn;
54 | private TextView mAttachmentTv;
55 | private Button mAddAttachmentBtn;
56 | private ContactCardRecyclerViewAdapter mAdapter;
57 |
58 |
59 | @Override
60 | protected void onCreate(Bundle savedInstanceState) {
61 | super.onCreate(savedInstanceState);
62 |
63 | mDictionary = new HashMap<>();
64 | mReceivers = new LinkedList<>();
65 |
66 | if (!WhatsappApi.getInstance().isWhatsappInstalled()) {
67 | Toast.makeText(this, "Whatsapp not installed", Toast.LENGTH_SHORT).show();
68 | return;
69 | }
70 |
71 |
72 | if (!WhatsappApi.getInstance().isRootAvailable()) {
73 | Toast.makeText(this, "Root is not available", Toast.LENGTH_SHORT).show();
74 | return;
75 | }
76 |
77 | setContentView(R.layout.activity_main);
78 | initView();
79 |
80 | mSendMsgBtn.setOnClickListener(this);
81 | mAddContactsBtn.setOnClickListener(this);
82 | mAddAttachmentBtn.setOnClickListener(this);
83 | mAddContactsBtn.setEnabled(false);
84 | mSendMsgBtn.setEnabled(false);
85 |
86 | RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext(), LinearLayoutManager.HORIZONTAL, true);
87 | mContactsRv.setLayoutManager(mLayoutManager);
88 | mContactsRv.setItemAnimator(new DefaultItemAnimator());
89 |
90 | try {
91 | WhatsappApi.getInstance().getContacts(this, new GetContactsListener() {
92 | @Override
93 | public void receiveWhatsappContacts(List contacts) {
94 | mAllContacts = contacts;
95 | mAddContactsBtn.setEnabled(true);
96 | mSendMsgBtn.setEnabled(true);
97 | mContacts = new String[contacts.size()];
98 | mSelectedContacts = new boolean[contacts.size()];
99 | mAdapter = new ContactCardRecyclerViewAdapter(MainActivity.this, mReceivers, mContacts, mSelectedContacts, mDictionary);
100 | mContactsRv.setAdapter(mAdapter);
101 | int i = 0;
102 | for (WContact contact : contacts) {
103 | mContacts[i] = contact.getName();//+ ", " + contact.getId().split("@")[0];
104 | i++;
105 | }
106 | }
107 | });
108 | } catch (WhatsappNotInstalledException e) {
109 | e.printStackTrace();
110 | }
111 |
112 |
113 | }
114 |
115 | private void initView() {
116 | mContactsRv = (RecyclerView) findViewById(R.id.contacts_rv);
117 | mAddContactsBtn = (Button) findViewById(R.id.add_contacts_btn);
118 | mMessageTextTv = (EditText) findViewById(R.id.message_text_tv);
119 | mSendMsgBtn = (Button) findViewById(R.id.send_msg_btn);
120 | mAttachmentTv = (TextView) findViewById(R.id.attachment_tv);
121 | mAddAttachmentBtn = (Button) findViewById(R.id.add_attachment_btn);
122 |
123 | }
124 |
125 | @Override
126 | public void onClick(View v) {
127 | switch (v.getId()) {
128 | case R.id.add_contacts_btn:
129 | new AlertDialog.Builder(this)
130 | .setMultiChoiceItems(mContacts, mSelectedContacts, new DialogInterface.OnMultiChoiceClickListener() {
131 | @Override
132 | public void onClick(DialogInterface dialog, int which, boolean isChecked) {
133 | mSelectedContacts[which] = isChecked;
134 | if (isChecked) {
135 | mReceivers.add(mAllContacts.get(which));
136 | mDictionary.put(mAllContacts.get(which), which);
137 | } else {
138 | mReceivers.remove(mAllContacts.get(which));
139 | mDictionary.remove(mAllContacts.get(which));
140 |
141 | }
142 | }
143 | })
144 | .setPositiveButton(R.string.ok_button_label, new DialogInterface.OnClickListener() {
145 | public void onClick(DialogInterface dialog, int whichButton) {
146 | dialog.dismiss();
147 | mAdapter.setmObjects(mReceivers);
148 |
149 | }
150 | })
151 | .show();
152 | break;
153 |
154 | case R.id.add_attachment_btn:
155 | new TedPermission(this)
156 | .setPermissionListener(new PermissionListener() {
157 | @Override
158 | public void onPermissionGranted() {
159 | MediaPicker.startForDocuments(MainActivity.this, MainActivity.this);
160 | }
161 |
162 | @Override
163 | public void onPermissionDenied(ArrayList deniedPermissions) {
164 | Toast.makeText(MainActivity.this, "We need \"read file from storage\" permission to select attachment", Toast.LENGTH_SHORT).show();
165 | }
166 | })
167 | .setDeniedMessage("If you reject permission,you can not use this service\n\nPlease turn on permissions at [Setting] > [Permission]")
168 | .setPermissions(Manifest.permission.READ_EXTERNAL_STORAGE)
169 | .check();
170 | break;
171 | case R.id.send_msg_btn:
172 | if (mReceivers.size() < 1) {
173 | Toast.makeText(this, "You should select one receiver at least", Toast.LENGTH_SHORT).show();
174 | return;
175 | }
176 | if (mReceivers.size() > 5) {
177 | Toast.makeText(this, "You should select less than 5 receivers, demo version !!", Toast.LENGTH_SHORT).show();
178 | return;
179 | }
180 | if (TextUtils.isEmpty(mMessageTextTv.getText()) && attachmentFile == null) {
181 | Toast.makeText(this, "please enter your message or select a media file to send", Toast.LENGTH_SHORT).show();
182 | return;
183 | }
184 | String text = (!TextUtils.isEmpty(mMessageTextTv.getText())) ? mMessageTextTv.getText().toString() : "";
185 | WMessage message = new WMessage(text, attachmentFile, this);
186 |
187 | try {
188 | WhatsappApi.getInstance().sendMessage(mReceivers, message, this, new SendMessageListener() {
189 | @Override
190 | public void finishSendWMessage(List contact, WMessage message) {
191 | Toast.makeText(MainActivity.this, "your message has been sent successfully", Toast.LENGTH_SHORT).show();
192 | }
193 | });
194 | } catch (WhatsappNotInstalledException e) {
195 | e.printStackTrace();
196 |
197 | } catch (IOException e) {
198 | e.printStackTrace();
199 | }
200 | break;
201 | }
202 | }
203 |
204 | @Override
205 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
206 | super.onActivityResult(requestCode, resultCode, data);
207 |
208 | MediaPicker.handleActivityResult(this, requestCode, resultCode, data, new MediaPicker.OnResult() {
209 |
210 | @Override
211 | public void onError(IOException e) {
212 | Log.e("MediaPicker", "Got file error.", e);
213 | e.printStackTrace();
214 | attachmentFile = null;
215 | mAttachmentTv.setText("");
216 | }
217 |
218 | @Override
219 | public void onSuccess(File mediaFile, String mimeType, RequestType request) {
220 | attachmentFile = mediaFile;
221 | mAttachmentTv.setText("Attachment file: " + mediaFile.getName());
222 | }
223 |
224 | @Override
225 | public void onCancelled() {
226 | Log.e("MediaPicker", "Got cancelled event.");
227 | attachmentFile = null;
228 | mAttachmentTv.setText("");
229 | }
230 | });
231 | }
232 |
233 | @Override
234 | public void onError(IOException e) {
235 | e.printStackTrace();
236 | }
237 |
238 | @Override
239 | public Context getContext() {
240 | return this;
241 | }
242 |
243 | @Override
244 | public File getImageFile() {
245 | return null;
246 | }
247 | }
248 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_backspace_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
21 |
22 |
23 |
28 |
29 |
36 |
37 |
38 |
45 |
46 |
53 |
54 |
55 |
63 |
64 |
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/contact_card.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
18 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/omegaes/Whatsapp-API/4925db69e5169ee84382c5697b3f1bd9f703deea/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/omegaes/Whatsapp-API/4925db69e5169ee84382c5697b3f1bd9f703deea/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/omegaes/Whatsapp-API/4925db69e5169ee84382c5697b3f1bd9f703deea/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/omegaes/Whatsapp-API/4925db69e5169ee84382c5697b3f1bd9f703deea/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/omegaes/Whatsapp-API/4925db69e5169ee84382c5697b3f1bd9f703deea/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Whatsapp API
3 | Select
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/mega4tech/whatsappapi/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.mega4tech.whatsappapi;
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
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.2'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 |
19 | maven {
20 | url 'http://lorenzo.villani.me/android-cropimage/'
21 | }
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/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 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/omegaes/Whatsapp-API/4925db69e5169ee84382c5697b3f1bd9f703deea/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
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-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':whatsappapilibrary'
2 |
--------------------------------------------------------------------------------
/whatsappapilibrary/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/whatsappapilibrary/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.0"
6 |
7 | defaultConfig {
8 | minSdkVersion 14
9 | targetSdkVersion 25
10 | versionCode 3
11 | versionName "1.0.2"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 |
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | compile fileTree(dir: 'libs', include: ['*.jar'])
25 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
26 | exclude group: 'com.android.support', module: 'support-annotations'
27 | })
28 | compile 'com.android.support:appcompat-v7:25.2.0'
29 | testCompile 'junit:junit:4.12'
30 | compile 'eu.chainfire:libsuperuser:1.0.0.+'
31 | compile 'org.apache.commons:commons-lang3:3.4'
32 | compile 'commons-io:commons-io:2.4'
33 | }
34 |
--------------------------------------------------------------------------------
/whatsappapilibrary/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/aboodba/Library/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 |
--------------------------------------------------------------------------------
/whatsappapilibrary/src/androidTest/java/com/mega4tech/whatsappapilibrary/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.mega4tech.whatsappapilibrary;
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)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.mega4tech.whatsappapilibrary.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/whatsappapilibrary/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/whatsappapilibrary/src/main/java/com/mega4tech/whatsappapilibrary/Utils.java:
--------------------------------------------------------------------------------
1 | package com.mega4tech.whatsappapilibrary;
2 |
3 | import android.content.ContentResolver;
4 | import android.content.Context;
5 | import android.net.Uri;
6 | import android.webkit.MimeTypeMap;
7 |
8 | import java.io.File;
9 |
10 | /**
11 | * Created by aboodba on 08/03/2017.
12 | */
13 |
14 | public class Utils {
15 |
16 | public static String getMimeType(Context context , File file) {
17 | String mimeType = null;
18 | Uri uri = Uri.fromFile(file);
19 | if (uri.getScheme().equals(ContentResolver.SCHEME_CONTENT)) {
20 | ContentResolver cr = context.getContentResolver();
21 | mimeType = cr.getType(uri);
22 | } else {
23 | String fileExtension = MimeTypeMap.getFileExtensionFromUrl(uri
24 | .toString());
25 | mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(
26 | fileExtension.toLowerCase());
27 | }
28 | return mimeType;
29 | }
30 |
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/whatsappapilibrary/src/main/java/com/mega4tech/whatsappapilibrary/WhatsappApi.java:
--------------------------------------------------------------------------------
1 | package com.mega4tech.whatsappapilibrary;
2 |
3 | import android.content.ContentValues;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.pm.PackageManager;
7 | import android.database.Cursor;
8 | import android.database.sqlite.SQLiteDatabase;
9 | import android.graphics.Bitmap;
10 | import android.graphics.BitmapFactory;
11 | import android.media.ThumbnailUtils;
12 | import android.os.AsyncTask;
13 | import android.os.Environment;
14 | import android.provider.MediaStore;
15 | import android.text.TextUtils;
16 |
17 | import com.mega4tech.whatsappapilibrary.exception.WhatsappNotInstalledException;
18 | import com.mega4tech.whatsappapilibrary.liseteners.GetContactsListener;
19 | import com.mega4tech.whatsappapilibrary.liseteners.SendMessageListener;
20 | import com.mega4tech.whatsappapilibrary.model.WContact;
21 | import com.mega4tech.whatsappapilibrary.model.WMessage;
22 | import com.whatsapp.MediaData;
23 |
24 | import org.apache.commons.io.FilenameUtils;
25 | import org.apache.commons.lang3.SerializationUtils;
26 |
27 | import java.io.ByteArrayOutputStream;
28 | import java.io.File;
29 | import java.io.FileInputStream;
30 | import java.io.FileOutputStream;
31 | import java.io.IOException;
32 | import java.nio.channels.FileChannel;
33 | import java.text.SimpleDateFormat;
34 | import java.util.Calendar;
35 | import java.util.LinkedList;
36 | import java.util.List;
37 | import java.util.Random;
38 |
39 | import eu.chainfire.libsuperuser.Shell;
40 |
41 | /**
42 | * Created by aboodba on 02/03/2017.
43 | */
44 |
45 | public class WhatsappApi {
46 |
47 | private static WhatsappApi instance;
48 | boolean isRootAvailable;
49 | private static String imgFolder = Environment.getExternalStorageDirectory().getAbsolutePath() + "/WhatsApp/Media/WhatsApp Images/Sent";
50 | private static String vidFolder = Environment.getExternalStorageDirectory().getAbsolutePath() + "/WhatsApp/Media/WhatsApp Video/Sent";
51 | private static String audFolder = Environment.getExternalStorageDirectory().getAbsolutePath() + "/WhatsApp/Media/WhatsApp Audio/Sent";
52 | private SQLiteDatabase db;
53 |
54 | public static WhatsappApi getInstance() {
55 | if (instance == null)
56 | instance = new WhatsappApi();
57 | return instance;
58 | }
59 |
60 | private WhatsappApi() {
61 |
62 | boolean suAvailable = Shell.SU.available();
63 | if (suAvailable) {
64 | Shell.SU.run("am force-stop com.whatsapp");
65 | Shell.SU.run("mount -o -R rw,remount /data/data/com.whatsapp");
66 | Shell.SU.run("mount -o rw,remount /data/data/com.whatsapp/databases");
67 | Shell.SU.run("chmod 777 /data/data/com.whatsapp/databases");
68 | Shell.SU.run("chmod 777 /data/data/com.whatsapp/files");
69 | Shell.SU.run("chmod 777 /data/data/com.whatsapp/shared_prefs");
70 | Shell.SU.run("chmod 777 /data/data/com.whatsapp/databases/msgstore.db");
71 | Shell.SU.run("chmod 777 /data/data/com.whatsapp/databases/msgstore.db-wal");
72 | Shell.SU.run("chmod 777 /data/data/com.whatsapp/databases/msgstore.db-shm");
73 | Shell.SU.run("chmod 777 /data/data/com.whatsapp/databases/wa.db");
74 | Shell.SU.run("chmod 777 /data/data/com.whatsapp/databases/wa.db-wal");
75 | Shell.SU.run("chmod 777 /data/data/com.whatsapp/databases/wa.db-shm");
76 | Shell.SU.run("ls -l /data/data/com.whatsapp/databases/msgstore.db-shm");
77 | isRootAvailable = true;
78 |
79 | } else {
80 |
81 | isRootAvailable = false;
82 | }
83 |
84 |
85 | }
86 |
87 | public boolean isWhatsappInstalled() {
88 | File file = new File("/data/data/com.whatsapp/");
89 | return file.exists();
90 | }
91 |
92 | public void sendMessage(WContact contact, WMessage message, Context context, SendMessageListener listener) throws IOException, WhatsappNotInstalledException {
93 | List contacts = new LinkedList<>();
94 | contacts.add(contact);
95 | sendMessage(contacts, message, context, listener);
96 | }
97 |
98 | public synchronized void sendMessage(final List contacts, final WMessage message, final Context context, final SendMessageListener listener) throws IOException, WhatsappNotInstalledException {
99 |
100 |
101 | if (isWhatsappInstalled()) {
102 | new AsyncTask() {
103 | @Override
104 | protected Boolean doInBackground(Void... params) {
105 | Shell.SU.run("am force-stop com.whatsapp");
106 | db = SQLiteDatabase.openOrCreateDatabase(new File("/data/data/com.whatsapp/databases/msgstore.db"), null);
107 | for (WContact contact : contacts) {
108 | try {
109 | sendMessage(contact, message);
110 | } catch (IOException e) {
111 | e.printStackTrace();
112 | }
113 | }
114 | db.close();
115 | PackageManager pm = context.getPackageManager();
116 | Intent intent = pm.getLaunchIntentForPackage("com.whatsapp");
117 | context.startActivity(intent);
118 | return true;
119 | }
120 |
121 | @Override
122 | protected void onPostExecute(Boolean finish) {
123 | super.onPostExecute(finish);
124 | if (listener != null) {
125 | listener.finishSendWMessage(contacts, message);
126 | }
127 | }
128 | }.execute();
129 | } else
130 | throw new WhatsappNotInstalledException();
131 |
132 | }
133 |
134 | private void sendMessage(WContact contact, WMessage message) throws IOException {
135 |
136 | String name = null;
137 | Calendar c = null;
138 | String formattedDate = null;
139 | SimpleDateFormat df = null;
140 | File source = null;
141 | Random rand = null;
142 | File destination = null;
143 |
144 | switch (message.getType()) {
145 | case TEXT:
146 | break;
147 | case VIDEO:
148 | name = message.getFile().getPath();
149 | c = Calendar.getInstance();
150 | df = new SimpleDateFormat("yyyyMMMdd");
151 | formattedDate = df.format(c.getTime());
152 | source = new File(name);
153 | rand = new Random();
154 | destination = new File(vidFolder, "VID-" + formattedDate + "-WA" + (rand.nextInt(100) + rand.nextInt(75) + rand.nextInt(50)) + "." + FilenameUtils.getExtension(message.getFile().getName()));
155 | if (source.exists()) {
156 | FileChannel src = new FileInputStream(source).getChannel();
157 | FileChannel dst = new FileOutputStream(destination).getChannel();
158 | dst.transferFrom(src, 0, src.size());
159 | src.close();
160 | dst.close();
161 | }
162 | name = destination.getName();
163 | break;
164 | case IMAGE:
165 | name = message.getFile().getPath();
166 | c = Calendar.getInstance();
167 | df = new SimpleDateFormat("yyyyMMdd");
168 | formattedDate = df.format(c.getTime());
169 | source = new File(name);
170 | rand = new Random();
171 | destination = new File(imgFolder, "IMG-" + formattedDate + "-WA" + (rand.nextInt(100) + rand.nextInt(75) + rand.nextInt(50)) + "." + FilenameUtils.getExtension(message.getFile().getName()));
172 | if (source.exists()) {
173 | FileChannel src = new FileInputStream(source).getChannel();
174 | FileChannel dst = new FileOutputStream(destination).getChannel();
175 | dst.transferFrom(src, 0, src.size());
176 | src.close();
177 | dst.close();
178 | }
179 | name = destination.getName();
180 | break;
181 | case AUDIO:
182 | name = message.getFile().getPath();
183 | c = Calendar.getInstance();
184 | df = new SimpleDateFormat("yyyyMMdd");
185 | formattedDate = df.format(c.getTime());
186 | source = new File(name);
187 | rand = new Random();
188 | destination = new File(audFolder, "AUD-" + formattedDate + "-WA" + (rand.nextInt(100) + rand.nextInt(75) + rand.nextInt(50)) + "." + FilenameUtils.getExtension(message.getFile().getName()));
189 | if (source.exists()) {
190 | FileChannel src = new FileInputStream(source).getChannel();
191 | FileChannel dst = new FileOutputStream(destination).getChannel();
192 | dst.transferFrom(src, 0, src.size());
193 | src.close();
194 | dst.close();
195 | }
196 | name = destination.getName();
197 | break;
198 | }
199 | sendBigMessage(contact.getId(), message.getText(), name, message.getMime());
200 | }
201 |
202 | public synchronized void getContacts(Context context, final GetContactsListener listener) throws WhatsappNotInstalledException {
203 |
204 | if (isWhatsappInstalled()) {
205 | new AsyncTask>() {
206 | @Override
207 | protected List doInBackground(Void... params) {
208 | Shell.SU.run("am force-stop com.whatsapp");
209 | db = SQLiteDatabase.openOrCreateDatabase(new File("/data/data/com.whatsapp/databases/wa.db"), null);
210 | List contactList = new LinkedList<>();
211 | String selectQuery = "SELECT jid, display_name FROM wa_contacts where phone_type is not null and is_whatsapp_user = 1";
212 | Cursor cursor = db.rawQuery(selectQuery, null);
213 | if (cursor.moveToFirst()) {
214 | do {
215 | WContact contact = new WContact(cursor.getString(1), cursor.getString(0));
216 | contactList.add(contact);
217 | } while (cursor.moveToNext());
218 | }
219 | db.close();
220 | return contactList;
221 | }
222 |
223 | @Override
224 | protected void onPostExecute(List contacts) {
225 | super.onPostExecute(contacts);
226 | if (listener != null) {
227 | listener.receiveWhatsappContacts(contacts);
228 | }
229 | }
230 | }.execute();
231 |
232 |
233 | } else
234 | throw new WhatsappNotInstalledException();
235 |
236 |
237 | }
238 |
239 | private void sendBigMessage(String jid, String msg, String file, String mimeType) {
240 |
241 |
242 | long l1;
243 | long l2;
244 | int k;
245 | String query2, query1;
246 |
247 | Random localRandom = new Random(20L);
248 | l1 = System.currentTimeMillis();
249 | l2 = l1 / 1000L;
250 | k = localRandom.nextInt();
251 |
252 | int mediaType = 0;
253 |
254 | if (mimeType == null || mimeType.length() < 2)
255 | mediaType = 0;
256 | else
257 | mediaType = (mimeType.contains("video")) ? 3
258 | : (mimeType.contains("image")) ? 1
259 | : (mimeType.contains("audio")) ? 2
260 | : 0;
261 |
262 | ContentValues initialValues = new ContentValues();
263 | initialValues.put("key_remote_jid", jid);
264 | initialValues.put("key_from_me", 1);
265 | initialValues.put("key_id", l2 + "-" + k);
266 | initialValues.put("status", 1);
267 | initialValues.put("needs_push", 0);
268 | initialValues.put("timestamp", l1);
269 | initialValues.put("media_wa_type", mediaType);
270 | initialValues.put("media_name", file);
271 | initialValues.put("latitude", 0.0);
272 | initialValues.put("longitude", 0.0);
273 | initialValues.put("received_timestamp", l1);
274 | initialValues.put("send_timestamp", -1);
275 | initialValues.put("receipt_server_timestamp", -1);
276 | initialValues.put("receipt_device_timestamp", -1);
277 | initialValues.put("raw_data", -1);
278 | initialValues.put("recipient_count", 0);
279 | initialValues.put("media_duration", 0);
280 |
281 | if (!TextUtils.isEmpty(file) && !TextUtils.isEmpty(mimeType)) {
282 | //boolean isVideo = mimeType.contains("video");
283 | Bitmap bMap = null;
284 | File spec;
285 | if (mediaType == 3) {
286 | spec = new File(vidFolder, file);
287 | bMap = ThumbnailUtils.createVideoThumbnail(spec.getAbsolutePath(), MediaStore.Video.Thumbnails.MICRO_KIND);
288 | } else if(mediaType == 2) {
289 | spec = new File(audFolder, file);
290 | }else{
291 | spec = new File(imgFolder, file);
292 | bMap = BitmapFactory.decodeFile(spec.getAbsolutePath());
293 | }
294 | long mediaSize = (file.equals("")) ? 0 : spec.length();
295 | ByteArrayOutputStream bos = new ByteArrayOutputStream();
296 | if(mediaType == 1 || mediaType ==3) {
297 | bMap = Bitmap.createScaledBitmap(bMap, 100, 59, false);
298 | bMap.compress(Bitmap.CompressFormat.JPEG, 60, bos);
299 | }
300 | byte[] bArray = bos.toByteArray();
301 |
302 | MediaData md = new MediaData();
303 | md.fileSize = mediaSize;
304 | md.file = spec;
305 | md.autodownloadRetryEnabled = true;
306 | byte[] arr = SerializationUtils.serialize(md);
307 |
308 | initialValues.put("thumb_image", arr);
309 | initialValues.put("quoted_row_id", 0);
310 | //initialValues.put("media_mime_type", mimeType);
311 | //initialValues.put("media_hash", "9vZ3oZyplgiZ40jJvo/sLNrk3c1fuLOA+hLEhEjL+rg=");
312 | initialValues.put("raw_data", bArray);
313 | initialValues.put("media_size", mediaSize);
314 | initialValues.put("origin", 0);
315 | initialValues.put("media_caption", msg);
316 | } else
317 | initialValues.put("data", msg);
318 |
319 | long idm = db.insert("messages", null, initialValues);
320 |
321 | query1 = " insert into chat_list (key_remote_jid) select '" + jid
322 | + "' where not exists (select 1 from chat_list where key_remote_jid='" + jid + "');";
323 |
324 | query2 = " update chat_list set message_table_id = (select max(messages._id) from messages) where chat_list.key_remote_jid='" + jid + "';";
325 |
326 |
327 | ContentValues values = new ContentValues();
328 | values.put("docid", idm);
329 | values.put("c0content", "null ");
330 | db.insert("messages_fts_content", null, values);
331 |
332 |
333 | db.execSQL(query1 + query2);
334 | }
335 |
336 | public boolean isRootAvailable() {
337 | return isRootAvailable;
338 | }
339 | }
340 |
--------------------------------------------------------------------------------
/whatsappapilibrary/src/main/java/com/mega4tech/whatsappapilibrary/exception/RootNotAvailableException.java:
--------------------------------------------------------------------------------
1 | package com.mega4tech.whatsappapilibrary.exception;
2 |
3 | /**
4 | * Created by aboodba on 02/03/2017.
5 | */
6 |
7 | public class RootNotAvailableException extends Exception {
8 | }
9 |
--------------------------------------------------------------------------------
/whatsappapilibrary/src/main/java/com/mega4tech/whatsappapilibrary/exception/WhatsappNotInstalledException.java:
--------------------------------------------------------------------------------
1 | package com.mega4tech.whatsappapilibrary.exception;
2 |
3 | /**
4 | * Created by aboodba on 08/03/2017.
5 | */
6 | public class WhatsappNotInstalledException extends Exception {
7 | }
8 |
--------------------------------------------------------------------------------
/whatsappapilibrary/src/main/java/com/mega4tech/whatsappapilibrary/liseteners/GetContactsListener.java:
--------------------------------------------------------------------------------
1 | package com.mega4tech.whatsappapilibrary.liseteners;
2 |
3 | import com.mega4tech.whatsappapilibrary.model.WContact;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * Created by aboodba on 02/03/2017.
9 | */
10 |
11 | public interface GetContactsListener {
12 |
13 | void receiveWhatsappContacts(List contacts);
14 | }
15 |
--------------------------------------------------------------------------------
/whatsappapilibrary/src/main/java/com/mega4tech/whatsappapilibrary/liseteners/SendMessageListener.java:
--------------------------------------------------------------------------------
1 | package com.mega4tech.whatsappapilibrary.liseteners;
2 |
3 | import com.mega4tech.whatsappapilibrary.model.WContact;
4 | import com.mega4tech.whatsappapilibrary.model.WMessage;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * Created by aboodba on 02/03/2017.
10 | */
11 |
12 | public interface SendMessageListener {
13 | void finishSendWMessage(List contact, WMessage message);
14 | }
15 |
--------------------------------------------------------------------------------
/whatsappapilibrary/src/main/java/com/mega4tech/whatsappapilibrary/model/WContact.java:
--------------------------------------------------------------------------------
1 | package com.mega4tech.whatsappapilibrary.model;
2 |
3 | /**
4 | * Created by aboodba on 02/03/2017.
5 | */
6 |
7 | public class WContact {
8 |
9 | String name;
10 | String id;
11 |
12 | public WContact(String name, String id) {
13 | this.name = name;
14 | this.id = id;
15 |
16 |
17 | if(!id.endsWith("@s.whatsapp.net"))
18 | throw new IllegalArgumentException("ID for Whatsapp contact should ends with : @s.whatsapp.net , for example 9999999999@s.whatsapp.net");
19 | }
20 |
21 | public String getName() {
22 | return name;
23 | }
24 |
25 | public void setName(String name) {
26 | this.name = name;
27 | }
28 |
29 | public String getId() {
30 | return id;
31 | }
32 |
33 | public void setId(String id) {
34 | this.id = id;
35 | }
36 |
37 | @Override
38 | public boolean equals(Object o) {
39 | if (this == o) return true;
40 | if (o == null || getClass() != o.getClass()) return false;
41 |
42 | WContact contact = (WContact) o;
43 |
44 | if (name != null ? !name.equals(contact.name) : contact.name != null) return false;
45 | return id != null ? id.equals(contact.id) : contact.id == null;
46 |
47 | }
48 |
49 | @Override
50 | public int hashCode() {
51 | int result = name != null ? name.hashCode() : 0;
52 | result = 31 * result + (id != null ? id.hashCode() : 0);
53 | return result;
54 | }
55 |
56 | @Override
57 | public String toString() {
58 | return "WContact{" +
59 | "name='" + name + '\'' +
60 | ", id='" + id + '\'' +
61 | '}';
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/whatsappapilibrary/src/main/java/com/mega4tech/whatsappapilibrary/model/WMessage.java:
--------------------------------------------------------------------------------
1 | package com.mega4tech.whatsappapilibrary.model;
2 |
3 | import android.content.Context;
4 | import android.util.Log;
5 |
6 | import com.mega4tech.whatsappapilibrary.Utils;
7 |
8 | import java.io.File;
9 |
10 | /**
11 | * Created by aboodba on 02/03/2017.
12 | */
13 |
14 | public class WMessage {
15 | public enum MessageType {TEXT, VIDEO, IMAGE, AUDIO}
16 |
17 | String text;
18 | String mime;
19 | File file;
20 | MessageType type;
21 |
22 | double lat,lng;
23 | public WMessage(String text, File file, Context context) {
24 | this.text = text;
25 | this.file = file;
26 | if (file != null) {
27 | mime = Utils.getMimeType(context, file);
28 | if (mime == null)
29 | type = MessageType.TEXT;
30 | else if (mime.contains("video"))
31 | type = MessageType.VIDEO;
32 | else if (mime.contains("audio"))
33 | type = MessageType.AUDIO;
34 | else if (mime.contains("image"))
35 | type = MessageType.IMAGE;
36 |
37 | } else
38 | type = MessageType.TEXT;
39 | }
40 |
41 | public String getText() {
42 | return text;
43 | }
44 |
45 | public void setText(String text) {
46 | this.text = text;
47 | }
48 |
49 | public File getFile() {
50 | return file;
51 | }
52 |
53 | public void setFile(File file) {
54 | this.file = file;
55 | }
56 |
57 | public MessageType getType() {
58 | return type;
59 | }
60 |
61 | public String getMime() {
62 | return mime;
63 | }
64 |
65 | public void setType(MessageType type) {
66 | this.type = type;
67 | }
68 |
69 | public double getLat() {
70 | return lat;
71 | }
72 |
73 | public void setLat(double lat) {
74 | this.lat = lat;
75 | }
76 |
77 | public double getLng() {
78 | return lng;
79 | }
80 |
81 | public void setLng(double lng) {
82 | this.lng = lng;
83 | }
84 |
85 | @Override
86 | public boolean equals(Object o) {
87 | if (this == o) return true;
88 | if (o == null || getClass() != o.getClass()) return false;
89 |
90 | WMessage wMessage = (WMessage) o;
91 |
92 | if (text != null ? !text.equals(wMessage.text) : wMessage.text != null) return false;
93 | if (mime != null ? !mime.equals(wMessage.mime) : wMessage.mime != null) return false;
94 | if (file != null ? !file.equals(wMessage.file) : wMessage.file != null) return false;
95 | return type == wMessage.type;
96 |
97 | }
98 |
99 | @Override
100 | public int hashCode() {
101 | int result = text != null ? text.hashCode() : 0;
102 | result = 31 * result + (mime != null ? mime.hashCode() : 0);
103 | result = 31 * result + (file != null ? file.hashCode() : 0);
104 | result = 31 * result + (type != null ? type.hashCode() : 0);
105 | return result;
106 | }
107 |
108 | @Override
109 | public String toString() {
110 | return "WMessage{" +
111 | "text='" + text + '\'' +
112 | ", mime='" + mime + '\'' +
113 | ", file=" + file +
114 | ", type=" + type +
115 | '}';
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/whatsappapilibrary/src/main/java/com/whatsapp/MediaData.java:
--------------------------------------------------------------------------------
1 | package com.whatsapp;
2 |
3 | import java.io.File;
4 | import java.io.Serializable;
5 |
6 | /**
7 | * Created by aboodba on 22/09/16.
8 | */
9 | public class MediaData implements Serializable {
10 |
11 | private static final long serialVersionUID = -3211751283609594L;
12 |
13 | public File file;
14 |
15 | public long fileSize, progress, trimFrom, trimTo;
16 | public int width, height, faceX, faceY, failErrorCode, suspiciousContent;
17 | public String uploadUrl;
18 |
19 | public boolean transcoded, transferred, autodownloadRetryEnabled;
20 |
21 | byte[] hmacKey, iv, mediaKey, refKey;
22 |
23 | public MediaData() {
24 |
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/whatsappapilibrary/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | WhatsappApiLibrary
3 |
4 |
--------------------------------------------------------------------------------
/whatsappapilibrary/src/test/java/com/mega4tech/whatsappapilibrary/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.mega4tech.whatsappapilibrary;
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
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------