Skip to content

Commit

Permalink
Merge pull request #4 from usefulness/updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszkwiecinski authored Nov 18, 2022
2 parents 04a584c + d2f6ba4 commit 689651d
Show file tree
Hide file tree
Showing 23 changed files with 293 additions and 227 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
java-version: 11

- uses: gradle/gradle-build-action@v2

Expand All @@ -94,20 +94,28 @@ jobs:
target: google_apis
arch: x86
disable-spellchecker: true
working-directory: sample
script: |
adb shell settings put global hidden_api_policy_p_apps 1
adb shell settings put global hidden_api_policy_pre_p_apps 1
adb shell settings put global hidden_api_policy 1
python --version
pip show Pillow
./gradlew connectedCheck
./gradlew executeScreenshotTests
- name: Upload tests result
uses: actions/upload-artifact@v3
with:
name: android-tests
path: "${{ github.workspace }}/**/build/*AndroidTest/"

- name: Upload screeenshots
uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: screenshots-report
path: "${{ github.workspace }}/**/build/**/shot/"

build-sample-app:
runs-on: ubuntu-latest
steps:
Expand Down
9 changes: 4 additions & 5 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
The code (most of it) is available under [BSD License](LICENSE)

```markdown
BSD License

For Shimmer-android software

Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.
Expand Down Expand Up @@ -29,10 +30,9 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
```

