From 054c6511c4a98e08976add2eb59f4afed83c7ecf Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 30 Aug 2014 09:34:46 +0200 Subject: [PATCH] Moved search to action bar Fixes #1918 --- CHANGELOG.md | 1 + res/drawable/cross_grayed_out_holo_dark.png | Bin 769 -> 0 bytes res/drawable/cross_grayed_out_holo_light.png | Bin 770 -> 0 bytes res/drawable/cross_holo_dark.png | Bin 1285 -> 0 bytes res/drawable/cross_holo_light.png | Bin 1358 -> 0 bytes res/layout/mainlist.xml | 75 ++++------------ res/menu/main.xml | 7 ++ res/values-v14/styles.xml | 4 - src/biz/bokhorst/xprivacy/ActivityMain.java | 81 ++++++++---------- .../bokhorst/xprivacy/ActivitySettings.java | 1 - 10 files changed, 59 insertions(+), 110 deletions(-) delete mode 100644 res/drawable/cross_grayed_out_holo_dark.png delete mode 100644 res/drawable/cross_grayed_out_holo_light.png delete mode 100644 res/drawable/cross_holo_dark.png delete mode 100644 res/drawable/cross_holo_light.png diff --git a/CHANGELOG.md b/CHANGELOG.md index bbb0c58f9..95adc91b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ Version 3.x will be available with a [pro license](http://www.xprivacy.eu/) only * Moved flush button to expert mode section ([issue](/../../issues/1934)) * Added category merge/reset ([issue](/../../issues/1909)) * Display introductory tutorial only on first run after *About* ([issue](/../../issues/1942)) +* Moved search to action bar ([issue](/../../issues/1918)) * Updated simplified Chinese translation [Open issues](https://github.com/M66B/XPrivacy/issues?state=open) diff --git a/res/drawable/cross_grayed_out_holo_dark.png b/res/drawable/cross_grayed_out_holo_dark.png deleted file mode 100644 index c00c56adc6deb27194d8b3bb589b389006eb890a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 769 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTCmUKs7M+SzCeKo%WCjxQjRpQQCRMVXvSlpZV{^qPZH26VrzwL%gM?>J@1p1vOj|!F3H(<+s*p94Rlvbz zxv9nv_N@(!CzC2Q=8JT%6cb=zbXmnNA))b|#WZ;$qe8=pj||MrKj$r2_1F<;%89Q) z-phFlc7b^sAi0n87IZ>*Ah|mKIqjEB3T-$TSOiRM7?^I@Fs_=Bkh(>NnOBCN321nh ztpmq`>#H_+@jZzMQ2pA`*wx3**ub!88~cGYBL$nrIqV62%U88BFq%A>eHo~JtqlY7 zk4XX=`3*_!t2{Xr8dls@X`5=MaQyJ4Kgt@v^_feh8Z>||TOrE4?fJ!&EQ@8vq z7#$b_4>SMJ(v(=>#w?)Cz@gw}>yX3iy*5mT4aBi=$okx%HV?=wvUSM2-S!I1v~kEh z+_MVA46=1t8>V{Ih7lO>6%Fhip^_`EuR8L)^R~mERtaYYrj99GuCo{eJp)&Va(+JI zykh2tQ+~4|m_ZT}JGhVRmsEIcb|okD5YYQ?9DFBu2Yl`X`M!(YA@C1FM`YsvDADBmF_V;vBp5ohPuW>?ChY>IVFpiEKbLh*2~7ZE C+XjXJ diff --git a/res/drawable/cross_grayed_out_holo_light.png b/res/drawable/cross_grayed_out_holo_light.png deleted file mode 100644 index 44e0627a566d26440304989d203075ba80e288a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 770 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTCmUKs7M+SzCeKo%WCjZ3i(^Q|oTNYh|Jxr9 zU}IoBVse3Rfd~W3g$dso92j^j`H5f(aBFt?`uI4=g)u)mo_=o5PcPqghO^Juf;KtS zaA$n8Px{KpB5=`=VGF~PNLPhxEJ?g8(pNAoNXv9M8`g5mRfK^I>2&9M1k>-|E~N@t1+orHgqU(?{nO^Y%OFoOf8LK0!vG-*hr(*74w^vp~&m zK~ak%bW+-)DjKJhc>8Wxd8VP`*#@AZNsH$P`3GG7sK6lLkg_zs z$ks9Ucr(z86X!B|er3^>;b#Kc6KLqMMm^(cg#bu{mtqV7w1!?eYu zft;)|w+~@KTRyP>{kC-Coo&3jHjDxeD%p#+B)aAL1GRfft+={s$uf1IT`!igTu6vh zSn9R%@x?PoL>0C-rq!t(<7r?}I=cN*K=(hxfR&-0s%rln-%e1w1{P*6Z}=g^oOQV8 zQJCr^bvehg`&hPiYXHOa3D0VtRSR7k7#39(&$mdKI;Vst04ll)yZ`_I diff --git a/res/drawable/cross_holo_dark.png b/res/drawable/cross_holo_dark.png deleted file mode 100644 index 094eea589246b46e26d3cf02285f26c1abb33700..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1285 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTC$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWuD@%qp275hW46K32*3xq68pHF_1f1wh>l3^w)^1&PVosU-?Y zsp*+{wo31J?^jaDOtDo8H}y5}EpSfF$n>ZxN)4{^3rViZPPR-@vbR&PsjvbXkegbP zs8ErclUHn2VXFi-*9yo63F|8hm3bwJ6}oxF$}kgLQj3#|G7CyF^YauyCMG83 zmzLNn0bL65LT&-v*t}wBFaZNhzap_f-%!s00+w{G(#^lGsViu&CG&eP`1g19yq1ObbUQlAlEdbi=l3J8mmYU*Ll%J~r_Ow+dZnqfX zG!Lpb1-Dy_aO%|uIz}H9wMbD769T3m5EGtofgE_!Pt60S_ab1z-u2mO3IhXUxu=U` zNX4x;5!QK!97IeyTqnMNpmcm8%M>G3-WWwz*F`c-$_jIgzI(VH*9}NfITIn}t^Miq zt^CxuFJV%VoA!QA+cW?BwdPGa!e?_6*v>Ra8Zf6F;K|54eBit62Bu9MQAS0(7sOrV zFmd6sVXA&0TEJNQze)M|Ji|-NYMq;OBp)a(&?%=8T3fK(ZA-OjPsrn-ICl#d^bMbWd5M3Yv*PdK6^%G=gKVBqt7Qj zN)BD@+%+et!bv%QPyM^iQh&ccXS^D`V!EqMm&!fysN*xMLvxC}Z?AaevTWCsfY>uD z^_GXqXN1UWzHe-uzC=arVY%9>ll3^w)^1&PVosU-?Y zsp*+{wo31J?^jaDOtDo8H}y5}EpSfF$n>ZxN)4{^3rViZPPR-@vbR&PsjvbXkegbP zs8ErclUHn2VXFi-*9yo63F|8hm3bwJ6}oxF$}kgLQj3#|G7CyF^YauyCMG83 zmzLNn0bL65LT&-v*t}wBFaZNhzap_f-%!s00+w{G(#^lGsVitz{uRt(ZJBu$-u?X(ACh=#L&{!#L3yw z&D7A`#K{n**Cju>G&eP`1g19yq1OnfUQlAlEdbi=l3J8mmYU*Ll%J~r_Ow+dF1J{^ zx#2Vqsy79jq(2n!XhGjGPNr-YWW@CJDHmK zJ&5LLy_WOYcc}%pyr$}zn*DR{o;AsRQu%IMrAprEc1DQ?5c-qP5dZa9*lN*t_QHER z?wyGH=GwlV}9bzo}}cX=i=H})~T@^ z-4ng}PpM+Yv)JCRyY*PE?peK)FnlmIp00i_>zopr0MX;(_W%F@ diff --git a/res/layout/mainlist.xml b/res/layout/mainlist.xml index d0c79df5b..28ae59e10 100644 --- a/res/layout/mainlist.xml +++ b/res/layout/mainlist.xml @@ -22,74 +22,29 @@ android:layout_marginBottom="3dip" android:layout_marginRight="@dimen/activity_horizontal_margin" android:background="?attr/drawable_card" - android:orientation="vertical" + android:orientation="horizontal" android:paddingBottom="6dip" android:paddingLeft="6dip" android:paddingRight="6dip" android:paddingTop="6dip" > - - - - - - - - + android:layout_weight="1" /> - - - - - - - - - - - + android:clickable="true" + android:contentDescription="@string/help_application" + android:focusable="true" + android:src="?attr/icon_info" /> + @drawable/expander_ic_maximized_holo_dark @drawable/ic_launcher_holo_dark @drawable/check_holo_dark - @drawable/cross_holo_dark - @drawable/cross_grayed_out_holo_dark @drawable/frozen_holo_dark @drawable/padlock_question_dark @android:color/black @@ -41,8 +39,6 @@ @drawable/expander_ic_maximized_holo_light @drawable/ic_launcher_holo_light @drawable/check_holo_light - @drawable/cross_holo_light - @drawable/cross_grayed_out_holo_light @drawable/frozen_holo_light @drawable/padlock_question_light @color/color_home_background_light diff --git a/src/biz/bokhorst/xprivacy/ActivityMain.java b/src/biz/bokhorst/xprivacy/ActivityMain.java index cf68bd01e..36877ebca 100644 --- a/src/biz/bokhorst/xprivacy/ActivityMain.java +++ b/src/biz/bokhorst/xprivacy/ActivityMain.java @@ -37,8 +37,6 @@ import android.os.Environment; import android.os.Handler; import android.os.Process; -import android.text.Editable; -import android.text.TextWatcher; import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; @@ -60,7 +58,6 @@ import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; -import android.widget.EditText; import android.widget.ExpandableListView; import android.widget.Filter; import android.widget.ImageView; @@ -70,6 +67,7 @@ import android.widget.RadioGroup; import android.widget.RelativeLayout; import android.widget.ScrollView; +import android.widget.SearchView; import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; @@ -77,6 +75,8 @@ public class ActivityMain extends ActivityBase implements OnItemSelectedListener { private Spinner spRestriction = null; private AppListAdapter mAppAdapter = null; + + private String searchQuery = ""; private int mSortMode; private boolean mSortInvert; private int mProgressWidth = 0; @@ -101,7 +101,6 @@ public class ActivityMain extends ActivityBase implements OnItemSelectedListener private static final int ERROR_NON_MATCHING_UID = 0x103; public static final Uri cProUri = Uri.parse("http://www.xprivacy.eu/"); - public static final String cRefreshUI = "RefreshUI"; private static ExecutorService mExecutor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(), new PriorityThreadFactory()); @@ -221,35 +220,6 @@ public void onClick(View view) { mSortMode = Integer.parseInt(PrivacyManager.getSetting(userId, PrivacyManager.cSettingSortMode, "0")); mSortInvert = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingSortInverted, false); - // Setup name filter - final EditText etFilter = (EditText) findViewById(R.id.etFilter); - etFilter.addTextChangedListener(new TextWatcher() { - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - String text = etFilter.getText().toString(); - ImageView imgClear = (ImageView) findViewById(R.id.imgClear); - imgClear.setImageDrawable(getResources().getDrawable( - getThemed(text.equals("") ? R.attr.icon_clear_grayed : R.attr.icon_clear))); - applyFilter(); - } - - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - } - - @Override - public void afterTextChanged(Editable s) { - } - }); - - ImageView imgClear = (ImageView) findViewById(R.id.imgClear); - imgClear.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - etFilter.setText(""); - } - }); - // Start task to get app list AppListTask appListTask = new AppListTask(); appListTask.executeOnExecutor(mExecutor, (Object) null); @@ -355,17 +325,13 @@ protected void onResume() { @Override protected void onNewIntent(Intent intent) { + // Refresh application list if (mAppAdapter != null) mAppAdapter.notifyDataSetChanged(); + // Import pro license if (Intent.ACTION_VIEW.equals(intent.getAction())) Util.importProLicense(new File(intent.getData().getPath())); - - // Handle clear XPrivacy data (needs UI refresh) - if (intent.hasExtra(cRefreshUI)) { - ((EditText) findViewById(R.id.etFilter)).setText(""); - recreate(); - } } @Override @@ -448,7 +414,6 @@ private void selectRestriction(int pos) { private void applyFilter() { if (mAppAdapter != null) { - EditText etFilter = (EditText) findViewById(R.id.etFilter); ProgressBar pbFilter = (ProgressBar) findViewById(R.id.pbFilter); TextView tvStats = (TextView) findViewById(R.id.tvStats); TextView tvState = (TextView) findViewById(R.id.tvState); @@ -466,9 +431,8 @@ private void applyFilter() { boolean fUser = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFUser, true); boolean fSystem = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFSystem, false); - String filter = String.format("%s\n%b\n%b\n%b\n%b\n%b\n%b\n%b\n%b\n%b", etFilter.getText().toString(), - fUsed, fInternet, fRestriction, fRestrictionNot, fPermission, fOnDemand, fOnDemandNot, fUser, - fSystem); + String filter = String.format("%s\n%b\n%b\n%b\n%b\n%b\n%b\n%b\n%b\n%b", searchQuery, fUsed, fInternet, + fRestriction, fRestrictionNot, fPermission, fOnDemand, fOnDemandNot, fUser, fSystem); pbFilter.setVisibility(ProgressBar.VISIBLE); tvStats.setVisibility(TextView.GONE); @@ -477,8 +441,6 @@ private void applyFilter() { tvStateLayout.addRule(RelativeLayout.LEFT_OF, R.id.pbFilter); mAppAdapter.getFilter().filter(filter); - - invalidateOptionsMenu(); } } @@ -493,7 +455,35 @@ private void applySort() { public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); if (inflater != null && PrivacyService.checkClient()) { + // Inflate menu inflater.inflate(R.menu.main, menu); + + // Searchable + SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView(); + searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { + @Override + public boolean onQueryTextChange(String newText) { + searchQuery = newText; + applyFilter(); + return true; + } + + @Override + public boolean onQueryTextSubmit(String query) { + searchQuery = query; + applyFilter(); + return true; + } + }); + searchView.setOnCloseListener(new SearchView.OnCloseListener() { + @Override + public boolean onClose() { + searchQuery = ""; + applyFilter(); + return true; + } + }); + return true; } else return false; @@ -820,6 +810,7 @@ public void onClick(DialogInterface dialog, int which) { PrivacyManager.setSetting(userId, PrivacyManager.cSettingFSystem, Boolean.toString(cbFSystem.isChecked())); + invalidateOptionsMenu(); applyFilter(); } }); diff --git a/src/biz/bokhorst/xprivacy/ActivitySettings.java b/src/biz/bokhorst/xprivacy/ActivitySettings.java index e4dfd686d..fa72ac942 100644 --- a/src/biz/bokhorst/xprivacy/ActivitySettings.java +++ b/src/biz/bokhorst/xprivacy/ActivitySettings.java @@ -518,7 +518,6 @@ public void onClick(DialogInterface dialog, int which) { // Refresh main UI Intent intent = new Intent(ActivitySettings.this, ActivityMain.class); - intent.putExtra(ActivityMain.cRefreshUI, true); startActivity(intent); } });