拷贝APP_Bck20250119项目源码,移除libjc/jcc/libs/android-29.jar文件。

This commit is contained in:
ZhanGSKen
2025-01-19 19:59:04 +08:00
commit 65509eacba
654 changed files with 35062 additions and 0 deletions

1
powerbell/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

111
powerbell/README.md Normal file
View File

@@ -0,0 +1,111 @@
# PowerBell
#### 介绍
一个接收手机电量信息的应用,当电量值达到设定范围时会提醒用户。
#### 软件架构
适配安卓应用 [AIDE Pro] 的 Gradle 编译结构。
也适配安卓应用 [AndroidIDE] 的 Gradle 编译结构。
#### Gradle 编译说明
调试版编译命令 gradle assembleBetaDebug
阶段版编译命令 gradle assembleStageRelease
#### 使用说明
在安卓系统中需要设置两个权限允许。
1.自启动权限允许。
2.省电策略-无限制权限允许。
3.设置背景图片需要读写手机存储权限。
#### 参与贡献
1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码 : ZhanGSKen(ZhanGSKen@QQ.COM)
4. 新建 Pull Request
#### 特技
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
#### 参考文档
AndroidManifest.xml详解
https://www.jianshu.com/p/3b5b89d4e154
CrashHandler自定义异常处理
https://www.jianshu.com/p/9a3d800a429a
Android用Intent启动Activity的方法
https://blog.csdn.net/huangxiaohu_coder/article/details/7105457
Android开发最详细的 Toolbar 开发实践总结
https://www.jianshu.com/p/79604c3ddcae
Using the App Toolbar
https://guides.codepath.com/android/using-the-app-toolbar
Android的onCreateOptionsMenu()创建菜单Menu详解
https://www.cnblogs.com/spring87/p/4312538.html
Android通知栏-Notification通知消息
https://blog.csdn.net/qq_35507234/article/details/90676587
android之PendingIntent的使用
https://blog.csdn.net/qq_16628781/article/details/51548324
change seekbar color android” Code Answer
https://www.codegrepper.com/code-examples/whatever/change+seekbar+color+android
如何选择开源项目许可证
https://www.zhihu.com/question/28292322
Android最简单的自定义布局Notification
https://blog.csdn.net/acesheep_911/article/details/81458784?utm_medium=distribute.wap_relevant.none-task-blog-2~default~baidujs_title~default-0.wap_blog_relevant_default&spm=1001.2101.3001.4242.1&utm_relevant_index=3
Android中通知栏Notification详解以及自定义Notification
https://blog.csdn.net/daitu_liang/article/details/50246803
Android 图像系列: 将本地图片加载到Drawable
https://blog.csdn.net/qzone123222/article/details/7930035
android 从相册选择,Android开发从相册中选取照片
https://blog.csdn.net/weixin_42146086/article/details/117570917
Android 任务栈简介
https://blog.csdn.net/qq_34368586/article/details/107653912
Android用Intent启动Activity的方法
https://blog.csdn.net/huangxiaohu_coder/article/details/7105457
Android中使用dimen定义尺寸
https://blog.csdn.net/yuzhiboyi/article/details/7696174
declare-styleable自定义控件的属性
https://blog.csdn.net/congqingbin/article/details/7869730
安卓自定义滑动解锁控件
https://blog.csdn.net/lp506954774/article/details/72677018
Android 添加菜单和返回按钮
https://blog.csdn.net/my_tiantian/article/details/77822173
Android Button的基本使用
https://www.cnblogs.com/yishaochu/p/5783605.html
Android应用中实现系统“分享”接口
https://blog.csdn.net/lowprofile_coding/article/details/37656255
Android 关于mimeType的使用
https://blog.csdn.net/dorytmx/article/details/80972248
使用GitHub Actions实现Android自动打包apk
https://blog.csdn.net/ZZL23333/article/details/115798615?app_version=6.0.0&code=app_1562916241&csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22115798615%22%2C%22source%22%3A%22weixin_38986226%22%7D&uLinkId=usr1mkqgl919blen&utm_source=app

View File

@@ -0,0 +1 @@

72
powerbell/build.gradle Normal file
View File

@@ -0,0 +1,72 @@
apply plugin: 'com.android.application'
apply from: '../.winboll/winboll_app_build.gradle'
apply from: '../.winboll/winboll_lint_build.gradle'
def genVersionName(def versionName){
// 检查编译标志位配置
assert (winbollBuildProps['stageCount'] != null)
assert (winbollBuildProps['baseVersion'] != null)
// 保存基础版本号
winbollBuildProps.setProperty("baseVersion", "${versionName}");
//保存编译标志配置
FileOutputStream fos = new FileOutputStream(winbollBuildPropsFile)
winbollBuildProps.store(fos, "${winbollBuildPropsDesc}");
fos.close();
// 返回编译版本号
return "${versionName}." + winbollBuildProps['stageCount']
}
android {
compileSdkVersion 32
buildToolsVersion "33.0.3"
defaultConfig {
applicationId "cc.winboll.studio.powerbell"
minSdkVersion 24
targetSdkVersion 30
versionCode 6
// versionName 更新后需要手动设置
// .winboll/winbollBuildProps.properties 文件的 stageCount=0
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
versionName "4.0"
if(true) {
versionName = genVersionName("${versionName}")
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
}
dependencies {
api 'cc.winboll.studio:winboll-shared:1.8.0'
api 'io.github.medyo:android-about-page:2.0.0'
api 'com.github.getActivity:ToastUtils:10.5'
api 'com.jcraft:jsch:0.1.55'
api 'org.jsoup:jsoup:1.13.1'
api 'com.squareup.okhttp3:okhttp:4.4.1'
api 'androidx.appcompat:appcompat:1.0.0'
api 'androidx.fragment:fragment:1.0.0'
api 'com.google.android.material:material:1.0.0'
api 'com.baoyz.pullrefreshlayout:library:1.2.0'
api 'com.github.getActivity:ToastUtils:10.5'
api 'io.github.medyo:android-about-page:2.0.0'
api 'org.jsoup:jsoup:1.13.1'
api 'com.squareup.okhttp3:okhttp:4.4.1'
api 'cc.winboll.studio:libaes:7.6.0'
api fileTree(dir: 'libs', include: ['*.jar'])
}

View File

@@ -0,0 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Thu Jan 02 11:13:45 HKT 2025
stageCount=6
libraryProject=
baseVersion=4.0
publishVersion=4.0.5
buildCount=0
baseBetaVersion=4.0.6

17
powerbell/proguard-rules.pro vendored Normal file
View File

@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\tools\adt-bundle-windows-x86_64-20131030\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# 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 *;
#}

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
tools:replace="android:icon"
android:icon="@drawable/ic_launcher_beta">
<!-- Put flavor specific code here -->
<provider
tools:replace="android:authorities"
android:name="androidx.core.content.FileProvider"
android:authorities="cc.winboll.studio.powerbell.beta.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
tools:replace="android:resource"
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_provider"/>
</provider>
</application>
</manifest>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">能源钟☆</string>
</resources>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">PowerBell+</string>
</resources>

View File

@@ -0,0 +1,117 @@
<?xml version='1.0' encoding='utf-8'?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="cc.winboll.studio.powerbell">
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<!-- 运行前台服务 -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<!-- 读取您共享存储空间中的内容 -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<!-- 修改或删除您共享存储空间中的内容 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- 开机启动 -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<!-- MANAGE_EXTERNAL_STORAGE -->
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<application
android:name=".GlobalApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme_Default"
android:persistent="true"
android:resizeableActivity="true"
android:requestLegacyExternalStorage="true">
<activity
android:name=".MainActivity"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name="cc.winboll.studio.powerbell.activities.ClearRecordActivity"
android:parentActivityName="cc.winboll.studio.powerbell.MainActivity"
android:launchMode="singleTask">
</activity>
<activity
android:name="cc.winboll.studio.powerbell.activities.BackgroundPictureActivity"
android:parentActivityName="cc.winboll.studio.powerbell.MainActivity"
android:exported="true"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="image/jpeg"/>
<data android:mimeType="image/jpg"/>
<data android:mimeType="image/png"/>
<data android:mimeType="image/webp"/>
<data android:mimeType="image/*"/>
</intent-filter>
</activity>
<receiver
android:name=".receivers.MainReceiver"
android:enabled="true"
android:exported="false"
android:directBootAware="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
<service
android:name="cc.winboll.studio.powerbell.services.ControlCenterService"
android:priority="1000"
android:enabled="true"
android:exported="false"
android:process=".controlcenterservice"/>
<service
android:name="cc.winboll.studio.powerbell.services.AssistantService"
android:enabled="true"
android:exported="false"
android:process=".assistantservice"/>
<meta-data
android:name="android.max_aspect"
android:value="4.0"/>
<activity android:name="cc.winboll.studio.powerbell.activities.AboutActivity"/>
</application>
</manifest>

View File

@@ -0,0 +1,58 @@
package cc.winboll.studio.powerbell;
import android.content.Context;
import android.view.Gravity;
import cc.winboll.studio.powerbell.receivers.GlobalApplicationReceiver;
import cc.winboll.studio.powerbell.utils.AppCacheUtils;
import cc.winboll.studio.powerbell.utils.AppConfigUtils;
import cc.winboll.studio.shared.app.WinBollApplication;
import com.hjq.toast.ToastUtils;
import com.hjq.toast.style.WhiteToastStyle;
public class GlobalApplication extends WinBollApplication {
public static final String TAG = "GlobalApplication";
// 数据配置存储工具
static AppConfigUtils _mAppConfigUtils;
static AppCacheUtils _mAppCacheUtils;
GlobalApplicationReceiver mReceiver;
@Override
public void onCreate() {
super.onCreate();
// 初始化 Toast 框架
ToastUtils.init(this);
// 设置 Toast 布局样式
//ToastUtils.setView(R.layout.toast_custom_view);
ToastUtils.setStyle(new WhiteToastStyle());
ToastUtils.setGravity(Gravity.BOTTOM, 0, 200);
// 设置数据配置存储工具
_mAppConfigUtils = getAppConfigUtils(this);
_mAppCacheUtils = getAppCacheUtils(this);
mReceiver = new GlobalApplicationReceiver(this);
mReceiver.registerAction();
}
public static AppConfigUtils getAppConfigUtils(Context context) {
if (_mAppConfigUtils == null) {
_mAppConfigUtils = AppConfigUtils.getInstance(context);
}
return _mAppConfigUtils;
}
public static AppCacheUtils getAppCacheUtils(Context context) {
if (_mAppCacheUtils == null) {
_mAppCacheUtils = AppCacheUtils.getInstance(context);
}
return _mAppCacheUtils;
}
public void clearBatteryHistory() {
_mAppCacheUtils.clearBatteryHistory();
}
}

View File

@@ -0,0 +1,190 @@
package cc.winboll.studio.powerbell;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
import cc.winboll.studio.libaes.views.AToolbar;
import cc.winboll.studio.powerbell.MainActivity;
import cc.winboll.studio.powerbell.activities.AboutActivity;
import cc.winboll.studio.powerbell.activities.BackgroundPictureActivity;
import cc.winboll.studio.powerbell.activities.ClearRecordActivity;
import cc.winboll.studio.powerbell.fragments.MainViewFragment;
import cc.winboll.studio.powerbell.utils.NotificationUtils;
import cc.winboll.studio.shared.log.LogUtils;
import cc.winboll.studio.shared.log.LogView;
public class MainActivity extends Activity {
public static final String TAG = "MainActivity";
public static final int BACKGROUND_PICTURE_REQUEST_CODE = 0;
public static MainActivity _mMainActivity;
LogView mLogView;
//ArrayList<Fragment> mlistFragment;
GlobalApplication mApplication;
//AppConfigUtils mAppConfigUtils;
Menu mMenu;
Fragment mCurrentShowFragment;
MainViewFragment mMainViewFragment;
AToolbar mAToolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
//LogUtils.d(TAG, "onCreate(...)");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 设置调试日志
mLogView = findViewById(R.id.logview);
mLogView.start();
//LogUtils.d(TAG, "LogView Start.");
mLogView.updateLogView();
_mMainActivity = MainActivity.this;
mApplication = (GlobalApplication) getApplication();
//mAppConfigUtils = AppConfigUtils.getInstance(mApplication);
// 初始化工具栏
mAToolbar = (AToolbar) findViewById(R.id.toolbar);
setActionBar(mAToolbar);
mAToolbar.setTitleTextAppearance(this, R.style.Toolbar_TitleText);
if (mMainViewFragment == null) {
FragmentTransaction tx = getFragmentManager().beginTransaction();
mMainViewFragment = new MainViewFragment();
tx.add(R.id.activitymainFrameLayout1, mMainViewFragment, MainViewFragment.TAG);
tx.commit();
}
showFragment(mMainViewFragment);
NotificationUtils notificationUtils = new NotificationUtils(this);
notificationUtils.createNotificationChannel();
}
void showFragment(Fragment fragment) {
FragmentTransaction tx = getFragmentManager().beginTransaction();
for (Fragment item : getFragmentManager().getFragments()) {
tx.hide(item);
}
tx.show(fragment);
tx.commit();
mCurrentShowFragment = fragment;
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
reloadBackground();
}
public static void reloadBackground() {
if (_mMainActivity != null) {
_mMainActivity.mMainViewFragment.loadBackground();
}
}
/**
* 通过Uri获取文件在本地存储的真实路径
*/
private String getRealPathFromURI(Uri contentUri) {
String[] proj = {MediaStore.MediaColumns.DATA};
Cursor cursor=getContentResolver().query(contentUri, proj, null, null, null);
if (cursor.moveToNext()) {
int nColumnIndex = cursor.getColumnIndex(MediaStore.MediaColumns.DATA);
if (nColumnIndex > -1) {
return cursor.getString(nColumnIndex);
} else {
LogUtils.d(TAG, "getRealPathFromURI nColumnIndex is -1.");
}
}
cursor.close();
return null;
}
@Override
protected void onResume() {
super.onResume();
// 回到窗口自动取消提醒消息
NotificationUtils.cancelRemindNotification(this);
reloadBackground();
}
// Menu icons are inflated just as they were with actionbar
//
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
mMenu = menu;
getMenuInflater().inflate(R.menu.toolbar_main, mMenu);
return true;
}
// 回退开发者选项重设UI到初始用户状态
//
/*public void resetUI(MainActivity MainActivity) {
mMenu.clear();
getMenuInflater().inflate(R.menu.toolbar_main, mMenu);
}*/
@Override
public boolean onOptionsItemSelected(MenuItem item) {
super.onOptionsItemSelected(item);
int menuItemId = item.getItemId();
if (menuItemId == R.id.action_about) {
Intent intent = new Intent();
intent.setClass(this, AboutActivity.class);
startActivity(intent);
} else if (menuItemId == R.id.action_clearrecord) {
Intent intent = new Intent();
intent.setClass(this, ClearRecordActivity.class);
startActivity(intent);
} else if (menuItemId == R.id.action_changepicture) {
Intent intent = new Intent();
intent.setClass(this, BackgroundPictureActivity.class);
startActivity(intent);
}
return true;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//LogUtils.d(TAG, "onActivityResult(...)");
//LogUtils.d(TAG, "requestCode is : " + Integer.toString(requestCode));
//LogUtils.d(TAG, "resultCode is : " + Integer.toString(resultCode));
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == BACKGROUND_PICTURE_REQUEST_CODE) {
// 处理选择后图片
if (resultCode == RESULT_OK) {
//mMainViewFragment.loadBackgroundPicture();
Toast.makeText(getApplication(), "OK", Toast.LENGTH_SHORT).show();
}
} else {
String sz = "Unsolved requestCode = " + Integer.toString(requestCode);
Toast.makeText(getApplication(), sz, Toast.LENGTH_SHORT).show();
LogUtils.d(TAG, sz);
}
}
/**
* 返回键
*/
@Override
public void onBackPressed() {
if (mCurrentShowFragment != mMainViewFragment) {
showFragment(mMainViewFragment);
} else {
moveTaskToBack(true);
}
}
}

View File

@@ -0,0 +1,42 @@
package cc.winboll.studio.powerbell.activities;
/**
* @Author ZhanGSKen@QQ.COM
* @Date 2024/07/12 13:33:59
* @Describe AboutActivity
*/
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import cc.winboll.studio.libaes.views.AToolbar;
import cc.winboll.studio.powerbell.R;
public class AboutActivity extends Activity {
public static final String TAG = "AboutActivity";
AToolbar mAToolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
// 初始化工具栏
mAToolbar = (AToolbar) findViewById(R.id.toolbar);
setActionBar(mAToolbar);
//mAToolbar.setTitle(getTitle() + "-" + getString(R.string.subtitle_activity_backgroundpicture));
mAToolbar.setSubtitle(R.string.subtitle_activity_about);
mAToolbar.setTitleTextAppearance(this, R.style.Toolbar_TitleText);
mAToolbar.setSubtitleTextAppearance(this, R.style.Toolbar_SubTitleText);
//mAToolbar.setBackgroundColor(getColor(R.color.colorPrimary));
setActionBar(mAToolbar);
getActionBar().setDisplayHomeAsUpEnabled(true);
mAToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
}

View File

