version:1.2.1
fix: update:优化双卡拨号
This commit is contained in:
@@ -17,9 +17,11 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.shehuan.niv.NiceImageView;
|
||||
import com.xxpatx.os.R;
|
||||
import com.xxpatx.os.activity.selectnumber.SelectNumberActivity;
|
||||
import com.xxpatx.os.bean.Contact;
|
||||
import com.xxpatx.os.bean.RecordsInfo;
|
||||
import com.xxpatx.os.utils.GlideLoadUtils;
|
||||
import com.xxpatx.os.utils.Utils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
@@ -85,10 +87,21 @@ public class CallRecordAdapter extends RecyclerView.Adapter<CallRecordAdapter.Ho
|
||||
holder.root.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent dialIntent = new Intent(Intent.ACTION_CALL);
|
||||
Uri data = Uri.parse("tel:" + phone);
|
||||
dialIntent.setData(data);
|
||||
mContext.startActivity(dialIntent);
|
||||
if (Utils.isMultiSim(mContext)) {
|
||||
Intent intent = new Intent(mContext, SelectNumberActivity.class);
|
||||
intent.putExtra("phone_number", phone);
|
||||
mContext.startActivity(intent);
|
||||
} else {
|
||||
try {
|
||||
Intent dialIntent = new Intent(Intent.ACTION_CALL);
|
||||
Uri data = Uri.parse("tel:" + phone);
|
||||
dialIntent.setData(data);
|
||||
dialIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mContext.startActivity(dialIntent);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "callNumber: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
holder.iv_remove.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -19,11 +20,14 @@ import com.hjq.toast.Toaster;
|
||||
import com.shehuan.niv.NiceImageView;
|
||||
import com.xxpatx.os.R;
|
||||
import com.xxpatx.os.activity.contact.AddWechatContactActivity;
|
||||
import com.xxpatx.os.activity.selectnumber.SelectNumberActivity;
|
||||
import com.xxpatx.os.bean.Contact;
|
||||
import com.xxpatx.os.utils.Utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ContactHolder> {
|
||||
private static final String TAG = "ContactAdapter";
|
||||
private List<Contact> mContactList;
|
||||
private Context mContext;
|
||||
|
||||
@@ -68,7 +72,6 @@ public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ContactH
|
||||
// Toaster.show("电话功能被禁用");
|
||||
// return;
|
||||
// }
|
||||
Intent dialIntent = new Intent(Intent.ACTION_CALL);
|
||||
String phone = contact.getMobile();
|
||||
if (DIALER_PACKAGE.equals(phone)) {
|
||||
try {
|
||||
@@ -82,9 +85,21 @@ public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ContactH
|
||||
Intent intent = new Intent(mContext, AddWechatContactActivity.class);
|
||||
mContext.startActivity(intent);
|
||||
} else if (!TextUtils.isEmpty(phone)) {
|
||||
Uri data = Uri.parse("tel:" + phone);
|
||||
dialIntent.setData(data);
|
||||
mContext.startActivity(dialIntent);
|
||||
if (Utils.isMultiSim(mContext)) {
|
||||
Intent intent = new Intent(mContext, SelectNumberActivity.class);
|
||||
intent.putExtra("phone_number", phone);
|
||||
mContext.startActivity(intent);
|
||||
} else {
|
||||
try {
|
||||
Intent dialIntent = new Intent(Intent.ACTION_CALL);
|
||||
Uri data = Uri.parse("tel:" + phone);
|
||||
dialIntent.setData(data);
|
||||
dialIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mContext.startActivity(dialIntent);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "callNumber: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
104
app/src/main/java/com/xxpatx/os/adapter/PhoneAdapter.java
Normal file
104
app/src/main/java/com/xxpatx/os/adapter/PhoneAdapter.java
Normal file
@@ -0,0 +1,104 @@
|
||||
package com.xxpatx.os.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.xxpatx.os.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PhoneAdapter extends RecyclerView.Adapter<PhoneAdapter.Holder> {
|
||||
|
||||
//指定SIM卡拨打
|
||||
public static final String[] DUAL_SIM_TYPES = {"subscription", "Subscription",
|
||||
"com.android.phone.extra.slot",
|
||||
"phone", "com.android.phone.DialingMode",
|
||||
"simId", "simnum", "phone_type",
|
||||
"simSlot"};
|
||||
|
||||
private Context mContext;
|
||||
private List<String> mPhoneList;
|
||||
private String mPhone;
|
||||
|
||||
public void setPhoneList(List<String> phoneList) {
|
||||
mPhoneList = phoneList;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
mPhone = phone;
|
||||
}
|
||||
|
||||
public interface OutCallback {
|
||||
public void onCall();
|
||||
}
|
||||
|
||||
private OutCallback mOutCallback;
|
||||
|
||||
public void setOutCallback(OutCallback outCallback) {
|
||||
mOutCallback = outCallback;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
mContext = parent.getContext();
|
||||
return new Holder(LayoutInflater.from(mContext).inflate(R.layout.item_phone, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Holder holder, int position) {
|
||||
String phone = mPhoneList.get(position);
|
||||
if (position == 0) {
|
||||
holder.iv_card.setImageDrawable(mContext.getDrawable(R.drawable.sim_card_1));
|
||||
} else if (position == 1) {
|
||||
holder.iv_card.setImageDrawable(mContext.getDrawable(R.drawable.sim_card_2));
|
||||
}
|
||||
holder.tv_number.setText(phone);
|
||||
holder.root.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent dialIntent = new Intent(Intent.ACTION_CALL);
|
||||
Uri data = Uri.parse("tel:" + mPhone);
|
||||
dialIntent.setData(data);
|
||||
for (int i = 0; i < DUAL_SIM_TYPES.length; i++) {
|
||||
//0代表卡1,1代表卡2
|
||||
dialIntent.putExtra(DUAL_SIM_TYPES[i], position);
|
||||
}
|
||||
mContext.startActivity(dialIntent);
|
||||
if (mOutCallback != null) {
|
||||
mOutCallback.onCall();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mPhoneList == null ? 0 : mPhoneList.size();
|
||||
}
|
||||
|
||||
public class Holder extends RecyclerView.ViewHolder {
|
||||
ConstraintLayout root;
|
||||
TextView tv_sim, tv_number;
|
||||
ImageView iv_card;
|
||||
|
||||
public Holder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
root = itemView.findViewById(R.id.root);
|
||||
iv_card = itemView.findViewById(R.id.iv_card);
|
||||
tv_sim = itemView.findViewById(R.id.tv_sim);
|
||||
tv_number = itemView.findViewById(R.id.tv_number);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user