mirror of
				https://github.com/SimpleMobileTools/Simple-Draw.git
				synced 2025-06-05 21:59:17 +02:00 
			
		
		
		
	couple minor changes related to save image code style
This commit is contained in:
		| @@ -35,19 +35,17 @@ import java.io.FileOutputStream | |||||||
| import java.io.IOException | import java.io.IOException | ||||||
|  |  | ||||||
| class MainActivity : SimpleActivity(), MyCanvas.PathsChangedListener { | class MainActivity : SimpleActivity(), MyCanvas.PathsChangedListener { | ||||||
|  |     private val FOLDER_NAME = "images" | ||||||
|  |     private val FILE_NAME = "simple-draw.png" | ||||||
|  |     private val SAVE_FOLDER_NAME = "Simple Draw" | ||||||
|  |     private val STORAGE_PERMISSION = 1 | ||||||
|  |  | ||||||
|     private var curFileName: String? = null |     private var curFileName: String? = null | ||||||
|     private var curExtensionId = 0 |     private var curExtensionId = 0 | ||||||
|  |  | ||||||
|     private var color = 0 |     private var color = 0 | ||||||
|     private var strokeWidth = 0f |     private var strokeWidth = 0f | ||||||
|  |  | ||||||
|     companion object { |  | ||||||
|         private val FOLDER_NAME = "images" |  | ||||||
|         private val FILE_NAME = "simple-draw.png" |  | ||||||
|         private val SAVE_FOLDER_NAME = "Simple Draw" |  | ||||||
|         private val STORAGE_PERMISSION = 1 |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     override fun onCreate(savedInstanceState: Bundle?) { |     override fun onCreate(savedInstanceState: Bundle?) { | ||||||
|         super.onCreate(savedInstanceState) |         super.onCreate(savedInstanceState) | ||||||
|         setContentView(R.layout.activity_main) |         setContentView(R.layout.activity_main) | ||||||
| @@ -85,7 +83,7 @@ class MainActivity : SimpleActivity(), MyCanvas.PathsChangedListener { | |||||||
|  |  | ||||||
|     override fun onOptionsItemSelected(item: MenuItem): Boolean { |     override fun onOptionsItemSelected(item: MenuItem): Boolean { | ||||||
|         when (item.itemId) { |         when (item.itemId) { | ||||||
|             R.id.menu_save -> saveImage() |             R.id.menu_save -> trySaveImage() | ||||||
|             R.id.menu_share -> shareImage() |             R.id.menu_share -> shareImage() | ||||||
|             R.id.clear -> my_canvas.clearCanvas() |             R.id.clear -> my_canvas.clearCanvas() | ||||||
|             R.id.change_background -> changeBackgroundClicked() |             R.id.change_background -> changeBackgroundClicked() | ||||||
| @@ -124,13 +122,16 @@ class MainActivity : SimpleActivity(), MyCanvas.PathsChangedListener { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun saveImage() { |     private fun trySaveImage() { | ||||||
|         if (!hasWriteStoragePermission()) { |         if (!hasWriteStoragePermission()) { | ||||||
|             ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), STORAGE_PERMISSION) |             saveImage() | ||||||
|             return |         } else { | ||||||
|  |             ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), STORAGE_PERMISSION) | ||||||
|         } |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|         val saveFileView = layoutInflater.inflate(R.layout.save_file, null) |     private fun saveImage() { | ||||||
|  |         val saveFileView = layoutInflater.inflate(R.layout.dialog_save_file, null) | ||||||
|  |  | ||||||
|         val builder = AlertDialog.Builder(this) |         val builder = AlertDialog.Builder(this) | ||||||
|         builder.setTitle(resources.getString(R.string.save_file)) |         builder.setTitle(resources.getString(R.string.save_file)) | ||||||
|   | |||||||
| @@ -6,19 +6,20 @@ | |||||||
|     android:orientation="vertical" |     android:orientation="vertical" | ||||||
|     android:padding="@dimen/activity_margin"> |     android:padding="@dimen/activity_margin"> | ||||||
| 
 | 
 | ||||||
|     <TextView |     <com.simplemobiletools.commons.views.MyTextView | ||||||
|         android:id="@+id/file_name_label" |         android:id="@+id/file_name_label" | ||||||
|         android:layout_width="wrap_content" |         android:layout_width="wrap_content" | ||||||
|         android:layout_height="wrap_content" |         android:layout_height="wrap_content" | ||||||
|         android:text="@string/file_name"/> |         android:text="@string/file_name"/> | ||||||
| 
 | 
 | ||||||
|     <EditText |     <com.simplemobiletools.commons.views.MyEditText | ||||||
|         android:id="@+id/file_name" |         android:id="@+id/file_name" | ||||||
|         android:layout_width="match_parent" |         android:layout_width="match_parent" | ||||||
|         android:layout_height="wrap_content" |         android:layout_height="wrap_content" | ||||||
|         android:layout_below="@+id/file_name_label" |         android:layout_below="@+id/file_name_label" | ||||||
|         android:layout_marginBottom="@dimen/activity_margin" |         android:layout_marginBottom="@dimen/activity_margin" | ||||||
|         android:singleLine="true"/> |         android:singleLine="true" | ||||||
|  |         android:textCursorDrawable="@null"/> | ||||||
| 
 | 
 | ||||||
|     <RadioGroup |     <RadioGroup | ||||||
|         android:id="@+id/extension_radio_group" |         android:id="@+id/extension_radio_group" | ||||||
| @@ -27,16 +28,17 @@ | |||||||
|         android:layout_below="@+id/file_name" |         android:layout_below="@+id/file_name" | ||||||
|         android:checkedButton="@+id/extension_radio_png"> |         android:checkedButton="@+id/extension_radio_png"> | ||||||
| 
 | 
 | ||||||
|         <RadioButton |         <com.simplemobiletools.commons.views.MyCompatRadioButton | ||||||
|             android:id="@+id/extension_radio_png" |             android:id="@+id/extension_radio_png" | ||||||
|             android:layout_width="match_parent" |             android:layout_width="match_parent" | ||||||
|             android:layout_height="wrap_content" |             android:layout_height="wrap_content" | ||||||
|             android:text=".png"/> |             android:text=".png"/> | ||||||
| 
 | 
 | ||||||
|         <RadioButton |         <com.simplemobiletools.commons.views.MyCompatRadioButton | ||||||
|             android:id="@+id/extension_radio_svg" |             android:id="@+id/extension_radio_svg" | ||||||
|             android:layout_width="match_parent" |             android:layout_width="match_parent" | ||||||
|             android:layout_height="wrap_content" |             android:layout_height="wrap_content" | ||||||
|             android:text=".svg"/> |             android:text=".svg"/> | ||||||
|  | 
 | ||||||
|     </RadioGroup> |     </RadioGroup> | ||||||
| </RelativeLayout> | </RelativeLayout> | ||||||
		Reference in New Issue
	
	Block a user