Skip to content

Commit

Permalink
add clear history
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkempire78 committed Nov 6, 2022
1 parent 4ced23d commit cc71a8c
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.darkempire78.opencalculator"
minSdkVersion 21
targetSdkVersion 33
versionCode 16
versionName "1.7.3"
versionCode 17
versionName "1.8.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ class HistoryAdapter(
)
}

fun appendOneHistoryElement(history: History) {
this.history.add(history)
notifyDataSetChanged()
}
fun appendOneHistoryElement(history: History) {
this.history.add(history)
notifyDataSetChanged()
}

fun clearHistory() {
this.history.clear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ class MainActivity : AppCompatActivity() {
startActivity(intent, null)
}

fun clearHistory(menuItem: MenuItem) {
// Clear preferences
MyPreferences(this@MainActivity).saveHistory(this@MainActivity, mutableListOf<History>())
// Clear drawer
historyAdapter.clearHistory()
}

private fun keyVibration(view: View) {
if (MyPreferences(this).vibrationMode) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/menu/app_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
android:checkable="true"
android:onClick="checkVibration"/>

<item
android:id="@+id/app_menu_clear_history"
android:title="@string/app_menu_clear_history"
android:onClick="clearHistory"
/>

<item
android:id="@+id/app_menu_github_button"
android:title="@string/app_menu_about"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
<string name="app_menu_theme">Thème</string>
<string name="app_menu_vibration">Vibration</string>
<string name="app_menu_about">À propos</string>
<string name="infinity">Infinity</string>
<string name="infinity">Infini</string>
<string name="app_menu_clear_history">Supprimer l\'historique</string>
</resources>
4 changes: 3 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@
<string name="square" translatable="false">√</string>
<string name="squareInv" translatable="false">x²</string>

<string name="infinity">Infinity</string>

<!-- App Menu -->
<string name="app_menu_theme">Theme</string>
<string name="app_menu_vibration">Vibration</string>
<string name="app_menu_clear_history">Clear History</string>
<string name="app_menu_github" translatable="false">GitHub</string>
<string name="app_menu_about">About</string>
<string name="infinity">Infinity</string>
</resources>
2 changes: 2 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/17.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
New:
- Clear history

0 comments on commit cc71a8c

Please sign in to comment.