Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add feature: show-enabled-only filter && long press mode && others #38

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,17 @@ public void onCreate(Bundle savedInstanceState) {
public Dialog onCreateDialog(Bundle savedInstanceState) {
final IntentFilterInfo event = getArguments().getParcelable("event");
final ListActivity activity = (ListActivity)getActivity();
Object[] data = Actions.MAP.get(event.action);
CharSequence info = "";
if (data!=null && data[1] != null&& data[2] != null) // Hide info text both for null and empty string values.
info = "<p>"+getResources().getString((Integer)data[1])+":"+getResources().getText((Integer)data[2])+"</p>";

View v = activity.getLayoutInflater().inflate(
R.layout.receiver_info_panel, null, false);
String formattedString = String.format(
getString(R.string.receiver_info),
event.componentInfo.componentName, event.action, event.priority);
event.componentInfo.componentName, event.action, event.priority)
+info;
((TextView)v.findViewById(R.id.message)).setText(
Html.fromHtml(formattedString));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import android.text.Spanned;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.TextView;

import com.elsdoerfer.android.autostarts.opt.RootFeatures;

Expand Down Expand Up @@ -63,9 +63,7 @@ public void onCreate(Bundle savedInstanceState) {
}
}
fullText.append("</body></html>");

((WebView)findViewById(R.id.faq_text)).loadData(
fullText.toString(), "text/html", "utf-8");
((TextView)findViewById(R.id.faq_text)).setText(Html.fromHtml(fullText.toString()));

((Button)findViewById(R.id.close)).setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.ArrayList;

import android.app.AlertDialog;
import android.app.DialogFragment;
import android.app.ExpandableListActivity;
import android.app.Fragment;
Expand All @@ -17,6 +18,7 @@
import android.text.style.ClickableSpan;
import android.view.*;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ExpandableListView;
import android.widget.SearchView;
import android.widget.TextView;
Expand All @@ -31,9 +33,12 @@ public class ListActivity extends ExpandableListActivity {

static final String PREFS_NAME = "common";
static final String PREF_FILTER_SYS_APPS = "filter-sys-apps";
static final String PREF_FILTER_SHOW_ENABLED = "show-enabled-only";
static final String PREF_FILTER_SHOW_CHANGED = "show-changed-only";
static final String PREF_FILTER_UNKNOWN = "filter-unknown-events";
static final String PREF_GROUPING = "grouping";
static final String PREF_LONGCLICK = "enable_long_click";
static Boolean mEnableLongClick = false;

private Menu mActionBarMenu;
private MenuItem mExpandCollapseToggleItem;
Expand Down Expand Up @@ -143,14 +148,36 @@ public void onCreate(final Bundle saved) {
// Restore preferences
mListAdapter.setFilterSystemApps(
mPrefs.getBoolean(PREF_FILTER_SYS_APPS, false));
mListAdapter.setShowEnabledOnly(
mPrefs.getBoolean(PREF_FILTER_SHOW_ENABLED, false));
mListAdapter.setShowChangedOnly(
mPrefs.getBoolean(PREF_FILTER_SHOW_CHANGED, false));
mListAdapter.setFilterUnknown(
mPrefs.getBoolean(PREF_FILTER_UNKNOWN, true));
mListAdapter.setGrouping(mPrefs.getString(PREF_GROUPING, "action").equals("package")
? MyExpandableListAdapter.GROUP_BY_PACKAGE
: MyExpandableListAdapter.GROUP_BY_ACTION);
mEnableLongClick = mPrefs.getBoolean(PREF_LONGCLICK, false);

// LongClickListener
getExpandableListView().setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view,int position, long id) {
//int position = expandableListView.pointToPosition((int)view.getX(), (int)view.getY());
if (position != AdapterView.INVALID_POSITION) {
ExpandableListView expandableListView = (ExpandableListView)parent;
long pos = expandableListView.getExpandableListPosition(position);
int childPosition = ExpandableListView.getPackedPositionChild(pos);
int groupPosition = ExpandableListView.getPackedPositionGroup(pos);
if(childPosition == AdapterView.INVALID_POSITION){//group long click
onGroupLongClick(expandableListView,view, groupPosition,id);
}else{// child long click
onChildLongClick(expandableListView,view, groupPosition,childPosition,id);
}
}
return true;
}
});
bindService(new Intent(this, ToggleService.class),
mToggleServiceConnection, Context.BIND_AUTO_CREATE);

