-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b955639
commit 660b0b1
Showing
24 changed files
with
395 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
app/src/main/java/com/maiya/call/phone/adapter/CallerKeyboardAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.maiya.call.phone.adapter | ||
|
||
import android.view.View | ||
import android.widget.TextView | ||
import com.chad.library.adapter.base.BaseQuickAdapter | ||
import com.chad.library.adapter.base.viewholder.BaseViewHolder | ||
import com.maiya.call.R | ||
|
||
/** | ||
* @ClassName: [CallerKeyboardAdapter] | ||
* @Description: | ||
* | ||
* Created by admin at 2020-07-06 | ||
* @Email [email protected] | ||
*/ | ||
class CallerKeyboardAdapter | ||
: BaseQuickAdapter<CallerKeyboardAdapter.CallerKeyboard, CallerKeyboardAdapter.KeyboardHolder>( | ||
R.layout.item_caller_keyboard, mutableListOf<CallerKeyboard>().also { | ||
it.add(CallerKeyboard('1', "")) | ||
it.add(CallerKeyboard('2', "ABC")) | ||
it.add(CallerKeyboard('3', "DEF")) | ||
it.add(CallerKeyboard('4', "GHI")) | ||
it.add(CallerKeyboard('5', "JKL")) | ||
it.add(CallerKeyboard('6', "MNO")) | ||
it.add(CallerKeyboard('7', "PQRS")) | ||
it.add(CallerKeyboard('8', "TUV")) | ||
it.add(CallerKeyboard('9', "WXYZ")) | ||
it.add(CallerKeyboard('*', "")) | ||
it.add(CallerKeyboard('0', "+")) | ||
it.add(CallerKeyboard('#', "")) | ||
} | ||
) { | ||
|
||
override fun convert(helper: KeyboardHolder, item: CallerKeyboard) { | ||
helper.tvDigit.text = item.digit.toString() | ||
helper.tvLetter.text = item.desc | ||
} | ||
|
||
inner class KeyboardHolder(view: View) : BaseViewHolder(view) { | ||
val tvDigit: TextView = view.findViewById(R.id.tv_digit) | ||
val tvLetter: TextView = view.findViewById(R.id.tv_letter) | ||
} | ||
|
||
class CallerKeyboard(val digit: Char, val desc: String) | ||
|
||
} |
8 changes: 6 additions & 2 deletions
8
.../maiya/call/phone/utils/ContactUtils.java → ...ya/call/phone/manager/ContactManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 0 additions & 67 deletions
67
app/src/main/java/com/maiya/call/phone/utils/MobileNumberUtils.java
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
app/src/main/java/com/maiya/call/phone/utils/MobileNumberUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.maiya.call.phone.utils | ||
|
||
import android.content.Context | ||
import com.google.i18n.phonenumbers.NumberParseException | ||
import com.google.i18n.phonenumbers.PhoneNumberToCarrierMapper | ||
import com.google.i18n.phonenumbers.PhoneNumberUtil | ||
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber | ||
import com.google.i18n.phonenumbers.geocoding.PhoneNumberOfflineGeocoder | ||
import java.util.* | ||
|
||
/** | ||
* Author : ymc | ||
* Date : 2020/5/25 14:05 | ||
* Class : MobileNumberUtils | ||
*/ | ||
object MobileNumberUtils { | ||
private val phoneNumberUtil = PhoneNumberUtil.getInstance() | ||
private val carrierMapper = PhoneNumberToCarrierMapper.getInstance() | ||
private val geocoder = PhoneNumberOfflineGeocoder.getInstance() | ||
private const val LANGUAGE = "CN" | ||
|
||
//获取手机号码运营商 | ||
fun getCarrier(context: Context?, phoneNumber: String?, countryCode: Int): String { | ||
var referencePhonenumber: PhoneNumber? = PhoneNumber() | ||
try { | ||
referencePhonenumber = phoneNumberUtil.parse(phoneNumber, LANGUAGE) | ||
} catch (e: NumberParseException) { | ||
e.printStackTrace() | ||
} | ||
//返回结果只有英文,自己转成成中文 | ||
val carrierEn = carrierMapper.getNameForNumber(referencePhonenumber, Locale.ENGLISH) | ||
var carrierZh = "" | ||
return if (countryCode == 86 && Locale.CHINA.country == Locale.getDefault().country) { | ||
when (carrierEn) { | ||
"China Mobile" -> carrierZh += "中国移动" | ||
"China Unicom" -> carrierZh += "中国联通" | ||
"China Telecom" -> carrierZh += "中国电信" | ||
else -> { | ||
} | ||
} | ||
carrierZh | ||
} else { | ||
carrierEn | ||
} | ||
} | ||
|
||
//获取手机号码归属地 | ||
fun getGeo(phoneNumber: String?): String { | ||
var referencePhonenumber: PhoneNumber? = null | ||
try { | ||
referencePhonenumber = phoneNumberUtil.parse(phoneNumber, LANGUAGE) | ||
} catch (e: NumberParseException) { | ||
e.printStackTrace() | ||
} | ||
//手机号码归属城市 referenceRegion | ||
return geocoder.getDescriptionForNumber(referencePhonenumber, Locale.CHINA) | ||
} | ||
} |
Oops, something went wrong.