@@ -0,0 +1,382 @@
package cc.winboll.studio.powerbell.activities;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;
import cc.winboll.studio.libaes.views.AToolbar;
import cc.winboll.studio.powerbell.R;
import cc.winboll.studio.powerbell.activities.BackgroundPictureActivity;
import cc.winboll.studio.powerbell.beans.BackgroundPictureBean;
import cc.winboll.studio.powerbell.dialogs.BackgroundPicturePreviewDialog;
import cc.winboll.studio.powerbell.utils.BackgroundPictureUtils;
import cc.winboll.studio.powerbell.utils.FileUtils;
import cc.winboll.studio.powerbell.utils.UriUtil;
import cc.winboll.studio.shared.log.LogUtils;
import com.hjq.toast.ToastUtils;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class BackgroundPictureActivity extends Activity
implements BackgroundPicturePreviewDialog.IOnRecivedPictureListener {
public static final String TAG = "BackgroundPictureActivity";
public BackgroundPictureUtils mBackgroundPictureUtils;
// 图片选择请求
public static final int REQUEST_SELECT_PICTURE = 0;
// 照相选择请求
public static final int REQUEST_TAKE_PHOTO = 1;
// 图片裁剪选择请求
public static final int REQUEST_CROP_IMAGE = 2;
AToolbar mAToolbar;
// 所有图片存储的文件夹
File mfBackgroundDir;
// 拍照与剪裁的文件夹
File mfPictureDir;
// 拍照文件类
File mfTakePhoto;
// 接收到的图片文件类
public File mfRecivedPicture;
// 剪裁文件类
File mfTempCropPicture;
// 剪裁接收后的文件的文件名
public static String _mszRecivedCropPicture = "RecivedCrop.jpg";
File mfRecivedCropPicture;
static String _mszCommonFileType = "jpeg";
// 背景图片的压缩比
int mnPictureCompress = 100;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_backgroundpicture);
mBackgroundPictureUtils = BackgroundPictureUtils.getInstance(this);
mfBackgroundDir = new File(mBackgroundPictureUtils.getBackgroundDir());
if (!mfBackgroundDir.exists()) {
mfBackgroundDir.mkdirs();
}
mfPictureDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), getString(R.string.app_projectname));
if (!mfPictureDir.exists()) {
mfPictureDir.mkdirs();
}
mfTakePhoto = new File(mfPictureDir, "TakePhoto.jpg");
mfTempCropPicture = new File(mfPictureDir, "TempCrop.jpg");
mfRecivedPicture = getRecivedPictureFile(this);
mfRecivedCropPicture = new File(mfBackgroundDir, _mszRecivedCropPicture);
// 初始化工具栏
mAToolbar = (AToolbar) findViewById(R.id.toolbar);
setActionBar(mAToolbar);
//mAToolbar.setTitle(getTitle() + "-" + getString(R.string.subtitle_activity_backgroundpicture));
mAToolbar.setSubtitle(R.string.subtitle_activity_backgroundpicture);
mAToolbar.setTitleTextAppearance(this, R.style.Toolbar_TitleText);
mAToolbar.setSubtitleTextAppearance(this, R.style.Toolbar_SubTitleText);
//mAToolbar.setBackgroundColor(getColor(R.color.colorPrimary));
setActionBar(mAToolbar);
getActionBar().setDisplayHomeAsUpEnabled(true);
mAToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
//给按钮设置点击事件
findViewById(R.id.activitybackgroundpictureAButton5).setOnClickListener(onOriginNullClickListener);
findViewById(R.id.activitybackgroundpictureAButton4).setOnClickListener(onReceivedPictureClickListener);
findViewById(R.id.activitybackgroundpictureAButton1).setOnClickListener(onTakePhotoClickListener);
findViewById(R.id.activitybackgroundpictureAButton2).setOnClickListener(onSelectPictureClickListener);
findViewById(R.id.activitybackgroundpictureAButton3).setOnClickListener(onCropPictureClickListener);
findViewById(R.id.activitybackgroundpictureAButton6).setOnClickListener(onCropFreePictureClickListener);
updatePreviewBackground();
// 判断并且处理应用分享到的文件
//
//ToastUtils.show("Activity Opened.");
// 预备接收参数
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
//LogUtils.d(TAG, "action : " + action);
//LogUtils.d(TAG, "type : " + type);
// 判断是否进入图片分享状态
if (Intent.ACTION_SEND.equals(action)
&& type != null
&& ("image/*".equals(type) || "image/jpeg".equals(type) || "image/jpg".equals(type) || "image/png".equals(type) || "image/webp".equals(type))) {
// 预览图片
BackgroundPicturePreviewDialog dlg= new BackgroundPicturePreviewDialog(this);
dlg.show();
}
}
public static String getBackgroundFileName() {
return _mszRecivedCropPicture;
}
@Override
public void onAcceptRecivedPicture(String szPreRecivedPictureName) {
//ToastUtils.show("onAcceptRecivedPicture");
BackgroundPictureUtils utils = BackgroundPictureUtils.getInstance(this);
utils.getBackgroundPictureBean().setIsUseBackgroundFile(true);
utils.saveData();
File fPreRecivedPictureName = new File(utils.getBackgroundDir(), szPreRecivedPictureName);
FileUtils.copyFile(fPreRecivedPictureName, mfRecivedPicture);
// 加载背景
startCropImageActivity(false);
}
//
// 更新预览背景
//
public void updatePreviewBackground() {
LogUtils.d(TAG, "updatePreviewBackground");
ImageView ivPreviewBackground = findViewById(R.id.activitybackgroundpictureImageView1);
BackgroundPictureUtils utils = BackgroundPictureUtils.getInstance(this);
utils.loadBackgroundPictureBean();
boolean isUseBackgroundFile = utils.getBackgroundPictureBean().isUseBackgroundFile();
if (isUseBackgroundFile && mfRecivedCropPicture.exists()) {
try {
String szBackgroundFilePath = utils.getBackgroundDir() + getBackgroundFileName();
Drawable drawableBackground = FileUtils.getImageDrawable(szBackgroundFilePath);
drawableBackground.setAlpha(120);
ivPreviewBackground.setImageDrawable(drawableBackground);
ToastUtils.show("Use acceptRecived background.");
} catch (IOException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
} else {
ToastUtils.show(" No background.");
Drawable drawableBackground = getDrawable(R.drawable.blank10x10);
drawableBackground.setAlpha(120);
ivPreviewBackground.setImageDrawable(drawableBackground);
}
}
private View.OnClickListener onOriginNullClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
// 选择原始空白背景
BackgroundPictureUtils utils = BackgroundPictureUtils.getInstance(BackgroundPictureActivity.this);
BackgroundPictureBean bean = utils.getBackgroundPictureBean();
bean.setIsUseBackgroundFile(false);
utils.saveData();
updatePreviewBackground();
}
};
private View.OnClickListener onSelectPictureClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
// 导入外部图片
Intent intent = new Intent(
Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, REQUEST_SELECT_PICTURE);
}
};
private View.OnClickListener onCropPictureClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
File fCheck = new File(mfBackgroundDir, getBackgroundFileName());
if (fCheck.exists()) {
startCropImageActivity(false);
} else {
ToastUtils.show("There is not any picture to crop.");
}
}
};
private View.OnClickListener onCropFreePictureClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
File fCheck = new File(mfBackgroundDir, getBackgroundFileName());
if (fCheck.exists()) {
startCropImageActivity(true);
} else {
ToastUtils.show("There is not any picture to crop.");
}
}
};
private View.OnClickListener onTakePhotoClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
LogUtils.d(TAG, "onTakePhotoClickListener");
LogUtils.d(TAG, "mfTakePhoto : " + mfTakePhoto.getPath());
if (mfTakePhoto.exists()) {
mfTakePhoto.delete();
}
try {
mfTakePhoto.createNewFile();
} catch (IOException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
}
};
private View.OnClickListener onReceivedPictureClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
// 选择接收到的背景图片
BackgroundPictureUtils utils = BackgroundPictureUtils.getInstance(BackgroundPictureActivity.this);
utils.getBackgroundPictureBean().setIsUseBackgroundFile(true);
utils.saveData();
updatePreviewBackground();
}
};
void compressQualityToRecivedPicture(Bitmap bitmap) {
// 设置输出流
OutputStream outStream = null;
try {
// 创建输出流对象,准备写入压缩后的图片文件
mfRecivedPicture = getRecivedPictureFile(this);
// 创建新的接收文件
if (!mfRecivedPicture.exists()) {
mfRecivedPicture.createNewFile();
}
FileOutputStream fos = new FileOutputStream(mfRecivedPicture);
// 获取输出流对象
outStream = new BufferedOutputStream(fos);
// 使用默认的质量参数压缩图片
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outStream); // 70% 的质量
// 关闭输出流以完成文件操作
outStream.flush();
outStream.close();
} catch (IOException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
}
public void startCropImageActivity(boolean isCropFree) {
LogUtils.d(TAG, "startCropImageActivity");
BackgroundPictureBean bean = mBackgroundPictureUtils.loadBackgroundPictureBean();
mfRecivedPicture = getRecivedPictureFile(this);
Uri uri = UriUtil.getUriForFile(this, mfRecivedPicture);
LogUtils.d(TAG, "uri : " + uri.toString());
if (mfTempCropPicture.exists()) {
mfTempCropPicture.delete();
}
try {
mfTempCropPicture.createNewFile();
} catch (IOException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
// 使用正确的文件路径构建 Uri
Uri cropOutPutUri = Uri.fromFile(mfTempCropPicture);
LogUtils.d(TAG, "mfTempCropPicture : " + mfTempCropPicture.getPath());
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(uri, "image/" + _mszCommonFileType);
// 下面这个crop=true是设置在开启的Intent中设置显示的VIEW可裁剪
intent.putExtra("crop", "true");
intent.putExtra("noFaceDetection", true);
if (!isCropFree) {
// aspectX aspectY 是宽高的比例
intent.putExtra("aspectX", bean.getBackgroundWidth());
intent.putExtra("aspectY", bean.getBackgroundHeight());
}
// outputX outputY 是裁剪图片宽高
//intent.putExtra("outputX", 100);
//intent.putExtra("outputY", 100);
//return-data =false 意味着裁剪成功后不能在onActivityResult 的intent 中获得图片
//intent.putExtra("return-data", false);
intent.putExtra("return-data", true);
//裁剪后的图片输出至 cropOutPutUri
intent.putExtra(MediaStore.EXTRA_OUTPUT, cropOutPutUri);
intent.putExtra("scale", true);
intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
startActivityForResult(intent, REQUEST_CROP_IMAGE);
}
// 启动裁剪窗口,裁剪操作文件为 uirImage
//
void sharePicture() {
Uri uri = UriUtil.getUriForFile(this, mfRecivedPicture);
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareIntent.setType("image/" + _mszCommonFileType);
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntent, "Share Image"));
}
public static File getRecivedPictureFile(Context context) {
String szRecivedPictureFileName = "Recived.data";
BackgroundPictureUtils utils = BackgroundPictureUtils.getInstance(context);
utils.loadBackgroundPictureBean();
return new File(utils.getBackgroundDir(), szRecivedPictureFileName);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_SELECT_PICTURE) {
// 处理选择后图片
if (resultCode == RESULT_OK) {
try {
Uri selectedImage = data.getData();
LogUtils.d(TAG, "Uri is : " + selectedImage.toString());
File fSrcImage = new File(UriUtil.getFilePathFromUri(this, selectedImage));
mfRecivedPicture = getRecivedPictureFile(this);
FileUtils.copyFile(fSrcImage, mfRecivedPicture);
// 启动剪裁文件窗口
startCropImageActivity(false);
} catch (Exception e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
}
} else if (requestCode == REQUEST_TAKE_PHOTO) {
if (resultCode == RESULT_OK) {
LogUtils.d(TAG, "REQUEST_TAKE_PHOTO");
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data");
compressQualityToRecivedPicture(imageBitmap);
startCropImageActivity(false);
}
} else if (requestCode == REQUEST_CROP_IMAGE) {
if (resultCode == RESULT_OK) {
LogUtils.d(TAG, "CROP_IMAGE_REQUEST_CODE");
FileUtils.copyFile(mfTempCropPicture, mfRecivedCropPicture);
mfTempCropPicture.delete();
mBackgroundPictureUtils.getBackgroundPictureBean().setIsUseBackgroundFile(true);
updatePreviewBackground();
}
} else {
String sz = "Unsolved requestCode = " + Integer.toString(requestCode);
Toast.makeText(getApplication(), sz, Toast.LENGTH_SHORT).show();
LogUtils.d(TAG, sz);
}
}
}

View File

@@ -0,0 +1,85 @@
package cc.winboll.studio.powerbell.activities;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import cc.winboll.studio.libaes.views.AOHPCTCSeekBar;
import cc.winboll.studio.libaes.views.AToolbar;
import cc.winboll.studio.powerbell.GlobalApplication;
import cc.winboll.studio.powerbell.R;
import cc.winboll.studio.powerbell.beans.BatteryInfoBean;
import cc.winboll.studio.powerbell.receivers.ControlCenterServiceReceiver;
import cc.winboll.studio.powerbell.utils.AppCacheUtils;
import cc.winboll.studio.powerbell.utils.StringUtils;
import cc.winboll.studio.shared.log.LogUtils;
import com.hjq.toast.ToastUtils;
import java.util.ArrayList;
public class ClearRecordActivity extends Activity {
public static final String TAG = "ClearRecordActivity";
AToolbar mAToolbar;
TextView mtvRecordText;
GlobalApplication mApplication;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_clearrecord);
mApplication = (GlobalApplication) getApplication();
// 初始化工具栏
mAToolbar = (AToolbar) findViewById(R.id.toolbar);
setActionBar(mAToolbar);
//mAToolbar.setTitle(getTitle() + " - " + getString(R.string.subtitle_activity_clearrecord));
mAToolbar.setSubtitle(R.string.subtitle_activity_clearrecord);
mAToolbar.setTitleTextAppearance(this, R.style.Toolbar_TitleText);
mAToolbar.setSubtitleTextAppearance(this, R.style.Toolbar_SubTitleText);
//mAToolbar.setBackgroundColor(getColor(R.color.colorPrimary));
setActionBar(mAToolbar);
getActionBar().setDisplayHomeAsUpEnabled(true);
mAToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
// 设置滑动清理控件
//
// 初始化发送拉动控件
final AOHPCTCSeekBar aOHPCTCSeekBar = findViewById(R.id.activityclearrecordAOHPCTCSeekBar1);
aOHPCTCSeekBar.setThumb(getDrawable(R.drawable.cursor_pointer));
aOHPCTCSeekBar.setThumbOffset(0);
aOHPCTCSeekBar.setOnOHPCListener(
new AOHPCTCSeekBar.OnOHPCListener(){
@Override
public void onOHPCommit() {
mApplication.clearBatteryHistory();
sendBroadcast(new Intent(ControlCenterServiceReceiver.ACTION_UPDATE_SERVICENOTIFICATION));
initRecordText();
String szMSG = "The APP battery record is cleaned.";
LogUtils.d(TAG, szMSG);
ToastUtils.show(szMSG);
}
});
// 初始化提示框
TextView tvAOHPCTCSeekBarMSG = findViewById(R.id.activityclearrecordTextView1);
tvAOHPCTCSeekBarMSG.setText(R.string.msg_AOHPCTCSeekBar_ClearRecord);
mtvRecordText = findViewById(R.id.activityclearrecordTextView2);
initRecordText();
}
void initRecordText() {
ArrayList<BatteryInfoBean> listBatteryInfo = AppCacheUtils.getInstance(this).getArrayListBatteryInfo();
String szRecordText = StringUtils.formatPCMListString(listBatteryInfo);
mtvRecordText.setText(szRecordText);
}
}

View File

@@ -0,0 +1,130 @@
package cc.winboll.studio.powerbell.beans;
/**
* @Author ZhanGSKen@QQ.COM
* @Date 2024/04/29 17:24:53
* @Describe 应用运行参数类
*/
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.shared.app.BaseBean;
import java.io.IOException;
import java.io.Serializable;
public class AppConfigBean extends BaseBean implements Serializable {
transient public static final String TAG = "AppConfigBean";
boolean isEnableUsegeReminder = false;
int usegeReminderValue = 45;
boolean isEnableChargeReminder = false;
int chargeReminderValue = 100;
// 铃声提醒间隔时间。.
int reminderIntervalTime = 5000;
// 电池是否正在充电。
boolean isCharging = false;
// 电池当前电量。.
int currentValue = -1;
public AppConfigBean() {
setChargeReminderValue(100);
setIsEnableChargeReminder(false);
setUsegeReminderValue(10);
setIsEnableUsegeReminder(false);
setReminderIntervalTime(5000);
}
public void setReminderIntervalTime(int reminderIntervalTime) {
this.reminderIntervalTime = reminderIntervalTime;
}
public int getReminderIntervalTime() {
return reminderIntervalTime;
}
public void setIsCharging(boolean isCharging) {
this.isCharging = isCharging;
}
public boolean isCharging() {
return isCharging;
}
public void setCurrentValue(int currentValue) {
this.currentValue = currentValue;
}
public int getCurrentValue() {
return currentValue;
}
public void setIsEnableUsegeReminder(boolean isEnableUsegeReminder) {
this.isEnableUsegeReminder = isEnableUsegeReminder;
}
public boolean isEnableUsegeReminder() {
return isEnableUsegeReminder;
}
public void setUsegeReminderValue(int usegeReminderValue) {
this.usegeReminderValue = usegeReminderValue;
}
public int getUsegeReminderValue() {
return usegeReminderValue;
}
public void setIsEnableChargeReminder(boolean isEnableChargeReminder) {
this.isEnableChargeReminder = isEnableChargeReminder;
}
public boolean isEnableChargeReminder() {
return isEnableChargeReminder;
}
public void setChargeReminderValue(int chargeReminderValue) {
this.chargeReminderValue = chargeReminderValue;
}
public int getChargeReminderValue() {
return chargeReminderValue;
}
@Override
public String getName() {
return AppConfigBean.class.getName();
}
@Override
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
super.writeThisToJsonWriter(jsonWriter);
AppConfigBean bean = this;
jsonWriter.name("isEnableUsegeReminder").value(bean.isEnableUsegeReminder());
jsonWriter.name("usegeReminderValue").value(bean.getUsegeReminderValue());
jsonWriter.name("isEnableChargeReminder").value(bean.isEnableChargeReminder());
jsonWriter.name("chargeReminderValue").value(bean.getChargeReminderValue());
}
@Override
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
AppConfigBean bean = new AppConfigBean();
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String name = jsonReader.nextName();
if (name.equals("isEnableUsegeReminder")) {
bean.setIsEnableUsegeReminder(jsonReader.nextBoolean());
} else if (name.equals("usegeReminderValue")) {
bean.setUsegeReminderValue(jsonReader.nextInt());
} else if (name.equals("isEnableChargeReminder")) {
bean.setIsEnableChargeReminder(jsonReader.nextBoolean());
} else if (name.equals("chargeReminderValue")) {
bean.setChargeReminderValue(jsonReader.nextInt());
} else {
jsonReader.skipValue();
}
}
// 结束 JSON 对象
jsonReader.endObject();
return bean;
}
}

View File

@@ -0,0 +1,86 @@
package cc.winboll.studio.powerbell.beans;
/**
* @Author ZhanGSKen@QQ.COM
* @Date 2024/07/18 11:52:28
* @Describe 应用背景图片数据类
*/
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.shared.app.BaseBean;
import java.io.IOException;
public class BackgroundPictureBean extends BaseBean {
public static final String TAG = "BackgroundPictureBean";
int backgroundWidth = 100;
int backgroundHeight = 100;
boolean isUseBackgroundFile = false;
public BackgroundPictureBean() {
}
public BackgroundPictureBean(String recivedFileName, boolean isUseBackgroundFile) {
this.isUseBackgroundFile = isUseBackgroundFile;
}
public void setBackgroundWidth(int backgroundWidth) {
this.backgroundWidth = backgroundWidth;
}
public int getBackgroundWidth() {
return backgroundWidth;
}
public void setBackgroundHeight(int backgroundHeight) {
this.backgroundHeight = backgroundHeight;
}
public int getBackgroundHeight() {
return backgroundHeight;
}
public void setIsUseBackgroundFile(boolean isUseBackgroundFile) {
this.isUseBackgroundFile = isUseBackgroundFile;
}
public boolean isUseBackgroundFile() {
return isUseBackgroundFile;
}
@Override
public String getName() {
return BackgroundPictureBean.class.getName();
}
@Override
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
super.writeThisToJsonWriter(jsonWriter);
BackgroundPictureBean bean = this;
jsonWriter.name("backgroundWidth").value(bean.getBackgroundWidth());
jsonWriter.name("backgroundHeight").value(bean.getBackgroundHeight());
jsonWriter.name("isUseBackgroundFile").value(bean.isUseBackgroundFile());
}
@Override
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
BackgroundPictureBean bean = new BackgroundPictureBean();
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String name = jsonReader.nextName();
if (name.equals("backgroundWidth")) {
bean.setBackgroundWidth(jsonReader.nextInt());
} else if (name.equals("backgroundHeight")) {
bean.setBackgroundHeight(jsonReader.nextInt());
} else if (name.equals("isUseBackgroundFile")) {
bean.setIsUseBackgroundFile(jsonReader.nextBoolean());
} else {
jsonReader.skipValue();
}
}
// 结束 JSON 对象
jsonReader.endObject();
return bean;
}
}

