|
@@ -9,6 +9,7 @@ import android.content.Context;
|
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
|
import android.content.pm.PackageInfo;
|
|
import android.content.pm.PackageInfo;
|
|
|
import android.content.pm.PackageManager;
|
|
import android.content.pm.PackageManager;
|
|
|
|
|
+import android.graphics.drawable.BitmapDrawable;
|
|
|
import android.net.ConnectivityManager;
|
|
import android.net.ConnectivityManager;
|
|
|
import android.net.NetworkInfo;
|
|
import android.net.NetworkInfo;
|
|
|
import android.net.Uri;
|
|
import android.net.Uri;
|
|
@@ -338,59 +339,40 @@ public class SystemUtil {
|
|
|
ToastUtil.showToast(mContext, R.string.phone_number_format_error);
|
|
ToastUtil.showToast(mContext, R.string.phone_number_format_error);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- final PopupWindow window = new PopupWindow(mContext);
|
|
|
|
|
- View view = LayoutInflater.from(mContext).inflate(R.layout.item_select_alert_pop, null);
|
|
|
|
|
- window.setContentView(view);
|
|
|
|
|
- window.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.pop_round_bg));
|
|
|
|
|
- DisplayUtil.backgroundAlpha(mContext, 0.4f);
|
|
|
|
|
- window.setTouchable(true);
|
|
|
|
|
- setPopupWindowHW((Activity) mContext, window);
|
|
|
|
|
- window.setOutsideTouchable(false);
|
|
|
|
|
- window.setFocusable(true);
|
|
|
|
|
- TextView title_tv = (TextView) view.findViewById(R.id.title_tv);
|
|
|
|
|
- TextView message_tv = (TextView) view.findViewById(R.id.message_tv);
|
|
|
|
|
- TextView sure_tv = (TextView) view.findViewById(R.id.sure_tv);
|
|
|
|
|
- title_tv.setText(mContext.getString(R.string.dialog_confim_phone));
|
|
|
|
|
- message_tv.setText(mContext.getString(R.string.dialog_phone) + phone);
|
|
|
|
|
- sure_tv.setText(R.string.dialog_phone_action);
|
|
|
|
|
-
|
|
|
|
|
- window.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onDismiss() {
|
|
|
|
|
- DisplayUtil.backgroundAlpha(mContext, 1f);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- view.findViewById(R.id.goto_tv).setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onClick(View v) {
|
|
|
|
|
- window.dismiss();
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- sure_tv.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onClick(View v) {
|
|
|
|
|
- mContext.requestPermission(Manifest.permission.CALL_PHONE, new Runnable() {
|
|
|
|
|
|
|
+ MaterialDialog dialog = new MaterialDialog.Builder(mContext).title(R.string.dialog_confim_phone).content(mContext.getString(R.string.dialog_phone) + phone)
|
|
|
|
|
+ .positiveText(R.string.dialog_phone_action).negativeText(R.string.common_cancel).autoDismiss(false).callback(new MaterialDialog.ButtonCallback() {
|
|
|
@Override
|
|
@Override
|
|
|
- public void run() {
|
|
|
|
|
- // 用intent启动拨打电话
|
|
|
|
|
- Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phone));
|
|
|
|
|
- if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
|
|
|
|
|
- //预防万一
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- mContext.startActivity(intent);
|
|
|
|
|
|
|
+ public void onPositive(MaterialDialog dialog) {
|
|
|
|
|
+ mContext.requestPermission(Manifest.permission.CALL_PHONE, new Runnable() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void run() {
|
|
|
|
|
+ // 用intent启动拨打电话
|
|
|
|
|
+ Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phone));
|
|
|
|
|
+ if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
|
|
|
|
|
+ //预防万一
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ mContext.startActivity(intent);
|
|
|
|
|
+ }
|
|
|
|
|
+ }, new Runnable() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void run() {
|
|
|
|
|
+ ToastUtil.showToast(mContext, R.string.not_system_permission);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ dialog.dismiss();
|
|
|
}
|
|
}
|
|
|
- }, new Runnable() {
|
|
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
- public void run() {
|
|
|
|
|
- ToastUtil.showToast(mContext, R.string.not_system_permission);
|
|
|
|
|
|
|
+ public void onNegative(MaterialDialog dialog) {
|
|
|
|
|
+ super.onNegative(dialog);
|
|
|
|
|
+ dialog.dismiss();
|
|
|
}
|
|
}
|
|
|
- });
|
|
|
|
|
- window.dismiss();
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- window.showAtLocation(view, Gravity.CENTER, 0, 0);
|
|
|
|
|
|
|
+ }).build();
|
|
|
|
|
+
|
|
|
|
|
+ dialog.show();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Deprecated
|
|
@Deprecated
|
|
@@ -403,8 +385,8 @@ public class SystemUtil {
|
|
|
final PopupWindow window = new PopupWindow(mContext);
|
|
final PopupWindow window = new PopupWindow(mContext);
|
|
|
View view = LayoutInflater.from(mContext).inflate(R.layout.item_select_alert_pop, null);
|
|
View view = LayoutInflater.from(mContext).inflate(R.layout.item_select_alert_pop, null);
|
|
|
window.setContentView(view);
|
|
window.setContentView(view);
|
|
|
- window.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.pop_round_bg));
|
|
|
|
|
- DisplayUtil.backgroundAlpha(mContext, 0.4f);
|
|
|
|
|
|
|
+ window.setBackgroundDrawable(new BitmapDrawable());
|
|
|
|
|
+ DisplayUtil.backgroundAlpha(mContext, 0.5f);
|
|
|
window.setTouchable(true);
|
|
window.setTouchable(true);
|
|
|
setPopupWindowHW((Activity) mContext, window);
|
|
setPopupWindowHW((Activity) mContext, window);
|
|
|
window.setOutsideTouchable(false);
|
|
window.setOutsideTouchable(false);
|
|
@@ -446,6 +428,8 @@ public class SystemUtil {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
public static void setPopupWindowHW(Activity ct, PopupWindow window) {
|
|
public static void setPopupWindowHW(Activity ct, PopupWindow window) {
|
|
|
window.getContentView().measure(0, 0);
|
|
window.getContentView().measure(0, 0);
|