Replaced empty spinner with the document title

Replaced empty spinner with the document title in the Main (viewer)
activity. Had to edit the themes to not disable title, and edit the
manifest to make the desired activities use that theme. If the theme
is set in the "application" tag, it will apply the theme globablly.
Also cleaned up and tightened the ToolbarController.

Change-Id: I5099860787b5f84d01c98c5e53ade519c2f89cc4
Reviewed-on: https://gerrit.libreoffice.org/33306
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Aleksandar Stefanović <theonewithideas@gmail.com>
This commit is contained in:
aleksandar-stefanovic 2017-01-19 12:06:30 +01:00 committed by Aleksandar Stefanović
parent 39ced315aa
commit 6310fa8a70
5 changed files with 28 additions and 31 deletions

View file

@ -13,6 +13,7 @@
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/LibreOfficeTheme"
android:debuggable="true"
android:hardwareAccelerated="true"
android:largeHeap="false">
@ -21,8 +22,7 @@
<activity
android:name=".LibreOfficeMainActivity"
android:label="@string/app_name"
android:configChanges="orientation|keyboard|keyboardHidden|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@style/LibreOfficeTheme">
android:configChanges="orientation|keyboard|keyboardHidden|screenLayout|uiMode|screenSize|smallestScreenSize" >
<!-- android:windowSoftInputMode="adjustResize" -->
<intent-filter>
@ -98,8 +98,7 @@
<!-- Document Browser Activity -->
<activity android:name="org.libreoffice.ui.LibreOfficeUIActivity"
android:label="@string/app_name"
android:theme="@style/BrowserTheme">
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
@ -114,13 +113,11 @@
</intent-filter>
</activity>
<activity android:name=".storage.external.BrowserSelectorActivity"
android:theme="@style/LibreOfficeTheme">
<activity android:name=".storage.external.BrowserSelectorActivity" >
</activity>
<activity android:name=".storage.external.DirectoryBrowserActivity"
android:label="@string/directory_browser_label"
android:theme="@style/LibreOfficeTheme"
android:windowSoftInputMode="stateHidden">
</activity>

View file

@ -1,18 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
<android.support.v4.widget.DrawerLayout android:id="@+id/drawer_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fff"
tools:context=".LibreOfficeMainActivity">
tools:context=".LibreOfficeMainActivity" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/toolbar"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="3dp"
android:background="@color/toolbar_background"
app:theme="@style/LibreOfficeTheme.Toolbar"
tools:theme="@style/LibreOfficeTheme.Toolbar"
app:popupTheme="@style/LibreOfficeTheme" />
<include layout="@layout/toolbar_bottom"/>

View file

@ -3,10 +3,6 @@
<style name="LibreOfficeTheme" parent="LibreOfficeTheme.Base"/>
<style name="LibreOfficeTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
</style>
<style name="BrowserTheme" parent="Theme.AppCompat.Light.NoActionBar">
</style>
<style name="ListItemText">

View file

@ -116,10 +116,9 @@ public class LibreOfficeMainActivity extends AppCompatActivity {
setContentView(R.layout.activity_main);
Toolbar toolbarTop = (Toolbar) findViewById(R.id.toolbar);
hideBottomToolbar();
mToolbarController = new ToolbarController(this, getSupportActionBar(), toolbarTop);
mToolbarController = new ToolbarController(this, toolbarTop);
mFormattingController = new FormattingController(this);
toolbarTop.setNavigationOnClickListener(new View.OnClickListener() {
@Override
@ -154,6 +153,9 @@ public class LibreOfficeMainActivity extends AppCompatActivity {
mInputFile = new File(DEFAULT_DOC_PATH);
}
toolbarTop.setTitle(mInputFile.getName());
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
if (mDocumentPartViewListAdapter == null) {

View file

@ -8,7 +8,6 @@
*/
package org.libreoffice;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
@ -22,13 +21,11 @@ public class ToolbarController implements Toolbar.OnMenuItemClickListener {
private static final String LOGTAG = ToolbarController.class.getSimpleName();
private final Toolbar mToolbarTop;
private final ActionBar mActionBar;
private LibreOfficeMainActivity mContext;
private Menu mMainMenu;
private final LibreOfficeMainActivity mContext;
private final Menu mMainMenu;
public ToolbarController(LibreOfficeMainActivity context, ActionBar actionBar, Toolbar toolbarTop) {
public ToolbarController(LibreOfficeMainActivity context, Toolbar toolbarTop) {
mToolbarTop = toolbarTop;
mActionBar = actionBar;
mContext = context;
mToolbarTop.inflateMenu(R.menu.main);
@ -38,7 +35,7 @@ public class ToolbarController implements Toolbar.OnMenuItemClickListener {
mMainMenu = mToolbarTop.getMenu();
}
public void disableMenuItem(final int menuItemId, final boolean disabled) {
private void disableMenuItem(final int menuItemId, final boolean disabled) {
LOKitShell.getMainHandler().post(new Runnable() {
public void run() {
MenuItem menuItem = mMainMenu.findItem(menuItemId);
@ -64,7 +61,6 @@ public class ToolbarController implements Toolbar.OnMenuItemClickListener {
public void run() {
mMainMenu.setGroupVisible(R.id.group_edit_actions, true);
mToolbarTop.setNavigationIcon(R.drawable.ic_check);
mToolbarTop.setTitle(null);
mToolbarTop.setLogo(null);
}
@ -84,7 +80,6 @@ public class ToolbarController implements Toolbar.OnMenuItemClickListener {
public void run() {
mMainMenu.setGroupVisible(R.id.group_edit_actions, false);
mToolbarTop.setNavigationIcon(R.drawable.lo_icon);
mToolbarTop.setTitle(null);
mToolbarTop.setLogo(null);
}
});
@ -124,13 +119,12 @@ public class ToolbarController implements Toolbar.OnMenuItemClickListener {
return false;
}
public void setupToolbars() {
LibreOfficeMainActivity activity = mContext;
if (activity.usesTemporaryFile()) {
void setupToolbars() {
if (mContext.usesTemporaryFile()) {
disableMenuItem(R.id.action_save, true);
Toast.makeText(activity, activity.getString(R.string.temp_file_saving_disabled), Toast.LENGTH_LONG).show();
Toast.makeText(mContext, mContext.getString(R.string.temp_file_saving_disabled), Toast.LENGTH_LONG).show();
}
mMainMenu.findItem(R.id.action_parts).setVisible(activity.isDrawerEnabled());
mMainMenu.findItem(R.id.action_parts).setVisible(mContext.isDrawerEnabled());
}
}