Skip to content

Commit

Permalink
优化类和方法命名
Browse files Browse the repository at this point in the history
优化判断点击事件逻辑
新增扩展一些 API 方法
  • Loading branch information
getActivity committed Dec 12, 2021
1 parent df99bce commit 842b335
Show file tree
Hide file tree
Showing 38 changed files with 936 additions and 378 deletions.
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: https://raw.githubusercontent.com/getActivity/Donate/master/picture/pay_ali.png
41 changes: 41 additions & 0 deletions .github/ISSUE_TEMPLATE/issue_template_bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
name: 提交 Bug
about: 请告诉我框架存在的问题,我会协助你解决此问题!
labels: bug
assignees: getActivity

---

## 问题描述

* 框架版本:XXX

* 问题描述:XXX

* 复现步骤:XXX

* 是否必现:填是/否

* 手机信息:例如某米 9 / Android 10

## 请回答

* 是部分机型还是所有机型都会出现:部分/全部(例如:某为,某 Android 版本会出现)

* 框架最新的版本是否存在这个问题:是/否(如果用的是旧版本的话,建议升级看问题是否还存在)

* 是否已经查阅框架文档还未能解决的:是/否(文档会提供最常见的问题解答,可以看看是否有自己想要的)

* issue 是否有人曾提过类似的问题:是/否(看看曾经有人提过类似的问题,先参考一下别人是怎么解决的)

* 是否可以通过 Demo 来复现该问题:是/否(排查一下是不是自己的项目代码写得有问题导致的)

* 使用原生 API 是否会出现该问题:是/否(排查一下是不是框架的代码写法存在问题导致的)

## 其他

* 提供报错堆栈(如果有报错的话必填)

* 提供截图或视频(根据需要提供,此项不强制)

* 提供解决方案(如果已经解决了的话,此项不强制)
13 changes: 13 additions & 0 deletions .github/ISSUE_TEMPLATE/issue_template_suggest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
name: 提交建议
about: 请告诉我框架的不足之处,让我做得更好!
labels: bug
assignees: getActivity

---

## 建议收集

* 你觉得框架有什么不足之处?(必答项,你可以描述框架有什么令你不满意的地方)

* 你觉得该怎么去完善会比较好?(非必答项,你可以提供一下自己的想法或者做法供作者参考)
17 changes: 17 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Android CI

on: [push]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Gradle
run: ./gradlew build aR
65 changes: 47 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,52 @@

