Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ android:
- platform-tools
- tools
- build-tools-23.0.3
- android-23
- android-26
- extra-android-m2repository
- extra-google-m2repository
script:
Expand Down
1 change: 1 addition & 0 deletions blockcanary/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ dependencies {
compile project(':views')
testCompile "junit:junit:${libs.junit}"
provided "com.android.support:appcompat-v7:${libs.support}"
provided "com.android.support:support-compat:${libs.support}"
compile "org.jetbrains.kotlin:kotlin-stdlib:${libs.kotlin}"
}
repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ internal class __BlockDetailAdapter : BaseAdapter() {
if (view == null) {
view = LayoutInflater.from(context).inflate(R.layout.__dt_canary_ref_top_row, parent, false)
}
val textView = view!!.findViewById(R.id.__dt_canary_row_text) as TextView
val textView = view!!.findViewById<TextView>(R.id.__dt_canary_row_text)
textView.text = context.packageName
} else {
if (view == null) {
view = LayoutInflater.from(context).inflate(R.layout.__dt_canary_ref_row, parent, false)
}
val textView = view!!.findViewById(R.id.__dt_canary_row_text) as TextView
val textView = view!!.findViewById<TextView>(R.id.__dt_canary_row_text)

val isThreadStackEntry = position == POSITION_THREAD_STACK + 1
val element = getItem(position)
Expand All @@ -47,24 +47,22 @@ internal class __BlockDetailAdapter : BaseAdapter() {
}
textView.text = Html.fromHtml(htmlString)

val connectorView = view.findViewById(R.id.__dt_canary_row_connector) as __DisplayLeakConnectorView
val connectorView = view.findViewById<__DisplayLeakConnectorView>(R.id.__dt_canary_row_connector)
connectorView.setType(connectorViewType(position))

val moreDetailsView = view.findViewById(R.id.__dt_canary_row_more) as __MoreDetailsView
val moreDetailsView = view.findViewById<__MoreDetailsView>(R.id.__dt_canary_row_more)
moreDetailsView.setFolding(mFoldings[position])
}

return view
}

private fun connectorViewType(position: Int): __DisplayLeakConnectorView.Type {
return if (position == 1)
__DisplayLeakConnectorView.Type.START
else
if (position == count - 1)
__DisplayLeakConnectorView.Type.END
else
__DisplayLeakConnectorView.Type.NODE
return when (position) {
1 -> __DisplayLeakConnectorView.Type.START
count - 1 -> __DisplayLeakConnectorView.Type.END
else -> __DisplayLeakConnectorView.Type.NODE
}
}

