markerPoints = NeoMarkerPen.computeStrokePoints(points, strokeWidth,
17 | EpdController.getMaxTouchPressure());
18 | NeoMarkerPen.drawStroke(renderContext.canvas, renderContext.paint, markerPoints, strokeWidth, isTransparent());
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/doc/Onyx-Scribble-SDK.md:
--------------------------------------------------------------------------------
1 | Scribble SDK for devices with stylus.
2 |
3 | Latest version is 1.0.8, can be referenced with following gradle statement:
4 |
5 | compile 'com.onyx.android.sdk:onyxsdk-scribble:1.0.8'
6 |
7 | For onyxsdk-scribble SDK, dbflow library is inside the jitpack, so you have to add the following statement to your project build.gradle:
8 | ```gradle
9 | maven { url "https://jitpack.io" }
10 | ```
11 |
12 | `TouchHelper` is the latest api that you can scribble with stylus. You should call it.For more detailed usage, check out it out [here](Scribble-TouchHelper-API.md)
13 |
14 | # Change logs
15 |
16 | ## 1.0.8
17 | 1. Remove `initRawDrawing()` (use `openRawDrawing()` instead): Turn on scribble and initialize resources.
18 | 2. Add `closeRawDrawing()`: Turn off scribble and release resources. Unlock the screen, screen can refresh.
19 | 3. Add `setRawDrawingEnabled(boolean enable)`: Set true, you enter scribble mode, and the screen will not refresh.
20 |
--------------------------------------------------------------------------------
/doc/Eink-Develop-Guide.md:
--------------------------------------------------------------------------------
1 | # UI/UX
2 |
3 | ## How to develop Apps for BOOX eink device
4 |
5 | Because of the eink feture, the refresh rate in eink device is much lower than normal LCD tablet,
6 | to ensure App runs smoothly and give users good using experience, we would like to provide following suggestion when develop Apps
7 |
8 | 1. Pls use black and white (16 level gray scale) as the main color of pages;
9 | If need to change the color for state switching, pls try to ensure that the color is in the 256 level gray scale.
10 | 2. Pls don’t add transparent layers on images or texts;
11 | 3. Pls use the page based way to load more contents;
12 | 4. Pls try to avoid animation, such as scrolling/dragging etc.
13 | 5. The font size should not be smaller than 14sp;
14 | If embed fonts are needed, pls use bold or bold as much as possible
15 | 6. Normally, the button icon in the central area should not be smaller than 36dp x 36dp. The button icon in the edge area should not be smaller than 48dp x 48dp.
--------------------------------------------------------------------------------
/doc/EpdDeviceManager.md:
--------------------------------------------------------------------------------
1 | Wrapper of [EpdController](./EpdController.md) to provide uniform and simple [EPD Screen Update](./EPD-Screen-Update.md) interface for both RK3026 and IMX6 devices
2 |
3 | You can set partial and full screen update intervals by calling:
4 |
5 | ```
6 | EpdDeviceManager.setGcInterval(THE_INTERVAL_YOU_WANT_TO_SET);
7 | ```
8 |
9 | Then update screen with:
10 |
11 | ```
12 | EpdDeviceManager.applyWithGCInterval(textView, isTextPage);
13 | ```
14 |
15 | EpdDeviceManager will take care of device type and choose to use normal/regal partial screen update automatically.
16 |
17 | You can also force full screen update by calling:
18 |
19 | ```
20 | EpdDeviceManager.applyGCUpdate(textView);
21 | ```
22 |
23 |
24 | Enter/leave fast update mode:
25 |
26 | `EpdDeviceManager.enterAnimationUpdate(true);`
27 |
28 | `EpdDeviceManager.exitAnimationUpdate(true);`
29 |
30 | You can see sample code in [EpdDemoActivity](../app/src/main/java/com/android/onyx/demo/EpdDemoActivity.java)
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/scribble/util/TouchUtils.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.scribble.util;
2 |
3 | import android.content.Context;
4 | import android.graphics.Rect;
5 |
6 | import com.onyx.android.sdk.api.device.epd.EpdController;
7 |
8 | /**
9 | *
10 | * author : lxw
11 | * time : 2018/7/27 17:03
12 | * desc :
13 | *
14 | */
15 | public class TouchUtils {
16 |
17 | public static void disableFingerTouch(Context context) {
18 | int width = context.getResources().getDisplayMetrics().widthPixels;
19 | int height = context.getResources().getDisplayMetrics().heightPixels;
20 | Rect rect = new Rect(0, 0, width, height);
21 | Rect[] arrayRect =new Rect[]{rect};
22 | EpdController.setAppCTPDisableRegion(context, arrayRect);
23 | }
24 |
25 | public static void enableFingerTouch(Context context) {
26 | EpdController.appResetCTPDisableRegion(context);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/java/com/android/onyx/demo/FullScreenDemoActivity.java:
--------------------------------------------------------------------------------
1 | package com.android.onyx.demo;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.view.View;
6 |
7 | import androidx.databinding.DataBindingUtil;
8 |
9 | import com.onyx.android.demo.R;
10 | import com.onyx.android.demo.databinding.ActivityFullScreenDemoBinding;
11 | import com.onyx.android.sdk.utils.DeviceUtils;
12 |
13 |
14 | public class FullScreenDemoActivity extends AppCompatActivity {
15 | private ActivityFullScreenDemoBinding binding;
16 |
17 | protected void onCreate(Bundle savedInstanceState) {
18 |
19 | super.onCreate(savedInstanceState);
20 | binding = DataBindingUtil.setContentView(this, R.layout.activity_full_screen_demo);
21 |
22 | }
23 |
24 | public void switchFullScreen(View v) {
25 | boolean fullscreen = !DeviceUtils.isFullScreen(this);
26 | DeviceUtils.setFullScreenOnResume(this, fullscreen);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/ui/popup/BasePopup.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.ui.popup;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 | import android.widget.PopupWindow;
6 |
7 | import com.onyx.android.eink.pen.demo.action.PopupChangeAction;
8 |
9 | public class BasePopup extends PopupWindow {
10 | protected Context context;
11 |
12 | public BasePopup(Context context) {
13 | super(context);
14 | this.context = context;
15 | }
16 |
17 | @Override
18 | public void showAsDropDown(View anchor, int xoff, int yoff, int gravity) {
19 | onPopupWindowChange(true);
20 | super.showAsDropDown(anchor, xoff, yoff, gravity);
21 | }
22 |
23 | @Override
24 | public void dismiss() {
25 | super.dismiss();
26 | onPopupWindowChange(false);
27 | }
28 |
29 | private void onPopupWindowChange(boolean show) {
30 | new PopupChangeAction(show).execute();
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/shape/NewBrushScribbleShape.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.shape;
2 |
3 | import com.onyx.android.eink.pen.demo.helper.RendererHelper;
4 | import com.onyx.android.sdk.api.device.epd.EpdController;
5 | import com.onyx.android.sdk.data.note.TouchPoint;
6 | import com.onyx.android.sdk.pen.NeoBrushPen;
7 | import com.onyx.android.sdk.pen.PenUtils;
8 |
9 | import java.util.List;
10 |
11 | public class NewBrushScribbleShape extends Shape {
12 |
13 | @Override
14 | public void render(RendererHelper.RenderContext renderContext) {
15 | List points = touchPointList.getPoints();
16 | applyStrokeStyle(renderContext);
17 |
18 | List NeoBrushPoints = NeoBrushPen.computeStrokePoints(points,
19 | strokeWidth, EpdController.getMaxTouchPressure());
20 | PenUtils.drawStrokeByPointSize(renderContext.canvas, renderContext.paint, NeoBrushPoints, isTransparent());
21 |
22 |
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
13 |
16 |
17 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/request/StrokeStyleChangeRequest.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.request;
2 |
3 | import androidx.annotation.NonNull;
4 |
5 | import com.onyx.android.eink.pen.demo.PenManager;
6 | import com.onyx.android.eink.pen.demo.data.ShapeFactory;
7 |
8 | public class StrokeStyleChangeRequest extends BaseRequest {
9 | private int shapeType;
10 | private int texture;
11 |
12 | public StrokeStyleChangeRequest(@NonNull PenManager penManager) {
13 | super(penManager);
14 | }
15 |
16 | public StrokeStyleChangeRequest setShapeType(int shapeType) {
17 | this.shapeType = shapeType;
18 | return this;
19 | }
20 |
21 | public StrokeStyleChangeRequest setTexture(int texture) {
22 | this.texture = texture;
23 | return this;
24 | }
25 |
26 | @Override
27 | public void execute(PenManager penManager) throws Exception {
28 | getPenManager().setStrokeStyle(ShapeFactory.getStrokeStyle(shapeType, texture));
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/render/Renderer.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.render;
2 |
3 | import android.graphics.Bitmap;
4 | import android.view.SurfaceView;
5 |
6 | import com.onyx.android.eink.pen.demo.helper.RendererHelper;
7 | import com.onyx.android.eink.pen.demo.shape.Shape;
8 |
9 | import java.util.List;
10 |
11 | /**
12 | * Created by lxm on 2018/2/8.
13 | */
14 |
15 | public interface Renderer {
16 |
17 | void renderToBitmap(SurfaceView surfaceView,
18 | RendererHelper.RenderContext renderContext);
19 |
20 | void renderToBitmap(final List shapes,
21 | final RendererHelper.RenderContext renderContext);
22 |
23 | void renderToScreen(final SurfaceView surfaceView, final Bitmap bitmap);
24 |
25 | void renderToScreen(final SurfaceView surfaceView,
26 | RendererHelper.RenderContext renderContext);
27 |
28 | void onDeactivate(final SurfaceView surfaceView);
29 |
30 | void onActive(final SurfaceView surfaceView);
31 | }
32 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/shape/BrushScribbleShape.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.shape;
2 |
3 | import com.onyx.android.eink.pen.demo.helper.RendererHelper;
4 | import com.onyx.android.sdk.api.device.epd.EpdController;
5 | import com.onyx.android.sdk.data.note.TouchPoint;
6 | import com.onyx.android.sdk.pen.NeoFountainPen;
7 | import com.onyx.android.sdk.pen.PenUtils;
8 | import com.onyx.android.sdk.utils.NumberUtils;
9 |
10 | import java.util.List;
11 |
12 | public class BrushScribbleShape extends Shape {
13 |
14 | @Override
15 | public void render(RendererHelper.RenderContext renderContext) {
16 | List points = touchPointList.getPoints();
17 | applyStrokeStyle(renderContext);
18 | List brushPoints = NeoFountainPen.computeStrokePoints(points,
19 | NumberUtils.FLOAT_ONE, strokeWidth, EpdController.getMaxTouchPressure());
20 | PenUtils.drawStrokeByPointSize(renderContext.canvas, renderContext.paint, brushPoints, isTransparent());
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/res/values-zh-rCN/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 笔刷
3 | 擦除
4 | 擦除轨迹
5 | 抬笔刷新
6 | 颜色
7 | 纹理
8 | 线宽
9 |
10 | 钢笔
11 | 毛笔
12 | 圆珠笔
13 | 马克笔
14 | 铅笔
15 |
16 | 黑色
17 | 灰色
18 | 绿色
19 | 红色
20 | 蓝色
21 |
22 | 纹理1
23 | 纹理2
24 |
25 | 移动擦除
26 | 区域擦除
27 | 笔画擦除
28 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/java/com/android/onyx/demo/utils/RendererUtils.java:
--------------------------------------------------------------------------------
1 | package com.android.onyx.demo.utils;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Color;
5 | import android.graphics.Paint;
6 | import android.graphics.Rect;
7 | import android.view.SurfaceView;
8 |
9 | public class RendererUtils {
10 |
11 | public static void renderBackground(Canvas canvas,
12 | Rect viewRect) {
13 | RendererUtils.clearBackground(canvas, new Paint(), viewRect);
14 | }
15 |
16 | public static Rect checkSurfaceView(SurfaceView surfaceView) {
17 | if (surfaceView == null || !surfaceView.getHolder().getSurface().isValid()) {
18 | return null;
19 | }
20 | return new Rect(0, 0, surfaceView.getWidth(), surfaceView.getHeight());
21 | }
22 |
23 | public static void clearBackground(final Canvas canvas, final Paint paint, final Rect rect) {
24 | paint.setStyle(Paint.Style.FILL);
25 | paint.setColor(Color.WHITE);
26 | canvas.drawRect(rect, paint);
27 | }
28 |
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
14 |
15 |
20 |
21 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/doc/AppOpenGuide.md:
--------------------------------------------------------------------------------
1 | #### Open with ADB command ```adb shell am start -n ```, here list the component of some apps
2 | |App|component|
3 | |---|---|
4 | |Dictionary|com.onyx.dict/.activity.DictMainActivity|
5 | |Email|com.android.email/.activity.Welcome|
6 | |Calculator|com.onyx.calculator/.Calculator|
7 | |Browser|com.android.browser/.BrowserActivity|
8 | |Recorder|com.android.soundrecorder/.SoundRecorder|
9 | |Calender|com.android.calendar/.AllInOneActivity|
10 | |Clock|com.onyx.deskclock/.deskclock.DeskClock|
11 | |Music|com.onyx.music/.MusicBrowserActivity|
12 | |App Market|com.onyx.appmarket/.activity.AppMarketActivity|
13 | |Floating Button|com.onyx.floatingbutton/.FloatButtonSettingActivity|
14 | #### Exceptions
15 | * Book Shop: `am start -n com.onyx/.main.ui.MainActivity --es "json" "{'action':'OPEN_SHOP'}"` , Intent needs to carry a String whose key is `json` with content `{'action':'OPEN_SHOP'}`
16 | * Note: `am start -n com.onyx/.main.ui.MainActivity --es "json" "{'action':'OPEN_NOTE'}"` , Intent needs to carry a String whose key is `json` with content `{'action':'OPEN_NOTE'}`
17 | > Call this command after entering adb shell mode
18 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/res/drawable/bg_common_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
10 | -
11 |
12 |
13 |
14 |
15 |
16 |
17 | -
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/doc/Onyx-Base-SDK.md:
--------------------------------------------------------------------------------
1 | Base SDK for Onyx-Intl Android E-Ink devices
2 |
3 | Latest version is 1.4.3.7, can be referenced with following gradle statement:
4 | ```gradle
5 | compile ('com.onyx.android.sdk:onyxsdk-base:1.4.3.7')
6 | ```
7 |
8 | Change logs:
9 | * 1.4.3.7
10 |
11 | Add Dict Query API, for more detail to see [DictionaryUtils-API](./DictionaryUtils-API.md)
12 | * 1.4.3.4
13 |
14 | Add method `setWebViewContrastOptimize(WebView webview, boolean enable)` prevent webview enter A2 mode
15 | * 1.3.2
16 |
17 | Small improvements
18 | * 1.3.1
19 |
20 | Add OTAUtil and DeviceInfoUtil for onyxsdk-data ota
21 | * 1.3.0
22 |
23 | Expose public names for internal development convenience, for 3rdparty developers, it's recommended to use APIs inside com.onyx.android.sdk.api package which are more stable.
24 | * 1.2.4
25 |
26 | Small fixes
27 | * 1.2.3
28 |
29 | Add [EpdDeviceManager](./EpdDeviceManager.md)
30 | * 1.2.2
31 |
32 | Add [DeviceEnvironment](./DeviceEnvironment.md)
33 | * 1.2.1
34 |
35 | Add [Scribble API](./Scribble-API.md) to [EpdController](./EpdController.md)
36 |
37 | * 1.2.0
38 |
39 | First public version of SDK
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/java/com/android/onyx/demo/EnvironmentDemoActivity.java:
--------------------------------------------------------------------------------
1 | package com.android.onyx.demo;
2 |
3 | import android.os.Bundle;
4 | import android.os.Environment;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.widget.TextView;
7 |
8 | import androidx.databinding.DataBindingUtil;
9 |
10 | import com.onyx.android.demo.R;
11 | import com.onyx.android.demo.databinding.ActivityEnvironmentDemoBinding;
12 | import com.onyx.android.sdk.api.device.DeviceEnvironment;
13 |
14 | public class EnvironmentDemoActivity extends AppCompatActivity {
15 | private ActivityEnvironmentDemoBinding binding;
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | binding = DataBindingUtil.setContentView(this, R.layout.activity_environment_demo);
21 |
22 | binding.textViewFlashPath.setText(Environment.getExternalStorageDirectory().getAbsolutePath());
23 | binding.textViewFlashState.setText(Environment.getExternalStorageState());
24 | binding.textViewSdCardPath.setText(DeviceEnvironment.getRemovableSDCardDirectory().getAbsolutePath());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/java/com/android/onyx/demo/factory/FrontLightFactory.java:
--------------------------------------------------------------------------------
1 | package com.android.onyx.demo.factory;
2 |
3 | import android.content.Context;
4 |
5 | import com.android.onyx.demo.model.BaseLightModel;
6 | import com.android.onyx.demo.model.CTMAllLightModel;
7 | import com.android.onyx.demo.model.FLLightModel;
8 | import com.android.onyx.demo.model.WarmAndColdLightModel;
9 | import com.onyx.android.sdk.api.device.brightness.BrightnessController;
10 |
11 | public class FrontLightFactory {
12 |
13 | public static BaseLightModel createLightModel(Context context) {
14 | BaseLightModel lightModel = null;
15 | switch (BrightnessController.getBrightnessType(context)) {
16 | case FL:
17 | lightModel = new FLLightModel(context);
18 | break;
19 | case WARM_AND_COLD:
20 | lightModel = new WarmAndColdLightModel(context);
21 | break;
22 | case CTM:
23 | lightModel = new CTMAllLightModel(context);
24 | break;
25 | case NONE:
26 | default:
27 | break;
28 | }
29 | return lightModel;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/shape/NormalPencilShape.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.shape;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import android.graphics.Path;
6 | import android.graphics.PointF;
7 |
8 | import com.onyx.android.eink.pen.demo.helper.RendererHelper;
9 | import com.onyx.android.sdk.data.note.TouchPoint;
10 |
11 | import java.util.List;
12 |
13 | public class NormalPencilShape extends Shape {
14 |
15 | @Override
16 | public void render(RendererHelper.RenderContext renderContext) {
17 | List points = touchPointList.getPoints();
18 | applyStrokeStyle(renderContext);
19 | Canvas canvas = renderContext.canvas;
20 | Paint paint = renderContext.paint;
21 | Path path = new Path();
22 | PointF prePoint = new PointF(points.get(0).x, points.get(0).y);
23 | path.moveTo(prePoint.x, prePoint.y);
24 | for (TouchPoint point : points) {
25 | path.quadTo(prePoint.x, prePoint.y, point.x, point.y);
26 | prePoint.x = point.x;
27 | prePoint.y = point.y;
28 | }
29 | canvas.drawPath(path, paint);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/request/AddShapeRequest.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.request;
2 |
3 | import androidx.annotation.NonNull;
4 |
5 | import com.onyx.android.eink.pen.demo.PenManager;
6 | import com.onyx.android.eink.pen.demo.data.InteractiveMode;
7 | import com.onyx.android.eink.pen.demo.shape.Shape;
8 |
9 | import org.jetbrains.annotations.NotNull;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | public class AddShapeRequest extends BaseRequest {
15 | private List shapes = new ArrayList<>();
16 |
17 | public AddShapeRequest(@NonNull @NotNull PenManager penManager) {
18 | super(penManager);
19 | }
20 |
21 | public AddShapeRequest setShape(Shape shape) {
22 | shapes.add(shape);
23 | return this;
24 | }
25 |
26 | public AddShapeRequest setShapes(List shapes){
27 | this.shapes.addAll(shapes);
28 | return this;
29 | }
30 |
31 | @Override
32 | public void execute(PenManager penManager) throws Exception {
33 | penManager.activeRenderMode(InteractiveMode.SCRIBBLE);
34 | penManager.getDrawShape().addAll(shapes);
35 | penManager.renderToBitmap(shapes);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/doc/DPI-and-DP-for-each-devices.asciidoc:
--------------------------------------------------------------------------------
1 | # calculation
2 |
3 | resolution width * 160 / dpi == > real and find the closest sw-dp, for example
4 | 1024x758 with 212 dpi returns 758 * 160 / 212 = 572 and use 480 finally.
5 |
6 | # list
7 |
8 |
9 | Resolution DPI real/sw-dp
10 | E43: 800x480 216 355/320
11 | C65-Pearl: 800x600 160 600/570
12 | C65: 1024x758 212 572/570
13 | C67: 1024x758 240 505/500
14 | T68: 1440x1080 265 652/640
15 | M96: 1200x825 160 825/800
16 | I86: 1600x1200 250 768/720
17 | E47: 800x480 240 480/320
18 | Kepler: 1448x1072 300 571.73334/570
19 | Max: 1600x1200 160 1200/1200
20 | PLColor: 640x480 160 480/480
21 | PL107: 1280x960 160 960/960
22 | max2: 2200x1650 212 1245/1200
23 | Note: 1872x1404
24 |
25 |
26 | sw-dp 计算公式:
27 | sw*160/dpi 计算出结果之后,选择一个比这个结果小,而又最接近这个值的dp。
28 | 比如 1280 * 960 根据公司 960 * 160 / 160 = 960
29 |
--------------------------------------------------------------------------------
/doc/EPD-Update-Mode.md:
--------------------------------------------------------------------------------
1 | ## UpdateOption:
2 |
3 | * NORMAL
4 |
5 | Good display effect, suitable for general text reading.
6 |
7 | * FAST_QUALITY
8 |
9 | Slight ghosting, suitable for quickly skimming through images and text.
10 |
11 | * REGAL
12 |
13 | Minimal ghosting, slightly flickering on the dark backgrounds, suitable for light-colored backgrounds.
14 |
15 | * FAST
16 |
17 | Slightly heavier ghosting, suitable for scrolling images and text.
18 |
19 | * FAST_X
20 |
21 | Heavier loss of details, suitable for viewing webpage and playing videos.
22 |
23 | ## UpdateMode:
24 |
25 | * DU
26 |
27 | black/white screen update
28 |
29 | * DU_QUALITY
30 |
31 | optimized DU mode with dither
32 |
33 | * GU
34 |
35 | 16 level gray partial update
36 |
37 | * GU_FAST
38 |
39 | fast GU update mode, deprecated
40 |
41 | * GC
42 | 16 level gray full screen update
43 |
44 | * GC_4
45 |
46 | 4 level gray full screen update, deprecated
47 |
48 | * ANIMATION
49 |
50 | black/white screen update, faster than DU, but lower quality
51 |
52 | * ANIMATION_QUALITY
53 |
54 | optimized animation mode with dither
55 |
56 | * REGAL
57 |
58 | optimized 16 level partial update mode for text pages
59 |
60 | * REGAL_D
61 |
62 | same as REGAL now
--------------------------------------------------------------------------------
/doc/Onyx-Data-SDK.md:
--------------------------------------------------------------------------------
1 | Data SDK for Onyx-Intl Android E-Ink devices
2 |
3 | Latest version is 1.0.1, can be referenced with following gradle statement:
4 |
5 | compile 'com.onyx.android.sdk:onyxsdk-base:1.3.7'
6 | compile 'com.onyx.android.sdk:onyxsdk-data:1.0.1'
7 |
8 | base need dependencies
9 | apt "com.github.Raizlabs.DBFlow:dbflow-processor:$rootProject.dbflowVersion"
10 | compile "com.github.Raizlabs.DBFlow:dbflow-core:$rootProject.dbflowVersion"
11 | compile "com.github.Raizlabs.DBFlow:dbflow:$rootProject.dbflowVersion"
12 | compile "org.apache.commons:commons-collections4:$rootProject.apachecommonsVersion"
13 | compile "com.alibaba:fastjson:$rootProject.fastjsonVersion"
14 | compile "com.squareup.retrofit2:retrofit:$rootProject.retrofit2Version"
15 | compile "com.liulishuo.filedownloader:library:$rootProject.filedownloaderVersion"
16 | compile "com.squareup.okhttp:okhttp-urlconnection:$rootProject.okhttpurlconnectionVersion"
17 | compile "com.aliyun.dpa:oss-android-sdk:$rootProject.aliyunOssSdkVersion"
18 | compile "com.tencent.mm.opensdk:wechat-sdk-android-with-mta:$rootProject.wechatSdkWithMtaVersion"
19 |
20 | Change logs:.
21 | * 1.0.1
22 | Add onyxsdk-data for WechatManager/OssManager/FileDownloader/OTAManager/part Request
--------------------------------------------------------------------------------
/app/moreApps/daydreamdemo/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/action/CommonPenAction.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.action;
2 |
3 | import com.onyx.android.eink.pen.demo.PenBundle;
4 | import com.onyx.android.eink.pen.demo.PenManager;
5 | import com.onyx.android.sdk.rx.RxBaseAction;
6 | import com.onyx.android.sdk.rx.RxRequest;
7 | import com.onyx.android.sdk.utils.ResManager;
8 |
9 | import io.reactivex.Observable;
10 |
11 | public class CommonPenAction extends RxBaseAction {
12 | private final T request;
13 |
14 | public CommonPenAction(T request) {
15 | this.request = request;
16 | }
17 |
18 | @Override
19 | protected Observable create() {
20 | return getPenManager().createObservable()
21 | .map(o -> executeRequest())
22 | .observeOn(getMainUIScheduler());
23 | }
24 |
25 | private T executeRequest() throws Exception {
26 | request.setContext(ResManager.getAppContext());
27 | request.execute();
28 | return request;
29 | }
30 |
31 | public PenBundle getDataBundle() {
32 | return PenBundle.getInstance();
33 | }
34 |
35 | public PenManager getPenManager() {
36 | return getDataBundle().getPenManager();
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/action/StrokeColorChangeAction.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.action;
2 |
3 | import com.onyx.android.eink.pen.demo.request.StrokeColorChangeRequest;
4 |
5 | import io.reactivex.Observable;
6 | import io.reactivex.android.schedulers.AndroidSchedulers;
7 |
8 | public class StrokeColorChangeAction extends BaseAction {
9 | private final int color;
10 |
11 | public StrokeColorChangeAction(int color) {
12 | this.color = color;
13 | }
14 |
15 | @Override
16 | protected Observable create() {
17 | return getPenManager().createObservable()
18 | .map(o -> change())
19 | .observeOn(AndroidSchedulers.mainThread())
20 | .map(o -> updateDrawingArgs());
21 | }
22 |
23 | private StrokeColorChangeRequest change() throws Exception {
24 | final StrokeColorChangeRequest request = new StrokeColorChangeRequest(getPenManager())
25 | .setColor(color);
26 | request.execute();
27 | return request;
28 | }
29 |
30 | private StrokeColorChangeAction updateDrawingArgs() {
31 | getDataBundle().setCurrentStrokeColor(color);
32 | return this;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/res/raw/demo.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
26 |
27 |
28 |
36 |
37 |
--------------------------------------------------------------------------------
/app/moreApps/daydreamdemo/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 29
5 | buildToolsVersion "29.0.3"
6 |
7 | defaultConfig {
8 | applicationId "com.onyx.daydreamdemo"
9 | minSdkVersion 26
10 | targetSdkVersion 29
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 | }
16 |
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 |
24 | }
25 |
26 | dependencies {
27 | implementation fileTree(dir: 'libs', include: ['*.jar'])
28 |
29 | implementation 'com.android.support:appcompat-v7:28.0.0'
30 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
31 | testImplementation 'junit:junit:4.12'
32 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
33 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
34 |
35 | api "io.reactivex.rxjava2:rxjava:2.1.13"
36 | api "io.reactivex.rxjava2:rxandroid:2.1.0"
37 |
38 | implementation('com.onyx.android.sdk:onyxsdk-base:1.5.5')
39 | }
40 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/java/com/android/onyx/demo/SampleApplication.java:
--------------------------------------------------------------------------------
1 | package com.android.onyx.demo;
2 |
3 | import android.content.Context;
4 | import android.os.Build;
5 | import android.support.multidex.MultiDex;
6 | import android.support.multidex.MultiDexApplication;
7 |
8 | import com.onyx.android.sdk.rx.RxManager;
9 |
10 | import org.lsposed.hiddenapibypass.HiddenApiBypass;
11 |
12 | /**
13 | * Created by suicheng on 2017/3/23.
14 | */
15 |
16 | public class SampleApplication extends MultiDexApplication {
17 | private static SampleApplication sInstance;
18 |
19 | @Override
20 | protected void attachBaseContext(Context base) {
21 | super.attachBaseContext(base);
22 | MultiDex.install(SampleApplication.this);
23 | }
24 |
25 | @Override
26 | public void onCreate() {
27 | super.onCreate();
28 | initConfig();
29 | RxManager.Builder.initAppContext(this);
30 | checkHiddenApiBypass();
31 | }
32 |
33 | private void initConfig() {
34 | try {
35 | sInstance = this;
36 | } catch (Exception e) {
37 | }
38 | }
39 |
40 | private void checkHiddenApiBypass() {
41 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
42 | HiddenApiBypass.addHiddenApiExemptions("");
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/request/PartialRefreshRequest.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.request;
2 |
3 | import android.graphics.RectF;
4 |
5 | import com.onyx.android.eink.pen.demo.PenManager;
6 | import com.onyx.android.eink.pen.demo.data.InteractiveMode;
7 | import com.onyx.android.sdk.api.device.epd.EpdController;
8 | import com.onyx.android.sdk.api.device.epd.UpdateMode;
9 | import com.onyx.android.sdk.rx.RxRequest;
10 |
11 | public class PartialRefreshRequest extends RxRequest {
12 | private final RectF refreshRect;
13 | private final PenManager penManager;
14 |
15 | public PartialRefreshRequest(PenManager penManager, RectF refreshRect) {
16 | this.penManager = penManager;
17 | this.refreshRect = refreshRect;
18 | }
19 |
20 | @Override
21 | public void execute() throws Exception {
22 | try {
23 | EpdController.setViewDefaultUpdateMode(penManager.getSurfaceView(), UpdateMode.HAND_WRITING_REPAINT_MODE);
24 | penManager.getRenderContext().clipRect = refreshRect;
25 | penManager.activeRenderMode(InteractiveMode.SCRIBBLE_PARTIAL_REFRESH);
26 | penManager.renderToScreen();
27 | } finally {
28 | EpdController.resetViewUpdateMode(penManager.getSurfaceView());
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/java/com/android/onyx/demo/WebViewOptimizeActivity.java:
--------------------------------------------------------------------------------
1 | package com.android.onyx.demo;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.view.View;
6 | import android.webkit.WebView;
7 | import android.webkit.WebViewClient;
8 |
9 | import androidx.databinding.DataBindingUtil;
10 |
11 | import com.onyx.android.demo.R;
12 | import com.onyx.android.demo.databinding.ActivityWebviewOptimizeBinding;
13 | import com.onyx.android.sdk.api.device.epd.EpdController;
14 |
15 |
16 | public class WebViewOptimizeActivity extends AppCompatActivity {
17 |
18 | WebView webView;
19 |
20 | private boolean toggled = true;
21 |
22 | private ActivityWebviewOptimizeBinding binding;
23 |
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | binding = DataBindingUtil.setContentView(this, R.layout.activity_webview_optimize);
28 | binding.setActivityWebview(this);
29 |
30 | webView = binding.webView;
31 | webView.setWebViewClient(new WebViewClient());
32 | webView.loadUrl("https://www.google.com");
33 | }
34 |
35 | public void toggleOptimize(View view) {
36 | toggled = !toggled;
37 | EpdController.setWebViewContrastOptimize(webView, toggled);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/res/layout/layout_pen_setting_pop_brush_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
15 |
16 |
21 |
22 |
29 |
30 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/ui/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.ui;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.view.View;
7 |
8 | import androidx.databinding.DataBindingUtil;
9 |
10 | import com.onyx.android.eink.pen.demo.R;
11 | import com.onyx.android.eink.pen.demo.databinding.ActivityMainBinding;
12 | import com.onyx.android.eink.pen.demo.scribble.ui.ScribbleDemoActivity;
13 |
14 | public class MainActivity extends Activity {
15 |
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
20 | binding.buttonScribbleDemo.setOnClickListener(new View.OnClickListener() {
21 | @Override
22 | public void onClick(View v) {
23 | go(ScribbleDemoActivity.class);
24 | }
25 | });
26 | binding.buttonPenDemo.setOnClickListener(new View.OnClickListener() {
27 | @Override
28 | public void onClick(View v) {
29 | go(PenDemoActivity.class);
30 | }
31 | });
32 | }
33 |
34 | private void go(Class> activityClass) {
35 | startActivity(new Intent(this, activityClass));
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/action/StrokeWidthChangeAction.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.action;
2 |
3 | import com.onyx.android.eink.pen.demo.request.StrokeWidthChangeRequest;
4 |
5 | import io.reactivex.Observable;
6 | import io.reactivex.android.schedulers.AndroidSchedulers;
7 |
8 | public class StrokeWidthChangeAction extends BaseAction {
9 | private final int shapeType;
10 | private final float width;
11 |
12 | public StrokeWidthChangeAction(int shapeType, float width) {
13 | this.shapeType = shapeType;
14 | this.width = width;
15 | }
16 |
17 | @Override
18 | protected Observable create() {
19 | return getPenManager().createObservable()
20 | .map(o -> change())
21 | .observeOn(AndroidSchedulers.mainThread())
22 | .map(o -> updateDrawingArgs());
23 | }
24 |
25 | private StrokeWidthChangeRequest change() throws Exception {
26 | final StrokeWidthChangeRequest request = new StrokeWidthChangeRequest(getPenManager())
27 | .setWidth(width);
28 | request.execute();
29 | return request;
30 | }
31 |
32 | private StrokeWidthChangeAction updateDrawingArgs() {
33 | getDataBundle().setCurrentStrokeWidth(width);
34 | getDataBundle().savePenLineWidth(shapeType, width);
35 | return this;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/render/PartialRefreshRenderer.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.render;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Rect;
5 | import android.view.SurfaceView;
6 |
7 | import com.onyx.android.eink.pen.demo.helper.RendererHelper;
8 | import com.onyx.android.eink.pen.demo.util.RendererUtils;
9 | import com.onyx.android.sdk.utils.CanvasUtils;
10 | import com.onyx.android.sdk.utils.RectUtils;
11 |
12 | public class PartialRefreshRenderer extends BaseRenderer {
13 |
14 | @Override
15 | public void renderToScreen(SurfaceView surfaceView, RendererHelper.RenderContext renderContext) {
16 | if (surfaceView == null) {
17 | return;
18 | }
19 | Rect renderRect = RectUtils.toRect(renderContext.clipRect);
20 | Rect viewRect = RendererUtils.checkSurfaceView(surfaceView);
21 | Canvas canvas = lockHardwareCanvas(surfaceView.getHolder(), renderRect);
22 | if (canvas == null) {
23 | return;
24 | }
25 | try {
26 | CanvasUtils.clipRect(canvas, renderRect);
27 | RendererUtils.renderBackground(canvas, viewRect);
28 | drawRendererContent(renderContext.bitmap, canvas);
29 | } catch (Exception e) {
30 | e.printStackTrace();
31 | } finally {
32 | surfaceView.getHolder().unlockCanvasAndPost(canvas);
33 | }
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/java/com/android/onyx/demo/FrontLightDemoActivity.java:
--------------------------------------------------------------------------------
1 | package com.android.onyx.demo;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 |
6 | import androidx.databinding.DataBindingUtil;
7 |
8 | import com.android.onyx.demo.factory.FrontLightFactory;
9 | import com.android.onyx.demo.model.BaseLightModel;
10 | import com.onyx.android.demo.R;
11 | import com.onyx.android.demo.databinding.ActivityFrontLightDemoBinding;
12 |
13 |
14 | public class FrontLightDemoActivity extends AppCompatActivity {
15 | private ActivityFrontLightDemoBinding binding;
16 | private BaseLightModel lightModel;
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | binding = DataBindingUtil.setContentView(this, R.layout.activity_front_light_demo);
22 | initLightModel();
23 | }
24 |
25 | private void initLightModel() {
26 | lightModel = FrontLightFactory.createLightModel(this);
27 | if (lightModel != null) {
28 | lightModel.initView(binding);
29 | binding.buttonShowBrightnessSetting.setOnClickListener(v -> lightModel.showBrightnessSetting(v));
30 | }
31 | }
32 |
33 | @Override
34 | protected void onResume() {
35 | super.onResume();
36 | if (lightModel != null) {
37 | lightModel.updateLightValue();
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/action/StrokeStyleChangeAction.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.action;
2 |
3 | import com.onyx.android.eink.pen.demo.request.StrokeStyleChangeRequest;
4 |
5 | import io.reactivex.Observable;
6 | import io.reactivex.android.schedulers.AndroidSchedulers;
7 |
8 | public class StrokeStyleChangeAction extends BaseAction {
9 | private final int shapeType;
10 | private final int texture;
11 |
12 | public StrokeStyleChangeAction(int shapeType, int texture) {
13 | this.shapeType = shapeType;
14 | this.texture = texture;
15 | }
16 |
17 | @Override
18 | protected Observable create() {
19 | return getPenManager().createObservable()
20 | .map(o -> change())
21 | .observeOn(AndroidSchedulers.mainThread())
22 | .map(o -> updateDrawingArgs());
23 | }
24 |
25 | private StrokeStyleChangeRequest change() throws Exception {
26 | final StrokeStyleChangeRequest request = new StrokeStyleChangeRequest(getPenManager())
27 | .setShapeType(shapeType)
28 | .setTexture(texture);
29 | request.execute();
30 | return request;
31 | }
32 |
33 | private StrokeStyleChangeAction updateDrawingArgs() {
34 | getDataBundle().setCurrentShapeType(shapeType);
35 | getDataBundle().setCurrentTexture(texture);
36 | return this;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/doc/DictionaryUtils-API.md:
--------------------------------------------------------------------------------
1 | update `onyx-base-sdk` to version 1.4.3.7 or above
2 |
3 |
4 | This Method may block thread, Do not invoke in UI thread, for more detail to see [DictionaryActivity](../app/src/main/java/com/android/onyx/demo/DictionaryActivity.java)
5 |
6 | ```
7 | /**
8 | *
9 | * @param context
10 | * @param keyword
11 | * @return DictionaryQuery
12 | *
13 | */
14 | public static DictionaryQuery queryKeyWord(Context context, String keyword)
15 | ```
16 |
17 | POJO **DictionaryQuery** FIELD EXPLAIN
18 |
19 |
20 | | field | meaning |
21 | |:--|--:|
22 | | state | the total state of query result |
23 | | `List` | a list contain result from multiple dictionary |
24 | | `DictionaryQuery.Dictionary` | POJO for single result |
25 | | state | state for single result in list |
26 | | dictName | name of dictionary |
27 | | keyword | the keyword to query |
28 | | explanation | explanation of the keyword |
29 |
30 | > be careful. for single result, even state field is success, the explantion field may null
31 |
32 | **state** EXPLAIN
33 |
34 |
35 | | field | meaning |
36 | |:--|--:|
37 | | DICT_STATE_ERROR | query failed, the dictionary not installed or query occur exception |
38 | | DICT_STATE_PARAM_ERROR | query failed, the params incorrect |
39 | | DICT_STATE_QUERY_SUCCESSFUL | query success |
40 | | DICT_STATE_QUERY_FAILED | query failed |
41 | | DICT_STATE_LOADING | is loading |
42 | | DICT_STATE_NO_DATA | query success, but no data get |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/request/AttachNoteViewRequest.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.request;
2 |
3 | import android.view.SurfaceView;
4 | import android.view.View;
5 |
6 | import androidx.annotation.NonNull;
7 |
8 | import com.onyx.android.eink.pen.demo.PenManager;
9 | import com.onyx.android.sdk.pen.RawInputCallback;
10 |
11 | import org.jetbrains.annotations.NotNull;
12 |
13 | public class AttachNoteViewRequest extends BaseRequest {
14 | private SurfaceView hostView;
15 | private View floatMenuLayout;
16 | private boolean windowFocused = true;
17 | private RawInputCallback callback;
18 |
19 | public AttachNoteViewRequest(@NonNull @NotNull PenManager penManager) {
20 | super(penManager);
21 | }
22 |
23 | public AttachNoteViewRequest setHostView(SurfaceView hostView) {
24 | this.hostView = hostView;
25 | return this;
26 | }
27 |
28 | public AttachNoteViewRequest setFloatMenuLayout(View floatMenuLayout) {
29 | this.floatMenuLayout = floatMenuLayout;
30 | return this;
31 | }
32 |
33 | public AttachNoteViewRequest setCallback(RawInputCallback callback) {
34 | this.callback = callback;
35 | return this;
36 | }
37 |
38 | @Override
39 | public void execute(PenManager penManager) throws Exception {
40 | penManager.attachHostView(hostView, floatMenuLayout, windowFocused, callback);
41 | penManager.setViewPoint(hostView);
42 | setRenderToScreen(false);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/data/ShapeType.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.data;
2 |
3 | import com.onyx.android.eink.pen.demo.R;
4 |
5 | public enum ShapeType {
6 |
7 | FOUNTAIN_PEN(R.drawable.ic_pen_fountain, R.string.fountain_pen, ShapeFactory.SHAPE_BRUSH_SCRIBBLE),
8 | SOFT_PEN(R.drawable.ic_pen_soft, R.string.brush_pen, ShapeFactory.SHAPE_NEO_BRUSH_SCRIBBLE),
9 | HARD_PEN(R.drawable.ic_pen_hard, R.string.ballpoint_pen, ShapeFactory.SHAPE_PENCIL_SCRIBBLE),
10 | CHARCOAL_PEN(R.drawable.ic_charcoal_pen, R.string.pencil, ShapeFactory.SHAPE_CHARCOAL_SCRIBBLE),
11 | MARKER_PEN(R.drawable.ic_marker_pen, R.string.marker_pen, ShapeFactory.SHAPE_MARKER_SCRIBBLE);
12 |
13 | private final int iconResId;
14 | private final int textResId;
15 | private final int value;
16 |
17 | ShapeType(int iconResId, int textResId, int value) {
18 | this.iconResId = iconResId;
19 | this.textResId = textResId;
20 | this.value = value;
21 | }
22 |
23 | public int getIconResId() {
24 | return iconResId;
25 | }
26 |
27 | public int getTextResId() {
28 | return textResId;
29 | }
30 |
31 | public int getValue() {
32 | return value;
33 | }
34 |
35 |
36 | public static ShapeType find(int shapeType) {
37 | for (ShapeType style : ShapeType.values()) {
38 | if (style.value == shapeType) {
39 | return style;
40 | }
41 | }
42 | return ShapeType.FOUNTAIN_PEN;
43 | }
44 | }
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/util/RendererUtils.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.util;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Color;
5 | import android.graphics.Matrix;
6 | import android.graphics.Paint;
7 | import android.graphics.Point;
8 | import android.graphics.Rect;
9 | import android.view.SurfaceView;
10 |
11 | import com.onyx.android.eink.pen.demo.helper.RendererHelper;
12 |
13 | public class RendererUtils {
14 |
15 | public static void renderBackground(Canvas canvas,
16 | Rect viewRect) {
17 | RendererUtils.clearBackground(canvas, new Paint(), viewRect);
18 | }
19 |
20 |
21 | public static Rect checkSurfaceView(SurfaceView surfaceView) {
22 | if (surfaceView == null || !surfaceView.getHolder().getSurface().isValid()) {
23 | return null;
24 | }
25 | return new Rect(0, 0, surfaceView.getWidth(), surfaceView.getHeight());
26 | }
27 |
28 | public static void clearBackground(final Canvas canvas, final Paint paint, final Rect rect) {
29 | paint.setStyle(Paint.Style.FILL);
30 | paint.setColor(Color.WHITE);
31 | canvas.drawRect(rect, paint);
32 | }
33 |
34 | public static Matrix getPointMatrix(final RendererHelper.RenderContext renderContext) {
35 | Point anchorPoint = renderContext.viewPoint;
36 | Matrix matrix = new Matrix();
37 | matrix.postTranslate(anchorPoint.x, anchorPoint.y);
38 | return matrix;
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/bean/EraseArgs.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.bean;
2 |
3 | import com.onyx.android.sdk.data.note.TouchPoint;
4 | import com.onyx.android.sdk.pen.data.TouchPointList;
5 |
6 | public class EraseArgs {
7 | public TouchPointList eraseTrackPoints;
8 | public float eraserWidth = 20f;
9 | public float drawRadius = eraserWidth / 2;
10 | public boolean showEraseCircle;
11 | private int eraserType;
12 |
13 | public EraseArgs setEraseTrackPoints(TouchPointList eraseTrackPoints) {
14 | this.eraseTrackPoints = eraseTrackPoints;
15 | return this;
16 | }
17 |
18 | public EraseArgs setDrawRadius(float drawRadius) {
19 | this.drawRadius = drawRadius;
20 | return this;
21 | }
22 |
23 | public EraseArgs setShowEraseCircle(boolean showEraseCircle) {
24 | this.showEraseCircle = showEraseCircle;
25 | return this;
26 | }
27 |
28 | public TouchPoint getErasePoint() {
29 | TouchPoint erasePoint = eraseTrackPoints.get(eraseTrackPoints.size() - 1);
30 | return erasePoint;
31 | }
32 |
33 | public int getEraserType() {
34 | return eraserType;
35 | }
36 |
37 | public EraseArgs setEraserType(int eraserType) {
38 | this.eraserType = eraserType;
39 | return this;
40 | }
41 |
42 | public float getEraserWidth() {
43 | return eraserWidth;
44 | }
45 |
46 | public EraseArgs setEraserWidth(float eraserWidth) {
47 | this.eraserWidth = eraserWidth;
48 | return this;
49 | }
50 | }
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/res/layout/activity_scribble_hwr_demo.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
13 |
14 |
19 |
20 |
25 |
26 |
27 |
31 |
32 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/data/StrokeColor.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.data;
2 |
3 | import android.graphics.Color;
4 |
5 | import com.onyx.android.eink.pen.demo.R;
6 | import com.onyx.android.sdk.utils.ResManager;
7 |
8 | import java.util.ArrayList;
9 | import java.util.Arrays;
10 | import java.util.List;
11 |
12 | public enum StrokeColor {
13 |
14 | BLACK(Color.BLACK, R.string.black),
15 | DARK_GRAY(ResManager.getColor(R.color.dark_gray_color), R.string.dark_gray_color),
16 | RED(ResManager.getColor(R.color.shape_red_color), R.string.red),
17 | GREEN(ResManager.getColor(R.color.shape_green_color), R.string.green),
18 | BLUE(ResManager.getColor(R.color.shape_blue_color), R.string.blue);
19 |
20 | public static List LIST = new ArrayList<>(Arrays.asList(
21 | BLACK, DARK_GRAY, RED, GREEN, BLUE
22 | ));
23 |
24 | private int value;
25 | private int textResId;
26 |
27 | StrokeColor(int value, int textResId) {
28 | this.value = value;
29 | this.textResId = textResId;
30 | }
31 |
32 | public int getValue() {
33 | return value;
34 | }
35 |
36 | public int getTextResId() {
37 | return textResId;
38 | }
39 |
40 | public static StrokeColor find(int value) {
41 | StrokeColor[] strokeColors = StrokeColor.values();
42 | for (StrokeColor strokeColor : strokeColors) {
43 | if (strokeColor.value == value) {
44 | return strokeColor;
45 | }
46 | }
47 | return BLACK;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | OnyxPenDemo
3 | Brush
4 | Eraser
5 | Erasing Track
6 | Pen Up Refresh
7 | Color
8 | Texture
9 | Line width
10 |
11 | Pen
12 | Brush Pen
13 | Ballpoint Pen
14 | Marker
15 | Pencil
16 |
17 | Black
18 | Gray
19 | Green
20 | Red
21 | Blue
22 |
23 | Texture One
24 | Texture Two
25 |
26 | Move Eraser
27 | Lasso Eraser
28 | Stroke Eraser
29 |
30 | ok
31 | This is a test tile
32 | This is a test message.\nIn handwriting state, the screen will be locked. If the page view changed, you need to pause the handwriting first.
33 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/util/ShapeUtils.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.util;
2 |
3 | import android.graphics.RectF;
4 |
5 | import com.onyx.android.eink.pen.demo.PenBundle;
6 | import com.onyx.android.eink.pen.demo.data.ShapeFactory;
7 | import com.onyx.android.eink.pen.demo.shape.Shape;
8 | import com.onyx.android.sdk.data.note.TouchPoint;
9 | import com.onyx.android.sdk.pen.data.TouchPointList;
10 |
11 | import java.util.List;
12 |
13 | public class ShapeUtils {
14 |
15 | public static Shape createShape(PenBundle penBundle, int shapeType, TouchPointList pointList) {
16 | Shape shape = ShapeFactory.createShape(shapeType)
17 | .setTouchPointList(pointList)
18 | .setStrokeColor(penBundle.getCurrentStrokeColor())
19 | .setStrokeWidth(penBundle.getCurrentStrokeWidth());
20 | if (shapeType == ShapeFactory.SHAPE_CHARCOAL_SCRIBBLE) {
21 | shape.setTexture(penBundle.getCurrentTexture());
22 | }
23 | shape.updateShapeRect();
24 | return shape;
25 | }
26 |
27 | public static RectF getBoundingRect(final TouchPointList touchPointList) {
28 | RectF boundingRect = null;
29 | List list = touchPointList.getPoints();
30 | for(TouchPoint touchPoint: list) {
31 | if (boundingRect == null) {
32 | boundingRect = new RectF(touchPoint.x, touchPoint.y, touchPoint.x, touchPoint.y);
33 | } else {
34 | boundingRect.union(touchPoint.x, touchPoint.y);
35 | }
36 | }
37 | return boundingRect;
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/res/layout/activity_dictquery.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
9 |
10 |
11 |
15 |
16 |
20 |
21 |
28 |
29 |
36 |
37 |
38 |
43 |
44 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/res/layout/activity_scribble_webview_stylus_demo.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
19 |
20 |
25 |
26 |
31 |
32 |
33 |
34 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/res/layout/activity_scribble_touch_screen_demo.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
19 |
20 |
25 |
26 |
31 |
32 |
33 |
34 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/res/layout/activity_scribble_surfaceview_stylus_demo.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
19 |
20 |
25 |
26 |
31 |
32 |
33 |
34 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/res/layout/activity_scribble_touch_helper_stylus_demo.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
19 |
20 |
25 |
26 |
31 |
32 |
33 |
34 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/java/com/android/onyx/demo/AppOptimizeActivity.java:
--------------------------------------------------------------------------------
1 | package com.android.onyx.demo;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.EditText;
10 |
11 |
12 | import androidx.databinding.DataBindingUtil;
13 |
14 |
15 | import com.onyx.android.demo.R;
16 | import com.onyx.android.demo.databinding.ActivityAppOptimizeBinding;
17 |
18 | /**
19 | * Created by Administrator on 2018/3/26 17:35.
20 | */
21 |
22 | public class AppOptimizeActivity extends Activity {
23 | private EditText etIsFull;
24 | private EditText etPkgName;
25 | private Button btnSendBroadcast;
26 | private ActivityAppOptimizeBinding binding;
27 |
28 | @Override
29 | protected void onCreate(@Nullable Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | binding = DataBindingUtil.setContentView(this, R.layout.activity_app_optimize);
32 |
33 |
34 | }
35 |
36 | public void onClick(View v) {
37 | boolean isfull;
38 | String isfullTxt = etIsFull.getText().toString();
39 | if (isfullTxt.equals("false")) {
40 | isfull = false;
41 | } else {
42 | isfull = true;
43 | }
44 | String pkgnameTxt = etPkgName.getText().toString();
45 | Intent intent = new Intent();
46 | intent.setAction("com.onyx.app.optimize.setting");
47 | intent.putExtra("optimize_fullScreen", isfull);
48 | intent.putExtra("optimize_pkgName", pkgnameTxt);
49 | sendBroadcast(intent);
50 | }
51 |
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/res/layout/activity_webview_optimize.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
9 |
10 |
11 |
19 |
20 |
26 |
27 |
33 |
34 |
35 |
36 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/res/layout/activity_scribble_state_demo.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
19 |
20 |
25 |
26 |
31 |
32 |
33 |
34 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/event/PenEvent.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.event;
2 |
3 | import com.onyx.android.sdk.utils.DeviceInfoUtil;
4 | import com.onyx.android.sdk.utils.ResManager;
5 |
6 | import static com.onyx.android.sdk.data.note.NoteConstant.COLOR_DEVICE_PEN_RESUME_DELAY_TIME_MS;
7 | import static com.onyx.android.sdk.data.note.NoteConstant.COMMON_PEN_RESUME_DELAY_TIME_MS;
8 |
9 | public class PenEvent {
10 | public static final int DELAY_ENABLE_RAW_DRAWING_MILLS = DeviceInfoUtil.isWideColorGamut(ResManager.getAppContext()) ?
11 | COLOR_DEVICE_PEN_RESUME_DELAY_TIME_MS : COMMON_PEN_RESUME_DELAY_TIME_MS;
12 | public static final int POPUP_RESUME_PEN_TIME_MS = DeviceInfoUtil.isWideColorGamut(ResManager.getAppContext()) ? 500 : 300;
13 | private boolean resumeDrawingRender;
14 | private boolean resumeRawInputReader;
15 | private int delayResumePenTimeMs = DELAY_ENABLE_RAW_DRAWING_MILLS;
16 |
17 | public PenEvent(boolean resumeDrawingRender, boolean resumeRawInputReader, int delayResumePenTimeMs) {
18 | this.resumeDrawingRender = resumeDrawingRender;
19 | this.resumeRawInputReader = resumeRawInputReader;
20 | this.delayResumePenTimeMs = delayResumePenTimeMs;
21 | }
22 |
23 | public static PenEvent resumeRawDrawing(int delayResumePenTimeMs) {
24 | return new PenEvent(true, true, delayResumePenTimeMs);
25 | }
26 |
27 | public boolean isResumeDrawingRender() {
28 | return resumeDrawingRender;
29 | }
30 |
31 | public boolean isResumeRawInputReader() {
32 | return resumeRawInputReader;
33 | }
34 |
35 | public int getDelayResumePenTimeMs() {
36 | return delayResumePenTimeMs;
37 | }
38 | }
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/res/layout/activity_open_setting.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
9 |
10 |
11 |
15 |
16 |
27 |
28 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/data/ShapeTexture.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.data;
2 |
3 | import com.onyx.android.eink.pen.demo.R;
4 | import com.onyx.android.sdk.data.note.PenTexture;
5 |
6 | import java.util.Arrays;
7 | import java.util.List;
8 | import java.util.stream.Collectors;
9 |
10 | public enum ShapeTexture {
11 |
12 | CHARCOAL_V1(ShapeFactory.SHAPE_CHARCOAL_SCRIBBLE, PenTexture.CHARCOAL_SHAPE_V1, R.string.texture_1),
13 | CHARCOAL_V2(ShapeFactory.SHAPE_CHARCOAL_SCRIBBLE, PenTexture.CHARCOAL_SHAPE_V2, R.string.texture_2);
14 |
15 | private int shapeType;
16 | private int texture;
17 | private int textureTextResId;
18 |
19 | ShapeTexture(int shapeType, int texture, int textureTextResId) {
20 | this.shapeType = shapeType;
21 | this.texture = texture;
22 | this.textureTextResId = textureTextResId;
23 | }
24 |
25 | public int getShapeType() {
26 | return shapeType;
27 | }
28 |
29 | public int getTexture() {
30 | return texture;
31 | }
32 |
33 | public int getTextureTextResId() {
34 | return textureTextResId;
35 | }
36 |
37 | public static List getShapeTextures(int shapeType) {
38 | ShapeTexture[] textures = ShapeTexture.values();
39 | return Arrays.stream(textures)
40 | .filter(o -> o.getShapeType() == shapeType)
41 | .collect(Collectors.toList());
42 | }
43 |
44 | public static ShapeTexture find(int texture) {
45 | ShapeTexture[] values = ShapeTexture.values();
46 | for (ShapeTexture shapeTexture : values) {
47 | if (texture == shapeTexture.texture) {
48 | return shapeTexture;
49 | }
50 | }
51 | return CHARCOAL_V1;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/res/layout/activity_app_optimize.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
13 |
14 |
19 |
20 |
21 |
27 |
28 |
34 |
35 |
36 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/action/PopupChangeAction.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.action;
2 |
3 | import com.onyx.android.eink.pen.demo.PenBundle;
4 | import com.onyx.android.eink.pen.demo.PenManager;
5 | import com.onyx.android.eink.pen.demo.event.PopupWindowChangeEvent;
6 | import com.onyx.android.sdk.rx.RxBaseAction;
7 | import com.onyx.android.sdk.utils.EventBusUtils;
8 |
9 | import io.reactivex.Observable;
10 |
11 | public class PopupChangeAction extends RxBaseAction {
12 | private final boolean show;
13 |
14 | public PopupChangeAction(boolean show) {
15 | this.show = show;
16 | }
17 |
18 | @Override
19 | protected Observable create() {
20 | return Observable.just(this)
21 | .observeOn(trampolineMainThread())
22 | .map(o -> postPopShowEvent())
23 | .flatMap(o -> new RefreshScreenAction()
24 | .setResumeRawDrawing(false).build())
25 | .map(o -> postPopDismissEvent());
26 | }
27 |
28 | private PopupChangeAction postPopShowEvent() {
29 | if (show) {
30 | EventBusUtils.safelyPostEvent(getPenManager().getEventBus()
31 | , new PopupWindowChangeEvent(true));
32 | }
33 | return this;
34 | }
35 |
36 | private PopupChangeAction postPopDismissEvent() {
37 | if (!show) {
38 | EventBusUtils.safelyPostEvent(getPenManager().getEventBus()
39 | , new PopupWindowChangeEvent(false));
40 | }
41 | return this;
42 | }
43 |
44 | public PenBundle getDataBundle() {
45 | return PenBundle.getInstance();
46 | }
47 |
48 | public PenManager getPenManager() {
49 | return getDataBundle().getPenManager();
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/app/moreApps/daydreamdemo/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/res/layout/activity_boox_setting.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
11 |
12 |
13 |
19 |
20 |
25 |
26 |
33 |
34 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/shape/CharcoalScribbleShape.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.shape;
2 |
3 | import com.onyx.android.eink.pen.demo.data.ShapeFactory;
4 | import com.onyx.android.eink.pen.demo.helper.RendererHelper;
5 | import com.onyx.android.eink.pen.demo.util.RendererUtils;
6 | import com.onyx.android.sdk.data.PenConstant;
7 | import com.onyx.android.sdk.data.note.ShapeCreateArgs;
8 | import com.onyx.android.sdk.data.note.TouchPoint;
9 | import com.onyx.android.sdk.pen.NeoCharcoalPenV2;
10 | import com.onyx.android.sdk.pen.PenRenderArgs;
11 |
12 | import java.util.List;
13 |
14 | public class CharcoalScribbleShape extends Shape {
15 |
16 | @Override
17 | public void render(RendererHelper.RenderContext renderContext) {
18 | List points = touchPointList.getPoints();
19 | applyStrokeStyle(renderContext);
20 |
21 | PenRenderArgs renderArgs = new PenRenderArgs()
22 | .setCreateArgs(new ShapeCreateArgs())
23 | .setCanvas(renderContext.canvas)
24 | .setPenType(ShapeFactory.getCharcoalPenType(texture))
25 | .setColor(strokeColor)
26 | .setErase(isTransparent())
27 | .setPaint(renderContext.paint)
28 | .setScreenMatrix(RendererUtils.getPointMatrix(renderContext));
29 | if (strokeWidth <= PenConstant.CHARCOAL_SHAPE_DRAW_NORMAL_SCALE_WIDTH_THRESHOLD) {
30 | renderArgs.setStrokeWidth(strokeWidth)
31 | .setPoints(points);
32 | NeoCharcoalPenV2.drawNormalStroke(renderArgs);
33 | } else {
34 | renderArgs.setStrokeWidth(strokeWidth)
35 | .setPoints(points)
36 | .setRenderMatrix(RendererUtils.getPointMatrix(renderContext));
37 | NeoCharcoalPenV2.drawBigStroke(renderArgs);
38 | }
39 |
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/doc/EPD-Touch.md:
--------------------------------------------------------------------------------
1 | **This API add on onyxsdk-base 1.4.3 to use it ,upgrade it**
2 |
3 | [EpdController](./EpdController.md) provides API to enable and disable touch region on screen.
4 |
5 |
6 | ***Get touch function state***
7 |
8 | ```
9 | /**
10 | *
11 | * @param context
12 | * @return boolean
13 | * if true touch is disable, otherwise touch is enable
14 | */
15 | boolean isCTPDisableRegion(Context context)
16 | ```
17 |
18 | ***Set the region you want to disable touch***
19 |
20 | there have two method to set regions, we suggested use first method:
21 | ```
22 | /**
23 | *
24 | * @param context
25 | * @param disableRegions
26 | * the regions that you want to disable touch
27 | */
28 | void setAppCTPDisableRegion(Context context, Rect[] disableRegions);
29 | ```
30 |
31 | or use this
32 |
33 | ```
34 | /**
35 | *
36 | * @param context
37 | * @param disableRegionArray
38 | * a array of rect which four point order by left, top, right, bottom
39 | */
40 | void setAppCTPDisableRegion(Context context, int[] disableRegionArray)
41 | ```
42 |
43 |
44 |
45 | ***Set the region you want to enable touch***
46 | to exclude some region enable touch use this:
47 | ```
48 | /**
49 | *
50 | * @param context
51 | * @param disableRegions
52 | the regions that you want to disable touch
53 | * @param excludeRegions
54 | * the regions that your want to exclude from disabled touch area
55 | */
56 | void setAppCTPDisableRegion(Context context, Rect[] disableRegions, Rect[] excludeRegions)`
57 | ```
58 |
59 |
60 |
61 | ***Reset the touch***
62 | Reset touch function to default, default status is the screen can be touch.
63 | ```
64 | /**
65 | *
66 | * @param context
67 | */
68 | void appResetCTPDisableRegion(Context context)
69 | ```
70 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/res/layout/activity_reader_demo.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
9 |
10 |
11 |
15 |
16 |
21 |
22 |
28 |
29 |
34 |
35 |
41 |
42 |
48 |
49 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/res/layout/activity_screen_saver.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
11 |
12 |
13 |
17 |
18 |
23 |
24 |
30 |
31 |
38 |
39 |
46 |
47 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/java/com/android/onyx/demo/OpenSettingActivity.java:
--------------------------------------------------------------------------------
1 | package com.android.onyx.demo;
2 |
3 | import android.content.ComponentName;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.view.View;
8 |
9 | import android.widget.Toast;
10 |
11 | import androidx.databinding.DataBindingUtil;
12 |
13 | import com.onyx.android.demo.R;
14 | import com.onyx.android.demo.databinding.ActivityOpenSettingBinding;
15 |
16 |
17 | public class OpenSettingActivity extends AppCompatActivity {
18 | private ActivityOpenSettingBinding binding;
19 |
20 | private static final String PACKAGE_NAME = "com.onyx";
21 | private static final String ACTIVITY_KCB_SETTING = "com.onyx.common.setting.ui.SettingContainerActivity";
22 |
23 | @Override
24 | protected void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | binding = DataBindingUtil.setContentView(this, R.layout.activity_open_setting);
27 | binding.setActivityOpenSetting(this);
28 | }
29 |
30 | public void openNetwork(View view) {
31 | openActivity(PACKAGE_NAME, ACTIVITY_KCB_SETTING, "onyx.settings.action.network");
32 | }
33 |
34 | public void openDateTime(View view) {
35 | openActivity(PACKAGE_NAME, ACTIVITY_KCB_SETTING, "onyx.settings.action.datetime");
36 | }
37 |
38 | private void openActivity(String pkgName, String className, String action) {
39 | try {
40 | Intent intent = new Intent(action);
41 | ComponentName componentName = new ComponentName(pkgName, className);
42 | intent.setComponent(componentName);
43 | startActivity(intent);
44 | } catch (Exception e) {
45 | e.printStackTrace();
46 | Toast.makeText(getApplicationContext(), "open settings failed!", Toast.LENGTH_SHORT).show();
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/res/drawable/seekbar_progress.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
7 |
8 |
9 |
12 |
13 |
14 |
15 |
16 | -
20 |
21 |
22 |
23 |
26 |
27 |
28 |
29 |
30 |
31 | -
35 |
36 |
37 |
38 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/java/com/android/onyx/demo/BooxSettingsDemoActivity.java:
--------------------------------------------------------------------------------
1 | package com.android.onyx.demo;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.widget.CompoundButton;
6 |
7 | import androidx.databinding.DataBindingUtil;
8 | import androidx.databinding.ObservableBoolean;
9 |
10 | import com.onyx.android.demo.R;
11 | import com.onyx.android.demo.databinding.ActivityBooxSettingBinding;
12 | import com.onyx.android.sdk.api.device.GlobalContrastController;
13 | import com.onyx.android.sdk.utils.SystemPropertiesUtil;
14 |
15 | public class BooxSettingsDemoActivity extends AppCompatActivity {
16 |
17 | private ActivityBooxSettingBinding binding;
18 | public ObservableBoolean isHighContrastEnabled = new ObservableBoolean();
19 | public ObservableBoolean supportHighContrast = new ObservableBoolean();
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | binding = DataBindingUtil.setContentView(this, R.layout.activity_boox_setting);
25 | binding.setActivity(this);
26 | updateData();
27 | }
28 |
29 | private void updateData() {
30 | isHighContrastEnabled.set(GlobalContrastController.isHighContrastEnabled());
31 | supportHighContrast.set(SystemPropertiesUtil.isPhone() || SystemPropertiesUtil.isTablet());
32 | }
33 |
34 | /**
35 | * {@link GlobalContrastController#isHighContrastEnabled()}
36 | * {@link GlobalContrastController#setHighContrastEnabled(boolean)}
37 | * Please be careful not to call it directly during the initial lifecycle of the application when using it, as this may cause incorrect results.You can use {@link android.view.View#post(Runnable)} call it.
38 | */
39 | public void onHighContrastCheckedChanged(CompoundButton view, boolean isChecked) {
40 | GlobalContrastController.setHighContrastEnabled(isChecked);
41 | isHighContrastEnabled.set(isChecked);
42 | }
43 | }
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/render/BaseRenderer.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.render;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.Canvas;
5 | import android.graphics.Rect;
6 | import android.view.SurfaceHolder;
7 | import android.view.SurfaceView;
8 |
9 | import androidx.annotation.Nullable;
10 |
11 | import com.onyx.android.eink.pen.demo.helper.RendererHelper;
12 | import com.onyx.android.eink.pen.demo.shape.Shape;
13 | import com.onyx.android.sdk.api.device.epd.EpdController;
14 | import com.onyx.android.sdk.utils.BitmapUtils;
15 | import com.onyx.android.sdk.utils.CanvasUtils;
16 |
17 | import java.util.List;
18 |
19 | public abstract class BaseRenderer implements Renderer {
20 |
21 | @Override
22 | public void onDeactivate(SurfaceView surfaceView) {
23 | }
24 |
25 | @Override
26 | public void onActive(SurfaceView surfaceView) {
27 | }
28 |
29 | @Override
30 | public void renderToBitmap(SurfaceView surfaceView, RendererHelper.RenderContext renderContext) {
31 | }
32 |
33 | @Override
34 | public void renderToBitmap(List shapes, RendererHelper.RenderContext renderContext) {
35 | }
36 |
37 | @Override
38 | public void renderToScreen(SurfaceView surfaceView, Bitmap bitmap) {
39 | }
40 |
41 | protected void drawRendererContent(Bitmap bitmap, Canvas canvas) {
42 | Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
43 | BitmapUtils.safelyDrawBitmap(canvas, bitmap, rect, rect, null);
44 | }
45 |
46 | protected Canvas lockHardwareCanvas(SurfaceHolder holder, @Nullable Rect dirty) {
47 | return CanvasUtils.lockHardwareCanvas(holder, dirty);
48 | }
49 |
50 | protected void unlockCanvasAndPost(SurfaceView surfaceView, Canvas canvas) {
51 | CanvasUtils.unlockCanvasAndPost(surfaceView, canvas);
52 | }
53 |
54 | protected void beforeUnlockCanvas(SurfaceView surfaceView) {
55 | EpdController.enablePost(surfaceView, 1);
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/scribble/request/RendererToScreenRequest.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.scribble.request;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.Canvas;
5 | import android.graphics.Rect;
6 | import android.view.SurfaceView;
7 |
8 | import com.onyx.android.eink.pen.demo.util.RendererUtils;
9 | import com.onyx.android.sdk.api.device.epd.EpdController;
10 | import com.onyx.android.sdk.api.device.epd.UpdateMode;
11 | import com.onyx.android.sdk.rx.RxRequest;
12 |
13 | public class RendererToScreenRequest extends RxRequest {
14 | private SurfaceView surfaceView;
15 | private Bitmap bitmap;
16 |
17 | public RendererToScreenRequest(SurfaceView surfaceView, Bitmap bitmap) {
18 | this.surfaceView = surfaceView;
19 | this.bitmap = bitmap;
20 | }
21 |
22 | @Override
23 | public void execute() throws Exception {
24 | renderToScreen(surfaceView, bitmap);
25 | }
26 |
27 | private void renderToScreen(SurfaceView surfaceView, Bitmap bitmap) {
28 | if (surfaceView == null) {
29 | return;
30 | }
31 | Rect viewRect = RendererUtils.checkSurfaceView(surfaceView);
32 | EpdController.setViewDefaultUpdateMode(surfaceView, UpdateMode.HAND_WRITING_REPAINT_MODE);
33 | Canvas canvas = surfaceView.getHolder().lockCanvas();
34 | if (canvas == null) {
35 | return;
36 | }
37 | try {
38 | RendererUtils.renderBackground(canvas, viewRect);
39 | drawRendererContent(bitmap, canvas);
40 | } catch (Exception e) {
41 | e.printStackTrace();
42 | } finally {
43 | surfaceView.getHolder().unlockCanvasAndPost(canvas);
44 | EpdController.resetViewUpdateMode(surfaceView);
45 | }
46 | }
47 |
48 |
49 | private void drawRendererContent(Bitmap bitmap, Canvas canvas) {
50 | Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
51 | canvas.drawBitmap(bitmap, rect, rect, null);
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/res/layout/activity_scribble_move_erase_stylus_demo.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
9 |
10 |
11 |
20 |
21 |
27 |
28 |
34 |
35 |
41 |
42 |
43 |
44 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 30
5 | buildToolsVersion "29.0.3"
6 |
7 | defaultConfig {
8 | applicationId "com.android.onyx.eink.pen.demo"
9 | minSdkVersion 26
10 | targetSdkVersion 30
11 | versionCode 1
12 | versionName "1.0"
13 | multiDexEnabled true
14 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
15 |
16 | ndk {
17 | abiFilters "armeabi-v7a", "arm64-v8a"
18 | }
19 |
20 | sourceSets.main {
21 | aidl.srcDirs = ['src/main/java']
22 | jniLibs.srcDir 'src/main/libs' //set libs as .so's location instead of jniLibs
23 | jni.srcDirs = [] //disable automatic ndk-build call with auto-generated Android.mk
24 | }
25 |
26 | }
27 |
28 | buildTypes {
29 | release {
30 | minifyEnabled false
31 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
32 | }
33 | }
34 |
35 | compileOptions {
36 |
37 | sourceCompatibility JavaVersion.VERSION_1_8
38 | targetCompatibility JavaVersion.VERSION_1_8
39 | }
40 |
41 | dataBinding {
42 | enabled = true
43 | }
44 |
45 | packagingOptions {
46 | exclude 'META-INF/DEPENDENCIES'
47 | exclude 'META-INF/LICENSE'
48 | exclude 'META-INF/LICENSE.txt'
49 | exclude 'META-INF/license.txt'
50 | exclude 'META-INF/NOTICE'
51 | exclude 'META-INF/NOTICE.txt'
52 | exclude 'META-INF/notice.txt'
53 | exclude 'META-INF/ASL2.0'
54 | pickFirst 'lib/*/libc++_shared.so'
55 | exclude 'lib/*/libc++.so'
56 | }
57 |
58 | lintOptions {
59 | abortOnError false
60 | }
61 |
62 | }
63 |
64 | dependencies {
65 | implementation 'com.android.support:appcompat-v7:28.0.0'
66 | implementation "com.android.support:recyclerview-v7:28.0.0"
67 |
68 | implementation 'com.onyx.android.sdk:onyxsdk-pen:1.4.11'
69 | implementation 'org.lsposed.hiddenapibypass:hiddenapibypass:4.3'
70 |
71 | }
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/scribble/ui/ScribbleDemoActivity.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.scribble.ui;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.view.View;
8 |
9 | import androidx.databinding.DataBindingUtil;
10 |
11 | import com.onyx.android.eink.pen.demo.R;
12 | import com.onyx.android.eink.pen.demo.databinding.ActivitySribbleDemoBinding;
13 |
14 | /**
15 | * Created by seeksky on 2018/4/26.
16 | */
17 |
18 | public class ScribbleDemoActivity extends AppCompatActivity {
19 | private ActivitySribbleDemoBinding binding;
20 |
21 | @Override
22 | protected void onCreate(@Nullable Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | binding = DataBindingUtil.setContentView(this, R.layout.activity_sribble_demo);
25 | binding.setActivitySribble(this);
26 | }
27 |
28 | public void button_scribble_touch_helper(View view) {
29 | go(ScribbleTouchHelperDemoActivity.class);
30 | }
31 |
32 | public void button_surfaceview_stylus_scribble(View view) {
33 | go(ScribbleTouchHelperDemoActivity.class);
34 | }
35 |
36 | public void button_webview_stylus_scribble(View view) {
37 | go(ScribbleWebViewDemoActivity.class);
38 | }
39 |
40 | public void button_move_erase_scribble(View view) {
41 | go(ScribbleMoveEraserDemoActivity.class);
42 | }
43 |
44 | public void button_multiple_scribble(View view) {
45 | go(ScribbleMultipleScribbleViewActivity.class);
46 | }
47 |
48 | public void button_pen_up_refresh(View view) {
49 | go(ScribblePenUpRefreshDemoActivity.class);
50 | }
51 |
52 | public void button_epd_controller(View view) {
53 | go(ScribbleEpdControllerDemoActivity.class);
54 | }
55 |
56 | public void gotoScribbleFingerTouchDemo(View view) {
57 | go(ScribbleFingerTouchDemoActivity.class);
58 | }
59 |
60 | private void go(Class> activityClass) {
61 | startActivity(new Intent(this, activityClass));
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/res/layout/activity_scribble_save_points_demo.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |
15 |
21 |
22 |
27 |
28 |
33 |
34 |
39 |
40 |
45 |
46 |
47 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 30
5 | buildToolsVersion "29.0.2"
6 | dataBinding {
7 | enabled = true
8 | }
9 | defaultConfig {
10 | applicationId "com.android.onyx.demo"
11 | minSdkVersion 23
12 | targetSdkVersion 30
13 | versionCode 1
14 | versionName "1.0"
15 | multiDexEnabled true
16 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
17 |
18 | javaCompileOptions {
19 | annotationProcessorOptions {
20 | includeCompileClasspath = true
21 | arguments=['targetModuleName':'Scribble']
22 | }
23 | }
24 |
25 | ndk {
26 | abiFilters "armeabi-v7a"
27 | }
28 | }
29 | buildTypes {
30 | release {
31 | minifyEnabled false
32 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
33 | }
34 | }
35 |
36 | lintOptions {
37 | abortOnError false
38 | }
39 |
40 | packagingOptions {
41 | pickFirst 'lib/*/libc++_shared.so'
42 | pickFirst 'androidsupportmultidexversion.txt'
43 | }
44 |
45 | compileOptions {
46 | sourceCompatibility 1.8
47 | targetCompatibility 1.8
48 | }
49 | }
50 |
51 | dependencies {
52 | implementation fileTree(dir: 'libs', include: ['*.jar'])
53 | implementation 'com.android.support:appcompat-v7:28.0.0'
54 | testImplementation 'junit:junit:4.12'
55 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
56 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
57 |
58 | implementation('com.onyx.android.sdk:onyxsdk-device:1.3.0')
59 | implementation('com.onyx.android.sdk:onyxsdk-pen:1.4.10.1')
60 |
61 | implementation 'org.lsposed.hiddenapibypass:hiddenapibypass:4.3'
62 |
63 | implementation "com.android.support:multidex:1.0.3"
64 | api "com.android.support.constraint:constraint-layout:1.1.3"
65 |
66 |
67 | annotationProcessor "com.github.Raizlabs.DBFlow:dbflow-processor:4.2.4"
68 | implementation "com.github.Raizlabs.DBFlow:dbflow-core:4.2.4"
69 | implementation "com.github.Raizlabs.DBFlow:dbflow:4.2.4"
70 | }
71 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/java/com/android/onyx/demo/model/BaseLightModel.java:
--------------------------------------------------------------------------------
1 | package com.android.onyx.demo.model;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.database.ContentObserver;
6 | import android.provider.Settings;
7 | import android.view.View;
8 | import android.widget.SeekBar;
9 |
10 | import com.onyx.android.demo.databinding.ActivityFrontLightDemoBinding;
11 | import com.onyx.android.sdk.api.device.brightness.BaseBrightnessProvider;
12 | import com.onyx.android.sdk.utils.RxTimerUtil;
13 |
14 | import java.util.concurrent.TimeUnit;
15 |
16 | public abstract class BaseLightModel {
17 | protected static final String TAG = "LightModel";
18 | protected Context mContext;
19 | protected ActivityFrontLightDemoBinding binding;
20 |
21 | public BaseLightModel(Context mContext) {
22 | this.mContext = mContext;
23 | }
24 |
25 | public abstract void updateLightValue();
26 |
27 | public abstract void initView(ActivityFrontLightDemoBinding binding);
28 |
29 | public void initSeekBar(SeekBar seekBar, BaseBrightnessProvider provider) {
30 | seekBar.setMax(provider.getMaxIndex());
31 | seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
32 | @Override
33 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
34 | if (fromUser) {
35 | provider.setIndex(progress);
36 | }
37 | }
38 |
39 | @Override
40 | public void onStartTrackingTouch(SeekBar seekBar) {
41 |
42 | }
43 |
44 | @Override
45 | public void onStopTrackingTouch(SeekBar seekBar) {
46 |
47 | }
48 | });
49 | seekBar.setProgress(provider.getIndex());
50 | }
51 |
52 | public void showBrightnessSetting(View view) {
53 | mContext.sendBroadcast(new Intent("action.show.brightness.dialog"));
54 | }
55 |
56 | public void delay(RxTimerUtil.TimerObserver timerObserver) {
57 | RxTimerUtil.timer(100, TimeUnit.MILLISECONDS, timerObserver);
58 | }
59 |
60 | public void registerObserver(String key, ContentObserver contentObserver) {
61 | mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(key), false, contentObserver);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/java/com/android/onyx/demo/OTADemoActivity.java:
--------------------------------------------------------------------------------
1 | package com.android.onyx.demo;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 | import android.widget.EditText;
8 |
9 |
10 | import androidx.databinding.DataBindingUtil;
11 |
12 | import com.onyx.android.demo.R;
13 | import com.onyx.android.demo.databinding.ActivityOtaDemoBinding;
14 | import com.onyx.android.sdk.api.data.model.FirmwareBean;
15 | import com.onyx.android.sdk.api.device.OTAManager;
16 | import com.onyx.android.sdk.rx.RxUtils;
17 | import com.onyx.android.sdk.utils.JSONUtils;
18 |
19 | import java.util.concurrent.Callable;
20 |
21 | import io.reactivex.functions.Consumer;
22 |
23 | /**
24 | * Created by seeksky on 2018/5/17.
25 | */
26 |
27 | public class OTADemoActivity extends AppCompatActivity {
28 | private ActivityOtaDemoBinding binding;
29 |
30 | @Override
31 | protected void onCreate(@Nullable Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 | binding = DataBindingUtil.setContentView(this, R.layout.activity_ota_demo);
34 | binding.setActivityOta(this);
35 | initData();
36 | }
37 |
38 | private void initData() {
39 | RxUtils.runWithInComputation(new Callable() {
40 | @Override
41 | public FirmwareBean call() throws Exception {
42 | return getCurrentFirmwareInfo();
43 | }
44 | }, new Consumer() {
45 | @Override
46 | public void accept(FirmwareBean firmwareBean) throws Exception {
47 | if (firmwareBean != null) {
48 | binding.tvFirmwareInfo.setText(JSONUtils.toJson(firmwareBean));
49 | }
50 | }
51 | });
52 | }
53 |
54 | @Override
55 | protected void onDestroy() {
56 | super.onDestroy();
57 | }
58 |
59 | public void onOTAUpdate(View view) {
60 | EditText editText = binding.edittextOtaPackagePath;
61 | String path = editText.getText().toString();
62 | //TODO
63 | //OTAManager.startFirmwareUpdate(this, path);
64 | }
65 |
66 | private FirmwareBean getCurrentFirmwareInfo() {
67 | return OTAManager.getCurrentFirmware(this);
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/res/layout/activity_ota_demo.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
9 |
10 |
11 |
16 |
17 |
21 |
22 |
30 |
31 |
38 |
39 |
40 |
41 |
46 |
47 |
53 |
54 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/render/NormalRenderer.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.render;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.Canvas;
5 | import android.graphics.Rect;
6 | import android.view.SurfaceView;
7 |
8 | import com.onyx.android.eink.pen.demo.helper.RendererHelper;
9 | import com.onyx.android.eink.pen.demo.shape.Shape;
10 | import com.onyx.android.eink.pen.demo.util.RendererUtils;
11 |
12 | import java.util.List;
13 |
14 | public class NormalRenderer extends BaseRenderer {
15 |
16 | @Override
17 | public void renderToBitmap(List shapes, RendererHelper.RenderContext renderContext) {
18 | for (Shape shape : shapes) {
19 | shape.render(renderContext);
20 | }
21 | }
22 |
23 | @Override
24 | public void renderToScreen(SurfaceView surfaceView, Bitmap bitmap) {
25 | if (surfaceView == null) {
26 | return;
27 | }
28 | Rect rect = RendererUtils.checkSurfaceView(surfaceView);
29 | if (rect == null) {
30 | return;
31 | }
32 | Canvas canvas = lockHardwareCanvas(surfaceView.getHolder(), null);
33 | if (canvas == null) {
34 | return;
35 | }
36 | try {
37 | RendererUtils.renderBackground(canvas, rect);
38 | drawRendererContent(bitmap, canvas);
39 | } catch (Exception e) {
40 | e.printStackTrace();
41 | } finally {
42 | beforeUnlockCanvas(surfaceView);
43 | unlockCanvasAndPost(surfaceView, canvas);
44 | }
45 | }
46 |
47 | @Override
48 | public void renderToScreen(SurfaceView surfaceView, RendererHelper.RenderContext renderContext) {
49 | if (surfaceView == null) {
50 | return;
51 | }
52 | Rect rect = RendererUtils.checkSurfaceView(surfaceView);
53 | if (rect == null) {
54 | return;
55 | }
56 | Canvas canvas = lockHardwareCanvas(surfaceView.getHolder(), null);
57 | if (canvas == null) {
58 | return;
59 | }
60 | try {
61 | RendererUtils.renderBackground(canvas, rect);
62 | drawRendererContent(renderContext.bitmap, canvas);
63 | } catch (Exception e) {
64 | e.printStackTrace();
65 | } finally {
66 | beforeUnlockCanvas(surfaceView);
67 | unlockCanvasAndPost(surfaceView, canvas);
68 | }
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/java/com/android/onyx/demo/ScreensaverActivity.java:
--------------------------------------------------------------------------------
1 | package com.android.onyx.demo;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.view.View;
6 | import android.widget.Toast;
7 |
8 | import androidx.annotation.NonNull;
9 | import androidx.databinding.DataBindingUtil;
10 | import androidx.databinding.ObservableBoolean;
11 |
12 | import com.onyx.android.demo.R;
13 | import com.onyx.android.demo.databinding.ActivityScreenSaverBinding;
14 | import com.onyx.android.sdk.api.device.screensaver.ScreenResourceManager;
15 |
16 |
17 | public class ScreensaverActivity extends AppCompatActivity {
18 | private ActivityScreenSaverBinding binding;
19 | public ObservableBoolean supportWallpaper = new ObservableBoolean();
20 | public ObservableBoolean supportSetShutdown = new ObservableBoolean();
21 |
22 | @Override
23 | protected void onCreate(Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | binding = DataBindingUtil.setContentView(this, R.layout.activity_screen_saver);
26 | binding.setActivityScreenSaver(this);
27 | initData();
28 | }
29 |
30 | private void initData() {
31 | supportWallpaper.set(ScreenResourceManager.supportWallpaperSetting());
32 | supportSetShutdown.set(ScreenResourceManager.supportShutdownSetting());
33 | }
34 |
35 | public void setScreensaver(View view) {
36 | boolean success = ScreenResourceManager.setScreensaver(this, getFilePath(), true);
37 | if (!success) {
38 | Toast.makeText(this, "Set screensaver failed, detailed information can be found in the logs.", Toast.LENGTH_LONG).show();
39 | }
40 | }
41 |
42 | public void setShutdown(View view) {
43 | boolean success = ScreenResourceManager.setShutdown(this, getFilePath(), true);
44 | if (!success) {
45 | Toast.makeText(this, "Set shutdown failed, detailed information can be found in the logs.", Toast.LENGTH_LONG).show();
46 | }
47 | }
48 |
49 | public void setWallpaper(View view) {
50 | boolean success = ScreenResourceManager.setWallpaper(this, getFilePath(), true);
51 | if (!success) {
52 | Toast.makeText(this, "Set wallpaper failed, detailed information can be found in the logs.", Toast.LENGTH_LONG).show();
53 | }
54 | }
55 |
56 | @NonNull
57 | private String getFilePath() {
58 | return binding.etImage.getText().toString();
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/scribble/request/PartialRefreshRequest.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.scribble.request;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.Canvas;
6 | import android.graphics.Rect;
7 | import android.graphics.RectF;
8 | import android.view.SurfaceView;
9 |
10 | import com.onyx.android.eink.pen.demo.util.RendererUtils;
11 | import com.onyx.android.sdk.api.device.epd.EpdController;
12 | import com.onyx.android.sdk.api.device.epd.UpdateMode;
13 | import com.onyx.android.sdk.rx.RxRequest;
14 | import com.onyx.android.sdk.utils.RectUtils;
15 |
16 | public class PartialRefreshRequest extends RxRequest {
17 | private RectF refreshRect;
18 | private SurfaceView surfaceView;
19 | private Bitmap bitmap;
20 |
21 | public PartialRefreshRequest(Context context, SurfaceView surfaceView, RectF refreshRect) {
22 | setContext(context);
23 | this.surfaceView = surfaceView;
24 | this.refreshRect = refreshRect;
25 | }
26 |
27 | public PartialRefreshRequest setBitmap(Bitmap bitmap) {
28 | this.bitmap = bitmap;
29 | return this;
30 | }
31 |
32 | @Override
33 | public void execute() throws Exception {
34 | renderToScreen(surfaceView, bitmap);
35 | }
36 |
37 | private void renderToScreen(SurfaceView surfaceView, Bitmap bitmap) {
38 | if (surfaceView == null) {
39 | return;
40 | }
41 | Rect renderRect = RectUtils.toRect(refreshRect);
42 | Rect viewRect = RendererUtils.checkSurfaceView(surfaceView);
43 | EpdController.setViewDefaultUpdateMode(surfaceView, UpdateMode.HAND_WRITING_REPAINT_MODE);
44 | Canvas canvas = surfaceView.getHolder().lockCanvas(renderRect);
45 | if (canvas == null) {
46 | return;
47 | }
48 | try {
49 | canvas.clipRect(renderRect);
50 | RendererUtils.renderBackground(canvas, viewRect);
51 | drawRendererContent(bitmap, canvas);
52 | } catch (Exception e) {
53 | e.printStackTrace();
54 | } finally {
55 | surfaceView.getHolder().unlockCanvasAndPost(canvas);
56 | EpdController.resetViewUpdateMode(surfaceView);
57 | }
58 | }
59 |
60 | private void drawRendererContent(Bitmap bitmap, Canvas canvas) {
61 | Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
62 | canvas.drawBitmap(bitmap, rect, rect, null);
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/java/com/android/onyx/demo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.android.onyx.demo;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 |
8 | import androidx.databinding.DataBindingUtil;
9 |
10 | import com.onyx.android.demo.R;
11 | import com.onyx.android.demo.databinding.ActivityMainBinding;
12 | import com.onyx.android.sdk.api.device.epd.EpdController;
13 |
14 |
15 | public class MainActivity extends AppCompatActivity {
16 | private ActivityMainBinding binding;
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
22 | final View view = binding.getRoot();
23 | binding.setActivityMain(this);
24 | EpdController.enablePost(view, 1);
25 | }
26 |
27 | public void button_epd(View view) {
28 | go(EpdDemoActivity.class);
29 | }
30 |
31 | public void button_front_light(View view) {
32 | go(FrontLightDemoActivity.class);
33 | }
34 |
35 | public void button_full_screen(View view) {
36 | go(FullScreenDemoActivity.class);
37 | }
38 |
39 | public void button_environment(View view) {
40 | go(EnvironmentDemoActivity.class);
41 | }
42 |
43 | public void btn_dict_query(View view) {
44 | go(DictionaryActivity.class);
45 | }
46 |
47 | public void btn_reader(View view) {
48 | go(ReaderDemoActivity.class);
49 | }
50 |
51 | public void btn_screen_saver(View view) {
52 | go(ScreensaverActivity.class);
53 | }
54 |
55 | public void btn_open_setting(View view) {
56 | go(OpenSettingActivity.class);
57 | }
58 |
59 | public void btn_webview_optimize(View view) {
60 | go(WebViewOptimizeActivity.class);
61 | }
62 |
63 | public void btn_open_kcb(View view) {
64 | go(OpenKcbActivity.class);
65 | }
66 |
67 | public void btn_open_ota(View view) {
68 | go(OTADemoActivity.class);
69 | }
70 |
71 | public void onClickButtonRefreshMode(View view) {
72 | go(RefreshModeDemoActivity.class);
73 | }
74 |
75 | public void onClickButtonEacDemo(View view) {
76 | go(EacDemoActivity.class);
77 | }
78 |
79 | public void openBooxSettingDemo(View view) {
80 | go(BooxSettingsDemoActivity.class);
81 | }
82 |
83 | private void go(Class> activityClass) {
84 | startActivity(new Intent(this, activityClass));
85 | }
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
44 |
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/app/moreApps/daydreamdemo/src/main/java/com/onyx/daydreamdemo/service/MyDreamService.java:
--------------------------------------------------------------------------------
1 | package com.onyx.daydreamdemo.service;
2 |
3 | import android.service.dreams.DreamService;
4 |
5 | import com.onyx.android.sdk.common.request.WakeLockHolder;
6 | import com.onyx.android.sdk.utils.RxTimerUtil;
7 | import com.onyx.daydreamdemo.ImageDayDream;
8 | import com.onyx.daydreamdemo.utils.ReflectUtils;
9 |
10 | import java.lang.reflect.Method;
11 |
12 | public class MyDreamService extends DreamService {
13 |
14 | private static final long DOZE_DELAY_MILLIS = 1200;
15 | private static final long WAKELOCK_DURATION_MILLIS = DOZE_DELAY_MILLIS + 500;
16 |
17 | private RxTimerUtil.TimerObserver startDozingTimer;
18 | private WakeLockHolder wakeLockHolder;
19 | private ImageDayDream dream;
20 |
21 | @Override
22 | public void onCreate() {
23 | super.onCreate();
24 |
25 | dream = new ImageDayDream(this);
26 | wakeLockHolder = new WakeLockHolder();
27 | startDozingTimer = new RxTimerUtil.TimerObserver() {
28 | @Override
29 | public void onNext(Long aLong) {
30 | invokeStartDozing();
31 | }
32 | };
33 | }
34 |
35 | @Override
36 | public void onAttachedToWindow() {
37 | super.onAttachedToWindow();
38 |
39 | setInteractive(false);
40 | setFullscreen(true);
41 |
42 | setContentView(dream.getContentViewId());
43 | }
44 |
45 | @Override
46 | public void onDreamingStarted() {
47 | super.onDreamingStarted();
48 |
49 | dream.onDreamingStarted();
50 | delayInvokeStartDozing();
51 | }
52 |
53 | @Override
54 | public void onDreamingStopped() {
55 | super.onDreamingStopped();
56 |
57 | dream.onDreamingStopped();
58 | invokeStopDozing();
59 | }
60 |
61 | private void delayInvokeStartDozing() {
62 | wakeLockHolder.acquireWakeLock(this, WakeLockHolder.FULL_FLAGS, getClass().getSimpleName(), (int) WAKELOCK_DURATION_MILLIS);
63 | RxTimerUtil.timer(DOZE_DELAY_MILLIS, startDozingTimer);
64 | }
65 |
66 | private void invokeStartDozing() {
67 | Method method = ReflectUtils.getDeclaredMethod(DreamService.class, "startDozing");
68 | if (method != null) {
69 | ReflectUtils.invokeMethod(method, this);
70 | }
71 | }
72 |
73 | private void invokeStopDozing() {
74 | Method method = ReflectUtils.getDeclaredMethod(DreamService.class, "stopDozing");
75 | if (method != null) {
76 | ReflectUtils.invokeMethod(method, this);
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/java/com/android/onyx/demo/model/FLLightModel.java:
--------------------------------------------------------------------------------
1 | package com.android.onyx.demo.model;
2 |
3 | import android.content.Context;
4 | import android.database.ContentObserver;
5 | import android.util.Log;
6 | import android.view.View;
7 |
8 | import androidx.databinding.ObservableInt;
9 |
10 | import com.onyx.android.demo.databinding.ActivityFrontLightDemoBinding;
11 | import com.onyx.android.sdk.api.device.brightness.BaseBrightnessProvider;
12 | import com.onyx.android.sdk.api.device.brightness.BrightnessController;
13 | import com.onyx.android.sdk.device.BaseDevice;
14 | import com.onyx.android.sdk.utils.RxTimerUtil;
15 |
16 | public class FLLightModel extends BaseLightModel {
17 | private static final String KEY_FL_BRIGHTNESS_STATE = "screen_brightness";
18 | private static final String KEY_FL_BRIGHTNESS = "screen_cold_brightness";
19 |
20 | private BaseBrightnessProvider flProvider;
21 |
22 | public ObservableInt lightValue = new ObservableInt(){
23 | @Override
24 | public int get() {
25 | if (flProvider == null) {
26 | return 0;
27 | }
28 | return flProvider.getIndex();
29 | }
30 | };
31 |
32 | public FLLightModel(Context mContext) {
33 | super(mContext);
34 | }
35 |
36 | @Override
37 | public void updateLightValue() {
38 | lightValue.notifyChange();
39 | }
40 |
41 | @Override
42 | public void initView(ActivityFrontLightDemoBinding binding) {
43 | this.binding = binding;
44 | binding.setFlLightModel(this);
45 | binding.flContainer.setVisibility(View.VISIBLE);
46 | flProvider = BrightnessController.getBrightnessProvider(mContext, BaseDevice.LIGHT_TYPE_FL);
47 | initSeekBar(binding.flBrightnessSeek, flProvider);
48 |
49 | registerObserver(KEY_FL_BRIGHTNESS, new ContentObserver(null) {
50 | @Override
51 | public void onChange(boolean selfChange) {
52 | lightValue.notifyChange();
53 | }
54 | });
55 | registerObserver(KEY_FL_BRIGHTNESS_STATE, new ContentObserver(null) {
56 | @Override
57 | public void onChange(boolean selfChange) {
58 | Log.i(TAG, "Cold brightness light on: " + flProvider.isLightOn());
59 | }
60 | });
61 | }
62 |
63 | public void toggleFLLight() {
64 | flProvider.toggle();
65 | delay(new RxTimerUtil.TimerObserver() {
66 | @Override
67 | public void onNext(Long aLong) {
68 | updateLightValue();
69 | }
70 | });
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/request/BaseRequest.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.request;
2 |
3 | import androidx.annotation.NonNull;
4 |
5 | import com.onyx.android.eink.pen.demo.PenManager;
6 | import com.onyx.android.sdk.rx.RxRequest;
7 |
8 | public abstract class BaseRequest extends RxRequest {
9 | private volatile PenManager penManager;
10 | private volatile boolean renderToScreen = true;
11 | private volatile boolean pauseRawDrawingRender = true;
12 | private volatile boolean pauseRawInputReader = true;
13 |
14 | public BaseRequest(@NonNull PenManager penManager) {
15 | this.penManager = penManager;
16 | }
17 |
18 | public boolean isRenderToScreen() {
19 | return renderToScreen;
20 | }
21 |
22 | public boolean isPauseRawDrawingRender() {
23 | return pauseRawDrawingRender;
24 | }
25 |
26 | public boolean isPauseRawInputReader() {
27 | return pauseRawInputReader;
28 | }
29 |
30 | public BaseRequest setRenderToScreen(boolean renderToScreen) {
31 | this.renderToScreen = renderToScreen;
32 | return this;
33 | }
34 |
35 | public BaseRequest setPauseRawInputReader(boolean pauseRawInputReader) {
36 | this.pauseRawInputReader = pauseRawInputReader;
37 | return this;
38 | }
39 |
40 | public BaseRequest setPauseRawDrawingRender(boolean pauseRawDrawingRender) {
41 | this.pauseRawDrawingRender = pauseRawDrawingRender;
42 | return this;
43 | }
44 |
45 | public BaseRequest setPauseRawDraw(boolean pauseRawDrawing) {
46 | this.pauseRawDrawingRender = pauseRawDrawing;
47 | this.pauseRawInputReader = pauseRawDrawing;
48 | return this;
49 | }
50 |
51 | public PenManager getPenManager() {
52 | return penManager;
53 | }
54 |
55 | @Override
56 | public void execute() throws Exception {
57 | beforeExecute(getPenManager());
58 | execute(getPenManager());
59 | afterExecute(getPenManager());
60 | }
61 |
62 | public abstract void execute(PenManager penManager) throws Exception;
63 |
64 | private void beforeExecute(PenManager penManager) {
65 | if (isPauseRawDrawingRender() && isPauseRawInputReader()) {
66 | penManager.setRawDrawingEnabled(false);
67 | return;
68 | }
69 | if (isPauseRawDrawingRender()) {
70 | penManager.setRawDrawingRenderEnabled(false);
71 | }
72 | if (isPauseRawInputReader()) {
73 | penManager.setRawInputReaderEnable(false);
74 | }
75 | }
76 |
77 | private void afterExecute(PenManager noteManager) {
78 | if (isRenderToScreen()) {
79 | noteManager.renderToScreen();
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/res/layout/activity_scribble_epd_controller_demo.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
16 |
17 |
22 |
27 |
32 |
37 |
42 |
43 |
44 |
45 |
51 |
52 |
59 |
60 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/app/OnyxAndroidDemo/src/main/java/com/android/onyx/demo/RefreshModeDemoActivity.java:
--------------------------------------------------------------------------------
1 | package com.android.onyx.demo;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.widget.RadioGroup;
7 |
8 | import androidx.databinding.DataBindingUtil;
9 |
10 | import com.onyx.android.demo.R;
11 | import com.onyx.android.demo.databinding.ActivityRefreshModeDemoBinding;
12 | import com.onyx.android.sdk.api.device.epd.UpdateOption;
13 | import com.onyx.android.sdk.device.Device;
14 |
15 |
16 | public class RefreshModeDemoActivity extends AppCompatActivity implements RadioGroup.OnCheckedChangeListener {
17 |
18 | private static final String TAG = RefreshModeDemoActivity.class.getSimpleName();
19 |
20 | private ActivityRefreshModeDemoBinding binding;
21 |
22 | @Override
23 | protected void onCreate(@Nullable Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | binding = DataBindingUtil.setContentView(this, R.layout.activity_refresh_mode_demo);
26 |
27 | initData();
28 | binding.rgRefreshMode.setOnCheckedChangeListener(this);
29 | }
30 |
31 | private void initData() {
32 | UpdateOption updateOption = Device.currentDevice().getAppScopeRefreshMode();
33 | binding.rgRefreshMode.check(getRadioButtonIdByUpdateOption(updateOption));
34 | }
35 |
36 | @Override
37 | public void onCheckedChanged(RadioGroup radioGroup, int checkedId) {
38 | switch (checkedId) {
39 | case R.id.rb_normal:
40 | Device.currentDevice().setAppScopeRefreshMode(UpdateOption.NORMAL);
41 | break;
42 | case R.id.rb_fast_quality:
43 | Device.currentDevice().setAppScopeRefreshMode(UpdateOption.FAST_QUALITY);
44 | break;
45 | case R.id.rb_regal:
46 | Device.currentDevice().setAppScopeRefreshMode(UpdateOption.REGAL);
47 | break;
48 | case R.id.rb_fast:
49 | Device.currentDevice().setAppScopeRefreshMode(UpdateOption.FAST);
50 | break;
51 | case R.id.rb_fast_x:
52 | Device.currentDevice().setAppScopeRefreshMode(UpdateOption.FAST_X);
53 | break;
54 | }
55 | }
56 |
57 | public int getRadioButtonIdByUpdateOption(UpdateOption updateOption) {
58 | switch (updateOption) {
59 | case NORMAL:
60 | return R.id.rb_normal;
61 | case FAST_QUALITY:
62 | return R.id.rb_fast_quality;
63 | case FAST:
64 | return R.id.rb_fast;
65 | case FAST_X:
66 | return R.id.rb_fast_x;
67 | case REGAL:
68 | return R.id.rb_regal;
69 | }
70 | return -1;
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/action/RefreshScreenAction.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.action;
2 |
3 | import com.onyx.android.eink.pen.demo.PenBundle;
4 | import com.onyx.android.eink.pen.demo.PenManager;
5 | import com.onyx.android.eink.pen.demo.event.PenEvent;
6 | import com.onyx.android.eink.pen.demo.request.RendererToScreenRequest;
7 | import com.onyx.android.sdk.rx.RxBaseAction;
8 | import com.onyx.android.sdk.utils.EventBusUtils;
9 |
10 | import java.util.concurrent.TimeUnit;
11 |
12 | import io.reactivex.Observable;
13 | import io.reactivex.Scheduler;
14 |
15 | public class RefreshScreenAction extends RxBaseAction {
16 | private volatile boolean pauseRawInputReader = true;
17 | private volatile boolean resumeRawDrawing = true;
18 | private int delayResumePenTimeMs = PenEvent.DELAY_ENABLE_RAW_DRAWING_MILLS;
19 | private int delayRefreshTime;
20 |
21 | public RefreshScreenAction() {
22 | }
23 |
24 | public RefreshScreenAction setDelayResumePenTimeMs(int delayResumePenTimeMs) {
25 | this.delayResumePenTimeMs = delayResumePenTimeMs;
26 | return this;
27 | }
28 |
29 | public RefreshScreenAction setDelayRefreshTime(int delayRefreshTime) {
30 | this.delayRefreshTime = delayRefreshTime;
31 | return this;
32 | }
33 |
34 | @Override
35 | protected Observable create() {
36 | return getPenManager().createObservable()
37 | .flatMap(o -> getDelayObservable())
38 | .map(o -> refresh());
39 | }
40 |
41 | public RefreshScreenAction setResumeRawDrawing(boolean resumeRawDrawing) {
42 | this.resumeRawDrawing = resumeRawDrawing;
43 | return this;
44 | }
45 |
46 | private RefreshScreenAction refresh() throws Exception {
47 | new RendererToScreenRequest(getPenManager())
48 | .setPauseRawInputReader(pauseRawInputReader)
49 | .execute();
50 | if (resumeRawDrawing) {
51 | EventBusUtils.safelyPostEvent(getPenManager().getEventBus(), PenEvent.resumeRawDrawing(delayResumePenTimeMs));
52 | }
53 | return this;
54 | }
55 |
56 | private Observable getDelayObservable() {
57 | Observable observable =
58 | Observable.just(this)
59 | .observeOn(getScheduler());
60 | if (delayRefreshTime == 0 ) {
61 | return observable;
62 | }
63 | return observable.delay(delayRefreshTime, TimeUnit.MILLISECONDS);
64 | }
65 |
66 | public PenBundle getDataBundle() {
67 | return PenBundle.getInstance();
68 | }
69 |
70 | public PenManager getPenManager() {
71 | return getDataBundle().getPenManager();
72 | }
73 |
74 | public Scheduler getScheduler() {
75 | return getPenManager().getObserveOn();
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/app/OnyxPenDemo/src/main/java/com/onyx/android/eink/pen/demo/request/StrokeErasingRequest.java:
--------------------------------------------------------------------------------
1 | package com.onyx.android.eink.pen.demo.request;
2 |
3 | import android.graphics.RectF;
4 |
5 | import androidx.annotation.NonNull;
6 |
7 | import com.onyx.android.eink.pen.demo.PenManager;
8 | import com.onyx.android.eink.pen.demo.bean.EraseArgs;
9 | import com.onyx.android.eink.pen.demo.data.InteractiveMode;
10 | import com.onyx.android.eink.pen.demo.shape.Shape;
11 | import com.onyx.android.eink.pen.demo.util.ShapeUtils;
12 | import com.onyx.android.sdk.pen.data.TouchPointList;
13 | import com.onyx.android.sdk.utils.RectUtils;
14 |
15 | import java.util.ArrayList;
16 | import java.util.List;
17 |
18 | public class StrokeErasingRequest extends BaseRequest {
19 | private final EraseArgs eraseArgs;
20 | private List removedShapeList = new ArrayList<>();
21 |
22 | public StrokeErasingRequest(@NonNull PenManager noteManager, EraseArgs eraseArgs) {
23 | super(noteManager);
24 | this.eraseArgs = eraseArgs;
25 | setPauseRawDraw(false);
26 | }
27 |
28 | @Override
29 | public void execute(PenManager penManager) throws Exception {
30 | penManager.activeRenderMode(InteractiveMode.SCRIBBLE_ERASE);
31 | penManager.getRenderContext().eraseArgs = eraseArgs;
32 | removeShapesByTouchPointList(eraseArgs.eraseTrackPoints, eraseArgs.drawRadius);
33 | penManager.renderToBitmap(removedShapeList);
34 | }
35 |
36 | public void removeShapesByTouchPointList(final TouchPointList touchPointList, final float radius) {
37 | if (touchPointList == null) {
38 | return;
39 | }
40 | ArrayList hitShapes = new ArrayList<>();
41 | List shapeList = getPenManager().getDrawShape();
42 | int shapeSize = shapeList.size();
43 | RectF eraseRect = ShapeUtils.getBoundingRect(touchPointList);
44 | RectUtils.expand(eraseRect, radius);
45 |
46 | for (int i = shapeSize - 1; i >= 0; i--) {
47 | Shape shape = shapeList.get(i);
48 | if (shape.getBoundingRect() == null) {
49 | continue;
50 | }
51 | RectF shapeRect = new RectF(shape.getBoundingRect());
52 | RectUtils.expand(shapeRect, shape.getStrokeWidth() / 2f);
53 | if (RectUtils.intersects(eraseRect, shapeRect)) {
54 | hitShapes.add(shape);
55 | }
56 | }
57 | for (Shape shape : hitShapes) {
58 | if (hitTestAndRemoveShape(shape, touchPointList, radius)) {
59 | removedShapeList.add(shape);
60 | shapeList.remove(shape);
61 | }
62 | }
63 | }
64 |
65 | private boolean hitTestAndRemoveShape(Shape shape, final TouchPointList touchPointList, final float radius) {
66 | if (shape.hitTestPoints(touchPointList, radius)) {
67 | shape.setTransparent(true);
68 | return true;
69 | }
70 | return false;
71 | }
72 |
73 |
74 | }
75 |
--------------------------------------------------------------------------------