diff --git a/app/build.gradle b/app/build.gradle
index 18a6c6f..1f4627a 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -9,11 +9,11 @@ android {
defaultConfig {
applicationId "dev.ukanth.iconmanager"
minSdkVersion 19
- targetSdkVersion 27
+ targetSdkVersion 28
versionCode 3000
versionName "3.0.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
- buildConfigField "boolean", "LICENSECHECK", "false"
+ buildConfigField "boolean", "LICENSECHECK", "true"
}
compileOptions {
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 3bda449..4bbe2a9 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -103,6 +103,17 @@
android:value="dev.ukanth.iconmgr.MainActivity" />
+
+
+
+
+
+
+
diff --git a/app/src/main/java/dev/ukanth/iconmgr/IconPackUtil.java b/app/src/main/java/dev/ukanth/iconmgr/IconPackUtil.java
index c71997c..724f7d3 100644
--- a/app/src/main/java/dev/ukanth/iconmgr/IconPackUtil.java
+++ b/app/src/main/java/dev/ukanth/iconmgr/IconPackUtil.java
@@ -247,6 +247,9 @@ public HashMap> getIconsList(Context mContext, String packa
return list;
}
+
+
+
public Set getListIcons(String packageName) {
Set icons = new HashSet<>();
Key key = Key.ACTIVITY;
@@ -277,6 +280,36 @@ public Set getListIcons(String packageName) {
return icons;
}
+ public Set getFilterIcons(String packageName,String query) {
+ Set icons = new HashSet<>();
+ Key key = Key.ACTIVITY;
+ List items = new ArrayList<>();
+ try {
+ XmlPullParser xpp = getXmlParser(packageName, "appfilter");
+ while (xpp.getEventType() != XmlPullParser.END_DOCUMENT) {
+ if (xpp.getEventType() == XmlPullParser.START_TAG) {
+ if (xpp.getName().equals("item")) {
+ String sKey = xpp.getAttributeValue(null, key.getKey());
+ if (sKey != null) {
+ sKey = sKey.replace("ComponentInfo{", "").replace("}", "");
+ if (sKey != null) {
+ String name = xpp.getAttributeValue(null, "drawable");
+ if (name != null && name.contains(query)) {
+ items.add(new Attrb(sKey, name));
+ }
+ }
+ }
+ }
+ }
+ xpp.next();
+ }
+ icons = processXpp(packageName, items);
+ } catch (Exception e) {
+ Log.e("MICO", e.getMessage(), e);
+ }
+ return icons;
+ }
+
private Bitmap generateBitmap(Bitmap defaultBitmap, List mBackImages, Paint mPaint, Bitmap mMaskImage, Bitmap mFrontImage, String packageName) {
// No need to go through below process id defaultBitmap is null
diff --git a/app/src/main/java/dev/ukanth/iconmgr/IconPreviewActivity.java b/app/src/main/java/dev/ukanth/iconmgr/IconPreviewActivity.java
index a55b651..64e63de 100644
--- a/app/src/main/java/dev/ukanth/iconmgr/IconPreviewActivity.java
+++ b/app/src/main/java/dev/ukanth/iconmgr/IconPreviewActivity.java
@@ -175,7 +175,7 @@ private void saveImage(Icon icon, String packageName) {
file.delete();
try {
FileOutputStream out = new FileOutputStream(file);
- icon.getIconBitmap().compress(Bitmap.CompressFormat.PNG, 100, out);
+ icon.getIconBitmap().compress(Bitmap.CompressFormat.PNG, 85, out);
out.flush();
out.close();
Toast.makeText(getApplicationContext(), "Saved successfully: " + file.getAbsolutePath(), Toast.LENGTH_SHORT).show();
diff --git a/app/src/main/java/dev/ukanth/iconmgr/IconSearchActivity.java b/app/src/main/java/dev/ukanth/iconmgr/IconSearchActivity.java
new file mode 100644
index 0000000..673faa8
--- /dev/null
+++ b/app/src/main/java/dev/ukanth/iconmgr/IconSearchActivity.java
@@ -0,0 +1,232 @@
+package dev.ukanth.iconmgr;
+
+import android.content.Context;
+import android.graphics.drawable.BitmapDrawable;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+import android.util.DisplayMetrics;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.GridLayout;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.SearchView;
+
+import com.afollestad.materialdialogs.MaterialDialog;
+import com.glidebitmappool.GlideBitmapPool;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import dev.ukanth.iconmgr.dao.DaoSession;
+import dev.ukanth.iconmgr.dao.IPObj;
+import dev.ukanth.iconmgr.dao.IPObjDao;
+
+/**
+ * Created by ukanth on 3/9/17.
+ */
+
+public class IconSearchActivity extends AppCompatActivity {
+
+ private MaterialDialog plsWait;
+
+ private LinearLayout.LayoutParams params;
+
+ private GridLayout gridLayout;
+ private List objList;
+
+ private SearchView mSearchView;
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ super.onCreateOptionsMenu(menu);
+
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.menu_search, menu);
+ MenuItem searchItem = menu.findItem(R.id.i_search);
+ mSearchView = (SearchView) searchItem.getActionView();
+ setupSearchView(searchItem);
+
+ return true;
+ }
+
+ private void setupSearchView(MenuItem searchItem) {
+ mSearchView.setIconifiedByDefault(false);
+ mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
+ @Override
+ public boolean onQueryTextSubmit(String s) {
+ gridLayout.removeAllViews();
+ searchIcons(s);
+ return false;
+ }
+
+ @Override
+ public boolean onQueryTextChange(String s) {
+ if (s.length() == 0) {
+ gridLayout.removeAllViews();
+ }
+ return false;
+ }
+ });
+ }
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ if (Prefs.isDarkTheme()) {
+ setTheme(R.style.AppTheme_Dark);
+ } else {
+ setTheme(R.style.AppTheme_Light);
+ }
+
+ GlideBitmapPool.initialize(10 * 1024 * 1024);
+
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.iconsearch);
+
+
+ gridLayout = (GridLayout) findViewById(R.id.iconsearchpreview);
+ int colNumber = 4;
+ gridLayout.setColumnCount(colNumber);
+
+ DisplayMetrics metrics = getResources().getDisplayMetrics();
+ int screenWidth = metrics.widthPixels;
+ params = new LinearLayout.LayoutParams(screenWidth / colNumber, screenWidth / colNumber);
+
+ //SearchView searchView = findViewById(R.id.search);
+
+
+ App app = ((App) getApplicationContext());
+ DaoSession daoSession = app.getDaoSession();
+ IPObjDao ipObjDao = daoSession.getIPObjDao();
+
+ objList = ipObjDao.loadAll();
+
+
+ }
+
+ private void searchIcons(String query) {
+ if (!query.isEmpty()) {
+ query = query.toLowerCase();
+ }
+ IconsPreviewLoader previewLoader = new IconsPreviewLoader(IconSearchActivity.this, query);
+ if (plsWait == null && (previewLoader.getStatus() == AsyncTask.Status.PENDING ||
+ previewLoader.getStatus() == AsyncTask.Status.FINISHED)) {
+ previewLoader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ }
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ }
+
+
+ private class IconsPreviewLoader extends AsyncTask {
+
+ private Context mContext;
+ private String query;
+ private List themed_icons = new ArrayList<>();
+
+ private IconsPreviewLoader(Context context, String query) {
+ this.query = query;
+ this.mContext = context;
+ }
+
+ @Override
+ protected void onPreExecute() {
+ plsWait = new MaterialDialog.Builder(mContext).cancelable(false).title(mContext.getString(R.string.searching)).content(R.string.please_wait_normal).progress(true, 0).show();
+ }
+
+ @Override
+ protected Boolean doInBackground(Void... voids) {
+ while (!isCancelled()) {
+ try {
+ IconPackUtil packUtil = new IconPackUtil();
+ for (IPObj obj : objList) {
+ themed_icons.addAll(packUtil.getFilterIcons(obj.getIconPkg(), query));
+ }
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ protected void onPostExecute(Boolean aBoolean) {
+ super.onPostExecute(aBoolean);
+
+ try {
+ if (plsWait != null && plsWait.isShowing()) {
+ plsWait.dismiss();
+ }
+ } catch (final IllegalArgumentException e) {
+ // Handle or log or ignore
+ } catch (final Exception e) {
+ // Handle or log or ignore
+ } finally {
+ plsWait.dismiss();
+ plsWait = null;
+ }
+
+ gridLayout.removeAllViews();
+
+ if (themed_icons != null) {
+ List list = new ArrayList(themed_icons);
+ if (list != null && list.size() > 0) {
+ Collections.sort(list, (o1, o2) -> String.CASE_INSENSITIVE_ORDER.compare(o1.getTitle(), o2.getTitle()));
+
+ for (final Icon icon : list) {
+ if (icon.getIconBitmap() != null) {
+ ImageView image = new ImageView(mContext);
+ image.setLayoutParams(params);
+ image.setPadding(15, 15, 15, 15);
+ image.setScaleType(ImageView.ScaleType.FIT_CENTER);
+ image.setImageDrawable(new BitmapDrawable(getResources(), icon.getIconBitmap()));
+ image.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ new MaterialDialog.Builder(mContext)
+ .title(icon.getTitle())
+ .positiveText(R.string.save)
+ .onPositive((dialog, which) -> {
+
+ })
+ .negativeText(R.string.close)
+ .icon(new BitmapDrawable(getResources(), icon.getIconBitmap()))
+ .show();
+ }
+ });
+ image.setOnLongClickListener(view -> {
+
+ return true;
+ });
+ gridLayout.addView(image);
+ }
+ }
+ GlideBitmapPool.clearMemory();
+ //processInputs(list, res, params, gridLayout);
+ } else {
+ }
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/dev/ukanth/iconmgr/MainActivity.java b/app/src/main/java/dev/ukanth/iconmgr/MainActivity.java
index a0c84b9..7ff1e42 100644
--- a/app/src/main/java/dev/ukanth/iconmgr/MainActivity.java
+++ b/app/src/main/java/dev/ukanth/iconmgr/MainActivity.java
@@ -1,5 +1,6 @@
package dev.ukanth.iconmgr;
+import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -435,6 +436,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
case R.id.pref:
showPreference();
return true;
+ case R.id.iconsearch:
+ showIconSearch();
+ return true;
case R.id.about:
showAbout();
return true;
@@ -506,6 +510,11 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
}
+ private void showIconSearch() {
+ Intent myIntent = new Intent(MainActivity.this, IconSearchActivity.class);
+ startActivity(myIntent);
+ }
+
private void reload() {
Collections.sort(iconPacksList, new PackageComparator());
adapter = new IconAdapter(iconPacksList, installed);
diff --git a/app/src/main/res/layout/iconsearch.xml b/app/src/main/res/layout/iconsearch.xml
new file mode 100644
index 0000000..dab4c4a
--- /dev/null
+++ b/app/src/main/res/layout/iconsearch.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/menu/main_menu.xml b/app/src/main/res/menu/main_menu.xml
index 65309e0..7a32529 100644
--- a/app/src/main/res/menu/main_menu.xml
+++ b/app/src/main/res/menu/main_menu.xml
@@ -48,6 +48,12 @@
+
+
+
-
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 125048a..c0f17f8 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -114,4 +114,8 @@
No iconpack found
Sorry! Unable to create screenshot
Save
+ Icon Search
+ app
+ Search Icons
+ Searching
diff --git a/app/src/main/res/xml/searchable.xml b/app/src/main/res/xml/searchable.xml
new file mode 100644
index 0000000..24584f4
--- /dev/null
+++ b/app/src/main/res/xml/searchable.xml
@@ -0,0 +1,5 @@
+
+
+
\ No newline at end of file