Android: show drawer ("hamburger") icon on root directory
When browsing the root directory, the application home button (on the top left corner) becomes a drawer icon. When not in the root dir, the icon is an arrow as usual. This will increase the visibility of the document providers feature. Also, modified the behavior of the system back key to close the drawer in case it is open. Change-Id: Id0ce932907bcec4b8601029482eda0c1c1f0df35 Reviewed-on: https://gerrit.libreoffice.org/16246 Reviewed-by: Jacobo Aragunde Pérez <jaragunde@igalia.com> Tested-by: Jacobo Aragunde Pérez <jaragunde@igalia.com>
This commit is contained in:
@@ -46,6 +46,8 @@
|
|||||||
<string name="share_via">Share via</string>
|
<string name="share_via">Share via</string>
|
||||||
|
|
||||||
<!-- Document provider names -->
|
<!-- Document provider names -->
|
||||||
|
<string name="document_locations">Document locations</string>
|
||||||
|
<string name="close_document_locations">Close document locations</string>
|
||||||
<string name="local_documents">Local documents</string>
|
<string name="local_documents">Local documents</string>
|
||||||
<string name="local_file_system">Local file system</string>
|
<string name="local_file_system">Local file system</string>
|
||||||
<string name="owncloud">ownCloud</string>
|
<string name="owncloud">ownCloud</string>
|
||||||
|
@@ -25,6 +25,7 @@ import android.preference.PreferenceManager;
|
|||||||
import android.support.v4.widget.DrawerLayout;
|
import android.support.v4.widget.DrawerLayout;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
|
import android.support.v7.app.ActionBarDrawerToggle;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
@@ -93,6 +94,7 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
|
|||||||
|
|
||||||
private DrawerLayout drawerLayout;
|
private DrawerLayout drawerLayout;
|
||||||
private ListView drawerList;
|
private ListView drawerList;
|
||||||
|
private ActionBarDrawerToggle drawerToggle;
|
||||||
GridView gv;
|
GridView gv;
|
||||||
ListView lv;
|
ListView lv;
|
||||||
|
|
||||||
@@ -128,6 +130,7 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
|
|||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
ActionBar actionBar = getSupportActionBar();
|
ActionBar actionBar = getSupportActionBar();
|
||||||
actionBar.setDisplayShowTitleEnabled(false); //This should show current directory if anything
|
actionBar.setDisplayShowTitleEnabled(false); //This should show current directory if anything
|
||||||
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
//make the navigation spinner
|
//make the navigation spinner
|
||||||
Context context = actionBar.getThemedContext();
|
Context context = actionBar.getThemedContext();
|
||||||
@@ -163,6 +166,25 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
|
|||||||
|
|
||||||
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
|
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||||
drawerList = (ListView) findViewById(R.id.left_drawer);
|
drawerList = (ListView) findViewById(R.id.left_drawer);
|
||||||
|
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout,
|
||||||
|
R.string.document_locations, R.string.close_document_locations) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDrawerOpened(View drawerView) {
|
||||||
|
super.onDrawerOpened(drawerView);
|
||||||
|
supportInvalidateOptionsMenu();
|
||||||
|
drawerList.requestFocus(); // Make keypad navigation easier
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDrawerClosed(View drawerView) {
|
||||||
|
super.onDrawerClosed(drawerView);
|
||||||
|
supportInvalidateOptionsMenu();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
drawerToggle.setDrawerIndicatorEnabled(true);
|
||||||
|
drawerLayout.setDrawerListener(drawerToggle);
|
||||||
|
drawerToggle.syncState();
|
||||||
|
|
||||||
// Set the adapter for the list view
|
// Set the adapter for the list view
|
||||||
drawerList.setAdapter(new ArrayAdapter<String>(this,
|
drawerList.setAdapter(new ArrayAdapter<String>(this,
|
||||||
@@ -178,12 +200,19 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostCreate(Bundle savedInstanceState) {
|
||||||
|
super.onPostCreate(savedInstanceState);
|
||||||
|
|
||||||
|
drawerToggle.syncState();
|
||||||
|
}
|
||||||
|
|
||||||
private void refreshView() {
|
private void refreshView() {
|
||||||
// enable home icon as "up" if required
|
// enable home icon as "up" if required
|
||||||
if (!currentDirectory.equals(homeDirectory)) {
|
if (!currentDirectory.equals(homeDirectory)) {
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
drawerToggle.setDrawerIndicatorEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
drawerToggle.setDrawerIndicatorEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileUtilities.sortFiles(filePaths, sortMode);
|
FileUtilities.sortFiles(filePaths, sortMode);
|
||||||
@@ -201,7 +230,9 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
if (!currentDirectory.equals(homeDirectory)) {
|
if (drawerLayout.isDrawerOpen(drawerList)) {
|
||||||
|
drawerLayout.closeDrawer(drawerList);
|
||||||
|
} else if (!currentDirectory.equals(homeDirectory)) {
|
||||||
// navigate upwards in directory hierarchy
|
// navigate upwards in directory hierarchy
|
||||||
openParentDirectory();
|
openParentDirectory();
|
||||||
} else {
|
} else {
|
||||||
@@ -459,7 +490,13 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
// Will close the drawer if the home button is pressed
|
||||||
|
if (drawerToggle.onOptionsItemSelected(item)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
if (!currentDirectory.equals(homeDirectory)){
|
if (!currentDirectory.equals(homeDirectory)){
|
||||||
|
Reference in New Issue
Block a user