Skip to content

Commit

Permalink
fix for crashes due to vector drawable on pre-lollipop
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Mar 14, 2019
1 parent cedafc3 commit 554c74f
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 45 deletions.
7 changes: 7 additions & 0 deletions app/src/main/java/co/tinode/tindroid/ContactsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import android.net.Uri;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatDelegate;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
Expand Down Expand Up @@ -40,6 +42,11 @@ public class ContactsActivity extends AppCompatActivity implements
private MeListener mMeTopicListener = null;
private MeTopic mMeTopic = null;

static {
// Otherwise crash on pre-Lollipop (per-API 21)
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/co/tinode/tindroid/CreateGroupActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.pm.PackageManager;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.fragment.app.FragmentTransaction;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
Expand All @@ -16,6 +17,11 @@ public class CreateGroupActivity extends AppCompatActivity {

private static final String TAG = "CreateGroupActivity";

static {
// Otherwise crash on pre-Lollipop (per-API 21)
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/co/tinode/tindroid/LoginActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.core.app.ActivityCompat;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
Expand Down Expand Up @@ -72,6 +73,11 @@ public class LoginActivity extends AppCompatActivity {
private AccountAuthenticatorResponse mAccountAuthenticatorResponse = null;
private Bundle mResultBundle = null;

static {
// Otherwise crash on pre-Lollipop (per-API 21)
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}

//private LoginFragment mLoginFragment = null;
//private SignUpFragment mSignUpFragment = null;
//private LoginSettingsFragment mSettingsFragment = null;
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/co/tinode/tindroid/MessageActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;

import androidx.appcompat.app.AppCompatDelegate;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
Expand Down Expand Up @@ -78,6 +80,11 @@ public class MessageActivity extends AppCompatActivity {
private DownloadManager mDownloadMgr = null;
private long mDownloadId = -1;

static {
// Otherwise crash on pre-Lollipop (per-API 21)
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/layout/dialog_accept_chat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:clickable="true"
android:drawablePadding="4sp"
android:drawableStart="@drawable/ic_check_grey"
app:drawableStartCompat="@drawable/ic_check_grey"
android:focusable="true"
android:gravity="center_vertical"
android:text="@string/new_chat_accept"
Expand All @@ -61,7 +61,7 @@
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:clickable="true"
android:drawablePadding="4sp"
android:drawableStart="@drawable/ic_delete_grey"
app:drawableStartCompat="@drawable/ic_delete_grey"
android:focusable="true"
android:gravity="center_vertical"
android:text="@string/new_chat_ignore"
Expand All @@ -79,7 +79,7 @@
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:clickable="true"
android:drawablePadding="4sp"
android:drawableStart="@drawable/ic_block"
app:drawableStartCompat="@drawable/ic_block"
android:focusable="true"
android:gravity="center_vertical"
android:text="@string/new_chat_block"
Expand Down
18 changes: 7 additions & 11 deletions app/src/main/res/layout/dialog_member_actions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:paddingEnd="@dimen/dialog_padding_right"
android:paddingStart="@dimen/dialog_padding_left">
Expand All @@ -14,7 +15,7 @@
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:clickable="true"
android:drawablePadding="4sp"
android:drawableStart="@drawable/ic_person"
app:drawableStartCompat="@drawable/ic_person"
android:focusable="true"
android:gravity="center_vertical"
android:text="@string/view_profile"/>
Expand All @@ -26,9 +27,8 @@
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:clickable="true"
android:drawableLeft="@drawable/ic_chat_grey"
android:drawablePadding="4sp"
android:drawableStart="@drawable/ic_chat_grey"
app:drawableStartCompat="@drawable/ic_chat_grey"
android:focusable="true"
android:gravity="center_vertical"
android:text="@string/send_message"/>
Expand All @@ -41,9 +41,8 @@
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:clickable="true"
android:drawableLeft="@drawable/ic_checklist_grey"
android:drawablePadding="4sp"
android:drawableStart="@drawable/ic_checklist_grey"
app:drawableStartCompat="@drawable/ic_checklist_grey"
android:focusable="true"
android:gravity="center_vertical"
android:text="@string/change_permissions"/>
Expand All @@ -56,9 +55,8 @@
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:clickable="true"
android:drawableLeft="@drawable/ic_flag"
android:drawablePadding="4sp"
android:drawableStart="@drawable/ic_flag"
app:drawableStartCompat="@drawable/ic_flag"
android:focusable="true"
android:gravity="center_vertical"
android:text="@string/make_owner"/>
Expand All @@ -70,9 +68,8 @@
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:clickable="true"
android:drawableLeft="@drawable/ic_exit_gray"
android:drawablePadding="4sp"
android:drawableStart="@drawable/ic_exit_gray"
app:drawableStartCompat="@drawable/ic_exit_gray"
android:focusable="true"
android:gravity="center_vertical"
android:text="@string/remove_from_group"/>
Expand All @@ -84,9 +81,8 @@
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:clickable="true"
android:drawableLeft="@drawable/ic_block"
android:drawablePadding="4sp"
android:drawableStart="@drawable/ic_block"
app:drawableStartCompat="@drawable/ic_block"
android:focusable="true"
android:gravity="center_vertical"
android:text="@string/block"/>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/edit_group.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
android:layout_alignParentEnd="true"
android:layout_margin="2sp"
android:background="@drawable/pill_counter"
android:drawableTop="@drawable/ic_add_a_photo"
android:paddingTop="10dp"/>
android:paddingTop="10dp"
app:drawableTopCompat="@drawable/ic_add_a_photo"/>

<LinearLayout
android:layout_width="wrap_content"
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/res/layout/fragment_account_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
android:layout_alignParentEnd="true"
android:layout_margin="2sp"
android:background="@drawable/pill_counter"
android:drawableTop="@drawable/ic_add_a_photo"
android:gravity="center"
android:paddingTop="10dp"/>
android:paddingTop="10dp"
app:drawableTopCompat="@drawable/ic_add_a_photo"/>

<TextView
android:id="@+id/topicTitle"
Expand Down Expand Up @@ -185,9 +185,9 @@
android:layout_height="wrap_content"
android:contentDescription="@string/change_password"
android:drawablePadding="4sp"
android:drawableStart="@drawable/ic_lock_outline"
android:text="@string/change_password"
android:textColor="@color/colorTextPrimary"/>
android:textColor="@color/colorTextPrimary"
app:drawableStartCompat="@drawable/ic_lock_outline" />

<Button
android:id="@+id/buttonLogout"
Expand All @@ -196,9 +196,9 @@
android:layout_height="wrap_content"
android:contentDescription="@string/logout"
android:drawablePadding="4sp"
android:drawableStart="@drawable/ic_exit"
android:text="@string/logout"
android:textColor="@color/colorTextPrimary"/>
android:textColor="@color/colorDangerDark"
app:drawableStartCompat="@drawable/ic_exit_red" />

</LinearLayout>

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/fragment_edit_members.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
android:layout_alignParentEnd="true"
android:layout_margin="16dp"
android:clickable="true"
android:focusable="true"
app:elevation="@dimen/fab_elevation"
app:srcCompat="@drawable/ic_check"
/>
app:srcCompat="@drawable/ic_check" />

</RelativeLayout>
24 changes: 14 additions & 10 deletions app/src/main/res/layout/fragment_signup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
android:orientation="horizontal">

<LinearLayout
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
Expand Down Expand Up @@ -63,29 +64,32 @@
</LinearLayout>

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="128dp"
android:layout_marginRight="8dp">
android:layout_weight="0.1"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_marginEnd="4dp"
android:layout_marginTop="4dp">

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/imageAvatar"
android:layout_width="112sp"
android:layout_height="112sp"
android:layout_marginLeft="8sp"
android:layout_width="@dimen/avatar_size_large"
android:layout_height="@dimen/avatar_size_large"
android:layout_marginStart="8sp"
android:clickable="true"
android:focusable="true"
android:contentDescription="@string/avatar"
app:srcCompat="@drawable/ic_person"/>
app:srcCompat="@drawable/ic_person_grey"/>

<Button
android:id="@+id/uploadAvatar"
android:layout_width="48sp"
android:layout_height="48sp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_margin="2sp"
android:background="@drawable/pill_counter"
android:drawableTop="@drawable/ic_add_a_photo"
android:paddingTop="10dp"/>
android:paddingTop="10dp"
app:drawableTopCompat="@drawable/ic_add_a_photo"/>
</RelativeLayout>

</LinearLayout>
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/res/layout/fragment_topic_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
android:layout_alignParentEnd="true"
android:layout_margin="2sp"
android:background="@drawable/pill_counter"
android:drawableTop="@drawable/ic_add_a_photo"
android:gravity="center"
android:paddingTop="10dp"/>
android:paddingTop="10dp"
app:drawableTopCompat="@drawable/ic_add_a_photo"/>

<TextView
android:id="@+id/topicTitle"
Expand Down Expand Up @@ -138,9 +138,9 @@
android:layout_below="@id/membersTitle"
android:contentDescription="@string/add_members"
android:drawablePadding="4sp"
android:drawableStart="@drawable/ic_person_add"
android:text="@string/add_members"
android:textColor="@color/colorTextPrimary"/>
android:textColor="@color/colorTextPrimary"
app:drawableStartCompat="@drawable/ic_person_add" />

<Button
android:id="@+id/buttonLeaveGroup"
Expand All @@ -150,9 +150,9 @@
android:layout_below="@id/membersTitle"
android:layout_toEndOf="@id/buttonAddMembers"
android:drawablePadding="4sp"
android:drawableStart="@drawable/ic_exit_red"
android:text="@string/leave_group"
android:textColor="@color/colorDangerDark"/>
android:textColor="@color/colorDangerDark"
app:drawableStartCompat="@drawable/ic_exit_red" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/groupMembers"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/fragment_view_image.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:contentDescription=""
tools:src="@drawable/logo_src"/>
tools:src="@drawable/logo_src"
tools:ignore="ContentDescription"/>

</RelativeLayout>
5 changes: 2 additions & 3 deletions app/src/main/res/layout/group_member.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
android:id="@+id/statusContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/optionsMenu"
android:layout_toStartOf="@id/optionsMenu"
android:layout_marginTop="3.5dp"
android:orientation="horizontal"
Expand Down Expand Up @@ -88,8 +87,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:paddingEnd="16sp" tools:ignore="RtlSymmetry"
android:paddingRight="16sp"
android:paddingEnd="16sp"
tools:ignore="RtlSymmetry"
android:layout_alignParentTop="true"
android:maxLines="1"
tools:text="Test text"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/toolbar_with_tabs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
android:id="@+id/toolbar_progress_bar"
android:layout_width="24dp"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:visibility="gone" />

</androidx.appcompat.widget.Toolbar>
Expand Down

0 comments on commit 554c74f

Please sign in to comment.