From b4c2e241ba39191ccd1398fb17c0cbd1d28e29f2 Mon Sep 17 00:00:00 2001 From: Exenifix Date: Fri, 25 Mar 2022 13:39:26 +0300 Subject: [PATCH] Minor bugfixes --- .../main/java/com/exenifix/weatherapp/MainActivity.java | 8 +++++++- app/src/main/res/values/strings.xml | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/exenifix/weatherapp/MainActivity.java b/app/src/main/java/com/exenifix/weatherapp/MainActivity.java index 36b7367..41675a6 100644 --- a/app/src/main/java/com/exenifix/weatherapp/MainActivity.java +++ b/app/src/main/java/com/exenifix/weatherapp/MainActivity.java @@ -53,7 +53,7 @@ protected void onCreate(Bundle savedInstanceState) { if (!serverURL.endsWith("/")) { serverURL += "/"; } - currentServerText.setText("Current server: " + serverURL); + currentServerText.setText(getString(R.string.current_server, serverURL)); findViewById(R.id.inputButton).setOnClickListener(this::onSearchButtonClick); findViewById(R.id.update_server_button).setOnClickListener(this::onSetServerButtonClick); @@ -78,7 +78,13 @@ private void onSetServerButtonClick(View v) { Toast.makeText(this, "Server field must not be empty!", Toast.LENGTH_SHORT).show(); return; } + if (newUrl.endsWith("/")) { + newUrl += "/"; + } + serverURL = newUrl; + currentServerText.setText(getString(R.string.current_server, newUrl)); sharedPrefsEditor.putString("baseURL", newUrl); + sharedPrefsEditor.commit(); Toast.makeText(this, "Updated the server successfully!", Toast.LENGTH_SHORT).show(); } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fe21aa5..b4e6ada 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -5,4 +5,5 @@ Искать http://147.182.254.173:5001/ Установить сервер + Current server: %s \ No newline at end of file