From 87cd5df70918e6ba1af849c5f026d3719bfdb1ac Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期三, 09 四月 2025 09:06:29 +0800
Subject: [PATCH] Merge branch '1.5.2' into dev

---
 countrypicker/src/main/java/com/sahooz/library/countrypicker/Country.java |   45 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/countrypicker/src/main/java/com/sahooz/library/countrypicker/Country.java b/countrypicker/src/main/java/com/sahooz/library/countrypicker/Country.java
index cd57984..629266a 100644
--- a/countrypicker/src/main/java/com/sahooz/library/countrypicker/Country.java
+++ b/countrypicker/src/main/java/com/sahooz/library/countrypicker/Country.java
@@ -1,9 +1,16 @@
 package com.sahooz.library.countrypicker;
 
+import android.Manifest;
 import android.content.Context;
 
 import androidx.annotation.NonNull;
+import androidx.core.app.ActivityCompat;
 
+import android.content.pm.PackageManager;
+import android.location.Address;
+import android.location.Geocoder;
+import android.location.Location;
+import android.location.LocationManager;
 import android.text.TextUtils;
 import android.util.Log;
 
@@ -14,9 +21,12 @@
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
+import java.util.List;
 import java.util.Locale;
 
 /**
@@ -128,6 +138,41 @@
         }
 
         Collections.sort(countries, (o1, o2) -> o1.getPinyin().compareTo(o2.getPinyin()));
+
+    }
+
+
+    /**
+     * 鑾峰彇褰撳墠鐨勫浗瀹跺尯鍙凤紙鍩轰簬鐢ㄦ埛璁剧疆鐨勮瑷�鍜屽湴鍖鸿幏鍙栧浗瀹剁爜锛�
+     *
+     * @return Country
+     */
+    public static Country getCountryInfo() {
+        String countryCode = Locale.getDefault().getCountry();
+        for (Country country : countries) {
+            if (country.locale.equals(countryCode)) {
+                return country;
+            }
+        }
+        return null;
+    }
+
+
+    /**
+     * 鑾峰彇褰撳墠鐨勫浗瀹跺尯鍙凤紙鏍规嵁瀹氫綅鑽诲彇鍥藉缂栫爜锛�
+     *
+     * @return Country
+     */
+    public static Country getLocationCountryInfo(String countryCode) {
+        if (TextUtils.isEmpty(countryCode)) {
+            return null;
+        }
+        for (Country country : countries) {
+            if (country.locale.equals(countryCode)) {
+                return country;
+            }
+        }
+        return null;
     }
 
     public static void destroy() {

--
Gitblit v1.8.0