* 博客地址:[悬浮窗需求终结者](https://www.jianshu.com/p/247d705b87b6)

* 已投入公司项目多时,没有任何毛病,可胜任任何需求,[点击此处下载Demo](XToast.apk)
* 可以扫码下载 Demo 进行演示或者测试,如果扫码下载不了的,[点击此处可直接下载](https://github.com/getActivity/XToast/releases/download/8.5/XToast.apk)

![](XToast.gif)
![](picture/demo_code.png)

![](picture/dynamic_figure.gif)

#### 本框架意在解决一些极端需求,如果是普通的 Toast 封装推荐使用 [ToastUtils](https://github.com/getActivity/ToastUtils)

#### 集成步骤

* 在项目根目录下的 `build.gradle` 文件中加入
* 如果你的项目 Gradle 配置是在 `7.0 以下`,需要在 `build.gradle` 文件中加入

```groovy
buildscript {
allprojects {
repositories {
// JitPack 远程仓库:https://jitpack.io
maven { url 'https://jitpack.io' }
}
}
allprojects {
```

* 如果你的 Gradle 配置是 `7.0 及以上`,则需要在 `settings.gradle` 文件中加入

```groovy
dependencyResolutionManagement {
repositories {
// JitPack 远程仓库:https://jitpack.io
maven { url 'https://jitpack.io' }
}
}
```

* 在项目 app 模块下的 `build.gradle` 文件中加入
* 配置完远程仓库后,在项目 app 模块下的 `build.gradle` 文件中加入远程依赖

```groovy
android {
// 支持 JDK 1.8
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
// 悬浮窗框架:https://github.com/getActivity/XToast
implementation 'com.github.getActivity:XToast:8.3'
implementation 'com.github.getActivity:XToast:8.5'
}
```

Expand All @@ -43,7 +60,7 @@ dependencies {
```java
// 传入 Activity 对象表示设置成局部的,不需要有悬浮窗权限
// 传入 Application 对象表示设置成全局的,但需要有悬浮窗权限
new XToast<>(XToastActivity.this)
new XToast<>(this)
.setContentView(R.layout.toast_hint)
// 设置成可拖拽的
//.setDraggable()
Expand Down Expand Up @@ -138,7 +155,7 @@ public final class FloatingLifecycle implements Application.ActivityLifecycleCal
@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
new XToast<>(activity)
.setXxx()
.setView(R.layout.xxx)
.show();
}

Expand Down Expand Up @@ -178,23 +195,35 @@ public final class FloatingLifecycle implements Application.ActivityLifecycleCal

#### 作者的其他开源项目

* 安卓技术中台:[AndroidProject](https://github.com/getActivity/AndroidProject)
* 安卓技术中台:[AndroidProject](https://github.com/getActivity/AndroidProject) ![](https://img.shields.io/github/stars/getActivity/AndroidProject.svg) ![](https://img.shields.io/github/forks/getActivity/AndroidProject.svg)

* 安卓技术中台 Kt 版:[AndroidProject-Kotlin](https://github.com/getActivity/AndroidProject-Kotlin) ![](https://img.shields.io/github/stars/getActivity/AndroidProject-Kotlin.svg) ![](https://img.shields.io/github/forks/getActivity/AndroidProject-Kotlin.svg)

* 权限框架:[XXPermissions](https://github.com/getActivity/XXPermissions) ![](https://img.shields.io/github/stars/getActivity/XXPermissions.svg) ![](https://img.shields.io/github/forks/getActivity/XXPermissions.svg)

* 吐司框架:[ToastUtils](https://github.com/getActivity/ToastUtils) ![](https://img.shields.io/github/stars/getActivity/ToastUtils.svg) ![](https://img.shields.io/github/forks/getActivity/ToastUtils.svg)

* 网络框架:[EasyHttp](https://github.com/getActivity/EasyHttp) ![](https://img.shields.io/github/stars/getActivity/EasyHttp.svg) ![](https://img.shields.io/github/forks/getActivity/EasyHttp.svg)

* 标题栏框架:[TitleBar](https://github.com/getActivity/TitleBar) ![](https://img.shields.io/github/stars/getActivity/TitleBar.svg) ![](https://img.shields.io/github/forks/getActivity/TitleBar.svg)

* Shape 框架:[ShapeView](https://github.com/getActivity/ShapeView) ![](https://img.shields.io/github/stars/getActivity/ShapeView.svg) ![](https://img.shields.io/github/forks/getActivity/ShapeView.svg)

* 网络框架:[EasyHttp](https://github.com/getActivity/EasyHttp)
* 语种切换框架:[MultiLanguages](https://github.com/getActivity/MultiLanguages) ![](https://img.shields.io/github/stars/getActivity/MultiLanguages.svg) ![](https://img.shields.io/github/forks/getActivity/MultiLanguages.svg)

* 权限框架:[XXPermissions](https://github.com/getActivity/XXPermissions)
* Gson 解析容错:[GsonFactory](https://github.com/getActivity/GsonFactory) ![](https://img.shields.io/github/stars/getActivity/GsonFactory.svg) ![](https://img.shields.io/github/forks/getActivity/GsonFactory.svg)

* 吐司框架:[ToastUtils](https://github.com/getActivity/ToastUtils)
* 日志查看框架:[Logcat](https://github.com/getActivity/Logcat) ![](https://img.shields.io/github/stars/getActivity/Logcat.svg) ![](https://img.shields.io/github/forks/getActivity/Logcat.svg)

* 标题栏框架:[TitleBar](https://github.com/getActivity/TitleBar)
* Android 版本适配:[AndroidVersionAdapter](https://github.com/getActivity/AndroidVersionAdapter) ![](https://img.shields.io/github/stars/getActivity/AndroidVersionAdapter.svg) ![](https://img.shields.io/github/forks/getActivity/AndroidVersionAdapter.svg)

* 国际化框架:[MultiLanguages](https://github.com/getActivity/MultiLanguages)
* Android 代码规范:[AndroidCodeStandard](https://github.com/getActivity/AndroidCodeStandard) ![](https://img.shields.io/github/stars/getActivity/AndroidCodeStandard.svg) ![](https://img.shields.io/github/forks/getActivity/AndroidCodeStandard.svg)

* Shape 框架:[ShapeView](https://github.com/getActivity/ShapeView)
* Studio 精品插件:[StudioPlugins](https://github.com/getActivity/StudioPlugins) ![](https://img.shields.io/github/stars/getActivity/StudioPlugins.svg) ![](https://img.shields.io/github/forks/getActivity/StudioPlugins.svg)

* Gson 解析容错:[GsonFactory](https://github.com/getActivity/GsonFactory)
* 表情包大集合:[EmojiPackage](https://github.com/getActivity/EmojiPackage) ![](https://img.shields.io/github/stars/getActivity/EmojiPackage.svg) ![](https://img.shields.io/github/forks/getActivity/EmojiPackage.svg)

* 日志查看框架:[Logcat](https://github.com/getActivity/Logcat)
* 省市区 Json 数据:[ProvinceJson](https://github.com/getActivity/ProvinceJson) ![](https://img.shields.io/github/stars/getActivity/ProvinceJson.svg) ![](https://img.shields.io/github/forks/getActivity/ProvinceJson.svg)

#### 微信公众号:Android轮子哥

Expand Down
Binary file removed XToast.apk
Binary file not shown.
Binary file removed XToast.gif
Binary file not shown.
18 changes: 9 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 30
compileSdkVersion 31

defaultConfig {
applicationId "com.hjq.xtoast.demo"
minSdkVersion 16
targetSdkVersion 30
versionCode 83
versionName "8.3"
targetSdkVersion 31
versionCode 85
versionName "8.5"
}

// 支持 Java JDK 8
Expand Down Expand Up @@ -50,8 +50,8 @@ android {
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation fileTree(include: ['*.aar'], dir: 'libs')
// 依赖 libs 目录下所有的 jar 和 aar 包
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
implementation project(':library')

// AndroidX 库:https://github.com/androidx/androidx
Expand All @@ -60,13 +60,13 @@ dependencies {
implementation 'com.google.android.material:material:1.4.0'

// 权限请求框架:https://github.com/getActivity/XXPermissions
implementation 'com.github.getActivity:XXPermissions:12.3'
implementation 'com.github.getActivity:XXPermissions:13.2'

// 标题栏框架:https://github.com/getActivity/TitleBar
implementation 'com.github.getActivity:TitleBar:9.2'
implementation 'com.github.getActivity:TitleBar:9.3'

// 吐司框架:https://github.com/getActivity/ToastUtils
implementation 'com.github.getActivity:ToastUtils:9.5'
implementation 'com.github.getActivity:ToastUtils:10.0'

// 内存泄漏捕捉:https://github.com/square/leakcanary
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7'
Expand Down
64 changes: 37 additions & 27 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hjq.xtoast.demo">

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

<application
android:name=".AppApplication"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme">

<activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hjq.xtoast.demo">

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

<application
android:name=".AppApplication"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme">

<activity
android:name=".MainActivity"
android:exported="true">

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>

<!-- Android 11 软件包可见性适配 -->
<queries>

<!-- 调起其他页面意图:Intent.ACTION_VIEW -->
<intent>
<action android:name="android.intent.action.VIEW" />
</intent>

</queries>

</manifest>
6 changes: 3 additions & 3 deletions app/src/main/java/com/hjq/xtoast/demo/IOSToast.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public final class IOSToast {
public static void showSucceed(Activity activity, CharSequence text) {
new XToast<>(activity)
.setDuration(TIME)
.setContentView(R.layout.toast_hint)
.setContentView(R.layout.window_hint)
.setAnimStyle(android.R.style.Animation_Translucent)
.setImageDrawable(android.R.id.icon, R.mipmap.ic_dialog_tip_finish)
.setText(android.R.id.message, text)
Expand All @@ -27,7 +27,7 @@ public static void showSucceed(Activity activity, CharSequence text) {
public static void showFail(Activity activity, CharSequence text) {
new XToast<>(activity)
.setDuration(TIME)
.setContentView(R.layout.toast_hint)
.setContentView(R.layout.window_hint)
.setAnimStyle(android.R.style.Animation_Activity)
.setImageDrawable(android.R.id.icon, R.mipmap.ic_dialog_tip_error)
.setText(android.R.id.message, text)
Expand All @@ -37,7 +37,7 @@ public static void showFail(Activity activity, CharSequence text) {
public static void showWarn(Activity activity, CharSequence text) {
new XToast<>(activity)
.setDuration(TIME)
.setContentView(R.layout.toast_hint)
.setContentView(R.layout.window_hint)
.setAnimStyle(android.R.style.Animation_Dialog)
.setImageDrawable(android.R.id.icon, R.mipmap.ic_dialog_tip_warning)
.setText(android.R.id.message, text)
Expand Down
Loading

0 comments on commit 842b335

Please sign in to comment.