mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-25 01:55:50 +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:
parent
5417c5b5f6
commit
98b04dd2fc
@ -1,5 +1,8 @@
|
|||||||
### Changelog
|
### Changelog
|
||||||
|
|
||||||
|
#### Version NEXT
|
||||||
|
* Charts: added preference to disable swiping charts left/right
|
||||||
|
|
||||||
#### Version 0.22.1
|
#### Version 0.22.1
|
||||||
* Mi Band 2: Fix being detected as Amazfit Bip which lead to various problems especially on newly paired devices
|
* Mi Band 2: Fix being detected as Amazfit Bip which lead to various problems especially on newly paired devices
|
||||||
|
|
||||||
|
@ -29,8 +29,10 @@ import android.support.v4.app.FragmentStatePagerAdapter;
|
|||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
|
import android.util.AttributeSet;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
@ -66,7 +68,7 @@ public class ChartsActivity extends AbstractGBFragmentActivity implements Charts
|
|||||||
private Date mStartDate;
|
private Date mStartDate;
|
||||||
private Date mEndDate;
|
private Date mEndDate;
|
||||||
private SwipeRefreshLayout swipeLayout;
|
private SwipeRefreshLayout swipeLayout;
|
||||||
private ViewPager viewPager;
|
private NonSwipeableViewPager viewPager;
|
||||||
|
|
||||||
LimitedQueue mActivityAmountCache = new LimitedQueue(60);
|
LimitedQueue mActivityAmountCache = new LimitedQueue(60);
|
||||||
|
|
||||||
@ -153,7 +155,7 @@ public class ChartsActivity extends AbstractGBFragmentActivity implements Charts
|
|||||||
enableSwipeRefresh(true);
|
enableSwipeRefresh(true);
|
||||||
|
|
||||||
// Set up the ViewPager with the sections adapter.
|
// 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.setAdapter(getPagerAdapter());
|
||||||
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||||
@Override
|
@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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<android.support.v4.view.ViewPager
|
<nodomain.freeyourgadget.gadgetbridge.activities.charts.NonSwipeableViewPager
|
||||||
android:id="@+id/charts_pager"
|
android:id="@+id/charts_pager"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
@ -25,7 +25,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="top"
|
android:layout_gravity="top"
|
||||||
app:tabMode="scrollable" />
|
app:tabMode="scrollable" />
|
||||||
</android.support.v4.view.ViewPager>
|
</nodomain.freeyourgadget.gadgetbridge.activities.charts.NonSwipeableViewPager>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/charts_date_bar"
|
android:id="@+id/charts_date_bar"
|
||||||
|
@ -70,6 +70,7 @@
|
|||||||
<string name="pref_title_general_autocreonnect">Reconnect automatically</string>
|
<string name="pref_title_general_autocreonnect">Reconnect automatically</string>
|
||||||
<string name="pref_title_audo_player">Preferred Audioplayer</string>
|
<string name="pref_title_audo_player">Preferred Audioplayer</string>
|
||||||
<string name="pref_default">Default</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_header_datetime">Date and Time</string>
|
||||||
<string name="pref_title_datetime_syctimeonconnect">Sync time</string>
|
<string name="pref_title_datetime_syctimeonconnect">Sync time</string>
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<changelog>
|
<changelog>
|
||||||
|
<release version="next">
|
||||||
|
<change>Charts: added preference to disable swiping charts left/right</change>
|
||||||
|
</release>
|
||||||
<release version="0.22.1" versioncode="109">
|
<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>
|
<change>Mi Band 2: Fix being detected as Amazfit Bip which lead to various problems especially on newly paired devices</change>
|
||||||
</release>
|
</release>
|
||||||
|
@ -92,6 +92,10 @@
|
|||||||
android:maxLength="2"
|
android:maxLength="2"
|
||||||
android:title="@string/activity_prefs_sleep_duration" />
|
android:title="@string/activity_prefs_sleep_duration" />
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="charts_allow_swipe"
|
||||||
|
android:title="@string/pref_title_charts_swipe" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="pref_key_datetime"
|
android:key="pref_key_datetime"
|
||||||
|
Loading…
Reference in New Issue
Block a user