Compare commits
No commits in common. "e784d515dc3df01b755e6832ce40e89ff68da19b" and "59cd02f91653aaeed8f474fd7aeedb7c6d997f92" have entirely different histories.
e784d515dc
...
59cd02f916
|
|
@ -1,5 +1,4 @@
|
|||
.gradle
|
||||
.idea/deploymentTargetSelector.xml
|
||||
app/.externalNativeBuild
|
||||
app/build
|
||||
app/release
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetSelector">
|
||||
<selectionStates>
|
||||
<SelectionState runConfigName="app">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
<DropdownSelection timestamp="2026-03-07T07:26:40.093624067Z">
|
||||
<Target type="DEFAULT_BOOT">
|
||||
<handle>
|
||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=RF8Y80CE2DA" />
|
||||
</handle>
|
||||
</Target>
|
||||
</DropdownSelection>
|
||||
<DialogSelection />
|
||||
</SelectionState>
|
||||
<SelectionState runConfigName="New Run Config">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
<DropdownSelection timestamp="2026-03-06T00:03:16.988860344Z">
|
||||
<Target type="DEFAULT_BOOT">
|
||||
<handle>
|
||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=a026a310" />
|
||||
</handle>
|
||||
</Target>
|
||||
</DropdownSelection>
|
||||
<DialogSelection />
|
||||
</SelectionState>
|
||||
</selectionStates>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -77,5 +77,4 @@ android {
|
|||
dependencies {
|
||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
implementation 'androidx.biometric:biometric:1.1.0'
|
||||
implementation 'com.google.android.material:material:1.11.0'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ import androidx.annotation.NonNull;
|
|||
import androidx.biometric.BiometricManager;
|
||||
import androidx.biometric.BiometricPrompt;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
|
|
@ -100,7 +99,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
|
||||
private ActivityResultLauncher<Intent> vpnPermissionLauncher;
|
||||
private ActivityResultLauncher<String[]> requestPermissionsLauncher;
|
||||
private ActivityResultLauncher<Intent> batteryOptLauncher;
|
||||
|
||||
private boolean isReadingLogs = false;
|
||||
private final Handler sizeUpdateHandler = new Handler();
|
||||
|
|
@ -135,14 +133,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
}
|
||||
);
|
||||
|
||||
batteryOptLauncher = registerForActivityResult(
|
||||
new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
Log.d(TAG, "Regresamos de la pantalla de ajustes de batería");
|
||||
checkBatteryOptimizations();
|
||||
}
|
||||
);
|
||||
|
||||
requestPermissionsLauncher = registerForActivityResult(
|
||||
new ActivityResultContracts.RequestMultiplePermissions(),
|
||||
result -> {
|
||||
|
|
@ -231,13 +221,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
};
|
||||
}
|
||||
|
||||
private void showBatterySnackbar() {
|
||||
View rootView = findViewById(android.R.id.content);
|
||||
Snackbar.make(rootView, R.string.battery_opt_denied, Snackbar.LENGTH_INDEFINITE)
|
||||
.setAction(R.string.fix_action, v -> checkBatteryOptimizations())
|
||||
.show();
|
||||
}
|
||||
|
||||
private void initiatePermissionChain() {
|
||||
List<String> permissions = new ArrayList<>();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
|
|
@ -373,16 +356,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
// Comprobamos batería siempre que volvemos a la app
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
if (pm != null && !pm.isIgnoringBatteryOptimizations(getPackageName())) {
|
||||
// Si no está ignorado, mostramos el aviso (o Snackbar si ya se lanzó el diálogo)
|
||||
Log.d(TAG, "onResume: Batería aún optimizada, mostrando aviso");
|
||||
showBatterySnackbar();
|
||||
}
|
||||
}
|
||||
|
||||
if (getIntent() != null && getIntent().getBooleanExtra(VpnRecoveryReceiver.EXTRA_RECOVERY, false)) {
|
||||
addToLog(getString(R.string.recovery_pulse_received));
|
||||
Intent vpnIntent = new Intent(this, TProxyService.class);
|
||||
|
|
@ -407,8 +380,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
String manufacturer = Build.MANUFACTURER.toLowerCase();
|
||||
String message = getString(R.string.battery_opt_msg);
|
||||
|
||||
if (manufacturer.contains("oppo") || manufacturer.contains("realme") || manufacturer.contains("xiaomi")) {
|
||||
|
||||
if (manufacturer.contains("oppo") || manufacturer.contains("realme")) {
|
||||
message += getString(R.string.battery_opt_oppo_extra);
|
||||
} else if (manufacturer.contains("xiaomi")) {
|
||||
|
|
@ -422,52 +393,38 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
.setNegativeButton(R.string.cancel, null)
|
||||
.show();
|
||||
}
|
||||
else {
|
||||
Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
|
||||
intent.setData(Uri.parse("package:" + getPackageName()));
|
||||
batteryOptLauncher.launch(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void openBatterySettings(String manufacturer) {
|
||||
boolean success = false;
|
||||
|
||||
if (manufacturer.contains("oppo") || manufacturer.contains("realme")) {
|
||||
try {
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity"));
|
||||
startActivity(intent);
|
||||
success = true;
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent(new ComponentName("com.coloros.oppoguardelf", "com.coloros.oppoguardelf.Permission.BackgroundAllowAppListActivity"));
|
||||
startActivity(intent);
|
||||
success = true;
|
||||
return;
|
||||
} catch (Exception e2) {}
|
||||
}
|
||||
}
|
||||
else if (manufacturer.contains("xiaomi")) {
|
||||
} else if (manufacturer.contains("xiaomi")) {
|
||||
try {
|
||||
Intent intent = new Intent("miui.intent.action.APP_BATTERY_SAVER_SETTINGS");
|
||||
intent.setComponent(new ComponentName("com.miui.powerkeeper", "com.miui.powerkeeper.ui.HiddenAppsConfigActivity"));
|
||||
intent.putExtra("package_name", getPackageName());
|
||||
intent.putExtra("package_label", getString(R.string.app_name));
|
||||
startActivity(intent);
|
||||
success = true;
|
||||
return;
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
try {
|
||||
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
intent.setData(Uri.parse("package:" + getPackageName()));
|
||||
startActivity(intent);
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleTheme() {
|
||||
|
|
|
|||
|
|
@ -79,7 +79,5 @@
|
|||
|
||||
<!-- Brand specific battery warnings -->
|
||||
<string name="battery_opt_oppo_extra">\n\nOPPO/Realme detected: Please ensure you also enable \'Allow background activity\' in this app\'s settings.</string>
|
||||
<string name="battery_opt_xiaomi_extra">\n\nXiaomi detected: Please set battery saver to \'No restrictions\' in settings.</string>
|
||||
<string name="battery_opt_denied">Para que la app funcione al 100%, desactiva la optimización de batería.</string>
|
||||
<string name="fix_action">SOLUCIONAR</string>
|
||||
<string name="battery_opt_xiaomi_extra">\n\nXiaomi detected: Please set battery saver to \'No restrictions\' for this app.</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Reference in New Issue