-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
84 additions
and
15 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ package com.chiclaim.android.downloader | |
|
||
import android.app.ActivityManager | ||
import android.app.Application | ||
import android.app.DownloadManager | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.net.Uri | ||
|
@@ -18,7 +17,7 @@ import com.chiclaim.android.downloader.util.e | |
import java.io.File | ||
|
||
/** | ||
* | ||
* 内置的更新弹窗 | ||
* @author by [email protected] | ||
*/ | ||
class UpgradeDialogActivity : AppCompatActivity(), DownloadListener { | ||
|
@@ -73,6 +72,8 @@ class UpgradeDialogActivity : AppCompatActivity(), DownloadListener { | |
findViewById<TextView>(R.id.tv_updater_desc).text = | ||
dialogInfo.description ?: getString(R.string.downloader_desc_default) | ||
|
||
// findViewById<MaxHeightScrollView>(R.id.scrollView).setMaxHeight(150) | ||
|
||
tvNegative = findViewById<TextView>(R.id.tv_updater_cancel).apply { | ||
this.text = dialogInfo.negativeText ?: getString(R.string.downloader_cancel) | ||
} | ||
|
48 changes: 48 additions & 0 deletions
48
downloader/src/main/java/com/chiclaim/android/downloader/widget/MaxHeightScrollView.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,48 @@ | ||
package com.chiclaim.android.downloader.widget | ||
|
||
import android.content.Context | ||
import android.util.AttributeSet | ||
import android.widget.ScrollView | ||
import com.chiclaim.android.downloader.R | ||
|
||
class MaxHeightScrollView : ScrollView { | ||
|
||
private var maxHeight: Int = -1 | ||
|
||
constructor(context: Context) : super(context) { | ||
initAttrs(null) | ||
} | ||
|
||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) { | ||
initAttrs(attrs) | ||
} | ||
|
||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super( | ||
context, | ||
attrs, | ||
defStyleAttr | ||
) { | ||
initAttrs(attrs) | ||
} | ||
|
||
private fun defaultMaxHeight() = context.resources.displayMetrics.heightPixels / 2 | ||
|
||
fun setMaxHeight(maxHeight: Int) { | ||
this.maxHeight = maxHeight | ||
} | ||
|
||
private fun initAttrs(attrs: AttributeSet?) { | ||
if (attrs != null) { | ||
val attr = context.obtainStyledAttributes(attrs, R.styleable.MaxHeightScrollView) | ||
maxHeight = attr.getDimensionPixelSize(R.styleable.MaxHeightScrollView_maxHeight, -1) | ||
attr.recycle() | ||
maxHeight | ||
} | ||
} | ||
|
||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { | ||
if (maxHeight == -1) maxHeight = defaultMaxHeight() | ||
val newHeightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST) | ||
super.onMeasure(widthMeasureSpec, newHeightMeasureSpec) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<resources> | ||
<declare-styleable name="MaxHeightScrollView"> | ||
<attr name="maxHeight" format="dimension" /> | ||
</declare-styleable> | ||
</resources> |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="black_3">#333333</color> | ||
<color name="black_6">#666666</color> | ||
<color name="updater_positive_color">#4169E1</color> | ||
</resources> |