|
@@ -1,4 +1,4 @@
|
|
|
-package com.ntels.product.chatbot.util
|
|
|
|
|
|
|
+package com.hanwha.morakmorak.util
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint
|
|
import android.annotation.SuppressLint
|
|
|
import android.annotation.TargetApi
|
|
import android.annotation.TargetApi
|
|
@@ -7,7 +7,7 @@ import android.os.Build
|
|
|
import android.provider.Settings.Secure
|
|
import android.provider.Settings.Secure
|
|
|
import android.telephony.TelephonyManager
|
|
import android.telephony.TelephonyManager
|
|
|
import android.text.format.DateFormat
|
|
import android.text.format.DateFormat
|
|
|
-import com.ntels.product.chatbot.data.DataManager
|
|
|
|
|
|
|
+//import com.ntels.product.chatbot.data.DataManager
|
|
|
import timber.log.Timber
|
|
import timber.log.Timber
|
|
|
import java.io.BufferedReader
|
|
import java.io.BufferedReader
|
|
|
import java.io.IOException
|
|
import java.io.IOException
|
|
@@ -69,11 +69,11 @@ class CommonUtils {
|
|
|
|
|
|
|
|
@JvmStatic fun readTermsFromAssets(context: Context): String? {
|
|
@JvmStatic fun readTermsFromAssets(context: Context): String? {
|
|
|
var tempStr = ""
|
|
var tempStr = ""
|
|
|
- var inputStreamReader: InputStreamReader? = InputStreamReader(context.assets.open("terms.txt"))
|
|
|
|
|
- var reader: BufferedReader? = BufferedReader(inputStreamReader)
|
|
|
|
|
|
|
+ val inputStreamReader: InputStreamReader? = InputStreamReader(context.assets.open("terms.txt"))
|
|
|
|
|
+ val reader: BufferedReader? = BufferedReader(inputStreamReader)
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- var line: String? = null
|
|
|
|
|
|
|
+ var line: String?
|
|
|
while (!reader!!.readLine().also { line = it }.isNullOrEmpty()) tempStr += "$line\n"
|
|
while (!reader!!.readLine().also { line = it }.isNullOrEmpty()) tempStr += "$line\n"
|
|
|
reader.close()
|
|
reader.close()
|
|
|
inputStreamReader?.close()
|
|
inputStreamReader?.close()
|
|
@@ -96,7 +96,7 @@ class CommonUtils {
|
|
|
|
|
|
|
|
return when {
|
|
return when {
|
|
|
id.isNullOrEmpty() -> 1
|
|
id.isNullOrEmpty() -> 1
|
|
|
- id!!.length < 6 -> 2
|
|
|
|
|
|
|
+ id.length < 6 -> 2
|
|
|
id.contains(" ") -> 3
|
|
id.contains(" ") -> 3
|
|
|
(!matcher.matches() || englishMatcher.matches() || numberMatcher.matches()) -> 4
|
|
(!matcher.matches() || englishMatcher.matches() || numberMatcher.matches()) -> 4
|
|
|
(!checkContinueChar(id)) -> 6
|
|
(!checkContinueChar(id)) -> 6
|
|
@@ -204,32 +204,32 @@ class CommonUtils {
|
|
|
*/
|
|
*/
|
|
|
@JvmStatic fun delSpecialChar(str: String) = str.replace("[^\uAC00-\uD7A3xfe0-9a-zA-Z\\s]".toRegex(), "")
|
|
@JvmStatic fun delSpecialChar(str: String) = str.replace("[^\uAC00-\uD7A3xfe0-9a-zA-Z\\s]".toRegex(), "")
|
|
|
|
|
|
|
|
- @JvmStatic fun getDeviceUUID(context: Context, dataManager: DataManager): String {
|
|
|
|
|
- val id = dataManager.deviceId
|
|
|
|
|
-
|
|
|
|
|
- var uuid: UUID? = null
|
|
|
|
|
- if (id.isNotEmpty()) {
|
|
|
|
|
- uuid = UUID.fromString(id)
|
|
|
|
|
- } else {
|
|
|
|
|
- val androidId = Secure.getString(context.contentResolver, Secure.ANDROID_ID)
|
|
|
|
|
- try {
|
|
|
|
|
- uuid = if ("9774d56d682e549c" != androidId) {
|
|
|
|
|
- UUID.nameUUIDFromBytes(androidId.toByteArray(Charset.forName("utf-8")))
|
|
|
|
|
- } else {
|
|
|
|
|
- val deviceId = (context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager).deviceId
|
|
|
|
|
- if (deviceId != null) UUID.nameUUIDFromBytes(deviceId.toByteArray(Charset.forName("utf-8"))) else UUID.randomUUID()
|
|
|
|
|
- }
|
|
|
|
|
- } catch (e: UnsupportedEncodingException) {
|
|
|
|
|
- throw RuntimeException(e)
|
|
|
|
|
- } catch (e: SecurityException) {
|
|
|
|
|
- throw RuntimeException(e)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- dataManager.deviceId = uuid.toString()
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return uuid.toString()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// @JvmStatic fun getDeviceUUID(context: Context, dataManager: DataManager): String {
|
|
|
|
|
+// val id = dataManager.deviceId
|
|
|
|
|
+//
|
|
|
|
|
+// var uuid: UUID? = null
|
|
|
|
|
+// if (id.isNotEmpty()) {
|
|
|
|
|
+// uuid = UUID.fromString(id)
|
|
|
|
|
+// } else {
|
|
|
|
|
+// val androidId = Secure.getString(context.contentResolver, Secure.ANDROID_ID)
|
|
|
|
|
+// try {
|
|
|
|
|
+// uuid = if ("9774d56d682e549c" != androidId) {
|
|
|
|
|
+// UUID.nameUUIDFromBytes(androidId.toByteArray(Charset.forName("utf-8")))
|
|
|
|
|
+// } else {
|
|
|
|
|
+// val deviceId = (context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager).deviceId
|
|
|
|
|
+// if (deviceId != null) UUID.nameUUIDFromBytes(deviceId.toByteArray(Charset.forName("utf-8"))) else UUID.randomUUID()
|
|
|
|
|
+// }
|
|
|
|
|
+// } catch (e: UnsupportedEncodingException) {
|
|
|
|
|
+// throw RuntimeException(e)
|
|
|
|
|
+// } catch (e: SecurityException) {
|
|
|
|
|
+// throw RuntimeException(e)
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// dataManager.deviceId = uuid.toString()
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// return uuid.toString()
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
// @JvmStatic fun unixTimeToDate(unixTime: Long): String {
|
|
// @JvmStatic fun unixTimeToDate(unixTime: Long): String {
|
|
|
// val date = Date(unixTime * 1000L)
|
|
// val date = Date(unixTime * 1000L)
|