Skip to content

Commit

Permalink
Fix delete permanently logic; configure spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
VishalNehra committed Jul 18, 2023
1 parent d4d6d81 commit ea97362
Show file tree
Hide file tree
Showing 11 changed files with 396 additions and 112 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/android-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Android Main CI

on:
push:
branches:
- 'main'
- 'release/*'

concurrency:
group: build-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
check_spotless:
name: Check spotless
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: 11
- name: Check formatting using spotless
uses: gradle/[email protected]
with:
arguments: spotlessCheck
build:
name: Build debug
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: 11
- name: Build with Gradle
uses: gradle/[email protected]
with:
arguments: build
env:
TZ: UTC
21 changes: 21 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,25 @@ plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
id "com.diffplug.spotless" version "5.14.2"
}

spotless {
java {
licenseHeaderFile 'spotless.license-java'
target 'trashbin/src/**/*.java'
googleJavaFormat('1.13.0')
removeUnusedImports() // removes any unused imports
importOrder 'java', 'javax', 'org', 'com', 'android', 'androidx', ''
}
kotlin {
licenseHeaderFile 'spotless.license-java'
target 'trashbin/src/**/*.kt'
ktlint("0.43.2").userData(['disabled_rules': 'no-wildcard-imports',
'kotlin_imports_layout': 'idea', 'indent_size': '4',
'max_line_length': '100'])
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
}
16 changes: 16 additions & 0 deletions spotless.license-java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Copyright 2023 Arpit Khurana <[email protected]>, Vishal Nehra <[email protected]>,
* Emmanuel Messulam<[email protected]>, Raymond Lai <airwave209gt at gmail.com> and Contributors.
*
* 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.
*/
31 changes: 31 additions & 0 deletions trashbin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ plugins {
id 'org.jetbrains.kotlin.android'
}

apply plugin: 'maven-publish'

android {
namespace 'com.amaze.trashbin'
compileSdk 33
Expand Down Expand Up @@ -39,4 +41,33 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release
pom {
groupId = 'com.amaze.trashbin'
artifactId = 'amaze-trash-bin'
licenses {
license {
name = 'Apache License'
url = 'http://www.apache.org/licenses/LICENSE-2.0'
}
}
developers {
developer {
id = 'vishalnehra'
name = 'Vishal Nehra'
email = '[email protected]'
}
}
description = 'Library to manage your deleted files in a trash bin'
version = '1.0.0'
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
/**
* Copyright 2023 Arpit Khurana <[email protected]>, Vishal Nehra <[email protected]>,
* Emmanuel Messulam<[email protected]>, Raymond Lai <airwave209gt at gmail.com> and Contributors.
*
* 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 com.amaze.trashbin

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.*
import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
Expand All @@ -21,4 +35,4 @@ class ExampleInstrumentedTest {
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.amaze.trashbin.test", appContext.packageName)
}
}
}
22 changes: 20 additions & 2 deletions trashbin/src/main/java/com/amaze/trashbin/SingletonHolder.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
/**
* Copyright 2023 Arpit Khurana <[email protected]>, Vishal Nehra <[email protected]>,
* Emmanuel Messulam<[email protected]>, Raymond Lai <airwave209gt at gmail.com> and Contributors.
*
* 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 com.amaze.trashbin

open class SingletonSingleArgHolder<out T, in A, in B, in C>(private val constructor: (A, B, C) -> T) {
open class SingletonSingleArgHolder<out T, in A, in B, in C>(
private val constructor: (A, B, C) -> T
) {

@Volatile
private var instance: T? = null
Expand All @@ -9,4 +27,4 @@ open class SingletonSingleArgHolder<out T, in A, in B, in C>(private val constru
instance ?: synchronized(this) {
instance ?: constructor(arg1, arg2, arg3).also { instance = it }
}
}
}
Loading

0 comments on commit ea97362

Please sign in to comment.