Skip to content

Commit 79b46f2

Browse files
author
paolorotolo
committed
Show disabled items in bottom sheet menu when there're no readings.
1 parent 19113bf commit 79b46f2

12 files changed

+247
-45
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@
154154

155155
<category android:name="android.intent.category.DEFAULT" />
156156
</intent-filter>
157-
158157
<meta-data
159158
android:name="android.nfc.action.TECH_DISCOVERED"
160159
android:resource="@xml/nfc_tech_filter" />

app/src/main/java/org/glucosio/android/activity/AddGlucoseActivity.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020

2121
package org.glucosio.android.activity;
2222

23+
import android.content.Intent;
2324
import android.os.Bundle;
2425
import android.support.design.widget.Snackbar;
2526
import android.support.design.widget.TextInputLayout;
26-
import android.support.v7.app.AppCompatActivity;
2727
import android.support.v7.widget.AppCompatButton;
2828
import android.support.v7.widget.Toolbar;
2929
import android.view.View;
@@ -145,7 +145,7 @@ public void onNothingChosen(View labelledSpinner, AdapterView<?> adapterView) {
145145
presenter.updateSpinnerTypeTime();
146146
}
147147

148-
this.getDoneFAB().postDelayed(this.getFabAnimationRunnable(), 600)
148+
this.getDoneFAB().postDelayed(this.getFabAnimationRunnable(), 600);
149149

150150
// Check if activity was started from a NFC sensor
151151
if (getIntent().getExtras() != null) {
@@ -235,5 +235,4 @@ public void onTimeSet(RadialPickerLayout view, int hourOfDay, int minute, int se
235235
DecimalFormat df = new DecimalFormat("00");
236236
updateSpinnerTypeHour(Integer.parseInt(df.format(hourOfDay)));
237237
}
238-
239238
}

app/src/main/java/org/glucosio/android/activity/MainActivity.java

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ public class MainActivity extends AppCompatActivity implements DatePickerDialog.
8989
private BottomSheetDialog bottomSheetAddDialog;
9090
private TextView exportDialogDateFrom;
9191
private TextView exportDialogDateTo;
92-
92+
private View bottomSheetAddDialogView;
9393
private FloatingActionButton fabAddReading;
94-
private FloatingActionButton fabGlucoseEmpty;
94+
BottomSheetBehavior bottomSheetBehavior;
9595
private Toolbar toolbar;
9696
private TabLayout tabLayout;
9797

@@ -102,6 +102,7 @@ protected void onCreate(Bundle savedInstanceState) {
102102
GlucosioApplication application = (GlucosioApplication) getApplication();
103103

104104
setContentView(R.layout.activity_main);
105+
initPresenters(application);
105106

106107
toolbar = (Toolbar) findViewById(R.id.activity_main_toolbar);
107108
tabLayout = (TabLayout) findViewById(R.id.activity_main_tab_layout);
@@ -154,28 +155,17 @@ public void onPageScrollStateChanged(int state) {
154155
}
155156
});
156157

157-
fabGlucoseEmpty = (FloatingActionButton) findViewById(R.id.activity_main_fab_glucose_empty);
158-
fabGlucoseEmpty.setOnClickListener(new View.OnClickListener() {
159-
@Override
160-
public void onClick(View view) {
161-
openNewAddActivity(AddGlucoseActivity.class);
162-
}
163-
});
164158
fabAddReading = (FloatingActionButton) findViewById(R.id.activity_main_fab_add_reading);
165159
fabAddReading.setOnClickListener(new View.OnClickListener() {
166160
@Override
167161
public void onClick(View view) {
168162
bottomSheetAddDialog.show();
163+
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
169164
}
170165
});
171166

172167
bottomSheetAddDialog = new BottomSheetDialog(this);
173168

174-
View bottomSheetAddDialogView = getLayoutInflater().inflate(R.layout.fragment_add_bottom_dialog, null);
175-
bottomSheetAddDialog.setContentView(bottomSheetAddDialogView);
176-
BottomSheetBehavior behavior = BottomSheetBehavior.from((View) bottomSheetAddDialogView.getParent());
177-
behavior.setHideable(false);
178-
179169
// Add Nav Drawer
180170
final PrimaryDrawerItem itemSettings = new PrimaryDrawerItem().withName(R.string.action_settings).withIcon(R.drawable.ic_settings_grey_24dp).withSelectable(false).withTypeface(Typeface.DEFAULT_BOLD);
181171
final PrimaryDrawerItem itemExport = new PrimaryDrawerItem().withName(R.string.sidebar_backup_export).withIcon(R.drawable.ic_backup_grey_24dp).withSelectable(false).withTypeface(Typeface.DEFAULT_BOLD);
@@ -255,8 +245,10 @@ public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
255245
viewPager.setCurrentItem(b.getInt("pager"));
256246
}
257247