Expand Down Expand Up @@ -331,7 +358,9 @@ public boolean onPrepareOptionsMenu(Menu menu) {
// Reload button disabled while reloading
mReloadItem.setEnabled(mLoadTask == null || mLoadTask.getStatus() != AsyncTask.Status.RUNNING);

menu.findItem(R.id.enable_long_click).setChecked(mEnableLongClick);
// View/Filter Submenu
menu.findItem(R.id.view_enabled_only).setChecked(mListAdapter.getShowEnabledOnly());
menu.findItem(R.id.view_changed_only).setChecked(mListAdapter.getShowChangedOnly());
menu.findItem(R.id.view_hide_sys_apps).setChecked(mListAdapter.getFilterSystemApps());
menu.findItem(R.id.view_hide_unknown).setChecked(mListAdapter.getFilterUnknown());
Expand Down Expand Up @@ -367,6 +396,15 @@ else if (id == R.id.view_hide_sys_apps) {
return true;
}

else if (id == R.id.view_enabled_only) {
item.setChecked(!item.isChecked());
mListAdapter.setShowEnabledOnly(item.isChecked());
mListAdapter.notifyDataSetChanged();
updateEmptyText();
mPrefs.edit().putBoolean(ListActivity.PREF_FILTER_SHOW_ENABLED, item.isChecked()).commit();
return true;
}

else if (id == R.id.view_changed_only) {
item.setChecked(!item.isChecked());
mListAdapter.setShowChangedOnly(item.isChecked());
Expand Down Expand Up @@ -396,6 +434,12 @@ else if (id == R.id.expand) {
return true;
}

else if (id == R.id.enable_long_click) {
item.setChecked(!item.isChecked());
mEnableLongClick = item.isChecked();
mPrefs.edit().putBoolean(ListActivity.PREF_LONGCLICK, mEnableLongClick).commit();
return true;
}
else if (id == R.id.reload) {
loadAndApply();
return true;
Expand All @@ -414,10 +458,55 @@ else if (id == R.id.help) {
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
showEventDetails((IntentFilterInfo) mListAdapter.getChild(groupPosition, childPosition));
if (mEnableLongClick){
IntentFilterInfo event = (IntentFilterInfo) mListAdapter.getChild(groupPosition, childPosition);
final boolean componentIsEnabled = mToggleService.getQueuedState(
event.componentInfo, event.componentInfo.isCurrentlyEnabled());
boolean doEnable = !componentIsEnabled;
addJob(event.componentInfo, doEnable);
}
else
showEventDetails((IntentFilterInfo) mListAdapter.getChild(groupPosition, childPosition));
return super.onChildClick(parent, v, groupPosition, childPosition, id);
}

public boolean onChildLongClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
if (mEnableLongClick)
showEventDetails((IntentFilterInfo) mListAdapter.getChild(groupPosition, childPosition));
return false;
}


private void onGroupLongClick(ExpandableListView expandableListView, View view, final int groupPosition, long id) {
if (mEnableLongClick){
if (mListAdapter.getGrouping() == MyExpandableListAdapter.GROUP_BY_PACKAGE){
AlertDialog.Builder bb = new AlertDialog.Builder(this);
bb.setCancelable(true);
bb.setTitle(R.string.warning);
bb.setMessage(R.string.disable_all_warning);
//bb.setNeutralButton(R.string.enable_all,);
bb.setPositiveButton(R.string.disable_all, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
int ChildrenCount = mListAdapter.getChildrenCount(groupPosition);
for (int childPosition = 0; childPosition <ChildrenCount ; childPosition++) {
IntentFilterInfo event = (IntentFilterInfo) mListAdapter.getChild(groupPosition, childPosition);
addJob(event.componentInfo, false);
}
}
});
bb.show();
} else {
View v = view.findViewById(R.id.show_info);
if (v!=null)
v.callOnClick();
//if (Actions.MAP.containsKey(action))
// showInfoToast(action);
}
}
}

