Skip to content

Commit

Permalink
Create stub options menu for FormHierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperka committed Jan 23, 2019
1 parent e44e38b commit 1bd5b54
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.TextView;

Expand Down Expand Up @@ -110,6 +112,11 @@ public class FormHierarchyActivity extends CollectAbstractActivity {
*/
private FormIndex screenIndex;

/**
* The toolbar menu.
*/
private Menu optionsMenu;

protected Button jumpPreviousButton;
protected Button jumpBeginningButton;
protected Button jumpEndButton;
Expand Down Expand Up @@ -186,6 +193,34 @@ private void restoreInstanceState(Bundle state) {
}
}

public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.form_hierarchy_menu, menu);
return super.onCreateOptionsMenu(menu);
}

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);

optionsMenu = menu;
updateOptionsMenu();

return true;
}

private void updateOptionsMenu() {
// Not ready yet. Menu will be updated automatically once it's been prepared.
if (optionsMenu == null) return;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
default:
return super.onOptionsItemSelected(item);
}
}

/**
* Configure the navigation buttons at the bottom of the screen.
*/
Expand Down Expand Up @@ -364,6 +399,7 @@ private void refreshView(boolean isGoingUp) {
elementsToDisplay = new ArrayList<>();

jumpToHierarchyStartIndex();
updateOptionsMenu();

int event = formController.getEvent();

Expand Down
15 changes: 15 additions & 0 deletions collect_app/src/main/res/menu/form_hierarchy_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 Shobhit Licensed under the Apache
License, Version 2.0 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
OR CONDITIONS OF ANY KIND, either express or implied. See the License for
the specific language governing permissions and limitations under the License.
-->
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

</menu>

0 comments on commit 1bd5b54

Please sign in to comment.