提交 9b04c52e 编写于 作者: A andrewleo

Added: add button to refresh application list in main page

上级 b452b105
res/drawable-hdpi/settings.png

3.5 KB | W: | H:

res/drawable-hdpi/settings.png

1.7 KB | W: | H:

res/drawable-hdpi/settings.png
res/drawable-hdpi/settings.png
res/drawable-hdpi/settings.png
res/drawable-hdpi/settings.png
  • 2-up
  • Swipe
  • Onion skin
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/settings_pressed" android:state_pressed="true"/>
<item android:drawable="@drawable/settings_pressed" android:state_focused="true"/>
<item android:drawable="@drawable/settings"></item>
</selector>
......@@ -18,7 +18,7 @@
android:id="@+id/go_back"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/btn_back" />
android:src="@drawable/left_arrow" />
</LinearLayout>
<TextView
......@@ -38,7 +38,7 @@
android:layout_height="match_parent"
android:layout_weight="0.1"
android:gravity="center_horizontal|center_vertical" >
<ImageView
android:id="@+id/btn_set"
android:layout_width="wrap_content"
......
......@@ -86,4 +86,6 @@
<string name="root_failed_notification">无法获取root权限,请确认手机是否已root</string>
<string name="stop_when_exited">应用退出后停止监听</string>
<string name="update_list">列表更新成功</string>
</resources>
......@@ -20,7 +20,7 @@
<dimen name="button_height">40dp</dimen>
<dimen name="image_padding">10dp</dimen>
<dimen name="image_padding_small">5dp</dimen>
<dimen name="image_padding_small">10dp</dimen>
<dimen name="line_height">1px</dimen>
......
......@@ -85,4 +85,6 @@
<string name="root_notification">(root is necessary)</string>
<string name="root_failed_notification">Fail to get root permission, please check if this phone is rooted</string>
<string name="stop_when_exited">Stop monitoring when app exited</string>
<string name="update_list">Update List Successfully</string>
</resources>
......@@ -72,6 +72,7 @@ public class MainPageActivity extends Activity {
private ImageView ivBtnSet;
private LinearLayout layBtnSet;
private Long mExitTime = (long) 0;
private ListAdapter la;
@Override
public void onCreate(Bundle savedInstanceState) {
......@@ -128,7 +129,9 @@ public class MainPageActivity extends Activity {
}
}
});
lstViProgramme.setAdapter(new ListAdapter());
la = new ListAdapter(processInfo.getAllPackages(getBaseContext()));
lstViProgramme.setAdapter(la);
lstViProgramme.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
......@@ -138,7 +141,7 @@ public class MainPageActivity extends Activity {
});
nbTitle.setText(getString(R.string.app_name));
ivGoBack.setVisibility(ImageView.INVISIBLE);
ivGoBack.setImageResource(R.drawable.refresh);
ivBtnSet.setImageResource(R.drawable.settings_button);
layBtnSet.setOnClickListener(new OnClickListener() {
@Override
......@@ -146,6 +149,15 @@ public class MainPageActivity extends Activity {
goToSettingsActivity();
}
});
ivGoBack.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Toast.makeText(MainPageActivity.this, R.string.update_list, Toast.LENGTH_SHORT).show();
la.swapItems(processInfo.getAllPackages(getBaseContext()));
}
});
receiver = new UpdateReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction(EmmageeService.SERVICE_ACTION);
......@@ -255,8 +267,8 @@ public class MainPageActivity extends Activity {
Programe checkedProg;
int lastCheckedPosition = -1;
public ListAdapter() {
programes = processInfo.getAllPackages(getBaseContext());
public ListAdapter(List<Programe> programes) {
this.programes = programes;
}
@Override
......@@ -273,6 +285,11 @@ public class MainPageActivity extends Activity {
public long getItemId(int position) {
return position;
}
public void swapItems(List<Programe> programes) {
this.programes = programes;
notifyDataSetChanged();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册