Applied theme
BIN
app/src/main/ic_launcher-web.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
app/src/main/ic_launcher_round-web.png
Normal file
After Width: | Height: | Size: 34 KiB |
|
@ -13,6 +13,7 @@ import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v4.content.FileProvider;
|
import android.support.v4.content.FileProvider;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
|
import android.text.Layout;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -62,7 +63,8 @@ public class EditFragment extends Fragment {
|
||||||
filter
|
filter
|
||||||
);
|
);
|
||||||
mContext = getActivity();
|
mContext = getActivity();
|
||||||
mFileUtils = new FileUtils(mContext); }
|
mFileUtils = new FileUtils(mContext);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
@ -107,6 +109,16 @@ public class EditFragment extends Fragment {
|
||||||
public static void updatePreview(Context context) {
|
public static void updatePreview(Context context) {
|
||||||
Intent broadcastIntent = new Intent(PreviewFragment.PREVIEW_ACTION);
|
Intent broadcastIntent = new Intent(PreviewFragment.PREVIEW_ACTION);
|
||||||
broadcastIntent.putExtra("markdownData", mMarkdownEditor.getText().toString());
|
broadcastIntent.putExtra("markdownData", mMarkdownEditor.getText().toString());
|
||||||
|
Layout layout = mMarkdownEditor.getLayout();
|
||||||
|
if (layout != null) {
|
||||||
|
int line =
|
||||||
|
layout.getLineForOffset(mMarkdownEditor.getSelectionStart());
|
||||||
|
int baseline = layout.getLineBaseline(line);
|
||||||
|
int ascent = layout.getLineAscent(line);
|
||||||
|
float yPos = (baseline + ascent) * 1.0f;
|
||||||
|
float yPercent = yPos / mMarkdownEditor.getMeasuredHeight();
|
||||||
|
broadcastIntent.putExtra("scrollY", yPercent);
|
||||||
|
}
|
||||||
LocalBroadcastManager manager = LocalBroadcastManager.getInstance(context);
|
LocalBroadcastManager manager = LocalBroadcastManager.getInstance(context);
|
||||||
manager.sendBroadcast(broadcastIntent);
|
manager.sendBroadcast(broadcastIntent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
@ -90,10 +91,13 @@ public class MainActivity extends AppCompatActivity
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
getWindow().setBackgroundDrawable(new ColorDrawable(0xFFFFFFFF));
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
pager.setAdapter(
|
pager.setAdapter(
|
||||||
new EditPagerAdapter(getSupportFragmentManager(), MainActivity.this)
|
new EditPagerAdapter(getSupportFragmentManager(), MainActivity.this)
|
||||||
);
|
);
|
||||||
|
pager.setPageMargin(1);
|
||||||
|
pager.setPageMarginDrawable(R.color.colorAccent);
|
||||||
mFilesDir = getFilesDir();
|
mFilesDir = getFilesDir();
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
if (intent != null && !intent.getAction().equals(Intent.ACTION_MAIN) && intent.getData() != null) {
|
if (intent != null && !intent.getAction().equals(Intent.ACTION_MAIN) && intent.getData() != null) {
|
||||||
|
|
|
@ -14,6 +14,7 @@ import android.support.v4.app.ActivityCompat;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -28,11 +29,11 @@ public class PreviewFragment extends Fragment {
|
||||||
private static final String TAG = PreviewFragment.class.getSimpleName();
|
private static final String TAG = PreviewFragment.class.getSimpleName();
|
||||||
private static final int INTERNET_REQUEST = 0;
|
private static final int INTERNET_REQUEST = 0;
|
||||||
private WebView mMarkdownView;
|
private WebView mMarkdownView;
|
||||||
private boolean timeoutActive = false;
|
|
||||||
|
|
||||||
@BindView(R.id.markdown_view)
|
@BindView(R.id.markdown_view)
|
||||||
WebView markdownView;
|
WebView markdownView;
|
||||||
|
|
||||||
|
public static final String SCROLL_ACTION = "com.wbrawner.simplemarkdown.scroll";
|
||||||
public static final String PREVIEW_ACTION = "com.wbrawner.simplemarkdown.preview";
|
public static final String PREVIEW_ACTION = "com.wbrawner.simplemarkdown.preview";
|
||||||
|
|
||||||
public PreviewFragment() {
|
public PreviewFragment() {
|
||||||
|
@ -77,16 +78,25 @@ public class PreviewFragment extends Fragment {
|
||||||
private class MarkdownBroadcastSender extends BroadcastReceiver {
|
private class MarkdownBroadcastSender extends BroadcastReceiver {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
if (intent.hasExtra("markdownData")) {
|
Log.d(TAG, "Intent received: " + intent.getAction());
|
||||||
String data = intent.getStringExtra("markdownData");
|
switch (intent.getAction()) {
|
||||||
markdown(data);
|
case PREVIEW_ACTION:
|
||||||
|
if (intent.hasExtra("markdownData")) {
|
||||||
|
String data = intent.getStringExtra("markdownData");
|
||||||
|
int yPos = 0;
|
||||||
|
if (intent.hasExtra("scrollY")) {
|
||||||
|
float yPercent = intent.getFloatExtra("scrollY", 0);
|
||||||
|
Log.d(TAG, "Scrolling to: " + yPercent);
|
||||||
|
yPos = Math.round(mMarkdownView.getContentHeight() * yPercent);
|
||||||
|
}
|
||||||
|
markdown(data, yPos);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void markdown(String text) {
|
private void markdown(final String text, final int scrollY) {
|
||||||
final String iText = text;
|
|
||||||
final Handler handler = new Handler();
|
|
||||||
Thread setMarkdown = new Thread() {
|
Thread setMarkdown = new Thread() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -94,14 +104,11 @@ public class PreviewFragment extends Fragment {
|
||||||
int hoedownFlags =
|
int hoedownFlags =
|
||||||
AndDown.HOEDOWN_EXT_STRIKETHROUGH | AndDown.HOEDOWN_EXT_TABLES |
|
AndDown.HOEDOWN_EXT_STRIKETHROUGH | AndDown.HOEDOWN_EXT_TABLES |
|
||||||
AndDown.HOEDOWN_EXT_UNDERLINE | AndDown.HOEDOWN_EXT_SUPERSCRIPT;
|
AndDown.HOEDOWN_EXT_UNDERLINE | AndDown.HOEDOWN_EXT_SUPERSCRIPT;
|
||||||
String html = andDown.markdownToHtml(iText, hoedownFlags, 0);
|
String html = andDown.markdownToHtml(text, hoedownFlags, 0);
|
||||||
mMarkdownView.loadDataWithBaseURL(null, html, "text/html", "UTF-8", null);
|
mMarkdownView.loadDataWithBaseURL(null, html, "text/html", "UTF-8", null);
|
||||||
timeoutActive = false;
|
mMarkdownView.scrollTo(0, scrollY);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (!timeoutActive) {
|
setMarkdown.run();
|
||||||
timeoutActive = true;
|
|
||||||
handler.postDelayed(setMarkdown, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
BIN
app/src/main/res/drawable-hdpi/ic_action_save.png
Normal file
After Width: | Height: | Size: 561 B |
BIN
app/src/main/res/drawable-hdpi/ic_action_share.png
Normal file
After Width: | Height: | Size: 793 B |
BIN
app/src/main/res/drawable-land/bg_splash.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
app/src/main/res/drawable-mdpi/ic_action_save.png
Normal file
After Width: | Height: | Size: 304 B |
BIN
app/src/main/res/drawable-mdpi/ic_action_share.png
Normal file
After Width: | Height: | Size: 458 B |
BIN
app/src/main/res/drawable-xhdpi/ic_action_save.png
Normal file
After Width: | Height: | Size: 593 B |
BIN
app/src/main/res/drawable-xhdpi/ic_action_share.png
Normal file
After Width: | Height: | Size: 993 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_action_save.png
Normal file
After Width: | Height: | Size: 994 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_action_share.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/ic_action_save.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/ic_action_share.png
Normal file
After Width: | Height: | Size: 2 KiB |
BIN
app/src/main/res/drawable/bg_splash.png
Normal file
After Width: | Height: | Size: 22 KiB |
|
@ -4,12 +4,12 @@
|
||||||
<item
|
<item
|
||||||
android:title="@string/action_save"
|
android:title="@string/action_save"
|
||||||
android:id="@+id/action_save"
|
android:id="@+id/action_save"
|
||||||
android:icon="@android:drawable/ic_menu_save"
|
android:icon="@drawable/ic_action_save"
|
||||||
app:showAsAction="always" />
|
app:showAsAction="always" />
|
||||||
<item
|
<item
|
||||||
android:title="@string/action_share"
|
android:title="@string/action_share"
|
||||||
android:id="@+id/action_share"
|
android:id="@+id/action_share"
|
||||||
android:icon="@android:drawable/ic_menu_share"
|
android:icon="@drawable/ic_action_share"
|
||||||
app:showAsAction="always" />
|
app:showAsAction="always" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_load"
|
android:id="@+id/action_load"
|
||||||
|
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 3 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 799 B |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 6 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 7 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 10 KiB |
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<color name="colorPrimary">#3F51B5</color>
|
<color name="colorPrimary">#d32f2f</color>
|
||||||
<color name="colorPrimaryDark">#303F9F</color>
|
<color name="colorPrimaryDark">#b71c1c</color>
|
||||||
<color name="colorAccent">#FF4081</color>
|
<color name="colorAccent">#ef9a9a</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<item name="colorPrimary">@color/colorPrimary</item>
|
<item name="colorPrimary">@color/colorPrimary</item>
|
||||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||||
<item name="colorAccent">@color/colorAccent</item>
|
<item name="colorAccent">@color/colorAccent</item>
|
||||||
|
<item name="android:windowBackground">@drawable/bg_splash</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="AppTheme.NoActionBar">
|
<style name="AppTheme.NoActionBar">
|
||||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#Tue Jul 25 18:04:23 CDT 2017
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
|