the code, added in 2022 and onwards, is available under MIT License:
```markdown
the new code, added in 2022 and onwards, is available under MIT License:

MIT License

Copyright (c) Developers from https://github.com/usefulness organization
Expand All @@ -54,4 +54,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
6 changes: 5 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[versions]
gradle-starter = "0.53.0"
gradle-kotlinter = "3.12.0"
gradle-screenshotTesting = "0.16.10"
google-agp = "7.3.1"
maven-kotlin = "1.7.21"
maven-junit = "5.9.1"
Expand All @@ -19,10 +20,12 @@ agp-gradle = { module = "com.android.tools.build:gradle", version.ref = "google-
kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "maven-kotlin" }

junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "maven-junit" }
junit-vintage = { module = "org.junit.vintage:junit-vintage-engine", version.ref = "maven-junit" }

assertj-core = { module = "org.assertj:assertj-core", version.ref = "maven-assertj" }
androidx-core = { module = "androidx.core:core", version.ref = "google-androidx-core" }
androidx-annotation = { module = "androidx.annotation:annotation", version.ref = "google-androidx-annotation" }
androidtest-core = { module = "androidx.test:core", version.ref = "google-androidtest" }
androidtest-core = { module = "androidx.test:core-ktx", version.ref = "google-androidtest" }
androidtest-runner = { module = "androidx.test:runner", version.ref = "google-androidtestRunner" }
androidtest-rules = { module = "androidx.test:rules", version.ref = "google-androidtest" }
androidtest-junitext = { module = "androidx.test.ext:junit-ktx", version.ref = "google-androidtestext" }
Expand All @@ -38,3 +41,4 @@ starter-versioning = { id = "com.starter.versioning", version.ref = "gradle-star
starter-library-kotlin = { id = "com.starter.library.kotlin", version.ref = "gradle-starter" }
starter-library-android = { id = "com.starter.library.android", version.ref = "gradle-starter" }
starter-application-android = { id = "com.starter.application.android", version.ref = "gradle-starter" }
starter-screenshottesting = { id = "io.github.usefulness.screenshot-testing-plugin", version.ref = "gradle-screenshotTesting" }
15 changes: 15 additions & 0 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
import com.karumi.shot.tasks.ExecuteScreenshotTests

plugins {
alias(libs.plugins.starter.application.android)
id("shot")
}

android {
namespace = "io.github.usefulness.shimmer.sample"
defaultConfig {
minSdk 28
applicationId "io.github.usefulness.shimmer.sample"
testInstrumentationRunner "com.karumi.shot.ShotTestRunner"
}
buildFeatures {
viewBinding = true
}
}


dependencies {
implementation("io.github.usefulness:shimmer-android-core")
implementation(libs.appcompat.core)
implementation(libs.constraintlayout.core)

testImplementation(libs.junit.jupiter)

androidTestImplementation(libs.appcompat.core)
androidTestImplementation(libs.espresso.core)
androidTestImplementation(libs.androidtest.core)
androidTestImplementation(libs.androidtest.runner)
androidTestImplementation(libs.androidtest.rules)
androidTestImplementation(libs.androidtest.junitext)
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions sample/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
pluginManagement {
resolutionStrategy {
eachPlugin {
if (requested.id.id == 'shot') {
useModule("com.karumi:shot:5.14.1")
}
}
}
repositories {
gradlePluginPortal()
google()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.github.usefulness.shimmer.android

import android.view.LayoutInflater
import androidx.test.ext.junit.rules.activityScenarioRule
import com.karumi.shot.ActivityScenarioUtils.waitForActivity
import com.karumi.shot.ScreenshotTest
import io.github.usefulness.shimmer.sample.MainActivity
import io.github.usefulness.shimmer.sample.R
import org.junit.Rule
import org.junit.Test

class ShimmerTest {

val test = object : ScreenshotTest {}

@get:Rule
val rule = activityScenarioRule<MainActivity>()

@Test
fun launchView() {
val activity = rule.scenario.waitForActivity()
val inflater = LayoutInflater.from(activity)
val view = inflater.inflate(R.layout.main, null, false)
val shimmer = view.findViewById<ShimmerFrameLayout>(R.id.shimmer_view_container)
shimmer.setStaticAnimationProgress(0.5f)

test.compareScreenshot(view, 2000, 1200)
test.compareScreenshot(view, 2000, 1600, name = "launchView-wide")
}
}
11 changes: 9 additions & 2 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android">
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
>

<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage"
/>

<application
android:hardwareAccelerated="true"
android:icon="@drawable/icon"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
>
<activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import com.facebook.shimmer.Shimmer
import io.github.usefulness.shimmer.android.Shimmer
import io.github.usefulness.shimmer.sample.databinding.MainBinding

class MainActivity : AppCompatActivity() {
Expand Down
Binary file removed sample/src/main/res/drawable/fb_logo.png
Binary file not shown.
18 changes: 18 additions & 0 deletions sample/src/main/res/drawable/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
>
<group
android:scaleX="0.5392683"
android:scaleY="0.5392683"
android:translateX="5.5287805"
android:translateY="5.5287805"
>
<path
android:fillColor="#FFFFFF"
android:pathData="M21,14L19,14L19,10L21,10L21,14ZM17,16L15,16L15,8L17,8L17,16ZM13,19L11,19L11,5L13,5L13,19ZM9,16L7,16L7,8L9,8L9,16ZM5,14L3,14L3,10L5,10L5,14Z"
/>
</group>
</vector>
10 changes: 10 additions & 0 deletions sample/src/main/res/drawable/ic_wave.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFF"
android:pathData="M21,14L19,14L19,10L21,10L21,14ZM17,16L15,16L15,8L17,8L17,16ZM13,19L11,19L11,5L13,5L13,19ZM9,16L7,16L7,8L9,8L9,16ZM5,14L3,14L3,10L5,10L5,14Z"
android:fillType="evenOdd"/>
</vector>
Binary file removed sample/src/main/res/drawable/icon.png
Binary file not shown.
10 changes: 5 additions & 5 deletions sample/src/main/res/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:padding="20dp"
>

<com.facebook.shimmer.ShimmerFrameLayout
<io.github.usefulness.shimmer.android.ShimmerFrameLayout
android:id="@+id/shimmer_view_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -30,19 +30,19 @@
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:src="@drawable/fb_logo"
android:src="@drawable/ic_wave"
/>

<TextView
style="@style/thin.white.large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginTop="8dp"
android:gravity="center"
android:text="@string/mission_statement"
android:text="@string/sample_shimmered_copy"
/>
</LinearLayout>
</com.facebook.shimmer.ShimmerFrameLayout>
</io.github.usefulness.shimmer.android.ShimmerFrameLayout>

<TextView
android:id="@+id/preset"
Expand Down
5 changes: 5 additions & 0 deletions sample/src/main/res/mipmap-anydpi/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
4 changes: 4 additions & 0 deletions sample/src/main/res/values/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#8D1F1F</color>
</resources>
6 changes: 3 additions & 3 deletions sample/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Shimmer</string>
<string name="mission_statement">Facebook’s mission is to give people the power to build community and bring the world closer together.</string>
<string name="presets">Presets</string>
<string name="app_name">Shimmer</string>
<string name="sample_shimmered_copy">Lorem ipsum dolor sit amet. Est tenetur quaerat sed consequatur cumque in accusantium nemo nam sint voluptates non modi sint nam possimus laboriosam.</string>
<string name="presets">Presets</string>
</resources>
2 changes: 2 additions & 0 deletions shimmer-android-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ tasks.withType(Test).configureEach {

dependencies {
implementation(libs.androidx.annotation)

testImplementation(libs.junit.jupiter)
}
Loading

0 comments on commit 689651d

Please sign in to comment.