258-
initPresenters(application);
259248
checkIfEmptyLayout();
249+
bottomSheetAddDialog.setContentView(bottomSheetAddDialogView);
250+
bottomSheetBehavior = BottomSheetBehavior.from((View) bottomSheetAddDialogView.getParent());
251+
bottomSheetBehavior.setHideable(false);
260252

261253
Analytics analytics = application.getAnalytics();
262254
Log.i("MainActivity", "Setting screen name: " + "main");
@@ -291,7 +283,7 @@ private void startAboutActivity() {
291283
public void startHelloActivity() {
292284
Intent intent = new Intent(this, HelloActivity.class);
293285
startActivity(intent);
294-
finishActivity();
286+
finish();
295287
}
296288

297289
public void openPreferences() {
@@ -595,9 +587,7 @@ public void checkIfEmptyLayout() {
595587
tabLayout.setVisibility(View.GONE);
596588
emptyLayout.setVisibility(View.VISIBLE);
597589

598-
// If empty show only Glucose fab
599-
fabAddReading.setVisibility(View.GONE);
600-
fabGlucoseEmpty.setVisibility(View.VISIBLE);
590+
bottomSheetAddDialogView = getLayoutInflater().inflate(R.layout.fragment_add_bottom_dialog_disabled, null);
601591

602592
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
603593
if (getResources().getConfiguration().orientation == 1) {
@@ -613,7 +603,7 @@ public void checkIfEmptyLayout() {
613603
} else {
614604
pager.setVisibility(View.VISIBLE);
615605
emptyLayout.setVisibility(View.GONE);
616-
fabGlucoseEmpty.setVisibility(View.GONE);
606+
bottomSheetAddDialogView = getLayoutInflater().inflate(R.layout.fragment_add_bottom_dialog, null);
617607
}
618608
}
619609

app/src/main/java/org/glucosio/android/presenter/AddGlucosePresenter.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020

2121
package org.glucosio.android.presenter;
2222

23+
import android.content.SharedPreferences;
24+
import android.preference.PreferenceManager;
25+
2326
import com.google.firebase.crash.FirebaseCrash;
2427

2528
import org.glucosio.android.activity.AddGlucoseActivity;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item>
4+
<shape android:shape="oval">
5+
<solid android:color="@color/light_grey" />
6+
</shape>
7+
</item>
8+
<item android:drawable="@drawable/ic_fab_a1c" />
9+
10+
</layer-list>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item>
4+
<shape android:shape="oval">
5+
<solid android:color="@color/light_grey" />
6+
</shape>
7+
</item>
8+
<item android:drawable="@drawable/ic_fab_cholesterol" />
9+
10+
</layer-list>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item>
4+
<shape android:shape="oval">
5+
<solid android:color="@color/light_grey" />
6+
</shape>
7+
</item>
8+
<item android:drawable="@drawable/ic_fab_ketones" />
9+
10+
</layer-list>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item>
4+
<shape android:shape="oval">
5+
<solid android:color="@color/light_grey" />
6+
</shape>
7+
</item>
8+
<item android:drawable="@drawable/ic_fab_pressure" />
9+
10+
</layer-list>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item>
4+
<shape android:shape="oval">
5+
<solid android:color="@color/light_grey" />
6+
</shape>
7+
</item>
8+
<item android:drawable="@drawable/ic_fab_weight" />
9+
10+
</layer-list>

app/src/main/res/layout/activity_main.xml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,20 +132,4 @@
132132
app:fab_colorPressed="@color/glucosio_accent"
133133
app:fab_colorRipple="#99FFFFFF"
134134
app:fab_size="normal" />
135-
136-
<com.github.clans.fab.FloatingActionButton
137-
android:id="@+id/activity_main_fab_glucose_empty"
138-
android:layout_width="wrap_content"
139-
android:layout_height="wrap_content"
140-
android:layout_alignParentBottom="true"
141-
android:layout_alignParentRight="true"
142-
android:layout_gravity="bottom|right"
143-
android:layout_marginBottom="16dp"
144-
android:layout_marginLeft="10dp"
145-
android:layout_marginRight="16dp"
146-
android:src="@drawable/ic_add_black_24dp"
147-
app:fab_colorNormal="@color/glucosio_accent"
148-
app:fab_colorPressed="@color/glucosio_accent"
149-
app:fab_colorRipple="#99FFFFFF"
150-
app:fab_size="normal" />
151135
</android.support.design.widget.CoordinatorLayout>

0 commit comments

Comments
 (0)