Skip to content

Commit

Permalink
Added descriptions for buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
Celestial04 committed Aug 1, 2024
1 parent b740346 commit 57a64e2
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 24 deletions.
41 changes: 30 additions & 11 deletions app/src/main/java/com/bouillie/web/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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() {

Expand All @@ -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);

Expand Down Expand Up @@ -521,6 +537,8 @@ private void showStartDialog() {
finish();
}



private void FirstStart() {
SharedPreferences prefs = getSharedPreferences("prefs", MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
Expand Down Expand Up @@ -611,3 +629,4 @@ public void setAlert2(AlertDialog alert2) {
}
}


30 changes: 17 additions & 13 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,11 @@
android:layout_height="35dp"
app:srcCompat="@android:drawable/ic_menu_info_details" />

<EditText
android:id="@+id/UrlContent"
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="35dp"
android:fontFamily="sans-serif-black"
android:hapticFeedbackEnabled="true"
android:hint="https://..."
android:imeOptions="actionGo"
android:inputType="textUri"
android:minHeight="48dp"
android:singleLine="true"
android:textSize="14sp" />
android:layout_height="match_parent"
android:text="TextView" />

</LinearLayout>

Expand Down Expand Up @@ -85,17 +78,22 @@

<Button
android:id="@+id/changeUrlButton"
style="@style/Widget.Material3.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_marginEnd="10dp"
android:layout_weight="1"
android:text="Button" />
android:text="Changer l'URL"
app:icon="@android:drawable/ic_menu_preferences" />

<Button
android:id="@+id/button"
style="@style/Widget.Material3.Button"
android:layout_width="wrap_content"
android:layout_height="@dimen/SizeMenu"
android:layout_marginEnd="10dp"
android:contentDescription="@string/forward_button"
android:text="Page précédente"
app:icon="@drawable/baseline_arrow_circle_right_24"
app:iconGravity="textEnd"
app:iconPadding="0dp"
Expand All @@ -107,6 +105,7 @@
android:layout_height="@dimen/SizeMenu"
android:layout_marginEnd="10dp"
android:contentDescription="@string/refresh_button"
android:text="Recharger la page"
app:icon="@drawable/baseline_refresh_24"
app:iconPadding="0dp"
app:iconSize="@dimen/SizeMenubtn" />
Expand All @@ -116,6 +115,7 @@
android:layout_width="wrap_content"
android:layout_height="@dimen/SizeMenu"
android:layout_marginEnd="10dp"
android:text="Favoris enregistrés"
app:icon="@drawable/baseline_bookmarks_24"
app:iconGravity="textEnd"
app:iconPadding="0dp"
Expand All @@ -127,6 +127,7 @@
android:layout_height="@dimen/SizeMenu"
android:layout_marginEnd="10dp"
android:contentDescription="@string/favorite_button_add"
android:text="Ajouter un favoris"
app:icon="@drawable/baseline_bookmark_add_24"
app:iconPadding="0dp"
app:iconSize="@dimen/SizeMenubtn" />
Expand All @@ -137,6 +138,7 @@
android:layout_height="@dimen/SizeMenu"
android:layout_marginEnd="10dp"
android:contentDescription="@string/delete_fav_button"
android:text="Supprimer un favoris"
app:icon="@drawable/baseline_bookmark_remove_24"
app:iconPadding="0dp"
app:iconSize="@dimen/SizeMenubtn" />
Expand All @@ -147,6 +149,7 @@
android:layout_height="@dimen/SizeMenu"
android:layout_marginEnd="10dp"
android:contentDescription="@string/changer_la_couleur"
android:text="Changer le thème (INSTABLE)"
app:icon="@drawable/baseline_palette_24"
app:iconPadding="0dp"
app:iconSize="@dimen/SizeMenubtn" />
Expand All @@ -156,6 +159,7 @@
android:layout_height="@dimen/SizeMenu"
android:contentDescription="@string/delete_data_button"
android:onClick='onDeleteDataClick'
android:text="Supprimer toutes les données"
app:icon="@drawable/baseline_delete_forever_24"
app:iconPadding="0dp"
app:iconSize="@dimen/SizeMenubtn" />
Expand Down

0 comments on commit 57a64e2

Please sign in to comment.