提交 bdc7c4c8 编写于 作者: 奶油话梅糖's avatar 奶油话梅糖 🎨

首次提交

上级 b89994f0
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>DKLauncherDemo</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.source=1.6
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.dklauncherdemo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="17" />
<!-- 程序自启动权限 -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.dklauncherdemo.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop" >
<intent-filter>
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- 程序自启动广播 -->
<receiver
android:name=".MyReceiver"
android:enabled="true"
android:exported="true" >
<intent-filter android:priority="1000" >
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>
\ No newline at end of file
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# 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 *;
#}
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-17
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="top|center_vertical|center_horizontal"
android:orientation="vertical" >
<TextView
android:id="@+id/tv_batterLevel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10sp"
android:gravity="center_vertical|center_horizontal"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="bottom|center_vertical|center_horizontal"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="bottom|center_vertical|center_horizontal"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="bottom|center_vertical|center_horizontal"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="bottom|center_vertical|center_horizontal"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="bottom|center_vertical|center_horizontal"
android:orientation="vertical" >
<ImageView
android:id="@+id/iv_setting"
android:layout_width="60sp"
android:layout_height="60sp"
android:layout_margin="10sp"
android:src="@drawable/menu_setting" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="2sp"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/linearLayout1"
android:background="#000" />
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
\ No newline at end of file
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/menu_settings"/>
</menu>
\ No newline at end of file
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>
\ No newline at end of file
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">DKLauncherDemo</string>
<string name="hello_world">Hello world!</string>
<string name="menu_settings">Settings</string>
</resources>
\ No newline at end of file
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
\ No newline at end of file
package com.example.dklauncherdemo;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.BatteryManager;
import android.os.Bundle;
import android.view.KeyEvent;
import android.widget.PopupWindow;
import android.widget.TextView;
import com.example.dklauncherdemo.toast.DiyToast;
/**
* @author Administrator
* @year 2019
* @Todo TODO 桌面主页
* @package_name com.example.dklauncherdemo
* @project_name DKLauncherDemo
* @file_name MainActivity.java
* @我的博客 https://naiyouhuameitang.club/
*/
public class MainActivity extends Activity {
private PopupWindow mPopupWindow;
private TextView batterLevel;
private BroadcastReceiver batteryLevelRcvr;
private IntentFilter batteryLevelFilter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
monitorBatteryState();
}
private void initView() {
// TODO Auto-generated method stub
batterLevel = (TextView) findViewById(R.id.tv_batterLevel);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if (keyCode == KeyEvent.KEYCODE_BACK) {
DiyToast.showToast(getApplicationContext(), "你已经在桌面了");
return false;
}
if (keyCode == KeyEvent.KEYCODE_HOME) {
DiyToast.showToast(getApplicationContext(), "你已经在桌面了");
return false;
}
return super.onKeyDown(keyCode, event);
}
@Override
protected void onDestroy() {
super.onDestroy();
unregisterReceiver(batteryLevelRcvr);
}
private void monitorBatteryState() {
batteryLevelRcvr = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
StringBuilder sb = new StringBuilder();
int rawlevel = intent.getIntExtra("level", -1);
int scale = intent.getIntExtra("scale", -1);
int status = intent.getIntExtra("status", -1);
int health = intent.getIntExtra("health", -1);
int level = -1; // percentage, or -1 for unknown
if (rawlevel >= 0 && scale > 0) {
level = (rawlevel * 100) / scale;
}
if (BatteryManager.BATTERY_HEALTH_OVERHEAT == health) {
sb.append("'s battery feels very hot!");
} else {
switch (status) {
case BatteryManager.BATTERY_STATUS_UNKNOWN:
sb.append("未找到电池.");
break;
case BatteryManager.BATTERY_STATUS_CHARGING:
if (level <= 33)
sb.append("充电中" + "\n" + "电池电量低" + "\n" + "["
+ level + "]");
else if (level <= 84)
sb.append(" 充电中." + "\n" + "[" + level + "]");
else
sb.append("即将充满." + "\n" + "[" + level + "]");
break;
case BatteryManager.BATTERY_STATUS_DISCHARGING:
case BatteryManager.BATTERY_STATUS_NOT_CHARGING:
if (level == 0)
sb.append("急需充电.");
else if (level > 0 && level <= 33)
sb.append("低电量." + "\n" + "[" + level + "]");
else
sb.append("当前电量." + "\n" + "[" + level + "]");
break;
case BatteryManager.BATTERY_STATUS_FULL:
sb.append(" is fully charged.");
break;
default:
sb.append("'s battery is indescribable!");
break;
}
}
sb.append(' ');
batterLevel.setText(sb.toString());
}
};
batteryLevelFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
registerReceiver(batteryLevelRcvr, batteryLevelFilter);
}
}
\ No newline at end of file
package com.example.dklauncherdemo;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
/**
* @author Administrator
* @year 2019
* @Todo TODO
* @package_name com.example.dklauncherdemo
* @project_name DKLauncherDemo
* @file_name MyReceiver.java
* @ҵIJ https://naiyouhuameitang.club/
*/
public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
Intent i = new Intent(context, MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
}
\ No newline at end of file
package com.example.dklauncherdemo.toast;
import android.content.Context;
import android.widget.Toast;
/**
* @author Administrator
* @year 2019
* @Todo TODO ԶToast
* @package_name com.example.dklauncherdemo.toast
* @project_name DKLauncherDemo
* @file_name DiyToast.java
* @ҵIJ https://naiyouhuameitang.club/
*/
public class DiyToast {
private static Toast toast;
public static void showToast(Context context, String string) {
if (toast == null) {
toast = Toast.makeText(context, string, Toast.LENGTH_SHORT);
} else {
toast.setText(string);
}
toast.show();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册