New icon pack importer
@@ -93,5 +93,6 @@ dependencies {
|
|||||||
annotationProcessor "com.github.hotchemi:permissionsdispatcher-processor:$permissionDispatcherVersion"
|
annotationProcessor "com.github.hotchemi:permissionsdispatcher-processor:$permissionDispatcherVersion"
|
||||||
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.1'
|
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.1'
|
||||||
implementation group: 'com.google.guava', name: 'guava', version: '23.0-android'
|
implementation group: 'com.google.guava', name: 'guava', version: '23.0-android'
|
||||||
compile project(path: ':classiciconpack')
|
// Icon pack
|
||||||
|
implementation project(path: ':icon-pack-classic')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ public class EntryActivity extends LockingHideActivity {
|
|||||||
mEntry.startToManageFieldReferences(pm);
|
mEntry.startToManageFieldReferences(pm);
|
||||||
|
|
||||||
// Assign title
|
// Assign title
|
||||||
populateTitle(db.getDrawFactory().getIconDrawable(getResources(), mEntry.getIcon()),
|
populateTitle(db.getDrawFactory().getIconDrawable(this, mEntry.getIcon()),
|
||||||
mEntry.getTitle());
|
mEntry.getTitle());
|
||||||
|
|
||||||
// Assign basic fields
|
// Assign basic fields
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ import com.kunzisoft.keepass.database.edit.UpdateEntry;
|
|||||||
import com.kunzisoft.keepass.database.security.ProtectedString;
|
import com.kunzisoft.keepass.database.security.ProtectedString;
|
||||||
import com.kunzisoft.keepass.dialogs.GeneratePasswordDialogFragment;
|
import com.kunzisoft.keepass.dialogs.GeneratePasswordDialogFragment;
|
||||||
import com.kunzisoft.keepass.dialogs.IconPickerDialogFragment;
|
import com.kunzisoft.keepass.dialogs.IconPickerDialogFragment;
|
||||||
import com.kunzisoft.keepass.icon.classic.Icons;
|
import com.kunzisoft.keepass.icons.IconPackChooser;
|
||||||
import com.kunzisoft.keepass.settings.PreferencesUtil;
|
import com.kunzisoft.keepass.settings.PreferencesUtil;
|
||||||
import com.kunzisoft.keepass.tasks.ProgressTask;
|
import com.kunzisoft.keepass.tasks.ProgressTask;
|
||||||
import com.kunzisoft.keepass.utils.MenuUtil;
|
import com.kunzisoft.keepass.utils.MenuUtil;
|
||||||
@@ -315,7 +315,7 @@ public class EntryEditActivity extends LockingHideActivity
|
|||||||
|
|
||||||
protected void fillData() {
|
protected void fillData() {
|
||||||
ImageButton currIconButton = findViewById(R.id.icon_button);
|
ImageButton currIconButton = findViewById(R.id.icon_button);
|
||||||
App.getDB().getDrawFactory().assignDrawableTo(currIconButton, getResources(), mEntry.getIcon());
|
App.getDB().getDrawFactory().assignDrawableTo(this, currIconButton, mEntry.getIcon());
|
||||||
|
|
||||||
// Don't start the field reference manager, we want to see the raw ref
|
// Don't start the field reference manager, we want to see the raw ref
|
||||||
mEntry.endToManageFieldReferences();
|
mEntry.endToManageFieldReferences();
|
||||||
@@ -351,7 +351,7 @@ public class EntryEditActivity extends LockingHideActivity
|
|||||||
public void iconPicked(Bundle bundle) {
|
public void iconPicked(Bundle bundle) {
|
||||||
mSelectedIconID = bundle.getInt(IconPickerDialogFragment.KEY_ICON_ID);
|
mSelectedIconID = bundle.getInt(IconPickerDialogFragment.KEY_ICON_ID);
|
||||||
ImageButton currIconButton = findViewById(R.id.icon_button);
|
ImageButton currIconButton = findViewById(R.id.icon_button);
|
||||||
currIconButton.setImageResource(Icons.iconToResId(mSelectedIconID));
|
currIconButton.setImageResource(IconPackChooser.getDefaultIconPack(this).iconToResId(mSelectedIconID));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ public class GroupActivity extends ListNodesActivity
|
|||||||
protected void setGroupIcon() {
|
protected void setGroupIcon() {
|
||||||
if (mCurrentGroup != null) {
|
if (mCurrentGroup != null) {
|
||||||
ImageView iv = findViewById(R.id.icon);
|
ImageView iv = findViewById(R.id.icon);
|
||||||
App.getDB().getDrawFactory().assignDrawableTo(iv, getResources(), mCurrentGroup.getIcon());
|
App.getDB().getDrawFactory().assignDrawableTo(this, iv, mCurrentGroup.getIcon());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -175,8 +175,7 @@ public class NodeAdapter extends RecyclerView.Adapter<BasicViewHolder> {
|
|||||||
public void onBindViewHolder(BasicViewHolder holder, int position) {
|
public void onBindViewHolder(BasicViewHolder holder, int position) {
|
||||||
PwNode subNode = nodeSortedList.get(position);
|
PwNode subNode = nodeSortedList.get(position);
|
||||||
// Assign image
|
// Assign image
|
||||||
App.getDB().getDrawFactory().assignDrawableTo(holder.icon,
|
App.getDB().getDrawFactory().assignDrawableTo(context, holder.icon, subNode.getIcon());
|
||||||
context.getResources(), subNode.getIcon());
|
|
||||||
// Assign text
|
// Assign text
|
||||||
holder.text.setText(subNode.getDisplayTitle());
|
holder.text.setText(subNode.getDisplayTitle());
|
||||||
// Assign click
|
// Assign click
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import com.kunzisoft.keepass.R;
|
import com.kunzisoft.keepass.R;
|
||||||
import com.kunzisoft.keepass.database.PwNode;
|
import com.kunzisoft.keepass.database.PwNode;
|
||||||
import com.kunzisoft.keepass.icon.classic.Icons;
|
import com.kunzisoft.keepass.icons.IconPackChooser;
|
||||||
|
|
||||||
public class GroupEditDialogFragment extends DialogFragment
|
public class GroupEditDialogFragment extends DialogFragment
|
||||||
implements IconPickerDialogFragment.IconPickerListener {
|
implements IconPickerDialogFragment.IconPickerListener {
|
||||||
@@ -131,7 +131,7 @@ public class GroupEditDialogFragment extends DialogFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void populateIcon(int iconId) {
|
private void populateIcon(int iconId) {
|
||||||
iconButton.setImageResource(Icons.iconToResId(iconId));
|
iconButton.setImageResource(IconPackChooser.getDefaultIconPack(getContext()).iconToResId(iconId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -33,13 +33,15 @@ import android.widget.GridView;
|
|||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import com.kunzisoft.keepass.R;
|
import com.kunzisoft.keepass.R;
|
||||||
import com.kunzisoft.keepass.icon.classic.Icons;
|
import com.kunzisoft.keepass.icons.IconPack;
|
||||||
|
import com.kunzisoft.keepass.icons.IconPackChooser;
|
||||||
import com.kunzisoft.keepass.stylish.StylishActivity;
|
import com.kunzisoft.keepass.stylish.StylishActivity;
|
||||||
|
|
||||||
|
|
||||||
public class IconPickerDialogFragment extends DialogFragment {
|
public class IconPickerDialogFragment extends DialogFragment {
|
||||||
public static final String KEY_ICON_ID = "icon_id";
|
public static final String KEY_ICON_ID = "icon_id";
|
||||||
private IconPickerListener iconPickerListener;
|
private IconPickerListener iconPickerListener;
|
||||||
|
private IconPack iconPack;
|
||||||
|
|
||||||
public static void launch(StylishActivity activity) {
|
public static void launch(StylishActivity activity) {
|
||||||
// Create an instance of the dialog fragment and show it
|
// Create an instance of the dialog fragment and show it
|
||||||
@@ -66,6 +68,8 @@ public class IconPickerDialogFragment extends DialogFragment {
|
|||||||
// Get the layout inflater
|
// Get the layout inflater
|
||||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||||
|
|
||||||
|
iconPack = IconPackChooser.getDefaultIconPack(getContext());
|
||||||
|
|
||||||
// Inflate and set the layout for the dialog
|
// Inflate and set the layout for the dialog
|
||||||
// Pass null as the parent view because its going in the dialog layout
|
// Pass null as the parent view because its going in the dialog layout
|
||||||
View root = inflater.inflate(R.layout.icon_picker, null);
|
View root = inflater.inflate(R.layout.icon_picker, null);
|
||||||
@@ -96,7 +100,7 @@ public class IconPickerDialogFragment extends DialogFragment {
|
|||||||
|
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
/* Return number of KeePass icons */
|
/* Return number of KeePass icons */
|
||||||
return Icons.count();
|
return iconPack.numberOfIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getItem(int position) {
|
public Object getItem(int position) {
|
||||||
@@ -118,7 +122,7 @@ public class IconPickerDialogFragment extends DialogFragment {
|
|||||||
currView = convertView;
|
currView = convertView;
|
||||||
}
|
}
|
||||||
ImageView iv = currView.findViewById(R.id.icon_image);
|
ImageView iv = currView.findViewById(R.id.icon_image);
|
||||||
iv.setImageResource(Icons.iconToResId(position));
|
iv.setImageResource(iconPack.iconToResId(position));
|
||||||
|
|
||||||
return currView;
|
return currView;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.kunzisoft.keepass.icons;
|
package com.kunzisoft.keepass.icons;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
@@ -32,7 +33,6 @@ import com.kunzisoft.keepass.compat.BitmapDrawableCompat;
|
|||||||
import com.kunzisoft.keepass.database.PwIcon;
|
import com.kunzisoft.keepass.database.PwIcon;
|
||||||
import com.kunzisoft.keepass.database.PwIconCustom;
|
import com.kunzisoft.keepass.database.PwIconCustom;
|
||||||
import com.kunzisoft.keepass.database.PwIconStandard;
|
import com.kunzisoft.keepass.database.PwIconStandard;
|
||||||
import com.kunzisoft.keepass.icon.classic.Icons;
|
|
||||||
|
|
||||||
import org.apache.commons.collections.map.AbstractReferenceMap;
|
import org.apache.commons.collections.map.AbstractReferenceMap;
|
||||||
import org.apache.commons.collections.map.ReferenceMap;
|
import org.apache.commons.collections.map.ReferenceMap;
|
||||||
@@ -54,17 +54,17 @@ public class DrawableFactory {
|
|||||||
*/
|
*/
|
||||||
private ReferenceMap standardIconMap = new ReferenceMap(AbstractReferenceMap.HARD, AbstractReferenceMap.WEAK);
|
private ReferenceMap standardIconMap = new ReferenceMap(AbstractReferenceMap.HARD, AbstractReferenceMap.WEAK);
|
||||||
|
|
||||||
public void assignDrawableTo(ImageView iv, Resources res, PwIcon icon) {
|
public void assignDrawableTo(Context context, ImageView iv, PwIcon icon) {
|
||||||
Drawable draw = getIconDrawable(res, icon);
|
Drawable draw = getIconDrawable(context, icon);
|
||||||
if (iv != null && draw != null)
|
if (iv != null && draw != null)
|
||||||
iv.setImageDrawable(draw);
|
iv.setImageDrawable(draw);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Drawable getIconDrawable(Resources res, PwIcon icon) {
|
public Drawable getIconDrawable(Context context, PwIcon icon) {
|
||||||
if (icon instanceof PwIconStandard) {
|
if (icon instanceof PwIconStandard) {
|
||||||
return getIconDrawable(res, (PwIconStandard) icon);
|
return getIconDrawable(context, (PwIconStandard) icon);
|
||||||
} else {
|
} else {
|
||||||
return getIconDrawable(res, (PwIconCustom) icon);
|
return getIconDrawable(context, (PwIconCustom) icon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,20 +77,20 @@ public class DrawableFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Drawable getIconDrawable(Resources res, PwIconStandard icon) {
|
private Drawable getIconDrawable(Context context, PwIconStandard icon) {
|
||||||
int resId = Icons.iconToResId(icon.iconId);
|
int resId = IconPackChooser.getDefaultIconPack(context).iconToResId(icon.iconId);
|
||||||
|
|
||||||
Drawable draw = (Drawable) standardIconMap.get(resId);
|
Drawable draw = (Drawable) standardIconMap.get(resId);
|
||||||
if (draw == null) {
|
if (draw == null) {
|
||||||
draw = res.getDrawable(resId);
|
draw = context.getResources().getDrawable(resId);
|
||||||
standardIconMap.put(resId, draw);
|
standardIconMap.put(resId, draw);
|
||||||
}
|
}
|
||||||
|
|
||||||
return draw;
|
return draw;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Drawable getIconDrawable(Resources res, PwIconCustom icon) {
|
private Drawable getIconDrawable(Context context, PwIconCustom icon) {
|
||||||
initBlank(res);
|
initBlank(context.getResources());
|
||||||
if (icon == null) {
|
if (icon == null) {
|
||||||
return blank;
|
return blank;
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ public class DrawableFactory {
|
|||||||
|
|
||||||
bitmap = resize(bitmap);
|
bitmap = resize(bitmap);
|
||||||
|
|
||||||
draw = BitmapDrawableCompat.getBitmapDrawable(res, bitmap);
|
draw = BitmapDrawableCompat.getBitmapDrawable(context.getResources(), bitmap);
|
||||||
customIconMap.put(icon.uuid, draw);
|
customIconMap.put(icon.uuid, draw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
65
app/src/main/java/com/kunzisoft/keepass/icons/IconPack.java
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* 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.icons;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.util.SparseIntArray;
|
||||||
|
|
||||||
|
import com.kunzisoft.keepass.R;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
|
public class IconPack {
|
||||||
|
|
||||||
|
private static final int NB_ICONS = 68;
|
||||||
|
|
||||||
|
private static SparseIntArray icons = null;
|
||||||
|
|
||||||
|
private Resources resources;
|
||||||
|
|
||||||
|
IconPack(Context context) {
|
||||||
|
|
||||||
|
resources = context.getResources();
|
||||||
|
int num = 0;
|
||||||
|
icons = new SparseIntArray();
|
||||||
|
while(num < NB_ICONS) {
|
||||||
|
String drawableId = "ic" + new DecimalFormat("00").format(num);
|
||||||
|
int resId = resources.getIdentifier(drawableId, "drawable", context.getPackageName());
|
||||||
|
icons.put(num, resId);
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int numberOfIcons() {
|
||||||
|
return icons.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int iconToResId(int iconId) {
|
||||||
|
return icons.get(iconId, com.kunzisoft.keepass.icon.classic.R.drawable.ic99_blank); // TODO change
|
||||||
|
}
|
||||||
|
|
||||||
|
public Drawable getDrawable(int iconId) {
|
||||||
|
return resources.getDrawable(iconId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package com.kunzisoft.keepass.icons;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.kunzisoft.keepass.BuildConfig;
|
||||||
|
import com.kunzisoft.keepass.R;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility class to select an IconPack
|
||||||
|
*/
|
||||||
|
public class IconPackChooser {
|
||||||
|
|
||||||
|
private static final String TAG = IconPackChooser.class.getName();
|
||||||
|
|
||||||
|
private static List<IconPack> iconPackList = new ArrayList<>();
|
||||||
|
|
||||||
|
private static volatile IconPackChooser sIconPackBuilder;
|
||||||
|
|
||||||
|
private IconPackChooser(){
|
||||||
|
if (sIconPackBuilder != null){
|
||||||
|
throw new RuntimeException("Use build() method to get the single instance of this class.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IconPackChooser build(Context context) {
|
||||||
|
if (sIconPackBuilder == null) { //if there is no instance available... create new one
|
||||||
|
synchronized (IconPackChooser.class) {
|
||||||
|
if (sIconPackBuilder == null) {
|
||||||
|
sIconPackBuilder = new IconPackChooser();
|
||||||
|
if (BuildConfig.FULL_VERSION)
|
||||||
|
try {
|
||||||
|
iconPackList.add(new IconPack(context));
|
||||||
|
// Do something
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "Icon pack can't be load", e);
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sIconPackBuilder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IconPack getDefaultIconPack(Context context) {
|
||||||
|
build(context);
|
||||||
|
return iconPackList.get(0);
|
||||||
|
/*
|
||||||
|
try {
|
||||||
|
return iconPackList.get(0);
|
||||||
|
} catch (IndexOutOfBoundsException e) {
|
||||||
|
//throw new IconPackUnknownException(); TODO exception
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.kunzisoft.keepass.icons;
|
||||||
|
|
||||||
|
public class IconPackUnknownException extends Exception{
|
||||||
|
|
||||||
|
IconPackUnknownException() {
|
||||||
|
super("Icon pack isn't defined");
|
||||||
|
}
|
||||||
|
}
|
||||||
1
classiciconpack/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
/build
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
apply plugin: 'com.android.library'
|
|
||||||
|
|
||||||
android {
|
|
||||||
compileSdkVersion 27
|
|
||||||
|
|
||||||
defaultConfig {
|
|
||||||
minSdkVersion 14
|
|
||||||
targetSdkVersion 27
|
|
||||||
versionCode 1
|
|
||||||
versionName "1.0"
|
|
||||||
|
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
buildTypes {
|
|
||||||
release {
|
|
||||||
minifyEnabled false
|
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
android {
|
|
||||||
resourcePrefix 'kunzisoft_keepass_icon'
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
||||||
|
|
||||||
implementation 'com.android.support:appcompat-v7:27.1.0'
|
|
||||||
testImplementation 'junit:junit:4.12'
|
|
||||||
androidTestImplementation 'com.android.support.test:runner:1.0.1'
|
|
||||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
|
|
||||||
}
|
|
||||||
21
classiciconpack/proguard-rules.pro
vendored
@@ -1,21 +0,0 @@
|
|||||||
# Add project specific ProGuard rules here.
|
|
||||||
# You can control the set of applied configuration files using the
|
|
||||||
# proguardFiles setting in build.gradle.
|
|
||||||
#
|
|
||||||
# For more details, see
|
|
||||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
||||||
|
|
||||||
# If your project uses WebView with JS, uncomment the following
|
|
||||||
# and specify the fully qualified class name to the JavaScript interface
|
|
||||||
# class:
|
|
||||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
|
||||||
# public *;
|
|
||||||
#}
|
|
||||||
|
|
||||||
# Uncomment this to preserve the line number information for
|
|
||||||
# debugging stack traces.
|
|
||||||
#-keepattributes SourceFile,LineNumberTable
|
|
||||||
|
|
||||||
# If you keep the line number information, uncomment this to
|
|
||||||
# hide the original source file name.
|
|
||||||
#-renamesourcefileattribute SourceFile
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package com.kunzisoft.keepass.icon.classic;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.support.test.InstrumentationRegistry;
|
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instrumented test, which will execute on an Android device.
|
|
||||||
*
|
|
||||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
|
||||||
*/
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
public class ExampleInstrumentedTest {
|
|
||||||
@Test
|
|
||||||
public void useAppContext() {
|
|
||||||
// Context of the app under test.
|
|
||||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
|
||||||
|
|
||||||
assertEquals("com.kunzisoft.keepass.icon.classic.test", appContext.getPackageName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,74 +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.icon.classic;
|
|
||||||
|
|
||||||
import android.util.SparseIntArray;
|
|
||||||
|
|
||||||
import com.kunzisoft.keepass.icon.classic.R;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
|
|
||||||
public class Icons {
|
|
||||||
private static SparseIntArray icons = null;
|
|
||||||
|
|
||||||
private static void buildList() {
|
|
||||||
if (icons == null) {
|
|
||||||
icons = new SparseIntArray();
|
|
||||||
|
|
||||||
Class<com.kunzisoft.keepass.icon.classic.R.drawable> c = com.kunzisoft.keepass.icon.classic.R.drawable.class;
|
|
||||||
|
|
||||||
Field[] fields = c.getFields();
|
|
||||||
|
|
||||||
for (Field field : fields) {
|
|
||||||
String fieldName = field.getName();
|
|
||||||
if (fieldName.matches("ic\\d{2}.*")) {
|
|
||||||
String sNum = fieldName.substring(2, 4);
|
|
||||||
int num = Integer.parseInt(sNum);
|
|
||||||
if (num > 69) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int resId;
|
|
||||||
try {
|
|
||||||
resId = field.getInt(null);
|
|
||||||
} catch (Exception e) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
icons.put(num, resId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int iconToResId(int iconId) {
|
|
||||||
buildList();
|
|
||||||
|
|
||||||
return icons.get(iconId, R.drawable.ic99_blank);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int count() {
|
|
||||||
buildList();
|
|
||||||
|
|
||||||
return icons.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
<resources>
|
|
||||||
<string name="app_name">Classic Icon Pack</string>
|
|
||||||
</resources>
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package com.kunzisoft.keepass.icon.classic;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Example local unit test, which will execute on the development machine (host).
|
|
||||||
*
|
|
||||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
|
||||||
*/
|
|
||||||
public class ExampleUnitTest {
|
|
||||||
@Test
|
|
||||||
public void addition_isCorrect() {
|
|
||||||
assertEquals(4, 2 + 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
21
icon-pack-classic/build.gradle
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
apply plugin: 'com.android.library'
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 27
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
minSdkVersion 14
|
||||||
|
targetSdkVersion 27
|
||||||
|
versionCode 1
|
||||||
|
versionName "1.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resourcePrefix 'classic_'
|
||||||
|
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 773 B After Width: | Height: | Size: 773 B |
|
Before Width: | Height: | Size: 968 B After Width: | Height: | Size: 968 B |
|
Before Width: | Height: | Size: 196 B After Width: | Height: | Size: 196 B |
|
Before Width: | Height: | Size: 1005 B After Width: | Height: | Size: 1005 B |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1000 B After Width: | Height: | Size: 1000 B |