|
@@ -7,12 +7,14 @@ import android.app.ProgressDialog;
|
|
|
import android.content.ClipboardManager;
|
|
import android.content.ClipboardManager;
|
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
|
|
|
+import android.database.Cursor;
|
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.Bitmap;
|
|
|
import android.graphics.Color;
|
|
import android.graphics.Color;
|
|
|
import android.net.Uri;
|
|
import android.net.Uri;
|
|
|
import android.os.AsyncTask;
|
|
import android.os.AsyncTask;
|
|
|
import android.os.Build;
|
|
import android.os.Build;
|
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
|
|
+import android.provider.ContactsContract;
|
|
|
import android.support.constraint.ConstraintLayout;
|
|
import android.support.constraint.ConstraintLayout;
|
|
|
import android.support.v4.app.Fragment;
|
|
import android.support.v4.app.Fragment;
|
|
|
import android.text.Editable;
|
|
import android.text.Editable;
|
|
@@ -33,6 +35,7 @@ import android.webkit.WebView;
|
|
|
import android.webkit.WebViewClient;
|
|
import android.webkit.WebViewClient;
|
|
|
import android.widget.Button;
|
|
import android.widget.Button;
|
|
|
import android.widget.EditText;
|
|
import android.widget.EditText;
|
|
|
|
|
+import android.widget.ImageButton;
|
|
|
import android.widget.ImageView;
|
|
import android.widget.ImageView;
|
|
|
import android.widget.LinearLayout;
|
|
import android.widget.LinearLayout;
|
|
|
import android.widget.RelativeLayout;
|
|
import android.widget.RelativeLayout;
|
|
@@ -61,6 +64,8 @@ public class DetailFragment extends Fragment implements OnClickListener /*
|
|
|
*/
|
|
*/
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
|
|
+ private static final int People_Pick_Code = 1357;
|
|
|
|
|
+
|
|
|
private String copiedKey;
|
|
private String copiedKey;
|
|
|
private String copiedVal;
|
|
private String copiedVal;
|
|
|
private View touchedView;
|
|
private View touchedView;
|
|
@@ -406,6 +411,9 @@ public class DetailFragment extends Fragment implements OnClickListener /*
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public JSONObject mContent;
|
|
public JSONObject mContent;
|
|
|
|
|
+
|
|
|
|
|
+ private int mSelectContactPosition = -1;
|
|
|
|
|
+
|
|
|
void init(String jstr, LayoutInflater inflater)
|
|
void init(String jstr, LayoutInflater inflater)
|
|
|
{
|
|
{
|
|
|
String TAG = "init@DetailFragment";
|
|
String TAG = "init@DetailFragment";
|
|
@@ -747,6 +755,9 @@ public class DetailFragment extends Fragment implements OnClickListener /*
|
|
|
|
|
|
|
|
TextView toTv = commu_header.findViewById(R.id.comm_to_tv);
|
|
TextView toTv = commu_header.findViewById(R.id.comm_to_tv);
|
|
|
EditText ccTv = commu_header.findViewById(R.id.comm_cc_tv);
|
|
EditText ccTv = commu_header.findViewById(R.id.comm_cc_tv);
|
|
|
|
|
+ ImageButton contactBtn = commu_header.findViewById(R.id.comm_contact_btn);
|
|
|
|
|
+
|
|
|
|
|
+ ccTv.setTag("group_" + i + "_cc");
|
|
|
|
|
|
|
|
String to = groupobj.optString("receipt");
|
|
String to = groupobj.optString("receipt");
|
|
|
String cc = groupobj.optString("cc");
|
|
String cc = groupobj.optString("cc");
|
|
@@ -757,6 +768,18 @@ public class DetailFragment extends Fragment implements OnClickListener /*
|
|
|
TextFieldTextWatcher ccWatcher = new TextFieldTextWatcher(getContext(),ccTv,i,0);
|
|
TextFieldTextWatcher ccWatcher = new TextFieldTextWatcher(getContext(),ccTv,i,0);
|
|
|
ccTv.addTextChangedListener(ccWatcher);
|
|
ccTv.addTextChangedListener(ccWatcher);
|
|
|
|
|
|
|
|
|
|
+ final int selectIndex = i;
|
|
|
|
|
+ contactBtn.setOnClickListener(new OnClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
|
+
|
|
|
|
|
+ mSelectContactPosition = selectIndex;
|
|
|
|
|
+ Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
|
|
|
|
|
+ startActivityForResult(intent, People_Pick_Code);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
listview.addView(commu_header);
|
|
listview.addView(commu_header);
|
|
|
|
|
|
|
|
|
|
|
|
@@ -989,6 +1012,45 @@ public class DetailFragment extends Fragment implements OnClickListener /*
|
|
|
{
|
|
{
|
|
|
// ((NewDetailActivity) getActivity()).showlogin = false;
|
|
// ((NewDetailActivity) getActivity()).showlogin = false;
|
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
|
|
|
+
|
|
|
|
|
+ if (requestCode == People_Pick_Code) {
|
|
|
|
|
+ Uri contactData = data.getData();
|
|
|
|
|
+ Cursor c = mContext.getContentResolver().query(contactData, null, null, null, null);
|
|
|
|
|
+
|
|
|
|
|
+ if (c.moveToFirst()) {
|
|
|
|
|
+ String contactId = c.getString(c.getColumnIndex(ContactsContract.Contacts._ID));
|
|
|
|
|
+
|
|
|
|
|
+ Cursor cursor = mContext.getContentResolver().query(
|
|
|
|
|
+ ContactsContract.CommonDataKinds.Email.CONTENT_URI,
|
|
|
|
|
+ new String[]{ContactsContract.CommonDataKinds.Email.DATA, ContactsContract.CommonDataKinds.Email.TYPE}, ContactsContract.Data.CONTACT_ID + "='" + contactId + "'", null, null);
|
|
|
|
|
+
|
|
|
|
|
+ while(cursor.moveToNext()) {
|
|
|
|
|
+ String email = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
|
|
|
|
|
+ String emailType = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.TYPE));
|
|
|
|
|
+
|
|
|
|
|
+ email = email.replace("\r\n",";");
|
|
|
|
|
+ email = email.replace("\r",";");
|
|
|
|
|
+ email = email.replace("\n",";");
|
|
|
|
|
+
|
|
|
|
|
+ String[] emailArr = email.split(";");
|
|
|
|
|
+ for (int i = 0; i < emailArr.length; i++) {
|
|
|
|
|
+ email = emailArr[i];
|
|
|
|
|
+ if (email.length() > 0) {
|
|
|
|
|
+ if (emailType != null && Integer.valueOf(emailType) == ContactsContract.CommonDataKinds.Email.TYPE_WORK) {
|
|
|
|
|
+ appendContactEmail(email,mSelectContactPosition);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ mSelectContactPosition = -1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -1356,6 +1418,44 @@ public class DetailFragment extends Fragment implements OnClickListener /*
|
|
|
// }
|
|
// }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void appendContactEmail(String email,int group) {
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+
|
|
|
|
|
+ String groupKey = "group" + group;
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject groupObj = mContent.getJSONObject(groupKey);
|
|
|
|
|
+ String groupType = groupObj.getString("_type");
|
|
|
|
|
+
|
|
|
|
|
+ if (groupType.equals("communication")) {
|
|
|
|
|
+
|
|
|
|
|
+ String oldCC = groupObj.optString("cc");
|
|
|
|
|
+ if (oldCC == null || oldCC.length() == 0) {
|
|
|
|
|
+ oldCC = email + ";";
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (oldCC.substring(oldCC.length() - 1).equals(";")) {
|
|
|
|
|
+ oldCC = oldCC + email + ";";
|
|
|
|
|
+ } else {
|
|
|
|
|
+ oldCC = oldCC + ";" + email + ";";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ commContentChange(oldCC,group,0);
|
|
|
|
|
+
|
|
|
|
|
+ EditText ccTv = ll_root.findViewWithTag("group_" + group + "_cc");
|
|
|
|
|
+ if (ccTv != null) {
|
|
|
|
|
+ ccTv.setText(oldCC);
|
|
|
|
|
+ ccTv.requestFocus();
|
|
|
|
|
+ ccTv.setSelection(oldCC.length());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } catch (JSONException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void commContentChange(String content,int group,int child) {
|
|
private void commContentChange(String content,int group,int child) {
|
|
|
|
|
|
|
|
try {
|
|
try {
|