View File

@@ -0,0 +1,75 @@
package cc.winboll.studio.powerbell.beans;
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.shared.app.BaseBean;
import java.io.IOException;
import java.io.Serializable;
public class BatteryInfoBean extends BaseBean implements Serializable {
public static final String TAG = "BatteryInfoBean";
// 记录电量的时间戳
long timeStamp;
// 电量值
int battetyValue;
public BatteryInfoBean() {
this.timeStamp = 0;
this.battetyValue = 0;
}
public BatteryInfoBean(long timeStamp, int battetyValue) {
this.timeStamp = timeStamp;
this.battetyValue = battetyValue;
}
public void setTimeStamp(long timeStamp) {
this.timeStamp = timeStamp;
}
public long getTimeStamp() {
return timeStamp;
}
public void setBattetyValue(int battetyValue) {
this.battetyValue = battetyValue;
}
public int getBattetyValue() {
return battetyValue;
}
@Override
public String getName() {
return BatteryInfoBean.class.getName();
}
@Override
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
super.writeThisToJsonWriter(jsonWriter);
BatteryInfoBean bean = this;
jsonWriter.name("timeStamp").value(bean.getTimeStamp());
jsonWriter.name("battetyValue").value(bean.getBattetyValue());
}
@Override
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
BatteryInfoBean bean = new BatteryInfoBean();
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String name = jsonReader.nextName();
if (name.equals("timeStamp")) {
bean.setTimeStamp(jsonReader.nextLong());
} else if (name.equals("battetyValue")) {
bean.setBattetyValue(jsonReader.nextInt());
} else {
jsonReader.skipValue();
}
}
// 结束 JSON 对象
jsonReader.endObject();
return bean;
}
}

View File

@@ -0,0 +1,63 @@
package cc.winboll.studio.powerbell.beans;
/**
* @Author ZhanGSKen@QQ.COM
* @Date 2024/07/18 07:06:07
* @Describe 服务控制参数
*/
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.shared.app.BaseBean;
import java.io.IOException;
public class ControlCenterServiceBean extends BaseBean {
public static final String TAG = "ControlCenterServiceBean";
boolean isEnableService = false;
public ControlCenterServiceBean() {
this.isEnableService = false;
}
public ControlCenterServiceBean(boolean isEnableService) {
this.isEnableService = isEnableService;
}
public void setIsEnableService(boolean isEnableService) {
this.isEnableService = isEnableService;
}
public boolean isEnableService() {
return isEnableService;
}
@Override
public String getName() {
return ControlCenterServiceBean.class.getName();
}
@Override
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
super.writeThisToJsonWriter(jsonWriter);
ControlCenterServiceBean bean = this;
jsonWriter.name("isEnableService").value(bean.isEnableService());
}
@Override
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
ControlCenterServiceBean bean = new ControlCenterServiceBean();
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String name = jsonReader.nextName();
if (name.equals("isEnableService")) {
bean.setIsEnableService(jsonReader.nextBoolean());
} else {
jsonReader.skipValue();
}
}
// 结束 JSON 对象
jsonReader.endObject();
return bean;
}
}

View File

@@ -0,0 +1,40 @@
package cc.winboll.studio.powerbell.beans;
// 应用消息结构
//
public class NotificationMessage {
String Title;
String Content;
String RemindMSG;
public NotificationMessage(String title, String content) {
Title = title;
Content = content;
}
public void setRemindMSG(String remindMSG) {
RemindMSG = remindMSG;
}
public String getRemindMSG() {
return RemindMSG;
}
public void setTitle(String title) {
Title = title;
}
public String getTitle() {
return Title;
}
public void setContent(String content) {
Content = content;
}
public String getContent() {
return Content;
}
}

View File

@@ -0,0 +1,134 @@
package cc.winboll.studio.powerbell.dialogs;
import cc.winboll.studio.powerbell.R;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
import cc.winboll.studio.powerbell.MainActivity;
import cc.winboll.studio.powerbell.activities.BackgroundPictureActivity;
import cc.winboll.studio.powerbell.utils.BackgroundPictureUtils;
import cc.winboll.studio.powerbell.utils.FileUtils;
import cc.winboll.studio.powerbell.utils.UriUtil;
import cc.winboll.studio.shared.log.LogUtils;
import java.io.File;
import java.io.IOException;
/**
* @Author ZhanGSKen@QQ.COM
* @Date 2024/04/25 16:27:53
* @Describe 背景图片的接收分享文件后的预览对话框
*/
public class BackgroundPicturePreviewDialog extends Dialog {
public static final String TAG = "BackgroundPicturePreviewDialog";
Context mContext;
BackgroundPictureUtils mBackgroundPictureUtils;
Button dialogbackgroundpicturepreviewButton1;
Button dialogbackgroundpicturepreviewButton2;
String mszPreReceivedFileName;
public BackgroundPicturePreviewDialog(Context context) {
super(context);
setContentView(R.layout.dialog_backgroundpicturepreview);
mContext = context;
mBackgroundPictureUtils = ((BackgroundPictureActivity)context).mBackgroundPictureUtils;
ImageView imageView = findViewById(R.id.dialogbackgroundpicturepreviewImageView1);
copyAndViewRecivePicture(imageView);
dialogbackgroundpicturepreviewButton1 = findViewById(R.id.dialogbackgroundpicturepreviewButton1);
dialogbackgroundpicturepreviewButton1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// 不使用分享到的图片
// 跳转到主窗口
Intent i = new Intent(mContext, MainActivity.class);
mContext.startActivity(i);
}
});
dialogbackgroundpicturepreviewButton2 = findViewById(R.id.dialogbackgroundpicturepreviewButton2);
dialogbackgroundpicturepreviewButton2.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
// 使用分享到的图片
//
//LogUtils.d(TAG, "mszReceivedFileName : " + mszReceivedFileName);
((IOnRecivedPictureListener)mContext).onAcceptRecivedPicture(mszPreReceivedFileName);
// 关闭对话框
dismiss();
}
});
}
void copyAndViewRecivePicture(ImageView imageView) {
//AppConfigUtils appConfigUtils = AppConfigUtils.getInstance((GlobalApplication)mContext.getApplicationContext());
BackgroundPictureActivity activity = ((BackgroundPictureActivity)mContext);
//取出文件uri
Uri uri = activity.getIntent().getData();
if (uri == null) {
uri = activity.getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
}
//获取文件真实地址
String szSrcImage = UriUtil.getFilePathFromUri(mContext, uri);
if (TextUtils.isEmpty(szSrcImage)) {
Toast.makeText(mContext, "接收到的文件为空。", Toast.LENGTH_SHORT).show();
dismiss();
return;
}
File fSrcImage = new File(szSrcImage);
mszPreReceivedFileName = "PreReceived.data";
//mszPreReceivedFileName = DateUtils.getDateNowString() + "-" + fSrcImage.getName();
File mfPreReceivedPhoto = new File(activity.mBackgroundPictureUtils.getBackgroundDir(), mszPreReceivedFileName);
// 复制源图片到剪裁文件
try {
FileUtils.copyFileUsingFileChannels(fSrcImage, mfPreReceivedPhoto);
LogUtils.d(TAG, "copyFileUsingFileChannels");
Drawable drawable = Drawable.createFromPath(mfPreReceivedPhoto.getPath());
imageView.setBackground(drawable);
LogUtils.d(TAG, "mszPreReceivedFileName : " + mszPreReceivedFileName);
} catch (IOException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
}
//
// 创建图片背景图片目录
//
boolean createBackgroundFolder2(String szBackgroundFolder) {
// 文件路径参数为空值或无效值时返回false.
if (szBackgroundFolder == null | szBackgroundFolder.equals("")) {
return false;
}
LogUtils.d(TAG, "Background Folder Is : " + szBackgroundFolder);
File f = new File(szBackgroundFolder);
if (f.exists()) {
if (f.isDirectory()) {
return true;
} else {
// 工作路径不是一个目录
LogUtils.d(TAG, "createImageWorkFolder() error : szImageCacheFolder isDirectory return false. -->" + szBackgroundFolder);
return false;
}
} else {
return f.mkdirs();
}
}
public interface IOnRecivedPictureListener {
void onAcceptRecivedPicture(String szBackgroundFileName);
}
}

View File

@@ -0,0 +1,59 @@
package cc.winboll.studio.powerbell.dialogs;
/**
* @Author ZhanGSKen@QQ.COM
* @Date 2024/06/10 19:32:55
* @Describe 用户确定与否选择框
*/
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
public class YesNoAlertDialog {
public static final String TAG = "YesNoAlertDialog";
public static void show(Context context, String szTitle, String szMessage, final OnDialogResultListener listener) {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
context);
// set title
alertDialogBuilder.setTitle(szTitle);
// set dialog message
alertDialogBuilder
.setMessage(szMessage)
.setCancelable(true)
.setOnCancelListener(new DialogInterface.OnCancelListener(){
@Override
public void onCancel(DialogInterface dialog) {
listener.onNo();
}
})
.setPositiveButton("YES", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// if this button is clicked, close
// current activity
listener.onYes();
}
})
.setNegativeButton("NO", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// if this button is clicked, just close
// the dialog box and do nothing
dialog.cancel();
}
});
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
// show it
alertDialog.show();
}
public interface OnDialogResultListener {
abstract void onYes();
abstract void onNo();
}
}

View File

@@ -0,0 +1,359 @@
package cc.winboll.studio.powerbell.fragments;
import android.app.Fragment;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.Switch;
import android.widget.TextView;
import cc.winboll.studio.powerbell.GlobalApplication;
import cc.winboll.studio.powerbell.R;
import cc.winboll.studio.powerbell.activities.BackgroundPictureActivity;
import cc.winboll.studio.powerbell.beans.BackgroundPictureBean;
import cc.winboll.studio.powerbell.services.ControlCenterService;
import cc.winboll.studio.powerbell.utils.AppConfigUtils;
import cc.winboll.studio.powerbell.utils.BackgroundPictureUtils;
import cc.winboll.studio.powerbell.utils.ServiceUtils;
import cc.winboll.studio.powerbell.views.BatteryDrawable;
import cc.winboll.studio.powerbell.views.VerticalSeekBar;
import cc.winboll.studio.shared.log.LogUtils;
import java.io.File;
public class MainViewFragment extends Fragment {
public static final String TAG = MainViewFragment.class.getSimpleName();
public static final int MSG_RELOAD_APPCONFIG = 0;
public static final int MSG_CURRENTVALUEBATTERY = 1;
static MainViewFragment _mMainViewFragment;
AppConfigUtils mAppConfigUtils;
View mView;
Drawable mDrawableFrame;
LinearLayout mllLeftSeekBar;
LinearLayout mllRightSeekBar;
CheckBox mcbIsEnableChargeReminder;
CheckBox mcbIsEnableUsegeReminder;
Switch mswIsEnableService;
TextView mtvTips;
// 背景布局
//LinearLayout mLinearLayoutloadBackground;
// 现在电量图示
BatteryDrawable mCurrentValueBatteryDrawable;
// 现在充电提醒电量图示
BatteryDrawable mChargeReminderValueBatteryDrawable;
// 现在耗电提醒电量图示
BatteryDrawable mUsegeReminderValueBatteryDrawable;
ImageView mCurrentValueBatteryImageView;
ImageView mChargeReminderValueBatteryImageView;
ImageView mUsegeReminderValueBatteryImageView;
VerticalSeekBar mChargeReminderSeekBar;
ChargeReminderSeekBarChangeListener mChargeReminderSeekBarChangeListener;
TextView mtvChargeReminderValue;
VerticalSeekBar mUsegeReminderSeekBar;
UsegeReminderSeekBarChangeListener mUsegeReminderSeekBarChangeListener;
TextView mtvUsegeReminderValue;
CheckBox mcbUsegeReminderValue;
TextView mtvCurrentValue;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mView = inflater.inflate(R.layout.fragment_mainview, container, false);
_mMainViewFragment = MainViewFragment.this;
mAppConfigUtils = GlobalApplication.getAppConfigUtils(getActivity());
// 获取指定ID的View实例
final View mainImageView = mView.findViewById(R.id.fragmentmainviewImageView1);
// 注册OnGlobalLayoutListener
mainImageView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
// 获取宽度和高度
int width = mainImageView.getMeasuredWidth();
int height = mainImageView.getMeasuredHeight();
BackgroundPictureUtils utils = BackgroundPictureUtils.getInstance(getActivity());
BackgroundPictureBean bean = utils.loadBackgroundPictureBean();
bean.setBackgroundWidth(width);
bean.setBackgroundHeight(height);
utils.saveData();
// 移除监听器以避免内存泄漏
mainImageView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
});
mDrawableFrame = getActivity().getDrawable(R.drawable.bg_frame);
mllLeftSeekBar = (LinearLayout) mView.findViewById(R.id.fragmentmainviewLinearLayout1);
mllRightSeekBar = (LinearLayout) mView.findViewById(R.id.fragmentmainviewLinearLayout2);
// 初始化充电电量提醒设置控件
mtvChargeReminderValue = (TextView) mView.findViewById(R.id.fragmentandroidviewTextView2);
mChargeReminderSeekBar = (VerticalSeekBar) mView.findViewById(R.id.fragmentandroidviewVerticalSeekBar1);
mcbIsEnableChargeReminder = mView.findViewById(R.id.fragmentmainviewCheckBox1);
// 初始化耗电电量提醒设置控件
mtvUsegeReminderValue = (TextView) mView.findViewById(R.id.fragmentandroidviewTextView3);
mUsegeReminderSeekBar = (VerticalSeekBar) mView.findViewById(R.id.fragmentandroidviewVerticalSeekBar2);
mcbIsEnableUsegeReminder = mView.findViewById(R.id.fragmentmainviewCheckBox2);
// 初始化现在电量显示控件
mtvCurrentValue = (TextView) mView.findViewById(R.id.fragmentandroidviewTextView4);
// 初始化服务总开关
mswIsEnableService = (Switch) mView.findViewById(R.id.fragmentandroidviewSwitch1);
mtvTips = mView.findViewById(R.id.fragmentandroidviewTextView1);
// 设置视图显示数据
setViewData();
// 设置视图控件响应
setViewListener();
// 注册一个广播接收
//mMainActivityReceiver = new MainActivityReceiver(this);
//mMainActivityReceiver.registerAction();
// 启动的时候检查一下服务
if (mAppConfigUtils.getIsEnableService()
&& ServiceUtils.isServiceAlive(getActivity(), ControlCenterService.class.getName()) == false) {
// 如果配置了服务启动,服务没有启动
// 就启动服务
Intent intent = new Intent(getActivity(), ControlCenterService.class);
getActivity().startForegroundService(intent);
}
return mView;
}
void setViewData() {
int nChargeReminderValue = mAppConfigUtils.getChargeReminderValue();
int nUsegeReminderValue = mAppConfigUtils.getUsegeReminderValue();
int nCurrentValue = mAppConfigUtils.getCurrentValue();
mllLeftSeekBar.setBackground(mDrawableFrame);
mllRightSeekBar.setBackground(mDrawableFrame);
// 初始化电量图
mCurrentValueBatteryDrawable = new BatteryDrawable(getActivity().getColor(R.color.colorCurrent));
mCurrentValueBatteryDrawable.setValue(mAppConfigUtils.getCurrentValue());
mCurrentValueBatteryImageView = mView.findViewById(R.id.fragmentandroidviewImageView1);
mCurrentValueBatteryImageView.setImageDrawable(mCurrentValueBatteryDrawable);
// 初始化充电电量提醒图
mChargeReminderValueBatteryDrawable = new BatteryDrawable(getActivity().getColor(R.color.colorCharge));
mChargeReminderValueBatteryDrawable.setValue(nChargeReminderValue);
mChargeReminderValueBatteryImageView = mView.findViewById(R.id.fragmentandroidviewImageView3);
mChargeReminderValueBatteryImageView.setImageDrawable(mChargeReminderValueBatteryDrawable);
// 初始化耗电电量提醒图
mUsegeReminderValueBatteryDrawable = new BatteryDrawable(getActivity().getColor(R.color.colorUsege));
mUsegeReminderValueBatteryDrawable.setValue(nUsegeReminderValue);
mUsegeReminderValueBatteryImageView = mView.findViewById(R.id.fragmentandroidviewImageView2);
mUsegeReminderValueBatteryImageView.setImageDrawable(mUsegeReminderValueBatteryDrawable);
// 初始化充电电量提醒设置控件
mtvChargeReminderValue.setTextColor(getActivity().getColor(R.color.colorCharge));
//LogUtils.d(TAG, "Color.YELLOW is " + Integer.toString(mApplication.getColor(R.color.colorCharge)));
mtvChargeReminderValue.setText(Integer.toString(nChargeReminderValue) + "%");
mChargeReminderSeekBar.setProgress(nChargeReminderValue);
mcbIsEnableChargeReminder.setChecked(mAppConfigUtils.getIsEnableChargeReminder());
// 初始化耗电电量提醒设置控件
mtvUsegeReminderValue.setTextColor(getActivity().getColor(R.color.colorUsege));
mtvUsegeReminderValue.setText(Integer.toString(nUsegeReminderValue) + "%");
mUsegeReminderSeekBar.setProgress(nUsegeReminderValue);
mcbIsEnableUsegeReminder.setChecked(mAppConfigUtils.getIsEnableUsegeReminder());
// 初始化现在电量显示控件
mtvCurrentValue.setTextColor(getActivity().getColor(R.color.colorCurrent));
mtvCurrentValue.setText(Integer.toString(nCurrentValue) + "%");
// 初始化服务总开关
mswIsEnableService.setChecked(mAppConfigUtils.getIsEnableService());
if (mAppConfigUtils.getIsEnableService()) {
//LogUtils.d(TAG, "mApplication.getIsEnableService() " + Boolean.toString(mAppConfigUtils.getIsEnableService()));
ControlCenterService.startControlCenterService(getActivity());
} else {
//LogUtils.d(TAG, "mApplication.getIsEnableService() " + Boolean.toString(mAppConfigUtils.getIsEnableService()));
ControlCenterService.stopControlCenterService(getActivity());
}
mswIsEnableService.setText(getString(R.string.txt_aboveswitch));
mtvTips.setText(getString(R.string.txt_aboveswitchtips));
}
void setViewListener() {
// 初始化充电电量提醒设置控件
mChargeReminderSeekBarChangeListener = new ChargeReminderSeekBarChangeListener();
mChargeReminderSeekBar.setOnSeekBarChangeListener(mChargeReminderSeekBarChangeListener);
mcbIsEnableChargeReminder.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LogUtils.d(TAG, "setIsEnableChargeReminder");
mAppConfigUtils.setIsEnableChargeReminder(mcbIsEnableChargeReminder.isChecked());
//ControlCenterService.updateIsEnableChargeReminder(mcbIsEnableChargeReminder.isChecked());
}
});
// 初始化耗电电量提醒设置控件
mUsegeReminderSeekBarChangeListener = new UsegeReminderSeekBarChangeListener();
mUsegeReminderSeekBar.setOnSeekBarChangeListener(mUsegeReminderSeekBarChangeListener);
mcbIsEnableUsegeReminder.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LogUtils.d(TAG, "setIsEnableUsegeReminder");
mAppConfigUtils.setIsEnableUsegeReminder(mcbIsEnableUsegeReminder.isChecked());
//ControlCenterService.updateIsEnableUsegeReminder(mcbIsEnableUsegeReminder.isChecked());
}
});
// 初始化服务总开关
mswIsEnableService.setOnClickListener(new CompoundButton.OnClickListener() {
@Override
public void onClick(View view) {
mAppConfigUtils.setIsEnableService(getActivity(), mswIsEnableService.isChecked());
}
});
}
void setCurrentValueBattery(int value) {
//LogUtils.d(TAG, "setCurrentValueBattery");
mtvCurrentValue.setText(Integer.toString(value) + "%");
mCurrentValueBatteryDrawable.setValue(value);
mCurrentValueBatteryDrawable.invalidateSelf();
}
class ChargeReminderSeekBarChangeListener implements SeekBar.OnSeekBarChangeListener {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
//LogUtils.d(TAG, "call onProgressChanged");
int nChargeReminderValue = progress;
mtvChargeReminderValue.setText(Integer.toString(nChargeReminderValue) + "%");
mChargeReminderValueBatteryDrawable.setValue(nChargeReminderValue);
mChargeReminderValueBatteryDrawable.invalidateSelf();
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
//LogUtils.d(TAG, "call onStartTrackingTouch");
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
//LogUtils.d(TAG, "call onStopTrackingTouch");
//取得当前进度条的刻度
int nChargeReminderValue = ((VerticalSeekBar)seekBar)._mnProgress;
mAppConfigUtils.setChargeReminderValue(nChargeReminderValue);
mtvChargeReminderValue.setText(Integer.toString(nChargeReminderValue) + "%");
//ControlCenterService.updateChargeReminderValue(nChargeReminderValue);
}
}
class UsegeReminderSeekBarChangeListener implements SeekBar.OnSeekBarChangeListener {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
//LogUtils.d(TAG, "call onProgressChanged");
int nUsegeReminderValue = progress;
mtvUsegeReminderValue.setText(Integer.toString(nUsegeReminderValue) + "%");
mUsegeReminderValueBatteryDrawable.setValue(nUsegeReminderValue);
mUsegeReminderValueBatteryDrawable.invalidateSelf();
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
//LogUtils.d(TAG, "call onStartTrackingTouch");
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
//LogUtils.d(TAG, "call onStopTrackingTouch");
//取得当前进度条的刻度
int nUsegeReminderValue = ((VerticalSeekBar)seekBar)._mnProgress;
LogUtils.d(TAG, "nUsegeReminderValue is " + Integer.toString(nUsegeReminderValue));
//LogUtils.d(TAG, "mPowerReminder is " + mApplication);
mAppConfigUtils.setUsegeReminderValue(nUsegeReminderValue);
//LogUtils.d(TAG, "opopopopopopopop");
mtvUsegeReminderValue.setText(Integer.toString(nUsegeReminderValue) + "%");
//ControlCenterService.updateUsegeReminderValue(nUsegeReminderValue);
}
}
public void loadBackground() {
BackgroundPictureBean bean = BackgroundPictureUtils.getInstance(getActivity()).getBackgroundPictureBean();
ImageView imageView = mView.findViewById(R.id.fragmentmainviewImageView1);
String szBackgroundFilePath = BackgroundPictureUtils.getInstance(getActivity()).getBackgroundDir() + BackgroundPictureActivity.getBackgroundFileName();
File fBackgroundFilePath = new File(szBackgroundFilePath);
LogUtils.d(TAG, "szBackgroundFilePath : " + szBackgroundFilePath);
if (bean.isUseBackgroundFile() && fBackgroundFilePath.exists()) {
Drawable drawableBackground = Drawable.createFromPath(szBackgroundFilePath);
drawableBackground.setAlpha(120);
imageView.setImageDrawable(drawableBackground);
} else {
Drawable drawableBackground = getActivity().getDrawable(R.drawable.blank10x10);
drawableBackground.setAlpha(120);
imageView.setImageDrawable(drawableBackground);
}
}
Handler mHandler = new Handler(){
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_RELOAD_APPCONFIG : {
setViewData();
break;
}
case MSG_CURRENTVALUEBATTERY : {
setCurrentValueBattery(msg.arg1);
break;
}
}
super.handleMessage(msg);
}
};
public static void relaodAppConfigs() {
if (_mMainViewFragment != null) {
Handler handler = _mMainViewFragment.mHandler;
handler.sendMessage(handler.obtainMessage(MSG_RELOAD_APPCONFIG));
}
}
public static void sendMsgCurrentValueBattery(int value) {
if (_mMainViewFragment != null) {
Handler handler = _mMainViewFragment.mHandler;
Message msg = handler.obtainMessage(MSG_CURRENTVALUEBATTERY);
msg.arg1 = value;
handler.sendMessage(msg);
}
}
}

