Skip to content

Commit 9bce9fb

Browse files
Yuntaek RimEtienneDauphin
authored andcommitted
update of additional samples to iink 2.1.1
1 parent e179ba8 commit 9bce9fb

File tree

35 files changed

+248
-349
lines changed

35 files changed

+248
-349
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This repository comes in addition with further advanced Android examples that de
88

99
## Installation
1010

11-
1. Clone the examples repository `git clone https://github.com/MyScript/iink_sdk-additional-examples-android.git`.
11+
1. Clone the examples repository `git clone https://github.com/MyScript/iink_sdk-additional-examples-android.git`.
1212

1313
2. If you already have a certificate go to next step, else claim to receive the free license to start develop your application by following the first steps of [Getting Started](https://developer.myscript.com/getting-started).
1414

@@ -31,14 +31,14 @@ This repository provides you with an additional set of ready-to-use examples bas
3131
<img src="batch.gif" alt="batch sample" width="302">
3232
</div>
3333

34-
NB: you will retrieve data converted in your device internal storage : Android\data\com.myscript.iink.samples.batchmode\files
34+
NB: you will retrieve data converted in your device internal storage: `Android/data/com.myscript.iink.samples.batchmode/files`
3535

3636
2. The exercise assessment illustrates the case when you want to use several writing areas each one for a specific purpose in your application. It is thus using multiple editors, one per writing area, as each one has a different purpose:
3737
- First one is dedicated to "Math" content types
38-
- Second one is dedicated to "Math" content types but with user defined gramar which is dynamically loaded at start.
38+
- Second one is dedicated to "Math" content types but with a user defined grammar which is dynamically loaded at start.
3939
- Third one is dedicated to "Text" content types
40-
- Fourth one is dedicated to "Diagram" content types
41-
- Fifth one is dedicated to "Draw" content types
40+
- Fourth one is dedicated to "Diagram" content types
41+
- Fifth one is dedicated to "Draw" content types
4242

4343
<div align="center">
4444
<img src="assessment.gif" alt="assessment sample" width="302">
@@ -52,7 +52,7 @@ NB: you will retrieve data converted in your device internal storage : Android\d
5252
val partType = "Raw Content" // change to "Text Document" if you want to test
5353
~~~
5454
<div align="center">
55-
<img src="search-sample.gif" alt="search sample" width="302">
55+
<img src="search-sample.gif" alt="search sample" width="302">
5656
</div>
5757

5858
## Documentation

UIReferenceImplementation/build.gradle

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ plugins {
33
}
44

55
android {
6-
compileSdkVersion project.ext.compileSdkVersion
6+
namespace 'com.myscript.iink.uireferenceimplementation'
7+
8+
compileSdk project.ext.compileSdk
79

810
defaultConfig {
9-
minSdkVersion project.ext.minSdkVersion
10-
targetSdkVersion project.ext.targetSdkVersion
11-
versionCode 2010
12-
versionName '2.0.1'
11+
minSdk project.ext.minSdk
12+
targetSdk project.ext.targetSdk
13+
versionCode 2110
14+
versionName '2.1.1'
1315

1416
vectorDrawables.useSupportLibrary true
1517
}
@@ -18,5 +20,7 @@ android {
1820
dependencies {
1921
implementation "androidx.appcompat:appcompat:${project.ext.appcompatVersion}"
2022
implementation "com.google.code.gson:gson:${project.ext.gsonVersion}"
23+
// iink SDK.
24+
// once iink wil be published we will use this
2125
api "com.myscript:iink:${project.ext.iinkVersionName}"
2226
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<manifest package="com.myscript.iink.uireferenceimplementation" />
1+
<manifest/>
Binary file not shown.
Binary file not shown.
171 KB
Binary file not shown.
325 KB
Binary file not shown.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.myscript.iink.uireferenceimplementation;
2+
3+
import com.myscript.iink.ContentSelection;
4+
import com.myscript.iink.Editor;
5+
6+
/**
7+
* Describes the actions available for a given selection or block.
8+
*
9+
* @since 2.0
10+
*/
11+
public enum ContextualActions {
12+
/**
13+
* Add block
14+
*/
15+
ADD_BLOCK,
16+
/**
17+
* Remove block or selection
18+
*/
19+
REMOVE,
20+
/**
21+
* Convert.
22+
* @see Editor#getSupportedTargetConversionStates(ContentSelection)
23+
*/
24+
CONVERT,
25+
/**
26+
* Copy block or selection
27+
*/
28+
COPY,
29+
/**
30+
* Paste current copy
31+
*/
32+
PASTE,
33+
/**
34+
* Export.
35+
* @see Editor#getSupportedExportMimeTypes(ContentSelection)
36+
*/
37+
EXPORT,
38+
/**
39+
* Format text.
40+
* @see Editor#getSupportedTextFormats(ContentSelection)
41+
*/
42+
FORMAT_TEXT
43+
}

UIReferenceImplementation/src/main/java/com/myscript/iink/uireferenceimplementation/ContextualActionsHelper.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import com.myscript.iink.ContentBlock;
66
import com.myscript.iink.ContentPart;
77
import com.myscript.iink.ContentSelection;
8-
import com.myscript.iink.ContextualActions;
98
import com.myscript.iink.Editor;
109

1110
import java.util.EnumSet;
@@ -32,7 +31,7 @@ public static EnumSet<ContextualActions> getAvailableActionsForBlock(@NonNull Ed
3231
boolean onTextDocument = "Text Document".equals(part != null ? part.getType() : null);
3332
boolean blockIsEmpty = editor.isEmpty(block);
3433

35-
boolean displayAddBlock = editor.getSupportedAddBlockTypes().length > 0 && isRootBlock;
34+
boolean displayAddBlock = editor.getSupportedAddBlockTypes().length > 0 && (!onTextDocument || isRootBlock);
3635
boolean displayRemove = !isRootBlock;
3736
boolean displayCopy = !isRootBlock || !onTextDocument;
3837
boolean displayConvert = !blockIsEmpty && editor.getSupportedTargetConversionStates(block).length > 0;

UIReferenceImplementation/src/main/java/com/myscript/iink/uireferenceimplementation/EditorView.java

Lines changed: 18 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ public class EditorView extends FrameLayout implements IRenderTarget, InputContr
3737
@NonNull
3838
private final OfflineSurfaceManager offlineSurfaceManager;
3939
@Nullable
40-
private IRenderView renderView;
41-
@Nullable
42-
private IRenderView[] layerViews;
40+
private LayerView layerView;
4341

4442
private Map<String, Typeface> typefaceMap = new HashMap<>();
4543

@@ -70,46 +68,22 @@ protected void onFinishInflate()
7068
for (int i = 0, count = getChildCount(); i < count; ++i)
7169
{
7270
View view = getChildAt(i);
73-
if (view instanceof IRenderView)
71+
if (view instanceof LayerView)
7472
{
75-
IRenderView renderView = (IRenderView) view;
76-
if (renderView.isSingleLayerView())
77-
{
78-
if (layerViews == null)
79-
layerViews = new IRenderView[2];
80-
if (renderView.getType() == LayerType.MODEL)
81-
layerViews[0] = renderView;
82-
else if (renderView.getType() == LayerType.CAPTURE)
83-
{
84-
layerViews[1] = renderView;
85-
}
86-
else
87-
{
88-
throw new RuntimeException("Unknown layer view type");
89-
}
90-
}
91-
else
92-
{
93-
this.renderView = renderView;
94-
}
73+
layerView = (LayerView) view;
9574

96-
renderView.setRenderTarget(this);
75+
layerView.setRenderTarget(this);
9776
if (editor != null)
9877
{
99-
renderView.setEditor(editor);
78+
layerView.setEditor(editor);
10079
}
10180
if (imageLoader != null)
10281
{
103-
renderView.setImageLoader(imageLoader);
82+
layerView.setImageLoader(imageLoader);
10483
}
10584

106-
renderView.setCustomTypefaces(typefaceMap);
107-
108-
if (view instanceof LayerView)
109-
{
110-
LayerView layerView = (LayerView) view;
111-
layerView.setOfflineSurfaceManager(offlineSurfaceManager);
112-
}
85+
layerView.setCustomTypefaces(typefaceMap);
86+
layerView.setOfflineSurfaceManager(offlineSurfaceManager);
11387
}
11488
}
11589
}
@@ -125,19 +99,9 @@ public void setEditor(@Nullable Editor editor)
12599
if (editor != null)
126100
{
127101
renderer = editor.getRenderer();
128-
if (renderView != null)
102+
if (layerView != null)
129103
{
130-
renderView.setEditor(editor);
131-
}
132-
else if (layerViews != null)
133-
{
134-
for (IRenderView layerView : layerViews)
135-
{
136-
if (layerView != null)
137-
{
138-
layerView.setEditor(editor);
139-
}
140-
}
104+
layerView.setEditor(editor);
141105
}
142106
if (viewWidth > 0 && viewHeight > 0)
143107
{
@@ -168,17 +132,9 @@ public void setImageLoader(ImageLoader imageLoader)
168132
this.imageLoader = imageLoader;
169133

170134
// transfer image loader to render views
171-
if (renderView != null)
172-
{
173-
renderView.setImageLoader(imageLoader);
174-
}
175-
else if (layerViews != null)
135+
if (layerView != null)
176136
{
177-
for (IRenderView layerView : layerViews)
178-
{
179-
if (layerView != null)
180-
layerView.setImageLoader(imageLoader);
181-
}
137+
layerView.setImageLoader(imageLoader);
182138
}
183139
}
184140

@@ -193,10 +149,10 @@ public void setTypefaces(@NonNull Map<String, Typeface> typefaceMap)
193149
for (int i = 0, count = getChildCount(); i < count; ++i)
194150
{
195151
View view = getChildAt(i);
196-
if (view instanceof IRenderView)
152+
if (view instanceof LayerView)
197153
{
198-
IRenderView renderView = (IRenderView) view;
199-
renderView.setCustomTypefaces(typefaceMap);
154+
LayerView layerView = (LayerView) view;
155+
layerView.setCustomTypefaces(typefaceMap);
200156
}
201157
}
202158
}
@@ -239,19 +195,9 @@ public final void invalidate(@NonNull Renderer renderer, int x, int y, int width
239195
if (width <= 0 || height <= 0)
240196
return;
241197

242-
if (renderView != null)
198+
if (layerView != null)
243199
{
244-
renderView.update(renderer, x, y, width, height, layers);
245-
}
246-
else if (layerViews != null)
247-
{
248-
for (LayerType type : layers)
249-
{
250-
int layerID = (type == LayerType.MODEL) ? 0 : 1;
251-
IRenderView layerView = layerViews[layerID];
252-
if (layerView != null)
253-
layerView.update(renderer, x, y, width, height, layers);
254-
}
200+
layerView.update(renderer, x, y, width, height, layers);
255201
}
256202
}
257203

@@ -331,10 +277,6 @@ public void showScrollbars()
331277
editor.clampViewOffset(bottomRightPx);
332278
float pageHeightPx = bottomRightPx.y - topLeftPx.y + viewHeightPx;
333279
float pageWidthPx = bottomRightPx.x - topLeftPx.x + viewWidthPx;
334-
for (IRenderView layerView : layerViews)
335-
{
336-
if (layerView instanceof LayerView && layerView.getType() == LayerType.MODEL)
337-
((LayerView) layerView).setScrollbar(renderer, viewWidthPx, (int) pageWidthPx, (int) topLeftPx.x, viewHeightPx, (int) pageHeightPx, (int) topLeftPx.y);
338-
}
280+
layerView.setScrollbar(renderer, viewWidthPx, (int) pageWidthPx, (int) topLeftPx.x, viewHeightPx, (int) pageHeightPx, (int) topLeftPx.y);
339281
}
340282
}

0 commit comments

Comments
 (0)