Skip to content

Commit

Permalink
Fix QuickContactBadge crash
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkourlas committed Nov 7, 2020
1 parent 48a6688 commit 0f76703
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* VoIP.ms SMS
* Copyright (C) 2020 Michael Kourlas
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.kourlas.voipms_sms.ui

import android.content.ActivityNotFoundException
import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.QuickContactBadge
import android.widget.Toast
import net.kourlas.voipms_sms.R

class CustomQuickContactBadge : QuickContactBadge {
constructor(context: Context?) : super(context)
constructor(context: Context?, attrs: AttributeSet?) : super(context,
attrs)

constructor(context: Context?, attrs: AttributeSet?,
defStyleAttr: Int) : super(context, attrs, defStyleAttr)

@Suppress("unused")
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int,
defStyleRes: Int) : super(context, attrs, defStyleAttr,
defStyleRes)

override fun onClick(v: View) {
try {
super.onClick(v)
} catch (ex: ActivityNotFoundException) {
Toast.makeText(context, context.getString(
R.string.conversations_no_contact_app),
Toast.LENGTH_SHORT).show()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
android:layout_gravity="bottom"
android:layout_marginEnd="@dimen/margin">

<QuickContactBadge
<net.kourlas.voipms_sms.ui.CustomQuickContactBadge
android:id="@+id/photo"
android:layout_width="@dimen/contact_badge"
android:layout_height="@dimen/contact_badge"
Expand Down
2 changes: 1 addition & 1 deletion voipms-sms/src/main/res/layout/conversations_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<QuickContactBadge
<net.kourlas.voipms_sms.ui.CustomQuickContactBadge
android:id="@+id/photo"
android:layout_width="@dimen/contact_badge"
android:layout_height="@dimen/contact_badge"
Expand Down
2 changes: 1 addition & 1 deletion voipms-sms/src/main/res/layout/new_conversation_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<QuickContactBadge
<net.kourlas.voipms_sms.ui.CustomQuickContactBadge
android:id="@+id/photo"
android:layout_width="@dimen/contact_badge"
android:layout_height="@dimen/contact_badge"
Expand Down
1 change: 1 addition & 0 deletions voipms-sms/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@
<string name="conversations_perm_denied_contacts">Contacts permission required to view names and photos</string>
<string name="conversations_sync_date_suggestion">Synchronization start date is %1$s</string>
<string name="conversations_text_hint">Search…</string>
<string name="conversations_no_contact_app">Failed to open contacts</string>

<!-- ConversationsArchivedActivity -->
<string name="conversations_archived_name">Archived</string>
Expand Down

0 comments on commit 0f76703

Please sign in to comment.