From 57a64e287fdeed664eaab3ee38b8ca791cb41bc2 Mon Sep 17 00:00:00 2001 From: Celestial04 Date: Thu, 1 Aug 2024 18:42:40 +0200 Subject: [PATCH] Added descriptions for buttons --- .../java/com/bouillie/web/MainActivity.java | 41 ++++++++++++++----- app/src/main/res/layout/activity_main.xml | 30 ++++++++------ 2 files changed, 47 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/com/bouillie/web/MainActivity.java b/app/src/main/java/com/bouillie/web/MainActivity.java index 42c1c45..66a8024 100644 --- a/app/src/main/java/com/bouillie/web/MainActivity.java +++ b/app/src/main/java/com/bouillie/web/MainActivity.java @@ -4,6 +4,8 @@ import static android.app.DownloadManager.Request; import static android.app.usage.UsageEvents.Event.NONE; +import static com.boullie.web.R.*; + import android.annotation.SuppressLint; import android.app.DownloadManager; import android.content.DialogInterface; @@ -106,6 +108,28 @@ public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request }); + Button changeUrlButton = findViewById(R.id.changeUrlButton); + changeUrlButton.setOnClickListener(v -> { + String currentUrl = webView.getUrl(); + AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); + builder.setTitle("Change URL"); + + final EditText input = new EditText(MainActivity.this); + input.setInputType(EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_URI); + input.setText(currentUrl); + builder.setView(input); + + builder.setPositiveButton("OK", (dialog, which) -> { + String newUrl = input.getText().toString(); + webView.loadUrl(newUrl); + }); + + builder.setNegativeButton("Cancel", (dialog, which) -> dialog.cancel()); + + builder.show(); + }); + + Button soundButton = findViewById(R.id.soundButton); soundButton.setOnClickListener(v -> { // Créer une boîte de dialogue avec trois options @@ -311,17 +335,9 @@ private void showNextDialog() { ProgressBar myProgressBar = findViewById(R.id.progressBar); - EditText urlcontent = findViewById(R.id.UrlContent); + TextView urlContent = findViewById(R.id.textView);; ImageView secureimage = findViewById(R.id.SecureImage); - urlcontent.setImeOptions(EditorInfo.IME_ACTION_GO); - urlcontent.setOnEditorActionListener((v, actionId, event) -> { - if (actionId == EditorInfo.IME_ACTION_GO || actionId == EditorInfo.IME_ACTION_SEARCH) { - String url = urlcontent.getText().toString(); - webView.loadUrl(url); - return true; - } - return false; - }); + webView.setWebViewClient(new WebViewClient() { @@ -332,7 +348,7 @@ public void onPageStarted(WebView view, String url, Bitmap favicon) { @Override public void onPageFinished(WebView view, String url) { - urlcontent.setText(url); + urlContent.setText(url); // Masquer la barre de progression myProgressBar.setVisibility(View.GONE); @@ -521,6 +537,8 @@ private void showStartDialog() { finish(); } + + private void FirstStart() { SharedPreferences prefs = getSharedPreferences("prefs", MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); @@ -611,3 +629,4 @@ public void setAlert2(AlertDialog alert2) { } } + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 9c79ed5..81ad62c 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -33,18 +33,11 @@ android:layout_height="35dp" app:srcCompat="@android:drawable/ic_menu_info_details" /> - + android:layout_height="match_parent" + android:text="TextView" /> @@ -85,17 +78,22 @@