Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix issue 217 -- LoginActivity crash when run in Android 4.2.2 #218

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.apache.fineract.ui.online.login;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.graphics.drawable.VectorDrawableCompat;
import android.text.TextUtils;
import android.widget.EditText;
import android.widget.Toast;
Expand Down Expand Up @@ -41,12 +43,24 @@ public class LoginActivity extends FineractBaseActivity implements LoginContract
@Inject
PreferencesHelper preferencesHelper;

private void setDrawableLeftOfEditText(EditText editText, int drawableResource) {
VectorDrawableCompat vdc =
VectorDrawableCompat.create(getResources(), drawableResource, null);
editText.setCompoundDrawables(vdc, null, null, null);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
editText.setCompoundDrawablesRelativeWithIntrinsicBounds(vdc, null, null, null);
}
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActivityComponent().inject(this);
setContentView(R.layout.activity_login);
ButterKnife.bind(this);
setDrawableLeftOfEditText(etTenant, R.drawable.ic_tenant_black_24dp);
setDrawableLeftOfEditText(etUsername, R.drawable.ic_person_black_24dp);
setDrawableLeftOfEditText(etPassword, R.drawable.ic_password_black_24dp);
loginPresenter.attachView(this);
setActionBarTitle(getString(R.string.fineract_account));
preferencesHelper.clear();
Expand Down
6 changes: 0 additions & 6 deletions app/src/main/res/layout/activity_login.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@

<EditText
style="@style/Base.TextAppearance.AppCompat.Medium"
android:drawableLeft="@drawable/ic_tenant_black_24dp"
android:drawableStart="@drawable/ic_tenant_black_24dp"
android:drawablePadding="@dimen/layout_padding_8dp"
android:hint="@string/tenant"
android:id="@+id/et_tenant"
Expand All @@ -69,8 +67,6 @@

<EditText
style="@style/Base.TextAppearance.AppCompat.Medium"
android:drawableLeft="@drawable/ic_person_black_24dp"
android:drawableStart="@drawable/ic_person_black_24dp"
android:drawablePadding="@dimen/layout_padding_8dp"
android:hint="@string/username"
android:id="@+id/et_username"
Expand All @@ -87,8 +83,6 @@

<EditText
style="@style/Base.TextAppearance.AppCompat.Medium"
android:drawableLeft="@drawable/ic_password_black_24dp"
android:drawableStart="@drawable/ic_password_black_24dp"
android:drawablePadding="@dimen/layout_padding_8dp"
android:hint="@string/password"
android:id="@+id/et_password"
Expand Down