From f8839088a258c90bc6a8145c8f6fc0e7ce077bae Mon Sep 17 00:00:00 2001 From: Marcus Radisch Date: Thu, 23 Jun 2022 13:02:58 +0200 Subject: [PATCH] =?UTF-8?q?Palatschinkencounter=201.0.7=20SettingsFragment?= =?UTF-8?q?=20preferences.xml=20implementiert=20Rezept=20Style=20Counterre?= =?UTF-8?q?set=20=C3=BCberarbeitet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../palatschinkencounter/AboutActivity.java | 1 - .../palatschinkencounter/RecipeActivity.java | 4 -- .../SettingsFragment.java | 46 +++++-------------- ...n_bg.xml => counter_plus_btn_bg_shape.xml} | 0 app/src/main/res/layout/activity_main.xml | 2 +- 5 files changed, 13 insertions(+), 40 deletions(-) rename app/src/main/res/drawable/{counter_txt_button_bg.xml => counter_plus_btn_bg_shape.xml} (100%) diff --git a/app/src/main/java/com/git/amarradi/palatschinkencounter/AboutActivity.java b/app/src/main/java/com/git/amarradi/palatschinkencounter/AboutActivity.java index 0c0cd39..f473933 100644 --- a/app/src/main/java/com/git/amarradi/palatschinkencounter/AboutActivity.java +++ b/app/src/main/java/com/git/amarradi/palatschinkencounter/AboutActivity.java @@ -28,7 +28,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { oss.setTypeface(typeface_regular); TextView resethow = findViewById(R.id.resethowto); resethow.setTypeface(typeface_regular); - //Resources resources = getResources(); @SuppressLint({"StringFormatInvalid", "LocalSuppress"}) String version = String.format(getResources().getString(R.string.version), BuildConfig.VERSION_NAME); appVersion.setText(version); } diff --git a/app/src/main/java/com/git/amarradi/palatschinkencounter/RecipeActivity.java b/app/src/main/java/com/git/amarradi/palatschinkencounter/RecipeActivity.java index 7e7ee2c..f893085 100644 --- a/app/src/main/java/com/git/amarradi/palatschinkencounter/RecipeActivity.java +++ b/app/src/main/java/com/git/amarradi/palatschinkencounter/RecipeActivity.java @@ -9,7 +9,6 @@ public class RecipeActivity extends AppCompatActivity { ListView listView_Recipe; - String[] listItem_Recipe; @@ -20,9 +19,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { listView_Recipe = findViewById(R.id.listViewIngredients); listItem_Recipe = getResources().getStringArray(R.array.ingredients_array); - - - final ArrayAdapter arrayAdapter_Ingredients = new ArrayAdapter<>(this, R.layout.simple_list_item_1, listItem_Recipe); listView_Recipe.setAdapter(arrayAdapter_Ingredients); diff --git a/app/src/main/java/com/git/amarradi/palatschinkencounter/SettingsFragment.java b/app/src/main/java/com/git/amarradi/palatschinkencounter/SettingsFragment.java index b04cb5e..9451857 100644 --- a/app/src/main/java/com/git/amarradi/palatschinkencounter/SettingsFragment.java +++ b/app/src/main/java/com/git/amarradi/palatschinkencounter/SettingsFragment.java @@ -5,6 +5,7 @@ import android.net.Uri; import android.os.Bundle; +import androidx.annotation.NonNull; import androidx.preference.CheckBoxPreference; import androidx.preference.EditTextPreference; import androidx.preference.ListPreference; @@ -26,23 +27,24 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences(); PreferenceScreen prefScreen = getPreferenceScreen(); - - Preference feedback_preference = getPreferenceManager().findPreference("feed_preference"); - if (feedback_preference != null) { - feedback_preference.setOnPreferenceClickListener(preference -> { + Preference feedback_preference = findPreference("feedback_preference"); + assert feedback_preference != null; + feedback_preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(@NonNull Preference preference) { Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setData(Uri.parse("mailto:")); intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"info@palatschinkencounter.de"}); intent.putExtra(Intent.EXTRA_SUBJECT, "Feedback"); startActivity(intent); - return true; - }); - } + return false; + } + }); Preference version_preference = getPreferenceManager().findPreference("version_preference"); assert version_preference != null; - version_preference.setTitle("Palatschinkencounter "+BuildConfig.VERSION_NAME); + version_preference.setTitle("Palatschinkencounter " + BuildConfig.VERSION_NAME); int count = prefScreen.getPreferenceCount(); // Go through all of the preferences, and set up their preference summary. @@ -58,44 +60,20 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { } } - Preference recipe_preference = getPreferenceManager().findPreference("recipe"); Objects.requireNonNull(recipe_preference).setOnPreferenceClickListener(preference -> { - Intent recipe_intent = new Intent(getActivity(),RecipeActivity.class); + Intent recipe_intent = new Intent(getActivity(), RecipeActivity.class); startActivity(recipe_intent); return false; }); Preference about_preference = getPreferenceManager().findPreference("about"); Objects.requireNonNull(about_preference).setOnPreferenceClickListener(preference -> { - Intent about_intent = new Intent(getActivity(),AboutActivity.class); + Intent about_intent = new Intent(getActivity(), AboutActivity.class); startActivity(about_intent); return false; }); - } - /* - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - Toast error = Toast.makeText(getContext(), "Please select a number.", Toast.LENGTH_SHORT); - - String sizeKey = getString(R.string.pref_size_key); - if (preference.getKey().equals(sizeKey)) { - String stringSize = (String) newValue; - try { - float size = Float.parseFloat(stringSize); - - } catch (NumberFormatException nfe) { - error.show(); - return false; - } - } - - return true; - - - } */ - @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { // Figure out which preference was changed diff --git a/app/src/main/res/drawable/counter_txt_button_bg.xml b/app/src/main/res/drawable/counter_plus_btn_bg_shape.xml similarity index 100% rename from app/src/main/res/drawable/counter_txt_button_bg.xml rename to app/src/main/res/drawable/counter_plus_btn_bg_shape.xml diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 892246a..0c68162 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -29,7 +29,7 @@ android:layout_marginEnd="16dp" android:layout_marginRight="16dp" android:layout_marginBottom="32dp" - android:background="@drawable/counter_txt_button_bg" + android:background="@drawable/counter_plus_btn_bg_shape" android:text="@string/btnCounter" android:fontFamily="@font/opensans_extrabold" app:layout_constraintBottom_toBottomOf="parent"