fixed #142, add Print functionality

This commit is contained in:
tibbi 2019-11-27 23:06:38 +01:00
parent 9f02a0557c
commit 917907e902
2 changed files with 12 additions and 0 deletions

View file

@ -14,6 +14,7 @@ import android.view.MenuItem
import android.view.WindowManager
import android.webkit.MimeTypeMap
import android.widget.SeekBar
import androidx.print.PrintHelper
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
import com.simplemobiletools.commons.dialogs.ConfirmationAdvancedDialog
import com.simplemobiletools.commons.extensions.*
@ -141,6 +142,7 @@ class MainActivity : SimpleActivity(), CanvasListener {
R.id.clear -> clearCanvas()
R.id.open_file -> tryOpenFile()
R.id.change_background -> changeBackgroundClicked()
R.id.menu_print -> printImage()
R.id.settings -> launchSettings()
R.id.about -> launchAbout()
else -> return super.onOptionsItemSelected(item)
@ -532,6 +534,12 @@ class MainActivity : SimpleActivity(), CanvasListener {
stroke_width_preview.scaleY = scale
}
private fun printImage() {
val printHelper = PrintHelper(this)
printHelper.scaleMode = PrintHelper.SCALE_MODE_FIT
printHelper.printBitmap(getString(R.string.app_name), my_canvas.getBitmap())
}
private fun checkWhatsNewDialog() {
arrayListOf<Release>().apply {
add(Release(18, R.string.release_18))

View file

@ -29,6 +29,10 @@
android:id="@+id/change_background"
android:title="@string/change_background_color"
app:showAsAction="never" />
<item
android:id="@+id/menu_print"
android:title="@string/print"
app:showAsAction="never"/>
<item
android:id="@+id/settings"
android:title="@string/settings"