void apply() {
mListAdapter.setData(mEvents);
mListAdapter.notifyDataSetChanged();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class MyExpandableListAdapter extends BaseExpandableListAdapter {

private boolean mHideSystemApps = false;
private boolean mHideUnknownEvents = false;
private boolean mShowEnabledOnly = false;
private boolean mShowChangedOnly = false;
private String mTextFilter = "";

Expand Down Expand Up @@ -92,6 +93,8 @@ private boolean checkAgainstFilters(IntentFilterInfo info) {

if (mHideSystemApps && comp.packageInfo.isSystem)
return false;
if (mShowEnabledOnly && !comp.isCurrentlyEnabled())
return false;
if (mShowChangedOnly && comp.isCurrentlyEnabled() ==
comp.defaultEnabled)
return false;
Expand Down Expand Up @@ -168,7 +171,7 @@ public boolean hasStableIds() {
*/
public boolean isFiltered() {

return mHideSystemApps || mShowChangedOnly || mHideUnknownEvents || !mTextFilter.equals("");
return mHideSystemApps || mShowEnabledOnly || mShowChangedOnly || mHideUnknownEvents || !mTextFilter.equals("");
}

/**
Expand Down Expand Up @@ -208,6 +211,17 @@ public void setShowChangedOnly(boolean newState) {
}
}

public void setShowEnabledOnly(boolean newState) {
if (newState != mShowEnabledOnly) {
mShowEnabledOnly = newState;
rebuildGroupDisplay();
}
}

public boolean getShowEnabledOnly() {
return mShowEnabledOnly;
}

public boolean getShowChangedOnly() {
return mShowChangedOnly;
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/layout/help.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_height="fill_parent"
>

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="5dp"
>

<WebView
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/faq_text"
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/menu/actionbar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<item android:id="@+id/view_hide_sys_apps"
android:title="@string/hide_sys_apps"
android:checkable="true"/>
<item android:id="@+id/view_enabled_only"
android:title="@string/show_enabled_only"
android:checkable="true"/>
<item android:id="@+id/view_changed_only"
android:title="@string/show_changed_only"
android:checkable="true"/>
Expand All @@ -27,6 +30,11 @@
</menu>
</item>

<item android:id="@+id/enable_long_click"
android:title="@string/enable_long_click"
android:checkable="true"
android:showAsAction="never"/>

<item android:id="@+id/expand"
android:icon="@drawable/ic_action_navigation_expand_more"
android:title="@string/expand_all"
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="no_receivers">アプリケーションは自動起動しません。</string>
<string name="no_receivers_filtered">現在の選択範囲に自動起動するアプリケーションはありません。</string>
<string name="change_filter_settings">フィルター設定を変更します。</string>
<string name="no_search_match">検索クエリと一致するアプリケーションは一致しません。</string>
<string name="appliation_info">アプリケーション情報</string>
<string name="find_in_market">マーケットで検索</string>
<string name="find_in_appstore">アプリストアで検索</string>
Expand All @@ -12,11 +13,13 @@
<string name="group_by_package">アプリケーションでグループ化</string>
<string name="group_by_action">イベントでグループ化</string>
<string name="hide_sys_apps">システムアプリを非表示</string>
<string name="show_enabled_only">有効なみ表示されます</string>
<string name="show_changed_only">変更済のみ表示</string>
<string name="hide_unknown">不明なイベントを非表示</string>
<string name="expand_all">すべて展開</string>
<string name="collapse_all">すべて折りたたむ</string>
<string name="reload">再読み込み</string>
<string name="search">探す</string>
<string name="help">ヘルプ</string>
<string name="error">エラー</string>
<string name="warning">警告</string>
Expand All @@ -26,4 +29,5 @@
<string name="changing_state">%1$s を変更中...</string>
<string name="state_change_failed">%1$s (%2$s) の状態を変更できません。\n\nお使いのデバイスに root アクセス権がないようです。これは必須です。</string>
<string name="close_help">ヘルプを閉じて、アプリに戻る</string>
<string name="enable_long_click">ロングクリックを有効にします</string>
</resources>
6 changes: 3 additions & 3 deletions app/src/main/res/values-zh-rCN/actions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,10 @@
<string name="act_bt_pan_connection_state_changed_detail">当个人蓝牙区域网络变更时提醒。</string>
<string name="act_background_data_setting_changed">后台数据设置变更。</string>
<string name="act_background_data_setting_changed_detail">设置为后台数据的使用已变更的值。</string>
<string name="act_appwidget_enabled">允许桌面小部件。</string>
<string name="act_appwidget_enabled">启用桌面小部件</string>
<string name="act_appwidget_enabled_detail">桌面小部件的第一个副本已加入。</string>
<string name="act_appwidget_update">正在桌面小部件更新</string>
<string name="act_appwidget_update_detail">一个桌面小部件要求自更新。多久触发一次是个问题,但设为「从不」会使桌面小部件无效。\n\n<b>请注意,禁用此事件很可能会呈现小部件失效。</b></string>
<string name="act_appwidget_update">桌面小部件更新中</string>
<string name="act_appwidget_update_detail">一个桌面小部件要求自更新。不确定多久触发一次,但设为「从不」会使桌面小部件无效。\n\n<b>请注意,禁用此事件很可能会使小部件失效。</b></string>
<string name="act_appwidget_disabled">禁用桌面小部件</string>
<string name="act_appwidget_disabled_detail">桌面小部件最后一个副本已移除。</string>
<string name="act_appwidget_deleted">桌面小部件移除</string>
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<string name="no_receivers">没有应用程序是自动启动的。</string>
<string name="no_receivers_filtered">您当前所选的类别里没有任何应用程序是自动启动的。</string>
<string name="change_filter_settings">更改筛选设置。</string>
<string name="no_search_match">没有应用程序匹配您的搜索查询。</string>
<string name="appliation_info">应用程序信息</string>
<string name="find_in_market">在 Google Play 中寻找</string>
<string name="find_in_appstore">在 Amazon Appstore 中寻找</string>
Expand All @@ -12,18 +13,23 @@
<string name="group_by_package">按应用程序分组</string>
<string name="group_by_action">按事件类别分组</string>
<string name="hide_sys_apps">隐藏系统程序</string>
<string name="show_enabled_only">仅显示启用项</string>
<string name="show_changed_only">只显示更改项目</string>
<string name="hide_unknown">隐藏未知事件</string>
<string name="expand_all">全部展开</string>
<string name="collapse_all">全部折叠</string>
<string name="reload">重新载入</string>
<string name="search">搜索</string>
<string name="help">帮助</string>
<string name="error">错误</string>
<string name="warning">警告</string>
<string name="info">信息</string>
<string name="receiver_info">"接收 &lt;b&gt;%1$s&lt;/b&gt; 处理操作 &lt;i&gt;%2$s&lt;/i&gt; 优先 &lt;b&gt;%3$d&lt;/b&gt;."</string>
<string name="receiver_info">"接收器 &lt;b&gt;%1$s&lt;/b&gt; 处理操作 &lt;i&gt;%2$s&lt;/i&gt; 优先级为 &lt;b&gt;%3$d&lt;/b&gt;."</string>
<string name="sys_disable">这是系统组件。若不清楚您在做什么请不要更改。</string>
<string name="changing_state">正在更改 %1$s...</string>
<string name="state_change_failed">无法更改 %1$s (%2$s) 的状态。\n\n很可能是由于您的设备还未获取必要的 ROOT 权限。</string>
<string name="close_help">关闭帮助并返回程序</string>
<string name="enable_long_click">启用长按</string>
<string name="disable_all_warning">禁用该App下的全部项目?</string>
<string name="disable_all">禁用全部</string>
</resources>
6 changes: 6 additions & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<string name="no_receivers">沒有應用程式是自動啟動的。</string>
<string name="no_receivers_filtered">您目前所選的類別裡沒有任何應用程式是自動啟動的。</string>
<string name="change_filter_settings">變更篩選設定。</string>
<string name="no_search_match">沒有應用程序匹配您的搜索查詢。</string>
<string name="appliation_info">應用程式資訊</string>
<string name="find_in_market">在 Google Play 中尋找</string>
<string name="find_in_appstore">在 Amazon Appstore 中尋找</string>
Expand All @@ -12,11 +13,13 @@
<string name="group_by_package">依應用程式分組</string>
<string name="group_by_action">依事件類別分組</string>
<string name="hide_sys_apps">隱藏系統程式</string>
<string name="show_enabled_only">僅顯示啟用</string>
<string name="show_changed_only">僅顯示已變更項目</string>
<string name="hide_unknown">隱藏未知事件</string>
<string name="expand_all">展開全部</string>
<string name="collapse_all">全部折疊</string>
<string name="reload">重新載入</string>
<string name="search">搜索</string>
<string name="help">說明</string>
<string name="error">錯誤</string>
<string name="warning">警告</string>
Expand All @@ -26,4 +29,7 @@
<string name="changing_state">正在變更 %1$s...</string>
<string name="state_change_failed">無法變更 %1$s (%2$s) 的狀態。\n\n很可能是由於您的裝置尚未取得必要的 ROOT 權限。</string>
<string name="close_help">關閉說明並回到應用程式</string>
<string name="enable_long_click">啟用長點擊</string>
<string name="disable_all_warning">停用该應用程式下的全部項目?</string>
<string name="disable_all">停用全部</string>
</resources>
Loading