|
@@ -5,12 +5,18 @@ import android.graphics.Bitmap;
|
|
import android.graphics.BitmapFactory;
|
|
import android.graphics.BitmapFactory;
|
|
import android.net.ConnectivityManager;
|
|
import android.net.ConnectivityManager;
|
|
import android.net.NetworkInfo;
|
|
import android.net.NetworkInfo;
|
|
|
|
+import android.util.Log;
|
|
import android.widget.ImageView;
|
|
import android.widget.ImageView;
|
|
|
|
|
|
|
|
+import com.android.i18n.phonenumbers.PhoneNumberUtil;
|
|
|
|
+import com.android.i18n.phonenumbers.Phonenumber;
|
|
|
|
+import com.android.internal.telephony.ITelephony;
|
|
|
|
+
|
|
import java.io.FileInputStream;
|
|
import java.io.FileInputStream;
|
|
import java.io.FileNotFoundException;
|
|
import java.io.FileNotFoundException;
|
|
|
|
|
|
public class ToolsUtils {
|
|
public class ToolsUtils {
|
|
|
|
+ public static String TAG = "losion / skcontact :" + "ToolsUtils";
|
|
|
|
|
|
public static int dip2px(Context context, float dpValue) {
|
|
public static int dip2px(Context context, float dpValue) {
|
|
float scale = context.getResources().getDisplayMetrics().density;
|
|
float scale = context.getResources().getDisplayMetrics().density;
|
|
@@ -59,4 +65,61 @@ public class ToolsUtils {
|
|
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
|
|
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
|
|
return networkInfo != null && networkInfo.isAvailable();
|
|
return networkInfo != null && networkInfo.isAvailable();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public static String phoneNumberSubString(String content, int endCount) {
|
|
|
|
+ if (content.length() < endCount)
|
|
|
|
+ return content;
|
|
|
|
+ return content.substring(content.length() - endCount);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static boolean isUrgencyNumber(String value) {
|
|
|
|
+ String[] urgencyNumbers = android.os.SystemProperties.get("ril.ecclist").split(",");
|
|
|
|
+ for (String v : urgencyNumbers) {
|
|
|
|
+ if (v.equals(value))
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static String getCallNumber(String countryCode, String number) {
|
|
|
|
+ if (Macros.DEBUG) {
|
|
|
|
+ return countryCode + number;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ countryCode = countryCode.replace("+", "");
|
|
|
|
+ number = number.replace("+", "");
|
|
|
|
+
|
|
|
|
+ String national = number;
|
|
|
|
+ String extension = "";
|
|
|
|
+ if (number.contains(",")) {
|
|
|
|
+ int index = number.indexOf(",");
|
|
|
|
+ national = number.substring(0,index);
|
|
|
|
+ extension = number.substring(index+1);
|
|
|
|
+ }
|
|
|
|
+ if (number.contains(";")) {
|
|
|
|
+ int index = number.indexOf(";");
|
|
|
|
+ national = number.substring(0,index);
|
|
|
|
+ extension = number.substring(index+1);
|
|
|
|
+ }
|
|
|
|
+ Log.d(TAG, "getCallNumber: national:" + national + " extension:" + extension);
|
|
|
|
+
|
|
|
|
+ Phonenumber.PhoneNumber phoneNumber = new Phonenumber.PhoneNumber();
|
|
|
|
+ if (!national.equals("")) {
|
|
|
|
+ //TODO:需要屏蔽下非法字符
|
|
|
|
+ phoneNumber.setNationalNumber(Long.parseLong(national));
|
|
|
|
+ if (extension.length() > 0) {
|
|
|
|
+ phoneNumber.setExtension(extension);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!countryCode.equals("")) {
|
|
|
|
+ phoneNumber.setCountryCode(Integer.parseInt(countryCode));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance();
|
|
|
|
+ String ret = phoneNumberUtil.format(phoneNumber, PhoneNumberUtil.PhoneNumberFormat.E164);
|
|
|
|
+ if (extension.length() > 0) {
|
|
|
|
+ ret = ret + "," + extension;
|
|
|
|
+ }
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
}
|
|
}
|