use our own icons for messaging apps, we cannot scan the system anymore

This commit is contained in:
tibbi 2021-11-17 19:43:03 +01:00
parent 3e23f9d8ec
commit 06e55b6218
9 changed files with 61 additions and 27 deletions

View file

@ -1,9 +1,10 @@
package com.simplemobiletools.contacts.pro.extensions
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.content.pm.LauncherApps
import android.database.Cursor
import android.graphics.*
import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.Handler
@ -26,6 +27,7 @@ import com.simplemobiletools.contacts.pro.models.Organization
import com.simplemobiletools.contacts.pro.models.SocialAction
import java.io.File
val Context.config: Config get() = Config.newInstance(applicationContext)
val Context.contactsDB: ContactsDao get() = ContactsDatabase.getInstance(applicationContext).ContactsDao()
@ -35,8 +37,10 @@ val Context.groupsDB: GroupsDao get() = ContactsDatabase.getInstance(application
fun Context.getEmptyContact(): Contact {
val originalContactSource = if (hasContactPermissions()) config.lastUsedContactSource else SMT_PRIVATE
val organization = Organization("", "")
return Contact(0, "", "", "", "", "", "", "", ArrayList(), ArrayList(), ArrayList(), ArrayList(), originalContactSource, 0, 0, "",
null, "", ArrayList(), organization, ArrayList(), ArrayList(), DEFAULT_MIMETYPE, null)
return Contact(
0, "", "", "", "", "", "", "", ArrayList(), ArrayList(), ArrayList(), ArrayList(), originalContactSource, 0, 0, "",
null, "", ArrayList(), organization, ArrayList(), ArrayList(), DEFAULT_MIMETYPE, null
)
}
fun Context.viewContact(contact: Contact) {
@ -355,22 +359,15 @@ fun Context.getSocialActions(id: Int): ArrayList<SocialAction> {
return socialActions
}
fun Context.getPackageDrawable(packageName: String): Drawable? {
var drawable: Drawable? = null
try {
// try getting the properly colored launcher icons
val launcher = getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
val activityList = launcher.getActivityList(packageName, android.os.Process.myUserHandle())[0]
drawable = activityList.getBadgedIcon(0)
} catch (ignored: Exception) {
}
if (drawable == null) {
try {
drawable = packageManager.getApplicationIcon(packageName)
} catch (ignored: Exception) {
}
}
return drawable
@SuppressLint("UseCompatLoadingForDrawables")
fun Context.getPackageDrawable(packageName: String): Drawable {
return resources.getDrawable(
when (packageName) {
TELEGRAM_PACKAGE -> R.drawable.ic_telegram_vector
SIGNAL_PACKAGE -> R.drawable.ic_signal_vector
WHATSAPP_PACKAGE -> R.drawable.ic_whatsapp_vector
VIBER_PACKAGE -> R.drawable.ic_viber_vector
else -> R.drawable.ic_threema_vector
}, theme
)
}

View file

@ -0,0 +1,4 @@
<vector android:height="24dp" android:viewportHeight="1024" android:viewportWidth="1024" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#3a76f0" android:pathData="M0 0v1024h1024V0H0z"/>
<path android:fillColor="#ffffff" android:pathData="M442.08 229.27l6.54 26.48a264.44 264.44 0 0 0-73.14 30.28l-13.99-23.41a287.61 287.61 0 0 1 80.59-33.34zm139.84 0l-6.54 26.48a264.44 264.44 0 0 1 73.14 30.28l14.15-23.41a289.68 289.68 0 0 0-80.75-33.35zm-319.3 132.14a289.18 289.18 0 0 0-33.34 80.67l26.48 6.54a264.44 264.44 0 0 1 30.28-73.14zM248.05 512a263.53 263.53 0 0 1 2.98-39.55l-26.97-4.14a291.25 291.25 0 0 0 0 87.29l26.97-4.05a264.36 264.36 0 0 1-2.98-39.55zm414.46 249.3l-13.99-23.33a262.95 262.95 0 0 1-73.06 30.28l6.54 26.48a289.84 289.84 0 0 0 80.51-33.43zM775.95 512a264.36 264.36 0 0 1-2.98 39.55l26.97 4.05a291.25 291.25 0 0 0 0-87.29l-26.97 4.14a263.53 263.53 0 0 1 2.98 39.55zm18.78 69.83l-26.48-6.53a263.95 263.95 0 0 1-30.28 73.23l23.42 14.07a288.68 288.68 0 0 0 33.34-80.77zM551.55 772.97a264.03 264.03 0 0 1-79.1 0l-4.05 26.97a290.67 290.67 0 0 0 87.21 0zm172.93-104.42a263.2 263.2 0 0 1-55.93 55.85l16.22 22.01a293.81 293.81 0 0 0 61.73-61.48zm-55.93-369.03a263.61 263.61 0 0 1 55.93 55.93l22.01-16.38a293.4 293.4 0 0 0-61.56-61.56zm-369.03 55.93a263.61 263.61 0 0 1 55.93-55.93l-16.38-22.01a293.4 293.4 0 0 0-61.56 61.56zm461.86 5.96l-23.41 14.07a262.95 262.95 0 0 1 30.28 73.06l26.48-6.54a288.68 288.68 0 0 0-33.35-80.59zM472.45 251.03a264.03 264.03 0 0 1 79.1 0l4.05-26.97a290.67 290.67 0 0 0-87.21 0zM313.5 753.69l-56.34 13.07 13.15-56.35-26.56-6.2-13.15 56.35a27.3 27.3 0 0 0 20.35 32.85 28.55 28.55 0 0 0 12.41 0l56.35-12.99zm-64.12-73.81l26.64 6.13 9.1-39.06a261.63 261.63 0 0 1-29.37-71.65l-26.48 6.54a292.33 292.33 0 0 0 26.81 69.25zm127.42 59.08l-39.05 9.1 6.2 26.64 28.71-6.7a288.77 288.77 0 0 0 69.25 26.81l6.54-26.48a262.04 262.04 0 0 1-71.41-29.54zM512 275.36c-130.73 0.08-236.56 106.07-236.56 236.72a237.22 237.22 0 0 0 36.32 125.77l-22.75 97.14 97.06-22.75c110.62 69.58 256.74 36.4 326.33-74.14 69.59-110.54 36.49-256.67-74.05-326.33A237.22 237.22 0 0 0 512 275.36" android:strokeWidth="0.82741475"/>
</vector>

View file

@ -0,0 +1,4 @@
<vector android:height="24dp" android:viewportHeight="455.731" android:viewportWidth="455.731" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#36a6de" android:pathData="M0 0h455.731v455.731H0z"/>
<path android:fillColor="#ffffff" android:pathData="M107.812 223.206l148.606-61.208c14.664-6.376 64.396-26.779 64.396-26.779s22.953-8.926 21.04 12.752c-0.638 8.926-5.738 40.168-10.839 74.009l-15.94 100.15s-1.275 14.664-12.114 17.215c-10.839 2.55-28.691-8.926-31.879-11.477-2.55-1.913-47.819-30.604-64.396-44.631-4.463-3.826-9.564-11.477 0.638-20.403 22.953-21.04 50.369-47.181 66.946-63.758 7.651-7.651 15.302-25.503-16.577-3.826l-89.948 60.472s-10.201 6.376-29.329 0.638-41.443-13.389-41.443-13.389-15.302-9.564 10.839-19.765z" android:strokeWidth="0.49044925"/>
</vector>

View file

@ -0,0 +1,5 @@
<vector android:height="24dp" android:viewportHeight="512" android:viewportWidth="512" android:width="24dp" xmlns:aapt="http://schemas.android.com/aapt" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#3b3b3b" android:pathData="M0 0h512v512H0z"/>
<path android:fillColor="#ffffff" android:pathData="M193.916 316.176l-70.308 17.36 14.756-59.892c-14.756-19.096-23.436-43.4-23.436-68.572 0-68.572 63.364-124.123 141.483-124.123s141.483 55.552 141.483 124.123c0 68.572-63.364 124.123-141.483 124.123-21.7 0-43.4-4.34-61.628-12.152zm21.7-122.388h-1.736c-3.472 0-6.076 2.604-5.208 6.076v56.42c0 3.472 2.604 6.076 6.076 6.076h83.327c3.472 0 6.076-2.604 6.076-6.076v-56.42c0-3.472-2.604-6.076-6.076-6.076h-1.736v-15.624c0-21.7-18.228-39.928-39.928-39.928-21.7 0-39.928 18.228-39.928 39.928v15.624zm64.232 0h-47.74v-15.624c0-13.02 10.416-24.304 24.304-24.304 13.02 0 24.304 10.416 24.304 24.304v15.624z" android:strokeWidth="0.86799389"/>
<path android:fillColor="#3fe669" android:pathData="M144.951 384.747a24.304 24.304 0 1 1 48.608 0 24.304 24.304 0 1 1-48.608 0m86.799 0a24.304 24.304 0 1 1 48.608 0 24.304 24.304 0 1 1-48.608 0m86.8 0a24.304 24.304 0 1 1 48.608 0 24.304 24.304 0 1 1-48.608 0" android:strokeWidth="0.86799389"/>
</vector>

View file

@ -0,0 +1,9 @@
<vector android:height="24dp" android:viewportHeight="512" android:viewportWidth="512" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#7b519d" android:pathData="M0 0h512v512H0z"/>
<path android:fillColor="#ffffff" android:pathData="M407.294 186.94l-0.092-0.369c-7.477-30.229-41.188-62.664-72.145-69.412l-0.349-0.072c-50.073-9.552-100.844-9.552-150.905 0l-0.36 0.072c-30.947 6.748-64.658 39.186-72.145 69.412l-0.083 0.369c-9.244 42.214-9.244 85.026 0 127.24l0.083 0.369c7.169 28.938 38.368 59.885 68.171 68.395v33.743c0 12.214 14.883 18.212 23.346 9.398l34.188-35.537c7.416 0.414 14.835 0.646 22.252 0.646 25.205 0 50.421-2.384 75.452-7.159l0.349-0.072c30.958-6.748 64.668-39.186 72.145-69.412l0.092-0.369c9.244-42.215 9.244-85.025 0.001-127.241zm-27.056 121.12c-4.992 19.721-30.587 44.238-50.924 48.768-26.624 5.063-53.459 7.227-80.267 6.484-0.533-0.016-1.046 0.192-1.417 0.575l-24.962 25.625-26.55 27.25c-1.941 2.025-5.352 0.646-5.352-2.147v-55.899c0-0.924-0.659-1.707-1.566-1.887-0.005-0.002-0.011-0.002-0.016-0.003-20.337-4.53-45.923-29.047-50.924-48.768-8.32-38.157-8.32-76.839 0-114.996 5.001-19.721 30.587-44.238 50.924-48.768 46.498-8.844 93.643-8.844 140.131 0 20.347 4.53 45.932 29.047 50.924 48.768 8.329 38.158 8.329 76.84-0.001 114.998z" android:strokeWidth="1.09314275"/>
<path android:fillColor="#ffffff" android:pathData="M303.493 333.862c-3.126-0.95-6.105-1.587-8.874-2.734-28.674-11.897-55.063-27.244-75.965-50.77-11.887-13.378-21.191-28.482-29.055-44.466-3.73-7.58-6.873-15.456-10.077-23.283-2.921-7.136 1.382-14.508 5.912-19.886 4.251-5.047 9.722-8.908 15.647-11.756 4.624-2.221 9.185-0.94 12.562 2.979 7.3 8.474 14.008 17.381 19.436 27.204 3.34 6.042 2.423 13.427-3.629 17.538-1.471 0.999-2.812 2.173-4.181 3.301-1.202 0.989-2.333 1.988-3.157 3.328-1.505 2.45-1.577 5.341-0.609 8.005 7.463 20.508 20.042 36.457 40.686 45.048 3.303 1.374 6.62 2.973 10.426 2.531 6.373-0.744 8.437-7.736 12.903-11.388 4.365-3.569 9.944-3.616 14.646-0.641 4.704 2.978 9.262 6.172 13.794 9.402 4.449 3.17 8.877 6.269 12.98 9.884 3.946 3.475 5.305 8.034 3.083 12.748-4.067 8.637-9.986 15.82-18.522 20.407-2.41 1.292-5.29 1.711-8.007 2.548-3.126-0.95 2.718-0.837 0 0zm-44.162-162.77c37.505 1.052 68.31 25.941 74.912 63.021 1.125 6.318 1.525 12.777 2.026 19.19 0.211 2.697-1.317 5.259-4.227 5.295-3.006 0.037-4.358-2.48-4.555-5.175-0.386-5.337-0.654-10.699-1.389-15.989-3.882-27.94-26.16-51.054-53.97-56.014-4.186-0.747-8.466-0.942-12.707-1.387-2.679-0.281-6.188-0.442-6.782-3.775-0.497-2.793 1.859-5.016 4.519-5.16 0.72-0.043 1.447-0.011 2.173-0.005 37.507 1.052-0.726-0.002 0 0z" android:strokeWidth="1.09314275"/>
<path android:fillColor="#ffffff" android:pathData="M316.328 244.981c-0.063 0.469-0.094 1.57-0.369 2.606-0.995 3.765-6.705 4.236-8.018 0.437-0.39-1.127-0.448-2.41-0.45-3.624-0.011-7.943-1.739-15.879-5.746-22.791-4.118-7.104-10.41-13.074-17.788-16.689-4.462-2.184-9.286-3.543-14.177-4.351-2.137-0.354-4.297-0.567-6.445-0.867-2.603-0.362-3.993-2.02-3.869-4.585 0.115-2.403 1.871-4.133 4.491-3.983 8.606 0.487 16.921 2.35 24.574 6.401 15.56 8.241 24.449 21.247 27.044 38.616 0.117 0.788 0.305 1.566 0.365 2.356 0.146 1.948 0.239 3.899 0.388 6.472-0.063 0.467-0.149-2.573 0 0z" android:strokeWidth="1.09314275"/>
<path android:fillColor="#ffffff" android:pathData="M293.001 244.072c-3.137 0.057-4.816-1.681-5.141-4.556-0.224-2.005-0.404-4.038-0.882-5.99-0.942-3.845-2.985-7.406-6.219-9.762-1.526-1.112-3.256-1.922-5.068-2.446-2.301-0.666-4.693-0.482-6.987-1.044-2.493-0.611-3.873-2.631-3.481-4.969 0.357-2.129 2.427-3.791 4.754-3.622 14.541 1.049 24.933 8.567 26.417 25.686 0.106 1.208 0.228 2.484-0.037 3.641-0.461 1.975-1.926 2.967-3.354 3.063-3.138 0.056 1.428-0.096 0 0zm10.492 89.79c2.718-0.837-3.126-0.95 0 0z" android:strokeWidth="1.09314275"/>
<path android:fillColor="#ffffff" android:pathData="M259.427 171.097c-0.032 0-0.062-0.003-0.094-0.003-0.031-0.002 0.009 0 0.094 0.003zm-0.095-0.005c0.032 0 0.062 0.003 0.094 0.003 2.081 0.074 35.934 1.007-0.094-0.003zm56.996 73.889c-0.149-2.573-0.062 0.467 0 0zm-23.327-0.909c0.049-0.003 0.096-0.028 0.143-0.034-0.132 0-0.336 0.003-0.544 0.011 0.136 0.003 0.259 0.024 0.401 0.023z"/>
<path android:fillColor="#ffffff" android:pathData="M293.001 244.072c-0.141 0.002-0.266-0.019-0.401-0.023-0.679 0.019-1.38 0.055 0.401 0.023zm0.143-0.033c-0.049 0.005-0.096 0.031-0.143 0.034 0.367-0.025 0.336-0.034 0.143-0.034z"/>
</vector>

View file

@ -0,0 +1,5 @@
<vector android:height="24dp" android:viewportHeight="455.731" android:viewportWidth="455.731" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#1BD741" android:pathData="M0 0h455.731v455.731H0z"/>
<path android:fillColor="#ffffff" android:pathData="M89.713 366.168l19.351-68.728c-12.444-21.14-18.996-45.193-18.996-69.902 0-76.08 61.896-137.976 137.976-137.976s137.975 61.896 137.975 137.976-61.895 137.976-137.975 137.976c-23.706 0-46.919-6.068-67.454-17.59zm74.5-43.346l4.224 2.579c17.904 10.93 38.516 16.708 59.607 16.708 63.174 0 114.569-51.396 114.569-114.57 0-63.174-51.395-114.57-114.569-114.57s-114.57 51.396-114.57 114.57c0 22.012 6.256 43.388 18.091 61.817l2.844 4.429-11.143 39.579z"/>
<path android:fillColor="#ffffff" android:pathData="M189.285 163.32l-8.953-0.488c-2.812-0.153-5.57 0.786-7.696 2.633-4.34 3.769-11.28 11.056-13.412 20.552-3.179 14.158 1.734 31.496 14.448 48.833s36.408 45.077 78.306 56.924c13.501 3.818 24.122 1.244 32.317-3.998 6.49-4.151 10.964-10.815 12.576-18.348l1.429-6.677c0.454-2.122-0.623-4.275-2.595-5.184l-30.257-13.947c-1.964-0.905-4.294-0.333-5.615 1.379l-11.879 15.399c-0.897 1.163-2.433 1.624-3.82 1.137-8.135-2.859-35.383-14.271-50.335-43.072-0.648-1.249-0.487-2.765 0.433-3.831l11.352-13.133c1.16-1.341 1.453-3.226 0.756-4.856l-13.043-30.514c-0.694-1.624-2.25-2.713-4.013-2.809z"/>
</vector>

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item_social_holder"
android:layout_width="match_parent"
@ -7,12 +8,14 @@
android:background="?attr/selectableItemBackground"
android:padding="@dimen/medium_margin">
<ImageView
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/item_social_image"
android:layout_width="@dimen/normal_icon_size"
android:layout_height="@dimen/normal_icon_size"
android:padding="@dimen/medium_margin"
android:src="@drawable/ic_phone_vector" />
android:padding="@dimen/small_margin"
android:scaleType="centerCrop"
app:shapeAppearanceOverlay="@style/roundedImageView"
tools:src="@drawable/ic_whatsapp_vector" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/item_social_label"

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/contact_source_holder"
android:layout_width="match_parent"
@ -22,7 +23,7 @@
android:singleLine="true"
android:textSize="@dimen/bigger_text_size" />
<ImageView
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/contact_source_image"
android:layout_width="@dimen/normal_icon_size"
android:layout_height="@dimen/normal_icon_size"
@ -32,7 +33,8 @@
android:layout_marginEnd="@dimen/normal_margin"
android:background="?attr/selectableItemBackgroundBorderless"
android:padding="@dimen/small_margin"
android:visibility="gone"
tools:src="@drawable/ic_phone_vector" />
android:scaleType="centerCrop"
app:shapeAppearanceOverlay="@style/roundedImageView"
tools:src="@drawable/ic_whatsapp_vector" />
</RelativeLayout>

View file

@ -2,4 +2,9 @@
<style name="AppTheme" parent="AppTheme.Base" />
<style name="roundedImageView">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">50%</item>
</style>
</resources>