moved to common package

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2023-04-20 13:31:18 +02:00 committed by Andy Scherzinger
parent 331f5b2371
commit 9f49e0dbc4
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
17 changed files with 142 additions and 41 deletions

View file

@ -23,6 +23,7 @@ package com.owncloud.android.app_review
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import com.nextcloud.client.preferences.AppPreferences import com.nextcloud.client.preferences.AppPreferences
import com.nextcloud.app_review.InAppReviewHelper
class InAppReviewHelperImpl(appPreferences: AppPreferences) : class InAppReviewHelperImpl(appPreferences: AppPreferences) :
InAppReviewHelper { InAppReviewHelper {

View file

@ -19,7 +19,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package com.nmc.android.app_review package com.owncloud.android.app_review
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import com.google.android.gms.tasks.Task import com.google.android.gms.tasks.Task
@ -28,9 +28,11 @@ import com.google.android.play.core.review.ReviewInfo
import com.google.android.play.core.review.ReviewManager import com.google.android.play.core.review.ReviewManager
import com.google.android.play.core.review.ReviewManagerFactory import com.google.android.play.core.review.ReviewManagerFactory
import com.google.android.play.core.review.model.ReviewErrorCode import com.google.android.play.core.review.model.ReviewErrorCode
import com.nextcloud.app_review.AppReviewShownModel
import com.nextcloud.app_review.InAppReviewHelper
import com.nextcloud.client.preferences.AppPreferences import com.nextcloud.client.preferences.AppPreferences
import com.nmc.android.utils.getFormattedStringDate import com.nextcloud.utils.getFormattedStringDate
import com.nmc.android.utils.isCurrentYear import com.nextcloud.utils.isCurrentYear
import com.owncloud.android.lib.common.utils.Log_OC import com.owncloud.android.lib.common.utils.Log_OC
//Reference: https://developer.android.com/guide/playcore/in-app-review //Reference: https://developer.android.com/guide/playcore/in-app-review
@ -68,10 +70,14 @@ class InAppReviewHelperImpl(val appPreferences: AppPreferences) : InAppReviewHel
appReviewShownModel?.let { appReviewShownModel?.let {
if (it.appRestartCount >= MIN_APP_RESTARTS_REQ if (it.appRestartCount >= MIN_APP_RESTARTS_REQ
&& currentTimeMills.isCurrentYear(it.firstShowYear) && currentTimeMills.isCurrentYear(it.firstShowYear)
&& it.reviewShownCount < MAX_DISPLAY_PER_YEAR) { && it.reviewShownCount < MAX_DISPLAY_PER_YEAR
) {
doAppReview(activity) doAppReview(activity)
} else { } else {
Log_OC.d(TAG, "Yearly limit has been reached or minimum app restarts are not completed: $appReviewShownModel") Log_OC.d(
TAG,
"Yearly limit has been reached or minimum app restarts are not completed: $appReviewShownModel"
)
} }
} }
} }

View file

@ -22,6 +22,7 @@
package com.owncloud.android.app_review package com.owncloud.android.app_review
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import com.nextcloud.app_review.InAppReviewHelper
import com.nextcloud.client.preferences.AppPreferences import com.nextcloud.client.preferences.AppPreferences
class InAppReviewHelperImpl(appPreferences: AppPreferences) : class InAppReviewHelperImpl(appPreferences: AppPreferences) :

View file

@ -0,0 +1,30 @@
/*
*
* Nextcloud Android client application
*
* @author Tobias Kaminsky
* Copyright (C) 2023 Tobias Kaminsky
* 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 as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) 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 <https://www.gnu.org/licenses/>.
*/
package com.nextcloud.app_review
data class AppReviewShownModel(
var firstShowYear: String?,
var appRestartCount: Int,
var reviewShownCount: Int,
var lastReviewShownDate: String?
)

View file

@ -1,5 +1,26 @@
package com.nmc.android.app_review /*
*
* Nextcloud Android client application
*
* @author Tobias Kaminsky
* Copyright (C) 2023 Tobias Kaminsky
* 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 as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) 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 <https://www.gnu.org/licenses/>.
*/
package com.nextcloud.app_review
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity

View file

@ -0,0 +1,40 @@
/*
*
* Nextcloud Android client application
*
* @author Tobias Kaminsky
* Copyright (C) 2023 Tobias Kaminsky
* 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 as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) 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 <https://www.gnu.org/licenses/>.
*/
package com.nextcloud.app_review
import com.nextcloud.client.preferences.AppPreferences
import com.owncloud.android.app_review.InAppReviewHelperImpl
// import com.owncloud.android.app_review.InAppReviewHelperImpl
import dagger.Module
import dagger.Provides
import javax.inject.Singleton
@Module
class InAppReviewModule {
@Provides
@Singleton
internal fun providesInAppReviewHelper(appPreferences: AppPreferences): InAppReviewHelper {
return InAppReviewHelperImpl(appPreferences)
}
}

View file