View File

@@ -0,0 +1,36 @@
package cc.winboll.studio.powerbell.handlers;
import android.os.Handler;
import android.os.Message;
import cc.winboll.studio.powerbell.services.ControlCenterService;
import java.lang.ref.WeakReference;
public class ControlCenterServiceHandler extends Handler {
public static final String TAG = ControlCenterServiceHandler.class.getSimpleName();
public static final int MSG_REMIND_TEXT = 0;
WeakReference<ControlCenterService> serviceWeakReference;
public ControlCenterServiceHandler(ControlCenterService service) {
serviceWeakReference = new WeakReference<ControlCenterService>(service);
}
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_REMIND_TEXT: // 处理下载完成消息更新UI
{
// 显示提醒消息
//
//LogUtils.d(TAG, "显示提醒消息");
ControlCenterService controlCenterService = serviceWeakReference.get();
if (controlCenterService != null) {
//LogUtils.d(TAG, ((NotificationMessage)msg.obj).getTitle());
//LogUtils.d(TAG, ((NotificationMessage)msg.obj).getContent());
controlCenterService.appenRemindMSG((String)msg.obj);
}
break;
}
}
}
}

View File

@@ -0,0 +1,80 @@
package cc.winboll.studio.powerbell.receivers;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import cc.winboll.studio.powerbell.beans.AppConfigBean;
import cc.winboll.studio.powerbell.services.ControlCenterService;
import cc.winboll.studio.powerbell.utils.AppConfigUtils;
import cc.winboll.studio.powerbell.utils.BatteryUtils;
import cc.winboll.studio.shared.log.LogUtils;
import java.lang.ref.WeakReference;
public class ControlCenterServiceReceiver extends BroadcastReceiver {
public static final String TAG = ControlCenterServiceReceiver.class.getSimpleName();
public static final String ACTION_UPDATE_SERVICENOTIFICATION = ControlCenterServiceReceiver.class.getName() + ".ACTION_UPDATE_NOTIFICATION";
public static final String ACTION_START_REMINDTHREAD = ControlCenterServiceReceiver.class.getName() + ".ACTION_UPDATE_REMINDTHREAD";
WeakReference<ControlCenterService> mwrService;
// 存储电量指示值,
// 用于校验电量消息时的电量变化
static volatile int _mnTheQuantityOfElectricityOld = -1;
static volatile boolean _mIsCharging = false;
public ControlCenterServiceReceiver(ControlCenterService service) {
mwrService = new WeakReference<ControlCenterService>(service);
}
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(ACTION_UPDATE_SERVICENOTIFICATION)) {
mwrService.get().updateServiceNotification();
} else if (intent.getAction().equals(Intent.ACTION_BATTERY_CHANGED)) {
boolean isCharging = BatteryUtils.isCharging(intent);
int nTheQuantityOfElectricity = BatteryUtils.getTheQuantityOfElectricity(intent);
if (mwrService.get().getRemindThread() != null) {
// 先设置提醒进程电池状态标志
if (_mIsCharging != isCharging) {
mwrService.get().getRemindThread().setIsCharging(isCharging);
}
if (_mnTheQuantityOfElectricityOld != nTheQuantityOfElectricity) {
mwrService.get().getRemindThread().setQuantityOfElectricity(nTheQuantityOfElectricity);
}
}
// 新电池状态标志某一个有变化就更新显示信息
if (_mIsCharging != isCharging || _mnTheQuantityOfElectricityOld != nTheQuantityOfElectricity) {
mwrService.get().updateServiceNotification();
AppConfigUtils appConfigUtils = AppConfigUtils.getInstance(context);
appConfigUtils.loadAppConfigBean();
AppConfigBean appConfigBean = appConfigUtils.mAppConfigBean;
appConfigBean.setCurrentValue(nTheQuantityOfElectricity);
appConfigBean.setIsCharging(isCharging);
mwrService.get().startRemindThread(appConfigBean);
// 保存好新的电池状态标志
_mIsCharging = isCharging;
_mnTheQuantityOfElectricityOld = nTheQuantityOfElectricity;
}
} else if (intent.getAction().equals(ACTION_START_REMINDTHREAD)) {
LogUtils.d(TAG, "ACTION_START_REMINDTHREAD");
//AppConfigUtils appConfigUtils = AppConfigUtils.getInstance(context);
//appConfigUtils.loadAppConfigBean();
AppConfigBean appConfigBean = (AppConfigBean)intent.getSerializableExtra("appConfigBean");
mwrService.get().startRemindThread(appConfigBean);
}
}
// 注册 Receiver
//
public void registerAction(Context context) {
IntentFilter filter=new IntentFilter();
filter.addAction(ACTION_UPDATE_SERVICENOTIFICATION);
filter.addAction(ACTION_START_REMINDTHREAD);
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
context.registerReceiver(this, filter);
}
}

View File

@@ -0,0 +1,66 @@
package cc.winboll.studio.powerbell.receivers;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import cc.winboll.studio.powerbell.GlobalApplication;
import cc.winboll.studio.powerbell.fragments.MainViewFragment;
import cc.winboll.studio.powerbell.utils.AppConfigUtils;
import cc.winboll.studio.powerbell.utils.BatteryUtils;
import cc.winboll.studio.powerbell.utils.NotificationUtils;
public class GlobalApplicationReceiver extends BroadcastReceiver {
public static final String TAG = "GlobalApplicationReceiver";
AppConfigUtils mAppConfigUtils;
GlobalApplication mGlobalApplication;
// 存储电量指示值,
// 用于校验电量消息时的电量变化
static volatile int _mnTheQuantityOfElectricityOld = -1;
static volatile boolean _mIsCharging = false;
// 保存当前实例,
// 便利封装 registerAction() 函数
GlobalApplicationReceiver mReceiver;
public GlobalApplicationReceiver(GlobalApplication globalApplication) {
mReceiver = this;
mGlobalApplication = globalApplication;
mAppConfigUtils = GlobalApplication.getAppConfigUtils(mGlobalApplication);
}
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_BATTERY_CHANGED)) {
// 先设置好新电池状态标志
boolean isCharging = BatteryUtils.isCharging(intent);
if (_mIsCharging != isCharging) {
mAppConfigUtils.setIsCharging(isCharging);
}
int nTheQuantityOfElectricity = BatteryUtils.getTheQuantityOfElectricity(intent);
if (_mnTheQuantityOfElectricityOld != nTheQuantityOfElectricity) {
mAppConfigUtils.setCurrentValue(nTheQuantityOfElectricity);
}
// 新电池状态标志某一个有变化就更新显示信息
if (_mIsCharging != isCharging || _mnTheQuantityOfElectricityOld != nTheQuantityOfElectricity) {
// 电池状态改变先取消旧的提醒消息
NotificationUtils.cancelRemindNotification(context);
GlobalApplication.getAppCacheUtils(context).addChangingTime(nTheQuantityOfElectricity);
MainViewFragment.sendMsgCurrentValueBattery(nTheQuantityOfElectricity);
// 保存好新的电池状态标志
_mIsCharging = isCharging;
_mnTheQuantityOfElectricityOld = nTheQuantityOfElectricity;
}
}
}
// 注册 Receiver
//
public void registerAction() {
IntentFilter filter=new IntentFilter();
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
mGlobalApplication.registerReceiver(mReceiver, filter);
}
}

View File

@@ -0,0 +1,43 @@
package cc.winboll.studio.powerbell.receivers;
/**
* @Author ZhanGSKen@QQ.COM
* @Date 2024/06/06 15:01:39
* @Describe 应用广播消息接收类
*/
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import cc.winboll.studio.powerbell.GlobalApplication;
import cc.winboll.studio.powerbell.services.ControlCenterService;
import cc.winboll.studio.powerbell.utils.ServiceUtils;
import cc.winboll.studio.shared.log.LogUtils;
public class MainReceiver extends BroadcastReceiver {
public static final String TAG = "MainReceiver";
static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
// 存储电量指示值,
// 用于校验电量消息时的电量变化
static volatile int _mnTheQuantityOfElectricityOld = -1;
@Override
public void onReceive(Context context, Intent intent) {
String szAction = intent.getAction();
if (szAction.equals(ACTION_BOOT_COMPLETED)) {
boolean isEnableService = GlobalApplication.getAppConfigUtils(context).getIsEnableService();
if (isEnableService) {
if (ServiceUtils.isServiceAlive(context.getApplicationContext(), ControlCenterService.class.getName()) == false) {
LogUtils.d(TAG, "wakeupAndBindMain() Wakeup... ControlCenterService");
if (Build.VERSION.SDK_INT >= 26) {
context.startForegroundService(new Intent(context, ControlCenterService.class));
} else {
context.startService(new Intent(context, ControlCenterService.class));
}
}
}
}
}
}

View File

@@ -0,0 +1,105 @@
package cc.winboll.studio.powerbell.services;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import cc.winboll.studio.powerbell.GlobalApplication;
import cc.winboll.studio.powerbell.services.ControlCenterService;
import cc.winboll.studio.powerbell.utils.AppConfigUtils;
import cc.winboll.studio.powerbell.utils.ServiceUtils;
public class AssistantService extends Service {
private final static String TAG = "AssistantService";
//MyBinder mMyBinder;
MyServiceConnection mMyServiceConnection;
volatile boolean mIsThreadAlive;
AppConfigUtils mAppConfigUtils;
@Override
public IBinder onBind(Intent intent) {
//return mMyBinder;
return null;
}
@Override
public void onCreate() {
//LogUtils.d(TAG, "onCreate");
super.onCreate();
mAppConfigUtils = GlobalApplication.getAppConfigUtils(this);
//mMyBinder = new MyBinder();
if (mMyServiceConnection == null) {
mMyServiceConnection = new MyServiceConnection();
}
// 设置运行参数
mIsThreadAlive = false;
run();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
//LogUtils.d(TAG, "call onStartCommand(...)");
run();
return START_STICKY;
}
/*class MyBinder extends IMyAidlInterface.Stub {
@Override
public String getServiceName() {
return AssistantService.class.getSimpleName();
}
}*/
@Override
public void onDestroy() {
//LogUtils.d(TAG, "onDestroy");
mIsThreadAlive = false;
super.onDestroy();
}
// 运行服务内容
//
void run() {
//LogUtils.d(TAG, "run");
if (mAppConfigUtils.getIsEnableService()) {
if (mIsThreadAlive == false) {
// 设置运行状态
mIsThreadAlive = true;
// 唤醒和绑定主进程
wakeupAndBindMain();
}
}
}
// 唤醒和绑定主进程
//
void wakeupAndBindMain() {
if (ServiceUtils.isServiceAlive(getApplicationContext(), ControlCenterService.class.getName()) == false) {
//LogUtils.d(TAG, "wakeupAndBindMain() Wakeup... ControlCenterService");
startForegroundService(new Intent(AssistantService.this, ControlCenterService.class));
}
//LogUtils.d(TAG, "wakeupAndBindMain() Bind... ControlCenterService");
bindService(new Intent(AssistantService.this, ControlCenterService.class), mMyServiceConnection, Context.BIND_IMPORTANT);
}
// 主进程与守护进程连接时需要用到此类
//
class MyServiceConnection implements ServiceConnection {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
//LogUtils.d(TAG, "call onServiceConnected(...)");
}
@Override
public void onServiceDisconnected(ComponentName name) {
//LogUtils.d(TAG, "call onServiceDisconnected(...)");
if (mAppConfigUtils.getIsEnableService()) {
wakeupAndBindMain();
}
}
}
}

View File

