diff --git a/README-zh.md b/README-zh.md index 577630b..509a32c 100644 --- a/README-zh.md +++ b/README-zh.md @@ -1,7 +1,7 @@ [![](https://travis-ci.org/YummyLau/PanelSwitchHelper.svg?branch=master)](https://travis-ci.org/YummyLau/panelSwitchHelper) ![Language](https://img.shields.io/badge/language-java-orange.svg) ![Language](https://img.shields.io/badge/language-kotlin-orange.svg) -![Version](https://img.shields.io/badge/version-1.3.13-blue.svg) +![Version](https://img.shields.io/badge/version-1.4.0-blue.svg) ![Size](https://img.shields.io/badge/size-14K-brightgreen.svg) README: [English Doc](https://github.com/YummyLau/PanelSwitchHelper/blob/master/README.md) @@ -41,10 +41,8 @@ Demo 内容如下 1. 在模块脚本 `build.gradle` 添加库依赖 ``` -implementation 'com.effective.android:panelSwitchHelper:1.3.13' - -//or for androidx -implementation 'com.effective.android:panelSwitchHelper-androidx:1.3.13' +//1.4.0 版本及后续,仅支持 Androidx +implementation 'com.github.YummyLau:PanelSwitchHelper:1.4.0' ``` 2. 在布局文件 Xml 中使用框架提供的容器 diff --git a/README.md b/README.md index cd55aa6..f9415b2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [![](https://travis-ci.org/YummyLau/PanelSwitchHelper.svg?branch=master)](https://travis-ci.org/YummyLau/panelSwitchHelper) ![Language](https://img.shields.io/badge/language-java-orange.svg) ![Language](https://img.shields.io/badge/language-kotlin-orange.svg) -![Version](https://img.shields.io/badge/version-1.3.13-blue.svg) +![Version](https://img.shields.io/badge/version-1.4.0-blue.svg) ![Size](https://img.shields.io/badge/size-14K-brightgreen.svg) README: [中文文档](https://github.com/YummyLau/PanelSwitchHelper/blob/master/README-zh.md) @@ -24,7 +24,7 @@ For more details, please refer to * [Introduction to scenario usage](https://github.com/YummyLau/PanelSwitchHelper/blob/master/README_SENCE.md) * [API Usage Guide](https://github.com/YummyLau/PanelSwitchHelper/blob/master/README_API.md) - * [Library version update log] (https://github.com/YummyLau/PanelSwitchHelper/blob/master/README_UPDATE.md) + * [Library version update log](https://github.com/YummyLau/PanelSwitchHelper/blob/master/README_UPDATE.md) Demo content is as follows @@ -41,10 +41,8 @@ The Androidx version runs by default. If you need to open non-Androidx, open the 1. Add library dependencies in module script `build.gradle` ``` -implementation'com.effective.android:panelSwitchHelper:1.3.13' - -//or for androidx -implementation 'com.effective.android:panelSwitchHelper-androidx:1.3.13' +// Version 1.4.0 and later, only supports Androidx +implementation 'com.github.YummyLau:PanelSwitchHelper:1.4.0' ``` 2. Use the container provided by the framework in the layout file Xml diff --git a/README_API-zh.md b/README_API-zh.md index 6e993b8..eacfb01 100644 --- a/README_API-zh.md +++ b/README_API-zh.md @@ -172,6 +172,7 @@ PanelSwitchHelper mHelper = new PanelSwitchHelper.Builder(this) 5. resetState,隐藏所有面板 6. hookSystemBackByPanelSwitcher 拦截返回,如果当前用户按下返回或者业务返回键,则优先隐藏面板 7. addSecondaryInputView/removeSecondaryInputView 添加额外输入源,用于驱动输入法显示 +8. setTriggerViewClickInterceptor 支持动态控制 TriggerView 是否自动响应"点击触发切换面板"行为,默认相应 diff --git a/README_API.md b/README_API.md index ee518ec..5865466 100644 --- a/README_API.md +++ b/README_API.md @@ -172,4 +172,5 @@ In addition to the functions provided in the above construction process, the fol 4. toPanelState, switch to the corresponding function panel 5. resetState, hide all panels 6. hookSystemBackByPanelSwitcher intercepts the return, if the current user presses the return or business return button, the panel is preferentially hidden -7. addSecondaryInputView/removeSecondaryInputView to add an additional input source to drive the input method display \ No newline at end of file +7. addSecondaryInputView/removeSecondaryInputView to add an additional input source to drive the input method display +8. setTriggerViewClickInterceptor supports dynamic control of whether TriggerView automatically responds to the "click to trigger the switch panel" behavior, the default is corresponding \ No newline at end of file diff --git a/README_UPDATE-zh.md b/README_UPDATE-zh.md index 928062f..ed7d4ee 100644 --- a/README_UPDATE-zh.md +++ b/README_UPDATE-zh.md @@ -61,3 +61,7 @@ * 1.3.11 修复部分 MiUI 手机横屏状态栏拉起输入法异常问题,优化 Log 显示,统一所有自定义面板容器属性命名的前缀 * 1.3.12 兼容悬浮键盘场景 * 1.3.13 兼容部分手机锁屏收起输入法问题;兼容华为定制平板问题;优化全屏显示速度; +* 1.4.0 该版本起仅支持 Androidx,非 Androidx 不再维护 + * 修复三星部分设备的兼容问题 + * 新增 `setTriggerViewClickInterceptor` 支持动态控制 TriggerView 是否自动响应"点击触发切换面板"行为,默认相应 + * 新增 `DisUtils#setCompatSizeProxy` 支持动态设置像素转化逻辑 diff --git a/README_UPDATE.md b/README_UPDATE.md index b0deec6..98d502b 100644 --- a/README_UPDATE.md +++ b/README_UPDATE.md @@ -63,4 +63,8 @@ * 1.3.10 Supports full screen mode, supports additional setting of EditText to invoke the panel, and fixes known issues * 1.3.11 Fixed some MiUI mobile phone horizontal screen status bar pull up the input method abnormal problem, optimize the Log display, unify the prefix of all custom panel container property names * 1.3.12 compatible with floating keyboard scene -* 1.3.12 Compatible with some mobile phone lock screen input method issues; compatible with Huawei customized tablet issues; optimize the full screen display speed; \ No newline at end of file +* 1.3.12 Compatible with some mobile phone lock screen input method issues; compatible with Huawei customized tablet issues; optimize the full screen display speed; +* Starting from 1.4.0, only Androidx is supported, non-Androidx is no longer maintained + * Fix the compatibility issue of some Samsung devices + * Added `setTriggerViewClickInterceptor` to support dynamic control of whether TriggerView automatically responds to the "click to trigger switch panel" behavior, the default is corresponding + * Added `DisUtils#setCompatSizeProxy` to support dynamic setting of pixel conversion logic \ No newline at end of file diff --git a/app-androidx/src/main/java/com/example/demo/scene/chat/ChatActivity.java b/app-androidx/src/main/java/com/example/demo/scene/chat/ChatActivity.java index 01f5a65..0c36a9e 100644 --- a/app-androidx/src/main/java/com/example/demo/scene/chat/ChatActivity.java +++ b/app-androidx/src/main/java/com/example/demo/scene/chat/ChatActivity.java @@ -23,6 +23,7 @@ import com.effective.android.panel.PanelSwitchHelper; import com.effective.android.panel.interfaces.ContentScrollMeasurer; import com.effective.android.panel.interfaces.PanelHeightMeasurer; +import com.effective.android.panel.interfaces.TriggerViewClickInterceptor; import com.effective.android.panel.interfaces.listener.OnPanelChangeListener; import com.effective.android.panel.utils.DisplayUtil; import com.effective.android.panel.view.panel.IPanelView; @@ -47,7 +48,7 @@ */ public class ChatActivity extends AppCompatActivity { - public static void start(Context context, @ChatPageType int type) { + public static void start(Context context, @ChatPageType int type) { Intent intent = new Intent(context, ChatActivity.class); intent.putExtra(Constants.KEY_PAGE_TYPE, type); context.startActivity(intent); @@ -147,6 +148,13 @@ protected void onStart() { scrollToBottom(); } }) + .setTriggerViewClickInterceptor((TriggerViewClickInterceptor) triggerId -> { + if (R.id.emotion_btn == triggerId) { + Toast.makeText(ChatActivity.this, "R.id.emotion_btn 被拦截,可在 setTriggerViewClickInterceptor 解除", Toast.LENGTH_SHORT).show(); + return true; + } + return false; + }) //可选 .addViewClickListener(view -> { switch (view.getId()) { diff --git a/app-androidx/src/main/java/com/example/demo/scene/chat/view/AutoHidePanelRecyclerView.java b/app-androidx/src/main/java/com/example/demo/scene/chat/view/AutoHidePanelRecyclerView.java index 4a826d8..ecab1dc 100644 --- a/app-androidx/src/main/java/com/example/demo/scene/chat/view/AutoHidePanelRecyclerView.java +++ b/app-androidx/src/main/java/com/example/demo/scene/chat/view/AutoHidePanelRecyclerView.java @@ -29,61 +29,17 @@ public AutoHidePanelRecyclerView(Context context, @Nullable AttributeSet attrs) this(context, attrs, 0); } + public AutoHidePanelRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setLayoutManager(new LinearLayoutManager(context)); - addOnItemTouchListener(new OnItemTouchListener() { - - public boolean isTouchInView(View view, MotionEvent event) { - if (view == null) { - return false; - } - int[] location = new int[2]; - view.getLocationOnScreen(location); - int x = location[0]; - int y = location[1]; - return x < event.getRawX() && event.getRawX() < x + view.getWidth() - && y < event.getRawY() && event.getRawY() < y + view.getHeight(); - } - - public void hidePanel() { - if (panelSwitchHelper != null) { - panelSwitchHelper.hookSystemBackByPanelSwitcher(); - } - } - - @Override - public boolean onInterceptTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) { - int action = e.getAction(); - if (action == MotionEvent.ACTION_DOWN) { - View view = rv.findChildViewUnder(e.getX(), e.getY()); - if (view == null) { - hidePanel(); - return false; - } - View text = view.findViewById(R.id.text); - View avatar = view.findViewById(R.id.avatar); - if (text == null || avatar == null) { - hidePanel(); - return false; - } - - if (!isTouchInView(text, e) && !isTouchInView(avatar, e)) { - hidePanel(); - } - } - return false; - } - - @Override - public void onTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) { - - } - - @Override - public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) { + } - } - }); + @Override + public boolean onTouchEvent(MotionEvent e) { + if(panelSwitchHelper != null){ + panelSwitchHelper.hookSystemBackByPanelSwitcher(); + } + return super.onTouchEvent(e); } } diff --git a/app/.gitignore b/app/.gitignore deleted file mode 100644 index 796b96d..0000000 --- a/app/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index ee12d56..0000000 --- a/app/build.gradle +++ /dev/null @@ -1,65 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' - -android { - compileSdkVersion config.compile_sdk_version - buildToolsVersion config.build_tool_version - - dataBinding { - enabled = true - } - - defaultConfig { - applicationId "com.example.demo" - minSdkVersion config.min_sdk_version - targetSdkVersion config.target_sdk_version - versionCode config.version_code - versionName config.version_name - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - buildConfigField "String", "VERSION", "\"${versions.panelSwitchHelper}\"" - } - - signingConfigs { - release { - keyAlias 'keystore' - keyPassword 'mm123456' - storeFile file('../android.keystore') - storePassword '123456' - } - } - - buildTypes { - release { - minifyEnabled true - signingConfig signingConfigs.release - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - lintOptions { - abortOnError false - } - - // 配置一个路径专门存放kotlin文件 - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } -} - -dependencies { - implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation deps.support.v7 - implementation deps.support.recyclerview - implementation deps.support.constraint - implementation deps.pageindicator - implementation deps.circleimageview - implementation deps.panelSwitchHelper -// implementation project(":panel") -} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro deleted file mode 100644 index f1b4245..0000000 --- a/app/proguard-rules.pro +++ /dev/null @@ -1,21 +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 name 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 name. -#-renamesourcefileattribute SourceFile diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml deleted file mode 100644 index 881c221..0000000 --- a/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/java/com/example/demo/Constants.java b/app/src/main/java/com/example/demo/Constants.java deleted file mode 100644 index e3c42e7..0000000 --- a/app/src/main/java/com/example/demo/Constants.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.example.demo; - -public class Constants { - public static final String KEY_PAGE_TYPE = "pageType"; - public static final String KEY_CONTENT_TYPE = "contentType"; -} diff --git a/app/src/main/java/com/example/demo/MainActivity.java b/app/src/main/java/com/example/demo/MainActivity.java deleted file mode 100644 index b545d19..0000000 --- a/app/src/main/java/com/example/demo/MainActivity.java +++ /dev/null @@ -1,292 +0,0 @@ -package com.example.demo; - -import android.app.Dialog; -import android.content.Intent; -import android.databinding.DataBindingUtil; -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v4.app.DialogFragment; -import android.support.v7.app.AppCompatActivity; -import android.view.Gravity; -import android.view.View; -import android.widget.ExpandableListView; -import android.widget.PopupWindow; -import android.widget.SimpleExpandableListAdapter; - -import com.effective.BuildConfig; -import com.effective.R; -import com.effective.databinding.ActivityMainLayoutBinding; -import com.example.demo.anno.ApiContentType; -import com.example.demo.anno.ApiResetType; -import com.example.demo.anno.ChatPageType; -import com.example.demo.scene.api.ContentActivity; -import com.example.demo.scene.api.CusPanelActivity; -import com.example.demo.scene.api.DefaultHeightPanelActivity; -import com.example.demo.scene.api.PanelActivity; -import com.example.demo.scene.api.ResetActivity; -import com.example.demo.scene.chat.ChatActivity; -import com.example.demo.scene.chat.ChatCusContentScrollActivity; -import com.example.demo.scene.chat.ChatDialog; -import com.example.demo.scene.chat.ChatDialogFragment; -import com.example.demo.scene.chat.ChatFragmentActivity; -import com.example.demo.scene.chat.ChatPopupWindow; -import com.example.demo.scene.chat.ChatSuperActivity; -import com.example.demo.scene.feed.FeedActivity; -import com.example.demo.scene.feed.FeedDialogActivity; -import com.example.demo.scene.live.douyin.PhoneDouyinLiveActivity; -import com.example.demo.scene.live.huya.PcHuyaLiveActivity; -import com.example.demo.scene.video.BiliBiliSampleActivity; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class MainActivity extends AppCompatActivity { - - private ActivityMainLayoutBinding mBinding; - - final String activity_title = "聊天场景 Activity实现"; - final String activity_1 = "activity 无标题栏"; - final String activity_2 = "activity 有标题栏"; - final String activity_3 = "activity 自定义标题栏"; - final String activity_4 = "activity 有标题栏,状态栏着色"; - final String activity_5 = "activity 无标题栏,状态栏透明,不绘制到状态栏"; - final String activity_6 = "activity 无标题栏,状态栏透明,绘制到状态栏"; - - final String fragment_title = "聊天场景 Fragment实现"; - final String fragment_1 = "fragment 无标题栏"; - final String fragment_2 = "fragment 自定义标题栏"; - final String fragment_3 = "fragment 自定义标题栏,状态栏着色"; - final String fragment_4 = "fragment 自定义标题栏,状态栏透明"; - - final String window_title = "聊天场景 other window 实现"; - final String window_1 = "DialogFragment"; - final String window_2 = "PopupWindow"; - final String window_3 = "Dialog"; - - final String scene_title = "扩展场景"; - final String scene_1 = "视频播放(优于b站)"; - final String scene_2 = "信息流评论(同微信朋友圈效果)"; - // final String scene_2_2 = "信息流评论(同微信朋友圈效果-非dialog)"; - final String scene_3 = "PC直播(优于虎牙效果)"; - final String scene_4 = "手机直播(优于抖音效果)"; - final String scene_5 = "复杂聊天场景"; - - final String api_content_container_title = "api 内容容器及扩展"; - final String api_content_container_1 = "基于 LinearLayout 实现"; - final String api_content_container_2 = "基于 RelativeLayout 实现"; - final String api_content_container_3 = "基于 FrameLayout 实现"; - final String api_content_container_4 = "自定义布局实现"; - - final String api_define_content_container_scroll_title = "api 内容容器内部布局干预滑动"; - final String api_define_content_container_scroll = "内容区域干预子View滑动行为"; - - final String api_cus_panel_title = "api 面板扩展及默认高度设置"; - final String api_cus_panel = "自定义PanelView"; - final String api_cus_panel_height = "未获取输入法高度前高度兼容"; - - final String api_reset_title = "api 自动隐藏软键盘/面板"; - final String api_reset_1 = "点击内容容器收起面板(默认处理)"; - final String api_reset_2 = "点击空白 View 收起面板"; - final String api_reset_3 = "点击原生 RecyclerView 收起面板"; - final String api_reset_4 = "点击自定义 RecyclerView 收起面板"; - final String api_reset_5 = "关闭点击内容容器收起面板"; - - final String[] groupStrings = { - activity_title, - fragment_title, - window_title, - scene_title, - api_content_container_title, - api_define_content_container_scroll_title, - api_cus_panel_title, - api_reset_title}; - - final String[][] childStrings = { - {activity_1, activity_2, activity_3, activity_4, activity_5, activity_6}, - {fragment_1, fragment_2, fragment_3, fragment_4}, - {window_1, window_2, window_3}, - {scene_1, scene_2, scene_3, scene_4, scene_5}, - {api_content_container_1, api_content_container_2, api_content_container_3, api_content_container_4}, - {api_define_content_container_scroll}, - {api_cus_panel, api_cus_panel_height}, - {api_reset_1, api_reset_2, api_reset_3, api_reset_4, api_reset_5} - }; - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - mBinding = DataBindingUtil.setContentView(this, R.layout.activity_main_layout); - mBinding.version.setText("version : " + BuildConfig.VERSION); - - final String TITLE = "TITLE"; - - List> groupData = new ArrayList>(); - List>> childData = new ArrayList>>(); - for (int i = 0; i < groupStrings.length; i++) { - Map curGroupMap = new HashMap(); - groupData.add(curGroupMap); - curGroupMap.put(TITLE, groupStrings[i]); - - List> children = new ArrayList>(); - for (int j = 0; j < childStrings[i].length; j++) { - Map curChildMap = new HashMap(); - children.add(curChildMap); - curChildMap.put(TITLE, childStrings[i][j]); - } - childData.add(children); - } - - SimpleExpandableListAdapter adapter = new SimpleExpandableListAdapter(this, groupData, - R.layout.list_parent_title_layout, - new String[]{TITLE}, new int[]{R.id.title}, - childData, R.layout.list_sub_title_layout, - new String[]{TITLE}, new int[]{R.id.title}); - - mBinding.list.setAdapter(adapter); - mBinding.list.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { - @Override - public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { - switch (childStrings[groupPosition][childPosition]) { - case activity_1: { - ChatActivity.start(MainActivity.this, ChatPageType.DEFAULT); - break; - } - case activity_2: { - ChatActivity.start(MainActivity.this, ChatPageType.TITLE_BAR); - break; - } - case activity_3: { - ChatActivity.start(MainActivity.this, ChatPageType.CUS_TITLE_BAR); - break; - } - case activity_4: { - ChatActivity.start(MainActivity.this, ChatPageType.COLOR_STATUS_BAR); - break; - } - case activity_5: { - ChatActivity.start(MainActivity.this, ChatPageType.TRANSPARENT_STATUS_BAR); - break; - } - case activity_6: { - ChatActivity.start(MainActivity.this, ChatPageType.TRANSPARENT_STATUS_BAR_DRAW_UNDER); - break; - } - - case fragment_1: { - ChatFragmentActivity.startFragment(MainActivity.this, ChatPageType.DEFAULT); - break; - } - case fragment_2: { - ChatFragmentActivity.startFragment(MainActivity.this, ChatPageType.TITLE_BAR); - break; - } - case fragment_3: { - ChatFragmentActivity.startFragment(MainActivity.this, ChatPageType.COLOR_STATUS_BAR); - break; - } - case fragment_4: { - ChatFragmentActivity.startFragment(MainActivity.this, ChatPageType.TRANSPARENT_STATUS_BAR); - break; - } - - case window_1: { - DialogFragment dialogFragment = new ChatDialogFragment(); - dialogFragment.showNow(getSupportFragmentManager(), "dialogFragment"); - break; - } - case window_2: { - PopupWindow popupWindow = new ChatPopupWindow(MainActivity.this); - popupWindow.showAtLocation(mBinding.getRoot(), Gravity.NO_GRAVITY, 0, 0); - break; - } - case window_3: { - Dialog dialog = new ChatDialog(MainActivity.this); - dialog.show(); - break; - } - - case scene_1: { - startActivity(new Intent(MainActivity.this, BiliBiliSampleActivity.class)); - break; - } - case scene_2: { - startActivity(new Intent(MainActivity.this, FeedDialogActivity.class)); - break; - } -// case scene_2_2:{ -// startActivity(new Intent(MainActivity.this, FeedActivity.class)); -// break; -// } - case scene_3: { - startActivity(new Intent(MainActivity.this, PcHuyaLiveActivity.class)); - break; - } - case scene_4: { - startActivity(new Intent(MainActivity.this, PhoneDouyinLiveActivity.class)); - break; - } - case scene_5: { - startActivity(new Intent(MainActivity.this, ChatSuperActivity.class)); - break; - } - - case api_cus_panel: { - startActivity(new Intent(MainActivity.this, CusPanelActivity.class)); - break; - } - - case api_cus_panel_height: { - startActivity(new Intent(MainActivity.this, DefaultHeightPanelActivity.class)); - break; - } - - case api_define_content_container_scroll: { - ChatCusContentScrollActivity.start(MainActivity.this); - break; - } - - case api_content_container_1: { - ContentActivity.start(MainActivity.this, ApiContentType.Linear); - break; - } - case api_content_container_2: { - ContentActivity.start(MainActivity.this, ApiContentType.Relative); - break; - } - case api_content_container_3: { - ContentActivity.start(MainActivity.this, ApiContentType.Frame); - break; - } - case api_content_container_4: { - ContentActivity.start(MainActivity.this, ApiContentType.CUS); - break; - } - - case api_reset_1: { - ResetActivity.start(MainActivity.this, ApiResetType.ENABLE); - break; - } - case api_reset_2: { - ResetActivity.start(MainActivity.this, ApiResetType.ENABLE_EmptyView); - break; - } - case api_reset_3: { - ResetActivity.start(MainActivity.this, ApiResetType.ENABLE_RecyclerView); - break; - } - case api_reset_4: { - ResetActivity.start(MainActivity.this, ApiResetType.ENABLE_HookActionUpRecyclerview); - break; - } - case api_reset_5: { - ResetActivity.start(MainActivity.this, ApiResetType.DISABLE); - break; - } - } - return true; - } - }); - } -} diff --git a/app/src/main/java/com/example/demo/anno/ApiContentType.java b/app/src/main/java/com/example/demo/anno/ApiContentType.java deleted file mode 100644 index 6623f3a..0000000 --- a/app/src/main/java/com/example/demo/anno/ApiContentType.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.example.demo.anno; - - -import android.support.annotation.IntDef; - -import static com.example.demo.anno.ApiContentType.Linear; -import static com.example.demo.anno.ApiContentType.Relative; -import static com.example.demo.anno.ApiContentType.Frame; -import static com.example.demo.anno.ApiContentType.CUS; - -@IntDef({Linear, Relative, Frame, CUS}) -public @interface ApiContentType { - int Linear = 0; - int Relative = 1; - int Frame = 2; - int CUS = 3; -} diff --git a/app/src/main/java/com/example/demo/anno/ApiResetType.java b/app/src/main/java/com/example/demo/anno/ApiResetType.java deleted file mode 100644 index 2ca777f..0000000 --- a/app/src/main/java/com/example/demo/anno/ApiResetType.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.example.demo.anno; - - -import android.support.annotation.IntDef; -import static com.example.demo.anno.ApiResetType.ENABLE_EmptyView; -import static com.example.demo.anno.ApiResetType.ENABLE_RecyclerView; -import static com.example.demo.anno.ApiResetType.ENABLE_HookActionUpRecyclerview; -import static com.example.demo.anno.ApiResetType.DISABLE; -import static com.example.demo.anno.ApiResetType.ENABLE; - -@IntDef({DISABLE,ENABLE,ENABLE_EmptyView, ENABLE_RecyclerView, ENABLE_HookActionUpRecyclerview}) -public @interface ApiResetType { - int DISABLE = 0; - int ENABLE = 1; - int ENABLE_EmptyView = 11; - int ENABLE_RecyclerView = 12; - int ENABLE_HookActionUpRecyclerview = 13; -} diff --git a/app/src/main/java/com/example/demo/anno/ChatPageType.java b/app/src/main/java/com/example/demo/anno/ChatPageType.java deleted file mode 100644 index 241194f..0000000 --- a/app/src/main/java/com/example/demo/anno/ChatPageType.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.example.demo.anno; - - -import android.support.annotation.IntDef; - -import static com.example.demo.anno.ChatPageType.DEFAULT; -import static com.example.demo.anno.ChatPageType.COLOR_STATUS_BAR; -import static com.example.demo.anno.ChatPageType.TITLE_BAR; -import static com.example.demo.anno.ChatPageType.TRANSPARENT_STATUS_BAR; -import static com.example.demo.anno.ChatPageType.TRANSPARENT_STATUS_BAR_DRAW_UNDER; -import static com.example.demo.anno.ChatPageType.CUS_TITLE_BAR; - -@IntDef({DEFAULT, TITLE_BAR, COLOR_STATUS_BAR, CUS_TITLE_BAR, TRANSPARENT_STATUS_BAR, TRANSPARENT_STATUS_BAR_DRAW_UNDER}) -public @interface ChatPageType { - int DEFAULT = 0; - int TITLE_BAR = 1; - int CUS_TITLE_BAR = 2; - int COLOR_STATUS_BAR = 3; - int TRANSPARENT_STATUS_BAR = 4; - int TRANSPARENT_STATUS_BAR_DRAW_UNDER = 5; -} diff --git a/app/src/main/java/com/example/demo/scene/chat/ChatActivity.java b/app/src/main/java/com/example/demo/scene/chat/ChatActivity.java deleted file mode 100644 index 4181f15..0000000 --- a/app/src/main/java/com/example/demo/scene/chat/ChatActivity.java +++ /dev/null @@ -1,245 +0,0 @@ -package com.example.demo.scene.chat; - -import android.content.Context; -import android.content.Intent; -import android.databinding.DataBindingUtil; -import android.graphics.Color; -import android.support.annotation.NonNull; -import android.support.v4.content.ContextCompat; -import android.support.v7.app.AppCompatActivity; -import android.os.Bundle; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.text.TextUtils; -import android.util.Log; -import android.view.View; -import android.view.Window; -import android.widget.Toast; - -import com.effective.R; -import com.effective.android.panel.PanelSwitchHelper; -import com.effective.android.panel.interfaces.ContentScrollMeasurer; -import com.effective.android.panel.interfaces.listener.OnPanelChangeListener; -import com.effective.android.panel.view.panel.IPanelView; -import com.effective.android.panel.view.panel.PanelView; -import com.effective.databinding.CommonChatLayoutBinding; -import com.example.demo.Constants; -import com.example.demo.anno.ChatPageType; -import com.example.demo.scene.chat.adapter.ChatAdapter; -import com.example.demo.scene.chat.adapter.ChatInfo; -import com.example.demo.scene.chat.emotion.EmotionPagerView; -import com.example.demo.scene.chat.emotion.Emotions; -import com.example.demo.systemui.StatusbarHelper; -import com.example.demo.util.DisplayUtils; -import com.rd.PageIndicatorView; - -import org.jetbrains.annotations.NotNull; - -/** - * Created by yummyLau on 18-7-11 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -public class ChatActivity extends AppCompatActivity { - - public static void start(Context context, @ChatPageType int type) { - Intent intent = new Intent(context, ChatActivity.class); - intent.putExtra(Constants.KEY_PAGE_TYPE, type); - context.startActivity(intent); - } - - private CommonChatLayoutBinding mBinding; - private PanelSwitchHelper mHelper; - private ChatAdapter mAdapter; - private LinearLayoutManager mLinearLayoutManager; - - private static final String TAG = ChatActivity.class.getSimpleName(); - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - int type = getIntent().getIntExtra(Constants.KEY_PAGE_TYPE, ChatPageType.DEFAULT); - switch (type) { - case ChatPageType.TITLE_BAR: { - mBinding = DataBindingUtil.setContentView(this, R.layout.common_chat_layout); - mBinding.getRoot().setBackgroundColor(ContextCompat.getColor(this, R.color.common_page_bg_color)); - getSupportActionBar().setTitle("Activity-有标题栏"); - break; - } - case ChatPageType.COLOR_STATUS_BAR: { - mBinding = DataBindingUtil.setContentView(this, R.layout.common_chat_layout); - StatusbarHelper.setStatusBarColor(this, ContextCompat.getColor(this, R.color.colorPrimary)); - mBinding.statusBar.setVisibility(View.VISIBLE); - getSupportActionBar().setTitle("Activity-有标题栏,状态栏着色"); - mBinding.getRoot().setBackgroundColor(ContextCompat.getColor(this, R.color.common_page_bg_color)); - break; - } - case ChatPageType.DEFAULT: { - supportRequestWindowFeature(Window.FEATURE_NO_TITLE); - mBinding = DataBindingUtil.setContentView(this, R.layout.common_chat_layout); - mBinding.getRoot().setBackgroundColor(ContextCompat.getColor(this, R.color.common_page_bg_color)); - break; - } - case ChatPageType.CUS_TITLE_BAR: { - supportRequestWindowFeature(Window.FEATURE_NO_TITLE); - mBinding = DataBindingUtil.setContentView(this, R.layout.common_chat_layout); - mBinding.cusTitleBar.setVisibility(View.VISIBLE); - mBinding.title.setText("Activity-自定义标题栏"); - mBinding.getRoot().setBackgroundColor(ContextCompat.getColor(this, R.color.common_page_bg_color)); - break; - } - case ChatPageType.TRANSPARENT_STATUS_BAR: { - supportRequestWindowFeature(Window.FEATURE_NO_TITLE); - mBinding = DataBindingUtil.setContentView(this, R.layout.common_chat_layout); - mBinding.statusBar.setVisibility(View.VISIBLE); - StatusbarHelper.setStatusBarColor(this, Color.TRANSPARENT); - mBinding.getRoot().setBackgroundResource(R.drawable.bg_gradient); - break; - } - case ChatPageType.TRANSPARENT_STATUS_BAR_DRAW_UNDER: { - supportRequestWindowFeature(Window.FEATURE_NO_TITLE); - mBinding = DataBindingUtil.setContentView(this, R.layout.common_chat_layout); - StatusbarHelper.setStatusBarColor(this, Color.TRANSPARENT); - mBinding.getRoot().setBackgroundResource(R.drawable.bg_gradient); - break; - } - } - initView(); - } - - private void initView() { - mLinearLayoutManager = new LinearLayoutManager(this); - mBinding.recyclerView.setLayoutManager(mLinearLayoutManager); - mAdapter = new ChatAdapter(this, 4); - mBinding.recyclerView.setAdapter(mAdapter); - mBinding.send.setOnClickListener(v -> { - String content = mBinding.editText.getText().toString(); - if (TextUtils.isEmpty(content)) { - Toast.makeText(ChatActivity.this, "当前没有输入", Toast.LENGTH_SHORT).show(); - return; - } - mAdapter.insertInfo(ChatInfo.CREATE(content)); - mBinding.editText.setText(null); - scrollToBottom(); - }); - } - - - private void scrollToBottom() { - mBinding.getRoot().post(() -> mLinearLayoutManager.scrollToPosition(mAdapter.getItemCount() - 1)); - } - - @Override - protected void onStart() { - super.onStart(); - if (mHelper == null) { - mHelper = new PanelSwitchHelper.Builder(this) - //可选 - .addKeyboardStateListener((visible, height) -> Log.d(TAG, "系统键盘是否可见 : " + visible + " 高度为:" + height)) - .addEditTextFocusChangeListener((view, hasFocus) -> { - Log.d(TAG, "输入框是否获得焦点 : " + hasFocus); - if (hasFocus) { - scrollToBottom(); - } - }) - //可选 - .addViewClickListener(view -> { - switch (view.getId()) { - case R.id.edit_text: - case R.id.add_btn: - case R.id.emotion_btn: { - scrollToBottom(); - } - } - Log.d(TAG, "点击了View : " + view); - }) - //可选 - .addPanelChangeListener(new OnPanelChangeListener() { - - @Override - public void onKeyboard() { - Log.d(TAG, "唤起系统输入法"); - mBinding.emotionBtn.setSelected(false); - scrollToBottom(); - } - - @Override - public void onNone() { - Log.d(TAG, "隐藏所有面板"); - mBinding.emotionBtn.setSelected(false); - } - - @Override - public void onPanel(IPanelView view) { - Log.d(TAG, "唤起面板 : " + view); - if (view instanceof PanelView) { - mBinding.emotionBtn.setSelected(((PanelView) view).getId() == R.id.panel_emotion ? true : false); - scrollToBottom(); - } - } - - @Override - public void onPanelSizeChange(IPanelView panelView, boolean portrait, int oldWidth, int oldHeight, int width, int height) { - if (panelView instanceof PanelView) { - switch (((PanelView) panelView).getId()) { - case R.id.panel_emotion: { - EmotionPagerView pagerView = mBinding.getRoot().findViewById(R.id.view_pager); - int viewPagerSize = height - DisplayUtils.dip2px(ChatActivity.this, 30f); - pagerView.buildEmotionViews( - (PageIndicatorView) mBinding.getRoot().findViewById(R.id.pageIndicatorView), - mBinding.editText, - Emotions.getEmotions(), width, viewPagerSize); - break; - } - case R.id.panel_addition: { - //auto center,nothing to do - break; - } - } - } - } - }) - .addContentScrollMeasurer(new ContentScrollMeasurer() { - @Override - public int getScrollDistance(int defaultDistance) { - return defaultDistance - unfilledHeight; - } - - @Override - public int getScrollViewId() { - return R.id.recycler_view; - } - }) - .logTrack(true) //output log - .build(); - mBinding.recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { - @Override - public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { - super.onScrolled(recyclerView, dx, dy); - RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); - if (layoutManager instanceof LinearLayoutManager) { - int childCount = recyclerView.getChildCount(); - if (childCount > 0) { - View lastChildView = recyclerView.getChildAt(childCount - 1); - int bottom = lastChildView.getBottom(); - int listHeight = mBinding.recyclerView.getHeight() - mBinding.recyclerView.getPaddingBottom(); - unfilledHeight = listHeight - bottom; - } - } - } - }); - } - mBinding.recyclerView.setPanelSwitchHelper(mHelper); - } - - private int unfilledHeight = 0; - - - @Override - public void onBackPressed() { - if (mHelper != null && mHelper.hookSystemBackByPanelSwitcher()) { - return; - } - super.onBackPressed(); - } -} diff --git a/app/src/main/java/com/example/demo/scene/chat/ChatCusContentScrollActivity.java b/app/src/main/java/com/example/demo/scene/chat/ChatCusContentScrollActivity.java deleted file mode 100644 index f59635d..0000000 --- a/app/src/main/java/com/example/demo/scene/chat/ChatCusContentScrollActivity.java +++ /dev/null @@ -1,262 +0,0 @@ -package com.example.demo.scene.chat; - -import android.content.Context; -import android.content.Intent; -import android.databinding.DataBindingUtil; -import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.v4.content.ContextCompat; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.text.TextUtils; -import android.util.Log; -import android.view.View; -import android.view.Window; -import android.widget.Toast; - - -import com.effective.R; -import com.effective.android.panel.PanelSwitchHelper; -import com.effective.android.panel.interfaces.ContentScrollMeasurer; -import com.effective.android.panel.interfaces.listener.OnPanelChangeListener; -import com.effective.android.panel.utils.PanelUtil; -import com.effective.android.panel.view.panel.IPanelView; -import com.effective.android.panel.view.panel.PanelView; -import com.effective.databinding.CommonChatLayoutBinding; -import com.example.demo.scene.chat.adapter.ChatAdapter; -import com.example.demo.scene.chat.adapter.ChatInfo; -import com.example.demo.scene.chat.emotion.EmotionPagerView; -import com.example.demo.scene.chat.emotion.Emotions; -import com.example.demo.util.DisplayUtils; -import com.rd.PageIndicatorView; - -import org.jetbrains.annotations.NotNull; - -/** - * 自定义内容面板内的scroll - * 处理单独的兼容聊天场景,比如聊天页面内部可能出现一些复层的UI,如新消息提示,悬浮view等,可以自定义兼容滑动行为。 - * Created by yummyLau on 18-7-11 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -public class ChatCusContentScrollActivity extends AppCompatActivity { - - public static void start(Context context) { - Intent intent = new Intent(context, ChatCusContentScrollActivity.class); - context.startActivity(intent); - } - - private CommonChatLayoutBinding mBinding; - private PanelSwitchHelper mHelper; - private ChatAdapter mAdapter; - private LinearLayoutManager mLinearLayoutManager; - private static final String TAG = ChatCusContentScrollActivity.class.getSimpleName(); - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - supportRequestWindowFeature(Window.FEATURE_NO_TITLE); - mBinding = DataBindingUtil.setContentView(this, R.layout.common_chat_layout); - mBinding.getRoot().setBackgroundColor(ContextCompat.getColor(this, R.color.common_page_bg_color)); - mBinding.tipView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - PanelUtil.clearData(ChatCusContentScrollActivity.this); - } - }); - initView(); - } - - private void initView() { - mBinding.tipViewTop.setVisibility(View.VISIBLE); - mBinding.tipViewBottom.setVisibility(View.VISIBLE); - mBinding.tipView.setVisibility(View.VISIBLE); - mLinearLayoutManager = new LinearLayoutManager(this); - mBinding.recyclerView.setLayoutManager(mLinearLayoutManager); - mAdapter = new ChatAdapter(this, 4); - mBinding.recyclerView.setAdapter(mAdapter); - mBinding.send.setOnClickListener(v -> { - String content = mBinding.editText.getText().toString(); - if (TextUtils.isEmpty(content)) { - Toast.makeText(ChatCusContentScrollActivity.this, "当前没有输入", Toast.LENGTH_SHORT).show(); - return; - } - mAdapter.insertInfo(ChatInfo.CREATE(content)); - mBinding.editText.setText(null); - scrollToBottom(); - }); - } - - - private void scrollToBottom() { - mBinding.getRoot().post(() -> mLinearLayoutManager.scrollToPosition(mAdapter.getItemCount() - 1)); - } - - @Override - protected void onStart() { - super.onStart(); - if (mHelper == null) { - mHelper = new PanelSwitchHelper.Builder(this) - //可选 - .addKeyboardStateListener((visible, height) -> Log.d(TAG, "系统键盘是否可见 : " + visible + " 高度为:" + height)) - .addEditTextFocusChangeListener((view, hasFocus) -> { - Log.d(TAG, "输入框是否获得焦点 : " + hasFocus); - if (hasFocus) { - scrollToBottom(); - } - }) - //可选 - .addViewClickListener(view -> { - switch (view.getId()) { - case R.id.edit_text: - case R.id.add_btn: - case R.id.emotion_btn: { - scrollToBottom(); - } - } - Log.d(TAG, "点击了View : " + view); - }) - //可选 - .addPanelChangeListener(new OnPanelChangeListener() { - - @Override - public void onKeyboard() { - Log.d(TAG, "唤起系统输入法"); - mBinding.emotionBtn.setSelected(false); - scrollToBottom(); - } - - @Override - public void onNone() { - Log.d(TAG, "隐藏所有面板"); - mBinding.emotionBtn.setSelected(false); - } - - @Override - public void onPanel(IPanelView view) { - Log.d(TAG, "唤起面板 : " + view); - if (view instanceof PanelView) { - mBinding.emotionBtn.setSelected(((PanelView) view).getId() == R.id.panel_emotion ? true : false); - scrollToBottom(); - } - } - - @Override - public void onPanelSizeChange(IPanelView panelView, boolean portrait, int oldWidth, int oldHeight, int width, int height) { - if (panelView instanceof PanelView) { - switch (((PanelView) panelView).getId()) { - case R.id.panel_emotion: { - EmotionPagerView pagerView = mBinding.getRoot().findViewById(R.id.view_pager); - int viewPagerSize = height - DisplayUtils.dip2px(ChatCusContentScrollActivity.this, 30f); - pagerView.buildEmotionViews( - (PageIndicatorView) mBinding.getRoot().findViewById(R.id.pageIndicatorView), - mBinding.editText, - Emotions.getEmotions(), width, viewPagerSize); - break; - } - case R.id.panel_addition: { - //auto center,nothing to do - break; - } - } - } - } - }) - /** - * 根据recyclerview的内容填充度来滑动 - */ - .addContentScrollMeasurer(new ContentScrollMeasurer() { - @Override - public int getScrollDistance(int defaultDistance) { - return defaultDistance - listUnfilledHeight; - } - - @Override - public int getScrollViewId() { - return R.id.recycler_view; - } - }) - /** - * tipViewBottom 确保底部输入栏不遮挡 - */ - .addContentScrollMeasurer(new ContentScrollMeasurer() { - @Override - public int getScrollDistance(int defaultDistance) { - return defaultDistance - bottomUnfilledHeight; - } - - @Override - public int getScrollViewId() { - return R.id.tip_view_bottom; - } - }) - /** - * tipViewTop 不跟随滑动 - */ - .addContentScrollMeasurer(new ContentScrollMeasurer() { - @Override - public int getScrollDistance(int defaultDistance) { - return 0; - } - - @Override - public int getScrollViewId() { - return R.id.tip_view_top; - } - }) - /** - * 默认实现,contentContainer 内部的子view会随容器向上scroll defaultDistance 距离 - */ - .addContentScrollMeasurer(new ContentScrollMeasurer() { - - @Override - public int getScrollDistance(int defaultDistance) { - return defaultDistance; - } - - @Override - public int getScrollViewId() { - return R.id.tip_view; - } - }) - .logTrack(true) //output log - .build(); - mBinding.recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { - @Override - public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { - super.onScrolled(recyclerView, dx, dy); - RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); - if (layoutManager instanceof LinearLayoutManager) { - int childCount = recyclerView.getChildCount(); - if (childCount > 0) { - View lastChildView = recyclerView.getChildAt(childCount - 1); - int bottom = lastChildView.getBottom(); - int listHeight = mBinding.recyclerView.getHeight() - mBinding.recyclerView.getPaddingBottom(); - listUnfilledHeight = listHeight - bottom; - } - } - } - }); - mBinding.recyclerView.post(new Runnable() { - @Override - public void run() { - bottomUnfilledHeight = mBinding.bottomAction.getTop() - mBinding.tipViewBottom.getBottom(); - } - }); - } - mBinding.recyclerView.setPanelSwitchHelper(mHelper); - } - - private int listUnfilledHeight = 0; - private int bottomUnfilledHeight = 0; - - - @Override - public void onBackPressed() { - if (mHelper != null && mHelper.hookSystemBackByPanelSwitcher()) { - return; - } - super.onBackPressed(); - } -} diff --git a/app/src/main/java/com/example/demo/scene/chat/ChatDialog.java b/app/src/main/java/com/example/demo/scene/chat/ChatDialog.java deleted file mode 100644 index f095b48..0000000 --- a/app/src/main/java/com/example/demo/scene/chat/ChatDialog.java +++ /dev/null @@ -1,167 +0,0 @@ -package com.example.demo.scene.chat; - -import android.app.Activity; -import android.content.DialogInterface; -import android.databinding.DataBindingUtil; -import android.graphics.drawable.ColorDrawable; -import android.support.v4.content.ContextCompat; -import android.support.v7.widget.LinearLayoutManager; -import android.text.TextUtils; -import android.util.Log; -import android.view.KeyEvent; -import android.view.View; -import android.widget.Toast; - -import com.effective.R; -import com.effective.android.panel.PanelSwitchHelper; -import com.effective.android.panel.interfaces.listener.OnPanelChangeListener; -import com.effective.android.panel.view.panel.IPanelView; -import com.effective.android.panel.view.panel.PanelView; -import com.effective.android.panel.window.PanelDialog; -import com.effective.databinding.CommonChatWithTitlebarLayoutBinding; -import com.example.demo.scene.chat.adapter.ChatAdapter; -import com.example.demo.scene.chat.adapter.ChatInfo; -import com.example.demo.scene.chat.emotion.EmotionPagerView; -import com.example.demo.scene.chat.emotion.Emotions; -import com.example.demo.util.DisplayUtils; -import com.rd.PageIndicatorView; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class ChatDialog extends PanelDialog implements DialogInterface.OnKeyListener { - - private CommonChatWithTitlebarLayoutBinding mBinding; - private PanelSwitchHelper mHelper; - private ChatAdapter mAdapter; - private LinearLayoutManager mLinearLayoutManager; - private static final String TAG = "ChatDialog"; - private Activity activity; - - @Override - public int getDialogLayout() { - return R.layout.common_chat_with_titlebar_layout; - } - - public ChatDialog(Activity context) { - super(context); - this.activity = context; - mBinding = DataBindingUtil.bind(rootView); - mBinding.statusBar.setVisibility(View.GONE); - getWindow().setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(activity, R.color.common_page_bg_color))); - setOnKeyListener(this); - initView(); - } - - @Override - public void show() { - if (mHelper == null) { - mHelper = new PanelSwitchHelper.Builder(activity.getWindow(), mBinding.getRoot()) - //可选 - .addKeyboardStateListener((visible, height) -> Log.d(TAG, "系统键盘是否可见 : " + visible + " 高度为:" + height)) - //可选 - .addEditTextFocusChangeListener((view, hasFocus) -> { - Log.d(TAG, "输入框是否获得焦点 : " + hasFocus); - if (hasFocus) { - scrollToBottom(); - } - }) - //可选 - .addViewClickListener(view -> { - switch (view.getId()) { - case R.id.edit_text: - case R.id.add_btn: - case R.id.emotion_btn: { - scrollToBottom(); - } - } - Log.d(TAG, "点击了View : " + view); - }) - //可选 - .addPanelChangeListener(new OnPanelChangeListener() { - - @Override - public void onKeyboard() { - Log.d(TAG, "唤起系统输入法"); - mBinding.emotionBtn.setSelected(false); - } - - @Override - public void onNone() { - Log.d(TAG, "隐藏所有面板"); - mBinding.emotionBtn.setSelected(false); - } - - @Override - public void onPanel(IPanelView view) { - Log.d(TAG, "唤起面板 : " + view); - if (view instanceof PanelView) { - mBinding.emotionBtn.setSelected(((PanelView) view).getId() == R.id.panel_emotion ? true : false); - } - } - - - @Override - public void onPanelSizeChange(IPanelView panelView, boolean portrait, int oldWidth, int oldHeight, int width, int height) { - if (panelView instanceof PanelView) { - switch (((PanelView) panelView).getId()) { - case R.id.panel_emotion: { - EmotionPagerView pagerView = mBinding.getRoot().findViewById(R.id.view_pager); - int viewPagerSize = height - DisplayUtils.dip2px(getContext(), 30f); - pagerView.buildEmotionViews( - (PageIndicatorView) mBinding.getRoot().findViewById(R.id.pageIndicatorView), - mBinding.editText, - Emotions.getEmotions(), width, viewPagerSize); - break; - } - case R.id.panel_addition: { - //auto center,nothing to do - break; - } - } - } - } - }) - .logTrack(true) //output log - .build(); - } - mBinding.recyclerView.setPanelSwitchHelper(mHelper); - super.show(); - } - - - private void initView() { - mBinding.title.setText("我是一个dialog"); - mLinearLayoutManager = new LinearLayoutManager(getContext()); - mBinding.recyclerView.setLayoutManager(mLinearLayoutManager); - mAdapter = new ChatAdapter(getContext(), 50); - mBinding.recyclerView.setAdapter(mAdapter); - mBinding.send.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - String content = mBinding.editText.getText().toString(); - if (TextUtils.isEmpty(content)) { - Toast.makeText(getContext(), "当前没有输入", Toast.LENGTH_SHORT).show(); - return; - } - mAdapter.insertInfo(ChatInfo.CREATE(content)); - mBinding.editText.setText(null); - scrollToBottom(); - } - }); - } - - private void scrollToBottom() { - mLinearLayoutManager.scrollToPosition(mAdapter.getItemCount() - 1); - } - - @Override - public boolean onKey(@Nullable DialogInterface dialog, int keyCode, @NotNull KeyEvent event) { - if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { - if (mHelper != null && mHelper.hookSystemBackByPanelSwitcher()) { - return true; - } - } - return false; - } -} diff --git a/app/src/main/java/com/example/demo/scene/chat/ChatDialogFragment.java b/app/src/main/java/com/example/demo/scene/chat/ChatDialogFragment.java deleted file mode 100644 index a89cd90..0000000 --- a/app/src/main/java/com/example/demo/scene/chat/ChatDialogFragment.java +++ /dev/null @@ -1,183 +0,0 @@ -package com.example.demo.scene.chat; - -import android.app.Dialog; -import android.content.DialogInterface; -import android.databinding.DataBindingUtil; -import android.graphics.drawable.ColorDrawable; -import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.DialogFragment; -import android.support.v4.content.ContextCompat; -import android.support.v7.widget.LinearLayoutManager; -import android.text.TextUtils; -import android.util.Log; -import android.view.KeyEvent; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.Toast; - -import com.effective.R; -import com.effective.android.panel.PanelSwitchHelper; -import com.effective.android.panel.interfaces.listener.OnPanelChangeListener; -import com.effective.android.panel.view.panel.IPanelView; -import com.effective.android.panel.view.panel.PanelView; -import com.effective.databinding.CommonChatWithTitlebarLayoutBinding; -import com.example.demo.scene.chat.adapter.ChatAdapter; -import com.example.demo.scene.chat.adapter.ChatInfo; -import com.example.demo.scene.chat.emotion.EmotionPagerView; -import com.example.demo.scene.chat.emotion.Emotions; -import com.example.demo.util.DisplayUtils; -import com.rd.PageIndicatorView; - -public class ChatDialogFragment extends DialogFragment implements DialogInterface.OnKeyListener { - - private CommonChatWithTitlebarLayoutBinding mBinding; - private PanelSwitchHelper mHelper; - private ChatAdapter mAdapter; - private LinearLayoutManager mLinearLayoutManager; - private static final String TAG = "ChatDialogFragment"; - - @Nullable - @Override - public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - mBinding = DataBindingUtil.inflate(LayoutInflater.from(getContext()), R.layout.common_chat_with_titlebar_layout, container, false); - mBinding.statusBar.setVisibility(View.GONE); - mBinding.titleBar.setVisibility(View.VISIBLE); - mBinding.titleBar.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.colorPrimary)); - mBinding.title.setText(R.string.dialog_fragment_name); - initView(); - return mBinding.getRoot(); - } - - /** - * dialogfragment基于dialog实现,需要设置以下代码 - */ - @Override - public void onStart() { - super.onStart(); - Dialog dialog = getDialog(); - if (dialog != null) { - dialog.setOnKeyListener(this); - int width = ViewGroup.LayoutParams.MATCH_PARENT; - int height = ViewGroup.LayoutParams.MATCH_PARENT; - dialog.getWindow().setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(getContext(),R.color.common_page_bg_color))); - dialog.getWindow().setLayout(width, height); - } - } - - private void initView() { - mLinearLayoutManager = new LinearLayoutManager(getContext()); - mBinding.recyclerView.setLayoutManager(mLinearLayoutManager); - mAdapter = new ChatAdapter(getContext(), 50); - mBinding.recyclerView.setAdapter(mAdapter); - mBinding.send.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - String content = mBinding.editText.getText().toString(); - if (TextUtils.isEmpty(content)) { - Toast.makeText(getContext(), "当前没有输入", Toast.LENGTH_SHORT).show(); - return; - } - mAdapter.insertInfo(ChatInfo.CREATE(content)); - mBinding.editText.setText(null); - scrollToBottom(); - } - }); - } - - private void scrollToBottom() { - mLinearLayoutManager.scrollToPosition(mAdapter.getItemCount() - 1); - } - - @Override - public void onActivityCreated(@Nullable Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - if (mHelper == null) { - mHelper = new PanelSwitchHelper.Builder(this) - //可选 - .addKeyboardStateListener((visible, height) -> Log.d(TAG, "系统键盘是否可见 : " + visible + " 高度为:" + height)) - //可选 - .addEditTextFocusChangeListener((view, hasFocus) -> { - Log.d(TAG, "输入框是否获得焦点 : " + hasFocus); - if(hasFocus){ - scrollToBottom(); - } - }) - //可选 - .addViewClickListener(view -> { - switch (view.getId()){ - case R.id.edit_text: - case R.id.add_btn: - case R.id.emotion_btn:{ - scrollToBottom(); - } - } - Log.d(TAG, "点击了View : " + view); - }) - //可选 - .addPanelChangeListener(new OnPanelChangeListener() { - - @Override - public void onKeyboard() { - Log.d(TAG, "唤起系统输入法"); - mBinding.emotionBtn.setSelected(false); - } - - @Override - public void onNone() { - Log.d(TAG, "隐藏所有面板"); - mBinding.emotionBtn.setSelected(false); - } - - @Override - public void onPanel(IPanelView view) { - Log.d(TAG, "唤起面板 : " + view); - if(view instanceof PanelView){ - mBinding.emotionBtn.setSelected(((PanelView)view).getId() == R.id.panel_emotion ? true : false); - } - } - - @Override - public void onPanelSizeChange(IPanelView panelView, boolean portrait, int oldWidth, int oldHeight, int width, int height) { - if(panelView instanceof PanelView){ - switch (((PanelView)panelView).getId()) { - case R.id.panel_emotion: { - EmotionPagerView pagerView = mBinding.getRoot().findViewById(R.id.view_pager); - int viewPagerSize = height - DisplayUtils.dip2px(getContext(), 30f); - pagerView.buildEmotionViews( - (PageIndicatorView) mBinding.getRoot().findViewById(R.id.pageIndicatorView), - mBinding.editText, - Emotions.getEmotions(), width, viewPagerSize); - break; - } - case R.id.panel_addition: { - //auto center,nothing to do - break; - } - } - } - } - }) - .logTrack(true) //output log - .build(); - } - mBinding.recyclerView.setPanelSwitchHelper(mHelper); - } - - - @Override - public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { - if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { - if (mHelper != null && mHelper.hookSystemBackByPanelSwitcher()) { - return true; - } else { - dismiss(); - return true; - } - } - return false; - } - -} diff --git a/app/src/main/java/com/example/demo/scene/chat/ChatFragment.java b/app/src/main/java/com/example/demo/scene/chat/ChatFragment.java deleted file mode 100644 index 27d3ffd..0000000 --- a/app/src/main/java/com/example/demo/scene/chat/ChatFragment.java +++ /dev/null @@ -1,184 +0,0 @@ -package com.example.demo.scene.chat; - -import android.databinding.DataBindingUtil; -import android.graphics.Color; -import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.support.v4.content.ContextCompat; -import android.support.v7.widget.LinearLayoutManager; -import android.text.TextUtils; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.Toast; - -import com.effective.R; -import com.effective.android.panel.PanelSwitchHelper; -import com.effective.android.panel.interfaces.listener.OnPanelChangeListener; -import com.effective.android.panel.view.panel.IPanelView; -import com.effective.android.panel.view.panel.PanelView; -import com.effective.databinding.CommonChatWithTitlebarLayoutBinding; -import com.example.demo.Constants; -import com.example.demo.anno.ChatPageType; -import com.example.demo.scene.chat.adapter.ChatAdapter; -import com.example.demo.scene.chat.adapter.ChatInfo; -import com.example.demo.scene.chat.emotion.EmotionPagerView; -import com.example.demo.scene.chat.emotion.Emotions; -import com.example.demo.systemui.StatusbarHelper; -import com.example.demo.util.DisplayUtils; -import com.rd.PageIndicatorView; - -public class ChatFragment extends Fragment { - - private CommonChatWithTitlebarLayoutBinding mBinding; - private PanelSwitchHelper mHelper; - private ChatAdapter mAdapter; - private LinearLayoutManager mLinearLayoutManager; - private static final String TAG = "ChatFragment"; - - @Nullable - @Override - public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - mBinding = DataBindingUtil.inflate(LayoutInflater.from(getContext()), R.layout.common_chat_with_titlebar_layout, container, false); - - int type = getArguments().getInt(Constants.KEY_PAGE_TYPE); - - switch (type) { - case ChatPageType.COLOR_STATUS_BAR: { - mBinding.getRoot().setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.common_page_bg_color)); - mBinding.statusBar.setColor(R.color.colorPrimary); - mBinding.titleBar.setVisibility(View.VISIBLE); - mBinding.titleBar.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.colorPrimary)); - mBinding.title.setText("Fragment-自定义标题栏,状态栏着色"); - break; - } - case ChatPageType.TRANSPARENT_STATUS_BAR: { - StatusbarHelper.setStatusBarColor(getActivity(), Color.TRANSPARENT); - mBinding.titleBar.setVisibility(View.VISIBLE); - mBinding.title.setText("Fragment-自定义标题栏,状态栏透明"); - break; - } - default: { - mBinding.getRoot().setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.common_page_bg_color)); - mBinding.statusBar.setColor(R.color.colorPrimary); - mBinding.titleBar.setVisibility(type == ChatPageType.DEFAULT ? View.GONE : View.VISIBLE); - mBinding.titleBar.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.colorPrimary)); - mBinding.title.setText("Fragment-自定义标题栏"); - } - } - initView(); - return mBinding.getRoot(); - } - - - private void initView() { - mLinearLayoutManager = new LinearLayoutManager(getContext()); - mBinding.recyclerView.setLayoutManager(mLinearLayoutManager); - mAdapter = new ChatAdapter(getContext(), 50); - mBinding.recyclerView.setAdapter(mAdapter); - mBinding.send.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - String content = mBinding.editText.getText().toString(); - if (TextUtils.isEmpty(content)) { - Toast.makeText(getContext(), "当前没有输入", Toast.LENGTH_SHORT).show(); - return; - } - mAdapter.insertInfo(ChatInfo.CREATE(content)); - mBinding.editText.setText(null); - scrollToBottom(); - } - }); - } - - private void scrollToBottom() { - mLinearLayoutManager.scrollToPosition(mAdapter.getItemCount() - 1); - } - - @Override - public void onActivityCreated(@Nullable Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - if (mHelper == null) { - mHelper = new PanelSwitchHelper.Builder(this) - //可选 - .addKeyboardStateListener((visible, height) -> Log.d(TAG, "系统键盘是否可见 : " + visible + " 高度为:" + height)) - //可选 - .addEditTextFocusChangeListener((view, hasFocus) -> { - Log.d(TAG, "输入框是否获得焦点 : " + hasFocus); - if(hasFocus){ - scrollToBottom(); - } - }) - //可选 - .addViewClickListener(view -> { - switch (view.getId()){ - case R.id.edit_text: - case R.id.add_btn: - case R.id.emotion_btn:{ - scrollToBottom(); - } - } - Log.d(TAG, "点击了View : " + view); - }) - //可选 - .addPanelChangeListener(new OnPanelChangeListener() { - - @Override - public void onKeyboard() { - Log.d(TAG, "唤起系统输入法"); - mBinding.emotionBtn.setSelected(false); - } - - @Override - public void onNone() { - Log.d(TAG, "隐藏所有面板"); - mBinding.emotionBtn.setSelected(false); - } - - @Override - public void onPanel(IPanelView view) { - Log.d(TAG, "唤起面板 : " + view); - if(view instanceof PanelView){ - mBinding.emotionBtn.setSelected(((PanelView)view).getId() == R.id.panel_emotion ? true : false); - } - } - - @Override - public void onPanelSizeChange(IPanelView panelView, boolean portrait, int oldWidth, int oldHeight, int width, int height) { - if(panelView instanceof PanelView){ - switch (((PanelView)panelView).getId()) { - case R.id.panel_emotion: { - EmotionPagerView pagerView = mBinding.getRoot().findViewById(R.id.view_pager); - int viewPagerSize = height - DisplayUtils.dip2px(getContext(), 30f); - pagerView.buildEmotionViews( - (PageIndicatorView) mBinding.getRoot().findViewById(R.id.pageIndicatorView), - mBinding.editText, - Emotions.getEmotions(), width, viewPagerSize); - break; - } - case R.id.panel_addition: { - //auto center,nothing to do - break; - } - } - } - } - }) - .logTrack(true) //output log - .build(); - } - mBinding.recyclerView.setPanelSwitchHelper(mHelper); - } - - public boolean hookOnBackPressed() { - return mHelper != null && mHelper.hookSystemBackByPanelSwitcher(); - } - - @Override - public void onDestroy() { - super.onDestroy(); - } -} diff --git a/app/src/main/java/com/example/demo/scene/chat/ChatFragmentActivity.java b/app/src/main/java/com/example/demo/scene/chat/ChatFragmentActivity.java deleted file mode 100644 index ebfb478..0000000 --- a/app/src/main/java/com/example/demo/scene/chat/ChatFragmentActivity.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.example.demo.scene.chat; - -import android.content.Context; -import android.content.Intent; -import android.databinding.DataBindingUtil; -import android.graphics.Color; -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v4.app.FragmentActivity; - -import com.effective.R; -import com.effective.databinding.ActivityChatFragmentLayoutBinding; -import com.example.demo.Constants; -import com.example.demo.anno.ChatPageType; -import com.example.demo.systemui.StatusbarHelper; - -public class ChatFragmentActivity extends FragmentActivity { - - public static void startFragment(Context context, @ChatPageType int pageType) { - Intent intent = new Intent(context, ChatFragmentActivity.class); - intent.putExtra(Constants.KEY_PAGE_TYPE, pageType); - context.startActivity(intent); - } - - private ActivityChatFragmentLayoutBinding mBinding; - private ChatFragment fragment; - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - //涉及fragment页面沉浸的,建议统一都在fragment里面,这样做是为了多fragment的时候灵活控制 - mBinding = DataBindingUtil.setContentView(this, R.layout.activity_chat_fragment_layout); - StatusbarHelper.setStatusBarColor(this, Color.TRANSPARENT); - fragment = new ChatFragment(); - fragment.setArguments(getIntent().getExtras()); - getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, fragment).commit(); -/* if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - Window window = getWindow(); - window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - window.setStatusBarColor(Color.TRANSPARENT); - window.setNavigationBarColor(Color.TRANSPARENT); - window.getDecorView().setSystemUiVisibility( - window.getDecorView().getSystemUiVisibility() | - View.SYSTEM_UI_FLAG_LAYOUT_STABLE | - View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); - }*/ - } - - @Override - public void onBackPressed() { - if (fragment != null && fragment.hookOnBackPressed()) { - return; - } - super.onBackPressed(); - } -} diff --git a/app/src/main/java/com/example/demo/scene/chat/ChatPopupWindow.java b/app/src/main/java/com/example/demo/scene/chat/ChatPopupWindow.java deleted file mode 100644 index 0e04c47..0000000 --- a/app/src/main/java/com/example/demo/scene/chat/ChatPopupWindow.java +++ /dev/null @@ -1,170 +0,0 @@ -package com.example.demo.scene.chat; - -import android.app.Activity; -import android.databinding.DataBindingUtil; -import android.graphics.drawable.ColorDrawable; -import android.support.v4.content.ContextCompat; -import android.support.v7.widget.LinearLayoutManager; -import android.text.TextUtils; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.WindowManager; -import android.widget.PopupWindow; -import android.widget.Toast; - -import com.effective.R; -import com.effective.android.panel.PanelSwitchHelper; -import com.effective.android.panel.interfaces.listener.OnPanelChangeListener; -import com.effective.android.panel.view.panel.IPanelView; -import com.effective.android.panel.view.panel.PanelView; -import com.effective.databinding.CommonChatWithTitlebarLayoutBinding; -import com.example.demo.scene.chat.adapter.ChatAdapter; -import com.example.demo.scene.chat.adapter.ChatInfo; -import com.example.demo.scene.chat.emotion.EmotionPagerView; -import com.example.demo.scene.chat.emotion.Emotions; -import com.example.demo.util.DisplayUtils; -import com.rd.PageIndicatorView; - -public class ChatPopupWindow extends PopupWindow { - - private CommonChatWithTitlebarLayoutBinding mBinding; - private PanelSwitchHelper mHelper; - private ChatAdapter mAdapter; - private LinearLayoutManager mLinearLayoutManager; - private Activity mActivity; - private static final String TAG = "ChatPupupWindow"; - - public ChatPopupWindow(Activity activity) { - super(activity); - this.mActivity = activity; - mBinding = DataBindingUtil.inflate(LayoutInflater.from(mActivity), R.layout.common_chat_with_titlebar_layout, null, false); - setContentView(mBinding.getRoot()); - mBinding.statusBar.setVisibility(View.GONE); - mBinding.titleBar.setVisibility(View.VISIBLE); - mBinding.titleBar.setBackgroundColor(ContextCompat.getColor(mActivity, R.color.colorPrimary)); - mBinding.title.setText(R.string.pupupwindow_name); - setHeight(WindowManager.LayoutParams.MATCH_PARENT); - setWidth(WindowManager.LayoutParams.MATCH_PARENT); - setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(mActivity, R.color.common_page_bg_color))); - setFocusable(true); - setOutsideTouchable(true); - setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); - setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); - initView(); - } - - - private void initView() { - mLinearLayoutManager = new LinearLayoutManager(mActivity); - mBinding.recyclerView.setLayoutManager(mLinearLayoutManager); - mAdapter = new ChatAdapter(mActivity,50); - mBinding.recyclerView.setAdapter(mAdapter); - mBinding.send.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - String content = mBinding.editText.getText().toString(); - if (TextUtils.isEmpty(content)) { - Toast.makeText(mActivity, "当前没有输入", Toast.LENGTH_SHORT).show(); - return; - } - mAdapter.insertInfo(ChatInfo.CREATE(content)); - mBinding.editText.setText(null); - scrollToBottom(); - } - }); - } - - - private void scrollToBottom() { - mLinearLayoutManager.scrollToPosition(mAdapter.getItemCount() - 1); - } - - @Override - public void showAtLocation(View parent, int gravity, int x, int y) { - initHelper(); - super.showAtLocation(parent, gravity, x, y); - } - - @Override - public void dismiss() { - if (mHelper != null && mHelper.hookSystemBackByPanelSwitcher()) { - return; - } - super.dismiss(); - } - - private void initHelper() { - if (mHelper == null) { - mHelper = new PanelSwitchHelper.Builder(mActivity.getWindow(), this.getContentView()) - //可选 - .addKeyboardStateListener((visible, height) -> Log.d(TAG, "系统键盘是否可见 : " + visible + " 高度为:" + height)) - //可选 - .addEditTextFocusChangeListener((view, hasFocus) -> { - Log.d(TAG, "输入框是否获得焦点 : " + hasFocus); - if(hasFocus){ - scrollToBottom(); - } - }) - //可选 - .addViewClickListener(view -> { - switch (view.getId()){ - case R.id.edit_text: - case R.id.add_btn: - case R.id.emotion_btn:{ - scrollToBottom(); - } - } - Log.d(TAG, "点击了View : " + view); - }) - //可选 - .addPanelChangeListener(new OnPanelChangeListener() { - - @Override - public void onKeyboard() { - Log.d(TAG, "唤起系统输入法"); - mBinding.emotionBtn.setSelected(false); - } - - @Override - public void onNone() { - Log.d(TAG, "隐藏所有面板"); - mBinding.emotionBtn.setSelected(false); - } - - @Override - public void onPanel(IPanelView view) { - Log.d(TAG, "唤起面板 : " + view); - if(view instanceof PanelView){ - mBinding.emotionBtn.setSelected(((PanelView)view).getId() == R.id.panel_emotion ? true : false); - } - } - - @Override - public void onPanelSizeChange(IPanelView panelView, boolean portrait, int oldWidth, int oldHeight, int width, int height) { - if(panelView instanceof PanelView) { - switch (((PanelView)panelView).getId()) { - case R.id.panel_emotion: { - EmotionPagerView pagerView = mBinding.getRoot().findViewById(R.id.view_pager); - int viewPagerSize = height - DisplayUtils.dip2px(mActivity, 30f); - pagerView.buildEmotionViews( - (PageIndicatorView) mBinding.getRoot().findViewById(R.id.pageIndicatorView), - mBinding.editText, - Emotions.getEmotions(), width, viewPagerSize); - break; - } - case R.id.panel_addition: { - //auto center,nothing to do - break; - } - } - } - } - }) - .logTrack(true) //output log - .build(); - } - mBinding.recyclerView.setPanelSwitchHelper(mHelper); - } - -} diff --git a/app/src/main/java/com/example/demo/scene/chat/ChatSuperActivity.java b/app/src/main/java/com/example/demo/scene/chat/ChatSuperActivity.java deleted file mode 100644 index caf9351..0000000 --- a/app/src/main/java/com/example/demo/scene/chat/ChatSuperActivity.java +++ /dev/null @@ -1,322 +0,0 @@ -package com.example.demo.scene.chat; - -import android.content.Context; -import android.content.Intent; -import android.databinding.DataBindingUtil; -import android.graphics.Color; -import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.v4.content.ContextCompat; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.text.TextUtils; -import android.util.Log; -import android.view.View; -import android.view.Window; -import android.view.WindowManager; -import android.widget.Toast; - - -import com.effective.R; -import com.effective.android.panel.PanelSwitchHelper; -import com.effective.android.panel.interfaces.ContentScrollMeasurer; -import com.effective.android.panel.interfaces.PanelHeightMeasurer; -import com.effective.android.panel.interfaces.listener.OnPanelChangeListener; -import com.effective.android.panel.utils.PanelUtil; -import com.effective.android.panel.view.panel.IPanelView; -import com.effective.android.panel.view.panel.PanelView; -import com.effective.databinding.ActivitySuperChatLayoutBinding; -import com.effective.databinding.CommonChatLayoutBinding; -import com.example.demo.Constants; -import com.example.demo.anno.ChatPageType; -import com.example.demo.scene.api.CusPanelView; -import com.example.demo.scene.chat.adapter.ChatAdapter; -import com.example.demo.scene.chat.adapter.ChatInfo; -import com.example.demo.scene.chat.emotion.EmotionPagerView; -import com.example.demo.scene.chat.emotion.Emotions; -import com.example.demo.systemui.StatusbarHelper; -import com.example.demo.util.DisplayUtils; -import com.rd.PageIndicatorView; - -/** - * 复杂的聊天界面,演示所有可能用到的api - * 包括:滑动模式,控制内容区元素滑动,初始化面板适配,自定义面板等 - * Created by yummyLau on 20/07/13 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -public class ChatSuperActivity extends AppCompatActivity { - - public static void start(Context context) { - Intent intent = new Intent(context, ChatCusContentScrollActivity.class); - context.startActivity(intent); - } - - private ActivitySuperChatLayoutBinding mBinding; - private PanelSwitchHelper mHelper; - private ChatAdapter mAdapter; - private LinearLayoutManager mLinearLayoutManager; - private static final String TAG = ChatCusContentScrollActivity.class.getSimpleName(); - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - supportRequestWindowFeature(Window.FEATURE_NO_TITLE); -// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); - mBinding = DataBindingUtil.setContentView(this, R.layout.activity_super_chat_layout); - mBinding.getRoot().setBackgroundColor(ContextCompat.getColor(this, R.color.common_page_bg_color)); - initView(); - } - - private void initView() { - mBinding.tipViewTop.setVisibility(View.VISIBLE); - mBinding.tipViewBottom.setVisibility(View.VISIBLE); - - mLinearLayoutManager = new LinearLayoutManager(this); - mBinding.recyclerView.setLayoutManager(mLinearLayoutManager); - mAdapter = new ChatAdapter(this, 4); - mBinding.recyclerView.setAdapter(mAdapter); - mBinding.send.setOnClickListener(v -> { - String content = mBinding.editText.getText().toString(); - if (TextUtils.isEmpty(content)) { - Toast.makeText(ChatSuperActivity.this, "当前没有输入", Toast.LENGTH_SHORT).show(); - return; - } - mAdapter.insertInfo(ChatInfo.CREATE(content)); - mBinding.editText.setText(null); - scrollToBottom(); - }); - mBinding.title.setText("点击左侧 \"默认滑动演示 \" 可清除框架输入法高度缓存测试 \"功能面板不同步软键盘高度 & 表情面板同步软键盘高度\""); - mBinding.tipView.setOnClickListener(v -> { - PanelUtil.clearData(ChatSuperActivity.this); - Toast.makeText(ChatSuperActivity.this, "已清除面板高度缓存,可拉起功能面板测试默认高度", Toast.LENGTH_SHORT).show(); - }); - } - - private void scrollToBottom() { - mBinding.getRoot().post(() -> mLinearLayoutManager.scrollToPosition(mAdapter.getItemCount() - 1)); - } - - @Override - protected void onStart() { - super.onStart(); - if (mHelper == null) { - mHelper = new PanelSwitchHelper.Builder(this) - //可选 - .addKeyboardStateListener((visible, height) -> Log.d(TAG, "系统键盘是否可见 : " + visible + " 高度为:" + height)) - .addEditTextFocusChangeListener((view, hasFocus) -> { - Log.d(TAG, "输入框是否获得焦点 : " + hasFocus); - if (hasFocus) { - scrollToBottom(); - } - }) - //可选 - .addViewClickListener(view -> { - switch (view.getId()) { - case R.id.edit_text: - case R.id.add_btn: - case R.id.emotion_btn: { - scrollToBottom(); - } - } - Log.d(TAG, "点击了View : " + view); - }) - //可选 - .addPanelChangeListener(new OnPanelChangeListener() { - - @Override - public void onKeyboard() { - Log.d(TAG, "唤起系统输入法"); - mBinding.emotionBtn.setSelected(false); - scrollToBottom(); - } - - @Override - public void onNone() { - Log.d(TAG, "隐藏所有面板"); - mBinding.emotionBtn.setSelected(false); - mBinding.mutilEditText.clearFocus(); - } - - @Override - public void onPanel(IPanelView view) { - Log.d(TAG, "唤起面板 : " + view); - if (view instanceof PanelView) { - mBinding.emotionBtn.setSelected(((PanelView) view).getId() == R.id.panel_emotion ? true : false); - scrollToBottom(); - } - } - - @Override - public void onPanelSizeChange(IPanelView panelView, boolean portrait, int oldWidth, int oldHeight, int width, int height) { - if (panelView instanceof PanelView) { - switch (((PanelView) panelView).getId()) { - case R.id.panel_emotion: { - EmotionPagerView pagerView = mBinding.getRoot().findViewById(R.id.view_pager); - int viewPagerSize = height - DisplayUtils.dip2px(ChatSuperActivity.this, 30f); - pagerView.buildEmotionViews( - (PageIndicatorView) mBinding.getRoot().findViewById(R.id.pageIndicatorView), - mBinding.editText, - Emotions.getEmotions(), width, viewPagerSize); - break; - } - case R.id.panel_addition: { - //auto center,nothing to do - break; - } - } - } - } - }) - /** - * 根据recyclerview的内容填充度来滑动 - */ - .addContentScrollMeasurer(new ContentScrollMeasurer() { - @Override - public int getScrollDistance(int defaultDistance) { - return defaultDistance - unfilledHeight; - } - - @Override - public int getScrollViewId() { - return R.id.recycler_view; - } - }) - /** - * tipViewBottom 确保底部输入栏不遮挡 - */ - .addContentScrollMeasurer(new ContentScrollMeasurer() { - @Override - public int getScrollDistance(int defaultDistance) { - return defaultDistance - getBottomUnfilledHeight(); - } - - @Override - public int getScrollViewId() { - return R.id.tip_view_bottom; - } - }) - /** - * tipViewTop 不跟随滑动 - */ - .addContentScrollMeasurer(new ContentScrollMeasurer() { - @Override - public int getScrollDistance(int defaultDistance) { - return 0; - } - - @Override - public int getScrollViewId() { - return R.id.tip_view_top; - } - }) - /** - * 默认实现,contentContainer 内部的子view会随容器向上scroll defaultDistance 距离 - */ - .addContentScrollMeasurer(new ContentScrollMeasurer() { - - @Override - public int getScrollDistance(int defaultDistance) { - return defaultDistance; - } - - @Override - public int getScrollViewId() { - return R.id.tip_view; - } - }) - /** - * 可选,可不设置 - * 面板默认高度设置,输入法显示后会采纳输入法高度为面板高度,否则则以框架内部默认值为主 - */ - .addPanelHeightMeasurer(new PanelHeightMeasurer() { - - /** - * false 为不同步输入法高度 - * @return - */ - @Override - public boolean synchronizeKeyboardHeight() { - return false; - } - - @Override - public int getTargetPanelDefaultHeight() { - return DisplayUtils.dip2px(ChatSuperActivity.this, 200f); - } - - @Override - public int getPanelTriggerId() { - return R.id.add_btn; - } - }) - /** - * 可选,可不设置 - * 面板默认高度设置,输入法显示后会采纳输入法高度为面板高度,否则则以框架内部默认值为主 - */ - .addPanelHeightMeasurer(new PanelHeightMeasurer() { - - /** - * true表示当输入法显示过时,则同步输入法高度 - * @return - */ - @Override - public boolean synchronizeKeyboardHeight() { - return true; - } - - @Override - public int getTargetPanelDefaultHeight() { - return DisplayUtils.dip2px(ChatSuperActivity.this, 400f); - } - - @Override - public int getPanelTriggerId() { - return R.id.emotion_btn; - } - }) - .logTrack(true) //output log - .build(); - mBinding.recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { - @Override - public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { - super.onScrolled(recyclerView, dx, dy); - RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); - if (layoutManager instanceof LinearLayoutManager) { - int childCount = recyclerView.getChildCount(); - if (childCount > 0) { - View lastChildView = recyclerView.getChildAt(childCount - 1); - int bottom = lastChildView.getBottom(); - int listHeight = mBinding.recyclerView.getHeight() - mBinding.recyclerView.getPaddingBottom(); - unfilledHeight = listHeight - bottom; - } - } - } - }); - } - mHelper.addSecondaryInputView(mBinding.mutilEditText); - //如果Edittext的生命周期小于当前activity,则需要remove避免内存泄漏 - // mHelper.removeSecondaryInputView(mBinding.mutilEditText); - mBinding.recyclerView.setPanelSwitchHelper(mHelper); - } - - private int unfilledHeight = 0; - private int bottomUnfilledHeight = 0; - - private int getBottomUnfilledHeight() { - if (bottomUnfilledHeight == 0) { - bottomUnfilledHeight = mBinding.bottomAction.getTop() - mBinding.tipViewBottom.getBottom(); - } - return bottomUnfilledHeight; - } - - - @Override - public void onBackPressed() { - if (mHelper != null && mHelper.hookSystemBackByPanelSwitcher()) { - return; - } - super.onBackPressed(); - } -} diff --git a/app/src/main/java/com/example/demo/scene/chat/adapter/ChatAdapter.java b/app/src/main/java/com/example/demo/scene/chat/adapter/ChatAdapter.java deleted file mode 100644 index c848dcc..0000000 --- a/app/src/main/java/com/example/demo/scene/chat/adapter/ChatAdapter.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.example.demo.scene.chat.adapter; - -import android.content.Context; -import android.databinding.DataBindingUtil; -import android.support.annotation.NonNull; -import android.support.v7.widget.RecyclerView; -import android.view.LayoutInflater; -import android.view.ViewGroup; - -import com.effective.R; -import com.effective.databinding.VhChatLeftLayoutBinding; -import com.effective.databinding.VhChatRightLayoutBinding; - -import java.util.ArrayList; -import java.util.List; - -/** - * chatting pager adapter - * Created by yummyLau on 18-7-11 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -public class ChatAdapter extends RecyclerView.Adapter { - - private List mData; - private Context mContext; - - public ChatAdapter(Context context) { - mData = new ArrayList<>(); - mContext = context; - } - - public ChatAdapter(Context context, List data) { - if (data != null) { - mData = data; - } else { - mData = new ArrayList<>(); - } - mContext = context; - } - - public ChatAdapter(Context context,int count) { - mData = new ArrayList<>(); - for (int i = 0; i < count; i++) { - mData.add(ChatInfo.CREATE("模拟数据第" + (i + 1) + "条")); - } - mContext = context; - } - - public void insertInfo(ChatInfo chatInfo) { - if (chatInfo != null) { - mData.add(chatInfo); - notifyItemInserted(mData.size() - 1); - } - } - - @Override - public int getItemViewType(int position) { - if (mData.get(position).owner) { - return 0; - } else { - return 1; - } - } - - @NonNull - @Override - public ChatBaseVH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - if (viewType == 0) { - VhChatRightLayoutBinding binding = DataBindingUtil.inflate(LayoutInflater.from(mContext), R.layout.vh_chat_right_layout, parent, false); - return new ChatRightVH(binding); - } else { - VhChatLeftLayoutBinding binding = DataBindingUtil.inflate(LayoutInflater.from(mContext), R.layout.vh_chat_left_layout, parent, false); - return new ChatLeftVH(binding); - } - } - - @Override - @SuppressWarnings("unchecked") - public void onBindViewHolder(ChatBaseVH holder, int position) { - holder.bindData((mData.get(position)), position); - } - - @Override - public int getItemCount() { - return mData.size(); - } -} diff --git a/app/src/main/java/com/example/demo/scene/chat/adapter/ChatBaseVH.java b/app/src/main/java/com/example/demo/scene/chat/adapter/ChatBaseVH.java deleted file mode 100644 index 4496155..0000000 --- a/app/src/main/java/com/example/demo/scene/chat/adapter/ChatBaseVH.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.example.demo.scene.chat.adapter; - -import android.databinding.ViewDataBinding; -import android.support.v7.widget.RecyclerView; - -/** - * base {@link android.support.v7.widget.RecyclerView.ViewHolder} for chatting pager. - * Created by yummyLau on 18-7-11 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -public abstract class ChatBaseVH extends RecyclerView.ViewHolder { - - protected dataBinding binding; - protected data data; - - public ChatBaseVH(dataBinding binding) { - super(binding.getRoot()); - this.binding = binding; - } - - @SuppressWarnings("unchecked") - public abstract void bindData(data data, int position); -} diff --git a/app/src/main/java/com/example/demo/scene/chat/adapter/ChatInfo.java b/app/src/main/java/com/example/demo/scene/chat/adapter/ChatInfo.java deleted file mode 100644 index df1b286..0000000 --- a/app/src/main/java/com/example/demo/scene/chat/adapter/ChatInfo.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.example.demo.scene.chat.adapter; - -/** - * the information of chatting item - * Created by yummyLau on 18-7-11 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -public class ChatInfo { - - public String message; - public boolean owner; - public static boolean sBoolean = true; - - public ChatInfo(String message, boolean owner) { - this.message = message; - this.owner = owner; - } - - public static ChatInfo CREATE(String message) { - ChatInfo chatInfo = new ChatInfo(message, sBoolean); - sBoolean = !sBoolean; - return chatInfo; - } -} diff --git a/app/src/main/java/com/example/demo/scene/chat/adapter/ChatLeftVH.java b/app/src/main/java/com/example/demo/scene/chat/adapter/ChatLeftVH.java deleted file mode 100644 index 2de5ec3..0000000 --- a/app/src/main/java/com/example/demo/scene/chat/adapter/ChatLeftVH.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.example.demo.scene.chat.adapter; - - -import android.view.View; -import android.widget.Toast; - -import com.effective.databinding.VhChatLeftLayoutBinding; -import com.example.demo.scene.chat.emotion.EmojiSpanBuilder; - -/** - * the left of chatting item - * Created by yummyLau on 18-7-11 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -public class ChatLeftVH extends ChatBaseVH { - - public ChatLeftVH(VhChatLeftLayoutBinding binding) { - super(binding); - } - - @Override - public void bindData(ChatInfo chatInfo, int position) { - binding.text.setText(EmojiSpanBuilder.buildEmotionSpannable(binding.getRoot().getContext(), chatInfo.message)); - binding.avatar.setOnLongClickListener(new View.OnLongClickListener() { - @Override - public boolean onLongClick(View view) { - Toast.makeText(view.getContext(),"长按了头像",Toast.LENGTH_SHORT).show(); - return true; - } - }); - binding.avatar.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Toast.makeText(view.getContext(),"点击了头像",Toast.LENGTH_SHORT).show(); - } - }); - binding.text.setOnLongClickListener(new View.OnLongClickListener() { - @Override - public boolean onLongClick(View view) { - Toast.makeText(view.getContext(),"长按了消息",Toast.LENGTH_SHORT).show(); - return true; - } - }); - binding.text.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Toast.makeText(view.getContext(),"点击了消息",Toast.LENGTH_SHORT).show(); - } - }); - } -} diff --git a/app/src/main/java/com/example/demo/scene/chat/adapter/ChatRightVH.java b/app/src/main/java/com/example/demo/scene/chat/adapter/ChatRightVH.java deleted file mode 100644 index 942c66d..0000000 --- a/app/src/main/java/com/example/demo/scene/chat/adapter/ChatRightVH.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.example.demo.scene.chat.adapter; - -import android.view.View; -import android.widget.Toast; - -import com.effective.databinding.VhChatRightLayoutBinding; -import com.example.demo.scene.chat.emotion.EmojiSpanBuilder; - -/** - * the right of chatting item - * Created by yummyLau on 18-7-11 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -public class ChatRightVH extends ChatBaseVH { - - public ChatRightVH(VhChatRightLayoutBinding binding) { - super(binding); - } - - @Override - public void bindData(ChatInfo chatInfo, int position) { - binding.text.setText(EmojiSpanBuilder.buildEmotionSpannable(binding.getRoot().getContext(), chatInfo.message)); - binding.avatar.setOnLongClickListener(new View.OnLongClickListener() { - @Override - public boolean onLongClick(View view) { - Toast.makeText(view.getContext(),"长按了头像",Toast.LENGTH_SHORT).show(); - return true; - } - }); - binding.avatar.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Toast.makeText(view.getContext(),"点击了头像",Toast.LENGTH_SHORT).show(); - } - }); - binding.text.setOnLongClickListener(new View.OnLongClickListener() { - @Override - public boolean onLongClick(View view) { - Toast.makeText(view.getContext(),"长按了消息",Toast.LENGTH_SHORT).show(); - return true; - } - }); - binding.text.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Toast.makeText(view.getContext(),"点击了消息",Toast.LENGTH_SHORT).show(); - } - }); - } -} diff --git a/app/src/main/java/com/example/demo/scene/chat/emotion/CenterImageSpan.java b/app/src/main/java/com/example/demo/scene/chat/emotion/CenterImageSpan.java deleted file mode 100644 index c6ceff7..0000000 --- a/app/src/main/java/com/example/demo/scene/chat/emotion/CenterImageSpan.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.example.demo.scene.chat.emotion; - -import android.graphics.Canvas; -import android.graphics.Paint; -import android.graphics.Rect; -import android.graphics.drawable.Drawable; -import android.text.style.ImageSpan; - -/** - * 处理图文混排时图片居中 - * ascent 为字体最上端到基线的距离,为负值 - * descent 为字体最下端到基线的距离,为正值 - * Created by yummyLau on 2018/6/15. - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -public class CenterImageSpan extends ImageSpan { - - public CenterImageSpan(Drawable drawable) { - super(drawable); - } - - /** - * @param paint - * @param text - * @param start - * @param end - * @param fontMetricsInt - * @return - */ - public int getSize(Paint paint, CharSequence text, int start, int end, - Paint.FontMetricsInt fontMetricsInt) { - Drawable drawable = getDrawable(); - Rect rect = drawable.getBounds(); - if (fontMetricsInt != null) { - - //获取绘制字体的度量 - Paint.FontMetricsInt fmPaint = paint.getFontMetricsInt(); - int fontHeight = fmPaint.bottom - fmPaint.top; - int drHeight = rect.bottom - rect.top; - - int top = drHeight / 2 - fontHeight / 4; - int bottom = drHeight / 2 + fontHeight / 4; - - fontMetricsInt.ascent = -bottom; - fontMetricsInt.top = -bottom; - fontMetricsInt.bottom = top; - fontMetricsInt.descent = top; - } - return rect.right; - } - - /** - * @param canvas - * @param text - * @param start - * @param end - * @param x 要绘制的image的左边框到textview左边框的距离。 - * @param top 替换行的最顶部位置 - * @param y 要替换的文字的基线坐标,即基线到textview上边框的距离 - * @param bottom 替换行的最底部位置。注意,textview中两行之间的行间距是属于上一行的,所以这里bottom是指行间隔的底部位置 - * @param paint - */ - @Override - public void draw(Canvas canvas, CharSequence text, int start, int end, - float x, int top, int y, int bottom, Paint paint) { - - Drawable drawable = getDrawable(); - Paint.FontMetricsInt fm = paint.getFontMetricsInt(); - - /** - * y + fm.descent 字体的descent线 y坐标 - * y + fm.ascent 字体的ascent线 y坐标 - * drawble.getBounds().bottom 图片的高度 - */ - int transY = (int) (1f / 2 * (y + fm.descent + y + fm.ascent - drawable.getBounds().bottom)); - canvas.save(); - canvas.translate(x, transY); - drawable.draw(canvas); - canvas.restore(); - } -} \ No newline at end of file diff --git a/app/src/main/java/com/example/demo/scene/chat/emotion/EmojiSpanBuilder.java b/app/src/main/java/com/example/demo/scene/chat/emotion/EmojiSpanBuilder.java deleted file mode 100644 index a1978b9..0000000 --- a/app/src/main/java/com/example/demo/scene/chat/emotion/EmojiSpanBuilder.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.example.demo.scene.chat.emotion; - -import android.content.Context; -import android.graphics.drawable.Drawable; -import android.support.v4.content.ContextCompat; -import android.text.Spannable; -import android.text.SpannableString; - -import com.example.demo.util.DisplayUtils; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Created by yummyLau on 18-7-11 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -public class EmojiSpanBuilder { - - private static Pattern sPatternEmotion = - Pattern.compile("\\[([\u4e00-\u9fa5\\w])+\\]|[\\ud83c\\udc00-\\ud83c\\udfff]|[\\ud83d\\udc00-\\ud83d\\udfff]|[\\u2600-\\u27ff]"); - - public static Spannable buildEmotionSpannable(Context context, String text) { - Matcher matcherEmotion = sPatternEmotion.matcher(text); - SpannableString spannableString = new SpannableString(text); - while (matcherEmotion.find()) { - String key = matcherEmotion.group(); - int imgRes = Emotions.getDrawableResByName(key); - if (imgRes != -1) { - int start = matcherEmotion.start(); - Drawable drawable = ContextCompat.getDrawable(context, imgRes); - drawable.setBounds(0, 0, DisplayUtils.dip2px(context, 20f), DisplayUtils.dip2px(context, 20f)); - CenterImageSpan span = new CenterImageSpan(drawable); - spannableString.setSpan(span, start, start + key.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - } - } - - return spannableString; - } -} diff --git a/app/src/main/java/com/example/demo/scene/chat/emotion/Emotion.java b/app/src/main/java/com/example/demo/scene/chat/emotion/Emotion.java deleted file mode 100644 index cdadfa2..0000000 --- a/app/src/main/java/com/example/demo/scene/chat/emotion/Emotion.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.example.demo.scene.chat.emotion; - -import android.support.annotation.DrawableRes; - -/** - * Created by yummyLau on 18-7-11 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -public class Emotion { - - public String text; - - @DrawableRes - public int drawableRes; - - public Emotion(String text, @DrawableRes int drawableRes) { - this.text = text; - this.drawableRes = drawableRes; - } -} diff --git a/app/src/main/java/com/example/demo/scene/chat/emotion/EmotionPagerView.java b/app/src/main/java/com/example/demo/scene/chat/emotion/EmotionPagerView.java deleted file mode 100644 index 99b8c76..0000000 --- a/app/src/main/java/com/example/demo/scene/chat/emotion/EmotionPagerView.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.example.demo.scene.chat.emotion; - -import android.content.Context; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.view.PagerAdapter; -import android.support.v4.view.ViewPager; -import android.util.AttributeSet; -import android.view.View; -import android.view.ViewGroup; -import android.widget.EditText; - -import com.rd.PageIndicatorView; - -import java.util.ArrayList; -import java.util.List; - - -/** - * Created by yummyLau on 18-7-11 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -public class EmotionPagerView extends ViewPager { - - private int currentWidth = -1; - private int currentHeight = -1; - private Adapter mAdapter; - - public EmotionPagerView(@NonNull Context context) { - this(context, null); - } - - public EmotionPagerView(@NonNull Context context, @Nullable AttributeSet attrs) { - super(context, attrs); - } - - public void buildEmotionViews(final PageIndicatorView indicatorView, final EditText editText, List data, int width, int height) { - if (data == null || data.isEmpty() || indicatorView == null || editText == null) { - return; - } - if (currentWidth == width && currentHeight == height) { - return; - } - currentWidth = width; - currentHeight = height; - int emotionViewContainSize = EmotionView.calSizeForContainEmotion(getContext(), currentWidth, currentHeight); - if (emotionViewContainSize == 0) { - return; - } - int pagerCount = data.size() / emotionViewContainSize; - pagerCount += (data.size() % emotionViewContainSize == 0) ? 0 : 1; - int index = 0; - List emotionViews = new ArrayList<>(); - for (int i = 0; i < pagerCount; i++) { - EmotionView emotionView = new EmotionView(getContext(), editText); - int end = (i + 1) * emotionViewContainSize; - if (end > data.size()) { - end = data.size(); - } - emotionView.buildEmotions(data.subList(index, end)); - emotionViews.add(emotionView); - index = end; - } - mAdapter = new Adapter(emotionViews); - setAdapter(mAdapter); - addOnPageChangeListener(new OnPageChangeListener() { - @Override - public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { - - } - - @Override - public void onPageSelected(int position) { - indicatorView.setSelection(position); - } - - @Override - public void onPageScrollStateChanged(int state) { - - } - }); - } - - public static class Adapter extends PagerAdapter { - - private List mList; - - public Adapter(List mList) { - this.mList = mList; - } - - @Override - public int getCount() { - return mList.size(); - } - - @Override - public boolean isViewFromObject(View view, Object object) { - return object == view; - } - - @Override - public Object instantiateItem(ViewGroup container, int position) { - container.addView(mList.get(position)); - return mList.get(position); - } - - @Override - public void destroyItem(ViewGroup container, int position, Object object) { - container.removeView(mList.get(position)); - } - } -} diff --git a/app/src/main/java/com/example/demo/scene/chat/emotion/EmotionView.java b/app/src/main/java/com/example/demo/scene/chat/emotion/EmotionView.java deleted file mode 100644 index 53b04ed..0000000 --- a/app/src/main/java/com/example/demo/scene/chat/emotion/EmotionView.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.example.demo.scene.chat.emotion; - -import android.content.Context; -import android.text.Editable; -import android.text.Spannable; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.BaseAdapter; -import android.widget.EditText; -import android.widget.GridView; -import android.widget.ImageView; - -import com.effective.R; -import com.example.demo.util.DisplayUtils; - -import java.util.ArrayList; -import java.util.List; - -/** - * 编码参考 http://www.oicqzone.com/tool/emoji/ - * Created by yummyLau on 18-7-11 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -public class EmotionView extends GridView { - - private static int sNumColumns = 0; - private static int sNumRows = 0; - private static int sPadding = 0; - private static int sEmotionSize = 0; - private EditText mEditText; - - public static int calSizeForContainEmotion(Context context, int width, int height) { - sPadding = DisplayUtils.dip2px(context, 5f); - sEmotionSize = DisplayUtils.dip2px(context, 50f); - sNumColumns = width / sEmotionSize; - sNumRows = height / sEmotionSize; - return sNumColumns * sNumRows; - } - - public EmotionView(Context context, EditText editText) { - super(context); - this.mEditText = editText; - } - - public void buildEmotions(final List data) { - setNumColumns(sNumColumns); - setPadding(sPadding, sPadding, sPadding, sPadding); - setClipToPadding(false); - setAdapter(new EmotionAdapter(getContext(), data)); - setOnItemClickListener(new OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - Emotion emotion = data.get(position); - int start = mEditText.getSelectionStart(); - Editable editable = mEditText.getEditableText(); - Spannable emotionSpannable = EmojiSpanBuilder.buildEmotionSpannable(getContext(), emotion.text); - editable.insert(start, emotionSpannable); - } - }); - } - - public static class EmotionAdapter extends BaseAdapter { - - public List mEmotions; - private Context mContext; - - public EmotionAdapter(Context context, List emotions) { - if (emotions == null) { - emotions = new ArrayList<>(); - } - mEmotions = emotions; - mContext = context; - } - - @Override - public View getView(int position, View view, ViewGroup parent) { - if (view == null) { - view = LayoutInflater.from(mContext).inflate(R.layout.vh_emotion_item_layout, parent, false); - } - ImageView imageView = view.findViewById(R.id.image); - imageView.setImageResource(((Emotion) getItem(position)).drawableRes); - return view; - } - - @Override - public int getCount() { - return mEmotions.size(); - } - - @Override - public Object getItem(int position) { - return mEmotions.get(position); - } - - @Override - public long getItemId(int position) { - return position; - } - - } -} diff --git a/app/src/main/java/com/example/demo/scene/chat/emotion/Emotions.java b/app/src/main/java/com/example/demo/scene/chat/emotion/Emotions.java deleted file mode 100644 index 156402a..0000000 --- a/app/src/main/java/com/example/demo/scene/chat/emotion/Emotions.java +++ /dev/null @@ -1,145 +0,0 @@ -package com.example.demo.scene.chat.emotion; - -import android.text.TextUtils; - -import com.effective.R; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -/** - * 编码参考 http://www.oicqzone.com/tool/emoji/ - * Created by yummyLau on 18-7-11 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -public class Emotions { - - public static Map EMOTIONS = new LinkedHashMap<>(); - - static { - EMOTIONS.put("[微笑]", R.drawable.expression_1); - EMOTIONS.put("[撇嘴]", R.drawable.expression_2); - EMOTIONS.put("[色]", R.drawable.expression_3); - EMOTIONS.put("[发呆]", R.drawable.expression_4); - EMOTIONS.put("[得意]", R.drawable.expression_5); - EMOTIONS.put("[流泪]", R.drawable.expression_6); - EMOTIONS.put("[害羞]", R.drawable.expression_7); - EMOTIONS.put("[闭嘴]", R.drawable.expression_8); - EMOTIONS.put("[睡]", R.drawable.expression_9); - EMOTIONS.put("[大哭]", R.drawable.expression_10); - EMOTIONS.put("[尴尬]", R.drawable.expression_11); - EMOTIONS.put("[发怒]", R.drawable.expression_12); - EMOTIONS.put("[调皮]", R.drawable.expression_13); - EMOTIONS.put("[呲牙]", R.drawable.expression_14); - EMOTIONS.put("[惊讶]", R.drawable.expression_15); - EMOTIONS.put("[难过]", R.drawable.expression_16); - EMOTIONS.put("[囧]", R.drawable.expression_18); - EMOTIONS.put("[抓狂]", R.drawable.expression_19); - EMOTIONS.put("[吐]", R.drawable.expression_20); - EMOTIONS.put("[偷笑]", R.drawable.expression_21); - EMOTIONS.put("[愉快]", R.drawable.expression_22); - EMOTIONS.put("[白眼]", R.drawable.expression_23); - EMOTIONS.put("[傲慢]", R.drawable.expression_24); - EMOTIONS.put("[困]", R.drawable.expression_26); - EMOTIONS.put("[惊恐]", R.drawable.expression_27); - EMOTIONS.put("[流汗]", R.drawable.expression_28); - EMOTIONS.put("[憨笑]", R.drawable.expression_29); - EMOTIONS.put("[悠闲]", R.drawable.expression_30); - EMOTIONS.put("[奋斗]", R.drawable.expression_31); - EMOTIONS.put("[咒骂]", R.drawable.expression_32); - EMOTIONS.put("[疑问]", R.drawable.expression_33); - EMOTIONS.put("[嘘]", R.drawable.expression_34); - EMOTIONS.put("[晕]", R.drawable.expression_35); - EMOTIONS.put("[衰]", R.drawable.expression_37); - EMOTIONS.put("[骷髅]", R.drawable.expression_38); - EMOTIONS.put("[敲打]", R.drawable.expression_39); - EMOTIONS.put("[再见]", R.drawable.expression_40); - EMOTIONS.put("[擦汗]", R.drawable.expression_41); - EMOTIONS.put("[抠鼻]", R.drawable.expression_42); - EMOTIONS.put("[鼓掌]", R.drawable.expression_43); - EMOTIONS.put("[坏笑]", R.drawable.expression_45); - EMOTIONS.put("[左哼哼]", R.drawable.expression_46); - EMOTIONS.put("[右哼哼]", R.drawable.expression_47); - EMOTIONS.put("[哈欠]", R.drawable.expression_48); - EMOTIONS.put("[鄙视]", R.drawable.expression_49); - EMOTIONS.put("[委屈]", R.drawable.expression_50); - EMOTIONS.put("[快哭了]", R.drawable.expression_51); - EMOTIONS.put("[阴险]", R.drawable.expression_52); - EMOTIONS.put("[亲亲]", R.drawable.expression_53); - EMOTIONS.put("[可怜]", R.drawable.expression_55); - EMOTIONS.put("[菜刀]", R.drawable.expression_56); - EMOTIONS.put("[西瓜]", R.drawable.expression_57); - EMOTIONS.put("[啤酒]", R.drawable.expression_58); - EMOTIONS.put("[咖啡]", R.drawable.expression_61); - EMOTIONS.put("[猪头]", R.drawable.expression_63); - EMOTIONS.put("[玫瑰]", R.drawable.expression_64); - EMOTIONS.put("[凋谢]", R.drawable.expression_65); - EMOTIONS.put("[嘴唇]", R.drawable.expression_66); - EMOTIONS.put("[爱心]", R.drawable.expression_67); - EMOTIONS.put("[心碎]", R.drawable.expression_68); - EMOTIONS.put("[蛋糕]", R.drawable.expression_69); - EMOTIONS.put("[炸弹]", R.drawable.expression_71); - EMOTIONS.put("[便便]", R.drawable.expression_75); - EMOTIONS.put("[月亮]", R.drawable.expression_76); - EMOTIONS.put("[太阳]", R.drawable.expression_77); - EMOTIONS.put("[拥抱]", R.drawable.expression_79); - EMOTIONS.put("[强]", R.drawable.expression_80); - EMOTIONS.put("[弱]", R.drawable.expression_81); - EMOTIONS.put("[握手]", R.drawable.expression_82); - EMOTIONS.put("[胜利]", R.drawable.expression_83); - EMOTIONS.put("[抱拳]", R.drawable.expression_84); - EMOTIONS.put("[勾引]", R.drawable.expression_85); - EMOTIONS.put("[拳头]", R.drawable.expression_86); - EMOTIONS.put("[OK]", R.drawable.expression_90); - EMOTIONS.put("[跳跳]", R.drawable.expression_93); - EMOTIONS.put("[发抖]", R.drawable.expression_94); - EMOTIONS.put("[怄火]", R.drawable.expression_95); - EMOTIONS.put("[转圈]", R.drawable.expression_96); - EMOTIONS.put(emotionCode2String(0x1F604), R.drawable.expression_97); - EMOTIONS.put(emotionCode2String(0x1F637), R.drawable.expression_98); - EMOTIONS.put(emotionCode2String(0x1F602), R.drawable.expression_99); - EMOTIONS.put(emotionCode2String(0x1F61D), R.drawable.expression_101); - EMOTIONS.put(emotionCode2String(0x1F633), R.drawable.expression_102); - EMOTIONS.put(emotionCode2String(0x1F631), R.drawable.expression_103); - EMOTIONS.put(emotionCode2String(0x1F614), R.drawable.expression_104); - EMOTIONS.put(emotionCode2String(0x1F612), R.drawable.expression_105); - EMOTIONS.put("[嘿哈]", R.drawable.expression_107); - EMOTIONS.put("[捂脸]", R.drawable.expression_108); - EMOTIONS.put("[奸笑]", R.drawable.expression_106); - EMOTIONS.put("[机智]", R.drawable.expression_109); - EMOTIONS.put("[皱眉]", R.drawable.expression_119); - EMOTIONS.put("[耶]", R.drawable.expression_113); - EMOTIONS.put(emotionCode2String(0x1F47B), R.drawable.expression_114); - EMOTIONS.put(emotionCode2String(0x1F64F), R.drawable.expression_115); - EMOTIONS.put(emotionCode2String(0x1F4AA), R.drawable.expression_116); - EMOTIONS.put(emotionCode2String(0x1F389), R.drawable.expression_117); - EMOTIONS.put(emotionCode2String(0x1F381), R.drawable.expression_118); - EMOTIONS.put("[红包]", R.drawable.expression_111); - } - - private static String emotionCode2String(int code) { - return new String(Character.toChars(code)); - } - - public static int getDrawableResByName(String emotionName) { - if (!TextUtils.isEmpty(emotionName) && EMOTIONS.containsKey(emotionName)) { - return EMOTIONS.get(emotionName); - } - return -1; - } - - public static List getEmotions() { - List emotions = new ArrayList<>(); - Iterator> entries = EMOTIONS.entrySet().iterator(); - - while (entries.hasNext()) { - Map.Entry entry = entries.next(); - emotions.add(new Emotion(entry.getKey(), entry.getValue())); - } - return emotions; - } -} diff --git a/app/src/main/java/com/example/demo/scene/chat/view/AutoHidePanelRecyclerView.java b/app/src/main/java/com/example/demo/scene/chat/view/AutoHidePanelRecyclerView.java deleted file mode 100644 index adec6f0..0000000 --- a/app/src/main/java/com/example/demo/scene/chat/view/AutoHidePanelRecyclerView.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.example.demo.scene.chat.view; - -import android.content.Context; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.util.AttributeSet; -import android.util.Log; -import android.view.MotionEvent; -import android.view.View; - -import com.effective.R; -import com.effective.android.panel.PanelSwitchHelper; -import com.example.demo.util.DisplayUtils; - -public class AutoHidePanelRecyclerView extends RecyclerView { - - PanelSwitchHelper panelSwitchHelper; - - public void setPanelSwitchHelper(PanelSwitchHelper panelSwitchHelper) { - this.panelSwitchHelper = panelSwitchHelper; - } - - public AutoHidePanelRecyclerView(Context context) { - this(context, null); - } - - public AutoHidePanelRecyclerView(Context context, @Nullable AttributeSet attrs) { - this(context, attrs, 0); - } - - public AutoHidePanelRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - setLayoutManager(new LinearLayoutManager(context)); - addOnItemTouchListener(new OnItemTouchListener() { - - public boolean isTouchInView(View view, MotionEvent event) { - if (view == null) { - return false; - } - int[] location = new int[2]; - view.getLocationOnScreen(location); - int x = location[0]; - int y = location[1]; - return x < event.getRawX() && event.getRawX() < x + view.getWidth() - && y < event.getRawY() && event.getRawY() < y + view.getHeight(); - } - - public void hidePanel() { - if (panelSwitchHelper != null) { - panelSwitchHelper.hookSystemBackByPanelSwitcher(); - } - } - - @Override - public boolean onInterceptTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) { - int action = e.getAction(); - if (action == MotionEvent.ACTION_DOWN) { - View view = rv.findChildViewUnder(e.getX(), e.getY()); - if (view == null) { - hidePanel(); - return false; - } - View text = view.findViewById(R.id.text); - View avatar = view.findViewById(R.id.avatar); - if (text == null || avatar == null) { - hidePanel(); - return false; - } - - if (!isTouchInView(text, e) && !isTouchInView(avatar, e)) { - hidePanel(); - } - } - return false; - } - - @Override - public void onTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) { - - } - - @Override - public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) { - - } - }); - } -} diff --git a/app/src/main/java/com/example/demo/scene/feed/FeedActivity.java b/app/src/main/java/com/example/demo/scene/feed/FeedActivity.java deleted file mode 100644 index 2368a05..0000000 --- a/app/src/main/java/com/example/demo/scene/feed/FeedActivity.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.example.demo.scene.feed; - -import android.annotation.TargetApi; -import android.content.Context; -import android.databinding.DataBindingUtil; -import android.graphics.Color; -import android.graphics.Rect; -import android.graphics.drawable.ColorDrawable; -import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.content.ContextCompat; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.util.Log; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.Window; -import android.widget.ImageView; -import android.widget.PopupWindow; - - -import com.effective.R; -import com.effective.android.panel.PanelSwitchHelper; -import com.effective.android.panel.interfaces.ContentScrollMeasurer; -import com.effective.android.panel.interfaces.listener.OnPanelChangeListener; -import com.effective.android.panel.utils.DisplayUtil; -import com.effective.android.panel.utils.PanelUtil; -import com.effective.android.panel.view.panel.IPanelView; -import com.effective.android.panel.view.panel.PanelView; -import com.effective.databinding.ActivityFeedLayoutBinding; -import com.example.demo.scene.chat.ChatCusContentScrollActivity; -import com.example.demo.scene.chat.emotion.EmotionPagerView; -import com.example.demo.scene.chat.emotion.Emotions; -import com.example.demo.systemui.StatusbarHelper; -import com.example.demo.util.DisplayUtils; -import com.rd.PageIndicatorView; - -/** - * 类微博/微信朋友圈信息流 - 非 dialog 实现 - * created by yummylau on 2020/06/01 - */ -public class FeedActivity extends AppCompatActivity { - - private static final String TAG = FeedActivity.class.getSimpleName(); - private ActivityFeedLayoutBinding mBinding; - private PanelSwitchHelper mHelper; - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - supportRequestWindowFeature(Window.FEATURE_NO_TITLE); - StatusbarHelper.setStatusBarColor(this, Color.TRANSPARENT); - mBinding = DataBindingUtil.setContentView(this, R.layout.activity_feed_layout); - mBinding.recyclerView.setLayoutManager(new LinearLayoutManager(this)); - mBinding.recyclerView.setAdapter(new FeedAdapter(this)); - } - - @Override - protected void onStart() { - super.onStart(); - if (mHelper == null) { - mHelper = new PanelSwitchHelper.Builder(this) - .addPanelChangeListener(new OnPanelChangeListener() { - @Override - public void onKeyboard() { - mBinding.emotionBtn.setSelected(false); - } - - @Override - public void onNone() { - mBinding.emotionBtn.setSelected(false); - mBinding.bottomAction.setVisibility(View.GONE); - } - - @Override - public void onPanel(IPanelView view) { - if (view instanceof PanelView) { - mBinding.emotionBtn.setSelected(((PanelView) view).getId() == R.id.panel_emotion ? true : false); - } - } - - @Override - public void onPanelSizeChange(IPanelView panelView, boolean portrait, int oldWidth, int oldHeight, int width, int height) { - if (panelView instanceof PanelView) { - switch (((PanelView) panelView).getId()) { - case R.id.panel_emotion: { - EmotionPagerView pagerView = mBinding.getRoot().findViewById(R.id.view_pager); - int viewPagerSize = height - DisplayUtils.dip2px(FeedActivity.this, 30f); - pagerView.buildEmotionViews( - (PageIndicatorView) mBinding.getRoot().findViewById(R.id.pageIndicatorView), - mBinding.editText, - Emotions.getEmotions(), width, viewPagerSize); - break; - } - case R.id.panel_addition: { - //auto center,nothing to do - break; - } - } - } - } - }) - .contentScrollOutsideEnable(false) - .logTrack(true) //output log - .build(); - } - } - - @Override - public void onBackPressed() { - if (mHelper != null && mHelper.hookSystemBackByPanelSwitcher()) { - return; - } - super.onBackPressed(); - } - - public class FeedAdapter extends RecyclerView.Adapter { - - private Context context; - - public FeedAdapter(Context context) { - super(); - this.context = context; - } - - @NonNull - @Override - public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - return viewType == 0 ? new CoverHolder(LayoutInflater.from(context).inflate(R.layout.holder_feed_cover_layout, parent, false)) - : new FeedItemHolder(LayoutInflater.from(context).inflate(R.layout.holder_feed_item_layout, parent, false)); - } - - @Override - public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { - if (holder instanceof FeedItemHolder) { - ((FeedItemHolder) holder).bindData(position, position == getItemCount() - 1); - } - } - - @Override - public int getItemViewType(int position) { - return position == 0 ? 0 : 1; - } - - @Override - public int getItemCount() { - return 20; - } - } - - public class FeedItemHolder extends RecyclerView.ViewHolder { - - private FeedActionPopup popup; - private Rect selectedItemRect = new Rect(); - - public FeedItemHolder(View itemView) { - super(itemView); - } - - @TargetApi(19) - public void bindData(int position, boolean isLast) { - Context context = itemView.getContext(); - ((ImageView) itemView.findViewById(R.id.image)).setImageDrawable(ContextCompat.getDrawable(context, context.getResources().getIdentifier("ic_uzi_" + position % 10, "drawable", context.getApplicationInfo().packageName))); - itemView.findViewById(R.id.divider).setVisibility(isLast ? View.GONE : View.VISIBLE); - final View action = itemView.findViewById(R.id.action); - action.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (popup == null) { - popup = new FeedActionPopup(context, v1 -> { - itemView.getGlobalVisibleRect(selectedItemRect); - scrollView(selectedItemRect, PanelUtil.getKeyBoardHeight(v.getContext())); - }); - } - if (popup.isShowing()) { - popup.dismiss(); - } else { - //api 19 request,demo make targetApi 19.if your targerApi below 19,should user showAtLocation - popup.showAsDropDown(action, -DisplayUtil.dip2px(context, 10f) - action.getMeasuredWidth(), (DisplayUtil.dip2px(context, 30f) - action.getMeasuredHeight()) / 2 - DisplayUtil.dip2px(context, 30f), Gravity.RIGHT); - } - } - }); - } - } - - private void scrollView(Rect selectedItemRect, int panelHeight) { - mBinding.bottomAction.setVisibility(View.VISIBLE); - mHelper.toKeyboardState(true); - int dist = selectedItemRect.bottom - (mBinding.recyclerView.getBottom() - panelHeight - DisplayUtil.dip2px(FeedActivity.this, 50f)); - mBinding.recyclerView.scrollBy(0, dist); - } - - public class CoverHolder extends RecyclerView.ViewHolder { - - public CoverHolder(View itemView) { - super(itemView); - } - } - - public class FeedActionPopup extends PopupWindow { - - public FeedActionPopup(final Context context, View.OnClickListener clickListener) { - final View view = LayoutInflater.from(context).inflate(R.layout.pop_feed_action_layout, null, false); - setAnimationStyle(R.style.FeedActionPopup_anim_style); - setFocusable(true); - setWidth(DisplayUtil.dip2px(context, 150f)); - setHeight(DisplayUtil.dip2px(context, 34f)); - setOutsideTouchable(true); - ColorDrawable dw = new ColorDrawable(Color.TRANSPARENT); - setBackgroundDrawable(dw); - setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); - setContentView(view); - view.findViewById(R.id.comment).setOnClickListener(v -> { - dismiss(); - clickListener.onClick(v); - }); - - } - - } - - -} diff --git a/app/src/main/java/com/example/demo/scene/feed/FeedCommentDialog.java b/app/src/main/java/com/example/demo/scene/feed/FeedCommentDialog.java deleted file mode 100644 index 721c4a4..0000000 --- a/app/src/main/java/com/example/demo/scene/feed/FeedCommentDialog.java +++ /dev/null @@ -1,143 +0,0 @@ -package com.example.demo.scene.feed; - -import android.app.Activity; -import android.content.DialogInterface; -import android.text.Editable; -import android.text.TextWatcher; -import android.util.Log; -import android.view.KeyEvent; -import android.view.View; -import android.widget.EditText; - -import com.effective.R; -import com.effective.android.panel.PanelSwitchHelper; -import com.effective.android.panel.interfaces.listener.OnPanelChangeListener; -import com.effective.android.panel.utils.PanelUtil; -import com.effective.android.panel.view.panel.IPanelView; -import com.effective.android.panel.view.panel.PanelView; -import com.effective.android.panel.window.PanelDialog; -import com.example.demo.scene.chat.emotion.EmotionPagerView; -import com.example.demo.scene.chat.emotion.Emotions; -import com.example.demo.util.DisplayUtils; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class FeedCommentDialog extends PanelDialog implements DialogInterface.OnKeyListener { - - private static final String TAG = FeedCommentDialog.class.getSimpleName(); - private Activity activity; - private onDialogStatus status; - - @Override - public int getDialogLayout() { - return R.layout.dialog_feed_comment_layout; - } - - public FeedCommentDialog(Activity activity,onDialogStatus status) { - super(activity); - this.activity = activity; - this.status = status; - setOnKeyListener(this); - ((EditText) rootView.findViewById(R.id.edit_text)).addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - - } - - @Override - public void afterTextChanged(Editable s) { - rootView.findViewById(R.id.send).setEnabled(s.length() != 0); - } - }); - rootView.findViewById(R.id.send).setOnClickListener(v -> ((EditText) rootView.findViewById(R.id.edit_text)).setText("")); - rootView.findViewById(R.id.input_layout).addOnLayoutChangeListener(new View.OnLayoutChangeListener() { - @Override - public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { - if (status != null) { - status.onStatus(true, top + DisplayUtils.getStatusBarHeight(activity) - PanelUtil.getKeyBoardHeight(getContext())); - } - } - }); - } - - @Override - public void show() { - if (helper == null) { - helper = new PanelSwitchHelper.Builder(activity.getWindow(), rootView) - //可选 - .addKeyboardStateListener((visible, height) -> Log.d(TAG, "系统键盘是否可见 : " + visible + " 高度为:" + height)) - //可选 - .addPanelChangeListener(new OnPanelChangeListener() { - - @Override - public void onKeyboard() { - Log.d(TAG, "唤起系统输入法"); - rootView.findViewById(R.id.emotion_btn).setSelected(false); - } - - @Override - public void onNone() { - Log.d(TAG, "隐藏所有面板"); - rootView.findViewById(R.id.emotion_btn).setSelected(false); - dismiss(); - } - - @Override - public void onPanel(IPanelView view) { - Log.d(TAG, "唤起面板 : " + view); - if (view instanceof PanelView) { - rootView.findViewById(R.id.emotion_btn).setSelected(((PanelView) view).getId() == R.id.panel_emotion ? true : false); - } - } - - - @Override - public void onPanelSizeChange(IPanelView panelView, boolean portrait, int oldWidth, int oldHeight, int width, int height) { - if (panelView instanceof PanelView) { - switch (((PanelView) panelView).getId()) { - case R.id.panel_emotion: { - EmotionPagerView pagerView = rootView.findViewById(R.id.view_pager); - int viewPagerSize = height - DisplayUtils.dip2px(getContext(), 30f); - pagerView.buildEmotionViews( - rootView.findViewById(R.id.pageIndicatorView), - rootView.findViewById(R.id.edit_text), - Emotions.getEmotions(), width, viewPagerSize); - break; - } - } - } - } - }) - .logTrack(true) - .build(true); - } - super.show(); - } - - @Override - public void dismiss() { - if (status != null) { - status.onStatus(false, 0); - } - super.dismiss(); - } - - @Override - public boolean onKey(@Nullable DialogInterface dialog, int keyCode, @NotNull KeyEvent event) { - if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { - dismiss(); - return true; - } - return false; - } - - public interface onDialogStatus { - void onStatus(boolean visible, int currentTop); - } -} diff --git a/app/src/main/java/com/example/demo/scene/feed/FeedDialogActivity.java b/app/src/main/java/com/example/demo/scene/feed/FeedDialogActivity.java deleted file mode 100644 index b45c0a8..0000000 --- a/app/src/main/java/com/example/demo/scene/feed/FeedDialogActivity.java +++ /dev/null @@ -1,168 +0,0 @@ -package com.example.demo.scene.feed; - -import android.annotation.TargetApi; -import android.content.Context; -import android.databinding.DataBindingUtil; -import android.graphics.Color; -import android.graphics.Rect; -import android.graphics.drawable.ColorDrawable; -import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.content.ContextCompat; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.Window; -import android.widget.ImageView; -import android.widget.PopupWindow; - - -import com.effective.R; -import com.effective.android.panel.utils.DisplayUtil; -import com.effective.databinding.ActivityFeedDialogLayoutBinding; -import com.example.demo.systemui.StatusbarHelper; - -/** - * 类微博/微信朋友圈信息流 Dialog 实现 - * created by yummylau on 2020/06/01 - */ -public class FeedDialogActivity extends AppCompatActivity { - - private ActivityFeedDialogLayoutBinding mBinding; - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - supportRequestWindowFeature(Window.FEATURE_NO_TITLE); - StatusbarHelper.setStatusBarColor(this, Color.TRANSPARENT); - mBinding = DataBindingUtil.setContentView(this, R.layout.activity_feed_dialog_layout); - mBinding.feedList.setLayoutManager(new LinearLayoutManager(this)); - mBinding.feedList.setAdapter(new FeedAdapter(this)); - } - - public class FeedAdapter extends RecyclerView.Adapter { - - private Context context; - - public FeedAdapter(Context context) { - super(); - this.context = context; - } - - @NonNull - @Override - public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - return viewType == 0 ? new CoverHolder(LayoutInflater.from(context).inflate(R.layout.holder_feed_cover_layout, parent, false)) - : new FeedItemHolder(LayoutInflater.from(context).inflate(R.layout.holder_feed_item_layout, parent, false)); - } - - @Override - public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { - if (holder instanceof FeedItemHolder) { - ((FeedItemHolder) holder).bindData(position, position == getItemCount() - 1); - } - } - - @Override - public int getItemViewType(int position) { - return position == 0 ? 0 : 1; - } - - @Override - public int getItemCount() { - return 20; - } - } - - public class FeedItemHolder extends RecyclerView.ViewHolder { - - private FeedActionPopup popup; - private Rect selectedItemRect = new Rect(); - private FeedCommentDialog.onDialogStatus dialogStatusListener = new FeedCommentDialog.onDialogStatus() { - private boolean lastVisibleStatue = false; - - @Override - public void onStatus(boolean visible, final int currentTop) { - if (lastVisibleStatue == visible) { - return; - } - lastVisibleStatue = visible; - if (visible) { - int dist = selectedItemRect.bottom - currentTop; - mBinding.feedList.scrollBy(0, dist); - } - //如果需要还原到原来位置,则把注释打开就好 -// else { -// Rect currentRect = new Rect(); -// itemView.getGlobalVisibleRect(currentRect); -// mBinding.feedList.scrollBy(0, currentRect.bottom - selectedItemRect.bottom); -// } - } - }; - - public FeedItemHolder(View itemView) { - super(itemView); - } - - @TargetApi(19) - public void bindData(int position, boolean isLast) { - Context context = itemView.getContext(); - ((ImageView) itemView.findViewById(R.id.image)).setImageDrawable(ContextCompat.getDrawable(context, context.getResources().getIdentifier("ic_uzi_" + position % 10, "drawable", context.getApplicationInfo().packageName))); - itemView.findViewById(R.id.divider).setVisibility(isLast ? View.GONE : View.VISIBLE); - final View action = itemView.findViewById(R.id.action); - action.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (popup == null) { - popup = new FeedActionPopup(context, v1 -> { - itemView.getGlobalVisibleRect(selectedItemRect); - new FeedCommentDialog((FeedDialogActivity) v1.getContext(), dialogStatusListener).show(); - }); - } - if (popup.isShowing()) { - popup.dismiss(); - } else { - //api 19 request,demo make targetApi 19.if your targerApi below 19,should user showAtLocation - popup.showAsDropDown(action, -DisplayUtil.dip2px(context, 10f) - action.getMeasuredWidth(), (DisplayUtil.dip2px(context, 30f) - action.getMeasuredHeight()) / 2 - DisplayUtil.dip2px(context, 30f), Gravity.RIGHT); - } - } - }); - } - } - - public class CoverHolder extends RecyclerView.ViewHolder { - - public CoverHolder(View itemView) { - super(itemView); - } - } - - public class FeedActionPopup extends PopupWindow { - - public FeedActionPopup(final Context context, View.OnClickListener clickListener) { - final View view = LayoutInflater.from(context).inflate(R.layout.pop_feed_action_layout, null, false); - setAnimationStyle(R.style.FeedActionPopup_anim_style); - setFocusable(true); - setWidth(DisplayUtil.dip2px(context, 150f)); - setHeight(DisplayUtil.dip2px(context, 34f)); - setOutsideTouchable(true); - ColorDrawable dw = new ColorDrawable(Color.TRANSPARENT); - setBackgroundDrawable(dw); - setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); - setContentView(view); - view.findViewById(R.id.comment).setOnClickListener(v -> { - dismiss(); - clickListener.onClick(v); - }); - - } - - } - - -} diff --git a/app/src/main/java/com/example/demo/scene/live/douyin/PhoneDouyinLiveActivity.java b/app/src/main/java/com/example/demo/scene/live/douyin/PhoneDouyinLiveActivity.java deleted file mode 100644 index 249e000..0000000 --- a/app/src/main/java/com/example/demo/scene/live/douyin/PhoneDouyinLiveActivity.java +++ /dev/null @@ -1,256 +0,0 @@ -package com.example.demo.scene.live.douyin; - -import android.content.Context; -import android.databinding.DataBindingUtil; -import android.graphics.Color; -import android.media.MediaPlayer; -import android.net.Uri; -import android.os.Bundle; -import android.os.Handler; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.util.Log; -import android.util.Pair; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.WindowManager; -import android.widget.TextView; -import android.widget.Toast; - -import com.effective.R; -import com.effective.android.panel.PanelSwitchHelper; -import com.effective.android.panel.interfaces.listener.OnPanelChangeListener; -import com.effective.android.panel.view.panel.IPanelView; -import com.effective.android.panel.view.panel.PanelView; -import com.effective.databinding.ActivityDouyinLiveLayoutBinding; -import com.example.demo.scene.chat.emotion.EmotionPagerView; -import com.example.demo.scene.chat.emotion.Emotions; -import com.example.demo.systemui.StatusbarHelper; -import com.example.demo.util.DisplayUtils; - -import java.util.LinkedList; - - -/** - * 手机直播效果,只有竖屏 - * created by yummylau on 2020/06/01 - */ -public class PhoneDouyinLiveActivity extends AppCompatActivity { - - private ActivityDouyinLiveLayoutBinding mBinding; - private PanelSwitchHelper mHelper; - private LinearLayoutManager mLinearLayoutManager; - private ChatAdapter mAdapter; - private Handler handler = new Handler(); - private Runnable insertMessage = new Runnable() { - @Override - public void run() { - if (mAdapter != null) { - mAdapter.insertMessage(new Message("yummylau", "我来啦 " + mAdapter.getItemCount())); - } - handler.postDelayed(this, 5000); - } - }; - private static final String TAG = PhoneDouyinLiveActivity.class.getSimpleName(); - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); - initView(); - } - - private void initView() { - mBinding = DataBindingUtil.setContentView(this, R.layout.activity_douyin_live_layout); - Pair size = DisplayUtils.getScreenSize(this); - mBinding.videoView.getLayoutParams().width = size.first; - mBinding.videoView.getLayoutParams().height = size.second; - mBinding.videoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.yexiaoma)); - mBinding.videoView.setOnPreparedListener(mp -> { - mp.setVideoScalingMode(MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT); - mp.start(); - mp.setLooping(true); - }); - mBinding.videoView.start(); - mBinding.gift.setSelected(true); - mBinding.actionRealLayout.setVisibility(View.GONE); - mBinding.actionShowLayout.setVisibility(View.VISIBLE); - mBinding.close.setOnClickListener(v -> finish()); - mBinding.inputAction.setOnClickListener(v -> { - mBinding.actionRealLayout.setVisibility(View.VISIBLE); - mBinding.actionShowLayout.setVisibility(View.GONE); - mBinding.input.requestFocus(); - }); - mBinding.send.setOnClickListener(v -> { - mAdapter.insertMessage(new Message("yummylau", mBinding.input.getText().toString())); - mBinding.input.setText(""); - }); - - mLinearLayoutManager = new LinearLayoutManager(this); - mBinding.commentList.setLayoutManager(mLinearLayoutManager); - LinkedList messages = new LinkedList<>(); - for (int i = 0; i < 100; i++) { - messages.addFirst(new Message("yummylau" + i, "唱的好好听哦")); - } - mAdapter = new ChatAdapter(this, messages); - mBinding.commentList.setAdapter(mAdapter); - scrollToBottom(); - handler.postDelayed(insertMessage, 5000); - } - - private void scrollToBottom() { - mBinding.getRoot().post(() -> mLinearLayoutManager.scrollToPosition(mAdapter.getItemCount()-1)); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - handler.removeCallbacks(insertMessage); - } - - @Override - protected void onStart() { - super.onStart(); - if (mHelper == null) { - mHelper = new PanelSwitchHelper.Builder(this) - //可选 - .addKeyboardStateListener((visible, height) -> Log.d(TAG, "系统键盘是否可见 : " + visible + " 高度为:" + height)) - .addEditTextFocusChangeListener((view, hasFocus) -> { - Log.d(TAG, "输入框是否获得焦点 : " + hasFocus); - if (hasFocus) { - scrollToBottom(); - } - }) - //可选 - .addViewClickListener(view -> { - switch (view.getId()) { - case R.id.edit_text: - case R.id.emotion_btn: { - scrollToBottom(); - } - } - Log.d(TAG, "点击了View : " + view); - }) - //可选 - .addPanelChangeListener(new OnPanelChangeListener() { - - @Override - public void onKeyboard() { - Log.d(TAG, "唤起系统输入法"); - mBinding.emotionBtn.setSelected(false); - scrollToBottom(); - } - - @Override - public void onNone() { - Log.d(TAG, "隐藏所有面板"); - mBinding.emotionBtn.setSelected(false); - mBinding.actionRealLayout.setVisibility(View.GONE); - mBinding.actionShowLayout.setVisibility(View.VISIBLE); - } - - @Override - public void onPanel(IPanelView view) { - Log.d(TAG, "唤起面板 : " + view); - if (view instanceof PanelView) { - mBinding.emotionBtn.setSelected(((PanelView) view).getId() == R.id.panel_emotion ? true : false); - scrollToBottom(); - } - } - - @Override - public void onPanelSizeChange(IPanelView panelView, boolean portrait, int oldWidth, int oldHeight, int width, int height) { - if (panelView instanceof PanelView) { - switch (((PanelView) panelView).getId()) { - case R.id.panel_emotion: { - EmotionPagerView pagerView = mBinding.getRoot().findViewById(R.id.view_pager); - int viewPagerSize = height - DisplayUtils.dip2px(PhoneDouyinLiveActivity.this, 30f); - pagerView.buildEmotionViews( - mBinding.getRoot().findViewById(R.id.pageIndicatorView), - mBinding.input, - Emotions.getEmotions(), width, viewPagerSize); - break; - } - } - } - } - }) - .logTrack(true) - .build(); - } - } - - @Override - public void onBackPressed() { - if (mHelper != null && mHelper.hookSystemBackByPanelSwitcher()) { - return; - } - super.onBackPressed(); - } - - - public class ChatAdapter extends RecyclerView.Adapter { - - private LinkedList list; - private Context context; - - public ChatAdapter(Context context, LinkedList list) { - this.context = context; - this.list = list; - if (this.list == null) { - this.list = new LinkedList<>(); - } - } - - public void insertMessage(Message message) { - if (message != null) { - this.list.addLast(message); - notifyItemInserted(getItemCount()-1); - scrollToBottom(); - } - } - - @NonNull - @Override - public ChatHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - return new ChatHolder(LayoutInflater.from(context).inflate(R.layout.holder_douyin_chat_item, parent, false)); - } - - @Override - public void onBindViewHolder(@NonNull ChatHolder holder, int position) { - holder.bindData(list.get(position)); - } - - @Override - public int getItemCount() { - return list.size(); - } - } - - - public class ChatHolder extends RecyclerView.ViewHolder { - public ChatHolder(View itemView) { - super(itemView); - } - - public void bindData(Message message) { - ((TextView) itemView.findViewById(R.id.name)).setText(message.name + ": "); - ((TextView) itemView.findViewById(R.id.content)).setText(message.content); - itemView.findViewById(R.id.name).setOnClickListener(v -> Toast.makeText(PhoneDouyinLiveActivity.this, "点击了用户 " + message.name, Toast.LENGTH_SHORT).show()); - } - } - - public class Message { - public String name; - public String content; - - public Message(String name, String content) { - this.name = name; - this.content = content; - } - } -} diff --git a/app/src/main/java/com/example/demo/scene/live/huya/PcHuyaCommentPopWindow.java b/app/src/main/java/com/example/demo/scene/live/huya/PcHuyaCommentPopWindow.java deleted file mode 100644 index 66e87ae..0000000 --- a/app/src/main/java/com/example/demo/scene/live/huya/PcHuyaCommentPopWindow.java +++ /dev/null @@ -1,122 +0,0 @@ -package com.example.demo.scene.live.huya; - -import android.app.Activity; -import android.graphics.Color; -import android.graphics.drawable.ColorDrawable; -import android.text.Editable; -import android.text.TextWatcher; -import android.view.LayoutInflater; -import android.view.View; -import android.view.WindowManager; -import android.widget.EditText; -import android.widget.PopupWindow; -import android.widget.TextView; - -import com.effective.R; -import com.effective.android.panel.PanelSwitchHelper; -import com.effective.android.panel.interfaces.listener.OnPanelChangeListener; -import com.effective.android.panel.view.panel.IPanelView; -import com.effective.android.panel.view.panel.PanelView; -import com.example.demo.scene.chat.emotion.EmotionPagerView; -import com.example.demo.scene.chat.emotion.Emotions; -import com.example.demo.util.DisplayUtils; - -public class PcHuyaCommentPopWindow extends PopupWindow { - - private Activity activity; - private PanelSwitchHelper mHelper; - - public PcHuyaCommentPopWindow(final Activity activity) { - super(activity); - this.activity = activity; - final View view = LayoutInflater.from(activity).inflate(R.layout.pop_huya_live_comment_layout, null, false); - setFocusable(true); - setWidth(WindowManager.LayoutParams.MATCH_PARENT); - setHeight(WindowManager.LayoutParams.MATCH_PARENT); - setOutsideTouchable(true); - ColorDrawable dw = new ColorDrawable(Color.TRANSPARENT); - setBackgroundDrawable(dw); - setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); - setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); - setContentView(view); - view.findViewById(R.id.send).setOnClickListener(v -> ((EditText) view.findViewById(R.id.input)).setText("")); - ((EditText) view.findViewById(R.id.input)).addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - - } - - @Override - public void afterTextChanged(Editable s) { - view.findViewById(R.id.send).setEnabled(s.length() != 0); - } - }); - if (mHelper == null) { - mHelper = new PanelSwitchHelper.Builder(activity.getWindow(), getContentView()) - .addPanelChangeListener(new OnPanelChangeListener() { - - @Override - public void onKeyboard() { - getContentView().findViewById(R.id.emotion_btn).setSelected(false); - } - - @Override - public void onNone() { - getContentView().findViewById(R.id.emotion_btn).setSelected(false); - dismiss(); - } - - @Override - public void onPanel(IPanelView panelView) { - getContentView().findViewById(R.id.emotion_btn).setSelected(true); - } - - @Override - public void onPanelSizeChange(IPanelView panelView, boolean portrait, int oldWidth, int oldHeight, int width, int height) { - if (panelView instanceof PanelView) { - switch (((PanelView) panelView).getId()) { - case R.id.panel_emotion: { - EmotionPagerView pagerView = getContentView().findViewById(R.id.view_pager); - int viewPagerSize = height - DisplayUtils.dip2px(activity, 30f); - pagerView.buildEmotionViews( - getContentView().findViewById(R.id.pageIndicatorView), - getContentView().findViewById(R.id.input), - Emotions.getEmotions(), width, viewPagerSize); - break; - } - } - } - } - }) - .logTrack(true) - .build(false); - } - } - - @Override - public void showAtLocation(View parent, int gravity, int x, int y) { - getContentView().findViewById(R.id.emotion_btn).setSelected(false); - getContentView().findViewById(R.id.send).setSelected(true); - ((TextView)getContentView().findViewById(R.id.input)).setText(""); - super.showAtLocation(parent, gravity, x, y); - } - - public void showKeyboard() { - if (mHelper != null) { - mHelper.toKeyboardState(); - } - } - - @Override - public void dismiss() { - if (mHelper != null && mHelper.hookSystemBackByPanelSwitcher()) { - return; - } - super.dismiss(); - } -} diff --git a/app/src/main/java/com/example/demo/scene/live/huya/PcHuyaLiveActivity.java b/app/src/main/java/com/example/demo/scene/live/huya/PcHuyaLiveActivity.java deleted file mode 100644 index 5edaa63..0000000 --- a/app/src/main/java/com/example/demo/scene/live/huya/PcHuyaLiveActivity.java +++ /dev/null @@ -1,367 +0,0 @@ -package com.example.demo.scene.live.huya; - -import android.content.Context; -import android.content.res.Configuration; -import android.databinding.DataBindingUtil; -import android.graphics.Color; -import android.net.Uri; -import android.os.Build; -import android.os.Bundle; -import android.os.Handler; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.text.Editable; -import android.text.TextWatcher; -import android.util.Log; -import android.util.Pair; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.Window; -import android.view.WindowManager; -import android.widget.RelativeLayout; -import android.widget.TextView; -import android.widget.Toast; - -import com.effective.R; -import com.effective.android.panel.PanelSwitchHelper; -import com.effective.android.panel.interfaces.listener.OnPanelChangeListener; -import com.effective.android.panel.utils.DisplayUtil; -import com.effective.android.panel.view.panel.IPanelView; -import com.effective.android.panel.view.panel.PanelView; -import com.effective.databinding.ActivityHuyaLiveLayoutBinding; -import com.example.demo.scene.chat.emotion.EmotionPagerView; -import com.example.demo.scene.chat.emotion.Emotions; -import com.example.demo.systemui.StatusbarHelper; -import com.example.demo.util.DisplayUtils; -import com.rd.PageIndicatorView; - -import java.util.ArrayList; -import java.util.List; - -/** - * pc虎牙直播效果,竖屏顶部区域,横屏满屏 - * created by yummylau on 2020/06/01 - */ -public class PcHuyaLiveActivity extends AppCompatActivity { - - private static final String TAG = "PcHuyaLiveActivity"; - private ActivityHuyaLiveLayoutBinding mBinding; - private PcHuyaCommentPopWindow videoPopWindow; - private LinearLayoutManager mLinearLayoutManager; - private PanelSwitchHelper mHelper; - private ChatAdapter mAdapter; - private Handler handler = new Handler(); - private Runnable insertMessage = new Runnable() { - @Override - public void run() { - if (mAdapter != null) { - mAdapter.insertMessage(new Message("yummylau", "模拟插入数据" + System.currentTimeMillis())); - } - handler.postDelayed(this, 1500); - } - }; - private Runnable showKeyboardRunnable = new Runnable() { - @Override - public void run() { - if (videoPopWindow != null) { - videoPopWindow.showKeyboard(); - } - } - }; - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - StatusbarHelper.setStatusBarColor(this, Color.BLACK); - initView(); - } - - private void initView() { - Pair size = DisplayUtils.getScreenSize(this); - mBinding = DataBindingUtil.setContentView(this, R.layout.activity_huya_live_layout); - mBinding.videoView.getLayoutParams().width = size.first; - mBinding.videoView.getLayoutParams().height = size.first * 9 / 16; - mBinding.videoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.uzi)); - mBinding.videoView.setOnPreparedListener(mp -> { - mp.start(); - mp.setLooping(true); - }); - mBinding.videoView.start(); - mBinding.checkout.setOnClickListener(v -> DisplayUtils.checkoutOrientation(PcHuyaLiveActivity.this)); - mBinding.back.setOnClickListener(v -> onBackPressed()); - View.OnClickListener inputClick = v -> { - if(videoPopWindow == null){ - videoPopWindow = new PcHuyaCommentPopWindow(PcHuyaLiveActivity.this); - } - videoPopWindow.showAtLocation(mBinding.getRoot(), Gravity.NO_GRAVITY, 0, 0); - mBinding.getRoot().postDelayed(showKeyboardRunnable, 200); - }; - mBinding.inputH.setOnClickListener(inputClick); - mBinding.input.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - - } - - @Override - public void afterTextChanged(Editable s) { - mBinding.send.setEnabled(s.length() != 0); - } - }); - mBinding.send.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - mAdapter.insertMessage(new Message("yummylau", mBinding.input.getText().toString())); - mBinding.input.setText(""); - } - }); - - mLinearLayoutManager = new LinearLayoutManager(this); - mBinding.chatList.setLayoutManager(mLinearLayoutManager); - List messages = new ArrayList<>(); - for (int i = 0; i < 50; i++) { - messages.add(new Message("yummylau" + i, "进入直播间")); - } - mAdapter = new ChatAdapter(this, messages); - mBinding.chatList.setAdapter(mAdapter); - scrollToBottom(); - handler.postDelayed(insertMessage, 1500); - psize = DisplayUtils.getScreenSize(this); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (showKeyboardRunnable != null) { - mBinding.getRoot().removeCallbacks(showKeyboardRunnable); - } - handler.removeCallbacks(insertMessage); - } - - private void scrollToBottom() { - mBinding.getRoot().post(() -> mLinearLayoutManager.scrollToPosition(mAdapter.getItemCount() - 1)); - } - - @Override - protected void onStart() { - super.onStart(); - if (mHelper == null) { - mHelper = new PanelSwitchHelper.Builder(this) - //可选 - .addKeyboardStateListener((visible, height) -> Log.d(TAG, "系统键盘是否可见 : " + visible + " 高度为:" + height)) - .addEditTextFocusChangeListener((view, hasFocus) -> { - Log.d(TAG, "输入框是否获得焦点 : " + hasFocus); - if (hasFocus) { - scrollToBottom(); - } - }) - //可选 - .addViewClickListener(view -> { - switch (view.getId()) { - case R.id.edit_text: - case R.id.emotion_btn: { - scrollToBottom(); - } - } - Log.d(TAG, "点击了View : " + view); - }) - //可选 - .addPanelChangeListener(new OnPanelChangeListener() { - - @Override - public void onKeyboard() { - Log.d(TAG, "唤起系统输入法"); - mBinding.emotionBtn.setSelected(false); - scrollToBottom(); - } - - @Override - public void onNone() { - Log.d(TAG, "隐藏所有面板"); - mBinding.emotionBtn.setSelected(false); - } - - @Override - public void onPanel(IPanelView view) { - Log.d(TAG, "唤起面板 : " + view); - if (view instanceof PanelView) { - mBinding.emotionBtn.setSelected(((PanelView) view).getId() == R.id.panel_emotion ? true : false); - scrollToBottom(); - } - } - - @Override - public void onPanelSizeChange(IPanelView panelView, boolean portrait, int oldWidth, int oldHeight, int width, int height) { - if (panelView instanceof PanelView) { - switch (((PanelView) panelView).getId()) { - case R.id.panel_emotion: { - EmotionPagerView pagerView = mBinding.getRoot().findViewById(R.id.view_pager); - int viewPagerSize = height - DisplayUtils.dip2px(PcHuyaLiveActivity.this, 30f); - pagerView.buildEmotionViews( - (PageIndicatorView) mBinding.getRoot().findViewById(R.id.pageIndicatorView), - mBinding.input, - Emotions.getEmotions(), width, viewPagerSize); - break; - } - } - } - } - }) - .logTrack(true) //output log - .build(); - } - } - - @Override - public void onBackPressed() { - if (!DisplayUtils.isPortrait(this)) { - if (videoPopWindow != null && videoPopWindow.isShowing()) { - videoPopWindow.dismiss(); - } else { - DisplayUtils.checkoutOrientation(PcHuyaLiveActivity.this); - } - return; - } else { - if (mHelper != null && mHelper.hookSystemBackByPanelSwitcher()) { - return; - } - } - super.onBackPressed(); - } - - Pair psize; - - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mBinding.videoView.getLayoutParams(); - if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { - checkoutSystemUIMode(true); - psize = DisplayUtils.getScreenSize(this); - layoutParams.width = psize.first; - layoutParams.height = psize.first * 9 / 16; - mBinding.inputH.setVisibility(View.GONE); - mBinding.panelRoot.setVisibility(View.VISIBLE); - mBinding.checkout.setVisibility(View.VISIBLE); - } else { - checkoutSystemUIMode(false); - Pair size = DisplayUtils.getScreenSize(this); - layoutParams.width = size.first; - layoutParams.height = psize.first; - mBinding.inputH.setVisibility(View.VISIBLE); - mBinding.panelRoot.setVisibility(View.GONE); - mBinding.checkout.setVisibility(View.GONE); - } - mBinding.videoView.setLayoutParams(layoutParams); - } - - private void checkoutSystemUIMode(boolean isP){ - if(isP){ - getWindow().getDecorView().setSystemUiVisibility(0); //重置 - getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - StatusbarHelper.setStatusBarColor(this, Color.BLACK); - }else{ - getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - Window window = getWindow(); - getWindow().getDecorView().setSystemUiVisibility(0); - window.getDecorView().setSystemUiVisibility( - window.getDecorView().getSystemUiVisibility() | - View.SYSTEM_UI_FLAG_HIDE_NAVIGATION| - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION| - View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); - } - } - } - - @Override - public void onWindowFocusChanged(boolean hasFocus) { - super.onWindowFocusChanged(hasFocus); - if(hasFocus && !DisplayUtil.isPortrait(this)){ - getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - Window window = getWindow(); - getWindow().getDecorView().setSystemUiVisibility(0); - window.getDecorView().setSystemUiVisibility( - window.getDecorView().getSystemUiVisibility() | - View.SYSTEM_UI_FLAG_HIDE_NAVIGATION| - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION| - View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); - } - } - } - - public class ChatAdapter extends RecyclerView.Adapter { - - private List list; - private Context context; - - public ChatAdapter(Context context, List list) { - this.context = context; - this.list = list; - if (this.list == null) { - this.list = new ArrayList<>(); - } - } - - public void insertMessage(Message message) { - if (message != null) { - this.list.add(message); - notifyItemInserted(this.list.size() - 1); - scrollToBottom(); - } - } - - @NonNull - @Override - public ChatHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - return new ChatHolder(LayoutInflater.from(context).inflate(R.layout.holder_huya_chat_item, parent, false)); - } - - @Override - public void onBindViewHolder(@NonNull ChatHolder holder, int position) { - holder.bindData(list.get(position)); - } - - @Override - public int getItemCount() { - return list.size(); - } - } - - public class ChatHolder extends RecyclerView.ViewHolder { - - - public ChatHolder(View itemView) { - super(itemView); - } - - public void bindData(Message message) { - ((TextView) itemView.findViewById(R.id.name)).setText(message.name + ": "); - ((TextView) itemView.findViewById(R.id.content)).setText(message.content); - itemView.findViewById(R.id.name).setOnClickListener(v -> Toast.makeText(PcHuyaLiveActivity.this, "点击了用户 " + message.name, Toast.LENGTH_SHORT).show()); - } - } - - public class Message { - public String name; - public String content; - - public Message(String name, String content) { - this.name = name; - this.content = content; - } - } -} diff --git a/app/src/main/java/com/example/demo/scene/video/BiliBiliCommentPopWindow.java b/app/src/main/java/com/example/demo/scene/video/BiliBiliCommentPopWindow.java deleted file mode 100644 index 820f706..0000000 --- a/app/src/main/java/com/example/demo/scene/video/BiliBiliCommentPopWindow.java +++ /dev/null @@ -1,129 +0,0 @@ -package com.example.demo.scene.video; - -import android.app.Activity; -import android.graphics.Color; -import android.graphics.drawable.ColorDrawable; -import android.support.v4.content.ContextCompat; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.WindowManager; -import android.widget.EditText; -import android.widget.PopupWindow; -import android.widget.TextView; - -import com.effective.R; -import com.effective.android.panel.PanelSwitchHelper; -import com.effective.android.panel.interfaces.listener.OnPanelChangeListener; -import com.effective.android.panel.utils.DisplayUtil; -import com.effective.android.panel.view.panel.IPanelView; -import com.effective.android.panel.view.panel.PanelView; -import com.example.demo.util.DisplayUtils; - -public class BiliBiliCommentPopWindow extends PopupWindow { - - private Activity activity; - private PanelSwitchHelper mHelper; - - public BiliBiliCommentPopWindow(final Activity activity) { - super(activity); - this.activity = activity; - final View view = LayoutInflater.from(activity).inflate(R.layout.pop_bilibili_video_comment_layout, null, false); - setFocusable(true); - setWidth(WindowManager.LayoutParams.MATCH_PARENT); - setHeight(WindowManager.LayoutParams.MATCH_PARENT); - setOutsideTouchable(true); - ColorDrawable dw = new ColorDrawable(Color.TRANSPARENT); - setBackgroundDrawable(dw); - setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); - setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); - setContentView(view); - view.findViewById(R.id.send).setOnClickListener(v -> ((EditText) view.findViewById(R.id.edit_text)).setText("")); - if (mHelper == null) { - mHelper = new PanelSwitchHelper.Builder(activity.getWindow(), getContentView()) - .addPanelChangeListener(new OnPanelChangeListener() { - - @Override - public void onKeyboard() { - getContentView().findViewById(R.id.add_btn).setSelected(false); - } - - @Override - public void onNone() { - getContentView().findViewById(R.id.add_btn).setSelected(false); - dismiss(); - } - - @Override - public void onPanel(IPanelView panelView) { - getContentView().findViewById(R.id.add_btn).setSelected(true); - } - - @Override - public void onPanelSizeChange(IPanelView panelView, boolean portrait, int oldWidth, int oldHeight, int width, int height) { - if (panelView instanceof PanelView) { - switch (((PanelView) panelView).getId()) { - case R.id.panel_bilibili: { - View root = view.findViewById(R.id.danmu_setting); - ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) root.getLayoutParams(); - if (layoutParams.width != width || layoutParams.height == height) { - layoutParams.width = width; - layoutParams.height = height; - root.setLayoutParams(layoutParams); - } - } - } - } - } - }) - .logTrack(true) - .build(false); - } - } - - @Override - public void showAtLocation(View parent, int gravity, int x, int y) { - boolean isP = DisplayUtils.isPortrait(getContentView().getContext()); - adjustDanmuPanel(isP); - if (isP) { - getContentView().findViewById(R.id.add_btn).setBackground(ContextCompat.getDrawable(activity, R.drawable.se_bilibili_panel_key_p)); - getContentView().findViewById(R.id.add_btn).setSelected(false); - getContentView().findViewById(R.id.send).setSelected(false); - getContentView().findViewById(R.id.panel_container).setBackgroundColor(ContextCompat.getColor(activity, R.color.common_page_bg_color)); - getContentView().findViewById(R.id.input_layout).setBackgroundColor(Color.WHITE); - getContentView().findViewById(R.id.edit_text).setBackground(ContextCompat.getDrawable(activity, R.drawable.sh_bilibili_input_p)); - } else { - getContentView().findViewById(R.id.add_btn).setBackground(ContextCompat.getDrawable(activity, R.drawable.se_bilibili_panel_key_l)); - getContentView().findViewById(R.id.add_btn).setSelected(false); - getContentView().findViewById(R.id.send).setSelected(true); - getContentView().findViewById(R.id.panel_container).setBackgroundColor(Color.BLACK); - getContentView().findViewById(R.id.input_layout).setBackgroundColor(Color.BLACK); - getContentView().findViewById(R.id.edit_text).setBackground(ContextCompat.getDrawable(activity, R.drawable.sh_bilibili_input_l_but_white)); - } - super.showAtLocation(parent, gravity, x, y); - } - - public void adjustDanmuPanel(boolean isPortrait) { - getContentView().findViewById(R.id.color_for_p).setVisibility(isPortrait ? View.VISIBLE : View.GONE); - getContentView().findViewById(R.id.color_for_l).setVisibility(isPortrait ? View.GONE : View.VISIBLE); - ((TextView) getContentView().findViewById(R.id.danmu_font_title)).setTextColor(isPortrait ? Color.parseColor("#999999") : Color.WHITE); - ((TextView) getContentView().findViewById(R.id.danmu_location_title)).setTextColor(isPortrait ? Color.parseColor("#999999") : Color.WHITE); - ((TextView) getContentView().findViewById(R.id.color_for_p_title)).setTextColor(isPortrait ? Color.parseColor("#999999") : Color.WHITE); - ((TextView) getContentView().findViewById(R.id.color_for_l_title)).setTextColor(isPortrait ? Color.parseColor("#999999") : Color.WHITE); - ((ViewGroup.MarginLayoutParams)getContentView().findViewById(R.id.danmu_location).getLayoutParams()).topMargin = isPortrait ? DisplayUtil.dip2px(getContentView().getContext(),15f) : DisplayUtil.dip2px(getContentView().getContext(),20f); - } - - public void showKeyboard() { - if (mHelper != null) { - mHelper.toKeyboardState(); - } - } - - @Override - public void dismiss() { - if (mHelper != null && mHelper.hookSystemBackByPanelSwitcher()) { - return; - } - super.dismiss(); - } -} diff --git a/app/src/main/java/com/example/demo/scene/video/BiliBiliSampleActivity.java b/app/src/main/java/com/example/demo/scene/video/BiliBiliSampleActivity.java deleted file mode 100644 index 2516e28..0000000 --- a/app/src/main/java/com/example/demo/scene/video/BiliBiliSampleActivity.java +++ /dev/null @@ -1,147 +0,0 @@ -package com.example.demo.scene.video; - -import android.content.res.Configuration; -import android.databinding.DataBindingUtil; -import android.graphics.Color; -import android.net.Uri; -import android.os.Build; -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v7.app.AppCompatActivity; -import android.util.Pair; -import android.view.Gravity; -import android.view.View; -import android.view.Window; -import android.view.WindowManager; -import android.widget.RelativeLayout; - -import com.effective.R; -import com.effective.android.panel.utils.DisplayUtil; -import com.effective.databinding.ActivityBilibiliVideoLayoutBinding; -import com.example.demo.systemui.StatusbarHelper; -import com.example.demo.util.DisplayUtils; - -/** - * Created by yummyLau on 18-12-13 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -public class BiliBiliSampleActivity extends AppCompatActivity { - private ActivityBilibiliVideoLayoutBinding mBinding; - private BiliBiliCommentPopWindow videoPopWindow; - private Runnable runnable = new Runnable() { - @Override - public void run() { - if (videoPopWindow != null) { - videoPopWindow.showKeyboard(); - } - } - }; - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - StatusbarHelper.setStatusBarColor(this, Color.BLACK); - initView(); - } - - private void initView() { - Pair size = DisplayUtils.getScreenSize(this); - mBinding = DataBindingUtil.setContentView(this, R.layout.activity_bilibili_video_layout); - mBinding.videoView.getLayoutParams().width = size.first; - mBinding.videoView.getLayoutParams().height = size.first * 9 / 16; - mBinding.videoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.uzi)); - mBinding.videoView.setOnPreparedListener(mp -> { - mp.start(); - mp.setLooping(true); - }); - mBinding.videoView.start(); - mBinding.checkout.setOnClickListener(v -> DisplayUtils.checkoutOrientation(BiliBiliSampleActivity.this)); - mBinding.back.setOnClickListener(v -> onBackPressed()); - View.OnClickListener inputClick = v -> { - //如果横竖屏复用同一个popupwindow,则需要处理好切换的时候panel动态变化,因为横竖屏的高度不一样。bilibili看起来是两个不同的布局。 - //一个或两个都可以,如果采用一个,则需要处理popupwindow内布局的高度变化。 - videoPopWindow = new BiliBiliCommentPopWindow(BiliBiliSampleActivity.this); - videoPopWindow.showAtLocation(mBinding.getRoot(), Gravity.NO_GRAVITY, 0, 0); - mBinding.getRoot().postDelayed(runnable, 200); - }; - mBinding.input.setOnClickListener(inputClick); - mBinding.inputH.setOnClickListener(inputClick); - psize = DisplayUtils.getScreenSize(this); - } - - @Override - public void onBackPressed() { - if (!DisplayUtils.isPortrait(this)) { - if (videoPopWindow != null && videoPopWindow.isShowing()) { - videoPopWindow.dismiss(); - } else { - DisplayUtils.checkoutOrientation(BiliBiliSampleActivity.this); - } - return; - } - super.onBackPressed(); - } - - Pair psize; - - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mBinding.videoView.getLayoutParams(); - if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { - checkoutSystemUIMode(true); - psize = DisplayUtils.getScreenSize(this); - layoutParams.width = psize.first; - layoutParams.height = psize.first * 9 / 16; - mBinding.inputH.setVisibility(View.GONE); - mBinding.checkout.setVisibility(View.VISIBLE); - } else { - checkoutSystemUIMode(false); - Pair size = DisplayUtils.getScreenSize(this); - layoutParams.width = size.first; - layoutParams.height = psize.first; - mBinding.inputH.setVisibility(View.VISIBLE); - mBinding.checkout.setVisibility(View.GONE); - } - mBinding.videoView.setLayoutParams(layoutParams); - } - - private void checkoutSystemUIMode(boolean isP){ - if(isP){ - getWindow().getDecorView().setSystemUiVisibility(0); //重置 - getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - StatusbarHelper.setStatusBarColor(this, Color.BLACK); - }else{ - getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - Window window = getWindow(); - getWindow().getDecorView().setSystemUiVisibility(0); - window.getDecorView().setSystemUiVisibility( - window.getDecorView().getSystemUiVisibility() | - View.SYSTEM_UI_FLAG_HIDE_NAVIGATION| - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION| - View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); - } - } - } - - @Override - public void onWindowFocusChanged(boolean hasFocus) { - super.onWindowFocusChanged(hasFocus); - if(hasFocus && !DisplayUtil.isPortrait(this)){ - getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - Window window = getWindow(); - getWindow().getDecorView().setSystemUiVisibility(0); - window.getDecorView().setSystemUiVisibility( - window.getDecorView().getSystemUiVisibility() | - View.SYSTEM_UI_FLAG_HIDE_NAVIGATION| - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION| - View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); - } - } - } -} diff --git a/app/src/main/java/com/example/demo/systemui/QMUIDeviceHelper.java b/app/src/main/java/com/example/demo/systemui/QMUIDeviceHelper.java deleted file mode 100644 index 6f221e0..0000000 --- a/app/src/main/java/com/example/demo/systemui/QMUIDeviceHelper.java +++ /dev/null @@ -1,252 +0,0 @@ -package com.example.demo.systemui; - -import android.annotation.TargetApi; -import android.app.AppOpsManager; -import android.content.Context; -import android.content.res.Configuration; -import android.os.Binder; -import android.os.Build; -import android.os.Environment; -import android.support.annotation.Nullable; -import android.text.TextUtils; -import android.util.Log; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.lang.reflect.Method; -import java.util.Properties; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - - -/** - * @author cginechen - * @date 2016-08-11 - */ -public class QMUIDeviceHelper { - private final static String TAG = "QMUIDeviceHelper"; - private final static String KEY_MIUI_VERSION_NAME = "ro.miui.ui.version.name"; - private static final String KEY_FLYME_VERSION_NAME = "ro.build.display.id"; - private final static String FLYME = "flyme"; - private final static String ZTEC2016 = "zte c2016"; - private final static String ZUKZ1 = "zuk z1"; - private final static String MEIZUBOARD[] = {"m9", "M9", "mx", "MX"}; - private static String sMiuiVersionName; - private static String sFlymeVersionName; - private static boolean sIsTabletChecked = false; - private static boolean sIsTabletValue = false; - - static { - Properties properties = new Properties(); - - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { - // android 8.0,读取 /system/uild.prop 会报 permission denied - FileInputStream fileInputStream = null; - try { - fileInputStream = new FileInputStream(new File(Environment.getRootDirectory(), "build.prop")); - properties.load(fileInputStream); - } catch (Exception e) { - Log.e(TAG, e.getMessage()); - } finally { - if (fileInputStream != null) { - try { - fileInputStream.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - - Class clzSystemProperties = null; - try { - clzSystemProperties = Class.forName("android.os.SystemProperties"); - Method getMethod = clzSystemProperties.getDeclaredMethod("get", String.class); - // miui - sMiuiVersionName = getLowerCaseName(properties, getMethod, KEY_MIUI_VERSION_NAME); - //flyme - sFlymeVersionName = getLowerCaseName(properties, getMethod, KEY_FLYME_VERSION_NAME); - } catch (Exception e) { - Log.e(TAG, e.getMessage()); - } - } - - private static boolean _isTablet(Context context) { - return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= - Configuration.SCREENLAYOUT_SIZE_LARGE; - } - - /** - * 判断是否为平板设备 - */ - public static boolean isTablet(Context context) { - if (sIsTabletChecked) { - return sIsTabletValue; - } - sIsTabletValue = _isTablet(context); - sIsTabletChecked = true; - return sIsTabletValue; - } - - /** - * 判断是否是flyme系统 - */ - public static boolean isFlyme() { - return !TextUtils.isEmpty(sFlymeVersionName) && sFlymeVersionName.contains(FLYME); - } - - /** - * 判断是否是MIUI系统 - */ - public static boolean isMIUI() { - return !TextUtils.isEmpty(sMiuiVersionName); - } - - public static boolean isMIUIV5() { - return "v5".equals(sMiuiVersionName); - } - - public static boolean isMIUIV6() { - return "v6".equals(sMiuiVersionName); - } - - public static boolean isMIUIV7() { - return "v7".equals(sMiuiVersionName); - } - - public static boolean isMIUIV8() { - return "v8".equals(sMiuiVersionName); - } - - public static boolean isMIUIV9() { - return "v9".equals(sMiuiVersionName); - } - - public static boolean isFlymeVersionHigher5_2_4() { - //查不到默认高于5.2.4 - boolean isHigher = true; - if (sFlymeVersionName != null && !sFlymeVersionName.equals("")) { - Pattern pattern = Pattern.compile("(\\d+\\.){2}\\d"); - Matcher matcher = pattern.matcher(sFlymeVersionName); - if (matcher.find()) { - String versionString = matcher.group(); - if (versionString != null && !versionString.equals("")) { - String[] version = versionString.split("\\."); - if (version.length == 3) { - if (Integer.valueOf(version[0]) < 5) { - isHigher = false; - } else if (Integer.valueOf(version[0]) > 5) { - isHigher = true; - } else { - if (Integer.valueOf(version[1]) < 2) { - isHigher = false; - } else if (Integer.valueOf(version[1]) > 2) { - isHigher = true; - } else { - if (Integer.valueOf(version[2]) < 4) { - isHigher = false; - } else if (Integer.valueOf(version[2]) >= 5) { - isHigher = true; - } - } - } - } - - } - } - } - return isMeizu() && isHigher; - } - - /** - * 判断是否为魅族 - */ - public static boolean isMeizu() { - return isPhone(MEIZUBOARD) || isFlyme(); - } - - /** - * 判断是否为小米 - * https://dev.mi.com/doc/?p=254 - */ - public static boolean isXiaomi() { - return Build.MANUFACTURER.toLowerCase().equals("xiaomi"); - } - - - /** - * 判断是否为 ZUK Z1 和 ZTK C2016。 - * 两台设备的系统虽然为 android 6.0,但不支持状态栏icon颜色改变,因此经常需要对它们进行额外判断。 - */ - public static boolean isZUKZ1() { - final String board = Build.MODEL; - return board != null && board.toLowerCase().contains(ZUKZ1); - } - - public static boolean isZTKC2016() { - final String board = Build.MODEL; - return board != null && board.toLowerCase().contains(ZTEC2016); - } - - private static boolean isPhone(String[] boards) { - final String board = Build.BOARD; - if (board == null) { - return false; - } - for (String board1 : boards) { - if (board.equals(board1)) { - return true; - } - } - return false; - } - - /** - * 判断悬浮窗权限(目前主要用户魅族与小米的检测)。 - */ - public static boolean isFloatWindowOpAllowed(Context context) { - final int version = Build.VERSION.SDK_INT; - if (version >= 19) { - return checkOp(context, 24); // 24 是AppOpsManager.OP_SYSTEM_ALERT_WINDOW 的值,该值无法直接访问 - } else { - try { - return (context.getApplicationInfo().flags & 1 << 27) == 1 << 27; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - } - - @TargetApi(19) - private static boolean checkOp(Context context, int op) { - final int version = Build.VERSION.SDK_INT; - if (version >= Build.VERSION_CODES.KITKAT) { - AppOpsManager manager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE); - try { - Method method = manager.getClass().getDeclaredMethod("checkOp", int.class, int.class, String.class); - int property = (Integer) method.invoke(manager, op, - Binder.getCallingUid(), context.getPackageName()); - return AppOpsManager.MODE_ALLOWED == property; - } catch (Exception e) { - e.printStackTrace(); - } - } - return false; - } - - @Nullable - private static String getLowerCaseName(Properties p, Method get, String key) { - String name = p.getProperty(key); - if (name == null) { - try { - name = (String) get.invoke(null, key); - } catch (Exception ignored) { - } - } - if (name != null) name = name.toLowerCase(); - return name; - } -} - diff --git a/app/src/main/java/com/example/demo/systemui/QMUIDisplayHelper.java b/app/src/main/java/com/example/demo/systemui/QMUIDisplayHelper.java deleted file mode 100644 index fc17082..0000000 --- a/app/src/main/java/com/example/demo/systemui/QMUIDisplayHelper.java +++ /dev/null @@ -1,358 +0,0 @@ -package com.example.demo.systemui; - -import android.Manifest; -import android.app.Activity; -import android.content.Context; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; -import android.content.res.Configuration; -import android.content.res.Resources; -import android.graphics.Point; -import android.net.ConnectivityManager; -import android.os.Build; -import android.os.Environment; -import android.support.annotation.RequiresPermission; -import android.util.DisplayMetrics; -import android.util.TypedValue; -import android.view.Display; -import android.view.KeyCharacterMap; -import android.view.KeyEvent; -import android.view.ViewConfiguration; -import android.view.WindowManager; - -import java.lang.reflect.Field; -import java.util.Locale; - - -/** - * @author cginechen - * @date 2016-03-17 - */ -public class QMUIDisplayHelper { - - /** - * 屏幕密度,系统源码注释不推荐使用 - */ - public static final float DENSITY = Resources.getSystem() - .getDisplayMetrics().density; - private static final String TAG = "Devices"; - /** - * 屏幕密度 - */ - public static float sDensity = 0f; - /** - * 是否有摄像头 - */ - private static Boolean sHasCamera = null; - - /** - * 获取 DisplayMetrics - * - * @return - */ - public static DisplayMetrics getDisplayMetrics(Context context) { - DisplayMetrics displayMetrics = new DisplayMetrics(); - ((WindowManager) context.getApplicationContext().getSystemService(Context.WINDOW_SERVICE)) - .getDefaultDisplay().getMetrics(displayMetrics); - return displayMetrics; - } - - /** - * 把以 dp 为单位的值,转化为以 px 为单位的值 - * - * @param dpValue 以 dp 为单位的值 - * @return px value - */ - public static int dpToPx(int dpValue) { - return (int) (dpValue * DENSITY + 0.5f); - } - - /** - * 把以 px 为单位的值,转化为以 dp 为单位的值 - * - * @param pxValue 以 px 为单位的值 - * @return dp值 - */ - public static int pxToDp(float pxValue) { - return (int) (pxValue / DENSITY + 0.5f); - } - - public static float getDensity(Context context) { - if (sDensity == 0f) { - sDensity = getDisplayMetrics(context).density; - } - return sDensity; - } - - /** - * 获取屏幕宽度 - * - * @return - */ - public static int getScreenWidth(Context context) { - return getDisplayMetrics(context).widthPixels; - } - - /** - * 获取屏幕高度 - * - * @return - */ - public static int getScreenHeight(Context context) { - return getDisplayMetrics(context).heightPixels; - } - - /** - * 获取屏幕的真实宽高 - * - * @param context - * @return - */ - public static int[] getRealScreenSize(Context context) { - int[] size = new int[2]; - int widthPixels = 0, heightPixels = 0; - WindowManager w = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); - Display d = w.getDefaultDisplay(); - DisplayMetrics metrics = new DisplayMetrics(); - d.getMetrics(metrics); - // since SDK_INT = 1; - widthPixels = metrics.widthPixels; - heightPixels = metrics.heightPixels; - try { - // used when 17 > SDK_INT >= 14; includes window decorations (statusbar bar/menu bar) - widthPixels = (Integer) Display.class.getMethod("getRawWidth").invoke(d); - heightPixels = (Integer) Display.class.getMethod("getRawHeight").invoke(d); - } catch (Exception ignored) { - } - try { - // used when SDK_INT >= 17; includes window decorations (statusbar bar/menu bar) - Point realSize = new Point(); - d.getRealSize(realSize); - - - Display.class.getMethod("getRealSize", Point.class).invoke(d, realSize); - widthPixels = realSize.x; - heightPixels = realSize.y; - } catch (Exception ignored) { - } - - size[0] = widthPixels; - size[1] = heightPixels; - return size; - - } - - public static boolean isNavMenuExist(Context context) { - //通过判断设备是否有返回键、菜单键(不是虚拟键,是手机屏幕外的按键)来确定是否有navigation bar - boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey(); - boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); - - if (!hasMenuKey && !hasBackKey) { - // 做任何你需要做的,这个设备有一个导航栏 - return true; - } - return false; - } - - /** - * 单位转换: dp -> px - * - * @param dp - * @return - */ - public static int dp2px(Context context, int dp) { - return (int) (getDensity(context) * dp + 0.5); - } - - /** - * 单位转换:px -> dp - * - * @param px - * @return - */ - public static int px2dp(Context context, int px) { - return (int) (px / getDensity(context) + 0.5); - } - - /** - * 判断是否有状态栏 - * - * @param context - * @return - */ - public static boolean hasStatusBar(Context context) { - if (context instanceof Activity) { - Activity activity = (Activity) context; - WindowManager.LayoutParams attrs = activity.getWindow().getAttributes(); - return (attrs.flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) != WindowManager.LayoutParams.FLAG_FULLSCREEN; - } - return true; - } - - /** - * 获取ActionBar高度 - * - * @param context - * @return - */ - public static int getActionBarHeight(Context context) { - int actionBarHeight = 0; - TypedValue tv = new TypedValue(); - if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { - actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, - context.getResources().getDisplayMetrics()); - } - return actionBarHeight; - } - - /** - * 获取状态栏高度 - * - * @param context - * @return - */ - public static int getStatusBarHeight(Context context) { - Class c; - Object obj; - Field field; - int x; - try { - c = Class.forName("com.android.internal.R$dimen"); - obj = c.newInstance(); - field = c.getField("status_bar_height"); - x = Integer.parseInt(field.get(obj).toString()); - return context.getResources() - .getDimensionPixelSize(x); - } catch (Exception e) { - e.printStackTrace(); - } - return 0; - } - - /** - * 获取虚拟菜单的高度,若无则返回0 - * - * @param context - * @return - */ - public static int getNavMenuHeight(Context context) { - if(!isNavMenuExist(context)){ - return 0; - } - // 小米4没有nav bar, 而 navigation_bar_height 有值 - int resourceId = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android"); - if (resourceId > 0) { - return context.getResources().getDimensionPixelSize(resourceId); - } - - // 小米 MIX 有nav bar, 而 getRealScreenSize(context)[1] - getScreenHeight(context) = 0 - return getRealScreenSize(context)[1] - getScreenHeight(context); - } - - public static final boolean hasCamera(Context context) { - if (sHasCamera == null) { - PackageManager pckMgr = context.getPackageManager(); - boolean flag = pckMgr - .hasSystemFeature("android.hardware.camera.front"); - boolean flag1 = pckMgr.hasSystemFeature("android.hardware.camera"); - boolean flag2; - flag2 = flag || flag1; - sHasCamera = flag2; - } - return sHasCamera; - } - - /** - * 是否有硬件menu - * - * @param context - * @return - */ - @SuppressWarnings("SimplifiableIfStatement") - public static boolean hasHardwareMenuKey(Context context) { - boolean flag; - if (Build.VERSION.SDK_INT < 11) - flag = true; - else if (Build.VERSION.SDK_INT >= 14) { - flag = ViewConfiguration.get(context).hasPermanentMenuKey(); - } else - flag = false; - return flag; - } - - - /** - * 判断是否存在pckName包 - * - * @param pckName - * @return - */ - public static boolean isPackageExist(Context context, String pckName) { - try { - PackageInfo pckInfo = context.getPackageManager() - .getPackageInfo(pckName, 0); - if (pckInfo != null) - return true; - } catch (PackageManager.NameNotFoundException ignored) { - } - return false; - } - - /** - * 判断 SD Card 是否 ready - * - * @return - */ - public static boolean isSdcardReady() { - return Environment.MEDIA_MOUNTED.equals(Environment - .getExternalStorageState()); - } - - - /** - * 设置全屏 - * - * @param context - */ - public static void setFullScreen(Context context) { - if (context instanceof Activity) { - Activity activity = (Activity) context; - WindowManager.LayoutParams params = activity.getWindow().getAttributes(); - params.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN; - activity.getWindow().setAttributes(params); - activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); - } - - } - - /** - * 取消全屏 - * - * @param context - */ - public static void cancelFullScreen(Context context) { - if (context instanceof Activity) { - Activity activity = (Activity) context; - WindowManager.LayoutParams params = activity.getWindow().getAttributes(); - params.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN); - activity.getWindow().setAttributes(params); - activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); - } - } - - /** - * 判断是否全屏 - * - * @param activity - * @return - */ - public static boolean isFullScreen(Activity activity) { - WindowManager.LayoutParams params = activity.getWindow().getAttributes(); - return (params.flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == WindowManager.LayoutParams.FLAG_FULLSCREEN; - } - - - public static boolean isElevationSupported() { - return Build.VERSION.SDK_INT >= 21; - } -} diff --git a/app/src/main/java/com/example/demo/systemui/QMUIStatusBarHelper.java b/app/src/main/java/com/example/demo/systemui/QMUIStatusBarHelper.java deleted file mode 100644 index 330358f..0000000 --- a/app/src/main/java/com/example/demo/systemui/QMUIStatusBarHelper.java +++ /dev/null @@ -1,423 +0,0 @@ -package com.example.demo.systemui; - -import android.annotation.TargetApi; -import android.app.Activity; -import android.content.Context; -import android.os.Build; -import android.support.annotation.ColorInt; -import android.support.annotation.IntDef; -import android.view.View; -import android.view.Window; -import android.view.WindowManager; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.reflect.Field; -import java.lang.reflect.Method; - - -/** - * @author cginechen - * @date 2016-03-27 - */ -public class QMUIStatusBarHelper { - - private final static int STATUSBAR_TYPE_DEFAULT = 0; - private final static int STATUSBAR_TYPE_MIUI = 1; - private final static int STATUSBAR_TYPE_FLYME = 2; - private final static int STATUSBAR_TYPE_ANDROID6 = 3; // Android 6.0 - private final static int STATUS_BAR_DEFAULT_HEIGHT_DP = 25; // 大部分状态栏都是25dp - // 在某些机子上存在不同的density值,所以增加两个虚拟值 - public static float sVirtualDensity = -1; - public static float sVirtualDensityDpi = -1; - private static int sStatusbarHeight = -1; - private static @StatusBarType - int mStatuBarType = STATUSBAR_TYPE_DEFAULT; - private static Integer sTransparentValue; - - public static void translucent(Activity activity) { - translucent(activity, 0x40000000); - } - - /** - * 沉浸式状态栏。 - * 支持 4.4 以上版本的 MIUI 和 Flyme,以及 5.0 以上版本的其他 Android。 - * - * @param activity 需要被设置沉浸式状态栏的 Activity。 - */ - @TargetApi(19) - public static void translucent(Activity activity, @ColorInt int colorOn5x) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - // 版本小于4.4,绝对不考虑沉浸式 - return; - } - // 小米和魅族4.4 以上版本支持沉浸式 - if (QMUIDeviceHelper.isMeizu() || QMUIDeviceHelper.isMIUI()) { - Window window = activity.getWindow(); - window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, - WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - return; - } - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - Window window = activity.getWindow(); - window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && supportTransclentStatusBar6()) { - // android 6以后可以改状态栏字体颜色,因此可以自行设置为透明 - // ZUK Z1是个另类,自家应用可以实现字体颜色变色,但没开放接口 - window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - window.setStatusBarColor(colorOn5x); - } else { - // android 5不能修改状态栏字体颜色,因此直接用FLAG_TRANSLUCENT_STATUS,nexus表现为半透明 - // 魅族和小米的表现如何? - // update: 部分手机运用FLAG_TRANSLUCENT_STATUS时背景不是半透明而是没有背景了。。。。。 -// window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - - // 采取setStatusBarColor的方式,部分机型不支持,那就纯黑了,保证状态栏图标可见 - window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - window.setStatusBarColor(colorOn5x); - } -// } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { -// // android4.4的默认是从上到下黑到透明,我们的背景是白色,很难看,因此只做魅族和小米的 -// } else if(Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR1){ -// // 如果app 为白色,需要更改状态栏颜色,因此不能让19一下支持透明状态栏 -// Window window = activity.getWindow(); -// Integer transparentValue = getStatusBarAPITransparentValue(activity); -// if(transparentValue != null) { -// window.getDecorView().setSystemUiVisibility(transparentValue); -// } - } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - Window mWindow = activity.getWindow(); - mWindow.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - SystemBarTintManager mTintManager = new SystemBarTintManager(activity); - mTintManager.setStatusBarTintEnabled(true); - mTintManager.setStatusBarTintColor(colorOn5x); - } - } - - /** - * 设置状态栏黑色字体图标, - * 支持 4.4 以上版本 MIUI 和 Flyme,以及 6.0 以上版本的其他 Android - * - * @param activity 需要被处理的 Activity - */ - public static boolean setStatusBarLightMode(Activity activity) { - if (activity == null) return false; - // 无语系列:ZTK C2016只能时间和电池图标变色。。。。 - if (QMUIDeviceHelper.isZTKC2016()) { - return false; - } - - if (mStatuBarType != STATUSBAR_TYPE_DEFAULT) { - return setStatusBarLightMode(activity, mStatuBarType); - } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - if (isMIUICustomStatusBarLightModeImpl() && MIUISetStatusBarLightMode(activity.getWindow(), true)) { - mStatuBarType = STATUSBAR_TYPE_MIUI; - return true; - } else if (FlymeSetStatusBarLightMode(activity.getWindow(), true)) { - mStatuBarType = STATUSBAR_TYPE_FLYME; - return true; - } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - Android6SetStatusBarLightMode(activity.getWindow(), true); - mStatuBarType = STATUSBAR_TYPE_ANDROID6; - return true; - } - } - return false; - } - - /** - * 已知系统类型时,设置状态栏黑色字体图标。 - * 支持 4.4 以上版本 MIUI 和 Flyme,以及 6.0 以上版本的其他 Android - * - * @param activity 需要被处理的 Activity - * @param type StatusBar 类型,对应不同的系统 - */ - private static boolean setStatusBarLightMode(Activity activity, @StatusBarType int type) { - if (type == STATUSBAR_TYPE_MIUI) { - return MIUISetStatusBarLightMode(activity.getWindow(), true); - } else if (type == STATUSBAR_TYPE_FLYME) { - return FlymeSetStatusBarLightMode(activity.getWindow(), true); - } else if (type == STATUSBAR_TYPE_ANDROID6) { - return Android6SetStatusBarLightMode(activity.getWindow(), true); - } - return false; - } - - - /** - * 设置状态栏白色字体图标 - * 支持 4.4 以上版本 MIUI 和 Flyme,以及 6.0 以上版本的其他 Android - */ - public static boolean setStatusBarDarkMode(Activity activity) { - if (activity == null) return false; - if (mStatuBarType == STATUSBAR_TYPE_DEFAULT) { - // 默认状态,不需要处理 - return true; - } - - if (mStatuBarType == STATUSBAR_TYPE_MIUI) { - return MIUISetStatusBarLightMode(activity.getWindow(), false); - } else if (mStatuBarType == STATUSBAR_TYPE_FLYME) { - return FlymeSetStatusBarLightMode(activity.getWindow(), false); - } else if (mStatuBarType == STATUSBAR_TYPE_ANDROID6) { - return Android6SetStatusBarLightMode(activity.getWindow(), false); - } - return true; - } - - @TargetApi(23) - private static int changeStatusBarModeRetainFlag(Window window, int out) { - out = retainSystemUiFlag(window, out, View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); - out = retainSystemUiFlag(window, out, View.SYSTEM_UI_FLAG_FULLSCREEN); - out = retainSystemUiFlag(window, out, View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); - out = retainSystemUiFlag(window, out, View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); - out = retainSystemUiFlag(window, out, View.SYSTEM_UI_FLAG_IMMERSIVE); - out = retainSystemUiFlag(window, out, View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); - out = retainSystemUiFlag(window, out, View.SYSTEM_UI_FLAG_LOW_PROFILE); - return out; - } - - public static int retainSystemUiFlag(Window window, int out, int type) { - int now = window.getDecorView().getSystemUiVisibility(); - if ((now & type) == type) { - out |= type; - } - return out; - } - - - /** - * 设置状态栏字体图标为深色,Android 6 - * - * @param window 需要设置的窗口 - * @param light 是否把状态栏字体及图标颜色设置为深色 - * @return boolean 成功执行返回true - */ - @TargetApi(23) - private static boolean Android6SetStatusBarLightMode(Window window, boolean light) { - View decorView = window.getDecorView(); - int systemUi = light ? View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR : View.SYSTEM_UI_FLAG_LAYOUT_STABLE; - systemUi = changeStatusBarModeRetainFlag(window, systemUi); - decorView.setSystemUiVisibility(systemUi); - if (QMUIDeviceHelper.isMIUIV9()) { - // MIUI 9 低于 6.0 版本依旧只能回退到以前的方案 - // https://github.com/QMUI/QMUI_Android/issues/160 - MIUISetStatusBarLightMode(window, light); - } - return true; - } - - /** - * 设置状态栏字体图标为深色,需要 MIUIV6 以上 - * - * @param window 需要设置的窗口 - * @param dark 是否把状态栏字体及图标颜色设置为深色 - * @return boolean 成功执行返回 true - */ - @SuppressWarnings("unchecked") - public static boolean MIUISetStatusBarLightMode(Window window, boolean dark) { - boolean result = false; - if (window != null) { - Class clazz = window.getClass(); - try { - int darkModeFlag; - Class layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams"); - Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE"); - darkModeFlag = field.getInt(layoutParams); - Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class); - if (dark) { - extraFlagField.invoke(window, darkModeFlag, darkModeFlag);//状态栏透明且黑色字体 - } else { - extraFlagField.invoke(window, 0, darkModeFlag);//清除黑色字体 - } - result = true; - } catch (Exception ignored) { - - } - } - return result; - } - - /** - * 更改状态栏图标、文字颜色的方案是否是MIUI自家的, MIUI9之后用回Android原生实现 - * 见小米开发文档说明:https://dev.mi.com/console/doc/detail?pId=1159 - */ - private static boolean isMIUICustomStatusBarLightModeImpl() { - if (QMUIDeviceHelper.isMIUIV9() && Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - return true; - } - return QMUIDeviceHelper.isMIUIV5() || QMUIDeviceHelper.isMIUIV6() || - QMUIDeviceHelper.isMIUIV7() || QMUIDeviceHelper.isMIUIV8(); - } - - /** - * 设置状态栏图标为深色和魅族特定的文字风格 - * 可以用来判断是否为 Flyme 用户 - * - * @param window 需要设置的窗口 - * @param dark 是否把状态栏字体及图标颜色设置为深色 - * @return boolean 成功执行返回true - */ - public static boolean FlymeSetStatusBarLightMode(Window window, boolean dark) { - - // flyme 在 6.2.0.0A 支持了 Android 官方的实现方案,旧的方案失效 - Android6SetStatusBarLightMode(window, dark); - - boolean result = false; - if (window != null) { - try { - WindowManager.LayoutParams lp = window.getAttributes(); - Field darkFlag = WindowManager.LayoutParams.class - .getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON"); - Field meizuFlags = WindowManager.LayoutParams.class - .getDeclaredField("meizuFlags"); - darkFlag.setAccessible(true); - meizuFlags.setAccessible(true); - int bit = darkFlag.getInt(null); - int value = meizuFlags.getInt(lp); - if (dark) { - value |= bit; - } else { - value &= ~bit; - } - meizuFlags.setInt(lp, value); - window.setAttributes(lp); - result = true; - } catch (Exception ignored) { - - } - } - return result; - } - - /** - * 获取是否全屏 - * - * @return 是否全屏 - */ - public static boolean isFullScreen(Activity activity) { - boolean ret = false; - try { - WindowManager.LayoutParams attrs = activity.getWindow().getAttributes(); - ret = (attrs.flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0; - } catch (Exception e) { - e.printStackTrace(); - } - return ret; - } - - /** - * API19之前透明状态栏:获取设置透明状态栏的system ui visibility的值,这是部分有提供接口的rom使用的 - * http://stackoverflow.com/questions/21865621/transparent-status-bar-before-4-4-kitkat - */ - public static Integer getStatusBarAPITransparentValue(Context context) { - if (sTransparentValue != null) { - return sTransparentValue; - } - String[] systemSharedLibraryNames = context.getPackageManager() - .getSystemSharedLibraryNames(); - String fieldName = null; - for (String lib : systemSharedLibraryNames) { - if ("touchwiz".equals(lib)) { - fieldName = "SYSTEM_UI_FLAG_TRANSPARENT_BACKGROUND"; - } else if (lib.startsWith("com.sonyericsson.navigationbar")) { - fieldName = "SYSTEM_UI_FLAG_TRANSPARENT"; - } - } - - if (fieldName != null) { - try { - Field field = View.class.getField(fieldName); - if (field != null) { - Class type = field.getType(); - if (type == int.class) { - sTransparentValue = field.getInt(null); - } - } - } catch (Exception ignored) { - } - } - return sTransparentValue; - } - - /** - * 检测 Android 6.0 是否可以启用 window.setStatusBarColor(Color.TRANSPARENT)。 - */ - public static boolean supportTransclentStatusBar6() { - return !(QMUIDeviceHelper.isZUKZ1() || QMUIDeviceHelper.isZTKC2016()); - } - - /** - * 获取状态栏的高度。 - */ - public static int getStatusbarHeight(Context context) { - if (sStatusbarHeight == -1) { - initStatusBarHeight(context); - } - return sStatusbarHeight; - } - - private static void initStatusBarHeight(Context context) { - Class clazz; - Object obj = null; - Field field = null; - try { - clazz = Class.forName("com.android.internal.R$dimen"); - obj = clazz.newInstance(); - if (QMUIDeviceHelper.isMeizu()) { - try { - field = clazz.getField("status_bar_height_large"); - } catch (Throwable t) { - t.printStackTrace(); - } - } - if (field == null) { - field = clazz.getField("status_bar_height"); - } - } catch (Throwable t) { - t.printStackTrace(); - } - if (field != null && obj != null) { - try { - int id = Integer.parseInt(field.get(obj).toString()); - sStatusbarHeight = context.getResources().getDimensionPixelSize(id); - } catch (Throwable t) { - t.printStackTrace(); - } - } - if (QMUIDeviceHelper.isTablet(context) - && sStatusbarHeight > QMUIDisplayHelper.dp2px(context, STATUS_BAR_DEFAULT_HEIGHT_DP)) { - //状态栏高度大于25dp的平板,状态栏通常在下方 - sStatusbarHeight = 0; - } else { - if (sStatusbarHeight <= 0 - || sStatusbarHeight > QMUIDisplayHelper.dp2px(context, STATUS_BAR_DEFAULT_HEIGHT_DP * 2)) { - //安卓默认状态栏高度为25dp,如果获取的状态高度大于2倍25dp的话,这个数值可能有问题,用回桌面定义的值从新获取。出现这种可能性较低,只有小部分手机出现 - if (sVirtualDensity == -1) { - sStatusbarHeight = QMUIDisplayHelper.dp2px(context, STATUS_BAR_DEFAULT_HEIGHT_DP); - } else { - sStatusbarHeight = (int) (STATUS_BAR_DEFAULT_HEIGHT_DP * sVirtualDensity + 0.5f); - } - } - } - } - - public static void setVirtualDensity(float density) { - sVirtualDensity = density; - } - - public static void setVirtualDensityDpi(float densityDpi) { - sVirtualDensityDpi = densityDpi; - } - - @IntDef({STATUSBAR_TYPE_DEFAULT, STATUSBAR_TYPE_MIUI, STATUSBAR_TYPE_FLYME, STATUSBAR_TYPE_ANDROID6}) - @Retention(RetentionPolicy.SOURCE) - private @interface StatusBarType { - } - -} diff --git a/app/src/main/java/com/example/demo/systemui/StatusBarView.java b/app/src/main/java/com/example/demo/systemui/StatusBarView.java deleted file mode 100644 index d32bcb0..0000000 --- a/app/src/main/java/com/example/demo/systemui/StatusBarView.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.example.demo.systemui; - -import android.content.Context; -import android.content.res.TypedArray; -import android.os.Build; -import android.support.annotation.ColorRes; -import android.support.annotation.Nullable; -import android.support.v4.content.ContextCompat; -import android.util.AttributeSet; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.LinearLayout; - -import com.effective.R; - -import java.lang.reflect.Field; - -/** - * 状态栏view - * Created by yummylau on 2017/9/09. - */ - -public class StatusBarView extends LinearLayout { - - @ColorRes - private int mStatusBarColor; - - public StatusBarView(Context context) { - this(context, null); - } - - public StatusBarView(Context context, @Nullable AttributeSet attrs) { - this(context, attrs, 0); - } - - public StatusBarView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - initView(attrs, defStyleAttr); - } - - private void initView(AttributeSet attrs, int defStyle) { - View view = LayoutInflater.from(getContext()).inflate(R.layout.view_status_bar_layout, this, true); - final TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.StatusBarView, defStyle, 0); - if (typedArray != null) { - mStatusBarColor = typedArray.getResourceId(R.styleable.StatusBarView_status_bar_color, R.color.colorPrimary); - } else { - mStatusBarColor = R.color.colorPrimary; - } - setBackgroundColor(ContextCompat.getColor(getContext(), mStatusBarColor)); - view.findViewById(R.id.status_bar).setMinimumHeight(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT ? getStatusBarHeight(getContext()) : 0); - } - - public void setColor(@ColorRes int statusBarColor) { - mStatusBarColor = statusBarColor; - setBackgroundColor(ContextCompat.getColor(getContext(), mStatusBarColor)); - } - - - public static int getStatusBarHeight(Context context) { - int sbar = 0; - try { - Class c = Class.forName("com.android.internal.R$dimen"); - Object obj = c.newInstance(); - Field field = c.getField("status_bar_height"); - int x = Integer.parseInt(field.get(obj).toString()); - sbar = context.getResources().getDimensionPixelSize(x); - } catch (Exception var7) { - var7.printStackTrace(); - } - return sbar; - } -} diff --git a/app/src/main/java/com/example/demo/systemui/StatusbarHelper.java b/app/src/main/java/com/example/demo/systemui/StatusbarHelper.java deleted file mode 100644 index 1774414..0000000 --- a/app/src/main/java/com/example/demo/systemui/StatusbarHelper.java +++ /dev/null @@ -1,122 +0,0 @@ -package com.example.demo.systemui; - -import android.annotation.TargetApi; -import android.app.Activity; -import android.graphics.Color; -import android.os.Build; -import android.support.annotation.ColorInt; -import android.view.View; -import android.view.Window; -import android.view.WindowManager; - - -/** - * 状态栏 统一处理入口 - * 第三方库持续更新,作为与应用层交互类 - * 沉浸式策略:支持 4.4 以上版本的 MIUI 和 Flyme,以及 5.0 以上版本的其他 Android - * 设置状态栏黑色字体图标:支持 4.4 以上版本 MIUI 和 Flyme,以及 6.0 以上版本的其他 Android - * 设置状态栏白色字体图标:支持 4.4 以上版本 MIUI 和 Flyme,以及 6.0 以上版本的其他 Android - *

- * 分离主题色和状态栏颜色,主题色主要用于控制状态栏字体是否发生变化,比如说状态栏透明情况下,主题色由其页面底色决定,可以通过场景理解。 - * - * 业务场景场景设置: - * 1. 状态栏和标题栏都为纯色,技术上实现可分为两种,一种是状态栏透明,标题栏的高度增加状态栏高度,第二种是状态栏着色,标题栏与状态栏同色,高度为业务高度,此时 themeColor 和 statusBarColor一样 - * 2. 状态栏和标题栏不为纯色(比如是一张背景图),技术上实现为状态栏透明,底色用一张图处理,是否改变状态栏字体由图片的颜色来决定themeColor - * - * Email yummyl.lau@gmail.com - * Created by yummylau on 2018/01/25. - */ - -public class StatusbarHelper { - - public static void translucentStatusBar(Activity activity) { - QMUIStatusBarHelper.translucent(activity); - } - - public static void setStatusBarColor(Activity activity, - int statusBarColor, @ColorInt int themeColor) { - colorStatusBar(activity, statusBarColor); - if (isNearWhiteColor(themeColor)) { - QMUIStatusBarHelper.setStatusBarLightMode(activity); - } else { - QMUIStatusBarHelper.setStatusBarDarkMode(activity); - } - } - - public static void setStatusBarColor(Activity activity, @ColorInt int statusBarColor, boolean isNearWhiteColor) { - colorStatusBar(activity, statusBarColor); - if (isNearWhiteColor) { - QMUIStatusBarHelper.setStatusBarLightMode(activity); - } else { - QMUIStatusBarHelper.setStatusBarDarkMode(activity); - } - } - - public static void setStatusBarColor(Activity activity, @ColorInt int statusBarColor) { - if (isNearWhiteColor(statusBarColor)) { - if (QMUIStatusBarHelper.setStatusBarLightMode(activity)) { - colorStatusBar(activity, statusBarColor); - } - } else { - if (QMUIStatusBarHelper.setStatusBarDarkMode(activity)) { - colorStatusBar(activity, statusBarColor); - } - } - } - - @TargetApi(19) - private static void colorStatusBar(Activity activity, @ColorInt int statusBarColor) { - // 部分三星机型在window.getDecorView() NPE 崩溃,可能是此时Activity onCreate,部分drawable为空 - try { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - // 版本小于4.4,绝对不考虑沉浸式 - return; - } - // 小米和魅族4.4 以上版本支持沉浸式 - if (QMUIDeviceHelper.isMeizu() || QMUIDeviceHelper.isMIUI()) { - Window window = activity.getWindow(); - window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, - WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - return; - } - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - Window window = activity.getWindow(); - window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && QMUIStatusBarHelper.supportTransclentStatusBar6()) { - // android 6以后可以改状态栏字体颜色,因此可以自行设置为透明 - // ZUK Z1是个另类,自家应用可以实现字体颜色变色,但没开放接口 - window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - window.setStatusBarColor(statusBarColor); - } else { - window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - window.setStatusBarColor(statusBarColor); - } - } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - Window mWindow = activity.getWindow(); - mWindow.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - SystemBarTintManager mTintManager = new SystemBarTintManager(activity); - mTintManager.setStatusBarTintEnabled(true); - mTintManager.setStatusBarTintColor(statusBarColor); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - - public static boolean isNearWhiteColor(@ColorInt int color) { - int alpha = Color.alpha(color); - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - return alpha >= 255 * 0.7 - && red >= 255 * 0.7 - && green >= 255 * 0.7 - && blue >= 255 * 0.7; - } - -} diff --git a/app/src/main/java/com/example/demo/systemui/SystemBarTintManager.java b/app/src/main/java/com/example/demo/systemui/SystemBarTintManager.java deleted file mode 100755 index 43a6249..0000000 --- a/app/src/main/java/com/example/demo/systemui/SystemBarTintManager.java +++ /dev/null @@ -1,561 +0,0 @@ -/* - * Copyright (C) 2013 readyState Software Ltd - * - * 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.example.demo.systemui; - -import android.annotation.SuppressLint; -import android.annotation.TargetApi; -import android.app.Activity; -import android.content.Context; -import android.content.res.Configuration; -import android.content.res.Resources; -import android.content.res.TypedArray; -import android.graphics.drawable.Drawable; -import android.os.Build; -import android.util.DisplayMetrics; -import android.util.TypedValue; -import android.view.Gravity; -import android.view.View; -import android.view.ViewConfiguration; -import android.view.ViewGroup; -import android.view.Window; -import android.view.WindowManager; -import android.widget.FrameLayout.LayoutParams; - -import java.lang.reflect.Method; - -/** - * Class to manage status and navigation bar tint effects when using KitKat - * translucent system UI modes. - */ -@SuppressWarnings("unchecked") -public class SystemBarTintManager { - - static { - // Android allows a system property to override the presence of the navigation bar. - // Used by the emulator. - // See https://github.com/android/platform_frameworks_base/blob/master/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java#L1076 - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - try { - Class c = Class.forName("android.os.SystemProperties"); - Method m = c.getDeclaredMethod("get", String.class); - m.setAccessible(true); - sNavBarOverride = (String) m.invoke(null, "qemu.hw.mainkeys"); - } catch (Throwable e) { - sNavBarOverride = null; - } - } - } - - /** - * The default system bar tint color value. - */ - public static final int DEFAULT_TINT_COLOR = 0x99000000; - - private static String sNavBarOverride; - - private final SystemBarConfig mConfig; - private boolean mStatusBarAvailable; - private boolean mNavBarAvailable; - private boolean mStatusBarTintEnabled; - private boolean mNavBarTintEnabled; - private View mStatusBarTintView; - private View mNavBarTintView; - - /** - * Constructor. Call this in the host activity onCreate method after its - * content view has been set. You should always create new instances when - * the host activity is recreated. - * - * @param activity The host activity. - */ - @SuppressLint("ResourceType") - @TargetApi(19) - public SystemBarTintManager(Activity activity) { - - Window win = activity.getWindow(); - ViewGroup decorViewGroup = (ViewGroup) win.getDecorView(); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - // check theme attrs - int[] attrs = {android.R.attr.windowTranslucentStatus, android.R.attr.windowTranslucentNavigation}; - TypedArray a = activity.obtainStyledAttributes(attrs); - try { - mStatusBarAvailable = a.getBoolean(0, false); - mNavBarAvailable = a.getBoolean(1, false); - } finally { - a.recycle(); - } - - // check window flags - WindowManager.LayoutParams winParams = win.getAttributes(); - int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; - if ((winParams.flags & bits) != 0) { - mStatusBarAvailable = true; - } - bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION; - if ((winParams.flags & bits) != 0) { - mNavBarAvailable = true; - } - } - - mConfig = new SystemBarConfig(activity, mStatusBarAvailable, mNavBarAvailable); - // device might not have virtual navigation keys - if (!mConfig.hasNavigtionBar()) { - mNavBarAvailable = false; - } - - if (mStatusBarAvailable) { - setupStatusBarView(activity, decorViewGroup); - } - if (mNavBarAvailable) { - setupNavBarView(activity, decorViewGroup); - } - - } - - /** - * Enable tinting of the system status bar. - * If the platform is running Jelly Bean or earlier, or translucent system - * UI modes have not been enabled in either the theme or via window flags, - * then this method does nothing. - * - * @param enabled True to enable tinting, false to disable it (default). - */ - public void setStatusBarTintEnabled(boolean enabled) { - mStatusBarTintEnabled = enabled; - if (mStatusBarAvailable) { - mStatusBarTintView.setVisibility(enabled ? View.VISIBLE : View.GONE); - } - } - - /** - * Enable tinting of the system navigation bar. - * If the platform does not have soft navigation keys, is running Jelly Bean - * or earlier, or translucent system UI modes have not been enabled in either - * the theme or via window flags, then this method does nothing. - * - * @param enabled True to enable tinting, false to disable it (default). - */ - public void setNavigationBarTintEnabled(boolean enabled) { - mNavBarTintEnabled = enabled; - if (mNavBarAvailable) { - mNavBarTintView.setVisibility(enabled ? View.VISIBLE : View.GONE); - } - } - - /** - * Apply the specified color tint to all system UI bars. - * - * @param color The color of the background tint. - */ - public void setTintColor(int color) { - setStatusBarTintColor(color); - setNavigationBarTintColor(color); - } - - /** - * Apply the specified drawable or color resource to all system UI bars. - * - * @param res The identifier of the resource. - */ - public void setTintResource(int res) { - setStatusBarTintResource(res); - setNavigationBarTintResource(res); - } - - /** - * Apply the specified drawable to all system UI bars. - * - * @param drawable The drawable to use as the background, or null to remove it. - */ - public void setTintDrawable(Drawable drawable) { - setStatusBarTintDrawable(drawable); - setNavigationBarTintDrawable(drawable); - } - - /** - * Apply the specified alpha to all system UI bars. - * - * @param alpha The alpha to use - */ - public void setTintAlpha(float alpha) { - setStatusBarAlpha(alpha); - setNavigationBarAlpha(alpha); - } - - /** - * Apply the specified color tint to the system status bar. - * - * @param color The color of the background tint. - */ - public void setStatusBarTintColor(int color) { - if (mStatusBarAvailable) { - mStatusBarTintView.setBackgroundColor(color); - } - } - - /** - * Apply the specified drawable or color resource to the system status bar. - * - * @param res The identifier of the resource. - */ - public void setStatusBarTintResource(int res) { - if (mStatusBarAvailable) { - mStatusBarTintView.setBackgroundResource(res); - } - } - - /** - * Apply the specified drawable to the system status bar. - * - * @param drawable The drawable to use as the background, or null to remove it. - */ - @SuppressWarnings("deprecation") - public void setStatusBarTintDrawable(Drawable drawable) { - if (mStatusBarAvailable) { - mStatusBarTintView.setBackgroundDrawable(drawable); - } - } - - /** - * Apply the specified alpha to the system status bar. - * - * @param alpha The alpha to use - */ - @TargetApi(11) - public void setStatusBarAlpha(float alpha) { - if (mStatusBarAvailable && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - mStatusBarTintView.setAlpha(alpha); - } - } - - /** - * Apply the specified color tint to the system navigation bar. - * - * @param color The color of the background tint. - */ - public void setNavigationBarTintColor(int color) { - if (mNavBarAvailable) { - mNavBarTintView.setBackgroundColor(color); - } - } - - /** - * Apply the specified drawable or color resource to the system navigation bar. - * - * @param res The identifier of the resource. - */ - public void setNavigationBarTintResource(int res) { - if (mNavBarAvailable) { - mNavBarTintView.setBackgroundResource(res); - } - } - - /** - * Apply the specified drawable to the system navigation bar. - * - * @param drawable The drawable to use as the background, or null to remove it. - */ - @SuppressWarnings("deprecation") - public void setNavigationBarTintDrawable(Drawable drawable) { - if (mNavBarAvailable) { - mNavBarTintView.setBackgroundDrawable(drawable); - } - } - - /** - * Apply the specified alpha to the system navigation bar. - * - * @param alpha The alpha to use - */ - @TargetApi(11) - public void setNavigationBarAlpha(float alpha) { - if (mNavBarAvailable && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - mNavBarTintView.setAlpha(alpha); - } - } - - /** - * Get the system bar configuration. - * - * @return The system bar configuration for the current device configuration. - */ - public SystemBarConfig getConfig() { - return mConfig; - } - - /** - * Is tinting enabled for the system status bar? - * - * @return True if enabled, False otherwise. - */ - public boolean isStatusBarTintEnabled() { - return mStatusBarTintEnabled; - } - - /** - * Is tinting enabled for the system navigation bar? - * - * @return True if enabled, False otherwise. - */ - public boolean isNavBarTintEnabled() { - return mNavBarTintEnabled; - } - - private void setupStatusBarView(Context context, ViewGroup decorViewGroup) { - mStatusBarTintView = new View(context); - LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, mConfig.getStatusBarHeight()); - params.gravity = Gravity.TOP; - if (mNavBarAvailable && !mConfig.isNavigationAtBottom()) { - params.rightMargin = mConfig.getNavigationBarWidth(); - } - mStatusBarTintView.setLayoutParams(params); - mStatusBarTintView.setBackgroundColor(DEFAULT_TINT_COLOR); - mStatusBarTintView.setVisibility(View.GONE); - decorViewGroup.addView(mStatusBarTintView); - } - - private void setupNavBarView(Context context, ViewGroup decorViewGroup) { - mNavBarTintView = new View(context); - LayoutParams params; - if (mConfig.isNavigationAtBottom()) { - params = new LayoutParams(LayoutParams.MATCH_PARENT, mConfig.getNavigationBarHeight()); - params.gravity = Gravity.BOTTOM; - } else { - params = new LayoutParams(mConfig.getNavigationBarWidth(), LayoutParams.MATCH_PARENT); - params.gravity = Gravity.RIGHT; - } - mNavBarTintView.setLayoutParams(params); - mNavBarTintView.setBackgroundColor(DEFAULT_TINT_COLOR); - mNavBarTintView.setVisibility(View.GONE); - decorViewGroup.addView(mNavBarTintView); - } - - /** - * Class which describes system bar sizing and other characteristics for the current - * device configuration. - */ - public static class SystemBarConfig { - - private static final String STATUS_BAR_HEIGHT_RES_NAME = "status_bar_height"; - private static final String NAV_BAR_HEIGHT_RES_NAME = "navigation_bar_height"; - private static final String NAV_BAR_HEIGHT_LANDSCAPE_RES_NAME = "navigation_bar_height_landscape"; - private static final String NAV_BAR_WIDTH_RES_NAME = "navigation_bar_width"; - private static final String SHOW_NAV_BAR_RES_NAME = "config_showNavigationBar"; - - private final boolean mTranslucentStatusBar; - private final boolean mTranslucentNavBar; - private final int mStatusBarHeight; - private final int mActionBarHeight; - private final boolean mHasNavigationBar; - private final int mNavigationBarHeight; - private final int mNavigationBarWidth; - private final boolean mInPortrait; - private final float mSmallestWidthDp; - - private SystemBarConfig(Activity activity, boolean translucentStatusBar, boolean traslucentNavBar) { - Resources res = activity.getResources(); - mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT); - mSmallestWidthDp = getSmallestWidthDp(activity); - mStatusBarHeight = getInternalDimensionSize(res, STATUS_BAR_HEIGHT_RES_NAME); - mActionBarHeight = getActionBarHeight(activity); - mNavigationBarHeight = getNavigationBarHeight(activity); - mNavigationBarWidth = getNavigationBarWidth(activity); - mHasNavigationBar = (mNavigationBarHeight > 0); - mTranslucentStatusBar = translucentStatusBar; - mTranslucentNavBar = traslucentNavBar; - } - - @TargetApi(14) - private int getActionBarHeight(Context context) { - int result = 0; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - TypedValue tv = new TypedValue(); - context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true); - result = TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics()); - } - return result; - } - - @TargetApi(14) - private int getNavigationBarHeight(Context context) { - Resources res = context.getResources(); - int result = 0; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - if (hasNavBar(context)) { - String key; - if (mInPortrait) { - key = NAV_BAR_HEIGHT_RES_NAME; - } else { - key = NAV_BAR_HEIGHT_LANDSCAPE_RES_NAME; - } - return getInternalDimensionSize(res, key); - } - } - return result; - } - - @TargetApi(14) - private int getNavigationBarWidth(Context context) { - Resources res = context.getResources(); - int result = 0; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - if (hasNavBar(context)) { - return getInternalDimensionSize(res, NAV_BAR_WIDTH_RES_NAME); - } - } - return result; - } - - @TargetApi(14) - private boolean hasNavBar(Context context) { - Resources res = context.getResources(); - int resourceId = res.getIdentifier(SHOW_NAV_BAR_RES_NAME, "bool", "android"); - if (resourceId != 0) { - boolean hasNav = res.getBoolean(resourceId); - // check override flag (see static block) - if ("1".equals(sNavBarOverride)) { - hasNav = false; - } else if ("0".equals(sNavBarOverride)) { - hasNav = true; - } - return hasNav; - } else { // fallback - return !ViewConfiguration.get(context).hasPermanentMenuKey(); - } - } - - private int getInternalDimensionSize(Resources res, String key) { - int result = 0; - int resourceId = res.getIdentifier(key, "dimen", "android"); - if (resourceId > 0) { - result = res.getDimensionPixelSize(resourceId); - } - return result; - } - - @SuppressLint("NewApi") - private float getSmallestWidthDp(Activity activity) { - DisplayMetrics metrics = new DisplayMetrics(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - activity.getWindowManager().getDefaultDisplay().getRealMetrics(metrics); - } else { - // TODO this is not correct, but we don't really care pre-kitkat - activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); - } - float widthDp = metrics.widthPixels / metrics.density; - float heightDp = metrics.heightPixels / metrics.density; - return Math.min(widthDp, heightDp); - } - - /** - * Should a navigation bar appear at the bottom of the screen in the current - * device configuration? A navigation bar may appear on the right side of - * the screen in certain configurations. - * - * @return True if navigation should appear at the bottom of the screen, False otherwise. - */ - public boolean isNavigationAtBottom() { - return (mSmallestWidthDp >= 600 || mInPortrait); - } - - /** - * Get the height of the system status bar. - * - * @return The height of the status bar (in pixels). - */ - public int getStatusBarHeight() { - return mStatusBarHeight; - } - - /** - * Get the height of the action bar. - * - * @return The height of the action bar (in pixels). - */ - public int getActionBarHeight() { - return mActionBarHeight; - } - - /** - * Does this device have a system navigation bar? - * - * @return True if this device uses soft key navigation, False otherwise. - */ - public boolean hasNavigtionBar() { - return mHasNavigationBar; - } - - /** - * Get the height of the system navigation bar. - * - * @return The height of the navigation bar (in pixels). If the device does not have - * soft navigation keys, this will always return 0. - */ - public int getNavigationBarHeight() { - return mNavigationBarHeight; - } - - /** - * Get the width of the system navigation bar when it is placed vertically on the screen. - * - * @return The width of the navigation bar (in pixels). If the device does not have - * soft navigation keys, this will always return 0. - */ - public int getNavigationBarWidth() { - return mNavigationBarWidth; - } - - /** - * Get the layout inset for any system UI that appears at the top of the screen. - * - * @param withActionBar True to include the height of the action bar, False otherwise. - * @return The layout inset (in pixels). - */ - public int getPixelInsetTop(boolean withActionBar) { - return (mTranslucentStatusBar ? mStatusBarHeight : 0) + (withActionBar ? mActionBarHeight : 0); - } - - /** - * Get the layout inset for any system UI that appears at the bottom of the screen. - * - * @return The layout inset (in pixels). - */ - public int getPixelInsetBottom() { - if (mTranslucentNavBar && isNavigationAtBottom()) { - return mNavigationBarHeight; - } else { - return 0; - } - } - - /** - * Get the layout inset for any system UI that appears at the right of the screen. - * - * @return The layout inset (in pixels). - */ - public int getPixelInsetRight() { - if (mTranslucentNavBar && !isNavigationAtBottom()) { - return mNavigationBarWidth; - } else { - return 0; - } - } - - } - -} diff --git a/app/src/main/java/com/example/demo/util/DisplayUtils.java b/app/src/main/java/com/example/demo/util/DisplayUtils.java deleted file mode 100644 index d59c27c..0000000 --- a/app/src/main/java/com/example/demo/util/DisplayUtils.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.example.demo.util; - -import android.app.Activity; -import android.content.Context; -import android.content.pm.ActivityInfo; -import android.content.res.Configuration; -import android.support.v4.content.ContextCompat; -import android.util.DisplayMetrics; -import android.util.Pair; -import android.util.Size; - -import java.lang.reflect.Field; - -/** - * Created by yummyLau on 18-7-11 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -public class DisplayUtils { - - public static int dip2px(Context context, float dipValue) { - final float scale = context.getResources().getDisplayMetrics().density; - return (int) (dipValue * scale + 0.5f); - } - - public static Pair getScreenSize(Context context) { - DisplayMetrics dm = context.getResources().getDisplayMetrics(); - return new Pair(dm.widthPixels, dm.heightPixels); - } - - public static boolean isPortrait(Context context){ - return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; - - } - - public static void checkoutOrientation(Activity activity) { - activity.setRequestedOrientation(isPortrait(activity) ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); - } - - public static int getStatusBarHeight(Context context) { - int result = 0; - try { - Class c = Class.forName("com.android.internal.R$dimen"); - Object o = c.newInstance(); - Field field = c.getField("status_bar_height"); - int x = (Integer)field.get(o); - result = context.getResources().getDimensionPixelSize(x); - } catch (Exception var6) { - var6.printStackTrace(); - } - - if (result == 0) { - result = dip2px(context, 25.0F); - } - - return result; - } -} diff --git a/app/src/main/kotlin/com/example/demo/scene/api/ContentActivity.kt b/app/src/main/kotlin/com/example/demo/scene/api/ContentActivity.kt deleted file mode 100644 index 20ed7e4..0000000 --- a/app/src/main/kotlin/com/example/demo/scene/api/ContentActivity.kt +++ /dev/null @@ -1,183 +0,0 @@ -package com.example.demo.scene.api - -import android.content.Context -import android.content.Intent -import android.os.Bundle -import android.support.v7.app.AppCompatActivity -import android.support.v7.widget.LinearLayoutManager -import android.text.TextUtils -import android.util.Log -import android.view.View -import android.view.Window -import android.view.WindowManager -import android.widget.EditText -import android.widget.TextView -import android.widget.Toast -import com.effective.R -import com.effective.android.panel.PanelSwitchHelper -import com.effective.android.panel.view.panel.PanelView -import com.example.demo.Constants -import com.example.demo.anno.ApiContentType -import com.example.demo.scene.chat.adapter.ChatAdapter -import com.example.demo.scene.chat.adapter.ChatInfo -import com.example.demo.scene.chat.emotion.EmotionPagerView -import com.example.demo.scene.chat.emotion.Emotions -import com.example.demo.scene.chat.view.AutoHidePanelRecyclerView -import com.example.demo.util.DisplayUtils -import com.rd.PageIndicatorView - -/** - * 内容区域支持多种布局,不再限定为线性布局 - * 框架提供 ContentLinearContainer,ContentRelativeContainer,ContentFrameContainer ,可供开发者替换对应的原生布局类 - * 同时还可自主实现 IContentContainer 接口自定义业务的 Container,[CusContentContainer] 提供了约束布局实现 - * Created by yummyLau on 2020/05/07 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -class ContentActivity : AppCompatActivity() { - private var mHelper: PanelSwitchHelper? = null - private lateinit var mAdapter: ChatAdapter - private var mLinearLayoutManager: LinearLayoutManager? = null - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - supportRequestWindowFeature(Window.FEATURE_NO_TITLE) - when (intent.getIntExtra(Constants.KEY_CONTENT_TYPE, ApiContentType.CUS)) { - ApiContentType.Linear -> { - setContentView(R.layout.activity_api_content_linear_layout) - findViewById(R.id.title).text = "线性布局" - } - ApiContentType.Frame -> { - setContentView(R.layout.activity_api_content_frame_layout) - findViewById(R.id.title).text = "帧布局" - } - ApiContentType.Relative -> { - setContentView(R.layout.activity_api_content_relative_layout) - findViewById(R.id.title).text = "相对布局" - } - else -> { - setContentView(R.layout.activity_api_content_cus_layout) - findViewById(R.id.title).text = "自定义布局" - } - } - initView() - } - - private val recyclerView: AutoHidePanelRecyclerView - get() = findViewById(R.id.recycler_view) as AutoHidePanelRecyclerView - - private val sendView: View - get() = findViewById(R.id.send) - - private val editView: EditText - get() = findViewById(R.id.edit_text) - - private val emotionView: View - get() = findViewById(R.id.emotion_btn) - - private fun initView() { - mLinearLayoutManager = LinearLayoutManager(this) - recyclerView.layoutManager = mLinearLayoutManager - mAdapter = ChatAdapter(this, 50) - recyclerView.adapter = mAdapter - sendView.setOnClickListener(View.OnClickListener { - val content = editView.text.toString() - if (TextUtils.isEmpty(content)) { - Toast.makeText(this@ContentActivity, "当前没有输入", Toast.LENGTH_SHORT).show() - return@OnClickListener - } - mAdapter.insertInfo(ChatInfo.CREATE(content)) - editView.text = null - scrollToBottom() - }) - } - - private fun scrollToBottom() { - editView.post{ mLinearLayoutManager?.scrollToPosition(mAdapter.itemCount - 1) } - } - - override fun onStart() { - super.onStart() - if (mHelper == null) { - mHelper = PanelSwitchHelper.Builder(this) //可选 - .addKeyboardStateListener { - onKeyboardChange { visible, height -> - Log.d(TAG, "系统键盘是否可见 : $visible ,高度为:$height") - } - } - .addEditTextFocusChangeListener { - onFocusChange { _, hasFocus -> - Log.d(TAG, "输入框是否获得焦点 : $hasFocus") - if (hasFocus) { - scrollToBottom() - } - } - } - .addViewClickListener { - onClickBefore { - when (it!!.id) { - R.id.edit_text, R.id.add_btn, R.id.emotion_btn -> { - scrollToBottom() - } - } - Log.d(TAG, "点击了View : $it") - } - } - .addPanelChangeListener { - onKeyboard { - Log.d(TAG, "唤起系统输入法") - emotionView.isSelected = false - scrollToBottom() - } - onNone { - Log.d(TAG, "隐藏所有面板") - emotionView.isSelected = false - } - onPanel { - Log.d(TAG, "唤起面板 : $it") - if (it is PanelView) { - emotionView.isSelected = it.id == R.id.panel_emotion - scrollToBottom() - } - } - onPanelSizeChange { panelView, _, _, _, width, height -> - if (panelView is PanelView) { - when (panelView.id) { - R.id.panel_emotion -> { - val pagerView: EmotionPagerView = findViewById(R.id.view_pager) - val viewPagerSize = height - DisplayUtils.dip2px(this@ContentActivity, 30f) - pagerView.buildEmotionViews( - findViewById(R.id.pageIndicatorView) as PageIndicatorView, - editView, - Emotions.getEmotions(), width, viewPagerSize) - } - R.id.panel_addition -> { - } - } - } - } - } - .logTrack(true) //output log - .build() - } - findViewById(R.id.recycler_view).setPanelSwitchHelper(mHelper) - } - - override fun onBackPressed() { - if (mHelper != null && mHelper!!.hookSystemBackByPanelSwitcher()) { - return - } - super.onBackPressed() - } - - companion object { - @JvmStatic - fun start(context: Context, @ApiContentType type: Int) { - val intent = Intent(context, ContentActivity::class.java) - intent.putExtra(Constants.KEY_CONTENT_TYPE, type) - context.startActivity(intent) - } - - private const val TAG = "ContentActivity" - } -} \ No newline at end of file diff --git a/app/src/main/kotlin/com/example/demo/scene/api/CusContentContainer.kt b/app/src/main/kotlin/com/example/demo/scene/api/CusContentContainer.kt deleted file mode 100644 index 1f2d433..0000000 --- a/app/src/main/kotlin/com/example/demo/scene/api/CusContentContainer.kt +++ /dev/null @@ -1,80 +0,0 @@ -package com.example.demo.scene.api - -import android.content.Context -import android.support.annotation.IdRes -import android.support.constraint.ConstraintLayout -import android.util.AttributeSet -import android.view.MotionEvent -import android.view.View -import com.effective.R -import com.effective.android.panel.interfaces.ContentScrollMeasurer -import com.effective.android.panel.view.content.ContentContainerImpl -import com.effective.android.panel.view.content.IContentContainer -import com.effective.android.panel.view.content.IInputAction -import com.effective.android.panel.view.content.IResetAction - -/** - * 实现IContentContainer接口,可参考 - * [com.effective.android.panel.view.content.FrameContentContainer] 等库提供的模版实现基础的container容器 - * demo已约束布局为例子,使用者按需扩展就可以了 - * Created by yummyLau on 2020/05/07 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -class CusContentContainer @JvmOverloads constructor(context: Context?, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : ConstraintLayout(context, attrs, defStyleAttr), IContentContainer { - @IdRes - private var editTextId = 0 - - @IdRes - private var resetViewId = 0 - private var autoResetByOnTouch: Boolean = true - private lateinit var contentContainer: ContentContainerImpl - private fun initView(attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) { - val typedArray = context.obtainStyledAttributes(attrs, R.styleable.CusContentContainer, defStyleAttr, 0) - editTextId = typedArray.getResourceId(R.styleable.CusContentContainer_edit_view, -1) - resetViewId = typedArray.getResourceId(R.styleable.CusContentContainer_auto_reset_area, -1) - autoResetByOnTouch = typedArray.getBoolean(R.styleable.CusContentContainer_auto_reset_enable, autoResetByOnTouch) - typedArray.recycle() - } - - override fun onFinishInflate() { - super.onFinishInflate() - contentContainer = ContentContainerImpl(this, autoResetByOnTouch, editTextId, resetViewId) - val editText = getInputActionImpl().getFullScreenPixelInputView() - addView(editText, 0, LayoutParams(1, 1)) - } - - override fun layoutContainer(l: Int, t: Int, r: Int, b: Int, - contentScrollMeasurers: MutableList, defaultScrollHeight: Int, canScrollOutsize: Boolean, - reset: Boolean) { - contentContainer.layoutContainer(l, t, r, b, contentScrollMeasurers, defaultScrollHeight, canScrollOutsize, reset) - } - - override fun findTriggerView(id: Int): View? { - return contentContainer.findTriggerView(id) - } - - override fun changeContainerHeight(targetHeight: Int) { - contentContainer.changeContainerHeight(targetHeight) - } - - override fun dispatchTouchEvent(ev: MotionEvent?): Boolean { - val onTouchTrue = super.dispatchTouchEvent(ev) - val hookResult = getResetActionImpl().hookDispatchTouchEvent(ev, onTouchTrue) - return hookResult or onTouchTrue - } - - override fun onTouchEvent(event: MotionEvent?): Boolean { - val onTouchBySelf = super.onTouchEvent(event) - val hookResult = getResetActionImpl().hookOnTouchEvent(event) - return onTouchBySelf or hookResult - } - - override fun getInputActionImpl(): IInputAction = contentContainer.getInputActionImpl() - - override fun getResetActionImpl(): IResetAction = contentContainer.getResetActionImpl() - - init { - initView(attrs, defStyleAttr, 0) - } -} \ No newline at end of file diff --git a/app/src/main/kotlin/com/example/demo/scene/api/CusPanelActivity.kt b/app/src/main/kotlin/com/example/demo/scene/api/CusPanelActivity.kt deleted file mode 100644 index 836b43d..0000000 --- a/app/src/main/kotlin/com/example/demo/scene/api/CusPanelActivity.kt +++ /dev/null @@ -1,125 +0,0 @@ -package com.example.demo.scene.api - -import android.os.Bundle -import android.support.v7.app.AppCompatActivity -import android.text.TextUtils -import android.util.Log -import android.view.View -import android.view.Window -import android.widget.EditText -import android.widget.TextView -import android.widget.Toast -import com.effective.R -import com.effective.android.panel.PanelSwitchHelper -import com.effective.android.panel.view.panel.PanelView -import com.example.demo.scene.chat.emotion.EmotionPagerView -import com.example.demo.scene.chat.emotion.Emotions -import com.example.demo.scene.chat.view.AutoHidePanelRecyclerView -import com.example.demo.util.DisplayUtils -import com.rd.PageIndicatorView - -/** - * 处理可以使用默认的 PanelView,也可以通过继承 IPanelView 来实现自己的 PanelView。 - * 使用自定义面板 - * created by yummylau on 2020/06/06 - */ -class CusPanelActivity : AppCompatActivity() { - private var mHelper: PanelSwitchHelper? = null - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - supportRequestWindowFeature(Window.FEATURE_NO_TITLE) - setContentView(R.layout.activity_api_cus_panel_layout) - findViewById(R.id.title).text = "继承 IPanelView 实现 PanelView,点击左下角 + 试试吧" - initView() - } - - private val sendView: View - get() = findViewById(R.id.send) - - private val editView: EditText - get() = findViewById(R.id.edit_text) - - private val emotionView: View - get() = findViewById(R.id.emotion_btn) - - private fun initView() { - sendView.setOnClickListener(View.OnClickListener { - val content = editView.text.toString() - if (TextUtils.isEmpty(content)) { - Toast.makeText(this@CusPanelActivity, "当前没有输入", Toast.LENGTH_SHORT).show() - return@OnClickListener - } - editView.text = null - }) - } - - override fun onStart() { - super.onStart() - if (mHelper == null) { - mHelper = PanelSwitchHelper.Builder(this) //可选 - .addKeyboardStateListener { - onKeyboardChange { visible, height -> - Log.d(TAG, "系统键盘是否可见 : $visible ,高度为:$height") - } - } - .addEditTextFocusChangeListener { - onFocusChange { _, hasFocus -> - Log.d(TAG, "输入框是否获得焦点 : $hasFocus") - } - } - .addViewClickListener { - onClickBefore { - Log.d(TAG, "点击了View : $it") - } - } - .addPanelChangeListener { - onKeyboard { - Log.d(TAG, "唤起系统输入法") - emotionView.isSelected = false - } - onNone { - Log.d(TAG, "隐藏所有面板") - emotionView.isSelected = false - } - onPanel { - Log.d(TAG, "唤起面板 : $it") - if (it is PanelView) { - emotionView.isSelected = it.id == R.id.panel_emotion - } - } - onPanelSizeChange { panelView, _, _, _, width, height -> - if (panelView is PanelView) { - when (panelView.id) { - R.id.panel_emotion -> { - val pagerView: EmotionPagerView = findViewById(R.id.view_pager) - val viewPagerSize = height - DisplayUtils.dip2px(this@CusPanelActivity, 30f) - pagerView.buildEmotionViews( - findViewById(R.id.pageIndicatorView) as PageIndicatorView, - editView, - Emotions.getEmotions(), width, viewPagerSize) - } - R.id.panel_addition -> { - } - } - } - } - } - .logTrack(true) //output log - .build() - } - findViewById(R.id.recycler_view).setPanelSwitchHelper(mHelper) - } - - override fun onBackPressed() { - if (mHelper != null && mHelper!!.hookSystemBackByPanelSwitcher()) { - return - } - super.onBackPressed() - } - - companion object { - private const val TAG = "PanelActivity" - } - -} \ No newline at end of file diff --git a/app/src/main/kotlin/com/example/demo/scene/api/CusPanelView.kt b/app/src/main/kotlin/com/example/demo/scene/api/CusPanelView.kt deleted file mode 100644 index 4cc7938..0000000 --- a/app/src/main/kotlin/com/example/demo/scene/api/CusPanelView.kt +++ /dev/null @@ -1,50 +0,0 @@ -package com.example.demo.scene.api - -import android.content.Context -import android.graphics.Color -import android.support.v7.widget.AppCompatTextView -import android.util.AttributeSet -import android.view.Gravity -import com.effective.R -import com.effective.android.panel.view.panel.IPanelView - -class CusPanelView : IPanelView, AppCompatTextView { - - private var triggerViewId = 0 - private var isToggle = true - - constructor(context: Context?) : this(context, null) - constructor(context: Context?, attrs: AttributeSet?) : this(context, attrs, 0) - constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - initView(attrs, defStyleAttr, 0) - } - - private fun initView(attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) { - val typedArray = context.obtainStyledAttributes(attrs, R.styleable.CusPanelView, defStyleAttr, defStyleRes) - triggerViewId = typedArray.getResourceId(R.styleable.CusPanelView_cus_panel_trigger, -1) - isToggle = typedArray.getBoolean(R.styleable.CusPanelView_cus_panel_toggle, isToggle) - typedArray.recycle() - setBackgroundColor(Color.BLACK) - text = "自定义面板" - gravity = Gravity.CENTER - setTextColor(Color.WHITE) - textSize = 20f - } - - override fun getBindingTriggerViewId(): Int = triggerViewId - - override fun isTriggerViewCanToggle(): Boolean = isToggle - - override fun isShowing(): Boolean = isShown - - override fun assertView() { - if (triggerViewId == -1) { - throw RuntimeException("PanelView -- you must set 'panel_layout' and panel_trigger by Integer id") - } - } - - override fun onFinishInflate() { - super.onFinishInflate() - assertView() - } -} \ No newline at end of file diff --git a/app/src/main/kotlin/com/example/demo/scene/api/DefaultHeightPanelActivity.kt b/app/src/main/kotlin/com/example/demo/scene/api/DefaultHeightPanelActivity.kt deleted file mode 100644 index b8062f3..0000000 --- a/app/src/main/kotlin/com/example/demo/scene/api/DefaultHeightPanelActivity.kt +++ /dev/null @@ -1,137 +0,0 @@ -package com.example.demo.scene.api - -import android.os.Bundle -import android.support.v7.app.AppCompatActivity -import android.text.TextUtils -import android.util.Log -import android.view.View -import android.view.Window -import android.widget.EditText -import android.widget.TextView -import android.widget.Toast -import com.effective.R -import com.effective.android.panel.PanelSwitchHelper -import com.effective.android.panel.utils.PanelUtil.clearData -import com.effective.android.panel.view.panel.PanelView -import com.example.demo.scene.chat.emotion.EmotionPagerView -import com.example.demo.scene.chat.emotion.Emotions -import com.example.demo.scene.chat.view.AutoHidePanelRecyclerView -import com.example.demo.util.DisplayUtils -import com.rd.PageIndicatorView - -/** - * 设置面板默认高度 - * created by yummylau on 2020/07/13 - */ -class DefaultHeightPanelActivity : AppCompatActivity() { - private var mHelper: PanelSwitchHelper? = null - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - supportRequestWindowFeature(Window.FEATURE_NO_TITLE) - setContentView(R.layout.activity_api_default_panel_height_layout) - findViewById(R.id.title).text = "设置面板默认高度,点击切换下面面板进行体验,如果曾拉起过输入法,则需要点击此标题清除高度缓存。" - findViewById(R.id.title).setOnClickListener { - clearData(this@DefaultHeightPanelActivity) - Toast.makeText(this@DefaultHeightPanelActivity, "已清除面板高度缓存,可拉起功能面板测试默认高度", Toast.LENGTH_SHORT).show() - } - initView() - } - - private val sendView: View - get() = findViewById(R.id.send) - - private val editView: EditText - get() = findViewById(R.id.edit_text) - - private val emotionView: View - get() = findViewById(R.id.emotion_btn) - - private fun initView() { - sendView.setOnClickListener(View.OnClickListener { - val content = editView.text.toString() - if (TextUtils.isEmpty(content)) { - Toast.makeText(this@DefaultHeightPanelActivity, "当前没有输入", Toast.LENGTH_SHORT).show() - return@OnClickListener - } - editView.text = null - }) - } - - override fun onStart() { - super.onStart() - if (mHelper == null) { - mHelper = PanelSwitchHelper.Builder(this) //可选 - .addKeyboardStateListener { - onKeyboardChange { visible, height -> - Log.d(TAG, "系统键盘是否可见 : $visible ,高度为:$height") - } - } - .addEditTextFocusChangeListener { - onFocusChange { _, hasFocus -> - Log.d(TAG, "输入框是否获得焦点 : $hasFocus") - } - } - .addViewClickListener { - onClickBefore { - Log.d(TAG, "点击了View : $it") - } - } - .addPanelChangeListener { - onKeyboard { - Log.d(TAG, "唤起系统输入法") - emotionView.isSelected = false - } - onNone { - Log.d(TAG, "隐藏所有面板") - emotionView.isSelected = false - } - onPanel { - Log.d(TAG, "唤起面板 : $it") - if (it is PanelView) { - emotionView.isSelected = it.id == R.id.panel_emotion - } - } - onPanelSizeChange { panelView, _, _, _, width, height -> - if (panelView is PanelView) { - when (panelView.id) { - R.id.panel_emotion -> { - val pagerView: EmotionPagerView = findViewById(R.id.view_pager) - val viewPagerSize = height - DisplayUtils.dip2px(this@DefaultHeightPanelActivity, 30f) - pagerView.buildEmotionViews( - findViewById(R.id.pageIndicatorView) as PageIndicatorView, - editView, - Emotions.getEmotions(), width, viewPagerSize) - } - R.id.panel_addition -> { - } - } - } - } - } - .addPanelHeightMeasurer { - getTargetPanelDefaultHeight { DisplayUtils.dip2px(this@DefaultHeightPanelActivity,400f)} - getPanelTriggerId { R.id.add_btn } - } - .addPanelHeightMeasurer { - getTargetPanelDefaultHeight { DisplayUtils.dip2px(this@DefaultHeightPanelActivity,200f)} - getPanelTriggerId { R.id.emotion_btn } - } - .logTrack(true) //output log - .build() - } - findViewById(R.id.recycler_view).setPanelSwitchHelper(mHelper) - } - - override fun onBackPressed() { - if (mHelper != null && mHelper!!.hookSystemBackByPanelSwitcher()) { - return - } - super.onBackPressed() - } - - companion object { - private const val TAG = "PanelActivity" - } - -} \ No newline at end of file diff --git a/app/src/main/kotlin/com/example/demo/scene/api/PanelActivity.kt b/app/src/main/kotlin/com/example/demo/scene/api/PanelActivity.kt deleted file mode 100644 index b48ef51..0000000 --- a/app/src/main/kotlin/com/example/demo/scene/api/PanelActivity.kt +++ /dev/null @@ -1,123 +0,0 @@ -package com.example.demo.scene.api - -import android.os.Bundle -import android.support.v7.app.AppCompatActivity -import android.text.TextUtils -import android.util.Log -import android.view.View -import android.view.Window -import android.widget.EditText -import android.widget.TextView -import android.widget.Toast -import com.effective.R -import com.effective.android.panel.PanelSwitchHelper -import com.effective.android.panel.view.panel.PanelView -import com.example.demo.scene.chat.emotion.EmotionPagerView -import com.example.demo.scene.chat.emotion.Emotions -import com.example.demo.util.DisplayUtils -import com.rd.PageIndicatorView - -/** - * 处理可以使用默认的 PanelView,也可以通过继承 IPanelView 来实现自己的 PanelView。 - * 使用自定义面板 - * created by yummylau on 2020/06/06 - */ -class PanelActivity : AppCompatActivity() { - private var mHelper: PanelSwitchHelper? = null - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - supportRequestWindowFeature(Window.FEATURE_NO_TITLE) - setContentView(R.layout.activity_api_cus_panel_layout) - findViewById(R.id.title).text = "继承 IPanelView 实现 PanelView,点击左下角 + 试试吧" - initView() - } - - private val sendView: View - get() = findViewById(R.id.send) - - private val editView: EditText - get() = findViewById(R.id.edit_text) - - private val emotionView: View - get() = findViewById(R.id.emotion_btn) - - private fun initView() { - sendView.setOnClickListener(View.OnClickListener { - val content = editView.text.toString() - if (TextUtils.isEmpty(content)) { - Toast.makeText(this@PanelActivity, "当前没有输入", Toast.LENGTH_SHORT).show() - return@OnClickListener - } - editView.text = null - }) - } - - override fun onStart() { - super.onStart() - if (mHelper == null) { - mHelper = PanelSwitchHelper.Builder(this) //可选 - .addKeyboardStateListener { - onKeyboardChange { visible, height -> - Log.d(TAG, "系统键盘是否可见 : $visible ,高度为:$height") - } - } - .addEditTextFocusChangeListener { - onFocusChange { _, hasFocus -> - Log.d(TAG, "输入框是否获得焦点 : $hasFocus") - } - } - .addViewClickListener { - onClickBefore { - Log.d(TAG, "点击了View : $it") - } - } - .addPanelChangeListener { - onKeyboard { - Log.d(TAG, "唤起系统输入法") - emotionView.isSelected = false - } - onNone { - Log.d(TAG, "隐藏所有面板") - emotionView.isSelected = false - } - onPanel { - Log.d(TAG, "唤起面板 : $it") - if (it is PanelView) { - emotionView.isSelected = it.id == R.id.panel_emotion - } - } - onPanelSizeChange { panelView, _, _, _, width, height -> - if (panelView is PanelView) { - when (panelView.id) { - R.id.panel_emotion -> { - val pagerView: EmotionPagerView = findViewById(R.id.view_pager) - val viewPagerSize = height - DisplayUtils.dip2px(this@PanelActivity, 30f) - pagerView.buildEmotionViews( - findViewById(R.id.pageIndicatorView) as PageIndicatorView, - editView, - Emotions.getEmotions(), width, viewPagerSize) - } - R.id.panel_addition -> { - } - } - } - } - } - .logTrack(true) //output log - .build() - } - } - - override fun onBackPressed() { - if (mHelper != null && mHelper!!.hookSystemBackByPanelSwitcher()) { - return - } - super.onBackPressed() - } - - companion object { - private const val TAG = "PanelActivity" - } - -} \ No newline at end of file diff --git a/app/src/main/kotlin/com/example/demo/scene/api/ResetActivity.kt b/app/src/main/kotlin/com/example/demo/scene/api/ResetActivity.kt deleted file mode 100644 index e651433..0000000 --- a/app/src/main/kotlin/com/example/demo/scene/api/ResetActivity.kt +++ /dev/null @@ -1,199 +0,0 @@ -package com.example.demo.scene.api - -import android.content.Context -import android.content.Intent -import android.os.Bundle -import android.support.v7.app.AppCompatActivity -import android.support.v7.widget.LinearLayoutManager -import android.support.v7.widget.RecyclerView -import android.text.TextUtils -import android.util.Log -import android.view.View -import android.view.Window -import android.widget.EditText -import android.widget.TextView -import android.widget.Toast -import com.effective.R -import com.effective.android.panel.PanelSwitchHelper -import com.effective.android.panel.view.panel.PanelView -import com.example.demo.Constants -import com.example.demo.anno.ApiResetType -import com.example.demo.scene.chat.adapter.ChatAdapter -import com.example.demo.scene.chat.adapter.ChatInfo -import com.example.demo.scene.chat.emotion.EmotionPagerView -import com.example.demo.scene.chat.emotion.Emotions -import com.example.demo.scene.chat.view.AutoHidePanelRecyclerView -import com.example.demo.util.DisplayUtils -import com.rd.PageIndicatorView - -/** - * 演示如何正确使用 auto_reset (点击内容区域自动隐藏面板) 的功能 - * auto_reset 可以被定义在 container 的扩展属性内,包含 - * 1. auto_reset_enable 表示是否支持点击内容区域内隐藏面板,默认打开。 - * 打开时,当区域内子view没有消费事件时,则会默认消费该事件并自动隐藏。 - * 2. auto_reset_area,当且仅当 auto_reset_enable 为 true 才有效,指定一个 view 的id,为 1 的消费事件限定区域。 - * 比如场景一,指定了空白透明 view ,view 没有消费事件时,则才会自动隐藏面板; - * 比如场景二,指定了列表的 recyclerview ,则recyclerview 没有消费事件时,则才会自动隐藏面板; - * 比如场景三,场景二 recyclerview 时显然很难不消费事件,如果 holder 被点击(比如聊天项),则应该被正常消费, - * 如果点击 recyclerview 内的空白,recyclerview 也会默认消费,因为可能需要滑动、 - * 为了解决这种下层应该消费点击滑动事件,而上层容器应该获取点击并自动隐藏,HookActionUpRecyclerView 就是该场景的 DEMO - * 需要把下层消费完之后的 ACTION_UP 返回 false 让上层有机会处理。 ContentContainerImpl 内的实现预留了这种可能,用于处理该复杂场景。 - * - * 可参考自定义 [CusContentContainer] 或库提供的多种Container实现类 - * created by yummylau on 2020/06/06 - */ -class ResetActivity : AppCompatActivity() { - private var mHelper: PanelSwitchHelper? = null - private lateinit var mAdapter: ChatAdapter - private var mLinearLayoutManager: LinearLayoutManager? = null - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - supportRequestWindowFeature(Window.FEATURE_NO_TITLE) - when (intent.getIntExtra(Constants.KEY_CONTENT_TYPE, ApiResetType.DISABLE)) { - ApiResetType.DISABLE -> { - setContentView(R.layout.activity_api_auto_reset_disable_layout) - findViewById(R.id.title).text = "关闭自动隐藏面板,点击空白处无法隐藏面板" - } - ApiResetType.ENABLE -> { - setContentView(R.layout.activity_api_auto_reset_enable_layout) - findViewById(R.id.title).text = "打开自动隐藏面板,点击空白处即可隐藏面板" - } - ApiResetType.ENABLE_EmptyView -> { - setContentView(R.layout.activity_api_auto_reset_enable_on_empty_view_layout) - findViewById(R.id.title).text = "打开自动隐藏面板-自定义EmptyView,不消费事件,点击可隐藏面板" - } - ApiResetType.ENABLE_RecyclerView -> { - setContentView(R.layout.activity_api_auto_reset_enable_on_recyclerview_layout) - findViewById(R.id.title).text = "打开自动隐藏面板-原生RecyclerView,默认消费事件,点击无法隐藏面板" - } - ApiResetType.ENABLE_HookActionUpRecyclerview -> { - setContentView(R.layout.activity_api_auto_reset_enbale_on_cus_recyclerview_layout) - findViewById(R.id.title).text = "打开自动隐藏面板-HookActionUpRecyclerView,重写消费逻辑,点击非空白可隐藏面板,列表可滑动,holder可点击" - } - } - initView() - } - - private val recyclerView: RecyclerView - get() = findViewById(R.id.recycler_view) as RecyclerView - - private val sendView: View - get() = findViewById(R.id.send) - - private val editView: EditText - get() = findViewById(R.id.edit_text) - - private val emotionView: View - get() = findViewById(R.id.emotion_btn) - - private fun initView() { - mLinearLayoutManager = LinearLayoutManager(this) - recyclerView.layoutManager = mLinearLayoutManager - mAdapter = ChatAdapter(this, 50) - recyclerView.adapter = mAdapter - sendView.setOnClickListener(View.OnClickListener { - val content = editView.text.toString() - if (TextUtils.isEmpty(content)) { - Toast.makeText(this@ResetActivity, "当前没有输入", Toast.LENGTH_SHORT).show() - return@OnClickListener - } - mAdapter.insertInfo(ChatInfo.CREATE(content)) - editView.text = null - scrollToBottom() - }) - } - - private fun scrollToBottom() { - recyclerView.post { mLinearLayoutManager?.scrollToPosition(mAdapter.itemCount - 1) } - } - - override fun onStart() { - super.onStart() - if (mHelper == null) { - mHelper = PanelSwitchHelper.Builder(this) //可选 - .addKeyboardStateListener { - onKeyboardChange { visible, height -> - Log.d(TAG, "系统键盘是否可见 : $visible ,高度为:$height") - } - } - .addEditTextFocusChangeListener { - onFocusChange { _, hasFocus -> - Log.d(TAG, "输入框是否获得焦点 : $hasFocus") - if (hasFocus) { - scrollToBottom() - } - } - } - .addViewClickListener { - onClickBefore { - when (it!!.id) { - R.id.edit_text, R.id.add_btn, R.id.emotion_btn -> { - scrollToBottom() - } - } - Log.d(TAG, "点击了View : $it") - } - } - .addPanelChangeListener { - onKeyboard { - Log.d(TAG, "唤起系统输入法") - emotionView.isSelected = false - scrollToBottom() - } - onNone { - Log.d(TAG, "隐藏所有面板") - emotionView.isSelected = false - } - onPanel { - Log.d(TAG, "唤起面板 : $it") - if (it is PanelView) { - emotionView.isSelected = it.id == R.id.panel_emotion - scrollToBottom() - } - } - onPanelSizeChange { panelView, _, _, _, width, height -> - if (panelView is PanelView) { - when (panelView.id) { - R.id.panel_emotion -> { - val pagerView: EmotionPagerView = findViewById(R.id.view_pager) - val viewPagerSize = height - DisplayUtils.dip2px(this@ResetActivity, 30f) - pagerView.buildEmotionViews( - findViewById(R.id.pageIndicatorView) as PageIndicatorView, - editView, - Emotions.getEmotions(), width, viewPagerSize) - } - R.id.panel_addition -> { - } - } - } - } - } - .logTrack(true) //output log - .build() - } - if (findViewById(R.id.recycler_view) is AutoHidePanelRecyclerView) { - findViewById(R.id.recycler_view).setPanelSwitchHelper(mHelper) - } - } - - override fun onBackPressed() { - if (mHelper != null && mHelper!!.hookSystemBackByPanelSwitcher()) { - return - } - super.onBackPressed() - } - - companion object { - - @JvmStatic - fun start(context: Context, @ApiResetType type: Int) { - val intent = Intent(context, ResetActivity::class.java) - intent.putExtra(Constants.KEY_CONTENT_TYPE, type) - context.startActivity(intent) - } - - private const val TAG = "ResetActivity" - } - -} \ No newline at end of file diff --git a/app/src/main/res/anim/anim_feed_pop_hide.xml b/app/src/main/res/anim/anim_feed_pop_hide.xml deleted file mode 100644 index 79bb6fe..0000000 --- a/app/src/main/res/anim/anim_feed_pop_hide.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/anim/anim_feed_pop_show.xml b/app/src/main/res/anim/anim_feed_pop_show.xml deleted file mode 100644 index c786884..0000000 --- a/app/src/main/res/anim/anim_feed_pop_show.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/color/color_send_btn.xml b/app/src/main/res/color/color_send_btn.xml deleted file mode 100644 index 495aec5..0000000 --- a/app/src/main/res/color/color_send_btn.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable-xxhdpi/avatar_android.png b/app/src/main/res/drawable-xxhdpi/avatar_android.png deleted file mode 100644 index 8e6ed75..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/avatar_android.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/avatar_cat.jpeg b/app/src/main/res/drawable-xxhdpi/avatar_cat.jpeg deleted file mode 100644 index 6712611..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/avatar_cat.jpeg and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/bg_gradient.jpeg b/app/src/main/res/drawable-xxhdpi/bg_gradient.jpeg deleted file mode 100644 index 6273491..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/bg_gradient.jpeg and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/chat_left_bg.9.png b/app/src/main/res/drawable-xxhdpi/chat_left_bg.9.png deleted file mode 100644 index 726e200..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/chat_left_bg.9.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/chat_right_bg.9.png b/app/src/main/res/drawable-xxhdpi/chat_right_bg.9.png deleted file mode 100644 index 85f35aa..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/chat_right_bg.9.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_1.png b/app/src/main/res/drawable-xxhdpi/expression_1.png deleted file mode 100644 index d1683ad..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_1.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_10.png b/app/src/main/res/drawable-xxhdpi/expression_10.png deleted file mode 100644 index 00c525c..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_10.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_101.png b/app/src/main/res/drawable-xxhdpi/expression_101.png deleted file mode 100644 index 4749f85..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_101.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_102.png b/app/src/main/res/drawable-xxhdpi/expression_102.png deleted file mode 100644 index fff6360..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_102.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_103.png b/app/src/main/res/drawable-xxhdpi/expression_103.png deleted file mode 100644 index 7f17bdc..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_103.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_104.png b/app/src/main/res/drawable-xxhdpi/expression_104.png deleted file mode 100644 index c616b42..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_104.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_105.png b/app/src/main/res/drawable-xxhdpi/expression_105.png deleted file mode 100644 index 71d3863..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_105.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_106.png b/app/src/main/res/drawable-xxhdpi/expression_106.png deleted file mode 100644 index 0622d53..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_106.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_107.png b/app/src/main/res/drawable-xxhdpi/expression_107.png deleted file mode 100644 index d71da78..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_107.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_108.png b/app/src/main/res/drawable-xxhdpi/expression_108.png deleted file mode 100644 index 4995047..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_108.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_109.png b/app/src/main/res/drawable-xxhdpi/expression_109.png deleted file mode 100644 index 4e71097..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_109.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_11.png b/app/src/main/res/drawable-xxhdpi/expression_11.png deleted file mode 100644 index 4cde82c..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_11.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_111.png b/app/src/main/res/drawable-xxhdpi/expression_111.png deleted file mode 100644 index de8953d..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_111.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_113.png b/app/src/main/res/drawable-xxhdpi/expression_113.png deleted file mode 100644 index 0f7b2bd..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_113.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_114.png b/app/src/main/res/drawable-xxhdpi/expression_114.png deleted file mode 100644 index 85a28c3..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_114.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_115.png b/app/src/main/res/drawable-xxhdpi/expression_115.png deleted file mode 100644 index 95b1152..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_115.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_116.png b/app/src/main/res/drawable-xxhdpi/expression_116.png deleted file mode 100644 index e0fd80a..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_116.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_117.png b/app/src/main/res/drawable-xxhdpi/expression_117.png deleted file mode 100644 index 70fa1e5..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_117.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_118.png b/app/src/main/res/drawable-xxhdpi/expression_118.png deleted file mode 100644 index 99dcd04..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_118.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_119.png b/app/src/main/res/drawable-xxhdpi/expression_119.png deleted file mode 100644 index cd5707a..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_119.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_12.png b/app/src/main/res/drawable-xxhdpi/expression_12.png deleted file mode 100644 index e9860ae..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_12.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_13.png b/app/src/main/res/drawable-xxhdpi/expression_13.png deleted file mode 100644 index 5f8b837..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_13.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_14.png b/app/src/main/res/drawable-xxhdpi/expression_14.png deleted file mode 100644 index ea301eb..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_14.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_15.png b/app/src/main/res/drawable-xxhdpi/expression_15.png deleted file mode 100644 index 130092a..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_15.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_16.png b/app/src/main/res/drawable-xxhdpi/expression_16.png deleted file mode 100644 index ed16f43..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_16.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_18.png b/app/src/main/res/drawable-xxhdpi/expression_18.png deleted file mode 100644 index c6e3d60..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_19.png b/app/src/main/res/drawable-xxhdpi/expression_19.png deleted file mode 100644 index 708f598..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_19.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_2.png b/app/src/main/res/drawable-xxhdpi/expression_2.png deleted file mode 100644 index 5c0bc81..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_2.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_20.png b/app/src/main/res/drawable-xxhdpi/expression_20.png deleted file mode 100644 index 3374de0..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_20.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_21.png b/app/src/main/res/drawable-xxhdpi/expression_21.png deleted file mode 100644 index 7cdf30d..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_21.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_22.png b/app/src/main/res/drawable-xxhdpi/expression_22.png deleted file mode 100644 index d38af6c..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_22.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_23.png b/app/src/main/res/drawable-xxhdpi/expression_23.png deleted file mode 100644 index 54d60f2..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_23.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_24.png b/app/src/main/res/drawable-xxhdpi/expression_24.png deleted file mode 100644 index f9f3274..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_26.png b/app/src/main/res/drawable-xxhdpi/expression_26.png deleted file mode 100644 index d00bcca..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_26.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_27.png b/app/src/main/res/drawable-xxhdpi/expression_27.png deleted file mode 100644 index 74d7367..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_27.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_28.png b/app/src/main/res/drawable-xxhdpi/expression_28.png deleted file mode 100644 index 1bd1d8d..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_28.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_29.png b/app/src/main/res/drawable-xxhdpi/expression_29.png deleted file mode 100644 index fba8e42..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_29.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_3.png b/app/src/main/res/drawable-xxhdpi/expression_3.png deleted file mode 100644 index 6666d24..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_3.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_30.png b/app/src/main/res/drawable-xxhdpi/expression_30.png deleted file mode 100644 index 6930c1f..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_30.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_31.png b/app/src/main/res/drawable-xxhdpi/expression_31.png deleted file mode 100644 index 4c8b210..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_31.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_32.png b/app/src/main/res/drawable-xxhdpi/expression_32.png deleted file mode 100644 index c866a78..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_32.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_33.png b/app/src/main/res/drawable-xxhdpi/expression_33.png deleted file mode 100644 index 8efeae2..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_33.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_34.png b/app/src/main/res/drawable-xxhdpi/expression_34.png deleted file mode 100644 index 9a77988..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_34.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_35.png b/app/src/main/res/drawable-xxhdpi/expression_35.png deleted file mode 100644 index 1ec5395..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_35.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_37.png b/app/src/main/res/drawable-xxhdpi/expression_37.png deleted file mode 100644 index 51a909d..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_37.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_38.png b/app/src/main/res/drawable-xxhdpi/expression_38.png deleted file mode 100644 index 35b1502..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_38.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_39.png b/app/src/main/res/drawable-xxhdpi/expression_39.png deleted file mode 100644 index 58963aa..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_39.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_4.png b/app/src/main/res/drawable-xxhdpi/expression_4.png deleted file mode 100644 index a88ed87..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_4.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_40.png b/app/src/main/res/drawable-xxhdpi/expression_40.png deleted file mode 100644 index b14391c..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_40.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_41.png b/app/src/main/res/drawable-xxhdpi/expression_41.png deleted file mode 100644 index f0cc76b..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_41.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_42.png b/app/src/main/res/drawable-xxhdpi/expression_42.png deleted file mode 100644 index a5cba11..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_42.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_43.png b/app/src/main/res/drawable-xxhdpi/expression_43.png deleted file mode 100644 index b3d735a..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_43.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_45.png b/app/src/main/res/drawable-xxhdpi/expression_45.png deleted file mode 100644 index 9d3b66d..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_45.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_46.png b/app/src/main/res/drawable-xxhdpi/expression_46.png deleted file mode 100644 index 8488d4e..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_46.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_47.png b/app/src/main/res/drawable-xxhdpi/expression_47.png deleted file mode 100644 index f21b136..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_47.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_48.png b/app/src/main/res/drawable-xxhdpi/expression_48.png deleted file mode 100644 index 2dc0d2b..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_49.png b/app/src/main/res/drawable-xxhdpi/expression_49.png deleted file mode 100644 index e325cc7..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_49.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_5.png b/app/src/main/res/drawable-xxhdpi/expression_5.png deleted file mode 100644 index 5cf5d2a..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_5.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_50.png b/app/src/main/res/drawable-xxhdpi/expression_50.png deleted file mode 100644 index f2885b0..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_50.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_51.png b/app/src/main/res/drawable-xxhdpi/expression_51.png deleted file mode 100644 index 0e86351..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_51.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_52.png b/app/src/main/res/drawable-xxhdpi/expression_52.png deleted file mode 100644 index 29e18fb..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_52.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_53.png b/app/src/main/res/drawable-xxhdpi/expression_53.png deleted file mode 100644 index 3413b29..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_53.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_55.png b/app/src/main/res/drawable-xxhdpi/expression_55.png deleted file mode 100644 index 2d7cc1a..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_55.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_56.png b/app/src/main/res/drawable-xxhdpi/expression_56.png deleted file mode 100644 index 3cc6c19..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_56.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_57.png b/app/src/main/res/drawable-xxhdpi/expression_57.png deleted file mode 100644 index 23c6030..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_57.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_58.png b/app/src/main/res/drawable-xxhdpi/expression_58.png deleted file mode 100644 index de8aa32..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_58.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_6.png b/app/src/main/res/drawable-xxhdpi/expression_6.png deleted file mode 100644 index ebb6f9a..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_6.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_61.png b/app/src/main/res/drawable-xxhdpi/expression_61.png deleted file mode 100644 index 04aa040..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_61.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_63.png b/app/src/main/res/drawable-xxhdpi/expression_63.png deleted file mode 100644 index 67c8d5d..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_63.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_64.png b/app/src/main/res/drawable-xxhdpi/expression_64.png deleted file mode 100644 index e8c595d..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_64.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_65.png b/app/src/main/res/drawable-xxhdpi/expression_65.png deleted file mode 100644 index 9520cd4..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_65.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_66.png b/app/src/main/res/drawable-xxhdpi/expression_66.png deleted file mode 100644 index 6bc0010..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_66.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_67.png b/app/src/main/res/drawable-xxhdpi/expression_67.png deleted file mode 100644 index ba289ed..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_67.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_68.png b/app/src/main/res/drawable-xxhdpi/expression_68.png deleted file mode 100644 index 3180af0..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_68.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_69.png b/app/src/main/res/drawable-xxhdpi/expression_69.png deleted file mode 100644 index cdc7e26..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_69.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_7.png b/app/src/main/res/drawable-xxhdpi/expression_7.png deleted file mode 100644 index e17176f..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_7.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_71.png b/app/src/main/res/drawable-xxhdpi/expression_71.png deleted file mode 100644 index 0440f78..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_71.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_75.png b/app/src/main/res/drawable-xxhdpi/expression_75.png deleted file mode 100644 index 6395b58..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_75.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_76.png b/app/src/main/res/drawable-xxhdpi/expression_76.png deleted file mode 100644 index 1d8de0f..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_76.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_77.png b/app/src/main/res/drawable-xxhdpi/expression_77.png deleted file mode 100644 index 5a23833..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_77.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_79.png b/app/src/main/res/drawable-xxhdpi/expression_79.png deleted file mode 100644 index 3dd0eab..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_79.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_8.png b/app/src/main/res/drawable-xxhdpi/expression_8.png deleted file mode 100644 index 038fc76..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_8.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_80.png b/app/src/main/res/drawable-xxhdpi/expression_80.png deleted file mode 100644 index 9b8e03f..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_80.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_81.png b/app/src/main/res/drawable-xxhdpi/expression_81.png deleted file mode 100644 index 58aba10..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_81.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_82.png b/app/src/main/res/drawable-xxhdpi/expression_82.png deleted file mode 100644 index 9550767..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_82.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_83.png b/app/src/main/res/drawable-xxhdpi/expression_83.png deleted file mode 100644 index 0ceabba..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_83.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_84.png b/app/src/main/res/drawable-xxhdpi/expression_84.png deleted file mode 100644 index ef83fa0..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_84.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_85.png b/app/src/main/res/drawable-xxhdpi/expression_85.png deleted file mode 100644 index 7113916..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_85.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_86.png b/app/src/main/res/drawable-xxhdpi/expression_86.png deleted file mode 100644 index 4913254..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_86.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_9.png b/app/src/main/res/drawable-xxhdpi/expression_9.png deleted file mode 100644 index 5c0ae24..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_9.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_90.png b/app/src/main/res/drawable-xxhdpi/expression_90.png deleted file mode 100644 index 30df439..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_90.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_93.png b/app/src/main/res/drawable-xxhdpi/expression_93.png deleted file mode 100644 index d05e520..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_93.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_94.png b/app/src/main/res/drawable-xxhdpi/expression_94.png deleted file mode 100644 index 15cfec7..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_94.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_95.png b/app/src/main/res/drawable-xxhdpi/expression_95.png deleted file mode 100644 index 7e0d258..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_95.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_96.png b/app/src/main/res/drawable-xxhdpi/expression_96.png deleted file mode 100644 index c2604ad..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_96.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_97.png b/app/src/main/res/drawable-xxhdpi/expression_97.png deleted file mode 100644 index a3a223f..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_97.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_98.png b/app/src/main/res/drawable-xxhdpi/expression_98.png deleted file mode 100644 index 84e3d8e..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_98.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/expression_99.png b/app/src/main/res/drawable-xxhdpi/expression_99.png deleted file mode 100644 index 97202a5..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/expression_99.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_bilibili_input_send.png b/app/src/main/res/drawable-xxhdpi/ic_bilibili_input_send.png deleted file mode 100644 index 232b11d..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_bilibili_input_send.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_bilibili_input_send_select.png b/app/src/main/res/drawable-xxhdpi/ic_bilibili_input_send_select.png deleted file mode 100644 index 6736bcd..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_bilibili_input_send_select.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_bilibili_input_tip.png b/app/src/main/res/drawable-xxhdpi/ic_bilibili_input_tip.png deleted file mode 100644 index 9a83637..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_bilibili_input_tip.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_bilibili_panel_key.png b/app/src/main/res/drawable-xxhdpi/ic_bilibili_panel_key.png deleted file mode 100644 index 50a1667..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_bilibili_panel_key.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_bilibili_panel_key_l.png b/app/src/main/res/drawable-xxhdpi/ic_bilibili_panel_key_l.png deleted file mode 100644 index 7560c6e..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_bilibili_panel_key_l.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_bilibili_panel_key_select.png b/app/src/main/res/drawable-xxhdpi/ic_bilibili_panel_key_select.png deleted file mode 100644 index 48f14fd..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_bilibili_panel_key_select.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_bilibili_video_back.png b/app/src/main/res/drawable-xxhdpi/ic_bilibili_video_back.png deleted file mode 100644 index 6fee8c4..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_bilibili_video_back.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_bilibili_video_checkout.png b/app/src/main/res/drawable-xxhdpi/ic_bilibili_video_checkout.png deleted file mode 100644 index 97c0c9f..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_bilibili_video_checkout.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_douyin_close.png b/app/src/main/res/drawable-xxhdpi/ic_douyin_close.png deleted file mode 100644 index ec768d3..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_douyin_close.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_douyin_gift.png b/app/src/main/res/drawable-xxhdpi/ic_douyin_gift.png deleted file mode 100644 index fb1c5ae..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_douyin_gift.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_douyin_live_user.jpg b/app/src/main/res/drawable-xxhdpi/ic_douyin_live_user.jpg deleted file mode 100644 index 3f81fd1..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_douyin_live_user.jpg and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_douyin_love.png b/app/src/main/res/drawable-xxhdpi/ic_douyin_love.png deleted file mode 100644 index 8d350e2..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_douyin_love.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_douyin_more.png b/app/src/main/res/drawable-xxhdpi/ic_douyin_more.png deleted file mode 100644 index 6b0ae32..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_douyin_more.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_douyin_send.png b/app/src/main/res/drawable-xxhdpi/ic_douyin_send.png deleted file mode 100644 index a4bdcfe..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_douyin_send.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_feed_action_comment.png b/app/src/main/res/drawable-xxhdpi/ic_feed_action_comment.png deleted file mode 100644 index a9c1886..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_feed_action_comment.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_feed_action_like.png b/app/src/main/res/drawable-xxhdpi/ic_feed_action_like.png deleted file mode 100644 index 1d9c75a..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_feed_action_like.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_feed_avatar.jpg b/app/src/main/res/drawable-xxhdpi/ic_feed_avatar.jpg deleted file mode 100644 index b04fc1c..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_feed_avatar.jpg and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_feed_cover.jpeg b/app/src/main/res/drawable-xxhdpi/ic_feed_cover.jpeg deleted file mode 100644 index 71693ff..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_feed_cover.jpeg and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_icon.png b/app/src/main/res/drawable-xxhdpi/ic_icon.png deleted file mode 100644 index d97794b..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_icon.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_uzi_0.jpg b/app/src/main/res/drawable-xxhdpi/ic_uzi_0.jpg deleted file mode 100644 index a115754..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_uzi_0.jpg and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_uzi_1.jpg b/app/src/main/res/drawable-xxhdpi/ic_uzi_1.jpg deleted file mode 100644 index 14b1402..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_uzi_1.jpg and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_uzi_2.jpg b/app/src/main/res/drawable-xxhdpi/ic_uzi_2.jpg deleted file mode 100644 index 89a8945..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_uzi_2.jpg and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_uzi_3.jpg b/app/src/main/res/drawable-xxhdpi/ic_uzi_3.jpg deleted file mode 100644 index 9917090..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_uzi_3.jpg and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_uzi_4.jpg b/app/src/main/res/drawable-xxhdpi/ic_uzi_4.jpg deleted file mode 100644 index 7056a12..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_uzi_4.jpg and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_uzi_5.jpg b/app/src/main/res/drawable-xxhdpi/ic_uzi_5.jpg deleted file mode 100644 index 60eb1c5..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_uzi_5.jpg and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_uzi_6.jpg b/app/src/main/res/drawable-xxhdpi/ic_uzi_6.jpg deleted file mode 100644 index 1602f78..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_uzi_6.jpg and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_uzi_7.jpg b/app/src/main/res/drawable-xxhdpi/ic_uzi_7.jpg deleted file mode 100644 index 7d228c0..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_uzi_7.jpg and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_uzi_8.jpg b/app/src/main/res/drawable-xxhdpi/ic_uzi_8.jpg deleted file mode 100644 index 7e66672..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_uzi_8.jpg and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_uzi_9.jpg b/app/src/main/res/drawable-xxhdpi/ic_uzi_9.jpg deleted file mode 100644 index d7c1257..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_uzi_9.jpg and /dev/null differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index d5fccc5..0000000 --- a/app/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/drawable/icon_account.xml b/app/src/main/res/drawable/icon_account.xml deleted file mode 100644 index da0263f..0000000 --- a/app/src/main/res/drawable/icon_account.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/icon_add.xml b/app/src/main/res/drawable/icon_add.xml deleted file mode 100644 index b7e2161..0000000 --- a/app/src/main/res/drawable/icon_add.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/icon_camera.xml b/app/src/main/res/drawable/icon_camera.xml deleted file mode 100644 index 44fc1f4..0000000 --- a/app/src/main/res/drawable/icon_camera.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - diff --git a/app/src/main/res/drawable/icon_emotion.xml b/app/src/main/res/drawable/icon_emotion.xml deleted file mode 100644 index 033bd7f..0000000 --- a/app/src/main/res/drawable/icon_emotion.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/icon_image.xml b/app/src/main/res/drawable/icon_image.xml deleted file mode 100644 index 72309cd..0000000 --- a/app/src/main/res/drawable/icon_image.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/icon_keyboard.xml b/app/src/main/res/drawable/icon_keyboard.xml deleted file mode 100644 index 55038f3..0000000 --- a/app/src/main/res/drawable/icon_keyboard.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/icon_location.xml b/app/src/main/res/drawable/icon_location.xml deleted file mode 100644 index 15ad224..0000000 --- a/app/src/main/res/drawable/icon_location.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/icon_video.xml b/app/src/main/res/drawable/icon_video.xml deleted file mode 100644 index 9ed5882..0000000 --- a/app/src/main/res/drawable/icon_video.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/icon_voice.xml b/app/src/main/res/drawable/icon_voice.xml deleted file mode 100644 index af1edb3..0000000 --- a/app/src/main/res/drawable/icon_voice.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/se_bilibili_input_send.xml b/app/src/main/res/drawable/se_bilibili_input_send.xml deleted file mode 100644 index 2d61e0e..0000000 --- a/app/src/main/res/drawable/se_bilibili_input_send.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/se_bilibili_panel_key_l.xml b/app/src/main/res/drawable/se_bilibili_panel_key_l.xml deleted file mode 100644 index 3549e8f..0000000 --- a/app/src/main/res/drawable/se_bilibili_panel_key_l.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/se_bilibili_panel_key_p.xml b/app/src/main/res/drawable/se_bilibili_panel_key_p.xml deleted file mode 100644 index 2886e43..0000000 --- a/app/src/main/res/drawable/se_bilibili_panel_key_p.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/se_douyin_action_btn.xml b/app/src/main/res/drawable/se_douyin_action_btn.xml deleted file mode 100644 index 090900b..0000000 --- a/app/src/main/res/drawable/se_douyin_action_btn.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/drawable/se_huya_comment_send_p.xml b/app/src/main/res/drawable/se_huya_comment_send_p.xml deleted file mode 100644 index 69eb4fd..0000000 --- a/app/src/main/res/drawable/se_huya_comment_send_p.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/drawable/se_wechat_comment_send.xml b/app/src/main/res/drawable/se_wechat_comment_send.xml deleted file mode 100644 index 9f42b7c..0000000 --- a/app/src/main/res/drawable/se_wechat_comment_send.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/drawable/selector_edit_focus.xml b/app/src/main/res/drawable/selector_edit_focus.xml deleted file mode 100644 index 956756c..0000000 --- a/app/src/main/res/drawable/selector_edit_focus.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/selector_emotion_btn.xml b/app/src/main/res/drawable/selector_emotion_btn.xml deleted file mode 100644 index 1440936..0000000 --- a/app/src/main/res/drawable/selector_emotion_btn.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/selector_send_btn.xml b/app/src/main/res/drawable/selector_send_btn.xml deleted file mode 100644 index 0d86229..0000000 --- a/app/src/main/res/drawable/selector_send_btn.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/drawable/sh_activity_btn.xml b/app/src/main/res/drawable/sh_activity_btn.xml deleted file mode 100644 index 0422ada..0000000 --- a/app/src/main/res/drawable/sh_activity_btn.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/sh_bilibili_input_l.xml b/app/src/main/res/drawable/sh_bilibili_input_l.xml deleted file mode 100644 index d1e280b..0000000 --- a/app/src/main/res/drawable/sh_bilibili_input_l.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/sh_bilibili_input_l_but_white.xml b/app/src/main/res/drawable/sh_bilibili_input_l_but_white.xml deleted file mode 100644 index dde15a2..0000000 --- a/app/src/main/res/drawable/sh_bilibili_input_l_but_white.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/sh_bilibili_input_p.xml b/app/src/main/res/drawable/sh_bilibili_input_p.xml deleted file mode 100644 index eedc4b2..0000000 --- a/app/src/main/res/drawable/sh_bilibili_input_p.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/sh_bilibili_panel_item_bg.xml b/app/src/main/res/drawable/sh_bilibili_panel_item_bg.xml deleted file mode 100644 index e50e964..0000000 --- a/app/src/main/res/drawable/sh_bilibili_panel_item_bg.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/sh_bilibili_panel_item_select_bg.xml b/app/src/main/res/drawable/sh_bilibili_panel_item_select_bg.xml deleted file mode 100644 index 67a280d..0000000 --- a/app/src/main/res/drawable/sh_bilibili_panel_item_select_bg.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/sh_content_btn.xml b/app/src/main/res/drawable/sh_content_btn.xml deleted file mode 100644 index 3ce63c3..0000000 --- a/app/src/main/res/drawable/sh_content_btn.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/sh_douyin_follow_bg.xml b/app/src/main/res/drawable/sh_douyin_follow_bg.xml deleted file mode 100644 index 4e32250..0000000 --- a/app/src/main/res/drawable/sh_douyin_follow_bg.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/sh_douyin_time_bg.xml b/app/src/main/res/drawable/sh_douyin_time_bg.xml deleted file mode 100644 index d05aeb3..0000000 --- a/app/src/main/res/drawable/sh_douyin_time_bg.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/sh_douyin_user_bg.xml b/app/src/main/res/drawable/sh_douyin_user_bg.xml deleted file mode 100644 index 6da4e34..0000000 --- a/app/src/main/res/drawable/sh_douyin_user_bg.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/sh_feed_action.xml b/app/src/main/res/drawable/sh_feed_action.xml deleted file mode 100644 index 815dff9..0000000 --- a/app/src/main/res/drawable/sh_feed_action.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/sh_fragment_btn.xml b/app/src/main/res/drawable/sh_fragment_btn.xml deleted file mode 100644 index 555f632..0000000 --- a/app/src/main/res/drawable/sh_fragment_btn.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/sh_huya_edit_cursor.xml b/app/src/main/res/drawable/sh_huya_edit_cursor.xml deleted file mode 100644 index 51777bf..0000000 --- a/app/src/main/res/drawable/sh_huya_edit_cursor.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/sh_panel_btn.xml b/app/src/main/res/drawable/sh_panel_btn.xml deleted file mode 100644 index 8b4b229..0000000 --- a/app/src/main/res/drawable/sh_panel_btn.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/sh_pop_feed_action.xml b/app/src/main/res/drawable/sh_pop_feed_action.xml deleted file mode 100644 index 22adaa9..0000000 --- a/app/src/main/res/drawable/sh_pop_feed_action.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/sh_reset_btn.xml b/app/src/main/res/drawable/sh_reset_btn.xml deleted file mode 100644 index 81a6d1e..0000000 --- a/app/src/main/res/drawable/sh_reset_btn.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/sh_special_page_btn.xml b/app/src/main/res/drawable/sh_special_page_btn.xml deleted file mode 100644 index 2bf8099..0000000 --- a/app/src/main/res/drawable/sh_special_page_btn.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/sh_tip_btn.xml b/app/src/main/res/drawable/sh_tip_btn.xml deleted file mode 100644 index 3b39254..0000000 --- a/app/src/main/res/drawable/sh_tip_btn.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/sh_video_btn.xml b/app/src/main/res/drawable/sh_video_btn.xml deleted file mode 100644 index e8bb672..0000000 --- a/app/src/main/res/drawable/sh_video_btn.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/sh_wechat_comment_input.xml b/app/src/main/res/drawable/sh_wechat_comment_input.xml deleted file mode 100644 index 01cefe1..0000000 --- a/app/src/main/res/drawable/sh_wechat_comment_input.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_edit_cursor.xml b/app/src/main/res/drawable/shape_edit_cursor.xml deleted file mode 100644 index 7e15349..0000000 --- a/app/src/main/res/drawable/shape_edit_cursor.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_edit_selected.xml b/app/src/main/res/drawable/shape_edit_selected.xml deleted file mode 100644 index f16b27c..0000000 --- a/app/src/main/res/drawable/shape_edit_selected.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_edit_unselected.xml b/app/src/main/res/drawable/shape_edit_unselected.xml deleted file mode 100644 index 459b704..0000000 --- a/app/src/main/res/drawable/shape_edit_unselected.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_input_layout.xml b/app/src/main/res/drawable/shape_input_layout.xml deleted file mode 100644 index 2fae6e9..0000000 --- a/app/src/main/res/drawable/shape_input_layout.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_video_input_text.xml b/app/src/main/res/drawable/shape_video_input_text.xml deleted file mode 100644 index 49af1f5..0000000 --- a/app/src/main/res/drawable/shape_video_input_text.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_api_auto_reset_disable_layout.xml b/app/src/main/res/layout/activity_api_auto_reset_disable_layout.xml deleted file mode 100644 index b2a6c15..0000000 --- a/app/src/main/res/layout/activity_api_auto_reset_disable_layout.xml +++ /dev/null @@ -1,156 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_api_auto_reset_enable_layout.xml b/app/src/main/res/layout/activity_api_auto_reset_enable_layout.xml deleted file mode 100644 index 45402ba..0000000 --- a/app/src/main/res/layout/activity_api_auto_reset_enable_layout.xml +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_api_auto_reset_enable_on_empty_view_layout.xml b/app/src/main/res/layout/activity_api_auto_reset_enable_on_empty_view_layout.xml deleted file mode 100644 index 0dc2413..0000000 --- a/app/src/main/res/layout/activity_api_auto_reset_enable_on_empty_view_layout.xml +++ /dev/null @@ -1,168 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_api_auto_reset_enable_on_recyclerview_layout.xml b/app/src/main/res/layout/activity_api_auto_reset_enable_on_recyclerview_layout.xml deleted file mode 100644 index 53ecb9c..0000000 --- a/app/src/main/res/layout/activity_api_auto_reset_enable_on_recyclerview_layout.xml +++ /dev/null @@ -1,154 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_api_auto_reset_enbale_on_cus_recyclerview_layout.xml b/app/src/main/res/layout/activity_api_auto_reset_enbale_on_cus_recyclerview_layout.xml deleted file mode 100644 index 743af11..0000000 --- a/app/src/main/res/layout/activity_api_auto_reset_enbale_on_cus_recyclerview_layout.xml +++ /dev/null @@ -1,154 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_api_content_cus_layout.xml b/app/src/main/res/layout/activity_api_content_cus_layout.xml deleted file mode 100644 index b328793..0000000 --- a/app/src/main/res/layout/activity_api_content_cus_layout.xml +++ /dev/null @@ -1,152 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_api_content_frame_layout.xml b/app/src/main/res/layout/activity_api_content_frame_layout.xml deleted file mode 100644 index 2c90782..0000000 --- a/app/src/main/res/layout/activity_api_content_frame_layout.xml +++ /dev/null @@ -1,150 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_api_content_linear_layout.xml b/app/src/main/res/layout/activity_api_content_linear_layout.xml deleted file mode 100644 index d86576f..0000000 --- a/app/src/main/res/layout/activity_api_content_linear_layout.xml +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_api_content_relative_layout.xml b/app/src/main/res/layout/activity_api_content_relative_layout.xml deleted file mode 100644 index f6c4213..0000000 --- a/app/src/main/res/layout/activity_api_content_relative_layout.xml +++ /dev/null @@ -1,150 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_api_cus_panel_layout.xml b/app/src/main/res/layout/activity_api_cus_panel_layout.xml deleted file mode 100644 index c781c4f..0000000 --- a/app/src/main/res/layout/activity_api_cus_panel_layout.xml +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_api_default_panel_height_layout.xml b/app/src/main/res/layout/activity_api_default_panel_height_layout.xml deleted file mode 100644 index 39cb3bd..0000000 --- a/app/src/main/res/layout/activity_api_default_panel_height_layout.xml +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_bilibili_video_layout.xml b/app/src/main/res/layout/activity_bilibili_video_layout.xml deleted file mode 100644 index 7edc46f..0000000 --- a/app/src/main/res/layout/activity_bilibili_video_layout.xml +++ /dev/null @@ -1,134 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_chat_fragment_layout.xml b/app/src/main/res/layout/activity_chat_fragment_layout.xml deleted file mode 100644 index 761f19d..0000000 --- a/app/src/main/res/layout/activity_chat_fragment_layout.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_douyin_live_layout.xml b/app/src/main/res/layout/activity_douyin_live_layout.xml deleted file mode 100644 index 4e2f7ba..0000000 --- a/app/src/main/res/layout/activity_douyin_live_layout.xml +++ /dev/null @@ -1,248 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_feed_dialog_layout.xml b/app/src/main/res/layout/activity_feed_dialog_layout.xml deleted file mode 100644 index 7c98ff3..0000000 --- a/app/src/main/res/layout/activity_feed_dialog_layout.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_feed_layout.xml b/app/src/main/res/layout/activity_feed_layout.xml deleted file mode 100644 index 65220ce..0000000 --- a/app/src/main/res/layout/activity_feed_layout.xml +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_huya_live_layout.xml b/app/src/main/res/layout/activity_huya_live_layout.xml deleted file mode 100644 index 6ba6dcf..0000000 --- a/app/src/main/res/layout/activity_huya_live_layout.xml +++ /dev/null @@ -1,214 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main_layout.xml b/app/src/main/res/layout/activity_main_layout.xml deleted file mode 100644 index fc401eb..0000000 --- a/app/src/main/res/layout/activity_main_layout.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_super_chat_layout.xml b/app/src/main/res/layout/activity_super_chat_layout.xml deleted file mode 100644 index 1d92e54..0000000 --- a/app/src/main/res/layout/activity_super_chat_layout.xml +++ /dev/null @@ -1,231 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/common_chat_layout.xml b/app/src/main/res/layout/common_chat_layout.xml deleted file mode 100644 index 1f2452f..0000000 --- a/app/src/main/res/layout/common_chat_layout.xml +++ /dev/null @@ -1,214 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/common_chat_with_titlebar_layout.xml b/app/src/main/res/layout/common_chat_with_titlebar_layout.xml deleted file mode 100644 index 8e759ca..0000000 --- a/app/src/main/res/layout/common_chat_with_titlebar_layout.xml +++ /dev/null @@ -1,156 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_feed_comment_layout.xml b/app/src/main/res/layout/dialog_feed_comment_layout.xml deleted file mode 100644 index 902bb58..0000000 --- a/app/src/main/res/layout/dialog_feed_comment_layout.xml +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/holder_douyin_chat_item.xml b/app/src/main/res/layout/holder_douyin_chat_item.xml deleted file mode 100644 index 043834b..0000000 --- a/app/src/main/res/layout/holder_douyin_chat_item.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/holder_feed_cover_layout.xml b/app/src/main/res/layout/holder_feed_cover_layout.xml deleted file mode 100644 index 17164dc..0000000 --- a/app/src/main/res/layout/holder_feed_cover_layout.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/holder_feed_item_layout.xml b/app/src/main/res/layout/holder_feed_item_layout.xml deleted file mode 100644 index e2a500a..0000000 --- a/app/src/main/res/layout/holder_feed_item_layout.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/holder_huya_chat_item.xml b/app/src/main/res/layout/holder_huya_chat_item.xml deleted file mode 100644 index 4f8ed54..0000000 --- a/app/src/main/res/layout/holder_huya_chat_item.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/list_parent_title_layout.xml b/app/src/main/res/layout/list_parent_title_layout.xml deleted file mode 100644 index 1d0fae8..0000000 --- a/app/src/main/res/layout/list_parent_title_layout.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/list_sub_title_layout.xml b/app/src/main/res/layout/list_sub_title_layout.xml deleted file mode 100644 index 90be0bc..0000000 --- a/app/src/main/res/layout/list_sub_title_layout.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/panel_add_layout.xml b/app/src/main/res/layout/panel_add_layout.xml deleted file mode 100644 index 74f1dd2..0000000 --- a/app/src/main/res/layout/panel_add_layout.xml +++ /dev/null @@ -1,171 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/panel_bilibili_layout.xml b/app/src/main/res/layout/panel_bilibili_layout.xml deleted file mode 100644 index e71c0ca..0000000 --- a/app/src/main/res/layout/panel_bilibili_layout.xml +++ /dev/null @@ -1,337 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/panel_emotion_layout.xml b/app/src/main/res/layout/panel_emotion_layout.xml deleted file mode 100644 index db9310b..0000000 --- a/app/src/main/res/layout/panel_emotion_layout.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/panel_include_edit_layout.xml b/app/src/main/res/layout/panel_include_edit_layout.xml deleted file mode 100644 index 3f19b59..0000000 --- a/app/src/main/res/layout/panel_include_edit_layout.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/pop_bilibili_video_comment_layout.xml b/app/src/main/res/layout/pop_bilibili_video_comment_layout.xml deleted file mode 100644 index b47c8d9..0000000 --- a/app/src/main/res/layout/pop_bilibili_video_comment_layout.xml +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/pop_feed_action_layout.xml b/app/src/main/res/layout/pop_feed_action_layout.xml deleted file mode 100644 index f22e04f..0000000 --- a/app/src/main/res/layout/pop_feed_action_layout.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/pop_huya_live_comment_layout.xml b/app/src/main/res/layout/pop_huya_live_comment_layout.xml deleted file mode 100644 index d39b767..0000000 --- a/app/src/main/res/layout/pop_huya_live_comment_layout.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/vh_chat_left_layout.xml b/app/src/main/res/layout/vh_chat_left_layout.xml deleted file mode 100644 index 582d0d6..0000000 --- a/app/src/main/res/layout/vh_chat_left_layout.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/vh_chat_right_layout.xml b/app/src/main/res/layout/vh_chat_right_layout.xml deleted file mode 100644 index 381614a..0000000 --- a/app/src/main/res/layout/vh_chat_right_layout.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/vh_emotion_item_layout.xml b/app/src/main/res/layout/vh_emotion_item_layout.xml deleted file mode 100644 index ef4b13f..0000000 --- a/app/src/main/res/layout/vh_emotion_item_layout.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/view_status_bar_layout.xml b/app/src/main/res/layout/view_status_bar_layout.xml deleted file mode 100644 index 8f8b894..0000000 --- a/app/src/main/res/layout/view_status_bar_layout.xml +++ /dev/null @@ -1,5 +0,0 @@ - - \ No newline at end of file diff --git a/app/src/main/res/raw/uzi.mp4 b/app/src/main/res/raw/uzi.mp4 deleted file mode 100644 index 2c27f0a..0000000 Binary files a/app/src/main/res/raw/uzi.mp4 and /dev/null differ diff --git a/app/src/main/res/raw/yexiaoma.mp4 b/app/src/main/res/raw/yexiaoma.mp4 deleted file mode 100644 index c6a733f..0000000 Binary files a/app/src/main/res/raw/yexiaoma.mp4 and /dev/null differ diff --git a/app/src/main/res/values/attr.xml b/app/src/main/res/values/attr.xml deleted file mode 100644 index 225a8b6..0000000 --- a/app/src/main/res/values/attr.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml deleted file mode 100644 index b2da5c1..0000000 --- a/app/src/main/res/values/colors.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - #3F51B5 - #303F9F - #FF4081 - - #FAFAFA - #F5F5F5 - #EEEEEE - #E0E0E0 - #BDBDBD - #9E9E9E - #757575 - #616161 - #424242 - #212121 - - #ebebeb - @android:color/white - #2196F3 - #009688 - #FFC107 - #FF5722 - #673AB7 - #8BC34A - #E91E63 - #212121 - #00BCD4 - - #5FFFFFFF - - diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml deleted file mode 100644 index 316eead..0000000 --- a/app/src/main/res/values/dimens.xml +++ /dev/null @@ -1,31 +0,0 @@ - - -1dp - 1dp - 3dp - 5dp - 7.5dp - 10dp - 15dp - 20dp - 30dp - 35dp - 40dp - 50dp - 60dp - 80dp - 200dp - 250dp - - - 10sp - 12sp - 14sp - 16sp - 20sp - 15sp - - 1px - -1px - - 25dp - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml deleted file mode 100644 index 594a0ba..0000000 --- a/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,15 +0,0 @@ - - 切换面板框架演示 - 我是一个dialog - 我是一个pupupwindow - 我是一个dialogfragment - 发送 - 提示信息:\n框架支持任何页面的沉浸,基本满足绝大部分 app 页面 UI 涉及。完全全屏的页面接入请参考视频场景下的横屏处理。框架 Demo 提供 聊天/视频/信息流/直播 等主流场景方案,如遇到疑惑请备注\n \"机型-版本-框架版本-场景简述\" 作为标题提交 issue 并附上伪代码或者代码进行详细描述。所有问题都会第一时间得到作者回应。 - - 相册 - 拍摄 - 视频通话 - 位置 - 语音输入 - 名片 - diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml deleted file mode 100644 index 35353f5..0000000 --- a/app/src/main/res/values/styles.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - diff --git a/build.gradle b/build.gradle index bf16a2b..c41ad29 100644 --- a/build.gradle +++ b/build.gradle @@ -9,11 +9,11 @@ buildscript { repositories { google() jcenter() + maven { url 'https://jitpack.io' } } dependencies { classpath deps.android_gradle_plugin classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'com.novoda:bintray-release:0.9.1' } } @@ -21,7 +21,7 @@ allprojects { repositories { google() jcenter() - maven { url 'https://dl.bintray.com/yummylau/maven' } + maven { url 'https://jitpack.io' } } gradle.projectsEvaluated { tasks.withType(JavaCompile) { diff --git a/gradle.properties b/gradle.properties index 3a1e71f..31fd5b3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ #Fri Jun 12 11:17:21 CST 2020 android.enableJetifier=true android.useAndroidX=true -android_gradle_plugin=3.4.0 +android_gradle_plugin=3.6.0 org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M" # mac 升级到 BigSur java 环境发生改变,主动申明 -#org.gradle.java.home=/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home +#org.gradle.java.home=/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b68b17d..ab02fb6 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/panel-androidx/build.gradle b/panel-androidx/build.gradle index 2b2ea4b..f6c6974 100644 --- a/panel-androidx/build.gradle +++ b/panel-androidx/build.gradle @@ -1,7 +1,7 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' -apply plugin: 'com.novoda.bintray-release' +apply plugin: 'maven-publish' android { compileSdkVersion config.compile_sdk_version @@ -31,11 +31,30 @@ dependencies { implementation deps.androidx.appcompat } -publish { - userOrg = 'yummylau' - groupId = 'com.effective.android' - artifactId = 'panelSwitchHelper-androidx' - publishVersion = '1.3.13' - desc = 'the helper that is used to checkout panel when we are chatting' - website = 'https://github.com/YummyLau/Anchors' +task generateSourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier 'sources' } + +def versionName = "1.4.0" + +// Because the components are created only during the afterEvaluate phase, you must +// configure your publications using the afterEvaluate() lifecycle method. +afterEvaluate { + publishing { + publications { + Production(MavenPublication) { + // Creates a Maven publication called "release". + // Applies the component for the release build variant. + from components.release + // You can then customize attributes of the publication as shown below. + groupId = 'com.github.Yummylau' + artifactId = 'panelSwitchHelper-androidx' + version = versionName + // 上传source,这样使用放可以看到方法注释 + artifact generateSourcesJar + } + } + } +} + diff --git a/panel-androidx/src/main/java/com/effective/android/panel/Constants.kt b/panel-androidx/src/main/java/com/effective/android/panel/Constants.kt index 919134f..c37af66 100644 --- a/panel-androidx/src/main/java/com/effective/android/panel/Constants.kt +++ b/panel-androidx/src/main/java/com/effective/android/panel/Constants.kt @@ -18,6 +18,8 @@ object Constants { const val NAVIGATION_BAR_HEIGHT_RES_NAME = "navigation_bar_height" const val DIMEN = "dimen" const val ANDROID = "android" + const val SHOW_NAV_BAR_RES_NAME = "config_showNavigationBar" + /** * panel id, custom panel (PanelView) id is panelView's triggerViewId * [PanelView.getTriggerViewId] diff --git a/panel-androidx/src/main/java/com/effective/android/panel/PanelSwitchHelper.kt b/panel-androidx/src/main/java/com/effective/android/panel/PanelSwitchHelper.kt index 9290dd3..34f14b0 100644 --- a/panel-androidx/src/main/java/com/effective/android/panel/PanelSwitchHelper.kt +++ b/panel-androidx/src/main/java/com/effective/android/panel/PanelSwitchHelper.kt @@ -9,10 +9,7 @@ import android.widget.EditText import androidx.annotation.IdRes import androidx.fragment.app.DialogFragment import androidx.fragment.app.Fragment -import com.effective.android.panel.interfaces.ContentScrollMeasurer -import com.effective.android.panel.interfaces.ContentScrollMeasurerBuilder -import com.effective.android.panel.interfaces.PanelHeightMeasurer -import com.effective.android.panel.interfaces.PanelHeightMeasurerBuilder +import com.effective.android.panel.interfaces.* import com.effective.android.panel.interfaces.listener.* import com.effective.android.panel.log.LogTracker import com.effective.android.panel.view.PanelSwitchLayout @@ -40,6 +37,7 @@ class PanelSwitchHelper private constructor(builder: Builder, showKeyboard: Bool builder.editFocusChangeListeners.add(LogTracker) } mPanelSwitchLayout = builder.panelSwitchLayout!! + mPanelSwitchLayout.setTriggerViewClickInterceptor(builder.triggerViewClickInterceptor) mPanelSwitchLayout.setContentScrollOutsizeEnable(builder.contentScrollOutsideEnable) mPanelSwitchLayout.setScrollMeasurers(builder.contentScrollMeasurers) mPanelSwitchLayout.setPanelHeightMeasurers(builder.panelHeightMeasurers) @@ -50,11 +48,11 @@ class PanelSwitchHelper private constructor(builder: Builder, showKeyboard: Bool } } - fun addSecondaryInputView(editText: EditText){ + fun addSecondaryInputView(editText: EditText) { mPanelSwitchLayout.getContentContainer().getInputActionImpl().addSecondaryInputView(editText) } - fun removeSecondaryInputView(editText: EditText){ + fun removeSecondaryInputView(editText: EditText) { mPanelSwitchLayout.getContentContainer().getInputActionImpl().removeSecondaryInputView(editText) } @@ -111,6 +109,7 @@ class PanelSwitchHelper private constructor(builder: Builder, showKeyboard: Bool internal var editFocusChangeListeners: MutableList = mutableListOf() internal var contentScrollMeasurers: MutableList = mutableListOf() internal var panelHeightMeasurers: MutableList = mutableListOf() + internal var triggerViewClickInterceptor: TriggerViewClickInterceptor? = null internal var panelSwitchLayout: PanelSwitchLayout? = null internal var window: Window internal var rootView: View @@ -128,6 +127,11 @@ class PanelSwitchHelper private constructor(builder: Builder, showKeyboard: Bool this.rootView = root } + fun setTriggerViewClickInterceptor(interceptor: TriggerViewClickInterceptor): Builder { + this.triggerViewClickInterceptor = interceptor; + return this; + } + /** * note: helper will set view's onClickListener to View ,so you should add OnViewClickListener for your project. * diff --git a/panel-androidx/src/main/java/com/effective/android/panel/interfaces/TriggerViewClickInterceptor.kt b/panel-androidx/src/main/java/com/effective/android/panel/interfaces/TriggerViewClickInterceptor.kt new file mode 100644 index 0000000..92cc9cf --- /dev/null +++ b/panel-androidx/src/main/java/com/effective/android/panel/interfaces/TriggerViewClickInterceptor.kt @@ -0,0 +1,5 @@ +package com.effective.android.panel.interfaces + +interface TriggerViewClickInterceptor { + fun intercept(triggerId: Int): Boolean +} \ No newline at end of file diff --git a/panel-androidx/src/main/java/com/effective/android/panel/utils/DisplayUtil.kt b/panel-androidx/src/main/java/com/effective/android/panel/utils/DisplayUtil.kt index ef308ef..cde00ee 100644 --- a/panel-androidx/src/main/java/com/effective/android/panel/utils/DisplayUtil.kt +++ b/panel-androidx/src/main/java/com/effective/android/panel/utils/DisplayUtil.kt @@ -10,10 +10,7 @@ import android.graphics.Rect import android.os.Build import android.provider.Settings import android.util.DisplayMetrics -import android.view.View -import android.view.ViewGroup -import android.view.Window -import android.view.WindowManager +import android.view.* import com.effective.android.panel.Constants import com.effective.android.panel.R @@ -180,15 +177,14 @@ object DisplayUtil { * @param window * @return */ - @JvmStatic fun isNavBarVisible(context: Context, window: Window): Boolean { var isVisible = false - var viewGroup: ViewGroup? = window.decorView as ViewGroup? + val viewGroup: ViewGroup? = window.decorView as ViewGroup? viewGroup?.let { for (i in 0 until it.childCount) { - var id: Int = it.getChildAt(i).id + val id: Int = it.getChildAt(i).id if (id != android.view.View.NO_ID) { - var resourceEntryName: String? = context.resources.getResourceEntryName(id) + val resourceEntryName: String? = context.resources.getResourceEntryName(id) if ((("navigationBarBackground" == resourceEntryName) && it.getChildAt(i).visibility == android.view.View.VISIBLE)) { isVisible = true } @@ -203,16 +199,23 @@ object DisplayUtil { } } } + val manufacturer = if (Build.MANUFACTURER == null) "" else Build.MANUFACTURER.trim { it <= ' ' } + val isSamsung = manufacturer.toLowerCase().contains("samsung") + if((viewGroup == null || !isVisible) && isSamsung){ + isVisible = hasNavBar(context) + } if (isVisible) { // 对于三星手机,android10以下非OneUI2的版本,比如 s8,note8 等设备上,导航栏显示存在bug:"当用户隐藏导航栏时显示输入法的时候导航栏会跟随显示",会导致隐藏输入之后判断错误 // 这个问题在 OneUI 2 & android 10 版本已修复, - val manufacturer = if (Build.MANUFACTURER == null) "" else Build.MANUFACTURER.trim { it <= ' ' } - if (manufacturer.toLowerCase().contains("samsung") - && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { + if (isSamsung && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { try { - return Settings.Global.getInt(context.contentResolver, "navigationbar_hide_bar_enabled") == 0 + isVisible = Settings.Global.getInt( + context.contentResolver, + "navigationbar_hide_bar_enabled" + ) == 0 + if (isVisible) return true } catch (e: Exception) { - //nothing to do + e.printStackTrace() } } isVisible = !hasSystemUIFlag(window, View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) @@ -220,11 +223,64 @@ object DisplayUtil { return isVisible } + private fun hasNavBar(context: Context): Boolean { + val res = context.resources + val resourceId = res.getIdentifier( + Constants.SHOW_NAV_BAR_RES_NAME, + "bool", + "android" + ) + return if (resourceId != 0) { + var hasNav = res.getBoolean(resourceId) + // check override flag (see static block) + + // Android allows a system property to override the presence of the navigation bar. + // Used by the emulator. + // See https://github.com/android/platform_frameworks_base/blob/master/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java#L1076 + var sNavBarOverride:String? = null + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + try { + val c = Class.forName("android.os.SystemProperties") + val m = c.getDeclaredMethod("get", String::class.java) + m.isAccessible = true + sNavBarOverride = m.invoke(null, "qemu.hw.mainkeys") as? String + } catch (e: Throwable) { + sNavBarOverride = null + } + } + if ("1" == sNavBarOverride) { + hasNav = false + } else if ("0" == sNavBarOverride) { + hasNav = true + } + hasNav + } else { // fallback + !ViewConfiguration.get(context).hasPermanentMenuKey() + } + } + @JvmStatic fun dip2px(context: Context, dipValue: Float): Int { + compatSizeProxy?.let { + return it.dip2px(context, dipValue) + } val scale: Float = context.resources.displayMetrics.density return (dipValue * scale + 0.5f).toInt() } fun hasSystemUIFlag(window: Window, flag: Int): Boolean = window.decorView.systemUiVisibility and flag == flag + + interface CompatSizeProxy { + fun dip2px(context: Context, dipValue: Float): Int + } + + private var compatSizeProxy: CompatSizeProxy? = null + + /** + * 兼容autoSize + */ + @JvmStatic + fun setCompatSizeProxy(proxy: CompatSizeProxy) { + this.compatSizeProxy = compatSizeProxy + } } diff --git a/panel-androidx/src/main/java/com/effective/android/panel/view/PanelSwitchLayout.kt b/panel-androidx/src/main/java/com/effective/android/panel/view/PanelSwitchLayout.kt index b27eaff..ec7ec0a 100644 --- a/panel-androidx/src/main/java/com/effective/android/panel/view/PanelSwitchLayout.kt +++ b/panel-androidx/src/main/java/com/effective/android/panel/view/PanelSwitchLayout.kt @@ -19,6 +19,7 @@ import com.effective.android.panel.device.DeviceInfo import com.effective.android.panel.device.DeviceRuntime import com.effective.android.panel.interfaces.ContentScrollMeasurer import com.effective.android.panel.interfaces.PanelHeightMeasurer +import com.effective.android.panel.interfaces.TriggerViewClickInterceptor import com.effective.android.panel.interfaces.ViewAssertion import com.effective.android.panel.interfaces.listener.* import com.effective.android.panel.log.LogFormatter @@ -64,6 +65,7 @@ class PanelSwitchLayout : LinearLayout, ViewAssertion { private lateinit var contentContainer: IContentContainer private lateinit var panelContainer: PanelContainer private lateinit var window: Window + private var triggerViewClickInterceptor: TriggerViewClickInterceptor? = null private val contentScrollMeasurers = mutableListOf() private val panelHeightMeasurers = HashMap() @@ -116,6 +118,10 @@ class PanelSwitchLayout : LinearLayout, ViewAssertion { TAG = "${PanelSwitchLayout::class.java.simpleName}(${hashCode()})" } + internal fun setTriggerViewClickInterceptor(interceptor: TriggerViewClickInterceptor?) { + this.triggerViewClickInterceptor = interceptor + } + internal fun setContentScrollOutsizeEnable(enable: Boolean) { this.contentScrollOutsizeEnable = enable } @@ -182,6 +188,11 @@ class PanelSwitchLayout : LinearLayout, ViewAssertion { val keyView = contentContainer.findTriggerView(panelView.getBindingTriggerViewId()) keyView?.setOnClickListener(object : OnClickListener { override fun onClick(v: View) { + triggerViewClickInterceptor?.let { + if (it.intercept(v.id)) { + return + } + } val currentTime = System.currentTimeMillis() if (currentTime - preClickTime <= Constants.PROTECT_KEY_CLICK_DURATION) { LogTracker.log("$TAG#initListener", "panelItem invalid click! preClickTime: $preClickTime currentClickTime: $currentTime") @@ -628,7 +639,7 @@ class PanelSwitchLayout : LinearLayout, ViewAssertion { //模仿系统输入法隐藏,如果直接掉 checkoutPanel(Constants.PANEL_NONE),可能导致隐藏时上层 recyclerview 因为 layout 导致界面出现短暂卡顿。 if (isKeyboardState()) { if (isKeyboardShowing) { - contentContainer.getInputActionImpl().hideKeyboard(true) + contentContainer.getInputActionImpl().hideKeyboard(isKeyboardShowing, true) } else { checkoutPanel(Constants.PANEL_NONE) return false @@ -670,7 +681,7 @@ class PanelSwitchLayout : LinearLayout, ViewAssertion { when (panelId) { Constants.PANEL_NONE -> { - contentContainer.getInputActionImpl().hideKeyboard(true) + contentContainer.getInputActionImpl().hideKeyboard(isKeyboardShowing, true) contentContainer.getResetActionImpl().enableReset(false) } @@ -690,7 +701,7 @@ class PanelSwitchLayout : LinearLayout, ViewAssertion { if (size.first != oldSize.first || size.second != oldSize.second) { notifyPanelSizeChange(panelContainer.getPanelView(panelId), isPortrait(context), oldSize.first, oldSize.second, size.first, size.second) } - contentContainer.getInputActionImpl().hideKeyboard(false) + contentContainer.getInputActionImpl().hideKeyboard(isKeyboardShowing, false) contentContainer.getResetActionImpl().enableReset(true) } } diff --git a/panel-androidx/src/main/java/com/effective/android/panel/view/content/ContentContainerImpl.kt b/panel-androidx/src/main/java/com/effective/android/panel/view/content/ContentContainerImpl.kt index bdb39dd..a3bf2d8 100644 --- a/panel-androidx/src/main/java/com/effective/android/panel/view/content/ContentContainerImpl.kt +++ b/panel-androidx/src/main/java/com/effective/android/panel/view/content/ContentContainerImpl.kt @@ -296,9 +296,11 @@ class ContentContainerImpl(private val mViewGroup: ViewGroup, private val autoRe } } - override fun hideKeyboard(clearFocus: Boolean) { + override fun hideKeyboard(isKeyboardShowing: Boolean, clearFocus: Boolean) { val targetView = if (realEditViewAttach) mainInputView else mPixelInputView - PanelUtil.hideKeyboard(context, targetView) + if (isKeyboardShowing) { + PanelUtil.hideKeyboard(context, targetView) + } if (clearFocus) { targetView.clearFocus() } diff --git a/panel-androidx/src/main/java/com/effective/android/panel/view/content/IContentContainer.kt b/panel-androidx/src/main/java/com/effective/android/panel/view/content/IContentContainer.kt index f7ecca8..690e1ea 100644 --- a/panel-androidx/src/main/java/com/effective/android/panel/view/content/IContentContainer.kt +++ b/panel-androidx/src/main/java/com/effective/android/panel/view/content/IContentContainer.kt @@ -29,7 +29,7 @@ interface IInputAction { fun setEditTextClickListener(l: View.OnClickListener) fun setEditTextFocusChangeListener(l: OnFocusChangeListener) fun requestKeyboard() - fun hideKeyboard(clearFocus : Boolean) + fun hideKeyboard(isKeyboardShowing : Boolean,clearFocus : Boolean) fun showKeyboard() : Boolean fun getFullScreenPixelInputView(): EditText fun updateFullScreenParams(isFullScreen : Boolean, panelId : Int, panelHeight : Int) diff --git a/panel/.gitignore b/panel/.gitignore deleted file mode 100644 index 796b96d..0000000 --- a/panel/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/panel/build.gradle b/panel/build.gradle deleted file mode 100644 index ccde96a..0000000 --- a/panel/build.gradle +++ /dev/null @@ -1,41 +0,0 @@ -apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' -apply plugin: 'com.novoda.bintray-release' - -android { - compileSdkVersion config.compile_sdk_version - - defaultConfig { - multiDexEnabled true - minSdkVersion config.min_sdk_version - targetSdkVersion config.target_sdk_version - versionCode config.version_code - versionName config.version_name - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation deps.support.annotations - implementation deps.support.v7 -} - -publish { - userOrg = 'yummylau' - groupId = 'com.effective.android' - artifactId = 'panelSwitchHelper' - publishVersion = '1.3.13' - desc = 'the helper that is used to checkout panel when we are chatting' - website = 'https://github.com/YummyLau/Anchors' -} diff --git a/panel/consumer-rules.pro b/panel/consumer-rules.pro deleted file mode 100644 index e69de29..0000000 diff --git a/panel/proguard-rules.pro b/panel/proguard-rules.pro deleted file mode 100644 index f1b4245..0000000 --- a/panel/proguard-rules.pro +++ /dev/null @@ -1,21 +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 name 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 name. -#-renamesourcefileattribute SourceFile diff --git a/panel/src/main/AndroidManifest.xml b/panel/src/main/AndroidManifest.xml deleted file mode 100644 index 80b704c..0000000 --- a/panel/src/main/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - diff --git a/panel/src/main/java/com/effective/android/panel/Constants.kt b/panel/src/main/java/com/effective/android/panel/Constants.kt deleted file mode 100644 index 8def705..0000000 --- a/panel/src/main/java/com/effective/android/panel/Constants.kt +++ /dev/null @@ -1,31 +0,0 @@ -package com.effective.android.panel - -/** - * Created by yummyLau on 18-7-07 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -object Constants { - - const val LOG_TAG = "Panel" - //输入法高度 - const val KB_PANEL_PREFERENCE_NAME = "ky_panel_name" - const val KEYBOARD_HEIGHT_FOR_L = "keyboard_height_for_l" - const val KEYBOARD_HEIGHT_FOR_P = "keyboard_height_for_p" - const val DEFAULT_KEYBOARD_HEIGHT_FOR_L = 198f - const val DEFAULT_KEYBOARD_HEIGHT_FOR_P = 290f - const val STATUS_BAR_HEIGHT_RES_NAME = "status_bar_height" - const val NAVIGATION_BAR_HEIGHT_RES_NAME = "navigation_bar_height" - const val DIMEN = "dimen" - const val ANDROID = "android" - /** - * panel id, custom panel (PanelView) id is panelView's triggerViewId - * [PanelView.getTriggerViewId] - */ - const val PANEL_NONE = -1 - const val PANEL_KEYBOARD = 0 - const val PROTECT_KEY_CLICK_DURATION = 500L - - @JvmField - var DEBUG = false -} \ No newline at end of file diff --git a/panel/src/main/java/com/effective/android/panel/PanelSwitchHelper.kt b/panel/src/main/java/com/effective/android/panel/PanelSwitchHelper.kt deleted file mode 100644 index 7e19d3f..0000000 --- a/panel/src/main/java/com/effective/android/panel/PanelSwitchHelper.kt +++ /dev/null @@ -1,237 +0,0 @@ -package com.effective.android.panel - -import android.R -import android.app.Activity -import android.support.annotation.IdRes -import android.support.v4.app.DialogFragment -import android.support.v4.app.Fragment -import android.view.View -import android.view.ViewGroup -import android.view.Window -import android.widget.EditText -import com.effective.android.panel.interfaces.* -import com.effective.android.panel.interfaces.listener.* -import com.effective.android.panel.log.LogTracker -import com.effective.android.panel.view.PanelSwitchLayout - -/** - * the helper of panel switching - * Created by yummyLau on 2018-6-21. - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - * - * - * updated by yummyLau on 20/03/18 - * 重构整个输入法切换框架,移除旧版使用 weight+Runnable延迟切换,使用新版 layout+动画无缝衔接! - */ -class PanelSwitchHelper private constructor(builder: Builder, showKeyboard: Boolean) { - - private val mPanelSwitchLayout: PanelSwitchLayout - - init { - Constants.DEBUG = builder.logTrack - if (builder.logTrack) { - builder.viewClickListeners.add(LogTracker) - builder.panelChangeListeners.add(LogTracker) - builder.keyboardStatusListeners.add(LogTracker) - builder.editFocusChangeListeners.add(LogTracker) - } - mPanelSwitchLayout = builder.panelSwitchLayout!! - mPanelSwitchLayout.setContentScrollOutsizeEnable(builder.contentScrollOutsideEnable) - mPanelSwitchLayout.setScrollMeasurers(builder.contentScrollMeasurers) - mPanelSwitchLayout.setPanelHeightMeasurers(builder.panelHeightMeasurers) - mPanelSwitchLayout.bindListener(builder.viewClickListeners, builder.panelChangeListeners, builder.keyboardStatusListeners, builder.editFocusChangeListeners) - mPanelSwitchLayout.bindWindow(builder.window) - if (showKeyboard) { - mPanelSwitchLayout.toKeyboardState(true) - } - } - - fun addSecondaryInputView(editText: EditText){ - mPanelSwitchLayout.getContentContainer().getInputActionImpl().addSecondaryInputView(editText) - } - - fun removeSecondaryInputView(editText: EditText){ - mPanelSwitchLayout.getContentContainer().getInputActionImpl().removeSecondaryInputView(editText) - } - - fun hookSystemBackByPanelSwitcher(): Boolean { - return mPanelSwitchLayout.hookSystemBackByPanelSwitcher() - } - - fun isPanelState() = mPanelSwitchLayout.isPanelState() - - fun isKeyboardState() = mPanelSwitchLayout.isKeyboardState() - - fun isResetState() = mPanelSwitchLayout.isResetState() - - /** - * 设置内容滑动 - */ - fun setContentScrollOutsideEnable(enable: Boolean) { - mPanelSwitchLayout.setContentScrollOutsizeEnable(enable) - } - - /** - * 判断内容是否允许滑动 - */ - fun isContentScrollOutsizeEnable() = mPanelSwitchLayout.isContentScrollOutsizeEnable() - - /** - * 外部显示输入框 - */ - @JvmOverloads - fun toKeyboardState(async: Boolean = false) { - mPanelSwitchLayout.toKeyboardState(async) - } - - /** - * 外部显示面板 - */ - fun toPanelState(@IdRes triggerViewId: Int) { - mPanelSwitchLayout.findViewById(triggerViewId).let { - it.performClick() - } - } - - /** - * 隐藏输入法或者面板 - */ - fun resetState() { - mPanelSwitchLayout.checkoutPanel(Constants.PANEL_NONE) - } - - class Builder(window: Window?, root: View?) { - internal var viewClickListeners: MutableList = mutableListOf() - internal var panelChangeListeners: MutableList = mutableListOf() - internal var keyboardStatusListeners: MutableList = mutableListOf() - internal var editFocusChangeListeners: MutableList = mutableListOf() - internal var contentScrollMeasurers: MutableList = mutableListOf() - internal var panelHeightMeasurers: MutableList = mutableListOf() - internal var panelSwitchLayout: PanelSwitchLayout? = null - internal var window: Window - internal var rootView: View - internal var logTrack = false - internal var contentScrollOutsideEnable = true - - constructor(activity: Activity) : this(activity.window, activity.window.decorView.findViewById(R.id.content)) - constructor(fragment: Fragment) : this(fragment.activity?.window, fragment.view) - constructor(dialogFragment: DialogFragment) : this(dialogFragment.activity?.window, dialogFragment.view) - - init { - requireNotNull(window) { "PanelSwitchHelper\$Builder#build : window can't be null!please set value by call #Builder" } - this.window = window - requireNotNull(root) { "PanelSwitchHelper\$Builder#build : rootView can't be null!please set value by call #Builder" } - this.rootView = root - } - - /** - * note: helper will set view's onClickListener to View ,so you should add OnViewClickListener for your project. - * - * @param listener - * @return - */ - fun addViewClickListener(listener: OnViewClickListener): Builder { - if (!viewClickListeners.contains(listener)) { - viewClickListeners.add(listener) - } - return this - } - - fun addViewClickListener(function: OnViewClickListenerBuilder.() -> Unit): Builder { - viewClickListeners.add(OnViewClickListenerBuilder().also(function)) - return this - } - - fun addPanelChangeListener(listener: OnPanelChangeListener): Builder { - if (!panelChangeListeners.contains(listener)) { - panelChangeListeners.add(listener) - } - return this - } - - fun addPanelChangeListener(function: OnPanelChangeListenerBuilder.() -> Unit): Builder { - panelChangeListeners.add(OnPanelChangeListenerBuilder().also(function)) - return this - } - - fun addKeyboardStateListener(listener: OnKeyboardStateListener): Builder { - if (!keyboardStatusListeners.contains(listener)) { - keyboardStatusListeners.add(listener) - } - return this - } - - fun addKeyboardStateListener(function: OnKeyboardStateListenerBuilder.() -> Unit): Builder { - keyboardStatusListeners.add(OnKeyboardStateListenerBuilder().also(function)) - return this - } - - fun addEditTextFocusChangeListener(listener: OnEditFocusChangeListener): Builder { - if (!editFocusChangeListeners.contains(listener)) { - editFocusChangeListeners.add(listener) - } - return this - } - - fun addEditTextFocusChangeListener(function: OnEditFocusChangeListenerBuilder.() -> Unit): Builder { - editFocusChangeListeners.add(OnEditFocusChangeListenerBuilder().also(function)) - return this - } - - fun addContentScrollMeasurer(function: ContentScrollMeasurerBuilder.() -> Unit): Builder { - contentScrollMeasurers.add(ContentScrollMeasurerBuilder().also(function)) - return this - } - - fun addContentScrollMeasurer(scrollMeasurer: ContentScrollMeasurer): Builder { - if (!contentScrollMeasurers.contains(scrollMeasurer)) { - contentScrollMeasurers.add(scrollMeasurer) - } - return this - } - - fun addPanelHeightMeasurer(function: PanelHeightMeasurerBuilder.() -> Unit): Builder { - panelHeightMeasurers.add(PanelHeightMeasurerBuilder().also(function)) - return this - } - - fun addPanelHeightMeasurer(panelHeightMeasurer: PanelHeightMeasurer): Builder { - if (!panelHeightMeasurers.contains(panelHeightMeasurer)) { - panelHeightMeasurers.add(panelHeightMeasurer) - } - return this - } - - fun contentScrollOutsideEnable(contentScrollOutsideEnable: Boolean): Builder { - this.contentScrollOutsideEnable = contentScrollOutsideEnable - return this - } - - fun logTrack(logTrack: Boolean): Builder { - this.logTrack = logTrack - return this - } - - @JvmOverloads - fun build(showKeyboard: Boolean = false): PanelSwitchHelper { - findSwitchLayout(rootView) - requireNotNull(panelSwitchLayout) { "PanelSwitchHelper\$Builder#build : not found PanelSwitchLayout!" } - return PanelSwitchHelper(this, showKeyboard) - } - - private fun findSwitchLayout(view: View) { - if (view is PanelSwitchLayout) { - require(panelSwitchLayout == null) { "PanelSwitchHelper\$Builder#build : rootView has one more panelSwitchLayout!" } - panelSwitchLayout = view - return - } - if (view is ViewGroup) { - val childCount = view.childCount - for (i in 0 until childCount) { - findSwitchLayout(view.getChildAt(i)) - } - } - } - } -} \ No newline at end of file diff --git a/panel/src/main/java/com/effective/android/panel/device/DeviceInfo.kt b/panel/src/main/java/com/effective/android/panel/device/DeviceInfo.kt deleted file mode 100644 index e93e88a..0000000 --- a/panel/src/main/java/com/effective/android/panel/device/DeviceInfo.kt +++ /dev/null @@ -1,36 +0,0 @@ -package com.effective.android.panel.device - -import android.view.Window - -/** - * 保存当前设备信息不变的信息 - * Created by yummyLau on 2020-05-24 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -data class DeviceInfo(val window:Window, - val isPortrait: Boolean, - val statusBarH: Int, - val navigationBarH: Int, - val toolbarH: Int, - val screenH: Int, - val screenWithoutSystemUiH: Int, - val screenWithoutNavigationH: Int) { - - /** - * 由于pad的导航栏无论是横屏还是竖屏,都是在当前界面的底部 - * 而普通的手机,横屏状态下导航栏是在界面的两侧 - * 故需要做区分 - */ - fun getCurrentNavigationBarHeightWhenVisible(isPortrait: Boolean, isPad: Boolean): Int { - return if (isPortrait) { - navigationBarH - } else { - if (isPad) { - navigationBarH - } else { - 0 - } - } - } -} \ No newline at end of file diff --git a/panel/src/main/java/com/effective/android/panel/device/DeviceRuntime.kt b/panel/src/main/java/com/effective/android/panel/device/DeviceRuntime.kt deleted file mode 100644 index ddb1b2e..0000000 --- a/panel/src/main/java/com/effective/android/panel/device/DeviceRuntime.kt +++ /dev/null @@ -1,68 +0,0 @@ -package com.effective.android.panel.device - -import android.content.Context -import android.content.res.Configuration -import android.view.Window -import com.effective.android.panel.utils.DisplayUtil - -/** - * 保存当前设备信息跟随用户操作更改信息 - * Created by yummyLau on 2020-05-24 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -class DeviceRuntime(val context: Context, val window: Window) { - - var deviceInfoP: DeviceInfo? = null - var deviceInfoL: DeviceInfo? = null - - var isNavigationBarShow: Boolean = false - var isPortrait: Boolean = false - var isPad: Boolean = false - var isFullScreen: Boolean = false; - - init { - isPad = (context.resources.configuration.screenLayout and Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE - isPortrait = DisplayUtil.isPortrait(context) - isNavigationBarShow = DisplayUtil.isNavigationBarShow(context, window) - isFullScreen = DisplayUtil.isFullScreen(window) - } - - fun getDeviceInfoByOrientation(cache: Boolean = false): DeviceInfo { - isPortrait = DisplayUtil.isPortrait(context) - isNavigationBarShow = DisplayUtil.isNavigationBarShow(context, window) - isFullScreen = DisplayUtil.isFullScreen(window) - - if (cache) { - if (isPortrait && deviceInfoP != null) { - return deviceInfoP!! - } else if (!isPortrait && deviceInfoL != null) { - return deviceInfoL!! - } - } - - val navigationBarHeight = DisplayUtil.getNavigationBarHeight(context,window) - val statusBarHeight = DisplayUtil.getStatusBarHeight(window) - //以这种方式计算出来的toolbar,如果和statusBarHeight一样,则实际上就是statusBar的高度,大于statusBar的才是toolBar的高度。 - var toolbarH = DisplayUtil.getToolbarHeight(window) - if (toolbarH == statusBarHeight) { - toolbarH = 0 - } - val screenHeight = DisplayUtil.getScreenRealHeight(window) - val screenWithoutSystemUIHeight = DisplayUtil.getScreenHeightWithoutSystemUI(window) - val screenWithoutNavigationHeight = DisplayUtil.getScreenHeightWithoutNavigationBar(context) - - return if (isPortrait) { - deviceInfoP = DeviceInfo(window, true, - statusBarHeight, navigationBarHeight, toolbarH, - screenHeight, screenWithoutSystemUIHeight, screenWithoutNavigationHeight) - deviceInfoP!! - } else { - deviceInfoL = DeviceInfo(window, false, - statusBarHeight, navigationBarHeight, toolbarH, - screenHeight, screenWithoutSystemUIHeight, screenWithoutNavigationHeight) - deviceInfoL!! - } - - } -} \ No newline at end of file diff --git a/panel/src/main/java/com/effective/android/panel/interfaces/ContentScrollMeasurer.kt b/panel/src/main/java/com/effective/android/panel/interfaces/ContentScrollMeasurer.kt deleted file mode 100644 index 11ce565..0000000 --- a/panel/src/main/java/com/effective/android/panel/interfaces/ContentScrollMeasurer.kt +++ /dev/null @@ -1,33 +0,0 @@ -package com.effective.android.panel.interfaces - -/** - * 当内容允许滑动时,即[com.effective.android.panel.view.PanelSwitchLayout.isContentScrollOutsizeEnable] 返回true,则默认内容区域会向上 layout 一个面板距离 - * 默认 getScrollDistance 为软键盘/面板的距离 - * Created by yummyLau on 2020-07-08 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -interface ContentScrollMeasurer { - fun getScrollDistance(defaultDistance: Int): Int - fun getScrollViewId(): Int -} - -private typealias GetScrollDistance = (defaultDistance: Int) -> Int -private typealias GetScrollViewId = () -> Int - -class ContentScrollMeasurerBuilder : ContentScrollMeasurer { - - private var getScrollDistance: GetScrollDistance? = null - private var getScrollViewId: GetScrollViewId? = null - - override fun getScrollDistance(defaultDistance: Int): Int = getScrollDistance?.invoke(defaultDistance) ?: 0 - override fun getScrollViewId(): Int = getScrollViewId?.invoke() ?: -1 - - fun getScrollDistance(getScrollDistance: GetScrollDistance) { - this.getScrollDistance = getScrollDistance - } - - fun getScrollViewId(getScrollViewId: GetScrollViewId) { - this.getScrollViewId = getScrollViewId - } -} \ No newline at end of file diff --git a/panel/src/main/java/com/effective/android/panel/interfaces/PanelHeightMeasurer.kt b/panel/src/main/java/com/effective/android/panel/interfaces/PanelHeightMeasurer.kt deleted file mode 100644 index 90ef41c..0000000 --- a/panel/src/main/java/com/effective/android/panel/interfaces/PanelHeightMeasurer.kt +++ /dev/null @@ -1,36 +0,0 @@ -package com.effective.android.panel.interfaces - -interface PanelHeightMeasurer{ - fun synchronizeKeyboardHeight() : Boolean - fun getTargetPanelDefaultHeight(): Int - fun getPanelTriggerId(): Int -} - -private typealias GetTargetPanelDefaultHeight = () -> Int -private typealias GetPanelId = () -> Int -private typealias SynchronizeKeyboardHeight = () -> Boolean - -class PanelHeightMeasurerBuilder : PanelHeightMeasurer { - - private var getPanelDefaultHeight: GetTargetPanelDefaultHeight? = null - private var getPanelId: GetPanelId? = null - private var synchronizeKeyboardHeight: SynchronizeKeyboardHeight? = null - - override fun getTargetPanelDefaultHeight(): Int = getPanelDefaultHeight?.invoke() ?: 0 - - override fun getPanelTriggerId(): Int = getPanelId?.invoke() ?: -1 - - override fun synchronizeKeyboardHeight(): Boolean = synchronizeKeyboardHeight?.invoke() ?: true - - fun getTargetPanelDefaultHeight(getPanelDefaultHeight: GetTargetPanelDefaultHeight) { - this.getPanelDefaultHeight = getPanelDefaultHeight - } - - fun getPanelTriggerId(getPanelId: GetPanelId) { - this.getPanelId = getPanelId - } - - fun synchronizeKeyboardHeight(synchronizeKeyboardHeight: SynchronizeKeyboardHeight) { - this.synchronizeKeyboardHeight = synchronizeKeyboardHeight - } -} \ No newline at end of file diff --git a/panel/src/main/java/com/effective/android/panel/interfaces/ViewAssertion.kt b/panel/src/main/java/com/effective/android/panel/interfaces/ViewAssertion.kt deleted file mode 100644 index aef9b19..0000000 --- a/panel/src/main/java/com/effective/android/panel/interfaces/ViewAssertion.kt +++ /dev/null @@ -1,32 +0,0 @@ -package com.effective.android.panel.interfaces - -/** - * -------------------- - * | PanelSwitchLayout | - * | ---------------- | - * | | | | - * | |ContentContainer| | - * | | | | - * | ---------------- | - * | ---------------- | - * | | PanelContainer | | - * | ---------------- | - * -------------------- - * There are some rules that must be processed: - * - * 1. [com.effective.android.panel.view.PanelSwitchLayout] must have only two children - * [com.effective.android.panel.view.content.IContentContainer] and [com.effective.android.panel.view.PanelContainer] - * - * 2. [com.effective.android.panel.view.content.IContentContainer] must set "edit_view" value to provide [android.widget.EditText] - * - * 3. [com.effective.android.panel.view.PanelContainer] has some Children that are [com.effective.android.panel.view.PanelView] - * [com.effective.android.panel.view.PanelView] must set "panel_layout" value to provide panelView and set "panel_trigger" value to - * specify layout for click to checkout panelView - * - * Created by yummyLau on 18-7-10 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -interface ViewAssertion { - fun assertView() -} \ No newline at end of file diff --git a/panel/src/main/java/com/effective/android/panel/interfaces/listener/OnEditFocusChangeListener.kt b/panel/src/main/java/com/effective/android/panel/interfaces/listener/OnEditFocusChangeListener.kt deleted file mode 100644 index 15f311d..0000000 --- a/panel/src/main/java/com/effective/android/panel/interfaces/listener/OnEditFocusChangeListener.kt +++ /dev/null @@ -1,28 +0,0 @@ -package com.effective.android.panel.interfaces.listener - -import android.view.View - -/** - * listen to [android.widget.EditText] focus change - * Created by yummyLau on 18-7-07 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - * update 2020/05/08 支持 dsl - */ -interface OnEditFocusChangeListener { - fun onFocusChange(view: View?, hasFocus: Boolean) -} -private typealias OnFocusChange = (view: View?, hasFocus: Boolean) -> Unit - -class OnEditFocusChangeListenerBuilder : OnEditFocusChangeListener { - - private var onFocusChange: OnFocusChange? = null - - override fun onFocusChange(view: View?, hasFocus: Boolean) { - onFocusChange?.invoke(view, hasFocus) - } - - fun onFocusChange(onFocusChange: OnFocusChange) { - this.onFocusChange = onFocusChange - } -} diff --git a/panel/src/main/java/com/effective/android/panel/interfaces/listener/OnKeyboardStateListener.kt b/panel/src/main/java/com/effective/android/panel/interfaces/listener/OnKeyboardStateListener.kt deleted file mode 100644 index 515805f..0000000 --- a/panel/src/main/java/com/effective/android/panel/interfaces/listener/OnKeyboardStateListener.kt +++ /dev/null @@ -1,26 +0,0 @@ -package com.effective.android.panel.interfaces.listener - - -/** - * Created by yummyLau on 18-7-07 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - * update 2020/05/08 支持 dsl - */ -interface OnKeyboardStateListener { - fun onKeyboardChange(visible: Boolean, height: Int) -} -private typealias OnKeyboardChange = (visible: Boolean, height: Int) -> Unit - -class OnKeyboardStateListenerBuilder : OnKeyboardStateListener { - - private var onKeyboardChange: OnKeyboardChange? = null - - override fun onKeyboardChange(visible: Boolean, height: Int) { - onKeyboardChange?.invoke(visible, height) - } - - fun onKeyboardChange(onKeyboardChange: OnKeyboardChange) { - this.onKeyboardChange = onKeyboardChange - } -} \ No newline at end of file diff --git a/panel/src/main/java/com/effective/android/panel/interfaces/listener/OnPanelChangeListener.kt b/panel/src/main/java/com/effective/android/panel/interfaces/listener/OnPanelChangeListener.kt deleted file mode 100644 index a3f02fd..0000000 --- a/panel/src/main/java/com/effective/android/panel/interfaces/listener/OnPanelChangeListener.kt +++ /dev/null @@ -1,61 +0,0 @@ -package com.effective.android.panel.interfaces.listener -import com.effective.android.panel.view.panel.IPanelView - -/** - * Created by yummyLau on 18-7-07 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - * update 2020/05/08 支持 dsl - * update 2020/06/01 不再直接回调可空的panelView,IPanelView 提供更开放的能力 - */ -interface OnPanelChangeListener { - fun onKeyboard() - fun onNone() - fun onPanel(panel: IPanelView?) - fun onPanelSizeChange(panel: IPanelView?, portrait: Boolean, oldWidth: Int, oldHeight: Int, width: Int, height: Int) -} - -private typealias OnKeyboard = () -> Unit -private typealias OnNone = () -> Unit -private typealias OnPanel = (view: IPanelView?) -> Unit -private typealias OnPanelSizeChange = (panelView: IPanelView?, portrait: Boolean, oldWidth: Int, oldHeight: Int, width: Int, height: Int) -> Unit - -class OnPanelChangeListenerBuilder : OnPanelChangeListener { - - private var onKeyboard: OnKeyboard? = null - private var onNone: OnNone? = null - private var onPanel: OnPanel? = null - private var onPanelSizeChange: OnPanelSizeChange? = null - - override fun onKeyboard() { - onKeyboard?.invoke() - } - - override fun onNone() { - onNone?.invoke() - } - - override fun onPanel(panel: IPanelView?) { - onPanel?.invoke(panel) - } - - override fun onPanelSizeChange(panel: IPanelView?, portrait: Boolean, oldWidth: Int, oldHeight: Int, width: Int, height: Int) { - onPanelSizeChange?.invoke(panel, portrait, oldWidth, oldHeight, width, height) - } - - fun onKeyboard(onKeyboard: OnKeyboard) { - this.onKeyboard = onKeyboard - } - - fun onNone(onNone: OnNone) { - this.onNone = onNone - } - - fun onPanel(onPanel: OnPanel) { - this.onPanel = onPanel - } - - fun onPanelSizeChange(onPanelSizeChange: OnPanelSizeChange) { - this.onPanelSizeChange = onPanelSizeChange - } -} \ No newline at end of file diff --git a/panel/src/main/java/com/effective/android/panel/interfaces/listener/OnViewClickListener.kt b/panel/src/main/java/com/effective/android/panel/interfaces/listener/OnViewClickListener.kt deleted file mode 100644 index de1d925..0000000 --- a/panel/src/main/java/com/effective/android/panel/interfaces/listener/OnViewClickListener.kt +++ /dev/null @@ -1,29 +0,0 @@ -package com.effective.android.panel.interfaces.listener - -import android.view.View - -/** - * preventing listeners that [com.effective.android.panel.PanelSwitchHelper] set these to view from being overwritten - * Created by yummyLau on 18-7-07 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - * update 2020/05/08 支持 dsl - */ -interface OnViewClickListener { - fun onClickBefore(view: View?) -} - -private typealias OnClickBefore = (view: View?) -> Unit - -class OnViewClickListenerBuilder : OnViewClickListener { - - private var onClickBefore: OnClickBefore? = null - - override fun onClickBefore(view: View?) { - onClickBefore?.invoke(view) - } - - fun onClickBefore(onClickBefore: OnClickBefore) { - this.onClickBefore = onClickBefore - } -} \ No newline at end of file diff --git a/panel/src/main/java/com/effective/android/panel/log/LogFormatter.kt b/panel/src/main/java/com/effective/android/panel/log/LogFormatter.kt deleted file mode 100644 index 828eee5..0000000 --- a/panel/src/main/java/com/effective/android/panel/log/LogFormatter.kt +++ /dev/null @@ -1,37 +0,0 @@ -package com.effective.android.panel.log - - -class LogFormatter { - - private val stringBuilder = StringBuilder() - private val defaultKey = " " - private var keyLength: Int = 0 - - constructor(keyLength: Int) { - this.keyLength = keyLength - } - - companion object { - fun setUp(int: Int = 50): LogFormatter { - return LogFormatter(int) - } - } - - fun addContent(key: String = "", value: String): LogFormatter { - if (key.isEmpty()) { - stringBuilder.append("$value \n") - } else { - if (key.length < keyLength) { - stringBuilder.append("$key${defaultKey.subSequence(0, keyLength - key.length)} = $value \n") - } else { - stringBuilder.append("$key = $value \n") - } - } - return this - } - - fun log(tag: String) { - LogTracker.log(tag, stringBuilder.toString()) - stringBuilder.clear() - } -} \ No newline at end of file diff --git a/panel/src/main/java/com/effective/android/panel/log/LogTracker.kt b/panel/src/main/java/com/effective/android/panel/log/LogTracker.kt deleted file mode 100644 index 920b200..0000000 --- a/panel/src/main/java/com/effective/android/panel/log/LogTracker.kt +++ /dev/null @@ -1,66 +0,0 @@ -package com.effective.android.panel.log - -import android.text.TextUtils -import android.util.Log -import android.view.View -import com.effective.android.panel.Constants -import com.effective.android.panel.interfaces.listener.OnEditFocusChangeListener -import com.effective.android.panel.interfaces.listener.OnKeyboardStateListener -import com.effective.android.panel.interfaces.listener.OnPanelChangeListener -import com.effective.android.panel.interfaces.listener.OnViewClickListener -import com.effective.android.panel.view.panel.IPanelView - -/** - * single logTracker - * Created by yummyLau on 18-7-07 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -object LogTracker : OnEditFocusChangeListener, OnKeyboardStateListener, OnPanelChangeListener, OnViewClickListener { - - private val TAG = LogTracker::class.java.simpleName - - @JvmStatic - fun log(methodName: String, message: String) { - if (TextUtils.isEmpty(methodName) || TextUtils.isEmpty(message)) { - return - } - if (Constants.DEBUG) { - Log.d(TAG, "$methodName => $message") - } - } - - override fun onFocusChange(view: View?, hasFocus: Boolean) { - log("OnEditFocusChangeListener#onFocusChange", "EditText has focus ( $hasFocus )") - } - - override fun onKeyboardChange(show: Boolean,height: Int) { - log("OnKeyboardStateListener#onKeyboardChange", "Keyboard is showing ( $show ),height is $height") - } - - override fun onKeyboard() { - log("OnPanelChangeListener#onKeyboard", "panel: keyboard") - } - - override fun onNone() { - log("OnPanelChangeListener#onNone", "panel: none") - } - - override fun onPanel(panel: IPanelView?) { - log("OnPanelChangeListener#onPanel", "panel:" + (panel?.toString() - ?: "null")) - } - - override fun onPanelSizeChange(panel: IPanelView?, portrait: Boolean, oldWidth: Int, oldHeight: Int, width: Int, height: Int) { - log("OnPanelChangeListener#onPanelSizeChange", "panelView is " + (panel?.toString() - ?: "null" + - " portrait : " + portrait + - " oldWidth : " + oldWidth + " oldHeight : " + oldHeight + - " width : " + width + " height : " + height)) - } - - override fun onClickBefore(view: View?) { - log("OnViewClickListener#onViewClick", "view is " + (view?.toString() - ?: " null ")) - } -} \ No newline at end of file diff --git a/panel/src/main/java/com/effective/android/panel/utils/DisplayUtil.kt b/panel/src/main/java/com/effective/android/panel/utils/DisplayUtil.kt deleted file mode 100644 index a96ee1f..0000000 --- a/panel/src/main/java/com/effective/android/panel/utils/DisplayUtil.kt +++ /dev/null @@ -1,231 +0,0 @@ -package com.effective.android.panel.utils - -import android.annotation.TargetApi -import android.app.Activity -import android.content.Context -import android.content.res.Configuration -import android.content.res.Resources -import android.graphics.Point -import android.graphics.Rect -import android.os.Build -import android.provider.Settings -import android.util.DisplayMetrics -import android.view.View -import android.view.ViewGroup -import android.view.Window -import android.view.WindowManager -import com.effective.android.panel.Constants -import com.effective.android.panel.R -import java.lang.Exception - - -object DisplayUtil { - - /** - * 获取toolar的高度,但是这个方法仅仅在非沉浸下才有用。 - * - * @param window - * @return - */ - @JvmStatic - fun getToolbarHeight(window: Window): Int { - return window.decorView.findViewById(Window.ID_ANDROID_CONTENT).top - } - - @JvmStatic - fun getLocationOnScreen(view: View): IntArray { - val contentViewLocationInScreen = IntArray(2) - view.getLocationOnScreen(contentViewLocationInScreen) - return contentViewLocationInScreen - } - - @JvmStatic - fun contentViewCanDrawStatusBarArea(window: Window): Boolean { - return getLocationOnScreen(window.decorView.findViewById(Window.ID_ANDROID_CONTENT))[1] == 0 - } - - /** - * 对应 id 为 @Android:id/content 的 FrameLayout 所加载的布局。 - * 也就是我们 setContentView 的布局高度 - * - * @param window - * @return - */ - @JvmStatic - fun getContentViewHeight(window: Window): Int { - return window.decorView.findViewById(Window.ID_ANDROID_CONTENT).height - } - - /** - * 获取设备真实高度,包含可能存在的虚拟导航栏,未显示的刘海区域,状态栏等 - */ - fun getScreenRealHeight(window: Window): Int { - return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - val wm = window.context - .getSystemService(Context.WINDOW_SERVICE) as WindowManager - val outMetrics = DisplayMetrics() - wm.defaultDisplay.getRealMetrics(outMetrics) - return outMetrics.heightPixels - } else { - getScreenHeightWithSystemUI(window) - } - } - - - /** - * 实际上获取的是DecorView的布局高度,是一个 FrameLayout,其内置布局 id 为 com.android.internal.R.layout.screen_simple 的 LinearLayout - * 包含 id为 @+id/action_mode_bar_stub_ViewStub 的 ViewStub 还有 id 为 @Android:id/content 的 FrameLayout。 - * 如果系统设置刘海留空,则 该高度不包含刘海高度 - * - * @param window - * @return - */ - @JvmStatic - fun getScreenHeightWithSystemUI(window: Window): Int { - return window.decorView.height - } - - @JvmStatic - fun getScreenHeightWithoutNavigationBar(context: Context): Int { - return context.resources.displayMetrics.heightPixels - } - - @JvmStatic - fun getScreenHeightWithoutSystemUI(window: Window): Int { - val r = Rect() - window.decorView.getWindowVisibleDisplayFrame(r) - return r.bottom - r.top - } - - - @JvmStatic - fun isFullScreen(activity: Activity): Boolean { - return (activity.window.attributes.flags and WindowManager.LayoutParams.FLAG_FULLSCREEN - == WindowManager.LayoutParams.FLAG_FULLSCREEN) - } - - @JvmStatic - fun isFullScreen(window: Window): Boolean { - return (window.attributes.flags and WindowManager.LayoutParams.FLAG_FULLSCREEN - == WindowManager.LayoutParams.FLAG_FULLSCREEN) - } - - @JvmStatic - fun getStatusBarHeight(window: Window): Int { - val frame = Rect() - window.decorView.getWindowVisibleDisplayFrame(frame) - return frame.top - } - - - @JvmStatic - fun getNavigationBarHeight(context: Context, window: Window): Int { - val deviceNavigationHeight = getInternalDimensionSize(context.resources, Constants.NAVIGATION_BAR_HEIGHT_RES_NAME) - //三星android9 OneUI2.0一下打开全面屏手势,导航栏实际高度比 deviceHeight 小,需要做兼容 - val manufacturer = if (Build.MANUFACTURER == null) "" else Build.MANUFACTURER.trim { it <= ' ' } - if (manufacturer.toLowerCase().contains("samsung") && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { - val stableBottom = window.decorView.rootWindowInsets.stableInsetBottom - if (stableBottom < deviceNavigationHeight) { - return stableBottom; - } - } - return deviceNavigationHeight; - } - - private fun getInternalDimensionSize(res: Resources, key: String): Int { - var result = 0 - val resourceId = res.getIdentifier(key, Constants.DIMEN, Constants.ANDROID) - if (resourceId > 0) { - result = res.getDimensionPixelSize(resourceId) - } - return result - } - - @JvmStatic - fun isPortrait(context: Context): Boolean { - return when (context.resources.configuration.orientation) { - Configuration.ORIENTATION_PORTRAIT -> { - true - } - Configuration.ORIENTATION_LANDSCAPE -> { - false - } - else -> { - val display = (context.getSystemService(Context.WINDOW_SERVICE) as WindowManager).defaultDisplay - val point = Point() - display.getSize(point) - point.x <= point.y - } - } - } - - /** - * - */ - @JvmStatic - @TargetApi(14) - fun isNavigationBarShow(context: Context, window: Window): Boolean { - return isNavBarVisible(context, window) - } - - /** - * Decorview 源码 - * public static final ColorViewAttributes NAVIGATION_BAR_COLOR_VIEW_ATTRIBUTES = - * new ColorViewAttributes( - * SYSTEM_UI_FLAG_HIDE_NAVIGATION, FLAG_TRANSLUCENT_NAVIGATION, - * Gravity.BOTTOM, Gravity.RIGHT, Gravity.LEFT, - * Window.NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME, - * com.android.internal.R.id.navigationBarBackground, - * - * @param context - * @param window - * @return - */ - @JvmStatic - fun isNavBarVisible(context: Context, window: Window): Boolean { - var isVisible = false - var viewGroup: ViewGroup? = window.decorView as ViewGroup? - viewGroup?.let { - for (i in 0 until it.childCount) { - var id: Int = it.getChildAt(i).id - if (id != android.view.View.NO_ID) { - var resourceEntryName: String? = context.resources.getResourceEntryName(id) - if ((("navigationBarBackground" == resourceEntryName) && it.getChildAt(i).visibility == android.view.View.VISIBLE)) { - isVisible = true - } - } - } - if (!isVisible) { - val navigationBarView: View? = it.findViewById(R.id.immersion_navigation_bar_view) - navigationBarView?.let { navigationBar -> - if (navigationBar.visibility == View.VISIBLE) { - isVisible = true - } - } - } - } - if (isVisible) { - // 对于三星手机,android10以下非OneUI2的版本,比如 s8,note8 等设备上,导航栏显示存在bug:"当用户隐藏导航栏时显示输入法的时候导航栏会跟随显示",会导致隐藏输入之后判断错误 - // 这个问题在 OneUI 2 & android 10 版本已修复, - val manufacturer = if (Build.MANUFACTURER == null) "" else Build.MANUFACTURER.trim { it <= ' ' } - if (manufacturer.toLowerCase().contains("samsung") - && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { - try { - return Settings.Global.getInt(context.contentResolver, "navigationbar_hide_bar_enabled") == 0 - } catch (e: Exception) { - //nothing to do - } - } - isVisible = !hasSystemUIFlag(window, View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) - } - return isVisible - } - - @JvmStatic - fun dip2px(context: Context, dipValue: Float): Int { - val scale: Float = context.resources.displayMetrics.density - return (dipValue * scale + 0.5f).toInt() - } - - fun hasSystemUIFlag(window: Window, flag: Int): Boolean = window.decorView.systemUiVisibility and flag == flag -} diff --git a/panel/src/main/java/com/effective/android/panel/utils/PanelUtil.kt b/panel/src/main/java/com/effective/android/panel/utils/PanelUtil.kt deleted file mode 100644 index 7796119..0000000 --- a/panel/src/main/java/com/effective/android/panel/utils/PanelUtil.kt +++ /dev/null @@ -1,102 +0,0 @@ -package com.effective.android.panel.utils - -import android.content.Context -import android.view.View -import android.view.inputmethod.InputMethodManager -import com.effective.android.panel.Constants -import com.effective.android.panel.log.LogTracker -import com.effective.android.panel.utils.DisplayUtil.dip2px -import com.effective.android.panel.utils.DisplayUtil.isPortrait - -/** - * panel helper - * Created by yummyLau on 18-7-07 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -object PanelUtil { - - private var pHeight: Int = -1 - private var lHeight: Int = -1 - - @JvmStatic - fun clearData(context: Context) { - pHeight = -1 - lHeight = -1 - val sp = context.getSharedPreferences(Constants.KB_PANEL_PREFERENCE_NAME, Context.MODE_PRIVATE) - sp.edit().clear().apply() - } - - @JvmStatic - fun showKeyboard(context: Context, view: View): Boolean { - view.requestFocus() - val mInputManager = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager - return mInputManager.showSoftInput(view, 0) - } - - @JvmStatic - fun hideKeyboard(context: Context, view: View): Boolean { - val mInputManager = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager - return mInputManager.hideSoftInputFromWindow(view.windowToken, 0) - } - - @JvmStatic - fun getKeyBoardHeight(context: Context): Int { - val isPortrait = isPortrait(context) - if (isPortrait && pHeight != -1) { - return pHeight - } - if (!isPortrait && lHeight != -1) { - return lHeight - } - val sp = context.getSharedPreferences(Constants.KB_PANEL_PREFERENCE_NAME, Context.MODE_PRIVATE) - val key = if (isPortrait) Constants.KEYBOARD_HEIGHT_FOR_P else Constants.KEYBOARD_HEIGHT_FOR_L - val defaultHeight = dip2px(context, if (isPortrait) Constants.DEFAULT_KEYBOARD_HEIGHT_FOR_P else Constants.DEFAULT_KEYBOARD_HEIGHT_FOR_L) - val result = sp.getInt(key, defaultHeight) - if (result != defaultHeight) { - if (isPortrait) { - pHeight = result - } else { - lHeight = result - } - } - return result - } - - @JvmStatic - fun isPanelHeightBelowKeyboardHeight(context: Context, curPanelHeight: Int): Boolean = hasMeasuredKeyboard(context) && getKeyBoardHeight(context) > curPanelHeight - - @JvmStatic - fun setKeyBoardHeight(context: Context, height: Int): Boolean { - - if (getKeyBoardHeight(context) == height) { - LogTracker.log("PanelUtil#onGlobalLayout", "current KeyBoardHeight is equal,just ignore!") - return false - } - val isPortrait = isPortrait(context) - if (isPortrait && pHeight == height) { - LogTracker.log("PanelUtil#onGlobalLayout", "current KeyBoardHeight is equal,just ignore!") - return false - } - if (!isPortrait && lHeight == height) { - LogTracker.log("PanelUtil#onGlobalLayout", "current KeyBoardHeight is equal,just ignore!") - return false - } - val sp = context.getSharedPreferences(Constants.KB_PANEL_PREFERENCE_NAME, Context.MODE_PRIVATE) - val key = if (isPortrait) Constants.KEYBOARD_HEIGHT_FOR_P else Constants.KEYBOARD_HEIGHT_FOR_L - val result = sp.edit().putInt(key, height).commit() - if (result) { - if (isPortrait) { - pHeight = height - } else { - lHeight = height - } - } - return result - } - - internal fun hasMeasuredKeyboard(context: Context): Boolean { - getKeyBoardHeight(context) - return pHeight != -1 || lHeight != -1 - } -} \ No newline at end of file diff --git a/panel/src/main/java/com/effective/android/panel/view/PanelSwitchLayout.kt b/panel/src/main/java/com/effective/android/panel/view/PanelSwitchLayout.kt deleted file mode 100644 index 539966a..0000000 --- a/panel/src/main/java/com/effective/android/panel/view/PanelSwitchLayout.kt +++ /dev/null @@ -1,710 +0,0 @@ -package com.effective.android.panel.view - -import android.annotation.TargetApi -import android.content.Context -import android.graphics.Rect -import android.os.Build -import android.transition.ChangeBounds -import android.transition.TransitionManager -import android.util.AttributeSet -import android.util.Pair -import android.view.View -import android.view.ViewTreeObserver -import android.view.Window -import android.view.WindowManager -import android.widget.LinearLayout -import com.effective.android.panel.Constants -import com.effective.android.panel.R -import com.effective.android.panel.device.DeviceInfo -import com.effective.android.panel.device.DeviceRuntime -import com.effective.android.panel.interfaces.ContentScrollMeasurer -import com.effective.android.panel.interfaces.PanelHeightMeasurer -import com.effective.android.panel.interfaces.ViewAssertion -import com.effective.android.panel.interfaces.listener.OnEditFocusChangeListener -import com.effective.android.panel.interfaces.listener.OnKeyboardStateListener -import com.effective.android.panel.interfaces.listener.OnPanelChangeListener -import com.effective.android.panel.interfaces.listener.OnViewClickListener -import com.effective.android.panel.log.LogFormatter -import com.effective.android.panel.log.LogTracker -import com.effective.android.panel.utils.DisplayUtil -import com.effective.android.panel.utils.DisplayUtil.getLocationOnScreen -import com.effective.android.panel.utils.DisplayUtil.getScreenHeightWithSystemUI -import com.effective.android.panel.utils.DisplayUtil.getScreenHeightWithoutSystemUI -import com.effective.android.panel.utils.DisplayUtil.getScreenRealHeight -import com.effective.android.panel.utils.DisplayUtil.isPortrait -import com.effective.android.panel.utils.PanelUtil -import com.effective.android.panel.utils.PanelUtil.getKeyBoardHeight -import com.effective.android.panel.utils.PanelUtil.hideKeyboard -import com.effective.android.panel.utils.PanelUtil.showKeyboard -import com.effective.android.panel.view.content.IContentContainer -import com.effective.android.panel.view.panel.IPanelView -import com.effective.android.panel.view.panel.PanelContainer - -/** - * -------------------- - * | PanelSwitchLayout | - * | ---------------- | - * | | | | - * | |ContentContainer| | - * | | | | - * | ---------------- | - * | ---------------- | - * | | PanelContainer | | - * | ---------------- | - * -------------------- - * Created by yummyLau on 18-7-10 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - * - * - * updated by yummyLau on 20/03/18 - * 重构整个输入法切换框架,移除旧版使用 weight+Runnable延迟切换,使用新版 layout+动画无缝衔接! - */ -class PanelSwitchLayout : LinearLayout, ViewAssertion { - - private var viewClickListeners: MutableList? = null - private var panelChangeListeners: MutableList? = null - private var keyboardStatusListeners: MutableList? = null - private var editFocusChangeListeners: MutableList? = null - - private lateinit var contentContainer: IContentContainer - private lateinit var panelContainer: PanelContainer - private lateinit var window: Window - private val contentScrollMeasurers = mutableListOf() - private val panelHeightMeasurers = HashMap() - - private var isKeyboardShowing = false - private var panelId = Constants.PANEL_NONE - private var lastPanelId = Constants.PANEL_NONE - private var lastPanelHeight = -1; - private var animationSpeed = 200 //standard - private var contentScrollOutsizeEnable = true - - private var deviceRuntime: DeviceRuntime? = null - private var realBounds: Rect? = null - private var keyboardStateRunnable = Runnable { toKeyboardState(false) } - - private var doingCheckout = false - lateinit var TAG: String - - private val retryCheckoutKbRunnable = CheckoutKbRunnable() - - internal fun getContentContainer() = contentContainer - - inner class CheckoutKbRunnable : Runnable { - var retry = false - var delay: Long = 0L - override fun run() { - val result = checkoutPanel(Constants.PANEL_KEYBOARD) - if (!result && panelId != Constants.PANEL_KEYBOARD && retry) { - this@PanelSwitchLayout.postDelayed(this, delay) - } - retry = false - } - } - - - @JvmOverloads - constructor(context: Context?, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : super(context, attrs, defStyleAttr) { - initView(attrs, defStyleAttr, 0) - } - - @TargetApi(21) - constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) { - initView(attrs, defStyleAttr, defStyleRes) - } - - private fun initView(attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) { - val typedArray = context.obtainStyledAttributes(attrs, R.styleable.PanelSwitchLayout, defStyleAttr, 0) - animationSpeed = typedArray.getInteger(R.styleable.PanelSwitchLayout_animationSpeed, animationSpeed) - typedArray.recycle() - TAG = "${PanelSwitchLayout::class.java.simpleName}(${hashCode()})" - } - - internal fun setContentScrollOutsizeEnable(enable: Boolean) { - this.contentScrollOutsizeEnable = enable - } - - internal fun isContentScrollOutsizeEnable() = contentScrollOutsizeEnable - - override fun onDetachedFromWindow() { - super.onDetachedFromWindow() - recycle() - } - - override fun onAttachedToWindow() { - super.onAttachedToWindow() - if (!hasAttachLister) { - globalLayoutListener?.let { - window.decorView.rootView.viewTreeObserver.addOnGlobalLayoutListener(it) - hasAttachLister = true - } - } - } - - fun recycle() { - removeCallbacks(retryCheckoutKbRunnable) - removeCallbacks(keyboardStateRunnable) - contentContainer.getInputActionImpl().recycler() - if (hasAttachLister) { - globalLayoutListener?.let { - window.decorView.rootView.viewTreeObserver.removeOnGlobalLayoutListener(it) - hasAttachLister = false - } - } - } - - private fun checkoutKeyboard(retry: Boolean = true, delay: Long = 200L) { - this@PanelSwitchLayout.removeCallbacks(retryCheckoutKbRunnable) - retryCheckoutKbRunnable.retry = retry - retryCheckoutKbRunnable.delay = delay - retryCheckoutKbRunnable.run() - } - - private fun initListener() { - /** - * 1. if current currentPanelId is None,should show keyboard - * 2. current currentPanelId is not None or KeyBoard that means some panel is showing,hide it and show keyboard - */ - contentContainer.getInputActionImpl().setEditTextClickListener(OnClickListener { v -> - notifyViewClick(v) - checkoutKeyboard() - }) - contentContainer.getInputActionImpl().setEditTextFocusChangeListener(OnFocusChangeListener { v, hasFocus -> - notifyEditFocusChange(v, hasFocus) - checkoutKeyboard() - }) - contentContainer.getResetActionImpl().setResetCallback(Runnable { - hookSystemBackByPanelSwitcher() - }) - - /** - * save panel that you want to use these to checkout - */ - val array = panelContainer.panelSparseArray - for (i in 0 until array.size()) { - val panelView = array[array.keyAt(i)] - val keyView = contentContainer.findTriggerView(panelView.getBindingTriggerViewId()) - keyView?.setOnClickListener(object : OnClickListener { - override fun onClick(v: View) { - val currentTime = System.currentTimeMillis() - if (currentTime - preClickTime <= Constants.PROTECT_KEY_CLICK_DURATION) { - LogTracker.log("$TAG#initListener", "panelItem invalid click! preClickTime: $preClickTime currentClickTime: $currentTime") - return - } - notifyViewClick(v) - val targetId = panelContainer.getPanelId(panelView) - if (panelId == targetId && panelView.isTriggerViewCanToggle() && panelView.isShowing()) { - checkoutKeyboard(false) - } else { - checkoutPanel(targetId) - } - preClickTime = currentTime - } - }) - } - } - - internal fun bindListener(viewClickListeners: MutableList, panelChangeListeners: MutableList, - keyboardStatusListeners: MutableList, editFocusChangeListeners: MutableList) { - this.viewClickListeners = viewClickListeners - this.panelChangeListeners = panelChangeListeners - this.keyboardStatusListeners = keyboardStatusListeners - this.editFocusChangeListeners = editFocusChangeListeners - } - - internal fun setScrollMeasurers(mutableList: MutableList) { - contentScrollMeasurers.addAll(mutableList) - } - - internal fun setPanelHeightMeasurers(mutableList: MutableList) { - for (panelHeightMeasurer in mutableList) { - panelHeightMeasurers[panelHeightMeasurer.getPanelTriggerId()] = panelHeightMeasurer - } - } - - private var globalLayoutListener: ViewTreeObserver.OnGlobalLayoutListener? = null - private var hasAttachLister = false - - - /** - * 针对 Android Q 场景判断, - * 设备开启虚拟手势导航栏如 MIUI12时,正常情况下使用 navigationBarBackground 判断可见时是正确的 - * 如果同时采用 SYSTEM_UL_FLAG_LAYOUT_HIDE_NAVIGATION 绘制到导航栏下面,那么在 Layout Inspector 上 navigationBarBackground 布局是不存在的,但是 getWindowVisibleDisplayFrame 并没有包含这部分高度。 - * 所以针对 AndroidQ 采用 rootWindowInsets 来获取这部分可视导航栏的高度并在计算软键盘高度的时候需要加回去。 - */ - private fun getAndroidQNavHIfNavIsInvisible(runtime: DeviceRuntime, window: Window): Int { - return if (!runtime.isNavigationBarShow && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && DisplayUtil.hasSystemUIFlag(window, View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)) { - val inset = window.decorView.rootView.rootWindowInsets - LogTracker.log("$TAG#onGlobalLayout", " -> Android Q takes windowInset into calculation When nav is not shown and SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION flag is existed <-") - LogTracker.log("$TAG#onGlobalLayout", "stableInsetTop is : ${inset.stableInsetTop}") - LogTracker.log("$TAG#onGlobalLayout", "stableInsetBottom is : ${inset.stableInsetBottom}") - LogTracker.log("$TAG#onGlobalLayout", "androidQCompatNavH is ${inset.stableInsetBottom}") - inset.stableInsetBottom - } else 0 - } - - /** - * 常规导航栏显示或者全屏手势虚拟导航栏显示且不通过 SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION 让界面绘制到全屏手势导航栏下时有值 - */ - private fun getCurrentNavigationHeight(deviceRuntime: DeviceRuntime, deviceInfo: DeviceInfo): Int { - return if (deviceRuntime.isNavigationBarShow) - deviceInfo.getCurrentNavigationBarHeightWhenVisible(deviceRuntime.isPortrait, deviceRuntime.isPad) - else 0 - } - - /** - * 历史从 fullScreen api 控制上看,该属性决定状态栏行为。 - * 对于有导航栏的机型,使用该属性进行全屏显示不可取。 - */ - private fun getCurrentStatusBarHeight(deviceInfo: DeviceInfo): Int { - return deviceInfo.statusBarH - } - - private var lastContentHeight: Int? = null - private var lastNavigationBarShow: Boolean? = null - private var lastKeyboardHeight: Int = 0; - private var minLimitOpenKeyboardHeight = 300 - private var minLimitCloseKeyboardHeight: Int = 0; - - internal fun bindWindow(window: Window) { - this.window = window - window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN or WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) - deviceRuntime = DeviceRuntime(context, window) - deviceRuntime?.let { - contentContainer.getInputActionImpl().updateFullScreenParams(it.isFullScreen, panelId, getCompatPanelHeight(panelId)) - globalLayoutListener = ViewTreeObserver.OnGlobalLayoutListener { - val logFormatter = LogFormatter.setUp() - logFormatter.addContent(value = "界面每一次变化的信息回调") - logFormatter.addContent("windowSoftInputMode", "${window.attributes.softInputMode}") - logFormatter.addContent("currentPanelSwitchLayoutVisible", "${this@PanelSwitchLayout.visibility == View.VISIBLE}") - if (this@PanelSwitchLayout.visibility != View.VISIBLE) { - logFormatter.addContent(value = "skip cal keyboard Height When window is invisible!") - } - val screenHeight = getScreenRealHeight(window) - var contentHeight = getScreenHeightWithoutSystemUI(window) - val info = it.getDeviceInfoByOrientation(true) - val curStatusHeight = getCurrentStatusBarHeight(info) - val cusNavigationHeight = getCurrentNavigationHeight(it, info) - val androidQCompatNavH = getAndroidQNavHIfNavIsInvisible(it, window) - val systemUIHeight = curStatusHeight + cusNavigationHeight + androidQCompatNavH - logFormatter.addContent("screenHeight", "$screenHeight") - logFormatter.addContent("contentHeight", "$contentHeight") - logFormatter.addContent("isFullScreen", "${it.isFullScreen}") - logFormatter.addContent("isNavigationBarShown", "${it.isNavigationBarShow}") - logFormatter.addContent("deviceStatusBarH", "${info.statusBarH}") - logFormatter.addContent("deviceNavigationBarH", "${info.navigationBarH}") - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - val inset = window.decorView.rootWindowInsets - logFormatter.addContent("systemInset", "left(${inset.systemWindowInsetTop}) top(${inset.systemWindowInsetLeft}) right(${inset.systemWindowInsetRight}) bottom(${inset.systemWindowInsetBottom})") - logFormatter.addContent("inset", "left(${inset.stableInsetLeft}) top(${inset.stableInsetTop}) right(${inset.stableInsetRight}) bottom(${inset.stableInsetBottom})") - } - logFormatter.addContent("currentSystemInfo", "statusBarH : $curStatusHeight, navigationBarH : $cusNavigationHeight 全面屏手势虚拟栏H : $androidQCompatNavH") - logFormatter.addContent("currentSystemH", "$systemUIHeight") - - lastNavigationBarShow = it.isNavigationBarShow - val keyboardHeight = screenHeight - contentHeight - systemUIHeight - //输入法拉起时,需要追加 "悬浮在界面之上的全屏手势虚拟导航栏" 高度 - val realHeight = keyboardHeight + androidQCompatNavH - minLimitCloseKeyboardHeight = if (info.navigationBarH > androidQCompatNavH) info.navigationBarH else androidQCompatNavH - logFormatter.addContent("minLimitCloseKeyboardH", "$minLimitCloseKeyboardHeight") - logFormatter.addContent("minLimitOpenKeyboardH", "$minLimitOpenKeyboardHeight") - logFormatter.addContent("lastKeyboardH", "$lastKeyboardHeight") - logFormatter.addContent("currentKeyboardInfo", "keyboardH : $keyboardHeight, realKeyboardH : $realHeight, isShown : $isKeyboardShowing") - if (isKeyboardShowing) { - if (keyboardHeight <= minLimitOpenKeyboardHeight) { - isKeyboardShowing = false - if (isKeyboardState()) { - checkoutPanel(Constants.PANEL_NONE) - } - notifyKeyboardState(false) - } else { - /** - * 拉起输入法的时候递增,隐藏输入法的时候递减,机型较差的手机需要 requestLayout() 动态更新布局 - */ - if (keyboardHeight != lastKeyboardHeight) { - LogTracker.log("$TAG#onGlobalLayout", "try to set KeyBoardHeight : $realHeight,isShow $isKeyboardShowing") - PanelUtil.setKeyBoardHeight(context, realHeight) - requestLayout() - } - } - } else { - if (keyboardHeight > minLimitOpenKeyboardHeight) { - isKeyboardShowing = true - if (keyboardHeight > lastKeyboardHeight) { - LogTracker.log("$TAG#onGlobalLayout", "try to set KeyBoardHeight : $realHeight,isShow $isKeyboardShowing") - PanelUtil.setKeyBoardHeight(context, realHeight) - requestLayout() - } - if (!isKeyboardState()) { - checkoutPanel(Constants.PANEL_KEYBOARD, false) - } - notifyKeyboardState(true) - } else { - //1.3.5 实时兼容导航栏动态隐藏调整布局 - lastContentHeight?.let { lastHeight -> - lastNavigationBarShow?.let { lastShow -> - if (lastHeight != contentHeight && lastShow != it.isNavigationBarShow) { - requestLayout() - LogTracker.log("$TAG#onGlobalLayout", "update layout by navigation visibility State change") - } - } - } - } - } - lastKeyboardHeight = keyboardHeight - lastContentHeight = contentHeight - logFormatter.log("$TAG#onGlobalLayout") - } - window.decorView.rootView.viewTreeObserver.addOnGlobalLayoutListener(globalLayoutListener) - hasAttachLister = true - } - } - - private fun notifyViewClick(view: View) { - viewClickListeners?.let { - for (listener in it) { - listener.onClickBefore(view) - } - } - } - - private fun notifyKeyboardState(visible: Boolean) { - keyboardStatusListeners?.let { - for (listener in it) { - listener.onKeyboardChange(visible, if (visible) getKeyBoardHeight(context) else 0) - } - } - } - - private fun notifyEditFocusChange(view: View, hasFocus: Boolean) { - editFocusChangeListeners?.let { - for (listener in it) { - listener.onFocusChange(view, hasFocus) - } - } - } - - private fun notifyPanelChange(panelId: Int) { - panelChangeListeners?.let { - for (listener in it) { - when (panelId) { - Constants.PANEL_NONE -> { - listener.onNone() - } - Constants.PANEL_KEYBOARD -> { - listener.onKeyboard() - } - else -> { - listener.onPanel(panelContainer.getPanelView(panelId)) - } - } - } - } - } - - private fun notifyPanelSizeChange(panelView: IPanelView?, portrait: Boolean, oldWidth: Int, oldHeight: Int, width: Int, height: Int) { - panelChangeListeners?.let { - for (listener in it) { - listener.onPanelSizeChange(panelView, portrait, oldWidth, oldHeight, width, height) - } - } - } - - override fun onFinishInflate() { - super.onFinishInflate() - assertView() - initListener() - } - - override fun assertView() { - if (childCount != 2) { - throw RuntimeException("PanelSwitchLayout -- PanelSwitchLayout should has two children,the first is ContentContainer,the other is PanelContainer!") - } - val firstView = getChildAt(0) - val secondView = getChildAt(1) - if (firstView !is IContentContainer) { - throw RuntimeException("PanelSwitchLayout -- the first view isn't a IContentContainer") - } - contentContainer = firstView - if (secondView !is PanelContainer) { - throw RuntimeException("PanelSwitchLayout -- the second view is a ContentContainer, but the other isn't a PanelContainer!") - } - panelContainer = secondView - } - - private fun getContentContainerTop(scrollOutsideHeight: Int): Int { - val result = if (contentScrollOutsizeEnable) { - if (isResetState()) 0 else -scrollOutsideHeight - } else 0 - LogTracker.log("$TAG#onLayout", " getContentContainerTop :$result") - return result; - } - - private fun getContentContainerHeight(allHeight: Int, paddingTop: Int, scrollOutsideHeight: Int): Int { - return allHeight - paddingTop - - if (!contentScrollOutsizeEnable && !isResetState()) scrollOutsideHeight else 0 - } - - private fun getCompatPanelHeight(panelId: Int): Int { - if (isPanelState(panelId)) { - val panelHeightMeasurer = panelHeightMeasurers[panelId] - panelHeightMeasurer?.let { - //如果输入法还没有测量或者不同步输入法高度,则是有默认高度 - if (!PanelUtil.hasMeasuredKeyboard(context) || !it.synchronizeKeyboardHeight()) { - val result = it.getTargetPanelDefaultHeight() - LogTracker.log("$TAG#onLayout", " getCompatPanelHeight by default panel :$result") - return result - } - } - } - val result = getKeyBoardHeight(context); - LogTracker.log("$TAG#onLayout", " getCompatPanelHeight :$result") - return result - } - - /** - * @param changed - * @param l - * @param t - * @param r - * @param b - */ - override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) { - val visibility = visibility - if (visibility != View.VISIBLE) { - LogTracker.log("$TAG#onLayout", "isGone,skip") - return - } - - deviceRuntime?.let { - val logFormatter = LogFormatter.setUp() - val deviceInfo = it.getDeviceInfoByOrientation() - - /** - * 当还没有进行输入法高度获取时,由于兼容性测试之后设置的默认高度无法兼容所有机型 - * 为了业务能100%兼容,开放设置每个面板的默认高度,待输入法高度获取之后统一高度。 - */ - val compatPanelHeight = getCompatPanelHeight(panelId); - val paddingTop = paddingTop - var allHeight = deviceInfo.screenH - - if (it.isNavigationBarShow) { - /** - * 1.1.0 使用 screenWithoutNavigationHeight + navigationBarHeight ,结合 navigationBarShow 来动态计算高度,但是部分特殊机型 - * 比如水滴屏,刘海屏,等存在刘海区域,甚至华为,小米支持动态切换刘海模式(不隐藏刘海,隐藏后状态栏在刘海内,隐藏后状态栏在刘海外) - * 同时还存在全面屏,挖孔屏,这套方案存在兼容问题。 - * CusShortUtil 支持计算绝大部分机型的刘海高度,但是考虑到动态切换的模式计算太过于复杂,且不能完全兼容所有场景。 - * 1.1.1 使用 screenHeight - navigationBarHeight,结合 navigationBarShow 来动态计算告诉,原因是: - * 无论现不现实刘海区域,只需要记住应用的绘制区域以 getDecorView 的绘制区域为准,我们只需要关注一个关系: - * 刘海区域与状态栏区域的是否重叠。 - * 如果状态栏与刘海不重叠,则 screenHeight 不包含刘海 - * 如果状态栏与刘海重叠,则 screenHeight 包含刘海 - * 这样抽象逻辑变得更加简单。 - */ - allHeight -= deviceInfo.getCurrentNavigationBarHeightWhenVisible(it.isPortrait, it.isPad) - } - - val localLocation = getLocationOnScreen(this) - allHeight -= localLocation[1] - var contentContainerTop = getContentContainerTop(compatPanelHeight) - contentContainerTop += paddingTop - val contentContainerHeight = getContentContainerHeight(allHeight, paddingTop, compatPanelHeight) - val panelContainerTop = contentContainerTop + contentContainerHeight - - if (Constants.DEBUG) { - logFormatter.addContent(value = "界面每一次 layout 的信息回调") - logFormatter.addContent("layoutInfo", "onLayout(changed : $changed , l : $l , t : $t , r : $r , b : $b)") - val state = when (panelId) { - Constants.PANEL_NONE -> "收起所有输入源" - Constants.PANEL_KEYBOARD -> "显示键盘输入" - else -> "显示面板输入" - } - logFormatter.addContent("currentPanelState", "$state") - logFormatter.addContent("isPad", "${it.isPad}") - logFormatter.addContent("isFullScreen", "${it.isFullScreen}") - logFormatter.addContent("isPortrait", "${it.isPortrait}") - logFormatter.addContent("isNavigationShown", "${it.isNavigationBarShow}") - logFormatter.addContent("screenH (static,include SystemUI)", "${deviceInfo.screenH}") - logFormatter.addContent("screenH (static,exclude SystemUI)", "${deviceInfo.screenWithoutNavigationH}") - logFormatter.addContent("screenH (dynamic,exclude SystemUI)", "${deviceInfo.screenWithoutSystemUiH}") - logFormatter.addContent("localLocation[y]", "${localLocation[1]}") - logFormatter.addContent("toolbarH", "${deviceInfo.toolbarH}") - logFormatter.addContent("StatusBarH", "${deviceInfo.statusBarH}") - logFormatter.addContent("NavigationBarH", "${deviceInfo.navigationBarH}") - logFormatter.addContent("layout Location", "(${localLocation[0]},${localLocation[1]})") - logFormatter.addContent("paddingTop", "$paddingTop") - logFormatter.addContent("keyboardH", "${getKeyBoardHeight(context)}") - logFormatter.addContent("ContentContainerTop", "$contentContainerTop") - logFormatter.addContent("ContentContainerH", "$contentContainerHeight") - logFormatter.addContent("PanelContainerTop", "$panelContainerTop") - logFormatter.addContent("PanelContainerH", "$compatPanelHeight") - } - - //计算实际bounds - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - val changeBounds = isBoundChange(l, contentContainerTop, r, panelContainerTop + compatPanelHeight) - logFormatter.addContent("changeBounds", "$changeBounds") - if (changeBounds) { - val reverseResetState = reverseResetState() - logFormatter.addContent("reverseResetState", "$reverseResetState") - if (reverseResetState) { - setTransition(animationSpeed.toLong(), panelId) - } - } else { - //如果功能面板的互相切换,则需要判断是否存在高度不一致,如果不一致则需要过渡 - if (lastPanelHeight != -1 && lastPanelHeight != compatPanelHeight) { - setTransition(animationSpeed.toLong(), panelId) - } - } - } - - //处理第一个view contentContainer - run { - contentContainer.layoutContainer(l, contentContainerTop, r, contentContainerTop + contentContainerHeight, - contentScrollMeasurers, compatPanelHeight, contentScrollOutsizeEnable, isResetState()) - logFormatter.addContent("contentContainer Layout", "($l,$contentContainerTop,$r,${contentContainerTop + contentContainerHeight})") - contentContainer.changeContainerHeight(contentContainerHeight) - } - - //处理第二个view panelContainer - run { - panelContainer.layout(l, panelContainerTop, r, panelContainerTop + compatPanelHeight) - logFormatter.addContent("panelContainer Layout", "($l,$panelContainerTop,$r,${panelContainerTop + compatPanelHeight})") - panelContainer.changeContainerHeight(compatPanelHeight) - } - this.lastPanelHeight = compatPanelHeight; - contentContainer.getInputActionImpl().updateFullScreenParams(it.isFullScreen, panelId, compatPanelHeight) - logFormatter.log("$TAG#onLayout") - return - } - - //预览的时候由于 helper 还没有初始化导致可能为 null - super.onLayout(changed, l, t, r, b) - } - - - private fun isBoundChange(l: Int, t: Int, r: Int, b: Int): Boolean { - val change = realBounds == null || realBounds!!.run { - this.left != l || this.top != top || this.right != r || this.bottom != b - } - realBounds = Rect(l, t, r, b) - return change - } - - internal fun isPanelState() = isPanelState(panelId) - - internal fun isKeyboardState() = isKeyboardState(panelId) - - internal fun isResetState() = isResetState(panelId) - - private fun isPanelState(panelId: Int) = !isResetState(panelId) && !isKeyboardState(panelId) - - private fun isKeyboardState(panelId: Int) = panelId == Constants.PANEL_KEYBOARD - - private fun isResetState(panelId: Int) = panelId == Constants.PANEL_NONE - - private fun reverseResetState(): Boolean = (isResetState(lastPanelId) && !isResetState(panelId)) - || (!isResetState(lastPanelId) && isResetState(panelId)) - - - @TargetApi(19) - private fun setTransition(duration: Long, panelId: Int) { - val changeBounds = ChangeBounds() - changeBounds.duration = duration - TransitionManager.beginDelayedTransition(this, changeBounds) - } - - - /** - * This will be called when User press System Back Button. - * 1. if keyboard is showing, should be hide; - * 2. if you want to hide panel(exclude keyboard),you should call it before [android.support.v7.app.AppCompatActivity.onBackPressed] to hook it. - * - * @return if need hook - */ - internal fun hookSystemBackByPanelSwitcher(): Boolean { - if (!isResetState()) { - //模仿系统输入法隐藏,如果直接掉 checkoutPanel(Constants.PANEL_NONE),可能导致隐藏时上层 recyclerview 因为 layout 导致界面出现短暂卡顿。 - if (isKeyboardState()) { - if (isKeyboardShowing) { - contentContainer.getInputActionImpl().hideKeyboard(true) - } else { - checkoutPanel(Constants.PANEL_NONE) - return false - } - } else { - checkoutPanel(Constants.PANEL_NONE) - } - return true - } - return false - } - - @JvmOverloads - internal fun toKeyboardState(async: Boolean = false) { - if (async) { - post(keyboardStateRunnable) - } else { - contentContainer.getInputActionImpl().requestKeyboard() - } - } - - - /** - * @param panelId - * @return - */ - internal fun checkoutPanel(panelId: Int, checkoutKeyboard: Boolean = true): Boolean { - if (doingCheckout) { - LogTracker.log("$TAG#checkoutPanel", "is checkouting,just ignore!") - return false - } - doingCheckout = true - - if (panelId == this.panelId) { - LogTracker.log("$TAG#checkoutPanel", "current panelId is $panelId ,just ignore!") - doingCheckout = false - return false - } - - when (panelId) { - Constants.PANEL_NONE -> { - contentContainer.getInputActionImpl().hideKeyboard(true) - contentContainer.getResetActionImpl().enableReset(false) - } - - Constants.PANEL_KEYBOARD -> { - if (checkoutKeyboard) { - if (!contentContainer.getInputActionImpl().showKeyboard()) { - LogTracker.log("$TAG#checkoutPanel", "system show keyboard fail, just ignore!") - doingCheckout = false - return false - } - } - contentContainer.getResetActionImpl().enableReset(true) - } - else -> { - val size = Pair(measuredWidth - paddingLeft - paddingRight, getCompatPanelHeight(panelId)) - val oldSize = panelContainer.showPanel(panelId, size) - if (size.first != oldSize.first || size.second != oldSize.second) { - notifyPanelSizeChange(panelContainer.getPanelView(panelId), isPortrait(context), oldSize.first, oldSize.second, size.first, size.second) - } - contentContainer.getInputActionImpl().hideKeyboard(false) - contentContainer.getResetActionImpl().enableReset(true) - } - } - this.lastPanelId = this.panelId - this.panelId = panelId - LogTracker.log("$TAG#checkoutPanel", "checkout success ! lastPanel's id : $lastPanelId , panel's id :$panelId") - requestLayout() - notifyPanelChange(this.panelId) - doingCheckout = false - return true - } - - companion object { - val TAG = PanelSwitchLayout::class.java.simpleName - private var preClickTime: Long = 0 - } -} \ No newline at end of file diff --git a/panel/src/main/java/com/effective/android/panel/view/content/ContentContainerImpl.kt b/panel/src/main/java/com/effective/android/panel/view/content/ContentContainerImpl.kt deleted file mode 100644 index efc3fad..0000000 --- a/panel/src/main/java/com/effective/android/panel/view/content/ContentContainerImpl.kt +++ /dev/null @@ -1,417 +0,0 @@ -package com.effective.android.panel.view.content - -import android.graphics.Rect -import android.support.annotation.IdRes -import android.text.Editable -import android.text.TextWatcher -import android.view.MotionEvent -import android.view.View -import android.view.View.* -import android.view.ViewGroup -import android.view.accessibility.AccessibilityEvent -import android.view.inputmethod.EditorInfo -import android.widget.EditText -import com.effective.android.panel.Constants -import com.effective.android.panel.interfaces.ContentScrollMeasurer -import com.effective.android.panel.interfaces.ViewAssertion -import com.effective.android.panel.log.LogTracker -import com.effective.android.panel.utils.PanelUtil -import com.effective.android.panel.view.PanelSwitchLayout -import java.util.* -import kotlin.collections.HashMap - -/** - * 内容区域代理 - * -------------------- - * Created by yummyLau on 2020/05/07 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -class ContentContainerImpl(private val mViewGroup: ViewGroup, private val autoReset: Boolean, @IdRes private val editTextId: Int, @IdRes private val resetId: Int) : IContentContainer, ViewAssertion { - private val mEditText: EditText? = mViewGroup.findViewById(editTextId) - private val context = mViewGroup.context; - private val mResetView: View? = mViewGroup.findViewById(resetId) - private val mInputAction: IInputAction - private val mResetAction: IResetAction - private val tag = ContentContainerImpl::class.java.simpleName - private val mPixelInputView = EditText(mEditText?.context) - - init { - assertView() - var imeOptions = mEditText?.imeOptions - if (imeOptions != null) { - imeOptions = imeOptions or EditorInfo.IME_FLAG_NO_EXTRACT_UI - mEditText?.imeOptions = imeOptions - mPixelInputView.imeOptions = imeOptions - } - mResetAction = object : IResetAction { - - private var enableReset: Boolean = false - private var action: Runnable? = null - - /** - * 当子类不处理事件时,则 hookOnTouchEvent 会尝试消费 DOWN 。 - * 当子类处理事件时,则没有机会 hookOnTouchEvent。 这是时候有两种做法 - * 1. 寻找一个在子 View 的 hook 点,在不影响可滑动的场景先,拦截 ACTION_UP 就可以了.(Demo中) - * 2. 如果不想在子 View 处理,则需要在点击的区域构建一个透明view盖住,监听点击之后调用 PanelSwitchHelper#resetState 手动隐藏。 - * hookDispatchTouchEvent 为第一种方案预留可能 - */ - override fun hookDispatchTouchEvent(ev: MotionEvent?, consume: Boolean): Boolean { - ev?.let { event -> - if (event.action == MotionEvent.ACTION_UP) { - action?.let { - if (autoReset && enableReset && !consume) { - if (mResetView == null || eventInViewArea(mResetView, event)) { - it.run() - LogTracker.log("$tag#hookDispatchTouchEvent", "hook ACTION_UP") - return true - } - } - } - - } - } - return false - } - - /** - * 子view不消费事件时,则默认会自己处理。 - * 当不需要指定reset区域时,捕获 ACTION_DOWN 进行消费。 - * 当指定reset区域时,则需要匹配事件发生的位置是否在区域内 - */ - override fun hookOnTouchEvent(ev: MotionEvent?): Boolean { - ev?.let { event -> - if (event.action == MotionEvent.ACTION_DOWN) { - action?.let { - if (autoReset && enableReset) { - if (mResetView == null || eventInViewArea(mResetView, event)) { - it.run() - LogTracker.log("$tag#hookOnTouchEvent", "hook ACTION_DOWN") - } - } - } - } - } - return true - } - - override fun enableReset(enable: Boolean) { - enableReset = enable - } - - override fun setResetCallback(runnable: Runnable) { - action = runnable - } - - fun eventInViewArea(view: View, ev: MotionEvent?): Boolean { - ev?.let { - val x: Float = ev.rawX - val y: Float = ev.rawY - val rect = Rect() - view.getGlobalVisibleRect(rect) - return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom - } - return false - } - } - mInputAction = object : IInputAction { - - private val mainInputView: EditText = mEditText!! - private var mainFocusIndex = -1 - - private val secondaryViews = WeakHashMap() - private var secondaryViewRequestFocus = false - private var onClickListener: OnClickListener? = null - private var realEditViewAttach: Boolean = true - private var curPanelId = Int.MAX_VALUE - private var checkoutInputRight = true - private val requestFocusRunnable = RequestFocusRunnable() - private val resetSelectionRunnable = ResetSelectionRunnable() - - inner class RequestFocusRunnable : Runnable { - var resetSelection = false - override fun run() { - mainInputView.requestFocus() - if (resetSelection) { - mainInputView.postDelayed(resetSelectionRunnable, 100) - } else { - checkoutInputRight = false - } - } - } - - inner class ResetSelectionRunnable : Runnable { - override fun run() { - if (mainFocusIndex != -1 && mainFocusIndex <= mainInputView.text.length) { - mainInputView.setSelection(mainFocusIndex) - } else { - mainInputView.setSelection(mainInputView.text.length) - } - checkoutInputRight = false - } - } - - init { - mainInputView.addTextChangedListener(object : TextWatcher { - override fun afterTextChanged(s: Editable?) { - if (realEditViewAttach && mainInputView.hasFocus() && !checkoutInputRight) { - mainFocusIndex = mainInputView.selectionStart - } - } - - override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { - } - - override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { - } - }) - mainInputView.accessibilityDelegate = object : View.AccessibilityDelegate() { - override fun sendAccessibilityEvent(host: View?, eventType: Int) { - super.sendAccessibilityEvent(host, eventType) - if (eventType == AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED) { - if (realEditViewAttach && mainInputView.hasFocus() && !checkoutInputRight) { - mainFocusIndex = mainInputView.selectionStart - } - } - } - } - } - - private fun giveUpFocusRight() { - checkoutInputRight = true - realEditViewAttach = false - if (mPixelInputView.hasFocus()) { - mPixelInputView.clearFocus() - } - checkoutInputRight = false - } - - override fun getFullScreenPixelInputView(): EditText { - mPixelInputView.background = null - return mPixelInputView - } - - override fun recycler() { - mainInputView.removeCallbacks(requestFocusRunnable) - mainInputView.removeCallbacks(resetSelectionRunnable) - } - - /** - * 对于全屏模式: - * 1. 如果拉起的是输入法,焦点权利归属到 realEditView,重新获取焦点及重置光标 - * 2. 如果拉起的面板且面板高度大于输入法,焦点权利也归属到 realEditView, - * 3. 其他比如隐藏面板或者面板比输入法低,焦点权利让给 mPixelInputView - * 非全屏模式下: - * 所有焦点权利都在 realEditView - */ - override fun updateFullScreenParams(isFullScreen: Boolean, panelId: Int, panelHeight: Int) { - if (panelId == curPanelId) { - return - } - curPanelId = panelId - if (secondaryViewRequestFocus) { - secondaryViewRequestFocus = false - return - } - //解决部分手机抢占焦点,可能出现重复显示/隐藏输入法 - mPixelInputView.visibility = if (isFullScreen) VISIBLE else GONE - if (mPixelInputView.parent is ViewGroup) { - (mPixelInputView.parent as ViewGroup).isFocusableInTouchMode = true - (mPixelInputView.parent as ViewGroup).isFocusable = true - } - if (isFullScreen) { - if (panelId == Constants.PANEL_KEYBOARD) { - retrieveFocusRight(requestFocus = true, resetSelection = true) - } else if (panelId != Constants.PANEL_NONE && !PanelUtil.isPanelHeightBelowKeyboardHeight(context, panelHeight)) { - retrieveFocusRight(requestFocus = false, resetSelection = true) - } else { - giveUpFocusRight() - } - } else { - retrieveFocusRight() - } - } - - override fun addSecondaryInputView(editText: EditText) { - val key = editText.hashCode() - if (!secondaryViews.containsKey(key)) { - editText.setOnFocusChangeListener { v, hasFocus -> - secondaryViewRequestFocus = hasFocus - } - secondaryViews[key] = editText - } - } - - override fun removeSecondaryInputView(editText: EditText) { - val key = editText.hashCode() - if (secondaryViews.containsKey(key)) { - secondaryViews.remove(key) - } - } - - private fun retrieveFocusRight(requestFocus: Boolean = false, resetSelection: Boolean = false) { - checkoutInputRight = true - realEditViewAttach = true - if (mPixelInputView.hasFocus()) { - mPixelInputView.clearFocus() - } - recycler() - if (requestFocus) { - requestFocusRunnable.resetSelection = resetSelection - mainInputView.postDelayed(requestFocusRunnable, 200L) - } else { - if (resetSelection) { - resetSelectionRunnable.run() - } else { - checkoutInputRight = false - } - } - } - - override fun setEditTextClickListener(l: OnClickListener) { - onClickListener = l - mainInputView.setOnClickListener { v -> - if (realEditViewAttach) { - onClickListener?.onClick(v) - } else { - mPixelInputView.requestFocus() - } - } - } - - override fun setEditTextFocusChangeListener(l: OnFocusChangeListener) { - mainInputView.setOnFocusChangeListener { v, hasFocus -> - if (hasFocus) { - if (realEditViewAttach) { - l.onFocusChange(v, hasFocus) - } else { - mPixelInputView.requestFocus() - } - } - } - mPixelInputView.setOnFocusChangeListener { v, hasFocus -> - if (hasFocus) { - l.onFocusChange(v, hasFocus) - } - } - } - - override fun hideKeyboard(clearFocus: Boolean) { - val targetView = if (realEditViewAttach) mainInputView else mPixelInputView - PanelUtil.hideKeyboard(context, targetView) - if (clearFocus) { - targetView.clearFocus() - } - } - - override fun showKeyboard(): Boolean { - val targetView = if (realEditViewAttach) mainInputView else mPixelInputView - return PanelUtil.showKeyboard(context, targetView) - } - - override fun requestKeyboard() { - val targetView = if (realEditViewAttach) mainInputView else mPixelInputView - if (targetView.hasFocus()) { - targetView.performClick() - } else { - targetView.requestFocus() - } - } - } - } - - - override fun getInputActionImpl(): IInputAction = mInputAction - - override fun getResetActionImpl(): IResetAction = mResetAction - - override fun findTriggerView(id: Int): View? { - return mViewGroup.findViewById(id) - } - - private data class ViewPosition(val id: Int, val l: Int, val t: Int, val r: Int, val b: Int) { - var changeL: Int = l - var changeT: Int = t - var changeR: Int = r - var changeB: Int = b - - fun hasChange() = changeL != l || changeT != t || changeR != r || changeB != b - - fun change(newL: Int, newT: Int, newR: Int, newB: Int) { - changeL = newL - changeT = newT - changeR = newR - changeB = newB - } - - fun reset() { - changeL = l - changeT = t - changeR = r - changeB = b - } - } - - private val map = HashMap() - - override fun layoutContainer(l: Int, t: Int, r: Int, b: Int, - contentScrollMeasurers: MutableList, defaultScrollHeight: Int, canScrollOutsize: Boolean, - reset: Boolean) { - mViewGroup.layout(l, t, r, b) - if (!canScrollOutsize) { - return - } - for (contentScrollMeasurer in contentScrollMeasurers) { - val viewId = contentScrollMeasurer.getScrollViewId() - if (viewId != -1) { - val view = (mViewGroup).findViewById(viewId) - view.let { - var viewPosition = map[viewId] - if (viewPosition == null) { - viewPosition = ViewPosition(viewId, view.left, view.top, view.right, view.bottom) - map[viewId] = viewPosition - } - - var willScrollDistance = 0; - if (reset) { - if (viewPosition.hasChange()) { - val viewLeft = viewPosition.l - val viewTop = viewPosition.t - val viewRight = viewPosition.r - var viewBottom = viewPosition.b - view.layout(viewLeft, viewTop, viewRight, viewBottom) - viewPosition.reset(); - } - } else { - willScrollDistance = contentScrollMeasurer.getScrollDistance(defaultScrollHeight) - if (willScrollDistance > defaultScrollHeight) { - return - } - if (willScrollDistance < 0) { - willScrollDistance = 0 - } - val diffY = defaultScrollHeight - willScrollDistance; - viewPosition.change(viewPosition.l, viewPosition.t + diffY, viewPosition.r, viewPosition.b + diffY); - view.layout(viewPosition.changeL, viewPosition.changeT, viewPosition.changeR, viewPosition.changeB) - } - LogTracker.log("${PanelSwitchLayout.TAG}#onLayout", "ContentScrollMeasurer(id $viewId , defaultScrollHeight $defaultScrollHeight , scrollDistance $willScrollDistance reset $reset) origin (l ${viewPosition.l},t ${viewPosition.t},r ${viewPosition.l}, b ${viewPosition.b})") - LogTracker.log("${PanelSwitchLayout.TAG}#onLayout", "ContentScrollMeasurer(id $viewId , defaultScrollHeight $defaultScrollHeight , scrollDistance $willScrollDistance reset $reset) layout parent(l $l,t $t,r $r,b $b) self(l ${viewPosition.changeL},t ${viewPosition.changeT},r ${viewPosition.changeR}, b${viewPosition.changeB})") - } - } - } - } - - override fun changeContainerHeight(targetHeight: Int) { - val layoutParams = mViewGroup.layoutParams - if (layoutParams != null && layoutParams.height != targetHeight) { - layoutParams.height = targetHeight - mViewGroup.layoutParams = layoutParams - } - } - - override fun assertView() { - if (mEditText == null) { - throw RuntimeException("ContentContainer should set edit_view to get the editText!") - } - } -} \ No newline at end of file diff --git a/panel/src/main/java/com/effective/android/panel/view/content/FrameContentContainer.kt b/panel/src/main/java/com/effective/android/panel/view/content/FrameContentContainer.kt deleted file mode 100644 index 9e529fe..0000000 --- a/panel/src/main/java/com/effective/android/panel/view/content/FrameContentContainer.kt +++ /dev/null @@ -1,93 +0,0 @@ -package com.effective.android.panel.view.content - -import android.annotation.TargetApi -import android.content.Context -import android.support.annotation.IdRes -import android.util.AttributeSet -import android.view.MotionEvent -import android.view.View -import android.widget.FrameLayout -import com.effective.android.panel.R -import com.effective.android.panel.interfaces.ContentScrollMeasurer - -/** - * -------------------- - * | PanelSwitchLayout | - * | ---------------- | - * | | | | - * | |ContentContainer| | - * | | | | - * | ---------------- | - * | ---------------- | - * | | PanelContainer | | - * | ---------------- | - * -------------------- - * Created by yummyLau on 2020/05/07 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -class FrameContentContainer : FrameLayout, IContentContainer { - @IdRes - private var editTextId = 0 - - @IdRes - private var autoResetId = 0 - - private var autoResetByOnTouch :Boolean = true - private lateinit var contentContainer: ContentContainerImpl - - @JvmOverloads - constructor(context: Context?, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : super(context!!, attrs, defStyleAttr) { - initView(attrs, defStyleAttr, 0) - } - - @TargetApi(21) - constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context!!, attrs, defStyleAttr, defStyleRes) { - initView(attrs, defStyleAttr, defStyleRes) - } - - private fun initView(attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) { - val typedArray = context.obtainStyledAttributes(attrs, R.styleable.FrameContentContainer, defStyleAttr, 0) - editTextId = typedArray.getResourceId(R.styleable.FrameContentContainer_edit_view, -1) - autoResetId = typedArray.getResourceId(R.styleable.FrameContentContainer_auto_reset_area, -1) - autoResetByOnTouch = typedArray.getBoolean(R.styleable.FrameContentContainer_auto_reset_enable, autoResetByOnTouch) - typedArray.recycle() - } - - override fun onFinishInflate() { - super.onFinishInflate() - contentContainer = ContentContainerImpl(this,autoResetByOnTouch, editTextId, autoResetId) - val editText = getInputActionImpl().getFullScreenPixelInputView() - addView(editText, 0,LayoutParams(1, 1)) - } - - override fun layoutContainer(l: Int, t: Int, r: Int, b: Int, - contentScrollMeasurers: MutableList, defaultScrollHeight: Int, canScrollOutsize: Boolean, - reset: Boolean) { - contentContainer.layoutContainer(l, t, r, b, contentScrollMeasurers, defaultScrollHeight, canScrollOutsize,reset) - } - - override fun findTriggerView(id: Int): View? { - return contentContainer.findTriggerView(id) - } - - override fun changeContainerHeight(targetHeight: Int) { - contentContainer.changeContainerHeight(targetHeight) - } - - override fun dispatchTouchEvent(ev: MotionEvent?): Boolean { - val onTouchTrue = super.dispatchTouchEvent(ev) - val hookResult = getResetActionImpl().hookDispatchTouchEvent(ev, onTouchTrue) - return hookResult or onTouchTrue - } - - override fun onTouchEvent(event: MotionEvent?): Boolean { - val onTouchBySelf = super.onTouchEvent(event) - val hookResult = getResetActionImpl().hookOnTouchEvent(event) - return onTouchBySelf or hookResult - } - - override fun getInputActionImpl(): IInputAction = contentContainer.getInputActionImpl() - - override fun getResetActionImpl(): IResetAction = contentContainer.getResetActionImpl() -} \ No newline at end of file diff --git a/panel/src/main/java/com/effective/android/panel/view/content/IContentContainer.kt b/panel/src/main/java/com/effective/android/panel/view/content/IContentContainer.kt deleted file mode 100644 index 714a431..0000000 --- a/panel/src/main/java/com/effective/android/panel/view/content/IContentContainer.kt +++ /dev/null @@ -1,44 +0,0 @@ -package com.effective.android.panel.view.content - -import android.support.annotation.IdRes -import android.view.MotionEvent -import android.view.View -import android.view.View.OnFocusChangeListener -import android.widget.EditText -import com.effective.android.panel.interfaces.ContentScrollMeasurer - -interface IContentContainer { - //容器行为 - fun findTriggerView(@IdRes id: Int): View? - fun layoutContainer(l: Int, t: Int, r: Int, b: Int, - contentScrollMeasurer: MutableList, defaultScrollHeight: Int, canScrollOutsize: Boolean, - reset: Boolean) - - fun changeContainerHeight(targetHeight: Int) - - //输入相关 - fun getInputActionImpl(): IInputAction - - //隐藏相关 - fun getResetActionImpl(): IResetAction -} - -interface IInputAction { - fun addSecondaryInputView(editText: EditText) - fun removeSecondaryInputView(editText: EditText) - fun setEditTextClickListener(l: View.OnClickListener) - fun setEditTextFocusChangeListener(l: OnFocusChangeListener) - fun requestKeyboard() - fun hideKeyboard(clearFocus : Boolean) - fun showKeyboard() : Boolean - fun getFullScreenPixelInputView(): EditText - fun updateFullScreenParams(isFullScreen : Boolean, panelId : Int, panelHeight : Int) - fun recycler() -} - -interface IResetAction { - fun enableReset(enable: Boolean) - fun setResetCallback(runnable: Runnable) - fun hookDispatchTouchEvent(ev: MotionEvent?, consume: Boolean): Boolean - fun hookOnTouchEvent(ev: MotionEvent?): Boolean -} diff --git a/panel/src/main/java/com/effective/android/panel/view/content/LinearContentContainer.kt b/panel/src/main/java/com/effective/android/panel/view/content/LinearContentContainer.kt deleted file mode 100644 index 5c6ea06..0000000 --- a/panel/src/main/java/com/effective/android/panel/view/content/LinearContentContainer.kt +++ /dev/null @@ -1,95 +0,0 @@ -package com.effective.android.panel.view.content - -import android.annotation.TargetApi -import android.content.Context -import android.support.annotation.IdRes -import android.util.AttributeSet -import android.view.MotionEvent -import android.view.View -import android.widget.LinearLayout -import com.effective.android.panel.R -import com.effective.android.panel.interfaces.ContentScrollMeasurer - -/** - * -------------------- - * | PanelSwitchLayout | - * | ---------------- | - * | | | | - * | |ContentContainer| | - * | | | | - * | ---------------- | - * | ---------------- | - * | | PanelContainer | | - * | ---------------- | - * -------------------- - * Created by yummyLau on 2020/05/07 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -class LinearContentContainer : LinearLayout, IContentContainer { - @IdRes - private var editTextId = 0 - - @IdRes - private var autoResetId = 0 - private var autoResetByOnTouch: Boolean = true - private lateinit var contentContainer: ContentContainerImpl - - @JvmOverloads - constructor(context: Context?, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : super(context, attrs, defStyleAttr) { - initView(attrs, defStyleAttr, 0) - } - - @TargetApi(21) - constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) { - initView(attrs, defStyleAttr, defStyleRes) - } - - private fun initView(attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) { - val typedArray = context.obtainStyledAttributes(attrs, R.styleable.LinearContentContainer, defStyleAttr, 0) - editTextId = typedArray.getResourceId(R.styleable.LinearContentContainer_edit_view, -1) - autoResetId = typedArray.getResourceId(R.styleable.LinearContentContainer_auto_reset_area, -1) - autoResetByOnTouch = typedArray.getBoolean(R.styleable.LinearContentContainer_auto_reset_enable, autoResetByOnTouch) - typedArray.recycle() - orientation = VERTICAL - } - - override fun onFinishInflate() { - super.onFinishInflate() - contentContainer = ContentContainerImpl(this, autoResetByOnTouch, editTextId, autoResetId) - val editText = getInputActionImpl().getFullScreenPixelInputView() - val layoutParams = LayoutParams(1, 1) - layoutParams.topMargin = -1 - addView(editText,0,layoutParams) - } - - override fun layoutContainer(l: Int, t: Int, r: Int, b: Int, - contentScrollMeasurers: MutableList, defaultScrollHeight: Int, canScrollOutsize: Boolean, - reset: Boolean) { - contentContainer.layoutContainer(l, t, r, b, contentScrollMeasurers, defaultScrollHeight, canScrollOutsize,reset) - } - - override fun findTriggerView(id: Int): View? { - return contentContainer.findTriggerView(id) - } - - override fun changeContainerHeight(targetHeight: Int) { - contentContainer.changeContainerHeight(targetHeight) - } - - override fun dispatchTouchEvent(ev: MotionEvent?): Boolean { - val onTouchTrue = super.dispatchTouchEvent(ev) - val hookResult = getResetActionImpl().hookDispatchTouchEvent(ev, onTouchTrue) - return hookResult or onTouchTrue - } - - override fun onTouchEvent(event: MotionEvent?): Boolean { - val onTouchBySelf = super.onTouchEvent(event) - val hookResult = getResetActionImpl().hookOnTouchEvent(event) - return onTouchBySelf or hookResult - } - - override fun getInputActionImpl(): IInputAction = contentContainer.getInputActionImpl() - - override fun getResetActionImpl(): IResetAction = contentContainer.getResetActionImpl() -} \ No newline at end of file diff --git a/panel/src/main/java/com/effective/android/panel/view/content/RelativeContentContainer.kt b/panel/src/main/java/com/effective/android/panel/view/content/RelativeContentContainer.kt deleted file mode 100644 index 0b32396..0000000 --- a/panel/src/main/java/com/effective/android/panel/view/content/RelativeContentContainer.kt +++ /dev/null @@ -1,92 +0,0 @@ -package com.effective.android.panel.view.content - -import android.annotation.TargetApi -import android.content.Context -import android.support.annotation.IdRes -import android.util.AttributeSet -import android.view.MotionEvent -import android.view.View -import android.widget.RelativeLayout -import com.effective.android.panel.R -import com.effective.android.panel.interfaces.ContentScrollMeasurer - -/** - * -------------------- - * | PanelSwitchLayout | - * | ---------------- | - * | | | | - * | |ContentContainer| | - * | | | | - * | ---------------- | - * | ---------------- | - * | | PanelContainer | | - * | ---------------- | - * -------------------- - * Created by yummyLau on 2020/05/07 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -class RelativeContentContainer : RelativeLayout, IContentContainer { - @IdRes - private var editTextId = 0 - - @IdRes - private var autoResetId = 0 - private var autoResetByOnTouch: Boolean = true - private lateinit var contentContainer: ContentContainerImpl - - @JvmOverloads - constructor(context: Context?, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : super(context, attrs, defStyleAttr) { - initView(attrs, defStyleAttr, 0) - } - - @TargetApi(21) - constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) { - initView(attrs, defStyleAttr, defStyleRes) - } - - private fun initView(attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) { - val typedArray = context.obtainStyledAttributes(attrs, R.styleable.RelativeContentContainer, defStyleAttr, 0) - editTextId = typedArray.getResourceId(R.styleable.RelativeContentContainer_edit_view, -1) - autoResetId = typedArray.getResourceId(R.styleable.RelativeContentContainer_auto_reset_area, -1) - autoResetByOnTouch = typedArray.getBoolean(R.styleable.RelativeContentContainer_auto_reset_enable, autoResetByOnTouch) - typedArray.recycle() - } - - override fun onFinishInflate() { - super.onFinishInflate() - contentContainer = ContentContainerImpl(this, autoResetByOnTouch, editTextId, autoResetId) - val editText = getInputActionImpl().getFullScreenPixelInputView() - addView(editText, 0,LayoutParams(1, 1)) - } - - override fun layoutContainer(l: Int, t: Int, r: Int, b: Int, - contentScrollMeasurers: MutableList, defaultScrollHeight: Int, canScrollOutsize: Boolean, - reset: Boolean) { - contentContainer.layoutContainer(l, t, r, b, contentScrollMeasurers, defaultScrollHeight, canScrollOutsize, reset) - } - - override fun findTriggerView(id: Int): View? { - return contentContainer.findTriggerView(id) - } - - override fun changeContainerHeight(targetHeight: Int) { - contentContainer.changeContainerHeight(targetHeight) - } - - override fun dispatchTouchEvent(ev: MotionEvent?): Boolean { - val onTouchTrue = super.dispatchTouchEvent(ev) - val hookResult = getResetActionImpl().hookDispatchTouchEvent(ev, onTouchTrue) - return hookResult or onTouchTrue - } - - override fun onTouchEvent(event: MotionEvent?): Boolean { - val onTouchBySelf = super.onTouchEvent(event) - val hookResult = getResetActionImpl().hookOnTouchEvent(event) - return onTouchBySelf or hookResult - } - - override fun getInputActionImpl(): IInputAction = contentContainer.getInputActionImpl() - - override fun getResetActionImpl(): IResetAction = contentContainer.getResetActionImpl() -} \ No newline at end of file diff --git a/panel/src/main/java/com/effective/android/panel/view/panel/IPanelView.kt b/panel/src/main/java/com/effective/android/panel/view/panel/IPanelView.kt deleted file mode 100644 index b5752b0..0000000 --- a/panel/src/main/java/com/effective/android/panel/view/panel/IPanelView.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.effective.android.panel.view.panel - -import android.support.annotation.IdRes -import com.effective.android.panel.interfaces.ViewAssertion - -/** - * 扩展panelView - * 同时需要实现 ViewAssertion 校验 trigger 绑定的有效性,实现 IPanelView 应该是一个 ViewGroup - * created by yummylau on 2020/06/01 🧒儿童节 - */ -interface IPanelView : ViewAssertion { - - @IdRes - fun getBindingTriggerViewId(): Int - - fun isTriggerViewCanToggle(): Boolean - - fun isShowing():Boolean -} \ No newline at end of file diff --git a/panel/src/main/java/com/effective/android/panel/view/panel/PanelContainer.kt b/panel/src/main/java/com/effective/android/panel/view/panel/PanelContainer.kt deleted file mode 100644 index 6ac3bc5..0000000 --- a/panel/src/main/java/com/effective/android/panel/view/panel/PanelContainer.kt +++ /dev/null @@ -1,94 +0,0 @@ -package com.effective.android.panel.view.panel - -import android.annotation.TargetApi -import android.content.Context -import android.util.AttributeSet -import android.util.Pair -import android.util.SparseArray -import android.view.View -import android.widget.FrameLayout -import com.effective.android.panel.Constants -import com.effective.android.panel.interfaces.ViewAssertion - -/** - * -------------------- - * | PanelSwitchLayout | - * | ---------------- | - * | | | | - * | |ContentContainer| | - * | | | | - * | ---------------- | - * | ---------------- | - * | | PanelContainer | | - * | ---------------- | - * -------------------- - * Created by yummyLau on 18-7-10 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -class PanelContainer : FrameLayout, ViewAssertion { - var panelSparseArray = SparseArray() - private set - - @JvmOverloads - constructor(context: Context?, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : super(context!!, attrs, defStyleAttr) { - initView(attrs, defStyleAttr, 0) - } - - @TargetApi(21) - constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context!!, attrs, defStyleAttr, defStyleRes) { - initView(attrs, defStyleAttr, defStyleRes) - } - - private fun initView(attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) {} - - override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) { - super.onLayout(changed, left, top, right, bottom) - } - - override fun onFinishInflate() { - super.onFinishInflate() - assertView() - } - - override fun assertView() { - panelSparseArray = SparseArray() - for (i in 0 until childCount) { - val panel = getChildAt(i) as? IPanelView - ?: throw RuntimeException("PanelContainer -- PanelContainer's child should be IPanelView") - panelSparseArray.put(panel.getBindingTriggerViewId(), panel) - (panel as View).visibility = View.GONE - } - } - - fun getPanelView(panelId: Int): IPanelView? { - return panelSparseArray[panelId] - } - - fun getPanelId(panel: IPanelView?): Int { - return panel?.getBindingTriggerViewId() ?: Constants.PANEL_KEYBOARD - } - - fun showPanel(panelId: Int, size: Pair): Pair { - val panel = panelSparseArray[panelId] - for (i in 0 until panelSparseArray.size()) { - val panelView = panelSparseArray[panelSparseArray.keyAt(i)] - if (panelView is View) - panelView.visibility = if (panelView != panel) View.GONE else View.VISIBLE - } - val layoutParams = (panel as View).layoutParams - val curSize = Pair(layoutParams.width, layoutParams.height) - if (curSize.first != size.first || curSize.second != size.second) { - layoutParams.width = size.first - layoutParams.height = size.second - (panel as View).layoutParams = layoutParams - } - return curSize - } - - fun changeContainerHeight(targetHeight: Int) { - if (layoutParams != null && layoutParams.height != targetHeight) { - layoutParams.height = targetHeight - } - } -} \ No newline at end of file diff --git a/panel/src/main/java/com/effective/android/panel/view/panel/PanelView.kt b/panel/src/main/java/com/effective/android/panel/view/panel/PanelView.kt deleted file mode 100644 index f2e6904..0000000 --- a/panel/src/main/java/com/effective/android/panel/view/panel/PanelView.kt +++ /dev/null @@ -1,67 +0,0 @@ -package com.effective.android.panel.view.panel - -import android.annotation.TargetApi -import android.content.Context -import android.util.AttributeSet -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.FrameLayout -import com.effective.android.panel.R -import com.effective.android.panel.view.panel.IPanelView - -/** - * interface, everyPanel should implements - * Created by yummyLau on 18-7-07 - * Email: yummyl.lau@gmail.com - * blog: yummylau.com - */ -class PanelView : FrameLayout, IPanelView { - private var panelLayoutId = 0 - private var triggerViewId = 0 - private var isToggle = true - - @JvmOverloads - constructor(context: Context?, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : super(context!!, attrs, defStyleAttr) { - initView(attrs, defStyleAttr, 0) - } - - @TargetApi(21) - constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context!!, attrs, defStyleAttr, defStyleRes) { - initView(attrs, defStyleAttr, defStyleRes) - } - - private fun initView(attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) { - val typedArray = context.obtainStyledAttributes(attrs, R.styleable.PanelView, defStyleAttr, 0) - panelLayoutId = typedArray.getResourceId(R.styleable.PanelView_panel_layout, -1) - triggerViewId = typedArray.getResourceId(R.styleable.PanelView_panel_trigger, -1) - isToggle = typedArray.getBoolean(R.styleable.PanelView_panel_toggle, isToggle) - typedArray.recycle() - } - - override fun getBindingTriggerViewId(): Int = triggerViewId - - override fun isTriggerViewCanToggle(): Boolean = isToggle - - override fun isShowing(): Boolean = isShown - - override fun assertView() { - if (panelLayoutId == -1 || triggerViewId == -1) { - throw RuntimeException("PanelView -- you must set 'panel_layout' and panel_trigger by Integer id") - } - if (childCount > 0) { - throw RuntimeException("PanelView -- you can't have any child!") - } - //默认实现 FrameLayout 恒为false,这里只是强调申明而已,可以不写。 - if (this !is View) { - throw RuntimeException("PanelView -- should be a view!") - } - LayoutInflater.from(context).inflate(panelLayoutId, this, true) - } - - override fun onFinishInflate() { - super.onFinishInflate() - assertView() - } - -} \ No newline at end of file diff --git a/panel/src/main/java/com/effective/android/panel/window/PanelDialog.kt b/panel/src/main/java/com/effective/android/panel/window/PanelDialog.kt deleted file mode 100644 index 773aef9..0000000 --- a/panel/src/main/java/com/effective/android/panel/window/PanelDialog.kt +++ /dev/null @@ -1,49 +0,0 @@ -package com.effective.android.panel.window - -import android.app.Dialog -import android.content.Context -import android.content.DialogInterface -import android.graphics.Color -import android.graphics.drawable.ColorDrawable -import android.support.annotation.LayoutRes -import android.view.Gravity -import android.view.LayoutInflater -import android.view.View -import android.view.WindowManager -import com.effective.android.panel.PanelSwitchHelper - -/** - * 提供给外部使用的dialog,场景用于类 微博评论/微信朋友圈 - * created by yummylau on 2020/06/04 - */ -abstract class PanelDialog : Dialog { - - @JvmField - protected val rootView: View - - @JvmField - protected var helper: PanelSwitchHelper? = null - - constructor(context: Context) : super(context) - constructor(context: Context, themeResId: Int) : super(context, themeResId) - constructor(context: Context, cancelable: Boolean, cancelListener: DialogInterface.OnCancelListener?) : super(context, cancelable, cancelListener) - - @LayoutRes - abstract fun getDialogLayout(): Int - - init { - rootView = LayoutInflater.from(context).inflate(getDialogLayout(), null, false) - setContentView(rootView) - window?.let { - it.setGravity(Gravity.CENTER) - it.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) - val lp = it.attributes - lp.width = WindowManager.LayoutParams.MATCH_PARENT - lp.height = WindowManager.LayoutParams.MATCH_PARENT - it.attributes = lp - it.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) - it.setDimAmount(0f) - it.setType(WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) - } - } -} \ No newline at end of file diff --git a/panel/src/main/res/values/attr.xml b/panel/src/main/res/values/attr.xml deleted file mode 100644 index 6e9b555..0000000 --- a/panel/src/main/res/values/attr.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/panel/src/main/res/values/ids.xml b/panel/src/main/res/values/ids.xml deleted file mode 100644 index 84f599a..0000000 --- a/panel/src/main/res/values/ids.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/source/demo.apk b/source/demo.apk index aee963d..55a148c 100644 Binary files a/source/demo.apk and b/source/demo.apk differ diff --git a/versions.gradle b/versions.gradle index 1d5f006..ee9999d 100644 --- a/versions.gradle +++ b/versions.gradle @@ -3,8 +3,7 @@ def versions = [:] versions.android_gradle_plugin = android_gradle_plugin versions.support = "27.1.1" versions.pageindicator = "1.0.1" -versions.panelSwitchHelper = "1.3.13" -versions.panelSwitchHelper_androidx = "1.3.13" +versions.panelSwitchHelper = "1.4.0" versions.multidex = "1.0.1" versions.constraint = "1.1.2" versions.circleimageview = "3.1.0" @@ -30,6 +29,7 @@ ext.deps.androidx = androidx ext.deps.pageindicator = "com.romandanylyk:pageindicatorview:$versions.pageindicator" ext.deps.android_gradle_plugin = "com.android.tools.build:gradle:$versions.android_gradle_plugin" +ext.deps.panelSwitchHelper_androidx = "com.github.YummyLau:PanelSwitchHelper:$versions.panelSwitchHelper" ext.deps.circleimageview = "de.hdodenhof:circleimageview:$versions.circleimageview" def config = [:]