android: frontend: game_list: Rounded icons and other UX improvements.

This commit is contained in:
bunnei 2020-03-08 05:03:55 -04:00 committed by xperia64
parent 9c7a545d32
commit 97de618506
5 changed files with 55 additions and 9 deletions

View File

@ -73,7 +73,7 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
PicassoUtils.loadGameBanner(holder.imageScreenshot,
mCursor.getString(GameDatabase.GAME_COLUMN_PATH));
holder.textGameTitle.setText(mCursor.getString(GameDatabase.GAME_COLUMN_TITLE));
holder.textGameTitle.setText(mCursor.getString(GameDatabase.GAME_COLUMN_TITLE).replaceAll("[\\t\\n\\r]+"," "));
holder.textCompany.setText(mCursor.getString(GameDatabase.GAME_COLUMN_COMPANY));
// TODO These shouldn't be necessary once the move to a DB-based model is complete.
@ -201,10 +201,10 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
RecyclerView.State state) {
outRect.left = space;
outRect.right = space;
outRect.left = 0;
outRect.right = 0;
outRect.bottom = space;
outRect.top = space;
outRect.top = 0;
}
}

View File

@ -47,7 +47,7 @@ public final class PlatformGamesFragment extends Fragment implements PlatformGam
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.addItemDecoration(new GameAdapter.SpacesItemDecoration(8));
mRecyclerView.addItemDecoration(new GameAdapter.SpacesItemDecoration(1));
// Add swipe down to refresh gesture
final SwipeRefreshLayout pullToRefresh = view.findViewById(R.id.refresh_grid_games);

View File

@ -0,0 +1,44 @@
package org.citra.citra_android.utils;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import com.squareup.picasso.Transformation;
public class PicassoRoundedCornersTransformation implements Transformation {
@Override
public Bitmap transform(Bitmap icon) {
final Rect rect = new Rect(0, 0, icon.getWidth(), icon.getHeight());
final int size = Math.min(icon.getWidth(), icon.getHeight());
final int x = (icon.getWidth() - size) / 2;
final int y = (icon.getHeight() - size) / 2;
Bitmap squaredBitmap = Bitmap.createBitmap(icon, x, y, size, size);
if (squaredBitmap != icon) {
icon.recycle();
}
Bitmap output =
Bitmap.createBitmap(icon.getWidth(), icon.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(output);
BitmapShader shader = new BitmapShader(squaredBitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setShader(shader);
canvas.drawRoundRect(new RectF(rect), 10,10, paint);
squaredBitmap.recycle();
return output;
}
@Override
public String key() {
return "circle";
}
}

View File

@ -7,6 +7,7 @@ import android.widget.ImageView;
import com.squareup.picasso.Picasso;
import org.citra.citra_android.R;
import org.citra.citra_android.utils.PicassoRoundedCornersTransformation;
public class PicassoUtils {
public static void loadGameBanner(ImageView imageView, String gamePath) {
@ -22,6 +23,7 @@ public class PicassoUtils {
.centerInside()
.config(Bitmap.Config.RGB_565)
.error(R.drawable.no_banner)
.transform(new PicassoRoundedCornersTransformation())
.into(imageView);
}
}

View File

@ -18,8 +18,8 @@
<ImageView
android:id="@+id/image_game_screen"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_width="48dp"
android:layout_height="48dp"
android:adjustViewBounds="false"
android:cropToPadding="false"
android:scaleType="fitCenter"
@ -38,8 +38,8 @@
android:baselineAligned="false"
android:ellipsize="end"
android:gravity="center_vertical"
android:lines="2"
android:maxLines="2"
android:lines="1"
android:maxLines="1"
android:textAlignment="viewStart"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/image_game_screen"