Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solved issue of active screen while bottom sheet is up #1355

Merged
merged 1 commit into from
Aug 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/src/main/java/io/pslab/activity/AccelerometerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ protected void onCreate(Bundle savedInstanceState) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

setUpBottomSheet();
tvShadow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(bottomSheetBehavior.getState()==BottomSheetBehavior.STATE_EXPANDED)
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
tvShadow.setVisibility(View.GONE);
}
});
setSupportActionBar(mToolbar);

adapter = new AccelerometerAdapter(new String[]{"X axis", "Y axis", "Z axis"}, getApplicationContext());
Expand Down Expand Up @@ -258,6 +266,7 @@ private void setUpBottomSheet() {

if (isFirstTime) {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
tvShadow.setVisibility(View.VISIBLE);
tvShadow.setAlpha(0.8f);
arrowUpDown.setRotation(180);
bottomSheetSlideText.setText(R.string.hide_guide_text);
Expand Down Expand Up @@ -292,12 +301,14 @@ public void onStateChanged(@NonNull final View bottomSheet, int newState) {
default:
handler.removeCallbacks(runnable);
bottomSheetSlideText.setText(R.string.show_guide_text);
break;
}
}

@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
Float value = (float) MathUtils.map((double) slideOffset, 0.0, 1.0, 0.0, 0.8);
tvShadow.setVisibility(View.VISIBLE);
tvShadow.setAlpha(value);
arrowUpDown.setRotation(slideOffset * 180);
}
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/io/pslab/activity/BarometerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_barometer_main);
ButterKnife.bind(this);
setUpBottomSheet();
tvShadow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(bottomSheetBehavior.getState()==BottomSheetBehavior.STATE_EXPANDED)
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
tvShadow.setVisibility(View.GONE);
}
});
BarometerActivity.newInstance();

currentMin = 10000;
Expand Down Expand Up @@ -366,6 +374,7 @@ private void setUpBottomSheet() {

if (isFirstTime) {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
tvShadow.setVisibility(View.VISIBLE);
tvShadow.setAlpha(0.8f);
arrowUpDown.setRotation(180);
bottomSheetSlideText.setText(R.string.hide_guide_text);
Expand Down Expand Up @@ -407,6 +416,7 @@ public void onStateChanged(@NonNull final View bottomSheet, int newState) {
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
Float value = (float) MathUtils.map((double) slideOffset, 0.0, 1.0, 0.0, 0.8);
tvShadow.setVisibility(View.VISIBLE);
tvShadow.setAlpha(value);
arrowUpDown.setRotation(slideOffset * 180);
}
Expand Down
28 changes: 20 additions & 8 deletions app/src/main/java/io/pslab/activity/CompassActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ public void onClick(View v) {
direction = 2;
}
});

tvShadow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(bottomSheetBehavior.getState()==BottomSheetBehavior.STATE_EXPANDED)
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
tvShadow.setVisibility(View.GONE);
}
});
}

@Override
Expand Down Expand Up @@ -200,13 +209,6 @@ private void setCompassAnimation(float degree) {
compass.startAnimation(ra);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.activity_compass_help_menu, menu);
return true;
}

/**
* Initiates bottom sheet to display guide on how to use Compass instrument
*/
Expand All @@ -217,6 +219,7 @@ private void setUpBottomSheet() {

if (isFirstTime) {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
tvShadow.setVisibility(View.VISIBLE);
tvShadow.setAlpha(0.8f);
arrowUpDown.setRotation(180);
bottomSheetSlideText.setText(R.string.hide_guide_text);
Expand Down Expand Up @@ -249,19 +252,21 @@ public void onStateChanged(@NonNull final View bottomSheet, int newState) {
break;

case BottomSheetBehavior.STATE_COLLAPSED:
handler.postDelayed(runnable, 1000);
handler.postDelayed(runnable, 2000);
break;

default:
handler.removeCallbacks(runnable);
bottomSheetSlideText.setText(R.string.show_guide_text);
break;
}
}

@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
Float value = (float) MathUtils.map((double) slideOffset, 0.0, 1.0,
0.0, 0.8);
tvShadow.setVisibility(View.VISIBLE);
tvShadow.setAlpha(value);
arrowUpDown.setRotation(slideOffset * 180);
}
Expand All @@ -276,6 +281,13 @@ public boolean onTouchEvent(MotionEvent event) {
return super.onTouchEvent(event);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.activity_compass_help_menu, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/io/pslab/activity/LuxMeterActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,17 @@ protected void onCreate(Bundle savedInstanceState) {
ButterKnife.bind(this);
setSupportActionBar(toolbar);
realmPreferences = getSharedPreferences(NAME, Context.MODE_PRIVATE);

setUpBottomSheet();
tvShadow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(bottomSheetBehavior.getState()==BottomSheetBehavior.STATE_EXPANDED)
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
tvShadow.setVisibility(View.GONE);
}
});