@ -22,13 +22,13 @@ package com.nextcloud.client.di;
import android.app.Application; import android.app.Application;
import com.nextcloud.app_review.InAppReviewModule;
import com.nextcloud.client.appinfo.AppInfoModule; import com.nextcloud.client.appinfo.AppInfoModule;
import com.nextcloud.client.database.DatabaseModule; import com.nextcloud.client.database.DatabaseModule;
import com.nextcloud.client.device.DeviceModule; import com.nextcloud.client.device.DeviceModule;
import com.nextcloud.client.integrations.IntegrationsModule; import com.nextcloud.client.integrations.IntegrationsModule;
import com.nextcloud.client.jobs.JobsModule; import com.nextcloud.client.jobs.JobsModule;
import com.nextcloud.client.network.NetworkModule; import com.nextcloud.client.network.NetworkModule;
import com.nmc.android.app_review.InAppReviewModule;
import com.nextcloud.client.onboarding.OnboardingModule; import com.nextcloud.client.onboarding.OnboardingModule;
import com.nextcloud.client.preferences.PreferencesModule; import com.nextcloud.client.preferences.PreferencesModule;
import com.owncloud.android.MainApp; import com.owncloud.android.MainApp;

View file

@ -20,9 +20,9 @@
package com.nextcloud.client.preferences; package com.nextcloud.client.preferences;
import com.nextcloud.app_review.AppReviewShownModel;
import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.utils.FileSortOrder; import com.owncloud.android.utils.FileSortOrder;
import com.nmc.android.app_review.AppReviewShownModel;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;

View file

@ -26,10 +26,10 @@ import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.nextcloud.app_review.AppReviewShownModel;
import com.nextcloud.client.account.User; import com.nextcloud.client.account.User;
import com.nextcloud.client.account.UserAccountManager; import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.account.UserAccountManagerImpl; import com.nextcloud.client.account.UserAccountManagerImpl;
import com.nmc.android.app_review.AppReviewShownModel;
import com.owncloud.android.datamodel.ArbitraryDataProvider; import com.owncloud.android.datamodel.ArbitraryDataProvider;
import com.owncloud.android.datamodel.ArbitraryDataProviderImpl; import com.owncloud.android.datamodel.ArbitraryDataProviderImpl;
import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.FileDataStorageManager;

View file

@ -1,4 +1,26 @@
package com.nmc.android.utils /*
*
* Nextcloud Android client application
*
* @author Tobias Kaminsky
* Copyright (C) 2023 Tobias Kaminsky
* 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 as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) 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 <https://www.gnu.org/licenses/>.
*/
package com.nextcloud.utils
import android.text.Selection import android.text.Selection
import android.text.Spannable import android.text.Spannable
@ -10,7 +32,8 @@ import android.text.style.ClickableSpan
import android.view.View import android.view.View
import android.widget.TextView import android.widget.TextView
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.Date
import java.util.Locale
fun TextView.makeLinks(vararg links: Pair<String, View.OnClickListener>) { fun TextView.makeLinks(vararg links: Pair<String, View.OnClickListener>) {
val spannableString = SpannableString(this.text) val spannableString = SpannableString(this.text)

View file

@ -1,6 +0,0 @@
package com.nmc.android.app_review
data class AppReviewShownModel(var firstShowYear: String?,
var appRestartCount: Int,
var reviewShownCount: Int,
var lastReviewShownDate: String?)

View file

@ -1,18 +0,0 @@
package com.nmc.android.app_review
import com.nextcloud.client.preferences.AppPreferences
import com.owncloud.android.app_review.InAppReviewHelperImpl
import dagger.Module
import dagger.Provides
import javax.inject.Singleton
@Module
class InAppReviewModule {
@Provides
@Singleton
internal fun providesInAppReviewHelper(appPreferences: AppPreferences): InAppReviewHelper {
return InAppReviewHelperImpl(appPreferences)
}
}

View file

@ -40,7 +40,7 @@ import android.os.StrictMode;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.WindowManager; import android.view.WindowManager;
import com.nmc.android.app_review.InAppReviewHelper; import com.nextcloud.app_review.InAppReviewHelper;
import com.nextcloud.client.account.User; import com.nextcloud.client.account.User;
import com.nextcloud.client.account.UserAccountManager; import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.appinfo.AppInfo; import com.nextcloud.client.appinfo.AppInfo;

View file

@ -57,7 +57,7 @@ import android.view.WindowManager;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.nmc.android.app_review.InAppReviewHelper; import com.nextcloud.app_review.InAppReviewHelper;
import com.nextcloud.client.account.User; import com.nextcloud.client.account.User;
import com.nextcloud.client.appinfo.AppInfo; import com.nextcloud.client.appinfo.AppInfo;
import com.nextcloud.client.core.AsyncRunner; import com.nextcloud.client.core.AsyncRunner;

View file

@ -23,8 +23,8 @@
package com.owncloud.android.app_review package com.owncloud.android.app_review
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import com.nextcloud.app_review.InAppReviewHelper
import com.nextcloud.client.preferences.AppPreferences import com.nextcloud.client.preferences.AppPreferences
import com.nmc.android.app_review.InAppReviewHelper
class InAppReviewHelperImpl(appPreferences: AppPreferences) : class InAppReviewHelperImpl(appPreferences: AppPreferences) :
InAppReviewHelper { InAppReviewHelper {

View file

@ -1,5 +1,7 @@
package com.nmc.android.utils package com.nextcloud.android.utils
import com.nextcloud.utils.getFormattedStringDate
import com.nextcloud.utils.isCurrentYear
import org.junit.Assert.assertFalse import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue import org.junit.Assert.assertTrue
import org.junit.Test import org.junit.Test

View file

@ -24,6 +24,7 @@ package com.owncloud.android.app_review
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import com.nextcloud.client.preferences.AppPreferences import com.nextcloud.client.preferences.AppPreferences
import com.nextcloud.app_review.InAppReviewHelper
class InAppReviewHelperImpl(appPreferences: AppPreferences) : class InAppReviewHelperImpl(appPreferences: AppPreferences) :
InAppReviewHelper { InAppReviewHelper {