private fun elementToHtmlString(element: String?, position: Int, folding: Boolean): String {
Expand Down Expand Up @@ -134,12 +132,12 @@ internal class __BlockDetailAdapter : BaseAdapter() {
if (getItemViewType(position) == TOP_ROW) {
return null
}
when (position) {
POSITION_BASIC -> return mBlock?.basicString
POSITION_TIME -> return mBlock?.timeString
POSITION_CPU -> return mBlock?.cpuString
//POSITION_THREAD_STACK,
else -> return mBlock?.threadStackEntries?.get(position - POSITION_THREAD_STACK)
return when (position) {
POSITION_BASIC -> mBlock?.basicString
POSITION_TIME -> mBlock?.timeString
POSITION_CPU -> mBlock?.cpuString
//POSITION_THREAD_STACK,
else -> mBlock?.threadStackEntries?.get(position - POSITION_THREAD_STACK)
}
}

Expand Down Expand Up @@ -169,12 +167,12 @@ internal class __BlockDetailAdapter : BaseAdapter() {

companion object {

private val TOP_ROW = 0
private val NORMAL_ROW = 1
private const val TOP_ROW = 0
private const val NORMAL_ROW = 1

private val POSITION_BASIC = 1
private val POSITION_TIME = 2
private val POSITION_CPU = 3
private val POSITION_THREAD_STACK = 4
private const val POSITION_BASIC = 1
private const val POSITION_TIME = 2
private const val POSITION_CPU = 3
private const val POSITION_THREAD_STACK = 4
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ class __DisplayBlockActivity : Activity() {
private val mBlockEntries: MutableList<__Block> by lazy { ArrayList<__Block>() }
private var mBlockStartTime: String? = null

private val mListView by lazy { findViewById(R.id.__dt_canary_display_leak_list) as ListView }
private val mFailureView by lazy { findViewById(R.id.__dt_canary_display_leak_failure) as TextView }
private val mActionButton by lazy { findViewById(R.id.__dt_canary_action) as Button }
private val mListView by lazy { findViewById<ListView>(R.id.__dt_canary_display_leak_list) }
private val mFailureView by lazy { findViewById<TextView>(R.id.__dt_canary_display_leak_failure) }
private val mActionButton by lazy { findViewById<Button>(R.id.__dt_canary_action) }
private val mMaxStoredBlockCount by lazy { resources.getInteger(R.integer.__block_canary_max_stored_count) }

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -191,7 +191,7 @@ class __DisplayBlockActivity : Activity() {
} else {
val adapter = BlockListAdapter()
mListView.adapter = adapter
mListView.onItemClickListener = AdapterView.OnItemClickListener { parent, view, position, id ->
mListView.onItemClickListener = AdapterView.OnItemClickListener { _, _, position, _ ->
mBlockStartTime = mBlockEntries[position].timeStart
updateUi()
}
Expand Down Expand Up @@ -219,7 +219,7 @@ class __DisplayBlockActivity : Activity() {
} else {
adapter = __BlockDetailAdapter()
mListView.adapter = adapter
mListView.onItemClickListener = AdapterView.OnItemClickListener { parent, view, position, id -> adapter.toggleRow(position) }
mListView.onItemClickListener = AdapterView.OnItemClickListener { _, _, position, _ -> adapter.toggleRow(position) }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
invalidateOptionsMenu()
val actionBar = actionBar
Expand Down Expand Up @@ -271,8 +271,8 @@ class __DisplayBlockActivity : Activity() {
if (view == null) {
view = LayoutInflater.from(this@__DisplayBlockActivity).inflate(R.layout.__dt_canary_block_row, parent, false)
}
val titleView = view!!.findViewById(R.id.__dt_canary_row_text) as TextView
val timeView = view.findViewById(R.id.__dt_canary_row_time) as TextView
val titleView = view!!.findViewById<TextView>(R.id.__dt_canary_row_text)
val timeView = view.findViewById<TextView>(R.id.__dt_canary_row_time)
val block = getItem(position)

val index: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ package com.exyui.android.debugbottle.ui.layout

import android.annotation.TargetApi
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.app.PendingIntent.FLAG_UPDATE_CURRENT
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Build.VERSION_CODES.HONEYCOMB
import android.support.annotation.RequiresApi
import android.support.v4.app.NotificationCompat
import com.exyui.android.debugbottle.core.__OnBlockEventInterceptor
import com.exyui.android.debugbottle.ui.R

import android.app.PendingIntent.FLAG_UPDATE_CURRENT
import android.os.Build.VERSION.SDK_INT
import android.os.Build.VERSION_CODES.HONEYCOMB
import android.os.Build.VERSION_CODES.JELLY_BEAN
/**
* Created by yuriel on 8/9/16.
*/
Expand All @@ -31,31 +33,29 @@ internal class __Notifier : __OnBlockEventInterceptor {
@Suppress("DEPRECATION")
@TargetApi(HONEYCOMB)
private fun show(context: Context, contentTitle: String, contentText: String, pendingIntent: PendingIntent) {
val channelId = "default"
val builder = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
NotificationCompat.Builder(context, channelId)
else {
NotificationCompat.Builder(context)
}
builder.setSmallIcon(R.drawable.__block_canary_notification)
.setWhen(System.currentTimeMillis())
.setContentTitle(contentTitle)
.setContentText(contentText)
.setAutoCancel(true)
.setContentIntent(pendingIntent)
.setDefaults(Notification.DEFAULT_SOUND)

val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notificationManager.createNotificationChannel(createChannel(channelId))
}
notificationManager.notify(0xDEAFBEEF.toInt(), builder.build())
}

val notification: Notification
// if (SDK_INT < HONEYCOMB) {
// notification = Notification()
// notification.icon = R.drawable.__block_canary_notification
// notification.`when` = System.currentTimeMillis()
// notification.flags = notification.flags or Notification.FLAG_AUTO_CANCEL
// notification.defaults = Notification.DEFAULT_SOUND
// notification.setLatestEventInfo(context, contentTitle, contentText, pendingIntent)
// } else {
val builder = Notification.Builder(context)
.setSmallIcon(R.drawable.__block_canary_notification)
.setWhen(System.currentTimeMillis())
.setContentTitle(contentTitle)
.setContentText(contentText)
.setAutoCancel(true)
.setContentIntent(pendingIntent)
.setDefaults(Notification.DEFAULT_SOUND)
if (SDK_INT < JELLY_BEAN) {
notification = builder.notification
} else {
notification = builder.build()
}
// }
notificationManager.notify(0xDEAFBEEF.toInt(), notification)
@RequiresApi(Build.VERSION_CODES.O)
private fun createChannel(channelId: String): NotificationChannel? {
return NotificationChannel(channelId, channelId, NotificationManager.IMPORTANCE_DEFAULT)
}
}
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ buildscript {
libraries = [
gradle: '2.2.1',
kotlin: '1.1.4-3',
support: '23.4.0',
support: '27.0.2',
junit: '4.12',
leakcanary: '1.4',
leakcanary: '1.5.4',
okhttp: '2.4.0',
okhttp3: '3.4.2',
debugbottle: versionUploaded
Expand All @@ -40,6 +40,7 @@ buildscript {
repositories {
mavenCentral()
jcenter()
maven { url 'https://dl.google.com/dl/android/maven2/' }
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
Expand All @@ -61,6 +62,7 @@ allprojects {
repositories {
mavenCentral()
jcenter()
maven { url 'https://dl.google.com/dl/android/maven2/' }
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import kotlin.properties.Delegates
internal object DTActivityManager {
private var injected = false

var topActivity by Delegates.observable<Activity?>(null) { prop, old, new ->
var topActivity by Delegates.observable<Activity?>(null) { _, _, new ->
if (!injected && new != null) {
injected = DTInstaller.startInject()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.exyui.android.debugbottle.components

import android.Manifest
import android.app.ActivityManager
import android.content.Intent
import android.net.Uri
Expand Down Expand Up @@ -42,37 +41,37 @@ internal class DTDrawerActivity : AppCompatActivity(), DialogsCollection.SPDialo
resources.getStringArray(R.array.__dt_drawer_items)
}

private val drawerLayout by lazy { findViewById(R.id.__dt_drawer_layout) as DrawerLayout }
private val drawerLayout by lazy { findViewById<DrawerLayout>(R.id.__dt_drawer_layout) }

private val drawerRoot by lazy { findViewById(R.id.__dt_drawer_root) as ViewGroup }
private val drawerRoot by lazy { findViewById<ViewGroup>(R.id.__dt_drawer_root) }

private val drawerListView by lazy {
(findViewById(R.id.__dt_left_drawer) as ListView).apply {
findViewById<ListView>(R.id.__dt_left_drawer).apply {
adapter = DrawerAdapter(titles)
setOnItemClickListener { _: AdapterView<*>?, _: View?, position: Int, _: Long ->
selectItem(position)
}
}
}

private val contentFrame by lazy { findViewById(R.id.__dt_content_frame) as ViewGroup }
private val contentFrame by lazy { findViewById<ViewGroup>(R.id.__dt_content_frame) }

private val drawerToggle by lazy {
object: ActionBarDrawerToggle(this, drawerLayout, R.string.__dt_drawer_open, R.string.__dt_drawer_close) {
override fun onDrawerOpened(drawerView: View?) {
override fun onDrawerOpened(drawerView: View) {
super.onDrawerOpened(drawerView)
invalidateOptionsMenu() // creates call to onPrepareOptionsMenu()
}

override fun onDrawerClosed(drawerView: View?) {
override fun onDrawerClosed(drawerView: View) {
super.onDrawerClosed(drawerView)
invalidateOptionsMenu() // creates call to onPrepareOptionsMenu()
}
}.apply { setHomeAsUpIndicator(R.drawable.__dt_ic_bottle_24dp) }
}

private val infoLayout by lazy {
(findViewById(R.id.__dt_info) as ViewGroup).apply {
findViewById<ViewGroup>(R.id.__dt_info).apply {
setOnClickListener {
AlertDialog.Builder(this@DTDrawerActivity)
.setIcon(R.drawable.__dt_ic_bottle_24dp)
Expand All @@ -91,7 +90,7 @@ internal class DTDrawerActivity : AppCompatActivity(), DialogsCollection.SPDialo
}

private val introLayout by lazy {
(findViewById(R.id.__dt_helper) as ViewGroup).apply {
findViewById<ViewGroup>(R.id.__dt_helper).apply {
setOnClickListener {

// To start IntroductionActivity, need a AppCompatTheme.
Expand Down Expand Up @@ -336,8 +335,8 @@ internal class DTDrawerActivity : AppCompatActivity(), DialogsCollection.SPDialo
val item = menu[position]
(view?.let { view?.tag as ViewHolder }?: ViewHolder().apply {
view = LayoutInflater.from(this@DTDrawerActivity).inflate(R.layout.__item_drawer_menu, parent, false)
icon = view?.findViewById(R.id.__dt_icon) as ImageView
title = view?.findViewById(R.id.__dt_item_title) as TextView
icon = view?.findViewById<ImageView>(R.id.__dt_icon)
title = view?.findViewById<TextView>(R.id.__dt_item_title)
view?.tag = this
}).apply {
icon?.setImageResource(item.icon)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ internal abstract class DTReportMgr {
get() {
val f = detectedFileDirectory()
if (f.exists() && f.isDirectory) {
return f.listFiles { dir, filename ->
return f.listFiles { _, filename ->
filename.endsWith(TYPE)
}
}
Expand Down
Loading