Skip to content

Commit

Permalink
处理了一些历史遗留问题
Browse files Browse the repository at this point in the history
  • Loading branch information
hongui committed May 27, 2021
1 parent 9d76c84 commit 60fc03e
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 56 deletions.
47 changes: 0 additions & 47 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -16,60 +16,13 @@
# public *;
#}

#指定代码的压缩级别
-optimizationpasses 5
#不混合大小写
-dontusemixedcaseclassnames
#不去忽略非公共的库类
-dontskipnonpubliclibraryclasses
#优化
-dontoptimize
#预校验
-dontpreverify
#混淆时是否记录日志
-verbose
# 混淆时所采用的算法
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

#保护注解
-keepattributes *Annotation*
# 保持哪些类不被混淆
-keep public class * extends android.app.Fragment
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService

#如果引用了v4或者v7包
-dontwarn android.support.**

#忽略警告
-ignorewarning
##记录生成的日志数据,gradle build时在本项目根目录输出##
#apk 包内所有 class 的内部结构
-dump class_files.txt
#未混淆的类和成员
-printseeds seeds.txt
#列出从 apk 中删除的代码
-printusage unused.txt
#混淆前后的映射
-printmapping mapping.txt

####混淆保护自己项目的部分代码以及引用的第三方jar包 START####
-keep public class * extends android.view.View {
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
public void set*(...);
}
#保持 native 方法不被混淆
-keepclasseswithmembernames class * {
native <methods>;
}
#保持自定义控件类不被混淆
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ class DiscoverFragment : AppFragment() {
}
discoverView.removeAllViews()
for (device in it) {
if(null==device) continue
val view = LayoutInflater.from(context).inflate(R.layout.item_scan, null)
val name = view?.findViewById<TextView>(R.id.item_scan_name)
name?.text = device.deviceName
name?.text = device?.deviceName
view?.setOnClickListener {
stopDiscover = true

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/mob/lee/fastair/p2p/P2PManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import com.mob.lee.fastair.model.IS_HOST
*/
object P2PManager {
//设备信息列表
val devicesLiveData = MutableLiveData<List<WifiP2pDevice>>()
val devicesLiveData = MutableLiveData<MutableList<WifiP2pDevice>>()

//连接状态
val connectLiveData = MutableLiveData<Boolean?>()
Expand Down Expand Up @@ -52,7 +52,7 @@ object P2PManager {
}

fun unregister(context: Context) {
devicesLiveData.value = null
devicesLiveData.value?.clear()
connectLiveData.value = null
p2pInfoLiveData.value = null
stopReceiver(context)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/mob/lee/fastair/service/ScanService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ class ScanService : AppService() {
private val viewModel by lazy { viewModel<DeviceViewModel>() }

private val observer by lazy {
Observer<List<WifiP2pDevice>> { devices ->
Observer<List<WifiP2pDevice?>> { devices ->
devices ?: return@Observer
if (P2PManager.isConnected()) {
return@Observer
}
viewModel.readDevice(this) { device ->
devices.find { it.deviceAddress == device }?.let {
devices.find { it?.deviceAddress == device }?.let {
if (!P2PManager.isConnected()) {
P2PManager.connect(this, it)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import kotlinx.coroutines.launch
import androidx.fragment.app.viewModels

open class AppViewModel : ViewModel() {
val stateLiveData = DataLoad<Any>()
val stateLiveData = DataLoad<Any?>()

/**
* 执行耗时任务,不会阻塞UI
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/fragment_chat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,5 @@
android:id="@+id/chatContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/fragment_chat_edit"
android:layout_below="@+id/toolbar" />
android:layout_above="@id/fragment_chat_edit" />
</RelativeLayout>
2 changes: 1 addition & 1 deletion config.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
def appVersion = [:]
appVersion.code = 7
appVersion.name = '1.5.0'
appVersion.name = '1.4.1'
ext.appVersion = appVersion

def sdk = [:]
Expand Down

0 comments on commit 60fc03e

Please sign in to comment.