-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
691 additions
and
30 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
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
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
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
360 changes: 360 additions & 0 deletions
360
android/app/src/prc/assets/privacy/privacy_agreement.html
Large diffs are not rendered by default.
Oops, something went wrong.
203 changes: 203 additions & 0 deletions
203
android/app/src/prc/assets/privacy/privacy_agreement.txt
Large diffs are not rendered by default.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
android/app/src/prc/java/github/tornaco/android/thanos/main/NavActivityPlugin.java
This file was deleted.
Oops, something went wrong.
73 changes: 73 additions & 0 deletions
73
android/app/src/prc/java/github/tornaco/android/thanos/main/NavActivityPlugin.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,73 @@ | ||
/* | ||
* (C) Copyright 2022 Thanox | ||
* | ||
* 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 github.tornaco.android.thanos.main | ||
|
||
import android.text.Html | ||
import androidx.preference.PreferenceManager | ||
import github.tornaco.android.thanos.BuildProp | ||
import github.tornaco.android.thanos.R | ||
import github.tornaco.android.thanos.widget.ModernAlertDialog | ||
import util.AssetUtils | ||
|
||
object NavActivityPlugin { | ||
private val privacyAgreementKey get() = "PREF_PRIVACY_STATEMENT_ACCEPTED_V_" + BuildProp.THANOS_VERSION_CODE | ||
private var isPrivacyDialogShowing = false | ||
|
||
fun onCreate(activity: NavActivity): Boolean { | ||
return false | ||
} | ||
|
||
fun showPrivacyAgreement(activity: NavActivity): Boolean { | ||
if (isPrivacyStatementAccepted(activity)) { | ||
return false | ||
} | ||
if (isPrivacyDialogShowing) { | ||
return false | ||
} | ||
val privacyAgreement = | ||
AssetUtils.readFileToStringOrThrow(activity, "privacy/privacy_agreement.html") | ||
|
||
val dialog = ModernAlertDialog(activity).apply { | ||
setDialogTitle(activity.getString(R.string.privacy_agreement_title)) | ||
setDialogMessage(Html.fromHtml(privacyAgreement)) | ||
setCancelable(false) | ||
setPositive(activity.getString(R.string.privacy_agreement_accept)) | ||
setNegative(activity.getString(R.string.privacy_agreement_discard)) | ||
} | ||
dialog.setOnNegative { | ||
activity.finishAffinity() | ||
isPrivacyDialogShowing = false | ||
} | ||
dialog.setOnPositive { setPrivacyStatementAccepted(activity) } | ||
dialog.show() | ||
isPrivacyDialogShowing = true | ||
|
||
return true | ||
} | ||
|
||
private fun isPrivacyStatementAccepted(activity: NavActivity): Boolean { | ||
return PreferenceManager.getDefaultSharedPreferences(activity).getBoolean( | ||
privacyAgreementKey, false | ||
) | ||
} | ||
|
||
private fun setPrivacyStatementAccepted(activity: NavActivity) { | ||
PreferenceManager.getDefaultSharedPreferences(activity).edit() | ||
.putBoolean(privacyAgreementKey, true).commit() | ||
} | ||
} |
17 changes: 0 additions & 17 deletions
17
android/app/src/row/java/github/tornaco/android/thanos/main/NavActivityPlugin.java
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
android/app/src/row/java/github/tornaco/android/thanos/main/NavActivityPlugin.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,33 @@ | ||
/* | ||
* (C) Copyright 2022 Thanox | ||
* | ||
* 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 github.tornaco.android.thanos.main | ||
|
||
import github.tornaco.android.thanos.app.PLayLvlCheckActivity | ||
|
||
object NavActivityPlugin { | ||
fun onCreate(activity: NavActivity): Boolean { | ||
return if (!github.tornaco.android.thanos.app.Init.isLVLChecked(activity) | ||
&& github.tornaco.android.thanos.app.Init.s == 0 | ||
) { | ||
PLayLvlCheckActivity.Starter.start(activity) | ||
true | ||
} else false | ||
} | ||
|
||
fun showPrivacyAgreement(activity: NavActivity): Boolean = false | ||
} |
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