Android DialogFragment 相关代码段

设置软键盘弹出,自动上移

1
2
3
4
5
6
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
...
// 设置有软键盘时,窗口自动上移
dialog?.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
...
}

设置全屏显示

1
2
3
4
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(STYLE_NORMAL, R.style.Dialog_FullScreen)
}
1
2
3
4
5
<style name="Dialog.FullScreen" parent="Theme.AppCompat.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@color/transparent</item>
<item name="android:windowIsFloating">false</item>
</style>

子Fragment

1
2
3
4
5
private fun replace(fragment: androidx.fragment.app.Fragment) {
val transaction = childFragmentManager.beginTransaction()
transaction.replace(R.id.fragment, fragment)
transaction.commit()
}
阅读更多

Android动画相关代码段

ValueAnimator 实现TextView打字机效果

1
2
3
4
5
6
7
8
9
10
11
fun TextView.startTypeAnimation(duration: Long = 300) {
val originText = this.text
val valueAnimator = ValueAnimator.ofInt(0, originText.length)
valueAnimator.duration = duration
valueAnimator.interpolator = LinearInterpolator()
valueAnimator.addUpdateListener { animation ->
val length = animation.animatedValue as Int
this.text = originText.subSequence(0, length)
}
valueAnimator.start()
}

SpringInterpolator 简易的弹性插值器

1
2
3
4
5
6
7
8
/**
* 弹性插值器
*/
class SpringInterpolator(private val factor: Float) : Interpolator {
override fun getInterpolation(input: Float): Float {
return (2.0.pow((-10 * input).toDouble()) * sin((input - factor / 4) * (2 * Math.PI) / factor) + 1).toFloat()
}
}
阅读更多

LifeUp Release Log

Future Plan

  1. Custom Achievements
  2. Link Complete Reward of task to the inventory.
  3. Custom Exp of task
  4. Better settings of creating a task.


Support Us

Donations are always appreciated and help support the project. ❤️

With your support, we can get more time to developing and request more design resources to make it better. And there are lots of ideas we want to achieve.

Via PayPal: https://www.paypal.me/ayagikei

Share the application to your friends will also be a great help. ❤️


Release Log

1.73.0(Released at 2020/07/26)

Features:

  • User achievements
  • Exp decrease animation
  • Edit the completed time of history record
  • Team subtask coin setting

Improvement:

  • Add coin sound effect

Fix:

  • The problem of losing subtask coin setting after repeating a task

1.72.1(Released at 2020/06/14)

Features:

  • Clear achievements data

Improvement:

  • Better display of shop item description

Fix:

  • The problem of editing pictures of shop items
  • The problem of editing the text of feelings

1.72.0(Released at 2020/06/11)

Features:

  • Subtask Remind
  • Subtask Coin
  • App Widget
    1. Opacity Setting
    2. Display Coin Number
    3. Display Count Task Input Dialog
  • Statistics Page Time Select
  • Inventory: Return Item
  • Add subtask support for team

Improvement:

  • Swipe a count task now will add 1 completed time instead of marking it as completed
  • Add Help Translate Button
  • Add Enabled Multi Exp Reward Setting for count task

Fix:

  • Fixed that transparent part of png picture showing black after cropping.
  • Fixed that App Widget not working well on some devices.
  • Fixed that Coin Number showing in the Detail Page when it’s set to 0.
  • Fixed that Swipe to Finish (no dialog mode) will make the page displayed incorrectly
  • Fixed that subtask cannot be created when click the ENTER button on some devices

1.71.3/1.71.4(Released at 2020/04/16)

Minor Fixes about icon and crash report

1.71.2(Released at 2020/04/14)

Features:

  • Turkish Language (thanks İbrahim DOĞAN for helping translation)

  • Customize task card background and opacity

  • Customize the action button text of inventory item
  • Feelings Favorites
  • Feelings Search

Improvement:

  • New Icon

  • Report type support multiple languages

  • Improve UI of the Settings Page
  • Improve the method of switching theme color and language. No need to restart the app to make it work.
  • Improve the crop picture page
  • Improve UI of the select list
  • Add shop item description showing on the shop item list page

Fixed:

  • Fixed bug that achievement unlock date incorrectly showing
  • Fixed bug that shop item picture showing empty when the file deleted.
  • Not clear the status of sub-tasks after single task become overdue.
  • Fixed bug that not enough space for Difficulty Degree to show in the Task Detail Page.
  • Fixed bug that after setting overdue task to finished, completed times of the next task not plus one.
  • Fixed bug that the max coin number not showing correctly in the task default settings.
  • Make the data backup/restore page scrollable.
  • Fixed that swipe to complete task not working well when fast swiping multiple tasks.
  • Now app widgets will show the Frozen status
  • Fixed bug that the progress bar on task page showing incorrect progress sometimes

Server Fixed(2020/4/13)

  • Fixed that report function not working

v1.71.1 (Released at 2020/03/17)

Improvement:

  • Better progress bar animation in task page

Fixed:

  • Fixed a bug that may cause crash when launching application on some devices
  • Fixed a bug about selecting photos
阅读更多

Android 5.0共享元素崩溃

简介