@@ -0,0 +1,270 @@
package cc.winboll.studio.powerbell.services;
/*
* PowerBy : ZhanGSKen(ZhangShaojian2018@163.com)
* 参考:
* 进程保活-双进程守护的正确姿势
* https://blog.csdn.net/sinat_35159441/article/details/75267380
* Android Service之onStartCommand方法研究
* https://blog.csdn.net/cyp331203/article/details/38920491
*/
import cc.winboll.studio.powerbell.R;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import cc.winboll.studio.powerbell.GlobalApplication;
import cc.winboll.studio.powerbell.beans.AppConfigBean;
import cc.winboll.studio.powerbell.beans.NotificationMessage;
import cc.winboll.studio.powerbell.handlers.ControlCenterServiceHandler;
import cc.winboll.studio.powerbell.receivers.ControlCenterServiceReceiver;
import cc.winboll.studio.powerbell.services.AssistantService;
import cc.winboll.studio.powerbell.threads.RemindThread;
import cc.winboll.studio.powerbell.utils.AppCacheUtils;
import cc.winboll.studio.powerbell.utils.AppConfigUtils;
import cc.winboll.studio.powerbell.utils.NotificationUtils;
import cc.winboll.studio.powerbell.utils.ServiceUtils;
import cc.winboll.studio.powerbell.utils.StringUtils;
import cc.winboll.studio.shared.log.LogUtils;
import com.hjq.toast.ToastUtils;
public class ControlCenterService extends Service {
public static final String TAG = "ControlCenterService";
public static final int MSG_UPDATE_STATUS = 0;
static ControlCenterService _mControlCenterService;
volatile boolean isServiceRunning;
AppConfigUtils mAppConfigUtils;
AppCacheUtils mAppCacheUtils;
// 前台服务通知工具
NotificationUtils mNotificationUtils;
RemindThread mRemindThread;
ControlCenterServiceHandler mControlCenterServiceHandler;
MyServiceConnection mMyServiceConnection;
ControlCenterServiceReceiver mControlCenterServiceReceiver;
ControlCenterServiceReceiver mControlCenterServiceReceiverLocalBroadcast;
@Override
public IBinder onBind(Intent intent) {
return null;
}
public RemindThread getRemindThread() {
return mRemindThread;
}
@Override
public void onCreate() {
super.onCreate();
_mControlCenterService = ControlCenterService.this;
isServiceRunning = false;
mAppConfigUtils = GlobalApplication.getAppConfigUtils(this);
mAppCacheUtils = GlobalApplication.getAppCacheUtils(this);
mNotificationUtils = new NotificationUtils(ControlCenterService.this);
if (mMyServiceConnection == null) {
mMyServiceConnection = new MyServiceConnection();
}
mControlCenterServiceHandler = new ControlCenterServiceHandler(this);
// 运行服务内容
run();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// 运行服务内容
run();
return (mAppConfigUtils.getIsEnableService()) ? START_STICKY : super.onStartCommand(intent, flags, startId);
}
// 运行服务内容
//
void run() {
if (mAppConfigUtils.getIsEnableService() && isServiceRunning == false) {
LogUtils.d(TAG, "run");
isServiceRunning = true;
// 唤醒守护进程
wakeupAndBindAssistant();
// 显示前台通知栏
NotificationMessage notificationMessage=createNotificationMessage();
//Toast.makeText(getApplication(), "", Toast.LENGTH_SHORT).show();
mNotificationUtils.createForegroundNotification(this, notificationMessage);
mNotificationUtils.createRemindNotification(this, notificationMessage);
if (mControlCenterServiceReceiver == null) {
// 注册广播接收器
mControlCenterServiceReceiver = new ControlCenterServiceReceiver(this);
mControlCenterServiceReceiver.registerAction(this);
}
startRemindThread(mAppConfigUtils.mAppConfigBean);
ToastUtils.show("Service Is Start.");
LogUtils.i(TAG, "Service Is Start.");
}
}
String getValuesString() {
String szReturn = "Usege: ";
szReturn += mAppConfigUtils.getIsEnableUsegeReminder() ? Integer.toString(mAppConfigUtils.getUsegeReminderValue()) : "?";
szReturn += "% Charge: ";
szReturn += mAppConfigUtils.getIsEnableChargeReminder() ? Integer.toString(mAppConfigUtils.getChargeReminderValue()) : "?";
szReturn += "%\nCurrent: " + Integer.toString(mAppConfigUtils.getCurrentValue()) + "%";
return szReturn;
}
NotificationMessage createNotificationMessage() {
String szTitle = ((GlobalApplication)getApplication()).getString(R.string.app_name);
String szContent = getValuesString() + " {?} " + StringUtils.formatPCMListString(mAppCacheUtils.getArrayListBatteryInfo());
return new NotificationMessage(szTitle, szContent);
}
// 更新前台通知
//
public void updateServiceNotification() {
mNotificationUtils.updateForegroundNotification(ControlCenterService.this, createNotificationMessage());
}
// 更新前台通知
//
public void updateServiceNotification(NotificationMessage notificationMessage) {
mNotificationUtils.updateForegroundNotification(ControlCenterService.this, notificationMessage);
}
// 更新前台通知
//
public void updateRemindNotification(NotificationMessage notificationMessage) {
mNotificationUtils.updateRemindNotification(ControlCenterService.this, notificationMessage);
}
// 唤醒和绑定守护进程
//
void wakeupAndBindAssistant() {
if (ServiceUtils.isServiceAlive(getApplicationContext(), AssistantService.class.getName()) == false) {
startService(new Intent(ControlCenterService.this, AssistantService.class));
//LogUtils.d(TAG, "call wakeupAndBindAssistant() : Binding... AssistantService");
bindService(new Intent(ControlCenterService.this, AssistantService.class), mMyServiceConnection, Context.BIND_IMPORTANT);
}
}
// 开启提醒铃声线程
//
public void startRemindThread(AppConfigBean appConfigBean) {
//LogUtils.d(TAG, "startRemindThread");
if (mRemindThread == null) {
mRemindThread = new RemindThread(this, mControlCenterServiceHandler);
} else {
if (mRemindThread.isExist() == true) {
mRemindThread = new RemindThread(this, mControlCenterServiceHandler);
} else {
// 提醒进程正在进行中就更新状态后退出
mRemindThread.setChargeReminderValue(appConfigBean.getChargeReminderValue());
mRemindThread.setUsegeReminderValue(appConfigBean.getUsegeReminderValue());
mRemindThread.setIsEnableChargeReminder(appConfigBean.isEnableChargeReminder());
mRemindThread.setIsEnableUsegeReminder(appConfigBean.isEnableUsegeReminder());
mRemindThread.setSleepTime(appConfigBean.getReminderIntervalTime());
mRemindThread.setIsCharging(appConfigBean.isCharging());
mRemindThread.setQuantityOfElectricity(appConfigBean.getCurrentValue());
//LogUtils.d(TAG, "mRemindThread update.");
return;
}
}
mRemindThread.setChargeReminderValue(appConfigBean.getChargeReminderValue());
mRemindThread.setUsegeReminderValue(appConfigBean.getUsegeReminderValue());
mRemindThread.setSleepTime(appConfigBean.getReminderIntervalTime());
mRemindThread.setIsCharging(appConfigBean.isCharging());
mRemindThread.setQuantityOfElectricity(appConfigBean.getCurrentValue());
mRemindThread.setIsEnableChargeReminder(appConfigBean.isEnableChargeReminder());
mRemindThread.setIsEnableUsegeReminder(appConfigBean.isEnableUsegeReminder());
mRemindThread.start();
//LogUtils.d(TAG, "mRemindThread.start()");
}
public void stopRemindThread() {
if (mRemindThread != null) {
mRemindThread.setIsExist(true);
mRemindThread = null;
}
}
@Override
public void onDestroy() {
//LogUtils.d(TAG, "onDestroy");
mAppConfigUtils.loadAppConfigBean();
if (mAppConfigUtils.getIsEnableService() == false) {
// 设置运行状态
isServiceRunning = false;
// 停止守护进程
Intent intent = new Intent(this, AssistantService.class);
stopService(intent);
// 停止Receiver
if (mControlCenterServiceReceiver != null) {
unregisterReceiver(mControlCenterServiceReceiver);
mControlCenterServiceReceiver = null;
}
// 停止前台通知栏
stopForeground(true);
// 停止消息提醒进程
stopRemindThread();
super.onDestroy();
//LogUtils.d(TAG, "onDestroy done");
}
}
// 主进程与守护进程连接时需要用到此类
//
private class MyServiceConnection implements ServiceConnection {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
//LogUtils.d(TAG, "call onServiceConnected(...)");
}
@Override
public void onServiceDisconnected(ComponentName name) {
//LogUtils.d(TAG, "call onServiceConnected(...)");
if (mAppConfigUtils.getIsEnableService()) {
// 唤醒守护进程
wakeupAndBindAssistant();
}
}
}
public void appenRemindMSG(String szRemindMSG) {
NotificationMessage notificationMessage = createNotificationMessage();
notificationMessage.setRemindMSG(szRemindMSG);
//LogUtils.d(TAG, "notificationMessage : " + notificationMessage.getRemindMSG());
updateRemindNotification(notificationMessage);
}
//
// 启动服务
//
public static void startControlCenterService(Context context) {
Intent intent = new Intent(context, ControlCenterService.class);
context.startForegroundService(intent);
}
//
// 停止服务
//
public static void stopControlCenterService(Context context) {
Intent intent = new Intent(context, ControlCenterService.class);
context.stopService(intent);
}
public static void updateStatus(Context context, AppConfigBean appConfigBean) {
//LogUtils.d(TAG, "updateStatus");
// 创建一个Intent实例定义广播的内容
Intent intent = new Intent(ControlCenterServiceReceiver.ACTION_START_REMINDTHREAD);
// 设置可选的Action数据如额外信息
intent.putExtra("appConfigBean", appConfigBean);
// 发送广播
context.sendBroadcast(intent);
}
}

View File

