Skip to content

Commit

Permalink
Version 3.1.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
suragch committed Nov 27, 2018
1 parent c7dd1be commit 8e4d3d5
Show file tree
Hide file tree
Showing 8 changed files with 215 additions and 199 deletions.

This file was deleted.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

336 changes: 169 additions & 167 deletions .idea/workspace.xml

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions Chimee.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="Chimee" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
<option name="BUILDABLE" value="false" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
Expand Down
2 changes: 1 addition & 1 deletion app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@
<orderEntry type="library" name="Gradle: com.android.support:customview-28.0.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:localbroadcastmanager-28.0.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-vector-drawable-28.0.0" level="project" />
<orderEntry type="library" name="Gradle: net.studymongolian:mongol-library-1.16.6" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:interpolator-28.0.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-core-utils-28.0.0" level="project" />
<orderEntry type="library" name="Gradle: net.studymongolian:mongol-library-1.17.2" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-core-ui-28.0.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:slidingpanelayout-28.0.0" level="project" />
<orderEntry type="library" name="Gradle: android.arch.lifecycle:viewmodel-1.1.1" level="project" />
Expand Down
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "net.studymongolian.chimee"
minSdkVersion 14
targetSdkVersion 28
versionCode 26
versionName "3.0.1"
versionCode 28
versionName "3.1.0"
}

buildTypes {
Expand All @@ -25,5 +25,5 @@ dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'net.studymongolian:mongol-library:1.16.6'
implementation 'net.studymongolian:mongol-library:1.17.2'
}
Binary file modified app/release/app-release.apk
Binary file not shown.
48 changes: 33 additions & 15 deletions app/src/main/java/net/studymongolian/chimee/OverlayTextView.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class OverlayTextView extends ViewGroup {
private static final int BORDER_SIZE_PX = 1;
private static final float BOX_CONTROL_SIZE_DP = 10;
private static final float CONTROL_TOUCH_AREA_SIZE_DP = 48;
private static final int MIN_TEXT_LINES_FOR_LINE_SPACING = 3;
private static final float LINE_SPACING_ADJUSTMENT_DP = 5;

boolean hasFocus = true;

Expand All @@ -38,6 +40,7 @@ public class OverlayTextView extends ViewGroup {
private float mShadowDxMultiplier = 0;
private float mShadowDyMultiplier = 0;
private float mBgCornerRadiusMultiplier = 0;
private int lineSpacingPx;

public OverlayTextView(Context context) {
super(context);
Expand All @@ -58,6 +61,7 @@ private void setDpValues() {
textPadding = convertDpToPx(TEXT_PADDING_DP);
controlTouchAreaSize = convertDpToPx(CONTROL_TOUCH_AREA_SIZE_DP);
boxControlSize = convertDpToPx(BOX_CONTROL_SIZE_DP);
lineSpacingPx = convertDpToPx(LINE_SPACING_ADJUSTMENT_DP);
}

private int convertDpToPx(float dp) {
Expand Down Expand Up @@ -108,6 +112,7 @@ private void setupControls(Context context) {

float dx;
int[] textViewLocation = new int[2];
float oldDesiredWidth;

@SuppressLint("ClickableViewAccessibility")
@Override
Expand All @@ -118,15 +123,40 @@ public boolean onTouch(View v, MotionEvent event) {
mTextView.getLocationOnScreen(textViewLocation);
int rightEdgeStart = mTextView.getRight() + textViewLocation[0];
dx = rightEdgeStart - event.getRawX();
oldDesiredWidth = getDesiredWidth(event);
return true;
case MotionEvent.ACTION_MOVE:
float desiredWidth = event.getRawX() + dx - textViewLocation[0];
float scale = desiredWidth / mTextView.getUnscaledWidth();
mTextView.setScaleX(scale);
float desiredWidth = getDesiredWidth(event);
if (mTextView.getLineCount() >= MIN_TEXT_LINES_FOR_LINE_SPACING) {
setLineSpacing(desiredWidth);
} else {
scaleText(desiredWidth);
}
oldDesiredWidth = desiredWidth;
return true;
}
return true;
}

private float getDesiredWidth(MotionEvent event) {
return event.getRawX() + dx - textViewLocation[0];
}

private void setLineSpacing(float desiredWidth) {
float currentLineSpacing = mTextView.getLineSpacingExtra();
int numLines = mTextView.getLineCount();
float adjustment = lineSpacingPx / (numLines - 1);
if (oldDesiredWidth < desiredWidth) {
mTextView.setLineSpacing(currentLineSpacing + adjustment, 1);
} else {
mTextView.setLineSpacing(currentLineSpacing - adjustment, 1);
}
}

private void scaleText(float desiredWidth) {
float scale = desiredWidth / mTextView.getUnscaledWidth();
mTextView.setScaleX(scale);
}
};

OnTouchListener fontSizeTouchListener = new OnTouchListener() {
Expand Down Expand Up @@ -241,11 +271,6 @@ private int getTextViewLeft() {
return getPaddingLeft();
}

// in local coordinates
private int getTextViewRight() {
return getPaddingLeft() + mTextView.getWidth();
}

// in local coordinates
private int getTextViewBottom() {
return getTextViewTop() + mTextView.getHeight();
Expand Down Expand Up @@ -451,13 +476,6 @@ public PointF getTextViewTopLeft() {
return new PointF(x, y);
}

// in parent coordinates
public PointF getTextViewTopRight() {
float x = getX() + getTextViewRight();// + mTextView.getPaddingLeft();
float y = getY() + getTextViewTop();// + mTextView.getPaddingTop();
return new PointF(x, y);
}

// in parent coordinates
public PointF getTextViewBottomLeft() {
float x = getX() + getTextViewLeft();// + mTextView.getPaddingLeft();
Expand Down

0 comments on commit 8e4d3d5

Please sign in to comment.