Skip to content

Commit

Permalink
BaseDialog 沉浸式状态栏
Browse files Browse the repository at this point in the history
  • Loading branch information
guuguo committed Nov 2, 2018
1 parent 5e11102 commit af928c4
Show file tree
Hide file tree
Showing 30 changed files with 902 additions and 35 deletions.
29 changes: 0 additions & 29 deletions .idea/codeStyles/Project.xml

This file was deleted.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.guuguo.android.lib.app

import android.app.PendingIntent.getActivity
import android.content.Context
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package top.guuguo.myapplication.ui

import android.content.Context
import android.graphics.*
import android.util.AttributeSet
import android.widget.LinearLayout


class GuideHighLightBgView : LinearLayout {

constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)


private val mPaint = Paint(Paint.ANTI_ALIAS_FLAG)
init {
setWillNotDraw(false)
}

var targetCX = 0f
var targetCY = 0f
var targetRadius = 0f
var targetWidth = 0
var targetHeight = 0

var isCircle = true
fun makeDstShape(canvas: Canvas): Bitmap {
val bm = Bitmap.createBitmap(canvas.width, canvas.height, Bitmap.Config.ARGB_8888)
val lCanvas = Canvas(bm)
val paint = Paint(Paint.ANTI_ALIAS_FLAG)
paint.color = Color.WHITE
if (isCircle) {
lCanvas.drawCircle(targetCX, targetCY, targetRadius, paint)
} else {
lCanvas.drawRect(targetCX - targetWidth / 2, targetCY - targetHeight / 2, targetCX + targetWidth / 2, targetCY + targetWidth / 2, paint)
}
return bm
}

private fun makeSrcRect(canvas: Canvas): Bitmap {
val bm = Bitmap.createBitmap(canvas.width, canvas.height, Bitmap.Config.ARGB_8888);
val lCanvas = Canvas(bm);
val paint = Paint(Paint.ANTI_ALIAS_FLAG)
paint.color = Color.BLACK
lCanvas.drawRect(RectF(0f, 0f, canvas.width.toFloat(), canvas.height.toFloat()), paint)
return bm;
}

override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)

val mSrcRect = makeSrcRect(canvas);
val mDstCircle = makeDstShape(canvas);

canvas.drawBitmap(mDstCircle, 0f, 0f, mPaint)
mPaint.xfermode = PorterDuffXfermode(PorterDuff.Mode.SRC_OUT);
mPaint.alpha = 160;
canvas.drawBitmap(mSrcRect, 0f, 0f, mPaint)
}

}
5 changes: 3 additions & 2 deletions dialog/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
versionCode Integer.parseInt(VERSION_CODE)
versionName VERSION_NAME

resourcePrefix "drawable_"
resourcePrefix "dialog_"
renderscriptTargetApi 19
renderscriptSupportModeEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand All @@ -30,7 +30,8 @@ android {

dependencies {
api project(':drawable')
api 'io.reactivex.rxjava2:rxandroid:2.0.2'
api project(':systembar')
api 'io.reactivex.rxjava2:rxandroid:2.1.0'
}
repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ import android.view.WindowManager.LayoutParams
import android.widget.LinearLayout
import com.guuguo.android.dialog.utils.StatusBarUtils
import android.view.WindowManager
import android.view.View.SYSTEM_UI_FLAG_LAYOUT_STABLE
import android.view.View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
import android.os.Build
import com.guuguo.android.dialog.utils.DisplayUtil
import com.guuguo.android.lib.systembar.SystemBarHelper


abstract class BaseDialog<T : BaseDialog<T>> : Dialog {
Expand Down Expand Up @@ -193,7 +192,8 @@ abstract class BaseDialog<T : BaseDialog<T>> : Dialog {
layoutParams.width = mContext.resources.displayMetrics.widthPixels
layoutParams.height = DisplayUtil.getScreenRealHeight(mContext)//mContext.resources.displayMetrics.heightPixels
window!!.attributes = layoutParams
setTranslucentStatus()
// setTranslucentStatus()
SystemBarHelper.immersiveStatusBar(window,0f)
}

override fun onStart() {
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include ':androidLib', ':demo', ':dialog', ':drawable',
include ':androidLib', ':demo', ':dialog', ':drawable',':systembar',
':iconfont',':roundview',':utils', ':widget',':libdatabindingex',':androidOldLib'
1 change: 1 addition & 0 deletions systembar/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
38 changes: 38 additions & 0 deletions systembar/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion COMPILE_SDK_VERSION



defaultConfig {
minSdkVersion 15
versionCode Integer.parseInt(VERSION_CODE)
versionName VERSION_NAME
resourcePrefix "systembar_"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}

buildTypes {
release {
postprocessing {
removeUnusedCode false
removeUnusedResources false
obfuscate false
optimizeCode false
proguardFile 'proguard-rules.pro'
}
}
}

}

dependencies {
api "com.android.support:support-v4:$SUPPORT_VERSION"
}
repositories {
mavenCentral()
}
21 changes: 21 additions & 0 deletions systembar/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
2 changes: 2 additions & 0 deletions systembar/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.guuguo.android.lib.systembar" />
Loading

0 comments on commit af928c4

Please sign in to comment.