Skip to content

Commit db190c4

Browse files
author
ToastcodeDev
committed
Bugs Fixed and New Features Added
1 parent 8c26bec commit db190c4

39 files changed

+675
-515
lines changed

app/build.gradle.kts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ android {
1313
minSdk = 26
1414
targetSdk = 34
1515
versionCode = 1
16-
versionName = "1.0"
16+
versionName = "1.0.1"
1717

1818
vectorDrawables {
1919
useSupportLibrary = true
2020
}
2121
}
2222

2323
compileOptions {
24-
sourceCompatibility = JavaVersion.VERSION_11
25-
targetCompatibility = JavaVersion.VERSION_11
24+
sourceCompatibility = JavaVersion.VERSION_17
25+
targetCompatibility = JavaVersion.VERSION_17
2626
}
2727

2828
buildTypes {
29-
release{
30-
isMinifyEnabled = true
31-
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
32-
}
29+
release {
30+
isMinifyEnabled = true
31+
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
32+
}
3333
}
3434

3535
buildFeatures {

app/src/main/AndroidManifest.xml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
1-
<manifest
2-
xmlns:android="http://schemas.android.com/apk/res/android">
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
3+
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
4+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
35

4-
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
5-
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
6-
76
<application
87
android:allowBackup="true"
98
android:icon="@mipmap/ic_launcher"
109
android:label="@string/app_name"
11-
android:roundIcon="@mipmap/ic_launcher"
12-
android:theme="@style/ImprovedTheme">
10+
android:roundIcon="@mipmap/ic_launcher_round"
11+
android:theme="@style/MDynamic">
1312

1413
<activity
1514
android:name=".MainActivity"
1615
android:configChanges="orientation|screenSize|keyboardHidden|smallestScreenSize|screenLayout"
1716
android:launchMode="singleInstance"
1817
android:screenOrientation="user"
1918
android:windowSoftInputMode="stateHidden"
20-
android:exported="true">
19+
android:exported="true"
20+
android:enableOnBackInvokedCallback="true">
2121

2222
<intent-filter>
2323
<action android:name="android.intent.action.MAIN" />
2424
<category android:name="android.intent.category.LAUNCHER" />
25-
</intent-filter>
26-
27-
</activity>
28-
25+
</intent-filter>
26+
</activity>
2927
</application>
3028
</manifest>
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
package com.tcd.gamelauncher;
2+
3+
import android.content.Context;
4+
import android.graphics.drawable.Drawable;
5+
import android.os.Bundle;
6+
import android.view.LayoutInflater;
7+
import android.view.View;
8+
import android.view.ViewGroup;
9+
import android.widget.ImageView;
10+
import android.widget.TextView;
11+
import androidx.annotation.NonNull;
12+
import androidx.recyclerview.widget.RecyclerView;
13+
import java.util.List;
14+
15+
public class Game {
16+
String packageName;
17+
String title;
18+
transient Drawable icon;
19+
long totalTimePlayed;
20+
long lastStartTime;
21+
22+
Game(String packageName, String title, Drawable icon) {
23+
this.packageName = packageName;
24+
this.title = title;
25+
this.icon = icon;
26+
this.totalTimePlayed = 0;
27+
this.lastStartTime = 0;
28+
}
29+
}
30+
31+
class GameAdapter extends RecyclerView.Adapter<GameAdapter.GameViewHolder> {
32+
private final List<Game> gameList;
33+
private final Context context;
34+
private final GameLaunchCallback launchCallback;
35+
private final GameRemoveCallback removeCallback;
36+
37+
interface GameLaunchCallback {
38+
void onLaunch(String packageName);
39+
}
40+
41+
interface GameRemoveCallback {
42+
void onRemove(int position);
43+
}
44+
45+
public GameAdapter(
46+
List<Game> gameList,
47+
Context context,
48+
GameLaunchCallback launchCallback,
49+
GameRemoveCallback removeCallback) {
50+
this.gameList = gameList;
51+
this.context = context;
52+
this.launchCallback = launchCallback;
53+
this.removeCallback = removeCallback;
54+
}
55+
56+
@NonNull
57+
@Override
58+
public GameViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
59+
View view = LayoutInflater.from(context).inflate(R.layout.game_container, parent, false);
60+
return new GameViewHolder(view);
61+
}
62+
63+
@Override
64+
public void onBindViewHolder(@NonNull GameViewHolder holder, int position) {
65+
Game game = gameList.get(position);
66+
holder.gameTitle.setText(game.title);
67+
holder.gameIcon.setImageDrawable(game.icon);
68+
69+
holder.openGame.setOnClickListener(v -> launchCallback.onLaunch(game.packageName));
70+
71+
holder.itemView.setOnClickListener(
72+
v -> {
73+
GameFragment gameFragment = new GameFragment();
74+
Bundle args = new Bundle();
75+
args.putString("PACKAGE_NAME", game.packageName);
76+
args.putString("GAME_TITLE", game.title);
77+
args.putLong("TOTAL_TIME_PLAYED", game.totalTimePlayed);
78+
gameFragment.setArguments(args);
79+
80+
((MainActivity) context)
81+
.getSupportFragmentManager()
82+
.beginTransaction()
83+
.setCustomAnimations(
84+
R.anim.enter_from_left,
85+
R.anim.exit_to_right,
86+
R.anim.enter_from_right,
87+
R.anim.exit_to_left)
88+
.replace(R.id.Framelay, gameFragment)
89+
.addToBackStack(null)
90+
.commit();
91+
});
92+
}
93+
94+
@Override
95+
public int getItemCount() {
96+
return gameList.size();
97+
}
98+
99+
static class GameViewHolder extends RecyclerView.ViewHolder {
100+
TextView gameTitle;
101+
ImageView gameIcon, openGame;
102+
103+
GameViewHolder(@NonNull View itemView) {
104+
super(itemView);
105+
gameTitle = itemView.findViewById(R.id.Game_Title);
106+
gameIcon = itemView.findViewById(R.id.Game_Icon);
107+
openGame = itemView.findViewById(R.id.Open_Game);
108+
}
109+
}
110+
}

0 commit comments

Comments
 (0)