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

New Website

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.
  5. Pomodoro
  6. Custom achievement complete condition
  7. Shop Item usage effect
  8. Better user guide
  9. Loot boxes (working on it)
  10. Dropbox (working on it)


Support Us

Support 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 also lots of ideas we want to achieve.

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


Release Log

1.80.7(2021/01/26)

  1. Add shop item statistic
  2. Redesign attributes description dialog
  3. Custom attributes description
  4. Add a config settings for compact mode: hide all extra info
  5. Fixed a restore from backup file bug
  6. More fixes and improvements…

1.80.6(2021/01/22)

  1. Now the item with loot boxes effect can be shared to market
  2. New search page: now you can searching user by nickname
  3. Filter team/makret items with time range
  4. Quick add tasks notification
  5. Media files can be ignored when performing backup.
  6. More fixes and improvements…

1.80.5(2021/01/14)

  1. Open 10/50 loot boxes by one click
  2. Add unlock condition [Get selected item for specify times from Loot Boxes]
  3. ATM interest rate settings
  4. Input number for selling/eating tomatoes
  5. Custom rest timer end sound effect
  6. Add some user guide
  7. Fixed some problems and make some improvements

1.80.4(2021/01/04)

  1. Fix a crash on Android 6

1.80.3(2021/01/04)

  1. Free style crop picture
  2. View/Add the icon of the items in the market
  3. When selecting task/item, now you can create a new one directly
  4. Support COPY action for user achievements
  5. A lot of fixes and improvements

1.80.0(2020/12/24)

  1. Loot boxes shop item effect!
  2. Integrated with Dropbox backup
  3. Configurations for compact mode
  4. Add photo select history bar
  5. A lot of fixes and improvements

1.79.x(2020/12)

  1. 3 more unlock condition settings
  2. Custom sound effects settings
  3. Set item reward for achievements
  4. Pomodoro timer record page
  5. Create task from the Calendar page
  6. 5 new theme color.
  7. Lots of improvements and fixes

1.78.x(2020/11)

  1. Custom achievements unlock condition
  2. Custom task experience points
  3. Lots of improvements and fixes

1.77.1(2020/11/05)

  1. List switch toolbar
  2. Show completed task switch
  3. List can be archived now
  4. Add coin status card
  5. Now you can create feelings for a user achivements
  6. Add a setting to follow system’s night mode

1.77.0(2020/10/28)

  1. Add Market module for community, in where you can share the shop item design or import the item
  2. Fix the logic of the month repeat
  3. Fix webdav auto backup not working when haven’t backup at least once

1.76.0(2020/10/13)

  1. Default coin of subtask
  2. Add in-app icons for creating shop item and achievements
  3. Custom tomato price
  4. Global sound effect enable settings
  5. Now feelings can be search by task content

1.75.2(Released at 2020/10/05)

  1. Default coin number setting of subtask
  2. Add over 100+ icons that can be selected as shop item/achievements icons
  3. add “Enable sound effect” settings
  4. Filter feelings by task content and better ui of filters
  5. Create pomodoro shortcuts
  6. Custom tomatoes selling prices
  7. Pomodoro page will keep screen on when counting down now
  8. Fixed some problems

1.75.1(Released at 2020/09/20)

  1. Fix lots bugs of 1.75.0

1.75.0(Released at 2020/09/16)

  1. Gamify pomodoro timer
  2. Custom task/list tag color
  3. WebDAV auto backup
  4. Hide modules settings
  5. Lots of improvements and fixes

1.74.2(Released at 2020/08/23)

  1. Portuguese Language

1.74.0(Released at 2020/08/13)

  1. ATM: Deposit & Withdrawal coins
  2. Now support that selecting shop items as task reward
  3. Shop item stock quantity setting
  4. Improve animation and fixed some bugs
  5. Add hint for Repeat Frequency setting
  6. More.. (update description later)

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

人升LifeUp常见问题-事项篇

这里会讲解事项相关的内容~
比如怎么创建工作日事项、计数事项如何使用以及各种使用案例。

目录

  1. 建立事项
    1.1 设置介绍
    1.1.1 重复频次
    1.1.1.1 [艾宾浩斯记忆法](#艾宾浩斯记忆法的时间表)
    1.1.1.2 [设置忽略日(每周几,如工作日事项)](#设置忽略日(每周几,如工作日事项))
    
    1.1.2 完成奖励
    1.1.3 目标重复次数
    1.1.4 计数事项
    1.2 例子
    1.2.1 普通待办事项/琐事/购物清单
    1.2.2 习惯养成(每日早起、每周跑步等)
    1.2.3 每周一-周日
    1.2.4 当天23:00-第二天2:00
    1.2.5 指定每周几(仅工作日、仅周末等)
    1.2.6 坏习惯惩罚
  2. 清单管理
    2.1 清单分类
    2.2 筛选排序
    2.3 自定义排序
  3. 稍后阅读
阅读更多

人升更新介绍#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参数,实现清单选择。

阅读更多