Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Celestial04 committed Mar 29, 2024
1 parent e7609e9 commit ac23aea
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ android {
minSdk 24
targetSdk 34
versionCode 6
versionName "3"
versionName "3.0.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
16 changes: 5 additions & 11 deletions app/src/main/java/com/hugdev/webapper/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import android.os.Environment;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.webkit.CookieManager;
Expand Down Expand Up @@ -75,7 +74,7 @@ protected void onCreate(Bundle savedInstanceState) {
selectedTheme = savedTheme;
}
setTheme(selectedTheme);
DynamicColors.applyIfAvailable(this);
DynamicColors.applyToActivitiesIfAvailable(this.getApplication());
DynamicColors.applyToActivitiesIfAvailable(getApplication());
setContentView(R.layout.activity_main);
AppUpdateManager appUpdateManager = AppUpdateManagerFactory.create(this);
Expand Down Expand Up @@ -110,31 +109,26 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
soundButton.setOnClickListener(v -> {
// Créer une boîte de dialogue avec trois options
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle("Choisir un thème");
builder.setTitle("Choisissez un thème");

String[] options = {"Thème noir", "Thème blanc", "Thème auto de l'appareil"};
String[] options = {"Thème sombre", "Thème clair"};
builder.setItems(options, (dialog, which) -> {
// Vérifier quelle option a été sélectionnée et mettre le thème correspondant
switch (which) {
case 0:
Toast.makeText(getApplicationContext(), "Thème noir activé", Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), "Thème sombre activé", Toast.LENGTH_SHORT).show();
selectedTheme = R.style.Theme_WebApper_dark;
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES);
updateTheme();
break;
case 1:
Toast.makeText(getApplicationContext(), "Thème blanc activé", Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), "Thème clair activé", Toast.LENGTH_SHORT).show();
selectedTheme = R.style.Theme_WebApper_light;
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO);
updateTheme();
break;
case 2:
Toast.makeText(getApplicationContext(), "Thème auto de l'appareil activé", Toast.LENGTH_SHORT).show();
selectedTheme = AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
updateTheme();
break;
}
});
builder.show();
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/java/com/hugdev/webapper/tuto_1.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import static android.app.usage.UsageEvents.Event.NONE;

import static com.google.android.material.color.DynamicColors.applyIfAvailable;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
Expand All @@ -29,7 +27,7 @@ protected void onCreate(Bundle savedInstanceState) {
selectedTheme = savedTheme;
}
setTheme(selectedTheme);
applyIfAvailable(this);
DynamicColors.applyToActivitiesIfAvailable(this.getApplication());
setContentView(R.layout.tuto_1);
AppUpdateManager appUpdateManager = AppUpdateManagerFactory.create(this);

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hugdev/webapper/tuto_2.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected void onCreate(Bundle savedInstanceState) {
selectedTheme = savedTheme;
}
setTheme(selectedTheme);
DynamicColors.applyIfAvailable(this);
DynamicColors.applyToActivitiesIfAvailable(this.getApplication());
setContentView(R.layout.tuto_2);
AppUpdateManager appUpdateManager = AppUpdateManagerFactory.create(this);

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hugdev/webapper/tuto_3.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected void onCreate(Bundle savedInstanceState) {
selectedTheme = savedTheme;
}
setTheme(selectedTheme);
DynamicColors.applyIfAvailable(this);
DynamicColors.applyToActivitiesIfAvailable(this.getApplication());
setContentView(R.layout.tuto_3);

AppUpdateManager appUpdateManager = AppUpdateManagerFactory.create(this);
Expand Down

0 comments on commit ac23aea

Please sign in to comment.