|
|
|
|
@ -2,10 +2,10 @@ package net.pokeranalytics.android.ui.fragment.report |
|
|
|
|
|
|
|
|
|
import android.os.Bundle |
|
|
|
|
import android.view.View |
|
|
|
|
import android.view.WindowManager |
|
|
|
|
import android.widget.EditText |
|
|
|
|
import androidx.appcompat.app.AlertDialog |
|
|
|
|
import kotlinx.android.synthetic.main.fragment_progress_report.* |
|
|
|
|
import net.pokeranalytics.android.R |
|
|
|
|
import net.pokeranalytics.android.calculus.Report |
|
|
|
|
import net.pokeranalytics.android.model.CustomFieldCriteria |
|
|
|
|
import net.pokeranalytics.android.model.LiveData |
|
|
|
|
@ -13,6 +13,7 @@ import net.pokeranalytics.android.model.realm.ReportSetup |
|
|
|
|
import net.pokeranalytics.android.ui.fragment.data.DataManagerFragment |
|
|
|
|
import net.pokeranalytics.android.util.extensions.findById |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
abstract class AbstractReportFragment : DataManagerFragment() { |
|
|
|
|
|
|
|
|
|
private lateinit var _selectedReport: Report |
|
|
|
|
@ -54,20 +55,35 @@ abstract class AbstractReportFragment : DataManagerFragment() { |
|
|
|
|
|
|
|
|
|
// Inflate and set the layout for the dialog |
|
|
|
|
// Pass null as the parent view because its going in the dialog layout |
|
|
|
|
val view = inflater.inflate(R.layout.dialog_edit_text, null) |
|
|
|
|
val nameEditText = view.findViewById<EditText>(R.id.reportName) |
|
|
|
|
val view = inflater.inflate(net.pokeranalytics.android.R.layout.dialog_edit_text, null) |
|
|
|
|
val nameEditText = view.findViewById<EditText>(net.pokeranalytics.android.R.id.reportName) |
|
|
|
|
|
|
|
|
|
this.primaryKey?.let { id -> |
|
|
|
|
val reportSetup = getRealm().findById<ReportSetup>(id) |
|
|
|
|
reportSetup?.let { |
|
|
|
|
nameEditText.hint = it.name |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
builder.setView(view) |
|
|
|
|
// Add action buttons |
|
|
|
|
.setPositiveButton(R.string.save) { dialog, _ -> |
|
|
|
|
.setPositiveButton(net.pokeranalytics.android.R.string.save) { dialog, _ -> |
|
|
|
|
saveReport(nameEditText.text.toString()) |
|
|
|
|
dialog.dismiss() |
|
|
|
|
} |
|
|
|
|
.setNegativeButton(R.string.cancel) { dialog, _ -> |
|
|
|
|
.setNegativeButton(net.pokeranalytics.android.R.string.cancel) { dialog, _ -> |
|
|
|
|
dialog.cancel() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
val dialog = builder.create() |
|
|
|
|
dialog.setOnShowListener { |
|
|
|
|
nameEditText.requestFocus() |
|
|
|
|
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
dialog.show() |
|
|
|
|
// dialog.window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} ?: throw IllegalStateException("Activity cannot be null") |
|
|
|
|
|
|
|
|
|
@ -92,7 +108,8 @@ abstract class AbstractReportFragment : DataManagerFragment() { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
options.filterId?.let { id -> String |
|
|
|
|
options.filterId?.let { id -> |
|
|
|
|
String |
|
|
|
|
rs.filter = realm.findById(id) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|