1package org.libreoffice;
3import android.app.AlertDialog;
4import android.content.ClipData;
5import android.content.ClipboardManager;
6import android.content.ContentResolver;
7import android.content.Context;
8import android.content.DialogInterface;
9import android.content.Intent;
10import android.content.SharedPreferences;
11import android.content.res.AssetManager;
12import android.graphics.RectF;
13import android.net.Uri;
14import android.os.Build;
15import android.os.Bundle;
16import android.preference.PreferenceManager;
17import android.provider.DocumentsContract;
18import com.google.android.material.bottomsheet.BottomSheetBehavior;
19import com.google.android.material.snackbar.Snackbar;
20import androidx.drawerlayout.widget.DrawerLayout;
21import androidx.appcompat.app.AppCompatActivity;
22import androidx.appcompat.widget.Toolbar;
23import android.text.InputType;
24import android.util.Log;
25import android.view.KeyEvent;
26import android.view.View;
27import android.view.inputmethod.InputMethodManager;
28import android.widget.AdapterView;
29import android.widget.EditText;
30import android.widget.LinearLayout;
31import android.widget.ListView;
32import android.widget.TabHost;
33import android.widget.Toast;
43import java.io.FileInputStream;
44import java.io.FileNotFoundException;
45import java.io.FileOutputStream;
46import java.io.IOException;
47import java.io.InputStream;
48import java.io.OutputStream;
49import java.nio.ByteBuffer;
50import java.nio.channels.Channels;
51import java.nio.channels.FileChannel;
52import java.nio.channels.ReadableByteChannel;
53import java.util.ArrayList;
91 BottomSheetBehavior bottomToolbarSheetBehavior;
92 BottomSheetBehavior toolbarColorPickerBottomSheetBehavior;
93 BottomSheetBehavior toolbarBackColorPickerBottomSheetBehavior;
126 super.onCreate(savedInstanceState);
131 setContentView(
R.layout.activity_main);
133 toolbarTop = findViewById(
R.id.toolbar);
138 toolbarTop.setNavigationOnClickListener(
new View.OnClickListener() {
140 public void onClick(View view) {
141 LOKitShell.sendNavigationClickEvent();
153 LayerView layerView = findViewById(
R.id.layer_view);
158 layerView.setOnKeyListener(
new View.OnKeyListener() {
160 public boolean onKey(View view, int i, KeyEvent keyEvent) {
161 if(!isReadOnlyMode() && keyEvent.getKeyCode() != KeyEvent.KEYCODE_BACK){
162 setDocumentChanged(true);
169 mDocumentOverlay =
new DocumentOverlay(
this, layerView);
171 mbISReadOnlyMode = !isExperimentalMode();
173 final Uri docUri = getIntent().getData();
174 if (docUri !=
null) {
175 if (docUri.getScheme().equals(ContentResolver.SCHEME_CONTENT)
176 || docUri.getScheme().equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) {
177 final boolean isReadOnlyDoc = (getIntent().getFlags() & Intent.FLAG_GRANT_WRITE_URI_PERMISSION) == 0;
178 mbISReadOnlyMode = !isExperimentalMode() || isReadOnlyDoc;
179 Log.d(LOGTAG,
"SCHEME_CONTENT: getPath(): " + docUri.getPath());
181 String displayName = FileUtilities.retrieveDisplayNameForDocumentUri(getContentResolver(), docUri);
182 toolbarTop.setTitle(displayName);
184 }
else if (docUri.getScheme().equals(ContentResolver.SCHEME_FILE)) {
185 mbISReadOnlyMode =
true;
186 Log.d(LOGTAG,
"SCHEME_FILE: getPath(): " + docUri.getPath());
187 toolbarTop.setTitle(docUri.getLastPathSegment());
190 boolean copyOK = copyFileToTemp(docUri) && mTempFile !=
null;
193 Log.e(LOGTAG,
"couldn't create temporary file from " + docUri);
199 if (isTemplate(docUri)) {
200 toolbarTop.setTitle(
R.string.default_document_name);
202 mDocumentUri = docUri;
205 LOKitShell.sendLoadEvent(mTempFile.getPath());
206 }
else if (getIntent().getStringExtra(LibreOfficeUIActivity.NEW_DOC_TYPE_KEY) !=
null) {
208 String newDocumentType = getIntent().getStringExtra(LibreOfficeUIActivity.NEW_DOC_TYPE_KEY);
210 loadNewDocument(newDocumentType);
211 toolbarTop.setTitle(
getString(
R.string.default_document_name));
213 Log.e(LOGTAG,
"No document specified. This should never happen.");
218 mbSkipNextRefresh =
true;
220 mDrawerLayout = findViewById(
R.id.drawer_layout);
222 if (mDocumentPartViewListAdapter ==
null) {
223 mDrawerList = findViewById(
R.id.left_drawer);
225 mDocumentPartViewListAdapter =
new DocumentPartViewListAdapter(
this,
R.layout.document_part_list_layout, mDocumentPartView);
226 mDrawerList.setAdapter(mDocumentPartViewListAdapter);
227 mDrawerList.setOnItemClickListener(
new DocumentPartClickListener());
230 mToolbarController.setupToolbars();
232 TabHost host = findViewById(
R.id.toolbarTabHost);
235 TabHost.TabSpec spec = host.newTabSpec(
getString(
R.string.tabhost_character));
236 spec.setContent(
R.id.tab_character);
237 spec.setIndicator(
getString(
R.string.tabhost_character));
240 spec = host.newTabSpec(
getString(
R.string.tabhost_paragraph));
241 spec.setContent(
R.id.tab_paragraph);
242 spec.setIndicator(
getString(
R.string.tabhost_paragraph));
245 spec = host.newTabSpec(
getString(
R.string.tabhost_insert));
246 spec.setContent(
R.id.tab_insert);
247 spec.setIndicator(
getString(
R.string.tabhost_insert));
250 spec = host.newTabSpec(
getString(
R.string.tabhost_style));
251 spec.setContent(
R.id.tab_style);
252 spec.setIndicator(
getString(
R.string.tabhost_style));
255 LinearLayout bottomToolbarLayout = findViewById(
R.id.toolbar_bottom);
256 LinearLayout toolbarColorPickerLayout = findViewById(
R.id.toolbar_color_picker);
257 LinearLayout toolbarBackColorPickerLayout = findViewById(
R.id.toolbar_back_color_picker);
258 bottomToolbarSheetBehavior = BottomSheetBehavior.from(bottomToolbarLayout);
259 toolbarColorPickerBottomSheetBehavior = BottomSheetBehavior.from(toolbarColorPickerLayout);
260 toolbarBackColorPickerBottomSheetBehavior = BottomSheetBehavior.from(toolbarBackColorPickerLayout);
261 bottomToolbarSheetBehavior.setHideable(
true);
262 toolbarColorPickerBottomSheetBehavior.setHideable(
true);
263 toolbarBackColorPickerBottomSheetBehavior.setHideable(
true);
267 SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
268 mIsExperimentalMode = BuildConfig.ALLOW_EDITING
269 && sPrefs.getBoolean(ENABLE_EXPERIMENTAL_PREFS_KEY,
false);
270 mIsDeveloperMode = mIsExperimentalMode
271 && sPrefs.getBoolean(ENABLE_DEVELOPER_PREFS_KEY,
false);
272 if (sPrefs.getInt(ASSETS_EXTRACTED_PREFS_KEY, 0) != BuildConfig.VERSION_CODE) {
274 sPrefs.edit().putInt(ASSETS_EXTRACTED_PREFS_KEY, BuildConfig.VERSION_CODE).apply();
281 String tempFileName =
"LibreOffice_" + UUID.randomUUID().toString();
282 mTempFile =
new File(this.getCacheDir(), tempFileName);
293 String intentType = getIntent().getType();
295 if (
"text/comma-separated-values".equals(intentType) ||
"text/csv".equals(intentType))
299 mTempFile =
File.createTempFile(
"LibreOffice", suffix, this.getCacheDir());
300 final FileOutputStream outputStream =
new FileOutputStream(mTempFile);
301 return copyUriToStream(documentUri, outputStream);
302 }
catch (FileNotFoundException e) {
304 }
catch (IOException e) {
313 Toast.makeText(
this,
R.string.message_saving, Toast.LENGTH_SHORT).show();
323 Intent intent =
new Intent(Intent.ACTION_CREATE_DOCUMENT);
324 intent.addCategory(Intent.CATEGORY_OPENABLE);
325 String mimeType = getODFMimeTypeForDocument();
326 intent.setType(mimeType);
327 intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, mDocumentUri);
329 startActivityForResult(intent, REQUEST_CODE_SAVEAS);
338 mDocumentUri = newUri;
340 mTileProvider.saveDocumentAs(mTempFile.getPath(),
true);
341 saveFileToOriginalSource();
344 toolbarTop.setTitle(displayName);
345 mbISReadOnlyMode = !isExperimentalMode();
346 getToolbarController().setupToolbars();
350 Intent intent =
new Intent(Intent.ACTION_CREATE_DOCUMENT);
351 intent.addCategory(Intent.CATEGORY_OPENABLE);
353 intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, mDocumentUri);
355 startActivityForResult(intent, REQUEST_CODE_EXPORT_TO_PDF);
359 boolean exportOK =
false;
360 File tempFile =
null;
362 tempFile =
File.createTempFile(
"LibreOffice_",
".pdf");
363 mTileProvider.saveDocumentAs(tempFile.getAbsolutePath(),
"pdf",
false);
366 FileInputStream inputStream =
new FileInputStream(tempFile);
367 exportOK = copyStreamToUri(inputStream, uri);
368 }
catch (FileNotFoundException e) {
372 }
catch (IOException e) {
375 if (tempFile !=
null && tempFile.exists()) {
380 final int msgId = exportOK ?
R.string.pdf_export_finished :
R.string.unable_to_export_pdf;
384 showCustomStatusMessage(
getString(msgId));
396 if (mTileProvider.isTextDocument())
398 else if (mTileProvider.isSpreadsheet())
400 else if (mTileProvider.isPresentation())
402 else if (mTileProvider.isDrawing())
405 Log.w(
LOGTAG,
"Cannot determine MIME type to use.");
414 final String mimeType = getContentResolver().getType(documentUri);
419 if (isReadOnlyMode() || mTempFile ==
null || mDocumentUri ==
null || !mDocumentUri.getScheme().equals(ContentResolver.SCHEME_CONTENT))
422 boolean copyOK =
false;
424 final FileInputStream inputStream =
new FileInputStream(mTempFile);
425 copyOK = copyStreamToUri(inputStream, mDocumentUri);
426 }
catch (FileNotFoundException e) {
430 runOnUiThread(
new Runnable() {
434 Toast.LENGTH_SHORT).show();
437 setDocumentChanged(
false);
439 runOnUiThread(
new Runnable() {
443 Toast.LENGTH_SHORT).show();
456 mToolbarController.switchToEditMode();
458 mToolbarController.switchToViewMode();
472 if (!mbSkipNextRefresh) {
475 mbSkipNextRefresh =
false;
481 hideSoftKeyboardDirect();
493 if (mTempFile !=
null) {
497 if (mTempSlideShowFile !=
null && mTempSlideShowFile.exists()) {
499 mTempSlideShowFile.delete();
505 if (!isDocumentChanged) {
506 super.onBackPressed();
511 DialogInterface.OnClickListener dialogClickListener =
new DialogInterface.OnClickListener() {
513 public void onClick(DialogInterface dialog,
int which) {
515 case DialogInterface.BUTTON_POSITIVE:
516 mTileProvider.saveDocument();
517 isDocumentChanged=
false;
520 case DialogInterface.BUTTON_NEGATIVE:
523 case DialogInterface.BUTTON_NEUTRAL:
525 isDocumentChanged=
false;
532 AlertDialog.Builder builder =
new AlertDialog.Builder(
this);
533 builder.setMessage(
R.string.save_alert_dialog_title)
534 .setPositiveButton(
R.string.save_document, dialogClickListener)
535 .setNegativeButton(
R.string.action_cancel, dialogClickListener)
536 .setNeutralButton(
R.string.no_save_document, dialogClickListener)
542 return mDocumentPartView;
550 mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, mDrawerList);
556 return mDocumentPartViewListAdapter;
568 if(!isKeyboardOpen) showSoftKeyboardDirect();
569 else hideSoftKeyboardDirect();
576 LayerView layerView = findViewById(
R.id.layer_view);
578 if (layerView.requestFocus()) {
579 InputMethodManager inputMethodManager = (InputMethodManager) getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);
580 inputMethodManager.showSoftInput(layerView, InputMethodManager.SHOW_FORCED);
583 isSearchToolbarOpen=
false;
584 isFormattingToolbarOpen=
false;
585 isUNOCommandsToolbarOpen=
false;
593 if (findViewById(
R.id.toolbar_bottom).getVisibility() !=
View.VISIBLE
594 && findViewById(
R.id.toolbar_color_picker).getVisibility() !=
View.VISIBLE) {
595 showSoftKeyboardDirect();
608 hideSoftKeyboardDirect();
617 if (getCurrentFocus() !=
null) {
618 InputMethodManager inputMethodManager = (InputMethodManager) getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);
619 inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
620 isKeyboardOpen=
false;
628 bottomToolbarSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
637 bottomToolbarSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
638 toolbarColorPickerBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
639 toolbarBackColorPickerBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
640 findViewById(
R.id.search_toolbar).setVisibility(
View.GONE);
641 findViewById(
R.id.UNO_commands_toolbar).setVisibility(
View.GONE);
642 isFormattingToolbarOpen=
false;
643 isSearchToolbarOpen=
false;
644 isUNOCommandsToolbarOpen=
false;
653 if (isFormattingToolbarOpen) {
654 hideFormattingToolbar();
657 findViewById(
R.id.search_toolbar).setVisibility(
View.GONE);
658 findViewById(
R.id.formatting_toolbar).setVisibility(
View.VISIBLE);
659 findViewById(
R.id.search_toolbar).setVisibility(
View.GONE);
660 findViewById(
R.id.UNO_commands_toolbar).setVisibility(
View.GONE);
661 hideSoftKeyboardDirect();
662 isSearchToolbarOpen=
false;
663 isFormattingToolbarOpen=
true;
664 isUNOCommandsToolbarOpen=
false;
684 if (isSearchToolbarOpen) {
688 findViewById(
R.id.formatting_toolbar).setVisibility(
View.GONE);
689 toolbarColorPickerBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
690 toolbarBackColorPickerBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
691 findViewById(
R.id.search_toolbar).setVisibility(
View.VISIBLE);
692 findViewById(
R.id.UNO_commands_toolbar).setVisibility(
View.GONE);
693 hideSoftKeyboardDirect();
694 isFormattingToolbarOpen=
false;
695 isSearchToolbarOpen=
true;
696 isUNOCommandsToolbarOpen=
false;
715 if(isUNOCommandsToolbarOpen){
716 hideUNOCommandsToolbar();
719 findViewById(
R.id.formatting_toolbar).setVisibility(
View.GONE);
720 findViewById(
R.id.search_toolbar).setVisibility(
View.GONE);
721 findViewById(
R.id.UNO_commands_toolbar).setVisibility(
View.VISIBLE);
722 hideSoftKeyboardDirect();
723 isFormattingToolbarOpen=
false;
724 isSearchToolbarOpen=
false;
725 isUNOCommandsToolbarOpen=
true;
741 findViewById(
R.id.loadingPanel).setVisibility(
View.VISIBLE);
745 findViewById(
R.id.loadingPanel).setVisibility(
View.GONE);
752 alertDialogBuilder.setTitle(
R.string.error);
753 alertDialogBuilder.setMessage(message);
754 alertDialogBuilder.setNeutralButton(
R.string.alert_ok,
new DialogInterface.OnClickListener() {
755 public void onClick(DialogInterface dialog, int id) {
760 AlertDialog alertDialog = alertDialogBuilder.create();
765 return mDocumentOverlay;
769 return mCalcHeadersController;
773 return mToolbarController;
777 return mFontController;
781 return mFormattingController;
785 mDrawerLayout.openDrawer(mDrawerList);
791 aboutDialogFragment.show(getSupportFragmentManager(),
"AboutDialogFragment");
795 mTileProvider.addPart();
796 mDocumentPartViewListAdapter.notifyDataSetChanged();
797 setDocumentChanged(
true);
801 AlertDialog.Builder builder =
new AlertDialog.Builder(
this);
802 builder.setTitle(
R.string.enter_part_name);
803 final EditText input =
new EditText(
this);
804 input.setInputType(InputType.TYPE_CLASS_TEXT);
805 builder.setView(input);
807 builder.setPositiveButton(
R.string.alert_ok,
new DialogInterface.OnClickListener() {
809 public void onClick(DialogInterface dialog, int which) {
810 mTileProvider.renamePart( input.getText().toString());
813 builder.setNegativeButton(
R.string.alert_cancel,
new DialogInterface.OnClickListener() {
815 public void onClick(DialogInterface dialog, int which) {
824 mTileProvider.removePart();
832 boolean isDrawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
833 boolean isDrawerLocked = mDrawerLayout.getDrawerLockMode(mDrawerList) != DrawerLayout.LOCK_MODE_UNLOCKED;
834 return !isDrawerOpen && !isDrawerLocked;
839 if (key.matches(ENABLE_EXPERIMENTAL_PREFS_KEY)) {
840 Log.d(
LOGTAG,
"Editing Preference Changed");
841 mIsExperimentalMode = sharedPreferences.getBoolean(ENABLE_EXPERIMENTAL_PREFS_KEY,
false);
848 passwordDialogFragment.show(getSupportFragmentManager(),
"PasswordDialogFragment");
853 mTileProvider.setDocumentPassword(
"file://" + mTempFile.getPath(), mPassword);
858 mTileProvider = loKitTileProvider;
862 return mTileProvider;
867 synchronized (mTileProvider.getMessageCallback()) {
868 mTileProvider.getMessageCallback().notifyAll();
873 mPasswordProtected = b;
877 return mPasswordProtected;
886 findViewById(
R.id.calc_header_top_left).setVisibility(
View.VISIBLE);
887 findViewById(
R.id.calc_header_row).setVisibility(
View.VISIBLE);
888 findViewById(
R.id.calc_header_column).setVisibility(
View.VISIBLE);
889 findViewById(
R.id.calc_address).setVisibility(
View.VISIBLE);
890 findViewById(
R.id.calc_formula).setVisibility(
View.VISIBLE);
896 return mbISReadOnlyMode;
900 return mDocumentUri !=
null;
909 public void onItemClick(AdapterView<?> parent, View view,
int position,
long id) {
912 mDrawerLayout.closeDrawer(mDrawerList);
917 String fromAssetPath, String targetDir) {
919 String[] files = assetManager.list(fromAssetPath);
922 for (
String file : files) {
923 String[] dirOrFile = assetManager.list(fromAssetPath +
"/" + file);
924 if ( dirOrFile.length == 0) {
926 new File(targetDir).mkdirs();
927 res &= copyAsset(assetManager,
928 fromAssetPath +
"/" + file,
929 targetDir +
"/" + file);
931 res &= copyFromAssets(assetManager,
932 fromAssetPath +
"/" + file,
933 targetDir +
"/" + file);
938 Log.e(
LOGTAG,
"copyFromAssets failed: " + e.getMessage());
943 private static boolean copyAsset(AssetManager assetManager, String fromAssetPath, String toPath) {
944 ReadableByteChannel source =
null;
945 FileChannel dest =
null;
948 source = Channels.newChannel(assetManager.open(fromAssetPath));
949 dest =
new FileOutputStream(toPath).getChannel();
950 long bytesTransferred = 0;
952 ByteBuffer buffer = ByteBuffer.allocate(4096);
953 while (source.read(buffer) > 0) {
955 bytesTransferred += dest.write(buffer);
958 Log.v(
LOGTAG,
"Success copying " + fromAssetPath +
" to " + toPath +
" bytes: " + bytesTransferred);
961 if (dest !=
null) dest.close();
962 if (source !=
null) source.close();
964 }
catch (FileNotFoundException e) {
965 Log.e(
LOGTAG,
"file " + fromAssetPath +
" not found! " + e.getMessage());
967 }
catch (IOException e) {
968 Log.e(
LOGTAG,
"failed to copy file " + fromAssetPath +
" from assets to " + toPath +
" - " + e.getMessage());
978 private boolean copyStream(InputStream inputStream, OutputStream outputStream) {
980 byte[] buffer =
new byte[4096];
981 int readBytes = inputStream.read(buffer);
982 while (readBytes != -1) {
983 outputStream.write(buffer, 0, readBytes);
984 readBytes = inputStream.read(buffer);
987 }
catch (IOException e) {
993 outputStream.close();
994 }
catch (IOException e) {
1010 class CopyThread
extends Thread {
1012 private boolean result =
false;
1016 final ContentResolver contentResolver = getContentResolver();
1018 InputStream inputStream = contentResolver.openInputStream(inputUri);
1019 result = copyStream(inputStream, outputStream);
1020 }
catch (FileNotFoundException e) {
1021 e.printStackTrace();
1025 CopyThread copyThread =
new CopyThread();
1031 }
catch(InterruptedException e) {
1032 e.printStackTrace();
1034 return copyThread.result;
1044 class CopyThread
extends Thread {
1046 private boolean result =
false;
1050 final ContentResolver contentResolver = getContentResolver();
1052 OutputStream outputStream = contentResolver.openOutputStream(outputUri);
1053 result = copyStream(inputStream, outputStream);
1054 }
catch (FileNotFoundException e) {
1055 e.printStackTrace();
1059 CopyThread copyThread =
new CopyThread();
1065 }
catch(InterruptedException e) {
1066 e.printStackTrace();
1068 return copyThread.result;
1072 Snackbar.make(mDrawerLayout, message, Snackbar.LENGTH_LONG).show();
1076 if (getExternalCacheDir() !=
null) {
1077 String tempPath = getExternalCacheDir().getPath() +
"/" + mTempFile.getName() +
".svg";
1078 mTempSlideShowFile =
new File(tempPath);
1079 if (mTempSlideShowFile.exists() && !isDocumentChanged) {
1080 startPresentation(
"file://" + tempPath);
1089 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
1091 intent.setData(Uri.parse(tempPath));
1092 startActivity(intent);
1095 ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
1096 ClipData clip = ClipData.newPlainText(
"temp svg file path", tempPath);
1097 clipboard.setPrimaryClip(clip);
1099 AlertDialog.Builder builder =
new AlertDialog.Builder(
this);
1100 builder.setMessage(
R.string.alert_copy_svg_slide_show_to_clipboard)
1101 .setPositiveButton(
R.string.alert_copy_svg_slide_show_to_clipboard_dismiss,
null).show();
1107 super.onActivityResult(requestCode, resultCode, data);
1108 if (requestCode == REQUEST_CODE_SAVEAS && resultCode == RESULT_OK) {
1109 final Uri fileUri = data.getData();
1110 saveDocumentAs(fileUri);
1111 }
else if (requestCode == REQUEST_CODE_EXPORT_TO_PDF && resultCode == RESULT_OK) {
1112 final Uri fileUri = data.getData();
1113 exportToPDF(fileUri);
1115 mFormattingController.handleActivityResult(requestCode, resultCode, data);
1116 hideBottomToolbar();
Events and data that is queued and processed by LOKitThread.
static final int UNO_COMMAND_NOTIFY
Common static LOKit functions, functions to send events.
static void sendNewDocumentLoadEvent(String newDocumentPath, String newDocumentType)
static void sendEvent(LOEvent event)
Make sure LOKitThread is running and send event to it.
static void sendChangePartEvent(int part)
static Handler getMainHandler()
static void sendSaveCopyAsEvent(String filePath, String fileFormat)
static void sendCloseEvent()
void onItemClick(AdapterView<?> parent, View view, int position, long id)
Main activity of the LibreOffice App.
boolean copyFileToTemp(Uri documentUri)
void onCreate(Bundle savedInstanceState)
ToolbarController mToolbarController
boolean isFormattingToolbarOpen
GeckoLayerClient getLayerClient()
boolean mbSkipNextRefresh
void hideUNOCommandsToolbar()
DrawerLayout mDrawerLayout
boolean copyStream(InputStream inputStream, OutputStream outputStream)
Copies everything from the given input stream to the given output stream and closes both streams in t...
void showFormattingToolbar()
void disableNavigationDrawer()
RectF getCurrentCursorPosition()
GeckoLayerClient mLayerClient
static boolean mIsExperimentalMode
void hideSoftKeyboardDirect()
Hides software keyboard.
static boolean isReadOnlyMode()
CalcHeadersController mCalcHeadersController
CalcHeadersController getCalcHeadersController()
void initializeCalcHeaders()
void savePassword(String pwd)
void showAlertDialog(String message)
boolean isSearchToolbarOpen
void showSoftKeyboard()
Show software keyboard.
File mTempFile
Temporary local copy of the document.
void showCustomStatusMessage(String message)
UNOCommandsController mUNOCommandsController
static boolean isDeveloperMode()
List< DocumentPartView > getDocumentPartView()
static final String ENABLE_EXPERIMENTAL_PREFS_KEY
static final int REQUEST_CODE_EXPORT_TO_PDF
FormattingController getFormattingController()
DocumentOverlay mDocumentOverlay
boolean mPasswordProtected
static boolean copyAsset(AssetManager assetManager, String fromAssetPath, String toPath)
void showSoftKeyboardOrFormattingToolbar()
FontController getFontController()
boolean copyStreamToUri(final InputStream inputStream, final Uri outputUri)
Copies everything from the given InputStream to the given URI and closes the InputStream in the end.
DocumentOverlay getDocumentOverlay()
void setPasswordProtected(boolean b)
ToolbarController getToolbarController()
void hideProgressSpinner()
void setTileProvider(LOKitTileProvider loKitTileProvider)
void saveDocumentAs(Uri newUri)
Saves the document under the given URI using ODF format and uses that URI from now on for all operati...
FormattingController mFormattingController
static boolean copyFromAssets(AssetManager assetManager, String fromAssetPath, String targetDir)
static void setDocumentChanged(boolean changed)
boolean isDrawerEnabled()
boolean hasLocationForSave()
String getODFMimeTypeForDocument()
Returns the ODF MIME type that can be used for the current document, regardless of whether the docume...
static boolean isDocumentChanged
static final int REQUEST_CODE_SAVEAS
void saveDocument()
Save the document.
void showSoftKeyboardDirect()
boolean copyUriToStream(final Uri inputUri, final OutputStream outputStream)
Copies everything from the given Uri to the given OutputStream and closes the OutputStream in the end...
boolean isUNOCommandsToolbarOpen
static LOKitThread loKitThread
Uri mDocumentUri
URI to save the document to.
FontController mFontController
DocumentPartViewListAdapter getDocumentPartViewListAdapter()
void loadNewDocument(String newDocumentType)
LOKitTileProvider getTileProvider()
void saveDocumentAs()
Open file chooser and save the document to the URI selected there.
void onActivityResult(int requestCode, int resultCode, Intent data)
static final String LOGTAG
static final String ENABLE_DEVELOPER_PREFS_KEY
void startPresentation(String tempPath)
void settingsPreferenceChanged(SharedPreferences sharedPreferences, String key)
LOKitTileProvider mTileProvider
static boolean isExperimentalMode()
void hideFormattingToolbar()
boolean isTemplate(final Uri documentUri)
Returns whether the MIME type for the URI is considered one for a document template.
static boolean mIsDeveloperMode
void saveFileToOriginalSource()
static final String ASSETS_EXTRACTED_PREFS_KEY
void showProgressSpinner()
void showUNOCommandsToolbar()
void preparePresentation()
boolean isPasswordProtected()
DocumentPartViewListAdapter mDocumentPartViewListAdapter
static boolean mbISReadOnlyMode
SearchController mSearchController
final List< DocumentPartView > mDocumentPartView
void hideSoftKeyboard()
Hides software keyboard on UI thread.
void exportToPDF(final Uri uri)
void setLOMainActivity(LibreOfficeMainActivity context)
void setListener(OnSettingsPreferenceChangedListener listener)
static SettingsListenerModel getInstance()
The DocumentOverlay is an overlay over the document.
RectF getCurrentCursorPosition()
static final String MIMETYPE_OPENDOCUMENT_TEXT
static boolean isTemplateMimeType(final String mimeType)
Returns whether the passed MIME type is one for a document template.
static final String MIMETYPE_PDF
static final String MIMETYPE_OPENDOCUMENT_PRESENTATION
static String retrieveDisplayNameForDocumentUri(ContentResolver resolver, Uri docUri)
Tries to retrieve the display (which should be the document name) for the given URI using the given r...
static final String MIMETYPE_OPENDOCUMENT_GRAPHICS
static final String MIMETYPE_OPENDOCUMENT_SPREADSHEET
void setView(LayerView view)
A view rendered by the layer compositor.
void setInputConnectionHandler(InputConnectionHandler inputConnectionHandler)
void SAL_CALL changed(::sal_Int32 ID, const css::uno::Sequence< css::beans::NamedValue > &Properties) override
def run(arg=None, arg2=-1)
OUString getString(const Any &_rAny)
const application_info_impl * getApplicationInfo(std::u16string_view rServiceName)