Skip to content

Commit 8e4d3d5

Browse files
committed
Version 3.1.0 release
1 parent c7dd1be commit 8e4d3d5

8 files changed

Lines changed: 215 additions & 199 deletions

File tree

.idea/libraries/Gradle__net_studymongolian_mongol_library_1_16_6.xml

Lines changed: 0 additions & 12 deletions
This file was deleted.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 169 additions & 167 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Chimee.iml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<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">
3+
<component name="FacetManager">
4+
<facet type="java-gradle" name="Java-Gradle">
5+
<configuration>
6+
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
7+
<option name="BUILDABLE" value="false" />
8+
</configuration>
9+
</facet>
10+
</component>
311
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">
412
<exclude-output />
513
<content url="file://$MODULE_DIR$">

app/app.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@
134134
<orderEntry type="library" name="Gradle: com.android.support:customview-28.0.0" level="project" />
135135
<orderEntry type="library" name="Gradle: com.android.support:localbroadcastmanager-28.0.0" level="project" />
136136
<orderEntry type="library" name="Gradle: com.android.support:support-vector-drawable-28.0.0" level="project" />
137-
<orderEntry type="library" name="Gradle: net.studymongolian:mongol-library-1.16.6" level="project" />
138137
<orderEntry type="library" name="Gradle: com.android.support:interpolator-28.0.0" level="project" />
139138
<orderEntry type="library" name="Gradle: com.android.support:support-core-utils-28.0.0" level="project" />
139+
<orderEntry type="library" name="Gradle: net.studymongolian:mongol-library-1.17.2" level="project" />
140140
<orderEntry type="library" name="Gradle: com.android.support:support-core-ui-28.0.0" level="project" />
141141
<orderEntry type="library" name="Gradle: com.android.support:slidingpanelayout-28.0.0" level="project" />
142142
<orderEntry type="library" name="Gradle: android.arch.lifecycle:viewmodel-1.1.1" level="project" />

app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ android {
77
applicationId "net.studymongolian.chimee"
88
minSdkVersion 14
99
targetSdkVersion 28
10-
versionCode 26
11-
versionName "3.0.1"
10+
versionCode 28
11+
versionName "3.1.0"
1212
}
1313

1414
buildTypes {
@@ -25,5 +25,5 @@ dependencies {
2525
implementation 'com.android.support:appcompat-v7:28.0.0'
2626
implementation 'com.android.support:recyclerview-v7:28.0.0'
2727
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
28-
implementation 'net.studymongolian:mongol-library:1.16.6'
28+
implementation 'net.studymongolian:mongol-library:1.17.2'
2929
}

app/release/app-release.apk

732 Bytes
Binary file not shown.

app/src/main/java/net/studymongolian/chimee/OverlayTextView.java

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public class OverlayTextView extends ViewGroup {
2020
private static final int BORDER_SIZE_PX = 1;
2121
private static final float BOX_CONTROL_SIZE_DP = 10;
2222
private static final float CONTROL_TOUCH_AREA_SIZE_DP = 48;
23+
private static final int MIN_TEXT_LINES_FOR_LINE_SPACING = 3;
24+
private static final float LINE_SPACING_ADJUSTMENT_DP = 5;
2325

2426
boolean hasFocus = true;
2527

@@ -38,6 +40,7 @@ public class OverlayTextView extends ViewGroup {
3840
private float mShadowDxMultiplier = 0;
3941
private float mShadowDyMultiplier = 0;
4042
private float mBgCornerRadiusMultiplier = 0;
43+
private int lineSpacingPx;
4144

4245
public OverlayTextView(Context context) {
4346
super(context);
@@ -58,6 +61,7 @@ private void setDpValues() {
5861
textPadding = convertDpToPx(TEXT_PADDING_DP);
5962
controlTouchAreaSize = convertDpToPx(CONTROL_TOUCH_AREA_SIZE_DP);
6063
boxControlSize = convertDpToPx(BOX_CONTROL_SIZE_DP);
64+
lineSpacingPx = convertDpToPx(LINE_SPACING_ADJUSTMENT_DP);
6165
}
6266

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

109113
float dx;
110114
int[] textViewLocation = new int[2];
115+
float oldDesiredWidth;
111116

112117
@SuppressLint("ClickableViewAccessibility")
113118
@Override
@@ -118,15 +123,40 @@ public boolean onTouch(View v, MotionEvent event) {
118123
mTextView.getLocationOnScreen(textViewLocation);
119124
int rightEdgeStart = mTextView.getRight() + textViewLocation[0];
120125
dx = rightEdgeStart - event.getRawX();
126+
oldDesiredWidth = getDesiredWidth(event);
121127
return true;
122128
case MotionEvent.ACTION_MOVE:
123-
float desiredWidth = event.getRawX() + dx - textViewLocation[0];
124-
float scale = desiredWidth / mTextView.getUnscaledWidth();
125-
mTextView.setScaleX(scale);
129+
float desiredWidth = getDesiredWidth(event);
130+
if (mTextView.getLineCount() >= MIN_TEXT_LINES_FOR_LINE_SPACING) {
131+
setLineSpacing(desiredWidth);
132+
} else {
133+
scaleText(desiredWidth);
134+
}
135+
oldDesiredWidth = desiredWidth;
126136
return true;
127137
}
128138
return true;
129139
}
140+
141+
private float getDesiredWidth(MotionEvent event) {
142+
return event.getRawX() + dx - textViewLocation[0];
143+
}
144+
145+
private void setLineSpacing(float desiredWidth) {
146+
float currentLineSpacing = mTextView.getLineSpacingExtra();
147+
int numLines = mTextView.getLineCount();
148+
float adjustment = lineSpacingPx / (numLines - 1);
149+
if (oldDesiredWidth < desiredWidth) {
150+
mTextView.setLineSpacing(currentLineSpacing + adjustment, 1);
151+
} else {
152+
mTextView.setLineSpacing(currentLineSpacing - adjustment, 1);
153+
}
154+
}
155+
156+
private void scaleText(float desiredWidth) {
157+
float scale = desiredWidth / mTextView.getUnscaledWidth();
158+
mTextView.setScaleX(scale);
159+
}
130160
};
131161

132162
OnTouchListener fontSizeTouchListener = new OnTouchListener() {
@@ -241,11 +271,6 @@ private int getTextViewLeft() {
241271
return getPaddingLeft();
242272
}
243273

244-
// in local coordinates
245-
private int getTextViewRight() {
246-
return getPaddingLeft() + mTextView.getWidth();
247-
}
248-
249274
// in local coordinates
250275
private int getTextViewBottom() {
251276
return getTextViewTop() + mTextView.getHeight();
@@ -451,13 +476,6 @@ public PointF getTextViewTopLeft() {
451476
return new PointF(x, y);
452477
}
453478

454-
// in parent coordinates
455-
public PointF getTextViewTopRight() {
456-
float x = getX() + getTextViewRight();// + mTextView.getPaddingLeft();
457-
float y = getY() + getTextViewTop();// + mTextView.getPaddingTop();
458-
return new PointF(x, y);
459-
}
460-
461479
// in parent coordinates
462480
public PointF getTextViewBottomLeft() {
463481
float x = getX() + getTextViewLeft();// + mTextView.getPaddingLeft();

0 commit comments

Comments
 (0)