Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev
This commit is contained in:
@ -8,9 +8,6 @@ import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Window;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
|
||||
import com.gh.common.constant.Constants;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
@ -18,6 +15,7 @@ import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.RunningUtils;
|
||||
import com.gh.common.util.ShareUtils;
|
||||
import com.gh.common.util.StringUtils;
|
||||
import com.gh.common.util.TeaHelper;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.LoginActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
@ -39,6 +37,8 @@ import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import butterknife.ButterKnife;
|
||||
import pub.devrel.easypermissions.EasyPermissions;
|
||||
|
||||
@ -195,12 +195,14 @@ public abstract class BaseActivity extends BaseToolBarActivity implements EasyPe
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
TeaHelper.onPause(this);
|
||||
super.onPause();
|
||||
mIsPause = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
TeaHelper.onResume(this);
|
||||
super.onResume();
|
||||
mIsPause = false;
|
||||
}
|
||||
|
||||
@ -24,6 +24,8 @@ public class Constants {
|
||||
// 最近显示的弹窗信息
|
||||
public static final String SP_LAST_OPENING_ID = "last_opening_dialog_id";
|
||||
public static final String SP_LAST_OPENING_TIME = "last_opening_dialog_time";
|
||||
|
||||
public static final String SP_SHOWED_NOTIFICATION_HINT = "show_notification_hint";
|
||||
|
||||
//手机号码匹配规则
|
||||
public static final String REGEX_MOBILE = "^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$";
|
||||
|
||||
@ -0,0 +1,76 @@
|
||||
package com.gh.common.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
import android.util.TypedValue
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import com.gh.common.util.DisplayUtils
|
||||
import com.gh.common.util.PermissionHelper
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.entity.NotificationHint
|
||||
import com.lightgame.dialog.BaseDialogFragment
|
||||
import kotlinx.android.synthetic.main.dialog_notification_hint.*
|
||||
|
||||
class NotificationHintDialogFragment : BaseDialogFragment() {
|
||||
|
||||
private var mNotificationHint: NotificationHint? = null
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.dialog_notification_hint, null)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
titleTv.text = mNotificationHint?.title
|
||||
|
||||
contentContainer.removeAllViews()
|
||||
for (item in mNotificationHint?.content!!) {
|
||||
val tv = TextView(context)
|
||||
|
||||
tv.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT).apply {
|
||||
topMargin = if (contentContainer.childCount == 0) 0 else DisplayUtils.dip2px(12f)
|
||||
}
|
||||
tv.text = item
|
||||
tv.setTextColor(Color.parseColor("#1383EB"))
|
||||
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f)
|
||||
contentContainer.addView(tv)
|
||||
}
|
||||
|
||||
activateTv.setOnClickListener {
|
||||
dismiss()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
//这种方案适用于 API 26, 即8.0(含8.0)以上可以用
|
||||
val intent = Intent()
|
||||
intent.action = Settings.ACTION_APP_NOTIFICATION_SETTINGS
|
||||
intent.putExtra(Settings.EXTRA_APP_PACKAGE, BuildConfig.APPLICATION_ID)
|
||||
startActivity(intent)
|
||||
} else {
|
||||
PermissionHelper.toPermissionSetting(requireActivity())
|
||||
}
|
||||
}
|
||||
|
||||
laterTv.setOnClickListener { dismiss() }
|
||||
|
||||
dialog?.setCanceledOnTouchOutside(true)
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun getInstance(hint: NotificationHint) = NotificationHintDialogFragment().apply {
|
||||
mNotificationHint = hint
|
||||
}
|
||||
}
|
||||
}
|
||||
29
app/src/main/java/com/gh/common/util/NotificationHelper.kt
Normal file
29
app/src/main/java/com/gh/common/util/NotificationHelper.kt
Normal file
@ -0,0 +1,29 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import com.gh.common.constant.Constants
|
||||
import com.gh.common.dialog.NotificationHintDialogFragment
|
||||
import com.gh.gamecenter.entity.NotificationHint
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
|
||||
object NotificationHelper {
|
||||
|
||||
@JvmStatic
|
||||
fun showEnableNotificationDialogIfItsDisabled(activity: AppCompatActivity, notificationHint: NotificationHint) {
|
||||
if (notificationIsEnable()) {
|
||||
Utils.log("notification is enable")
|
||||
} else {
|
||||
NotificationHintDialogFragment.getInstance(notificationHint).show(activity.supportFragmentManager, "notification")
|
||||
SPUtils.setBoolean(Constants.SP_SHOWED_NOTIFICATION_HINT, true)
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun notificationIsEnable(): Boolean {
|
||||
val manager = NotificationManagerCompat.from(HaloApp.getInstance().application)
|
||||
return manager.areNotificationsEnabled()
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,13 +2,17 @@ package com.gh.common.util
|
||||
|
||||
import android.Manifest
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.provider.Settings
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import com.tbruyelle.rxpermissions2.RxPermissions
|
||||
|
||||
|
||||
|
||||
object PermissionHelper {
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@ -132,5 +136,52 @@ object PermissionHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到权限设置
|
||||
*
|
||||
* @param activity
|
||||
*/
|
||||
fun toPermissionSetting(activity: Activity) {
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||
toSystemConfig(activity)
|
||||
} else {
|
||||
try {
|
||||
toApplicationInfo(activity)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
toSystemConfig(activity)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 应用信息界面
|
||||
*
|
||||
* @param activity
|
||||
*/
|
||||
fun toApplicationInfo(activity: Activity) {
|
||||
val localIntent = Intent()
|
||||
localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
localIntent.action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
|
||||
localIntent.data = Uri.fromParts("package", activity.packageName, null)
|
||||
activity.startActivity(localIntent)
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统设置界面
|
||||
*
|
||||
* @param activity
|
||||
*/
|
||||
fun toSystemConfig(activity: Activity) {
|
||||
try {
|
||||
val intent = Intent(Settings.ACTION_SETTINGS)
|
||||
activity.startActivity(intent)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -3,6 +3,7 @@ package com.gh.common.util
|
||||
import android.content.Context
|
||||
import com.ss.android.common.applog.TeaAgent
|
||||
import com.ss.android.common.applog.TeaConfigBuilder
|
||||
import com.ss.android.common.lib.EventUtils
|
||||
|
||||
/**
|
||||
* 今日头条的激活统计 SDK https://gitlab.ghzs.com/pm/halo-app-issues/issues/567
|
||||
@ -17,6 +18,19 @@ object TeaHelper {
|
||||
.setAid(163824)
|
||||
.createTeaConfig()
|
||||
)
|
||||
|
||||
EventUtils.setRegister("mobile", false)
|
||||
EventUtils.setPurchase(null, null, null, 0, null, null, true, 0)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun onResume(context: Context) {
|
||||
TeaAgent.onResume(context)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun onPause(context: Context) {
|
||||
TeaAgent.onPause(context)
|
||||
}
|
||||
|
||||
}
|
||||
@ -22,14 +22,12 @@ import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
|
||||
import com.gh.base.AppUncaughtHandler;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.base.fragment.BaseFragment_ViewPager;
|
||||
import com.gh.common.AppExecutor;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.constant.Constants;
|
||||
import com.gh.common.exposure.ExposureUtils;
|
||||
import com.gh.common.exposure.meta.MetaUtil;
|
||||
import com.gh.common.im.ImManager;
|
||||
@ -49,9 +47,11 @@ import com.gh.common.util.GsonUtils;
|
||||
import com.gh.common.util.LogUtils;
|
||||
import com.gh.common.util.LunchType;
|
||||
import com.gh.common.util.MtaHelper;
|
||||
import com.gh.common.util.NotificationHelper;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
import com.gh.common.util.PushHelper;
|
||||
import com.gh.common.util.SPUtils;
|
||||
import com.gh.common.util.ThirdPartyPackageHelper;
|
||||
import com.gh.common.util.UrlFilterUtils;
|
||||
import com.gh.download.DownloadManager;
|
||||
@ -61,6 +61,7 @@ import com.gh.gamecenter.entity.CommunityEntity;
|
||||
import com.gh.gamecenter.entity.GameDigestEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.InnerMetaInfoEntity;
|
||||
import com.gh.gamecenter.entity.NotificationHint;
|
||||
import com.gh.gamecenter.entity.SettingsEntity;
|
||||
import com.gh.gamecenter.eventbus.EBNetworkState;
|
||||
import com.gh.gamecenter.eventbus.EBPackage;
|
||||
@ -75,6 +76,7 @@ import com.gh.gamecenter.normal.NormalFragment;
|
||||
import com.gh.gamecenter.packagehelper.PackageRepository;
|
||||
import com.gh.gamecenter.packagehelper.PackageViewModel;
|
||||
import com.gh.gamecenter.qa.CommunityFragment;
|
||||
import com.gh.gamecenter.retrofit.BiResponse;
|
||||
import com.gh.gamecenter.retrofit.EmptyResponse;
|
||||
import com.gh.gamecenter.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
@ -110,6 +112,8 @@ import java.util.Set;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.MediaType;
|
||||
@ -334,8 +338,10 @@ public class MainActivity extends BaseActivity {
|
||||
handler.postDelayed(() -> {
|
||||
PushHelper.postPushClickAction(this.getApplicationContext(), null);
|
||||
}, 2000);
|
||||
|
||||
showNotificationHintDialog();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
@ -663,6 +669,24 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void showNotificationHintDialog() {
|
||||
if (!SPUtils.getBoolean(Constants.SP_SHOWED_NOTIFICATION_HINT)) {
|
||||
RetrofitManager.getInstance(this).getApi().getBootPopup()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BiResponse<NotificationHint>() {
|
||||
@Override
|
||||
public void onSuccess(NotificationHint data) {
|
||||
try {
|
||||
NotificationHelper.showEnableNotificationDialogIfItsDisabled(MainActivity.this, data);
|
||||
} catch (Exception ignore){
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void oldUserSkip(String deviceId) {
|
||||
mSp.edit().putString("syncDeviceID", deviceId).apply();
|
||||
|
||||
@ -20,7 +20,6 @@ class CategoryListActivity : NormalActivity() {
|
||||
bundle.putParcelable(EntranceUtils.KEY_DATA, category)
|
||||
bundle.putString(EntranceUtils.KEY_NAME, category.name)
|
||||
bundle.putString(EntranceUtils.KEY_CATEGORY_TITLE, categoryTitle)
|
||||
bundle.putString(EntranceUtils.KEY_ENTRANCE, "(分类)")
|
||||
bundle.putString(EntranceUtils.KEY_CATEGORY_INIT_TITLE, initTitle)
|
||||
return getTargetIntent(context, CategoryListActivity::class.java, NewCategoryListFragment::class.java, bundle)
|
||||
}
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
package com.gh.gamecenter.entity
|
||||
|
||||
data class NotificationHint(var title: String = "", var content: List<String> = listOf())
|
||||
@ -7,9 +7,6 @@ import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.common.util.MtaHelper;
|
||||
import com.gh.gamecenter.R;
|
||||
@ -27,6 +24,8 @@ import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
|
||||
@ -94,7 +93,6 @@ public class KaiFuWrapperFragment extends NormalFragment {
|
||||
Bundle args = new Bundle();
|
||||
SimpleDateFormat format = new SimpleDateFormat("HH", Locale.CHINA);
|
||||
args.putInt(KEY_INDEX_PAGE, Integer.valueOf(format.format(new Date(System.currentTimeMillis()))) >= 18 ? 1 : -1);
|
||||
args.putString(EntranceUtils.KEY_ENTRANCE, mEntrance);
|
||||
|
||||
mKaiFuFragment = new KaiFuFragment();
|
||||
mKaiFuFragment.setArguments(args);
|
||||
|
||||
@ -25,6 +25,7 @@ import com.gh.gamecenter.entity.MessageUnreadEntity;
|
||||
import com.gh.gamecenter.entity.MyVideoEntity;
|
||||
import com.gh.gamecenter.entity.NewsDetailEntity;
|
||||
import com.gh.gamecenter.entity.NewsEntity;
|
||||
import com.gh.gamecenter.entity.NotificationHint;
|
||||
import com.gh.gamecenter.entity.OssEntity;
|
||||
import com.gh.gamecenter.entity.PackageEntity;
|
||||
import com.gh.gamecenter.entity.PersonalEntity;
|
||||
@ -2032,7 +2033,13 @@ public interface ApiService {
|
||||
*/
|
||||
@GET("games/servers/filter_tag")
|
||||
Single<List<ServersGameCategory>> getServerFilterTag();
|
||||
|
||||
|
||||
/**
|
||||
* 获取通知权限引导数据
|
||||
*/
|
||||
@GET("boot_popup")
|
||||
Single<NotificationHint> getBootPopup();
|
||||
|
||||
/**
|
||||
* 专题合集配置接口
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user