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 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)* Version 3.3.0 *(2018-02-22)*
---------------------------- ----------------------------

View File

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

View File

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

View File

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

View File

@ -82,7 +82,7 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
override fun getSelectableItemCount() = contactItems.size 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 val layout = if (showPhoneNumbers) R.layout.item_contact_with_number else R.layout.item_contact_without_number
return createViewHolder(layout, parent) 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) super.onViewRecycled(holder)
if (!activity.isActivityDestroyed()) { 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 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) val view = activity.layoutInflater.inflate(R.layout.item_filter_contact_source, parent, false)
return ViewHolder(view, adapterListener, activity) return ViewHolder(view, adapterListener, activity)
} }

View File

@ -73,7 +73,7 @@ class SelectContactsAdapter(val activity: SimpleActivity, val contacts: List<Con
return selectedItemsSet 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) val view = activity.layoutInflater.inflate(itemLayout, parent, false)
return ViewHolder(view, adapterListener, activity, allowPickMultiple, itemClick) 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) super.onViewRecycled(holder)
if (!activity.isActivityDestroyed()) { 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.* import kotlinx.android.synthetic.main.layout_select_contact.view.*
class AddFavoritesDialog(val activity: SimpleActivity, private val callback: () -> Unit) { 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 var view = activity.layoutInflater.inflate(R.layout.layout_select_contact, null)
private val config = activity.config private val config = activity.config
private var allContacts = ArrayList<Contact>() private var allContacts = ArrayList<Contact>()
@ -42,14 +41,11 @@ class AddFavoritesDialog(val activity: SimpleActivity, private val callback: ()
} }
} }
dialog = AlertDialog.Builder(activity) AlertDialog.Builder(activity)
.setPositiveButton(R.string.ok, null) .setPositiveButton(R.string.ok, { dialog, which -> dialogConfirmed() })
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .create().apply {
activity.setupDialogStuff(view, this) 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) contactsHelper.removeFavorites(allDisplayedContacts)
callback() callback()
dialog?.dismiss()
}.start() }.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 package com.simplemobiletools.contacts.fragments
import android.content.Context import android.content.Context
import android.graphics.Paint
import android.support.design.widget.CoordinatorLayout import android.support.design.widget.CoordinatorLayout
import android.util.AttributeSet import android.util.AttributeSet
import android.view.ViewGroup import android.view.ViewGroup
@ -40,7 +39,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
placeholderClicked() placeholderClicked()
} }
fragment_placeholder_2.paintFlags = fragment_placeholder_2.paintFlags or Paint.UNDERLINE_TEXT_FLAG fragment_placeholder_2.underlineText()
updateViewStuff() updateViewStuff()
if (this is FavoritesFragment) { if (this is FavoritesFragment) {

View File

@ -30,10 +30,6 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getString(LAST_USED_CONTACT_SOURCE, "") get() = prefs.getString(LAST_USED_CONTACT_SOURCE, "")
set(lastUsedContactSource) = prefs.edit().putString(LAST_USED_CONTACT_SOURCE, lastUsedContactSource).apply() 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 var localAccountName: String
get() = prefs.getString(LOCAL_ACCOUNT_NAME, "-1") get() = prefs.getString(LOCAL_ACCOUNT_NAME, "-1")
set(localAccountName) = prefs.edit().putString(LOCAL_ACCOUNT_NAME, localAccountName).apply() 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 DISPLAY_CONTACT_SOURCES = "display_contact_sources"
const val START_NAME_WITH_SURNAME = "start_name_with_surname" const val START_NAME_WITH_SURNAME = "start_name_with_surname"
const val LAST_USED_CONTACT_SOURCE = "last_used_contact_source" 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_NAME = "local_account_name"
const val LOCAL_ACCOUNT_TYPE = "local_account_type" const val LOCAL_ACCOUNT_TYPE = "local_account_type"
const val ON_CONTACT_CLICK = "on_contact_click" const val ON_CONTACT_CLICK = "on_contact_click"

View File

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

View File

@ -2,11 +2,9 @@
<RelativeLayout <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tooLs="http://schemas.android.com/tools"
android:id="@+id/main_holder" android:id="@+id/main_holder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
tooLs:ignore="MissingPrefix">
<android.support.design.widget.TabLayout <android.support.design.widget.TabLayout
android:id="@+id/main_tabs_holder" 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. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = '1.2.21' ext.kotlin_version = '1.2.30'
repositories { repositories {
google() google()