-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move optional appscan feature to a separate module to avoid duplicati…
…ng code between variants This now uses a AppScanOptionalFeature injected interface that is satisfied by each module, reducing the duplicated code to a minimum Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
- Loading branch information
1 parent
9478fb1
commit 1917198
Showing
29 changed files
with
417 additions
and
379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
app/src/generic/java/com/nextcloud/client/di/VariantModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Nextcloud Android client application | ||
* | ||
* @author Chris Narkiewicz | ||
* Copyright (C) 2919 Chris Narkiewicz <hello@ezaquarii.com> | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public | ||
* License along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.nextcloud.client.di | ||
|
||
import com.nextcloud.client.documentscan.AppScanOptionalFeature | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.Reusable | ||
|
||
@Module | ||
internal class VariantModule { | ||
@Provides | ||
@Reusable | ||
fun scanOptionalFeature(): AppScanOptionalFeature { | ||
return AppScanOptionalFeature.Stub | ||
} | ||
} |
42 changes: 0 additions & 42 deletions
42
app/src/generic/java/com/owncloud/android/ui/activity/AppScanActivity.kt
This file was deleted.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
app/src/gplay/java/com/nextcloud/client/di/VariantModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Nextcloud Android client application | ||
* | ||
* @author Chris Narkiewicz | ||
* Copyright (C) 2919 Chris Narkiewicz <hello@ezaquarii.com> | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public | ||
* License along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.nextcloud.client.di | ||
|
||
import com.nextcloud.appscan.ScanPageContract | ||
import com.nextcloud.client.documentscan.AppScanOptionalFeature | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.Reusable | ||
|
||
@Module | ||
internal class VariantModule { | ||
@Provides | ||
@Reusable | ||
fun scanOptionalFeature(): AppScanOptionalFeature { | ||
return object : AppScanOptionalFeature() { | ||
override fun getScanContract() = ScanPageContract() | ||
} | ||
} | ||
} |
80 changes: 0 additions & 80 deletions
80
app/src/gplay/java/com/owncloud/android/ui/activity/AppScanActivity.kt
This file was deleted.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
app/src/huawei/java/com/nextcloud/client/di/VariantModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Nextcloud Android client application | ||
* | ||
* @author Chris Narkiewicz | ||
* Copyright (C) 2919 Chris Narkiewicz <hello@ezaquarii.com> | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public | ||
* License along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.nextcloud.client.di | ||
|
||
import com.nextcloud.appscan.ScanPageContract | ||
import com.nextcloud.client.documentscan.AppScanOptionalFeature | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.Reusable | ||
|
||
@Module | ||
internal class VariantModule { | ||
@Provides | ||
@Reusable | ||
fun scanOptionalFeature(): AppScanOptionalFeature { | ||
return object : AppScanOptionalFeature() { | ||
override fun getScanContract() = ScanPageContract() | ||
} | ||
} | ||
} |
77 changes: 0 additions & 77 deletions
77
app/src/huawei/java/com/owncloud/android/ui/activity/AppScanActivity.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
app/src/main/java/com/nextcloud/client/documentscan/AppScanOptionalFeature.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Nextcloud Android client application | ||
* | ||
* @author Álvaro Brey | ||
* Copyright (C) 2023 Álvaro Brey | ||
* Copyright (C) 2023 Nextcloud GmbH | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public | ||
* License along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
package com.nextcloud.client.documentscan | ||
|
||
import androidx.activity.result.contract.ActivityResultContract | ||
|
||
abstract class AppScanOptionalFeature { | ||
/** | ||
* Check [isAvailable] before calling this method. | ||
*/ | ||
abstract fun getScanContract(): ActivityResultContract<Unit, String?> | ||
open val isAvailable: Boolean = true | ||
|
||
/** | ||
* Use this in variants where the feature is not available | ||
*/ | ||
@Suppress("unused") // used only in some variants | ||
object Stub : AppScanOptionalFeature() { | ||
override fun getScanContract(): ActivityResultContract<Unit, String?> { | ||
throw UnsupportedOperationException("Document scan is not available") | ||
} | ||
|
||
override val isAvailable = false | ||
} | ||
} |
Oops, something went wrong.