bottomNavigationView.setOnNavigationItemSelectedListener
(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
Expand Down Expand Up @@ -145,6 +155,7 @@ private void setUpBottomSheet() {

if (isFirstTime) {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
tvShadow.setVisibility(View.VISIBLE);
tvShadow.setAlpha(0.8f);
arrowUpDown.setRotation(180);
bottomSheetSlideText.setText(R.string.hide_guide_text);
Expand Down Expand Up @@ -179,12 +190,14 @@ public void onStateChanged(@NonNull final View bottomSheet, int newState) {
default:
handler.removeCallbacks(runnable);
bottomSheetSlideText.setText(R.string.show_guide_text);
break;
}
}

@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
Float value = (float) MathUtils.map((double) slideOffset, 0.0, 1.0, 0.0, 0.8);
tvShadow.setVisibility(View.VISIBLE);
tvShadow.setAlpha(value);
arrowUpDown.setRotation(slideOffset * 180);
}
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/io/pslab/activity/MultimeterActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,17 @@ protected void onCreate(final Bundle savedInstanceState) {
scienceLab = ScienceLabCommon.scienceLab;
knobMarker = getResources().getStringArray(io.pslab.R.array.multimeter_knob_states);
setSupportActionBar(mToolbar);

setUpBottomSheet();
tvShadow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(bottomSheetBehavior.getState()==BottomSheetBehavior.STATE_EXPANDED)
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
tvShadow.setVisibility(View.GONE);
}
});

multimeter_data = this.getSharedPreferences(NAME, MODE_PRIVATE);
knobState = multimeter_data.getInt("KnobState", 2);
switchIsChecked = multimeter_data.getBoolean("SwitchState", false);
Expand Down Expand Up @@ -243,6 +253,7 @@ private void setUpBottomSheet() {

if (isFirstTime) {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
tvShadow.setVisibility(View.VISIBLE);
tvShadow.setAlpha(0.8f);
arrowUpDown.setRotation(180);
bottomSheetSlideText.setText(R.string.hide_guide_text);
Expand Down Expand Up @@ -277,12 +288,14 @@ public void onStateChanged(@NonNull final View bottomSheet, int newState) {
default:
handler.removeCallbacks(runnable);
bottomSheetSlideText.setText(R.string.show_guide_text);
break;
}
}

@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
Float value = (float) MathUtils.map((double) slideOffset, 0.0, 1.0, 0.0, 0.8);
tvShadow.setVisibility(View.VISIBLE);
tvShadow.setAlpha(value);
arrowUpDown.setRotation(slideOffset * 180);
}
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/io/pslab/activity/OscilloscopeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,17 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_oscilloscope);
ButterKnife.bind(this);

setUpBottomSheet();
parentLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(bottomSheetBehavior.getState()==BottomSheetBehavior.STATE_EXPANDED)
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
parentLayout.setVisibility(View.GONE);
}
});

scienceLab = ScienceLabCommon.scienceLab;
x1 = mChart.getXAxis();
y1 = mChart.getAxisLeft();
Expand Down Expand Up @@ -703,6 +713,7 @@ private void setUpBottomSheet() {

if (isFirstTime) {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
parentLayout.setVisibility(View.VISIBLE);
parentLayout.setAlpha(0.8f);
arrowUpDown.setRotation(180);
bottomSheetSlideText.setText(R.string.hide_guide_text);
Expand Down Expand Up @@ -737,12 +748,14 @@ public void onStateChanged(@NonNull final View bottomSheet, int newState) {
default:
handler.removeCallbacks(runnable);
bottomSheetSlideText.setText(R.string.show_guide_text);
break;
}
}

@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
Float value = (float) MathUtils.map((double) slideOffset, 0.0, 1.0, 0.0, 0.8);
parentLayout.setVisibility(View.VISIBLE);
parentLayout.setAlpha(value);
arrowUpDown.setRotation(slideOffset * 180);
}
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/java/io/pslab/activity/PowerSourceActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ protected void onCreate(Bundle savedInstanceState) {
powerPreferences = getSharedPreferences(POWER_PREFERENCES, MODE_PRIVATE);

setUpBottomSheet();
tvShadow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(bottomSheetBehavior.getState()==BottomSheetBehavior.STATE_EXPANDED)
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
tvShadow.setVisibility(View.GONE);
}
});

