Skip to content

Commit

Permalink
Settings for overview Y-axes visibility (#971)
Browse files Browse the repository at this point in the history
* Settings for overview Y-axes visibility

* Removed the settings entry and moved option to the dropdown

* Removed unused xml declaration

* Update strings.xml

* Update overview_menu.xml

* Added autohiding right y-axis in overview if only one measurement view is selected

* Added autohiding of the appropriate axis

* Removed autohiding of y-axes on the overview

* Removed unused imports and unnecessary changes

* Removed changed space

---------

Co-authored-by: OliE <[email protected]>
  • Loading branch information
undefiened and oliexdev authored Jul 22, 2023
1 parent b211881 commit 168c832
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
chartView.setProgressBar(overviewView.findViewById(R.id.progressBar));
chartView.setIsInGraphKey(false);
chartView.getLegend().setEnabled(false);
chartView.getAxisRight().setDrawLabels(false);
chartView.getAxisRight().setDrawGridLines(false);
chartView.getAxisRight().setDrawAxisLine(false);
chartView.getAxisLeft().setDrawGridLines(false);
chartView.getAxisLeft().setDrawLabels(false);
chartView.getAxisLeft().setDrawAxisLine(false);
chartView.getXAxis().setDrawGridLines(false);

setYAxisVisibility(prefs.getBoolean("enableYAxis", false));

chartActionBarView = overviewView.findViewById(R.id.chartActionBar);
chartActionBarView.setIsInGraphKey(false);
Expand Down Expand Up @@ -149,6 +144,13 @@ public boolean onMenuItemClick(MenuItem item) {
chartActionBarView.setVisibility(View.VISIBLE);
}
return true;
case R.id.enableYAxis:
boolean checked = item.isChecked();
item.setChecked(!checked);
prefs.edit().putBoolean("enableYAxis", !checked).apply();
setYAxisVisibility(!checked);
updateChartView();
return true;
case R.id.menu_range_day:
prefs.edit().putInt("selectRangeMode", ChartMeasurementView.ViewMode.DAY_OF_ALL.ordinal()).commit();
break;
Expand Down Expand Up @@ -196,6 +198,9 @@ public boolean onMenuItemClick(MenuItem item) {
chartActionBarView.setVisibility(View.GONE);
}

MenuItem enableYAxis = rangePopupMenu.getMenu().findItem(R.id.enableYAxis);
enableYAxis.setChecked(prefs.getBoolean("enableYAxis", false));

recyclerView = overviewView.findViewById(R.id.recyclerView);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
layoutManager.setInitialPrefetchItemCount(5);
Expand Down Expand Up @@ -235,6 +240,18 @@ public void handleOnBackPressed() {
return overviewView;
}

protected void setYAxisVisibility(boolean visible) {
chartView.getAxisRight().setDrawLabels(visible);
chartView.getAxisRight().setDrawGridLines(visible);
chartView.getAxisRight().setDrawAxisLine(visible);

chartView.getAxisLeft().setDrawGridLines(visible);
chartView.getAxisLeft().setDrawLabels(visible);
chartView.getAxisLeft().setDrawAxisLine(visible);

chartView.getXAxis().setDrawGridLines(visible);
}

public void updateOnView(List<ScaleMeasurement> scaleMeasurementList) {
this.scaleMeasurementList = scaleMeasurementList;

Expand Down
5 changes: 5 additions & 0 deletions android_app/app/src/main/res/menu/overview_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
android:title="@string/label_measurement_bar"
android:checkable="true"
android:checked="false"/>
<item
android:id="@+id/enableYAxis"
android:title="@string/label_y_axis"
android:checkable="true"
android:checked="false"/>

<group android:id="@+id/rangeGroup"
android:checkableBehavior="single">
Expand Down
3 changes: 2 additions & 1 deletion android_app/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -287,4 +287,5 @@
<string name="app_intro_back_button">Back</string>
<string name="app_intro_done_button">Done</string>
<string name="info_create_new_user_on_scale">Create new user on scale.</string>
</resources>
<string name="label_y_axis">Y-axis</string>
</resources>

0 comments on commit 168c832

Please sign in to comment.