Grooming the cats.

- Closed up tiny gaps in the vectors
 - Export larger cat PNGs
 - Make it harder to delete cats by accident
 - Properly color the two front/back feet most of the time
   instead of the two left/right

Change-Id: I185bf433d3be004945d6e16387ec928c14376b7a
Fixes: 29922607
Fixes: 30064123
Fixes: 29922111
Fixes: 29922066
This commit is contained in:
Dan Sandler
2016-07-16 00:39:21 -04:00
committed by Daniel Sandler
parent adc51e460c
commit 4a1bcd966b
11 changed files with 55 additions and 23 deletions

View File

@@ -31,6 +31,7 @@ Copyright (C) 2016 The Android Open Source Project
android:label="@string/app_name"> android:label="@string/app_name">
<intent-filter> <intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES" /> <action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES" />
<action android:name="android.intent.action.MAIN" />
</intent-filter> </intent-filter>
</activity> </activity>

View File

@@ -18,5 +18,5 @@ Copyright (C) 2016 The Android Open Source Project
android:height="48dp" android:height="48dp"
android:viewportWidth="48.0" android:viewportWidth="48.0"
android:viewportHeight="48.0"> android:viewportHeight="48.0">
<path android:name="collar" android:fillColor="#FF000000" android:pathData="M9,18.4h30v1.6h-30z"/> <path android:name="collar" android:fillColor="#FF000000" android:pathData="M9,18.4h30v1.7h-30z"/>
</vector> </vector>

View File

@@ -18,5 +18,5 @@ Copyright (C) 2016 The Android Open Source Project
android:height="48dp" android:height="48dp"
android:viewportWidth="48.0" android:viewportWidth="48.0"
android:viewportHeight="48.0"> android:viewportHeight="48.0">
<path android:name="leg1" android:fillColor="#FF000000" android:pathData="M9,38h5v5h-5z"/> <path android:name="leg1" android:fillColor="#FF000000" android:pathData="M9,37h5v6h-5z"/>
</vector> </vector>

View File

@@ -18,5 +18,5 @@ Copyright (C) 2016 The Android Open Source Project
android:height="48dp" android:height="48dp"
android:viewportWidth="48.0" android:viewportWidth="48.0"
android:viewportHeight="48.0"> android:viewportHeight="48.0">
<path android:name="leg2" android:fillColor="#FF000000" android:pathData="M16,38h5v5h-5z"/> <path android:name="leg2" android:fillColor="#FF000000" android:pathData="M16,37h5v6h-5z"/>
</vector> </vector>

View File

@@ -18,5 +18,5 @@ Copyright (C) 2016 The Android Open Source Project
android:height="48dp" android:height="48dp"
android:viewportWidth="48.0" android:viewportWidth="48.0"
android:viewportHeight="48.0"> android:viewportHeight="48.0">
<path android:name="leg2_shadow" android:fillColor="#FF000000" android:pathData="M16,38h5v1h-5z"/> <path android:name="leg2_shadow" android:fillColor="#FF000000" android:pathData="M16,37h5v3h-5z"/>
</vector> </vector>

View File

@@ -18,5 +18,5 @@ Copyright (C) 2016 The Android Open Source Project
android:height="48dp" android:height="48dp"
android:viewportWidth="48.0" android:viewportWidth="48.0"
android:viewportHeight="48.0"> android:viewportHeight="48.0">
<path android:name="leg3" android:fillColor="#FF000000" android:pathData="M27,38h5v5h-5z"/> <path android:name="leg3" android:fillColor="#FF000000" android:pathData="M27,37h5v6h-5z"/>
</vector> </vector>

View File

@@ -18,5 +18,5 @@ Copyright (C) 2016 The Android Open Source Project
android:height="48dp" android:height="48dp"
android:viewportWidth="48.0" android:viewportWidth="48.0"
android:viewportHeight="48.0"> android:viewportHeight="48.0">
<path android:name="leg4" android:fillColor="#FF000000" android:pathData="M34,38h5v5h-5z"/> <path android:name="leg4" android:fillColor="#FF000000" android:pathData="M34,37h5v6h-5z"/>
</vector> </vector>

View File

@@ -20,12 +20,14 @@
android:minHeight="?android:attr/listPreferredItemHeightSmall" android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:paddingStart="?android:attr/listPreferredItemPaddingStart" android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:background="?android:attr/selectableItemBackgroundBorderless" android:background="?android:attr/selectableItemBackgroundBorderless"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:clipToPadding="false"> android:clipToPadding="false">
<FrameLayout <FrameLayout
android:layout_width="wrap_content" android:layout_width="96dp"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<ImageView <ImageView
@@ -33,6 +35,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="10dp" android:padding="10dp"
android:layout_gravity="center"
android:scaleType="fitCenter" /> android:scaleType="fitCenter" />
<LinearLayout <LinearLayout

View File

@@ -21,6 +21,7 @@ Copyright (C) 2016 The Android Open Source Project
<string name="notification_title" translatable="false">A cat is here.</string> <string name="notification_title" translatable="false">A cat is here.</string>
<string name="default_cat_name" translatable="false">Cat #%s</string> <string name="default_cat_name" translatable="false">Cat #%s</string>
<string name="directory_name" translatable="false">Cats</string> <string name="directory_name" translatable="false">Cats</string>
<string name="confirm_delete" translatable="false">Forget %s?</string>
<string-array name="food_names" translatable="false"> <string-array name="food_names" translatable="false">
<item>Empty dish</item> <item>Empty dish</item>
<item>Bits</item> <item>Bits</item>

