mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 13:45:35 +03:00
moved to common package
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
331f5b2371
commit
9f49e0dbc4
17 changed files with 142 additions and 41 deletions
|
@ -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 {
|
||||||
|
|
|
@ -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"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) :
|
||||||
|
|
|
@ -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?
|
||||||
|
)
|
|
@ -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
|
||||||
|
|
||||||
|
@ -23,4 +44,4 @@ interface InAppReviewHelper {
|
||||||
* once all the conditions satisfies it will trigger In-App Review manager to show the flow
|
* once all the conditions satisfies it will trigger In-App Review manager to show the flow
|
||||||
*/
|
*/
|
||||||
fun showInAppReview(activity: AppCompatActivity)
|
fun showInAppReview(activity: AppCompatActivity)
|
||||||
}
|
}
|
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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)
|
|
@ -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?)
|
|
|
@ -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)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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
|
||||||
|
@ -29,4 +31,4 @@ class ExtensionsTest {
|
||||||
assertTrue(actualYearNewValue == "")
|
assertTrue(actualYearNewValue == "")
|
||||||
assertFalse(actualYearNewValue == "2022")
|
assertFalse(actualYearNewValue == "2022")
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue