v1.3: group and app browsing, under "smartcard apps"
@@ -7,8 +7,8 @@ android {
|
||||
defaultConfig {
|
||||
applicationId "org.docrj.smartcard.reader"
|
||||
|
||||
versionCode 12
|
||||
versionName "1.2"
|
||||
versionCode 13
|
||||
versionName "1.3"
|
||||
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 21
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
android:theme="@android:style/Theme.NoDisplay" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
@@ -46,9 +45,7 @@
|
||||
android:theme="@android:style/Theme.NoDisplay" >
|
||||
<intent-filter android:priority="999" >
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<data android:mimeType="text/html" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
@@ -0,0 +1,640 @@
|
||||
/*
|
||||
* Copyright 2015 Ryan Jones
|
||||
* Copyright (C) 2014 Gary Guo
|
||||
*
|
||||
* This file was modified from the original source:
|
||||
* https://github.com/idunnololz/AnimatedExpandableListView
|
||||
*
|
||||
* This file is part of smartcard-reader, package org.docrj.smartcard.reader.
|
||||
*
|
||||
* smartcard-reader 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.
|
||||
*
|
||||
* smartcard-reader 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 smartcard-reader. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.docrj.smartcard.reader;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.SparseArray;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.Animation.AnimationListener;
|
||||
import android.view.animation.Transformation;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.BaseExpandableListAdapter;
|
||||
import android.widget.ExpandableListAdapter;
|
||||
import android.widget.ExpandableListView;
|
||||
|
||||
/**
|
||||
* This class defines an ExpandableListView which supports animations for
|
||||
* collapsing and expanding groups.
|
||||
*/
|
||||
public class AnimatedExpandableListView extends ExpandableListView {
|
||||
/*
|
||||
* A detailed explanation for how this class works:
|
||||
*
|
||||
* Animating the ExpandableListView was no easy task. The way that this
|
||||
* class does it is by exploiting how an ExpandableListView works.
|
||||
*
|
||||
* Normally when {@link ExpandableListView#collapseGroup(int)} or
|
||||
* {@link ExpandableListView#expandGroup(int)} is called, the view toggles
|
||||
* the flag for a group and calls notifyDataSetChanged to cause the ListView
|
||||
* to refresh all of it's view. This time however, depending on whether a
|
||||
* group is expanded or collapsed, certain childViews will either be ignored
|
||||
* or added to the list.
|
||||
*
|
||||
* Knowing this, we can come up with a way to animate our views. For
|
||||
* instance for group expansion, we tell the adapter to animate the
|
||||
* children of a certain group. We then expand the group which causes the
|
||||
* ExpandableListView to refresh all views on screen. The way that
|
||||
* ExpandableListView does this is by calling getView() in the adapter.
|
||||
* However since the adapter knows that we are animating a certain group,
|
||||
* instead of returning the real views for the children of the group being
|
||||
* animated, it will return a fake dummy view. This dummy view will then
|
||||
* draw the real child views within it's dispatchDraw function. The reason
|
||||
* we do this is so that we can animate all of it's children by simply
|
||||
* animating the dummy view. After we complete the animation, we tell the
|
||||
* adapter to stop animating the group and call notifyDataSetChanged. Now
|
||||
* the ExpandableListView is forced to refresh it's views again, except this
|
||||
* time, it will get the real views for the expanded group.
|
||||
*
|
||||
* So, to list it all out, when {@link #expandGroupWithAnimation(int)} is
|
||||
* called the following happens:
|
||||
*
|
||||
* 1. The ExpandableListView tells the adapter to animate a certain group.
|
||||
* 2. The ExpandableListView calls expandGroup.
|
||||
* 3. ExpandGroup calls notifyDataSetChanged.
|
||||
* 4. As an result, getChildView is called for expanding group.
|
||||
* 5. Since the adapter is in "animating mode", it will return a dummy view.
|
||||
* 6. This dummy view draws the actual children of the expanding group.
|
||||
* 7. This dummy view's height is animated from 0 to it's expanded height.
|
||||
* 8. Once the animation completes, the adapter is notified to stop
|
||||
* animating the group and notifyDataSetChanged is called again.
|
||||
* 9. This forces the ExpandableListView to refresh all of it's views again.
|
||||
* 10.This time when getChildView is called, it will return the actual
|
||||
* child views.
|
||||
*
|
||||
* For animating the collapse of a group is a bit more difficult since we
|
||||
* can't call collapseGroup from the start as it would just ignore the
|
||||
* child memberApps, giving up no chance to do any sort of animation. Instead
|
||||
* what we have to do is play the animation first and call collapseGroup
|
||||
* after the animation is done.
|
||||
*
|
||||
* So, to list it all out, when {@link #collapseGroupWithAnimation(int)} is
|
||||
* called the following happens:
|
||||
*
|
||||
* 1. The ExpandableListView tells the adapter to animate a certain group.
|
||||
* 2. The ExpandableListView calls notifyDataSetChanged.
|
||||
* 3. As an result, getChildView is called for expanding group.
|
||||
* 4. Since the adapter is in "animating mode", it will return a dummy view.
|
||||
* 5. This dummy view draws the actual children of the expanding group.
|
||||
* 6. This dummy view's height is animated from it's current height to 0.
|
||||
* 7. Once the animation completes, the adapter is notified to stop
|
||||
* animating the group and notifyDataSetChanged is called again.
|
||||
* 8. collapseGroup is finally called.
|
||||
* 9. This forces the ExpandableListView to refresh all of it's views again.
|
||||
* 10.This time when the ListView will not get any of the child views for
|
||||
* the collapsed group.
|
||||
*/
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static final String TAG = AnimatedExpandableListAdapter.class.getSimpleName();
|
||||
|
||||
/**
|
||||
* The duration of the expand/collapse animations
|
||||
*/
|
||||
private static final int ANIMATION_DURATION = 300;
|
||||
|
||||
private AnimatedExpandableListAdapter adapter;
|
||||
|
||||
public AnimatedExpandableListView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public AnimatedExpandableListView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public AnimatedExpandableListView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ExpandableListView#setAdapter(ExpandableListAdapter)
|
||||
*/
|
||||
public void setAdapter(ExpandableListAdapter adapter) {
|
||||
super.setAdapter(adapter);
|
||||
|
||||
// Make sure that the adapter extends AnimatedExpandableListAdapter
|
||||
if(adapter instanceof AnimatedExpandableListAdapter) {
|
||||
this.adapter = (AnimatedExpandableListAdapter) adapter;
|
||||
this.adapter.setParent(this);
|
||||
} else {
|
||||
throw new ClassCastException(adapter.toString() + " must implement AnimatedExpandableListAdapter");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Expands the given group with an animation.
|
||||
* @param groupPos The position of the group to expand
|
||||
* @return Returns true if the group was expanded. False if the group was
|
||||
* already expanded.
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
public boolean expandGroupWithAnimation(int groupPos) {
|
||||
boolean lastGroup = groupPos == adapter.getGroupCount() - 1;
|
||||
if (lastGroup && Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
return expandGroup(groupPos, true);
|
||||
}
|
||||
|
||||
// TODO: removed this block as all seems good without it; it was causing null view
|
||||
// and crash when expanding a group at the bottom of display, when (group - 1) was
|
||||
// expanded with only children showing; in that case, getFirstVisiblePosition() was
|
||||
// larger than groupFlatPos and so childIndex was negative
|
||||
/*
|
||||
int groupFlatPos = getFlatListPosition(getPackedPositionForGroup(groupPos));
|
||||
if (groupFlatPos != -1) {
|
||||
int childIndex = groupFlatPos - getFirstVisiblePosition();
|
||||
if (childIndex < getChildCount()) {
|
||||
// Get the view for the group is it is on screen...
|
||||
View v = getChildAt(childIndex);
|
||||
if (v.getBottom() >= getBottom()) {
|
||||
// If the user is not going to be able to see the animation
|
||||
// we just expand the group without an animation.
|
||||
// This resolves the case where getChildView will not be
|
||||
// called if the children of the group is not on screen
|
||||
|
||||
// We need to notify the adapter that the group was expanded
|
||||
// without it's knowledge
|
||||
adapter.notifyGroupExpanded(groupPos);
|
||||
return expandGroup(groupPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Let the adapter know that we are starting the animation...
|
||||
adapter.startExpandAnimation(groupPos, 0);
|
||||
// Finally call expandGroup (note that expandGroup will call
|
||||
// notifyDataSetChanged so we don't need to)
|
||||
return expandGroup(groupPos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Collapses the given group with an animation.
|
||||
* @param groupPos The position of the group to collapse
|
||||
* @return Returns true if the group was collapsed. False if the group was
|
||||
* already collapsed.
|
||||
*/
|
||||
public boolean collapseGroupWithAnimation(int groupPos) {
|
||||
int groupFlatPos = getFlatListPosition(getPackedPositionForGroup(groupPos));
|
||||
if (groupFlatPos != -1) {
|
||||
int childIndex = groupFlatPos - getFirstVisiblePosition();
|
||||
if (childIndex >= 0 && childIndex < getChildCount()) {
|
||||
// Get the view for the group is it is on screen...
|
||||
View v = getChildAt(childIndex);
|
||||
if (v.getBottom() >= getBottom()) {
|
||||
// If the user is not going to be able to see the animation
|
||||
// we just collapse the group without an animation.
|
||||
// This resolves the case where getChildView will not be
|
||||
// called if the children of the group is not on screen
|
||||
return collapseGroup(groupPos);
|
||||
}
|
||||
} else {
|
||||
// If the group is offscreen, we can just collapse it without an
|
||||
// animation...
|
||||
return collapseGroup(groupPos);
|
||||
}
|
||||
}
|
||||
|
||||
// Get the position of the firstChild visible from the top of the screen
|
||||
long packedPos = getExpandableListPosition(getFirstVisiblePosition());
|
||||
int firstChildPos = getPackedPositionChild(packedPos);
|
||||
int firstGroupPos = getPackedPositionGroup(packedPos);
|
||||
|
||||
// If the first visible view on the screen is a child view AND it's a
|
||||
// child of the group we are trying to collapse, then set that
|
||||
// as the first child position of the group... see
|
||||
// {@link #startCollapseAnimation(int, int)} for why this is necessary
|
||||
firstChildPos = firstChildPos == -1 || firstGroupPos != groupPos ? 0 : firstChildPos;
|
||||
|
||||
// Let the adapter know that we are going to start animating the
|
||||
// collapse animation.
|
||||
adapter.startCollapseAnimation(groupPos, firstChildPos);
|
||||
|
||||
// Force the listview to refresh it's views
|
||||
adapter.notifyDataSetChanged();
|
||||
return isGroupExpanded(groupPos);
|
||||
}
|
||||
|
||||
private int getAnimationDuration() {
|
||||
return ANIMATION_DURATION;
|
||||
}
|
||||
|
||||
public int getFirstVisibleGroup() {
|
||||
int firstVis = getFirstVisiblePosition();
|
||||
long packedPosition = getExpandableListPosition(firstVis);
|
||||
return ExpandableListView.getPackedPositionGroup(packedPosition);
|
||||
}
|
||||
|
||||
public int getLastVisibleGroup() {
|
||||
int lastVis = getLastVisiblePosition();
|
||||
long packedPosition = getExpandableListPosition(lastVis);
|
||||
return ExpandableListView.getPackedPositionGroup(packedPosition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for holding information regarding the group.
|
||||
*/
|
||||
private static class GroupInfo {
|
||||
boolean animating = false;
|
||||
boolean expanding = false;
|
||||
int firstChildPosition;
|
||||
|
||||
/**
|
||||
* This variable contains the last known height value of the dummy view.
|
||||
* We save this information so that if the user collapses a group
|
||||
* before it fully expands, the collapse animation will start from the
|
||||
* CURRENT height of the dummy view and not from the full expanded
|
||||
* height.
|
||||
*/
|
||||
int dummyHeight = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* A specialized adapter for use with the AnimatedExpandableListView. All
|
||||
* adapters used with AnimatedExpandableListView MUST extend this class.
|
||||
*/
|
||||
public static abstract class AnimatedExpandableListAdapter extends BaseExpandableListAdapter {
|
||||
private SparseArray<GroupInfo> groupInfo = new SparseArray<GroupInfo>();
|
||||
private AnimatedExpandableListView parent;
|
||||
|
||||
private static final int STATE_IDLE = 0;
|
||||
private static final int STATE_EXPANDING = 1;
|
||||
private static final int STATE_COLLAPSING = 2;
|
||||
|
||||
private void setParent(AnimatedExpandableListView parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public int getRealChildType(int groupPosition, int childPosition) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getRealChildTypeCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public abstract View getRealChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent);
|
||||
public abstract int getRealChildrenCount(int groupPosition);
|
||||
|
||||
private GroupInfo getGroupInfo(int groupPosition) {
|
||||
GroupInfo info = groupInfo.get(groupPosition);
|
||||
if (info == null) {
|
||||
info = new GroupInfo();
|
||||
groupInfo.put(groupPosition, info);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
public void notifyGroupExpanded(int groupPosition) {
|
||||
GroupInfo info = getGroupInfo(groupPosition);
|
||||
info.dummyHeight = -1;
|
||||
}
|
||||
|
||||
private void startExpandAnimation(int groupPosition, int firstChildPosition) {
|
||||
GroupInfo info = getGroupInfo(groupPosition);
|
||||
info.animating = true;
|
||||
info.firstChildPosition = firstChildPosition;
|
||||
info.expanding = true;
|
||||
}
|
||||
|
||||
private void startCollapseAnimation(int groupPosition, int firstChildPosition) {
|
||||
GroupInfo info = getGroupInfo(groupPosition);
|
||||
info.animating = true;
|
||||
info.firstChildPosition = firstChildPosition;
|
||||
info.expanding = false;
|
||||
}
|
||||
|
||||
private void stopAnimation(int groupPosition) {
|
||||
GroupInfo info = getGroupInfo(groupPosition);
|
||||
info.animating = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override {@link #getRealChildType(int, int)} instead.
|
||||
*/
|
||||
@Override
|
||||
public final int getChildType(int groupPosition, int childPosition) {
|
||||
GroupInfo info = getGroupInfo(groupPosition);
|
||||
if (info.animating) {
|
||||
// If we are animating this group, then all of it's children
|
||||
// are going to be dummy views which we will say is type 0.
|
||||
return 0;
|
||||
} else {
|
||||
// If we are not animating this group, then we will add 1 to
|
||||
// the type it has so that no type id conflicts will occur
|
||||
// unless getRealChildType() returns MAX_INT
|
||||
return getRealChildType(groupPosition, childPosition) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Override {@link #getRealChildTypeCount()} instead.
|
||||
*/
|
||||
@Override
|
||||
public final int getChildTypeCount() {
|
||||
// Return 1 more than the childTypeCount to account for DummyView
|
||||
return getRealChildTypeCount() + 1;
|
||||
}
|
||||
|
||||
protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
|
||||
return new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override {@link #getChildView(int, int, boolean, View, ViewGroup)} instead.
|
||||
*/
|
||||
@Override
|
||||
public final View getChildView(final int groupPosition, int childPosition, boolean isLastChild, View convertView, final ViewGroup parent) {
|
||||
final GroupInfo info = getGroupInfo(groupPosition);
|
||||
|
||||
if (info.animating) {
|
||||
// If this group is animating, return the a DummyView...
|
||||
if (convertView instanceof DummyView == false) {
|
||||
convertView = new DummyView(parent.getContext());
|
||||
convertView.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, 0));
|
||||
}
|
||||
|
||||
if (childPosition < info.firstChildPosition) {
|
||||
// The reason why we do this is to support the collapse
|
||||
// this group when the group view is not visible but the
|
||||
// children of this group are. When notifyDataSetChanged
|
||||
// is called, the ExpandableListView tries to keep the
|
||||
// list position the same by saving the first visible item
|
||||
// and jumping back to that item after the views have been
|
||||
// refreshed. Now the problem is, if a group has 2 memberApps
|
||||
// and the first visible item is the 2nd child of the group
|
||||
// and this group is collapsed, then the dummy view will be
|
||||
// used for the group. But now the group only has 1 item
|
||||
// which is the dummy view, thus when the ListView is trying
|
||||
// to restore the scroll position, it will try to jump to
|
||||
// the second item of the group. But this group no longer
|
||||
// has a second item, so it is forced to jump to the next
|
||||
// group. This will cause a very ugly visual glitch. So
|
||||
// the way that we counteract this is by creating as many
|
||||
// dummy views as we need to maintain the scroll position
|
||||
// of the ListView after notifyDataSetChanged has been
|
||||
// called.
|
||||
convertView.getLayoutParams().height = 0;
|
||||
return convertView;
|
||||
}
|
||||
|
||||
final ExpandableListView listView = (ExpandableListView) parent;
|
||||
|
||||
final DummyView dummyView = (DummyView) convertView;
|
||||
|
||||
// Clear the views that the dummy view draws.
|
||||
dummyView.clearViews();
|
||||
|
||||
// Set the style of the divider
|
||||
dummyView.setDivider(listView.getDivider(), parent.getMeasuredWidth(), listView.getDividerHeight());
|
||||
|
||||
// Make measure specs to measure child views
|
||||
final int measureSpecW = MeasureSpec.makeMeasureSpec(parent.getWidth(), MeasureSpec.EXACTLY);
|
||||
final int measureSpecH = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
|
||||
|
||||
int totalHeight = 0;
|
||||
int clipHeight = parent.getHeight();
|
||||
|
||||
final int len = getRealChildrenCount(groupPosition);
|
||||
for (int i = info.firstChildPosition; i < len; i++) {
|
||||
View childView = getRealChildView(groupPosition, i, (i == len - 1), null, parent);
|
||||
|
||||
LayoutParams p = (LayoutParams) childView.getLayoutParams();
|
||||
if (p == null) {
|
||||
p = (AbsListView.LayoutParams) generateDefaultLayoutParams();
|
||||
childView.setLayoutParams(p);
|
||||
}
|
||||
|
||||
int lpHeight = p.height;
|
||||
|
||||
int childHeightSpec;
|
||||
if (lpHeight > 0) {
|
||||
childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, MeasureSpec.EXACTLY);
|
||||
} else {
|
||||
childHeightSpec = measureSpecH;
|
||||
}
|
||||
|
||||
childView.measure(measureSpecW, childHeightSpec);
|
||||
totalHeight += childView.getMeasuredHeight();
|
||||
|
||||
if (totalHeight < clipHeight) {
|
||||
// we only need to draw enough views to fool the user...
|
||||
dummyView.addFakeView(childView);
|
||||
} else {
|
||||
dummyView.addFakeView(childView);
|
||||
|
||||
// if this group has too many views, we don't want to
|
||||
// calculate the height of everything... just do a light
|
||||
// approximation and break
|
||||
int averageHeight = totalHeight / (i + 1);
|
||||
totalHeight += (len - i - 1) * averageHeight;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Object o;
|
||||
int state = (o = dummyView.getTag()) == null ? STATE_IDLE : (Integer) o;
|
||||
|
||||
if (info.expanding && state != STATE_EXPANDING) {
|
||||
ExpandAnimation ani = new ExpandAnimation(dummyView, 0, totalHeight, info);
|
||||
ani.setDuration(this.parent.getAnimationDuration());
|
||||
ani.setAnimationListener(new AnimationListener() {
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
stopAnimation(groupPosition);
|
||||
notifyDataSetChanged();
|
||||
dummyView.setTag(STATE_IDLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {}
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {}
|
||||
|
||||
});
|
||||
dummyView.startAnimation(ani);
|
||||
dummyView.setTag(STATE_EXPANDING);
|
||||
} else if (!info.expanding && state != STATE_COLLAPSING) {
|
||||
if (info.dummyHeight == -1) {
|
||||
info.dummyHeight = totalHeight;
|
||||
}
|
||||
|
||||
ExpandAnimation ani = new ExpandAnimation(dummyView, info.dummyHeight, 0, info);
|
||||
ani.setDuration(this.parent.getAnimationDuration());
|
||||
ani.setAnimationListener(new AnimationListener() {
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
stopAnimation(groupPosition);
|
||||
listView.collapseGroup(groupPosition);
|
||||
notifyDataSetChanged();
|
||||
info.dummyHeight = -1;
|
||||
dummyView.setTag(STATE_IDLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {}
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {}
|
||||
|
||||
});
|
||||
dummyView.startAnimation(ani);
|
||||
dummyView.setTag(STATE_COLLAPSING);
|
||||
}
|
||||
|
||||
return convertView;
|
||||
} else {
|
||||
return getRealChildView(groupPosition, childPosition, isLastChild, convertView, parent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getChildrenCount(int groupPosition) {
|
||||
GroupInfo info = getGroupInfo(groupPosition);
|
||||
if (info.animating) {
|
||||
return info.firstChildPosition + 1;
|
||||
} else {
|
||||
return getRealChildrenCount(groupPosition);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class DummyView extends View {
|
||||
private List<View> views = new ArrayList<View>();
|
||||
private Drawable divider;
|
||||
private int dividerWidth;
|
||||
private int dividerHeight;
|
||||
|
||||
public DummyView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public void setDivider(Drawable divider, int dividerWidth, int dividerHeight) {
|
||||
if(divider != null) {
|
||||
this.divider = divider;
|
||||
this.dividerWidth = dividerWidth;
|
||||
this.dividerHeight = dividerHeight;
|
||||
|
||||
divider.setBounds(0, 0, dividerWidth, dividerHeight);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a view for the DummyView to draw.
|
||||
* @param childView View to draw
|
||||
*/
|
||||
public void addFakeView(View childView) {
|
||||
childView.layout(0, 0, getWidth(), childView.getMeasuredHeight());
|
||||
views.add(childView);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
final int len = views.size();
|
||||
for(int i = 0; i < len; i++) {
|
||||
View v = views.get(i);
|
||||
v.layout(left, top, left + v.getMeasuredWidth(), top + v.getMeasuredHeight());
|
||||
}
|
||||
}
|
||||
|
||||
public void clearViews() {
|
||||
views.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispatchDraw(Canvas canvas) {
|
||||
canvas.save();
|
||||
if(divider != null) {
|
||||
divider.setBounds(0, 0, dividerWidth, dividerHeight);
|
||||
}
|
||||
|
||||
final int len = views.size();
|
||||
for(int i = 0; i < len; i++) {
|
||||
View v = views.get(i);
|
||||
|
||||
canvas.save();
|
||||
canvas.clipRect(0, 0, getWidth(), v.getMeasuredHeight());
|
||||
v.draw(canvas);
|
||||
canvas.restore();
|
||||
|
||||
if(divider != null) {
|
||||
divider.draw(canvas);
|
||||
canvas.translate(0, dividerHeight);
|
||||
}
|
||||
|
||||
canvas.translate(0, v.getMeasuredHeight());
|
||||
}
|
||||
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
|
||||
private static class ExpandAnimation extends Animation {
|
||||
private int baseHeight;
|
||||
private int delta;
|
||||
private View view;
|
||||
private GroupInfo groupInfo;
|
||||
|
||||
private ExpandAnimation(View v, int startHeight, int endHeight, GroupInfo info) {
|
||||
baseHeight = startHeight;
|
||||
delta = endHeight - startHeight;
|
||||
view = v;
|
||||
groupInfo = info;
|
||||
|
||||
view.getLayoutParams().height = startHeight;
|
||||
view.requestLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||
super.applyTransformation(interpolatedTime, t);
|
||||
if (interpolatedTime < 1.0f) {
|
||||
int val = baseHeight + (int) (delta * interpolatedTime);
|
||||
view.getLayoutParams().height = val;
|
||||
groupInfo.dummyHeight = val;
|
||||
view.requestLayout();
|
||||
} else {
|
||||
int val = baseHeight + delta;
|
||||
view.getLayoutParams().height = val;
|
||||
groupInfo.dummyHeight = val;
|
||||
view.requestLayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,8 +49,10 @@ import com.google.gson.reflect.TypeToken;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class AppEditActivity extends ActionBarActivity {
|
||||
@@ -73,7 +75,13 @@ public class AppEditActivity extends ActionBarActivity {
|
||||
private SharedPreferences.Editor mEditor;
|
||||
private ArrayList<SmartcardApp> mApps;
|
||||
private String mAction;
|
||||
private int mAppPos;
|
||||
private int mAppPos; // app select pos
|
||||
|
||||
private List<String> mSortedAllGroups;
|
||||
private int mSelectedGrpPos; // batch select group idx
|
||||
private String mSelectedGrpName;
|
||||
private int mExpandedGrpPos; // app browse group idx
|
||||
private String mExpandedGrpName;
|
||||
|
||||
private EditText mName;
|
||||
private EditText mAid;
|
||||
@@ -85,7 +93,7 @@ public class AppEditActivity extends ActionBarActivity {
|
||||
private HashSet<String> mAppGroups;
|
||||
|
||||
private Button mGrpButton;
|
||||
// group items for the popup window list adapter
|
||||
// group memberApps for the popup window list adapter
|
||||
private ArrayList<GroupItem> mGrpItems = new ArrayList<>();
|
||||
private GroupAdapter mGrpAdapter;
|
||||
private ListPopupWindow mPopup;
|
||||
@@ -136,14 +144,24 @@ public class AppEditActivity extends ActionBarActivity {
|
||||
Type collectionType = new TypeToken<LinkedHashSet<String>>() {
|
||||
}.getType();
|
||||
mUserGroups = gson.fromJson(json, collectionType);
|
||||
// here we do not need the default groups payment/other
|
||||
//mUserGroups.removeAll(Arrays.asList(DEFAULT_GROUPS));
|
||||
}
|
||||
} else {
|
||||
mUserGroups =
|
||||
new LinkedHashSet<>(savedInstanceState.getStringArrayList("user_groups"));
|
||||
}
|
||||
|
||||
// alphabetize, case insensitive
|
||||
mSortedAllGroups = new ArrayList<>(mUserGroups);
|
||||
mSortedAllGroups.addAll(Arrays.asList(DEFAULT_GROUPS));
|
||||
Collections.sort(mSortedAllGroups, String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
// when adding or removing groups, we may need to adjust group position indices for
|
||||
// batch select and app browse activities, which apply to the sorted list of groups
|
||||
mSelectedGrpPos = ss.getInt("selected_grp_pos", 0);
|
||||
mSelectedGrpName = mSortedAllGroups.get(mSelectedGrpPos);
|
||||
mExpandedGrpPos = ss.getInt("expanded_grp_pos", -1);
|
||||
mExpandedGrpName = (mExpandedGrpPos == -1) ? "" : mSortedAllGroups.get(mExpandedGrpPos);
|
||||
|
||||
Intent intent = getIntent();
|
||||
mAction = intent.getAction();
|
||||
mAppPos = intent.getIntExtra(EXTRA_APP_POS, NEW_APP_POS);
|
||||
@@ -159,6 +177,7 @@ public class AppEditActivity extends ActionBarActivity {
|
||||
mType.check((app.getType() == SmartcardApp.TYPE_OTHER) ? R.id.radio_other
|
||||
: R.id.radio_payment);
|
||||
}
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
if (ACTION_EDIT_APP.equals(mAction) || ACTION_COPY_APP.equals(mAction)) {
|
||||
SmartcardApp app = mApps.get(mAppPos);
|
||||
@@ -305,6 +324,15 @@ public class AppEditActivity extends ActionBarActivity {
|
||||
if (!newApp.equals(app)) {
|
||||
appChanged = true;
|
||||
mApps.set(mAppPos, newApp);
|
||||
|
||||
if (!newApp.getGroups().equals(app.getGroups())) {
|
||||
for (String group : app.getGroups()) {
|
||||
// remove group if empty
|
||||
if (Util.isGroupEmpty(group, mApps)) {
|
||||
removeGroup(group);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,14 +355,17 @@ public class AppEditActivity extends ActionBarActivity {
|
||||
}
|
||||
|
||||
private void writePrefs() {
|
||||
// serialize list of SmartcardApp
|
||||
// serialize list of apps
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(mApps);
|
||||
mEditor.putString("apps", json);
|
||||
|
||||
// TODO: check this. shouldn't we store defaults: payment/other
|
||||
// serialize hash set of user-added groups
|
||||
json = gson.toJson(mUserGroups);
|
||||
mEditor.putString("groups", json);
|
||||
// selected group in batch select mode
|
||||
mEditor.putInt("selected_grp_pos", mSelectedGrpPos);
|
||||
// expanded group in app browse
|
||||
mEditor.putInt("expanded_grp_pos", mExpandedGrpPos);
|
||||
mEditor.commit();
|
||||
}
|
||||
|
||||
@@ -378,11 +409,49 @@ public class AppEditActivity extends ActionBarActivity {
|
||||
}
|
||||
mAppGroups.add(name);
|
||||
mUserGroups.add(name);
|
||||
// if inserting alphabetically "smaller" group name,
|
||||
// then adjust the saved group position indices
|
||||
if (name.compareTo(mSelectedGrpName) < 0) {
|
||||
mSelectedGrpPos++;
|
||||
mSelectedGrpName = mSortedAllGroups.get(mSelectedGrpPos);
|
||||
}
|
||||
if (name.compareTo(mExpandedGrpName) < 0) {
|
||||
mExpandedGrpPos++;
|
||||
mExpandedGrpName = mSortedAllGroups.get(mExpandedGrpPos);
|
||||
}
|
||||
updateGrpButton();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void removeGroup(String name) {
|
||||
// remove from saved hash set
|
||||
mUserGroups.remove(name);
|
||||
// adjust selected group position indices as needed
|
||||
if (name.equals(mSelectedGrpName)) {
|
||||
// always guaranteed at least two groups: other and payment
|
||||
mSelectedGrpName = (mSelectedGrpPos == 0) ?
|
||||
mSortedAllGroups.get(1) : mSortedAllGroups.get(0);
|
||||
mSelectedGrpPos = 0;
|
||||
} else
|
||||
if (name.compareTo(mSelectedGrpName) < 0) {
|
||||
mSelectedGrpPos--;
|
||||
mSelectedGrpName = mSortedAllGroups.get(mSelectedGrpPos);
|
||||
}
|
||||
// adjust expanded group position index as needed
|
||||
if (name.equals(mExpandedGrpName)) {
|
||||
// no expanded group; all collapsed
|
||||
mExpandedGrpPos = -1;
|
||||
mExpandedGrpName = "";
|
||||
} else
|
||||
if (name.compareTo(mExpandedGrpName) < 0) {
|
||||
mExpandedGrpPos--;
|
||||
mExpandedGrpName = mSortedAllGroups.get(mExpandedGrpPos);
|
||||
}
|
||||
// remove from sorted list
|
||||
mSortedAllGroups.remove(name);
|
||||
}
|
||||
|
||||
public static final class GroupItem {
|
||||
private final String mName;
|
||||
private boolean mChecked;
|
||||
@@ -408,7 +477,7 @@ public class AppEditActivity extends ActionBarActivity {
|
||||
|
||||
private class GroupAdapter extends ArrayAdapter<GroupItem> {
|
||||
public GroupAdapter(Activity context, ArrayList<GroupItem> groupItems) {
|
||||
super(context, R.layout.group_list_item, groupItems);
|
||||
super(context, R.layout.app_edit_group_list_item, groupItems);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -428,15 +497,20 @@ public class AppEditActivity extends ActionBarActivity {
|
||||
return checkedTextView;
|
||||
}
|
||||
|
||||
// list position (count - 2) is reserved for payment/other;
|
||||
// it is informational only and cannot be unchecked
|
||||
@Override
|
||||
public boolean isEnabled(int position) {
|
||||
return position != getCount()-2;
|
||||
}
|
||||
|
||||
// list position (count - 1) is reserved for "new group" action item
|
||||
// does not have a checkbox
|
||||
public boolean hasCheckbox(int position) {
|
||||
return position != getCount()-1;
|
||||
}
|
||||
|
||||
// this is needed for getView() to work as expected
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (hasCheckbox(position)) {
|
||||
@@ -446,6 +520,7 @@ public class AppEditActivity extends ActionBarActivity {
|
||||
}
|
||||
}
|
||||
|
||||
// this is needed for getView() to work as expected
|
||||
@Override
|
||||
public int getViewTypeCount() {
|
||||
return 3;
|
||||
@@ -457,10 +532,9 @@ public class AppEditActivity extends ActionBarActivity {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
ListView list = (ListView) parent;
|
||||
int count = mGrpItems.size();
|
||||
|
||||
if (list.isItemChecked(count - 1)) {
|
||||
list.setItemChecked(count - 1, false);
|
||||
int lastIndex = mGrpItems.size() - 1;
|
||||
if (list.isItemChecked(lastIndex)) {
|
||||
list.setItemChecked(lastIndex, false);
|
||||
createNewGroup();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ package org.docrj.smartcard.reader;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
@@ -69,30 +71,30 @@ public class AppSelectActivity extends ActionBarActivity implements ReaderXcvr.U
|
||||
|
||||
private static final String[] GROUPS = SmartcardApp.GROUPS;
|
||||
|
||||
// update all five items below when adding/removing default apps!
|
||||
// update all five memberApps below when adding/removing default apps!
|
||||
static final int DEFAULT_APP_POS = 0;
|
||||
static final String[] APP_NAMES = {
|
||||
"Amex", "Amex 5-Byte", "Amex 7-Byte", // American Express ExpressPay
|
||||
"Amex 8-Byte",
|
||||
"Amex 8-Byte", // ""
|
||||
"Discover", // Discover Zip
|
||||
"MasterCard", "MasterCard U.S.", // MasterCard PayPass
|
||||
"Visa", "Visa Credit", "Visa Debit", // Visa PayWave
|
||||
"Test Pay", "Test Other"
|
||||
"Test Other", "Test Pay", // test
|
||||
"Visa", "Visa Credit", "Visa Debit" // Visa PayWave
|
||||
};
|
||||
static final String[] APP_AIDS = {
|
||||
"A00000002501", "A000000025", "A0000000250107",
|
||||
"A000000025010701",
|
||||
"A0000003241010",
|
||||
"A0000000041010", "A0000000042203",
|
||||
"F07465737420414944", "F07465737420414944",
|
||||
"A0000000031010", "A000000003101001", "A000000003101002",
|
||||
"F07465737420414944", "F07465737420414944"
|
||||
};
|
||||
// all are payment type except "Test Other"
|
||||
static final int[] APP_TYPES = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
|
||||
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0
|
||||
};
|
||||
static final int[] APP_READ_ONLY = {
|
||||
1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0
|
||||
1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0
|
||||
};
|
||||
|
||||
// dialogs
|
||||
@@ -280,6 +282,10 @@ public class AppSelectActivity extends ActionBarActivity implements ReaderXcvr.U
|
||||
Gson gson = new Gson();
|
||||
Type collectionType = new TypeToken<ArrayList<SmartcardApp>>() {}.getType();
|
||||
mApps = gson.fromJson(json, collectionType);
|
||||
|
||||
// TODO: remove
|
||||
//Collections.sort(mApps, SmartcardApp.nameComparator);
|
||||
|
||||
mSelectedAppPos = ss.getInt("selected_app_pos", mSelectedAppPos);
|
||||
|
||||
// do not clear messages for this selection on resume;
|
||||
@@ -300,18 +306,18 @@ public class AppSelectActivity extends ActionBarActivity implements ReaderXcvr.U
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
writePrefs();
|
||||
releaseSoundPool();
|
||||
mConsole.onPause();
|
||||
mNfcManager.onPause();
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
// dismiss enable NFC dialog
|
||||
mNfcManager.onStop();
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -45,7 +45,11 @@ import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class AppViewActivity extends ActionBarActivity {
|
||||
@@ -74,6 +78,13 @@ public class AppViewActivity extends ActionBarActivity {
|
||||
private int mAppPos;
|
||||
private boolean mReadOnly;
|
||||
|
||||
private HashSet<String> mUserGroups;
|
||||
private List<String> mSortedAllGroups;
|
||||
private int mSelectedGrpPos; // batch select group idx
|
||||
private String mSelectedGrpName;
|
||||
private int mExpandedGrpPos; // app browse group idx
|
||||
private String mExpandedGrpName;
|
||||
|
||||
private EditText mName;
|
||||
private EditText mAid;
|
||||
private RadioGroup mType;
|
||||
@@ -81,6 +92,7 @@ public class AppViewActivity extends ActionBarActivity {
|
||||
private TextView mNote;
|
||||
private AlertDialog mConfirmDeleteDialog;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -101,6 +113,29 @@ public class AppViewActivity extends ActionBarActivity {
|
||||
|
||||
mSelectedAppPos = ss.getInt("selected_app_pos", 0);
|
||||
|
||||
Gson gson = new Gson();
|
||||
String json = ss.getString("groups", null);
|
||||
if (json == null) {
|
||||
mUserGroups = new LinkedHashSet<>();
|
||||
} else {
|
||||
Type collectionType = new TypeToken<LinkedHashSet<String>>() {
|
||||
}.getType();
|
||||
mUserGroups = gson.fromJson(json, collectionType);
|
||||
}
|
||||
|
||||
// alphabetize, case insensitive
|
||||
mSortedAllGroups = new ArrayList<>(mUserGroups);
|
||||
mSortedAllGroups.addAll(Arrays.asList(DEFAULT_GROUPS));
|
||||
Collections.sort(mSortedAllGroups, String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
// when deleting an app results in an empty group, we remove the group;
|
||||
// we may need to adjust group position indices for batch select and app
|
||||
// browse activities, which apply to the sorted list of groups
|
||||
mSelectedGrpPos = ss.getInt("selected_grp_pos", 0);
|
||||
mSelectedGrpName = mSortedAllGroups.get(mSelectedGrpPos);
|
||||
mExpandedGrpPos = ss.getInt("expanded_grp_pos", -1);
|
||||
mExpandedGrpName = (mExpandedGrpPos == -1) ? "" : mSortedAllGroups.get(mExpandedGrpPos);
|
||||
|
||||
Intent intent = getIntent();
|
||||
mAppPos = intent.getIntExtra(EXTRA_APP_POS, 0);
|
||||
|
||||
@@ -255,7 +290,17 @@ public class AppViewActivity extends ActionBarActivity {
|
||||
} else if (mSelectedAppPos > mAppPos) {
|
||||
mSelectedAppPos--;
|
||||
}
|
||||
mApps.remove(mAppPos);
|
||||
// remove app from list
|
||||
SmartcardApp app = mApps.remove(mAppPos);
|
||||
HashSet<String> groups = app.getGroups();
|
||||
// only bother if assigned to more than the default other/payment group
|
||||
if (groups.size() > 1) {
|
||||
for (String group : groups) {
|
||||
if (Util.isGroupEmpty(group, mApps)) {
|
||||
removeGroup(group);
|
||||
}
|
||||
}
|
||||
}
|
||||
writePrefs();
|
||||
finish();
|
||||
}
|
||||
@@ -306,11 +351,47 @@ public class AppViewActivity extends ActionBarActivity {
|
||||
}
|
||||
|
||||
private void writePrefs() {
|
||||
// serialize list of SmartcardApp
|
||||
// serialize list of apps
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(mApps);
|
||||
mEditor.putString("apps", json);
|
||||
// selected app in app select mode
|
||||
mEditor.putInt("selected_app_pos", mSelectedAppPos);
|
||||
// serialize hash set of user-added groups
|
||||
json = gson.toJson(mUserGroups);
|
||||
mEditor.putString("groups", json);
|
||||
// selected group in batch select mode
|
||||
mEditor.putInt("selected_grp_pos", mSelectedGrpPos);
|
||||
// expanded group in app browse
|
||||
mEditor.putInt("expanded_grp_pos", mExpandedGrpPos);
|
||||
mEditor.commit();
|
||||
}
|
||||
|
||||
private void removeGroup(String name) {
|
||||
// remove from saved hash set
|
||||
mUserGroups.remove(name);
|
||||
// adjust selected group position indices as needed
|
||||
if (name.equals(mSelectedGrpName)) {
|
||||
// always guaranteed at least two groups: other and payment
|
||||
mSelectedGrpName = (mSelectedGrpPos == 0) ?
|
||||
mSortedAllGroups.get(1) : mSortedAllGroups.get(0);
|
||||
mSelectedGrpPos = 0;
|
||||
} else
|
||||
if (name.compareTo(mSelectedGrpName) < 0) {
|
||||
mSelectedGrpPos--;
|
||||
mSelectedGrpName = mSortedAllGroups.get(mSelectedGrpPos);
|
||||
}
|
||||
// adjust expanded group position index as needed
|
||||
if (name.equals(mExpandedGrpName)) {
|
||||
// no expanded group; all collapsed
|
||||
mExpandedGrpPos = -1;
|
||||
mExpandedGrpName = "";
|
||||
} else
|
||||
if (name.compareTo(mExpandedGrpName) < 0) {
|
||||
mExpandedGrpPos--;
|
||||
mExpandedGrpName = mSortedAllGroups.get(mExpandedGrpPos);
|
||||
}
|
||||
// remove from sorted list
|
||||
mSortedAllGroups.remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,32 +19,49 @@
|
||||
|
||||
package org.docrj.smartcard.reader;
|
||||
|
||||
import android.os.Build;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ExpandableListView;
|
||||
import android.widget.ExpandableListView.OnGroupClickListener;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.docrj.smartcard.reader.AnimatedExpandableListView.AnimatedExpandableListAdapter;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class AppsListActivity extends ActionBarActivity {
|
||||
|
||||
private static final String TAG = LaunchActivity.TAG;
|
||||
|
||||
private static final String[] DEFAULT_GROUPS = SmartcardApp.GROUPS;
|
||||
|
||||
// actions
|
||||
static final String ACTION_NEW_APP = "org.docrj.smartcard.reader.action_new_app";
|
||||
static final String ACTION_VIEW_APP = "org.docrj.smartcard.reader.action_view_app";
|
||||
@@ -54,9 +71,14 @@ public class AppsListActivity extends ActionBarActivity {
|
||||
// extras
|
||||
static final String EXTRA_APP_POS = "org.docrj.smartcard.reader.app_pos";
|
||||
|
||||
private ListView mAppListView;
|
||||
private Handler mHandler;
|
||||
private SharedPreferences.Editor mEditor;
|
||||
private AnimatedExpandableListView mGrpListView;
|
||||
// groups created by user (no payment/other)
|
||||
private HashSet<String> mGroups;
|
||||
private ArrayList<SmartcardApp> mApps;
|
||||
private int mSelectedAppPos = 0;
|
||||
private GroupAdapter mGrpAdapter;
|
||||
private int mExpandedGrp = -1;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -72,20 +94,46 @@ public class AppsListActivity extends ActionBarActivity {
|
||||
}
|
||||
});
|
||||
|
||||
mAppListView = (ListView) findViewById(R.id.listView);
|
||||
mAppListView.setOnItemClickListener(new ListView.OnItemClickListener() {
|
||||
@SuppressWarnings("deprecation")
|
||||
mGrpListView = (AnimatedExpandableListView) findViewById(R.id.listView);
|
||||
// custom click handler so we can animate
|
||||
mGrpListView.setOnGroupClickListener(new OnGroupClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view,
|
||||
int pos, long id) {
|
||||
public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
|
||||
if (mGrpListView.isGroupExpanded(groupPosition)) {
|
||||
mGrpListView.collapseGroupWithAnimation(groupPosition);
|
||||
mExpandedGrp = -1;
|
||||
} else {
|
||||
if (mExpandedGrp != groupPosition) {
|
||||
mGrpListView.collapseGroupWithAnimation(mExpandedGrp);
|
||||
}
|
||||
mGrpListView.expandGroupWithAnimation(groupPosition);
|
||||
mExpandedGrp = groupPosition;
|
||||
// removed this as it causes some funky looking effects under
|
||||
// certain conditions
|
||||
//mGrpListView.setSelectedGroup(groupPosition);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
mGrpListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
|
||||
@Override
|
||||
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
||||
SmartcardApp app = mGrpAdapter.getChild(groupPosition, childPosition);
|
||||
// view app
|
||||
Intent i = new Intent(AppsListActivity.this, AppViewActivity.class);
|
||||
i.setAction(ACTION_VIEW_APP);
|
||||
i.putExtra(EXTRA_APP_POS, pos);
|
||||
i.putExtra(EXTRA_APP_POS, mGrpAdapter.getGroup(groupPosition).appToPosMap.get(app));
|
||||
startActivity(i);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
mHandler = new Handler();
|
||||
// persistent data in shared prefs
|
||||
SharedPreferences ss = getSharedPreferences("prefs", Context.MODE_PRIVATE);
|
||||
mEditor = ss.edit();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
Window w = getWindow();
|
||||
w.setFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS,
|
||||
@@ -95,33 +143,69 @@ public class AppsListActivity extends ActionBarActivity {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
writePrefs();
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
// restore persistent data
|
||||
SharedPreferences ss = getSharedPreferences("prefs", Context.MODE_PRIVATE);
|
||||
mSelectedAppPos = ss.getInt("selected_app_pos", mSelectedAppPos);
|
||||
|
||||
Gson gson = new Gson();
|
||||
Type collectionType;
|
||||
|
||||
String json = ss.getString("apps", null);
|
||||
if (json != null) {
|
||||
// deserialize list of SmartcardApp
|
||||
Gson gson = new Gson();
|
||||
Type collectionType = new TypeToken<ArrayList<SmartcardApp>>() {
|
||||
collectionType = new TypeToken<ArrayList<SmartcardApp>>() {
|
||||
}.getType();
|
||||
mApps = gson.fromJson(json, collectionType);
|
||||
}
|
||||
|
||||
AppAdapter appAdapter = new AppAdapter(this, mApps, false);
|
||||
mAppListView.setAdapter(appAdapter);
|
||||
appAdapter.notifyDataSetChanged();
|
||||
json = ss.getString("groups", null);
|
||||
if (json == null) {
|
||||
mGroups = new LinkedHashSet<>();
|
||||
} else {
|
||||
collectionType = new TypeToken<LinkedHashSet<String>>() {
|
||||
}.getType();
|
||||
mGroups = gson.fromJson(json, collectionType);
|
||||
}
|
||||
mGroups.addAll(Arrays.asList(DEFAULT_GROUPS));
|
||||
|
||||
List<GroupItem> groupItems = new ArrayList<>();
|
||||
for (String group : mGroups) {
|
||||
GroupItem groupItem = new GroupItem();
|
||||
groupItem.groupName = group;
|
||||
groupItem.appToPosMap = Util.mapGroupMembers(group, mApps);
|
||||
groupItem.memberApps = new ArrayList<>(groupItem.appToPosMap.keySet());
|
||||
// alphabetize member app list for each group
|
||||
Collections.sort(groupItem.memberApps, SmartcardApp.nameComparator);
|
||||
groupItems.add(groupItem);
|
||||
}
|
||||
// alphabetize group list
|
||||
Collections.sort(groupItems, GroupItem.nameComparator);
|
||||
|
||||
mGrpAdapter = new GroupAdapter(this);
|
||||
mGrpAdapter.setData(groupItems);
|
||||
mGrpListView.setAdapter(mGrpAdapter);
|
||||
|
||||
mExpandedGrp = ss.getInt("expanded_grp_pos", -1);
|
||||
if (mExpandedGrp != -1) {
|
||||
mGrpListView.expandGroup(mExpandedGrp);
|
||||
mGrpListView.setSelectedGroup(mExpandedGrp);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
// collapse; will write to prefs on pause
|
||||
mExpandedGrp = -1;
|
||||
super.onBackPressed();
|
||||
overridePendingTransition(R.anim.abc_fade_in,
|
||||
R.anim.abc_fade_out);
|
||||
overridePendingTransition(R.anim.abc_fade_in, R.anim.abc_fade_out);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -141,4 +225,144 @@ public class AppsListActivity extends ActionBarActivity {
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void writePrefs() {
|
||||
mEditor.putInt("expanded_grp_pos", mExpandedGrp);
|
||||
mEditor.commit();
|
||||
}
|
||||
|
||||
private static class GroupItem {
|
||||
String groupName;
|
||||
HashMap<SmartcardApp, Integer> appToPosMap;
|
||||
List<SmartcardApp> memberApps;
|
||||
|
||||
// for static reference
|
||||
static Comparator<GroupItem> nameComparator =
|
||||
new Comparator<GroupItem>() {
|
||||
@Override
|
||||
public int compare(GroupItem gi1, GroupItem gi2) {
|
||||
// alphabetize in ascending order, case insensitive
|
||||
return gi1.groupName.toLowerCase().compareTo(gi2.groupName.toLowerCase());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static class GroupHolder {
|
||||
TextView groupName;
|
||||
TextView memberCount;
|
||||
}
|
||||
|
||||
private static class ChildHolder {
|
||||
ImageView appIcon;
|
||||
TextView appName;
|
||||
TextView appAid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapter for our list of {@link GroupItem}s.
|
||||
*/
|
||||
private static class GroupAdapter extends AnimatedExpandableListAdapter {
|
||||
private Context context;
|
||||
private LayoutInflater inflater;
|
||||
private List<GroupItem> groupItems;
|
||||
|
||||
public GroupAdapter(Context context) {
|
||||
inflater = LayoutInflater.from(context);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public void setData(List<GroupItem> items) {
|
||||
groupItems = items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SmartcardApp getChild(int groupPosition, int childPosition) {
|
||||
return groupItems.get(groupPosition).memberApps.get(childPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getChildId(int groupPosition, int childPosition) {
|
||||
return childPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getRealChildView(int groupPosition, int childPosition,
|
||||
boolean isLastChild, View convertView, ViewGroup parent) {
|
||||
ChildHolder holder;
|
||||
SmartcardApp app = getChild(groupPosition, childPosition);
|
||||
|
||||
if (convertView == null) {
|
||||
holder = new ChildHolder();
|
||||
convertView = inflater.inflate(R.layout.apps_list_app_item, parent, false);
|
||||
holder.appIcon = (ImageView) convertView.findViewById(R.id.app_icon);
|
||||
holder.appName = (TextView) convertView.findViewById(R.id.app_name);
|
||||
holder.appAid = (TextView) convertView.findViewById(R.id.app_aid);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (ChildHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
Drawable img;
|
||||
if (app.getType() == SmartcardApp.TYPE_PAYMENT) {
|
||||
img = context.getResources().getDrawable(R.drawable.credit_card_green);
|
||||
} else {
|
||||
img = context.getResources().getDrawable(R.drawable.credit_card_blue);
|
||||
}
|
||||
holder.appIcon.setImageDrawable(img);
|
||||
holder.appName.setText(app.getName());
|
||||
holder.appAid.setText(app.getAid());
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRealChildrenCount(int groupPosition) {
|
||||
return groupItems.get(groupPosition).memberApps.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroupItem getGroup(int groupPosition) {
|
||||
return groupItems.get(groupPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupCount() {
|
||||
return groupItems.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getGroupId(int groupPosition) {
|
||||
return groupPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getGroupView(int groupPosition, boolean isExpanded,
|
||||
View convertView, ViewGroup parent) {
|
||||
GroupHolder holder;
|
||||
GroupItem groupItem = getGroup(groupPosition);
|
||||
|
||||
if (convertView == null) {
|
||||
holder = new GroupHolder();
|
||||
convertView = inflater.inflate(R.layout.apps_list_group_item, parent, false);
|
||||
holder.groupName = (TextView) convertView.findViewById(R.id.group_name);
|
||||
holder.memberCount = (TextView) convertView.findViewById(R.id.member_count);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (GroupHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
holder.groupName.setText(groupItem.groupName);
|
||||
holder.memberCount.setText("(" + groupItem.memberApps.size() + ")");
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasStableIds() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChildSelectable(int arg0, int arg1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import android.nfc.NfcAdapter.ReaderCallback;
|
||||
import android.nfc.Tag;
|
||||
import android.nfc.tech.IsoDep;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Vibrator;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
@@ -42,11 +41,9 @@ import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.ViewSwitcher;
|
||||
|
||||
import com.afollestad.materialdialogs.AlertDialogWrapper;
|
||||
@@ -56,6 +53,7 @@ import com.google.gson.reflect.TypeToken;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
@@ -99,7 +97,7 @@ public class BatchSelectActivity extends ActionBarActivity implements ReaderXcvr
|
||||
private boolean mSelectInInit;
|
||||
|
||||
private ArrayList<SmartcardApp> mGrpMembers;
|
||||
private GroupAdapter mGrpAdapter;
|
||||
private BatchSelectGroupAdapter mGrpAdapter;
|
||||
private Spinner mGrpSpinner;
|
||||
|
||||
@Override
|
||||
@@ -126,7 +124,7 @@ public class BatchSelectActivity extends ActionBarActivity implements ReaderXcvr
|
||||
|
||||
// do not clear messages for initial selection
|
||||
mSelectInInit = true;
|
||||
mGrpAdapter = new GroupAdapter(getLayoutInflater());
|
||||
mGrpAdapter = new BatchSelectGroupAdapter(getLayoutInflater());
|
||||
mGrpSpinner = (Spinner) findViewById(R.id.group);
|
||||
mGrpSpinner
|
||||
.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {
|
||||
@@ -139,7 +137,7 @@ public class BatchSelectActivity extends ActionBarActivity implements ReaderXcvr
|
||||
mSelectInInit = false;
|
||||
mSelectedGrpPos = pos;
|
||||
String groupName = mGrpAdapter.getGroupName(pos);
|
||||
mGrpMembers = findGroupMembers(groupName);
|
||||
mGrpMembers = Util.findGroupMembers(groupName, mApps);
|
||||
Log.d(TAG, "group: " + groupName + ", size: " + mGrpMembers.size());
|
||||
}
|
||||
|
||||
@@ -194,6 +192,7 @@ public class BatchSelectActivity extends ActionBarActivity implements ReaderXcvr
|
||||
}.getType();
|
||||
mApps = gson.fromJson(json, collectionType);
|
||||
}
|
||||
|
||||
json = ss.getString("groups", null);
|
||||
if (json == null) {
|
||||
mGroups = new LinkedHashSet<>();
|
||||
@@ -204,6 +203,10 @@ public class BatchSelectActivity extends ActionBarActivity implements ReaderXcvr
|
||||
}
|
||||
mGroups.addAll(Arrays.asList(DEFAULT_GROUPS));
|
||||
|
||||
// alphabetize, case insensitive
|
||||
List<String> groupList = new ArrayList<>(mGroups);
|
||||
Collections.sort(groupList, String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
mSelectedGrpPos = ss.getInt("selected_grp_pos", mSelectedGrpPos);
|
||||
|
||||
// do not clear messages for this selection on resume;
|
||||
@@ -211,8 +214,8 @@ public class BatchSelectActivity extends ActionBarActivity implements ReaderXcvr
|
||||
mSelectInInit = true;
|
||||
|
||||
mGrpAdapter.clear();
|
||||
for (String group : mGroups) {
|
||||
mGrpAdapter.addGroup(group, findGroupMembers(group));
|
||||
for (String group : groupList) {
|
||||
mGrpAdapter.addGroup(group, Util.findGroupMembers(group, mApps));
|
||||
}
|
||||
mGrpSpinner.setAdapter(mGrpAdapter);
|
||||
mGrpSpinner.setSelection(mSelectedGrpPos);
|
||||
@@ -407,18 +410,4 @@ public class BatchSelectActivity extends ActionBarActivity implements ReaderXcvr
|
||||
mEditor.putInt("test_mode", TEST_MODE_BATCH_SELECT);
|
||||
mEditor.commit();
|
||||
}
|
||||
|
||||
private ArrayList<SmartcardApp> findGroupMembers(String groupName) {
|
||||
ArrayList<SmartcardApp> apps = new ArrayList<>();
|
||||
for (SmartcardApp app : mApps) {
|
||||
HashSet<String> groups = app.getGroups();
|
||||
for (String group : groups) {
|
||||
if (group.equals(groupName)) {
|
||||
apps.add(app);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return apps;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,176 +1,176 @@
|
||||
/*
|
||||
* Copyright 2015 Ryan Jones
|
||||
*
|
||||
* This file is part of smartcard-reader, package org.docrj.smartcard.reader.
|
||||
*
|
||||
* smartcard-reader 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.
|
||||
*
|
||||
* smartcard-reader 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 smartcard-reader. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.docrj.smartcard.reader;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class GroupAdapter extends BaseAdapter {
|
||||
|
||||
public static final int GROUP_TYPE_PAYMENT = 0;
|
||||
public static final int GROUP_TYPE_OTHER = 1;
|
||||
public static final int GROUP_TYPE_MIXED = 2;
|
||||
|
||||
private static final String[] DEFAULT_GROUPS = SmartcardApp.GROUPS;
|
||||
|
||||
private class Group {
|
||||
private String name;
|
||||
private int type;
|
||||
private int numMembers;
|
||||
|
||||
Group(String name, int type, int numMembers) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.numMembers = numMembers;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getNumMembers() {
|
||||
return numMembers;
|
||||
}
|
||||
};
|
||||
|
||||
private LayoutInflater mLayoutInflater;
|
||||
private Context mContext;
|
||||
List<Group> mGroups = new ArrayList<>(5);
|
||||
|
||||
public GroupAdapter(LayoutInflater layoutInflater) {
|
||||
mLayoutInflater = layoutInflater;
|
||||
mContext = layoutInflater.getContext();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
mGroups.clear();
|
||||
}
|
||||
|
||||
public void addGroup(String name, Collection<SmartcardApp> members) {
|
||||
int type;
|
||||
if (name.equals(DEFAULT_GROUPS[SmartcardApp.TYPE_PAYMENT])) {
|
||||
type = GROUP_TYPE_PAYMENT;
|
||||
} else if (name.equals(DEFAULT_GROUPS[SmartcardApp.TYPE_OTHER])) {
|
||||
type = GROUP_TYPE_OTHER;
|
||||
} else {
|
||||
// determine type for user-added group
|
||||
int payment = 0;
|
||||
int other = 0;
|
||||
for (SmartcardApp app : members) {
|
||||
if (app.getType() == SmartcardApp.TYPE_PAYMENT) {
|
||||
payment++;
|
||||
} else {
|
||||
other++;
|
||||
}
|
||||
}
|
||||
if (payment > 0 && other > 0) {
|
||||
type = GROUP_TYPE_MIXED;
|
||||
} else if (payment > 0) {
|
||||
type = GROUP_TYPE_PAYMENT;
|
||||
} else {
|
||||
type = GROUP_TYPE_OTHER;
|
||||
}
|
||||
}
|
||||
addGroup(name, type, members.size());
|
||||
}
|
||||
|
||||
public void addGroup(String name, int type, int numMembers) {
|
||||
Group group = new Group(name, type, numMembers);
|
||||
mGroups.add(group);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public String getGroupName(int position) {
|
||||
Group group = mGroups.get(position);
|
||||
return group == null ? null : group.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mGroups == null ? 0 : mGroups.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return mGroups.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View item = convertView;
|
||||
if (item == null) {
|
||||
item = mLayoutInflater.inflate(R.layout.spinner_apps_list, parent, false);
|
||||
}
|
||||
Group group = mGroups.get(position);
|
||||
TextView textView = (TextView) item.findViewById(android.R.id.text1);
|
||||
textView.setText(group.getName() + " (" + group.getNumMembers() + ")");
|
||||
Drawable img;
|
||||
if (group.getType() == GROUP_TYPE_PAYMENT) {
|
||||
img = mContext.getResources().getDrawable(R.drawable.credit_card2_green);
|
||||
} else
|
||||
if (group.getType()== GROUP_TYPE_OTHER) {
|
||||
img = mContext.getResources().getDrawable(R.drawable.credit_card2_blue);
|
||||
} else {
|
||||
img = mContext.getResources().getDrawable(R.drawable.credit_card2_pink);
|
||||
}
|
||||
textView.setCompoundDrawablesWithIntrinsicBounds(img, null, null, null);
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
||||
View row = convertView;
|
||||
if (row == null) {
|
||||
row = mLayoutInflater.inflate(R.layout.spinner_dropdown_apps_list, parent, false);
|
||||
}
|
||||
Group group = mGroups.get(position);
|
||||
TextView textView = (TextView) row.findViewById(android.R.id.text1);
|
||||
textView.setText(group.getName() + " (" + group.getNumMembers() + ")");
|
||||
Drawable img;
|
||||
if (group.getType() == GROUP_TYPE_PAYMENT) {
|
||||
img = mContext.getResources().getDrawable(R.drawable.credit_card_green);
|
||||
} else
|
||||
if (group.getType()== GROUP_TYPE_OTHER) {
|
||||
img = mContext.getResources().getDrawable(R.drawable.credit_card_blue);
|
||||
} else {
|
||||
img = mContext.getResources().getDrawable(R.drawable.credit_card_pink);
|
||||
}
|
||||
textView.setCompoundDrawablesWithIntrinsicBounds(img, null, null, null);
|
||||
return row;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright 2015 Ryan Jones
|
||||
*
|
||||
* This file is part of smartcard-reader, package org.docrj.smartcard.reader.
|
||||
*
|
||||
* smartcard-reader 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.
|
||||
*
|
||||
* smartcard-reader 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 smartcard-reader. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.docrj.smartcard.reader;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class BatchSelectGroupAdapter extends BaseAdapter {
|
||||
|
||||
public static final int GROUP_TYPE_PAYMENT = 0;
|
||||
public static final int GROUP_TYPE_OTHER = 1;
|
||||
public static final int GROUP_TYPE_MIXED = 2;
|
||||
|
||||
private static final String[] DEFAULT_GROUPS = SmartcardApp.GROUPS;
|
||||
|
||||
private class Group {
|
||||
private String name;
|
||||
private int type;
|
||||
private int numMembers;
|
||||
|
||||
Group(String name, int type, int numMembers) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.numMembers = numMembers;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getNumMembers() {
|
||||
return numMembers;
|
||||
}
|
||||
};
|
||||
|
||||
private LayoutInflater mLayoutInflater;
|
||||
private Context mContext;
|
||||
List<Group> mGroups = new ArrayList<>(5);
|
||||
|
||||
public BatchSelectGroupAdapter(LayoutInflater layoutInflater) {
|
||||
mLayoutInflater = layoutInflater;
|
||||
mContext = layoutInflater.getContext();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
mGroups.clear();
|
||||
}
|
||||
|
||||
public void addGroup(String name, Collection<SmartcardApp> members) {
|
||||
int type;
|
||||
if (name.equals(DEFAULT_GROUPS[SmartcardApp.TYPE_PAYMENT])) {
|
||||
type = GROUP_TYPE_PAYMENT;
|
||||
} else if (name.equals(DEFAULT_GROUPS[SmartcardApp.TYPE_OTHER])) {
|
||||
type = GROUP_TYPE_OTHER;
|
||||
} else {
|
||||
// determine type for user-added group
|
||||
int payment = 0;
|
||||
int other = 0;
|
||||
for (SmartcardApp app : members) {
|
||||
if (app.getType() == SmartcardApp.TYPE_PAYMENT) {
|
||||
payment++;
|
||||
} else {
|
||||
other++;
|
||||
}
|
||||
}
|
||||
if (payment > 0 && other > 0) {
|
||||
type = GROUP_TYPE_MIXED;
|
||||
} else if (payment > 0) {
|
||||
type = GROUP_TYPE_PAYMENT;
|
||||
} else {
|
||||
type = GROUP_TYPE_OTHER;
|
||||
}
|
||||
}
|
||||
addGroup(name, type, members.size());
|
||||
}
|
||||
|
||||
public void addGroup(String name, int type, int numMembers) {
|
||||
Group group = new Group(name, type, numMembers);
|
||||
mGroups.add(group);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public String getGroupName(int position) {
|
||||
Group group = mGroups.get(position);
|
||||
return group == null ? null : group.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mGroups == null ? 0 : mGroups.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return mGroups.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View item = convertView;
|
||||
if (item == null) {
|
||||
item = mLayoutInflater.inflate(R.layout.spinner_apps_list, parent, false);
|
||||
}
|
||||
Group group = mGroups.get(position);
|
||||
TextView textView = (TextView) item.findViewById(android.R.id.text1);
|
||||
textView.setText(group.getName() + " (" + group.getNumMembers() + ")");
|
||||
Drawable img;
|
||||
if (group.getType() == GROUP_TYPE_PAYMENT) {
|
||||
img = mContext.getResources().getDrawable(R.drawable.credit_card2_green);
|
||||
} else
|
||||
if (group.getType()== GROUP_TYPE_OTHER) {
|
||||
img = mContext.getResources().getDrawable(R.drawable.credit_card2_blue);
|
||||
} else {
|
||||
img = mContext.getResources().getDrawable(R.drawable.credit_card2_pink);
|
||||
}
|
||||
textView.setCompoundDrawablesWithIntrinsicBounds(img, null, null, null);
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
||||
View row = convertView;
|
||||
if (row == null) {
|
||||
row = mLayoutInflater.inflate(R.layout.spinner_dropdown_apps_list, parent, false);
|
||||
}
|
||||
Group group = mGroups.get(position);
|
||||
TextView textView = (TextView) row.findViewById(android.R.id.text1);
|
||||
textView.setText(group.getName() + " (" + group.getNumMembers() + ")");
|
||||
Drawable img;
|
||||
if (group.getType() == GROUP_TYPE_PAYMENT) {
|
||||
img = mContext.getResources().getDrawable(R.drawable.credit_card_green);
|
||||
} else
|
||||
if (group.getType()== GROUP_TYPE_OTHER) {
|
||||
img = mContext.getResources().getDrawable(R.drawable.credit_card_blue);
|
||||
} else {
|
||||
img = mContext.getResources().getDrawable(R.drawable.credit_card_pink);
|
||||
}
|
||||
textView.setCompoundDrawablesWithIntrinsicBounds(img, null, null, null);
|
||||
return row;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* Copyright 2015 Ryan Jones
|
||||
*
|
||||
* This file is part of smartcard-reader, package org.docrj.smartcard.reader.
|
||||
*
|
||||
* smartcard-reader 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.
|
||||
*
|
||||
* smartcard-reader 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 smartcard-reader. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.docrj.smartcard.reader;
|
||||
|
||||
import android.os.Build;
|
||||
@@ -40,7 +59,7 @@ public class MsgParseActivity extends ActionBarActivity {
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
// toolbar reference does not work for setting title
|
||||
// toolbar reference does not work for setting groupName
|
||||
getSupportActionBar().setTitle(mActivityName);
|
||||
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
||||
@@ -75,14 +75,12 @@ public class NavDrawer {
|
||||
View batchSelect = drawerLayout.findViewById(R.id.batch_select);
|
||||
View emvRead = drawerLayout.findViewById(R.id.emv_read);
|
||||
View apps = drawerLayout.findViewById(R.id.apps);
|
||||
//View appGroups = drawerLayout.findViewById(R.id.app_groups);
|
||||
View settings = drawerLayout.findViewById(R.id.settings);
|
||||
|
||||
appSelect.setOnClickListener(mClickListener);
|
||||
batchSelect.setOnClickListener(mClickListener);
|
||||
emvRead.setOnClickListener(mClickListener);
|
||||
apps.setOnClickListener(mClickListener);
|
||||
//appGroups.setOnClickListener(mClickListener);
|
||||
settings.setOnClickListener(mClickListener);
|
||||
|
||||
if (inState != null) {
|
||||
@@ -141,7 +139,6 @@ public class NavDrawer {
|
||||
|
||||
final Intent intent = new Intent();
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
//intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
boolean finishCurrent = false;
|
||||
final int viewId = view.getId();
|
||||
switch(viewId) {
|
||||
@@ -165,13 +162,6 @@ public class NavDrawer {
|
||||
finishCurrent = false;
|
||||
break;
|
||||
|
||||
/*
|
||||
case R.id.app_groups:
|
||||
intent.setClass(mActivity, AppsListActivity.class);
|
||||
finishCurrent = false;
|
||||
break;
|
||||
*/
|
||||
|
||||
case R.id.settings:
|
||||
intent.setClass(mActivity, SettingsActivity.class);
|
||||
finishCurrent = false;
|
||||
|
||||
@@ -22,6 +22,7 @@ package org.docrj.smartcard.reader;
|
||||
import org.docrj.smartcard.util.Util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
@@ -42,6 +43,15 @@ public class SmartcardApp {
|
||||
|
||||
private HashSet<String> mGroups = new LinkedHashSet<>();
|
||||
|
||||
public static Comparator<SmartcardApp> nameComparator =
|
||||
new Comparator<SmartcardApp>() {
|
||||
@Override
|
||||
public int compare(SmartcardApp app1, SmartcardApp app2) {
|
||||
// alphabetize in ascending order, case insensitive
|
||||
return app1.mName.toLowerCase().compareTo(app2.mName.toLowerCase());
|
||||
}
|
||||
};
|
||||
|
||||
public SmartcardApp() {
|
||||
}
|
||||
|
||||
|
||||
85
app/src/main/java/org/docrj/smartcard/reader/Util.java
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright 2015 Ryan Jones
|
||||
*
|
||||
* This file is part of smartcard-reader, package org.docrj.smartcard.reader.
|
||||
*
|
||||
* smartcard-reader 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.
|
||||
*
|
||||
* smartcard-reader 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 smartcard-reader. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.docrj.smartcard.reader;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class Util {
|
||||
public static ArrayList<SmartcardApp> findGroupMembers(String groupName, List<SmartcardApp> apps) {
|
||||
ArrayList<SmartcardApp> memberApps = new ArrayList<>();
|
||||
for (SmartcardApp app : apps) {
|
||||
HashSet<String> groups = app.getGroups();
|
||||
for (String group : groups) {
|
||||
if (group.equals(groupName)) {
|
||||
memberApps.add(app);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return memberApps;
|
||||
}
|
||||
|
||||
public static int findNumGroupMembers(String groupName, List<SmartcardApp> apps) {
|
||||
int numMembers = 0;
|
||||
for (SmartcardApp app : apps) {
|
||||
HashSet<String> groups = app.getGroups();
|
||||
for (String group : groups) {
|
||||
if (group.equals(groupName)) {
|
||||
numMembers++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return numMembers;
|
||||
}
|
||||
|
||||
public static boolean isGroupEmpty(String groupName, List<SmartcardApp> apps) {
|
||||
for (SmartcardApp app : apps) {
|
||||
HashSet<String> groups = app.getGroups();
|
||||
for (String group : groups) {
|
||||
if (group.equals(groupName)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// returns a mapping of group member apps to their position in the mApps list
|
||||
public static HashMap<SmartcardApp, Integer> mapGroupMembers(String groupName, List<SmartcardApp> apps) {
|
||||
HashMap<SmartcardApp, Integer> memberApps = new LinkedHashMap<>();
|
||||
int i = 0;
|
||||
for (SmartcardApp app : apps) {
|
||||
HashSet<String> groups = app.getGroups();
|
||||
for (String group : groups) {
|
||||
if (group.equals(groupName)) {
|
||||
memberApps.put(app, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return memberApps;
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/drawable-hdpi/ic_action_done_all.png
Normal file
|
After Width: | Height: | Size: 782 B |
BIN
app/src/main/res/drawable-hdpi/ic_action_receipt.png
Normal file
|
After Width: | Height: | Size: 572 B |
BIN
app/src/main/res/drawable-hdpi/ic_folder.png
Normal file
|
After Width: | Height: | Size: 513 B |
BIN
app/src/main/res/drawable-mdpi/ic_action_done_all.png
Normal file
|
After Width: | Height: | Size: 544 B |
BIN
app/src/main/res/drawable-mdpi/ic_action_receipt.png
Normal file
|
After Width: | Height: | Size: 266 B |
BIN
app/src/main/res/drawable-mdpi/ic_folder.png
Normal file
|
After Width: | Height: | Size: 367 B |
BIN
app/src/main/res/drawable-xhdpi/ic_action_done_all.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
app/src/main/res/drawable-xhdpi/ic_action_receipt.png
Normal file
|
After Width: | Height: | Size: 651 B |
BIN
app/src/main/res/drawable-xhdpi/ic_folder.png
Normal file
|
After Width: | Height: | Size: 615 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_folder.png
Normal file
|
After Width: | Height: | Size: 780 B |
@@ -1,18 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<CheckedTextView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/group_item"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="6dp"
|
||||
android:paddingStart="6dp"
|
||||
android:paddingEnd="6dp"
|
||||
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:fontFamily="sans-serif-condensed"
|
||||
android:textSize="@dimen/font_normal"
|
||||
android:textColor="@color/black"
|
||||
android:clickable="false">
|
||||
</CheckedTextView>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<CheckedTextView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/group_item"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="6dp"
|
||||
android:paddingStart="6dp"
|
||||
android:paddingEnd="6dp"
|
||||
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:fontFamily="sans-serif-condensed"
|
||||
android:textSize="@dimen/font_normal"
|
||||
android:textColor="@color/black"
|
||||
android:clickable="false">
|
||||
</CheckedTextView>
|
||||
39
app/src/main/res/layout/apps_list_app_item.xml
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="70dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/app_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingRight="10dp"
|
||||
android:src="@drawable/credit_card_green"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:orientation="vertical"
|
||||
android:paddingRight="10dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/app_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:fontFamily="sans-serif-condensed"
|
||||
android:text="test app name"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/app_aid"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:fontFamily="sans-serif-condensed"
|
||||
android:text="325041592E5359532E4444463031"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
39
app/src/main/res/layout/apps_list_group_item.xml
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="40dp"
|
||||
android:paddingRight="20dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/group_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingRight="10dp"
|
||||
android:src="@drawable/ic_folder"/>
|
||||
|
||||
<TextView
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:id="@+id/group_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:fontFamily="sans-serif-condensed"
|
||||
android:text="test group name"/>
|
||||
|
||||
<TextView
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:id="@+id/member_count"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|right"
|
||||
android:gravity="right"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:fontFamily="sans-serif-condensed"
|
||||
android:text="10"/>
|
||||
</LinearLayout>
|
||||
@@ -19,11 +19,13 @@
|
||||
android:text="@string/choose_app"
|
||||
android:textSize="@dimen/font_medium"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingLeft="10dp" />
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingLeft="8dp" />
|
||||
|
||||
<ListView
|
||||
<org.docrj.smartcard.reader.AnimatedExpandableListView
|
||||
android:id="@+id/listView"
|
||||
style="@style/spinner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@id/text1" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -7,6 +7,6 @@
|
||||
android:layout_height="fill_parent"
|
||||
android:gravity="center_vertical|left"
|
||||
|
||||
android:drawableLeft="@drawable/credit_card2_dark"
|
||||
android:drawableLeft="@drawable/credit_card2_green"
|
||||
android:drawablePadding="3dp" />
|
||||
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
android:layout_height="fill_parent"
|
||||
android:gravity="center_vertical|left"
|
||||
|
||||
android:drawableLeft="@drawable/credit_card2_dark"
|
||||
android:drawableLeft="@drawable/credit_card_green"
|
||||
android:drawablePadding="4dp" />
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
<string name="name_exists">App name %s exists!</string>
|
||||
<string name="aid_exists">AID %s exists!</string>
|
||||
<string name="app_icon_alt">P</string>
|
||||
<string name="choose_app">Choose a smartcard app for detailed view…</string>
|
||||
<string name="choose_app">Choose a smartcard app for detailed view and edit…</string>
|
||||
<string name="nfc_disabled">Enable NFC?</string>
|
||||
<string name="enable_nfc">This app is useless when NFC is disabled. Reader mode depends on it. Hit OK to go to Settings, where you can enable NFC.</string>
|
||||
<string name="cmd_suffix">command</string>
|
||||
@@ -92,6 +92,7 @@
|
||||
<string name="unknown">unknown</string>
|
||||
<string name="title_activity_launch">LaunchActivity</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="title_activity_groups_list">smartcard app groups</string>
|
||||
<string name="title_activity_apps_list">smartcard apps</string>
|
||||
<string name="title_activity_app_view">smartcard app</string>
|
||||
<string name="title_activity_app_edit">AppEditActivity</string>
|
||||
|
||||
|
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 61 KiB |