Search in sources :

Example 1 with WriteFileAbstraction

use of com.amaze.filemanager.asynchronous.asynctasks.WriteFileAbstraction in project AmazeFileManager by TeamAmaze.

the class TextEditorActivity method saveFile.

/**
 * Method initiates a worker thread which writes the {@link #mInput} bytes to the defined
 * file/uri 's output stream
 *
 * @param editTextString the edit text string
 */
private void saveFile(final String editTextString) {
    Toast.makeText(this, R.string.saving, Toast.LENGTH_SHORT).show();
    new WriteFileAbstraction(this, getContentResolver(), mFile, editTextString, cacheFile, isRootExplorer(), (errorCode) -> {
        switch(errorCode) {
            case WriteFileAbstraction.NORMAL:
                mOriginal = editTextString;
                mModified = false;
                invalidateOptionsMenu();
                Toast.makeText(getApplicationContext(), getString(R.string.done), Toast.LENGTH_SHORT).show();
                break;
            case WriteFileAbstraction.EXCEPTION_STREAM_NOT_FOUND:
                Toast.makeText(getApplicationContext(), R.string.error_file_not_found, Toast.LENGTH_SHORT).show();
                break;
            case WriteFileAbstraction.EXCEPTION_IO:
                Toast.makeText(getApplicationContext(), R.string.error_io, Toast.LENGTH_SHORT).show();
                break;
            case WriteFileAbstraction.EXCEPTION_SHELL_NOT_RUNNING:
                Toast.makeText(getApplicationContext(), R.string.rootfailure, Toast.LENGTH_SHORT).show();
                break;
        }
    }).execute();
}
Also used : ImageButton(android.widget.ImageButton) Bundle(android.os.Bundle) PreferencesConstants(com.amaze.filemanager.fragments.preference_fragments.PreferencesConstants) ColorUsage(com.amaze.filemanager.utils.color.ColorUsage) Uri(android.net.Uri) WindowManager(android.view.WindowManager) FrameLayout(android.widget.FrameLayout) Timer(java.util.Timer) Animator(android.animation.Animator) ThemedActivity(com.amaze.filemanager.activities.superclasses.ThemedActivity) AppTheme(com.amaze.filemanager.utils.theme.AppTheme) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) Map(java.util.Map) View(android.view.View) TimerTask(java.util.TimerTask) GeneralDialogCreation(com.amaze.filemanager.ui.dialogs.GeneralDialogCreation) ObjectAnimator(android.animation.ObjectAnimator) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ViewAnimationUtils(android.view.ViewAnimationUtils) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) DisplayMetrics(android.util.DisplayMetrics) ViewGroup(android.view.ViewGroup) FileNotFoundException(java.io.FileNotFoundException) RelativeLayout(android.widget.RelativeLayout) MapEntry(com.amaze.filemanager.utils.MapEntry) R(com.amaze.filemanager.R) PREFERENCE_COLORED_NAVIGATION(com.amaze.filemanager.fragments.preference_fragments.PreferencesConstants.PREFERENCE_COLORED_NAVIGATION) Snackbar(android.support.design.widget.Snackbar) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Window(android.view.Window) EditorInfo(android.view.inputmethod.EditorInfo) PREFERENCE_TEXTEDITOR_NEWSTACK(com.amaze.filemanager.fragments.preference_fragments.PreferencesConstants.PREFERENCE_TEXTEDITOR_NEWSTACK) TextWatcher(android.text.TextWatcher) Typeface(android.graphics.Typeface) ActivityManager(android.app.ActivityManager) Context(android.content.Context) Spanned(android.text.Spanned) Editable(android.text.Editable) MenuItem(android.view.MenuItem) InputMethodManager(android.view.inputmethod.InputMethodManager) ArrayList(java.util.ArrayList) Toast(android.widget.Toast) PreferenceUtils(com.amaze.filemanager.utils.PreferenceUtils) Menu(android.view.Menu) SystemBarTintManager(com.readystatesoftware.systembartint.SystemBarTintManager) Build(android.os.Build) WriteFileAbstraction(com.amaze.filemanager.asynchronous.asynctasks.WriteFileAbstraction) ReadFileTask(com.amaze.filemanager.asynchronous.asynctasks.ReadFileTask) EditableFileAbstraction(com.amaze.filemanager.filesystem.EditableFileAbstraction) SearchTextTask(com.amaze.filemanager.asynchronous.asynctasks.SearchTextTask) BackgroundColorSpan(android.text.style.BackgroundColorSpan) File(java.io.File) Color(android.graphics.Color) Utils(com.amaze.filemanager.utils.Utils) ScrollView(android.widget.ScrollView) FileUtils(com.amaze.filemanager.utils.files.FileUtils) EditText(android.widget.EditText) WriteFileAbstraction(com.amaze.filemanager.asynchronous.asynctasks.WriteFileAbstraction)

Example 2 with WriteFileAbstraction

use of com.amaze.filemanager.asynchronous.asynctasks.WriteFileAbstraction in project AmazeFileManager by TeamAmaze.

