android一键清除最近应用按钮
来源:互联网 发布:笔记本wifi搜不到网络 编辑:程序博客网 时间:2024/05/16 10:14
diff --git a/packages/SystemUI/res/layout-land/status_bar_recent_panel.xml b/packages/SystemUI/res/layout-land/status_bar_recent_panel.xml
index 0c0be29..2675a4c 100644
--- a/packages/SystemUI/res/layout-land/status_bar_recent_panel.xml
+++ b/packages/SystemUI/res/layout-land/status_bar_recent_panel.xml
@@ -57,6 +57,15 @@
</FrameLayout>
+ <Button
+ android:text="@string/one_key_clean"
+ android:id = "@+id/one_key_clear"
+ android:layout_alignParentBottom="true"
+ android:layout_marginTop="450dp"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+
<include layout="@layout/status_bar_no_recent_apps"
android:id="@+id/recents_no_apps"
android:layout_width="match_parent"
diff --git a/packages/SystemUI/res/layout/status_bar_recent_panel.xml b/packages/SystemUI/res/layout/status_bar_recent_panel.xml
index 2f3968d..9665268 100644
--- a/packages/SystemUI/res/layout/status_bar_recent_panel.xml
+++ b/packages/SystemUI/res/layout/status_bar_recent_panel.xml
@@ -32,6 +32,7 @@
android:background="@drawable/status_bar_recents_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:layout_marginBottom="130dp"
android:layout_alignParentBottom="true">
<com.android.systemui.recent.RecentsVerticalScrollView
@@ -59,7 +60,15 @@
</com.android.systemui.recent.RecentsVerticalScrollView>
- </FrameLayout>
+ </FrameLayout>
+
+ <Button
+ android:text="@string/one_key_clean"
+ android:id = "@+id/one_key_clear"
+ android:layout_alignParentBottom="true"
+ android:layout_marginTop="880dp"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
<include layout="@layout/status_bar_no_recent_apps"
android:id="@+id/recents_no_apps"
diff --git a/packages/SystemUI/res/values-in/strings.xml b/packages/SystemUI/res/values-in/strings.xml
index 0893599..f55816c 100644
--- a/packages/SystemUI/res/values-in/strings.xml
+++ b/packages/SystemUI/res/values-in/strings.xml
@@ -20,6 +20,8 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="7164937344850004466">"Sistem UI"</string>
+ <string name="one_key_clean">Kunci untuk menghapus</string>
+ <string name="cleaning">jelas dalam ...</string>
<string name="status_bar_clear_all_button" msgid="7774721344716731603">"Bersihkan"</string>
<string name="status_bar_recent_remove_item_title" msgid="6026395868129852968">"Hapus dari daftar"</string>
<string name="status_bar_recent_inspect_item_title" msgid="7793624864528818569">"Info apl"</string>
diff --git a/packages/SystemUI/res/values-zh-rCN/strings.xml b/packages/SystemUI/res/values-zh-rCN/strings.xml
index 8b4ac30..0eff18c 100755
--- a/packages/SystemUI/res/values-zh-rCN/strings.xml
+++ b/packages/SystemUI/res/values-zh-rCN/strings.xml
@@ -20,6 +20,8 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="7164937344850004466">"系统用户界面"</string>
+ <string name="one_key_clean">一键清除</string>
+ <string name="cleaning">清除中 ...</string>
<string name="status_bar_clear_all_button" msgid="7774721344716731603">"清除"</string>
<string name="status_bar_recent_remove_item_title" msgid="6026395868129852968">"从列表中删除"</string>
<string name="status_bar_recent_inspect_item_title" msgid="7793624864528818569">"应用信息"</string>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 371f1ab..59d3e67 100755
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -19,6 +19,8 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Name of the status bar as seen in the applications info settings page. [CHAR LIMIT=12] -->
<string name="app_label">System UI</string>
+ <string name="one_key_clean">Clean all</string>
+ <string name="cleaning">Cleaning up ...</string>
<!-- The text for the button in the notification window-shade that clears
all of the currently visible notifications. [CHAR LIMIT=10]-->
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java
index 09a7a5e..c55ab52 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java
@@ -28,6 +28,10 @@ import android.os.UserHandle;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
+import android.util.Log;
+import android.widget.Button;
+import android.os.Handler;
+import android.os.Message;
import com.android.systemui.R;
import com.android.systemui.statusbar.StatusBarPanel;
@@ -175,11 +179,35 @@ public class RecentsActivity extends Activity {
finish();
}
+ private Handler mHandler=new Handler(){
+ @Override
+ public void handleMessage(Message msg) {
+ finish();
+ }
+ };
+
+
@Override
protected void onCreate(Bundle savedInstanceState) {
getWindow().addPrivateFlags(
WindowManager.LayoutParams.PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR);
setContentView(R.layout.status_bar_recent_panel);
+
+ final Button button=(Button) findViewById(R.id.one_key_clear);
+ button.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ RecentsPanelView recentsPanelView=new RecentsPanelView(RecentsActivity.this,null,0);
+ recentsPanelView.delAllRecentTask(RecentsActivity.this);
+ button.setText(getResources().getString(R.string.cleaning));
+ mHandler.sendEmptyMessageDelayed(0,500);
+
+ }
+ });
+
+
+
+
mRecentsPanel = (RecentsPanelView) findViewById(R.id.recents_root);
mRecentsPanel.setOnTouchListener(new TouchOutsideListener(mRecentsPanel));
mRecentsPanel.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
index 788e843..f14b975 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
@@ -810,4 +810,27 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
}
mRecentsContainer.drawFadedEdges(canvas, left, right, top, bottom);
}
+
+
+ public void delAllRecentTask(Context context){
+
+ final ActivityManager am =(ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
+
+ mRecentTaskDescriptions = new ArrayList<TaskDescription>();
+ mRecentTaskDescriptions=mRecentTasksLoader.getLoadedTasks();
+ if(mRecentTaskDescriptions!=null){
+
+ if (am != null) {
+ for(TaskDescription recent :mRecentTaskDescriptions){
+ am.removeTask(recent.persistentTaskId, ActivityManager.REMOVE_TASK_KILL_PROCESS);
+ setContentDescription(mContext.getString(R.string.accessibility_recents_item_dismissed, recent.getLabel()));
+ sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
+ setContentDescription(null);
+ }
+ dismissAndGoBack();
+ }
+
+ }
+ }
+
}
index 0c0be29..2675a4c 100644
--- a/packages/SystemUI/res/layout-land/status_bar_recent_panel.xml
+++ b/packages/SystemUI/res/layout-land/status_bar_recent_panel.xml
@@ -57,6 +57,15 @@
</FrameLayout>
+ <Button
+ android:text="@string/one_key_clean"
+ android:id = "@+id/one_key_clear"
+ android:layout_alignParentBottom="true"
+ android:layout_marginTop="450dp"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+
<include layout="@layout/status_bar_no_recent_apps"
android:id="@+id/recents_no_apps"
android:layout_width="match_parent"
diff --git a/packages/SystemUI/res/layout/status_bar_recent_panel.xml b/packages/SystemUI/res/layout/status_bar_recent_panel.xml
index 2f3968d..9665268 100644
--- a/packages/SystemUI/res/layout/status_bar_recent_panel.xml
+++ b/packages/SystemUI/res/layout/status_bar_recent_panel.xml
@@ -32,6 +32,7 @@
android:background="@drawable/status_bar_recents_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:layout_marginBottom="130dp"
android:layout_alignParentBottom="true">
<com.android.systemui.recent.RecentsVerticalScrollView
@@ -59,7 +60,15 @@
</com.android.systemui.recent.RecentsVerticalScrollView>
- </FrameLayout>
+ </FrameLayout>
+
+ <Button
+ android:text="@string/one_key_clean"
+ android:id = "@+id/one_key_clear"
+ android:layout_alignParentBottom="true"
+ android:layout_marginTop="880dp"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
<include layout="@layout/status_bar_no_recent_apps"
android:id="@+id/recents_no_apps"
diff --git a/packages/SystemUI/res/values-in/strings.xml b/packages/SystemUI/res/values-in/strings.xml
index 0893599..f55816c 100644
--- a/packages/SystemUI/res/values-in/strings.xml
+++ b/packages/SystemUI/res/values-in/strings.xml
@@ -20,6 +20,8 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="7164937344850004466">"Sistem UI"</string>
+ <string name="one_key_clean">Kunci untuk menghapus</string>
+ <string name="cleaning">jelas dalam ...</string>
<string name="status_bar_clear_all_button" msgid="7774721344716731603">"Bersihkan"</string>
<string name="status_bar_recent_remove_item_title" msgid="6026395868129852968">"Hapus dari daftar"</string>
<string name="status_bar_recent_inspect_item_title" msgid="7793624864528818569">"Info apl"</string>
diff --git a/packages/SystemUI/res/values-zh-rCN/strings.xml b/packages/SystemUI/res/values-zh-rCN/strings.xml
index 8b4ac30..0eff18c 100755
--- a/packages/SystemUI/res/values-zh-rCN/strings.xml
+++ b/packages/SystemUI/res/values-zh-rCN/strings.xml
@@ -20,6 +20,8 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="7164937344850004466">"系统用户界面"</string>
+ <string name="one_key_clean">一键清除</string>
+ <string name="cleaning">清除中 ...</string>
<string name="status_bar_clear_all_button" msgid="7774721344716731603">"清除"</string>
<string name="status_bar_recent_remove_item_title" msgid="6026395868129852968">"从列表中删除"</string>
<string name="status_bar_recent_inspect_item_title" msgid="7793624864528818569">"应用信息"</string>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 371f1ab..59d3e67 100755
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -19,6 +19,8 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Name of the status bar as seen in the applications info settings page. [CHAR LIMIT=12] -->
<string name="app_label">System UI</string>
+ <string name="one_key_clean">Clean all</string>
+ <string name="cleaning">Cleaning up ...</string>
<!-- The text for the button in the notification window-shade that clears
all of the currently visible notifications. [CHAR LIMIT=10]-->
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java
index 09a7a5e..c55ab52 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java
@@ -28,6 +28,10 @@ import android.os.UserHandle;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
+import android.util.Log;
+import android.widget.Button;
+import android.os.Handler;
+import android.os.Message;
import com.android.systemui.R;
import com.android.systemui.statusbar.StatusBarPanel;
@@ -175,11 +179,35 @@ public class RecentsActivity extends Activity {
finish();
}
+ private Handler mHandler=new Handler(){
+ @Override
+ public void handleMessage(Message msg) {
+ finish();
+ }
+ };
+
+
@Override
protected void onCreate(Bundle savedInstanceState) {
getWindow().addPrivateFlags(
WindowManager.LayoutParams.PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR);
setContentView(R.layout.status_bar_recent_panel);
+
+ final Button button=(Button) findViewById(R.id.one_key_clear);
+ button.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ RecentsPanelView recentsPanelView=new RecentsPanelView(RecentsActivity.this,null,0);
+ recentsPanelView.delAllRecentTask(RecentsActivity.this);
+ button.setText(getResources().getString(R.string.cleaning));
+ mHandler.sendEmptyMessageDelayed(0,500);
+
+ }
+ });
+
+
+
+
mRecentsPanel = (RecentsPanelView) findViewById(R.id.recents_root);
mRecentsPanel.setOnTouchListener(new TouchOutsideListener(mRecentsPanel));
mRecentsPanel.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
index 788e843..f14b975 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
@@ -810,4 +810,27 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
}
mRecentsContainer.drawFadedEdges(canvas, left, right, top, bottom);
}
+
+
+ public void delAllRecentTask(Context context){
+
+ final ActivityManager am =(ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
+
+ mRecentTaskDescriptions = new ArrayList<TaskDescription>();
+ mRecentTaskDescriptions=mRecentTasksLoader.getLoadedTasks();
+ if(mRecentTaskDescriptions!=null){
+
+ if (am != null) {
+ for(TaskDescription recent :mRecentTaskDescriptions){
+ am.removeTask(recent.persistentTaskId, ActivityManager.REMOVE_TASK_KILL_PROCESS);
+ setContentDescription(mContext.getString(R.string.accessibility_recents_item_dismissed, recent.getLabel()));
+ sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
+ setContentDescription(null);
+ }
+ dismissAndGoBack();
+ }
+
+ }
+ }
+
}
阅读全文
1 0
- android一键清除最近应用按钮
- 笔记:android4.3 添加清除最近使用应用按钮
- android N 最近任务的 全部清除按钮不隐藏
- Android一键清除某个应用下的数据
- Android一键清除其他应用缓存数据,有没有什么好方法?【已解决】
- Android一键清除其他应用缓存数据,有没有什么好方法?
- Android清除数据、清除缓存、一键清理的区别
- Android 清除应用缓存
- Android清除应用缓存
- android studio 一键清除无用资源
- Android带清除按钮的EditText
- Android带清除按钮的文本框
- Android输入框中加入清除按钮
- 19.Android 清除按钮EditText - AIEditText
- Android AutoCompleteTextView 增加删除按钮清除内容
- Android 自定义带有清除按钮的Edittext
- Android 清除指定应用缓存
- android 清除应用的缓存
- 硕士生预答辩中存在的共性问题
- Lua_ uLua_C#调用Lua方法_019
- js实现表格的增删改查
- 关联容器------map与pair的使用
- Idea导出jar包
- android一键清除最近应用按钮
- 哈哈日语养成十个习惯让你“疯狂说日语”
- Android样式的开发:View Animation篇
- C语言开发中应该注意的一些问题
- C中表达式语句以及副作用和++,--的有关问题
- 自定义View:Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context,
- lcs 51nod 1006 最长公共子序列Lcs
- QQ空间打不开怎么办
- MySQL分析SQL耗时瓶颈