From 050ede9f20b26bb148af6975e751581adf7cf334 Mon Sep 17 00:00:00 2001 From: marcus Date: Fri, 26 May 2023 12:39:02 +0200 Subject: [PATCH] minSDK 28 (Android 9) upgrade to minSDK 28 -> changed deprecated code locked portrait-modus about refresh logo changed from png to svg --- app/build.gradle | 6 ++-- app/src/main/AndroidManifest.xml | 1 + .../palatschinkencounter/AboutActivity.java | 11 +++++++ .../ChangelogActivity.java | 8 ++--- .../palatschinkencounter/MainActivity.java | 25 ++++++++++---- .../palatschinkencounter/RecipeActivity.java | 6 ++-- .../palatschinkencounter/SettingActivity.java | 7 ++++ app/src/main/res/layout/activity_about.xml | 33 +++++++++++-------- app/src/main/res/layout/app_start.xml | 2 +- app/src/main/res/raw/changelog.txt | 8 ++--- app/src/main/res/xml/changelog_master.xml | 4 +++ 11 files changed, 75 insertions(+), 36 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index a614c0a..9bd2d9b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,10 +7,10 @@ android { defaultConfig { applicationId "com.git.amarradi.palatschinkencounter" - minSdkVersion 26 + minSdkVersion 28 targetSdkVersion 33 - versionCode 18 - versionName "1.0.14" + versionCode 19 + versionName "1.0.15" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c9c6485..0c88b53 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,6 +2,7 @@ { @@ -143,14 +146,12 @@ private void shareImage() { floatingActionButton.setVisibility(View.INVISIBLE); View view1 = getWindow().getDecorView().getRootView(); - view1.setDrawingCacheEnabled(true); - Bitmap bitmap = Bitmap.createBitmap(view1.getDrawingCache()); - view1.setDrawingCacheEnabled(false); + Bitmap bitmap = getBitMapFromView(view1); imageButton.setVisibility(View.VISIBLE); floatingActionButton.setVisibility(View.VISIBLE); try { File cacheFile = new File(getApplicationContext().getCacheDir(), SCREENSHOT_PNG); - OutputStream outputStream = new FileOutputStream(cacheFile); + OutputStream outputStream = Files.newOutputStream(cacheFile.toPath()); bitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream); outputStream.flush(); outputStream.close(); @@ -169,6 +170,16 @@ private void shareImage() { startActivity(Intent.createChooser(shareIntent, String.format(resources.getString(R.string.share_with)))); } + private Bitmap getBitMapFromView(View view) { + Bitmap bitmap; + bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(bitmap); + Drawable background = view.getBackground(); + background.draw(canvas); + view.draw(canvas); + return bitmap; + } + private void setupSharedPreferences() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); sharedPreferences.registerOnSharedPreferenceChangeListener(this); 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 dd8d991..6f98b7b 100644 --- a/app/src/main/java/com/git/amarradi/palatschinkencounter/RecipeActivity.java +++ b/app/src/main/java/com/git/amarradi/palatschinkencounter/RecipeActivity.java @@ -1,5 +1,7 @@ package com.git.amarradi.palatschinkencounter; +import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; + import android.annotation.SuppressLint; import android.content.Intent; import android.content.res.Resources; @@ -25,6 +27,7 @@ public class RecipeActivity extends AppCompatActivity implements NotificationDia ArrayList ingredientsModels = new ArrayList<>(); ArrayList preparationModels = new ArrayList<>(); + private static final int SCREEN_ORIENTATION_UNSPECIFIED = SCREEN_ORIENTATION_PORTRAIT; private int portions = 1; @@ -34,10 +37,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { setTheme(R.style.Theme_Palatschinkencounter); super.onCreate(savedInstanceState); setContentView(R.layout.activity_recipe); + setRequestedOrientation(SCREEN_ORIENTATION_UNSPECIFIED); TextView ingredients; - ImageButton decrease; - ImageButton increase; ingredients = findViewById(R.id.ingredients_tv); diff --git a/app/src/main/java/com/git/amarradi/palatschinkencounter/SettingActivity.java b/app/src/main/java/com/git/amarradi/palatschinkencounter/SettingActivity.java index 703f9dd..62eb7a9 100644 --- a/app/src/main/java/com/git/amarradi/palatschinkencounter/SettingActivity.java +++ b/app/src/main/java/com/git/amarradi/palatschinkencounter/SettingActivity.java @@ -1,5 +1,9 @@ package com.git.amarradi.palatschinkencounter; + + +import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; + import android.os.Bundle; import androidx.appcompat.app.ActionBar; @@ -7,6 +11,8 @@ public class SettingActivity extends AppCompatActivity { + private static final int SCREEN_ORIENTATION_UNSPECIFIED = SCREEN_ORIENTATION_PORTRAIT; + @Override public boolean onSupportNavigateUp() { onBackPressed(); @@ -22,6 +28,7 @@ public void onBackPressed() { protected void onCreate(Bundle savedInstanceState) { setTheme(R.style.Theme_Palatschinkencounter); super.onCreate(savedInstanceState); + setRequestedOrientation(SCREEN_ORIENTATION_UNSPECIFIED); getSupportFragmentManager().beginTransaction() .replace(android.R.id.content, new SettingsFragment()) .commit(); diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index eb4a957..c57963c 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -1,9 +1,10 @@ - + android:src="@drawable/logo_psc" + android:layout_marginBottom="10dp"/> + android:textAppearance="?android:attr/textAppearanceLarge" + /> + android:textAppearance="?android:attr/textAppearanceMedium" + /> + + android:textAppearance="?android:attr/textAppearanceMedium" /> - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/app_start.xml b/app/src/main/res/layout/app_start.xml index 8608256..9c6c2a1 100644 --- a/app/src/main/res/layout/app_start.xml +++ b/app/src/main/res/layout/app_start.xml @@ -56,7 +56,7 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/tv_counterstate" app:layout_constraintVertical_bias="0.237" - app:srcCompat="@drawable/logo_psc_512_transparent" /> + app:srcCompat="@drawable/logo_psc" /> + + Die App benötigt jetzt mindestens Android 9 + App für den Landscape-Modus gesperrt + neue Änderungshistorie eingefügt Übersetzungen überarbeitet