the class TextEditorActivity method saveFile.

/**
 * Method initiates a worker thread which writes the {@link #mInput} bytes to the defined file/uri
 * 's output stream
 *
 * @param editTextString the edit text string
 */
private void saveFile(final String editTextString) {
    Toast.makeText(this, R.string.saving, Toast.LENGTH_SHORT).show();
    new WriteFileAbstraction(this, getContentResolver(), mFile, editTextString, cacheFile, isRootExplorer(), (errorCode) -> {
        switch(errorCode) {
            case WriteFileAbstraction.NORMAL:
                mOriginal = editTextString;
                mModified = false;
                invalidateOptionsMenu();
                Toast.makeText(getApplicationContext(), getString(R.string.done), Toast.LENGTH_SHORT).show();
                break;
            case WriteFileAbstraction.EXCEPTION_STREAM_NOT_FOUND:
                Toast.makeText(getApplicationContext(), R.string.error_file_not_found, Toast.LENGTH_SHORT).show();
                break;
            case WriteFileAbstraction.EXCEPTION_IO:
                Toast.makeText(getApplicationContext(), R.string.error_io, Toast.LENGTH_SHORT).show();
                break;
            case WriteFileAbstraction.EXCEPTION_SHELL_NOT_RUNNING:
                Toast.makeText(getApplicationContext(), R.string.root_failure, Toast.LENGTH_SHORT).show();
                break;
        }
    }).execute();
}
Also used : ImageButton(android.widget.ImageButton) CONTENT(com.amaze.filemanager.filesystem.EditableFileAbstraction.Scheme.CONTENT) Bundle(android.os.Bundle) Uri(android.net.Uri) Timer(java.util.Timer) Animator(android.animation.Animator) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) PREFERENCE_TEXTEDITOR_NEWSTACK(com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants.PREFERENCE_TEXTEDITOR_NEWSTACK) Map(java.util.Map) View(android.view.View) TimerTask(java.util.TimerTask) GeneralDialogCreation(com.amaze.filemanager.ui.dialogs.GeneralDialogCreation) ObjectAnimator(android.animation.ObjectAnimator) ViewAnimationUtils(android.view.ViewAnimationUtils) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) FileUtils(com.amaze.filemanager.filesystem.files.FileUtils) DisplayMetrics(android.util.DisplayMetrics) RelativeLayout(android.widget.RelativeLayout) MapEntry(com.amaze.filemanager.utils.MapEntry) R(com.amaze.filemanager.R) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) AppTheme(com.amaze.filemanager.ui.theme.AppTheme) Snackbar(com.google.android.material.snackbar.Snackbar) EditorInfo(android.view.inputmethod.EditorInfo) TextWatcher(android.text.TextWatcher) Typeface(android.graphics.Typeface) Context(android.content.Context) Spanned(android.text.Spanned) OpenMode(com.amaze.filemanager.file_operations.filesystem.OpenMode) Editable(android.text.Editable) ArrayList(java.util.ArrayList) MenuItem(android.view.MenuItem) InputMethodManager(android.view.inputmethod.InputMethodManager) HybridFileParcelable(com.amaze.filemanager.filesystem.HybridFileParcelable) Toast(android.widget.Toast) Menu(android.view.Menu) Build(android.os.Build) WriteFileAbstraction(com.amaze.filemanager.asynchronous.asynctasks.WriteFileAbstraction) ReadFileTask(com.amaze.filemanager.asynchronous.asynctasks.ReadFileTask) EditableFileAbstraction(com.amaze.filemanager.filesystem.EditableFileAbstraction) SearchTextTask(com.amaze.filemanager.asynchronous.asynctasks.SearchTextTask) BackgroundColorSpan(android.text.style.BackgroundColorSpan) File(java.io.File) Color(android.graphics.Color) Utils(com.amaze.filemanager.utils.Utils) ScrollView(android.widget.ScrollView) ThemedActivity(com.amaze.filemanager.ui.activities.superclasses.ThemedActivity) FILE(com.amaze.filemanager.filesystem.EditableFileAbstraction.Scheme.FILE) EditText(android.widget.EditText) WriteFileAbstraction(com.amaze.filemanager.asynchronous.asynctasks.WriteFileAbstraction)

Aggregations

Animator (android.animation.Animator)2 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)2 ObjectAnimator (android.animation.ObjectAnimator)2 Context (android.content.Context)2 Color (android.graphics.Color)2 Typeface (android.graphics.Typeface)2 Uri (android.net.Uri)2 Build (android.os.Build)2 Bundle (android.os.Bundle)2 Editable (android.text.Editable)2 Spanned (android.text.Spanned)2 TextWatcher (android.text.TextWatcher)2 BackgroundColorSpan (android.text.style.BackgroundColorSpan)2 DisplayMetrics (android.util.DisplayMetrics)2 Menu (android.view.Menu)2 MenuItem (android.view.MenuItem)2 View (android.view.View)2 ViewAnimationUtils (android.view.ViewAnimationUtils)2 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)2 EditorInfo (android.view.inputmethod.EditorInfo)2