Skip to content

Commit

Permalink
minSDK 28 (Android 9)
Browse files Browse the repository at this point in the history
upgrade to minSDK 28 -> changed deprecated code
locked portrait-modus
about refresh
logo changed from png to svg
  • Loading branch information
amarradi committed May 26, 2023
1 parent 278f763 commit 050ede9
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 36 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.git.amarradi.palatschinkencounter">
<application
android:screenOrientation="portrait"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@drawable/logo_psc_512_transparent"
Expand Down
Original file line number Diff line number Diff line change
@@ -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.graphics.Typeface;
Expand All @@ -15,16 +17,23 @@

public class AboutActivity extends AppCompatActivity {

private static final int SCREEN_ORIENTATION_UNSPECIFIED = SCREEN_ORIENTATION_PORTRAIT;

@SuppressLint("SourceLockedOrientationActivity")
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
setTheme(R.style.Theme_Palatschinkencounter);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
setRequestedOrientation(SCREEN_ORIENTATION_UNSPECIFIED);

TextView title = findViewById(R.id.tvAppName);

TextView havefun = findViewById(R.id.tvhavefun);
TextView intention = findViewById(R.id.intention);
TextView decision = findViewById(R.id.tv_decision);
TextView bibleverse = findViewById(R.id.tv_bibleverse);

TextView oss = findViewById(R.id.itsos);
oss.setMovementMethod(LinkMovementMethod.getInstance());
TextView appVersion = findViewById(R.id.tvVersion);
Expand All @@ -37,10 +46,12 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
oss.setTypeface(typeface_regular);
intention.setTypeface(typeface_regular);
decision.setTypeface(typeface_regular);
bibleverse.setTypeface(typeface_regular);
TextView resethow = findViewById(R.id.resethowto);
resethow.setTypeface(typeface_regular);
@SuppressLint({"StringFormatInvalid", "LocalSuppress"}) String version = String.format(getResources().getString(R.string.version), BuildConfig.VERSION_NAME);
appVersion.setText(version);

}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -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.os.Bundle;
Expand All @@ -13,12 +15,12 @@
import androidx.appcompat.app.AppCompatActivity;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Calendar;

public class ChangelogActivity extends AppCompatActivity {
private static final int SCREEN_ORIENTATION_UNSPECIFIED = SCREEN_ORIENTATION_PORTRAIT;
TextView tv_changelog, et_changelog;
ImageView birthday;

Expand All @@ -30,7 +32,7 @@ protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.Theme_Palatschinkencounter);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_changelog);

setRequestedOrientation(SCREEN_ORIENTATION_UNSPECIFIED);
tv_changelog = findViewById(R.id.tvChangeloghead);
et_changelog = findViewById(R.id.etChangelog);

Expand Down Expand Up @@ -74,8 +76,6 @@ private void readChangelog() {
stringBuilder.append(s).append("\n");
}
et_changelog.setText(stringBuilder.toString());
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.git.amarradi.palatschinkencounter;


import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
import static java.lang.String.format;
import static java.util.Objects.requireNonNull;

Expand All @@ -9,7 +10,9 @@
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
Expand All @@ -18,7 +21,6 @@
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
Expand All @@ -27,13 +29,12 @@
import androidx.core.splashscreen.SplashScreen;
import androidx.preference.PreferenceManager;

import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.util.Objects;

import de.cketti.library.changelog.ChangeLog;
Expand All @@ -44,6 +45,7 @@ public class MainActivity extends AppCompatActivity implements SharedPreferences
public static final String COUNTER = "text";
public static final String NIGHT_MODE = "night_mode";
public static final String SCREENSHOT_PNG = "screenshot.png";
private static final int SCREEN_ORIENTATION_UNSPECIFIED = SCREEN_ORIENTATION_PORTRAIT;
private CoordinatorLayout coordinatorLayout;
FloatingActionButton floatingActionButton;
@SuppressLint("DefaultLocale")
Expand All @@ -66,6 +68,7 @@ protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setRequestedOrientation(SCREEN_ORIENTATION_UNSPECIFIED);
floatingActionButton = findViewById(R.id.floatingActionButton);

