Skip to content

Commit

Permalink
commit AndroidAssembly
Browse files Browse the repository at this point in the history
  • Loading branch information
ming723 committed Sep 11, 2022
0 parents commit 6bdbdc2
Show file tree
Hide file tree
Showing 84 changed files with 2,074 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
*.iml
.gradle
/.idea
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
1 change: 1 addition & 0 deletions account/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
2 changes: 2 additions & 0 deletions account/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
apply from: "${rootProject.rootDir}/assembly.gradle"
project.ext.setAppOrLibDefaultConfig project
Empty file added account/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions account/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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.abner.account

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.abner.account.test", appContext.packageName)
}
}
10 changes: 10 additions & 0 deletions account/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abner.account">

<application>
<activity
android:name=".AccountActivity"
android:screenOrientation="portrait" />
</application>
</manifest>
52 changes: 52 additions & 0 deletions account/src/main/java/com/abner/account/AccountActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.abner.account

import android.os.Bundle
import android.widget.Button
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.abner.common.router.CommonRouterConstant
import com.abner.common.router.CommonRouterManger
import com.abner.common.utils.CommonUserUtils
import com.alibaba.android.arouter.facade.annotation.Route

/**
*AUTHOR:AbnerMing
*DATE:2022/9/8
*INTRODUCE:Account页面
*/
@Route(path = CommonRouterConstant.ACCOUNT)
class AccountActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_account)

//普通页面跳转
findViewById<Button>(R.id.btn_code).setOnClickListener {
CommonRouterManger.instance.navigationActivity(CommonRouterConstant.CODE)
}
//页面带参数跳转
findViewById<Button>(R.id.btn_code_params).setOnClickListener {
CommonRouterManger.instance.navigationActivityParams(
CommonRouterConstant.CODE,
"params" to "我是携带的参数",
"params2" to 100
)
}

//模拟登录,真实业务中,请以实际为准,目前只是测试
findViewById<Button>(R.id.btn_login).setOnClickListener {
//登录成功之后,保存用户信息,格式自定义,请以实际为准,当前为Demo测试
val json = "{\n" +
"\t\"code\": 0,\n" +
"\t\"message\": \"登录成功\",\n" +
"\t\"data\": {\n" +
"\t\t\"userName\": \"Abner0002323\",\n" +
"\t\t\"userId\": \"896767898989989879\",\n" +
"\t\t\"nickName\": \"AbnerMing\"\n" +
"\t}\n" +
"}"
CommonUserUtils.instance.setUser(json)
Toast.makeText(this, "模拟登录成功", Toast.LENGTH_SHORT).show()
}
}
}
14 changes: 14 additions & 0 deletions account/src/main/java/com/abner/account/AccountApp.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.abner.account

import android.app.Application

/**
*AUTHOR:AbnerMing
*DATE:2022/9/8
*INTRODUCE:
*/
class AccountApp :Application(){
override fun onCreate() {
super.onCreate()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.abner.account.iml

import android.app.AlertDialog
import android.content.Context
import android.text.TextUtils
import com.abner.common.data.bean.UserInfo
import com.abner.common.router.CommonRouterConstant
import com.abner.common.service.AccountUserService
import com.abner.common.utils.DataStoreUtils
import com.alibaba.android.arouter.facade.annotation.Route
import com.google.gson.Gson

/**
*AUTHOR:AbnerMing
*DATE:2022/9/10
*INTRODUCE:
*/
@Route(path = CommonRouterConstant.USER_INFO, name = "AccountUserServiceIml")
class AccountUserServiceIml : AccountUserService {

override fun getUser(): UserInfo? {
//获取用户信息后,转成需要的对象
val userJson = DataStoreUtils.getSyncData("user", "")
if (TextUtils.isEmpty(userJson)) {
return null
}
return Gson().fromJson(userJson, UserInfo::class.java)
}

/**
* AUTHOR:AbnerMing
* INTRODUCE:测试弹窗或其他功能
*/
override fun showDialog() {
AlertDialog.Builder(mContext)
.setTitle("测试一个Dialog弹出框")
.setMessage("简单测试以下")
.setNegativeButton("取消") { _, _ ->

}
.setPositiveButton("确定") { _, _ ->


}
.show()
}

private var mContext: Context? = null

override fun init(context: Context?) {
mContext = context
}
}
19 changes: 19 additions & 0 deletions account/src/main/manifest/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abner.account">

<application
android:name=".AccountApp"
android:icon="@mipmap/ic_launcher"
android:label="account"
android:theme="@style/Account">
<activity android:name=".AccountActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
38 changes: 38 additions & 0 deletions account/src/main/res/layout/activity_account.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="20dp"
android:paddingRight="20dp">

<Button
android:id="@+id/btn_code"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textAllCaps="false"
android:text="account组件跳转到Code组件"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/btn_code_params"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textAllCaps="false"
android:text="account组件跳转到Code组件带参数"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/btn_code" />

<Button
android:id="@+id/btn_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="模拟登录"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/btn_code_params" />

</androidx.constraintlayout.widget.ConstraintLayout>
Binary file added account/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions account/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
</resources>
3 changes: 3 additions & 0 deletions account/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">Account</string>
</resources>
16 changes: 16 additions & 0 deletions account/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Account" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
</resources>
17 changes: 17 additions & 0 deletions account/src/test/java/com/abner/account/ExampleUnitTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.abner.account

import org.junit.Test

import org.junit.Assert.*

/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
apply from: "${rootProject.rootDir}/assembly.gradle"
project.ext.setAppDefaultConfig project
32 changes: 32 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 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

# arouter
-keep public class com.alibaba.android.arouter.routes.**{*;}
-keep public class com.alibaba.android.arouter.facade.**{*;}
-keep class * implements com.alibaba.android.arouter.facade.template.ISyringe{*;}

# 如果使用了 byType 的方式获取 Service,需添加下面规则,保护接口
-keep interface * implements com.alibaba.android.arouter.facade.template.IProvider

# 如果使用了 单类注入,即不定义接口实现 IProvider,需添加下面规则,保护实现
# -keep class * implements com.alibaba.android.arouter.facade.template.IProvider
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.abner.assembly

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.abner.assembly", appContext.packageName)
}
}
Loading

0 comments on commit 6bdbdc2

Please sign in to comment.