autoSize(displayPV1);
autoSize(displayPV2);
Expand Down Expand Up @@ -179,6 +187,7 @@ private void setUpBottomSheet() {

if (isFirstTime) {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
tvShadow.setVisibility(View.VISIBLE);
tvShadow.setAlpha(0.8f);
arrowUpDown.setRotation(180);
bottomSheetSlideText.setText(R.string.hide_guide_text);
Expand Down Expand Up @@ -217,13 +226,15 @@ public void onStateChanged(@NonNull final View bottomSheet, int newState) {
default:
handler.removeCallbacks(runnable);
bottomSheetSlideText.setText(R.string.show_guide_text);
break;
}
}

@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
Float value = (float) MathUtils.map((double) slideOffset, 0.0, 1.0,
0.0, 0.8);
tvShadow.setVisibility(View.VISIBLE);
tvShadow.setAlpha(value);
arrowUpDown.setRotation(slideOffset * 180);
}
Expand All @@ -244,6 +255,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
inflater.inflate(R.menu.power_source_menu, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/io/pslab/activity/WaveGeneratorActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,17 @@ protected void onCreate(Bundle savedInstanceState) {
if (!WaveGeneratorCommon.isInitialized) {
new WaveGeneratorCommon(true);
}

setUpBottomSheet();
tvShadow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(bottomSheetBehavior.getState()==BottomSheetBehavior.STATE_EXPANDED)
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
tvShadow.setVisibility(View.GONE);
}
});

enableInitialState();
waveDialog = createIntentDialog();

Expand Down Expand Up @@ -697,6 +707,7 @@ private void setUpBottomSheet() {

if (isFirstTime) {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
tvShadow.setVisibility(View.VISIBLE);
tvShadow.setAlpha(0.8f);
arrowUpDown.setRotation(180);
bottomSheetSlideText.setText(R.string.hide_guide_text);
Expand Down Expand Up @@ -731,12 +742,14 @@ public void onStateChanged(@NonNull final View bottomSheet, int newState) {
default:
handler.removeCallbacks(runnable);
bottomSheetSlideText.setText(R.string.show_guide_text);
break;
}
}

@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
Float value = (float) MathUtils.map((double) slideOffset, 0.0, 1.0, 0.0, 0.8);
tvShadow.setVisibility(View.VISIBLE);
tvShadow.setAlpha(value);
arrowUpDown.setRotation(slideOffset * 180);
}
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/java/io/pslab/fragment/LALogicLinesFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,14 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
// Inflating bottom sheet dialog on how to use Logic Analyzer
bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
setUpBottomSheet();
tvShadow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(bottomSheetBehavior.getState()==BottomSheetBehavior.STATE_EXPANDED)
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
tvShadow.setVisibility(View.GONE);
}
});
v.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Expand Down Expand Up @@ -805,6 +813,7 @@ private void setUpBottomSheet() {

if (isFirstTime) {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
tvShadow.setVisibility(View.VISIBLE);
tvShadow.setAlpha(0.8f);
arrowUpDown.setRotation(180);
bottomSheetSlideText.setText(R.string.hide_guide_text);
Expand Down Expand Up @@ -839,12 +848,14 @@ public void onStateChanged(@NonNull final View bottomSheet, int newState) {
default:
handler.removeCallbacks(runnable);
bottomSheetSlideText.setText(R.string.show_guide_text);
break;
}
}

@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
Float value = (float) MathUtils.map((double) slideOffset, 0.0, 1.0, 0.0, 0.8);
tvShadow.setVisibility(View.VISIBLE);
tvShadow.setAlpha(value);
arrowUpDown.setRotation(slideOffset * 180);
}
Expand Down