View File

@@ -174,10 +174,10 @@ public class Cat extends Drawable {
} else { } else {
if (nsr.nextFloat() < 0.25f) { if (nsr.nextFloat() < 0.25f) {
mFootType = 2; mFootType = 2;
tint(0xFFFFFFFF, D.foot1, D.foot2); tint(0xFFFFFFFF, D.foot1, D.foot3);
} else if (nsr.nextFloat() < 0.25f) { } else if (nsr.nextFloat() < 0.25f) {
mFootType = 3; // maybe -2 would be better? meh. mFootType = 3; // maybe -2 would be better? meh.
tint(0xFFFFFFFF, D.foot3, D.foot4); tint(0xFFFFFFFF, D.foot2, D.foot4);
} else if (nsr.nextFloat() < 0.1f) { } else if (nsr.nextFloat() < 0.1f) {
mFootType = 1; mFootType = 1;
tint(0xFFFFFFFF, (Drawable) choose(nsr, D.foot1, D.foot2, D.foot3, D.foot4)); tint(0xFFFFFFFF, (Drawable) choose(nsr, D.foot1, D.foot2, D.foot3, D.foot4));

View File

@@ -59,6 +59,8 @@ public class NekoLand extends Activity implements PrefsListener {
public static boolean DEBUG = false; public static boolean DEBUG = false;
public static boolean DEBUG_NOTIFICATIONS = false; public static boolean DEBUG_NOTIFICATIONS = false;
private static final int EXPORT_BITMAP_SIZE = 600;
private static final int STORAGE_PERM_REQUEST = 123; private static final int STORAGE_PERM_REQUEST = 123;
private static boolean CAT_GEN = false; private static boolean CAT_GEN = false;
@@ -181,6 +183,31 @@ public class NekoLand extends Activity implements PrefsListener {
.inflate(R.layout.cat_view, parent, false)); .inflate(R.layout.cat_view, parent, false));
} }
private void setContextGroupVisible(final CatHolder holder, boolean vis) {
final View group = holder.contextGroup;
if (vis && group.getVisibility() != View.VISIBLE) {
group.setAlpha(0);
group.setVisibility(View.VISIBLE);
group.animate().alpha(1.0f).setDuration(333);
Runnable hideAction = new Runnable() {
@Override
public void run() {
setContextGroupVisible(holder, false);
}
};
group.setTag(hideAction);
group.postDelayed(hideAction, 5000);
} else if (!vis && group.getVisibility() == View.VISIBLE) {
group.removeCallbacks((Runnable) group.getTag());
group.animate().alpha(0f).setDuration(250).withEndAction(new Runnable() {
@Override
public void run() {
group.setVisibility(View.INVISIBLE);
}
});
}
}
@Override @Override
public void onBindViewHolder(final CatHolder holder, int position) { public void onBindViewHolder(final CatHolder holder, int position) {
Context context = holder.itemView.getContext(); Context context = holder.itemView.getContext();
@@ -195,30 +222,30 @@ public class NekoLand extends Activity implements PrefsListener {
holder.itemView.setOnLongClickListener(new OnLongClickListener() { holder.itemView.setOnLongClickListener(new OnLongClickListener() {
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
holder.contextGroup.removeCallbacks((Runnable) holder.contextGroup.getTag()); setContextGroupVisible(holder, true);
holder.contextGroup.setVisibility(View.VISIBLE);
Runnable hideAction = new Runnable() {
@Override
public void run() {
holder.contextGroup.setVisibility(View.INVISIBLE);
}
};
holder.contextGroup.setTag(hideAction);
holder.contextGroup.postDelayed(hideAction, 5000);
return true; return true;
} }
}); });
holder.delete.setOnClickListener(new View.OnClickListener() { holder.delete.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
holder.contextGroup.setVisibility(View.INVISIBLE); setContextGroupVisible(holder, false);
holder.contextGroup.removeCallbacks((Runnable) holder.contextGroup.getTag()); new AlertDialog.Builder(NekoLand.this)
.setTitle(getString(R.string.confirm_delete, mCats[position].getName()))
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
onCatRemove(mCats[holder.getAdapterPosition()]); onCatRemove(mCats[holder.getAdapterPosition()]);
} }
})
.show();
}
}); });
holder.share.setOnClickListener(new View.OnClickListener() { holder.share.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
setContextGroupVisible(holder, false);
Cat cat = mCats[holder.getAdapterPosition()]; Cat cat = mCats[holder.getAdapterPosition()];
if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) { != PackageManager.PERMISSION_GRANTED) {
@@ -248,7 +275,7 @@ public class NekoLand extends Activity implements PrefsListener {
return; return;
} }
final File png = new File(dir, cat.getName().replaceAll("[/ #:]+", "_") + ".png"); final File png = new File(dir, cat.getName().replaceAll("[/ #:]+", "_") + ".png");
Bitmap bitmap = cat.createBitmap(512, 512); Bitmap bitmap = cat.createBitmap(EXPORT_BITMAP_SIZE, EXPORT_BITMAP_SIZE);
if (bitmap != null) { if (bitmap != null) {
try { try {
OutputStream os = new FileOutputStream(png); OutputStream os = new FileOutputStream(png);