version:5.8
fix: update:优化拨打电话页面
This commit is contained in:
@@ -13,6 +13,7 @@ import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.hjq.toast.Toaster;
|
||||
@@ -54,6 +55,8 @@ public class AddContactActivity extends BaseDataBindingActivity {
|
||||
ImageView iv_cancel;
|
||||
@BindView(R.id.iv_confirm)
|
||||
ImageView iv_confirm;
|
||||
@BindView(R.id.cl_confirm)
|
||||
ConstraintLayout cl_confirm;
|
||||
@BindView(R.id.nv_avatar)
|
||||
NiceImageView nv_avatar;
|
||||
@BindView(R.id.et_name)
|
||||
@@ -67,11 +70,6 @@ public class AddContactActivity extends BaseDataBindingActivity {
|
||||
private String avatarFilePath;
|
||||
private boolean urgent = false;
|
||||
|
||||
@Override
|
||||
public boolean setNightMode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDataBinding() {
|
||||
DataBindingUtil.setContentView(this, R.layout.activity_add_contact);
|
||||
@@ -102,7 +100,7 @@ public class AddContactActivity extends BaseDataBindingActivity {
|
||||
checkContact();
|
||||
}
|
||||
});
|
||||
iv_confirm.setOnClickListener(new View.OnClickListener() {
|
||||
cl_confirm.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
checkContact();
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.uiuios.aios.activity.contact;
|
||||
|
||||
import com.uiuios.aios.base.mvvm.BaseViewModel;
|
||||
|
||||
public class AddContactViewModel extends BaseViewModel {
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -19,13 +19,14 @@ import java.util.List;
|
||||
public class PhoneActivity extends BaseMvvmActivity<PhoneViewModel, ActivityPhoneBinding> {
|
||||
private static final String TAG = PhoneActivity.class.getSimpleName();
|
||||
|
||||
private String[] title = new String[]{"通话", "记录", "联系人"};
|
||||
|
||||
private FragmentManager mFragmentManager;
|
||||
private CustomPagerAdapter mCustomPagerAdapter;
|
||||
private List<Fragment> mFragments;
|
||||
private ContactFragment mContactFragment;
|
||||
private DialerFragment mDialerFragment;
|
||||
private RecordFragment mRecordFragment;
|
||||
private ContactFragment mContactFragment;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@@ -44,20 +45,25 @@ public class PhoneActivity extends BaseMvvmActivity<PhoneViewModel, ActivityPhon
|
||||
protected void initView() {
|
||||
mFragmentManager = getSupportFragmentManager();
|
||||
mFragments = new ArrayList<>();
|
||||
if (mContactFragment == null) {
|
||||
mContactFragment = new ContactFragment();
|
||||
}
|
||||
mFragments.add(mContactFragment);
|
||||
|
||||
if (mDialerFragment == null) {
|
||||
mDialerFragment = new DialerFragment();
|
||||
}
|
||||
mFragments.add(mDialerFragment);
|
||||
|
||||
if (mRecordFragment == null) {
|
||||
mRecordFragment = new RecordFragment();
|
||||
}
|
||||
mFragments.add(mRecordFragment);
|
||||
|
||||
if (mContactFragment == null) {
|
||||
mContactFragment = new ContactFragment();
|
||||
}
|
||||
mFragments.add(mContactFragment);
|
||||
|
||||
mCustomPagerAdapter = new CustomPagerAdapter(mFragmentManager, mFragments, getLifecycle());
|
||||
mViewDataBinding.viewPager.setAdapter(mCustomPagerAdapter);
|
||||
mViewDataBinding.slidingTabLayout.setViewPager(mViewDataBinding.viewPager, title);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,6 +84,7 @@ public class PhoneActivity extends BaseMvvmActivity<PhoneViewModel, ActivityPhon
|
||||
public void call(View view) {
|
||||
mViewDataBinding.viewPager.setCurrentItem(1, true);
|
||||
}
|
||||
|
||||
public void toRecord(View view) {
|
||||
mViewDataBinding.viewPager.setCurrentItem(2, true);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.provider.CallLog;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -26,6 +27,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CallRecordAdapter extends RecyclerView.Adapter<CallRecordAdapter.Holder> {
|
||||
private static final String TAG = CallRecordAdapter.class.getSimpleName();
|
||||
|
||||
|
||||
private Context mContext;
|
||||
private List<RecordsInfo> mRecordsInfoList;
|
||||
@@ -82,10 +85,15 @@ public class CallRecordAdapter extends RecyclerView.Adapter<CallRecordAdapter.Ho
|
||||
holder.iv_remove.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String queryString = "NUMBER=" + recordsInfo.getNumber();
|
||||
mContext.getContentResolver().delete(CallLog.Calls.CONTENT_URI, queryString, null);
|
||||
mRecordsInfoList.remove(position);
|
||||
notifyDataSetChanged();
|
||||
String queryString = "number=" + recordsInfo.getNumber();
|
||||
try {
|
||||
mContext.getContentResolver().delete(CallLog.Calls.CONTENT_URI, queryString, null);
|
||||
mRecordsInfoList.remove(position);
|
||||
notifyDataSetChanged();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "onClick: " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -110,7 +110,20 @@ public class ControlFragment extends BaseMvvmFragment<ControlViewModel, PhoneFra
|
||||
@Override
|
||||
public void fetchData() {
|
||||
Log.e(TAG, "fetchData: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
Log.e(TAG, "onResume: ");
|
||||
super.onResume();
|
||||
registerReceivers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
Log.e(TAG, "onPause: ");
|
||||
super.onPause();
|
||||
unRegisterReceivers();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -145,11 +158,8 @@ public class ControlFragment extends BaseMvvmFragment<ControlViewModel, PhoneFra
|
||||
|
||||
private void initView() {
|
||||
getWifi();
|
||||
registerReceivers();
|
||||
getBluetooth();
|
||||
registerBluetoothReceiver();
|
||||
getBattery();
|
||||
registerBatteryReceiver();
|
||||
getFlashlight();
|
||||
getFontSize();
|
||||
getLocation();
|
||||
@@ -234,6 +244,23 @@ public class ControlFragment extends BaseMvvmFragment<ControlViewModel, PhoneFra
|
||||
|
||||
private void registerReceivers() {
|
||||
registerWiFiReceiver();
|
||||
registerBluetoothReceiver();
|
||||
registerBatteryReceiver();
|
||||
}
|
||||
|
||||
private void unRegisterReceivers() {
|
||||
if (mWifiReceiver != null) {
|
||||
mContext.unregisterReceiver(mWifiReceiver);
|
||||
mWifiReceiver = null;
|
||||
}
|
||||
if (mTimeUpdateReceiver != null) {
|
||||
mContext.unregisterReceiver(mTimeUpdateReceiver);
|
||||
mTimeUpdateReceiver = null;
|
||||
}
|
||||
if (mBatteryReceiver != null) {
|
||||
mContext.unregisterReceiver(mBatteryReceiver);
|
||||
mBatteryReceiver = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void registerWiFiReceiver() {
|
||||
@@ -892,8 +919,6 @@ public class ControlFragment extends BaseMvvmFragment<ControlViewModel, PhoneFra
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mWifiReceiver != null) mContext.unregisterReceiver(mWifiReceiver);
|
||||
if (mTimeUpdateReceiver != null) mContext.unregisterReceiver(mTimeUpdateReceiver);
|
||||
mContext.getContentResolver().unregisterContentObserver(mBrightnessObserver);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.uiuios.aios.fragment.phone.contact;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
@@ -11,7 +10,7 @@ import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.activity.contact.AddContactActivity;
|
||||
@@ -52,26 +51,23 @@ public class ContactFragment extends BaseMvvmFragment<ContactViewModel, Fragment
|
||||
protected void initDataBinding() {
|
||||
mContext = getActivity();
|
||||
mViewModel.setCtx(mContext);
|
||||
mViewModel.setVDBinding(mViewDataBinding);
|
||||
mViewModel.setLifecycle(getLifecycleSubject());
|
||||
mViewModel.setVDBinding(mViewDataBinding);
|
||||
mViewDataBinding.setClick(new BtnClick());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView(Bundle bundle) {
|
||||
mContactAdapter = new ContactAdapter();
|
||||
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
mViewDataBinding.rvContact.setLayoutManager(new GridLayoutManager(mContext, 3));
|
||||
} else {
|
||||
mViewDataBinding.rvContact.setLayoutManager(new GridLayoutManager(mContext, 2));
|
||||
}
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
|
||||
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
|
||||
mViewDataBinding.rvContact.setLayoutManager(linearLayoutManager);
|
||||
// if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
// mViewDataBinding.rvContact.setLayoutManager(new GridLayoutManager(mContext, 3));
|
||||
// } else {
|
||||
// mViewDataBinding.rvContact.setLayoutManager(new GridLayoutManager(mContext, 2));
|
||||
// }
|
||||
mViewDataBinding.rvContact.setAdapter(mContactAdapter);
|
||||
mViewDataBinding.tvAdd.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(mContext, AddContactActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
mViewModel.getContactListData().observe(this, new Observer<List<Contact>>() {
|
||||
@Override
|
||||
public void onChanged(List<Contact> contacts) {
|
||||
@@ -95,6 +91,13 @@ public class ContactFragment extends BaseMvvmFragment<ContactViewModel, Fragment
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
Log.e(TAG, "onResume: ");
|
||||
mViewModel.getContact();
|
||||
}
|
||||
|
||||
public static final String NAME = "name";
|
||||
public static final String NUMBER = "number";
|
||||
|
||||
@@ -119,4 +122,12 @@ public class ContactFragment extends BaseMvvmFragment<ContactViewModel, Fragment
|
||||
}
|
||||
return contactList;
|
||||
}
|
||||
|
||||
|
||||
public class BtnClick {
|
||||
public void add(View view) {
|
||||
Intent intent = new Intent(mContext, AddContactActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,12 @@ import android.view.View;
|
||||
import com.hjq.toast.Toaster;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.activity.SelectNumberActivity;
|
||||
import com.uiuios.aios.activity.contact.AddContactActivity;
|
||||
import com.uiuios.aios.activity.contact.ContactActivity;
|
||||
import com.uiuios.aios.activity.records.RecordsActivity;
|
||||
import com.uiuios.aios.base.mvvm.fragment.BaseMvvmFragment;
|
||||
import com.uiuios.aios.databinding.FragmentDialerBinding;
|
||||
import com.uiuios.aios.databinding.FragmentDialerNewBinding;
|
||||
import com.uiuios.aios.utils.Utils;
|
||||
|
||||
/**
|
||||
@@ -22,7 +24,7 @@ import com.uiuios.aios.utils.Utils;
|
||||
* Use the {@link DialerFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class DialerFragment extends BaseMvvmFragment<DialerViewModel, FragmentDialerBinding> {
|
||||
public class DialerFragment extends BaseMvvmFragment<DialerViewModel, FragmentDialerNewBinding> {
|
||||
private static final String TAG = DialerFragment.class.getSimpleName();
|
||||
|
||||
private Context mContext;
|
||||
@@ -39,7 +41,7 @@ public class DialerFragment extends BaseMvvmFragment<DialerViewModel, FragmentDi
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_dialer;
|
||||
return R.layout.fragment_dialer_new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -171,6 +173,11 @@ public class DialerFragment extends BaseMvvmFragment<DialerViewModel, FragmentDi
|
||||
Intent intent = new Intent(mContext, RecordsActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
public void add(View view) {
|
||||
Intent intent = new Intent(mContext, AddContactActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@ package com.uiuios.aios.fragment.phone.dialer;
|
||||
|
||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||
import com.uiuios.aios.base.mvvm.BaseViewModel;
|
||||
import com.uiuios.aios.databinding.FragmentDialerBinding;
|
||||
import com.uiuios.aios.databinding.FragmentDialerNewBinding;
|
||||
|
||||
public class DialerViewModel extends BaseViewModel<FragmentDialerBinding, FragmentEvent> {
|
||||
public class DialerViewModel extends BaseViewModel<FragmentDialerNewBinding, FragmentEvent> {
|
||||
@Override
|
||||
public FragmentDialerBinding getVDBinding() {
|
||||
public FragmentDialerNewBinding getVDBinding() {
|
||||
return binding;
|
||||
}
|
||||
|
||||
@@ -16,5 +16,4 @@ public class DialerViewModel extends BaseViewModel<FragmentDialerBinding, Fragme
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -154,9 +154,13 @@ public class RecordFragment extends BaseMvvmFragment<RecordViewModel, FragmentRe
|
||||
.setOnClickBottomListener(new DeleteDialog.OnClickBottomListener() {
|
||||
@Override
|
||||
public void onPositiveClick() {
|
||||
for (RecordsInfo recordsInfo : dataList) {
|
||||
String queryString = "NUMBER=" + recordsInfo.getNumber();
|
||||
mContext.getContentResolver().delete(CallLog.Calls.CONTENT_URI, queryString, null);
|
||||
try {
|
||||
for (RecordsInfo recordsInfo : dataList) {
|
||||
String queryString = "number=" + recordsInfo.getNumber();
|
||||
mContext.getContentResolver().delete(CallLog.Calls.CONTENT_URI, queryString, null);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "onPositiveClick: " + e.getMessage());
|
||||
}
|
||||
mViewModel.getRecordsInfoList();
|
||||
dialog.dismiss();
|
||||
|
||||
Reference in New Issue
Block a user