Showing
17 changed files
with
461 additions
and
6 deletions
| @@ -42,7 +42,7 @@ android { | @@ -42,7 +42,7 @@ android { | ||
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | dependencies { | 44 | dependencies { |
| 45 | - | 45 | + api 'com.alibaba:arouter-api:1.5.2' |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | uploadArchives { | 48 | uploadArchives { |
| @@ -53,7 +53,7 @@ uploadArchives { | @@ -53,7 +53,7 @@ uploadArchives { | ||
| 53 | } | 53 | } |
| 54 | pom.project { | 54 | pom.project { |
| 55 | artifactId 'wdinterface' | 55 | artifactId 'wdinterface' |
| 56 | - version '1.0.0' | 56 | + version '1.0.3' |
| 57 | groupId 'com.wd' | 57 | groupId 'com.wd' |
| 58 | packaging 'aar' | 58 | packaging 'aar' |
| 59 | } | 59 | } |
| 1 | +package com.wd.foundation.wdinterface | ||
| 2 | + | ||
| 3 | +import com.alibaba.android.arouter.facade.template.IProvider | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * 作者 : hl | ||
| 7 | + * 时间 : 2023/3/10 | ||
| 8 | + * 描述 :登录总线服务接口 | ||
| 9 | + **/ | ||
| 10 | +interface ILoginService : IProvider { | ||
| 11 | + | ||
| 12 | + /** | ||
| 13 | + * 获取缓存用户id | ||
| 14 | + */ | ||
| 15 | + fun getUserId(): String? | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * 获取缓存用户类型 | ||
| 19 | + */ | ||
| 20 | + fun getUserType(): String? | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * 获取缓存用户token | ||
| 24 | + */ | ||
| 25 | + fun getUserToken(): String? | ||
| 26 | +} |
| 1 | +package com.wd.foundation.wdinterface | ||
| 2 | + | ||
| 3 | +import com.alibaba.android.arouter.facade.template.IProvider | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * 作者 : hl | ||
| 7 | + * 时间 : 2023/3/7 | ||
| 8 | + * 描述 : 获取省份信息 | ||
| 9 | + **/ | ||
| 10 | +interface IProvinceService : IProvider { | ||
| 11 | + fun getProvinceCode(): String? | ||
| 12 | + fun getCityId(): String? | ||
| 13 | + fun getCityName(): String? | ||
| 14 | + fun getCarriageCode(): String? | ||
| 15 | +} |
| 1 | +package com.wd.foundation.wdinterface.app | ||
| 2 | + | ||
| 3 | +import com.alibaba.android.arouter.facade.template.IProvider | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * 作者 : 张波 | ||
| 7 | + * 时间 : 2024/10/14 | ||
| 8 | + * 描述 : 应用信息获取服务接口 | ||
| 9 | + **/ | ||
| 10 | +interface IAppInfoService : IProvider { | ||
| 11 | + /** | ||
| 12 | + * 获取平台标识 | ||
| 13 | + */ | ||
| 14 | + fun getPlat(): String | ||
| 15 | + | ||
| 16 | + /** | ||
| 17 | + * 获取端标识,如Android、ios | ||
| 18 | + */ | ||
| 19 | + fun getSystem(): String | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * 获取设备id,用于IMEI、DEVICE_ID字段等 | ||
| 23 | + */ | ||
| 24 | + fun getDeviceId(): String | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 获取应用版本码,如 100 | ||
| 28 | + */ | ||
| 29 | + fun getVersionCode(): String | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * 获取应用版本号,如 1.0.0 | ||
| 33 | + */ | ||
| 34 | + fun getVersionName(): String | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * 获取应用打包版本,如 "202410141452" | ||
| 38 | + */ | ||
| 39 | + fun getBuildVersion(): String | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * 获取手机系统版本,取值 VERSION.RELEASE | ||
| 43 | + */ | ||
| 44 | + fun getOsVersion(): String | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 获取渠道号 | ||
| 48 | + */ | ||
| 49 | + fun getChannelCode(): String | ||
| 50 | +} |
| 1 | + | ||
| 2 | +package com.wd.foundation.wdinterface.toast; | ||
| 3 | + | ||
| 4 | +import com.alibaba.android.arouter.facade.template.IProvider; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * toast使用接口 | ||
| 8 | + */ | ||
| 9 | +public interface IToast extends IProvider { | ||
| 10 | + void showShort(String message); | ||
| 11 | + | ||
| 12 | + void showTopShort(String message, int y); | ||
| 13 | + | ||
| 14 | + void showLong(String message); | ||
| 15 | + | ||
| 16 | + /** | ||
| 17 | + * 展示吐司 | ||
| 18 | + * | ||
| 19 | + * @param stringId 字符串资源id | ||
| 20 | + */ | ||
| 21 | + void showShort(int stringId); | ||
| 22 | + | ||
| 23 | + void showShortBottom(int stringId); | ||
| 24 | + | ||
| 25 | + void showLong(int stringId); | ||
| 26 | + | ||
| 27 | + void show(String content, int duration); | ||
| 28 | + | ||
| 29 | + IToast getInst(); | ||
| 30 | +} |
wdinterfaceimpl/.gitignore
0 → 100644
| 1 | +/build |
wdinterfaceimpl/README.md
0 → 100644
wdinterfaceimpl/build.gradle
0 → 100644
| 1 | +plugins { | ||
| 2 | + id 'com.android.library' | ||
| 3 | + id 'kotlin-android' | ||
| 4 | + id 'maven' | ||
| 5 | +} | ||
| 6 | + | ||
| 7 | +android { | ||
| 8 | + compileSdkVersion var.compileSdkVersion | ||
| 9 | + | ||
| 10 | + defaultConfig { | ||
| 11 | + minSdkVersion var.minSdkVersion | ||
| 12 | + targetSdkVersion var.targetSdkVersion | ||
| 13 | + versionCode var.versionCode | ||
| 14 | + versionName var.versionName | ||
| 15 | + | ||
| 16 | + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
| 17 | + consumerProguardFiles "consumer-rules.pro" | ||
| 18 | + | ||
| 19 | + buildConfigField "String", "API_VERSION", "\"${requestVersion}\"" | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + buildTypes { | ||
| 23 | + release { | ||
| 24 | + minifyEnabled false | ||
| 25 | + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | + compileOptions { | ||
| 29 | + sourceCompatibility JavaVersion.VERSION_1_8 | ||
| 30 | + targetCompatibility JavaVersion.VERSION_1_8 | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + // 自定义AAR包名 | ||
| 34 | + android.libraryVariants.all { variant -> | ||
| 35 | + variant.outputs.all { | ||
| 36 | + if (outputFileName != null && outputFileName.endsWith(".aar")) { | ||
| 37 | + def fileName = "${project.name}-${buildType.name}-v${var.aar_version}.aar" | ||
| 38 | + outputFileName = fileName | ||
| 39 | + } | ||
| 40 | + } | ||
| 41 | + } | ||
| 42 | +} | ||
| 43 | + | ||
| 44 | +dependencies { | ||
| 45 | + api 'com.wd:wdinterface:1.0.1' | ||
| 46 | + // 吐司 兼容 框架 | ||
| 47 | + api 'com.github.getActivity:Toaster:12.2' | ||
| 48 | +} | ||
| 49 | + | ||
| 50 | +uploadArchives { | ||
| 51 | + repositories { | ||
| 52 | + mavenDeployer { | ||
| 53 | + repository(url: "https://packages.aliyun.com/6708d221eef79c23d7b02189/maven/repo-higom/") { | ||
| 54 | + authentication(userName: '6708d1cf6f4c940bd257c88d', password: 'Wm51gc4rARyr') | ||
| 55 | + } | ||
| 56 | + pom.project { | ||
| 57 | + artifactId 'wdinterfaceimpl' | ||
| 58 | + version '1.0.0' | ||
| 59 | + groupId 'com.wd' | ||
| 60 | + packaging 'aar' | ||
| 61 | + } | ||
| 62 | + } | ||
| 63 | + } | ||
| 64 | +} |
wdinterfaceimpl/consumer-rules.pro
0 → 100644
wdinterfaceimpl/proguard-rules.pro
0 → 100644
| 1 | +# Add project specific ProGuard rules here. | ||
| 2 | +# You can control the set of applied configuration files using the | ||
| 3 | +# proguardFiles setting in build.gradle. | ||
| 4 | +# | ||
| 5 | +# For more details, see | ||
| 6 | +# http://developer.android.com/guide/developing/tools/proguard.html | ||
| 7 | + | ||
| 8 | +# If your project uses WebView with JS, uncomment the following | ||
| 9 | +# and specify the fully qualified class name to the JavaScript interface | ||
| 10 | +# class: | ||
| 11 | +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
| 12 | +# public *; | ||
| 13 | +#} | ||
| 14 | + | ||
| 15 | +# Uncomment this to preserve the line number information for | ||
| 16 | +# debugging stack traces. | ||
| 17 | +#-keepattributes SourceFile,LineNumberTable | ||
| 18 | + | ||
| 19 | +# If you keep the line number information, uncomment this to | ||
| 20 | +# hide the original source file name. | ||
| 21 | +#-renamesourcefileattribute SourceFile |
wdinterfaceimpl/src/main/AndroidManifest.xml
0 → 100644
wdinterfaceimpl/src/main/java/com/wd/foundation/wdinterfaceimpl/toast/CustomBlackToastStyle.java
0 → 100644
| 1 | + | ||
| 2 | +package com.wd.foundation.wdinterfaceimpl.toast; | ||
| 3 | + | ||
| 4 | +import android.content.Context; | ||
| 5 | +import android.graphics.drawable.Drawable; | ||
| 6 | +import android.graphics.drawable.GradientDrawable; | ||
| 7 | +import android.os.Build; | ||
| 8 | +import android.util.TypedValue; | ||
| 9 | +import android.view.Gravity; | ||
| 10 | +import android.view.View; | ||
| 11 | +import android.view.ViewGroup; | ||
| 12 | +import android.widget.TextView; | ||
| 13 | + | ||
| 14 | +import com.hjq.toast.config.IToastStyle; | ||
| 15 | + | ||
| 16 | +@SuppressWarnings({"unused", "deprecation"}) | ||
| 17 | +public class CustomBlackToastStyle implements IToastStyle<View> { | ||
| 18 | + private final int mGravity; | ||
| 19 | + | ||
| 20 | + private final int mXOffset; | ||
| 21 | + | ||
| 22 | + private final int mYOffset; | ||
| 23 | + | ||
| 24 | + private final float mHorizontalMargin; | ||
| 25 | + | ||
| 26 | + private final float mVerticalMargin; | ||
| 27 | + | ||
| 28 | + public CustomBlackToastStyle(int gravity, int xOffset, int yOffset, float horizontalMargin, float verticalMargin) { | ||
| 29 | + mGravity = gravity; | ||
| 30 | + mXOffset = xOffset; | ||
| 31 | + mYOffset = yOffset; | ||
| 32 | + mHorizontalMargin = horizontalMargin; | ||
| 33 | + mVerticalMargin = verticalMargin; | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + @Override | ||
| 37 | + public View createView(Context context) { | ||
| 38 | + TextView textView = new TextView(context); | ||
| 39 | + textView.setId(android.R.id.message); | ||
| 40 | + textView.setGravity(getTextGravity(context)); | ||
| 41 | + textView.setTextColor(getTextColor(context)); | ||
| 42 | + textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getTextSize(context)); | ||
| 43 | + | ||
| 44 | + int horizontalPadding = getHorizontalPadding(context); | ||
| 45 | + int verticalPadding = getVerticalPadding(context); | ||
| 46 | + | ||
| 47 | + // 适配布局反方向特性 | ||
| 48 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { | ||
| 49 | + textView.setPaddingRelative(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding); | ||
| 50 | + } else { | ||
| 51 | + textView.setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + textView.setLayoutParams( | ||
| 55 | + new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); | ||
| 56 | + | ||
| 57 | + Drawable backgroundDrawable = getBackgroundDrawable(context); | ||
| 58 | + // 设置背景 | ||
| 59 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { | ||
| 60 | + textView.setBackground(backgroundDrawable); | ||
| 61 | + } else { | ||
| 62 | + textView.setBackgroundDrawable(backgroundDrawable); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + // 设置 Z 轴阴影 | ||
| 66 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | ||
| 67 | + textView.setZ(getTranslationZ(context)); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + return textView; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + protected int getTextGravity(Context context) { | ||
| 74 | + return Gravity.CENTER; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + protected int getTextColor(Context context) { | ||
| 78 | + return 0XEEFFFFFF; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + protected float getTextSize(Context context) { | ||
| 82 | + return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 14, context.getResources().getDisplayMetrics()); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + protected int getHorizontalPadding(Context context) { | ||
| 86 | + return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, | ||
| 87 | + context.getResources().getDisplayMetrics()); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + protected int getVerticalPadding(Context context) { | ||
| 91 | + return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, | ||
| 92 | + context.getResources().getDisplayMetrics()); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + protected Drawable getBackgroundDrawable(Context context) { | ||
| 96 | + GradientDrawable drawable = new GradientDrawable(); | ||
| 97 | + // 设置颜色 | ||
| 98 | + drawable.setColor(0XB3000000); | ||
| 99 | + // 设置圆角 | ||
| 100 | + drawable.setCornerRadius( | ||
| 101 | + TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, context.getResources().getDisplayMetrics())); | ||
| 102 | + return drawable; | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + protected float getTranslationZ(Context context) { | ||
| 106 | + return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3, context.getResources().getDisplayMetrics()); | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + @Override | ||
| 110 | + public int getYOffset() { | ||
| 111 | + return mYOffset; | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + @Override | ||
| 115 | + public int getGravity() { | ||
| 116 | + return mGravity; | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + @Override | ||
| 120 | + public int getXOffset() { | ||
| 121 | + return mXOffset; | ||
| 122 | + } | ||
| 123 | +} |
| 1 | + | ||
| 2 | +package com.wd.foundation.wdinterfaceimpl.toast; | ||
| 3 | + | ||
| 4 | +import com.wd.foundation.wdinterface.toast.IToast; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * toast使用接口 | ||
| 8 | + */ | ||
| 9 | +public class ToastImpl implements IToast { | ||
| 10 | + | ||
| 11 | + @Override | ||
| 12 | + public void showShort(String msg) { | ||
| 13 | + ToastNightUtil.showShort(msg); | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + @Override | ||
| 17 | + public void showTopShort(String msg, int offsetY) { | ||
| 18 | + ToastNightUtil.showTopShort(msg, offsetY); | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + @Override | ||
| 22 | + public void showLong(String msg) { | ||
| 23 | + ToastNightUtil.showLong(msg); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + @Override | ||
| 27 | + public void showShort(int resId) { | ||
| 28 | + ToastNightUtil.showShort(resId); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + @Override | ||
| 32 | + public void showShortBottom(int resId) { | ||
| 33 | + ToastNightUtil.showShortBottom(resId); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + @Override | ||
| 37 | + public void showLong(int resId) { | ||
| 38 | + ToastNightUtil.showLong(resId); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + @Override | ||
| 42 | + public void show(String msg, int duration) { | ||
| 43 | + ToastNightUtil.show(msg, duration); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + IToast getInst() { | ||
| 47 | + return this; | ||
| 48 | + } | ||
| 49 | +} |
wdinterfaceimpl/src/main/java/com/wd/foundation/wdinterfaceimpl/toast/ToastNightUtil.java
0 → 100644
| 1 | + | ||
| 2 | +package com.wd.foundation.wdinterfaceimpl.toast; | ||
| 3 | + | ||
| 4 | +import android.text.TextUtils; | ||
| 5 | +import android.view.Gravity; | ||
| 6 | +import android.widget.Toast; | ||
| 7 | + | ||
| 8 | +import com.hjq.toast.Toaster; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 单例Toast工具类 | ||
| 12 | + * <p> | ||
| 13 | + * 1.解决toast排队的问题 | ||
| 14 | + * 2.修复Toast在android 7.1手机上的BadTokenException | ||
| 15 | + * 3.兼容位置、时长、stringId | ||
| 16 | + * ToastUtils更名为com.people.matisse.util.ToastNightUtil, | ||
| 17 | + * 第三方库也有这个类名,避免导错包。 | ||
| 18 | + * 统一使用:com.people.matisse.util.ToastNightUtil | ||
| 19 | + */ | ||
| 20 | +public class ToastNightUtil { | ||
| 21 | + | ||
| 22 | + public static void showShort(String message) { | ||
| 23 | + // show(message, Toast.LENGTH_SHORT); | ||
| 24 | + if (!TextUtils.isEmpty(message)) { | ||
| 25 | + Toaster.showShort(message); | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + public static void showTopShort(String message, int y) { | ||
| 30 | + if (!TextUtils.isEmpty(message)) { | ||
| 31 | + Toaster.setStyle(new CustomBlackToastStyle(Gravity.TOP, 0, y - 50, 0, 0)); | ||
| 32 | + Toaster.showShort(message); | ||
| 33 | + } | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + public static void showLong(String message) { | ||
| 37 | + // 显示长 Toast | ||
| 38 | + Toaster.showLong(message); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public static void showShort(int stringId) { | ||
| 42 | + Toaster.showShort(stringId); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + public static void showShortBottom(int stringId) { | ||
| 46 | + Toaster.setStyle(new CustomBlackToastStyle(Gravity.BOTTOM, 0, 200, 0, 0)); | ||
| 47 | + Toaster.showShort(stringId); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + public static void showLong(int stringId) { | ||
| 51 | + Toaster.showLong(stringId); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * show Toast 可选时长 | ||
| 56 | + * | ||
| 57 | + * @param content 内容 | ||
| 58 | + * @param duration {@link Toast#LENGTH_SHORT},{@link Toast#LENGTH_LONG} | ||
| 59 | + */ | ||
| 60 | + public static void show(String content, int duration) { | ||
| 61 | + if (TextUtils.isEmpty(content)) { | ||
| 62 | + return; | ||
| 63 | + } | ||
| 64 | + if (Toast.LENGTH_LONG == duration) { | ||
| 65 | + Toaster.showLong(content); | ||
| 66 | + } else { | ||
| 67 | + Toaster.showShort(content); | ||
| 68 | + } | ||
| 69 | + } | ||
| 70 | +} |
-
Please register or login to post a comment