Skip to content

Commit 7b63b15

Browse files
committed
代码备份
1 parent 7d56f7f commit 7b63b15

File tree

13 files changed

+525
-296
lines changed

13 files changed

+525
-296
lines changed

app/build.gradle

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
apply plugin: 'com.android.application'
2+
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlin-android-extensions'
24

35
android {
46
compileSdkVersion 26
@@ -22,9 +24,10 @@ dependencies {
2224
implementation fileTree(dir: 'libs', include: ['*.jar'])
2325
implementation 'com.android.support:appcompat-v7:26.1.0'
2426
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
25-
implementation 'io.reactivex.rxjava2:rxjava:2.1.9'
26-
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
27+
implementation "com.orhanobut:hawk:2.0.1"
2728
testImplementation 'junit:junit:4.12'
28-
androidTestImplementation 'com.android.support.test:runner:1.0.1'
29-
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
29+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
30+
}
31+
repositories {
32+
mavenCentral()
3033
}

app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="com.coderpig.wechathelper">
44

5+
<uses-permission android:name="android.permission.GET_TASKS" />
6+
57
<application
68
android:allowBackup="true"
79
android:icon="@mipmap/ic_launcher"
810
android:label="@string/app_name"
911
android:roundIcon="@mipmap/ic_launcher_round"
1012
android:supportsRtl="true"
13+
android:name=".HelperApp"
1114
android:theme="@style/AppTheme">
12-
<activity android:name=".MainActivity">
15+
<activity android:name=".ControlActivity">
1316
<intent-filter>
1417
<action android:name="android.intent.action.MAIN" />
1518

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.coderpig.wechathelper
2+
3+
/**
4+
* 描述:相关常量
5+
*
6+
* @author CoderPig on 2018/04/12 11:45.
7+
*/
8+
class Constant {
9+
companion object {
10+
val GROUP_NAME ="group_name"
11+
val ADD_FRIENDS ="add_friends"
12+
val FRIEND_LIST = "friend_list"
13+
val FRIEND_SQUARE ="friend_square"
14+
val RED_PACKET ="red_packet"
15+
}
16+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.coderpig.wechathelper
2+
3+
import android.os.Bundle
4+
import android.support.v7.app.AppCompatActivity
5+
import com.orhanobut.hawk.Hawk
6+
import kotlinx.android.synthetic.main.activity_control.*
7+
8+
/**
9+
* 描述:辅助服务控制页
10+
*
11+
* @author CoderPig on 2018/04/12 10:50.
12+
*/
13+
class ControlActivity : AppCompatActivity() {
14+
override fun onCreate(savedInstanceState: Bundle?) {
15+
super.onCreate(savedInstanceState)
16+
setContentView(R.layout.activity_control)
17+
initView()
18+
}
19+
20+
private fun initView() {
21+
ed_group_name.setText(Hawk.get(Constant.GROUP_NAME, ""))
22+
cb_add_friends.isChecked = Hawk.get(Constant.ADD_FRIENDS,false)
23+
cb_friends_square.isChecked = Hawk.get(Constant.FRIEND_SQUARE,false)
24+
cb_catch_red_packet.isChecked = Hawk.get(Constant.RED_PACKET,false)
25+
btn_sure.setOnClickListener({
26+
Hawk.put(Constant.GROUP_NAME, ed_group_name.text.toString())
27+
shortToast("群聊名称已保存!")
28+
})
29+
btn_clear.setOnClickListener({
30+
Hawk.put(Constant.GROUP_NAME, "")
31+
shortToast("群聊名称已清除!")
32+
ed_group_name.setText("")
33+
})
34+
cb_add_friends.setOnCheckedChangeListener { _, isChecked ->
35+
if (isChecked) Hawk.put(Constant.ADD_FRIENDS, true) else Hawk.put(Constant.ADD_FRIENDS, false)
36+
}
37+
cb_friends_square.setOnCheckedChangeListener { _, isChecked ->
38+
if (isChecked) Hawk.put(Constant.FRIEND_SQUARE, true) else Hawk.put(Constant.FRIEND_SQUARE, false)
39+
}
40+
cb_catch_red_packet.setOnCheckedChangeListener { _, isChecked ->
41+
if (isChecked) Hawk.put(Constant.RED_PACKET, true) else Hawk.put(Constant.RED_PACKET, false)
42+
}
43+
}
44+
45+
46+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.coderpig.wechathelper
2+
3+
import android.app.Application
4+
import com.orhanobut.hawk.Hawk
5+
import kotlin.properties.Delegates
6+
7+
/**
8+
* 描述:
9+
*
10+
* @author CoderPig on 2018/04/12 11:43.
11+
*/
12+
class HelperApp : Application() {
13+
companion object {
14+
var instance by Delegates.notNull<HelperApp>()
15+
}
16+
17+
override fun onCreate() {
18+
super.onCreate()
19+
instance = this
20+
Hawk.init(this).build()
21+
}
22+
}

0 commit comments

Comments
 (0)