LibreOffice Module android (master) 1
LOKitShell.java
Go to the documentation of this file.
1/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9package org.libreoffice;
10
11
12import android.app.ActivityManager;
13import android.content.Context;
14import android.graphics.PointF;
15import android.graphics.RectF;
16import android.os.Handler;
17import android.util.DisplayMetrics;
18import android.view.KeyEvent;
19
22
26public class LOKitShell {
27 public static float getDpi(Context context) {
28 LOKitTileProvider tileProvider = ((LibreOfficeMainActivity)context).getTileProvider();
29 if (tileProvider != null && tileProvider.isSpreadsheet())
30 return 96f;
31 DisplayMetrics metrics = context.getResources().getDisplayMetrics();
32 return metrics.density * 160;
33 }
34
35 // Get a Handler for the main java thread
36 public static Handler getMainHandler() {
38 }
39
40 public static void showProgressSpinner(final LibreOfficeMainActivity context) {
41 getMainHandler().post(new Runnable() {
42 @Override
43 public void run() {
44 context.showProgressSpinner();
45 }
46 });
47 }
48
49 public static void hideProgressSpinner(final LibreOfficeMainActivity context) {
50 getMainHandler().post(new Runnable() {
51 @Override
52 public void run() {
53 context.hideProgressSpinner();
54 }
55 });
56 }
57
58 public static int getMemoryClass(Context context) {
59 ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
60 return activityManager.getMemoryClass() * 1024 * 1024;
61 }
62
63 public static boolean isEditingEnabled() {
65 }
66
67 // EVENTS
68
72 public static void sendEvent(LOEvent event) {
73 LibreOfficeMainActivity.loKitThread.queueEvent(event);
74 }
75
78 }
79
83 public static void sendTouchEvent(String touchType, PointF documentTouchCoordinate) {
84 LOKitShell.sendEvent(new LOEvent(LOEvent.TOUCH, touchType, documentTouchCoordinate));
85 }
86
90 public static void sendKeyEvent(KeyEvent event) {
92 }
93
94 public static void sendSizeChangedEvent(int width, int height) {
96 }
97
98 public static void sendSwipeRightEvent() {
100 }
101
102 public static void sendSwipeLeftEvent() {
104 }
105
106 public static void sendChangePartEvent(int part) {
108 }
109
110 public static void sendLoadEvent(String inputFilePath) {
111 LOKitShell.sendEvent(new LOEvent(inputFilePath, LOEvent.LOAD));
112 }
113
114 public static void sendNewDocumentLoadEvent(String newDocumentPath, String newDocumentType) {
115 LOKitShell.sendEvent(new LOEvent(newDocumentPath, newDocumentType, LOEvent.LOAD_NEW));
116 }
117
118 public static void sendSaveAsEvent(String filePath, String fileFormat) {
120 }
121
122 public static void sendSaveCopyAsEvent(String filePath, String fileFormat) {
124 }
125
126 public static void sendCloseEvent() {
128 }
129
133 public static void sendTileReevaluationRequest(ComposedTileLayer composedTileLayer) {
135 }
136
140 public static void sendTileInvalidationRequest(RectF rect) {
142 }
143
147 public static void sendChangeHandlePositionEvent(SelectionHandle.HandleType handleType, PointF documentCoordinate) {
148 LOKitShell.sendEvent(new LOEvent(LOEvent.CHANGE_HANDLE_POSITION, handleType, documentCoordinate));
149 }
150
151 public static void sendNavigationClickEvent() {
153 }
154
159 public static void moveViewportTo(final LibreOfficeMainActivity context, final PointF position, final Float zoom) {
160 context.getLayerClient().post(new Runnable() {
161 @Override
162 public void run() {
163 context.getLayerClient().moveTo(position, zoom);
164 }
165 });
166 }
167}
168
169/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Events and data that is queued and processed by LOKitThread.
Definition: LOEvent.java:21
static final int LOAD_NEW
Definition: LOEvent.java:36
static final int CHANGE_PART
Definition: LOEvent.java:23
static final int TOUCH
Definition: LOEvent.java:29
static final int TILE_INVALIDATION
Definition: LOEvent.java:28
static final int SAVE_COPY_AS
Definition: LOEvent.java:44
static final int NAVIGATION_CLICK
Definition: LOEvent.java:34
static final int SWIPE_RIGHT
Definition: LOEvent.java:32
static final int SIZE_CHANGED
Definition: LOEvent.java:22
static final int LOAD
Definition: LOEvent.java:24
static final int SWIPE_LEFT
Definition: LOEvent.java:33
static final int CLOSE
Definition: LOEvent.java:25
static final int KEY_EVENT
Definition: LOEvent.java:30
static final int CHANGE_HANDLE_POSITION
Definition: LOEvent.java:31
static final int THUMBNAIL
Definition: LOEvent.java:27
static final int TILE_REEVALUATION_REQUEST
Definition: LOEvent.java:26
static final int SAVE_AS
Definition: LOEvent.java:37
Common static LOKit functions, functions to send events.
Definition: LOKitShell.java:26
static void sendSwipeLeftEvent()
static void sendSaveAsEvent(String filePath, String fileFormat)
static void sendChangeHandlePositionEvent(SelectionHandle.HandleType handleType, PointF documentCoordinate)
Send change handle position event to LOKitThread.
static boolean isEditingEnabled()
Definition: LOKitShell.java:63
static void sendNewDocumentLoadEvent(String newDocumentPath, String newDocumentType)
static void sendTileInvalidationRequest(RectF rect)
Send tile invalidation to LOKitThread.
static void sendEvent(LOEvent event)
Make sure LOKitThread is running and send event to it.
Definition: LOKitShell.java:72
static void sendChangePartEvent(int part)
static void sendKeyEvent(KeyEvent event)
Send key event to LOKitThread.
Definition: LOKitShell.java:90
static void sendTileReevaluationRequest(ComposedTileLayer composedTileLayer)
Send tile reevaluation to LOKitThread.
static void hideProgressSpinner(final LibreOfficeMainActivity context)
Definition: LOKitShell.java:49
static void sendTouchEvent(String touchType, PointF documentTouchCoordinate)
Send touch event to LOKitThread.
Definition: LOKitShell.java:83
static float getDpi(Context context)
Definition: LOKitShell.java:27
static void sendLoadEvent(String inputFilePath)
static Handler getMainHandler()
Definition: LOKitShell.java:36
static void sendSizeChangedEvent(int width, int height)
Definition: LOKitShell.java:94
static void sendThumbnailEvent(ThumbnailCreator.ThumbnailCreationTask task)
Definition: LOKitShell.java:76
static void sendSwipeRightEvent()
Definition: LOKitShell.java:98
static void moveViewportTo(final LibreOfficeMainActivity context, final PointF position, final Float zoom)
Move the viewport to the desired point (top-left), and change the zoom level.
static int getMemoryClass(Context context)
Definition: LOKitShell.java:58
static void sendNavigationClickEvent()
static void sendSaveCopyAsEvent(String filePath, String fileFormat)
static void sendCloseEvent()
static void showProgressSpinner(final LibreOfficeMainActivity context)
Definition: LOKitShell.java:40
Main activity of the LibreOffice App.
Create thumbnails for the parts of the document.
Selection handle is a common class for "start", "middle" and "end" types of selection handles.
void moveTo(PointF point, Float zoom)
Move the viewport to the desired point, and change the zoom level.
boolean post(Runnable action)
Implementation of PanZoomTarget.
def position(n=-1)
def run(arg=None, arg2=-1)
filePath