Merge pull request #7 from SimpleMobileTools/master

upd
This commit is contained in:
solokot 2018-03-04 11:21:19 +03:00 committed by GitHub
commit 1437888f15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 39 additions and 50 deletions

View File

@ -1,6 +1,16 @@
Changelog
==========
Version 3.3.2 *(2018-03-04)*
----------------------------
* Some stability and translation improvements
Version 3.3.1 *(2018-03-02)*
----------------------------
* Couple stability and translation improvements
Version 3.3.0 *(2018-02-22)*
----------------------------

View File

@ -10,8 +10,8 @@ android {
applicationId "com.simplemobiletools.contacts"
minSdkVersion 16
targetSdkVersion 27
versionCode 11
versionName "3.3.0"
versionCode 13
versionName "3.3.2"
setProperty("archivesBaseName", "contacts")
}
@ -45,7 +45,7 @@ ext {
}
dependencies {
implementation 'com.simplemobiletools:commons:3.12.20'
implementation 'com.simplemobiletools:commons:3.14.12'
implementation 'joda-time:joda-time:2.9.9'
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.google.code.gson:gson:2.8.2'

View File

@ -95,14 +95,18 @@ abstract class ContactActivity : SimpleActivity() {
fun deleteContact() {
ConfirmationDialog(this) {
if (contact != null) {
ContactsHelper(this).deleteContact(contact!!)
finish()
}
}
}
fun shareContact() {
if (contact != null) {
shareContacts(arrayListOf(contact!!))
}
}
fun trySendSMS() {
val numbers = contact!!.phoneNumbers

View File

@ -24,8 +24,8 @@ import com.simplemobiletools.contacts.dialogs.ExportContactsDialog
import com.simplemobiletools.contacts.dialogs.FilterContactSourcesDialog
import com.simplemobiletools.contacts.dialogs.ImportContactsDialog
import com.simplemobiletools.contacts.extensions.config
import com.simplemobiletools.contacts.extensions.dbHelper
import com.simplemobiletools.contacts.extensions.getTempFile
import com.simplemobiletools.contacts.extensions.onTabSelectionChanged
import com.simplemobiletools.contacts.helpers.ContactsHelper
import com.simplemobiletools.contacts.helpers.VcfExporter
import com.simplemobiletools.contacts.interfaces.RefreshContactsListener
@ -54,6 +54,9 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
appLaunched()
setupTabColors()
// just get a reference to the database to make sure it is created properly
dbHelper
handlePermission(PERMISSION_READ_CONTACTS) {
if (it) {
handlePermission(PERMISSION_WRITE_CONTACTS) {
@ -187,7 +190,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
override fun onQueryTextChange(newText: String): Boolean {
if (isSearchOpen) {
getCurrentFragment().onSearchQueryChanged(newText)
getCurrentFragment()?.onSearchQueryChanged(newText)
}
return true
}

View File

@ -82,7 +82,7 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
override fun getSelectableItemCount() = contactItems.size
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val layout = if (showPhoneNumbers) R.layout.item_contact_with_number else R.layout.item_contact_without_number
return createViewHolder(layout, parent)
}
@ -174,10 +174,10 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
}
}
override fun onViewRecycled(holder: ViewHolder?) {
override fun onViewRecycled(holder: ViewHolder) {
super.onViewRecycled(holder)
if (!activity.isActivityDestroyed()) {
Glide.with(activity).clear(holder?.itemView?.contact_tmb!!)
Glide.with(activity).clear(holder.itemView?.contact_tmb!!)
}
}

View File

@ -59,7 +59,7 @@ class FilterContactSourcesAdapter(val activity: SimpleActivity, private val cont
fun getSelectedItemsSet() = selectedPositions
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = activity.layoutInflater.inflate(R.layout.item_filter_contact_source, parent, false)
return ViewHolder(view, adapterListener, activity)
}

View File

@ -73,7 +73,7 @@ class SelectContactsAdapter(val activity: SimpleActivity, val contacts: List<Con
return selectedItemsSet
}
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = activity.layoutInflater.inflate(itemLayout, parent, false)
return ViewHolder(view, adapterListener, activity, allowPickMultiple, itemClick)
}
@ -135,10 +135,10 @@ class SelectContactsAdapter(val activity: SimpleActivity, val contacts: List<Con
}
}
override fun onViewRecycled(holder: ViewHolder?) {
override fun onViewRecycled(holder: ViewHolder) {
super.onViewRecycled(holder)
if (!activity.isActivityDestroyed()) {
Glide.with(activity).clear(holder?.itemView?.contact_tmb!!)
Glide.with(activity).clear(holder.itemView?.contact_tmb!!)
}
}
}

View File

@ -12,7 +12,6 @@ import com.simplemobiletools.contacts.models.Contact
import kotlinx.android.synthetic.main.layout_select_contact.view.*
class AddFavoritesDialog(val activity: SimpleActivity, private val callback: () -> Unit) {
private var dialog: AlertDialog? = null
private var view = activity.layoutInflater.inflate(R.layout.layout_select_contact, null)
private val config = activity.config
private var allContacts = ArrayList<Contact>()
@ -42,14 +41,11 @@ class AddFavoritesDialog(val activity: SimpleActivity, private val callback: ()
}
}
dialog = AlertDialog.Builder(activity)
.setPositiveButton(R.string.ok, null)
AlertDialog.Builder(activity)
.setPositiveButton(R.string.ok, { dialog, which -> dialogConfirmed() })
.setNegativeButton(R.string.cancel, null)
.create().apply {
activity.setupDialogStuff(view, this)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
dialogConfirmed()
}
}
}
@ -66,7 +62,6 @@ class AddFavoritesDialog(val activity: SimpleActivity, private val callback: ()
contactsHelper.removeFavorites(allDisplayedContacts)
callback()
dialog?.dismiss()
}.start()
}
}

