mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-03-15 02:40:18 +01:00
Added ExportCallHistoryDialog
This commit is contained in:
parent
931a2f63d1
commit
1c554c33fe
@ -17,6 +17,7 @@ import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
import com.simplemobiletools.dialer.R
|
||||
import com.simplemobiletools.dialer.dialogs.ExportCallHistoryDialog
|
||||
import com.simplemobiletools.dialer.dialogs.ManageVisibleTabsDialog
|
||||
import com.simplemobiletools.dialer.extensions.config
|
||||
import com.simplemobiletools.dialer.helpers.RecentsHelper
|
||||
@ -293,8 +294,9 @@ class SettingsActivity : SimpleActivity() {
|
||||
}
|
||||
|
||||
settings_calls_export_holder.setOnClickListener {
|
||||
val fileName = "call_history_${getCurrentFormattedDateTime()}"
|
||||
saveDocument.launch(fileName)
|
||||
ExportCallHistoryDialog(this) { filename ->
|
||||
saveDocument.launch(filename)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,36 @@
|
||||
package com.simplemobiletools.dialer.dialogs
|
||||
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.dialer.R
|
||||
import com.simplemobiletools.dialer.activities.SimpleActivity
|
||||
import kotlinx.android.synthetic.main.dialog_export_call_history.view.export_call_history_filename
|
||||
|
||||
class ExportCallHistoryDialog(val activity: SimpleActivity, callback: (filename: String) -> Unit) {
|
||||
|
||||
init {
|
||||
val view = (activity.layoutInflater.inflate(R.layout.dialog_export_call_history, null) as ViewGroup).apply {
|
||||
export_call_history_filename.setText("call_history_${activity.getCurrentFormattedDateTime()}")
|
||||
}
|
||||
|
||||
activity.getAlertDialogBuilder().setPositiveButton(R.string.ok, null).setNegativeButton(R.string.cancel, null).apply {
|
||||
activity.setupDialogStuff(view, this, R.string.export_call_history) { alertDialog ->
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
|
||||
val filename = view.export_call_history_filename.value
|
||||
when {
|
||||
filename.isEmpty() -> activity.toast(R.string.empty_name)
|
||||
filename.isAValidFilename() -> {
|
||||
callback(filename)
|
||||
alertDialog.dismiss()
|
||||
}
|
||||
|
||||
else -> activity.toast(R.string.invalid_name)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
45
app/src/main/res/layout/dialog_export_call_history.xml
Normal file
45
app/src/main/res/layout/dialog_export_call_history.xml
Normal file
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/export_contacts_scrollview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/export_call_history_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextInputLayout
|
||||
android:id="@+id/export_call_history_filename_hint"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/medium_margin"
|
||||
android:hint="@string/filename"
|
||||
android:paddingStart="@dimen/activity_margin"
|
||||
android:paddingEnd="@dimen/activity_margin">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/export_call_history_filename"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:textCursorDrawable="@null"
|
||||
android:textSize="@dimen/bigger_text_size" />
|
||||
|
||||
</com.simplemobiletools.commons.views.MyTextInputLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/export_call_history_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:layout_marginStart="@dimen/activity_margin"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:layout_marginEnd="@dimen/activity_margin"
|
||||
android:layout_marginBottom="@dimen/medium_margin"
|
||||
android:background="@color/divider_grey"
|
||||
android:importantForAccessibility="no" />
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
Loading…
x
Reference in New Issue
Block a user