WIP: Implementing UI mockup, different "selected" indicator for swap.

Using stock icons from Google Material Icons. Need to use the actual
icons provided by carrie, but will do so in the future.
This commit is contained in:
Peter Serwylo 2015-06-11 00:51:30 +10:00
parent c6bc8b5e37
commit 0d4c61df96
17 changed files with 116 additions and 38 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 947 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 738 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 650 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 510 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 963 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 650 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 510 B

View File

@ -12,11 +12,10 @@
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/activatedBackgroundIndicator"
android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingBottom="2dip"
android:paddingTop="2dip">
@ -28,30 +27,50 @@
android:layout_marginLeft="?attr/listPreferredItemPaddingLeft"
android:layout_marginStart="?android:attr/listPreferredItemPaddingStart"
android:layout_marginTop="6dip"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
tools:src="@drawable/ic_launcher"
tools:ignore="ContentDescription" />
<ImageView
android:id="@+id/checked"
android:layout_width="32dip"
android:layout_height="32dip"
android:layout_marginRight="?attr/listPreferredItemPaddingLeft"
android:layout_marginEnd="?android:attr/listPreferredItemPaddingStart"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_add_circle_outline_white" />
<TwoLineListItem
android:layout_width="match_parent"
android:layout_toRightOf="@android:id/icon"
android:layout_toEndOf="@android:id/icon"
android:layout_toLeftOf="@id/checked"
android:layout_toStartOf="@id/checked"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:mode="twoLine" >
<TextView
android:id="@+id/application_label"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="?attr/listPreferredItemPaddingLeft"
android:layout_marginStart="?android:attr/listPreferredItemPaddingStart"
android:layout_marginTop="6dip"
android:textAppearance="?android:attr/textAppearanceMedium" />
android:textAppearance="?android:attr/textAppearanceMedium"
tools:text="F-Droid" />
<TextView
android:id="@+id/package_name"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/application_label"
android:layout_alignLeft="@+id/application_label"
android:layout_below="@+id/application_label"
android:textAppearance="?android:attr/textAppearanceSmall" />
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="Application Manager" />
</TwoLineListItem>
</LinearLayout>
</RelativeLayout>

View File

@ -12,46 +12,57 @@
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/activatedBackgroundIndicator"
android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingBottom="2dip"
android:paddingTop="2dip" >
android:paddingTop="2dip">
<ImageView
android:id="@android:id/icon"
android:layout_width="48dip"
android:layout_height="48dip"
android:layout_marginLeft="?attr/listPreferredItemPaddingLeft"
android:layout_marginStart="?android:attr/listPreferredItemPaddingStart"
android:layout_marginTop="6dip"
android:layout_alignParentStart="true"
tools:src="@drawable/ic_launcher"
tools:ignore="ContentDescription" />
<ImageView
android:id="@+id/checked"
android:layout_width="32dip"
android:layout_height="32dip"
android:layout_marginEnd="?android:attr/listPreferredItemPaddingStart"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_add_circle_outline_white" />
<TwoLineListItem
android:layout_width="match_parent"
android:layout_toEndOf="@android:id/icon"
android:layout_toStartOf="@id/checked"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:mode="twoLine" >
<TextView
android:id="@+id/application_label"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="?attr/listPreferredItemPaddingLeft"
android:layout_marginStart="?android:attr/listPreferredItemPaddingStart"
android:layout_marginTop="6dip"
android:textAppearance="?android:attr/textAppearanceMedium" />
android:textAppearance="?android:attr/textAppearanceMedium"
tools:text="F-Droid" />
<TextView
android:id="@+id/package_name"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/application_label"
android:layout_alignLeft="@+id/application_label"
android:layout_below="@+id/application_label"
android:textAppearance="?android:attr/textAppearanceSmall" />
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="Application Manager" />
</TwoLineListItem>
</LinearLayout>
</RelativeLayout>

View File

