提交 fce0176f 编写于 作者: xuexiangjys's avatar xuexiangjys 😊

升级工具类的版本,并增加隐私政策弹窗

上级 bd22d892
......@@ -18,7 +18,7 @@
android:name=".activity.SplashActivity"
android:configChanges="screenSize|keyboardHidden|orientation|keyboard"
android:screenOrientation="portrait"
android:theme="@style/XUITheme.Launch.App"
android:theme="@style/AppTheme.Launch.App"
android:windowSoftInputMode="adjustPan|stateHidden">
<intent-filter>
......
......@@ -40,6 +40,7 @@ import com.xuexiang.templateproject.fragment.SettingsFragment;
import com.xuexiang.templateproject.fragment.news.NewsFragment;
import com.xuexiang.templateproject.fragment.profile.ProfileFragment;
import com.xuexiang.templateproject.fragment.trending.TrendingFragment;
import com.xuexiang.templateproject.utils.Utils;
import com.xuexiang.templateproject.utils.XToastUtils;
import com.xuexiang.xaop.annotation.SingleClick;
import com.xuexiang.xui.adapter.FragmentAdapter;
......@@ -57,7 +58,7 @@ import butterknife.BindView;
* @author xuexiang
* @since 2019-07-07 23:53
*/
public class MainActivity extends BaseActivity implements View.OnClickListener, ViewPager.OnPageChangeListener, BottomNavigationView.OnNavigationItemSelectedListener, ClickUtils.OnClick2ExitListener {
public class MainActivity extends BaseActivity implements View.OnClickListener, ViewPager.OnPageChangeListener, BottomNavigationView.OnNavigationItemSelectedListener, ClickUtils.OnClick2ExitListener, Toolbar.OnMenuItemClickListener {
@BindView(R.id.toolbar)
Toolbar toolbar;
......@@ -100,6 +101,8 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
private void initViews() {
mTitles = ResUtils.getStringArray(R.array.home_titles);
toolbar.setTitle(mTitles[0]);
toolbar.inflateMenu(R.menu.menu_main);
toolbar.setOnMenuItemClickListener(this);
initHeader();
......@@ -177,6 +180,17 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
return false;
}
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.action_privacy:
Utils.showPrivacyDialog(this, null);
break;
default:
break;
}
return false;
}
@SingleClick
@Override
......@@ -264,4 +278,6 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
public void onExit() {
XUtil.get().exitApp();
}
}
......@@ -20,6 +20,8 @@ package com.xuexiang.templateproject.activity;
import android.view.KeyEvent;
import com.xuexiang.templateproject.R;
import com.xuexiang.templateproject.utils.MMKVUtils;
import com.xuexiang.templateproject.utils.Utils;
import com.xuexiang.xui.utils.KeyboardUtils;
import com.xuexiang.xui.widget.activity.BaseSplashActivity;
import com.xuexiang.xutil.app.ActivityUtils;
......@@ -54,8 +56,17 @@ public class SplashActivity extends BaseSplashActivity implements CancelAdapt {
*/
@Override
protected void onSplashFinished() {
ActivityUtils.startActivity(MainActivity.class);
finish();
boolean isAgree = MMKVUtils.getBoolean("key_agree_privacy", false);
if (isAgree) {
ActivityUtils.startActivity(MainActivity.class);
finish();
} else {
Utils.showPrivacyDialog(this, (dialog, which) -> {
MMKVUtils.put("key_agree_privacy", true);
ActivityUtils.startActivity(MainActivity.class);
finish();
});
}
}
/**
......
/*
* Copyright (C) 2020 xuexiangjys(xuexiangjys@163.com)
*
* 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 com.xuexiang.templateproject.utils;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.View;
import androidx.annotation.NonNull;
import com.xuexiang.templateproject.R;
import com.xuexiang.templateproject.core.webview.AgentWebActivity;
import com.xuexiang.xui.utils.ResUtils;
import com.xuexiang.xui.widget.dialog.DialogLoader;
import com.xuexiang.xui.widget.dialog.materialdialog.DialogAction;
import com.xuexiang.xui.widget.dialog.materialdialog.MaterialDialog;
import com.xuexiang.xutil.XUtil;
import static com.xuexiang.templateproject.core.webview.AgentWebFragment.KEY_URL;
/**
* 工具类
*
* @author xuexiang
* @since 2020-02-23 15:12
*/
public final class Utils {
private Utils() {
throw new UnsupportedOperationException("u can't instantiate me...");
}
/**
* 这里填写你的应用隐私政策网页地址
*/
private static final String PRIVACY_URL = "https://www.baidu.com/";
/**
* 显示隐私政策的提示
*
* @param context
* @param submitListener 同意的监听
* @return
*/
public static Dialog showPrivacyDialog(Context context, MaterialDialog.SingleButtonCallback submitListener) {
MaterialDialog dialog = new MaterialDialog.Builder(context).title(R.string.title_reminder).autoDismiss(false).cancelable(false)
.positiveText(R.string.lab_agree).onPositive((dialog1, which) -> {
if (submitListener != null) {
submitListener.onClick(dialog1, which);
} else {
dialog1.dismiss();
}
})
.negativeText(R.string.lab_disagree).onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
DialogLoader.getInstance().showConfirmDialog(context, ResUtils.getString(R.string.title_reminder), String.format(ResUtils.getString(R.string.content_privacy_explain_again), ResUtils.getString(R.string.app_name)), ResUtils.getString(R.string.lab_look_again), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
showPrivacyDialog(context, submitListener);
}
}, ResUtils.getString(R.string.lab_still_disagree), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
DialogLoader.getInstance().showConfirmDialog(context, ResUtils.getString(R.string.content_think_about_it_again), ResUtils.getString(R.string.lab_look_again), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
showPrivacyDialog(context, submitListener);
}
}, ResUtils.getString(R.string.lab_exit_app), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
XUtil.get().exitApp();
}
});
}
});
}
}).build();
dialog.setContent(getPrivacyContent(context));
//开始响应点击事件
dialog.getContentView().setMovementMethod(LinkMovementMethod.getInstance());
dialog.show();
return dialog;
}
/**
* @return 隐私政策说明
*/
private static SpannableStringBuilder getPrivacyContent(Context context) {
SpannableStringBuilder stringBuilder = new SpannableStringBuilder()
.append(" 欢迎来到").append(ResUtils.getString(R.string.app_name)).append("!\n")
.append(" 我们深知个人信息对你的重要性,也感谢你对我们的信任。\n")
.append(" 为了更好地保护你的权益,同时遵守相关监管的要求,我们将通过");
stringBuilder.append(getPrivacyLink(context, PRIVACY_URL))
.append("向你说明我们会如何收集、存储、保护、使用及对外提供你的信息,并说明你享有的权利。\n")
.append(" 更多详情,敬请查阅")
.append(getPrivacyLink(context, PRIVACY_URL))
.append("全文。");
return stringBuilder;
}
/**
* @param context 隐私政策的链接
* @return
*/
private static SpannableString getPrivacyLink(Context context, String privacyUrl) {
String privacyName = String.format(ResUtils.getString(R.string.lab_privacy_name), ResUtils.getString(R.string.app_name));
SpannableString spannableString = new SpannableString(privacyName);
spannableString.setSpan(new ClickableSpan() {
@Override
public void onClick(@NonNull View widget) {
goWeb(context, privacyUrl);
}
}, 0, privacyName.length(), Spanned.SPAN_MARK_MARK);
return spannableString;
}
/**
* 请求浏览器
*
* @param url
*/
public static void goWeb(Context context, final String url) {
Intent intent = new Intent(context, AgentWebActivity.class);
intent.putExtra(KEY_URL, url);
context.startActivity(intent);
}
}
......@@ -17,7 +17,6 @@
package com.xuexiang.templateproject.utils.update;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
......@@ -26,12 +25,10 @@ import android.text.TextUtils;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.xuexiang.templateproject.core.webview.AgentWebActivity;
import com.xuexiang.templateproject.utils.Utils;
import com.xuexiang.xui.widget.dialog.DialogLoader;
import com.xuexiang.xupdate.XUpdate;
import static com.xuexiang.templateproject.core.webview.AgentWebFragment.KEY_URL;
/**
* 版本更新提示弹窗
*
......@@ -65,7 +62,7 @@ public class UpdateTipDialog extends AppCompatActivity implements DialogInterfac
DialogLoader.getInstance().showConfirmDialog(this, content, "是", (dialog, which) -> {
dialog.dismiss();
// goWeb(UpdateTipDialog.this, "这里填写你应用下载页面的链接");
// Utils.goWeb(UpdateTipDialog.this, "这里填写你应用下载页面的链接");
}, "否")
.setOnDismissListener(this);
......@@ -76,15 +73,4 @@ public class UpdateTipDialog extends AppCompatActivity implements DialogInterfac
finish();
}
/**
* 请求浏览器
*
* @param url
*/
public static void goWeb(Context context, final String url) {
Intent intent = new Intent(context, AgentWebActivity.class);
intent.putExtra(KEY_URL, url);
context.startActivity(intent);
}
}
<!--
~ Copyright (C) 2020 xuexiangjys(xuexiangjys@163.com)
~
~ 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.
~
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:pathData="M433.4,538.1v159.2c0,47.6 35.6,86.3 79.4,86.3s79.4,-38.7 79.4,-86.3L592.2,538.1c38.1,-26.3 61.5,-70.2 61.6,-116.9 0,-78.2 -63.2,-141.9 -141,-141.9 -77.7,0 -141,63.7 -141,141.9 0.1,46.8 23.4,90.6 61.6,116.9zM512.8,352.4c37.6,0 68.2,30.9 68.2,68.8 0,26.9 -15.8,51.5 -40.2,62.8l-0.2,0.1c-2,0.9 -3.4,2 -4.4,2.8 -1.8,1.1 -4.3,2.7 -6.7,5.2 -1.9,2 -3,3.9 -3.6,4.9l-0.1,0.1c-0.1,0.1 -0.2,0.2 -0.2,0.4 -0.9,1.3 -2.4,3.5 -3.6,6.4 -1.1,2.8 -1.5,5.3 -1.7,6.8 -0.4,1.3 -1,3.6 -1,6.6v180.1c0,8.4 -5,10.2 -6.6,10.2 -1.6,0 -6.6,-1.8 -6.6,-10.2L506.1,517.3c0,-2.6 -0.5,-4.6 -0.8,-5.8 -0.2,-1.8 -0.6,-4.7 -1.9,-7.8 -1.1,-2.7 -2.4,-4.6 -3.2,-5.8 -0.1,-0.1 -0.1,-0.2 -0.2,-0.2 0,-0.1 -0.1,-0.2 -0.1,-0.2 -0.7,-1.2 -1.9,-3.3 -3.9,-5.3 -2.4,-2.5 -4.8,-4 -6.4,-5.1 -0.9,-0.7 -2.5,-1.9 -4.7,-3l-0.1,-0.1c-24.5,-11.2 -40.2,-35.8 -40.2,-62.8 0,-37.9 30.6,-68.8 68.2,-68.8z"
android:fillColor="#ffffff"/>
<path
android:pathData="M854.1,182.8c-179.5,0 -304,-103.3 -310.1,-108.4 -8.1,-6.9 -18.4,-10.8 -29,-10.8 -13.6,0.1 -26.2,6.2 -34.7,16.7l-0.1,0.1c-26.8,33.9 -77.3,61.4 -146.1,79.4 -75.2,19.7 -143.3,21.3 -162.4,21.3h-1.2l-1.1,0.2c-12.7,1.7 -22.3,5.9 -29.2,12.9 -8.3,8.3 -13.1,19.8 -13.1,31.6v311.9c0,69.8 49.8,173.7 126.9,264.7 38.7,45.7 81.4,84.3 123.4,111.5 48.5,31.4 94.9,47.4 137.8,47.4 44.5,0 91.8,-16.2 140.5,-48.2 41.4,-27.2 83.4,-65.9 121.5,-112 72.7,-87.9 121.5,-189.8 121.5,-253.6v-320c-0.1,-24.7 -20.1,-44.7 -44.6,-44.7zM825.8,255.1v292.5c0,46.1 -43.8,132.7 -104.1,205.9 -32.7,39.6 -68,72.8 -102.2,96.1 -37.8,25.7 -73,38.7 -104.5,38.7 -58.4,0 -135.6,-50.3 -206.5,-134.5 -31.7,-37.6 -58.9,-78.3 -78.6,-117.7 -19.4,-38.6 -30,-73.5 -30,-98.4L199.9,253.6c53.9,-2.4 111.7,-11.4 161.1,-25.2 68.3,-19.1 121.2,-46.5 157.6,-81.8 45.5,32.4 158.1,100.6 307.2,108.5z"
android:fillColor="#ffffff"/>
</vector>
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (C) 2020 xuexiangjys(xuexiangjys@163.com)
~
~ 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.
~
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_privacy"
android:icon="@drawable/ic_menu_privacy"
android:orderInCategory="100"
android:title="隐私政策"
app:showAsAction="always" />
</menu>
\ No newline at end of file
......@@ -30,4 +30,15 @@
<string name="lab_no"></string>
<string name="lab_open_third_app">是否允许页面打开第三方应用?</string>
<!-- 隐私政策弹窗 -->
<string name="lab_exit_app">退出应用</string>
<string name="lab_agree">同意</string>
<string name="lab_disagree">不同意</string>
<string name="lab_look_again">再次查看</string>
<string name="lab_still_disagree">仍不同意</string>
<string name="title_reminder">温馨提示</string>
<string name="content_think_about_it_again">要不要再想想</string>
<string name="content_privacy_explain_again">我们非常重视对你个人信息的保护,承诺严格按照《%s隐私权政策》保护及处理你的信息。如果你不同意该政策,很遗憾我们将无法为你提供服务</string>
<string name="lab_privacy_name">《%s隐私权政策》</string>
</resources>
......@@ -15,9 +15,16 @@
<item name="xui_actionbar_height">?actionBarSize</item>
</style>
<!--窗体背景,这个背景能在第一时间显示, 避免启动时白屏,黑屏问题-->
<style name="XUITheme.Launch.App">
<style name="AppTheme.Launch">
<item name="xui_config_color_splash_bg">@color/xui_config_color_white</item>
<item name="xui_config_app_logo_bottom">@dimen/xui_config_app_logo_bottom</item>
<item name="xui_config_company_logo_bottom">@dimen/xui_config_company_logo_bottom</item>
<item name="android:windowBackground">@drawable/xui_config_bg_splash</item>
<item name="android:windowFullscreen">true</item>
</style>
<!--窗体背景,这个背景能在第一时间显示, 避免启动时白屏,黑屏问题-->
<style name="AppTheme.Launch.App">
<!--注意修改图标-->
<item name="xui_config_splash_app_logo">@drawable/ic_splash_app_logo_xui</item>
<item name="xui_config_splash_company_logo">@drawable/ic_splash_company_logo</item>
......
......@@ -12,7 +12,7 @@ project.configurations.each { configuration ->
configuration.dependencies.add(getProject().dependencies.create(deps.androidx.design))
configuration.dependencies.add(getProject().dependencies.create(deps.glide))
//XUtil工具类
configuration.dependencies.add(getProject().dependencies.create('com.github.xuexiangjys.XUtil:xutil-core:1.1.6'))
configuration.dependencies.add(getProject().dependencies.create('com.github.xuexiangjys.XUtil:xutil-core:1.1.7'))
//XAOP切片,版本号前带x的是支持androidx的版本
configuration.dependencies.add(getProject().dependencies.create('com.github.xuexiangjys.XAOP:xaop-runtime:1.0.5x'))
//XUpdate版本更新
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册