Skip to content

Commit

Permalink
little update to version 1.0.19
Browse files Browse the repository at this point in the history
closed #22
closed #23
  • Loading branch information
amarradi committed Aug 13, 2024
1 parent 52ad5e2 commit 4876cd2
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 35 deletions.
18 changes: 9 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ plugins {
}

android {
compileSdk 33
compileSdk 34
defaultConfig {
applicationId "com.git.amarradi.palatschinkencounter"
minSdkVersion 28
targetSdkVersion 33
versionCode 22
versionName "1.0.18"
targetSdkVersion 34
versionCode 23
versionName "1.0.19"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -25,19 +25,19 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}
namespace 'com.git.amarradi.palatschinkencounter'

}

dependencies {

implementation 'androidx.core:core-splashscreen:1.0.1'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.appcompat:appcompat:1.7.0'
def preference_version = "1.2.1"
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
implementation "androidx.preference:preference:$preference_version"
implementation 'com.google.android.material:material:1.9.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'de.cketti.library.changelog:ckchangelog:1.2.2'
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import de.cketti.library.changelog.BuildConfig;

public class AboutActivity extends AppCompatActivity {

private static final int SCREEN_ORIENTATION_UNSPECIFIED = SCREEN_ORIENTATION_PORTRAIT;
Expand Down Expand Up @@ -49,7 +51,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
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);
@SuppressLint({"StringFormatInvalid", "LocalSuppress"}) String version = String.format(getResources().getString(R.string.version)+" "+BuildConfig.VERSION_NAME);
appVersion.setText(version);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
Expand All @@ -35,14 +36,16 @@
import java.io.File;
import java.io.OutputStream;
import java.nio.file.Files;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Objects;

import de.cketti.library.changelog.ChangeLog;

public class MainActivity extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener, WipeDataDialog.WipeDialogListener {

public static final String SHARED_PREFS = "sharedPrefs";
public static final String COUNTER = "text";
public static final String SAVEDATE = "date";
public static final String DESIGN_MODE = "system";

public static final String SCREENSHOT_PNG = "screenshot.png";
Expand All @@ -53,6 +56,8 @@ public class MainActivity extends AppCompatActivity implements SharedPreferences

private int counter = 0;
private TextView textView;
private TextView tvSaveDate;
private String saveDate;


@SuppressLint("DefaultLocale")
Expand All @@ -77,21 +82,15 @@ protected void onCreate(Bundle savedInstanceState) {
});



ChangeLog cl = new ChangeLog(this);
if (cl.isFirstRun()) {
cl.getLogDialog().show();
}


ImageButton counterTextButton = findViewById(R.id.counter_text_button);
coordinatorLayout = findViewById(R.id.coordinatorLayout);

textView = findViewById(R.id.tv_counterstate);
TextView textView_start = findViewById(R.id.tv_startpage);
textView.setTypeface(typeface);
textView_start.setTypeface(typeface);


tvSaveDate = findViewById(R.id.tv_saveDate);
setupSharedPreferences();

textView.setOnLongClickListener(v -> {
Expand All @@ -108,13 +107,21 @@ protected void onCreate(Bundle savedInstanceState) {

counterTextButton.setOnClickListener(v -> {
counter++;
saveDate = setDate();
textView.setText(String.format("%d", counter));
tvSaveDate.setText(String.format(getResources().getString(R.string.last_count_date), saveDate));
save_data();
});
load_data();
updateViews();
}

private String setDate() {
SimpleDateFormat simpleDateFormat;
simpleDateFormat = new SimpleDateFormat("dd.MM.yyyy", Locale.GERMAN);
return simpleDateFormat.format(new Date());
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
Expand Down Expand Up @@ -200,6 +207,7 @@ private void loadThemeFromPreference(SharedPreferences sharedPreferences) {
private void changeTheme(String theme_value) {
switch (theme_value) {
case "lightmode": {
Log.d("changeTheme", "changeTheme: "+theme_value);
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
SharedPreferences sharedPreferences = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
Expand All @@ -208,14 +216,15 @@ private void changeTheme(String theme_value) {
break;
}
case "darkmode": {
Log.d("changeTheme", "changeTheme: "+theme_value);
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
SharedPreferences sharedPreferences = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(DESIGN_MODE, theme_value);
editor.apply();
break;
}
case "system": {
case "system": { Log.d("changeTheme", "changeTheme: "+theme_value);
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
SharedPreferences sharedPreferences = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
Expand All @@ -235,17 +244,25 @@ public void save_data() {
SharedPreferences sharedPreferences = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putInt(COUNTER, counter);
editor.putString(SAVEDATE, saveDate);
editor.apply();
}

public void load_data() {
SharedPreferences sharedPreferences = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE);
counter = sharedPreferences.getInt(COUNTER, 0);
saveDate = sharedPreferences.getString(SAVEDATE, "");
}

@SuppressLint("DefaultLocale")
public void updateViews() {
textView.setText(format("%d", counter));
if (counter != 0) {
tvSaveDate.setText(String.format(getResources().getString(R.string.last_count_date), saveDate));
} else {
tvSaveDate.setText("");
}

}

public void reset_counter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ 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
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public boolean onPreferenceClick(@NonNull Preference preference) {
for (int i = 0; i < count; i++) {
Preference p = prefScreen.getPreference(i);


// You don't need to set up preference summaries for checkbox preferences because
// they are already set up in xml using summaryOff and summary On
if (!(p instanceof CheckBoxPreference)) {
Expand Down Expand Up @@ -114,17 +115,15 @@ private void setPreferenceSummary(Preference preference, String value) {

@Override
public void onCreate(Bundle savedInstanceState) {


super.onCreate(savedInstanceState);
Objects.requireNonNull(getPreferenceScreen().getSharedPreferences())
.registerOnSharedPreferenceChangeListener(this);
Objects.requireNonNull(getPreferenceScreen().getSharedPreferences()).
registerOnSharedPreferenceChangeListener(this);
}

@Override
public void onDestroy() {
super.onDestroy();
Objects.requireNonNull(getPreferenceScreen().getSharedPreferences())
.unregisterOnSharedPreferenceChangeListener(this);
Objects.requireNonNull(getPreferenceScreen().getSharedPreferences()).
unregisterOnSharedPreferenceChangeListener(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public void onClick(DialogInterface dialog, int which) {

}
})
.setPositiveButton(getResources().getString(R.string.resetOK), new DialogInterface.OnClickListener() {
.setPositiveButton(getResources().getString(R.string.resetOK),

new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
listener.onYesClicked();
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/counter_plus_btn_bg_shape"
android:layout_margin="25dp"
android:layout_marginBottom="30dp"
android:layout_marginEnd="25dp"
android:src="@drawable/baseline_share_24"
android:layout_gravity="bottom|end"/>

Expand Down
11 changes: 11 additions & 0 deletions app/src/main/res/layout/app_start.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,15 @@
app:srcCompat="@drawable/round_add_24"
/>

<TextView
android:id="@+id/tv_saveDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="5dp"
android:paddingEnd="5dp"
android:textAppearance="@android:style/TextAppearance.Small"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
8 changes: 6 additions & 2 deletions app/src/main/res/raw/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [1.0.18] - 2023-08-24
## [1.0.19] - 2024-08-13

Das Theme folgt jetzt standardmäßig dem System
* Update, damit der Palatschinkencounter nicht aus dem PlayStore entfernt wird
* Text unterhalb zum geteilte Bilder in deutsch und englisch wurde angepasst
* Das Changelog wurde entfernt
* Auf der Startseite gibt es einen kleinen Hinweis, wann zuletzt mit dem Palatschinkencounter gezählt wurde.
* Kleinen Fehler im Löschdialog behoben
5 changes: 3 additions & 2 deletions app/src/main/res/values-de-rDE/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
aktivieren</string>
<string name="txViewCounterState">0</string>
<string name="textviewComplain">Anzahl der gegessenen Palatschinken</string>
<string name="share_counter">Ich habe Palatschinken %1$s gegessen</string>
<string name="share_counter">Ich habe %1$s Palatschinken gegessen</string>
<string name="attention">Zähler zurücksetzen</string>
<string name="cancel">Nein</string>
<string name="resetOK">OK</string>
<string name="resetOK">Ja</string>
<string name="resetMessage">Möchten Sie den Zähler wirklich zurücksetzen?</string>
<string name="intention">Wenn man Palatschinken mag, dann sollten das natürlich die besten der
Welt sein. Mit dem Palatschinkencounter und dem Rezept ist jetzt jeder in der Lage die besten
Expand Down Expand Up @@ -112,4 +112,5 @@
<string name="changelog_show_full">Mehr</string>
<string name="birthdayCake">Geburtstagskuchen</string>
<string name="item_home">home</string>
<string name="last_count_date">Ich habe zuletzt am %1$s Palatschinken gezählt.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,5 @@
<string name="changelog_show_full">More…</string>
<string name="birthdayCake">Birthdaycake</string>
<string name="item_home">home</string>
<string name="last_count_date">The last time I counted pancakes was on %1$s.</string>
</resources>
2 changes: 0 additions & 2 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<resources>



<style name="Theme.Palatschinkencounter" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="android:fontFamily">@font/opensans_regular</item>
<item name="colorPrimary">@color/md_theme_light_primary</item>
Expand Down

0 comments on commit 4876cd2

Please sign in to comment.