Skip to content

Commit 9da112c

Browse files
committed
Fix problem on Huawei devices
1 parent d22102b commit 9da112c

File tree

8 files changed

+64
-2
lines changed

8 files changed

+64
-2
lines changed

app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ dependencies {
4343
compile "com.google.firebase:firebase-core:$firebaseVersion"
4444
compile "com.google.firebase:firebase-crash:$firebaseVersion"
4545
compile "com.google.firebase:firebase-ads:$firebaseVersion"
46+
47+
compile 'com.hwangjr.rxbus:rxbus:1.0.5'
4648
}
4749

4850
buildscript {

app/proguard-rules.pro

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,24 @@
2727
}
2828

2929
-dontwarn org.jetbrains.anko.**
30-
-keep class org.jetbrains.anko.** { *;}
30+
-keep class org.jetbrains.anko.** { *;}
31+
32+
-dontwarn rx.**
33+
-keep class rx.** { *;}
34+
35+
-keepattributes *Annotation*
36+
-keepclassmembers class ** {
37+
@com.hwangjr.rxbus.annotation.Subscribe public *;
38+
@com.hwangjr.rxbus.annotation.Produce public *;
39+
}
40+
-keepclassmembers class * implements java.io.Serializable {
41+
static final long serialVersionUID;
42+
private static final java.io.ObjectStreamField[] serialPersistentFields;
43+
!static !transient <fields>;
44+
!private <fields>;
45+
!private <methods>;
46+
private void writeObject(java.io.ObjectOutputStream);
47+
private void readObject(java.io.ObjectInputStream);
48+
java.lang.Object writeReplace();
49+
java.lang.Object readResolve();
50+
}

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
<activity
2626
android:name=".StartFPQAActivity"
27+
android:excludeFromRecents="true"
2728
android:process=":bg"
2829
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
2930

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright 2016. Alex Zhang aka. ztc1997
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.ztc1997.fingerprint2sleep
18+
19+
object FinishStartFPQAActivityEvent
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.ztc1997.fingerprint2sleep
2+
3+
import com.hwangjr.rxbus.Bus
4+
import com.hwangjr.rxbus.RxBus
5+
6+
val rxBus: Bus get() = RxBus.get()

app/src/main/kotlin/com/ztc1997/fingerprint2sleep/FPQAService.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ class FPQAService : Service() {
9090
isScanning = true
9191
}
9292

93+
rxBus.post(FinishStartFPQAActivityEvent)
94+
9395
isError = false
9496

9597
lastIntent?.let {

app/src/main/kotlin/com/ztc1997/fingerprint2sleep/RequireAdminActivity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,6 @@ class RequireAdminActivity : Activity() {
4545
}
4646

4747
finish()
48+
overridePendingTransition(0, 0)
4849
}
4950
}

app/src/main/kotlin/com/ztc1997/fingerprint2sleep/StartFPQAActivity.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.app.Activity
44
import android.content.Context
55
import android.content.Intent
66
import android.os.Bundle
7+
import com.hwangjr.rxbus.annotation.Subscribe
78
import org.jetbrains.anko.startService
89

910
class StartFPQAActivity : Activity() {
@@ -12,15 +13,25 @@ class StartFPQAActivity : Activity() {
1213
val startIntent = Intent(context, StartFPQAActivity::class.java)
1314
startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
1415
startIntent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK)
15-
startIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
1616
startIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
1717
context.startActivity(startIntent)
1818
}
1919
}
2020

2121
override fun onCreate(savedInstanceState: Bundle?) {
2222
super.onCreate(savedInstanceState)
23+
rxBus.register(this)
2324
startService<FPQAService>()
25+
}
26+
27+
override fun onDestroy() {
28+
super.onDestroy()
29+
rxBus.unregister(this)
30+
}
31+
32+
@Subscribe
33+
fun finishSelf(event: FinishStartFPQAActivityEvent) {
2434
finish()
35+
overridePendingTransition(0, 0)
2536
}
2637
}

0 commit comments

Comments
 (0)