-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
优化Eink主题效果: 1.移除Eink主题时dialog及UI控件阴影; 2.Eink主题时dialog增加边框. (#4386)
* 优化Eink主题效果: 1.移除Eink主题时dialog及UI控件阴影; 2.Eink主题时dialog增加边框. * fix: 2处与全局不一致的UI效果
- Loading branch information
Showing
25 changed files
with
273 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
app/src/main/java/io/legado/app/base/BasePrefDialogFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package io.legado.app.base | ||
|
||
import android.view.Gravity | ||
import android.view.WindowManager | ||
import androidx.fragment.app.DialogFragment | ||
import androidx.lifecycle.Lifecycle | ||
import androidx.lifecycle.LifecycleEventObserver | ||
import androidx.lifecycle.LifecycleOwner | ||
import io.legado.app.R | ||
import io.legado.app.help.config.AppConfig | ||
import io.legado.app.utils.dpToPx | ||
|
||
|
||
abstract class BasePrefDialogFragment( | ||
) : DialogFragment() { | ||
|
||
override fun onStart() { | ||
super.onStart() | ||
if (AppConfig.isEInkMode) { | ||
dialog?.window?.let { | ||
it.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) | ||
val attr = it.attributes | ||
attr.dimAmount = 0.0f | ||
attr.windowAnimations = 0 | ||
it.attributes = attr | ||
it.setBackgroundDrawableResource(R.color.transparent) | ||
} | ||
|
||
// 修改gravity的时机一般在子类的onStart方法中, 因此需要在onStart之后执行. | ||
this.lifecycle.addObserver(object : LifecycleEventObserver { | ||
override fun onStateChanged( | ||
source: LifecycleOwner, | ||
event: Lifecycle.Event | ||
) { | ||
if (event == Lifecycle.Event.ON_START) { | ||
when (dialog?.window?.attributes?.gravity) { | ||
Gravity.TOP -> view?.setBackgroundResource(R.drawable.bg_eink_border_bottom) | ||
Gravity.BOTTOM -> view?.setBackgroundResource(R.drawable.bg_eink_border_top) | ||
else -> { | ||
val padding = 2.dpToPx(); | ||
view?.setPadding(padding, padding, padding, padding) | ||
view?.setBackgroundResource(R.drawable.bg_eink_border_dialog) | ||
} | ||
} | ||
} | ||
} | ||
}) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.