首次提交

This commit is contained in:
18631081161 2024-06-03 15:30:15 +08:00
commit f41919ba5a
254 changed files with 24394 additions and 0 deletions

45
.gitignore vendored Normal file
View File

@ -0,0 +1,45 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/
# Symbolication related
app.*.symbols
# Obfuscation related
app.*.map.json
# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
/pubspec.lock

30
.metadata Normal file
View File

@ -0,0 +1,30 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled.
version:
revision: 4f9d92fbbdf072a70a70d2179a9f87392b94104c
channel: stable
project_type: app
# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 4f9d92fbbdf072a70a70d2179a9f87392b94104c
base_revision: 4f9d92fbbdf072a70a70d2179a9f87392b94104c
- platform: android
create_revision: 4f9d92fbbdf072a70a70d2179a9f87392b94104c
base_revision: 4f9d92fbbdf072a70a70d2179a9f87392b94104c
# User provided section
# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'

92
README.md Normal file
View File

@ -0,0 +1,92 @@
# Ai_drawing
AI绘图包
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin http://192.168.1.33/mogu_flutter/ai_drawing.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](http://192.168.1.33/mogu_flutter/ai_drawing/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.

29
analysis_options.yaml Normal file
View File

@ -0,0 +1,29 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.
# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options

13
android/.gitignore vendored Normal file
View File

@ -0,0 +1,13 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
**/*.keystore
**/*.jks

85
android/app/build.gradle Normal file
View File

@ -0,0 +1,85 @@
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 33
ndkVersion flutter.ndkVersion
signingConfigs {
//
signConfig {
storeFile file("aiDraw.jks")
storePassword '123456'
keyAlias 'aiDraw'
keyPassword '123456'
}
}
lintOptions {
//Failed to transform libs.jar to match attributes
checkReleaseBuilds false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.hissai.draw"
minSdkVersion 19
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
signingConfig signingConfigs.signConfig //gradlew assembleRelease
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
//
minifyEnabled false //
shrinkResources false //
}
debug {
signingConfig signingConfigs.signConfig
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
}
}
flutter {
source '../..'
}

View File

@ -0,0 +1,59 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hissai.draw">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
<application
android:name="com.hissai.draw.App"
android:icon="@mipmap/ic_launcher"
android:label="HissAi">
<activity
android:name="com.hissai.draw.MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
</application>
</manifest>

View File

@ -0,0 +1,2 @@
BossId=27014
AppId=1001

View File

@ -0,0 +1,30 @@
package com.hissai.draw;
import android.content.Context;
import io.flutter.app.FlutterApplication;
public class App extends FlutterApplication {
private static App instance;
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
}
@Override
public void onCreate() {
super.onCreate();
instance = this;
}
public static App getInstance() {
return instance;
}
}

View File

@ -0,0 +1,82 @@
package com.hissai.draw;
import android.os.Bundle;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.hissai.draw.utils.AppUtil;
import com.hissai.draw.utils.Configs;
import com.hissai.draw.utils.MacInfo;
import com.hissai.draw.utils.NetWork;
import com.hissai.draw.utils.ThreadUtil;
import java.util.HashMap;
import java.util.Map;
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.StandardMethodCodec;
public class MainActivity extends FlutterActivity {
private static final String CHANNEL = "samples.flutter.dev/battery";
private MethodChannel nativeChannel;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ThreadUtil.INST.excute(() -> NetWork.getConfigs(MainActivity.this));
}
@Override
protected void onResume() {
super.onResume();
}
@Override
protected void onPause() {
super.onPause();
}
@Override
protected void onDestroy() {
super.onDestroy();
}
//flutter 通道
@Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
super.configureFlutterEngine(flutterEngine);
Log.d("TAG", "configureFlutterEngine: flutterEngine");
nativeChannel = new MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(), CHANNEL, StandardMethodCodec.INSTANCE);
nativeChannel.setMethodCallHandler((call, result) -> {
switch (call.method) {
case "getRequestHeaders":
Map<String, Object> map = new HashMap<>();
map.put("AppId", Configs.appId);
map.put("BossId", Configs.bossId);
map.put("Version", Configs.versionName);
map.put("CPU", Configs.cpu);
MacInfo.imsi = MacInfo.getSubscriptionOperatorType();
map.put("imsi", MacInfo.imsi != null ? MacInfo.imsi : "");
map.put("ip", Configs.ip);
map.put("timeZone", AppUtil.getTimeZone());
map.put("statusHeight", AppUtil.px2dip(App.getInstance(), AppUtil.getStatusBarHeight(App.getInstance())));//状态栏高度
result.success(map);
break;
case "initAPI"://同意隐私初始化信息
ThreadUtil.INST.excute(() -> {
NetWork.getInit(MainActivity.this);
});
break;
}
});
}
}