@@ -0,0 +1,197 @@
package cc.winboll.studio.powerbell.threads;
import android.content.Context;
import android.os.Message;
import cc.winboll.studio.powerbell.handlers.ControlCenterServiceHandler;
import cc.winboll.studio.shared.log.LogUtils;
import java.lang.ref.WeakReference;
public class RemindThread extends Thread {
public static final String TAG = RemindThread.class.getSimpleName();
Context mContext;
// 控制线程是否退出的标志
volatile boolean isExist = false;
// 消息提醒开关
static volatile boolean isReminding = false;
// 充电提醒开关
static volatile boolean isEnableUsegeReminder = false;
// 耗电提醒开关
static volatile boolean isEnableChargeReminder = false;
// 电量比较停顿时间
static volatile int sleepTime = 1000;
// 充电提醒电量
static volatile int chargeReminderValue = -1;
// 耗电提醒电量
static volatile int usegeReminderValue = -1;
// 当前电量
static volatile int quantityOfElectricity = -1;
// 是否正在充电
static volatile boolean isCharging = false;
// 服务Handler, 用于线程发送消息使用
WeakReference<ControlCenterServiceHandler> mwrControlCenterServiceHandler;
public void setIsExist(boolean isExist) {
this.isExist = isExist;
}
public boolean isExist() {
return isExist;
}
public static void setIsReminding(boolean isReminding) {
RemindThread.isReminding = isReminding;
}
public static boolean isReminding() {
return isReminding;
}
public static void setIsEnableUsegeReminder(boolean isEnableUsegeReminder) {
RemindThread.isEnableUsegeReminder = isEnableUsegeReminder;
}
public static boolean isEnableUsegeReminder() {
return isEnableUsegeReminder;
}
public static void setIsEnableChargeReminder(boolean isEnableChargeReminder) {
RemindThread.isEnableChargeReminder = isEnableChargeReminder;
}
public static boolean isEnableChargeReminder() {
return isEnableChargeReminder;
}
public static void setSleepTime(int sleepTime) {
RemindThread.sleepTime = sleepTime;
}
public static int getSleepTime() {
return sleepTime;
}
public static void setChargeReminderValue(int chargeReminderValue) {
RemindThread.chargeReminderValue = chargeReminderValue;
}
public static int getChargeReminderValue() {
return chargeReminderValue;
}
public static void setUsegeReminderValue(int usegeReminderValue) {
RemindThread.usegeReminderValue = usegeReminderValue;
}
public static int getUsegeReminderValue() {
return usegeReminderValue;
}
public static void setQuantityOfElectricity(int quantityOfElectricity) {
RemindThread.quantityOfElectricity = quantityOfElectricity;
}
public static int getQuantityOfElectricity() {
return quantityOfElectricity;
}
public static void setIsCharging(boolean isCharging) {
RemindThread.isCharging = isCharging;
}
public static boolean isCharging() {
return isCharging;
}
// 发送消息给用户
//
void sendNotificationMessage(String sz) {
//LogUtils.d(TAG, "sz is " + sz);
Message message = Message.obtain();
message.what = ControlCenterServiceHandler.MSG_REMIND_TEXT;
//message.obj = new NotificationMessage(mContext.getString(R.string.app_name), sz);
message.obj = sz;
ControlCenterServiceHandler handler = mwrControlCenterServiceHandler.get();
if (isReminding && handler != null) {
handler.sendMessage(message);
}
}
public RemindThread(Context context, ControlCenterServiceHandler handler) {
mContext = context;
mwrControlCenterServiceHandler = new WeakReference<ControlCenterServiceHandler>(handler);
}
@Override
public void run() {
//LogUtils.d(TAG, "call run()");
if (isReminding == false) {
isReminding = true;
// 等待些许时间,等所有数据初始化完成再执行下面的程序
// 解决窗口移除后自动重启后会发送一个错误消息的问题
try {
Thread.sleep(500);
} catch (InterruptedException e) {}
// 发送提醒线程开始的参数设置
//sendMessageToUser(Integer.toString(_mnTheQuantityOfElectricity) + ">>>" + Integer.toString(_mnTargetNumber));
//ToastUtils.show("Service Is Start.");
//LogUtils.i(TAG, "Service Is Start.");
while (!isExist()) {
/*
LogUtils.d(TAG, "isCharging is " + Boolean.toString(isCharging));
LogUtils.d(TAG, "usegeReminderValue is " + Integer.toString(usegeReminderValue));
LogUtils.d(TAG, "quantityOfElectricity is " + Integer.toString(quantityOfElectricity));
LogUtils.d(TAG, "chargeReminderValue is " + Integer.toString(chargeReminderValue));
LogUtils.d(TAG, "isEnableChargeReminder is " + Boolean.toString(isEnableChargeReminder));
LogUtils.d(TAG, "isEnableUsegeReminder is " + Boolean.toString(isEnableUsegeReminder));
*/
try {
if (isCharging) {
if ((quantityOfElectricity >= chargeReminderValue)
&& (isEnableChargeReminder)) {
// 正在充电时电量大于指定电量发送提醒
sendNotificationMessage("+");
// 应用需要继续提醒,设置退出标志为否
setIsExist(false);
//sendNotificationMessage("I am ready! +");
} else {
// 设置退出标志,如果后续不需要继续提醒就退出当前进程,用于应用节能。
setIsExist(true);
isReminding = false;
return;
}
} else {
if ((quantityOfElectricity <= usegeReminderValue)
&& (isEnableUsegeReminder)) {
// 正在放电时电量小于指定电量发送提醒
sendNotificationMessage("-");
// 应用需要继续提醒,设置退出标志为否
setIsExist(false);
//sendNotificationMessage("I am ready! -");
} else {
// 设置退出标志,如果后续不需要继续提醒就退出当前进程,用于应用节能。
setIsExist(true);
isReminding = false;
return;
}
}
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
}
//ToastUtils.show("Service Is Stop.");
//LogUtils.i(TAG, "Service Is Stop.");
isReminding = false;
}
}
}

View File

@@ -0,0 +1,85 @@
package cc.winboll.studio.powerbell.utils;
import android.content.Context;
import cc.winboll.studio.powerbell.beans.BatteryInfoBean;
import cc.winboll.studio.shared.log.LogUtils;
import java.util.ArrayList;
public class AppCacheUtils {
public static final String TAG = "AppCacheUtils";
// 保存唯一配置实例
static AppCacheUtils _mAppCacheUtils;
// 配置实例引用的上下文环境
Context mContext;
// 配置实例的数据的存储文件路径
//volatile String mAppCacheDataFilePath = null;
ArrayList<BatteryInfoBean> mlBatteryInfo;
// 私有实例构造方法
//
AppCacheUtils(Context context) {
mContext = context;
//mAppCacheDataFilePath = context.getExternalFilesDir(TAG) + File.separator + "mlBatteryInfo.dat";
mlBatteryInfo = new ArrayList<BatteryInfoBean>();
loadAppCacheData();
}
// 返回唯一实例
//
public static synchronized AppCacheUtils getInstance(Context context) {
if (_mAppCacheUtils == null) {
_mAppCacheUtils = new AppCacheUtils(context);
}
return _mAppCacheUtils;
}
// 添加电量改变时间
//
public void addChangingTime(int nBattetyValue) {
if (mlBatteryInfo.size() == 0) {
addChangingTimeToList(nBattetyValue);
//LogUtils.d(TAG, "nBattetyValue is "+Integer.toString(nBattetyValue));
return;
}
if (mlBatteryInfo.get(mlBatteryInfo.size() - 1).getBattetyValue() != nBattetyValue) {
addChangingTimeToList(nBattetyValue);
//LogUtils.d(TAG, "nBattetyValue is "+Integer.toString(nBattetyValue));
}
}
void addChangingTimeToList(int nBattetyValue) {
if (mlBatteryInfo.size() > 180) {
mlBatteryInfo.remove(0);
}
BatteryInfoBean batteryInfo = new BatteryInfoBean(System.currentTimeMillis(), nBattetyValue);
LogUtils.d(TAG, "getBattetyValue is " + Integer.toString(batteryInfo.getBattetyValue()));
LogUtils.d(TAG, "getTimeStamp is " + Long.toString(batteryInfo.getTimeStamp()));
mlBatteryInfo.add(batteryInfo);
saveAppCacheData();
}
public ArrayList<BatteryInfoBean> getArrayListBatteryInfo() {
loadAppCacheData();
return mlBatteryInfo;
}
// 读取文件存储的数据
//
void saveAppCacheData() {
BatteryInfoBean.saveBeanList(mContext, mlBatteryInfo, BatteryInfoBean.class);
}
// 保存数据到文件
//
void loadAppCacheData() {
mlBatteryInfo.clear();
BatteryInfoBean.loadBeanList(mContext, mlBatteryInfo, BatteryInfoBean.class);
}
public void clearBatteryHistory() {
mlBatteryInfo.clear();
saveAppCacheData();
}
}

View File

@@ -0,0 +1,203 @@
package cc.winboll.studio.powerbell.utils;
import android.app.Activity;
import android.content.Context;
import cc.winboll.studio.powerbell.GlobalApplication;
import cc.winboll.studio.powerbell.MainActivity;
import cc.winboll.studio.powerbell.beans.AppConfigBean;
import cc.winboll.studio.powerbell.beans.ControlCenterServiceBean;
import cc.winboll.studio.powerbell.dialogs.YesNoAlertDialog;
import cc.winboll.studio.powerbell.fragments.MainViewFragment;
import cc.winboll.studio.powerbell.services.ControlCenterService;
import cc.winboll.studio.shared.log.LogUtils;
import java.io.File;
// 应用配置工具类
//
public class AppConfigUtils {
public static final String TAG = "AppConfigUtils";
public static final String BACKGROUND_DIR = "Background";
// 保存唯一配置实例
static AppConfigUtils _mAppConfigUtils;
// 应用环境上下文
Context mContext;
// 是否启动铃声提醒服务
volatile boolean mIsEnableService = false;
public volatile AppConfigBean mAppConfigBean;
// 电池充电提醒值。
// Battery charge reminder value.
volatile int mnChargeReminderValue = -1;
volatile boolean mIsEnableChargeReminder = false;
// 电池耗电量提醒值。
// Battery power usege reminder value.
volatile int mnUsegeReminderValue = -1;
volatile boolean mIsEnableUsegeReminder = false;
volatile boolean mIsUseBackgroundFile = false;
volatile String mszBackgroundFileName = "";
// 保存应用实例
GlobalApplication mApplication;
AppConfigUtils(Context context) {
mContext = context;
String szExternalFilesDir = mContext.getExternalFilesDir(TAG) + File.separator;
//mlistAppConfigBean = new ArrayList<AppConfigBean>();
mAppConfigBean = new AppConfigBean();
loadAppConfigBean();
}
// 返回唯一实例
//
public static AppConfigUtils getInstance(Context context) {
if (_mAppConfigUtils == null) {
_mAppConfigUtils = new AppConfigUtils(context);
}
return _mAppConfigUtils;
}
public void setIsEnableService(Activity activity, final boolean isEnableService) {
YesNoAlertDialog.show(activity, "应用设置信息", "是否保存应用配置?", new YesNoAlertDialog.OnDialogResultListener(){
@Override
public void onYes() {
mIsEnableService = isEnableService;
ControlCenterServiceBean bean = new ControlCenterServiceBean(isEnableService);
ControlCenterServiceBean.saveBean(mContext, bean);
if (mIsEnableService) {
LogUtils.d(TAG, "startControlCenterService");
ControlCenterService.startControlCenterService(mContext);
} else {
LogUtils.d(TAG, "stopControlCenterService");
ControlCenterService.stopControlCenterService(mContext);
}
}
@Override
public void onNo() {
MainViewFragment.relaodAppConfigs();
}
});
}
public boolean getIsEnableService() {
ControlCenterServiceBean bean = ControlCenterServiceBean.loadBean(mContext, ControlCenterServiceBean.class);
if (bean == null) {
ControlCenterServiceBean.saveBean(mContext, new ControlCenterServiceBean(false));
return false;
}
return bean.isEnableService();
}
public void setIsEnableChargeReminder(boolean isEnableChargeReminder) {
mAppConfigBean.setIsEnableChargeReminder(isEnableChargeReminder);
saveConfigData(MainActivity._mMainActivity);
}
public boolean getIsEnableChargeReminder() {
return mAppConfigBean.isEnableChargeReminder();
}
public void setIsEnableUsegeReminder(boolean isEnableUsegeReminder) {
mAppConfigBean.setIsEnableUsegeReminder(isEnableUsegeReminder);
saveConfigData(MainActivity._mMainActivity);
}
public boolean getIsEnableUsegeReminder() {
return mAppConfigBean.isEnableUsegeReminder();
}
public void setChargeReminderValue(int value) {
mAppConfigBean.setChargeReminderValue(value);
saveConfigData(MainActivity._mMainActivity);
}
public int getChargeReminderValue() {
return mAppConfigBean.getChargeReminderValue();
}
public void setUsegeReminderValue(int value) {
mAppConfigBean.setUsegeReminderValue(value);
saveConfigData(MainActivity._mMainActivity);
}
public int getUsegeReminderValue() {
return mAppConfigBean.getUsegeReminderValue();
}
public void setIsCharging(boolean isCharging) {
mAppConfigBean.setIsCharging(isCharging);
}
public boolean isCharging() {
return mAppConfigBean.isCharging();
}
public void setCurrentValue(int nCurrentValue) {
mAppConfigBean.setCurrentValue(nCurrentValue);
}
public int getCurrentValue() {
return mAppConfigBean.getCurrentValue();
}
public void setReminderIntervalTime(int reminderIntervalTime) {
mAppConfigBean.setReminderIntervalTime(reminderIntervalTime);
}
public int getReminderIntervalTime() {
return mAppConfigBean.getReminderIntervalTime();
}
//
// 加载电池提醒配置数据
//
public void loadAppConfigBean() {
AppConfigBean bean = AppConfigBean.loadBean(mContext, AppConfigBean.class);
if (bean == null) {
bean = new AppConfigBean();
AppConfigBean.saveBean(mContext, mAppConfigBean);
}
mAppConfigBean.setIsEnableUsegeReminder(bean.isEnableUsegeReminder());
mAppConfigBean.setUsegeReminderValue(bean.getUsegeReminderValue());
mAppConfigBean.setIsEnableChargeReminder(bean.isEnableChargeReminder());
mAppConfigBean.setChargeReminderValue(bean.getChargeReminderValue());
}
public void saveConfigData(final MainActivity activity) {
if (MainActivity._mMainActivity == null) {
return;
}
YesNoAlertDialog.show(activity, "应用设置信息", "是否保存应用配置?", new YesNoAlertDialog.OnDialogResultListener(){
@Override
public void onYes() {
saveConfigData();
}
@Override
public void onNo() {
AppConfigUtils.getInstance(activity).loadAppConfigBean();
MainViewFragment.relaodAppConfigs();
}
});
}
//
// 保存应用配置数据
//
void saveConfigData() {
// 更新配置先取消一下旧的的提醒消息
NotificationUtils.cancelRemindNotification(mContext);
AppConfigBean.saveBean(mContext, mAppConfigBean);
// 通知活动窗口和服务配置已更新
ControlCenterService.updateStatus(mContext, mAppConfigBean);
MainViewFragment.relaodAppConfigs();
}
}

View File

@@ -0,0 +1,64 @@
package cc.winboll.studio.powerbell.utils;
/**
* @Author ZhanGSKen@QQ.COM
* @Date 2024/07/18 12:07:20
* @Describe 背景图片工具集
*/
import android.content.Context;
import cc.winboll.studio.powerbell.beans.BackgroundPictureBean;
import java.io.File;
public class BackgroundPictureUtils {
public static final String TAG = "BackgroundPictureUtils";
static BackgroundPictureUtils _mBackgroundPictureUtils;
Context mContext;
BackgroundPictureBean mBackgroundPictureBean;
// 背景图片目录
String mszBackgroundDir;
BackgroundPictureUtils(Context context) {
mContext = context;
String szExternalFilesDir = mContext.getExternalFilesDir(TAG) + File.separator;
setBackgroundDir(szExternalFilesDir + "Background" + File.separator);
loadBackgroundPictureBean();
}
public static BackgroundPictureUtils getInstance(Context context) {
if (_mBackgroundPictureUtils == null) {
_mBackgroundPictureUtils = new BackgroundPictureUtils(context);
}
return _mBackgroundPictureUtils;
}
//
// 加载应用背景图片配置数据
//
public BackgroundPictureBean loadBackgroundPictureBean() {
mBackgroundPictureBean = BackgroundPictureBean.loadBean(mContext, BackgroundPictureBean.class);
if (mBackgroundPictureBean == null) {
mBackgroundPictureBean = new BackgroundPictureBean();
BackgroundPictureBean.saveBean(mContext, mBackgroundPictureBean);
}
return mBackgroundPictureBean;
}
void setBackgroundDir(String mszBackgroundDir) {
this.mszBackgroundDir = mszBackgroundDir;
}
public String getBackgroundDir() {
return mszBackgroundDir;
}
public BackgroundPictureBean getBackgroundPictureBean() {
return mBackgroundPictureBean;
}
public void saveData() {
BackgroundPictureBean.saveBean(mContext, mBackgroundPictureBean);
}
}

View File

@@ -0,0 +1,28 @@
package cc.winboll.studio.powerbell.utils;
/**
* @Author ZhanGSKen@QQ.COM
* @Date 2024/07/18 04:32:46
* @Describe 电池工具类
*/
import android.content.Context;
import android.content.Intent;
import android.os.BatteryManager;
public class BatteryUtils {
public static final String TAG = "BatteryUtils";
public static boolean isCharging(Intent intent) {
int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING ||
status == BatteryManager.BATTERY_STATUS_FULL;
return isCharging;
}
public static int getTheQuantityOfElectricity(Intent intent) {
int intLevel = intent.getIntExtra("level", 0);
int intScale = intent.getIntExtra("scale", 100);
return intLevel * 100 / intScale;
}
}

View File

@@ -0,0 +1,16 @@
package cc.winboll.studio.powerbell.utils;
import java.text.SimpleDateFormat;
public class DateUtils {
// 获取当前时间的格式化字符串
public static String getDateNowString() {
// 日期类转化成字符串类的工具
SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat("YYYYMMdd_HHmmssmmm", java.util.Locale.getDefault());
// 读取当前时间
long nTimeNow = System.currentTimeMillis();
return mSimpleDateFormat.format(nTimeNow);
}
}

View File

@@ -0,0 +1,176 @@
package cc.winboll.studio.powerbell.utils;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import cc.winboll.studio.shared.log.LogUtils;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.channels.FileChannel;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
/**
* 文件读取工具类
*/
public class FileUtils {
public static final String TAG = "FileUtils";
//
// 读取文件内容,作为字符串返回
//
public static String readFileAsString(String filePath) throws IOException {
File file = new File(filePath);
if (!file.exists()) {
throw new FileNotFoundException(filePath);
}
if (file.length() > 1024 * 1024 * 1024) {
throw new IOException("File is too large");
}
StringBuilder sb = new StringBuilder((int) (file.length()));
// 创建字节输入流
FileInputStream fis = new FileInputStream(filePath);
// 创建一个长度为10240的Buffer
byte[] bbuf = new byte[10240];
// 用于保存实际读取的字节数
int hasRead = 0;
while ((hasRead = fis.read(bbuf)) > 0) {
sb.append(new String(bbuf, 0, hasRead));
}
fis.close();
return sb.toString();
}
//
// 根据文件路径读取byte[] 数组
//
public static byte[] readFileByBytes(String filePath) throws IOException {
File file = new File(filePath);
if (!file.exists()) {
throw new FileNotFoundException(filePath);
} else {
ByteArrayOutputStream bos = new ByteArrayOutputStream((int) file.length());
BufferedInputStream in = null;
try {
in = new BufferedInputStream(new FileInputStream(file));
short bufSize = 1024;
byte[] buffer = new byte[bufSize];
int len1;
while (-1 != (len1 = in.read(buffer, 0, bufSize))) {
bos.write(buffer, 0, len1);
}
byte[] var7 = bos.toByteArray();
return var7;
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException var14) {
var14.printStackTrace();
}
bos.close();
}
}
}
//
// 文件复制函数
//
public static void copyFileUsingFileChannels(File source, File dest) throws IOException {
FileChannel inputChannel = null;
FileChannel outputChannel = null;
try {
inputChannel = new FileInputStream(source).getChannel();
outputChannel = new FileOutputStream(dest).getChannel();
outputChannel.transferFrom(inputChannel, 0, inputChannel.size());
} finally {
inputChannel.close();
outputChannel.close();
}
}
/**
* 将文件生成位图
* @param path
* @return
* @throws IOException
*/
public static BitmapDrawable getImageDrawable(String path)
throws IOException {
//打开文件
File file = new File(path);
if (!file.exists()) {
return null;
}
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
int BUFFER_SIZE = 1000;
byte[] bt = new byte[BUFFER_SIZE];
//得到文件的输入流
InputStream in = new FileInputStream(file);
//将文件读出到输出流中
int readLength = in.read(bt);
while (readLength != -1) {
outStream.write(bt, 0, readLength);
readLength = in.read(bt);
}
//转换成byte 后 再格式化成位图
byte[] data = outStream.toByteArray();
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);// 生成位图
BitmapDrawable bd = new BitmapDrawable(bitmap);
return bd;
}
public static boolean copyFile(File oldFile, File newFile) {
//String oldPath = "path/to/original/file.txt";
//String newPath = "path/to/new-location/for/file.txt";
//File oldFile = new java.io.File(oldPath);
//File newFile = new java.io.File(newPath);
if (!newFile.getParentFile().exists()) {
newFile.getParentFile().mkdirs();
}
if (!oldFile.exists()) {
//System.out.println("The original file does not exist.");
LogUtils.d(TAG, "The original file does not exist.");
} else {
try {
// 源文件路径
Path sourcePath = Paths.get(oldFile.getPath());
// 目标文件路径
Path destPath = Paths.get(newFile.getPath());
if(newFile.exists()) {
newFile.delete();
}
Files.copy(sourcePath, destPath);
LogUtils.d(TAG, "File copy successfully.");
//System.out.println("File moved successfully.");
return true;
} catch (Exception e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
//System.err.println("An error occurred while moving the file: " + e.getMessage());
}
}
return false;
}
}

View File

@@ -0,0 +1,53 @@
package cc.winboll.studio.powerbell.utils;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import cc.winboll.studio.shared.log.LogUtils;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class ImageUtils {
public static final String TAG = ImageUtils.class.getSimpleName();
// 这里我们生成了一个Pic文件夹在下面放了我们质量压缩后的图片用于和原图对比
// 压缩图片使用Bitmap.compress(),这里是质量压缩
// 参数Context context :调用本函数函数引用的资源体系
// String szSrcImagePath :要压缩的源文件路径
// String szDstImagePath :压缩后文件要保存的路径
// int nPictureCompress :图片压缩比例
public static void bitmapCompress(Context context, String szSrcImagePath, String szDstImagePath, int nPictureCompress) {
try {
Bitmap bmpCompressImage;
//生成新的文件
File fDstCompressImage = new File(szDstImagePath);
//裁剪后的图像转成BitMap
//photoBitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uriClipUri));
bmpCompressImage = BitmapFactory.decodeFile(szSrcImagePath);
//创建输出流
OutputStream out = null;
out = new FileOutputStream(fDstCompressImage.getPath());
//压缩文件,返回结果,参数分别是压缩的格式,压缩质量的百分比,输出流
boolean bCompress = bmpCompressImage.compress(Bitmap.CompressFormat.JPEG, nPictureCompress, out);
// 复制压缩后的文件到源路径
File fSrcImage = new File(szSrcImagePath);
FileUtils.copyFileUsingFileChannels(fDstCompressImage, fSrcImage);
LogUtils.d(TAG, Integer.toString(nPictureCompress) + "%压缩结束。");
} catch (FileNotFoundException e) {
LogUtils.d(TAG, "bitmapCompress FileNotFoundException : " + e.getMessage());
} catch (IOException e) {
LogUtils.d(TAG, "bitmapCompress IOException : " + e.getMessage());
}
}
}

View File

@@ -0,0 +1,212 @@
package cc.winboll.studio.powerbell.utils;
/*
* 参考:
* https://blog.csdn.net/qq_35507234/article/details/90676587
* https://blog.csdn.net/qq_16628781/article/details/51548324
*/
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.media.RingtoneManager;
import android.os.Build;
import android.view.View;
import android.widget.RemoteViews;
import cc.winboll.studio.powerbell.MainActivity;
import cc.winboll.studio.powerbell.R;
import cc.winboll.studio.powerbell.beans.NotificationMessage;
import cc.winboll.studio.powerbell.services.ControlCenterService;
public class NotificationUtils {
public static final String TAG = NotificationUtils.class.getSimpleName();
Context mContext;
NotificationManager mNotificationManager;
Notification mForegroundNotification;
PendingIntent mForegroundPendingIntent;
Notification mRemindNotification;
PendingIntent mRemindPendingIntent;
RemoteViews mrvServiceNotificationView;
RemoteViews mrvRemindNotificationView;
static enum NotificationType { MIN, MAX };
private static int _mnServiceNotificationID = 1;
private static int _mnRemindNotificationID = 2;
private static String _mszChannelIDService = "1";
private static String _mszChannelNameService = "Service";
private static String _mszChannelIDRemind = "2";
private static String _mszChannelNameRemind = "Remind";
public NotificationUtils(Context context) {
mContext = context;
mNotificationManager = (NotificationManager) context.getSystemService(
Context.NOTIFICATION_SERVICE);
}
public void createNotificationChannel() {
NotificationChannel channel1 = new NotificationChannel(_mszChannelIDService, _mszChannelNameService, NotificationManager.IMPORTANCE_DEFAULT);
channel1.setSound(null, null);
mNotificationManager.createNotificationChannel(channel1);
NotificationChannel channel2 = new NotificationChannel(_mszChannelIDRemind, _mszChannelNameRemind, NotificationManager.IMPORTANCE_HIGH);
channel2.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE), Notification.AUDIO_ATTRIBUTES_DEFAULT);
mNotificationManager.createNotificationChannel(channel2);
}
// 创建并发送服务通知
//
public void createForegroundNotification(ControlCenterService service, NotificationMessage notificationMessage) {
//创建Notification传入Context和channelId
Intent intent = new Intent();//这个intent会传给目标,可以使用getIntent来获取
intent.setPackage(service.getPackageName());
//LogUtils.d(TAG, "mService.getPackageName() : " + service.getPackageName());
intent.setClass(service, MainActivity.class);
//LogUtils.d(TAG, "MainActivity.class.getName() : " + MainActivity.class.getName());
//这里放一个count用来区分每一个通知
//intent.putExtra("intent", "intent--->" + count);//这里设置一个数据,带过去
//参数1:context 上下文对象
//参数2:发送者私有的请求码(Private request code for the sender)
//参数3:intent 意图对象
//参数4:必须为FLAG_ONE_SHOT,FLAG_NO_CREATE,FLAG_CANCEL_CURRENT,FLAG_UPDATE_CURRENT,中的一个
//mForegroundPendingIntent = PendingIntent.getActivity(mService, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
mForegroundPendingIntent = PendingIntent.getActivity(service,
1, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
} else {
mForegroundPendingIntent = PendingIntent.getActivity(service,
1, intent, PendingIntent.FLAG_IMMUTABLE);
}
mForegroundNotification = new Notification.Builder(service, _mszChannelIDService)
.setAutoCancel(true)
.setContentTitle(notificationMessage.getTitle())
.setContentText(notificationMessage.getContent())
.setWhen(System.currentTimeMillis())
.setSmallIcon(R.drawable.ic_launcher)
//设置红色
.setColor(Color.parseColor("#F00606"))
.setLargeIcon(BitmapFactory.decodeResource(service.getResources(), R.drawable.ic_launcher))
.setContentIntent(mForegroundPendingIntent)
.build();
setForegroundNotificationRemoteViews(service, notificationMessage);
service.startForeground(_mnServiceNotificationID, mForegroundNotification);
}
void initmrvRemindNotificationView(ControlCenterService service, NotificationMessage notificationMessage) {
mrvRemindNotificationView = new RemoteViews(service.getPackageName(), R.layout.view_remindnotification);
mrvRemindNotificationView.setTextViewText(R.id.viewremindnotificationTextView1, notificationMessage.getTitle());
String szRemindMSG = notificationMessage.getRemindMSG();
//LogUtils.d(TAG, "szRemindMSG : " + szRemindMSG);
//mrvRemindNotificationView.setTextViewText(R.id.remoteviewTextView2, szRemindMSG);
if (szRemindMSG != null) {
if (szRemindMSG.trim().equals("-")) {
//LogUtils.d(TAG, "-");
mrvRemindNotificationView.setViewVisibility(R.id.remoteviewCharge, View.GONE);
mrvRemindNotificationView.setViewVisibility(R.id.remoteviewUsege, View.VISIBLE);
} else if (szRemindMSG.trim().equals("+")) {
//LogUtils.d(TAG, "+");
mrvRemindNotificationView.setViewVisibility(R.id.remoteviewUsege, View.GONE);
mrvRemindNotificationView.setViewVisibility(R.id.remoteviewCharge, View.VISIBLE);
}
mrvRemindNotificationView.setImageViewResource(R.id.remoteviewImageView1, R.drawable.ic_launcher);
//给我remoteViews上的控件tv_content添加监听事件
//remoteViews.setOnClickPendingIntent(R.id.remoteviewLinearLayout1, pi);
//return mrvServiceNotificationView;
}
}
void initmrvServiceNotificationView(ControlCenterService service, NotificationMessage notificationMessage) {
mrvServiceNotificationView = new RemoteViews(service.getPackageName(), R.layout.view_servicenotification);
mrvServiceNotificationView.setTextViewText(R.id.remoteviewTextView1, notificationMessage.getTitle());
//String szRemindMSG = notificationMessage.getRemindMSG();
//mrvServiceNotificationView.setTextViewText(R.id.remoteviewTextView2, szRemindMSG);
//rvServiceNotificationView.setTextViewText(R.id.remoteviewTextView3, notificationMessage.getContent() + Integer.toString(nTest));
mrvServiceNotificationView.setTextViewText(R.id.remoteviewTextView3, notificationMessage.getContent());
mrvServiceNotificationView.setImageViewResource(R.id.remoteviewImageView1, R.drawable.ic_launcher);
//给我remoteViews上的控件tv_content添加监听事件
//remoteViews.setOnClickPendingIntent(R.id.remoteviewLinearLayout1, pi);
//return mrvServiceNotificationView;
}
void setForegroundNotificationRemoteViews(ControlCenterService service, NotificationMessage notificationMessage) {
initmrvServiceNotificationView(service, notificationMessage);
mForegroundNotification.contentView = mrvServiceNotificationView;
mForegroundNotification.bigContentView = mrvServiceNotificationView;
}
void setRemindNotificationRemoteViews(ControlCenterService service, NotificationMessage notificationMessage) {
initmrvRemindNotificationView(service, notificationMessage);
mRemindNotification.contentView = mrvRemindNotificationView;
mRemindNotification.bigContentView = mrvRemindNotificationView;
}
// 更新服务通知
//
public void updateForegroundNotification(ControlCenterService service, NotificationMessage notificationMessage) {
setForegroundNotificationRemoteViews(service, notificationMessage);
mNotificationManager.notify(_mnServiceNotificationID, mForegroundNotification);
}
// 创建并发送电量提醒通知
//
public void updateRemindNotification(ControlCenterService service, NotificationMessage notificationMessage) {
//LogUtils.d(TAG, "updateRemindNotification : " + notificationMessage.getRemindMSG());
setRemindNotificationRemoteViews(service, notificationMessage);
mNotificationManager.notify(_mnRemindNotificationID, mRemindNotification);
}
public void createRemindNotification(ControlCenterService service, NotificationMessage notificationMessage) {
//LogUtils.d(TAG, "notificationMessage : " + notificationMessage.getRemindMSG());
//创建Notification传入Context和channelId
Intent intent = new Intent();//这个intent会传给目标,可以使用getIntent来获取
intent.setPackage(service.getPackageName());
intent.setClass(service, MainActivity.class);
//这里放一个count用来区分每一个通知
//intent.putExtra("intent", "intent--->" + count);//这里设置一个数据,带过去
//参数1:context 上下文对象
//参数2:发送者私有的请求码(Private request code for the sender)
//参数3:intent 意图对象
//参数4:必须为FLAG_ONE_SHOT,FLAG_NO_CREATE,FLAG_CANCEL_CURRENT,FLAG_UPDATE_CURRENT,中的一个
//mRemindPendingIntent = PendingIntent.getActivity(mService, 1, intent, PendingIntent.FLAG_CANCEL_CURRENT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
mRemindPendingIntent = PendingIntent.getActivity(service,
1, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
} else {
mRemindPendingIntent = PendingIntent.getActivity(service,
1, intent, PendingIntent.FLAG_IMMUTABLE);
}
mRemindNotification = new Notification.Builder(service, _mszChannelIDRemind)
.setAutoCancel(true)
.setContentTitle(notificationMessage.getTitle())
.setContentText(notificationMessage.getContent())
.setWhen(System.currentTimeMillis())
.setSmallIcon(R.drawable.ic_launcher)
//设置红色
.setColor(Color.parseColor("#F00606"))
.setLargeIcon(BitmapFactory.decodeResource(service.getResources(), R.drawable.ic_launcher))
.setContentIntent(mRemindPendingIntent)
.build();
setRemindNotificationRemoteViews(service, notificationMessage);
}
public static void cancelRemindNotification(Context context){
// 获取 NotificationManager 实例
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
// 撤回指定 ID 的通知栏消息
notificationManager.cancel(_mnRemindNotificationID);
}
}