后台监测到了数个仅限于Android5的崩溃问题,日志大概如下:

1
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.ViewParent android.view.View.getParent()' on a null object reference at android.view.ViewOverlay$OverlayViewGroup.add(ViewOverlay.java:164) at android.view.ViewGroupOverlay.add(ViewGroupOverlay.java:63) at android.app.EnterTransitionCoordinator.startRejectedAnimations(EnterTransitionCoordinator.java:598) at android.app.EnterTransitionCoordinator.startSharedElementTransition(EnterTransitionCoordinator.java:325) at android.app.EnterTransitionCoordinator.access$200(EnterTransitionCoordinator.java:42) at android.app.EnterTransitionCoordinator$5$1.run(EnterTransitionCoordinator.java:389) at android.app.ActivityTransitionCoordinator.startTransition(ActivityTransitionCoordinator.java:698) at android.app.EnterTransitionCoordinator$5.onPreDraw(EnterTransitionCoordinator.java:386) at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:847) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1985) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1077) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5845) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) at android.view.Choreographer.doCallbacks(Choreographer.java:580) at android.view.Choreographer.doFrame(Choreographer.java:550) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5272) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)

查了下资料,发现这是 Android 5.0 系统的内置Bug。

在执行切换动画的时候,有一定条件下会导致崩溃问题。

并且,在 API level 22(即 Android 5.1)之后,这个 bug 已经被修复了。

最简单也是最有效的解决方法:

只有在API level 22的情况下,再执行切换动画。

其他

也有一些想要在 Android 5.0 继续使用切换动画,避免崩溃的解决方案。

这个 Android 系统 bug 与分享元素的选取排除(’rejected’)的处理有关。如果一个分享元素在执行动画的时候没有 attached to the window 就有可能被拒绝,也就是当 View 可见性为 GONE 的时候。

所以,解决方法就是在执行切换动画的时候,检查每一个共享元素View,并且将可见性改为 VISIBLE

Glenn Schmidt

参考

https://stackoverflow.com/questions/34658911/entertransitioncoordinator-causes-npe-in-android-5-0

人升更新介绍#1.70.1 | 02/22 简洁模式

大家好~欢迎查阅本次更新日志。

v1.70.1的版本已经于2月14号发布了,修复了v1.70.0的数个问题。遇到一些奇怪的问题的用户可以升级下版本。

今年以来,「人升」陆续地登上了更多的应用市场:应用宝、华为应用市场、豌豆荚、360应用市场、UC等。

现在可以在上述的一些平台进行应用更新了。

(之前仅登录了酷安、小米、魅族、Google Play市场。华为应用市场的之前被侵权了,这次也靠着大家的举报和申诉成功拿回来了管理权)

本文会简单介绍各个新功能,以及其使用方法。

比如讲解了如何用坚果云做WebDAV备份。

总览

  1. 简洁模式

  2. 图片附件

  3. WebDAV备份

  4. 自定义属性

  5. 更多改进

    5.1 “撤销”功能优化

    5.2 动态显示效果优化

  6. 详细更新日志

阅读更多

人升更新介绍#1.69.0 | 01/02 子任务

上周六已经发布了本次1.69.0的更新。

更新内容覆盖面较广,本以为会出现很多问题,现在看来还好~

因为更新比较匆忙,当时没写更新介绍,现在补上。

有的更新内容不看更新日志不容易察觉,比如团队事项编辑的开放。

这次更新的主题是加强实用性,增强各个功能模块

开始正题之前,先发下这篇文章的总览:

总览

  1. 子任务

  2. 逾期处理

  3. 自定义排序以及菜单重制

  4. 桌面小部件升级

  5. 更多改进

    5.1 冻结

    5.2 编辑团队事项

  6. 详细更新日志

阅读更多

人升开发日志#18 | 12/22 优化遇到的坑

这个系列好久没更新了(离目标日渐遥远

这段时间的开发其实遇到了不少问题,不过都没及时记录导致最后也忘记了。

这里记一下新鲜的优化遇到的坑吧。

桌面小部件

之前匆忙写的桌面小部件是不支持分别显示不同清单的,并且还只能显示“所有”。

需要实现在桌面小部件,点击可以直接选择清单。

这里选择了透明Activity+BottomSheetDialog的方案,看上去没打开应用就进行了选择。

实现清单选择功能

第一步:实现透明Activity

透明Style(其实是历史代码):

1
2
3
4
5
6
7
8
9
10
<style name="Transparent_Activity" parent="AppTheme.NoActionBar">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowDisablePreview">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>

并且这个Activity应该是独立栈,所以将启动模式设置为singleInstance

并且在Activity处理Intent传递过来的appWidgetId参数,实现清单选择。

阅读更多

人升更新介绍#1.68.0 | 11/24 全新的成就、日历系统

欢迎更新到v1.68.0~

这个版本可能是比肩商店系统的一次重要更新。

首先是实现了远比之前版本完善的成就系统,其次也更新了日历视图,各个页面也有大大小小的优化。

开始正题之前,先发下这篇文章的总览:

总览

  1. 全新的成就系统,56种成就。
  2. 日历视图
  3. 金币详情
  4. 历史页面
  5. 其他改进
  6. To Do
阅读更多