Skip to content

Commit dcf7517

Browse files
author
Toastcode
committed
Bug Fix and New Changes
1 parent dea2a63 commit dcf7517

File tree

18 files changed

+98
-53
lines changed

18 files changed

+98
-53
lines changed

.idea/misc.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ android {
1010
applicationId = "com.tcd.gamelauncher"
1111
minSdk = 26
1212
targetSdk = 34
13-
versionCode = 3
14-
versionName = "1.0.2"
13+
versionCode = 4
14+
versionName = "1.0.3"
1515
}
1616

1717
buildTypes {

app/src/main/java/com/tcd/gamelauncher/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ private void checkInstalledApps() {
150150
gameList.remove(game);
151151
}
152152
saveGame();
153-
gameAdapter.notifyDataSetChanged();
153+
runOnUiThread(() -> gameAdapter.notifyDataSetChanged());
154154
}
155155

156156
private void loadBlacklist() {

app/src/main/java/com/tcd/gamelauncher/fragment/AppSelectorFragment.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
6666
LinearLayout layout = (LinearLayout) holder.itemView;
6767
ImageView icon = layout.findViewById(R.id.app_icon);
6868
TextView name = layout.findViewById(R.id.app_name);
69-
7069
icon.setImageDrawable(appInfo.loadIcon(pm));
7170
name.setText(appInfo.loadLabel(pm));
7271

app/src/main/java/com/tcd/gamelauncher/fragment/SettingsFragment.java

Lines changed: 14 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.tcd.gamelauncher.fragment;
22

33
import android.content.SharedPreferences;
4-
import android.content.res.TypedArray;
5-
import android.graphics.Color;
64
import android.os.Bundle;
75
import android.view.LayoutInflater;
86
import android.view.View;
@@ -21,15 +19,15 @@
2119
import com.tcd.gamelauncher.R;
2220

2321
public class SettingsFragment extends Fragment {
22+
private static final String PREF_HIDE_TIME = "hide_time";
2423
private SharedPreferences preferences;
24+
2525
public static SettingsFragment newInstance() {
2626
return new SettingsFragment();
2727
}
2828

2929
@Override
30-
public View onCreateView(
31-
@NonNull LayoutInflater inflater, ViewGroup container,
32-
@Nullable Bundle savedInstanceState) {
30+
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, @Nullable Bundle savedInstanceState) {
3331
preferences = PreferenceManager.getDefaultSharedPreferences(requireContext());
3432
View view = inflater.inflate(R.layout.settings, container, false);
3533
setupHideTimeSwitch(view);
@@ -40,33 +38,14 @@ public View onCreateView(
4038

4139
private void setupHideTimeSwitch(View view) {
4240
MaterialSwitch hideTimeSwitch = view.findViewById(R.id.Htime_switch);
43-
hideTimeSwitch.setChecked(preferences.getBoolean("hide_time", false));
44-
hideTimeSwitch.setOnCheckedChangeListener(
45-
(buttonView, isChecked) -> preferences.edit().putBoolean("hide_time", isChecked).apply());
41+
hideTimeSwitch.setChecked(preferences.getBoolean(PREF_HIDE_TIME, false));
42+
hideTimeSwitch.setOnCheckedChangeListener((buttonView, isChecked) ->
43+
preferences.edit().putBoolean(PREF_HIDE_TIME, isChecked).apply());
4644
}
4745

4846
private void setupClearTimeButton(View view) {
4947
MaterialButton clearTimeBtn = view.findViewById(R.id.clear_btn);
5048
clearTimeBtn.setOnClickListener(v -> resetAllGameTimes());
51-
adjustButtonTextColor(clearTimeBtn);
52-
}
53-
54-
private void adjustButtonTextColor(MaterialButton button) {
55-
int[] attrs = new int[]{android.R.attr.colorBackground};
56-
TypedArray ta = requireContext().obtainStyledAttributes(attrs);
57-
int backgroundColor = ta.getColor(0, Color.TRANSPARENT);
58-
ta.recycle();
59-
60-
if (isColorBright(backgroundColor)) {
61-
button.setTextColor(Color.BLACK);
62-
} else {
63-
button.setTextColor(Color.WHITE);
64-
}
65-
}
66-
67-
private boolean isColorBright(int color) {
68-
double brightness = (0.299 * Color.red(color) + 0.587 * Color.green(color) + 0.114 * Color.blue(color));
69-
return brightness > 186;
7049
}
7150

7251
private void setupCloseButton(View view) {
@@ -78,26 +57,19 @@ private void resetAllGameTimes() {
7857
new MaterialAlertDialogBuilder(requireContext())
7958
.setTitle(getString(R.string.time_dialog_title))
8059
.setMessage(getString(R.string.time_dialog_message))
81-
.setPositiveButton(
82-
getString(R.string.dialog_positive),
83-
(dialog, which) -> {
84-
if (getActivity() instanceof MainActivity mainActivity) {
85-
mainActivity.resetGameTime();
86-
mainActivity.showToast(getString(R.string.operation_success));
87-
closeSettings();
88-
}
89-
})
60+
.setPositiveButton(getString(R.string.dialog_positive), (dialog, which) -> {
61+
if (getActivity() instanceof MainActivity mainActivity) {
62+
mainActivity.resetGameTime();
63+
mainActivity.showToast(getString(R.string.operation_success));
64+
closeSettings();
65+
}
66+
})
9067
.setNegativeButton(getString(R.string.dialog_negative), null)
9168
.show();
9269
}
9370

9471
private void closeSettings() {
95-
requireActivityMethod();
96-
}
97-
98-
private void requireActivityMethod() {
99-
requireActivity()
100-
.getSupportFragmentManager()
72+
requireActivity().getSupportFragmentManager()
10173
.beginTransaction()
10274
.setCustomAnimations(R.anim.enter_from_left, R.anim.exit_to_right)
10375
.remove(this)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:autoMirrored="true"
3+
android:height="24dp"
4+
android:tint="#FFFFFF"
5+
android:viewportHeight="24"
6+
android:viewportWidth="24"
7+
android:width="24dp">
8+
9+
<path
10+
android:fillColor="@android:color/white"
11+
android:pathData="M11,7h2v2h-2zM11,11h2v6h-2zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z" />
12+
13+
</vector>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:autoMirrored="true"
3+
android:height="24dp"
4+
android:tint="#FFFFFF"
5+
android:viewportHeight="24"
6+
android:viewportWidth="24"
7+
android:width="24dp">
8+
9+
<path
10+
android:fillColor="@android:color/white"
11+
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
12+
13+
</vector>
1022 Bytes
Loading
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:autoMirrored="true"
3+
android:height="24dp"
4+
android:tint="#FFFFFF"
5+
android:viewportHeight="24"
6+
android:viewportWidth="24"
7+
android:width="24dp">
8+
9+
<path
10+
android:fillColor="@android:color/white"
11+
android:pathData="M7,9H2V7h5V9zM7,12H2v2h5V12zM20.59,19l-3.83,-3.83C15.96,15.69 15.02,16 14,16c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5s5,2.24 5,5c0,1.02 -0.31,1.96 -0.83,2.75L22,17.59L20.59,19zM17,11c0,-1.65 -1.35,-3 -3,-3s-3,1.35 -3,3s1.35,3 3,3S17,12.65 17,11zM2,19h10v-2H2V19z" />
12+
13+
</vector>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:autoMirrored="true"
3+
android:height="24dp"
4+
android:tint="#FFFFFF"
5+
android:viewportHeight="24"
6+
android:viewportWidth="24"
7+
android:width="24dp">
8+
9+
<path
10+
android:fillColor="@android:color/white"
11+
android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98 0,-0.34 -0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.09,-0.16 -0.26,-0.25 -0.44,-0.25 -0.06,0 -0.12,0.01 -0.17,0.03l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.06,-0.02 -0.12,-0.03 -0.18,-0.03 -0.17,0 -0.34,0.09 -0.43,0.25l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98 0,0.33 0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.09,0.16 0.26,0.25 0.44,0.25 0.06,0 0.12,-0.01 0.17,-0.03l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.06,0.02 0.12,0.03 0.18,0.03 0.17,0 0.34,-0.09 0.43,-0.25l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM17.45,11.27c0.04,0.31 0.05,0.52 0.05,0.73 0,0.21 -0.02,0.43 -0.05,0.73l-0.14,1.13 0.89,0.7 1.08,0.84 -0.7,1.21 -1.27,-0.51 -1.04,-0.42 -0.9,0.68c-0.43,0.32 -0.84,0.56 -1.25,0.73l-1.06,0.43 -0.16,1.13 -0.2,1.35h-1.4l-0.19,-1.35 -0.16,-1.13 -1.06,-0.43c-0.43,-0.18 -0.83,-0.41 -1.23,-0.71l-0.91,-0.7 -1.06,0.43 -1.27,0.51 -0.7,-1.21 1.08,-0.84 0.89,-0.7 -0.14,-1.13c-0.03,-0.31 -0.05,-0.54 -0.05,-0.74s0.02,-0.43 0.05,-0.73l0.14,-1.13 -0.89,-0.7 -1.08,-0.84 0.7,-1.21 1.27,0.51 1.04,0.42 0.9,-0.68c0.43,-0.32 0.84,-0.56 1.25,-0.73l1.06,-0.43 0.16,-1.13 0.2,-1.35h1.39l0.19,1.35 0.16,1.13 1.06,0.43c0.43,0.18 0.83,0.41 1.23,0.71l0.91,0.7 1.06,-0.43 1.27,-0.51 0.7,1.21 -1.07,0.85 -0.89,0.7 0.14,1.13zM12,8c-2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 -4,-4zM12,14c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2z" />
12+
13+
</vector>

0 commit comments

Comments
 (0)