Skip to content

Commit

Permalink
[app] privacy agreement
Browse files Browse the repository at this point in the history
  • Loading branch information
Tornaco committed May 23, 2022
1 parent 987fdf0 commit d8b7cf0
Show file tree
Hide file tree
Showing 11 changed files with 691 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static void start(Context context) {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

if (NavActivityPlugin.onCreate(this)) {
if (NavActivityPlugin.INSTANCE.onCreate(this)) {
finish();
return;
}
Expand Down Expand Up @@ -142,7 +142,13 @@ private void showRebootDialog() {
}

private void initFirstRun() {
if (AppPreference.isFirstRun(getApplication()) && !isFirstRunDialogShown) {
if (NavActivityPlugin.INSTANCE.showPrivacyAgreement(this)) {
return;
}

if (!ThanosManager.from(thisActivity()).isServiceInstalled() &&
AppPreference.isFirstRun(getApplication()) &&
!isFirstRunDialogShown) {
showAppNoticeDialog();
}
}
Expand Down
4 changes: 4 additions & 0 deletions android/app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -412,4 +412,8 @@
<string name="pre_title_smart_freeze_freeze_method_disable_summary">PM disable 是Android系统提供的可以\"停用\"某个应用的功能;使用这种方式\"冻结\"应用的时候,被冻结应用的桌面图标会消失,只能通过智能冻结页面或创建的快捷方式、代理应用启动。</string>
<string name="pre_title_smart_freeze_freeze_method_suspend">PM suspend</string>
<string name="pre_title_smart_freeze_freeze_method_suspend_summary">Suspend,是Android提供用于DPC管理的功能;被挂起的应用桌面通常会保留一个灰色的图标,但是无法直接启动该应用的活动,一般会弹出一个对话框提示这个应用已被管理员限制使用。你可以为该应用打开\"活检解冻\"开关,这样一来,Thanox检测到启动该应用活动页的请求会解冻该应用。</string>

<string name="privacy_agreement_title">隐私协议</string>
<string name="privacy_agreement_accept">接受</string>
<string name="privacy_agreement_discard">不接受</string>
</resources>
4 changes: 4 additions & 0 deletions android/app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -411,4 +411,8 @@
<string name="pre_title_smart_freeze_freeze_method_disable_summary">PM disable 是Android系統提供的可以\"停用\"某個應用的功能;使用這種方式\"凍結\"應用的時候,被凍結應用的桌面圖標會消失,只能通過智能凍結頁面或創建的快捷方式、代理應用啟動。</string>
<string name="pre_title_smart_freeze_freeze_method_suspend">PM suspend</string>
<string name="pre_title_smart_freeze_freeze_method_suspend_summary">Suspend,是Android提供用於DPC管理的功能;被掛起的應用桌面通常會保留一個灰色的圖標,但是無法直接啟動該應用的活動,一般會彈出一個對話框提示這個應用已被管理員限制使用。你可以為該應用打開\"活檢解冻\"開關,這樣一來,Thanox檢測到啟動該應用活動頁的請求會解凍該應用。</string>

<string name="privacy_agreement_title">隱私協議</string>
<string name="privacy_agreement_accept">接受</string>
<string name="privacy_agreement_discard">不接受</string>
</resources>
4 changes: 4 additions & 0 deletions android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -416,4 +416,8 @@
<string name="pre_title_smart_freeze_freeze_method_disable_summary">PM disable is a function provided by the Android system that can \"disable\" an application; when using this method to \"freeze\" an application, the desktop icon of the frozen application will disappear. You may create a shortcut or proxy app to launch it directly from Launcher.</string>
<string name="pre_title_smart_freeze_freeze_method_suspend">PM suspend</string>
<string name="pre_title_smart_freeze_freeze_method_suspend_summary">Suspend is a function provided by Android for DPC management; the suspended application usually retains a gray icon at Launcher, but the activities of the application cannot be started directly, and a dialog usually pops up indicating that the application has been restricted from use by the Administrator. You can turn on the \"DOL\" switch for the app, which will cause Thanox to unfreeze the app when it detects a request to launch the activity.</string>

<string name="privacy_agreement_title">Privacy agreement</string>
<string name="privacy_agreement_accept">Accept</string>
<string name="privacy_agreement_discard">Discard</string>
</resources>
360 changes: 360 additions & 0 deletions android/app/src/prc/assets/privacy/privacy_agreement.html

Large diffs are not rendered by default.

203 changes: 203 additions & 0 deletions android/app/src/prc/assets/privacy/privacy_agreement.txt

Large diffs are not rendered by default.

This file was deleted.

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()
}
}

This file was deleted.

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
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class ModernAlertDialog {
private final Context context;

private String dialogTitle;
private String dialogMessage;
private CharSequence dialogMessage;
private String positive;
private String negative;
private String neutral;
Expand All @@ -33,7 +33,7 @@ public void setDialogTitle(String dialogTitle) {
this.dialogTitle = dialogTitle;
}

public void setDialogMessage(String dialogMessage) {
public void setDialogMessage(CharSequence dialogMessage) {
this.dialogMessage = dialogMessage;
}

Expand Down

0 comments on commit d8b7cf0

Please sign in to comment.