1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-29 15:51:17 +00:00

Remove welcome slide dots from screen reading (fixes #216) (#217)

* Remove welcome slide dots from screen reading

according to advice from the prelaunch report.

* Try setImportantForAccessibility on TextViews

* Update APK version to 1.0.0.7

* Try setContentDescription

* Update APK version to 1.0.0.8

* Update APK version to 1.0.0.9

* Add meaningful content description

in case a screen reader unintentionally reads out loud

* Update APK version to 1.0.0.10

* Fix type conversion

* Update APK version to 1.0.0.11

* Add views/CustomViewPager

* Use CustomViewPager in FirstStartActivity

* FirstStartActivity: Use CustomViewPager

* Add main menu string for screen readers

* Reformat code

* Try toolbar.setNavigationContentDescription

* Update APK version to 1.0.0.12

* Import de translation
This commit is contained in:
Catfriend1 2019-01-12 17:54:08 +01:00 committed by GitHub
parent 48c35fd190
commit 2ecba33052
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 77 additions and 20 deletions

View file

@ -37,8 +37,8 @@ android {
applicationId "com.github.catfriend1.syncthingandroid"
minSdkVersion 16
targetSdkVersion 26
versionCode 1000006
versionName "1.0.0.6"
versionCode 1000012
versionName "1.0.0.12"
testApplicationId 'com.github.catfriend1.syncthingandroid.test'
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
playAccountConfig = playAccountConfigs.defaultAccountConfig

View file

@ -23,14 +23,11 @@ import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
@ -45,6 +42,7 @@ import com.nutomic.syncthingandroid.service.Constants;
import com.nutomic.syncthingandroid.service.SyncthingRunnable.ExecutableNotFoundException;
import com.nutomic.syncthingandroid.util.ConfigXml;
import com.nutomic.syncthingandroid.util.Util;
import com.nutomic.syncthingandroid.views.CustomViewPager;
import java.lang.ref.WeakReference;
@ -78,7 +76,7 @@ public class FirstStartActivity extends Activity {
private int mSlidePosIgnoreDozePermission = -1;
private int mSlidePosKeyGeneration = -1;
private ViewPager mViewPager;
private CustomViewPager mViewPager;
private ViewPagerAdapter mViewPagerAdapter;
private LinearLayout mDotsLayout;
private TextView[] mDots;
@ -145,19 +143,12 @@ public class FirstStartActivity extends Activity {
// Show first start welcome wizard UI.
setContentView(R.layout.activity_first_start);
mViewPager = (ViewPager) findViewById(R.id.view_pager);
mViewPager = (CustomViewPager) findViewById(R.id.view_pager);
mDotsLayout = (LinearLayout) findViewById(R.id.layoutDots);
mBackButton = (Button) findViewById(R.id.btn_back);
mNextButton = (Button) findViewById(R.id.btn_next);
mViewPager.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// Consume the event to prevent swiping through the slides.
v.performClick();
return true;
}
});
mViewPager.setPagingEnabled(false);
// Add welcome slides to be shown.
int[] colorsActive = getResources().getIntArray(R.array.array_dot_active);
@ -285,6 +276,10 @@ public class FirstStartActivity extends Activity {
mDots[i].setText(Html.fromHtml("•"));
mDots[i].setTextSize(35);
mDots[i].setTextColor(mSlides[currentPage].dotColorInActive);
// Prevent TalkBack from announcing a decorative TextView.
mDots[i].setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
mDots[i].setContentDescription(getString(R.string.page_x_of_y, Integer.toString(i), Integer.toString(mDots.length)));
mDotsLayout.addView(mDots[i]);
}
@ -297,7 +292,7 @@ public class FirstStartActivity extends Activity {
}
// ViewPager change listener
ViewPager.OnPageChangeListener mViewPagerPageChangeListener = new ViewPager.OnPageChangeListener() {
CustomViewPager.OnPageChangeListener mViewPagerPageChangeListener = new CustomViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {

View file

@ -448,10 +448,11 @@ public class MainActivity extends SyncthingActivity
@Override
public boolean onKeyDown(int keyCode, KeyEvent e) {
if (keyCode == KeyEvent.KEYCODE_MENU) {
if (!mDrawerLayout.isDrawerOpen(GravityCompat.START))
if (!mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
mDrawerLayout.openDrawer(GravityCompat.START);
else
} else {
closeDrawer();
}
return true;
}

View file

@ -42,6 +42,7 @@ public abstract class SyncthingActivity extends AppCompatActivity implements Ser
if (toolbar == null) {
return;
}
toolbar.setNavigationContentDescription(R.string.main_menu);
setSupportActionBar(toolbar);
//noinspection ConstantConditions

View file

@ -0,0 +1,50 @@
package com.nutomic.syncthingandroid.views;
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
public class CustomViewPager extends ViewPager {
private boolean isPagingEnabled = true;
public CustomViewPager(Context context) {
super(context);
}
public CustomViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean arrowScroll(int direction) {
return this.isPagingEnabled && super.arrowScroll(direction);
}
// Required to satisfy lint.
@Override
public boolean performClick() {
return super.performClick();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
super.performClick();
return this.isPagingEnabled && super.onTouchEvent(event);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
return this.isPagingEnabled && super.onInterceptTouchEvent(event);
}
@Override
public boolean canScrollHorizontally(int direction) {
return this.isPagingEnabled && super.canScrollHorizontally(direction);
}
public void setPagingEnabled(boolean b) {
this.isPagingEnabled = b;
}
}

View file

@ -8,7 +8,7 @@
tools:context="com.nutomic.syncthingandroid.activities.FirstStartActivity"
tools:showIn="@layout/activity_first_start">
<android.support.v4.view.ViewPager
<com.nutomic.syncthingandroid.views.CustomViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
@ -20,7 +20,9 @@
android:layout_alignParentBottom="true"
android:layout_marginBottom="@dimen/dots_margin_bottom"
android:gravity="center"
android:orientation="horizontal">
android:orientation="horizontal"
android:importantForAccessibility="no"
android:descendantFocusability="blocksDescendants">
</LinearLayout>
<View

View file

@ -51,6 +51,10 @@ Bitte melden Sie auftretende Probleme via GitHub.</string>
<string name="ignore">Ignorieren</string>
<string name="page_x_of_y">Seite %1$s von %2$s</string>
<string name="main_menu">Hauptmenü</string>
<!-- MainActivity -->

View file

@ -51,6 +51,10 @@ Please report any problems you encounter via Github.</string>
<string name="ignore">Ignore</string>
<string name="page_x_of_y">Page %1$s of %2$s</string>
<string name="main_menu">Main Menu</string>
<!-- MainActivity -->