diff --git a/app/build.gradle b/app/build.gradle index 17c68d6..f4dc97c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -20,7 +20,7 @@ android { } defaultConfig { applicationId "com.wbrawner.simplemarkdown" - minSdkVersion 15 + minSdkVersion 19 targetSdkVersion 26 versionCode 1 versionName "1.0" diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/presentation/MarkdownPresenterImpl.java b/app/src/main/java/com/wbrawner/simplemarkdown/presentation/MarkdownPresenterImpl.java index 540d5ee..9ac3a80 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/presentation/MarkdownPresenterImpl.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/presentation/MarkdownPresenterImpl.java @@ -83,6 +83,7 @@ public class MarkdownPresenterImpl implements MarkdownPresenter { @Override public void onMarkdownEdited(String markdown) { + setMarkdown(markdown); Runnable generateMarkdown = () -> { AndDown andDown = new AndDown(); int hoedownFlags = diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MainActivity.java b/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MainActivity.java index 9207ac8..44797dd 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MainActivity.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MainActivity.java @@ -59,7 +59,7 @@ public class MainActivity extends AppCompatActivity setContentView(R.layout.activity_main); ((MarkdownApplication) getApplication()).getComponent().inject(this); - + setTitle(presenter.getFileName()); // Reset the background color getWindow().setBackgroundDrawable(new ColorDrawable(0xFFFFFFFF)); ButterKnife.bind(this); @@ -142,8 +142,7 @@ public class MainActivity extends AppCompatActivity presenter.setFileName(input.getText().toString()); setTitle(input.getText()); if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { - String path = Environment.getExternalStorageDirectory() + "/" + - Environment.DIRECTORY_DOCUMENTS + "/" + input.getText(); + String path = getDocsPath() + input.getText(); presenter.saveMarkdown(path); } } @@ -155,6 +154,11 @@ public class MainActivity extends AppCompatActivity builder.show(); } + private String getDocsPath() { + return Environment.getExternalStorageDirectory() + "/" + + Environment.DIRECTORY_DOCUMENTS + "/"; + } + @Override public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/view/fragment/PreviewFragment.java b/app/src/main/java/com/wbrawner/simplemarkdown/view/fragment/PreviewFragment.java index 89fd514..7eafb01 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/view/fragment/PreviewFragment.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/view/fragment/PreviewFragment.java @@ -7,8 +7,10 @@ import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.webkit.WebSettings; import android.webkit.WebView; +import com.wbrawner.simplemarkdown.BuildConfig; import com.wbrawner.simplemarkdown.MarkdownApplication; import com.wbrawner.simplemarkdown.R; import com.wbrawner.simplemarkdown.presentation.MarkdownPresenter; @@ -39,9 +41,8 @@ public class PreviewFragment extends Fragment implements MarkdownPreviewView { View view = inflater.inflate(R.layout.fragment_preview, container, false); ButterKnife.bind(this, view); ((MarkdownApplication) getActivity().getApplication()).getComponent().inject(this); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + if (BuildConfig.DEBUG) WebView.setWebContentsDebuggingEnabled(true); - } return view; } @@ -55,7 +56,7 @@ public class PreviewFragment extends Fragment implements MarkdownPreviewView { @Override public void updatePreview(String html) { markdownPreview.post(() -> { - markdownPreview.loadData(html, "text/html", "UTF-8"); + markdownPreview.loadDataWithBaseURL(null, html, "text/html", "UTF-8", null); }); }