diff options
Diffstat (limited to 'android/experimental/LOAndroid3/src')
5 files changed, 70 insertions, 1 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java index d76e6722cbac..5c8ce78018a5 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java @@ -74,7 +74,7 @@ public class LOKitShell { } public static boolean isEditingEnabled() { - return true; + return LibreOfficeMainActivity.isExperimentalMode(); } public static LayerView getLayerView() { diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java index 2f47b1869b3f..822934f10f4d 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java @@ -4,8 +4,10 @@ import android.app.AlertDialog; import android.content.ContentResolver; import android.content.Context; import android.content.DialogInterface; +import android.content.Intent; import android.os.Bundle; import android.os.Handler; +import android.preference.PreferenceManager; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarActivity; import android.support.v7.widget.Toolbar; @@ -39,12 +41,15 @@ public class LibreOfficeMainActivity extends ActionBarActivity { private static final String LOGTAG = "LibreOfficeMainActivity"; private static final String DEFAULT_DOC_PATH = "/assets/example.odt"; + private static final String ENABLE_EXPERIMENTAL_PREFS_KEY = "ENABLE_EXPERIMENTAL"; public static LibreOfficeMainActivity mAppContext; private static GeckoLayerClient mLayerClient; private static LOKitThread sLOKitThread; + private static boolean mEnableEditing; + public Handler mMainHandler; private DrawerLayout mDrawerLayout; @@ -65,6 +70,10 @@ public class LibreOfficeMainActivity extends ActionBarActivity { return mLayerClient; } + public static boolean isExperimentalMode() { + return mEnableEditing; + } + @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. @@ -107,6 +116,9 @@ public class LibreOfficeMainActivity extends ActionBarActivity { case R.id.action_parts: mDrawerLayout.openDrawer(mDrawerList); return true; + case R.id.action_settings: + startActivity(new Intent(getApplicationContext(), SettingsActivity.class)); + return true; } return super.onOptionsItemSelected(item); } @@ -118,6 +130,7 @@ public class LibreOfficeMainActivity extends ActionBarActivity { // Do the same in case the drawer is locked. boolean isDrawerLocked = mDrawerLayout.getDrawerLockMode(mDrawerList) != DrawerLayout.LOCK_MODE_UNLOCKED; menu.findItem(R.id.action_parts).setVisible(!isDrawerOpen && !isDrawerLocked); + menu.setGroupVisible(R.id.group_edit_actions, mEnableEditing); return super.onPrepareOptionsMenu(menu); } @@ -127,6 +140,9 @@ public class LibreOfficeMainActivity extends ActionBarActivity { mAppContext = this; super.onCreate(savedInstanceState); + mEnableEditing = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()) + .getBoolean(ENABLE_EXPERIMENTAL_PREFS_KEY, false); + mMainHandler = new Handler(); setContentView(R.layout.activity_main); @@ -226,6 +242,12 @@ public class LibreOfficeMainActivity extends ActionBarActivity { protected void onResume() { super.onResume(); Log.i(LOGTAG, "onResume.."); + // check for config change + boolean bEnableExperimental = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean(ENABLE_EXPERIMENTAL_PREFS_KEY, false); + if (bEnableExperimental != mEnableEditing) { + mEnableEditing = bEnableExperimental; + invalidateOptionsMenu(); + } } @Override diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/SettingsActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/SettingsActivity.java new file mode 100644 index 000000000000..c453798a108a --- /dev/null +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/SettingsActivity.java @@ -0,0 +1,37 @@ +/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.libreoffice; + +import android.app.Activity; +import android.os.Bundle; +import android.preference.PreferenceFragment; + +import org.libreoffice.R; + +public class SettingsActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Display the fragment as the main content. + getFragmentManager().beginTransaction() + .replace(android.R.id.content, new SettingsFragment()) + .commit(); + } + + public static class SettingsFragment extends PreferenceFragment { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + addPreferencesFromResource(R.xml.libreoffice_preferences); + } + } +} +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/ToolbarController.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/ToolbarController.java index dde1a614ccc8..abd1f3e8d6a7 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ToolbarController.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ToolbarController.java @@ -102,6 +102,9 @@ public class ToolbarController { * Change the toolbar to edit mode. */ void switchToEditMode() { + if (!LOKitShell.isEditingEnabled()) + return; + // Ensure the change is done on UI thread LOKitShell.getMainHandler().post(new Runnable() { @Override @@ -118,6 +121,9 @@ public class ToolbarController { * Change the toolbar to view mode. */ void switchToViewMode() { + if (!LOKitShell.isEditingEnabled()) + return; + // Ensure the change is done on UI thread LOKitShell.getMainHandler().post(new Runnable() { @Override diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java index 938a2599e1cf..7ac40e4f8049 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java @@ -51,6 +51,7 @@ import android.widget.Toast; import org.libreoffice.LOAbout; import org.libreoffice.LibreOfficeMainActivity; import org.libreoffice.R; +import org.libreoffice.SettingsActivity; import org.libreoffice.storage.DocumentProviderFactory; import org.libreoffice.storage.IDocumentProvider; import org.libreoffice.storage.IFile; @@ -454,6 +455,9 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa case R.id.action_about: mAbout.showAbout(); return true; + case R.id.action_settings: + startActivity(new Intent(getApplicationContext(), SettingsActivity.class)); + return true; default: return super.onOptionsItemSelected(item); } |