floatingActionButton.setOnClickListener(v -> {
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -25,6 +27,7 @@ public class RecipeActivity extends AppCompatActivity implements NotificationDia

ArrayList<RecipeModel> ingredientsModels = new ArrayList<>();
ArrayList<RecipeModel> preparationModels = new ArrayList<>();
private static final int SCREEN_ORIENTATION_UNSPECIFIED = SCREEN_ORIENTATION_PORTRAIT;

private int portions = 1;

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
package com.git.amarradi.palatschinkencounter;



import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;

import android.os.Bundle;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

public class SettingActivity extends AppCompatActivity {

private static final int SCREEN_ORIENTATION_UNSPECIFIED = SCREEN_ORIENTATION_PORTRAIT;

@Override
public boolean onSupportNavigateUp() {
onBackPressed();
Expand All @@ -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();
Expand Down
33 changes: 20 additions & 13 deletions app/src/main/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:layout_margin="10dp"
android:overScrollMode="always"
android:scrollbars="vertical">

<LinearLayout
Expand All @@ -26,18 +27,20 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:gravity="fill"

android:text="@string/version"
android:textAppearance="?android:attr/textAppearanceMedium" />

<ImageView
android:layout_marginTop="10dp"
android:id="@+id/imageView"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_width="200dp"
android:layout_height="200dp"

android:contentDescription="@string/image"
android:src="@drawable/logo_psc_512_transparent" />
android:src="@drawable/logo_psc"
android:layout_marginBottom="10dp"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
Expand All @@ -62,7 +65,7 @@
<TextView
android:id="@+id/tv_decision"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"

Expand All @@ -75,7 +78,7 @@
<TextView
android:id="@+id/tv_bibleverse"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"

Expand All @@ -94,8 +97,8 @@
android:layout_height="wrap_content"

android:text="@string/havefun"
android:textColor="@color/md_theme_light_secondaryContainer"
android:textAppearance="?android:attr/textAppearanceLarge" />
android:textAppearance="?android:attr/textAppearanceLarge"
/>

<View
android:layout_width="match_parent"
Expand All @@ -104,10 +107,12 @@

<TextView
android:id="@+id/tv_share"
android:gravity="center"

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/share"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<View
android:layout_width="match_parent"
Expand All @@ -121,11 +126,13 @@

android:gravity="center"
android:text="@string/resethowto"
android:textAppearance="?android:attr/textAppearanceSmall" />
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider" />

<TextView
android:id="@+id/itsos"
android:layout_width="wrap_content"
Expand All @@ -134,6 +141,6 @@

android:gravity="center"
android:text="@string/itsos"
android:textAppearance="?android:attr/textAppearanceSmall" />
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</ScrollView>
</androidx.core.widget.NestedScrollView>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/app_start.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />

<ImageButton
android:id="@+id/counter_text_button"
Expand Down
8 changes: 2 additions & 6 deletions app/src/main/res/raw/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
## [1.0.14] - 2023-05-22
neue Änderungshistorie eingefügt
Übersetzungen überarbeitet
einen splashscreen beim Start der App eingefügt
eine einfache Teilen-Funktion über den bekannten share-Button eingefügt
das Löschen des Counters kann jetzt rückgängig gemacht werden
den Landscape-modus entfernt
App für den Landscape-Modus gesperrt
Die App benötigt jetzt mindestens Android 9
## Lizenzen
ckChangeLog - http://www.apache.org/licenses/LICENSE-2.0
4 changes: 4 additions & 0 deletions app/src/main/res/xml/changelog_master.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<changelog>
<release version="1.0.15" versioncode="19" >
<change>Die App benötigt jetzt mindestens Android 9</change>
<change>App für den Landscape-Modus gesperrt</change>
</release>
<release version="1.0.14" versioncode="18" >
<change>neue Änderungshistorie eingefügt</change>
<change>Übersetzungen überarbeitet</change>
Expand Down

0 comments on commit 050ede9

Please sign in to comment.