mirror of
https://github.com/syncthing/syncthing-android.git
synced 2025-01-07 10:42:07 +00:00
* Save welcome wizard button state (fixes #281) * FirstStartActivity xml: Disallow focus for non-button elements * Fix ViewPager taking focus on mouse click glitch on TV * Provide key navigation if ViewPager accidentially took focus (fixes #281)
This commit is contained in:
parent
f2eacf0401
commit
78ba036df7
2 changed files with 31 additions and 3 deletions
|
@ -198,6 +198,30 @@ public class FirstStartActivity extends AppCompatActivity {
|
|||
onBtnNextClick();
|
||||
}
|
||||
});
|
||||
|
||||
if (mRunningOnTV) {
|
||||
mNextButton.setFocusableInTouchMode(true);
|
||||
}
|
||||
if (savedInstanceState != null) {
|
||||
mBackButton.setVisibility(savedInstanceState.getBoolean("mBackButton") ? View.VISIBLE : View.GONE);
|
||||
mNextButton.setVisibility(savedInstanceState.getBoolean("mNextButton") ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
if (mNextButton.getVisibility() == View.VISIBLE) {
|
||||
mNextButton.requestFocus();
|
||||
} else if (mBackButton.getVisibility() == View.VISIBLE) {
|
||||
mBackButton.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves current tab index and fragment states.
|
||||
*/
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
outState.putBoolean("mBackButton", mBackButton.getVisibility() == View.VISIBLE);
|
||||
outState.putBoolean("mNextButton", mNextButton.getVisibility() == View.VISIBLE);
|
||||
}
|
||||
|
||||
public void onBtnBackClick() {
|
||||
|
@ -207,6 +231,7 @@ public class FirstStartActivity extends AppCompatActivity {
|
|||
mViewPager.setCurrentItem(current);
|
||||
if (current == 0) {
|
||||
mBackButton.setVisibility(View.GONE);
|
||||
mNextButton.requestFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,10 +10,13 @@
|
|||
<com.nutomic.syncthingandroid.views.CustomViewPager
|
||||
android:id="@+id/view_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
android:layout_height="match_parent"
|
||||
android:nextFocusLeft="@+id/btn_back"
|
||||
android:nextFocusRight="@+id/btn_next" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layoutDots"
|
||||
android:focusable="false"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dots_height"
|
||||
android:layout_alignParentBottom="true"
|
||||
|
@ -25,6 +28,7 @@
|
|||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:focusable="false"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:alpha=".5"
|
||||
|
@ -33,6 +37,7 @@
|
|||
|
||||
<Button
|
||||
android:id="@+id/btn_back"
|
||||
android:focusable="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
|
@ -45,7 +50,6 @@
|
|||
<Button
|
||||
android:id="@+id/btn_next"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
|
@ -53,7 +57,6 @@
|
|||
android:layout_alignParentEnd="true"
|
||||
android:text="@string/cont"
|
||||
style="@style/Theme.Syncthing.GreyButton" >
|
||||
<requestFocus />
|
||||
</Button>
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
Loading…
Reference in a new issue