主页显示联系人,增加联系人拨号选项,优化权限获取
This commit is contained in:
@@ -6,7 +6,9 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.ttstd.dialer"
|
||||
minSdkVersion 24
|
||||
|
||||
//There are no CERT files because If the mini sdk version is 23+, the AGP will ignore the V1 scheme signature.
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
@@ -20,7 +22,7 @@ android {
|
||||
|
||||
ndk {
|
||||
//根据需要 自行选择添加的对应cpu类型的.so库。
|
||||
abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a'
|
||||
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
|
||||
// 还可以添加 'x86', 'x86_64', 'mips', 'mips64'
|
||||
}
|
||||
|
||||
@@ -117,7 +119,7 @@ dependencies {
|
||||
//MMKV
|
||||
implementation 'com.tencent:mmkv-static:1.2.14'
|
||||
//bugly
|
||||
implementation 'com.tencent.bugly:crashreport:4.1.9.2'
|
||||
implementation 'com.tencent.bugly:crashreport:4.1.9.3'
|
||||
implementation 'com.iqiyi.xcrash:xcrash-android-lib:3.0.0'
|
||||
// 替换成最新版本, 需要注意的是api
|
||||
// 要与compiler匹配使用,均使用最新版可以保证兼容
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
package="com.ttstd.dialer">
|
||||
|
||||
|
||||
<uses-permission android:name="android.permission.CALL_PHONE" />
|
||||
|
||||
<application
|
||||
android:name=".base.BaseApplication"
|
||||
android:allowBackup="true"
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
package com.ttstd.dialer.activity.contact.list;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
@@ -14,6 +19,7 @@ import com.ttstd.dialer.adapter.ContactInfoAdapter;
|
||||
import com.ttstd.dialer.base.mvvm.BaseMvvmActivity;
|
||||
import com.ttstd.dialer.databinding.ActivityContactListBinding;
|
||||
import com.ttstd.dialer.db.contact.Contact;
|
||||
import com.ttstd.dialer.fragment.dialog.call.CallFragment;
|
||||
import com.ttstd.dialer.view.ItemTouchHelperCallback;
|
||||
|
||||
import java.util.List;
|
||||
@@ -21,6 +27,7 @@ import java.util.List;
|
||||
public class ContactListActivity extends BaseMvvmActivity<ContactListViewModel, ActivityContactListBinding> {
|
||||
|
||||
private static final String TAG = "ContactListActivity";
|
||||
private static final int REQUEST_CODE_CALL = 7897;
|
||||
|
||||
private ContactInfoAdapter mContactInfoAdapter;
|
||||
|
||||
@@ -72,6 +79,12 @@ public class ContactListActivity extends BaseMvvmActivity<ContactListViewModel,
|
||||
|
||||
}
|
||||
});
|
||||
mContactInfoAdapter.setOnClickListener(new ContactInfoAdapter.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(Contact contact) {
|
||||
new CallFragment(contact).show(getSupportFragmentManager(), "CallFragment");
|
||||
}
|
||||
});
|
||||
// 设置ItemTouchHelper,实现拖动和滑动删除
|
||||
ItemTouchHelper.Callback callback = new ItemTouchHelperCallback(mContactInfoAdapter);
|
||||
ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
|
||||
@@ -95,6 +108,30 @@ public class ContactListActivity extends BaseMvvmActivity<ContactListViewModel,
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
|
||||
if (requestCode == REQUEST_CODE_CALL) {
|
||||
// 检查所有权限的结果是否都已授予
|
||||
boolean allGranted = true;
|
||||
for (int result : grantResults) {
|
||||
if (result != PackageManager.PERMISSION_GRANTED) {
|
||||
allGranted = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if (allGranted) {
|
||||
// onAllPermissionsGranted(); // 权限全部获取成功
|
||||
// } else {
|
||||
// // 处理权限被拒绝的情况
|
||||
// handlePermissionDenied();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.ttstd.dialer.adapter;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -7,6 +11,8 @@ import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
@@ -41,6 +47,16 @@ public class ContactInfoAdapter extends RecyclerView.Adapter<ContactInfoAdapter.
|
||||
void onItemRemoved(int position);
|
||||
}
|
||||
|
||||
public interface OnClickListener {
|
||||
void onClick(Contact contact);
|
||||
}
|
||||
|
||||
private OnClickListener mOnClickListener;
|
||||
|
||||
public void setOnClickListener(OnClickListener onClickListener) {
|
||||
mOnClickListener = onClickListener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ContactInfoHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
@@ -55,6 +71,15 @@ public class ContactInfoAdapter extends RecyclerView.Adapter<ContactInfoAdapter.
|
||||
holder.tv_name.setText(name);
|
||||
String phone = contact.getPhoneNumber();
|
||||
holder.tv_phone.setText(phone);
|
||||
holder.root.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Log.e(TAG, "onClick: " + contact);
|
||||
if (mOnClickListener != null) {
|
||||
mOnClickListener.onClick(contact);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,11 +121,13 @@ public class ContactInfoAdapter extends RecyclerView.Adapter<ContactInfoAdapter.
|
||||
}
|
||||
|
||||
public class ContactInfoHolder extends RecyclerView.ViewHolder {
|
||||
ConstraintLayout root;
|
||||
NiceImageView nv_avatar;
|
||||
TextView tv_name, tv_phone;
|
||||
|
||||
public ContactInfoHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
root = itemView.findViewById(R.id.root);
|
||||
nv_avatar = itemView.findViewById(R.id.nv_avatar);
|
||||
tv_name = itemView.findViewById(R.id.tv_name);
|
||||
tv_phone = itemView.findViewById(R.id.tv_phone);
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
package com.ttstd.dialer.adapter;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.shehuan.niv.NiceImageView;
|
||||
import com.ttstd.dialer.R;
|
||||
import com.ttstd.dialer.db.contact.Contact;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class HomeContactAdapter extends RecyclerView.Adapter<HomeContactAdapter.ContactInfoHolder> {
|
||||
private static final String TAG = "ContactInfoAdapter";
|
||||
|
||||
private FragmentActivity mContext;
|
||||
|
||||
private List<Contact> mContacts;
|
||||
|
||||
public void setContacts(List<Contact> contacts) {
|
||||
mContacts = contacts;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setItemMoveCallback(ItemMoveCallback itemMoveCallback) {
|
||||
mItemMoveCallback = itemMoveCallback;
|
||||
}
|
||||
|
||||
private ItemMoveCallback mItemMoveCallback;
|
||||
|
||||
public interface ItemMoveCallback {
|
||||
void onItemMove(int fromPosition, int toPosition);
|
||||
|
||||
void onItemRemoved(int position);
|
||||
}
|
||||
|
||||
public interface OnClickListener {
|
||||
void onClick(Contact contact);
|
||||
}
|
||||
|
||||
private OnClickListener mOnClickListener;
|
||||
|
||||
public void setOnClickListener(OnClickListener onClickListener) {
|
||||
mOnClickListener = onClickListener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ContactInfoHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
mContext = (FragmentActivity) parent.getContext();
|
||||
return new ContactInfoHolder(LayoutInflater.from(mContext).inflate(R.layout.item_contact_home, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ContactInfoHolder holder, int position) {
|
||||
Contact contact = mContacts.get(position);
|
||||
String name = contact.getName();
|
||||
holder.tv_name.setText(name);
|
||||
String phone = contact.getPhoneNumber();
|
||||
holder.tv_phone.setText(phone);
|
||||
holder.root.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Log.e(TAG, "onClick: " + contact);
|
||||
if (mOnClickListener != null) {
|
||||
mOnClickListener.onClick(contact);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mContacts == null ? 0 : mContacts.size();
|
||||
}
|
||||
|
||||
|
||||
// 处理拖动交换位置
|
||||
public void onItemMove(int fromPosition, int toPosition) {
|
||||
Log.e(TAG, "onItemMove: fromPosition = " + fromPosition);
|
||||
Log.e(TAG, "onItemMove: toPosition = " + toPosition);
|
||||
if (fromPosition == toPosition) {
|
||||
return; // 直接返回,不执行后续操作
|
||||
}
|
||||
|
||||
if (fromPosition < toPosition) {
|
||||
for (int i = fromPosition; i < toPosition; i++) {
|
||||
Collections.swap(mContacts, i, i + 1);
|
||||
}
|
||||
} else {
|
||||
for (int i = fromPosition; i > toPosition; i--) {
|
||||
Collections.swap(mContacts, i, i - 1);
|
||||
}
|
||||
}
|
||||
notifyItemMoved(fromPosition, toPosition);
|
||||
if (mItemMoveCallback != null) {
|
||||
mItemMoveCallback.onItemMove(fromPosition, toPosition);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理滑动删除
|
||||
public void onItemDismiss(int position) {
|
||||
// mContacts.remove(position);
|
||||
if (mItemMoveCallback != null) {
|
||||
mItemMoveCallback.onItemRemoved(position);
|
||||
}
|
||||
notifyItemRemoved(position);
|
||||
}
|
||||
|
||||
public class ContactInfoHolder extends RecyclerView.ViewHolder {
|
||||
ConstraintLayout root;
|
||||
NiceImageView nv_avatar;
|
||||
TextView tv_name, tv_phone;
|
||||
|
||||
public ContactInfoHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
root = itemView.findViewById(R.id.root);
|
||||
nv_avatar = itemView.findViewById(R.id.nv_avatar);
|
||||
tv_name = itemView.findViewById(R.id.tv_name);
|
||||
tv_phone = itemView.findViewById(R.id.tv_phone);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
package com.ttstd.dialer.base.mvvm.fragment;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.ttstd.dialer.base.BaseDialogFragment;
|
||||
import com.ttstd.dialer.base.BaseFragment;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
|
||||
/**
|
||||
* @author: lml
|
||||
* @date: 2021/12/15
|
||||
*/
|
||||
public abstract class BaseMvvmDialogFragment<VM extends ViewModel, VDB extends ViewDataBinding> extends BaseDialogFragment {
|
||||
protected String mTag = this.getClass().getSimpleName();
|
||||
/**
|
||||
* 是否顯示了
|
||||
*/
|
||||
protected boolean mIsVisible;
|
||||
/**
|
||||
* 是否準備好了-Created
|
||||
*/
|
||||
protected boolean mHasPrepare;
|
||||
|
||||
|
||||
protected VM mViewModel;
|
||||
protected VDB mViewDataBinding;
|
||||
protected Class<VM> vmClass;
|
||||
//
|
||||
// protected Toolbar toolbar;
|
||||
// protected View statusBarView;
|
||||
//
|
||||
protected Bundle bundle;//来自getArguments()
|
||||
protected Bundle savedInstanceState;
|
||||
|
||||
// protected Context context;
|
||||
|
||||
/**
|
||||
* 上下文
|
||||
*/
|
||||
private WeakReference<Context> ctx;
|
||||
|
||||
public Context getCtx() {
|
||||
return ctx == null ? null : ctx.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
// this.context = context;
|
||||
ctx = new WeakReference<>(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* onCreate、onResume里不能调用
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isAttached() {
|
||||
boolean flag = getCtx() != null && isAdded();
|
||||
Log.e(" >> isAttached >>", "flag = " + flag);
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
//ViewDataBinding
|
||||
mViewDataBinding = DataBindingUtil.inflate(inflater, getLayoutId(), container, false);
|
||||
mViewDataBinding.setLifecycleOwner(this);
|
||||
|
||||
//ViewModel
|
||||
vmClass = (Class<VM>) ((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments()[0];
|
||||
mViewModel = new ViewModelProvider(this).get(vmClass);
|
||||
//
|
||||
return mViewDataBinding.getRoot();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
// if (initStatusBarToolBar()) {
|
||||
// toolbar = getToolbar();
|
||||
// }
|
||||
//注册eventbus
|
||||
// if (getClass().isAnnotationPresent(BindEventBus.class))
|
||||
// EventBusManager.register(this);
|
||||
//
|
||||
|
||||
// fitsLayoutOverlap();
|
||||
initDataBinding();
|
||||
initView(bundle = getArguments());
|
||||
//
|
||||
initData(this.savedInstanceState = savedInstanceState);
|
||||
//
|
||||
if (mIsVisible) {
|
||||
onEnter();
|
||||
}
|
||||
mHasPrepare = true;
|
||||
//
|
||||
// LiveDataBus.get().with(ConstantUtils.DATA_BUS_LOADING_FRAGMENT, Boolean.class).observe(getActivity(), bool -> {
|
||||
// L.e(" >> LiveDataBus >> DATA_BUS_LOADING_FRAGMENT: %s", bool);
|
||||
// if(bool) {
|
||||
// showLoading(R.string.str_please_wait);
|
||||
// } else {
|
||||
// hideLoading();
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
mHasPrepare = false;
|
||||
mViewDataBinding = null;
|
||||
//移除eventbus
|
||||
// if (getClass().isAnnotationPresent(BindEventBus.class))
|
||||
// EventBusManager.unregister(this);
|
||||
//
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||
super.setUserVisibleHint(isVisibleToUser);
|
||||
if (mIsVisible == getUserVisibleHint())
|
||||
return;
|
||||
mIsVisible = getUserVisibleHint();
|
||||
if (mIsVisible) {
|
||||
if (!mHasPrepare)
|
||||
return;
|
||||
onEnter();
|
||||
} else {
|
||||
onExit();
|
||||
}
|
||||
}
|
||||
|
||||
@LayoutRes
|
||||
protected abstract int getLayoutId();
|
||||
|
||||
// protected abstract Toolbar getToolbar();
|
||||
|
||||
// protected View getStatusView() {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
protected abstract void initDataBinding();
|
||||
|
||||
protected abstract void initView(Bundle bundle);
|
||||
|
||||
protected abstract void initData(Bundle savedInstanceState);
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
// fitsLayoutOverlap();
|
||||
}
|
||||
|
||||
// protected boolean isImmersionBarEnabled() {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// protected boolean initStatusBarToolBar() {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
|
||||
// private void fitsLayoutOverlap() {
|
||||
// if (!isImmersionBarEnabled()) return;
|
||||
// if (statusBarView != null) {
|
||||
// ImmersionBar.setStatusBarView(getActivity(), statusBarView);
|
||||
// }
|
||||
// if (toolbar != null) {
|
||||
// ImmersionBar.setTitleBar(getActivity(), toolbar);
|
||||
// }
|
||||
// }
|
||||
|
||||
protected void hideInputMethod(Activity activity) {
|
||||
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
|
||||
View view = activity.getCurrentFocus();
|
||||
if (view != null) {
|
||||
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
protected void hideInputMethod(Activity activity, EditText editText) {
|
||||
InputMethodManager imm = (InputMethodManager) editText.getContext().getSystemService(Activity.INPUT_METHOD_SERVICE);
|
||||
View view = activity.getCurrentFocus();
|
||||
if (view != null) {
|
||||
imm.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
|
||||
}
|
||||
}
|
||||
|
||||
protected void showInputMethod(EditText editText) {
|
||||
InputMethodManager imm = (InputMethodManager) editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.showSoftInput(editText, InputMethodManager.SHOW_FORCED);
|
||||
}
|
||||
|
||||
|
||||
// private CustomDialog mWaitDialog;
|
||||
//
|
||||
// public void showLoading(@StringRes int contentID) {
|
||||
// showLoading(contentID, R.color.white);
|
||||
// }
|
||||
//
|
||||
// public void showLoading(@StringRes int contentID, @ColorRes int color) {
|
||||
// hideLoading();
|
||||
// DialogX.init(getActivity());
|
||||
// if (color == R.color.white) {
|
||||
// mWaitDialog = DialogXUtil.getInstance().showLoading(getActivity(), getString(contentID), getResources().getColor(color));
|
||||
// } else {
|
||||
// mWaitDialog = DialogXUtil.getInstance().showLoading_black(getActivity(), getString(contentID), getResources().getColor(color));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void updateLoadingTip(@StringRes int messageID, int percent) {
|
||||
// try {
|
||||
// if (mWaitDialog != null && mWaitDialog.isShow()) {
|
||||
// TextView tvTip = mWaitDialog.getCustomView().findViewById(R.id.tv_load_tip);
|
||||
// if (tvTip != null)
|
||||
// tvTip.setText(getResources().getString(messageID) + (percent == -1 ? "" : percent + "%"));
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public boolean isShowLoading() {
|
||||
// return mWaitDialog != null && mWaitDialog.isShow();
|
||||
// }
|
||||
//
|
||||
// public void hideLoading() {
|
||||
// try {
|
||||
// boolean isShow = isShowLoading();
|
||||
// L.d(" >> hideLoading :: isShow: %s", isShow);
|
||||
// if (isShow)
|
||||
// mWaitDialog.dismiss();
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 進入界面
|
||||
*/
|
||||
protected void onEnter() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 離開界面
|
||||
*/
|
||||
protected void onExit() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +1,37 @@
|
||||
package com.ttstd.dialer.fragment.contact;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
import com.ttstd.dialer.R;
|
||||
import com.ttstd.dialer.adapter.HomeContactAdapter;
|
||||
import com.ttstd.dialer.base.mvvm.fragment.BaseMvvmFragment;
|
||||
import com.ttstd.dialer.databinding.FragmentContactBinding;
|
||||
import com.ttstd.dialer.db.contact.Contact;
|
||||
import com.ttstd.dialer.fragment.dialog.call.CallFragment;
|
||||
import com.ttstd.dialer.fragment.dialog.permission.PermissionDialogFragment;
|
||||
import com.ttstd.dialer.view.EqualHeightDecoration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ContactFragment extends BaseMvvmFragment<ContactViewModel, FragmentContactBinding> {
|
||||
private static final String TAG ="ContactFragment";
|
||||
private static final String TAG = "ContactFragment";
|
||||
|
||||
private Activity mContext;
|
||||
private HomeContactAdapter mHomeContactAdapter;
|
||||
private List<Contact> mContacts;
|
||||
|
||||
private static final int REQUEST_CODE_CALL = 7897;
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@@ -28,20 +49,44 @@ public class ContactFragment extends BaseMvvmFragment<ContactViewModel, Fragment
|
||||
|
||||
@Override
|
||||
protected void initView(Bundle bundle) {
|
||||
|
||||
mHomeContactAdapter = new HomeContactAdapter();
|
||||
mHomeContactAdapter.setOnClickListener(new HomeContactAdapter.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(Contact contact) {
|
||||
new CallFragment(contact).show(getChildFragmentManager(), "CallFragment");
|
||||
}
|
||||
});
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(mContext, 2);
|
||||
mViewDataBinding.recyclerView.addItemDecoration(new EqualHeightDecoration(3));
|
||||
mViewDataBinding.recyclerView.setLayoutManager(gridLayoutManager);
|
||||
mViewDataBinding.recyclerView.setAdapter(mHomeContactAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData(Bundle savedInstanceState) {
|
||||
|
||||
mViewModel.mContactListData.observe(this, new Observer<List<Contact>>() {
|
||||
@Override
|
||||
public void onChanged(List<Contact> contacts) {
|
||||
Log.e(TAG, "mContactListData: " + contacts);
|
||||
mContacts = contacts;
|
||||
mHomeContactAdapter.setContacts(mContacts);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void fetchData() {
|
||||
|
||||
}
|
||||
|
||||
public class BtnClick{
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mViewModel.getAllContacts();
|
||||
}
|
||||
|
||||
public class BtnClick {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,81 @@
|
||||
package com.ttstd.dialer.fragment.contact;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||
import com.ttstd.dialer.base.mvvm.BaseViewModel;
|
||||
import com.ttstd.dialer.databinding.FragmentContactBinding;
|
||||
import com.ttstd.dialer.db.contact.Contact;
|
||||
import com.ttstd.dialer.db.contact.ContactRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.ObservableEmitter;
|
||||
import io.reactivex.rxjava3.core.ObservableOnSubscribe;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
|
||||
public class ContactViewModel extends BaseViewModel<FragmentContactBinding, FragmentEvent> {
|
||||
private ContactRepository mRepository;
|
||||
|
||||
@Override
|
||||
public void setContext(Context context) {
|
||||
super.setContext(context);
|
||||
mRepository = new ContactRepository(context);
|
||||
}
|
||||
|
||||
public MutableLiveData<List<Contact>> mContactListData = new MutableLiveData<>();
|
||||
|
||||
public void getAllContacts() {
|
||||
Observable.create(new ObservableOnSubscribe<List<Contact>>() {
|
||||
@Override
|
||||
public void subscribe(@NonNull ObservableEmitter<List<Contact>> emitter) throws Throwable {
|
||||
List<Contact> contacts = mRepository.getAllContacts();
|
||||
emitter.onNext(contacts);
|
||||
emitter.onComplete();
|
||||
}
|
||||
}).compose(RxLifecycle.bindUntilEvent(getLifecycle(), FragmentEvent.DESTROY))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<List<Contact>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getAllContacts", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull List<Contact> contacts) {
|
||||
Log.e("getAllContacts", "onNext: ");
|
||||
mContactListData.setValue(contacts);
|
||||
|
||||
// List<Contact> sorted = contacts.stream().sorted(new Comparator<Contact>() {
|
||||
// @Override
|
||||
// public int compare(Contact o1, Contact o2) {
|
||||
// return Integer.compare(o1.getSort(), o2.getSort());
|
||||
// }
|
||||
// }).collect(Collectors.toList());
|
||||
// mContactListData.setValue(sorted);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getAllContacts", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getAllContacts", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
package com.ttstd.dialer.fragment.dialog.call;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.ttstd.dialer.R;
|
||||
import com.ttstd.dialer.activity.contact.list.ContactListActivity;
|
||||
import com.ttstd.dialer.base.mvvm.fragment.BaseMvvmDialogFragment;
|
||||
import com.ttstd.dialer.databinding.FragmentCallBinding;
|
||||
import com.ttstd.dialer.db.contact.Contact;
|
||||
|
||||
public class CallFragment extends BaseMvvmDialogFragment<CallViewModel, FragmentCallBinding> {
|
||||
private static final String TAG = "CallFragment";
|
||||
|
||||
private static final int REQUEST_CODE_CALL = 7897;
|
||||
|
||||
private Activity mContext;
|
||||
private Contact mContact;
|
||||
|
||||
public CallFragment(Contact contact) {
|
||||
mContact = contact;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_call;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDataBinding() {
|
||||
mContext = getActivity();
|
||||
mViewModel.setContext(mContext);
|
||||
mViewModel.setVDBinding(mViewDataBinding);
|
||||
mViewModel.setLifecycle(getLifecycleSubject());
|
||||
mViewDataBinding.setClick(new BtnClick());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView(Bundle bundle) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData(Bundle savedInstanceState) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
if (getDialog() != null) {
|
||||
Window window = getDialog().getWindow();
|
||||
if (window == null) return;
|
||||
WindowManager.LayoutParams params = window.getAttributes();
|
||||
params.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||
params.gravity = Gravity.BOTTOM;
|
||||
window.setAttributes(params);
|
||||
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
getDialog().setCancelable(true);
|
||||
getDialog().setCanceledOnTouchOutside(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show(FragmentManager manager, String tag) {
|
||||
DialogFragment fragment = (DialogFragment) manager.findFragmentByTag(tag);
|
||||
if (fragment != null && fragment.isAdded()
|
||||
&& fragment.getDialog() != null && fragment.getDialog().isShowing()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
FragmentTransaction ft = manager.beginTransaction();
|
||||
ft.add(this, tag);
|
||||
ft.commitAllowingStateLoss();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "show: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == REQUEST_CODE_CALL) {
|
||||
call();
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fetchData() {
|
||||
|
||||
}
|
||||
|
||||
public void call() {
|
||||
try {
|
||||
String phone = mContact.getPhoneNumber();
|
||||
Intent dialIntent = new Intent(Intent.ACTION_CALL);
|
||||
Uri data = Uri.parse("tel:" + phone);
|
||||
dialIntent.setData(data);
|
||||
dialIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(dialIntent);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "callNumber: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public class BtnClick {
|
||||
|
||||
public void callWechatVideo(View view) {
|
||||
|
||||
dismiss();
|
||||
}
|
||||
|
||||
public void callWechatAudio(View view) {
|
||||
|
||||
dismiss();
|
||||
}
|
||||
|
||||
public void callPhone(View view) {
|
||||
if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(mContext, new String[]{Manifest.permission.CALL_PHONE}, REQUEST_CODE_CALL);
|
||||
} else {
|
||||
call();
|
||||
}
|
||||
}
|
||||
|
||||
public void cancel(View view) {
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.ttstd.dialer.fragment.dialog.call;
|
||||
|
||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||
import com.ttstd.dialer.base.mvvm.BaseViewModel;
|
||||
import com.ttstd.dialer.databinding.FragmentCallBinding;
|
||||
|
||||
public class CallViewModel extends BaseViewModel<FragmentCallBinding, FragmentEvent> {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.ttstd.dialer.fragment.dialog.permission;
|
||||
|
||||
import android.Manifest;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.ttstd.dialer.R;
|
||||
import com.ttstd.dialer.base.BaseDialogFragment;
|
||||
import com.ttstd.dialer.databinding.DialogFragmentPermissionsBinding;
|
||||
|
||||
public class PermissionDialogFragment extends BaseDialogFragment {
|
||||
private static final String TAG = "PermissionDialog";
|
||||
private static final int REQUEST_CODE_CALL = 7897;
|
||||
|
||||
private View rootView;
|
||||
private FragmentActivity mContext;
|
||||
private DialogFragmentPermissionsBinding mBinding;
|
||||
private String mContent;
|
||||
|
||||
public PermissionDialogFragment(String content) {
|
||||
this.mContent = content;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
Log.e(TAG, "onCreateView: ");
|
||||
mBinding = DataBindingUtil.inflate(inflater, R.layout.dialog_fragment_permissions, container, false);
|
||||
mBinding.setClick(new BtnClick());
|
||||
rootView = mBinding.getRoot();
|
||||
mContext = getActivity();
|
||||
initView();
|
||||
return rootView;
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
mBinding.tvContent.setText(mContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
if (getDialog() != null) {
|
||||
Window window = getDialog().getWindow();
|
||||
if (window == null) return;
|
||||
WindowManager.LayoutParams params = window.getAttributes();
|
||||
params.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||
params.gravity = Gravity.CENTER;
|
||||
window.setAttributes(params);
|
||||
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
getDialog().setCancelable(true);
|
||||
getDialog().setCanceledOnTouchOutside(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show(FragmentManager manager, String tag) {
|
||||
DialogFragment fragment = (DialogFragment) manager.findFragmentByTag(tag);
|
||||
if (fragment != null && fragment.isAdded()
|
||||
&& fragment.getDialog() != null && fragment.getDialog().isShowing()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
FragmentTransaction ft = manager.beginTransaction();
|
||||
ft.add(this, tag);
|
||||
ft.commitAllowingStateLoss();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "show: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void fetchData() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == REQUEST_CODE_CALL) {
|
||||
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
public class BtnClick {
|
||||
public void onDenied(View view) {
|
||||
dismiss();
|
||||
}
|
||||
|
||||
public void onGranted(View view) {
|
||||
ActivityCompat.requestPermissions(mContext, new String[]{Manifest.permission.CALL_PHONE}, REQUEST_CODE_CALL);
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -208,6 +208,7 @@ public class HomeFragment extends BaseMvvmFragment<HomeViewModel, FragmentHomeBi
|
||||
ApkUtils.openPackage(mContext, "com.ss.android.ugc.aweme");
|
||||
} else {
|
||||
Toaster.show("抖音未安装,请安装后使用");
|
||||
openAppStore("com.ss.android.ugc.aweme");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.ttstd.dialer.view;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.ttstd.dialer.utils.ScreenUtils;
|
||||
|
||||
public class EqualHeightDecoration extends RecyclerView.ItemDecoration {
|
||||
private int rowCount;
|
||||
|
||||
public EqualHeightDecoration(int rowCount) {
|
||||
this.rowCount = rowCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
|
||||
int recyclerViewHeight = parent.getHeight();
|
||||
int height = recyclerViewHeight - 6 * ScreenUtils.dp2px(view.getResources(), 4);
|
||||
int itemHeight = recyclerViewHeight / rowCount;
|
||||
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||
params.height = itemHeight;
|
||||
view.setLayoutParams(params);
|
||||
}
|
||||
}
|
||||
|
||||
21
app/src/main/res/drawable/bg_permissions.xml
Normal file
21
app/src/main/res/drawable/bg_permissions.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<!-- 填充的颜色:这里设置背景透明 -->
|
||||
<solid android:color="#FFFFFF" />
|
||||
<!-- 边框的颜色 :不能和窗口背景色一样 -->
|
||||
|
||||
<!-- 设置按钮的四个角为弧形 -->
|
||||
<!-- android:radius 弧形的半径 -->
|
||||
<corners android:radius="@dimen/default_radius" />
|
||||
|
||||
|
||||
<!-- padding:Button里面的文字与Button边界的间隔 -->
|
||||
<!-- <padding-->
|
||||
<!-- android:bottom="10dp"-->
|
||||
<!-- android:left="10dp"-->
|
||||
<!-- android:right="10dp"-->
|
||||
<!-- android:top="10dp" />-->
|
||||
|
||||
</shape>
|
||||
14
app/src/main/res/drawable/wechat_call_audio.xml
Normal file
14
app/src/main/res/drawable/wechat_call_audio.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<!-- 圆角的幅度 -->
|
||||
<corners android:radius="@dimen/default_radius" />
|
||||
|
||||
<solid android:color="#3F51B5" />
|
||||
|
||||
<!-- <gradient-->
|
||||
<!-- android:angle="270"-->
|
||||
<!-- android:endColor="#E6581DA8"-->
|
||||
<!-- android:startColor="#E62E1B84"-->
|
||||
<!-- android:type="linear" />-->
|
||||
</shape>
|
||||
14
app/src/main/res/drawable/wechat_call_cancel.xml
Normal file
14
app/src/main/res/drawable/wechat_call_cancel.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<!-- 圆角的幅度 -->
|
||||
<corners android:radius="@dimen/default_radius" />
|
||||
|
||||
<solid android:color="#F44336" />
|
||||
|
||||
<!-- <gradient-->
|
||||
<!-- android:angle="270"-->
|
||||
<!-- android:endColor="#E6C9D6FF"-->
|
||||
<!-- android:startColor="#E6E1E2E3"-->
|
||||
<!-- android:type="linear" />-->
|
||||
</shape>
|
||||
14
app/src/main/res/drawable/wechat_call_dialer.xml
Normal file
14
app/src/main/res/drawable/wechat_call_dialer.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<!-- 圆角的幅度 -->
|
||||
<corners android:radius="@dimen/default_radius" />
|
||||
|
||||
<solid android:color="#2196F3" />
|
||||
|
||||
<!-- <gradient-->
|
||||
<!-- android:angle="270"-->
|
||||
<!-- android:endColor="#E6FEB37A"-->
|
||||
<!-- android:startColor="#E6FF805F"-->
|
||||
<!-- android:type="linear" />-->
|
||||
</shape>
|
||||
14
app/src/main/res/drawable/wechat_call_video.xml
Normal file
14
app/src/main/res/drawable/wechat_call_video.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<!-- 圆角的幅度 -->
|
||||
<corners android:radius="@dimen/default_radius" />
|
||||
|
||||
<solid android:color="#17D26B" />
|
||||
|
||||
<!-- <gradient-->
|
||||
<!-- android:angle="270"-->
|
||||
<!-- android:endColor="#E6418B24"-->
|
||||
<!-- android:startColor="#E612CA56"-->
|
||||
<!-- android:type="linear" />-->
|
||||
</shape>
|
||||
@@ -98,7 +98,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:onClick="@{click::save}"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginBottom="32dp"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true"
|
||||
|
||||
104
app/src/main/res/layout/dialog_fragment_permissions.xml
Normal file
104
app/src/main/res/layout/dialog_fragment_permissions.xml
Normal file
@@ -0,0 +1,104 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context=".fragment.dialog.permission.PermissionDialogFragment">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="click"
|
||||
type="com.ttstd.dialer.fragment.dialog.permission.PermissionDialogFragment.BtnClick" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_permissions"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="权限申请说明"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="32dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/linearLayout5"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_title">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="18sp"
|
||||
tools:text="内容文本" />
|
||||
</ScrollView>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout5"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintBottom_toBottomOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_denied"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true"
|
||||
android:onClick="@{click::onDenied}"
|
||||
android:text="拒绝"
|
||||
android:textColor="@color/red"
|
||||
android:textSize="19sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_granted"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:onClick="@{click::onGranted}"
|
||||
android:singleLine="true"
|
||||
android:text="同意"
|
||||
android:textColor="@color/dodgerBlue"
|
||||
android:textSize="19sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@+id/tv_content"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_content" />
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
203
app/src/main/res/layout/fragment_call.xml
Normal file
203
app/src/main/res/layout/fragment_call.xml
Normal file
@@ -0,0 +1,203 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context=".fragment.dialog.call.CallFragment">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="click"
|
||||
type="com.ttstd.dialer.fragment.dialog.call.CallFragment.BtnClick" />
|
||||
|
||||
<import type="android.view.View" />
|
||||
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="220dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_marginEnd="32dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_video"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/wechat_call_video"
|
||||
android:onClick="@{click::callWechatVideo}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:shadowColor="#80000000"
|
||||
android:shadowDx="2"
|
||||
android:shadowDy="2"
|
||||
android:shadowRadius="2"
|
||||
android:singleLine="true"
|
||||
android:text="微信视频"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_audio"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="@drawable/wechat_call_audio"
|
||||
android:onClick="@{click::callWechatAudio}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:shadowColor="#80000000"
|
||||
android:shadowDx="2"
|
||||
android:shadowDy="2"
|
||||
android:shadowRadius="2"
|
||||
android:singleLine="true"
|
||||
android:text="微信语音"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_dial"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="@drawable/wechat_call_dialer"
|
||||
android:onClick="@{click::callPhone}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:shadowColor="#80000000"
|
||||
android:shadowDx="2"
|
||||
android:shadowDy="2"
|
||||
android:shadowRadius="2"
|
||||
android:singleLine="true"
|
||||
android:text="电话"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_sms"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="@drawable/wechat_call_cancel"
|
||||
android:onClick="@{click::cancel}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:shadowColor="#80000000"
|
||||
android:shadowDx="2"
|
||||
android:shadowDy="2"
|
||||
android:shadowRadius="2"
|
||||
android:singleLine="true"
|
||||
android:text="取消"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
@@ -5,6 +5,7 @@
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="100dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
@@ -19,6 +20,7 @@
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/ic_default_avatar"
|
||||
app:corner_radius="@dimen/default_radius"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
69
app/src/main/res/layout/item_contact_home.xml
Normal file
69
app/src/main/res/layout/item_contact_home.xml
Normal file
@@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<com.shehuan.niv.NiceImageView
|
||||
android:id="@+id/nv_avatar"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/ic_default_avatar"
|
||||
app:corner_radius="@dimen/default_radius"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.159" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/nv_avatar"
|
||||
app:layout_constraintVertical_bias="0.5">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true"
|
||||
android:text="姓名"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_phone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="8dp"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true"
|
||||
android:text="姓名"
|
||||
android:textColor="@color/gray"
|
||||
android:textSize="13sp"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="home_item_text_size">20sp</dimen>
|
||||
<dimen name="default_radius">8dp</dimen>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user