From 2ed968456a6abf5bbfa5f749efb2d6e3079ac061 Mon Sep 17 00:00:00 2001 From: Martijn Brekhof Date: Thu, 5 Apr 2018 19:22:20 +0200 Subject: [PATCH] Upgraded butterknife to 8.8.1 (#524) Refactored MusicListFragment and PVRListFragment to use AbstractTabsFragment Fixed scrolling in a nested scroll view using espresso Fixed issue with setting and checking Kodi major version --- app/build.gradle | 3 +- app/proguard-rules.pro | 4 +- .../testhelpers/action/NestedScrollTo.java | 78 +++++++++++++++++++ .../kore/testhelpers/action/ViewActions.java | 14 ++++ .../xbmc/kore/tests/ui/AbstractTestClass.java | 15 +++- .../RestoreSearchQueryViewPagerTest.java | 2 + .../controlpad/eventserver/ButtonTests.java | 8 +- .../eventserver/KodiPreV17Tests.java | 6 ++ .../remote/controlpad/http/ButtonTests.java | 6 ++ .../controlpad/http/KodiPreV17Tests.java | 6 ++ .../ui/tvshows/TVShowsActivityTests.java | 14 ++-- .../java/org/xbmc/kore/host/HostInfo.java | 4 +- .../xbmc/kore/ui/AbstractInfoFragment.java | 58 ++++++++------ .../xbmc/kore/ui/AbstractListFragment.java | 18 +++-- .../xbmc/kore/ui/AbstractTabsFragment.java | 21 ++++- .../org/xbmc/kore/ui/BaseMediaActivity.java | 6 +- ...olumeControllerDialogFragmentListener.java | 21 +++-- .../ui/sections/audio/MusicListFragment.java | 47 +++++------ .../ui/sections/file/FileListFragment.java | 37 ++------- .../hosts/AddHostFragmentZeroconf.java | 24 ++++-- .../HostFragmentManualConfiguration.java | 36 +++++---- .../ui/sections/hosts/HostListFragment.java | 17 ++-- .../sections/remote/NowPlayingFragment.java | 57 ++++++++------ .../ui/sections/remote/PlaylistFragment.java | 21 +++-- .../ui/sections/remote/RemoteActivity.java | 14 ++-- .../ui/sections/remote/RemoteFragment.java | 66 +++++++++------- .../ui/sections/video/AllCastActivity.java | 8 +- .../video/PVRChannelEPGListFragment.java | 19 +++-- .../video/PVRChannelsListFragment.java | 19 +++-- .../ui/sections/video/PVRListFragment.java | 41 ++-------- .../video/PVRRecordingsListFragment.java | 19 +++-- .../org/xbmc/kore/ui/widgets/ControlPad.java | 35 +++++---- .../ui/widgets/MediaProgressIndicator.java | 27 +++++-- .../xbmc/kore/ui/widgets/NowPlayingPanel.java | 44 +++++++---- .../kore/ui/widgets/VolumeLevelIndicator.java | 18 ++++- .../fabspeeddial/DialActionButton.java | 8 +- .../ui/widgets/fabspeeddial/FABSpeedDial.java | 22 ++++-- .../main/res/layout/fragment_media_list.xml | 35 --------- .../org/xbmc/kore/testutils/Database.java | 7 +- 39 files changed, 563 insertions(+), 342 deletions(-) create mode 100644 app/src/androidTest/java/org/xbmc/kore/testhelpers/action/NestedScrollTo.java delete mode 100644 app/src/main/res/layout/fragment_media_list.xml diff --git a/app/build.gradle b/app/build.gradle index ed97622f9..d512d7531 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -119,7 +119,8 @@ dependencies { compile "com.android.support:design:${supportLibVersion}" compile 'com.fasterxml.jackson.core:jackson-databind:2.5.2' - compile 'com.jakewharton:butterknife:6.1.0' + compile 'com.jakewharton:butterknife:8.8.1' + annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1' compile 'com.squareup.okhttp:okhttp:2.3.0' compile 'com.squareup.picasso:picasso:2.5.2' compile 'de.greenrobot:eventbus:2.4.0' diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 4b445ab83..5610fbb68 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -20,8 +20,8 @@ # Butterknife -dontwarn butterknife.internal.** --keep class **$$ViewInjector { *; } --keepnames class * { @butterknife.InjectView *;} +-keep class **$$ViewBinder { *; } +-keepnames class * { @butterknife.BindView *;} # Jackson -dontskipnonpubliclibraryclassmembers diff --git a/app/src/androidTest/java/org/xbmc/kore/testhelpers/action/NestedScrollTo.java b/app/src/androidTest/java/org/xbmc/kore/testhelpers/action/NestedScrollTo.java new file mode 100644 index 000000000..53747abde --- /dev/null +++ b/app/src/androidTest/java/org/xbmc/kore/testhelpers/action/NestedScrollTo.java @@ -0,0 +1,78 @@ +/* + * Copyright 2018 Martijn Brekhof. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.xbmc.kore.testhelpers.action; + +import android.graphics.Rect; +import android.support.test.espresso.PerformException; +import android.support.test.espresso.UiController; +import android.support.test.espresso.ViewAction; +import android.support.test.espresso.matcher.ViewMatchers; +import android.support.test.espresso.util.HumanReadables; +import android.support.v4.widget.NestedScrollView; +import android.view.View; + +import org.hamcrest.Matcher; +import org.xbmc.kore.utils.LogUtils; + +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayingAtLeast; +import static android.support.test.espresso.matcher.ViewMatchers.isAssignableFrom; +import static android.support.test.espresso.matcher.ViewMatchers.isDescendantOfA; +import static android.support.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.CoreMatchers.anyOf; + +/** + * Modified version of {@link android.support.test.espresso.action.ScrollToAction} to support + * NestedScrollView. + * TODO Check future versions of {@link android.support.test.espresso.action.ScrollToAction} to see if support for NestedScrollView has been added + */ +public class NestedScrollTo implements ViewAction { + private final static String TAG = LogUtils.makeLogTag(NestedScrollTo.class); + + @Override + public Matcher getConstraints() { + return allOf(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE), isDescendantOfA(anyOf( + isAssignableFrom(NestedScrollView.class)))); + } + + @Override + public String getDescription() { + return "nested scroll to"; + } + + @Override + public void perform(UiController uiController, View view) { + if (isDisplayingAtLeast(90).matches(view)) { + LogUtils.LOGI(TAG, "View is already displayed. Returning."); + return; + } + Rect rect = new Rect(); + view.getDrawingRect(rect); + if (!view.requestRectangleOnScreen(rect, true /* immediate */)) { + LogUtils.LOGW(TAG, "Scrolling to view was requested, but none of the parents scrolled."); + } + uiController.loopMainThreadUntilIdle(); + if (!isDisplayingAtLeast(90).matches(view)) { + throw new PerformException.Builder() + .withActionDescription(this.getDescription()) + .withViewDescription(HumanReadables.describe(view)) + .withCause(new RuntimeException( + "Scrolling to view was attempted, but the view is not displayed")) + .build(); + } + } +} diff --git a/app/src/androidTest/java/org/xbmc/kore/testhelpers/action/ViewActions.java b/app/src/androidTest/java/org/xbmc/kore/testhelpers/action/ViewActions.java index 2eedad745..1bda9f9c9 100644 --- a/app/src/androidTest/java/org/xbmc/kore/testhelpers/action/ViewActions.java +++ b/app/src/androidTest/java/org/xbmc/kore/testhelpers/action/ViewActions.java @@ -22,6 +22,7 @@ import android.support.test.espresso.ViewAction; import android.support.test.espresso.action.MotionEvents; import android.support.test.espresso.action.Press; +import android.support.test.espresso.action.ScrollToAction; import android.support.test.espresso.util.HumanReadables; import android.support.test.espresso.util.TreeIterables; import android.view.View; @@ -50,6 +51,19 @@ public static ViewAction clearFocus() { return actionWithAssertions(new ClearFocus()); } + /** + * Returns an action that scrolls to the view in a nested scroll view.
+ *
+ * View preconditions: + *