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">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES" />
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>

View File

@@ -18,5 +18,5 @@ Copyright (C) 2016 The Android Open Source Project
android:height="48dp"
android:viewportWidth="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>

View File

@@ -18,5 +18,5 @@ Copyright (C) 2016 The Android Open Source Project
android:height="48dp"
android:viewportWidth="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>

View File

@@ -18,5 +18,5 @@ Copyright (C) 2016 The Android Open Source Project
android:height="48dp"
android:viewportWidth="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>

View File

@@ -18,5 +18,5 @@ Copyright (C) 2016 The Android Open Source Project
android:height="48dp"
android:viewportWidth="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>

View File

@@ -18,5 +18,5 @@ Copyright (C) 2016 The Android Open Source Project
android:height="48dp"
android:viewportWidth="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>

View File

@@ -18,5 +18,5 @@ Copyright (C) 2016 The Android Open Source Project
android:height="48dp"
android:viewportWidth="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>

View File

@@ -20,12 +20,14 @@
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:gravity="center_horizontal"
android:clipToPadding="false">
<FrameLayout
android:layout_width="wrap_content"
android:layout_width="96dp"
android:layout_height="wrap_content">
<ImageView
@@ -33,6 +35,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:layout_gravity="center"
android:scaleType="fitCenter" />
<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="default_cat_name" translatable="false">Cat #%s</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">
<item>Empty dish</item>
<item>Bits</item>

View File

@@ -174,10 +174,10 @@ public class Cat extends Drawable {
} else {
if (nsr.nextFloat() < 0.25f) {
mFootType = 2;
tint(0xFFFFFFFF, D.foot1, D.foot2);
tint(0xFFFFFFFF, D.foot1, D.foot3);
} else if (nsr.nextFloat() < 0.25f) {
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) {
mFootType = 1;
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_NOTIFICATIONS = false;
private static final int EXPORT_BITMAP_SIZE = 600;
private static final int STORAGE_PERM_REQUEST = 123;
private static boolean CAT_GEN = false;
@@ -181,6 +183,31 @@ public class NekoLand extends Activity implements PrefsListener {
.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
public void onBindViewHolder(final CatHolder holder, int position) {
Context context = holder.itemView.getContext();
@@ -195,30 +222,30 @@ public class NekoLand extends Activity implements PrefsListener {
holder.itemView.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
holder.contextGroup.removeCallbacks((Runnable) holder.contextGroup.getTag());
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);
setContextGroupVisible(holder, true);
return true;
}
});
holder.delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
holder.contextGroup.setVisibility(View.INVISIBLE);
holder.contextGroup.removeCallbacks((Runnable) holder.contextGroup.getTag());
onCatRemove(mCats[holder.getAdapterPosition()]);
setContextGroupVisible(holder, false);
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()]);
}
})
.show();
}
});
holder.share.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setContextGroupVisible(holder, false);
Cat cat = mCats[holder.getAdapterPosition()];
if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
@@ -248,7 +275,7 @@ public class NekoLand extends Activity implements PrefsListener {
return;
}
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) {
try {
OutputStream os = new FileOutputStream(png);