View File

@@ -0,0 +1,30 @@
package cc.winboll.studio.powerbell.utils;
import android.app.ActivityManager;
import android.content.Context;
import java.util.List;
public class ServiceUtils {
public static final String TAG = ServiceUtils.class.getSimpleName();
public static boolean isServiceAlive(Context context, String szServiceName) {
// 获取Activity管理者对象
ActivityManager manager = (ActivityManager) context
.getSystemService(Context.ACTIVITY_SERVICE);
// 获取正在运行的服务此处设置最多取1000个
List<ActivityManager.RunningServiceInfo> runningServices = manager
.getRunningServices(1000);
if (runningServices.size() <= 0) {
return false;
}
// 遍历若存在名字和传入的serviceName的一致则说明存在
for (ActivityManager.RunningServiceInfo runningServiceInfo : runningServices) {
if (runningServiceInfo.service.getClassName().equals(szServiceName)) {
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,105 @@
package cc.winboll.studio.powerbell.utils;
import cc.winboll.studio.powerbell.beans.BatteryInfoBean;
import java.util.ArrayList;
public class StringUtils {
public static final String TAG = StringUtils.class.getSimpleName();
// 电量改变使用分钟数列表
// List of power-changing usage minutes
//
public static String formatPCMListString(ArrayList<BatteryInfoBean> arrayListBatteryInfo) {
/* 调试数据
Time t1 = new Time();
//t.set(int second, int minute, int hour, int monthDay, int month, int year) {}
t1.set(4, 8, 0, 27, 4, 2022);
long ntime1 = t1.toMillis(true);
Time t2 = new Time();
//t.set(int second, int minute, int hour, int monthDay, int month, int year) {}
t2.set(9, 12, 3, 29, 4, 2022);
long ntime2 = t2.toMillis(true);
LogUtils.d(TAG, "ntime1 is " + Long.toString(ntime1));
LogUtils.d(TAG, "ntime2 is " + Long.toString(ntime2));
LogUtils.d(TAG, "getTimespanDifference(ntime1, ntime2) is " + getTimespanDifference(ntime1, ntime2));
*/
/*String sz = "";
for (int i = 0; i < lnTime.size() - 1; i++) {
sz += getTimespanDifference(lnTime.get(i), lnTime.get(i + 1));
}
return sz;*/
String sz = "";
for (int i = 0; i < arrayListBatteryInfo.size() - 1; i++) {
//LogUtils.d(TAG, "arrayListBatteryInfo.get(i).getBattetyValue() is "+ Integer.toString(arrayListBatteryInfo.get(i).getBattetyValue()));
sz = arrayListBatteryInfo.get(i).getBattetyValue() + "% " + getTimespanDifference(arrayListBatteryInfo.get(i).getTimeStamp(), arrayListBatteryInfo.get(i + 1).getTimeStamp()) + " " + sz;
}
return sz;
}
// 获取时间之间的时间跨度字符串。
// Get timespan string between times.
// 返回值: {(几天/)(几小时/)(几分钟/)(几秒钟)}
// 返回值: {(几小时/)(几分钟/)(几秒钟)}
// 返回值: {(几分钟/)(几秒钟)}
// 返回值: {(几秒钟)}
// (注start == end 时) 返回值: {0}
public static String getTimespanDifference(long start, long end) {
String szReturn = "{";
long between = end - start;
//LogUtils.d(TAG, "between is " + Long.toString(between));
long day = between / (24 * 60 * 60 * 1000);
long hour = (between / (60 * 60 * 1000) - day * 24);
long min = ((between / (60 * 1000)) - day * 24 * 60 - hour * 60);
long s = (between / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60);
/* 调试数据
day = 0;
hour = 2;
min = 0;
s = 7;
*/
//long ms = (between - day * 24 * 60 * 60 * 1000 - hour * 60 * 60 * 1000
//- min * 60 * 1000 - s * 1000);
szReturn += day > 0 ? String.format(java.util.Locale.getDefault(), "%d☀", day) : "";
szReturn += hour > 0 || day > 0 ? String.format(java.util.Locale.getDefault(), "%d★", hour) : "";
szReturn += min > 0 || hour > 0 || day > 0 ? String.format(java.util.Locale.getDefault(), "%d✰", min) : "";
szReturn += min > 0 || hour > 0 || day > 0 ? String.format(java.util.Locale.getDefault(), "%d}", s) : "☆}";
//String strmin = String.format("%02d", min);
//String strs = String.format("%02d", s);
//String strms = String.format("%03d",ms);
//String timeDifference = day + "天" + hour + "小时" + strmin + "分" + strs + "秒" + strms + "毫秒";
//String timeDifference = hour + getString(R.string.activity_main_msg_hour)
// + strmin + getString(R.string.activity_main_msg_minute)
// + strs + getString(R.string.activity_main_msg_second);
//return timeDifference;
return szReturn;
}
// 调试函数: 调试formatPCMListString(ArrayList<Long> lnTime)
//
/*public static String formatPCMListString_test() {
// 调试数据
ArrayList<Long> listTime = new ArrayList<Long>();
Time t1 = new Time();
//t.set(int second, int minute, int hour, int monthDay, int month, int year) {}
t1.set(0, 8, 0, 27, 4, 2022);
long ntime1 = t1.toMillis(true);
listTime.add(ntime1);
for (int i = 0; i < 5; i++) {
Time t2 = new Time();
//t.set(int second, int minute, int hour, int monthDay, int month, int year) {}
t2.set(4, 8 + i + 1, 0, 27, 4, 2022);
long ntime2 = t2.toMillis(true);
listTime.add(ntime2);
}
return formatPCMListString(listTime);
//LogUtils.d(TAG, StringUtils.formatPCMListString(listTime));
}*/
}

View File

@@ -0,0 +1,145 @@
package cc.winboll.studio.powerbell.utils;
/**
* @Author ZhanGSKen@QQ.COM
* @Date 2024/06/28 04:23:04
* @Describe UriUtil
*/
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.provider.MediaStore;
import androidx.core.content.FileProvider;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class UriUtil {
public static final String TAG = "UriUtil";
/**
* 获取真实路径
*
* @param context
*/
public static String getFilePathFromUri(Context context, Uri uri) {
if (uri == null) {
return null;
}
switch (uri.getScheme()) {
case ContentResolver.SCHEME_CONTENT:
//Android7.0之后的uri content:// URI
return getFilePathFromContentUri(context, uri);
case ContentResolver.SCHEME_FILE:
default:
//Android7.0之前的uri file://
return new File(uri.getPath()).getAbsolutePath();
}
}
/**
* 从uri获取path
*
* @param uri content://media/external/file/109009
* <p>
* FileProvider适配
* content://com.tencent.mobileqq.fileprovider/external_files/storage/emulated/0/Tencent/QQfile_recv/
* content://com.tencent.mm.external.fileprovider/external/tencent/MicroMsg/Download/
*/
private static String getFilePathFromContentUri(Context context, Uri uri) {
if (null == uri) return null;
String data = null;
String[] filePathColumn = {MediaStore.MediaColumns.DATA, MediaStore.MediaColumns.DISPLAY_NAME};
Cursor cursor = context.getContentResolver().query(uri, filePathColumn, null, null, null);
if (null != cursor) {
if (cursor.moveToFirst()) {
int index = cursor.getColumnIndex(MediaStore.MediaColumns.DATA);
if (index > -1) {
data = cursor.getString(index);
} else {
int nameIndex = cursor.getColumnIndex(MediaStore.MediaColumns.DISPLAY_NAME);
String fileName = cursor.getString(nameIndex);
data = getPathFromInputStreamUri(context, uri, fileName);
}
}
cursor.close();
}
return data;
}
/**
* 用流拷贝文件一份到自己APP私有目录下
*
* @param context
* @param uri
* @param fileName
*/
private static String getPathFromInputStreamUri(Context context, Uri uri, String fileName) {
InputStream inputStream = null;
String filePath = null;
if (uri.getAuthority() != null) {
try {
inputStream = context.getContentResolver().openInputStream(uri);
File file = createTemporalFileFrom(context, inputStream, fileName);
filePath = file.getPath();
} catch (Exception e) {
} finally {
try {
if (inputStream != null) {
inputStream.close();
}
} catch (Exception e) {
}
}
}
return filePath;
}
public static Uri getUriForFile(Context context, File file) {
//Uri uri = FileProvider.getUriForFile(context, context.getPackageName() + ".fileprovider", file);
if (Build.VERSION.SDK_INT >= 24) {//android 7.0以上
return FileProvider.getUriForFile(context, context.getPackageName() + ".fileprovider", file);
}
return Uri.fromFile(file);
}
private static File createTemporalFileFrom(Context context, InputStream inputStream, String fileName)
throws IOException {
File targetFile = null;
if (inputStream != null) {
int read;
byte[] buffer = new byte[8 * 1024];
//自己定义拷贝文件路径
targetFile = new File(context.getExternalCacheDir(), fileName);
if (targetFile.exists()) {
targetFile.delete();
}
OutputStream outputStream = new FileOutputStream(targetFile);
while ((read = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, read);
}
outputStream.flush();
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return targetFile;
}
}

View File

@@ -0,0 +1,80 @@
package cc.winboll.studio.powerbell.views;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.PixelFormat;
public class BatteryDrawable extends Drawable {
public static final String TAG = BatteryDrawable.class.getSimpleName();
// 电量颜色画笔
final Paint mPaint;
// 电量值
int mnValue = 1;
// @int color 电量颜色
//
public BatteryDrawable(int color) {
mPaint = new Paint();
mPaint.setColor(color);
mPaint.setAlpha(210);
}
// 设置电量值
//
public void setValue(int value) {
mnValue = value;
}
@Override
public void draw(Canvas canvas) {
int nWidth = getBounds().width();
int nHeight = getBounds().height();
int mnDx = nHeight / 203;
// 绘制耗电电量提醒值电量
// 能量绘图风格
int nTop;
int nLeft = 0;
int nBottom;
int nRight = nWidth;
//for (int i = 0; i < mnValue; i ++) {
nBottom = nHeight;
nTop = nHeight - (nHeight * mnValue / 100);
canvas.drawRect(new Rect(nLeft, nTop, nRight, nBottom), mPaint);
// 绘制耗电电量提醒值电量
// 意兴阑珊绘图风格
/*int nTop;
int nLeft = 0;
int nBottom;
int nRight = nWidth;
for (int i = 0; i < mnValue; i ++) {
nBottom = (nHeight * (100-i)/100) - mnDx;
nTop = nBottom + mnDx;
canvas.drawRect(new Rect(nLeft, nTop, nRight, nBottom), mPaint);
}*/
}
@Override
public void setColorFilter(ColorFilter colorFilter) {
// This method is required
}
@Override
public void setAlpha(int p1) {
}
@Override
public int getOpacity() {
return PixelFormat.UNKNOWN;
}
}

View File

@@ -0,0 +1,96 @@
package cc.winboll.studio.powerbell.views;
import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.SeekBar;
public class VerticalSeekBar extends SeekBar {
public static final String TAG = VerticalSeekBar.class.getSimpleName();
public volatile int _mnProgress = -1;
public VerticalSeekBar(Context context) {
super(context);
}
public VerticalSeekBar(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public VerticalSeekBar(Context context, AttributeSet attrs) {
super(context, attrs);
// 去除冗余的水平阴影
setBackgroundDrawable(null);
}
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(h, w, oldh, oldw);
}
@Override
protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(heightMeasureSpec, widthMeasureSpec);
setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth());
}
protected void onDraw(Canvas c) {
// 0--------100,顺时针旋转,小在上
// c.rotate(+90);
// c.translate(0, -getWidth());
// 0--------100,逆时针旋转,小在下
c.rotate(-90);
c.translate(-getHeight(), 0);
super.onDraw(c);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
// 调用基类的处理函数
// 该方法可以使得
// SeekBar.OnSeekBarChangeListener
// 的 onStopTrackingTouch 和 onStartTrackingTouch 等函数有效。
boolean handled = super.onTouchEvent(event);
if (handled) {
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_MOVE:
// 0--------100,顺时针旋转,小在上
//_mnProgress = (int)(getMax() * event.getY() / getHeight());
// // 0--------100,逆时针旋转,小在下
_mnProgress = getMax() - (int) (getMax() * event.getY() / getHeight());
_mnProgress = _mnProgress > 100 ? 100 : _mnProgress ;
//LogUtils.d(TAG, "_mnProgress is " + Integer.toString(_mnProgress));
setProgress(_mnProgress);
//onSizeChanged(getWidth(), getHeight(), 0, 0);
break;
case MotionEvent.ACTION_CANCEL:
break;
default :
//LogUtils.d(TAG, "event.getAction() is " + event.getAction());
break;
}
}
return handled;
}
// 解决调用setProgress方法时滑块不跟随的bug
@Override
public synchronized void setProgress(int progress) {
super.setProgress(progress);
onSizeChanged(getWidth(), getHeight(), 0, 0);
}
}

View File

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- 阴影部分 -->
<!-- 个人觉得更形象的表达top代表下边的阴影高度left代表右边的阴影宽度。其实也就是相对应的offsetsolid中的颜色是阴影的颜色也可以设置角度等等 -->
<item
android:left="2dp"
android:top="2dp"
android:right="2dp"
android:bottom="2dp">
<shape android:shape="rectangle" >
<gradient
android:angle="270"
android:endColor="#0F000000"
android:startColor="#0F000000" />
<corners
android:bottomLeftRadius="6dip"
android:bottomRightRadius="6dip"
android:topLeftRadius="6dip"
android:topRightRadius="6dip" />
</shape>
</item>
<!-- 背景部分 -->
<!-- 形象的表达bottom代表背景部分在上边缘超出阴影的高度right代表背景部分在左边超出阴影的宽度相对应的offset -->
<item
android:left="3dp"
android:top="3dp"
android:right="3dp"
android:bottom="5dp">
<shape android:shape="rectangle" >
<gradient
android:angle="270"
android:endColor="#0FFFFFFF"
android:startColor="#FFFFFFFF" />
<corners
android:bottomLeftRadius="6dip"
android:bottomRightRadius="6dip"
android:topLeftRadius="6dip"
android:topRightRadius="6dip" />
</shape>
</item>
</layer-list>

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 642 B

View File

@@ -0,0 +1,20 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:fillColor="#00FFFFFF"
android:strokeColor="#FF000000"
android:strokeWidth="2.0"
android:strokeLineCap="round"
android:strokeMiterLimit="10"
android:pathData="M24.17 5.23C34.61 5.23 43.16 13.78 43.16 24.22 43.16 34.66 34.61 43.2 24.17 43.2 13.73 43.2 5.18 34.66 5.18 24.22 5.18 13.78 13.73 5.23 24.17 5.23"/>
<path
android:fillColor="#00000000"
android:strokeColor="#FF000000"
android:strokeWidth="2.0"
android:strokeLineCap="round"
android:strokeMiterLimit="10"
android:pathData="M25.8 20.4C25.8 20.4 26.6 20.6 26.6 20.6 26.6 20.6 31.92 23.77 31.92 23.77 32.81 24.12 33.39 25.17 33.32 26.3 33.32 26.3 33.32 26.5 33.32 26.5 33.32 26.5 33.32 26.7 33.32 26.7 33.32 26.7 32.17 36.04 32.17 36.04 32.09 36.69 31.85 37.3 31.41 37.73 31.01 38.19 30.49 38.42 29.94 38.42 29.94 38.42 21.18 38.42 21.18 38.42 20.55 38.42 19.98 38.14 19.56 37.61 19.56 37.61 11.93 28.5 11.93 28.5 11.93 28.5 13.07 26.97 13.07 26.97 13.38 26.59 13.86 26.38 14.32 26.41 14.32 26.41 14.69 26.41 14.69 26.41 14.69 26.41 19.75 27.74 19.75 27.74 19.75 27.74 19.75 11.72 19.75 11.72 19.75 10.03 20.89 8.66 22.3 8.66 23.7 8.66 24.85 10.03 24.85 11.72 24.85 11.72 24.85 20.4 24.85 20.4 24.85 20.4 25.8 20.4 25.8 20.4 25.8 20.4 25.8 20.4 25.8 20.4"/>
</vector>

View File

@@ -0,0 +1,27 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#FF009600"
android:strokeColor="#00009D00"
android:strokeWidth="2.0"
android:strokeLineCap="round"
android:strokeMiterLimit="10"
android:pathData="M62.77 11.19C62.67 11.19 62.58 11.19 62.48 11.19 52.61 11.19 39.45 11.19 29.58 11.19 27.65 11.18 27.99 12.03 27.99 14.19 27.99 14.87 27.99 15.78 27.99 16.46 27.99 17.08 27.59 18.51 28.23 18.5 38.1 18.29 51.26 18.5 61.13 18.5 61.4 18.5 62.76 18.7 62.77 17.81 62.8 15.94 62.77 13.44 62.77 11.57 62.77 11.47 62.77 11.35 62.77 11.29 62.77 11.22 62.77 11.2 62.77 11.19M72.1 99.32C72.11 75.14 72.38 42.9 72.1 18.72 72.1 18.07 69.2 18.5 67.63 18.5 53.53 18.5 34.73 18.5 20.63 18.5 20.33 18.5 18.6 18.19 18.66 18.87 19.09 24.3 18.66 31.58 18.66 37.03 18.66 54.74 18.66 78.36 18.66 96.07 18.66 97.05 17.82 99.13 18.81 99.32 20.19 99.59 22.1 99.32 23.51 99.32 37.97 99.32 57.24 99.32 71.69 99.32 71.79 99.32 71.91 99.32 71.98 99.32 72.05 99.32 72.08 99.32 72.1 99.32"/>
<path
android:fillColor="#FFFFFFFF"
android:strokeColor="#FF000000"
android:strokeWidth="2.0"
android:strokeLineCap="round"
android:strokeMiterLimit="10"
android:pathData="M95.69 46.15C95.69 46.06 95.69 45.96 95.68 45.87 95.62 42.18 93.47 32.14 79.53 27.34 78.29 26.91 75.48 25.94 70.99 25.58 57.33 24.5 41.98 31.96 40.58 44.42 40.29 47.08 40.58 50.91 43.06 54.84 43.67 55.81 42.82 56.28 41.94 58.72 40.03 64.07 45.17 66.64 54.03 67.28 60.63 67.77 64.55 67.28 71.29 66.69 73.45 66.5 76.23 66.12 79.77 64.87 86.98 62.33 95.34 56.16 95.68 46.7 95.68 46.6 95.68 46.51 95.68 46.42 95.69 46.33 95.69 46.24 95.69 46.15"/>
<path
android:fillColor="#00FFFFFF"
android:strokeColor="#FF000000"
android:strokeWidth="2.0"
android:strokeLineCap="round"
android:strokeMiterLimit="10"
android:pathData="M241.47 177.43C241.47 177.43 241.47 177.43 241.47 177.43 241.47 177.43 241.47 177.43 241.47 177.43"/>
</vector>

View File

@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#FF009DCB"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:clickable="true">
<item android:drawable="@drawable/ic_launcher_background"/>
<item
android:left="0dp"
android:top="0dp"
android:right="0dp"
android:bottom="0dp"
android:drawable="@drawable/ic_launcher"/>
</layer-list>

Binary file not shown.

After

Width:  |  Height:  |  Size: 434 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<cc.winboll.studio.libaes.views.AToolbar
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:id="@+id/toolbar"
style="@style/DefaultAToolbar"/>
<cc.winboll.studio.shared.view.AboutView
app:appname="PowerBell"
app:appprojectname="PowerBell"
app:appdescription="@string/app_description"
app:appicon="@drawable/ic_launcher"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/activityaboutAboutView1"/>
</LinearLayout>

View File

@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<cc.winboll.studio.libaes.views.AToolbar
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:id="@+id/toolbar"
style="@style/DefaultAToolbar"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/activitybackgroundpictureImageView1"
android:layout_below="@id/toolbar">
</ImageView>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/toolbar">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right">
<cc.winboll.studio.libaes.views.AButton
android:layout_width="180dp"
android:layout_height="36dp"
android:text="Origin BG"
android:layout_gravity="center_vertical"
android:layout_margin="10dp"
android:id="@+id/activitybackgroundpictureAButton5"/>
<cc.winboll.studio.libaes.views.AButton
android:layout_width="180dp"
android:layout_height="36dp"
android:text="Received BG"
android:layout_gravity="center_vertical"
android:layout_margin="10dp"
android:id="@+id/activitybackgroundpictureAButton4"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right">
<cc.winboll.studio.libaes.views.AButton
android:layout_width="50dp"
android:layout_height="36dp"
android:text="◎"
android:layout_gravity="center_vertical"
android:layout_margin="10dp"
android:id="@+id/activitybackgroundpictureAButton1"/>
<cc.winboll.studio.libaes.views.AButton
android:layout_width="50dp"
android:layout_height="36dp"
android:text="☑"
android:layout_gravity="center_vertical"
android:layout_margin="10dp"
android:id="@+id/activitybackgroundpictureAButton2"/>
<cc.winboll.studio.libaes.views.AButton
android:layout_width="50dp"
android:layout_height="36dp"
android:text="[+]"
android:layout_gravity="center_vertical"
android:layout_margin="10dp"
android:id="@+id/activitybackgroundpictureAButton3"/>
<cc.winboll.studio.libaes.views.AButton
android:layout_width="50dp"
android:layout_height="36dp"
android:text="[+~]"
android:layout_gravity="center_vertical"
android:layout_margin="10dp"
android:id="@+id/activitybackgroundpictureAButton6"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>

View File

@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<cc.winboll.studio.libaes.views.AToolbar
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:id="@+id/toolbar"
style="@style/DefaultAToolbar"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="30dp">
<cc.winboll.studio.libaes.views.AOHPCTCSeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/activityclearrecordAOHPCTCSeekBar1"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/activityclearrecordTextView1"
android:gravity="center_horizontal"
android:layout_gravity="center_horizontal"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="10dp"
android:layout_weight="1.0"
android:background="@drawable/bg_frame">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Record Text"
android:textStyle="bold"
android:gravity="center_horizontal"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.0"
android:padding="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="@dimen/text_content_size"
android:id="@+id/activityclearrecordTextView2"/>
</ScrollView>
</LinearLayout>
</LinearLayout>

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<cc.winboll.studio.libaes.views.AToolbar
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:id="@+id/toolbar"
android:gravity="center_vertical"
style="@style/DefaultAToolbar"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/activitymainFrameLayout1"/>
</LinearLayout>
<cc.winboll.studio.shared.log.LogView
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="100dp"
android:id="@+id/logview"/>
</LinearLayout>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text"
android:id="@+id/activityunbelievableTextView1"
android:padding="10dp"
android:textIsSelectable="true"/>
</ScrollView>
</LinearLayout>

View File

@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="300dp"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:background="#FF1FD3CE">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="是否使用下列图片作为应用背景图?"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:id="@+id/dialogbackgroundpicturepreviewImageView1"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:gravity="right">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"
android:id="@+id/dialogbackgroundpicturepreviewButton1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="OK"
android:id="@+id/dialogbackgroundpicturepreviewButton2"/>
</LinearLayout>
</LinearLayout>

View File

@@ -0,0 +1,211 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/fragmentmainviewImageView1">
</ImageView>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/fragmentmainviewLinearLayout3"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:background="@drawable/bg_frame">
<Switch
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/fragmentandroidviewSwitch1"
android:padding="10dp"
android:layout_weight="1.0"
android:textSize="@dimen/text_title_size"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Tips"
android:textSize="@dimen/text_content_size"
android:id="@+id/fragmentandroidviewTextView1"
android:background="@drawable/bg_frame"
android:padding="10dp"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.0">
<LinearLayout
android:orientation="vertical"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:id="@+id/fragmentmainviewLinearLayout1">
<ImageView
android:layout_width="36dp"
android:layout_height="36dp"
android:background="@drawable/usege"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:id="@+id/fragmentmainviewCheckBox2"/>
<cc.winboll.studio.powerbell.views.VerticalSeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/fragmentandroidviewVerticalSeekBar2"
android:progressTint="@color/colorUsege"
android:progressBackgroundTint="@color/colorUsege"
android:layout_weight="1.0"
android:layout_margin="10dp"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="80dp"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="100%"
android:textSize="@dimen/text_title_size"
android:layout_gravity="center_horizontal"
android:id="@+id/fragmentandroidviewTextView3"
android:gravity="center_horizontal"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/fragmentandroidviewImageView2"
android:layout_weight="1.0"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1.0">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="100%"
android:textSize="@dimen/text_title_size"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:id="@+id/fragmentandroidviewTextView4"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/fragmentandroidviewImageView1"
android:layout_weight="1.0"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="80dp"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="100%"
android:textSize="@dimen/text_title_size"
android:layout_gravity="center_horizontal"
android:id="@+id/fragmentandroidviewTextView2"
android:gravity="center_horizontal"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/fragmentandroidviewImageView3"
android:layout_weight="1.0"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"
android:id="@+id/fragmentmainviewLinearLayout2">
<ImageView
android:layout_width="36dp"
android:layout_height="36dp"
android:background="@drawable/charge"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:id="@+id/fragmentmainviewCheckBox1"/>
<cc.winboll.studio.powerbell.views.VerticalSeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/fragmentandroidviewVerticalSeekBar1"
android:progressTint="@color/colorCharge"
android:progressBackgroundTint="@color/colorCharge"
android:layout_weight="1.0"
android:layout_margin="10dp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>

View File

@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/remoteviewLinearLayout1">
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:id="@+id/remoteviewImageView1"
android:layout_gravity="center_vertical"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Title"
android:textSize="@dimen/text_title_size"
android:textStyle="bold"
android:id="@+id/viewremindnotificationTextView1"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="@color/colorUsege"
android:background="@color/colorUsege"
android:id="@+id/remoteviewUsege"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
android:id="@+id/remoteviewCharge"
android:textColor="@color/colorCharge"
android:background="@color/colorCharge"/>
</LinearLayout>
</LinearLayout>

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/remoteviewLinearLayout1">
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:id="@+id/remoteviewImageView1"
android:layout_gravity="center_vertical"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text"
android:textSize="@dimen/text_title_size"
android:id="@+id/remoteviewTextView1"
android:textStyle="bold"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text"
android:textSize="@dimen/text_content_size"
android:id="@+id/remoteviewTextView3"/>
</LinearLayout>
</LinearLayout>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/action_clearrecord"
android:title="@string/item_clearrecord"/>
<item
android:id="@+id/action_changepicture"
android:title="@string/item_changepicture"/>
<item
android:id="@+id/action_about"
android:title="@string/item_aboutview"/>
</menu>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">能源钟</string>
<string name="app_description">手机电量变化铃声提醒应用。</string>
<string name="about_crashed">本应用崩溃了,作者水平有限,敬请谅解!</string>
<string name="item_mainview">Main View</string>
<string name="item_aboutview">About</string>
<string name="item_clearrecord">Clear Record</string>
<string name="item_changepicture">Change Picture</string>
<string name="item_devoloperoptionsview">Developer View</string>
<string name="item_logview">Log View</string>
<string name="item_sourceview">Source View</string>
<string name="txt_aboveswitch">消息总开关</string>
<string name="txt_aboveswitchtips">当电量低于左边(放电状态)或高于右边(充电状态),就会发送一个提醒铃声。</string>
<string name="texthint_CustomSlideToCleanRecord">Slide Right To Clean Up APP Record.</string>
<string name="subtitle_activity_clearrecord">清理记录</string>
<string name="subtitle_activity_backgroundpicture">更换背景图片</string>
<string name="subtitle_activity_about">关于应用</string>
<string name="msg_AOHPCTCSeekBar_ClearRecord">&gt;&gt;&gt;Seek 100% To Clear Battery Record.&gt;&gt;&gt;</string>
</resources>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="appTheme" format="reference"/>
<declare-styleable name="AToolbar">
<attr name="attrAToolbarStartColor" format="color" />
<attr name="attrAToolbarCenterColor" format="color" />
<attr name="attrAToolbarEndColor" format="color" />
</declare-styleable>
</resources>

View File

@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--
<color name="colorPrimary">@color/colorShui</color>
<color name="colorPrimaryDark">@color/colorXinling</color>
<color name="colorAccent">@color/colorShui</color>
-->
<!-- 地球超人主题配置方案 -->
<!--
我们的大地神盖亚已经无法忍受世界的环境污染恐怕会毁了地球,
她把五个拥有巨大魔力的戒指给了五大洲的五个特殊中学生:
非洲的夸美,拥有土地的威力;
北美的辉乐,拥有火的威力;
苏联的琳卡,拥有风的威力;
亚洲的姬伊,拥有水的威力;
南美的玛狄,拥有心灵的威力。
五个中学生的威力联合起来,就能唤来最伟大的地球超人!
地球超人!力量是你们的!
引用:(360百科) https://m.baike.so.com/doc/2093525-2214593.html
-->
<color name="colorTudi">#FF05CF00</color>
<color name="colorHuo">#FFC61414</color>
<color name="colorFeng">#FFDEDEDE</color>
<color name="colorShui">#FF009ADE</color>
<color name="colorShuiDark">#FF0072A4</color>
<color name="colorShuiAccent">#FF33C1FF</color>
<color name="colorXinling">#FFFCC500</color>
<color name="colorPrimary">@color/colorShui</color>
<color name="colorPrimaryDark">@color/colorFeng</color>
<color name="colorAccent">@color/colorShui</color>
<color name="colorYellow">#FFFFFF00</color>
<color name="colorRed">#FFFF0000</color>
<color name="colorBlue">#FF000FFF</color>
<color name="colorBlack">#FF000000</color>
<color name="colorUsege">@color/colorHuo</color>
<color name="colorCurrent">@color/colorShui</color>
<color name="colorCharge">@color/colorXinling</color>
<!-- 调试配置
<color name="colorYellow">#FF630066</color>
<color name="colorRed">#FF23244D</color>
<color name="colorBlue">#FF00E2F7</color>
<color name="colorBlack">#FF54FF00</color>
-->
<!-- 明色配置
<color name="colorYellow">#FFFFBD00</color>
<color name="colorRed">#FFE00000</color>
<color name="colorBlue">#FF000DE5</color>
<color name="colorBlack">#FF000000</color>
-->
<!-- 原色配置
<color name="colorYellow">#FFFFFF00</color>
<color name="colorRed">#FFFF0000</color>
<color name="colorBlue">#FF000FFF</color>
<color name="colorBlack">#FF000000</color>
<color name="colorUsege">@color/colorRed</color>
<color name="colorCurrent">@color/colorBlue</color>
<color name="colorCharge">@color/colorYellow</color>
-->
<!--CustomSlideToUnlockView控件配置-->
<color name="colorCustomSlideToUnlockViewWhite">#FFFFFFFF</color>
<!---->
</resources>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="toolbar_height">60dp</dimen>
<dimen name="slide_width">76dp</dimen>
<dimen name="text_content_size">18dp</dimen>
<dimen name="text_title_size">24dp</dimen>
<dimen name="text_subtitle_size">16dp</dimen>
</resources>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">PowerBell</string>
<string name="app_projectname">PowerBell</string>
<string name="app_description">Mobile phone power change ringtone alert app.</string>
<string name="about_crashed">This application has crashed, the author level is limited, please understand!</string>
<string name="item_mainview">Main View</string>
<string name="item_aboutview">About</string>
<string name="item_clearrecord">Clear Record</string>
<string name="item_changepicture">Change Picture</string>
<string name="item_devoloperoptionsview">Developer View</string>
<string name="item_logview">Log View</string>
<string name="item_cleanlog">Clean Log</string>
<string name="item_sourceview">Source View</string>
<string name="txt_aboveswitch">Message master switch</string>
<string name="txt_aboveswitchtips">Send a remind ringtone, when power is lower than left (usage state) or higher than right (charged state).</string>
<string name="texthint_CustomSlideToCleanRecord">Slide Right To Clean Up APP Record.</string>
<string name="subtitle_activity_clearrecord">Clean Record</string>
<string name="subtitle_activity_backgroundpicture">Background Picture</string>
<string name="subtitle_activity_about">About The APP</string>
<string name="msg_AOHPCTCSeekBar_ClearRecord">&gt;&gt;&gt;Seek 100% To Clear Battery Record.&gt;&gt;&gt;</string>
</resources>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme_Base" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
<!-- Customize your theme here. -->
</style>
<style name="AppTheme_Default" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textSize">@dimen/text_content_size</item>
</style>
<style name="DefaultAToolbar">
<item name="attrAToolbarStartColor">@color/colorShuiDark</item>
<item name="attrAToolbarCenterColor">@color/colorShui</item>
<item name="attrAToolbarEndColor">@color/colorShuiAccent</item>
</style>
<!-- 设置Toolbar标题字体的大小 -->
<style name="Toolbar.TitleText" parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
<item name="android:textSize">@dimen/text_title_size</item>
</style>
<style name="Toolbar.SubTitleText" parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
<item name="android:textSize">@dimen/text_subtitle_size</item>
</style>
</resources>

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path
name="external_storage_root"
path="." />
<files-path
name="files_path"
path="." />
<cache-path
name="cache_path"
path="." />
<!--/storage/emulated/0/Android/data/...-->
<external-files-path
name="external_file_path"
path="." />
<!--代表app 外部存储区域根目录下的文件 Context.getExternalCacheDir目录下的目录-->
<external-cache-path
name="external_cache_path"
path="." />
<!--配置root-path。这样子可以读取到sd卡和一些应用分身的目录否则微信分身保存的图片就会导致 java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/emulated/999/tencent/MicroMsg/WeiXin/export1544062754693.jpg在小米6的手机上微信分身有这个crash华为没有
-->
<root-path
name="root_path"
path="" />
</paths>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" >
<application>
<!-- Put flavor specific code here -->
<provider
tools:replace="android:authorities"
android:name="androidx.core.content.FileProvider"
android:authorities="cc.winboll.studio.powerbell.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
tools:replace="android:resource"
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_provider"/>
</provider>
</application>
</manifest>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Put flavor specific strings here -->
</resources>