Applied theme

This commit is contained in:
William Brawner 2017-08-04 20:04:00 -05:00
parent 4064ca5163
commit 66ebc6f675
32 changed files with 49 additions and 19 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View file

@ -13,6 +13,7 @@ import android.support.v4.app.FragmentActivity;
import android.support.v4.content.FileProvider;
import android.support.v4.content.LocalBroadcastManager;
import android.text.Editable;
import android.text.Layout;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
@ -62,7 +63,8 @@ public class EditFragment extends Fragment {
filter
);
mContext = getActivity();
mFileUtils = new FileUtils(mContext); }
mFileUtils = new FileUtils(mContext);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@ -107,6 +109,16 @@ public class EditFragment extends Fragment {
public static void updatePreview(Context context) {
Intent broadcastIntent = new Intent(PreviewFragment.PREVIEW_ACTION);
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);
manager.sendBroadcast(broadcastIntent);
}

View file

@ -9,6 +9,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Environment;
import android.support.annotation.Nullable;
@ -90,10 +91,13 @@ public class MainActivity extends AppCompatActivity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getWindow().setBackgroundDrawable(new ColorDrawable(0xFFFFFFFF));
ButterKnife.bind(this);
pager.setAdapter(
new EditPagerAdapter(getSupportFragmentManager(), MainActivity.this)
);
pager.setPageMargin(1);
pager.setPageMarginDrawable(R.color.colorAccent);
mFilesDir = getFilesDir();
Intent intent = getIntent();
if (intent != null && !intent.getAction().equals(Intent.ACTION_MAIN) && intent.getData() != null) {

View file

@ -14,6 +14,7 @@ import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -28,11 +29,11 @@ public class PreviewFragment extends Fragment {
private static final String TAG = PreviewFragment.class.getSimpleName();
private static final int INTERNET_REQUEST = 0;
private WebView mMarkdownView;
private boolean timeoutActive = false;
@BindView(R.id.markdown_view)
WebView markdownView;
public static final String SCROLL_ACTION = "com.wbrawner.simplemarkdown.scroll";
public static final String PREVIEW_ACTION = "com.wbrawner.simplemarkdown.preview";
public PreviewFragment() {
@ -77,16 +78,25 @@ public class PreviewFragment extends Fragment {
private class MarkdownBroadcastSender extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.hasExtra("markdownData")) {
String data = intent.getStringExtra("markdownData");
markdown(data);
Log.d(TAG, "Intent received: " + intent.getAction());
switch (intent.getAction()) {
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) {
final String iText = text;
final Handler handler = new Handler();
private void markdown(final String text, final int scrollY) {
Thread setMarkdown = new Thread() {
@Override
public void run() {
@ -94,14 +104,11 @@ public class PreviewFragment extends Fragment {
int hoedownFlags =
AndDown.HOEDOWN_EXT_STRIKETHROUGH | AndDown.HOEDOWN_EXT_TABLES |
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);
timeoutActive = false;
mMarkdownView.scrollTo(0, scrollY);
}
};
if (!timeoutActive) {
timeoutActive = true;
handler.postDelayed(setMarkdown, 0);
}
setMarkdown.run();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 561 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 793 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 993 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 994 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View file

@ -4,12 +4,12 @@
<item
android:title="@string/action_save"
android:id="@+id/action_save"
android:icon="@android:drawable/ic_menu_save"
android:icon="@drawable/ic_action_save"
app:showAsAction="always" />
<item
android:title="@string/action_share"
android:id="@+id/action_share"
android:icon="@android:drawable/ic_menu_share"
android:icon="@drawable/ic_action_share"
app:showAsAction="always" />
<item
android:id="@+id/action_load"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 799 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

After

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="colorPrimary">#d32f2f</color>
<color name="colorPrimaryDark">#b71c1c</color>
<color name="colorAccent">#ef9a9a</color>
</resources>

View file

@ -6,6 +6,7 @@
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowBackground">@drawable/bg_splash</item>
</style>
<style name="AppTheme.NoActionBar">

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View 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