[Delete]
删除了apps应用列表模块 删除了back返回按钮模块 Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
@@ -70,8 +70,6 @@ modulesearch : "com.mogo.module:module-search:${MOGO_COMMONS_VER
|
||||
modulepush : "com.mogo.module:module-push:${MOGO_COMMONS_VERSION}",
|
||||
modulepushbase : "com.mogo.module:module-push-base:${MOGO_COMMONS_VERSION}",
|
||||
modulepushnoop : "com.mogo.module:module-push-noop:${MOGO_COMMONS_VERSION}",
|
||||
//统一返回键
|
||||
mogomoduleback : "com.mogo.module:module-back:${MOGO_COMMONS_VERSION}",
|
||||
// OBU
|
||||
moduleobu : "com.mogo.module:module-obu:${MOGO_COMMONS_VERSION}",
|
||||
// 左侧面板
|
||||
|
||||
@@ -204,7 +204,6 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.modulemap
|
||||
implementation rootProject.ext.dependencies.mogomodulewidgets
|
||||
implementation rootProject.ext.dependencies.moduleADAS
|
||||
implementation rootProject.ext.dependencies.mogomoduleback
|
||||
implementation rootProject.ext.dependencies.modulepushbase
|
||||
implementation rootProject.ext.dependencies.modulepush
|
||||
implementation rootProject.ext.dependencies.callchat
|
||||
@@ -237,7 +236,6 @@ dependencies {
|
||||
implementation project(':modules:mogo-module-map')
|
||||
implementation project(':modules:mogo-module-widgets')
|
||||
implementation project(':modules:mogo-module-adas')
|
||||
implementation project(':modules:mogo-module-back')
|
||||
implementation project(":modules:mogo-module-push-base")
|
||||
implementation project(":modules:mogo-module-push")
|
||||
implementation project(':modules:mogo-module-carchatting')
|
||||
|
||||
@@ -168,8 +168,6 @@ ext {
|
||||
modulepush : "com.mogo.module:module-push:${MOGO_MODULE_PUSH_VERSION}",
|
||||
modulepushbase : "com.mogo.module:module-push-base:${MOGO_MODULE_PUSH_BASE_VERSION}",
|
||||
modulepushnoop : "com.mogo.module:module-push-noop:${MOGO_MODULE_PUSH_NOOP_VERSION}",
|
||||
//统一返回键
|
||||
mogomoduleback : "com.mogo.module:module-back:${MOGO_MODULE_BACK_VERSION}",
|
||||
// OBU
|
||||
moduleobu : "com.mogo.module:module-obu:${MOGO_MODULE_OBU_VERSION}",
|
||||
// 左侧面板
|
||||
|
||||
@@ -75,7 +75,6 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.modulemap
|
||||
implementation rootProject.ext.dependencies.mogomodulewidgets
|
||||
implementation rootProject.ext.dependencies.moduleADAS
|
||||
implementation rootProject.ext.dependencies.mogomoduleback
|
||||
implementation rootProject.ext.dependencies.modulepushbase
|
||||
implementation rootProject.ext.dependencies.modulepush
|
||||
implementation rootProject.ext.dependencies.callchat
|
||||
@@ -111,7 +110,6 @@ dependencies {
|
||||
implementation project(':modules:mogo-module-map')
|
||||
implementation project(':modules:mogo-module-widgets')
|
||||
implementation project(':modules:mogo-module-adas')
|
||||
implementation project(':modules:mogo-module-back')
|
||||
implementation project(":modules:mogo-module-push-base")
|
||||
implementation project(":modules:mogo-module-push")
|
||||
implementation project(':modules:mogo-module-carchatting')
|
||||
|
||||
@@ -285,11 +285,6 @@ public abstract class MainMoGoApplication extends AbsMogoApplication {
|
||||
MogoModulePaths.addBaseModule(new MogoModule(UpgradeReportConstants.PATH, UpgradeReportConstants.NAME));
|
||||
// 初始化 bugly 日志采集
|
||||
//MogoModulePaths.addBaseModule(new MogoModule(CrashReportConstants.PATH, CrashReportConstants.NAME));
|
||||
|
||||
if (DebugConfig.isLauncher() && DebugConfig.getCarMachineType() == CAR_MACHINE_TYPE_SELF_INNOVATE) {
|
||||
MogoModulePaths.addModule(new MogoModule(MogoServicePaths.PATH_BACK, MogoServicePaths.PATH_BACK));
|
||||
}
|
||||
|
||||
MogoModulePaths.addBaseModule(new MogoModule(MogoServicePaths.PATH_WIDGETS, MogoServicePaths.PATH_WIDGETS));
|
||||
if (DebugConfig.isMapBased()) {
|
||||
MogoModulePaths.addModule(new MogoModule(CallChatConstant.PROVIDER, CallChatConstant.MODULE_NAME));
|
||||
|
||||
@@ -159,13 +159,6 @@ public class MogoServicePaths {
|
||||
@Deprecated
|
||||
public static final String PATH_REFRESH_STRATEGY_API = "/refreshstrategy/api";
|
||||
|
||||
/**
|
||||
* 刷新策略控制
|
||||
*/
|
||||
@Keep
|
||||
@Deprecated
|
||||
public static final String PATH_LAUNCHER_API = "/launcher/api";
|
||||
|
||||
/**
|
||||
* 入口按钮
|
||||
*/
|
||||
@@ -299,13 +292,6 @@ public class MogoServicePaths {
|
||||
@Deprecated
|
||||
public static final String PATH_GLOBAL_UNWAKE = "/global/unwake";
|
||||
|
||||
/**
|
||||
* 返回悬浮按钮
|
||||
*/
|
||||
@Keep
|
||||
@Deprecated
|
||||
public static final String PATH_BACK = "/back2launcher/ui";
|
||||
|
||||
/**
|
||||
* 自研地图和高德地图切换
|
||||
*/
|
||||
|
||||
@@ -125,7 +125,6 @@ MOGO_MODULE_MAP_VERSION=2.1.14.4
|
||||
MOGO_MODULE_SERVICE_VERSION=2.1.14.4
|
||||
MOGO_MODULE_EXTENSIONS_VERSION=2.1.14.4
|
||||
MOGO_MODULE_SEARCH_VERSION=2.1.14.4
|
||||
MOGO_MODULE_BACK_VERSION=2.1.14.4
|
||||
MOGO_MODULE_V2X_VERSION=2.1.14.4
|
||||
# 探路
|
||||
MOGO_MODULE_TANLU_VERSION=2.1.14.4
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
:modules:mogo-module-share
|
||||
:modules:mogo-module-extensions
|
||||
:modules:mogo-module-v2x
|
||||
:modules:mogo-module-back
|
||||
:modules:mogo-module-main
|
||||
:OCH:mogo-och
|
||||
:OCH:mogo-och-bus
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
:modules:mogo-module-share
|
||||
:modules:mogo-module-extensions
|
||||
:modules:mogo-module-v2x
|
||||
:modules:mogo-module-back
|
||||
:modules:mogo-module-main
|
||||
:modules:mogo-module-push-base
|
||||
:modules:mogo-module-push-noop
|
||||
|
||||
1
modules/mogo-module-apps/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
/build
|
||||
@@ -1 +0,0 @@
|
||||
# 应用列表 + Launcher 模式下的左侧导航按钮
|
||||
@@ -1,80 +0,0 @@
|
||||
plugins {
|
||||
id 'com.android.library'
|
||||
id 'kotlin-android'
|
||||
id 'kotlin-android-extensions'
|
||||
id 'kotlin-kapt'
|
||||
id 'com.alibaba.arouter'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
// buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
defaultConfig {
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode Integer.valueOf(VERSION_CODE)
|
||||
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles 'consumer-rules.pro'
|
||||
//ARouter apt 参数
|
||||
kapt {
|
||||
useBuildCache = false
|
||||
arguments {
|
||||
arg("AROUTER_MODULE_NAME", project.getName())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main.res.srcDirs = ['src/main/res', 'src/main/res-voice-icon']
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
implementation rootProject.ext.dependencies.androidxappcompat
|
||||
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
||||
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
kapt rootProject.ext.dependencies.aroutercompiler
|
||||
|
||||
implementation rootProject.ext.dependencies.material
|
||||
implementation rootProject.ext.dependencies.androidxrecyclerview
|
||||
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
implementation rootProject.ext.dependencies.mogomapapi
|
||||
implementation rootProject.ext.dependencies.mogoutils
|
||||
api rootProject.ext.dependencies.mogocommons
|
||||
api rootProject.ext.dependencies.mogoserviceapi
|
||||
implementation rootProject.ext.dependencies.modulecommon
|
||||
|
||||
implementation rootProject.ext.dependencies.mogo_core_utils
|
||||
implementation rootProject.ext.dependencies.mogo_core_data
|
||||
} else {
|
||||
implementation project(":libraries:mogo-map-api")
|
||||
implementation project(":foudations:mogo-utils")
|
||||
api project(":foudations:mogo-commons")
|
||||
api project(':services:mogo-service-api')
|
||||
implementation project(':modules:mogo-module-common')
|
||||
|
||||
implementation project(':core:mogo-core-utils')
|
||||
implementation project(':core:mogo-core-data')
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
@@ -1,5 +0,0 @@
|
||||
#-----AppModule-----
|
||||
-keep class com.mogo.module.apps.anim.AnimRes.EmojiType{*;}
|
||||
-keep class com.mogo.module.apps.model.AppEnum{*;}
|
||||
-keep class com.mogo.module.apps.view.*{*;}
|
||||
-keep class com.mogo.module.apps.AppFilter
|
||||
@@ -1,3 +0,0 @@
|
||||
GROUP=com.mogo.module
|
||||
POM_ARTIFACT_ID=module-apps
|
||||
VERSION_CODE=1
|
||||
26
modules/mogo-module-apps/proguard-rules.pro
vendored
@@ -1,26 +0,0 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class mName to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file mName.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
|
||||
#-----AppModule-----
|
||||
-keep class com.mogo.module.apps.model.AppEnum
|
||||
-keep class com.mogo.module.apps.view.** {*;}
|
||||
-keep class com.mogo.module.apps.AppFilter
|
||||
@@ -1,37 +0,0 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.module.apps">
|
||||
|
||||
<application>
|
||||
<receiver
|
||||
android:name=".receiver.AppInstallReceiver"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<!-- 一个新应用包已经安装在设备上,数据包括包名(最新安装的包程序不能接收到这个广播)-->
|
||||
<action android:name="android.intent.action.PACKAGE_ADDED" />
|
||||
<!-- 一个新版本的应用安装到设备,替换之前已经存在的版本-->
|
||||
<action android:name="android.intent.action.PACKAGE_REPLACED" />
|
||||
<!-- 一个已存在的应用程序包已经从设备上移除,包括包名(正在被安装的包程序不能接收到这个广播)-->
|
||||
<action android:name="android.intent.action.PACKAGE_REMOVED" />
|
||||
<!-- 一个已存在的应用程序包已经改变,包括包名-->
|
||||
<action android:name="android.intent.action.ACTION_PACKAGE_CHANGED" />
|
||||
<!-- 用户重新开始一个包,包的所有进程将被杀死,所有与其联系的运行时间状态应该被移除,包括包名(重新开始包程序不能接收到这个广播-->
|
||||
<action android:name="android.intent.action.ACTION_PACKAGE_RESTARTED" />
|
||||
<!-- 用户已经清楚一个包的数据,包括包名(清除包程序不能接收到这个广播)-->
|
||||
<action android:name="android.intent.action.ACTION_PACKAGE_DATA_CLEARED" />
|
||||
|
||||
<data android:scheme="package" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<activity
|
||||
android:name=".AppsListActivity"
|
||||
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize"
|
||||
android:launchMode="singleTask"
|
||||
android:resizeableActivity="false"
|
||||
android:resumeWhilePausing="true"
|
||||
android:screenOrientation="landscape"
|
||||
android:stateNotNeeded="true"
|
||||
android:theme="@style/AppsList"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import android.content.pm.PackageInfo;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-08
|
||||
* <p>
|
||||
* app 过滤规则
|
||||
*/
|
||||
public interface AppFilter {
|
||||
|
||||
/**
|
||||
* 过滤包
|
||||
*
|
||||
* @param packageInfo
|
||||
* @return true - 过滤 false - 不过滤
|
||||
*/
|
||||
boolean filter( PackageInfo packageInfo );
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.module.common.utils.CarSeries;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-08
|
||||
* <p>
|
||||
* 过滤 app
|
||||
*/
|
||||
public class AppFilterImpl {
|
||||
|
||||
private static List< String > mFilterPackages;
|
||||
|
||||
private static String sExternalPath = "/system/etc/packagesFilterList.txt";
|
||||
private static List< String > sExternalConfigPackages = new ArrayList<>();
|
||||
|
||||
static {
|
||||
if ( !CarSeries.isF8xxSeries() ) {
|
||||
final String[] values = AbsMogoApplication.getApp().getResources().getStringArray( R.array.module_apps_array_filter_packages );
|
||||
if ( values != null ) {
|
||||
mFilterPackages = new ArrayList( Arrays.asList( values ) );
|
||||
}
|
||||
} else {
|
||||
final String[] values = AbsMogoApplication.getApp().getResources().getStringArray( R.array.module_apps_array_filter_packages_f );
|
||||
if ( values != null ) {
|
||||
mFilterPackages = new ArrayList( Arrays.asList( values ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isSelfApp( PackageInfo packageInfo ) {
|
||||
try {
|
||||
if ( packageInfo.packageName.startsWith( "com.mogo.launcher" ) ) {
|
||||
return true;
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean sFilter( PackageInfo packageInfo ) {
|
||||
if ( isInExternalFilter( packageInfo ) ) {
|
||||
return true;
|
||||
}
|
||||
if ( isFilterPackages( packageInfo ) ) {
|
||||
return true;
|
||||
}
|
||||
if ( noLaunchIntent( packageInfo ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isSystemApp( PackageInfo packageInfo ) {
|
||||
return ( packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM ) != 0;
|
||||
}
|
||||
|
||||
private static boolean isFilterPackages( PackageInfo packageInfo ) {
|
||||
return mFilterPackages.contains( packageInfo.packageName );
|
||||
}
|
||||
|
||||
private static boolean noLaunchIntent( PackageInfo packageInfo ) {
|
||||
return AbsMogoApplication.getApp().getPackageManager().getLaunchIntentForPackage( packageInfo.packageName ) == null;
|
||||
}
|
||||
|
||||
private static boolean isInExternalFilter( PackageInfo packageInfo ) {
|
||||
return sExternalConfigPackages.contains( packageInfo.packageName );
|
||||
}
|
||||
|
||||
public static void loadExternalFilterPackagesList() throws Exception {
|
||||
sExternalConfigPackages.clear();
|
||||
File file = new File( sExternalPath );
|
||||
if ( !file.exists() || file.length() == 0 ) {
|
||||
return;
|
||||
}
|
||||
FileInputStream fis = new FileInputStream( file );
|
||||
InputStreamReader isr = new InputStreamReader( fis );
|
||||
BufferedReader br = new BufferedReader( isr );
|
||||
String line = "";
|
||||
while ( ( line = br.readLine() ) != null ) {
|
||||
line = line.trim();
|
||||
if ( TextUtils.isEmpty( line ) ) {
|
||||
continue;
|
||||
}
|
||||
sExternalConfigPackages.add( line );
|
||||
}
|
||||
br.close();
|
||||
isr.close();
|
||||
fis.close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,189 +0,0 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.module.apps.adapter.AppIndicatorAdapter;
|
||||
import com.mogo.module.apps.anim.AnimRes;
|
||||
import com.mogo.module.apps.anim.AnimWrapper;
|
||||
import com.mogo.module.apps.applaunch.AppLauncher;
|
||||
import com.mogo.module.apps.applaunch.BaseAppLauncher;
|
||||
import com.mogo.module.apps.applaunch.InternalFunctionLauncher;
|
||||
import com.mogo.module.apps.model.AppEnum;
|
||||
import com.mogo.module.apps.model.AppInfo;
|
||||
import com.mogo.module.apps.model.NavigatorApps;
|
||||
import com.mogo.module.apps.view.OnAiAssistClickListener;
|
||||
import com.mogo.service.fragmentmanager.FragmentStackTransactionListener;
|
||||
import com.mogo.utils.AppUtils;
|
||||
import com.mogo.utils.CommonUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-06
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppNavigatorFragment extends MvpFragment< AppNavigatorView, AppNavigatorPresenter >
|
||||
implements AppNavigatorView,
|
||||
FragmentStackTransactionListener {
|
||||
|
||||
private static final String TAG = "AppNavigatorFragment";
|
||||
|
||||
private RecyclerView mNavigatorAppsList;
|
||||
private AppIndicatorAdapter mAppIndicatorAdapter;
|
||||
|
||||
private ImageView mAIAssistBkg;
|
||||
private ImageView mAIAssist;
|
||||
private View mAIAssistContainer;
|
||||
private AnimWrapper mAnim;
|
||||
|
||||
private BaseAppLauncher mLauncher;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.module_apps_fragment_apps_navigator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTagName() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
|
||||
mLauncher = new InternalFunctionLauncher( getActivity() );
|
||||
mLauncher.setNext( new AppLauncher() );
|
||||
|
||||
mNavigatorAppsList = findViewById( R.id.module_apps_id_apps_list );
|
||||
mNavigatorAppsList.setLayoutManager( new LinearLayoutManager( getActivity(), RecyclerView.VERTICAL, false ) );
|
||||
mAppIndicatorAdapter = new AppIndicatorAdapter( getContext(), NavigatorApps.getApps() );
|
||||
mAppIndicatorAdapter.setOnItemClickedListener( ( data, position ) -> {
|
||||
mLauncher.launch( getContext(), data );
|
||||
trackNavigatorClickEvent( data );
|
||||
} );
|
||||
mNavigatorAppsList.setAdapter( mAppIndicatorAdapter );
|
||||
|
||||
mAIAssistContainer = findViewById( R.id.module_apps_id_ai_assist_container );
|
||||
mAIAssistBkg = findViewById( R.id.module_apps_id_ai_assist_bkg );
|
||||
mAIAssist = findViewById( R.id.module_apps_id_ai_assist );
|
||||
|
||||
mAnim = new AnimWrapper( mAIAssist, mAIAssistBkg );
|
||||
boolean naviStatus = AppServiceHandler.getApis().getMapServiceApi().getNavi( getContext() ).isNaviing();
|
||||
if ( naviStatus ) {
|
||||
setCurrentXiaoZhiEmoji( AnimRes.EmojiType.Navigation );
|
||||
}
|
||||
|
||||
mAIAssist.setOnClickListener( new OnAiAssistClickListener() );
|
||||
mAIAssistContainer.setOnClickListener( view -> {
|
||||
mAIAssist.performClick();
|
||||
} );
|
||||
|
||||
AppServiceHandler.getApis().getFragmentManagerApi().addMainFragmentStackTransactionListener( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransaction( int size ) {
|
||||
// 主页 fragment 栈变化的时候,改变动画状态
|
||||
if ( size == 0 ) {
|
||||
mAnim.start();
|
||||
} else {
|
||||
mAnim.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideNavigationEntrance() {
|
||||
mAppIndicatorAdapter.setDatas( NavigatorApps.getAppsWithoutNavigation() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showNavigationEntrance() {
|
||||
mAppIndicatorAdapter.setDatas( NavigatorApps.getApps() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentXiaoZhiEmoji( AnimRes.EmojiType type ) {
|
||||
boolean started = mAnim.isStarted();
|
||||
mAnim.stop();
|
||||
mAnim.setCurrentAnim( type );
|
||||
if ( started ) {
|
||||
mAnim.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mAnim.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
mAnim.stop();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected AppNavigatorPresenter createPresenter() {
|
||||
return new AppNavigatorPresenter( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated( @Nullable Bundle savedInstanceState ) {
|
||||
super.onActivityCreated( savedInstanceState );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openAppsPanel() {
|
||||
AppsListActivity.start( getActivity() );
|
||||
}
|
||||
|
||||
private void trackNavigatorClickEvent( AppInfo app ) {
|
||||
final Map< String, Object > properties = new HashMap<>();
|
||||
String appLabel = AppUtils.getApplicationLabel( getContext(), app.getPackageName() );
|
||||
properties.put( "appname", app.getName() );
|
||||
if ( !TextUtils.isEmpty( appLabel ) ) {
|
||||
properties.put( "appname", appLabel );
|
||||
}
|
||||
if ( !TextUtils.equals( "全部应用", app.getName() ) ) {
|
||||
if ( TextUtils.equals( "com.zhidao.music", app.getPackageName() ) ) {
|
||||
if ( AppUtils.isAppInstalled( AbsMogoApplication.getApp(), AppEnum.KwMusic.getPkg() ) ) {
|
||||
properties.put( "appversion", CommonUtils.getVersionName( getContext(), AppEnum.KwMusic.getPkg() ) );
|
||||
} else if ( AppUtils.isAppInstalled( AbsMogoApplication.getApp(), AppEnum.QQMusic.getPkg() ) ) {
|
||||
properties.put( "appversion", CommonUtils.getVersionName( getContext(), AppEnum.QQMusic.getPkg() ) );
|
||||
}
|
||||
} else {
|
||||
properties.put( "appversion", CommonUtils.getVersionName( getContext(), app.getPackageName() ) );
|
||||
}
|
||||
} else {
|
||||
properties.put( "appversion", CommonUtils.getVersionName( getContext() ) );
|
||||
}
|
||||
AppServiceHandler.getApis().getAnalyticsApi().track( "Launcher_APP_Icon", properties );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
if ( mPresenter != null ) {
|
||||
mPresenter.onDestroy( getViewLifecycleOwner() );
|
||||
}
|
||||
if ( mAnim != null ) {
|
||||
mAnim.release();
|
||||
}
|
||||
AppServiceHandler.getApis().getFragmentManagerApi().removeMainFragmentStackTransactionListener( this );
|
||||
}
|
||||
}
|
||||
@@ -1,159 +0,0 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
|
||||
import com.mogo.map.navi.IMogoNaviListener2;
|
||||
import com.mogo.module.apps.anim.AnimRes;
|
||||
import com.mogo.module.apps.model.AppsModel;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.LaunchUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-12
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppNavigatorPresenter extends Presenter< AppNavigatorView > implements IMogoIntentListener,
|
||||
IMogoVoiceCmdCallBack,
|
||||
IMogoNaviListener2,
|
||||
IMogoStatusChangedListener {
|
||||
|
||||
private static final String TAG = "AppNavigatorPresenter";
|
||||
|
||||
public AppNavigatorPresenter( AppNavigatorView view ) {
|
||||
super( view );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate( @NonNull LifecycleOwner owner ) {
|
||||
super.onCreate( owner );
|
||||
AppServiceHandler.getApis().getRegisterCenterApi().registerMogoNaviListener( TAG, this );
|
||||
if ( DebugConfig.isLauncher() ) {
|
||||
// 预加载应用列表,空间换时间
|
||||
AppsModel.getInstance( getContext() ).load( null );
|
||||
}
|
||||
AppServiceHandler.getApis().getStatusManagerApi().registerStatusChangedListener( TAG, StatusDescriptor.MEDIA_PLAYER_STATUS, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume( @NonNull LifecycleOwner owner ) {
|
||||
super.onResume( owner );
|
||||
AIAssist.getInstance( getContext() ).registerUnWakeupCommand( AppsConst.CMD_UN_WAKE_OPEN_APP_LIST, AppsConst.CMD_UN_WAKE_WORDS_OPEN_APP_LIST, this );
|
||||
AIAssist.getInstance( getContext() ).registerUnWakeupCommand( AppsConst.CMD_UN_WAKE_OPEN_CAR_SETTINGS, AppsConst.CMD_UN_WAKE_WORDS_OPEN_CAR_SETTINGS, this );
|
||||
AppServiceHandler.getApis().getIntentManagerApi().registerIntentListener( AppsConst.COMMAND_OPERATION, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause( @NonNull LifecycleOwner owner ) {
|
||||
super.onPause( owner );
|
||||
AppServiceHandler.getApis().getIntentManagerApi().unregisterIntentListener( AppsConst.COMMAND_OPERATION, this );
|
||||
AIAssist.getInstance( getContext() ).unregisterUnWakeupCommand( AppsConst.CMD_UN_WAKE_OPEN_APP_LIST );
|
||||
AIAssist.getInstance( getContext() ).unregisterUnWakeupCommand( AppsConst.CMD_UN_WAKE_OPEN_CAR_SETTINGS );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntentReceived( String intentStr, Intent intent ) {
|
||||
if ( !AppsConst.COMMAND_OPERATION.equals( intentStr ) ) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
JSONObject object = new JSONObject( intent.getStringExtra( "data" ) );
|
||||
String app = object.optString( "object" );
|
||||
String operation = object.optString( "operation" );
|
||||
|
||||
if ( !AppsConst.OBJECT_ADAS.equals( app ) ) {
|
||||
AppServiceHandler.getApis().getAdasControllerApi().closeADAS();
|
||||
}
|
||||
|
||||
if ( !DebugConfig.isLauncher() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( AppsConst.OBJECT_ALL_APPS.equals( app ) ) {
|
||||
if ( AppsConst.OPERATION_OPEN.equals( operation ) ) {
|
||||
mView.openAppsPanel();
|
||||
}
|
||||
} else if ( AppsConst.OBJECT_FAST_SETTINGS.equals( app ) ) {
|
||||
if ( AppsConst.OPERATION_OPEN.equals( operation ) ) {
|
||||
try {
|
||||
LaunchUtils.launchByPkg( getContext(), AppsConst.APP_PKG_CAR_SETTINGS );
|
||||
} catch ( Exception e ) {
|
||||
TipToast.shortTip( R.string.module_apps_str_no_app );
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch ( JSONException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCmdSelected( String cmd ) {
|
||||
switch ( cmd ) {
|
||||
case AppsConst.CMD_UN_WAKE_OPEN_APP_LIST:
|
||||
mView.openAppsPanel();
|
||||
break;
|
||||
case AppsConst.CMD_UN_WAKE_OPEN_CAR_SETTINGS:
|
||||
try {
|
||||
LaunchUtils.launchByPkg( getContext(), AppsConst.APP_PKG_CAR_SETTINGS );
|
||||
} catch ( Exception e ) {
|
||||
TipToast.shortTip( R.string.module_apps_str_no_app );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy( @NonNull LifecycleOwner owner ) {
|
||||
super.onDestroy( owner );
|
||||
AppServiceHandler.getApis().getRegisterCenterApi().unregisterMogoNaviListener( TAG );
|
||||
AppServiceHandler.getApis().getIntentManagerApi().unregisterIntentListener( AppsConst.COMMAND_OPERATION, this );
|
||||
AppServiceHandler.getApis().getStatusManagerApi().unregisterStatusChangedListener( TAG, StatusDescriptor.MEDIA_PLAYER_STATUS, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartNavi() {
|
||||
mView.hideNavigationEntrance();
|
||||
mView.setCurrentXiaoZhiEmoji( AnimRes.EmojiType.Navigation );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopNavi() {
|
||||
mView.showNavigationEntrance();
|
||||
if ( AppServiceHandler.getApis().getStatusManagerApi().isMediaPlaying() ) {
|
||||
mView.setCurrentXiaoZhiEmoji( AnimRes.EmojiType.Music );
|
||||
} else {
|
||||
mView.setCurrentXiaoZhiEmoji( AnimRes.EmojiType.Others );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
|
||||
if ( descriptor != StatusDescriptor.MEDIA_PLAYER_STATUS ) {
|
||||
return;
|
||||
}
|
||||
if ( AppServiceHandler.getApis().getMapServiceApi().getNavi( getContext() ).isNaviing() ) {
|
||||
// 导航优先级更高
|
||||
return;
|
||||
}
|
||||
if ( isTrue ) {
|
||||
mView.setCurrentXiaoZhiEmoji( AnimRes.EmojiType.Music );
|
||||
} else {
|
||||
mView.setCurrentXiaoZhiEmoji( AnimRes.EmojiType.Others );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
|
||||
import com.mogo.commons.mvp.IView;
|
||||
import com.mogo.module.apps.anim.AnimRes;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-12
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public interface AppNavigatorView extends IView {
|
||||
|
||||
/**
|
||||
* 打开全部应用
|
||||
*/
|
||||
void openAppsPanel();
|
||||
|
||||
void hideNavigationEntrance();
|
||||
|
||||
void showNavigationEntrance();
|
||||
|
||||
/**
|
||||
* 设置当前小智形象表情
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
void setCurrentXiaoZhiEmoji( AnimRes.EmojiType type );
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
|
||||
/**
|
||||
* author : zyz
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020-01-0718:54
|
||||
* desc : 持有服务接口实例
|
||||
* version: 1.0
|
||||
*/
|
||||
public class AppServiceHandler {
|
||||
|
||||
private static final String TAG = "AppServiceHandler";
|
||||
|
||||
private static IMogoServiceApis mApis;
|
||||
|
||||
public static IMogoServiceApis getApis() {
|
||||
if ( mApis == null ) {
|
||||
mApis = MogoApisHandler.getInstance().getApis();
|
||||
}
|
||||
return mApis;
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.mogo.module.apps.model.AppInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-30
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppsAdapter extends BaseAdapter {
|
||||
|
||||
private List< AppInfo > mAppInfos;
|
||||
|
||||
public AppsAdapter( List< AppInfo > appInfos ) {
|
||||
this.mAppInfos = new ArrayList<>();
|
||||
for ( AppInfo appInfo : appInfos ) {
|
||||
if ( appInfo == null ) {
|
||||
continue;
|
||||
}
|
||||
mAppInfos.add( appInfo );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
int size = mAppInfos == null ? 0 : mAppInfos.size();
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppInfo getItem( int position ) {
|
||||
return mAppInfos.get( position );
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId( int position ) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView( int position, View convertView, ViewGroup parent ) {
|
||||
AppViewHolder holder = null;
|
||||
if ( convertView == null ) {
|
||||
holder = new AppViewHolder( LayoutInflater.from( parent.getContext() ).inflate( R.layout.module_apps_item_app, null ) );
|
||||
} else {
|
||||
holder = ( ( AppViewHolder ) convertView.getTag() );
|
||||
}
|
||||
AppInfo appInfo = getItem( position );
|
||||
if ( appInfo.getIconResId() <= 0 ) {
|
||||
if ( appInfo.getIcon() != null ) {
|
||||
holder.mIcon.setImageDrawable( appInfo.getIcon() );
|
||||
} else {
|
||||
holder.mIcon.setImageResource( R.drawable.module_apps_ic_default_icon );
|
||||
}
|
||||
} else {
|
||||
holder.mIcon.setImageResource( appInfo.getIconResId() );
|
||||
}
|
||||
holder.mName.setText( appInfo.getName() );
|
||||
return holder.mItemView;
|
||||
}
|
||||
|
||||
public static class AppViewHolder {
|
||||
|
||||
private View mItemView;
|
||||
public ImageView mIcon;
|
||||
public TextView mName;
|
||||
|
||||
public AppViewHolder( @NonNull View itemView ) {
|
||||
mItemView = itemView;
|
||||
mIcon = itemView.findViewById( R.id.module_apps_id_app_icon );
|
||||
mName = itemView.findViewById( R.id.module_apps_id_app_name );
|
||||
mItemView.setTag( this );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-08
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppsConst {
|
||||
|
||||
/**
|
||||
* 打开/关闭全部应用、打开/关闭车辆设置
|
||||
*/
|
||||
public static final String COMMAND_OPERATION = "system.application.operation";
|
||||
|
||||
/**
|
||||
* 每页显示多少个app
|
||||
*/
|
||||
public static final int TOTAL_SIZE_EACH_PAGE = 12;
|
||||
|
||||
/**
|
||||
* 车辆设置跳转
|
||||
*/
|
||||
public static final String APP_PKG_CAR_SETTINGS = "com.zhidao.settings";
|
||||
|
||||
public static final String OBJECT_ALL_APPS = "全部应用";
|
||||
public static final String OBJECT_FAST_SETTINGS = "快捷设置";
|
||||
public static final String OBJECT_ADAS = "辅助驾驶";
|
||||
public static final String OPERATION_OPEN = "打开";
|
||||
public static final String OPERATION_CLOSE = "关闭";
|
||||
|
||||
public static final String CMD_UN_WAKE_OPEN_APP_LIST = "CMD_UN_WAKE_OPEN_APP_LIST";
|
||||
public static final String[] CMD_UN_WAKE_WORDS_OPEN_APP_LIST = new String[]{"打开全部应用"};
|
||||
|
||||
public static final String CMD_UN_WAKE_CLOSE_APP_LIST = "CMD_UN_WAKE_CLOSE_APP_LIST";
|
||||
public static final String[] CMD_UN_WAKE_WORDS_CLOSE_APP_LIST = new String[]{"关闭全部应用"};
|
||||
|
||||
public static final String CMD_UN_WAKE_OPEN_CAR_SETTINGS = "CMD_UN_WAKE_OPEN_CAR_SETTINGS";
|
||||
public static final String[] CMD_UN_WAKE_WORDS_OPEN_CAR_SETTINGS = new String[]{"打开快捷设置"};
|
||||
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.commons.utils.ViewPagerSpeedScroller;
|
||||
import com.mogo.module.apps.model.AppInfo;
|
||||
import com.mogo.module.apps.view.PagerSlidingTabStripV2;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-30
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > implements AppsView {
|
||||
|
||||
public static final String TAG = "AppsFragment";
|
||||
|
||||
private ViewPager mAppsPager;
|
||||
private AppsPagerAdapter mAppsPagerAdapter;
|
||||
|
||||
private View mExit;
|
||||
|
||||
private View mLoadingView;
|
||||
private PagerSlidingTabStripV2 mIndicator;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.module_apps_fragment_apps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTagName() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
mAppsPager = findViewById( R.id.module_apps_id_apps_pager );
|
||||
mExit = findViewById( R.id.module_apps_id_apps_exit );
|
||||
mExit.setOnClickListener( view -> {
|
||||
if ( getActivity() != null ) {
|
||||
getActivity().finish();
|
||||
getActivity().overridePendingTransition( 0, R.anim.module_apps_anim_exit);
|
||||
}
|
||||
} );
|
||||
mLoadingView = findViewById( R.id.module_apps_id_loading );
|
||||
mLoadingView.setVisibility( View.VISIBLE );
|
||||
mIndicator = findViewById( R.id.module_apps_id_indicator );
|
||||
mIndicator.setOpenPadding( true );
|
||||
|
||||
// ViewPagerSpeedScroller.attach(getContext(), mAppsPager, 1000);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected AppsPresenter createPresenter() {
|
||||
return new AppsPresenter( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated( @Nullable Bundle savedInstanceState ) {
|
||||
super.onActivityCreated( savedInstanceState );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderApps( Map< Integer, List< AppInfo > > appInfos ) {
|
||||
mAppsPager.setOffscreenPageLimit( appInfos.size() );
|
||||
mLoadingView.setVisibility( View.GONE );
|
||||
if ( mAppsPagerAdapter == null ) {
|
||||
mAppsPagerAdapter = new AppsPagerAdapter( appInfos );
|
||||
mAppsPager.setAdapter( mAppsPagerAdapter );
|
||||
mAppsPagerAdapter.setOnAppClickedListener( ( appInfo, position ) -> {
|
||||
Logger.i( TAG, "position = %d clicked. name = %s", position, appInfo.getName() );
|
||||
mPresenter.launch( appInfo );
|
||||
} );
|
||||
} else {
|
||||
mAppsPagerAdapter.setPagedApps( appInfos );
|
||||
}
|
||||
mIndicator.setViewPager( mAppsPager );
|
||||
mLoadingView.setVisibility( View.GONE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
if ( mExit != null ) {
|
||||
mExit.performClick();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
if ( mPresenter != null ) {
|
||||
mPresenter.onDestroy( getViewLifecycleOwner() );
|
||||
}
|
||||
mPresenter = null;
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.service.module.ModuleType;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-30
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
|
||||
@Route( path = MogoModulePaths.PATH_MODULE_APPS )
|
||||
public class AppsFragmentProvider implements IMogoModuleProvider {
|
||||
|
||||
private AppNavigatorFragment mAppsFragment;
|
||||
|
||||
@Override
|
||||
public Fragment createFragment( Context context, Bundle data ) {
|
||||
mAppsFragment = new AppNavigatorFragment();
|
||||
mAppsFragment.setArguments( data );
|
||||
return mAppsFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView( Context context ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getModuleName() {
|
||||
return MogoModulePaths.PATH_MODULE_APPS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoModuleLifecycle getCardLifecycle() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMapListener getMapListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return ModuleType.TYPE_APP_LIST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoNaviListener getNaviListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoLocationListener getLocationListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMarkerClickListener getMarkerClickListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAppPackage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAppName() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.mogo.commons.mvp.MvpActivity;
|
||||
import com.mogo.module.apps.model.AppsModel;
|
||||
import com.mogo.service.fragmentmanager.FragmentStackTransactionListener;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-28
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppsListActivity extends MvpActivity< AppsListView, AppsListPresenter > implements AppsListView, FragmentStackTransactionListener {
|
||||
|
||||
private static final String TAG = "AppsListActivity";
|
||||
|
||||
private BottomSheetBehavior mBottomSheetBehavior;
|
||||
private IMogoFragmentManager mMogoFragmentManager;
|
||||
|
||||
public static void start( Context context ) {
|
||||
Intent starter = new Intent( context, AppsListActivity.class );
|
||||
context.startActivity( starter );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate( @Nullable Bundle savedInstanceState ) {
|
||||
overridePendingTransition( R.anim.module_apps_anim_enter, 0 );
|
||||
getWindow().addFlags( WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS );
|
||||
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ) {
|
||||
getWindow().setStatusBarColor( Color.BLACK );
|
||||
}
|
||||
super.onCreate( savedInstanceState );
|
||||
// 透明 activity 不会让前一个 activity 走 onStop 方法
|
||||
AppServiceHandler.getApis().getStatusManagerApi().setMainPageIsBackgroundStatus( TAG, true );
|
||||
AppServiceHandler.getApis().getStatusManagerApi().setAppListUIShow( TAG, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
try {
|
||||
AppServiceHandler.getApis().getAdasControllerApi().closeADAS();
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestart() {
|
||||
super.onRestart();
|
||||
try {
|
||||
AppServiceHandler.getApis().getAdasControllerApi().closeADAS();
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.module_apps_activity_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace( R.id.module_apps_id_container, new AppsFragment() )
|
||||
.commitAllowingStateLoss();
|
||||
|
||||
mBottomSheetBehavior = BottomSheetBehavior.from( findViewById( R.id.module_apps_id_container ) );
|
||||
mBottomSheetBehavior.setSkipCollapsed( true );
|
||||
mBottomSheetBehavior.setBottomSheetCallback( new BottomSheetBehavior.BottomSheetCallback() {
|
||||
@Override
|
||||
public void onStateChanged( @NonNull View bottomSheet, int newState ) {
|
||||
if ( newState == BottomSheetBehavior.STATE_COLLAPSED ) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlide( @NonNull View bottomSheet, float slideOffset ) {
|
||||
|
||||
}
|
||||
} );
|
||||
mBottomSheetBehavior.setState( BottomSheetBehavior.STATE_EXPANDED );
|
||||
|
||||
mMogoFragmentManager = AppServiceHandler.getApis().getFragmentManagerApi();
|
||||
mMogoFragmentManager.addMainFragmentStackTransactionListener( this );
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected AppsListPresenter createPresenter() {
|
||||
return new AppsListPresenter( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransaction( int size ) {
|
||||
if ( size == 0 ) {
|
||||
closeAppsPanel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState( Bundle savedInstanceState ) {
|
||||
super.onRestoreInstanceState( savedInstanceState );
|
||||
AppServiceHandler.getApis().getAdasControllerApi().closeADAS();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState( Bundle outState ) {
|
||||
super.onSaveInstanceState( outState );
|
||||
AppsModel.getInstance( this ).release();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeAppsPanel() {
|
||||
finish();
|
||||
overridePendingTransition( R.anim.module_apps_anim_enter, R.anim.module_apps_anim_exit );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeFinish() {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
AppServiceHandler.getApis().getStatusManagerApi().setAppListUIShow( TAG, false );
|
||||
mMogoFragmentManager.removeMainFragmentStackTransactionListener( this );
|
||||
mMogoFragmentManager = null;
|
||||
mBottomSheetBehavior = null;
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.Observer;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-13
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppsListChangedLiveData extends MutableLiveData {
|
||||
|
||||
private Observer mObserver;
|
||||
|
||||
private static volatile AppsListChangedLiveData sInstance;
|
||||
|
||||
private AppsListChangedLiveData(){}
|
||||
|
||||
public static AppsListChangedLiveData getInstance(){
|
||||
if( sInstance == null ){
|
||||
synchronized( AppsListChangedLiveData.class ) {
|
||||
if( sInstance == null ){
|
||||
sInstance = new AppsListChangedLiveData();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void observeForever( @NonNull Observer observer ) {
|
||||
super.observeForever( observer );
|
||||
mObserver = observer;
|
||||
}
|
||||
|
||||
public synchronized void release(){
|
||||
removeObserver( mObserver );
|
||||
mObserver = null;
|
||||
sInstance = null;
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-28
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppsListPresenter extends Presenter< AppsListView > implements IMogoIntentListener, IMogoVoiceCmdCallBack {
|
||||
|
||||
private static final String TAG = "AppsListPresenter";
|
||||
|
||||
private IMogoIntentManager mIntentManager;
|
||||
|
||||
public AppsListPresenter( AppsListView view ) {
|
||||
super( view );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate( @NonNull LifecycleOwner owner ) {
|
||||
super.onCreate( owner );
|
||||
mIntentManager = AppServiceHandler.getApis().getIntentManagerApi();
|
||||
mIntentManager.registerIntentListener( AppsConst.COMMAND_OPERATION, this );
|
||||
mIntentManager.registerIntentListener( Intent.ACTION_CLOSE_SYSTEM_DIALOGS, this );
|
||||
AIAssist.getInstance( getContext() ).registerUnWakeupCommand( AppsConst.CMD_UN_WAKE_CLOSE_APP_LIST, AppsConst.CMD_UN_WAKE_WORDS_CLOSE_APP_LIST, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntentReceived( String intentStr, Intent intent ) {
|
||||
if ( AppsConst.COMMAND_OPERATION.equals( intentStr ) ) {
|
||||
try {
|
||||
JSONObject object = new JSONObject( intent.getStringExtra( "data" ) );
|
||||
String app = object.optString( "object" );
|
||||
String operation = object.optString( "operation" );
|
||||
if ( AppsConst.OBJECT_ALL_APPS.equals( app ) ) {
|
||||
if ( AppsConst.OPERATION_CLOSE.equals( operation ) ) {
|
||||
mView.closeAppsPanel();
|
||||
}
|
||||
}
|
||||
} catch ( JSONException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if ( Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals( intentStr ) ) {
|
||||
Logger.d( TAG, "home 键导致 app 列表关闭" );
|
||||
mView.executeFinish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCmdSelected( String cmd ) {
|
||||
if ( TextUtils.equals( AppsConst.CMD_UN_WAKE_CLOSE_APP_LIST, cmd ) ) {
|
||||
mView.closeAppsPanel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCmdAction( String speakText ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCmdCancel( String speakText ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpeakEnd( String speakText ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpeakSelectTimeOut( String speakText ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy( @NonNull LifecycleOwner owner ) {
|
||||
super.onDestroy( owner );
|
||||
mIntentManager.unregisterIntentListener( AppsConst.COMMAND_OPERATION, this );
|
||||
mIntentManager.unregisterIntentListener( Intent.ACTION_CLOSE_SYSTEM_DIALOGS, this );
|
||||
AIAssist.getInstance( getContext() ).unregisterUnWakeupCommand( AppsConst.CMD_UN_WAKE_CLOSE_APP_LIST );
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import com.mogo.commons.mvp.IView;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-28
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public interface AppsListView extends IView {
|
||||
|
||||
void closeAppsPanel();
|
||||
|
||||
void executeFinish();
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.GridView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
|
||||
import com.mogo.module.apps.model.AppInfo;
|
||||
import com.mogo.module.apps.view.PagerIndicator;
|
||||
import com.mogo.module.apps.view.PagerSlidingTabStripV2;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.ResourcesHelper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-08
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppsPagerAdapter extends PagerAdapter implements PagerSlidingTabStripV2.ViewTabProvider {
|
||||
|
||||
private Map< Integer, List< AppInfo > > mPagedApps;
|
||||
private OnAppClickedListener mOnAppClickedListener;
|
||||
|
||||
public AppsPagerAdapter( Map< Integer, List< AppInfo > > apps ) {
|
||||
this.mPagedApps = apps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mPagedApps == null ? 0 : mPagedApps.size();
|
||||
}
|
||||
|
||||
public void setOnAppClickedListener( OnAppClickedListener onAppClickedListener ) {
|
||||
this.mOnAppClickedListener = onAppClickedListener;
|
||||
}
|
||||
|
||||
public OnAppClickedListener getOnAppClickedListener() {
|
||||
return mOnAppClickedListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViewFromObject( @NonNull View view, @NonNull Object object ) {
|
||||
return view == object;
|
||||
}
|
||||
|
||||
public void setPagedApps( Map< Integer, List< AppInfo > > pagedApps ) {
|
||||
this.mPagedApps = pagedApps;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Object instantiateItem( @NonNull ViewGroup container, int position ) {
|
||||
View pager = LayoutInflater.from( container.getContext() ).inflate( R.layout.module_apps_item_app_pager, null );
|
||||
GridView page = pager.findViewById( R.id.module_apps_id_apps_page );
|
||||
page.setAdapter( new AppsAdapter( mPagedApps.get( position ) ) );
|
||||
page.setOnItemClickListener( ( parent, view, appPosition, id ) -> {
|
||||
if ( getOnAppClickedListener() != null ) {
|
||||
getOnAppClickedListener().onClick( mPagedApps.get( position ).get( appPosition ), position * AppsConst.TOTAL_SIZE_EACH_PAGE + appPosition );
|
||||
}
|
||||
} );
|
||||
container.addView( page );
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyItem( @NonNull ViewGroup container, int position, @NonNull Object object ) {
|
||||
if ( object instanceof View ) {
|
||||
container.removeView( ( ( View ) object ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemPosition( @NonNull Object object ) {
|
||||
return POSITION_NONE;
|
||||
}
|
||||
|
||||
public interface OnAppClickedListener {
|
||||
void onClick( AppInfo appInfo, int position );
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getPageTabView( Context context, int position ) {
|
||||
return new PagerIndicator( context );
|
||||
}
|
||||
}
|
||||
@@ -1,224 +0,0 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.module.apps.applaunch.AppLaunchFilter;
|
||||
import com.mogo.module.apps.applaunch.AppLauncher;
|
||||
import com.mogo.module.apps.applaunch.GuideShowLauncher;
|
||||
import com.mogo.module.apps.applaunch.InternalFunctionLauncher;
|
||||
import com.mogo.module.apps.model.AppInfo;
|
||||
import com.mogo.module.apps.model.AppsModel;
|
||||
import com.mogo.module.apps.model.UnScannedApps;
|
||||
import com.mogo.service.analytics.IMogoAnalytics;
|
||||
import com.mogo.utils.ThreadPoolService;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-30
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppsPresenter extends Presenter< AppsView > {
|
||||
|
||||
private static final String TAG = "AppsPresenter";
|
||||
|
||||
private IMogoAnalytics mAnalytics;
|
||||
private AppLaunchFilter mLauncher;
|
||||
|
||||
public AppsPresenter( AppsView view ) {
|
||||
super( view );
|
||||
InternalFunctionLauncher internalFunctionLauncher = new InternalFunctionLauncher( getContext() );
|
||||
GuideShowLauncher guideShowLauncher = new GuideShowLauncher( AppServiceHandler.getApis().getMapServiceApi().getNavi( getContext() ) );
|
||||
internalFunctionLauncher.setNext( guideShowLauncher );
|
||||
guideShowLauncher.setNext( new AppLauncher() );
|
||||
mLauncher = internalFunctionLauncher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate( @NonNull LifecycleOwner owner ) {
|
||||
super.onCreate( owner );
|
||||
renderAppsList();
|
||||
AppsListChangedLiveData.getInstance().observeForever( bool -> {
|
||||
if ( mView != null ) {
|
||||
renderAppsList();
|
||||
}
|
||||
} );
|
||||
|
||||
mAnalytics = AppServiceHandler.getApis().getAnalyticsApi();
|
||||
}
|
||||
|
||||
private void renderAppsList() {
|
||||
ThreadPoolService.execute( () -> {
|
||||
AppsModel.getInstance( getContext() ).load( appInfoList -> {
|
||||
|
||||
Logger.d( TAG, "apps: %s", appInfoList );
|
||||
final Map< Integer, List< AppInfo > > result = addOthersEntrances( appInfoList );
|
||||
final Map< Integer, List< AppInfo > > newResult = rePutInOrderAppList( result );
|
||||
UiThreadHandler.post( () -> {
|
||||
if ( mView != null ) {
|
||||
mView.renderApps( newResult );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
} );
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增入口
|
||||
*
|
||||
* @param appInfoMap
|
||||
* @return
|
||||
*/
|
||||
private Map< Integer, List< AppInfo > > addOthersEntrances( Map< Integer, List< AppInfo > > appInfoMap ) {
|
||||
Map< Integer, List< AppInfo > > result = new HashMap<>();
|
||||
|
||||
if ( appInfoMap != null && !appInfoMap.isEmpty() ) {
|
||||
// val deep copy
|
||||
Set< Integer > keys = appInfoMap.keySet();
|
||||
for ( Integer key : keys ) {
|
||||
List< AppInfo > val = appInfoMap.get( key );
|
||||
try {
|
||||
result.put( key, new ArrayList<>( val ) );
|
||||
} catch ( Exception e ) {
|
||||
result.put( key, new ArrayList<>() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 手动添加无法识别到的app
|
||||
List< AppInfo > apps = UnScannedApps.getUnScannedApps();
|
||||
if ( apps != null && !apps.isEmpty() ) {
|
||||
for ( AppInfo app : apps ) {
|
||||
if ( app == null ) {
|
||||
continue;
|
||||
}
|
||||
Set< Integer > keys = result.keySet();
|
||||
boolean addFlag = true;
|
||||
for ( Integer key : keys ) {
|
||||
List< AppInfo > val = result.get( key );
|
||||
// 无法扫描到蓝牙电话app,这里手动添加
|
||||
for ( AppInfo appInfo : val ) {
|
||||
if ( appInfo == null ) {
|
||||
continue;
|
||||
}
|
||||
if ( appInfo.equals( app ) ) {
|
||||
addFlag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !addFlag ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( addFlag ) {
|
||||
growthCapacity( result );
|
||||
result.get( result.size() - 1 ).add( app );
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 扩容
|
||||
*
|
||||
* @param target
|
||||
*/
|
||||
private void growthCapacity( Map< Integer, List< AppInfo > > target ) {
|
||||
if ( target == null ) {
|
||||
return;
|
||||
}
|
||||
if ( target.isEmpty() ) {
|
||||
target.put( 0, new ArrayList<>() );
|
||||
} else if ( target.get( target.size() - 1 ) == null ) {
|
||||
target.put( target.size() - 1, new ArrayList<>() );
|
||||
} else if ( target.get( target.size() - 1 ).size() == AppsConst.TOTAL_SIZE_EACH_PAGE ) {
|
||||
target.put( target.size(), new ArrayList<>() );
|
||||
}
|
||||
}
|
||||
|
||||
private Map< Integer, List< AppInfo > > rePutInOrderAppList( Map< Integer, List< AppInfo > > target ) {
|
||||
if ( target == null || target.isEmpty() ) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
Map< Integer, List< AppInfo > > result = new HashMap<>();
|
||||
synchronized ( target ) {
|
||||
List< AppInfo > list = new ArrayList<>();
|
||||
for ( List< AppInfo > value : target.values() ) {
|
||||
for ( AppInfo appInfo : value ) {
|
||||
if ( list.contains( appInfo ) ) {
|
||||
continue;
|
||||
}
|
||||
list.add( appInfo );
|
||||
}
|
||||
}
|
||||
int page = 0;
|
||||
int counter = 0;
|
||||
for ( AppInfo appInfo : list ) {
|
||||
page = counter++ / AppsConst.TOTAL_SIZE_EACH_PAGE;
|
||||
if ( !result.containsKey( page ) ) {
|
||||
result.put( page, new ArrayList<>() );
|
||||
}
|
||||
result.get( page ).add( appInfo );
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void launch( AppInfo appInfo ) {
|
||||
if ( appInfo == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
trackAppClicked( appInfo );
|
||||
try {
|
||||
mLauncher.launch( getContext(), appInfo );
|
||||
} catch ( Exception e ) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void trackAppClicked( AppInfo appInfo ) {
|
||||
if ( appInfo == null ) {
|
||||
return;
|
||||
}
|
||||
Map< String, Object > properties = new HashMap<>();
|
||||
properties.put( "appname", appInfo.getName() );
|
||||
properties.put( "packagename", appInfo.getPackageName() );
|
||||
properties.put( "appversion", appInfo.getVersionName() );
|
||||
properties.put( "from", 1 );
|
||||
mAnalytics.track( "appenterfront", properties );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy( @NonNull LifecycleOwner owner ) {
|
||||
super.onDestroy( owner );
|
||||
AppsListChangedLiveData.getInstance().release();
|
||||
mView = null;
|
||||
mLauncher.destroy();
|
||||
mAnalytics = null;
|
||||
if ( mLauncher != null ) {
|
||||
mLauncher.destroy();
|
||||
}
|
||||
mLauncher = null;
|
||||
}
|
||||
|
||||
public void exit() {
|
||||
if ( mView != null ) {
|
||||
mView.exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import com.mogo.commons.mvp.IView;
|
||||
import com.mogo.module.apps.model.AppInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-30
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public interface AppsView extends IView {
|
||||
|
||||
/**
|
||||
* 显示加载的app列表
|
||||
*
|
||||
* @param appInfos
|
||||
*/
|
||||
void renderApps( Map< Integer, List< AppInfo > > appInfos );
|
||||
|
||||
/**
|
||||
* 退出列表页面
|
||||
*/
|
||||
void exit();
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.mogo.module.apps.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.mogo.module.apps.R;
|
||||
import com.mogo.module.apps.adapter.base.RecycleBaseAdapter;
|
||||
import com.mogo.module.apps.adapter.base.RecycleViewHolder;
|
||||
import com.mogo.module.apps.model.AppInfo;
|
||||
import com.mogo.module.apps.model.NavigatorApp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* 2020-03-09.
|
||||
*/
|
||||
public class AppIndicatorAdapter extends RecycleBaseAdapter< AppInfo > {
|
||||
|
||||
public AppIndicatorAdapter( Context context, List< AppInfo > list ) {
|
||||
super( context, list, R.layout.module_apps_item_app_indicator );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder( RecycleViewHolder holder, AppInfo app, int position ) {
|
||||
ImageView ivIndicator = holder.getView( R.id.module_apps_id_app_icon );
|
||||
ivIndicator.setBackgroundResource( app.getIconResId() );
|
||||
ivIndicator.setOnClickListener( ( view ) -> {
|
||||
if ( getOnItemClickedListener() != null ) {
|
||||
getOnItemClickedListener().onItemClicked( app, position );
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
package com.mogo.module.apps.adapter.base;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Title: adapter
|
||||
* </p>
|
||||
* <p>
|
||||
* Description:
|
||||
* </p>
|
||||
* <p>
|
||||
* Copyright: Copyright (c) 2015
|
||||
* </p>
|
||||
* <p>
|
||||
* </p>
|
||||
*/
|
||||
public abstract class RecycleBaseAdapter< T > extends
|
||||
RecyclerView.Adapter< RecycleViewHolder > {
|
||||
|
||||
protected Context context;
|
||||
protected List< T > list;
|
||||
private int resourceID;
|
||||
|
||||
protected OnItemClickListener<T> mOnItemClickedListener;
|
||||
|
||||
/**
|
||||
* @param context
|
||||
*/
|
||||
public RecycleBaseAdapter( Context context, List< T > list, int resourceID ) {
|
||||
super();
|
||||
this.context = context;
|
||||
this.list = list;
|
||||
this.resourceID = resourceID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecycleViewHolder onCreateViewHolder( ViewGroup viewGroup, int viewType ) {
|
||||
View v = LayoutInflater.from( context ).inflate( resourceID, viewGroup,
|
||||
false );
|
||||
|
||||
RecycleViewHolder holder = RecycleViewHolder
|
||||
.get( v );
|
||||
|
||||
initHolder( holder );
|
||||
|
||||
return holder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder( RecycleViewHolder viewHolder, int position ) {
|
||||
onBindViewHolder( viewHolder, list.get( position % list.size()), position );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list == null ? 0 : list.size();
|
||||
}
|
||||
|
||||
public abstract void onBindViewHolder( RecycleViewHolder holder, T t, int position );
|
||||
|
||||
public void initHolder( RecycleViewHolder holder ) {
|
||||
|
||||
}
|
||||
|
||||
public void setDatas( List< T > list ) {
|
||||
setDatas( list, false );
|
||||
}
|
||||
|
||||
public void setDatas( List< T > list, boolean add ) {
|
||||
if ( add ) {
|
||||
this.list.addAll( list );
|
||||
} else {
|
||||
this.list = list;
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
if ( list != null ) {
|
||||
list.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public T getItem( int position ) {
|
||||
if ( list == null || list.size() == 0 ) {
|
||||
return null;
|
||||
}
|
||||
return list.get( position );
|
||||
}
|
||||
|
||||
public List< T > getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public interface OnItemClickListener< T > {
|
||||
void onItemClicked( T data, int position );
|
||||
}
|
||||
|
||||
public RecycleBaseAdapter< T > setOnItemClickedListener( OnItemClickListener< T > onItemClickedListener ) {
|
||||
this.mOnItemClickedListener = onItemClickedListener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public OnItemClickListener< T > getOnItemClickedListener() {
|
||||
return mOnItemClickedListener;
|
||||
}
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
package com.mogo.module.apps.adapter.base;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.text.SpannableString;
|
||||
import android.util.SparseArray;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class RecycleViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private SparseArray<View> mViews;
|
||||
|
||||
private View mConvertView;
|
||||
|
||||
public RecycleViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
this.mConvertView = itemView;
|
||||
mViews = new SparseArray<View>();
|
||||
}
|
||||
|
||||
public static RecycleViewHolder get(View itemView) {
|
||||
return new RecycleViewHolder(itemView);
|
||||
}
|
||||
|
||||
public View getConvertView() {
|
||||
return mConvertView;
|
||||
}
|
||||
|
||||
public <T extends View> T getView(int viewId) {
|
||||
View view = mViews.get(viewId);
|
||||
if (view == null) {
|
||||
view = mConvertView.findViewById(viewId);
|
||||
mViews.put(viewId, view);
|
||||
}
|
||||
return (T) view;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param viewId
|
||||
* @param text
|
||||
* @return
|
||||
*/
|
||||
public RecycleViewHolder setText(int viewId, String text) {
|
||||
TextView tv = getView(viewId);
|
||||
if (tv==null)return this;
|
||||
tv.setText(text);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param viewId
|
||||
* @param text
|
||||
* @return
|
||||
*/
|
||||
public RecycleViewHolder setText(int viewId, SpannableString text) {
|
||||
TextView tv = getView(viewId);
|
||||
tv.setText(text);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param viewId
|
||||
* @param resId
|
||||
* @return
|
||||
*/
|
||||
public RecycleViewHolder setImageResource(int viewId, int resId) {
|
||||
ImageView view = getView(viewId);
|
||||
view.setImageResource(resId);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param viewId
|
||||
* @return
|
||||
*/
|
||||
public RecycleViewHolder setImageBitmap(int viewId, Bitmap bitmap) {
|
||||
ImageView view = getView(viewId);
|
||||
view.setImageBitmap(bitmap);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param viewId
|
||||
* @param resId
|
||||
* @return
|
||||
*/
|
||||
// public ViewHolder setImageURI(int viewId, String url) {
|
||||
// ImageView view = getView(viewId);
|
||||
// // ImageLoader.getInstance.loadImg(view,url);
|
||||
// return this;
|
||||
// }
|
||||
|
||||
/**
|
||||
*
|
||||
* @param viewId
|
||||
* @param resId
|
||||
* @return
|
||||
*/
|
||||
public RecycleViewHolder setBackgroundImage(int viewId, int resId) {
|
||||
View view = getView(viewId);
|
||||
view.setBackgroundResource(resId);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param viewId
|
||||
* @param resId
|
||||
* @return
|
||||
*/
|
||||
public RecycleViewHolder setTextColor(int viewId, int resId) {
|
||||
TextView view = getView(viewId);
|
||||
view.setTextColor(resId);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param viewId
|
||||
* @return
|
||||
*/
|
||||
public RecycleViewHolder setOnClickListener(int viewId,
|
||||
OnClickListener listener) {
|
||||
getView(viewId).setOnClickListener(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.mogo.module.apps.anim;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-26
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public interface Anim {
|
||||
|
||||
void start();
|
||||
|
||||
void stop();
|
||||
|
||||
void setCurrentAnim( AnimRes.EmojiType type );
|
||||
|
||||
void release();
|
||||
}
|
||||
@@ -1,532 +0,0 @@
|
||||
package com.mogo.module.apps.anim;
|
||||
|
||||
|
||||
import com.mogo.module.apps.R;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-09
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AnimRes {
|
||||
|
||||
public enum EmojiType {
|
||||
Navigation,
|
||||
Music,
|
||||
Others
|
||||
}
|
||||
|
||||
public static final int sNavigation[] = {
|
||||
R.drawable.ic_navi_00000,
|
||||
R.drawable.ic_navi_00001,
|
||||
R.drawable.ic_navi_00002,
|
||||
R.drawable.ic_navi_00003,
|
||||
R.drawable.ic_navi_00004,
|
||||
R.drawable.ic_navi_00005,
|
||||
R.drawable.ic_navi_00006,
|
||||
R.drawable.ic_navi_00007,
|
||||
R.drawable.ic_navi_00008,
|
||||
R.drawable.ic_navi_00009,
|
||||
R.drawable.ic_navi_00010,
|
||||
R.drawable.ic_navi_00011,
|
||||
R.drawable.ic_navi_00012,
|
||||
R.drawable.ic_navi_00013,
|
||||
R.drawable.ic_navi_00014,
|
||||
R.drawable.ic_navi_00015,
|
||||
R.drawable.ic_navi_00016,
|
||||
R.drawable.ic_navi_00017,
|
||||
R.drawable.ic_navi_00018,
|
||||
R.drawable.ic_navi_00019,
|
||||
R.drawable.ic_navi_00020,
|
||||
R.drawable.ic_navi_00021,
|
||||
R.drawable.ic_navi_00022,
|
||||
R.drawable.ic_navi_00023,
|
||||
R.drawable.ic_navi_00024,
|
||||
R.drawable.ic_navi_00025,
|
||||
R.drawable.ic_navi_00026,
|
||||
R.drawable.ic_navi_00027,
|
||||
R.drawable.ic_navi_00028,
|
||||
R.drawable.ic_navi_00029,
|
||||
R.drawable.ic_navi_00030,
|
||||
R.drawable.ic_navi_00031,
|
||||
R.drawable.ic_navi_00032,
|
||||
R.drawable.ic_navi_00033,
|
||||
R.drawable.ic_navi_00034,
|
||||
R.drawable.ic_navi_00035
|
||||
};
|
||||
|
||||
public static final int sMusic[] = {
|
||||
R.drawable.ic_music_00000,
|
||||
R.drawable.ic_music_00001,
|
||||
R.drawable.ic_music_00002,
|
||||
R.drawable.ic_music_00003,
|
||||
R.drawable.ic_music_00004,
|
||||
R.drawable.ic_music_00005,
|
||||
R.drawable.ic_music_00006,
|
||||
R.drawable.ic_music_00007,
|
||||
R.drawable.ic_music_00008,
|
||||
R.drawable.ic_music_00009,
|
||||
R.drawable.ic_music_00010,
|
||||
R.drawable.ic_music_00011,
|
||||
R.drawable.ic_music_00012,
|
||||
R.drawable.ic_music_00013,
|
||||
R.drawable.ic_music_00014,
|
||||
R.drawable.ic_music_00015,
|
||||
R.drawable.ic_music_00016,
|
||||
R.drawable.ic_music_00017,
|
||||
R.drawable.ic_music_00018,
|
||||
R.drawable.ic_music_00019,
|
||||
R.drawable.ic_music_00020,
|
||||
R.drawable.ic_music_00021,
|
||||
R.drawable.ic_music_00022,
|
||||
R.drawable.ic_music_00023,
|
||||
R.drawable.ic_music_00024,
|
||||
R.drawable.ic_music_00025
|
||||
};
|
||||
|
||||
public static final int sBlink[] = {
|
||||
R.drawable.ic_blink_00000,
|
||||
R.drawable.ic_blink_00001,
|
||||
R.drawable.ic_blink_00002,
|
||||
R.drawable.ic_blink_00003,
|
||||
R.drawable.ic_blink_00004,
|
||||
R.drawable.ic_blink_00005,
|
||||
R.drawable.ic_blink_00006,
|
||||
R.drawable.ic_blink_00007,
|
||||
R.drawable.ic_blink_00008,
|
||||
R.drawable.ic_blink_00009,
|
||||
R.drawable.ic_blink_00010,
|
||||
R.drawable.ic_blink_00011,
|
||||
R.drawable.ic_blink_00012,
|
||||
R.drawable.ic_blink_00013,
|
||||
R.drawable.ic_blink_00014,
|
||||
R.drawable.ic_blink_00015,
|
||||
R.drawable.ic_blink_00016,
|
||||
R.drawable.ic_blink_00017,
|
||||
R.drawable.ic_blink_00018,
|
||||
R.drawable.ic_blink_00019,
|
||||
R.drawable.ic_blink_00020,
|
||||
R.drawable.ic_blink_00021,
|
||||
R.drawable.ic_blink_00022,
|
||||
R.drawable.ic_blink_00023,
|
||||
R.drawable.ic_blink_00024,
|
||||
R.drawable.ic_blink_00025,
|
||||
R.drawable.ic_blink_00026,
|
||||
R.drawable.ic_blink_00027,
|
||||
R.drawable.ic_blink_00028,
|
||||
R.drawable.ic_blink_00029,
|
||||
R.drawable.ic_blink_00030,
|
||||
R.drawable.ic_blink_00031,
|
||||
R.drawable.ic_blink_00032,
|
||||
R.drawable.ic_blink_00033,
|
||||
R.drawable.ic_blink_00034,
|
||||
R.drawable.ic_blink_00035
|
||||
};
|
||||
|
||||
public static final int sDaily[] = {
|
||||
R.drawable.ic_daily_00000,
|
||||
R.drawable.ic_daily_00001,
|
||||
R.drawable.ic_daily_00002,
|
||||
R.drawable.ic_daily_00003,
|
||||
R.drawable.ic_daily_00004,
|
||||
R.drawable.ic_daily_00005,
|
||||
R.drawable.ic_daily_00006,
|
||||
R.drawable.ic_daily_00007,
|
||||
R.drawable.ic_daily_00008,
|
||||
R.drawable.ic_daily_00009,
|
||||
R.drawable.ic_daily_00010,
|
||||
R.drawable.ic_daily_00011,
|
||||
R.drawable.ic_daily_00012,
|
||||
R.drawable.ic_daily_00013,
|
||||
R.drawable.ic_daily_00014,
|
||||
R.drawable.ic_daily_00015,
|
||||
R.drawable.ic_daily_00016,
|
||||
R.drawable.ic_daily_00017,
|
||||
R.drawable.ic_daily_00018,
|
||||
R.drawable.ic_daily_00019,
|
||||
R.drawable.ic_daily_00020,
|
||||
R.drawable.ic_daily_00021,
|
||||
R.drawable.ic_daily_00022,
|
||||
R.drawable.ic_daily_00023,
|
||||
R.drawable.ic_daily_00024,
|
||||
R.drawable.ic_daily_00025,
|
||||
R.drawable.ic_daily_00026,
|
||||
R.drawable.ic_daily_00027,
|
||||
R.drawable.ic_daily_00028,
|
||||
R.drawable.ic_daily_00029,
|
||||
R.drawable.ic_daily_00030,
|
||||
R.drawable.ic_daily_00031,
|
||||
R.drawable.ic_daily_00032,
|
||||
R.drawable.ic_daily_00033,
|
||||
R.drawable.ic_daily_00034,
|
||||
R.drawable.ic_daily_00035,
|
||||
R.drawable.ic_daily_00036,
|
||||
R.drawable.ic_daily_00037,
|
||||
R.drawable.ic_daily_00038,
|
||||
R.drawable.ic_daily_00039,
|
||||
R.drawable.ic_daily_00040,
|
||||
R.drawable.ic_daily_00041,
|
||||
R.drawable.ic_daily_00042
|
||||
};
|
||||
|
||||
public static final int sHappy1[] = {
|
||||
R.drawable.ic_happy1_00000,
|
||||
R.drawable.ic_happy1_00001,
|
||||
R.drawable.ic_happy1_00002,
|
||||
R.drawable.ic_happy1_00003,
|
||||
R.drawable.ic_happy1_00004,
|
||||
R.drawable.ic_happy1_00005,
|
||||
R.drawable.ic_happy1_00006,
|
||||
R.drawable.ic_happy1_00007,
|
||||
R.drawable.ic_happy1_00008,
|
||||
R.drawable.ic_happy1_00009,
|
||||
R.drawable.ic_happy1_00010,
|
||||
R.drawable.ic_happy1_00011,
|
||||
R.drawable.ic_happy1_00012,
|
||||
R.drawable.ic_happy1_00013,
|
||||
R.drawable.ic_happy1_00014,
|
||||
R.drawable.ic_happy1_00015,
|
||||
R.drawable.ic_happy1_00016,
|
||||
R.drawable.ic_happy1_00017,
|
||||
R.drawable.ic_happy1_00018,
|
||||
R.drawable.ic_happy1_00019,
|
||||
R.drawable.ic_happy1_00020,
|
||||
R.drawable.ic_happy1_00021,
|
||||
R.drawable.ic_happy1_00022,
|
||||
R.drawable.ic_happy1_00023,
|
||||
R.drawable.ic_happy1_00024,
|
||||
R.drawable.ic_happy1_00025,
|
||||
R.drawable.ic_happy1_00026,
|
||||
R.drawable.ic_happy1_00027,
|
||||
R.drawable.ic_happy1_00028
|
||||
};
|
||||
|
||||
public static final int sHappy2[] = {
|
||||
R.drawable.ic_happy2_00000,
|
||||
R.drawable.ic_happy2_00001,
|
||||
R.drawable.ic_happy2_00002,
|
||||
R.drawable.ic_happy2_00003,
|
||||
R.drawable.ic_happy2_00004,
|
||||
R.drawable.ic_happy2_00005,
|
||||
R.drawable.ic_happy2_00006,
|
||||
R.drawable.ic_happy2_00007,
|
||||
R.drawable.ic_happy2_00008,
|
||||
R.drawable.ic_happy2_00009,
|
||||
R.drawable.ic_happy2_00010,
|
||||
R.drawable.ic_happy2_00011,
|
||||
R.drawable.ic_happy2_00012,
|
||||
R.drawable.ic_happy2_00013,
|
||||
R.drawable.ic_happy2_00014,
|
||||
R.drawable.ic_happy2_00015,
|
||||
R.drawable.ic_happy2_00016,
|
||||
R.drawable.ic_happy2_00017,
|
||||
R.drawable.ic_happy2_00018,
|
||||
R.drawable.ic_happy2_00019,
|
||||
R.drawable.ic_happy2_00020,
|
||||
R.drawable.ic_happy2_00021
|
||||
};
|
||||
|
||||
public static final int sOverlook[] = {
|
||||
R.drawable.ic_overlooking_00000,
|
||||
R.drawable.ic_overlooking_00001,
|
||||
R.drawable.ic_overlooking_00002,
|
||||
R.drawable.ic_overlooking_00003,
|
||||
R.drawable.ic_overlooking_00004,
|
||||
R.drawable.ic_overlooking_00005,
|
||||
R.drawable.ic_overlooking_00006,
|
||||
R.drawable.ic_overlooking_00007,
|
||||
R.drawable.ic_overlooking_00008,
|
||||
R.drawable.ic_overlooking_00009,
|
||||
R.drawable.ic_overlooking_00010,
|
||||
R.drawable.ic_overlooking_00011,
|
||||
R.drawable.ic_overlooking_00012,
|
||||
R.drawable.ic_overlooking_00013,
|
||||
R.drawable.ic_overlooking_00014,
|
||||
R.drawable.ic_overlooking_00015,
|
||||
R.drawable.ic_overlooking_00016,
|
||||
R.drawable.ic_overlooking_00017,
|
||||
R.drawable.ic_overlooking_00018,
|
||||
R.drawable.ic_overlooking_00019,
|
||||
R.drawable.ic_overlooking_00020,
|
||||
R.drawable.ic_overlooking_00021,
|
||||
R.drawable.ic_overlooking_00022,
|
||||
R.drawable.ic_overlooking_00023,
|
||||
R.drawable.ic_overlooking_00024,
|
||||
R.drawable.ic_overlooking_00025,
|
||||
R.drawable.ic_overlooking_00026,
|
||||
R.drawable.ic_overlooking_00027,
|
||||
R.drawable.ic_overlooking_00028,
|
||||
R.drawable.ic_overlooking_00029,
|
||||
R.drawable.ic_overlooking_00030,
|
||||
R.drawable.ic_overlooking_00031,
|
||||
R.drawable.ic_overlooking_00032,
|
||||
R.drawable.ic_overlooking_00033,
|
||||
R.drawable.ic_overlooking_00034,
|
||||
R.drawable.ic_overlooking_00035,
|
||||
R.drawable.ic_overlooking_00036,
|
||||
R.drawable.ic_overlooking_00037,
|
||||
R.drawable.ic_overlooking_00038,
|
||||
R.drawable.ic_overlooking_00039,
|
||||
R.drawable.ic_overlooking_00040,
|
||||
R.drawable.ic_overlooking_00041,
|
||||
R.drawable.ic_overlooking_00042,
|
||||
R.drawable.ic_overlooking_00043,
|
||||
R.drawable.ic_overlooking_00044,
|
||||
R.drawable.ic_overlooking_00045,
|
||||
R.drawable.ic_overlooking_00046,
|
||||
R.drawable.ic_overlooking_00047,
|
||||
R.drawable.ic_overlooking_00048,
|
||||
R.drawable.ic_overlooking_00049,
|
||||
R.drawable.ic_overlooking_00050,
|
||||
R.drawable.ic_overlooking_00051,
|
||||
R.drawable.ic_overlooking_00052,
|
||||
R.drawable.ic_overlooking_00053,
|
||||
R.drawable.ic_overlooking_00054,
|
||||
R.drawable.ic_overlooking_00055,
|
||||
R.drawable.ic_overlooking_00056,
|
||||
R.drawable.ic_overlooking_00057,
|
||||
R.drawable.ic_overlooking_00058,
|
||||
R.drawable.ic_overlooking_00059,
|
||||
R.drawable.ic_overlooking_00060,
|
||||
R.drawable.ic_overlooking_00061,
|
||||
R.drawable.ic_overlooking_00062,
|
||||
R.drawable.ic_overlooking_00063,
|
||||
R.drawable.ic_overlooking_00064,
|
||||
R.drawable.ic_overlooking_00065,
|
||||
R.drawable.ic_overlooking_00066,
|
||||
R.drawable.ic_overlooking_00067,
|
||||
R.drawable.ic_overlooking_00068,
|
||||
R.drawable.ic_overlooking_00069,
|
||||
R.drawable.ic_overlooking_00070,
|
||||
R.drawable.ic_overlooking_00071,
|
||||
R.drawable.ic_overlooking_00072,
|
||||
R.drawable.ic_overlooking_00073,
|
||||
R.drawable.ic_overlooking_00074,
|
||||
R.drawable.ic_overlooking_00075,
|
||||
R.drawable.ic_overlooking_00076,
|
||||
R.drawable.ic_overlooking_00077,
|
||||
R.drawable.ic_overlooking_00078,
|
||||
R.drawable.ic_overlooking_00079
|
||||
};
|
||||
|
||||
public static final int sReading[] = {
|
||||
R.drawable.ic_reading_00000,
|
||||
R.drawable.ic_reading_00001,
|
||||
R.drawable.ic_reading_00002,
|
||||
R.drawable.ic_reading_00003,
|
||||
R.drawable.ic_reading_00004,
|
||||
R.drawable.ic_reading_00005,
|
||||
R.drawable.ic_reading_00006,
|
||||
R.drawable.ic_reading_00007,
|
||||
R.drawable.ic_reading_00008,
|
||||
R.drawable.ic_reading_00009,
|
||||
R.drawable.ic_reading_00010,
|
||||
R.drawable.ic_reading_00011,
|
||||
R.drawable.ic_reading_00012,
|
||||
R.drawable.ic_reading_00013,
|
||||
R.drawable.ic_reading_00014,
|
||||
R.drawable.ic_reading_00015,
|
||||
R.drawable.ic_reading_00016,
|
||||
R.drawable.ic_reading_00017,
|
||||
R.drawable.ic_reading_00018,
|
||||
R.drawable.ic_reading_00019,
|
||||
R.drawable.ic_reading_00020,
|
||||
R.drawable.ic_reading_00021,
|
||||
R.drawable.ic_reading_00022,
|
||||
R.drawable.ic_reading_00023,
|
||||
R.drawable.ic_reading_00024,
|
||||
R.drawable.ic_reading_00025,
|
||||
R.drawable.ic_reading_00026,
|
||||
R.drawable.ic_reading_00027,
|
||||
R.drawable.ic_reading_00028,
|
||||
R.drawable.ic_reading_00029,
|
||||
R.drawable.ic_reading_00030,
|
||||
R.drawable.ic_reading_00031,
|
||||
R.drawable.ic_reading_00032,
|
||||
R.drawable.ic_reading_00033,
|
||||
R.drawable.ic_reading_00034,
|
||||
R.drawable.ic_reading_00035,
|
||||
R.drawable.ic_reading_00036,
|
||||
R.drawable.ic_reading_00037,
|
||||
R.drawable.ic_reading_00038,
|
||||
R.drawable.ic_reading_00039,
|
||||
R.drawable.ic_reading_00040,
|
||||
R.drawable.ic_reading_00041,
|
||||
R.drawable.ic_reading_00042,
|
||||
R.drawable.ic_reading_00043,
|
||||
R.drawable.ic_reading_00044,
|
||||
R.drawable.ic_reading_00045,
|
||||
R.drawable.ic_reading_00046,
|
||||
R.drawable.ic_reading_00047,
|
||||
R.drawable.ic_reading_00048,
|
||||
R.drawable.ic_reading_00049,
|
||||
R.drawable.ic_reading_00050,
|
||||
R.drawable.ic_reading_00051,
|
||||
R.drawable.ic_reading_00052,
|
||||
R.drawable.ic_reading_00053,
|
||||
R.drawable.ic_reading_00054,
|
||||
R.drawable.ic_reading_00055,
|
||||
R.drawable.ic_reading_00056,
|
||||
R.drawable.ic_reading_00057,
|
||||
R.drawable.ic_reading_00058,
|
||||
R.drawable.ic_reading_00059,
|
||||
R.drawable.ic_reading_00060,
|
||||
R.drawable.ic_reading_00061,
|
||||
R.drawable.ic_reading_00062,
|
||||
R.drawable.ic_reading_00063,
|
||||
R.drawable.ic_reading_00064,
|
||||
R.drawable.ic_reading_00065,
|
||||
R.drawable.ic_reading_00066,
|
||||
R.drawable.ic_reading_00067,
|
||||
R.drawable.ic_reading_00068,
|
||||
R.drawable.ic_reading_00069,
|
||||
R.drawable.ic_reading_00070,
|
||||
R.drawable.ic_reading_00071,
|
||||
R.drawable.ic_reading_00072,
|
||||
R.drawable.ic_reading_00073,
|
||||
R.drawable.ic_reading_00074,
|
||||
R.drawable.ic_reading_00075,
|
||||
R.drawable.ic_reading_00076,
|
||||
R.drawable.ic_reading_00077,
|
||||
R.drawable.ic_reading_00078,
|
||||
R.drawable.ic_reading_00079,
|
||||
R.drawable.ic_reading_00080,
|
||||
R.drawable.ic_reading_00081,
|
||||
R.drawable.ic_reading_00082,
|
||||
R.drawable.ic_reading_00083,
|
||||
R.drawable.ic_reading_00084,
|
||||
R.drawable.ic_reading_00085,
|
||||
R.drawable.ic_reading_00086,
|
||||
R.drawable.ic_reading_00087,
|
||||
R.drawable.ic_reading_00088,
|
||||
R.drawable.ic_reading_00089,
|
||||
R.drawable.ic_reading_00090,
|
||||
R.drawable.ic_reading_00091
|
||||
};
|
||||
|
||||
public static final int[] sRunning = {
|
||||
R.drawable.ic_running_00000,
|
||||
R.drawable.ic_running_00001,
|
||||
R.drawable.ic_running_00002,
|
||||
R.drawable.ic_running_00003,
|
||||
R.drawable.ic_running_00004,
|
||||
R.drawable.ic_running_00005,
|
||||
R.drawable.ic_running_00006,
|
||||
R.drawable.ic_running_00007,
|
||||
R.drawable.ic_running_00008,
|
||||
R.drawable.ic_running_00009,
|
||||
R.drawable.ic_running_00010,
|
||||
R.drawable.ic_running_00011,
|
||||
R.drawable.ic_running_00012,
|
||||
R.drawable.ic_running_00013,
|
||||
R.drawable.ic_running_00014,
|
||||
R.drawable.ic_running_00015,
|
||||
R.drawable.ic_running_00016,
|
||||
R.drawable.ic_running_00017,
|
||||
R.drawable.ic_running_00018,
|
||||
R.drawable.ic_running_00019,
|
||||
R.drawable.ic_running_00020,
|
||||
R.drawable.ic_running_00021,
|
||||
R.drawable.ic_running_00022,
|
||||
R.drawable.ic_running_00023,
|
||||
R.drawable.ic_running_00024,
|
||||
R.drawable.ic_running_00025,
|
||||
R.drawable.ic_running_00026,
|
||||
R.drawable.ic_running_00027,
|
||||
R.drawable.ic_running_00028,
|
||||
R.drawable.ic_running_00029,
|
||||
R.drawable.ic_running_00030,
|
||||
R.drawable.ic_running_00031,
|
||||
R.drawable.ic_running_00032,
|
||||
R.drawable.ic_running_00033,
|
||||
R.drawable.ic_running_00034,
|
||||
R.drawable.ic_running_00035,
|
||||
R.drawable.ic_running_00036
|
||||
};
|
||||
|
||||
public static final int sSleep[] = {
|
||||
R.drawable.ic_sleep_00000,
|
||||
R.drawable.ic_sleep_00001,
|
||||
R.drawable.ic_sleep_00002,
|
||||
R.drawable.ic_sleep_00003,
|
||||
R.drawable.ic_sleep_00004,
|
||||
R.drawable.ic_sleep_00005,
|
||||
R.drawable.ic_sleep_00006,
|
||||
R.drawable.ic_sleep_00007,
|
||||
R.drawable.ic_sleep_00008,
|
||||
R.drawable.ic_sleep_00009,
|
||||
R.drawable.ic_sleep_00010,
|
||||
R.drawable.ic_sleep_00011,
|
||||
R.drawable.ic_sleep_00012,
|
||||
R.drawable.ic_sleep_00013,
|
||||
R.drawable.ic_sleep_00014,
|
||||
R.drawable.ic_sleep_00015,
|
||||
R.drawable.ic_sleep_00016,
|
||||
R.drawable.ic_sleep_00017,
|
||||
R.drawable.ic_sleep_00018,
|
||||
R.drawable.ic_sleep_00019,
|
||||
R.drawable.ic_sleep_00020,
|
||||
R.drawable.ic_sleep_00021,
|
||||
R.drawable.ic_sleep_00022,
|
||||
R.drawable.ic_sleep_00023,
|
||||
R.drawable.ic_sleep_00024,
|
||||
R.drawable.ic_sleep_00025,
|
||||
R.drawable.ic_sleep_00026,
|
||||
R.drawable.ic_sleep_00027,
|
||||
R.drawable.ic_sleep_00028,
|
||||
R.drawable.ic_sleep_00029,
|
||||
R.drawable.ic_sleep_00030,
|
||||
R.drawable.ic_sleep_00031,
|
||||
R.drawable.ic_sleep_00032,
|
||||
R.drawable.ic_sleep_00033,
|
||||
R.drawable.ic_sleep_00034,
|
||||
R.drawable.ic_sleep_00035,
|
||||
R.drawable.ic_sleep_00036,
|
||||
R.drawable.ic_sleep_00037,
|
||||
R.drawable.ic_sleep_00038,
|
||||
R.drawable.ic_sleep_00039,
|
||||
R.drawable.ic_sleep_00040,
|
||||
R.drawable.ic_sleep_00041
|
||||
};
|
||||
|
||||
public static final int sAll[][] = new int[][]{
|
||||
sOverlook,
|
||||
sBlink,
|
||||
sDaily,
|
||||
sHappy1,
|
||||
sReading,
|
||||
sRunning,
|
||||
sHappy2,
|
||||
sSleep
|
||||
};
|
||||
|
||||
// 需要循环的点
|
||||
public static final int sKeyPoint[] = {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
47,
|
||||
26,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
// 背景
|
||||
public static final int sBkgRes[] = {
|
||||
R.drawable.ic_common_bkg,
|
||||
R.drawable.ic_common_bkg,
|
||||
R.drawable.ic_common_bkg,
|
||||
R.drawable.ic_common_bkg,
|
||||
R.drawable.ic_common_bkg,
|
||||
R.drawable.ic_runningg_bkg,
|
||||
R.drawable.ic_common_bkg,
|
||||
R.drawable.ic_common_bkg
|
||||
};
|
||||
|
||||
public static final int sKeyPointOfNavigation = 16;
|
||||
public static final int sCommonBkgRes = R.drawable.ic_common_bkg;
|
||||
|
||||
public static int sRes[] = sAll[0];
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package com.mogo.module.apps.anim;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.mogo.module.common.utils.CarSeries;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-26
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AnimWrapper implements Anim {
|
||||
|
||||
private static final String TAG = "AnimWrapper";
|
||||
private Anim mDelegate;
|
||||
private boolean mIsStarted = false;
|
||||
|
||||
public AnimWrapper( ImageView target, ImageView bkg ) {
|
||||
if ( CarSeries.isF8xxSeries() ) {
|
||||
bkg.setVisibility( View.VISIBLE );
|
||||
mDelegate = new OthersAnim( target, bkg );
|
||||
} else {
|
||||
mDelegate = new KitkatAnim( target );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void start() {
|
||||
if ( mDelegate != null && !mIsStarted ) {
|
||||
mIsStarted = true;
|
||||
mDelegate.start();
|
||||
Logger.d( TAG, "开启小智动画" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
if ( mDelegate != null ) {
|
||||
mIsStarted = false;
|
||||
mDelegate.stop();
|
||||
Logger.d( TAG, "停止小智动画" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentAnim( AnimRes.EmojiType type ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.setCurrentAnim( type );
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isStarted() {
|
||||
return mIsStarted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.release();
|
||||
}
|
||||
mDelegate = null;
|
||||
}
|
||||
}
|
||||
@@ -1,183 +0,0 @@
|
||||
package com.mogo.module.apps.anim;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class JSurfaceView extends SurfaceView implements Runnable, SurfaceHolder.Callback {
|
||||
|
||||
private static final String TAG = "JSurfaceView";
|
||||
|
||||
private SurfaceHolder mHolder;
|
||||
|
||||
/**
|
||||
* 动画是否执行中
|
||||
*/
|
||||
private boolean bRunning = false;
|
||||
/**
|
||||
* 当前执行的第几帧
|
||||
*/
|
||||
private int mCurrentPos;
|
||||
/**
|
||||
* 动画集合
|
||||
*/
|
||||
private int[] mFrames;
|
||||
|
||||
private Thread mThread;
|
||||
|
||||
// 使用 BitmapFactory.Option.inBitmap 属性复用 bitmap 对象
|
||||
private Bitmap mContainerBitmap = null;
|
||||
|
||||
// mContainerBitmap 是否生效
|
||||
private boolean mContainerBitmapStatus = true;
|
||||
|
||||
// mContainerBitmapStatus 为 false 时,使用该缓存方案
|
||||
private Map< Integer, WeakReference< Bitmap > > mBitmapRefMap = new HashMap<>();
|
||||
|
||||
public JSurfaceView( Context context ) {
|
||||
super( context );
|
||||
init();
|
||||
}
|
||||
|
||||
public JSurfaceView( Context context, AttributeSet attrs ) {
|
||||
super( context, attrs );
|
||||
init();
|
||||
}
|
||||
|
||||
public JSurfaceView( Context context, AttributeSet attrs, int defStyleAttr ) {
|
||||
super( context, attrs, defStyleAttr );
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mHolder = getHolder();
|
||||
mHolder.addCallback( this );
|
||||
setZOrderOnTop( true );
|
||||
mHolder.setFormat( PixelFormat.TRANSLUCENT );
|
||||
}
|
||||
|
||||
public void setFrames( int[] frames ) {
|
||||
mFrames = frames;
|
||||
}
|
||||
|
||||
public void startAnim() {
|
||||
if ( bRunning ) {
|
||||
return;
|
||||
}
|
||||
bRunning = true;
|
||||
mThread = new Thread( this );
|
||||
mThread.setName( TAG + "thread" );
|
||||
mThread.start();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
bRunning = false;
|
||||
try {
|
||||
mThread.interrupt();
|
||||
mThread = null;
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while ( bRunning ) {
|
||||
drawBitmap();
|
||||
mCurrentPos++;
|
||||
try {
|
||||
Thread.sleep( 100 );
|
||||
} catch ( InterruptedException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void drawBitmap() {
|
||||
//获取画布并锁定
|
||||
Canvas canvas = mHolder.lockCanvas();
|
||||
if ( canvas == null ) {
|
||||
return;
|
||||
}
|
||||
//绘制透明色
|
||||
canvas.drawColor( Color.TRANSPARENT, PorterDuff.Mode.CLEAR );
|
||||
|
||||
int factPosition = mCurrentPos % mFrames.length;
|
||||
|
||||
if ( mContainerBitmapStatus ) {
|
||||
if ( mContainerBitmap == null ) {
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inMutable = true;
|
||||
mContainerBitmap = BitmapFactory.decodeResource( getResources(), mFrames[factPosition], options );
|
||||
} else {
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inMutable = true;
|
||||
options.inBitmap = mContainerBitmap;
|
||||
try {
|
||||
BitmapFactory.decodeResource( getResources(), mFrames[factPosition], options );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
mContainerBitmapStatus = false;
|
||||
mContainerBitmap = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( !mContainerBitmapStatus ) {
|
||||
WeakReference< Bitmap > ref = mBitmapRefMap.get( factPosition );
|
||||
if ( ref != null && ref.get() != null && !ref.get().isRecycled() ) {
|
||||
mContainerBitmap = ref.get();
|
||||
} else {
|
||||
mContainerBitmap = BitmapFactory.decodeResource( getResources(), mFrames[factPosition] );
|
||||
mBitmapRefMap.put( factPosition, new WeakReference<>( mContainerBitmap ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( mContainerBitmap == null || mContainerBitmap.isRecycled() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
Paint paint = new Paint();
|
||||
Rect mSrcRect = new Rect( 0,
|
||||
0,
|
||||
mContainerBitmap.getWidth(),
|
||||
mContainerBitmap.getHeight() ); // 图片绘制
|
||||
Rect mDestRect = new Rect( 0,
|
||||
0,
|
||||
getWidth(),
|
||||
getHeight() );// 图片绘制位置
|
||||
|
||||
canvas.drawBitmap( mContainerBitmap, mSrcRect, mDestRect, paint );
|
||||
//解锁画布,并展示bitmap到surface
|
||||
mHolder.unlockCanvasAndPost( canvas );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceCreated( SurfaceHolder holder ) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceChanged( SurfaceHolder holder, int format, int width, int height ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceDestroyed( SurfaceHolder holder ) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.mogo.module.apps.anim;
|
||||
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.mogo.module.apps.R;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-26
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class KitkatAnim implements Anim {
|
||||
|
||||
private ImageView mTarget;
|
||||
|
||||
public KitkatAnim( ImageView target ) {
|
||||
this.mTarget = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
mTarget.setImageResource( R.drawable.mogo_tts_icon_00000 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentAnim( AnimRes.EmojiType type ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
mTarget = null;
|
||||
}
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
package com.mogo.module.apps.anim;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.widget.ImageView;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-26
|
||||
* <p>
|
||||
* 导航>音乐>其他(自己轮询)
|
||||
*/
|
||||
public class OthersAnim implements Anim {
|
||||
|
||||
private ImageView mBkg;
|
||||
private int mStartIndex = 0;
|
||||
|
||||
private final static int MSG_LOOP = 3003;
|
||||
public static final int MSG_CHANGE = 3004;
|
||||
public static final long FRAME_INTERVAL = 50L;
|
||||
private boolean mStarted = false;
|
||||
|
||||
public static final long ANIM_INTERVAL = 30 * 1_000L;
|
||||
|
||||
private ImageView mImageView;
|
||||
|
||||
private int mEmojiIndex = 0;
|
||||
private int mKeyPoint = 0;
|
||||
|
||||
private Handler mHandler = new Handler( Looper.getMainLooper() ) {
|
||||
@Override
|
||||
public void handleMessage( Message msg ) {
|
||||
super.handleMessage( msg );
|
||||
try {
|
||||
switch ( msg.what ) {
|
||||
case MSG_LOOP:
|
||||
if ( mStarted ) {
|
||||
if ( AnimRes.sRes.length == 0 ) {
|
||||
return;
|
||||
}
|
||||
if ( mStartIndex >= AnimRes.sRes.length - 1 ) {
|
||||
mStartIndex = mKeyPoint;
|
||||
}
|
||||
mImageView.setImageResource( AnimRes.sRes[mStartIndex++ % AnimRes.sRes.length] );
|
||||
mHandler.sendEmptyMessageDelayed( MSG_LOOP, FRAME_INTERVAL );
|
||||
}
|
||||
break;
|
||||
case MSG_CHANGE:
|
||||
if ( mLastType == AnimRes.EmojiType.Others ) {
|
||||
boolean start = mStarted;
|
||||
stop();
|
||||
mEmojiIndex++;
|
||||
AnimRes.sRes = AnimRes.sAll[mEmojiIndex % AnimRes.sAll.length];
|
||||
mKeyPoint = AnimRes.sKeyPoint[mEmojiIndex % AnimRes.sKeyPoint.length];
|
||||
mBkg.setImageResource( AnimRes.sBkgRes[mEmojiIndex % AnimRes.sBkgRes.length] );
|
||||
mStartIndex = 0;
|
||||
if ( start ) {
|
||||
start();
|
||||
}
|
||||
mHandler.sendEmptyMessageDelayed( MSG_CHANGE, ANIM_INTERVAL );
|
||||
}
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private AnimRes.EmojiType mLastType;
|
||||
|
||||
public OthersAnim( ImageView imageView, ImageView bkg ) {
|
||||
this.mImageView = imageView;
|
||||
mBkg = bkg;
|
||||
mLastType = AnimRes.EmojiType.Others;
|
||||
AnimRes.sRes = AnimRes.sAll[mEmojiIndex];
|
||||
mBkg.setImageResource( AnimRes.sCommonBkgRes );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if ( mStarted ) {
|
||||
return;
|
||||
}
|
||||
mStarted = true;
|
||||
mHandler.sendEmptyMessage( MSG_LOOP );
|
||||
mHandler.sendEmptyMessageDelayed( MSG_CHANGE, ANIM_INTERVAL );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
mStarted = false;
|
||||
mHandler.removeMessages( MSG_LOOP );
|
||||
mHandler.removeMessages( MSG_CHANGE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentAnim( AnimRes.EmojiType type ) {
|
||||
if ( mLastType == type ) {
|
||||
return;
|
||||
}
|
||||
mLastType = type;
|
||||
switch ( type ) {
|
||||
case Navigation:
|
||||
mStartIndex = 0;
|
||||
mKeyPoint = AnimRes.sKeyPointOfNavigation;
|
||||
AnimRes.sRes = AnimRes.sNavigation;
|
||||
mBkg.setImageResource( AnimRes.sCommonBkgRes );
|
||||
break;
|
||||
case Music:
|
||||
mStartIndex = 0;
|
||||
mKeyPoint = 0;
|
||||
AnimRes.sRes = AnimRes.sMusic;
|
||||
mBkg.setImageResource( AnimRes.sCommonBkgRes );
|
||||
break;
|
||||
case Others:
|
||||
mHandler.sendEmptyMessage( MSG_CHANGE );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
stop();
|
||||
mHandler = null;
|
||||
mImageView = null;
|
||||
mBkg = null;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.mogo.module.apps.applaunch;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.module.apps.model.AppInfo;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-09
|
||||
* <p>
|
||||
* 按指定方式启动指定的app
|
||||
*/
|
||||
public interface AppLaunchFilter {
|
||||
|
||||
void launch( Context context, AppInfo appInfo );
|
||||
|
||||
void launch( Context context, String pkg );
|
||||
|
||||
void destroy();
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.mogo.module.apps.applaunch;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.module.apps.model.AppInfo;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-09
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppLauncher extends BaseAppLauncher {
|
||||
|
||||
private static final String TAG = "AppLauncher";
|
||||
|
||||
@Override
|
||||
public void launch( Context context, AppInfo appInfo ) {
|
||||
if ( !TextUtils.isEmpty( appInfo.getActivityClsName() ) ) {
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent( new ComponentName( appInfo.getPackageName(), appInfo.getActivityClsName() ) );
|
||||
try {
|
||||
intent.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
|
||||
context.startActivity( intent );
|
||||
} catch ( Exception e ) {
|
||||
launch( context, appInfo.getPackageName() );
|
||||
}
|
||||
} else {
|
||||
launch( context, appInfo.getPackageName() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if ( getNext() != null ) {
|
||||
getNext().destroy();
|
||||
setNext( null );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.mogo.module.apps.applaunch;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.module.apps.AppServiceHandler;
|
||||
import com.mogo.module.apps.R;
|
||||
import com.mogo.utils.LaunchUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-09
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public abstract class BaseAppLauncher implements AppLaunchFilter {
|
||||
|
||||
private static final String TAG = "BaseAppLauncher";
|
||||
|
||||
private AppLaunchFilter mNext;
|
||||
|
||||
public AppLaunchFilter getNext() {
|
||||
return mNext;
|
||||
}
|
||||
|
||||
public void setNext( AppLaunchFilter next ) {
|
||||
this.mNext = next;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launch( Context context, String pkg ) {
|
||||
try {
|
||||
if ( LaunchUtils.getLaunchIntentForPackage( context, pkg ) != null ) {
|
||||
AppServiceHandler.getApis().getAdasControllerApi().closeADAS();
|
||||
}
|
||||
LaunchUtils.launchByPkg( context, pkg );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
TipToast.shortTip( R.string.module_apps_str_no_app );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.mogo.module.apps.applaunch;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.map.navi.IMogoNavi;
|
||||
import com.mogo.module.apps.model.AppInfo;
|
||||
|
||||
public class GuideShowLauncher extends BaseAppLauncher {
|
||||
|
||||
public static final String TAG = "GuideShowLauncher";
|
||||
public static final String APP_INFO_NAME_GUIDE_SHOW = "新手引导";
|
||||
|
||||
private IMogoNavi mNavi;
|
||||
|
||||
public GuideShowLauncher( IMogoNavi navi ) {
|
||||
this.mNavi = navi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launch(Context context, AppInfo appInfo) {
|
||||
processChain(context, appInfo);
|
||||
}
|
||||
|
||||
private void processChain(Context context, AppInfo appInfo) {
|
||||
if (getNext() != null) {
|
||||
getNext().launch(context, appInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if (getNext() != null) {
|
||||
getNext().destroy();
|
||||
setNext(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
package com.mogo.module.apps.applaunch;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.module.apps.AppsListActivity;
|
||||
import com.mogo.module.apps.R;
|
||||
import com.mogo.module.apps.model.AppEnum;
|
||||
import com.mogo.module.apps.model.AppInfo;
|
||||
import com.mogo.utils.AppUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-05-14
|
||||
* <p>
|
||||
* 处理一些特殊的跳转
|
||||
*/
|
||||
public class InternalFunctionLauncher extends BaseAppLauncher {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
public InternalFunctionLauncher( Context activity ) {
|
||||
this.mContext = activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launch( Context context, AppInfo appInfo ) {
|
||||
switch ( appInfo.getPackageName() ) {
|
||||
case "com.mogo.launcher.applist":
|
||||
AppsListActivity.start( mContext );
|
||||
break;
|
||||
case "com.zhidao.bluetooth":
|
||||
if ( TextUtils.equals( "蓝牙音乐", appInfo.getName() ) ) {
|
||||
startActivity( context, appInfo, "com.zhidao.bluetooth.ui.MusicActivity" );
|
||||
} else if ( TextUtils.equals( "蓝牙电话", appInfo.getName() ) ) {
|
||||
startActivity( context, appInfo, "com.zhidao.bluetooth.ui.MainActivity" );
|
||||
}
|
||||
break;
|
||||
case "com.zhidao.music":
|
||||
if ( AppUtils.isAppInstalled( AbsMogoApplication.getApp(), AppEnum.KwMusic.getPkg() ) ) {
|
||||
try {
|
||||
launch( context, AppEnum.KwMusic.getPkg() );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if ( AppUtils.isAppInstalled( AbsMogoApplication.getApp(), AppEnum.QQMusic.getPkg() ) ) {
|
||||
try {
|
||||
launch( context, AppEnum.QQMusic.getPkg() );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
TipToast.shortTip( R.string.module_apps_str_no_app );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if ( getNext() != null ) {
|
||||
getNext().launch( context, appInfo );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void startActivity( Context context, AppInfo target, String page ) {
|
||||
if ( context == null || target == null ) {
|
||||
return;
|
||||
}
|
||||
if ( TextUtils.isEmpty( page ) ) {
|
||||
if ( getNext() != null ) {
|
||||
getNext().launch( context, target );
|
||||
return;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent( new ComponentName( target.getPackageName(), page ) );
|
||||
intent.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
|
||||
context.startActivity( intent );
|
||||
} catch ( Exception e ) {
|
||||
TipToast.shortTip( "APP未安装" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if ( getNext() != null ) {
|
||||
getNext().destroy();
|
||||
setNext( null );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
package com.mogo.module.apps.model;
|
||||
|
||||
import com.mogo.module.apps.R;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-12
|
||||
* <p>
|
||||
* 定制化的 app 列表
|
||||
* <p>
|
||||
* <p>
|
||||
* 自研类:QQ音乐、车聊聊、探路、新鲜事、福利、蘑菇小队、行车记录仪、懒人听书、一键清理、系统升级
|
||||
* 第三方:车机微信助手、爱奇艺、喜马拉雅
|
||||
* 基础类:均衡器、方控学习、蓝牙、FM、车载设置、AUX
|
||||
*/
|
||||
public enum AppEnum {
|
||||
// 酷我音乐
|
||||
KwMusic("酷我音乐", "cn.kuwo.kwmusiccar", R.drawable.ic_kuwo),
|
||||
// 爱趣听
|
||||
WeCarFlow("爱趣听","com.tencent.wecarflow", R.drawable.module_apps_ic_we_car_flow ),
|
||||
//"QQ音乐",
|
||||
QQMusic( "QQ音乐", "com.pvetec.musics", R.drawable.module_apps_ic_qq_music ),
|
||||
|
||||
//"车聊聊",
|
||||
Im( "车聊聊", "com.zhidao.imdemo", R.drawable.module_apps_ic_im ),
|
||||
|
||||
//"探路",
|
||||
// RoadCondition( "探路", "com.zhidao.roadcondition", R.drawable.module_apps_ic_road_condition ),
|
||||
// RoadConditionSlit( "探路", "com.zhidao.roadcondition.split", R.drawable.module_apps_ic_road_condition ),
|
||||
|
||||
//"福利",
|
||||
Welfare( "福利", "com.zhidaohulian.welfare.car", R.drawable.module_apps_ic_welfare ),
|
||||
|
||||
//"蘑菇小队",
|
||||
Fleet( "蘑菇小队", "com.zhidao.fleet", R.drawable.module_apps_ic_fleet ),
|
||||
|
||||
//"行车记录仪",
|
||||
CarCorder( "行车记录仪", "com.zhidao.carcorder", R.drawable.module_apps_ic_carcorder ),
|
||||
|
||||
//"懒人听书",
|
||||
Lrts( "懒人听书", "com.zhidao.lrts", R.drawable.module_apps_ic_lrts ),
|
||||
|
||||
//"一键清理",
|
||||
CleanMaster( "一键清理", "com.zhidao.cleanmaster", R.drawable.module_apps_ic_clean_master ),
|
||||
|
||||
//"系统升级",
|
||||
Fota( "系统升级", "com.abupdate.fota_demo_iot", R.drawable.module_apps_ic_fota ),
|
||||
|
||||
//"微信车机助手",
|
||||
WechatHelper( "微信车机助手", "com.zhidao.wechathelper", R.drawable.module_apps_ic_wechat ),
|
||||
|
||||
//"爱奇艺HD",
|
||||
Qiyi( "爱奇艺HD", "com.qiyi.video.pad", R.drawable.module_apps_ic_qiyi ),
|
||||
|
||||
//"喜马拉雅",
|
||||
Ximalaya( "喜马拉雅", "com.ximalaya.ting.android.car", R.drawable.module_apps_ic_ximalaya ),
|
||||
|
||||
//"均衡器",
|
||||
Equlizer( "均衡器", "com.zhidao.equalizer", R.drawable.module_apps_ic_equlizer ),
|
||||
Equlizer_NWD( "均衡器", "com.nwd.audioset", R.drawable.module_apps_ic_equlizer ),
|
||||
|
||||
//"方控学习",
|
||||
SteerProduct( "方控学习", "com.zd.steerproduct", R.drawable.module_apps_ic_stee_product ),
|
||||
SteerProduct_NWD( "方控学习", "com.nwd.wheel.learning", R.drawable.module_apps_ic_stee_product ),
|
||||
|
||||
//"车载设置",
|
||||
CarSettings( "车载设置", "com.zhidao.settings", R.drawable.module_apps_ic_car_setting ),
|
||||
|
||||
//"AUX",
|
||||
AUX( "AUX", "com.nwd.auxin", R.drawable.module_apps_ic_aux ),
|
||||
|
||||
//FM
|
||||
FM( "FM收音机", "com.nwd.radio", R.drawable.module_apps_ic_fm ),
|
||||
|
||||
// 新鲜事
|
||||
FreshThings( "新鲜事", "com.zhidao.fresh.things", R.drawable.module_apps_ic_fresh_things ),
|
||||
|
||||
// 个人中心
|
||||
PersonCenter( "个人中心", "com.zhidao.auto.personal", R.drawable.module_apps_ic_personal_center ),
|
||||
|
||||
// 本地视频
|
||||
LocalVideo( "本地视频", "com.zhidao.video", R.drawable.module_apps_ic_local_video ),
|
||||
LocalVideo_NWD( "本地视频", "com.nwd.android.video.ui", R.drawable.module_apps_ic_local_video ),
|
||||
|
||||
// 车辆信息
|
||||
CanBus( "车辆信息", "com.nwd.can.setting", R.drawable.module_apps_ic_canbus ),
|
||||
|
||||
// 蓝牙电话
|
||||
BT_PHONE_NWD( "蓝牙电话", "com.nwd.android.phone", R.drawable.module_apps_ic_bt_phone ),
|
||||
BT_PHONE( "蓝牙电话", "com.zhidao.bluetooth", R.drawable.module_apps_ic_bt_phone ),
|
||||
|
||||
// 本地音乐
|
||||
LOCAL_MUSIC( "本地音乐", "com.nwd.android.music.ui", R.drawable.module_apps_ic_local_music ),
|
||||
|
||||
// 天气
|
||||
WEATHER( "天气", "com.zhidao.weather", R.drawable.module_apps_ic_weather ),
|
||||
|
||||
// 蓝牙音乐
|
||||
BT_MUSIC_NWD( "蓝牙音乐", "com.nwd.bt.music", R.drawable.module_apps_ic_bt_music ),
|
||||
BT_MUSIC( "蓝牙音乐", "com.zhidao.bluetooth", R.drawable.module_apps_ic_bt_music ),
|
||||
|
||||
// 高德地图
|
||||
AUTO_NAVI( "高德地图", "com.autonavi.amapauto", R.drawable.module_apps_ic_auto_navi ),
|
||||
;
|
||||
|
||||
private String mName;
|
||||
private String mPkg;
|
||||
private int mIconResId;
|
||||
|
||||
AppEnum( String name, String pkg, int iconResId ) {
|
||||
this.mName = name;
|
||||
this.mPkg = pkg;
|
||||
this.mIconResId = iconResId;
|
||||
}
|
||||
|
||||
public String getPkg() {
|
||||
return mPkg;
|
||||
}
|
||||
|
||||
public int getIconResId() {
|
||||
return mIconResId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.mogo.module.apps.model;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-12
|
||||
* <p>
|
||||
* 定制化的app
|
||||
*/
|
||||
public class AppEnumHelper {
|
||||
|
||||
private static Map< String, AppEnum > sCustomizedApps = new HashMap<>();
|
||||
|
||||
static {
|
||||
AppEnum[] customizedApps = AppEnum.values();
|
||||
for ( AppEnum customizedApp : customizedApps ) {
|
||||
sCustomizedApps.put( customizedApp.getPkg(), customizedApp );
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isCustomizedApp( String pkg ) {
|
||||
return sCustomizedApps.containsKey( pkg );
|
||||
}
|
||||
|
||||
public static int getCustomizedAppIconResId( String pkg ) {
|
||||
AppEnum appEnum = sCustomizedApps.get( pkg );
|
||||
if ( appEnum != null ) {
|
||||
return appEnum.getIconResId();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static String getTargetName(String pkg){
|
||||
AppEnum appEnum = sCustomizedApps.get( pkg );
|
||||
if ( appEnum != null ) {
|
||||
return appEnum.getName();
|
||||
}
|
||||
return pkg;
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
package com.mogo.module.apps.model;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-30
|
||||
* <p>
|
||||
* app 信息
|
||||
*/
|
||||
public class AppInfo {
|
||||
|
||||
private final String mName;
|
||||
private final String mPackageName;
|
||||
private final String mActivityClsName;
|
||||
private final String mVersionName;
|
||||
private final int mVersionCode;
|
||||
private final Drawable mIcon;
|
||||
private final int mIconResId;
|
||||
private final int mTrackType; // 埋点类型
|
||||
|
||||
public AppInfo( String mName, String mPackageName, String mActivityClsName, String mVersionName, int mVersionCode, Drawable mIcon, int mIconResId, int mTrackType ) {
|
||||
this.mName = mName;
|
||||
this.mPackageName = mPackageName;
|
||||
this.mActivityClsName = mActivityClsName;
|
||||
this.mVersionName = mVersionName;
|
||||
this.mVersionCode = mVersionCode;
|
||||
this.mIcon = mIcon;
|
||||
this.mIconResId = mIconResId;
|
||||
this.mTrackType = mTrackType;
|
||||
}
|
||||
|
||||
public AppInfo( String mName, String mPackageName, String mVersionName, int mVersionCode, Drawable mIcon, int mIconResId, int mTrackType ) {
|
||||
this( mName, mPackageName,"", mVersionName, mVersionCode, mIcon, mIconResId, mTrackType );
|
||||
}
|
||||
|
||||
public AppInfo( String mName, String mPackageName, String mVersionName, int mVersionCode, Drawable mIcon, int mIconResId ) {
|
||||
this( mName, mPackageName,"", mVersionName, mVersionCode, mIcon, mIconResId, 0 );
|
||||
}
|
||||
|
||||
public int getIconResId() {
|
||||
return mIconResId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
public String getActivityClsName() {
|
||||
return mActivityClsName;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return mPackageName;
|
||||
}
|
||||
|
||||
public String getVersionName() {
|
||||
return mVersionName;
|
||||
}
|
||||
|
||||
public int getVersionCode() {
|
||||
return mVersionCode;
|
||||
}
|
||||
|
||||
public Drawable getIcon() {
|
||||
return mIcon;
|
||||
}
|
||||
|
||||
public int getTrackType() {
|
||||
return mTrackType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( Object o ) {
|
||||
if ( this == o ) return true;
|
||||
if ( o == null || getClass() != o.getClass() ) return false;
|
||||
AppInfo appInfo = ( AppInfo ) o;
|
||||
return TextUtils.equals( mPackageName, appInfo.mPackageName )
|
||||
&& TextUtils.equals( mName, appInfo.mName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash( mPackageName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AppInfo{" +
|
||||
"mName='" + mName + '\'' +
|
||||
", mPackageName='" + mPackageName + '\'' +
|
||||
", mVersionName='" + mVersionName + '\'' +
|
||||
", mVersionCode=" + mVersionCode +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.mogo.module.apps.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-09
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public interface AppLoadCallback {
|
||||
|
||||
void onLoaded( Map< Integer, List< AppInfo > > appInfos );
|
||||
}
|
||||
@@ -1,281 +0,0 @@
|
||||
package com.mogo.module.apps.model;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.module.apps.AppFilterImpl;
|
||||
import com.mogo.module.apps.AppsConst;
|
||||
import com.mogo.module.apps.AppsListChangedLiveData;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-09
|
||||
* <p>
|
||||
* 加载并保存 app 列表
|
||||
*/
|
||||
public class AppsModel {
|
||||
|
||||
private static final String TAG = "AppsModel";
|
||||
|
||||
private static volatile AppsModel sInstance;
|
||||
private Context mContext;
|
||||
|
||||
private Map< Integer, List< AppInfo > > mPagedApps = new HashMap<>();
|
||||
|
||||
private AppsModel( Context context ) {
|
||||
mContext = context.getApplicationContext();
|
||||
}
|
||||
|
||||
public static AppsModel getInstance( Context context ) {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( AppsModel.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new AppsModel( context );
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
|
||||
private AtomicBoolean mIsLoaded = new AtomicBoolean( false );
|
||||
|
||||
public synchronized void release() {
|
||||
if ( mPagedApps != null ) {
|
||||
mPagedApps.clear();
|
||||
}
|
||||
mContext = null;
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
public void load( AppLoadCallback callback ) {
|
||||
if ( !mPagedApps.isEmpty() ) {
|
||||
if ( callback != null ) {
|
||||
callback.onLoaded( mPagedApps );
|
||||
}
|
||||
return;
|
||||
}
|
||||
try {
|
||||
AppFilterImpl.loadExternalFilterPackagesList();
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
final PackageManager packageManager = mContext.getPackageManager();
|
||||
List< PackageInfo > packages = packageManager.getInstalledPackages( 0 );
|
||||
int counter = 0;
|
||||
for ( int i = 0; i < packages.size(); ++i ) {
|
||||
PackageInfo packageInfo = packages.get( i );
|
||||
if ( AppFilterImpl.sFilter( packageInfo ) ) {
|
||||
if ( DebugConfig.isDebug() ) {
|
||||
if ( AppFilterImpl.isSelfApp( packageInfo ) ) {
|
||||
counter = addSelfLauncher( mContext, packageManager, packageInfo, counter );
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
List< ResolveInfo > resolveInfoList = getApkLaunchResolveInfoForInstalled( mContext, packageInfo.packageName );
|
||||
if ( resolveInfoList == null || resolveInfoList.isEmpty() ) {
|
||||
continue;
|
||||
}
|
||||
for ( ResolveInfo resolveInfo : resolveInfoList ) {
|
||||
if ( resolveInfo == null ) {
|
||||
continue;
|
||||
}
|
||||
int page = counter++ / AppsConst.TOTAL_SIZE_EACH_PAGE;
|
||||
addApp( packageManager, packageInfo, resolveInfo, page );
|
||||
}
|
||||
}
|
||||
if ( callback != null ) {
|
||||
callback.onLoaded( mPagedApps );
|
||||
}
|
||||
mIsLoaded.set( true );
|
||||
}
|
||||
|
||||
private int addSelfLauncher( Context context,
|
||||
PackageManager packageManager,
|
||||
PackageInfo packageInfo,
|
||||
int counter ) {
|
||||
List< ResolveInfo > resolveInfoList = getApkLaunchResolveInfoForInstalled( context, packageInfo.packageName );
|
||||
if ( resolveInfoList == null || resolveInfoList.isEmpty() ) {
|
||||
return counter;
|
||||
}
|
||||
for ( ResolveInfo resolveInfo : resolveInfoList ) {
|
||||
if ( resolveInfo == null ) {
|
||||
continue;
|
||||
}
|
||||
if ( TextUtils.equals( resolveInfo.activityInfo.name,
|
||||
"com.zhidao.mogo.module.main.launcher.MainLauncherActivity" ) ) {
|
||||
continue;
|
||||
}
|
||||
int page = counter++ / AppsConst.TOTAL_SIZE_EACH_PAGE;
|
||||
addApp( packageManager, packageInfo, resolveInfo, page );
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有可以启动的ResolveInfo,其中包含所有activity及其Icon
|
||||
*
|
||||
* @param context context of the operation
|
||||
* @return all app lists
|
||||
*/
|
||||
public static List< ResolveInfo > getApkLaunchResolveInfoForInstalled( Context context,
|
||||
String packageName ) {
|
||||
List< ResolveInfo > apps = null;
|
||||
if ( null != context ) {
|
||||
PackageManager manager = context.getPackageManager();
|
||||
Intent mainIntent = new Intent( Intent.ACTION_MAIN, null );
|
||||
mainIntent.addCategory( Intent.CATEGORY_LAUNCHER );
|
||||
if ( null != packageName && !packageName.isEmpty() ) {
|
||||
mainIntent.setPackage( packageName );
|
||||
}
|
||||
apps = manager.queryIntentActivities( mainIntent, 0 );
|
||||
}
|
||||
return null == apps ? new ArrayList<>() : apps;
|
||||
}
|
||||
|
||||
private void addApp( PackageManager packageManager,
|
||||
PackageInfo packageInfo,
|
||||
ResolveInfo resolveInfo,
|
||||
int page ) {
|
||||
if ( mPagedApps.get( page ) == null ) {
|
||||
mPagedApps.put( page, new ArrayList<>() );
|
||||
}
|
||||
mPagedApps.get( page ).add( wrapAppInfo( packageManager, packageInfo, resolveInfo ) );
|
||||
}
|
||||
|
||||
private AppInfo wrapAppInfo( PackageManager packageManager,
|
||||
PackageInfo packageInfo,
|
||||
ResolveInfo resolveInfo ) {
|
||||
String appName = getApplicationName( packageManager, packageInfo );
|
||||
String packageName = packageInfo.packageName;
|
||||
String versionName = packageInfo.versionName;
|
||||
int versionCode = packageInfo.versionCode;
|
||||
int iconResId = AppEnumHelper.getCustomizedAppIconResId( packageName );
|
||||
Drawable appIcon = null;
|
||||
if ( iconResId == 0 ) {
|
||||
if ( resolveInfo != null
|
||||
&& resolveInfo.activityInfo != null
|
||||
&& !TextUtils.equals( packageName, resolveInfo.activityInfo.processName ) ) {
|
||||
appIcon = resolveInfo.activityInfo.loadIcon( packageManager );
|
||||
appName = resolveInfo.activityInfo.loadLabel( packageManager ).toString();
|
||||
}
|
||||
if ( appIcon == null ) {
|
||||
appIcon = packageInfo.applicationInfo.loadIcon( packageManager );
|
||||
}
|
||||
}
|
||||
return new AppInfo( appName, packageName, resolveInfo != null ? resolveInfo.activityInfo.name : null, versionName, versionCode, appIcon, iconResId, 0 );
|
||||
}
|
||||
|
||||
public void appAdded( String packageName ) {
|
||||
if ( !mIsLoaded.get() ) {
|
||||
return;
|
||||
}
|
||||
if ( TextUtils.isEmpty( packageName ) ) {
|
||||
return;
|
||||
}
|
||||
if ( mPagedApps == null || mPagedApps.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final PackageManager packageManager = mContext.getPackageManager();
|
||||
PackageInfo packageInfo = packageManager.getPackageInfo( packageName, 0 );
|
||||
if ( !AppFilterImpl.sFilter( packageInfo ) ) {
|
||||
int pageIndex = getPageIndex( packageName, true );
|
||||
addApp( packageManager, packageInfo, null, pageIndex );
|
||||
}
|
||||
AppsListChangedLiveData.getInstance().postValue( true );
|
||||
} catch ( PackageManager.NameNotFoundException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private String getApplicationName( PackageManager packageManager, PackageInfo packageInfo ) {
|
||||
String name = packageManager.getApplicationLabel( packageInfo.applicationInfo ).toString();
|
||||
if ( AppEnumHelper.isCustomizedApp( packageInfo.packageName ) ) {
|
||||
return AppEnumHelper.getTargetName( packageInfo.packageName );
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
private int getPageIndex( String packageName, boolean add ) {
|
||||
int totalPages = mPagedApps.size();
|
||||
if ( add ) {
|
||||
if ( totalPages == 0 ) {
|
||||
return 0;
|
||||
} else {
|
||||
if ( mPagedApps.get( totalPages - 1 ) == null
|
||||
|| mPagedApps.get( totalPages - 1 ).size() == AppsConst.TOTAL_SIZE_EACH_PAGE ) {
|
||||
return totalPages;
|
||||
} else {
|
||||
return totalPages - 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( totalPages == 0 ) {
|
||||
return -1;
|
||||
}
|
||||
int pageIndex = -1;
|
||||
for ( int i = 0; i < totalPages; i++ ) {
|
||||
for ( AppInfo appInfo : mPagedApps.get( i ) ) {
|
||||
if ( TextUtils.equals( appInfo.getPackageName(), packageName ) ) {
|
||||
pageIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return pageIndex;
|
||||
}
|
||||
}
|
||||
|
||||
public void appRemoved( String packageName ) {
|
||||
if ( !mIsLoaded.get() ) {
|
||||
return;
|
||||
}
|
||||
if ( TextUtils.isEmpty( packageName ) ) {
|
||||
return;
|
||||
}
|
||||
if ( mPagedApps == null || mPagedApps.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
int pageIndex = getPageIndex( packageName, false );
|
||||
if ( pageIndex == -1 ) {
|
||||
return;
|
||||
}
|
||||
int totalPages = mPagedApps.size();
|
||||
List< AppInfo > dynamicAppsList = new ArrayList<>();
|
||||
for ( int i = pageIndex; i < totalPages; i++ ) {
|
||||
dynamicAppsList.addAll( mPagedApps.remove( i ) );
|
||||
}
|
||||
int counter = 0;
|
||||
for ( int i = 0; i < dynamicAppsList.size(); i++ ) {
|
||||
AppInfo appInfo = dynamicAppsList.get( i );
|
||||
if ( TextUtils.equals( appInfo.getPackageName(), packageName ) ) {
|
||||
continue;
|
||||
}
|
||||
int page = counter++ / AppsConst.TOTAL_SIZE_EACH_PAGE + pageIndex;
|
||||
if ( mPagedApps.get( page ) == null ) {
|
||||
mPagedApps.put( page, new ArrayList<>() );
|
||||
}
|
||||
mPagedApps.get( page ).add( appInfo );
|
||||
}
|
||||
AppsListChangedLiveData.getInstance().postValue( true );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.mogo.module.apps.model;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-13
|
||||
* <p>
|
||||
* app
|
||||
*/
|
||||
public class NavigatorApp {
|
||||
|
||||
@DrawableRes
|
||||
public int mIconId;
|
||||
@DrawableRes
|
||||
public int mUncheckedIconId;
|
||||
public String mName;
|
||||
|
||||
public NavigatorApp( int mIconId, int mUncheckedIconId, String mName ) {
|
||||
this.mIconId = mIconId;
|
||||
this.mUncheckedIconId = mUncheckedIconId;
|
||||
this.mName = mName;
|
||||
}
|
||||
|
||||
public int getIconId() {
|
||||
return mIconId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.mogo.module.apps.model;
|
||||
|
||||
import com.mogo.module.apps.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-13
|
||||
* <p>
|
||||
* app
|
||||
*/
|
||||
public class NavigatorApps {
|
||||
|
||||
private static AppInfo app = new AppInfo( "高德地图", "com.autonavi.amapauto", "", 0, null, R.drawable.module_apps_ic_navigator_navi_selector, 1 );
|
||||
private static AppInfo app_ = new AppInfo( "高德地图", "com.autonavi.amapauto", "", 0, null, R.drawable.module_apps_ic_navigator_navi_disable, 1 );
|
||||
// private static AppInfo app2 = new AppInfo( "音乐", "com.tencent.wecarflow", "", 0, null, R.drawable.module_apps_ic_navigator_media, 2 );
|
||||
private static AppInfo app2 = new AppInfo( "音乐", "com.zhidao.music", "", 0, null, R.drawable.module_apps_ic_navigator_media_selector, 2 );
|
||||
// private static AppInfo app3 = new AppInfo( "车聊聊", "com.zhidao.imdemo", "", 0, null, R.drawable.module_apps_ic_navigator_im_selector, 6 );
|
||||
private static AppInfo app4 = new AppInfo( "全部应用", "com.mogo.launcher.applist", "", 0, null, R.drawable.module_apps_ic_navigator_applist_selector, 4 );
|
||||
|
||||
public static List< AppInfo > getApps() {
|
||||
List< AppInfo > sApps = new ArrayList<>();
|
||||
sApps.add( app );
|
||||
sApps.add( app2 );
|
||||
// sApps.add( app3 );
|
||||
sApps.add( app4 );
|
||||
return sApps;
|
||||
}
|
||||
|
||||
public static List< AppInfo > getAppsWithoutNavigation() {
|
||||
List< AppInfo > sApps = new ArrayList<>();
|
||||
sApps.add( app );
|
||||
sApps.add( app2 );
|
||||
// sApps.add( app3 );
|
||||
sApps.add( app4 );
|
||||
return sApps;
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.mogo.module.apps.model;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.module.common.utils.CarSeries;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-02
|
||||
* <p>
|
||||
* 扫描不到的app
|
||||
*/
|
||||
public class UnScannedApps {
|
||||
|
||||
private static List< AppInfo > sUnScannedApps = new ArrayList<>();
|
||||
|
||||
static {
|
||||
if ( CarSeries.isF8xxSeries() ) {
|
||||
sUnScannedApps.add( new AppInfo( AppEnum.BT_PHONE.getName(), AppEnum.BT_PHONE.getPkg(), null, 0, null, AppEnum.BT_PHONE.getIconResId() ) );
|
||||
sUnScannedApps.add( new AppInfo( AppEnum.BT_MUSIC.getName(), AppEnum.BT_MUSIC.getPkg(), null, 0, null, AppEnum.BT_PHONE.getIconResId() ) );
|
||||
} else {
|
||||
sUnScannedApps.add( new AppInfo( AppEnum.BT_PHONE_NWD.getName(), AppEnum.BT_PHONE_NWD.getPkg(), null, 0, null, AppEnum.BT_PHONE_NWD.getIconResId() ) );
|
||||
sUnScannedApps.add( new AppInfo( AppEnum.CanBus.getName(), AppEnum.CanBus.getPkg(), null, 0, null, AppEnum.CanBus.getIconResId() ) );
|
||||
}
|
||||
}
|
||||
|
||||
public static List< AppInfo > getUnScannedApps() {
|
||||
return sUnScannedApps;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
|
||||
package com.mogo.module.apps.receiver;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.module.apps.AppServiceHandler;
|
||||
import com.mogo.module.apps.model.AppsModel;
|
||||
|
||||
public class AppInstallReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive( Context context, Intent intent ) {
|
||||
if ( intent.getAction().equals( Intent.ACTION_PACKAGE_ADDED ) ) {
|
||||
String packageName = intent.getData().getSchemeSpecificPart();
|
||||
AppsModel.getInstance( context ).appAdded( packageName );
|
||||
if ( TextUtils.equals( packageName, "com.zhidao.autopilot" ) ) {
|
||||
AppServiceHandler.getApis().getAdasControllerApi().showADAS();
|
||||
}
|
||||
}
|
||||
if ( intent.getAction().equals( Intent.ACTION_PACKAGE_REMOVED ) ) {
|
||||
String packageName = intent.getData().getSchemeSpecificPart();
|
||||
AppsModel.getInstance( context ).appRemoved( packageName );
|
||||
}
|
||||
if ( intent.getAction().equals( Intent.ACTION_PACKAGE_REPLACED ) ) {
|
||||
String packageName = intent.getData().getSchemeSpecificPart();
|
||||
if ( TextUtils.equals( packageName, "com.zhidao.autopilot" ) ) {
|
||||
AppServiceHandler.getApis().getAdasControllerApi().showADAS();
|
||||
}
|
||||
}
|
||||
if ( intent.getAction().equals( Intent.ACTION_PACKAGE_CHANGED ) ) {
|
||||
String packageName = intent.getData().getSchemeSpecificPart();
|
||||
}
|
||||
if ( intent.getAction().equals( Intent.ACTION_PACKAGE_RESTARTED ) ) {
|
||||
String packageName = intent.getData().getSchemeSpecificPart();
|
||||
}
|
||||
if ( intent.getAction().equals( Intent.ACTION_PACKAGE_DATA_CLEARED ) ) {
|
||||
String packageName = intent.getData().getSchemeSpecificPart();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
package com.mogo.module.apps.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
/**
|
||||
* Created by zeu on 2017/11/14.
|
||||
*/
|
||||
|
||||
public class GridAverageView extends ViewGroup {
|
||||
int mColumnCount = 1;
|
||||
int mRowCount = 1;
|
||||
|
||||
/**
|
||||
* 网格均等分布
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
public GridAverageView( Context context ) {
|
||||
super( context );
|
||||
}
|
||||
|
||||
public GridAverageView( Context context, @Nullable AttributeSet attrs ) {
|
||||
this( context, attrs, 0 );
|
||||
}
|
||||
|
||||
public GridAverageView( Context context, @Nullable AttributeSet attrs, int defStyleAttr ) {
|
||||
super( context, attrs, defStyleAttr );
|
||||
}
|
||||
|
||||
public void setColumnCount( int mColumnCount ) {
|
||||
this.mColumnCount = mColumnCount;
|
||||
}
|
||||
|
||||
public void setRowCount( int mRowCount ) {
|
||||
this.mRowCount = mRowCount;
|
||||
}
|
||||
|
||||
public int getColumnCount() {
|
||||
return mColumnCount;
|
||||
}
|
||||
|
||||
public int getRowCount() {
|
||||
return mRowCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure( int widthMeasureSpec, int heightMeasureSpec ) {
|
||||
int averageWidth = MeasureSpec.getSize( widthMeasureSpec ) / getColumnCount();
|
||||
int averageHeight = MeasureSpec.getSize( heightMeasureSpec ) / getRowCount();
|
||||
for ( int i = 0; i < getChildCount(); i++ ) {
|
||||
View child = this.getChildAt( i );
|
||||
child.measure( MeasureSpec.makeMeasureSpec( averageWidth, MeasureSpec.EXACTLY ), MeasureSpec.makeMeasureSpec( averageHeight, MeasureSpec.EXACTLY ) );
|
||||
}
|
||||
setMeasuredDimension( widthMeasureSpec, heightMeasureSpec );
|
||||
super.onMeasure( widthMeasureSpec, heightMeasureSpec );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout( boolean changed, int l, int t, int r, int b ) {
|
||||
int width = r - l - getPaddingLeft() - getPaddingRight();
|
||||
int height = b - t - getPaddingBottom() - getPaddingTop();
|
||||
int childWidth = width / getColumnCount();
|
||||
int childHeight = height / getRowCount();
|
||||
|
||||
int size = getChildCount();
|
||||
for ( int i = 0; i < size; i++ ) {
|
||||
View child = getChildAt( i );
|
||||
int row = i / getColumnCount();
|
||||
int col = i % getColumnCount();
|
||||
int cl = 0 + childWidth * col;
|
||||
int cr = cl + childWidth;
|
||||
|
||||
int ct = 0 + childHeight * row;
|
||||
int cb = ct + childHeight;
|
||||
child.layout( cl, ct, cr, cb );
|
||||
}
|
||||
}
|
||||
|
||||
public void setAdapter( BaseAdapter adapter ) {
|
||||
if ( adapter == null ) {
|
||||
return;
|
||||
}
|
||||
final int size = adapter.getCount();
|
||||
if ( size <= 0 ) {
|
||||
return;
|
||||
}
|
||||
for ( int i = 0; i < size; i++ ) {
|
||||
View childView = adapter.getView( i, null, this );
|
||||
addView( childView );
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.mogo.module.apps.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.widget.Scroller;
|
||||
|
||||
public class GridViewPagerScroller extends Scroller {
|
||||
private int duration;
|
||||
|
||||
public GridViewPagerScroller( Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public GridViewPagerScroller( Context context, Interpolator interpolator) {
|
||||
super(context, interpolator);
|
||||
}
|
||||
|
||||
public void setDuration(int duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startScroll(int startX, int startY, int dx, int dy) {
|
||||
super.startScroll(startX, startY, dx, dy,this.duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startScroll(int startX, int startY, int dx, int dy, int duration) {
|
||||
super.startScroll(startX, startY, dx, dy, this.duration);
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package com.mogo.module.apps.view;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.device.Devices;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/6/9
|
||||
*
|
||||
* 如果已经激活设备,则按照正常流程打开语音,否则需要连续点击5下小智才能激活语音功能
|
||||
*/
|
||||
class OnAiAssistClickListener implements View.OnClickListener {
|
||||
|
||||
public static final int TOTAL_CLICK_AMOUNT = 5;
|
||||
public static final int INTERVAL = 2_000 / TOTAL_CLICK_AMOUNT;
|
||||
|
||||
private int mClickCounter = 0;
|
||||
private long mLastClickTime = 0L;
|
||||
|
||||
private boolean mDebugModeOpen = false;
|
||||
|
||||
@Override
|
||||
public void onClick( View v ) {
|
||||
if ( Devices.isBind() || !DebugConfig.isActiveAIAssistFlag() ) {
|
||||
AIAssist.getInstance( v.getContext() ).startAssistant( v.getContext() );
|
||||
} else {
|
||||
if ( mDebugModeOpen ) {
|
||||
AIAssist.getInstance( v.getContext() ).startAssistant( v.getContext(), 1 );
|
||||
return;
|
||||
}
|
||||
if ( mClickCounter == 0 ) {
|
||||
mLastClickTime = System.currentTimeMillis();
|
||||
mClickCounter++;
|
||||
} else {
|
||||
if ( mClickCounter == TOTAL_CLICK_AMOUNT ) {
|
||||
AIAssist.getInstance( v.getContext() ).startAssistant( v.getContext(), 2 );
|
||||
TipToast.shortTip( "开启语音调试" );
|
||||
mClickCounter = 0;
|
||||
mLastClickTime = 0L;
|
||||
mDebugModeOpen = true;
|
||||
} else if ( System.currentTimeMillis() - mLastClickTime > INTERVAL ) {
|
||||
mClickCounter = 0;
|
||||
TipToast.shortTip( "请在2秒内连续点击5次打开语音调试模式" );
|
||||
} else {
|
||||
mClickCounter++;
|
||||
}
|
||||
mLastClickTime = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.mogo.module.apps.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.module.apps.R;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-11
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class PagerIndicator extends LinearLayout implements PagerSlidingTabStripV2.SelectedState {
|
||||
|
||||
private View mIndicator;
|
||||
|
||||
public PagerIndicator( Context context ) {
|
||||
this( context, null );
|
||||
}
|
||||
|
||||
public PagerIndicator( Context context, @Nullable AttributeSet attrs ) {
|
||||
this( context, attrs, 0 );
|
||||
}
|
||||
|
||||
public PagerIndicator( Context context, @Nullable AttributeSet attrs, int defStyleAttr ) {
|
||||
super( context, attrs, defStyleAttr );
|
||||
LayoutInflater.from( context ).inflate( R.layout.module_apps_page_indicator, this, true );
|
||||
mIndicator = findViewById( R.id.module_apps_id_indicator_dot );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelectedState( boolean isSelected ) {
|
||||
mIndicator.setSelected( isSelected );
|
||||
}
|
||||
}
|
||||
@@ -1,763 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Andreas Stuetz <andreas.stuetz@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.mogo.module.apps.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||
import android.widget.HorizontalScrollView;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
|
||||
import com.mogo.module.apps.R;
|
||||
import com.mogo.utils.WindowUtils;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Reference : http://doc.okbase.net/HarryWeasley/archive/121430.html
|
||||
*/
|
||||
public class PagerSlidingTabStripV2 extends HorizontalScrollView {
|
||||
|
||||
public interface IconTabProvider {
|
||||
public int getPageIconResId( int position );
|
||||
}
|
||||
|
||||
public interface ViewTabProvider {
|
||||
public View getPageTabView( Context context, int position );
|
||||
}
|
||||
|
||||
public interface SelectedState {
|
||||
void setSelectedState( boolean isSelected );
|
||||
}
|
||||
|
||||
// @formatter:off
|
||||
private static final int[] ATTRS = new int[]{
|
||||
android.R.attr.textSize,
|
||||
android.R.attr.textColor
|
||||
};
|
||||
// @formatter:on
|
||||
|
||||
public interface OnBeforeTabAction {
|
||||
boolean doAction( int position );
|
||||
}
|
||||
|
||||
private LinearLayout.LayoutParams defaultTabLayoutParams;
|
||||
private LinearLayout.LayoutParams expandedTabLayoutParams;
|
||||
|
||||
private final PageListener pageListener = new PageListener();
|
||||
public ViewPager.OnPageChangeListener delegatePageListener;
|
||||
|
||||
private LinearLayout tabsContainer;
|
||||
private ViewPager pager;
|
||||
|
||||
private int tabCount;
|
||||
|
||||
private int currentPosition = 0;
|
||||
private int selectedPosition = 0;
|
||||
private float currentPositionOffset = 0f;
|
||||
|
||||
private Paint rectPaint;
|
||||
private Paint dividerPaint;
|
||||
|
||||
private int indicatorColor = 0xFF666666;
|
||||
private int underlineColor = 0x1A000000;
|
||||
private int dividerColor = 0x1A000000;
|
||||
|
||||
private boolean shouldExpand = false;
|
||||
private boolean textAllCaps = true;
|
||||
|
||||
private int scrollOffset = 52;
|
||||
private int indicatorHeight = 8;
|
||||
private int underlineHeight = 2;
|
||||
private int dividerPadding = 12;
|
||||
private int tabPadding = 24;
|
||||
private int dividerWidth = 1;
|
||||
private int indicatorMarginBottom = 0;
|
||||
private int indicatorMarginLeft = 0;
|
||||
private int indicatorMarginRight = 0;
|
||||
|
||||
private int tabTextSize = 13;
|
||||
private int tabTextColor = 0xFF666666;
|
||||
private int selectedTabTextColor = 0xFF666666;
|
||||
|
||||
private Typeface tabTypeface = null;
|
||||
private int tabTypefaceStyle = Typeface.NORMAL;
|
||||
|
||||
private int lastScrollX = 0;
|
||||
|
||||
private int tabBackgroundResId = R.drawable.module_apps_pager_sliding_background_tab;
|
||||
|
||||
public static final int INDICATOR_MODE_UNDERLINE = -1;
|
||||
public static final int INDICATOR_MODE_SHADOW = 1;
|
||||
public static final int INDICATOR_MODE_RES = 2;
|
||||
private int indicatorMode = INDICATOR_MODE_SHADOW;
|
||||
|
||||
private Drawable indicatorRes;
|
||||
|
||||
public static final int INDICATOR_FIT_MODE_AUTO = 0;
|
||||
public static final int INDICATOR_FIT_MODE_FIXED = 1;
|
||||
private int indicatorFitMode = INDICATOR_FIT_MODE_AUTO;
|
||||
|
||||
private float indicatorFixedSize = 0;
|
||||
|
||||
private Locale locale;
|
||||
|
||||
private OnBeforeTabAction onBeforeTabAction;
|
||||
private boolean openPadding = false;
|
||||
|
||||
|
||||
public boolean isOpenPadding() {
|
||||
return openPadding;
|
||||
}
|
||||
|
||||
public void setOpenPadding( boolean openPadding ) {
|
||||
this.openPadding = openPadding;
|
||||
}
|
||||
|
||||
public PagerSlidingTabStripV2( Context context ) {
|
||||
this( context, null );
|
||||
}
|
||||
|
||||
public PagerSlidingTabStripV2( Context context, AttributeSet attrs ) {
|
||||
this( context, attrs, 0 );
|
||||
}
|
||||
|
||||
public PagerSlidingTabStripV2( Context context, AttributeSet attrs, int defStyle ) {
|
||||
super( context, attrs, defStyle );
|
||||
|
||||
setFillViewport( true );
|
||||
setWillNotDraw( false );
|
||||
|
||||
tabsContainer = new LinearLayout( context );
|
||||
tabsContainer.setOrientation( LinearLayout.HORIZONTAL );
|
||||
tabsContainer.setLayoutParams( new LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT ) );
|
||||
addView( tabsContainer );
|
||||
|
||||
DisplayMetrics dm = getResources().getDisplayMetrics();
|
||||
|
||||
scrollOffset = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm );
|
||||
indicatorHeight = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm );
|
||||
underlineHeight = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm );
|
||||
dividerPadding = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm );
|
||||
tabPadding = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm );
|
||||
dividerWidth = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm );
|
||||
tabTextSize = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm );
|
||||
indicatorMarginBottom = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, indicatorMarginBottom, dm );
|
||||
indicatorMarginLeft = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, indicatorMarginLeft, dm );
|
||||
indicatorMarginRight = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, indicatorMarginRight, dm );
|
||||
|
||||
// get system attrs (android:textSize and android:textColor)
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes( attrs, ATTRS );
|
||||
|
||||
tabTextSize = a.getDimensionPixelSize( 0, tabTextSize );
|
||||
tabTextColor = a.getColor( 1, tabTextColor );
|
||||
|
||||
a.recycle();
|
||||
|
||||
// get custom attrs
|
||||
|
||||
a = context.obtainStyledAttributes( attrs, R.styleable.PagerSlidingTabStripV2 );
|
||||
|
||||
indicatorColor = a.getColor( R.styleable.PagerSlidingTabStripV2_pstsV2IndicatorColor, indicatorColor );
|
||||
//tab文字选中时的颜色,默认和滑动指示器的颜色一致
|
||||
selectedTabTextColor = a.getColor( R.styleable.PagerSlidingTabStripV2_pstsV2SelectedTabTextColor, indicatorColor );
|
||||
tabTextColor = a.getColor( R.styleable.PagerSlidingTabStripV2_pstsV2TabTextColorValue, tabTextColor );
|
||||
underlineColor = a.getColor( R.styleable.PagerSlidingTabStripV2_pstsV2UnderlineColor, underlineColor );
|
||||
dividerColor = a.getColor( R.styleable.PagerSlidingTabStripV2_pstsV2DividerColor, dividerColor );
|
||||
indicatorHeight = a.getDimensionPixelSize( R.styleable.PagerSlidingTabStripV2_pstsV2IndicatorHeight, indicatorHeight );
|
||||
underlineHeight = a.getDimensionPixelSize( R.styleable.PagerSlidingTabStripV2_pstsV2UnderlineHeight, underlineHeight );
|
||||
dividerPadding = a.getDimensionPixelSize( R.styleable.PagerSlidingTabStripV2_pstsV2DividerPadding, dividerPadding );
|
||||
tabPadding = a.getDimensionPixelSize( R.styleable.PagerSlidingTabStripV2_pstsV2TabPaddingLeftRight, tabPadding );
|
||||
tabBackgroundResId = a.getResourceId( R.styleable.PagerSlidingTabStripV2_pstsV2TabBackground, tabBackgroundResId );
|
||||
shouldExpand = a.getBoolean( R.styleable.PagerSlidingTabStripV2_pstsV2ShouldExpand, shouldExpand );
|
||||
scrollOffset = a.getDimensionPixelSize( R.styleable.PagerSlidingTabStripV2_pstsV2ScrollOffset, scrollOffset );
|
||||
textAllCaps = a.getBoolean( R.styleable.PagerSlidingTabStripV2_pstsV2TextAllCaps, textAllCaps );
|
||||
indicatorMarginBottom = a.getDimensionPixelSize( R.styleable.PagerSlidingTabStripV2_pstsV2IndicatorMarginBottom, indicatorMarginBottom );
|
||||
indicatorMarginLeft = a.getDimensionPixelSize( R.styleable.PagerSlidingTabStripV2_pstsV2IndicatorMarginLeft, indicatorMarginLeft );
|
||||
indicatorMarginRight = a.getDimensionPixelSize( R.styleable.PagerSlidingTabStripV2_pstsV2IndicatorMarginRight, indicatorMarginRight );
|
||||
indicatorMode = a.getInt( R.styleable.PagerSlidingTabStripV2_pstsV2IndicatorMode, INDICATOR_MODE_SHADOW );
|
||||
indicatorRes = a.getDrawable( R.styleable.PagerSlidingTabStripV2_pstsV2IndicatorRes );
|
||||
a.recycle();
|
||||
|
||||
rectPaint = new Paint();
|
||||
rectPaint.setAntiAlias( true );
|
||||
rectPaint.setStyle( Style.FILL );
|
||||
|
||||
dividerPaint = new Paint();
|
||||
dividerPaint.setAntiAlias( true );
|
||||
dividerPaint.setStrokeWidth( dividerWidth );
|
||||
|
||||
defaultTabLayoutParams = new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT );
|
||||
expandedTabLayoutParams = new LinearLayout.LayoutParams( 0, LayoutParams.MATCH_PARENT, 1.0f );
|
||||
|
||||
if ( locale == null ) {
|
||||
locale = getResources().getConfiguration().locale;
|
||||
}
|
||||
}
|
||||
|
||||
public OnBeforeTabAction getOnBeforeTabAction() {
|
||||
return onBeforeTabAction;
|
||||
}
|
||||
|
||||
public void setOnBeforeTabAction( OnBeforeTabAction onBeforeTabAction ) {
|
||||
this.onBeforeTabAction = onBeforeTabAction;
|
||||
}
|
||||
|
||||
public void setViewPager( ViewPager pager ) {
|
||||
this.pager = pager;
|
||||
this.currentPosition = this.selectedPosition = pager.getCurrentItem();
|
||||
|
||||
if ( pager.getAdapter() == null ) {
|
||||
throw new IllegalStateException( "ViewPager does not have adapter instance." );
|
||||
}
|
||||
|
||||
pager.removeOnPageChangeListener( pageListener );
|
||||
pager.addOnPageChangeListener( pageListener );
|
||||
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setOnPageChangeListener( ViewPager.OnPageChangeListener listener ) {
|
||||
this.delegatePageListener = listener;
|
||||
}
|
||||
|
||||
public void notifyDataSetChanged() {
|
||||
|
||||
indicatorLineOffset = -1;
|
||||
tabsContainer.removeAllViews();
|
||||
|
||||
tabCount = pager.getAdapter().getCount();
|
||||
|
||||
for ( int i = 0; i < tabCount; i++ ) {
|
||||
|
||||
if ( pager.getAdapter() instanceof ViewTabProvider ) {
|
||||
addViewTab( i, ( ( ViewTabProvider ) pager.getAdapter() ).getPageTabView( getContext(), i ) );
|
||||
} else {
|
||||
addTextTab( i, TextUtils.isEmpty( pager.getAdapter().getPageTitle( i ) ) ? "" : pager.getAdapter().getPageTitle( i ).toString() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
updateTabStyles();
|
||||
|
||||
getViewTreeObserver().addOnGlobalLayoutListener( new OnGlobalLayoutListener() {
|
||||
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
getViewTreeObserver().removeGlobalOnLayoutListener( this );
|
||||
currentPosition = pager.getCurrentItem();
|
||||
scrollToChild( currentPosition, 0 );
|
||||
}
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
private void addTextTab( final int position, String title ) {
|
||||
|
||||
TextView tab = new TextView( getContext() );
|
||||
tab.setText( title );
|
||||
tab.setGravity( Gravity.CENTER );
|
||||
tab.setSingleLine();
|
||||
tab.setPadding( WindowUtils.dip2px( getContext(), 10 ),
|
||||
WindowUtils.dip2px( getContext(), 3 ),
|
||||
WindowUtils.dip2px( getContext(), 10 ),
|
||||
WindowUtils.dip2px( getContext(), 3 ) );
|
||||
|
||||
LinearLayout linearLayout = new LinearLayout( getContext() );
|
||||
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT );
|
||||
linearLayout.addView( tab, layoutParams );
|
||||
linearLayout.setGravity( Gravity.CENTER );
|
||||
addTab( position, linearLayout );
|
||||
}
|
||||
|
||||
private void addIconTab( final int position, int resId ) {
|
||||
|
||||
ImageButton tab = new ImageButton( getContext() );
|
||||
tab.setImageResource( resId );
|
||||
|
||||
addTab( position, tab );
|
||||
|
||||
}
|
||||
|
||||
private void addViewTab( final int position, View v ) {
|
||||
addTab( position, v );
|
||||
}
|
||||
|
||||
public void setCurrentTab( final int position ) {
|
||||
pager.post( new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
pager.setCurrentItem( position, false );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private void addTab( final int position, View tab ) {
|
||||
tab.setFocusable( true );
|
||||
tab.setOnClickListener( new OnClickListener() {
|
||||
@Override
|
||||
public void onClick( View v ) {
|
||||
if ( getOnBeforeTabAction() != null ) {
|
||||
if ( getOnBeforeTabAction().doAction( position ) ) {
|
||||
pager.setCurrentItem( position, false );
|
||||
}
|
||||
} else {
|
||||
pager.setCurrentItem( position, false );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
if ( openPadding ) {
|
||||
tab.setPadding( position == 0 ? 0 : tabPadding, 0, tabPadding, 0 );
|
||||
}
|
||||
|
||||
tabsContainer.addView( tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams );
|
||||
}
|
||||
|
||||
private void updateTabStyles() {
|
||||
|
||||
for ( int i = 0; i < tabCount; i++ ) {
|
||||
|
||||
View v = tabsContainer.getChildAt( i );
|
||||
|
||||
if ( v instanceof SelectedState ) {
|
||||
( ( SelectedState ) v ).setSelectedState( i == selectedPosition );
|
||||
} else if ( v instanceof LinearLayout ) {
|
||||
|
||||
TextView tab = ( TextView ) ( ( LinearLayout ) v ).getChildAt( 0 );
|
||||
tab.setTextSize( TypedValue.COMPLEX_UNIT_PX, tabTextSize );
|
||||
tab.setTypeface( tabTypeface, tabTypefaceStyle );
|
||||
tab.setTextColor( tabTextColor );
|
||||
|
||||
if ( textAllCaps ) {
|
||||
tab.setAllCaps( true );
|
||||
}
|
||||
|
||||
if ( i == selectedPosition ) {
|
||||
tab.setTextColor( selectedTabTextColor );
|
||||
if ( indicatorMode == INDICATOR_MODE_SHADOW ) {
|
||||
tab.setBackgroundResource( R.drawable.module_apps_shape_deep_blue );
|
||||
}
|
||||
} else {
|
||||
tab.setTextColor( tabTextColor );
|
||||
tab.setBackgroundResource( 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void scrollToChild( int position, int offset ) {
|
||||
|
||||
if ( tabCount == 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
int newScrollX = tabsContainer.getChildAt( position ).getLeft() + offset;
|
||||
|
||||
if ( position > 0 || offset > 0 ) {
|
||||
newScrollX -= scrollOffset;
|
||||
}
|
||||
|
||||
if ( newScrollX != lastScrollX ) {
|
||||
lastScrollX = newScrollX;
|
||||
scrollTo( newScrollX, 0 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw( Canvas canvas ) {
|
||||
super.onDraw( canvas );
|
||||
|
||||
if ( isInEditMode() || tabCount == 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int height = getHeight();
|
||||
|
||||
|
||||
// draw indicator line
|
||||
|
||||
rectPaint.setColor( indicatorColor );
|
||||
|
||||
// default: line below current tab
|
||||
View currentTab = tabsContainer.getChildAt( currentPosition );
|
||||
float lineLeft = currentTab.getLeft();
|
||||
float lineRight = currentTab.getRight();
|
||||
|
||||
// if there is an offset, start interpolating left and right coordinates between current and next tab
|
||||
if ( currentPositionOffset > 0f && currentPosition < tabCount - 1 ) {
|
||||
|
||||
View nextTab = tabsContainer.getChildAt( currentPosition + 1 );
|
||||
final float nextTabLeft = nextTab.getLeft();
|
||||
final float nextTabRight = nextTab.getRight();
|
||||
|
||||
lineLeft = ( currentPositionOffset * nextTabLeft + ( 1f - currentPositionOffset ) * lineLeft );
|
||||
lineRight = ( currentPositionOffset * nextTabRight + ( 1f - currentPositionOffset ) * lineRight );
|
||||
}
|
||||
|
||||
if ( indicatorMode == INDICATOR_MODE_UNDERLINE ) {
|
||||
float lineOffset = getLineOffset();
|
||||
float left, right, top, bottom;
|
||||
if ( indicatorFitMode == INDICATOR_FIT_MODE_AUTO ) {
|
||||
left = lineLeft + lineOffset + indicatorMarginLeft;
|
||||
right = lineRight - lineOffset - indicatorMarginRight;
|
||||
top = height - indicatorHeight - indicatorMarginBottom;
|
||||
bottom = height - indicatorMarginBottom;
|
||||
} else {
|
||||
left = lineLeft + lineOffset;
|
||||
right = lineRight - lineOffset;
|
||||
top = height - indicatorHeight - indicatorMarginBottom;
|
||||
bottom = height - indicatorMarginBottom;
|
||||
}
|
||||
|
||||
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ) {
|
||||
canvas.drawRoundRect( left, top, right, bottom, 90, 90, rectPaint );
|
||||
} else {
|
||||
canvas.drawRect( left, top, right, bottom, rectPaint );
|
||||
}
|
||||
}
|
||||
|
||||
if ( indicatorMode == INDICATOR_MODE_RES ) {
|
||||
if ( indicatorRes != null ) {
|
||||
int lineOffset = ( int ) getLineOffset();
|
||||
int left, right, top, bottom;
|
||||
int width = indicatorRes.getIntrinsicWidth();
|
||||
left = ( int ) lineLeft + lineOffset;
|
||||
right = ( int ) lineRight - lineOffset;
|
||||
top = height - indicatorRes.getIntrinsicHeight() - indicatorMarginBottom;
|
||||
left = left + ( right - left - width ) / 2;
|
||||
right = left + width;
|
||||
bottom = height - indicatorMarginBottom;
|
||||
indicatorRes.setBounds( left, top, right, bottom );
|
||||
indicatorRes.draw( canvas );
|
||||
}
|
||||
}
|
||||
|
||||
// draw underline
|
||||
|
||||
rectPaint.setColor( underlineColor );
|
||||
canvas.drawRect( 0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint );
|
||||
|
||||
// draw divider
|
||||
|
||||
dividerPaint.setColor( dividerColor );
|
||||
for ( int i = 0; i < tabCount - 1; i++ ) {
|
||||
View tab = tabsContainer.getChildAt( i );
|
||||
canvas.drawLine( tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint );
|
||||
}
|
||||
}
|
||||
|
||||
private float indicatorLineOffset = -1;
|
||||
|
||||
private float getLineOffset() {
|
||||
|
||||
if ( tabsContainer.getChildCount() == 0 ) {
|
||||
return 0;
|
||||
}
|
||||
if ( !shouldExpand ) {
|
||||
return 0;
|
||||
}
|
||||
if ( indicatorLineOffset != -1 ) {
|
||||
return indicatorLineOffset;
|
||||
}
|
||||
|
||||
float minViewMeasuredWidth = tabsContainer.getChildAt( 0 ).getMeasuredWidth();
|
||||
float minContentWidth = getTabContentWidth( tabsContainer.getChildAt( 0 ) );
|
||||
for ( int i = 1; i < tabsContainer.getChildCount(); i++ ) {
|
||||
float nextContentWidth = getTabContentWidth( tabsContainer.getChildAt( i ) );
|
||||
if ( minContentWidth > nextContentWidth ) {
|
||||
minContentWidth = nextContentWidth;
|
||||
}
|
||||
}
|
||||
float offset = ( minViewMeasuredWidth - minContentWidth ) / 2;
|
||||
return indicatorLineOffset = offset == 0 ? WindowUtils.dip2px( getContext(), 25 ) : offset;
|
||||
}
|
||||
|
||||
private float getTabContentWidth( View tab ) {
|
||||
if ( tab instanceof TextView ) {
|
||||
TextPaint paint = ( ( TextView ) tab ).getPaint();
|
||||
return paint.measureText( ( ( TextView ) tab ).getText().toString() );
|
||||
}
|
||||
return tab.getMeasuredWidth();
|
||||
}
|
||||
|
||||
private class PageListener implements ViewPager.OnPageChangeListener {
|
||||
|
||||
@Override
|
||||
public void onPageScrolled( int position, float positionOffset, int positionOffsetPixels ) {
|
||||
|
||||
currentPosition = position;
|
||||
currentPositionOffset = positionOffset;
|
||||
|
||||
scrollToChild( position, ( int ) ( positionOffset * tabsContainer.getChildAt( position ).getWidth() ) );
|
||||
|
||||
invalidate();
|
||||
|
||||
if ( delegatePageListener != null ) {
|
||||
delegatePageListener.onPageScrolled( position, positionOffset, positionOffsetPixels );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged( int state ) {
|
||||
if ( state == ViewPager.SCROLL_STATE_IDLE ) {
|
||||
scrollToChild( pager.getCurrentItem(), 0 );
|
||||
}
|
||||
|
||||
if ( delegatePageListener != null ) {
|
||||
delegatePageListener.onPageScrollStateChanged( state );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected( int position ) {
|
||||
selectedPosition = position;
|
||||
updateTabStyles();
|
||||
if ( delegatePageListener != null ) {
|
||||
delegatePageListener.onPageSelected( position );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setIndicatorColor( int indicatorColor ) {
|
||||
this.indicatorColor = indicatorColor;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setIndicatorColorResource( int resId ) {
|
||||
this.indicatorColor = getResources().getColor( resId );
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public int getIndicatorColor() {
|
||||
return this.indicatorColor;
|
||||
}
|
||||
|
||||
public void setIndicatorHeight( int indicatorLineHeightPx ) {
|
||||
this.indicatorHeight = indicatorLineHeightPx;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public int getIndicatorHeight() {
|
||||
return indicatorHeight;
|
||||
}
|
||||
|
||||
public void setUnderlineColor( int underlineColor ) {
|
||||
this.underlineColor = underlineColor;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setUnderlineColorResource( int resId ) {
|
||||
this.underlineColor = getResources().getColor( resId );
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public int getUnderlineColor() {
|
||||
return underlineColor;
|
||||
}
|
||||
|
||||
public void setDividerColor( int dividerColor ) {
|
||||
this.dividerColor = dividerColor;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setDividerColorResource( int resId ) {
|
||||
this.dividerColor = getResources().getColor( resId );
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public int getDividerColor() {
|
||||
return dividerColor;
|
||||
}
|
||||
|
||||
public void setUnderlineHeight( int underlineHeightPx ) {
|
||||
this.underlineHeight = underlineHeightPx;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public int getUnderlineHeight() {
|
||||
return underlineHeight;
|
||||
}
|
||||
|
||||
public void setDividerPadding( int dividerPaddingPx ) {
|
||||
this.dividerPadding = dividerPaddingPx;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public int getDividerPadding() {
|
||||
return dividerPadding;
|
||||
}
|
||||
|
||||
public void setScrollOffset( int scrollOffsetPx ) {
|
||||
this.scrollOffset = scrollOffsetPx;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public int getScrollOffset() {
|
||||
return scrollOffset;
|
||||
}
|
||||
|
||||
public void setShouldExpand( boolean shouldExpand ) {
|
||||
this.shouldExpand = shouldExpand;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public boolean getShouldExpand() {
|
||||
return shouldExpand;
|
||||
}
|
||||
|
||||
public boolean isTextAllCaps() {
|
||||
return textAllCaps;
|
||||
}
|
||||
|
||||
public void setAllCaps( boolean textAllCaps ) {
|
||||
this.textAllCaps = textAllCaps;
|
||||
}
|
||||
|
||||
public void setTextSize( int textSizePx ) {
|
||||
this.tabTextSize = textSizePx;
|
||||
updateTabStyles();
|
||||
}
|
||||
|
||||
public int getTextSize() {
|
||||
return tabTextSize;
|
||||
}
|
||||
|
||||
public void setTextColor( int textColor ) {
|
||||
this.tabTextColor = textColor;
|
||||
updateTabStyles();
|
||||
}
|
||||
|
||||
public void setTextColorResource( int resId ) {
|
||||
this.tabTextColor = getResources().getColor( resId );
|
||||
updateTabStyles();
|
||||
}
|
||||
|
||||
public int getTextColor() {
|
||||
return tabTextColor;
|
||||
}
|
||||
|
||||
public void setSelectedTextColor( int textColor ) {
|
||||
this.selectedTabTextColor = textColor;
|
||||
updateTabStyles();
|
||||
}
|
||||
|
||||
public void setSelectedTextColorResource( int resId ) {
|
||||
this.selectedTabTextColor = getResources().getColor( resId );
|
||||
updateTabStyles();
|
||||
}
|
||||
|
||||
public int getSelectedTextColor() {
|
||||
return selectedTabTextColor;
|
||||
}
|
||||
|
||||
public void setTypeface( Typeface typeface, int style ) {
|
||||
this.tabTypeface = typeface;
|
||||
this.tabTypefaceStyle = style;
|
||||
updateTabStyles();
|
||||
}
|
||||
|
||||
public void setTabBackground( int resId ) {
|
||||
this.tabBackgroundResId = resId;
|
||||
updateTabStyles();
|
||||
}
|
||||
|
||||
public int getTabBackground() {
|
||||
return tabBackgroundResId;
|
||||
}
|
||||
|
||||
public void setTabPaddingLeftRight( int paddingPx ) {
|
||||
this.tabPadding = paddingPx;
|
||||
updateTabStyles();
|
||||
}
|
||||
|
||||
public int getTabPaddingLeftRight() {
|
||||
return tabPadding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRestoreInstanceState( Parcelable state ) {
|
||||
SavedState savedState = ( SavedState ) state;
|
||||
super.onRestoreInstanceState( savedState.getSuperState() );
|
||||
currentPosition = savedState.currentPosition;
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Parcelable onSaveInstanceState() {
|
||||
Parcelable superState = super.onSaveInstanceState();
|
||||
SavedState savedState = new SavedState( superState );
|
||||
savedState.currentPosition = currentPosition;
|
||||
return savedState;
|
||||
}
|
||||
|
||||
static class SavedState extends BaseSavedState {
|
||||
int currentPosition;
|
||||
|
||||
public SavedState( Parcelable superState ) {
|
||||
super( superState );
|
||||
}
|
||||
|
||||
private SavedState( Parcel in ) {
|
||||
super( in );
|
||||
currentPosition = in.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel( Parcel dest, int flags ) {
|
||||
super.writeToParcel( dest, flags );
|
||||
dest.writeInt( currentPosition );
|
||||
}
|
||||
|
||||
public static final Creator< SavedState > CREATOR = new Creator< SavedState >() {
|
||||
@Override
|
||||
public SavedState createFromParcel( Parcel in ) {
|
||||
return new SavedState( in );
|
||||
}
|
||||
|
||||
@Override
|
||||
public SavedState[] newArray( int size ) {
|
||||
return new SavedState[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
Before Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 8.9 KiB |
|
Before Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 8.5 KiB |