@ -12,19 +12,15 @@
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/listPreferredItemHeight"
android:background="?android:attr/activatedBackgroundIndicator"
android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingBottom="2dip"
android:paddingTop="2dip">
<CheckBox
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:id="@android:id/icon"
android:layout_width="48dip"
@ -32,30 +28,49 @@
android:layout_marginLeft="?attr/listPreferredItemPaddingLeft"
android:layout_marginStart="?android:attr/listPreferredItemPaddingStart"
android:layout_marginTop="6dip"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
tools:src="@drawable/ic_launcher"
tools:ignore="ContentDescription" />
<CheckBox
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="?attr/listPreferredItemPaddingLeft"
android:layout_marginStart="?android:attr/listPreferredItemPaddingStart"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true" />
<TwoLineListItem
android:layout_width="match_parent"
android:layout_toRightOf="@android:id/icon"
android:layout_toEndOf="@android:id/icon"
android:layout_toLeftOf="@id/checkbox"
android:layout_toStartOf="@id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:mode="twoLine" >
<TextView
android:id="@+id/application_label"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="?attr/listPreferredItemPaddingLeft"
android:layout_marginStart="?android:attr/listPreferredItemPaddingStart"
android:layout_marginTop="6dip"
android:textAppearance="?android:attr/textAppearanceMedium" />
android:textAppearance="?android:attr/textAppearanceMedium"
tools:text="F-Droid" />
<TextView
android:id="@+id/package_name"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="?attr/listPreferredItemPaddingLeft"
android:layout_marginStart="?android:attr/listPreferredItemPaddingStart"
android:layout_alignStart="@+id/application_label"
android:layout_alignLeft="@+id/application_label"
android:layout_below="@+id/application_label"
android:textAppearance="?android:attr/textAppearanceSmall" />
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="Application Manager" />
</TwoLineListItem>
</LinearLayout>
</RelativeLayout>

View File

@ -4,6 +4,7 @@ import android.annotation.TargetApi;
import android.content.Context;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
@ -149,9 +150,12 @@ public class SelectAppsView extends ListView implements
String packageName = c.getString(c.getColumnIndex(InstalledAppProvider.DataColumns.APP_ID));
if (getState().hasSelectedPackage(packageName)) {
getState().deselectPackage(packageName);
adapter.updateCheckedIndicatorView(position, false);
} else {
getState().selectPackage(packageName);
adapter.updateCheckedIndicatorView(position, true);
}
}
@Override
@ -275,6 +279,8 @@ public class SelectAppsView extends ListView implements
labelView.setText(appLabel);
iconView.setImageDrawable(icon);
final int listPosition = cursor.getPosition() + 1; // To account for the header view.
// Since v11, the Android SDK provided the ability to show selected list items
// by highlighting their background. Prior to this, we need to handle this ourselves
// by adding a checkbox which can toggle selected items.
@ -283,8 +289,6 @@ public class SelectAppsView extends ListView implements
CheckBox checkBox = (CheckBox)checkBoxView;
checkBox.setOnCheckedChangeListener(null);
final int listPosition = cursor.getPosition() + 1; // To account for the header view.
checkBox.setChecked(listView.isItemChecked(listPosition));
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
@ -294,6 +298,35 @@ public class SelectAppsView extends ListView implements
}
});
}
updateCheckedIndicatorView(view, listView.isItemChecked(listPosition));
}
public void updateCheckedIndicatorView(int position, boolean checked) {
final int firstListItemPosition = listView.getFirstVisiblePosition();
final int lastListItemPosition = firstListItemPosition + listView.getChildCount() - 1;
if (position >= firstListItemPosition && position <= lastListItemPosition ) {
final int childIndex = position - firstListItemPosition;
updateCheckedIndicatorView(listView.getChildAt(childIndex), checked);
}
}
private void updateCheckedIndicatorView(View view, boolean checked) {
ImageView imageView = (ImageView)view.findViewById(R.id.checked);
if (imageView != null) {
int resource;
int colour;
if (checked) {
resource = R.drawable.ic_check_circle_white;
colour = getResources().getColor(R.color.fdroid_blue);
} else {
resource = R.drawable.ic_add_circle_outline_white;
colour = 0xFFD0D0D4;
}
imageView.setImageDrawable(getResources().getDrawable(resource));
imageView.setColorFilter(colour, PorterDuff.Mode.MULTIPLY);
}
}
}

View File

@ -48,7 +48,7 @@ function download {
RES_DIR=$1
CATEGORY=$2
ICON="${3}_white"
ICON="${3}_black"
BASE_URL="https://raw.githubusercontent.com/google/material-design-icons/master"
SCREENS="mdpi hdpi xhdpi xxhdpi xxxhdpi"