Premerge commit

This commit is contained in:
William Brawner 2017-08-23 14:23:18 -05:00
parent 6369d29e1d
commit 4a60c27d32
4 changed files with 13 additions and 7 deletions

View file

@ -20,7 +20,7 @@ android {
} }
defaultConfig { defaultConfig {
applicationId "com.wbrawner.simplemarkdown" applicationId "com.wbrawner.simplemarkdown"
minSdkVersion 15 minSdkVersion 19
targetSdkVersion 26 targetSdkVersion 26
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"

View file

@ -83,6 +83,7 @@ public class MarkdownPresenterImpl implements MarkdownPresenter {
@Override @Override
public void onMarkdownEdited(String markdown) { public void onMarkdownEdited(String markdown) {
setMarkdown(markdown);
Runnable generateMarkdown = () -> { Runnable generateMarkdown = () -> {
AndDown andDown = new AndDown(); AndDown andDown = new AndDown();
int hoedownFlags = int hoedownFlags =

View file

@ -59,7 +59,7 @@ public class MainActivity extends AppCompatActivity
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
((MarkdownApplication) getApplication()).getComponent().inject(this); ((MarkdownApplication) getApplication()).getComponent().inject(this);
setTitle(presenter.getFileName());
// Reset the background color // Reset the background color
getWindow().setBackgroundDrawable(new ColorDrawable(0xFFFFFFFF)); getWindow().setBackgroundDrawable(new ColorDrawable(0xFFFFFFFF));
ButterKnife.bind(this); ButterKnife.bind(this);
@ -142,8 +142,7 @@ public class MainActivity extends AppCompatActivity
presenter.setFileName(input.getText().toString()); presenter.setFileName(input.getText().toString());
setTitle(input.getText()); setTitle(input.getText());
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
String path = Environment.getExternalStorageDirectory() + "/" + String path = getDocsPath() + input.getText();
Environment.DIRECTORY_DOCUMENTS + "/" + input.getText();
presenter.saveMarkdown(path); presenter.saveMarkdown(path);
} }
} }
@ -155,6 +154,11 @@ public class MainActivity extends AppCompatActivity
builder.show(); builder.show();
} }
private String getDocsPath() {
return Environment.getExternalStorageDirectory() + "/" +
Environment.DIRECTORY_DOCUMENTS + "/";
}
@Override @Override
public void onRequestPermissionsResult(int requestCode, public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults) { String permissions[], int[] grantResults) {

View file

@ -7,8 +7,10 @@ import android.support.v4.app.Fragment;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
import com.wbrawner.simplemarkdown.BuildConfig;
import com.wbrawner.simplemarkdown.MarkdownApplication; import com.wbrawner.simplemarkdown.MarkdownApplication;
import com.wbrawner.simplemarkdown.R; import com.wbrawner.simplemarkdown.R;
import com.wbrawner.simplemarkdown.presentation.MarkdownPresenter; 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); View view = inflater.inflate(R.layout.fragment_preview, container, false);
ButterKnife.bind(this, view); ButterKnife.bind(this, view);
((MarkdownApplication) getActivity().getApplication()).getComponent().inject(this); ((MarkdownApplication) getActivity().getApplication()).getComponent().inject(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (BuildConfig.DEBUG)
WebView.setWebContentsDebuggingEnabled(true); WebView.setWebContentsDebuggingEnabled(true);
}
return view; return view;
} }
@ -55,7 +56,7 @@ public class PreviewFragment extends Fragment implements MarkdownPreviewView {
@Override @Override
public void updatePreview(String html) { public void updatePreview(String html) {
markdownPreview.post(() -> { markdownPreview.post(() -> {
markdownPreview.loadData(html, "text/html", "UTF-8"); markdownPreview.loadDataWithBaseURL(null, html, "text/html", "UTF-8", null);
}); });
} }