mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-06-05 17:00:23 +02:00
change "Save as file" to "Export as file" to make it clear its not synced
This commit is contained in:
@ -33,7 +33,7 @@ import java.nio.charset.Charset
|
||||
|
||||
class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
||||
val STORAGE_OPEN_FILE = 1
|
||||
val STORAGE_SAVE_AS_FILE = 2
|
||||
val STORAGE_EXPORT_AS_FILE = 2
|
||||
|
||||
lateinit var mCurrentNote: Note
|
||||
lateinit var mAdapter: NotesPagerAdapter
|
||||
@ -113,7 +113,7 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
||||
R.id.rename_note -> displayRenameDialog()
|
||||
R.id.share -> shareText()
|
||||
R.id.open_file -> tryOpenFile()
|
||||
R.id.save_as_file -> trySaveAsFile()
|
||||
R.id.export_as_file -> tryExportAsFile()
|
||||
R.id.delete_note -> displayDeleteNotePrompt()
|
||||
R.id.settings -> startActivity(Intent(applicationContext, SettingsActivity::class.java))
|
||||
R.id.about -> launchAbout()
|
||||
@ -181,21 +181,21 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
||||
}
|
||||
}
|
||||
|
||||
private fun trySaveAsFile() {
|
||||
private fun tryExportAsFile() {
|
||||
if (hasWriteStoragePermission()) {
|
||||
saveAsFile()
|
||||
exportAsFile()
|
||||
} else {
|
||||
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), STORAGE_SAVE_AS_FILE)
|
||||
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), STORAGE_EXPORT_AS_FILE)
|
||||
}
|
||||
}
|
||||
|
||||
private fun saveAsFile() {
|
||||
SaveAsDialog(this, mCurrentNote) {
|
||||
saveNoteValueToFile(it, getCurrentNoteText())
|
||||
private fun exportAsFile() {
|
||||
ExportAsDialog(this, mCurrentNote) {
|
||||
exportNoteValueToFile(it, getCurrentNoteText())
|
||||
}
|
||||
}
|
||||
|
||||
fun saveNoteValueToFile(path: String, content: String) {
|
||||
fun exportNoteValueToFile(path: String, content: String) {
|
||||
try {
|
||||
val file = File(path)
|
||||
if (file.isDirectory) {
|
||||
@ -306,8 +306,8 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
||||
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
if (requestCode == STORAGE_OPEN_FILE) {
|
||||
openFile()
|
||||
} else if (requestCode == STORAGE_SAVE_AS_FILE) {
|
||||
saveAsFile()
|
||||
} else if (requestCode == STORAGE_EXPORT_AS_FILE) {
|
||||
exportAsFile()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,14 +9,14 @@ import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.notes.R
|
||||
import com.simplemobiletools.notes.activities.SimpleActivity
|
||||
import com.simplemobiletools.notes.models.Note
|
||||
import kotlinx.android.synthetic.main.dialog_save_as.view.*
|
||||
import kotlinx.android.synthetic.main.dialog_export_as.view.*
|
||||
import java.io.File
|
||||
|
||||
class SaveAsDialog(val activity: SimpleActivity, val note: Note, val callback: (savePath: String) -> Unit) {
|
||||
class ExportAsDialog(val activity: SimpleActivity, val note: Note, val callback: (exportPath: String) -> Unit) {
|
||||
|
||||
init {
|
||||
var realPath = File(note.path).parent ?: Environment.getExternalStorageDirectory().toString()
|
||||
val view = LayoutInflater.from(activity).inflate(R.layout.dialog_save_as, null).apply {
|
||||
val view = LayoutInflater.from(activity).inflate(R.layout.dialog_export_as, null).apply {
|
||||
file_path.text = activity.humanizePath(realPath)
|
||||
|
||||
file_name.setText(note.title)
|
||||
@ -33,7 +33,7 @@ class SaveAsDialog(val activity: SimpleActivity, val note: Note, val callback: (
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
activity.setupDialogStuff(view, this, R.string.save_as)
|
||||
activity.setupDialogStuff(view, this, R.string.export_as_file)
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
|
||||
val filename = view.file_name.value
|
||||
|
@ -94,7 +94,7 @@ class NoteFragment : Fragment() {
|
||||
mDb.updateNoteValue(note)
|
||||
(activity as MainActivity).noteSavedSuccessfully(note.title)
|
||||
} else {
|
||||
(activity as MainActivity).saveNoteValueToFile(note.path, getCurrentNoteViewText())
|
||||
(activity as MainActivity).exportNoteValueToFile(note.path, getCurrentNoteViewText())
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user