summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authoraleksandar-stefanovic <theonewithideas@gmail.com>2016-12-29 20:29:41 +0100
committerjan iversen <jani@documentfoundation.org>2017-01-11 06:54:10 +0000
commitd976f9151af53319819c6adb77bc819c460c1bb5 (patch)
tree4fa222e0959fa6be7ead2fc0ea2189c820ce9b0f /android
parent11e443bfe1166939df4836f2e41c79fb7032089f (diff)
Updated toolbar spinner to newer implementation
Lowered all-caps navigation labels to something more professional. Added a Spinner to the Toolbar in XML. Reworked many lines of LibreOfficeUIActivity to remove possible NPE's, and also removed redundant lines, which were mostly deprecated, as well as switching to a newer implementation of a toolbar-spinner navigation pattern. There are more deprecated methods, but I wanted them in a separate commit. Change-Id: I15d5365ed7c00880873bf7874bc794008436bb99 Reviewed-on: https://gerrit.libreoffice.org/32497 Reviewed-by: jan iversen <jani@documentfoundation.org> Tested-by: jan iversen <jani@documentfoundation.org>
Diffstat (limited to 'android')
-rw-r--r--android/source/res/layout/toolbar.xml7
-rw-r--r--android/source/res/values/arrays.xml10
-rw-r--r--android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java46
3 files changed, 40 insertions, 23 deletions
diff --git a/android/source/res/layout/toolbar.xml b/android/source/res/layout/toolbar.xml
index 42136ce68ffc..bbeb62a7629c 100644
--- a/android/source/res/layout/toolbar.xml
+++ b/android/source/res/layout/toolbar.xml
@@ -4,11 +4,18 @@
android:id="@+id/toolbar"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
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">
+ <android.support.v7.widget.AppCompatSpinner
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/toolbar_spinner"/>
+
</android.support.v7.widget.Toolbar>
diff --git a/android/source/res/values/arrays.xml b/android/source/res/values/arrays.xml
index 28849afb5395..0467baae1b2a 100644
--- a/android/source/res/values/arrays.xml
+++ b/android/source/res/values/arrays.xml
@@ -33,11 +33,11 @@
<!-- Preference Name Arrays
This has to be in sync with FileUtilities.java. -->
<string-array name="file_view_modes">
- <item >EVERYTHING</item>
- <item >DOCUMENTS</item>
- <item>SPREADSHEETS</item>
- <item >PRESENTATIONS</item>
- <item>DRAWINGS</item>
+ <item>Everything</item>
+ <item>Documents</item>
+ <item>Spreadsheets</item>
+ <item>Presentations</item>
+ <item>Drawings</item>
</string-array>
<string-array name="FilterTypeNames">
diff --git a/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java b/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
index 148a98cbafec..d0681bd51773 100644
--- a/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
+++ b/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
@@ -24,6 +24,7 @@ import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.AppCompatSpinner;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.ContextMenu;
@@ -66,7 +67,7 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
-public class LibreOfficeUIActivity extends AppCompatActivity implements ActionBar.OnNavigationListener {
+public class LibreOfficeUIActivity extends AppCompatActivity {
private String LOGTAG = LibreOfficeUIActivity.class.getSimpleName();
private SharedPreferences prefs;
private int filterMode = FileUtilities.ALL;
@@ -128,19 +129,34 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements ActionBa
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
- actionBar.setDisplayShowTitleEnabled(false); //This should show current directory if anything
- actionBar.setDisplayHomeAsUpEnabled(true);
- //make the navigation spinner
- Context context = actionBar.getThemedContext();
- ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(context, R.array.file_view_modes, android.R.layout.simple_spinner_item);
- list.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ if (actionBar != null) {
+ actionBar.setDisplayShowTitleEnabled(false);
+ actionBar.setDisplayHomeAsUpEnabled(true);
+
+ //make the navigation spinner
+ Context context = actionBar.getThemedContext();
+ AppCompatSpinner toolbarSpinner = (AppCompatSpinner) findViewById(R.id.toolbar_spinner);
+ ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(context, R.array.file_view_modes, android.R.layout.simple_spinner_item);
+ spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ toolbarSpinner.setAdapter(spinnerAdapter);
+ toolbarSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView<?> adapterView, View view, int pos, long id) {
+ filterMode = pos -1; //bit of a hack, I know. -1 is ALL 0 Docs etc
+ openDirectory(currentDirectory);// Uses filter mode
+ }
- actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
- actionBar.setListNavigationCallbacks(list, this);
+ @Override
+ public void onNothingSelected(AdapterView<?> adapterView) {
+ filterMode = FileUtilities.ALL;
+ openDirectory(currentDirectory);
+ }
+ });
+ }
- LinearLayout content = (LinearLayout) findViewById(R.id.browser_main_content);
+ LinearLayout content = (LinearLayout) findViewById(R.id.browser_main_content);
if (viewMode == GRID_VIEW) {
// code to make a grid view
getLayoutInflater().inflate(R.layout.file_grid, content);
@@ -151,13 +167,13 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements ActionBa
open(position);
}
});
- actionBar.setSelectedNavigationItem(filterMode + 1);//This triggers the listener which modifies the view.
+ openDirectory(currentDirectory);
registerForContextMenu(gv);
} else {
getLayoutInflater().inflate(R.layout.file_list, content);
lv = (ListView)findViewById(R.id.file_explorer_list_view);
lv.setClickable(true);
- actionBar.setSelectedNavigationItem(filterMode + 1);
+ openDirectory(currentDirectory);
registerForContextMenu(lv);
}
@@ -678,12 +694,6 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements ActionBa
Log.d(LOGTAG, "onDestroy");
}
- public boolean onNavigationItemSelected(int itemPosition, long itemId) {
- filterMode = itemPosition -1; //bit of a hack, I know. -1 is ALL 0 Docs etc
- openDirectory(currentDirectory);// Uses filter mode
- return true;
- }
-
private int dpToPx(int dp){
final float scale = getApplicationContext().getResources().getDisplayMetrics().density;
return (int) (dp * scale + 0.5f);