View File

@ -1,17 +0,0 @@
package com.simplemobiletools.contacts.extensions
import android.support.design.widget.TabLayout
fun TabLayout.onTabSelectionChanged(tabUnselectedAction: (inactiveTab: TabLayout.Tab) -> Unit, tabSelectedAction: (activeTab: TabLayout.Tab) -> Unit) =
setOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
override fun onTabSelected(tab: TabLayout.Tab) {
tabSelectedAction(tab)
}
override fun onTabUnselected(tab: TabLayout.Tab) {
tabUnselectedAction(tab)
}
override fun onTabReselected(tab: TabLayout.Tab) {
}
})

View File

@ -1,7 +1,6 @@
package com.simplemobiletools.contacts.fragments
import android.content.Context
import android.graphics.Paint
import android.support.design.widget.CoordinatorLayout
import android.util.AttributeSet
import android.view.ViewGroup
@ -40,7 +39,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
placeholderClicked()
}
fragment_placeholder_2.paintFlags = fragment_placeholder_2.paintFlags or Paint.UNDERLINE_TEXT_FLAG
fragment_placeholder_2.underlineText()
updateViewStuff()
if (this is FavoritesFragment) {

View File

@ -30,10 +30,6 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getString(LAST_USED_CONTACT_SOURCE, "")
set(lastUsedContactSource) = prefs.edit().putString(LAST_USED_CONTACT_SOURCE, lastUsedContactSource).apply()
var lastUsedViewPagerPage: Int
get() = prefs.getInt(LAST_USED_VIEW_PAGER_PAGE, 0)
set(lastUsedViewPagerPage) = prefs.edit().putInt(LAST_USED_VIEW_PAGER_PAGE, lastUsedViewPagerPage).apply()
var localAccountName: String
get() = prefs.getString(LOCAL_ACCOUNT_NAME, "-1")
set(localAccountName) = prefs.edit().putString(LOCAL_ACCOUNT_NAME, localAccountName).apply()

View File

@ -6,7 +6,6 @@ const val SHOW_PHONE_NUMBERS = "show_phone_numbers"
const val DISPLAY_CONTACT_SOURCES = "display_contact_sources"
const val START_NAME_WITH_SURNAME = "start_name_with_surname"
const val LAST_USED_CONTACT_SOURCE = "last_used_contact_source"
const val LAST_USED_VIEW_PAGER_PAGE = "last_used_view_pager_page"
const val LOCAL_ACCOUNT_NAME = "local_account_name"
const val LOCAL_ACCOUNT_TYPE = "local_account_type"
const val ON_CONTACT_CLICK = "on_contact_click"

View File

@ -361,6 +361,8 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
sources.add(contactSource)
} while (cursor.moveToNext())
}
} catch (e: Exception) {
activity.showErrorToast(e)
} finally {
cursor?.close()
}

View File

@ -2,11 +2,9 @@
<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/main_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
tooLs:ignore="MissingPrefix">
android:layout_height="match_parent">
<android.support.design.widget.TabLayout
android:id="@+id/main_tabs_holder"

View File

@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.21'
ext.kotlin_version = '1.2.30'
repositories {
google()