Remove the first activity, fix colors in Classic theme and fix custom icon tint

This commit is contained in:
J-Jamet committed 2018-04-14 21:54:29 +02:00
1 parent 71bd3ab780
commit ceb80c6cac
7 files changed
+45 -80

No files matched your search

@@ -1,52 +0,0 @@
/*
* Copyright 2017 Brian Pellin, Jeremy Jamet / Kunzisoft.
*
* This file is part of KeePass DX.
*
* KeePass DX is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* KeePass DX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.kunzisoft.keepass.activities;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import com.kunzisoft.keepass.fileselect.FileSelectActivity;
public class StartActivity extends Activity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startFileSelectActivity();
// Delete flickering for kitkat <=
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
overridePendingTransition(0, 0);
}
protected void startFileSelectActivity() {
FileSelectActivity.launch(this);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_CANCELED) {
finish();
}
}
}
@@ -28,18 +28,19 @@ import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.v7.app.AppCompatActivity;
import com.kunzisoft.keepass.activities.StartActivity;
import com.kunzisoft.keepass.fileselect.FileSelectActivity;
@RequiresApi(api = Build.VERSION_CODES.O)
public class AutoFillAuthActivity extends StartActivity {
public class AutoFillAuthActivity extends AppCompatActivity {
private AutofillHelper autofillHelper;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
autofillHelper = new AutofillHelper();
startFileSelectActivity();
super.onCreate(savedInstanceState);
}
@@ -48,8 +49,7 @@ public class AutoFillAuthActivity extends StartActivity {
return PendingIntent.getActivity(context, 0,
intent, PendingIntent.FLAG_CANCEL_CURRENT).getIntentSender();
}
@Override
protected void startFileSelectActivity() {
// Pass extra for Autofill (EXTRA_ASSIST_STRUCTURE)
AssistStructure assistStructure = autofillHelper.retrieveAssistStructure(getIntent());
@@ -117,7 +117,7 @@ public class IconDrawableFactory {
* @param tintColor Use this color if tint is true
*/
public void assignDrawableTo(Context context, ImageView imageView, int iconId, boolean tint, int tintColor) {
assignDrawableToImageView(getIconDrawable(context, iconId, tint, tintColor),
assignDrawableToImageView(new SuperDrawable(getIconDrawable(context, iconId, tint, tintColor)),
imageView,
tint,
tintColor);
@@ -126,10 +126,10 @@ public class IconDrawableFactory {
/**
* Utility method to assign a drawable to an ImageView and tint it
*/
private void assignDrawableToImageView(Drawable drawable, ImageView imageView, boolean tint, int tintColor) {
if (imageView != null && drawable != null) {
imageView.setImageDrawable(drawable);
if (tint) {
private void assignDrawableToImageView(SuperDrawable superDrawable, ImageView imageView, boolean tint, int tintColor) {
if (imageView != null && superDrawable.drawable != null) {
imageView.setImageDrawable(superDrawable.drawable);
if (!superDrawable.custom && tint) {
ImageViewCompat.setImageTintList(imageView, ColorStateList.valueOf(tintColor));
} else {
ImageViewCompat.setImageTintList(imageView, null);
@@ -145,7 +145,7 @@ public class IconDrawableFactory {
* @return The build drawable
*/
public Drawable getIconDrawable(Context context, PwIcon icon) {
return getIconDrawable(context, icon, false, Color.WHITE);
return getIconDrawable(context, icon, false, Color.WHITE).drawable;
}
/**
@@ -157,11 +157,11 @@ public class IconDrawableFactory {
* @param tintColor Use this color if tint is true
* @return The build drawable
*/
public Drawable getIconDrawable(Context context, PwIcon icon, boolean tint, int tintColor) {
public SuperDrawable getIconDrawable(Context context, PwIcon icon, boolean tint, int tintColor) {
if (icon instanceof PwIconStandard) {
return getIconDrawable(context.getApplicationContext(), (PwIconStandard) icon, tint, tintColor);
return new SuperDrawable(getIconDrawable(context.getApplicationContext(), (PwIconStandard) icon, tint, tintColor));
} else {
return getIconDrawable(context, (PwIconCustom) icon);
return new SuperDrawable(getIconDrawable(context, (PwIconCustom) icon), true);
}
}
@@ -245,6 +245,24 @@ public class IconDrawableFactory {
return draw;
}
/**
* Utility class to prevent a custom icon to be tint
*/
private class SuperDrawable {
Drawable drawable;
boolean custom;
SuperDrawable(Drawable drawable) {
this.drawable = drawable;
this.custom = false;
}
SuperDrawable(Drawable drawable, boolean custom) {
this.drawable = drawable;
this.custom = custom;
}
}
/**
* Build a custom icon from database
* @param context Context to build the drawable