disable saving on .tmp files.
Change-Id: I80af505d0dd9a71eda5d640dd336a034288a574d
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
<string name="app_description">LibreOffice Viewer is a document viewer based on LibreOffice.</string>
|
||||
<string name="app_credits">http://www.libreoffice.org</string>
|
||||
<string name="app_vendor">This release was supplied by $VENDOR.</string>
|
||||
<string name="temp_file_saving_disabled">This file is read-only, saving is disabled.</string>
|
||||
|
||||
<string name="about_license">Show License</string>
|
||||
<string name="about_notice">Show Notice</string>
|
||||
@@ -34,6 +35,8 @@
|
||||
<!-- Document provider names -->
|
||||
<string name="local_documents">Local documents</string>
|
||||
<string name="local_file_system">Local file system</string>
|
||||
|
||||
<!-- Edit action names -->
|
||||
<string name="action_bold">Bold</string>
|
||||
<string name="action_underline">Underline</string>
|
||||
<string name="action_italic">Italic</string>
|
||||
|
@@ -70,6 +70,11 @@ public class LibreOfficeMainActivity extends ActionBarActivity {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.main, menu);
|
||||
mToolbarController.setOptionMenu(menu);
|
||||
|
||||
if (mTempFile != null) {
|
||||
mToolbarController.disableMenuItem(R.id.action_save, true);
|
||||
Toast.makeText(this, getString(R.string.temp_file_saving_disabled), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@@ -124,6 +129,12 @@ public class LibreOfficeMainActivity extends ActionBarActivity {
|
||||
|
||||
mMainHandler = new Handler();
|
||||
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
mToolbarController = new ToolbarController(this, getSupportActionBar(), toolbar);
|
||||
|
||||
if (getIntent().getData() != null) {
|
||||
if (getIntent().getData().getScheme().equals(ContentResolver.SCHEME_CONTENT)) {
|
||||
if (copyFileToTemp() && mTempFile != null) {
|
||||
@@ -138,12 +149,6 @@ public class LibreOfficeMainActivity extends ActionBarActivity {
|
||||
mInputFile = DEFAULT_DOC_PATH;
|
||||
}
|
||||
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
mToolbarController = new ToolbarController(this, getSupportActionBar(), toolbar);
|
||||
|
||||
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
@@ -38,6 +38,19 @@ public class ToolbarController {
|
||||
switchToViewMode();
|
||||
}
|
||||
|
||||
public void disableMenuItem(final int menuItemId, final boolean disabled) {
|
||||
LOKitShell.getMainHandler().post(new Runnable() {
|
||||
public void run() {
|
||||
MenuItem menuItem = mOptionsMenu.findItem(menuItemId);
|
||||
if (menuItem != null) {
|
||||
menuItem.setEnabled(!disabled);
|
||||
} else {
|
||||
Log.e(LOGTAG, "MenuItem not found.");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onToggleStateChanged(int type, boolean pressed) {
|
||||
MenuItem menuItem = null;
|
||||
Bitmap icon = null;
|
||||
|
Reference in New Issue
Block a user