编译报错,排查问题
This commit is contained in:
1 parent
ddde2e481b
commit
b4ab6fdbb8
49 files changed
+2516
-1719
No files matched your search
@@ -47,6 +47,11 @@ android {
|
|||||||
XG_ACCESS_ID : "1500026407",
|
XG_ACCESS_ID : "1500026407",
|
||||||
XG_ACCESS_KEY: "AQ6C6W1O19LT",
|
XG_ACCESS_KEY: "AQ6C6W1O19LT",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
dataBinding {
|
||||||
|
enabled true
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
@@ -261,9 +266,73 @@ android {
|
|||||||
v1SigningEnabled true
|
v1SigningEnabled true
|
||||||
v2SigningEnabled true
|
v2SigningEnabled true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
zhanruiG10Z {
|
||||||
|
storeFile file("keystore/zhanruiG10Z.keystore")
|
||||||
|
storePassword "123456"
|
||||||
|
keyAlias "zhanruiG10Z"
|
||||||
|
keyPassword "123456"
|
||||||
|
v1SigningEnabled true
|
||||||
|
v2SigningEnabled true
|
||||||
|
}
|
||||||
|
|
||||||
|
G10ZUserDebug {
|
||||||
|
storeFile file("keystore/G10zUserDebug.keystore")
|
||||||
|
storePassword "123456"
|
||||||
|
keyAlias "G10zUserDebug"
|
||||||
|
keyPassword "123456"
|
||||||
|
v1SigningEnabled true
|
||||||
|
v2SigningEnabled true
|
||||||
|
}
|
||||||
|
|
||||||
|
seewo {
|
||||||
|
storeFile file("keystore/aiud.keystore")
|
||||||
|
storePassword "s4HdJuphaiHhU7WY"
|
||||||
|
keyAlias "androidreleasekey"
|
||||||
|
keyPassword "JwUw2oV16rUjWLBC"
|
||||||
|
v1SigningEnabled true
|
||||||
|
v2SigningEnabled true
|
||||||
|
}
|
||||||
|
|
||||||
|
U1302 {
|
||||||
|
storeFile file("keystore/U1302.keystore")
|
||||||
|
storePassword "123456"
|
||||||
|
keyAlias "u1302"
|
||||||
|
keyPassword "123456"
|
||||||
|
v1SigningEnabled true
|
||||||
|
v2SigningEnabled true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
QZ15Debug.initWith(debug)
|
||||||
|
QZ15Debug {
|
||||||
|
buildConfigField "String", "platform", '"QZA15"'
|
||||||
|
versionNameSuffix "-debug"
|
||||||
|
debuggable true
|
||||||
|
signingConfig signingConfigs.U1302
|
||||||
|
}
|
||||||
|
|
||||||
|
QZ15Release.initWith(release)
|
||||||
|
QZ15Release {
|
||||||
|
buildConfigField "String", "platform", '"QZA15"'
|
||||||
|
signingConfig signingConfigs.U1302
|
||||||
|
}
|
||||||
|
|
||||||
|
seewoDebug.initWith(debug)
|
||||||
|
seewoDebug {
|
||||||
|
versionNameSuffix "-debug"
|
||||||
|
debuggable true
|
||||||
|
signingConfig signingConfigs.seewo
|
||||||
|
buildConfigField "String", "platform", '"seewo"'
|
||||||
|
}
|
||||||
|
|
||||||
|
seewoRelease.initWith(release)
|
||||||
|
seewoRelease {
|
||||||
|
signingConfig signingConfigs.seewo
|
||||||
|
buildConfigField "String", "platform", '"seewo"'
|
||||||
|
}
|
||||||
|
|
||||||
Huaruian8768Debug.initWith(debug)
|
Huaruian8768Debug.initWith(debug)
|
||||||
Huaruian8768Debug {
|
Huaruian8768Debug {
|
||||||
versionNameSuffix "-debug"
|
versionNameSuffix "-debug"
|
||||||
@@ -414,6 +483,14 @@ android {
|
|||||||
signingConfig signingConfigs.P20S
|
signingConfig signingConfigs.P20S
|
||||||
}
|
}
|
||||||
|
|
||||||
|
zhanruiG10ZUserDebug.initWith(debug)
|
||||||
|
zhanruiG10ZUserDebug {
|
||||||
|
versionNameSuffix "-debug"
|
||||||
|
debuggable true
|
||||||
|
signingConfig signingConfigs.G10ZUserDebug
|
||||||
|
buildConfigField "String", "platform", '"ZR6016"'
|
||||||
|
}
|
||||||
|
|
||||||
zhanruiG10ZDebug.initWith(debug)
|
zhanruiG10ZDebug.initWith(debug)
|
||||||
zhanruiG10ZDebug {
|
zhanruiG10ZDebug {
|
||||||
versionNameSuffix "-debug"
|
versionNameSuffix "-debug"
|
||||||
@@ -516,6 +593,7 @@ android {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||||
compileOnly files('libs/framework.jar')
|
compileOnly files('libs/framework.jar')
|
||||||
|
compileOnly files('libs/qz_cubemdm_sdk_v1.0.0_1.8.jar')
|
||||||
|
|
||||||
implementation project(':viewlibrary')
|
implementation project(':viewlibrary')
|
||||||
implementation project(path: ':niceimageview')
|
implementation project(path: ':niceimageview')
|
||||||
@@ -623,6 +701,8 @@ dependencies {
|
|||||||
// implementation 'com.github.zane618:NiceImageView:1.0.0'
|
// implementation 'com.github.zane618:NiceImageView:1.0.0'
|
||||||
// 权限请求框架:https://github.com/getActivity/XXPermissions
|
// 权限请求框架:https://github.com/getActivity/XXPermissions
|
||||||
implementation 'com.github.getActivity:XXPermissions:12.3'
|
implementation 'com.github.getActivity:XXPermissions:12.3'
|
||||||
|
// 吐司框架:https://github.com/getActivity/Toaster
|
||||||
|
implementation 'com.github.getActivity:Toaster:12.6'
|
||||||
//动态权限框架
|
//动态权限框架
|
||||||
implementation 'com.yanzhenjie:permission:2.0.3'
|
implementation 'com.yanzhenjie:permission:2.0.3'
|
||||||
//沉浸状态栏
|
//沉浸状态栏
|
||||||
@@ -637,6 +717,7 @@ dependencies {
|
|||||||
implementation 'com.gyf.immersionbar:immersionbar-ktx:3.0.0'
|
implementation 'com.gyf.immersionbar:immersionbar-ktx:3.0.0'
|
||||||
//网络监听
|
//网络监听
|
||||||
implementation 'com.github.tianma8023:NetDetector:v0.2.0'
|
implementation 'com.github.tianma8023:NetDetector:v0.2.0'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
preBuild {
|
preBuild {
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -59,7 +59,7 @@
|
|||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/ImmerseTheme">
|
android:theme="@style/ImmerseTheme">
|
||||||
<activity android:name="com.ttstd.ttutils.activity.AoleyunTestActivity">
|
<activity android:name="com.ttstd.ttutils.activity.aoleyuntest.AoleyunTestActivity">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
|||||||
@@ -1,662 +0,0 @@
|
|||||||
package com.ttstd.ttutils.activity;
|
|
||||||
|
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.app.StatusBarManager;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.media.AudioManager;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.provider.Settings;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.inputmethod.InputMethodInfo;
|
|
||||||
import android.view.inputmethod.InputMethodManager;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
|
||||||
|
|
||||||
import androidx.core.content.pm.ShortcutInfoCompat;
|
|
||||||
import androidx.core.content.pm.ShortcutManagerCompat;
|
|
||||||
import androidx.core.graphics.drawable.IconCompat;
|
|
||||||
|
|
||||||
import com.ttstd.ttutils.BuildConfig;
|
|
||||||
import com.ttstd.ttutils.R;
|
|
||||||
import com.ttstd.ttutils.activity.main.MainActivity;
|
|
||||||
import com.ttstd.ttutils.base.BaseActivity;
|
|
||||||
import com.ttstd.ttutils.receiver.ShortcutReceiver;
|
|
||||||
import com.ttstd.ttutils.utils.java.JGYUtils;
|
|
||||||
import com.ttstd.ttutils.utils.java.ToastUtil;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
|
|
||||||
public class AoleyunTestActivity extends BaseActivity {
|
|
||||||
private static final String TAG = AoleyunTestActivity.class.getSimpleName();
|
|
||||||
|
|
||||||
@BindView(R.id.bt_settings)
|
|
||||||
Button bt_settings;
|
|
||||||
@BindView(R.id.bt_usb)
|
|
||||||
Button bt_usb;
|
|
||||||
@BindView(R.id.bt_usb_statu)
|
|
||||||
Button bt_usb_statu;
|
|
||||||
@BindView(R.id.bt_usb_charge)
|
|
||||||
Button bt_usb_charge;
|
|
||||||
@BindView(R.id.bt_usb_mtp)
|
|
||||||
Button bt_usb_mtp;
|
|
||||||
@BindView(R.id.bt_usb_midi)
|
|
||||||
Button bt_usb_midi;
|
|
||||||
|
|
||||||
@BindView(R.id.bt_desktop)
|
|
||||||
Button bt_desktop;
|
|
||||||
@BindView(R.id.bt_desktop_statu)
|
|
||||||
Button bt_desktop_statu;
|
|
||||||
@BindView(R.id.bt_desktop_launcher)
|
|
||||||
Button bt_desktop_launcher;
|
|
||||||
@BindView(R.id.bt_desktop_dop2)
|
|
||||||
Button bt_desktop_dop2;
|
|
||||||
@BindView(R.id.bt_desktop_aoleyun_os)
|
|
||||||
Button bt_desktop_aoleyun_os;
|
|
||||||
@BindView(R.id.bt_desktop_aoleyun)
|
|
||||||
Button bt_desktop_aoleyun;
|
|
||||||
|
|
||||||
@BindView(R.id.bt_sd)
|
|
||||||
Button bt_sd;
|
|
||||||
@BindView(R.id.bt_sd_statu)
|
|
||||||
Button bt_sd_statu;
|
|
||||||
@BindView(R.id.bt_sd_on)
|
|
||||||
Button bt_sd_on;
|
|
||||||
@BindView(R.id.bt_sd_off)
|
|
||||||
Button bt_sd_off;
|
|
||||||
|
|
||||||
@BindView(R.id.bt_developer)
|
|
||||||
Button bt_developer;
|
|
||||||
@BindView(R.id.bt_developer_statu)
|
|
||||||
Button bt_developer_statu;
|
|
||||||
@BindView(R.id.bt_developer_on)
|
|
||||||
Button bt_developer_on;
|
|
||||||
@BindView(R.id.bt_developer_off)
|
|
||||||
Button bt_developer_off;
|
|
||||||
|
|
||||||
@BindView(R.id.bt_navigation)
|
|
||||||
Button bt_navigation;
|
|
||||||
@BindView(R.id.bt_navigation_statu)
|
|
||||||
Button bt_navigation_statu;
|
|
||||||
@BindView(R.id.bt_navigation_on)
|
|
||||||
Button bt_navigation_on;
|
|
||||||
@BindView(R.id.bt_navigation_off)
|
|
||||||
Button bt_navigation_off;
|
|
||||||
|
|
||||||
@BindView(R.id.bt_statusbar)
|
|
||||||
Button bt_statusbar;
|
|
||||||
@BindView(R.id.bt_statusbar_back)
|
|
||||||
Button bt_statusbar_back;
|
|
||||||
@BindView(R.id.bt_statusbar_home)
|
|
||||||
Button bt_statusbar_home;
|
|
||||||
@BindView(R.id.bt_statusbar_recent)
|
|
||||||
Button bt_statusbar_recent;
|
|
||||||
|
|
||||||
@BindView(R.id.bt_status)
|
|
||||||
Button bt_status;
|
|
||||||
@BindView(R.id.bt_status_statu)
|
|
||||||
Button bt_status_statu;
|
|
||||||
@BindView(R.id.bt_status_on)
|
|
||||||
Button bt_status_on;
|
|
||||||
@BindView(R.id.bt_status_off)
|
|
||||||
Button bt_status_off;
|
|
||||||
|
|
||||||
@BindView(R.id.bt_statusbar_collapse)
|
|
||||||
Button bt_statusbar_collapse;
|
|
||||||
@BindView(R.id.bt_collapse_statu)
|
|
||||||
Button bt_collapse_statu;
|
|
||||||
@BindView(R.id.bt_collapse_on)
|
|
||||||
Button bt_collapse_on;
|
|
||||||
@BindView(R.id.bt_collapse_off)
|
|
||||||
Button bt_collapse_off;
|
|
||||||
|
|
||||||
@BindView(R.id.bt_hotspot)
|
|
||||||
Button bt_hotspot;
|
|
||||||
@BindView(R.id.bt_hotspot_statu)
|
|
||||||
Button bt_hotspot_statu;
|
|
||||||
@BindView(R.id.bt_hotspot_on)
|
|
||||||
Button bt_hotspot_on;
|
|
||||||
@BindView(R.id.bt_hotspot_off)
|
|
||||||
Button bt_hotspot_off;
|
|
||||||
|
|
||||||
@BindView(R.id.bt_bht)
|
|
||||||
Button bt_bht;
|
|
||||||
@BindView(R.id.bt_bht_statu)
|
|
||||||
Button bt_bht_statu;
|
|
||||||
@BindView(R.id.bt_bht_on)
|
|
||||||
Button bt_bht_on;
|
|
||||||
@BindView(R.id.bt_bht_off)
|
|
||||||
Button bt_bht_off;
|
|
||||||
|
|
||||||
@BindView(R.id.bt_bt_on)
|
|
||||||
Button bt_bt_on;
|
|
||||||
@BindView(R.id.bt_bt_off)
|
|
||||||
Button bt_bt_off;
|
|
||||||
@BindView(R.id.bt_bhtvideo_on)
|
|
||||||
Button bt_bhtvideo_on;
|
|
||||||
@BindView(R.id.bt_bhtvideo_off)
|
|
||||||
Button bt_bhtvideo_off;
|
|
||||||
|
|
||||||
@BindView(R.id.bt_reset)
|
|
||||||
Button bt_reset;
|
|
||||||
@BindView(R.id.bt_reset_statu)
|
|
||||||
Button bt_reset_statu;
|
|
||||||
@BindView(R.id.bt_reset_on)
|
|
||||||
Button bt_reset_on;
|
|
||||||
@BindView(R.id.bt_reset_off)
|
|
||||||
Button bt_reset_off;
|
|
||||||
|
|
||||||
@BindView(R.id.bt_input)
|
|
||||||
Button bt_input;
|
|
||||||
@BindView(R.id.bt_input_statu)
|
|
||||||
EditText bt_input_statu;
|
|
||||||
@BindView(R.id.bt_input_on)
|
|
||||||
Button bt_input_on;
|
|
||||||
@BindView(R.id.bt_input_off)
|
|
||||||
Button bt_input_off;
|
|
||||||
|
|
||||||
@BindView(R.id.bt_browser)
|
|
||||||
Button bt_browser;
|
|
||||||
@BindView(R.id.bt_browser_statu)
|
|
||||||
Button bt_browser_statu;
|
|
||||||
@BindView(R.id.bt_browser_on)
|
|
||||||
Button bt_browser_on;
|
|
||||||
@BindView(R.id.bt_browser_off)
|
|
||||||
Button bt_browser_off;
|
|
||||||
|
|
||||||
@BindView(R.id.bt_app_net)
|
|
||||||
Button bt_app_net;
|
|
||||||
@BindView(R.id.bt_app_statu)
|
|
||||||
Button bt_app_statu;
|
|
||||||
@BindView(R.id.bt_app_on)
|
|
||||||
Button bt_app_on;
|
|
||||||
@BindView(R.id.bt_app_off)
|
|
||||||
Button bt_app_off;
|
|
||||||
|
|
||||||
@BindView(R.id.bt_night_on)
|
|
||||||
Button bt_night_on;
|
|
||||||
@BindView(R.id.bt_night_off)
|
|
||||||
Button bt_night_off;
|
|
||||||
@BindView(R.id.bt_read_on)
|
|
||||||
Button bt_read_on;
|
|
||||||
@BindView(R.id.bt_read_off)
|
|
||||||
Button bt_read_off;
|
|
||||||
|
|
||||||
@BindView(R.id.bt_add_shortcut)
|
|
||||||
Button bt_add_shortcut;
|
|
||||||
|
|
||||||
public static final String NIGHT_DISPLAY_ENABLED = "NIGHT_DISPLAY_ENABLED";
|
|
||||||
public static final String NIGHT_DISPLAY_DISABLED = "NIGHT_DISPLAY_DISABLED";
|
|
||||||
public static final String READ_MODEL_ENABLED = "READ_MODEL_ENABLED";
|
|
||||||
public static final String READ_MODEL_DISABLED = "READ_MODEL_DISABLED";
|
|
||||||
|
|
||||||
StatusBarManager mStatusBarManager;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLayoutId() {
|
|
||||||
return R.layout.activity_aoleyun_test;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initView() {
|
|
||||||
ButterKnife.bind(this);
|
|
||||||
|
|
||||||
PackageManager pm = getPackageManager();
|
|
||||||
try {
|
|
||||||
Log.e(TAG, "initView: " + pm.getApplicationEnabledSetting("com.teclast.update"));
|
|
||||||
pm.setApplicationEnabledSetting("com.teclast.update", PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
|
|
||||||
// pm.getApplicationEnabledSetting("com.teclast.update") == PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Intent intent = new Intent();
|
|
||||||
intent.setClassName("com.teclast.update", "com.teclast.update. GoogleOtaClient");
|
|
||||||
startActivity(intent);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (BuildConfig.DEBUG) {
|
|
||||||
// ApkUtils.openApp(this, "com.android.settings");
|
|
||||||
//静音
|
|
||||||
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
|
|
||||||
int ringMax = audioManager.getStreamMinVolumeInt(AudioManager.STREAM_RING);
|
|
||||||
audioManager.setStreamVolume(AudioManager.STREAM_RING, ringMax, 0);
|
|
||||||
int musicMax = audioManager.getStreamMinVolumeInt(AudioManager.STREAM_MUSIC);
|
|
||||||
int voiceMax = audioManager.getStreamMinVolumeInt(AudioManager.STREAM_VOICE_CALL);
|
|
||||||
audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, voiceMax, 0);
|
|
||||||
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, musicMax, 0); //音乐音量
|
|
||||||
}
|
|
||||||
mStatusBarManager = (StatusBarManager) getApplicationContext().getSystemService(Context.STATUS_BAR_SERVICE);
|
|
||||||
|
|
||||||
init();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initData() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init() {
|
|
||||||
bt_settings.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
startActivity(new Intent(Settings.ACTION_SETTINGS));
|
|
||||||
// startActivity(new Intent(Settings.ACTION_SECURITY_SETTINGS));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bt_usb.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
Settings.System.putString(getContentResolver(), "app_view_click_disabled",
|
|
||||||
"com.android.gallery3d:12345,78901;com.android.settings:9876543,12346");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bt_usb_statu.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
ToastUtil.show("app_view_click_disabled");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bt_usb_charge.setOnClickListener(view -> {
|
|
||||||
Log.e(TAG, "bt_usb_charge: " + view.getId());
|
|
||||||
Intent usbIntent = new Intent("aole_action_usb_usb_charge");
|
|
||||||
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.MTK8515Platform
|
|
||||||
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.TeclastP20sPlatform
|
|
||||||
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.AH6016Platform
|
|
||||||
) {
|
|
||||||
usbIntent.setPackage("com.android.settings");
|
|
||||||
}
|
|
||||||
sendBroadcast(usbIntent);
|
|
||||||
});
|
|
||||||
bt_usb_mtp.setOnClickListener(view -> {
|
|
||||||
Log.e(TAG, "bt_usb_charge: " + view.getId());
|
|
||||||
Intent usbIntent = new Intent("aole_action_usb_usb_mtp");
|
|
||||||
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.MTK8515Platform
|
|
||||||
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.TeclastP20sPlatform
|
|
||||||
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.AH6016Platform
|
|
||||||
) {
|
|
||||||
usbIntent.setPackage("com.android.settings");
|
|
||||||
}
|
|
||||||
sendBroadcast(usbIntent);
|
|
||||||
});
|
|
||||||
bt_usb_midi.setOnClickListener(view -> {
|
|
||||||
Log.e(TAG, "bt_usb_charge: " + view.getId());
|
|
||||||
Intent usbIntent = new Intent("aole_action_usb_usb_midi");
|
|
||||||
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.MTK8515Platform
|
|
||||||
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.TeclastP20sPlatform
|
|
||||||
) {
|
|
||||||
usbIntent.setPackage("com.android.settings");
|
|
||||||
}
|
|
||||||
sendBroadcast(usbIntent);
|
|
||||||
});
|
|
||||||
|
|
||||||
bt_desktop_statu.setOnClickListener(view -> gotoLauncher());
|
|
||||||
bt_desktop_launcher.setOnClickListener(view -> {
|
|
||||||
Intent intent = new Intent("setDefaultLauncher");
|
|
||||||
intent.putExtra("package", "com.android.launcher3");
|
|
||||||
intent.putExtra("className", "com.android.launcher3.Launcher");
|
|
||||||
intent.setPackage("com.android.settings");
|
|
||||||
sendBroadcast(intent);
|
|
||||||
});
|
|
||||||
bt_desktop_dop2.setOnClickListener(view -> {
|
|
||||||
Intent intent = new Intent("setDefaultLauncher");
|
|
||||||
intent.putExtra("package", "com.aoleyunos.dop2");
|
|
||||||
intent.putExtra("className", "com.aoleyunos.dop2.activity.main.MainActivity");
|
|
||||||
intent.setPackage("com.android.settings");
|
|
||||||
sendBroadcast(intent);
|
|
||||||
});
|
|
||||||
bt_desktop_aoleyun_os.setOnClickListener(view -> {
|
|
||||||
Intent intent = new Intent("setDefaultLauncher");
|
|
||||||
intent.putExtra("package", "com.android.uiuios");
|
|
||||||
intent.putExtra("className", "com.android.uiuios.Launcher");
|
|
||||||
intent.setPackage("com.android.settings");
|
|
||||||
sendBroadcast(intent);
|
|
||||||
});
|
|
||||||
bt_desktop_aoleyun.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
Intent intent = new Intent("setDefaultLauncher");
|
|
||||||
intent.putExtra("package", "com.aoleyun.os");
|
|
||||||
intent.putExtra("className", "com.aoleyun.os.Launcher");
|
|
||||||
intent.setPackage("com.android.settings");
|
|
||||||
sendBroadcast(intent);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
bt_sd_statu.setOnClickListener(view -> {
|
|
||||||
int aole_sdcard_forbid_on = Settings.System.getInt(getContentResolver(), "aole_sdcard_forbid_on", 0);
|
|
||||||
bt_sd_statu.setText("状态:" + aole_sdcard_forbid_on);
|
|
||||||
});
|
|
||||||
bt_sd_on.setOnClickListener(view -> Settings.System.putInt(getContentResolver(), "aole_sdcard_forbid_on", 0));
|
|
||||||
bt_sd_off.setOnClickListener(view -> Settings.System.putInt(getContentResolver(), "aole_sdcard_forbid_on", 1));
|
|
||||||
|
|
||||||
bt_developer_statu.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
int aole_Developeroptions = Settings.System.getInt(getContentResolver(), "aole_Developeroptions", 0);
|
|
||||||
Log.e(TAG, "onClick: aole_Developeroptions = " + aole_Developeroptions);
|
|
||||||
bt_developer_statu.setText("状态:" + aole_Developeroptions);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bt_developer_on.setOnClickListener(view -> setDeveloperOptions(0));
|
|
||||||
bt_developer_off.setOnClickListener(view -> setDeveloperOptions(1));
|
|
||||||
|
|
||||||
bt_navigation_statu.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bt_navigation_on.setOnClickListener(view -> {
|
|
||||||
Intent navIntent = new Intent("aole_show_NavigationBar");
|
|
||||||
// Intent navIntent = new Intent("aole_show_NavigationBar").setPackage("com.android.systemui");
|
|
||||||
sendBroadcast(navIntent);
|
|
||||||
});
|
|
||||||
bt_navigation_off.setOnClickListener(view -> {
|
|
||||||
Intent navIntent = new Intent("aole_hide_NavigationBar");
|
|
||||||
// Intent navIntent = new Intent("aole_hide_NavigationBar").setPackage("com.android.systemui");
|
|
||||||
sendBroadcast(navIntent);
|
|
||||||
});
|
|
||||||
|
|
||||||
bt_statusbar.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
// mStatusBarManager.disable(StatusBarManager.DISABLE_RECENT | StatusBarManager.DISABLE_HOME);
|
|
||||||
// mStatusBarManager.disable(StatusBarManager.DISABLE_BACK | StatusBarManager.DISABLE_RECENT | StatusBarManager.DISABLE_HOME);
|
|
||||||
mStatusBarManager.disable(StatusBarManager.DISABLE_NONE);//显示隐藏的虚拟按键
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bt_statusbar_back.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
mStatusBarManager.disable(StatusBarManager.DISABLE_BACK);//隐藏返回键
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bt_statusbar_home.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
mStatusBarManager.disable(StatusBarManager.DISABLE_HOME);//隐藏home键
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bt_statusbar_recent.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
mStatusBarManager.disable(StatusBarManager.DISABLE_RECENT);//隐藏recent键
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
bt_status_on.setOnClickListener(view -> {
|
|
||||||
Intent navIntent = new Intent("aole_show_statusBar");
|
|
||||||
// Intent navIntent = new Intent("aole_show_statusBar").setPackage("com.android.systemui");
|
|
||||||
sendBroadcast(navIntent);
|
|
||||||
});
|
|
||||||
bt_status_off.setOnClickListener(view -> {
|
|
||||||
Intent navIntent = new Intent("aole_hide_statusBar");
|
|
||||||
// Intent navIntent = new Intent("aole_hide_statusBar").setPackage("com.android.systemui");
|
|
||||||
sendBroadcast(navIntent);
|
|
||||||
});
|
|
||||||
|
|
||||||
bt_collapse_on.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
// StatusBarManager mStatusBarManager = (StatusBarManager) getApplicationContext().getSystemService(Context.STATUS_BAR_SERVICE);
|
|
||||||
// mStatusBarManager.disable(StatusBarManager.DISABLE_EXPAND);
|
|
||||||
// mStatusBarManager.disable(StatusBarManager.DISABLE2_NOTIFICATION_SHADE);
|
|
||||||
Settings.Global.putInt(getContentResolver(), "PULLDOWN_MENU_ENABLED", 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
bt_collapse_off.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
Settings.Global.putInt(getContentResolver(), "PULLDOWN_MENU_ENABLED", 0);
|
|
||||||
// StatusBarManager mStatusBarManager = (StatusBarManager) getApplicationContext().getSystemService(Context.STATUS_BAR_SERVICE);
|
|
||||||
// mStatusBarManager.disable(StatusBarManager.DISABLE_NONE);
|
|
||||||
// mStatusBarManager.disable(StatusBarManager.DISABLE2_NONE);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
bt_hotspot_on.setOnClickListener(view -> {
|
|
||||||
Settings.System.putInt(getContentResolver(), "aole_hotspot_forbid_on", 0);
|
|
||||||
});
|
|
||||||
bt_hotspot_off.setOnClickListener(view -> {
|
|
||||||
Settings.System.putInt(getContentResolver(), "aole_hotspot_forbid_on", 1);
|
|
||||||
Intent intent = new Intent("aole_hotspot_close");
|
|
||||||
intent.setPackage("com.android.settings");
|
|
||||||
sendStickyBroadcast(intent);
|
|
||||||
});
|
|
||||||
|
|
||||||
bt_bht_on.setOnClickListener(view -> Settings.System.putInt(getContentResolver(), "aole_bht_forbid_on", 0));
|
|
||||||
bt_bht_off.setOnClickListener(view -> Settings.System.putInt(getContentResolver(), "aole_bht_forbid_on", 1));
|
|
||||||
bt_bt_on.setOnClickListener(view -> Settings.System.putInt(getContentResolver(), "aole_bt_forbid_on", 0));
|
|
||||||
bt_bt_off.setOnClickListener(view -> Settings.System.putInt(getContentResolver(), "aole_bt_forbid_on", 1));
|
|
||||||
bt_bhtvideo_on.setOnClickListener(view -> Settings.System.putInt(getContentResolver(), "aole_bhtvideo_forbid_on", 0));
|
|
||||||
bt_bhtvideo_off.setOnClickListener(view -> Settings.System.putInt(getContentResolver(), "aole_bhtvideo_forbid_on", 1));
|
|
||||||
|
|
||||||
bt_reset_on.setOnClickListener(view -> Settings.System.putInt(getContentResolver(), "aole_restore_forbid_on", 0));
|
|
||||||
bt_reset_off.setOnClickListener(view -> Settings.System.putInt(getContentResolver(), "aole_restore_forbid_on", 1));
|
|
||||||
|
|
||||||
bt_input.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
InputMethodManager imeManager = (InputMethodManager) getApplicationContext().getSystemService(INPUT_METHOD_SERVICE);
|
|
||||||
List<InputMethodInfo> InputMethods = imeManager.getEnabledInputMethodList();
|
|
||||||
Log.e(TAG, "onClick: " + InputMethods);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bt_input_on.setOnClickListener(view -> {
|
|
||||||
Log.e(TAG, "init: " + getInputMethodId("com.baidu.input"));
|
|
||||||
Intent intent = new Intent("setDefaultInputMethod");
|
|
||||||
intent.putExtra("package", getInputMethodId("com.baidu.input"));
|
|
||||||
intent.setPackage("com.android.settings");
|
|
||||||
sendBroadcast(intent);
|
|
||||||
});
|
|
||||||
bt_input_off.setOnClickListener(view -> {
|
|
||||||
Log.e(TAG, "init: " + getInputMethodId("com.sohu.inputmethod.sogou"));
|
|
||||||
Intent intent = new Intent("setDefaultInputMethod");
|
|
||||||
intent.putExtra("package", getInputMethodId("com.sohu.inputmethod.sogou"));
|
|
||||||
intent.setPackage("com.android.settings");
|
|
||||||
sendBroadcast(intent);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
bt_browser_statu.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
Intent intent = new Intent();
|
|
||||||
intent.setAction("android.intent.action.VIEW");
|
|
||||||
Uri content_url = Uri.parse("https://www.baidu.com/");
|
|
||||||
intent.setData(content_url);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bt_browser_on.setOnClickListener(view -> {
|
|
||||||
Intent intent = new Intent("setDefaultBrowser");
|
|
||||||
intent.putExtra("package", ("com.quark.browser"));
|
|
||||||
intent.setPackage("com.android.settings");
|
|
||||||
sendBroadcast(intent);
|
|
||||||
});
|
|
||||||
bt_browser_off.setOnClickListener(view -> {
|
|
||||||
Intent intent = new Intent("setDefaultBrowser");
|
|
||||||
intent.putExtra("package", ("com.android.chrome"));
|
|
||||||
intent.setPackage("com.android.settings");
|
|
||||||
sendBroadcast(intent);
|
|
||||||
});
|
|
||||||
|
|
||||||
bt_app_net.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bt_app_statu.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
Log.e("aole_network_disallow", "onClick: " + Settings.System.getString(getContentResolver(), "aole_network_disallow"));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bt_app_on.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
Settings.System.putString(getContentResolver(), "aole_network_disallow", "com.quark.browser");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bt_app_off.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
Settings.System.putString(getContentResolver(), "aole_network_disallow", "");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bt_night_on.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
sendBroadcast(new Intent(NIGHT_DISPLAY_ENABLED));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bt_night_off.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
sendBroadcast(new Intent(NIGHT_DISPLAY_DISABLED));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bt_read_on.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
sendBroadcast(new Intent(READ_MODEL_ENABLED));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bt_read_off.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
sendBroadcast(new Intent(READ_MODEL_DISABLED));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bt_add_shortcut.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
// addShortcut(AoleyunTestActivity.this, new Intent(
|
|
||||||
// AoleyunTestActivity.this, MainActivity.class), "TTUtilsTest", false,
|
|
||||||
// ((BitmapDrawable) getResources().getDrawable(R.drawable.ic_launcher)).getBitmap());
|
|
||||||
addShortCutCompact(AoleyunTestActivity.this);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static final String ACTION_INSTALL_SHORTCUT =
|
|
||||||
"com.android.launcher.action.INSTALL_SHORTCUT";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加快捷方式
|
|
||||||
*
|
|
||||||
* @param context context
|
|
||||||
* @param actionIntent 要启动的Intent
|
|
||||||
* @param name name
|
|
||||||
*/
|
|
||||||
public void addShortcut(Context context, Intent actionIntent, String name, boolean allowRepeat, Bitmap iconBitmap) {
|
|
||||||
Intent addShortcutIntent = new Intent(ACTION_INSTALL_SHORTCUT);
|
|
||||||
// 是否允许重复创建
|
|
||||||
addShortcutIntent.putExtra("duplicate", allowRepeat);
|
|
||||||
// 快捷方式的标题
|
|
||||||
addShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name);
|
|
||||||
// 快捷方式的图标
|
|
||||||
addShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON, iconBitmap);
|
|
||||||
// 快捷方式的动作
|
|
||||||
addShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, actionIntent);
|
|
||||||
context.sendBroadcast(addShortcutIntent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addShortCutCompact(Context context) {
|
|
||||||
if (ShortcutManagerCompat.isRequestPinShortcutSupported(context)) {
|
|
||||||
Intent shortcutInfoIntent = new Intent(context, MainActivity.class);
|
|
||||||
shortcutInfoIntent.setAction(Intent.ACTION_VIEW); //action必须设置,不然报错
|
|
||||||
ShortcutInfoCompat info = new ShortcutInfoCompat.Builder(context, "id")
|
|
||||||
.setIcon(IconCompat.createWithResource(context, R.mipmap.ic_launcher))
|
|
||||||
.setShortLabel("name")
|
|
||||||
.setIntent(shortcutInfoIntent)
|
|
||||||
.build();
|
|
||||||
//当添加快捷方式的确认弹框弹出来时,将被回调,自定义Receiver
|
|
||||||
PendingIntent shortcutCallbackIntent = PendingIntent.getBroadcast(context, 0, new Intent(context, ShortcutReceiver.class), PendingIntent.FLAG_UPDATE_CURRENT);
|
|
||||||
ShortcutManagerCompat.requestPinShortcut(context, info,
|
|
||||||
shortcutCallbackIntent.getIntentSender());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
|
|
||||||
lazyExit();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return super.onKeyDown(keyCode, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
private long mPreClickTime;
|
|
||||||
|
|
||||||
private void lazyExit() {
|
|
||||||
if (System.currentTimeMillis() - mPreClickTime > 5000) {
|
|
||||||
ToastUtil.show("再按一次,退出");
|
|
||||||
mPreClickTime = System.currentTimeMillis();
|
|
||||||
} else {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void gotoLauncher() {
|
|
||||||
Intent i = new Intent(Intent.ACTION_MAIN);
|
|
||||||
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //android123提示如果是服务里调用,必须加入new task标识
|
|
||||||
i.addCategory(Intent.CATEGORY_HOME);
|
|
||||||
startActivity(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getInputMethodId(String pkg) {
|
|
||||||
InputMethodManager imeManager = (InputMethodManager) getApplicationContext().getSystemService(INPUT_METHOD_SERVICE);
|
|
||||||
List<InputMethodInfo> InputMethods = imeManager.getInputMethodList();
|
|
||||||
Map<String, String> inputMap = new HashMap<>();
|
|
||||||
for (InputMethodInfo inputMethodInfo : InputMethods) {
|
|
||||||
inputMap.put(inputMethodInfo.getPackageName(), inputMethodInfo.getId());
|
|
||||||
}
|
|
||||||
String id = inputMap.get(pkg);
|
|
||||||
Log.e(TAG, "getInputMethodId: " + id);
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDeveloperOptions(int state) {
|
|
||||||
Settings.System.putInt(getContentResolver(), "aole_Developeroptions", state);
|
|
||||||
|
|
||||||
Log.e(TAG, "setDeveloperOptions: " + state);
|
|
||||||
Settings.System.putInt(getContentResolver(), "aole_Developeroptions", state);
|
|
||||||
int old_dev_enabled = Settings.Global.getInt(getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
|
|
||||||
Log.e(TAG, "setDeveloperOptions: old_dev_enabled = " + old_dev_enabled);
|
|
||||||
int new_state = (state == 1 ? 0 : 1);
|
|
||||||
if (old_dev_enabled != new_state) {
|
|
||||||
Settings.Global.putInt(getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, new_state);
|
|
||||||
Settings.Global.putInt(getContentResolver(), Settings.Global.ADB_ENABLED, new_state);
|
|
||||||
}
|
|
||||||
if (state == 1) {
|
|
||||||
// Intent intent = new Intent();
|
|
||||||
// intent.setAction("qch_developeroptions_close");
|
|
||||||
// intent.setPackage(JGYActions.ANDROID_SETTINGS_PACKAGE_NAME);
|
|
||||||
// sendBroadcast(intent);
|
|
||||||
Log.e(TAG, "setDeveloperOptions: " + "关闭开发者模式");
|
|
||||||
} else {
|
|
||||||
Log.e(TAG, "setDeveloperOptions: " + "打开开发者模式");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +1,35 @@
|
|||||||
package com.ttstd.ttutils.activity;
|
package com.ttstd.ttutils.activity;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import com.ttstd.ttutils.receiver.PackageReceiver;
|
|
||||||
import com.ttstd.ttutils.R;
|
import com.ttstd.ttutils.R;
|
||||||
|
import com.ttstd.ttutils.base.mvvm.BaseMvvmActivity;
|
||||||
|
import com.ttstd.ttutils.receiver.PackageReceiver;
|
||||||
|
|
||||||
public class PackageActivity extends AppCompatActivity {
|
public class PackageActivity extends BaseMvvmActivity {
|
||||||
private PackageReceiver packageReceiver;
|
private PackageReceiver packageReceiver;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected int getLayoutId() {
|
||||||
super.onCreate(savedInstanceState);
|
return R.layout.activity_package;
|
||||||
setContentView(R.layout.activity_package);
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initDataBinding() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initView() {
|
||||||
|
// mViewModel.setCtx(this);
|
||||||
|
// mViewModel.setVDBinding(mViewDataBinding);
|
||||||
|
// mViewModel.setLifecycle(getLifecycleSubject());
|
||||||
|
// mViewDataBinding.setClick(new BtnClick());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initData() {
|
||||||
register();
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,567 @@
|
|||||||
|
package com.ttstd.ttutils.activity.aoleyuntest;
|
||||||
|
|
||||||
|
import android.app.NotificationChannel;
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.app.StatusBarManager;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.media.AudioManager;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.provider.Settings;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.inputmethod.InputMethodInfo;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
|
import androidx.core.app.NotificationCompat;
|
||||||
|
import androidx.core.app.NotificationManagerCompat;
|
||||||
|
import androidx.core.content.pm.ShortcutInfoCompat;
|
||||||
|
import androidx.core.content.pm.ShortcutManagerCompat;
|
||||||
|
import androidx.core.graphics.drawable.IconCompat;
|
||||||
|
|
||||||
|
import com.ttstd.ttutils.BuildConfig;
|
||||||
|
import com.ttstd.ttutils.R;
|
||||||
|
import com.ttstd.ttutils.activity.main.MainActivity;
|
||||||
|
import com.ttstd.ttutils.base.mvvm.BaseMvvmActivity;
|
||||||
|
import com.ttstd.ttutils.databinding.ActivityAoleyunTestBinding;
|
||||||
|
import com.ttstd.ttutils.receiver.ShortcutReceiver;
|
||||||
|
import com.ttstd.ttutils.utils.java.ApkUtils;
|
||||||
|
import com.ttstd.ttutils.utils.java.JgyUtils;
|
||||||
|
import com.ttstd.ttutils.utils.java.ToastUtil;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
public class AoleyunTestActivity extends BaseMvvmActivity<AoleyunTestViewModel, ActivityAoleyunTestBinding> {
|
||||||
|
private static final String TAG = "AoleyunTestActivity";
|
||||||
|
|
||||||
|
public static final String NIGHT_DISPLAY_ENABLED = "NIGHT_DISPLAY_ENABLED";
|
||||||
|
public static final String NIGHT_DISPLAY_DISABLED = "NIGHT_DISPLAY_DISABLED";
|
||||||
|
public static final String READ_MODEL_ENABLED = "READ_MODEL_ENABLED";
|
||||||
|
public static final String READ_MODEL_DISABLED = "READ_MODEL_DISABLED";
|
||||||
|
|
||||||
|
StatusBarManager mStatusBarManager;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLayoutId() {
|
||||||
|
return R.layout.activity_aoleyun_test;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initDataBinding() {
|
||||||
|
mViewModel.setCtx(this);
|
||||||
|
mViewModel.setVDBinding(mViewDataBinding);
|
||||||
|
mViewModel.setLifecycle(getLifecycleSubject());
|
||||||
|
mViewDataBinding.setClick(new BtnClick());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initView() {
|
||||||
|
PackageManager pm = getPackageManager();
|
||||||
|
try {
|
||||||
|
Log.e(TAG, "initView: " + pm.getApplicationEnabledSetting("com.teclast.update"));
|
||||||
|
pm.setApplicationEnabledSetting("com.teclast.update", PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
|
||||||
|
// pm.getApplicationEnabledSetting("com.teclast.update") == PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setClassName("com.teclast.update", "com.teclast.update. GoogleOtaClient");
|
||||||
|
startActivity(intent);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (BuildConfig.DEBUG) {
|
||||||
|
// ApkUtils.openApp(this, "com.android.settings");
|
||||||
|
//静音
|
||||||
|
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
|
||||||
|
int ringMax = audioManager.getStreamMinVolumeInt(AudioManager.STREAM_RING);
|
||||||
|
audioManager.setStreamVolume(AudioManager.STREAM_RING, ringMax, 0);
|
||||||
|
int musicMax = audioManager.getStreamMinVolumeInt(AudioManager.STREAM_MUSIC);
|
||||||
|
int voiceMax = audioManager.getStreamMinVolumeInt(AudioManager.STREAM_VOICE_CALL);
|
||||||
|
audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, voiceMax, 0);
|
||||||
|
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, musicMax, 0); //音乐音量
|
||||||
|
}
|
||||||
|
mStatusBarManager = (StatusBarManager) getApplicationContext().getSystemService(Context.STATUS_BAR_SERVICE);
|
||||||
|
notificationManager = NotificationManagerCompat.from(this);
|
||||||
|
|
||||||
|
createNotificationChannel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initData() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static final String CHANNEL_ID = "CHANNEL_ID";
|
||||||
|
private static final String CHANNEL_NAME = "应用中心";
|
||||||
|
private static final String CHANNEL_DESCRIPTION = "应用中心通知";
|
||||||
|
private NotificationManagerCompat notificationManager;
|
||||||
|
private int NotificationID = 7897;
|
||||||
|
|
||||||
|
|
||||||
|
private void createNotificationChannel() {
|
||||||
|
// Create the NotificationChannel, but only on API 26+ because
|
||||||
|
// the NotificationChannel class is new and not in the support library
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
|
||||||
|
channel.setDescription(CHANNEL_DESCRIPTION);
|
||||||
|
channel.setSound(null, null);
|
||||||
|
// Register the channel with the system; you can't change the importance
|
||||||
|
// or other notification behaviors after this
|
||||||
|
NotificationManager notificationManager = getSystemService(NotificationManager.class);
|
||||||
|
if (notificationManager != null) {
|
||||||
|
notificationManager.createNotificationChannel(channel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendSimpleNotification() {
|
||||||
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
|
||||||
|
.setSmallIcon(R.mipmap.ic_launcher)
|
||||||
|
.setContentTitle("应用中心正在运行")
|
||||||
|
// .setContentText("测试内容")
|
||||||
|
// .setAutoCancel(false)
|
||||||
|
.setShowWhen(false)
|
||||||
|
// .setOngoing(true)
|
||||||
|
.setOnlyAlertOnce(true)
|
||||||
|
.setPriority(NotificationCompat.PRIORITY_MIN);
|
||||||
|
// notificationId is a unique int for each notification that you must define
|
||||||
|
notificationManager.notify(NotificationID, builder.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String ACTION_INSTALL_SHORTCUT =
|
||||||
|
"com.android.launcher.action.INSTALL_SHORTCUT";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加快捷方式
|
||||||
|
*
|
||||||
|
* @param context context
|
||||||
|
* @param actionIntent 要启动的Intent
|
||||||
|
* @param name name
|
||||||
|
*/
|
||||||
|
public void addShortcut(Context context, Intent actionIntent, String name, boolean allowRepeat, Bitmap iconBitmap) {
|
||||||
|
Intent addShortcutIntent = new Intent(ACTION_INSTALL_SHORTCUT);
|
||||||
|
// 是否允许重复创建
|
||||||
|
addShortcutIntent.putExtra("duplicate", allowRepeat);
|
||||||
|
// 快捷方式的标题
|
||||||
|
addShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name);
|
||||||
|
// 快捷方式的图标
|
||||||
|
addShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON, iconBitmap);
|
||||||
|
// 快捷方式的动作
|
||||||
|
addShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, actionIntent);
|
||||||
|
context.sendBroadcast(addShortcutIntent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addShortCutCompact(Context context) {
|
||||||
|
if (ShortcutManagerCompat.isRequestPinShortcutSupported(context)) {
|
||||||
|
Intent shortcutInfoIntent = new Intent(context, MainActivity.class);
|
||||||
|
shortcutInfoIntent.setAction(Intent.ACTION_VIEW); //action必须设置,不然报错
|
||||||
|
ShortcutInfoCompat info = new ShortcutInfoCompat.Builder(context, "id")
|
||||||
|
.setIcon(IconCompat.createWithResource(context, R.mipmap.ic_launcher))
|
||||||
|
.setShortLabel("name")
|
||||||
|
.setIntent(shortcutInfoIntent)
|
||||||
|
.build();
|
||||||
|
//当添加快捷方式的确认弹框弹出来时,将被回调,自定义Receiver
|
||||||
|
PendingIntent shortcutCallbackIntent = PendingIntent.getBroadcast(context, 0, new Intent(context, ShortcutReceiver.class), PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
ShortcutManagerCompat.requestPinShortcut(context, info,
|
||||||
|
shortcutCallbackIntent.getIntentSender());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
|
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||||
|
lazyExit();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onKeyDown(keyCode, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
private long mPreClickTime;
|
||||||
|
|
||||||
|
private void lazyExit() {
|
||||||
|
if (System.currentTimeMillis() - mPreClickTime > 5000) {
|
||||||
|
ToastUtil.show("再按一次,退出");
|
||||||
|
mPreClickTime = System.currentTimeMillis();
|
||||||
|
} else {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void gotoLauncher() {
|
||||||
|
Intent i = new Intent(Intent.ACTION_MAIN);
|
||||||
|
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //android123提示如果是服务里调用,必须加入new task标识
|
||||||
|
i.addCategory(Intent.CATEGORY_HOME);
|
||||||
|
startActivity(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getInputMethodId(String pkg) {
|
||||||
|
InputMethodManager imeManager = (InputMethodManager) getApplicationContext().getSystemService(INPUT_METHOD_SERVICE);
|
||||||
|
List<InputMethodInfo> InputMethods = imeManager.getInputMethodList();
|
||||||
|
Map<String, String> inputMap = new HashMap<>();
|
||||||
|
for (InputMethodInfo inputMethodInfo : InputMethods) {
|
||||||
|
inputMap.put(inputMethodInfo.getPackageName(), inputMethodInfo.getId());
|
||||||
|
}
|
||||||
|
String id = inputMap.get(pkg);
|
||||||
|
Log.e(TAG, "getInputMethodId: " + id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeveloperOptions(int state) {
|
||||||
|
Settings.System.putInt(getContentResolver(), "aole_Developeroptions", state);
|
||||||
|
|
||||||
|
Log.e(TAG, "setDeveloperOptions: " + state);
|
||||||
|
Settings.System.putInt(getContentResolver(), "aole_Developeroptions", state);
|
||||||
|
int old_dev_enabled = Settings.Global.getInt(getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
|
||||||
|
Log.e(TAG, "setDeveloperOptions: old_dev_enabled = " + old_dev_enabled);
|
||||||
|
int new_state = (state == 1 ? 0 : 1);
|
||||||
|
if (old_dev_enabled != new_state) {
|
||||||
|
Settings.Global.putInt(getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, new_state);
|
||||||
|
Settings.Global.putInt(getContentResolver(), Settings.Global.ADB_ENABLED, new_state);
|
||||||
|
}
|
||||||
|
if (state == 1) {
|
||||||
|
// Intent intent = new Intent();
|
||||||
|
// intent.setAction("qch_developeroptions_close");
|
||||||
|
// intent.setPackage(JGYActions.ANDROID_SETTINGS_PACKAGE_NAME);
|
||||||
|
// sendBroadcast(intent);
|
||||||
|
Log.e(TAG, "setDeveloperOptions: " + "关闭开发者模式");
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "setDeveloperOptions: " + "打开开发者模式");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BtnClick {
|
||||||
|
public void openSettings(View view) {
|
||||||
|
startActivity(new Intent(Settings.ACTION_SETTINGS));
|
||||||
|
// startActivity(new Intent(Settings.ACTION_SECURITY_SETTINGS));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsbSettings(View view) {
|
||||||
|
Settings.System.putString(getContentResolver(), "app_view_click_disabled",
|
||||||
|
"com.android.gallery3d:12345,78901;com.android.settings:9876543,12346");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getUsbSettings(View view) {
|
||||||
|
String app_view_click_disabled = Settings.System.getString(getContentResolver(), "app_view_click_disabled");
|
||||||
|
ToastUtil.show(app_view_click_disabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsbCharge(View view) {
|
||||||
|
Log.e(TAG, "bt_usb_charge: " + view.getId());
|
||||||
|
Intent usbIntent = new Intent("aole_action_usb_usb_charge");
|
||||||
|
if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.MTK8515Platform
|
||||||
|
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.TeclastP20sPlatform
|
||||||
|
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.AH6016Platform
|
||||||
|
) {
|
||||||
|
usbIntent.setPackage("com.android.settings");
|
||||||
|
}
|
||||||
|
sendBroadcast(usbIntent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsbMtp(View view) {
|
||||||
|
Log.e(TAG, "bt_usb_charge: " + view.getId());
|
||||||
|
Intent usbIntent = new Intent("aole_action_usb_usb_mtp");
|
||||||
|
if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.MTK8515Platform
|
||||||
|
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.TeclastP20sPlatform
|
||||||
|
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.AH6016Platform
|
||||||
|
) {
|
||||||
|
usbIntent.setPackage("com.android.settings");
|
||||||
|
}
|
||||||
|
sendBroadcast(usbIntent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsbMidi(View view) {
|
||||||
|
Log.e(TAG, "bt_usb_charge: " + view.getId());
|
||||||
|
Intent usbIntent = new Intent("aole_action_usb_usb_midi");
|
||||||
|
if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.MTK8515Platform
|
||||||
|
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.TeclastP20sPlatform
|
||||||
|
) {
|
||||||
|
usbIntent.setPackage("com.android.settings");
|
||||||
|
}
|
||||||
|
sendBroadcast(usbIntent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void goLauncher(View view) {
|
||||||
|
gotoLauncher();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultLauncher3(View view) {
|
||||||
|
Intent intent = new Intent("setDefaultLauncher");
|
||||||
|
intent.putExtra("package", "com.android.launcher3");
|
||||||
|
intent.putExtra("className", "com.android.launcher3.Launcher");
|
||||||
|
intent.setPackage("com.android.settings");
|
||||||
|
sendBroadcast(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultDop2(View view) {
|
||||||
|
Intent intent = new Intent("setDefaultLauncher");
|
||||||
|
intent.putExtra("package", "com.aoleyunos.dop2");
|
||||||
|
intent.putExtra("className", "com.aoleyunos.dop2.activity.main.MainActivity");
|
||||||
|
intent.setPackage("com.android.settings");
|
||||||
|
sendBroadcast(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultUiuiOs(View view) {
|
||||||
|
Intent intent = new Intent("setDefaultLauncher");
|
||||||
|
intent.putExtra("package", "com.android.uiuios");
|
||||||
|
intent.putExtra("className", "com.android.uiuios.Launcher");
|
||||||
|
intent.setPackage("com.android.settings");
|
||||||
|
sendBroadcast(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultAoleyun(View view) {
|
||||||
|
Intent intent = new Intent("setDefaultLauncher");
|
||||||
|
intent.putExtra("package", "com.aoleyun.os");
|
||||||
|
intent.putExtra("className", "com.aoleyun.os.Launcher");
|
||||||
|
intent.setPackage("com.android.settings");
|
||||||
|
sendBroadcast(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openDocumentsui(View view) {
|
||||||
|
ApkUtils.openPackage(AoleyunTestActivity.this, "com.android.documentsui");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getSdStatus(View view) {
|
||||||
|
int aole_sdcard_forbid_on = Settings.System.getInt(getContentResolver(), "aole_sdcard_forbid_on", 0);
|
||||||
|
mViewDataBinding.btSdStatu.setText("状态:" + aole_sdcard_forbid_on);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSdOn(View view) {
|
||||||
|
Settings.System.putInt(getContentResolver(), "aole_sdcard_forbid_on", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSdOff(View view) {
|
||||||
|
Settings.System.putInt(getContentResolver(), "aole_sdcard_forbid_on", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getDeveloperStatu(View view) {
|
||||||
|
int aole_Developeroptions = Settings.System.getInt(getContentResolver(), "aole_Developeroptions", 0);
|
||||||
|
Log.e(TAG, "onClick: aole_Developeroptions = " + aole_Developeroptions);
|
||||||
|
mViewDataBinding.btDeveloperStatu.setText("状态:" + aole_Developeroptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeveloperOn(View view) {
|
||||||
|
setDeveloperOptions(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void btDeveloperOff(View view) {
|
||||||
|
setDeveloperOptions(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getNavigationStatus(View view) {
|
||||||
|
Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNavigationOn(View view) {
|
||||||
|
Intent navIntent = new Intent("aole_show_NavigationBar");
|
||||||
|
// Intent navIntent = new Intent("aole_show_NavigationBar").setPackage("com.android.systemui");
|
||||||
|
sendBroadcast(navIntent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNavigationOff(View view) {
|
||||||
|
Intent navIntent = new Intent("aole_hide_NavigationBar");
|
||||||
|
// Intent navIntent = new Intent("aole_hide_NavigationBar").setPackage("com.android.systemui");
|
||||||
|
sendBroadcast(navIntent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showStatusbar(View view) {
|
||||||
|
// mStatusBarManager.disable(StatusBarManager.DISABLE_RECENT | StatusBarManager.DISABLE_HOME);
|
||||||
|
// mStatusBarManager.disable(StatusBarManager.DISABLE_BACK | StatusBarManager.DISABLE_RECENT | StatusBarManager.DISABLE_HOME);
|
||||||
|
mStatusBarManager.disable(StatusBarManager.DISABLE_NONE);//显示隐藏的虚拟按键
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hideStatusbarBack(View view) {
|
||||||
|
mStatusBarManager.disable(StatusBarManager.DISABLE_BACK);//隐藏返回键
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hideStatusbarHome(View view) {
|
||||||
|
mStatusBarManager.disable(StatusBarManager.DISABLE_HOME);//隐藏home键
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hideStatusbarRecent(View view) {
|
||||||
|
mStatusBarManager.disable(StatusBarManager.DISABLE_RECENT);//隐藏recent键
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatusOn(View view) {
|
||||||
|
Intent navIntent = new Intent("aole_show_statusBar");
|
||||||
|
// Intent navIntent = new Intent("aole_show_statusBar").setPackage("com.android.systemui");
|
||||||
|
sendBroadcast(navIntent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hideStatusOff(View view) {
|
||||||
|
Intent navIntent = new Intent("aole_hide_statusBar");
|
||||||
|
// Intent navIntent = new Intent("aole_hide_statusBar").setPackage("com.android.systemui");
|
||||||
|
sendBroadcast(navIntent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCollapseOn(View view) {
|
||||||
|
// StatusBarManager mStatusBarManager = (StatusBarManager) getApplicationContext().getSystemService(Context.STATUS_BAR_SERVICE);
|
||||||
|
// mStatusBarManager.disable(StatusBarManager.DISABLE_EXPAND);
|
||||||
|
// mStatusBarManager.disable(StatusBarManager.DISABLE2_NOTIFICATION_SHADE);
|
||||||
|
Settings.Global.putInt(getContentResolver(), "PULLDOWN_MENU_ENABLED", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCollapseOff(View view) {
|
||||||
|
Settings.Global.putInt(getContentResolver(), "PULLDOWN_MENU_ENABLED", 0);
|
||||||
|
// StatusBarManager mStatusBarManager = (StatusBarManager) getApplicationContext().getSystemService(Context.STATUS_BAR_SERVICE);
|
||||||
|
// mStatusBarManager.disable(StatusBarManager.DISABLE_NONE);
|
||||||
|
// mStatusBarManager.disable(StatusBarManager.DISABLE2_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHotspotOn(View view) {
|
||||||
|
Settings.System.putInt(getContentResolver(), "aole_hotspot_forbid_on", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHotspotOff(View view) {
|
||||||
|
Settings.System.putInt(getContentResolver(), "aole_hotspot_forbid_on", 1);
|
||||||
|
Intent intent = new Intent("aole_hotspot_close");
|
||||||
|
intent.setPackage("com.android.settings");
|
||||||
|
sendStickyBroadcast(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBhtOn(View view) {
|
||||||
|
Settings.System.putInt(getContentResolver(), "aole_bht_forbid_on", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBhtOff(View view) {
|
||||||
|
Settings.System.putInt(getContentResolver(), "aole_bht_forbid_on", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBtOn(View view) {
|
||||||
|
Settings.System.putInt(getContentResolver(), "aole_bt_forbid_on", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBtOff(View view) {
|
||||||
|
Settings.System.putInt(getContentResolver(), "aole_bt_forbid_on", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBhtvideoOn(View view) {
|
||||||
|
Settings.System.putInt(getContentResolver(), "aole_bhtvideo_forbid_on", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBhtvideoOff(View view) {
|
||||||
|
Settings.System.putInt(getContentResolver(), "aole_bhtvideo_forbid_on", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResetOn(View view) {
|
||||||
|
Settings.System.putInt(getContentResolver(), "aole_restore_forbid_on", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResetOff(View view) {
|
||||||
|
Settings.System.putInt(getContentResolver(), "aole_restore_forbid_on", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void listInputMeth(View view) {
|
||||||
|
InputMethodManager imeManager = (InputMethodManager) getApplicationContext().getSystemService(INPUT_METHOD_SERVICE);
|
||||||
|
List<InputMethodInfo> InputMethods = imeManager.getEnabledInputMethodList();
|
||||||
|
Log.e(TAG, "onClick: " + InputMethods);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInputBaidu(View view) {
|
||||||
|
Log.e(TAG, "init: " + getInputMethodId("com.baidu.input"));
|
||||||
|
Intent intent = new Intent("setDefaultInputMethod");
|
||||||
|
intent.putExtra("package", getInputMethodId("com.baidu.input"));
|
||||||
|
intent.setPackage("com.android.settings");
|
||||||
|
sendBroadcast(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInputSogou(View view) {
|
||||||
|
Log.e(TAG, "init: " + getInputMethodId("com.sohu.inputmethod.sogou"));
|
||||||
|
Intent intent = new Intent("setDefaultInputMethod");
|
||||||
|
intent.putExtra("package", getInputMethodId("com.sohu.inputmethod.sogou"));
|
||||||
|
intent.setPackage("com.android.settings");
|
||||||
|
sendBroadcast(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openUrl(View view) {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setAction("android.intent.action.VIEW");
|
||||||
|
Uri content_url = Uri.parse("https://www.baidu.com/");
|
||||||
|
intent.setData(content_url);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBrowserOn(View view) {
|
||||||
|
Intent intent = new Intent("setDefaultBrowser");
|
||||||
|
intent.putExtra("package", ("com.quark.browser"));
|
||||||
|
intent.setPackage("com.android.settings");
|
||||||
|
sendBroadcast(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBrowserOff(View view) {
|
||||||
|
Intent intent = new Intent("setDefaultBrowser");
|
||||||
|
intent.putExtra("package", ("com.android.chrome"));
|
||||||
|
intent.setPackage("com.android.settings");
|
||||||
|
sendBroadcast(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getAppStatus(View view) {
|
||||||
|
Log.e("aole_network_disallow", "onClick: " + Settings.System.getString(getContentResolver(), "aole_network_disallow"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setAppOn(View view) {
|
||||||
|
Settings.System.putString(getContentResolver(), "aole_network_disallow", "com.quark.browser");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setAppOff(View view) {
|
||||||
|
Settings.System.putString(getContentResolver(), "aole_network_disallow", "");
|
||||||
|
|
||||||
|
}
|
||||||
|
public void setNightOn(View view) {
|
||||||
|
sendBroadcast(new Intent(NIGHT_DISPLAY_ENABLED));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNightOff(View view) {
|
||||||
|
sendBroadcast(new Intent(NIGHT_DISPLAY_DISABLED));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReadOn(View view) {
|
||||||
|
sendBroadcast(new Intent(READ_MODEL_ENABLED));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReadOff(View view) {
|
||||||
|
sendBroadcast(new Intent(READ_MODEL_DISABLED));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addshortcut(View view) {
|
||||||
|
// addShortcut(AoleyunTestActivity.this, new Intent(
|
||||||
|
// AoleyunTestActivity.this, MainActivity.class), "TTUtilsTest", false,
|
||||||
|
// ((BitmapDrawable) getResources().getDrawable(R.drawable.ic_launcher)).getBitmap());
|
||||||
|
addShortCutCompact(AoleyunTestActivity.this);
|
||||||
|
}
|
||||||
|
public void addNoti(View view) {
|
||||||
|
sendSimpleNotification();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void notiOff(View view) {
|
||||||
|
Intent statusIntent = new Intent("aole_hide_appinfo");
|
||||||
|
sendBroadcast(statusIntent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void notiOn(View view) {
|
||||||
|
Intent statusIntent = new Intent("aole_show_appinfo");
|
||||||
|
sendBroadcast(statusIntent);
|
||||||
|
}
|
||||||
|
public void setNotiBlackList(View view) {
|
||||||
|
Settings.System.putString(getContentResolver(), "aole_app_info", BuildConfig.APPLICATION_ID);
|
||||||
|
Log.e("bt_noti_black", "onClick: " + Settings.System.getString(getContentResolver(), "aole_app_info"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.ttstd.ttutils.activity.aoleyuntest;
|
||||||
|
|
||||||
|
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||||
|
import com.ttstd.ttutils.base.mvvm.BaseViewModel;
|
||||||
|
import com.ttstd.ttutils.databinding.ActivityAoleyunTestBinding;
|
||||||
|
|
||||||
|
public class AoleyunTestViewModel extends BaseViewModel<ActivityAoleyunTestBinding, ActivityEvent> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActivityAoleyunTestBinding getVDBinding() {
|
||||||
|
return binding;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@ import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
|||||||
* @author jgy02
|
* @author jgy02
|
||||||
*/
|
*/
|
||||||
public class MainAPresenter implements MainAContact.Presenter {
|
public class MainAPresenter implements MainAContact.Presenter {
|
||||||
private static final String TAG = MainAPresenter.class.getSimpleName();
|
private static final String TAG = "MainAPresenter";
|
||||||
private MainAContact.MainView mView;
|
private MainAContact.MainView mView;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import com.jiaoguanyi.appstore.IGetLicenseInterface;
|
import com.jiaoguanyi.appstore.IGetLicenseInterface;
|
||||||
import com.notepad.uiui.INoteAidlInterface;
|
import com.notepad.uiui.INoteAidlInterface;
|
||||||
import com.ttstd.ttutils.base.ImmerseBaseActivity;
|
import com.ttstd.ttutils.base.mvvm.BaseMvvmActivity;
|
||||||
import com.ttstd.ttutils.server.main.MainService;
|
import com.ttstd.ttutils.server.main.MainService;
|
||||||
import com.ttstd.ttutils.R;
|
import com.ttstd.ttutils.R;
|
||||||
import com.ttstd.ttutils.utils.java.CmdUtil;
|
import com.ttstd.ttutils.utils.java.CmdUtil;
|
||||||
import com.ttstd.ttutils.utils.java.JGYUtils;
|
import com.ttstd.ttutils.utils.java.JgyUtils;
|
||||||
import com.ttstd.ttutils.utils.java.TTUtils;
|
import com.ttstd.ttutils.utils.java.TTUtils;
|
||||||
import com.ttstd.ttutils.utils.java.ToastUtil;
|
import com.ttstd.ttutils.utils.java.ToastUtil;
|
||||||
import com.ttstd.ttutils.utils.jni.NDKTools;
|
import com.ttstd.ttutils.utils.jni.NDKTools;
|
||||||
@@ -39,7 +39,7 @@ import java.util.ArrayList;
|
|||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
public class MainActivity extends ImmerseBaseActivity {
|
public class MainActivity extends BaseMvvmActivity {
|
||||||
@BindView(R.id.tv_qch_Developeroptions)
|
@BindView(R.id.tv_qch_Developeroptions)
|
||||||
TextView tv_qch_Developeroptions;
|
TextView tv_qch_Developeroptions;
|
||||||
@BindView(R.id.tv_development_settings_enabled)
|
@BindView(R.id.tv_development_settings_enabled)
|
||||||
@@ -114,7 +114,7 @@ public class MainActivity extends ImmerseBaseActivity {
|
|||||||
private IGetLicenseInterface getLicenseInterface;
|
private IGetLicenseInterface getLicenseInterface;
|
||||||
private ServiceConnection mIGetInfoConnection;
|
private ServiceConnection mIGetInfoConnection;
|
||||||
private IGetInfoInterface getInfoInterface;
|
private IGetInfoInterface getInfoInterface;
|
||||||
private static final String TAG = MainActivity.class.getSimpleName();
|
private static final String TAG = "MainActivity";
|
||||||
|
|
||||||
private UsbManager mUsbManager;
|
private UsbManager mUsbManager;
|
||||||
|
|
||||||
@@ -123,6 +123,14 @@ public class MainActivity extends ImmerseBaseActivity {
|
|||||||
return R.layout.activity_main;
|
return R.layout.activity_main;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initDataBinding() {
|
||||||
|
// mViewModel.setCtx(this);
|
||||||
|
// mViewModel.setVDBinding(mViewDataBinding);
|
||||||
|
// mViewModel.setLifecycle(getLifecycleSubject());
|
||||||
|
// mViewDataBinding.setClick(new BtnClick());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initView() {
|
public void initView() {
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
@@ -140,19 +148,8 @@ public class MainActivity extends ImmerseBaseActivity {
|
|||||||
TTUtils.getExtrax(intent);
|
TTUtils.getExtrax(intent);
|
||||||
}
|
}
|
||||||
mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
|
mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
// mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_NONE, true);
|
||||||
protected void onNewIntent(Intent intent) {
|
|
||||||
super.onNewIntent(intent);
|
|
||||||
if (intent != null) {
|
|
||||||
TTUtils.getExtrax(intent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setListener() {
|
|
||||||
// mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_NONE, true);
|
|
||||||
none.setOnClickListener(view -> mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_NONE, true));
|
none.setOnClickListener(view -> mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_NONE, true));
|
||||||
//报错
|
//报错
|
||||||
adb.setOnClickListener(view -> mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_ADB, true));
|
adb.setOnClickListener(view -> mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_ADB, true));
|
||||||
@@ -219,12 +216,20 @@ public class MainActivity extends ImmerseBaseActivity {
|
|||||||
bt_bc_boot.setOnClickListener(view -> CmdUtil.execute("am broadcast -a android.intent.action.BOOT_COMPLETED"));
|
bt_bc_boot.setOnClickListener(view -> CmdUtil.execute("am broadcast -a android.intent.action.BOOT_COMPLETED"));
|
||||||
|
|
||||||
bt_start_jgy.setOnClickListener(view -> {
|
bt_start_jgy.setOnClickListener(view -> {
|
||||||
JGYUtils.getInstance().wakeUpAppstore();
|
JgyUtils.getInstance().wakeUpAppstore();
|
||||||
JGYUtils.getInstance().wakeUpDeviceInfo();
|
JgyUtils.getInstance().wakeUpDeviceInfo();
|
||||||
JGYUtils.getInstance().wakeUpNotify();
|
JgyUtils.getInstance().wakeUpNotify();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onNewIntent(Intent intent) {
|
||||||
|
super.onNewIntent(intent);
|
||||||
|
if (intent != null) {
|
||||||
|
TTUtils.getExtrax(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initData() {
|
public void initData() {
|
||||||
startService(new Intent(MainActivity.this, MainService.class));
|
startService(new Intent(MainActivity.this, MainService.class));
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.ttstd.ttutils.activity.retrofit;
|
package com.ttstd.ttutils.activity.retrofit;
|
||||||
|
|
||||||
import com.ttstd.ttutils.R;
|
import com.ttstd.ttutils.R;
|
||||||
import com.ttstd.ttutils.base.BaseActivity;
|
import com.ttstd.ttutils.base.mvvm.BaseMvvmActivity;
|
||||||
|
|
||||||
public class RetrofitActivity extends BaseActivity implements RetrofitContact.MainView {
|
public class RetrofitActivity extends BaseMvvmActivity implements RetrofitContact.MainView {
|
||||||
private RetrofitPresenter mRetrofitPresenter;
|
private RetrofitPresenter mRetrofitPresenter;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -11,12 +11,20 @@ public class RetrofitActivity extends BaseActivity implements RetrofitContact.Ma
|
|||||||
return R.layout.activity_retrofit;
|
return R.layout.activity_retrofit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initDataBinding() {
|
||||||
|
// mViewModel.setCtx(this);
|
||||||
|
// mViewModel.setVDBinding(mViewDataBinding);
|
||||||
|
// mViewModel.setLifecycle(getLifecycleSubject());
|
||||||
|
// mViewDataBinding.setClick(new BtnClick());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initView() {
|
public void initView() {
|
||||||
mRetrofitPresenter = new RetrofitPresenter(this);
|
mRetrofitPresenter = new RetrofitPresenter(this);
|
||||||
mRetrofitPresenter.attachView(this);
|
mRetrofitPresenter.attachView(this);
|
||||||
mRetrofitPresenter.setProvider(this);
|
mRetrofitPresenter.setProvider(this);
|
||||||
mRetrofitPresenter.setLifecycle(lifecycleSubject);
|
mRetrofitPresenter.setLifecycle(getLifecycleSubject());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
|||||||
* @author jgy02
|
* @author jgy02
|
||||||
*/
|
*/
|
||||||
public class RetrofitPresenter implements RetrofitContact.Presenter {
|
public class RetrofitPresenter implements RetrofitContact.Presenter {
|
||||||
private static final String TAG = RetrofitPresenter.class.getSimpleName();
|
private static final String TAG = "RetrofitPresenter";
|
||||||
private RetrofitContact.MainView mView;
|
private RetrofitContact.MainView mView;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import android.os.Bundle;
|
|||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
|
||||||
import com.ttstd.ttutils.R;
|
import com.ttstd.ttutils.R;
|
||||||
|
import com.ttstd.ttutils.base.BaseDataBindingActivity;
|
||||||
|
import com.ttstd.ttutils.base.mvvm.BaseMvvmActivity;
|
||||||
import com.ttstd.ttutils.utils.java.TTUtils;
|
import com.ttstd.ttutils.utils.java.TTUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -18,8 +20,8 @@ import java.util.List;
|
|||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
public class TestActivity extends AppCompatActivity {
|
public class TestActivity extends BaseMvvmActivity {
|
||||||
private String TAG = TestActivity.class.getSimpleName();
|
private String TAG = "TestActivity";
|
||||||
|
|
||||||
@BindView(R.id.bt1)
|
@BindView(R.id.bt1)
|
||||||
Button bt1;
|
Button bt1;
|
||||||
@@ -29,9 +31,20 @@ public class TestActivity extends AppCompatActivity {
|
|||||||
Button bt3;
|
Button bt3;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected int getLayoutId() {
|
||||||
super.onCreate(savedInstanceState);
|
return R.layout.activity_test;
|
||||||
setContentView(R.layout.activity_test);
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initDataBinding() {
|
||||||
|
// mViewModel.setCtx(this);
|
||||||
|
// mViewModel.setVDBinding(mViewDataBinding);
|
||||||
|
// mViewModel.setLifecycle(getLifecycleSubject());
|
||||||
|
// mViewDataBinding.setClick(new BtnClick());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initView() {
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
@@ -42,6 +55,11 @@ public class TestActivity extends AppCompatActivity {
|
|||||||
bt3.setOnClickListener(view -> setDefault("com.aoleyun.os"));
|
bt3.setOnClickListener(view -> setDefault("com.aoleyun.os"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initData() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNewIntent(Intent intent) {
|
protected void onNewIntent(Intent intent) {
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import android.os.Handler;
|
|||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.multidex.MultiDex;
|
||||||
|
|
||||||
|
import com.hjq.toast.Toaster;
|
||||||
import com.tencent.android.tpush.XGIOperateCallback;
|
import com.tencent.android.tpush.XGIOperateCallback;
|
||||||
import com.tencent.android.tpush.XGPushConfig;
|
import com.tencent.android.tpush.XGPushConfig;
|
||||||
import com.tencent.android.tpush.XGPushManager;
|
import com.tencent.android.tpush.XGPushManager;
|
||||||
@@ -14,9 +17,12 @@ public class BaseApplication extends Application {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
|
||||||
|
MultiDex.install(this);
|
||||||
if (!BuildConfig.DEBUG) {
|
if (!BuildConfig.DEBUG) {
|
||||||
catchException();
|
catchException();
|
||||||
}
|
}
|
||||||
|
Toaster.init(this);
|
||||||
XGPushConfig.enableDebug(this, true);
|
XGPushConfig.enableDebug(this, true);
|
||||||
XGPushManager.registerPush(this, new XGIOperateCallback() {
|
XGPushManager.registerPush(this, new XGIOperateCallback() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package com.ttstd.ttutils.base;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.annotation.CallSuper;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.ttstd.ttutils.R;
|
||||||
|
import com.ttstd.ttutils.base.rx.BaseRxActivity;
|
||||||
|
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||||
|
|
||||||
|
public abstract class BaseDataBindingActivity extends BaseRxActivity {
|
||||||
|
|
||||||
|
public BaseDataBindingActivity() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CallSuper
|
||||||
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
// StatusBarUtil.init(this);
|
||||||
|
UltimateBarX.statusBar(this)
|
||||||
|
.transparent()
|
||||||
|
.colorRes(R.color.colorPrimaryDark)
|
||||||
|
.light(setNightMode())
|
||||||
|
.fitWindow(setfitWindow())
|
||||||
|
.apply();
|
||||||
|
UltimateBarX.navigationBar(this)
|
||||||
|
.transparent()
|
||||||
|
.colorRes(R.color.colorPrimaryDark)
|
||||||
|
.light(setNightMode())
|
||||||
|
.fitWindow(setfitWindow())
|
||||||
|
.apply();
|
||||||
|
initDataBinding();
|
||||||
|
initView();
|
||||||
|
initData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 是否是黑色状态栏
|
||||||
|
*/
|
||||||
|
// protected abstract boolean setNightMode();
|
||||||
|
public boolean setNightMode() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 是否是入侵
|
||||||
|
*/
|
||||||
|
// protected abstract boolean setNightMode();
|
||||||
|
public boolean setfitWindow() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected abstract void initDataBinding();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化视图
|
||||||
|
*/
|
||||||
|
protected abstract void initView();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化数据
|
||||||
|
*/
|
||||||
|
protected abstract void initData();
|
||||||
|
}
|
||||||
@@ -1,114 +1,44 @@
|
|||||||
package com.ttstd.ttutils.base;
|
package com.ttstd.ttutils.base;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import androidx.annotation.CheckResult;
|
import com.ttstd.ttutils.base.rx.BaseRxFragment;
|
||||||
import androidx.annotation.ContentView;
|
|
||||||
import androidx.annotation.LayoutRes;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
|
|
||||||
import com.trello.rxlifecycle4.LifecycleProvider;
|
public abstract class BaseFragment extends BaseRxFragment {
|
||||||
import com.trello.rxlifecycle4.LifecycleTransformer;
|
|
||||||
import com.trello.rxlifecycle4.RxLifecycle;
|
|
||||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
|
||||||
import com.trello.rxlifecycle4.android.RxLifecycleAndroid;
|
|
||||||
|
|
||||||
import io.reactivex.rxjava3.core.Observable;
|
protected boolean isViewInitiated;
|
||||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
protected boolean isVisibleToUser;
|
||||||
|
protected boolean isDataInitiated;
|
||||||
|
|
||||||
public class BaseFragment extends Fragment implements LifecycleProvider<FragmentEvent> {
|
|
||||||
private final BehaviorSubject<FragmentEvent> lifecycleSubject = BehaviorSubject.create();
|
|
||||||
|
|
||||||
public BaseFragment() {
|
@Override
|
||||||
super();
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
}
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
isViewInitiated = true;
|
||||||
@ContentView
|
prepareFetchData();
|
||||||
public BaseFragment(@LayoutRes int contentLayoutId) {
|
|
||||||
super(contentLayoutId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NonNull
|
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||||
@CheckResult
|
super.setUserVisibleHint(isVisibleToUser);
|
||||||
public final Observable<FragmentEvent> lifecycle() {
|
this.isVisibleToUser = isVisibleToUser;
|
||||||
return lifecycleSubject.hide();
|
prepareFetchData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public abstract void fetchData();
|
||||||
@NonNull
|
|
||||||
@CheckResult
|
public boolean prepareFetchData() {
|
||||||
public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull FragmentEvent event) {
|
return prepareFetchData(false);
|
||||||
return RxLifecycle.bindUntilEvent(lifecycleSubject, event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public boolean prepareFetchData(boolean forceUpdate) {
|
||||||
@NonNull
|
if (isVisibleToUser && isViewInitiated && (!isDataInitiated || forceUpdate)) {
|
||||||
@CheckResult
|
fetchData();
|
||||||
public final <T> LifecycleTransformer<T> bindToLifecycle() {
|
//注释掉保证每次都更新数据
|
||||||
return RxLifecycleAndroid.bindFragment(lifecycleSubject);
|
// isDataInitiated = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttach(android.app.Activity activity) {
|
|
||||||
super.onAttach(activity);
|
|
||||||
lifecycleSubject.onNext(FragmentEvent.ATTACH);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
lifecycleSubject.onNext(FragmentEvent.CREATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
|
||||||
super.onViewCreated(view, savedInstanceState);
|
|
||||||
lifecycleSubject.onNext(FragmentEvent.CREATE_VIEW);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart() {
|
|
||||||
super.onStart();
|
|
||||||
lifecycleSubject.onNext(FragmentEvent.START);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
lifecycleSubject.onNext(FragmentEvent.RESUME);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
lifecycleSubject.onNext(FragmentEvent.PAUSE);
|
|
||||||
super.onPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStop() {
|
|
||||||
lifecycleSubject.onNext(FragmentEvent.STOP);
|
|
||||||
super.onStop();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroyView() {
|
|
||||||
lifecycleSubject.onNext(FragmentEvent.DESTROY_VIEW);
|
|
||||||
super.onDestroyView();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
lifecycleSubject.onNext(FragmentEvent.DESTROY);
|
|
||||||
super.onDestroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDetach() {
|
|
||||||
lifecycleSubject.onNext(FragmentEvent.DETACH);
|
|
||||||
super.onDetach();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package com.ttstd.ttutils.base;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.annotation.CallSuper;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.ttstd.ttutils.R;
|
||||||
|
import com.ttstd.ttutils.base.rx.BaseRxActivity;
|
||||||
|
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||||
|
|
||||||
|
public abstract class BaseTransparentActivity extends BaseRxActivity {
|
||||||
|
|
||||||
|
public BaseTransparentActivity() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CallSuper
|
||||||
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
// StatusBarUtil.init(this);
|
||||||
|
UltimateBarX.statusBar(this)
|
||||||
|
.transparent()
|
||||||
|
.colorRes(R.color.colorPrimaryDark)
|
||||||
|
.light(setNightMode())
|
||||||
|
.fitWindow(setfitWindow())
|
||||||
|
.apply();
|
||||||
|
UltimateBarX.navigationBar(this)
|
||||||
|
.transparent()
|
||||||
|
.colorRes(R.color.colorPrimaryDark)
|
||||||
|
.light(setNightMode())
|
||||||
|
.fitWindow(setfitWindow())
|
||||||
|
.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置布局
|
||||||
|
*/
|
||||||
|
protected abstract int getLayoutId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 是否是黑色状态栏
|
||||||
|
*/
|
||||||
|
// protected abstract boolean setNightMode();
|
||||||
|
public boolean setNightMode() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 是否是入侵
|
||||||
|
*/
|
||||||
|
// protected abstract boolean setNightMode();
|
||||||
|
public boolean setfitWindow() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
package com.ttstd.ttutils.base;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.ttstd.ttutils.R;
|
|
||||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
|
||||||
|
|
||||||
public abstract class ImmerseBaseActivity extends BaseActivity {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
// StatusBarUtil.init(this);
|
|
||||||
UltimateBarX.statusBar(this)
|
|
||||||
.transparent()
|
|
||||||
.colorRes(R.color.colorPrimaryDark)
|
|
||||||
.light(true)
|
|
||||||
.apply();
|
|
||||||
UltimateBarX.navigationBar(this)
|
|
||||||
.transparent()
|
|
||||||
.colorRes(R.color.colorPrimaryDark)
|
|
||||||
.light(true)
|
|
||||||
.apply();
|
|
||||||
//状态栏改变放在setContentView前后有所不同
|
|
||||||
setContentView(this.getLayoutId());
|
|
||||||
initView();
|
|
||||||
setListener();
|
|
||||||
initData();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置布局
|
|
||||||
*/
|
|
||||||
public abstract int getLayoutId();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化视图
|
|
||||||
*/
|
|
||||||
public abstract void initView();
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public abstract void setListener();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化数据
|
|
||||||
*/
|
|
||||||
public abstract void initData();
|
|
||||||
}
|
|
||||||
@@ -4,13 +4,15 @@ import android.app.Application
|
|||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import androidx.multidex.MultiDex
|
||||||
|
import com.hjq.toast.Toaster
|
||||||
import com.tencent.android.tpush.XGIOperateCallback
|
import com.tencent.android.tpush.XGIOperateCallback
|
||||||
import com.tencent.android.tpush.XGPushConfig
|
import com.tencent.android.tpush.XGPushConfig
|
||||||
import com.tencent.android.tpush.XGPushManager
|
import com.tencent.android.tpush.XGPushManager
|
||||||
import com.tencent.bugly.crashreport.CrashReport
|
import com.tencent.bugly.crashreport.CrashReport
|
||||||
import com.tencent.mmkv.MMKV
|
import com.tencent.mmkv.MMKV
|
||||||
import com.ttstd.ttutils.BuildConfig
|
import com.ttstd.ttutils.BuildConfig
|
||||||
import com.ttstd.ttutils.utils.java.JGYUtils
|
import com.ttstd.ttutils.utils.java.JgyUtils
|
||||||
import com.ttstd.ttutils.utils.java.TTUtils
|
import com.ttstd.ttutils.utils.java.TTUtils
|
||||||
import com.ttstd.ttutils.utils.java.ToastUtil
|
import com.ttstd.ttutils.utils.java.ToastUtil
|
||||||
|
|
||||||
@@ -19,12 +21,15 @@ class KotlinApplication : Application() {
|
|||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
|
MultiDex.install(this)
|
||||||
|
|
||||||
val rootDir = MMKV.initialize(this)
|
val rootDir = MMKV.initialize(this)
|
||||||
Log.e("KotlinApplication", "mmkv root: $rootDir")
|
Log.e("KotlinApplication", "mmkv root: $rootDir")
|
||||||
|
|
||||||
ToastUtil.init(this)
|
ToastUtil.init(this)
|
||||||
|
Toaster.init(this)
|
||||||
TTUtils.init(this)
|
TTUtils.init(this)
|
||||||
JGYUtils.init(this)
|
JgyUtils.init(this)
|
||||||
CrashReport.initCrashReport(getApplicationContext(), "注册时申请的APPID", false);
|
CrashReport.initCrashReport(getApplicationContext(), "注册时申请的APPID", false);
|
||||||
|
|
||||||
XGPushConfig.enableDebug(this, true)
|
XGPushConfig.enableDebug(this, true)
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.ttstd.ttutils.base.mvp;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.annotation.CallSuper;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.ttstd.ttutils.base.BaseTransparentActivity;
|
||||||
|
|
||||||
|
public abstract class BaseMvpActivity extends BaseTransparentActivity {
|
||||||
|
|
||||||
|
public BaseMvpActivity() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CallSuper
|
||||||
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(getLayoutId());
|
||||||
|
initView();
|
||||||
|
initData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化视图
|
||||||
|
*/
|
||||||
|
protected abstract void initView();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化数据
|
||||||
|
*/
|
||||||
|
protected abstract void initData();
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.ttstd.ttutils.base.mvp;
|
||||||
|
|
||||||
|
public interface BasePresenter<V extends BaseView> {
|
||||||
|
void attachView(V view);
|
||||||
|
|
||||||
|
void detachView();
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.ttstd.ttutils.base.mvp;
|
||||||
|
|
||||||
|
public interface BaseView {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.ttstd.ttutils.base.mvvm;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.databinding.DataBindingUtil;
|
||||||
|
import androidx.databinding.ViewDataBinding;
|
||||||
|
import androidx.lifecycle.ViewModel;
|
||||||
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
|
||||||
|
import com.ttstd.ttutils.base.BaseTransparentActivity;
|
||||||
|
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.lang.reflect.ParameterizedType;
|
||||||
|
|
||||||
|
public abstract class BaseMvvmActivity<VM extends ViewModel, VDB extends ViewDataBinding> extends BaseTransparentActivity {
|
||||||
|
|
||||||
|
private static final String TAG = "BaseMvvmActivity";
|
||||||
|
|
||||||
|
protected VM mViewModel;
|
||||||
|
protected VDB mViewDataBinding;
|
||||||
|
protected Class<VM> vmClass;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
//ViewDataBinding
|
||||||
|
mViewDataBinding = DataBindingUtil.setContentView(this, getLayoutId());
|
||||||
|
mViewDataBinding.setLifecycleOwner(this);
|
||||||
|
//ViewModel
|
||||||
|
vmClass = (Class<VM>) ((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments()[0];
|
||||||
|
boolean isAbstract = Modifier.isAbstract(vmClass.getModifiers());
|
||||||
|
Log.e(TAG, "isLocalClass:" + vmClass.getSimpleName().equals("ViewModel") + " isAbstract:" + isAbstract);
|
||||||
|
if (!isAbstract) {//不是一个抽象类
|
||||||
|
mViewModel = new ViewModelProvider(this).get(vmClass);
|
||||||
|
}
|
||||||
|
initDataBinding();
|
||||||
|
initView();
|
||||||
|
initData();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void initDataBinding();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化视图
|
||||||
|
*/
|
||||||
|
protected abstract void initView();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化数据
|
||||||
|
*/
|
||||||
|
protected abstract void initData();
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package com.ttstd.ttutils.base.mvvm;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.databinding.ViewDataBinding;
|
||||||
|
import androidx.lifecycle.ViewModel;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
|
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所有viewmodel的基类
|
||||||
|
*/
|
||||||
|
public abstract class BaseViewModel<VDB extends ViewDataBinding, T> extends ViewModel implements ViewDataBindingCallback {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前viewmodel对应的页面binding
|
||||||
|
*/
|
||||||
|
protected VDB binding;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setVDBinding(ViewDataBinding vdBinding) {
|
||||||
|
|
||||||
|
binding = (VDB) vdBinding;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VDB getVDBinding() {
|
||||||
|
if (binding == null) {
|
||||||
|
throw new NullPointerException("BaseViewModel >> getVDBinding >> null!!!");
|
||||||
|
}
|
||||||
|
return binding;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上下文
|
||||||
|
*/
|
||||||
|
private WeakReference<Context> ctx;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCtx(Context context) {
|
||||||
|
if (ctx == null) {
|
||||||
|
ctx = new WeakReference<>(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Context getCtx() {
|
||||||
|
if (ctx == null) {
|
||||||
|
throw new NullPointerException("BaseViewModel >> getCtx >> null!!!");
|
||||||
|
}
|
||||||
|
return ctx.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public abstract void onDestroy();
|
||||||
|
|
||||||
|
private BehaviorSubject<T> mBehaviorSubject;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLifecycle(BehaviorSubject subject) {
|
||||||
|
this.mBehaviorSubject = (BehaviorSubject<T>) subject;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BehaviorSubject<T> getLifecycle() {
|
||||||
|
return mBehaviorSubject;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.ttstd.ttutils.base.mvvm;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.databinding.ViewDataBinding;
|
||||||
|
|
||||||
|
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||||
|
|
||||||
|
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||||
|
|
||||||
|
public interface ViewDataBindingCallback<VDB extends ViewDataBinding> {
|
||||||
|
|
||||||
|
|
||||||
|
void setVDBinding(VDB binding);
|
||||||
|
|
||||||
|
VDB getVDBinding() throws NullPointerException;
|
||||||
|
|
||||||
|
|
||||||
|
void setCtx(Context context);
|
||||||
|
|
||||||
|
Context getCtx() throws NullPointerException;
|
||||||
|
|
||||||
|
void setLifecycle(BehaviorSubject<ActivityEvent> subject);
|
||||||
|
|
||||||
|
BehaviorSubject<ActivityEvent> getLifecycle();
|
||||||
|
}
|
||||||
@@ -0,0 +1,275 @@
|
|||||||
|
package com.ttstd.ttutils.base.mvvm.fragment;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
|
import androidx.annotation.LayoutRes;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.databinding.DataBindingUtil;
|
||||||
|
import androidx.databinding.ViewDataBinding;
|
||||||
|
import androidx.lifecycle.ViewModel;
|
||||||
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
|
||||||
|
import com.ttstd.ttutils.base.BaseFragment;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
|
import java.lang.reflect.ParameterizedType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: lml
|
||||||
|
* @date: 2021/12/15
|
||||||
|
*/
|
||||||
|
public abstract class BaseMvvmFragment<VM extends ViewModel, VDB extends ViewDataBinding> extends BaseFragment {
|
||||||
|
protected String mTag = this.getClass().getSimpleName();
|
||||||
|
/**
|
||||||
|
* 是否顯示了
|
||||||
|
*/
|
||||||
|
protected boolean mIsVisible;
|
||||||
|
/**
|
||||||
|
* 是否準備好了-Created
|
||||||
|
*/
|
||||||
|
protected boolean mHasPrepare;
|
||||||
|
|
||||||
|
|
||||||
|
protected VM mViewModel;
|
||||||
|
protected VDB mViewDataBinding;
|
||||||
|
protected Class<VM> vmClass;
|
||||||
|
//
|
||||||
|
// protected Toolbar toolbar;
|
||||||
|
// protected View statusBarView;
|
||||||
|
//
|
||||||
|
protected Bundle bundle;//来自getArguments()
|
||||||
|
protected Bundle savedInstanceState;
|
||||||
|
|
||||||
|
// protected Context context;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上下文
|
||||||
|
*/
|
||||||
|
private WeakReference<Context> ctx;
|
||||||
|
|
||||||
|
public Context getCtx() {
|
||||||
|
return ctx == null ? null : ctx.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(@NonNull Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
// this.context = context;
|
||||||
|
ctx = new WeakReference<>(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* onCreate、onResume里不能调用
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isAttached() {
|
||||||
|
boolean flag = getCtx() != null && isAdded();
|
||||||
|
Log.e(" >> isAttached >>", "flag = " + flag);
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
//ViewDataBinding
|
||||||
|
mViewDataBinding = DataBindingUtil.inflate(inflater, getLayoutId(), container, false);
|
||||||
|
mViewDataBinding.setLifecycleOwner(this);
|
||||||
|
|
||||||
|
//ViewModel
|
||||||
|
vmClass = (Class<VM>) ((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments()[0];
|
||||||
|
mViewModel = new ViewModelProvider(this).get(vmClass);
|
||||||
|
//
|
||||||
|
return mViewDataBinding.getRoot();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
|
||||||
|
// if (initStatusBarToolBar()) {
|
||||||
|
// toolbar = getToolbar();
|
||||||
|
// }
|
||||||
|
//注册eventbus
|
||||||
|
// if (getClass().isAnnotationPresent(BindEventBus.class))
|
||||||
|
// EventBusManager.register(this);
|
||||||
|
//
|
||||||
|
|
||||||
|
// fitsLayoutOverlap();
|
||||||
|
initDataBinding();
|
||||||
|
initView(bundle = getArguments());
|
||||||
|
//
|
||||||
|
initData(this.savedInstanceState = savedInstanceState);
|
||||||
|
//
|
||||||
|
if (mIsVisible) {
|
||||||
|
onEnter();
|
||||||
|
}
|
||||||
|
mHasPrepare = true;
|
||||||
|
//
|
||||||
|
// LiveDataBus.get().with(ConstantUtils.DATA_BUS_LOADING_FRAGMENT, Boolean.class).observe(getActivity(), bool -> {
|
||||||
|
// L.e(" >> LiveDataBus >> DATA_BUS_LOADING_FRAGMENT: %s", bool);
|
||||||
|
// if(bool) {
|
||||||
|
// showLoading(R.string.str_please_wait);
|
||||||
|
// } else {
|
||||||
|
// hideLoading();
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
mHasPrepare = false;
|
||||||
|
mViewDataBinding = null;
|
||||||
|
//移除eventbus
|
||||||
|
// if (getClass().isAnnotationPresent(BindEventBus.class))
|
||||||
|
// EventBusManager.unregister(this);
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||||
|
super.setUserVisibleHint(isVisibleToUser);
|
||||||
|
if (mIsVisible == getUserVisibleHint())
|
||||||
|
return;
|
||||||
|
mIsVisible = getUserVisibleHint();
|
||||||
|
if (mIsVisible) {
|
||||||
|
if (!mHasPrepare)
|
||||||
|
return;
|
||||||
|
onEnter();
|
||||||
|
} else {
|
||||||
|
onExit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@LayoutRes
|
||||||
|
protected abstract int getLayoutId();
|
||||||
|
|
||||||
|
// protected abstract Toolbar getToolbar();
|
||||||
|
|
||||||
|
// protected View getStatusView() {
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
|
||||||
|
protected abstract void initDataBinding();
|
||||||
|
|
||||||
|
protected abstract void initView(Bundle bundle);
|
||||||
|
|
||||||
|
protected abstract void initData(Bundle savedInstanceState);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
|
super.onConfigurationChanged(newConfig);
|
||||||
|
// fitsLayoutOverlap();
|
||||||
|
}
|
||||||
|
|
||||||
|
// protected boolean isImmersionBarEnabled() {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// protected boolean initStatusBarToolBar() {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// private void fitsLayoutOverlap() {
|
||||||
|
// if (!isImmersionBarEnabled()) return;
|
||||||
|
// if (statusBarView != null) {
|
||||||
|
// ImmersionBar.setStatusBarView(getActivity(), statusBarView);
|
||||||
|
// }
|
||||||
|
// if (toolbar != null) {
|
||||||
|
// ImmersionBar.setTitleBar(getActivity(), toolbar);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
protected void hideInputMethod(Activity activity) {
|
||||||
|
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
|
||||||
|
View view = activity.getCurrentFocus();
|
||||||
|
if (view != null) {
|
||||||
|
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void hideInputMethod(Activity activity, EditText editText) {
|
||||||
|
InputMethodManager imm = (InputMethodManager) editText.getContext().getSystemService(Activity.INPUT_METHOD_SERVICE);
|
||||||
|
View view = activity.getCurrentFocus();
|
||||||
|
if (view != null) {
|
||||||
|
imm.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void showInputMethod(EditText editText) {
|
||||||
|
InputMethodManager imm = (InputMethodManager) editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
imm.showSoftInput(editText, InputMethodManager.SHOW_FORCED);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// private CustomDialog mWaitDialog;
|
||||||
|
//
|
||||||
|
// public void showLoading(@StringRes int contentID) {
|
||||||
|
// showLoading(contentID, R.color.white);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void showLoading(@StringRes int contentID, @ColorRes int color) {
|
||||||
|
// hideLoading();
|
||||||
|
// DialogX.init(getActivity());
|
||||||
|
// if (color == R.color.white) {
|
||||||
|
// mWaitDialog = DialogXUtil.getInstance().showLoading(getActivity(), getString(contentID), getResources().getColor(color));
|
||||||
|
// } else {
|
||||||
|
// mWaitDialog = DialogXUtil.getInstance().showLoading_black(getActivity(), getString(contentID), getResources().getColor(color));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void updateLoadingTip(@StringRes int messageID, int percent) {
|
||||||
|
// try {
|
||||||
|
// if (mWaitDialog != null && mWaitDialog.isShow()) {
|
||||||
|
// TextView tvTip = mWaitDialog.getCustomView().findViewById(R.id.tv_load_tip);
|
||||||
|
// if (tvTip != null)
|
||||||
|
// tvTip.setText(getResources().getString(messageID) + (percent == -1 ? "" : percent + "%"));
|
||||||
|
// }
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public boolean isShowLoading() {
|
||||||
|
// return mWaitDialog != null && mWaitDialog.isShow();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void hideLoading() {
|
||||||
|
// try {
|
||||||
|
// boolean isShow = isShowLoading();
|
||||||
|
// L.d(" >> hideLoading :: isShow: %s", isShow);
|
||||||
|
// if (isShow)
|
||||||
|
// mWaitDialog.dismiss();
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 進入界面
|
||||||
|
*/
|
||||||
|
protected void onEnter() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 離開界面
|
||||||
|
*/
|
||||||
|
protected void onExit() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
package com.ttstd.ttutils.base.old;
|
|
||||||
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.Window;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
|
|
||||||
public abstract class BaseActivity1 extends AppCompatActivity {
|
|
||||||
private static Handler sHandler;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
|
||||||
setContentView(setLayoutResourceID());
|
|
||||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
||||||
sHandler = new Handler();
|
|
||||||
sHandler.post(mHideRunnable); // hide the navigation bar
|
|
||||||
final View decorView = getWindow().getDecorView();
|
|
||||||
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onSystemUiVisibilityChange(int visibility) {
|
|
||||||
if (visibility == View.SYSTEM_UI_FLAG_VISIBLE) {
|
|
||||||
sHandler.postDelayed(mHideRunnable, 3000); // hide the navigation bar
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
initView();
|
|
||||||
initData();
|
|
||||||
setListener();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected abstract int setLayoutResourceID();
|
|
||||||
|
|
||||||
protected abstract void initView();
|
|
||||||
|
|
||||||
|
|
||||||
protected void setListener() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected abstract void initData();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onWindowFocusChanged(boolean hasFocus) {
|
|
||||||
super.onWindowFocusChanged(hasFocus);
|
|
||||||
if (hasFocus) {
|
|
||||||
// initViewFull(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// public static void initViewFull(final Activity activity) {
|
|
||||||
// activity.getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
|
|
||||||
// @Override
|
|
||||||
// public void onSystemUiVisibilityChange(int visibility) {
|
|
||||||
// new Thread() {
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
// super.run();
|
|
||||||
// try {
|
|
||||||
// Thread.sleep(3000);
|
|
||||||
// } catch (InterruptedException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// activity.runOnUiThread(new Runnable() {
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
// initViewFull(activity);
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }.start();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// // //设置无标题
|
|
||||||
// activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
|
||||||
// WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
||||||
// activity.getWindow().getDecorView().setSystemUiVisibility(
|
|
||||||
// View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
|
||||||
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
|
||||||
// | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
|
||||||
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
|
|
||||||
// | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
|
|
||||||
// | View.SYSTEM_UI_FLAG_IMMERSIVE);
|
|
||||||
// }
|
|
||||||
|
|
||||||
Runnable mHideRunnable = new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
int flags;
|
|
||||||
int curApiVersion = Build.VERSION.SDK_INT;
|
|
||||||
// This work only for android 4.4+
|
|
||||||
if (curApiVersion >= Build.VERSION_CODES.KITKAT) {
|
|
||||||
// This work only for android 4.4+
|
|
||||||
// hide navigation bar permanently in android activity
|
|
||||||
// touch the screen, the navigation bar will not show
|
|
||||||
flags =
|
|
||||||
// View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
|
||||||
// | View.SYSTEM_UI_FLAG_IMMERSIVE
|
|
||||||
// | View.SYSTEM_UI_FLAG_FULLSCREEN;
|
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
|
||||||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
|
||||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
|
||||||
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
|
|
||||||
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
|
|
||||||
| View.SYSTEM_UI_FLAG_IMMERSIVE;
|
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
|
|
||||||
} else {
|
|
||||||
// touch the screen, the navigation bar will show
|
|
||||||
flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
|
||||||
}
|
|
||||||
// must be executed in main thread
|
|
||||||
|
|
||||||
getWindow().getDecorView().setSystemUiVisibility(flags);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
+10
-45
@@ -1,11 +1,9 @@
|
|||||||
package com.ttstd.ttutils.base;
|
package com.ttstd.ttutils.base.rx;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.annotation.CallSuper;
|
import androidx.annotation.CallSuper;
|
||||||
import androidx.annotation.CheckResult;
|
import androidx.annotation.CheckResult;
|
||||||
import androidx.annotation.ContentView;
|
|
||||||
import androidx.annotation.LayoutRes;
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
@@ -15,23 +13,19 @@ import com.trello.rxlifecycle4.LifecycleTransformer;
|
|||||||
import com.trello.rxlifecycle4.RxLifecycle;
|
import com.trello.rxlifecycle4.RxLifecycle;
|
||||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||||
import com.trello.rxlifecycle4.android.RxLifecycleAndroid;
|
import com.trello.rxlifecycle4.android.RxLifecycleAndroid;
|
||||||
import com.ttstd.ttutils.R;
|
|
||||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
|
||||||
|
|
||||||
import io.reactivex.rxjava3.core.Observable;
|
import io.reactivex.rxjava3.core.Observable;
|
||||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link com.trello.rxlifecycle4.components.RxActivity}
|
||||||
|
* copied form RxActivity}
|
||||||
|
*/
|
||||||
|
public abstract class BaseRxActivity extends AppCompatActivity implements LifecycleProvider<ActivityEvent> {
|
||||||
|
private final BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();
|
||||||
|
|
||||||
public abstract class BaseActivity extends AppCompatActivity implements LifecycleProvider<ActivityEvent> {
|
public BehaviorSubject<ActivityEvent> getLifecycleSubject() {
|
||||||
public final BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();
|
return lifecycleSubject;
|
||||||
|
|
||||||
public BaseActivity() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
@ContentView
|
|
||||||
public BaseActivity(@LayoutRes int contentLayoutId) {
|
|
||||||
super(contentLayoutId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -60,38 +54,8 @@ public abstract class BaseActivity extends AppCompatActivity implements Lifecycl
|
|||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
lifecycleSubject.onNext(ActivityEvent.CREATE);
|
lifecycleSubject.onNext(ActivityEvent.CREATE);
|
||||||
// StatusBarUtil.init(this);
|
|
||||||
UltimateBarX.statusBar(this)
|
|
||||||
.transparent()
|
|
||||||
.colorRes(R.color.colorPrimaryDark)
|
|
||||||
.light(true)
|
|
||||||
.apply();
|
|
||||||
UltimateBarX.navigationBar(this)
|
|
||||||
.transparent()
|
|
||||||
.colorRes(R.color.colorPrimaryDark)
|
|
||||||
.light(true)
|
|
||||||
.apply();
|
|
||||||
setContentView(this.getLayoutId());
|
|
||||||
initView();
|
|
||||||
initData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置布局
|
|
||||||
*/
|
|
||||||
public abstract int getLayoutId();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化视图
|
|
||||||
*/
|
|
||||||
public abstract void initView();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化数据
|
|
||||||
*/
|
|
||||||
public abstract void initData();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CallSuper
|
@CallSuper
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
@@ -127,3 +91,4 @@ public abstract class BaseActivity extends AppCompatActivity implements Lifecycl
|
|||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
package com.ttstd.ttutils.base.rx;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.annotation.CallSuper;
|
||||||
|
import androidx.annotation.CheckResult;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import com.trello.rxlifecycle4.LifecycleProvider;
|
||||||
|
import com.trello.rxlifecycle4.LifecycleTransformer;
|
||||||
|
import com.trello.rxlifecycle4.RxLifecycle;
|
||||||
|
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||||
|
import com.trello.rxlifecycle4.android.RxLifecycleAndroid;
|
||||||
|
|
||||||
|
import io.reactivex.rxjava3.core.Observable;
|
||||||
|
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link com.trello.rxlifecycle4.components.RxFragment}
|
||||||
|
* copied form RxFragment}
|
||||||
|
*/
|
||||||
|
public class BaseRxFragment extends Fragment implements LifecycleProvider<FragmentEvent> {
|
||||||
|
private final BehaviorSubject<FragmentEvent> lifecycleSubject = BehaviorSubject.create();
|
||||||
|
|
||||||
|
public BehaviorSubject<FragmentEvent> getLifecycleSubject() {
|
||||||
|
return lifecycleSubject;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull
|
||||||
|
@CheckResult
|
||||||
|
public final Observable<FragmentEvent> lifecycle() {
|
||||||
|
return lifecycleSubject.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull
|
||||||
|
@CheckResult
|
||||||
|
public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull FragmentEvent event) {
|
||||||
|
return RxLifecycle.bindUntilEvent(lifecycleSubject, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull
|
||||||
|
@CheckResult
|
||||||
|
public final <T> LifecycleTransformer<T> bindToLifecycle() {
|
||||||
|
return RxLifecycleAndroid.bindFragment(lifecycleSubject);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CallSuper
|
||||||
|
public void onAttach(android.app.Activity activity) {
|
||||||
|
super.onAttach(activity);
|
||||||
|
lifecycleSubject.onNext(FragmentEvent.ATTACH);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CallSuper
|
||||||
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
lifecycleSubject.onNext(FragmentEvent.CREATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CallSuper
|
||||||
|
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
lifecycleSubject.onNext(FragmentEvent.CREATE_VIEW);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CallSuper
|
||||||
|
public void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
lifecycleSubject.onNext(FragmentEvent.START);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CallSuper
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
lifecycleSubject.onNext(FragmentEvent.RESUME);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CallSuper
|
||||||
|
public void onPause() {
|
||||||
|
lifecycleSubject.onNext(FragmentEvent.PAUSE);
|
||||||
|
super.onPause();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CallSuper
|
||||||
|
public void onStop() {
|
||||||
|
lifecycleSubject.onNext(FragmentEvent.STOP);
|
||||||
|
super.onStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CallSuper
|
||||||
|
public void onDestroyView() {
|
||||||
|
lifecycleSubject.onNext(FragmentEvent.DESTROY_VIEW);
|
||||||
|
super.onDestroyView();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CallSuper
|
||||||
|
public void onDestroy() {
|
||||||
|
lifecycleSubject.onNext(FragmentEvent.DESTROY);
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CallSuper
|
||||||
|
public void onDetach() {
|
||||||
|
lifecycleSubject.onNext(FragmentEvent.DETACH);
|
||||||
|
super.onDetach();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package com.ttstd.ttutils.base.rx;
|
||||||
|
|
||||||
|
import android.app.Service;
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
|
import androidx.annotation.CheckResult;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.trello.rxlifecycle4.LifecycleProvider;
|
||||||
|
import com.trello.rxlifecycle4.LifecycleTransformer;
|
||||||
|
import com.trello.rxlifecycle4.RxLifecycle;
|
||||||
|
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||||
|
import com.trello.rxlifecycle4.android.RxLifecycleAndroid;
|
||||||
|
|
||||||
|
import io.reactivex.rxjava3.core.Observable;
|
||||||
|
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||||
|
|
||||||
|
public abstract class BaseRxService extends Service implements LifecycleProvider<ActivityEvent> {
|
||||||
|
private final BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();
|
||||||
|
|
||||||
|
public BehaviorSubject<ActivityEvent> getLifecycleSubject() {
|
||||||
|
return lifecycleSubject;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull
|
||||||
|
@CheckResult
|
||||||
|
public final Observable<ActivityEvent> lifecycle() {
|
||||||
|
return lifecycleSubject.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull
|
||||||
|
@CheckResult
|
||||||
|
public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull ActivityEvent event) {
|
||||||
|
return RxLifecycle.bindUntilEvent(lifecycleSubject, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull
|
||||||
|
@CheckResult
|
||||||
|
public final <T> LifecycleTransformer<T> bindToLifecycle() {
|
||||||
|
return RxLifecycleAndroid.bindActivity(lifecycleSubject);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate() {
|
||||||
|
super.onCreate();
|
||||||
|
lifecycleSubject.onNext(ActivityEvent.CREATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
|
return super.onStartCommand(intent, flags, startId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
lifecycleSubject.onNext(ActivityEvent.STOP);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,7 +29,7 @@ import java.io.Serializable;
|
|||||||
* 磁盘缓存帮助类
|
* 磁盘缓存帮助类
|
||||||
*/
|
*/
|
||||||
public class CacheHelper {
|
public class CacheHelper {
|
||||||
private static final String TAG = CacheHelper.class.getSimpleName();
|
private static final String TAG = "CacheHelper";
|
||||||
|
|
||||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;
|
|||||||
import retrofit2.converter.gson.GsonConverterFactory;
|
import retrofit2.converter.gson.GsonConverterFactory;
|
||||||
|
|
||||||
public class NetInterfaceManager {
|
public class NetInterfaceManager {
|
||||||
private static final String TAG = NetInterfaceManager.class.getSimpleName();
|
private static final String TAG = "NetInterfaceManager";
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
private static NetInterfaceManager INSTANCE;
|
private static NetInterfaceManager INSTANCE;
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ import okio.Buffer;
|
|||||||
* v1.0 2022-07-15 16:16:52
|
* v1.0 2022-07-15 16:16:52
|
||||||
*/
|
*/
|
||||||
public class RepeatRequestInterceptor implements Interceptor {
|
public class RepeatRequestInterceptor implements Interceptor {
|
||||||
private static final String TAG = RepeatRequestInterceptor.class.getSimpleName();
|
private static final String TAG = "RepeatRequestInterceptor";
|
||||||
|
|
||||||
private final ConcurrentHashMap<String, Long> requestIdsMap = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<String, Long> requestIdsMap = new ConcurrentHashMap<>();
|
||||||
public static final String REPEAT_REQUEST_PROTOCOL = "OKHTTP_REPEAT_REQUEST_PROTOCOL";
|
public static final String REPEAT_REQUEST_PROTOCOL = "OKHTTP_REPEAT_REQUEST_PROTOCOL";
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import okhttp3.Request;
|
|||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
public class RequestInterceptor implements Interceptor {
|
public class RequestInterceptor implements Interceptor {
|
||||||
private static final String TAG = RequestInterceptor.class.getSimpleName();
|
private static final String TAG = "RequestInterceptor";
|
||||||
|
|
||||||
private final ConcurrentHashMap<String, Long> requestIdsMap = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<String, Long> requestIdsMap = new ConcurrentHashMap<>();
|
||||||
public static final String REPEAT_REQUEST_PROTOCOL = "OKHTTP_REPEAT_REQUEST_PROTOCOL";
|
public static final String REPEAT_REQUEST_PROTOCOL = "OKHTTP_REPEAT_REQUEST_PROTOCOL";
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import android.content.Intent;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
public class BootReceiver extends BroadcastReceiver {
|
public class BootReceiver extends BroadcastReceiver {
|
||||||
private static String TAG = BootReceiver.class.getSimpleName() + ":ttutils";
|
private static String TAG = "BootReceiver" + ":ttutils";
|
||||||
public static final String BOOT_COMPLETED = "aoleyun.intent.action.BOOT_COMPLETED";
|
public static final String BOOT_COMPLETED = "aoleyun.intent.action.BOOT_COMPLETED";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import android.content.Intent;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
public class ShortcutReceiver extends BroadcastReceiver {
|
public class ShortcutReceiver extends BroadcastReceiver {
|
||||||
private static final String TAG = ShortcutReceiver.class.getSimpleName();
|
private static final String TAG = "ShortcutReceiver";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
|||||||
* @author jgy02
|
* @author jgy02
|
||||||
*/
|
*/
|
||||||
public class MainSPresenter implements MainSContact.Presenter {
|
public class MainSPresenter implements MainSContact.Presenter {
|
||||||
private static final String TAG = MainSPresenter.class.getSimpleName();
|
private static final String TAG = "MainSPresenter";
|
||||||
private MainSContact.MainView mView;
|
private MainSContact.MainView mView;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import io.reactivex.rxjava3.core.Observer;
|
|||||||
import io.reactivex.rxjava3.disposables.Disposable;
|
import io.reactivex.rxjava3.disposables.Disposable;
|
||||||
|
|
||||||
public class MainService extends Service implements MainSContact.MainView {
|
public class MainService extends Service implements MainSContact.MainView {
|
||||||
private static final String TAG = MainService.class.getSimpleName();
|
private static final String TAG = "MainService";
|
||||||
|
|
||||||
private MainSPresenter mPresenter;
|
private MainSPresenter mPresenter;
|
||||||
private UsbManager mUsbManager;
|
private UsbManager mUsbManager;
|
||||||
|
|||||||
@@ -1,19 +1,26 @@
|
|||||||
package com.ttstd.ttutils.utils.java;
|
package com.ttstd.ttutils.utils.java;
|
||||||
|
|
||||||
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.pm.IPackageDataObserver;
|
import android.content.pm.IPackageDataObserver;
|
||||||
import android.content.pm.IPackageStatsObserver;
|
import android.content.pm.IPackageStatsObserver;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageStats;
|
import android.content.pm.PackageStats;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.hjq.toast.Toaster;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class ApkUtils {
|
public class ApkUtils {
|
||||||
private static final String TAG = ApkUtils.class.getSimpleName();
|
private static final String TAG = "ApkUtils";
|
||||||
private final long MAX_WAIT_TIME = 60 * 1000;
|
private final long MAX_WAIT_TIME = 60 * 1000;
|
||||||
private final long WAIT_TIME_INCR = 10 * 1000;
|
private final long WAIT_TIME_INCR = 10 * 1000;
|
||||||
|
|
||||||
@@ -104,4 +111,78 @@ public class ApkUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean openPackage(Context context, String packageName) {
|
||||||
|
Context pkgContext = getPackageContext(context, packageName);
|
||||||
|
Intent intent = getAppOpenIntentByPackageName(context, packageName);
|
||||||
|
if (pkgContext != null && intent != null) {
|
||||||
|
pkgContext.startActivity(intent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean openPackage(Context context, String packageName, String className) {
|
||||||
|
if (TextUtils.isEmpty(className)) {
|
||||||
|
return openPackage(context, packageName);
|
||||||
|
}
|
||||||
|
ComponentName cn = new ComponentName(packageName, className);
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setComponent(cn);
|
||||||
|
intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
if (context != null) {
|
||||||
|
try {
|
||||||
|
context.startActivity(intent);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "openPackage: " + e.getMessage());
|
||||||
|
Toaster.show("打开失败");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Context getPackageContext(Context context, String packageName) {
|
||||||
|
Context pkgContext = null;
|
||||||
|
if (context.getPackageName().equals(packageName)) {
|
||||||
|
pkgContext = context;
|
||||||
|
} else {
|
||||||
|
// 创建第三方应用的上下文环境
|
||||||
|
try {
|
||||||
|
pkgContext = context.createPackageContext(packageName,
|
||||||
|
Context.CONTEXT_IGNORE_SECURITY
|
||||||
|
| Context.CONTEXT_INCLUDE_CODE);
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pkgContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Intent getAppOpenIntentByPackageName(Context context, String packageName) {
|
||||||
|
//Activity完整名
|
||||||
|
String mainAct = null;
|
||||||
|
//根据包名寻找
|
||||||
|
PackageManager pkgMag = context.getPackageManager();
|
||||||
|
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||||
|
intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
|
||||||
|
List<ResolveInfo> list = pkgMag.queryIntentActivities(intent,
|
||||||
|
PackageManager.GET_ACTIVITIES);
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
ResolveInfo info = list.get(i);
|
||||||
|
if (info.activityInfo.packageName.equals(packageName)) {
|
||||||
|
mainAct = info.activityInfo.name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (TextUtils.isEmpty(mainAct)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
intent.setComponent(new ComponentName(packageName, mainAct));
|
||||||
|
return intent;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.ttstd.ttutils.utils.java;
|
package com.ttstd.ttutils.utils.java;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -38,6 +39,24 @@ public class DevicesUtils {
|
|||||||
return serial;
|
return serial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint({"NewApi"})
|
||||||
|
public String getBuildSerial() {
|
||||||
|
String serial = "";
|
||||||
|
if (Build.VERSION.SDK_INT >= 28) {
|
||||||
|
try {
|
||||||
|
Class<?> c = Class.forName("android.os.SystemProperties");
|
||||||
|
Method get = c.getMethod("get", String.class);
|
||||||
|
serial = (String)get.invoke(c, "ro.serialno");
|
||||||
|
} catch (Exception var4) {
|
||||||
|
var4.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
serial = Build.SERIAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return serial;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getDeviceSN() {
|
public static String getDeviceSN() {
|
||||||
String serial = null;
|
String serial = null;
|
||||||
try {
|
try {
|
||||||
|
|||||||
+18
-12
@@ -13,11 +13,11 @@ import com.ttstd.ttutils.BuildConfig;
|
|||||||
import com.ttstd.ttutils.disklrucache.CacheHelper;
|
import com.ttstd.ttutils.disklrucache.CacheHelper;
|
||||||
import com.ttstd.ttutils.receiver.BootReceiver;
|
import com.ttstd.ttutils.receiver.BootReceiver;
|
||||||
|
|
||||||
public class JGYUtils {
|
public class JgyUtils {
|
||||||
private static final String TAG = JGYUtils.class.getSimpleName();
|
private static final String TAG = "JgyUtils";
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
private static JGYUtils sInstance;
|
private static JgyUtils sInstance;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private ContentResolver crv;
|
private ContentResolver crv;
|
||||||
private CacheHelper cacheHelper;
|
private CacheHelper cacheHelper;
|
||||||
@@ -32,6 +32,7 @@ public class JGYUtils {
|
|||||||
public static final int UnknowPlatform = 0;
|
public static final int UnknowPlatform = 0;
|
||||||
public static final int AH6016Platform = 9;
|
public static final int AH6016Platform = 9;
|
||||||
public static final int TeclastP20sPlatform = 11;
|
public static final int TeclastP20sPlatform = 11;
|
||||||
|
public static final int U1302Platform = 26;
|
||||||
|
|
||||||
|
|
||||||
public static final String MTKTag = "MTK";
|
public static final String MTKTag = "MTK";
|
||||||
@@ -42,9 +43,10 @@ public class JGYUtils {
|
|||||||
public static final String G13Tag = "G13";
|
public static final String G13Tag = "G13";
|
||||||
public static final String AH6016Tag = "AH6016";
|
public static final String AH6016Tag = "AH6016";
|
||||||
public static final String TeclastP20sTag = "P20S";
|
public static final String TeclastP20sTag = "P20S";
|
||||||
|
public static final String allwinner_U1302 = "QZA15";
|
||||||
|
|
||||||
|
|
||||||
private JGYUtils(Context context) {
|
private JgyUtils(Context context) {
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
throw new RuntimeException("Context is NULL");
|
throw new RuntimeException("Context is NULL");
|
||||||
}
|
}
|
||||||
@@ -56,13 +58,13 @@ public class JGYUtils {
|
|||||||
public static void init(Context context) {
|
public static void init(Context context) {
|
||||||
if (sInstance == null) {
|
if (sInstance == null) {
|
||||||
Log.e(TAG, "init: ");
|
Log.e(TAG, "init: ");
|
||||||
sInstance = new JGYUtils(context);
|
sInstance = new JgyUtils(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JGYUtils getInstance() {
|
public static JgyUtils getInstance() {
|
||||||
if (sInstance == null) {
|
if (sInstance == null) {
|
||||||
throw new IllegalStateException("You must be init JGYUtils first");
|
throw new IllegalStateException("You must be init JgyUtils first");
|
||||||
}
|
}
|
||||||
return sInstance;
|
return sInstance;
|
||||||
}
|
}
|
||||||
@@ -147,6 +149,10 @@ public class JGYUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isAllWinnerDevice() {
|
||||||
|
return JgyUtils.getInstance().checkAppPlatform() == U1302Platform;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从Manifest中获取meta-data值
|
* 从Manifest中获取meta-data值
|
||||||
* https://blog.csdn.net/yue_233/article/details/91453451
|
* https://blog.csdn.net/yue_233/article/details/91453451
|
||||||
@@ -165,28 +171,28 @@ public class JGYUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isOfficialVersion() {
|
public static boolean isOfficialVersion() {
|
||||||
String channelValue = JGYUtils.getInstance().getStringMetaData();
|
String channelValue = JgyUtils.getInstance().getStringMetaData();
|
||||||
return "official".equals(channelValue);
|
return "official".equals(channelValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isOfficialVersion(Context context) {
|
public static boolean isOfficialVersion(Context context) {
|
||||||
Log.e(TAG, "isOfficialVersion: " + ProcessUtil.getCurrentProcessName(context));
|
Log.e(TAG, "isOfficialVersion: " + ProcessUtil.getCurrentProcessName(context));
|
||||||
String channelValue = JGYUtils.getInstance().getStringMetaData();
|
String channelValue = JgyUtils.getInstance().getStringMetaData();
|
||||||
return "official".equals(channelValue);
|
return "official".equals(channelValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isNewlyVersion() {
|
public static boolean isNewlyVersion() {
|
||||||
String channelValue = JGYUtils.getInstance().getStringMetaData();
|
String channelValue = JgyUtils.getInstance().getStringMetaData();
|
||||||
return "beta".equals(channelValue);
|
return "beta".equals(channelValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isBetaVersion() {
|
public static boolean isBetaVersion() {
|
||||||
String channelValue = JGYUtils.getInstance().getStringMetaData();
|
String channelValue = JgyUtils.getInstance().getStringMetaData();
|
||||||
return "beta".equals(channelValue);
|
return "beta".equals(channelValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCHANNEL_VALUE() {
|
public static String getCHANNEL_VALUE() {
|
||||||
return JGYUtils.getInstance().getStringMetaData();
|
return JgyUtils.getInstance().getStringMetaData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ public class LauncherUtils {
|
|||||||
UserHandle user = Process.myUserHandle();
|
UserHandle user = Process.myUserHandle();
|
||||||
Log.i("settingssssssstemf", (add ? "Adding" : "Removing") + " package as role holder, role: "
|
Log.i("settingssssssstemf", (add ? "Adding" : "Removing") + " package as role holder, role: "
|
||||||
+ roleName + ", package: " + packageName);
|
+ roleName + ", package: " + packageName);
|
||||||
if (JGYUtils.getInstance().checkAppPlatform() != JGYUtils.MTKPlatform) {
|
if (JgyUtils.getInstance().checkAppPlatform() != JgyUtils.MTKPlatform) {
|
||||||
RoleManager roleManager = context.getSystemService(RoleManager.class);
|
RoleManager roleManager = context.getSystemService(RoleManager.class);
|
||||||
Executor executor = context.getMainExecutor();
|
Executor executor = context.getMainExecutor();
|
||||||
Consumer<Boolean> callback = successful -> {
|
Consumer<Boolean> callback = successful -> {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import java.util.Iterator;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class TTUtils {
|
public class TTUtils {
|
||||||
private static final String TAG = TTUtils.class.getSimpleName();
|
private static final String TAG = "TTUtils";
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
private static TTUtils sInstance;
|
private static TTUtils sInstance;
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -21,6 +21,17 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
|
configurations.all {
|
||||||
|
resolutionStrategy {
|
||||||
|
force 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||||
|
// 统一 androidx.annotation
|
||||||
|
force 'androidx.annotation:annotation:1.3.0'
|
||||||
|
// 统一 lifecycle-runtime
|
||||||
|
force 'androidx.lifecycle:lifecycle-runtime:2.3.1'
|
||||||
|
// 统一 Kotlin 标准库
|
||||||
|
force 'org.jetbrains.kotlin:kotlin-stdlib:1.5.10'
|
||||||
|
}
|
||||||
|
}
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
@@ -11,6 +11,13 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
QZ15Debug {}
|
||||||
|
QZ15Release {}
|
||||||
|
seewoDebug {}
|
||||||
|
seewoRelease {}
|
||||||
|
zhanruiG10ZUserDebug {}
|
||||||
|
Huaruian8768Debug {}
|
||||||
|
Huaruian8768Release {}
|
||||||
iPlay50PDebug {}
|
iPlay50PDebug {}
|
||||||
iPlay50PRelease {}
|
iPlay50PRelease {}
|
||||||
UnisocS6688Debug {}
|
UnisocS6688Debug {}
|
||||||
|
|||||||
@@ -25,6 +25,13 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
QZ15Debug {}
|
||||||
|
QZ15Release {}
|
||||||
|
seewoDebug {}
|
||||||
|
seewoRelease {}
|
||||||
|
zhanruiG10ZUserDebug {}
|
||||||
|
Huaruian8768Debug {}
|
||||||
|
Huaruian8768Release {}
|
||||||
iPlay50PDebug {}
|
iPlay50PDebug {}
|
||||||
iPlay50PRelease {}
|
iPlay50PRelease {}
|
||||||
UnisocS6688Debug {}
|
UnisocS6688Debug {}
|
||||||
|
|||||||
Reference in new issue
Block a user