1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-03 17:02:13 +01:00

Allow disabling left/right swipe on the graphs

Fixes #860
 Added preference to control this option
 Swiping down will still toggle a sync of the data from the device (if connected) in any case
This commit is contained in:
Daniele Gobbetti 2017-11-01 09:07:01 +01:00
parent 5417c5b5f6
commit 98b04dd2fc
6 changed files with 40 additions and 4 deletions

View File

@ -1,5 +1,8 @@
### Changelog
#### Version NEXT
* Charts: added preference to disable swiping charts left/right
#### Version 0.22.1
* Mi Band 2: Fix being detected as Amazfit Bip which lead to various problems especially on newly paired devices

View File

@ -29,8 +29,10 @@ import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.AttributeSet;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
@ -66,7 +68,7 @@ public class ChartsActivity extends AbstractGBFragmentActivity implements Charts
private Date mStartDate;
private Date mEndDate;
private SwipeRefreshLayout swipeLayout;
private ViewPager viewPager;
private NonSwipeableViewPager viewPager;
LimitedQueue mActivityAmountCache = new LimitedQueue(60);
@ -153,7 +155,7 @@ public class ChartsActivity extends AbstractGBFragmentActivity implements Charts
enableSwipeRefresh(true);
// Set up the ViewPager with the sections adapter.
viewPager = (ViewPager) findViewById(R.id.charts_pager);
viewPager = (NonSwipeableViewPager) findViewById(R.id.charts_pager);
viewPager.setAdapter(getPagerAdapter());
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
@ -365,3 +367,26 @@ public class ChartsActivity extends AbstractGBFragmentActivity implements Charts
}
}
}
class NonSwipeableViewPager extends ViewPager {
public NonSwipeableViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (GBApplication.getPrefs().getBoolean("charts_allow_swipe", true)) {
return super.onInterceptTouchEvent(ev);
}
return false;
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (GBApplication.getPrefs().getBoolean("charts_allow_swipe", true)) {
return super.onTouchEvent(ev);
}
return false;
}
}

View File

@ -12,7 +12,7 @@
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v4.view.ViewPager
<nodomain.freeyourgadget.gadgetbridge.activities.charts.NonSwipeableViewPager
android:id="@+id/charts_pager"
android:layout_width="match_parent"
android:layout_height="0dp"
@ -25,7 +25,7 @@
android:layout_height="wrap_content"
android:layout_gravity="top"
app:tabMode="scrollable" />
</android.support.v4.view.ViewPager>
</nodomain.freeyourgadget.gadgetbridge.activities.charts.NonSwipeableViewPager>
<LinearLayout
android:id="@+id/charts_date_bar"

View File

@ -70,6 +70,7 @@
<string name="pref_title_general_autocreonnect">Reconnect automatically</string>
<string name="pref_title_audo_player">Preferred Audioplayer</string>
<string name="pref_default">Default</string>
<string name="pref_title_charts_swipe">Enable left/right swipe in the charts activity</string>
<string name="pref_header_datetime">Date and Time</string>
<string name="pref_title_datetime_syctimeonconnect">Sync time</string>

View File

@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<changelog>
<release version="next">
<change>Charts: added preference to disable swiping charts left/right</change>
</release>
<release version="0.22.1" versioncode="109">
<change>Mi Band 2: Fix being detected as Amazfit Bip which lead to various problems especially on newly paired devices</change>
</release>

View File

@ -92,6 +92,10 @@
android:maxLength="2"
android:title="@string/activity_prefs_sleep_duration" />
</PreferenceScreen>
<CheckBoxPreference
android:defaultValue="true"
android:key="charts_allow_swipe"
android:title="@string/pref_title_charts_swipe" />
</PreferenceCategory>
<PreferenceCategory
android:key="pref_key_datetime"