View File

@ -0,0 +1,807 @@
package com.hissai.draw.utils;
import android.Manifest;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.AppOpsManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.media.AudioManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.Toast;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.core.app.NotificationManagerCompat;
import com.hissai.draw.App;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* App工具类
*/
public class AppUtil {
public static boolean checkURL(String url) {
boolean value = false;
try {
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
int code = conn.getResponseCode();
if (code != 200) {
value = false;
} else {
value = true;
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return value;
}
/**
* 获得屏幕宽度
*
* @param context
* @return
*/
public static int getScreenWidth(Context context) {
WindowManager wm = (WindowManager) context
.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics outMetrics = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(outMetrics);
return outMetrics.widthPixels;
}
/**
* 获得屏幕高度
* 小于android4.4去掉状态栏高度
*
* @param context
* @return
*/
public static int getScreenHeight(Context context) {
WindowManager wm = (WindowManager) context
.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics outMetrics = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(outMetrics);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
return outMetrics.heightPixels;
} else {
return outMetrics.heightPixels - getStatusBarHeight(context);
}
}
/**
* 获取状态栏高度
*
* @param context
* @return
*/
public static int getStatusBarHeight(Context context) {
int result = 0;
try {
int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
result = context.getResources().getDimensionPixelSize(resourceId);
}
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
// 根据手机的分辨率从 px(像素) 的单位 转成为 dp
public static int px2dip(Context context, float pxValue) {
// 获取当前手机的像素密度1个dp对应几个px
float scale = context.getResources().getDisplayMetrics().density;
return (int) (pxValue / scale + 0.5f); // 四舍五入取整
}
/**
* 获取屏幕宽度
*
* @param context
* @return
*/
public static int getWindowWidth(Context context) {
// 获取屏幕分辨率
WindowManager wm = (WindowManager) (context
.getSystemService(Context.WINDOW_SERVICE));
DisplayMetrics dm = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(dm);
int mScreenWidth = dm.widthPixels;
return mScreenWidth;
}
/**
* 获取屏幕高度
*
* @param context
* @return
*/
public static int getWindowHight(Context context) {
// 获取屏幕分辨率
WindowManager wm = (WindowManager) (context.getSystemService(Context.WINDOW_SERVICE));
DisplayMetrics dm = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(dm);
int mScreenHight = dm.heightPixels;
return mScreenHight;
}
/**
* 检测耳机是否接入
* 0无插入1耳机和话筒均插入2仅插入话筒
*
* @return
*/
public static boolean isHeadsetExists(Context context) {
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
return audioManager.isWiredHeadsetOn();
}
public static boolean isBlueTooth(Context context) {
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
return audioManager.isBluetoothA2dpOn();
}
/**
* 获取唯一设备号
*
* @param context
* @return
*/
public static String getDeviceId(Context context) {
String android_id = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
Log.d("TAG", "getDeviceId: android_id==" + android_id);
return android_id;
}
/**
* 隐藏软键盘
*
* @param context
* @param editText
* @return
*/
public static void hideInputMethod(Context context, EditText editText) {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
}
/**
* 隐藏软键盘
*
* @param activity
* @return
*/
public static boolean hideInputMethod(Activity activity) {
InputMethodManager imm = (InputMethodManager) activity
.getSystemService(Context.INPUT_METHOD_SERVICE);
if (activity.getCurrentFocus() == null)
return false;
return imm.hideSoftInputFromWindow(activity.getCurrentFocus()
.getApplicationWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
}
/**
* 显示或者隐藏状态栏true隐藏false显示
*
* @param @param context
* @param @param enable
* @return void
* @description
* @author yanqin
*/
public static void full(Context context, boolean enable) {
if (enable) {
((Activity) context).getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);//隐藏状态栏
} else {
((Activity) context).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); //显示状态栏
}
}
//打开扬声器
public static void OpenSpeaker(Context mContext) {
try {
//判断扬声器是否在打开
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
audioManager.setMode(AudioManager.ROUTE_SPEAKER);
//获取当前通话音量
audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL);
if (!audioManager.isSpeakerphoneOn()) {
audioManager.setSpeakerphoneOn(true);
audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL,
audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL),
AudioManager.STREAM_VOICE_CALL);
}
} catch (Exception e) {
e.printStackTrace();
}
}
//关闭扬声器
public static void CloseSpeaker(Context mContext) {
try {
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
if (audioManager != null) {
if (audioManager.isSpeakerphoneOn()) {
audioManager.setSpeakerphoneOn(false);
audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, 50,
AudioManager.STREAM_VOICE_CALL);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static String getUserAgent(Context context) {
String userAgent = "";
if (context != null) {
PackageManager pm = context.getPackageManager();
if (pm != null) {
String appName = context.getApplicationInfo().loadLabel(pm).toString();
String packageName = context.getPackageName();
userAgent = packageName.substring(packageName.lastIndexOf(".") + 1, packageName.length());
userAgent = userAgent + "/" + getVersionName(context);
userAgent = userAgent + "(" + Build.MODEL + ";" + getAndroidSDKVersionString() + ")";
}
}
if (userAgent != null) {
if (isChinese(userAgent)) {
userAgent = chinaToUnicode(userAgent);
}
}
return userAgent;
}
// 判断一个字符是否是中文
public static boolean isChinese(char c) {
return c >= 0x4E00 && c <= 0x9FA5;// 根据字节码判断
}
// 判断一个字符串是否含有中文
public static boolean isChinese(String str) {
if (str == null)
return false;
for (char c : str.toCharArray()) {
if (isChinese(c))
return true;// 有一个中文字符就返回
}
return false;
}
public static String chinaToUnicode(String str) {
String result = null;
for (int i = 0; i < str.length(); i++) {
int chr1 = (char) str.charAt(i);
result += "\\u" + Integer.toHexString(chr1);
}
return result;
}
/**
* 描述判断网络是否有效.
*
* @param context the context
* @return true, if is network available
*/
public static boolean isNetworkAvailable(Context context) {
try {
ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity != null) {
NetworkInfo info = connectivity.getActiveNetworkInfo();
if (info != null && info.isConnected()) {
if (info.getState() == NetworkInfo.State.CONNECTED) {
return true;
}
}
}
} catch (Exception e) {
return false;
}
return false;
}
/**
* 描述判断网络是否有效.没有网络时进行提示
*
* @param context the context
* @return true, if is network available
*/
public static boolean isNetworkAvailableMsg(Context context, int msgId) {
try {
ConnectivityManager connectivity = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity != null) {
NetworkInfo info = connectivity.getActiveNetworkInfo();
if (info != null && info.isConnected()) {
if (info.getState() == NetworkInfo.State.CONNECTED) {
return true;
} else {
Toast.makeText(context, msgId, Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(context, msgId, Toast.LENGTH_SHORT).show();
}
}
} catch (Exception e) {
return false;
}
return false;
}
/**
* 判断当前网络是否是wifi网络.
*
* @param context the context
* @return boolean
*/
public static boolean isWifi(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
if (activeNetInfo != null
&& activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI) {
return true;
}
return false;
}
//版本号
public static int getVersionCode(Context context) {
return getPackageInfo(context).versionCode;
}
private static PackageInfo getPackageInfo(Context context) {
PackageInfo pi = null;
try {
PackageManager pm = context.getPackageManager();
pi = pm.getPackageInfo(context.getPackageName(),
PackageManager.GET_CONFIGURATIONS);
return pi;
} catch (Exception e) {
e.printStackTrace();
}
return pi;
}
/**
* 获取当前应用的版本名
*
* @return
*/
public static String getVersionName(Context context) {
// 获取packagemanager的实例
if (context == null) {
return "";
}
PackageManager packageManager = context.getPackageManager();
if (packageManager == null)
return "";
// getPackageName()是你当前类的包名0代表是获取版本信息
PackageInfo packInfo;
String version = "";
try {
packInfo = packageManager.getPackageInfo(context.getPackageName(),
0);
version = packInfo.versionName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return version;
}
/**
* 初始化手机屏幕的宽高
*
* @param activity
*/
public static DisplayMetrics getScreenSize(Activity activity) {
DisplayMetrics dm = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
return dm;
}
/**
* 根据手机的分辨率从 dp 的单位 转成为 px(像素)
*/
public static int dip2px(Context context, double dpValue) {
Context mContext = context;//防止获取的上下文为空
final float scale = mContext.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
/**
* 判断是否有sim卡
*
* @param context
* @return
*/
public static boolean hasSimCard(Context context) {
TelephonyManager telMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
int simState = telMgr.getSimState();
boolean result = true;
switch (simState) {
case TelephonyManager.SIM_STATE_ABSENT:
result = false; // 没有SIM卡
break;
case TelephonyManager.SIM_STATE_UNKNOWN:
result = false;
break;
}
return result;
}
/**
* 判断是否是通话设备
*
* @param context
* @return
*/
public static boolean isPhoneDevice(Context context) {
TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
int type = telephony.getPhoneType();
if (type == TelephonyManager.PHONE_TYPE_NONE) {
//是通话设备
return false;
} else {
//不是通话设备
return true;
}
}
/**
* 获取手机系统版本
*
* @param @return
* @return String
* @description
* @author yanqin
*/
public static String getAndroidSDKVersionString() {
return "Android " + Build.VERSION.RELEASE;
}
/**
* 获取外网的IP(要访问Url要放到后台线程里处理)
*
* @param @return
* @return String
* @throws
* @Title: GetNetIp
* @Description:
*/
public static String getNetIp() {
URL infoUrl = null;
InputStream inStream = null;
String ipLine = "";
HttpURLConnection httpConnection = null;
try {
infoUrl = new URL("http://pv.sohu.com/cityjson?ie=utf-8");//必须要用这个网址因为这个网址返回了我们的ip地址
URLConnection connection = infoUrl.openConnection();
httpConnection = (HttpURLConnection) connection;
int responseCode = httpConnection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
inStream = httpConnection.getInputStream();
BufferedReader reader = new BufferedReader(
new InputStreamReader(inStream, "utf-8"));
StringBuilder strber = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
strber.append(line + "\n");
}
Pattern pattern = Pattern
.compile("((?:(?:25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d)))\\.){3}(?:25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d))))");
Matcher matcher = pattern.matcher(strber.toString());
if (matcher.find()) {
ipLine = matcher.group();
}
//释放资源
reader.close();
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
inStream.close();
httpConnection.disconnect();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
}
}
return ipLine;
}
/**
* 判断android activity是否运行可见
*
* @param mContext
* @param activityClassName
* @return
*/
public static boolean isActivityRunning(Context mContext, String activityClassName) {
ActivityManager activityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> info = activityManager.getRunningTasks(1);
if (info != null && info.size() > 0) {
ComponentName component = info.get(0).topActivity;
if (activityClassName.equals(component.getClassName())) {
return true;
}
}
return false;
}
/**
* 获取手机型号
*
* @return 手机型号
*/
public static String getSystemModel() {
return Build.MODEL;
}
/**
* 获取手机厂商
*
* @return 手机厂商
*/
public static String getDeviceBrand() {
return Build.BRAND;
}
/**
* 获取手机IMEI(需要android.permission.READ_PHONE_STATE权限)
*
* @return 手机IMEI
*/
public static String getIMEI(Context ctx) {
TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Activity.TELEPHONY_SERVICE);
if (tm != null) {
if (ActivityCompat.checkSelfPermission(ctx, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
return "";
}
return tm.getDeviceId();
}
return null;
}
/**
* 获取手机mac地址
* 并不是所有机型都适配
*
* @param ctx
* @return
*/
public static String getWifiMac(Context ctx) {
WifiManager wifi = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE);
WifiInfo info = wifi.getConnectionInfo();
String str = info.getMacAddress();
if (str == null) str = "";
return str;
}
/**
* 这是使用adb shell命令来获取mac地址的方式
*
* @return
*/
public static String getMac(Context ctx) {
String macSerial = null;
String str = "";
try {
Process pp = Runtime.getRuntime().exec("cat /sys/class/net/wlan0/address ");
InputStreamReader ir = new InputStreamReader(pp.getInputStream());
LineNumberReader input = new LineNumberReader(ir);
for (; null != str; ) {
str = input.readLine();
if (str != null) {
macSerial = str.trim();// 去空格
break;
}
}
//释放资源
ir.close();
input.close();
} catch (IOException ex) {
// 赋予默认值
ex.printStackTrace();
}
if ("".equals(str)) {
return getWifiMac(ctx);
}
return macSerial;
}
/**
* 获取系统音量
*
* @return
*/
public static int getMediaVolume(Context context) {
AudioManager audioMgr = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
return audioMgr.getStreamVolume(AudioManager.STREAM_MUSIC);
}
/**
* 获取系统最大音量
*
* @param streamType AudioManager.STREAM_MUSIC 声道
* @return
*/
public static int getMediaMaxVolume(Context context, int streamType) {
AudioManager audioMgr = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
return audioMgr.getStreamMaxVolume(streamType);
}
/**
* 设置音量
*
* @param volume
*/
public static void setMediaVolume(int volume, Context context) {
AudioManager audioMgr = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
audioMgr.setStreamVolume(AudioManager.STREAM_MUSIC, volume, AudioManager.FLAG_PLAY_SOUND);
}
/**
* 设置音量
*
* @param volume
*/
public static void setMediaVolumeNoSound(int volume, Context context) {
AudioManager audioMgr = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
audioMgr.setStreamVolume(AudioManager.STREAM_MUSIC, volume, 0);
}
/**
* 获取是否存在NavigationBar(虚拟按键)
*
* @param @param context
* @param @return
* @return boolean
* @description
* @author yanqin
*/
private static boolean checkDeviceHasNavigationBar(Context context) {
boolean hasNavigationBar = false;
Resources rs = context.getResources();
int id = rs
.getIdentifier("config_showNavigationBar", "bool", "android");
if (id > 0) {
hasNavigationBar = rs.getBoolean(id);
}
try {
Class systemPropertiesClass = Class
.forName("android.os.SystemProperties");
Method m = systemPropertiesClass.getMethod("get", String.class);
String navBarOverride = (String) m.invoke(systemPropertiesClass,
"qemu.hw.mainkeys");
if ("1".equals(navBarOverride)) {
hasNavigationBar = false;
} else if ("0".equals(navBarOverride)) {
hasNavigationBar = true;
}
} catch (Exception e) {
}
return hasNavigationBar;
}
/**
* 获取NavigationBar(虚拟按键)的高度
*
* @param @param context
* @param @return
* @return int
* @description
* @author yangqin
*/
public static int getNavigationBarHeight(Context context) {
int navigationBarHeight = 0;
Resources rs = context.getResources();
int id = rs.getIdentifier("navigation_bar_height", "dimen", "android");
if (id > 0 && checkDeviceHasNavigationBar(context)) {
navigationBarHeight = rs.getDimensionPixelSize(id);
}
return navigationBarHeight;
}
//获取系统语言
public static String getSystemLan() {
Locale locale = App.getInstance().getResources().getConfiguration().locale;
String language = locale.getLanguage();
String local = Locale.getDefault().toString();
String country = App.getInstance().getResources().getConfiguration().locale.getCountry();
Log.e("HJL", "tjCountry: language:" + language + ",local:" + local + ",country:" + country);
return language;
}
//获取系统时区
public static String getTimeZone() {
TimeZone timeZone = TimeZone.getDefault();
String id = timeZone.getID(); //获取时区idAsia/Shanghai
String name = timeZone.getDisplayName(); //获取名字
String shotName = timeZone.getDisplayName(false, TimeZone.SHORT); //获取名字GMT+08:00
int time = timeZone.getRawOffset(); //获取时差返回值毫秒
/*Log.d("TAG", "getTimeZone: id==" + id);
Log.d("TAG", "getTimeZone: name==" + name);
Log.d("TAG", "getTimeZone: shotName==" + shotName);
Log.d("TAG", "getTimeZone: time==" + time);*/
return shotName;
}
}

View File

@ -0,0 +1,14 @@
package com.hissai.draw.utils;
public class Configs {
public static String bossId = "24001";
public static String serverURL = "https://ecdnjyouapihw.cnrplay.com/phone300_Api/";
public static String ip = "";//本机ip地址
public static String deviceId = "";//设备ID
public static String appId = "1";
public static String versionName = "";//版本号
public static String deviceModel = "";//设备的硬件厂商和型号
public static String systemVersion = "";//操作系统版本号
public static String cpu = "";//
}

View File

@ -0,0 +1,365 @@
package com.hissai.draw.utils;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.telephony.TelephonyManager;
import android.util.Log;
import com.hissai.draw.App;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.UUID;
public class MacInfo {
public static String getMac(Activity activity) {
return md5s(getDeviceUDID(activity));
}
private static String md5s(String plainText) {
String str = "";
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(plainText.getBytes());
byte b[] = md.digest();
int i;
StringBuffer buf = new StringBuffer("");
for (int offset = 0; offset < b.length; offset++) {
i = b[offset];
if (i < 0)
i += 256;
if (i < 16)
buf.append("0");
buf.append(Integer.toHexString(i));
}
str = buf.toString();
str = str.toUpperCase();
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return str;
}
public static String android_id = "";
public static String imei = "";
public static String imei2 = "";
public static String imsi = "";
public static String imsi2 = "";
public static String sn = "";
public static String mac = "";
public static String device_id = "";
public static String oaId = "";
@SuppressLint("MissingPermission")
private static String getDeviceUDID(Activity activity) {
android_id = Configs.deviceId;
try {
TelephonyManager tm = (TelephonyManager) activity.getSystemService(Context.TELEPHONY_SERVICE);
if (tm != null) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
if (tm.hasCarrierPrivileges()) {
imei = tm.getImei(0);
imei2 = tm.getImei(1);
} else {
System.out.println("Can not get IMEI info.");
}
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
imei = tm.getImei(0);
imei2 = tm.getImei(1);
} else {
imei = tm.getDeviceId();
}
}
} catch (Exception e) {
e.printStackTrace();
}
try {
device_id = getUUID();
} catch (Exception e) {
e.printStackTrace();
}
if (device_id == null) {
device_id = "";
}
if (imei == null) {
imei = "";
}
try {
// sn
sn = Build.SERIAL;
if (sn == null)
sn = "";
} catch (Exception e) {
sn = "";
}
try {
// mac address
WifiManager wifi = (WifiManager) activity.getApplicationContext()
.getSystemService(Context.WIFI_SERVICE);
WifiInfo info = wifi.getConnectionInfo();
mac = info.getMacAddress();
if (mac == null || mac.equals("")
|| mac.equals("00:00:00:00:00:00") || mac.equals("02:00:00:00:00:00")) {
mac = getLocalMacAddressFromIp();
}
if (mac == null || mac.equals("")
|| mac.equals("00:00:00:00:00:00") || mac.equals("02:00:00:00:00:00")) {
mac = getNewMac();
}
if (mac == null || mac.equals("")
|| mac.equals("00:00:00:00:00:00") || mac.equals("02:00:00:00:00:00")) {
mac = "";
}
} catch (Exception e) {
mac = "";
}
return android_id + ":" + imei + ":" + sn + ":" + mac;
}
public static String getOAID(Activity activity) {
try {
oaId = "";
} catch (Exception e) {
e.printStackTrace();
}
return oaId;
}
@SuppressLint("MissingPermission")
public static String getUUID() {
String serial = null;
String m_szDevIDShort = "35" +
Build.BOARD.length() % 10 + Build.BRAND.length() % 10 +
Build.CPU_ABI.length() % 10 + Build.DEVICE.length() % 10 +
Build.DISPLAY.length() % 10 + Build.HOST.length() % 10 +
Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 +
Build.MODEL.length() % 10 + Build.PRODUCT.length() % 10 +
Build.TAGS.length() % 10 + Build.TYPE.length() % 10 +
Build.USER.length() % 10; //13
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
serial = Build.getSerial();
} else {
serial = Build.SERIAL;
}
//API>=9 使用serial号
return new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString();
} catch (Exception exception) {
//serial需要一个初始化
serial = "serial"; // 随便一个初始化
}
//使用硬件信息拼凑出来的15位号码
return new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString();
}
/**
* 通过网络接口取
*
* @return
*/
private static String getNewMac() {
try {
List<NetworkInterface> all = Collections.list(NetworkInterface.getNetworkInterfaces());
for (NetworkInterface nif : all) {
if (!nif.getName().equalsIgnoreCase("wlan0")) continue;
byte[] macBytes = nif.getHardwareAddress();
if (macBytes == null) {
return null;
}
StringBuilder res1 = new StringBuilder();
for (byte b : macBytes) {
res1.append(String.format("%02X:", b));
}
if (res1.length() > 0) {
res1.deleteCharAt(res1.length() - 1);
}
return res1.toString();
}
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
/**
*  * 根据IP地址获取MAC地址
*  * @return
*  
*/
private static String getLocalMacAddressFromIp() {
String strMacAddr = null;
try {
//获得IpD地址
InetAddress ip = getLocalInetAddress();
byte[] b = NetworkInterface.getByInetAddress(ip).getHardwareAddress();
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < b.length; i++) {
if (i != 0) {
buffer.append(':');
}
String str = Integer.toHexString(b[i] & 0xFF);
buffer.append(str.length() == 1 ? 0 + str : str);
}
strMacAddr = buffer.toString().toUpperCase();
} catch (Exception e) {
}
return strMacAddr;
}
/**
*  * 获取移动设备本地IP
*  * @return
*  
*/
private static InetAddress getLocalInetAddress() {
InetAddress ip = null;
try {
//列举
Enumeration<NetworkInterface> en_netInterface = NetworkInterface.getNetworkInterfaces();
while (en_netInterface.hasMoreElements()) {//是否还有元素
NetworkInterface ni = (NetworkInterface) en_netInterface.nextElement();//得到下一个元素
Enumeration<InetAddress> en_ip = ni.getInetAddresses();//得到一个ip地址的列举
while (en_ip.hasMoreElements()) {
ip = en_ip.nextElement();
if (!ip.isLoopbackAddress() && ip.getHostAddress().indexOf(":") == -1)
break;
else
ip = null;
}
if (ip != null) {
break;
}
}
} catch (SocketException e) {
e.printStackTrace();
}
return ip;
}
private static String callCmd(String cmd, String filter) {
String result = "";
String line = "";
try {
Process proc = Runtime.getRuntime().exec(cmd);
InputStreamReader is = new InputStreamReader(proc.getInputStream());
BufferedReader br = new BufferedReader(is);
// ִ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>cmd<EFBFBD><EFBFBD>ֻȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>к<EFBFBD><EFBFBD><EFBFBD>filter<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>
while ((line = br.readLine()) != null
&& line.contains(filter) == false) {
// result += line;
Log.i("test", "line: " + line);
}
result = line;
Log.i("test", "result: " + result);
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
private static String getMacForHisense() {
String path = "/sys/class/net/eth0/address";
File file = new File(path);
if (file.exists()) {
BufferedReader buf;
try {
buf = new BufferedReader(new FileReader(file));
String mac = buf.readLine();
if (mac != null) {
return mac;
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return "";
}
/**
* 获取设备拨号运营商
*
* @return ["中国电信CTCC":3]["中国联通CUCC:2]["中国移动CMCC":1]["other":0]["无sim卡":-1]
*/
public static String getSubscriptionOperatorType() {
//int opeType = -1;
// No sim
if (!hasSim()) {
return null;
}
TelephonyManager tm = (TelephonyManager) App.getInstance().getSystemService(Context.TELEPHONY_SERVICE);
String operator = tm.getSimOperator();
String operator2 = tm.getSimOperatorName();
/* // 中国联通
if ("46001".equals(operator) || "46006".equals(operator) || "46009".equals(operator)) {
opeType = 2;
// 中国移动
} else if ("46000".equals(operator) || "46002".equals(operator) || "46004".equals(operator) || "46007".equals(operator)) {
opeType = 1;
// 中国电信
} else if ("46003".equals(operator) || "46005".equals(operator) || "46011".equals(operator)) {
opeType = 3;
} else {
opeType = 0;
}*/
return operator;
}
/**
* 判断是否有Sim卡
*
* @return
*/
public static boolean hasSim() {
TelephonyManager tm = (TelephonyManager) App.getInstance().getSystemService(Context.TELEPHONY_SERVICE);
if (tm.getSimState() == TelephonyManager.SIM_STATE_READY) {
return true;
} else {
return false;
}
}
}

View File

@ -0,0 +1,89 @@
package com.hissai.draw.utils;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class NetWork {
//读取文件
public static Properties getNetConfigProperties(Context activity) {
Properties props = new Properties();
InputStream in;
try {
in = activity.getAssets().open("holybladeCloud.properties");
props.load(in);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
return props;
}
//获取配置
public static void getConfigs(Context context) {
Properties con = getNetConfigProperties(context);
if (Configs.serverURL.equals("")) {
Configs.serverURL = con.getProperty("ServerURL");
}
Configs.bossId = con.getProperty("BossId");
Configs.appId = con.getProperty("AppId");
// 获取版本号
PackageManager packageManager = context.getPackageManager();
// getPackageName()是你当前类的包名0代表是获取版本信息
PackageInfo packInfo = null;
try {
packInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
Configs.versionName = packInfo.versionName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
//同意协议 初始化 获取设备信息
public static void getInit(Context context) {
Configs.deviceId = AppUtil.getDeviceId(context);
String brand = android.os.Build.BRAND;
String model = android.os.Build.MODEL;
Configs.deviceModel = brand + ":" + model;
Configs.systemVersion = "android:" + android.os.Build.VERSION.RELEASE;
Configs.cpu = getCpuName();
}
//获取cpu名称
public static String getCpuName() {
String cpuName = "";
try {
FileReader fr = new FileReader("/proc/cpuinfo");
BufferedReader br = new BufferedReader(fr);
String text;
while ((text = br.readLine()) != null) {
String[] array = text.split(":\\s+", 2);
for (int i = 0; i < array.length; i++) {
//LogUtil.d("cpuName = "+ i + "="+array[i]);
cpuName = array[i];
}
if (array[0].contains("Hardware") || array[0].contains("hardware"))
break;
}
return cpuName;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return "";
}
}

View File

@ -0,0 +1,61 @@
package com.hissai.draw.utils;
import android.os.Handler;
import android.os.Looper;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* 线程工具用于执行线程等
*/
public final class ThreadUtil {
public static final ThreadUtil INST = new ThreadUtil();
private ExecutorService executors;
private ThreadUtil() {
}
/**
* 在线程中执行
*
* @param runnable 要执行的runnable
*/
public void excute(Runnable runnable) {
ExecutorService executorService = getExecutorService();
if (executorService != null) {
// 优先使用线程池提高效率
executorService.execute(runnable);
} else {
// 线程池获取失败则直接使用线程
new Thread(runnable).start();
}
}
/**
* 在主线程中执行
*
* @param runnable 要执行的runnable
*/
public void excuteInMainThread(Runnable runnable) {
new Handler(Looper.getMainLooper()).post(runnable);
}
/**
* 获取缓存线程池
*
* @return 缓存线程池服务
*/
private ExecutorService getExecutorService() {
if (executors == null) {
try {
executors = Executors.newCachedThreadPool();
} catch (Exception e) {
}
}
return executors;
}
}

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<!-- You can insert your own image assets here -->
<!-- <item>-->
<!-- <bitmap-->
<!-- android:gravity="fill"-->
<!-- android:src="@mipmap/kpy" />-->
<!-- </item>-->
<!-- <item android:drawable="@mipmap/kpy"/>-->
</layer-list>

Binary file not shown.

After

Width:  |  Height:  |  Size: 700 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 700 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 700 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 700 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 700 KiB

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="Test">#C4C4C4</color>
</resources>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>

View File

@ -0,0 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hissai.draw">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>

33
android/build.gradle Normal file
View File

@ -0,0 +1,33 @@
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}

View File

@ -0,0 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true

View File

@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip

11
android/settings.gradle Normal file
View File

@ -0,0 +1,11 @@
include ':app'
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
assets/images/create.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

BIN
assets/images/create_r.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

BIN
assets/images/cuo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 807 B

BIN
assets/images/cuo2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
assets/images/gallery.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
assets/images/gallery_r.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

BIN
assets/images/head.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
assets/images/ic_ad.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
assets/images/ic_bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 KiB

BIN
assets/images/ic_check.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 873 B

BIN
assets/images/ic_close.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 969 B

BIN
assets/images/ic_count.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

BIN
assets/images/ic_follow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
assets/images/ic_jump.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 675 B

BIN
assets/images/ic_like.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

BIN
assets/images/ic_mall.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
assets/images/ic_open.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
assets/images/ic_random.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
assets/images/ic_return.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 964 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

BIN
assets/images/ic_search.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
assets/images/ic_share.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
assets/images/ic_sort.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
assets/images/ic_tip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
assets/images/ic_title.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 682 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
assets/images/ic_upload.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
assets/images/ic_works.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
assets/images/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
assets/images/img_11.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 869 B

BIN
assets/images/img_11_no.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
assets/images/img_169.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
assets/images/img_34.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
assets/images/img_34_no.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
assets/images/img_43.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
assets/images/img_43_no.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
assets/images/img_916.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
assets/images/jia.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
assets/images/jia_w.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

BIN
assets/images/kpy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

BIN
assets/images/kuang.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
assets/images/login_bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

BIN
assets/images/me.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
assets/images/me_r.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
assets/images/shop_bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

BIN
assets/images/shop_logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Some files were not shown because too many files have changed in this diff Show More