This commit is contained in:
An Bui 2025-06-08 00:04:22 +07:00
parent b0812301fa
commit 047eb23967
19 changed files with 269 additions and 171 deletions

View file

@ -24,6 +24,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.util.Timer;
import java.util.TimerTask;
public class AudioStreamService extends Service {
@ -40,13 +42,13 @@ public class AudioStreamService extends Service {
public void onCreate() {
super.onCreate();
createNotificationChannel();
Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle("Audio Streaming")
.setContentText("Receiving audio stream...")
.setSmallIcon(R.drawable.volume_up_24px)
.build();
startForeground(1, notification);
// createNotificationChannel();
// Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
// .setContentTitle("Audio Streaming")
// .setContentText("Receiving audio stream...")
// .setSmallIcon(R.drawable.volume_up_24px)
// .build();
// startForeground(1, notification);
}
@Override

View file

@ -147,6 +147,9 @@ public class MainActivity extends AppCompatActivity {
public boolean skipIDEwithARM64DialogInStartVM = false;
BottomAppBar bottomAppBar;
public static Timer timer = new Timer();
public static TimerTask timerTask;
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
@ -990,16 +993,22 @@ public class MainActivity extends AppCompatActivity {
public static void startVM(String vmName, String env, String itemExtra, String itemPath) {
ActivityManager manager = (ActivityManager) activity.getSystemService(ACTIVITY_SERVICE);
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (!AudioStreamService.class.getName().equals(service.service.getClassName())) {
if (SDK_INT >= Build.VERSION_CODES.O) {
activity.startForegroundService(new Intent(activity, AudioStreamService.class));
} else {
activity.startService(new Intent(activity, AudioStreamService.class));
timerTask = new TimerTask() {
@Override
public void run() {
ActivityManager manager = (ActivityManager) activity.getSystemService(ACTIVITY_SERVICE);
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (!AudioStreamService.class.getName().equals(service.service.getClassName())) {
if (SDK_INT >= Build.VERSION_CODES.O) {
activity.startForegroundService(new Intent(activity, AudioStreamService.class));
} else {
activity.startService(new Intent(activity, AudioStreamService.class));
}
}
}
}
}
}
};
timer.schedule(timerTask, 5000);
File romDir = new File(Config.getCacheDir()+ "/" + Config.vmID);
romDir.mkdirs();

View file

@ -88,7 +88,7 @@ public class RomInfo extends AppCompatActivity {
Glide.with(this).load(getIntent().getStringExtra("icon")).into(ivIcon);
}
btn_pick.setText(getString(R.string.select) + " " + getIntent().getStringExtra("filename"));
// btn_pick.setText(getString(R.string.select) + " " + getIntent().getStringExtra("filename"));
}
public void onResume() {

View file

@ -14,6 +14,7 @@ import android.view.animation.AnimationUtils;
import android.webkit.URLUtil;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.TextView;
@ -81,18 +82,18 @@ public class AdapterRoms extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
Glide.with(RomsManagerActivity.activity).load(current.itemIcon).placeholder(R.drawable.no_machine_image).error(R.drawable.no_machine_image).into(myHolder.ivIcon);
myHolder.textName.setText(current.itemName);
myHolder.textSize.setText(current.itemSize);
myHolder.checkBox.setChecked(position == mSelectedItem);
//myHolder.checkBox.setChecked(position == mSelectedItem);
if (current.itemAvail) {
if (FileUtils.fileValid(RomsManagerActivity.activity, AppConfig.maindirpath + current.itemPath)) {
myHolder.checkBox.setEnabled(false);
//myHolder.checkBox.setEnabled(false);
myHolder.textAvail.setTextColor(Color.BLUE);
myHolder.textAvail.setText(RomsManagerActivity.sInstalled);
} else {
myHolder.checkBox.setEnabled(true);
//myHolder.checkBox.setEnabled(true);
myHolder.textAvail.setTextColor(Color.GREEN);
myHolder.textAvail.setText(RomsManagerActivity.sAvailable);
}
myHolder.checkBox.setOnClickListener(new View.OnClickListener() {
myHolder.linearItem.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mSelectedItem = position;
@ -147,7 +148,7 @@ public class AdapterRoms extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
} else {
myHolder.textAvail.setText(RomsManagerActivity.sUnavailable);
myHolder.textAvail.setTextColor(Color.RED);
myHolder.checkBox.setEnabled(false);
//myHolder.checkBox.setEnabled(false);
}
}
@ -163,7 +164,9 @@ public class AdapterRoms extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
TextView textName, textAvail, textSize;
ImageView ivIcon;
RadioButton checkBox;
//RadioButton checkBox;
LinearLayout linearItem;
// create constructor to get widget reference
public MyHolder(View itemView) {
@ -173,7 +176,8 @@ public class AdapterRoms extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
textSize = (TextView) itemView.findViewById(R.id.textSize);
textAvail = (TextView) itemView.findViewById(R.id.textAvail);
checkBox = (RadioButton) itemView.findViewById(R.id.checkBox);
//checkBox = (RadioButton) itemView.findViewById(R.id.checkBox);
linearItem = itemView.findViewById(R.id.linearItem);
}
}