From fa31a969fabe40b2eb4f6618b5af36d66a11f8c3 Mon Sep 17 00:00:00 2001 From: HenriDellal Date: Sun, 23 Sep 2018 15:16:49 +0300 Subject: [PATCH] fix dock content duplication and shortcuts addition to dock --- app/src/main/java/ru/henridellal/emerald/Apps.java | 5 ++--- app/src/main/java/ru/henridellal/emerald/Dock.java | 7 +++++-- .../main/java/ru/henridellal/emerald/ShortcutData.java | 10 +++------- app/src/main/res/values-ru/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/ru/henridellal/emerald/Apps.java b/app/src/main/java/ru/henridellal/emerald/Apps.java index ee1108a..db27282 100644 --- a/app/src/main/java/ru/henridellal/emerald/Apps.java +++ b/app/src/main/java/ru/henridellal/emerald/Apps.java @@ -486,12 +486,11 @@ public void itemContextMenu(final ShortcutData item) { builder.setCancelable(true); String[] commands = new String[]{ - getResources().getString(R.string.editAppCategories), + getResources().getString(R.string.editCategories), getResources().getString(R.string.uninstall), (dock.hasApp(item)) ? getResources().getString(R.string.remove_from_dock): - getResources().getString(R.string.add_to_dock), - getResources().getString(R.string.change_icon) + getResources().getString(R.string.add_to_dock) }; builder.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, commands), new DialogInterface.OnClickListener(){ diff --git a/app/src/main/java/ru/henridellal/emerald/Dock.java b/app/src/main/java/ru/henridellal/emerald/Dock.java index 2a81d7d..266deb0 100644 --- a/app/src/main/java/ru/henridellal/emerald/Dock.java +++ b/app/src/main/java/ru/henridellal/emerald/Dock.java @@ -9,6 +9,7 @@ import java.io.FileReader; import java.io.FileWriter; import java.lang.ref.SoftReference; + import android.content.Context; import android.view.View; import android.view.ViewGroup; @@ -73,6 +74,7 @@ public boolean isEmpty() { public void initApps() { BufferedReader reader = null; boolean needSave = false; + apps.clear(); File f = new File(contextRef.get().getFilesDir(), "dock"); try { if (!f.exists()) { @@ -87,12 +89,13 @@ public void initApps() { if (data.startsWith(AppData.COMPONENT)) { a = new AppData(); a.read(reader, data); - apps.add(a); + if (DatabaseHelper.hasItem(contextRef.get(), a, null)) { + apps.add(a); + } } else if (data.startsWith(ShortcutData.SHORTCUT_NAME)) { a = new ShortcutData(); a.read(reader, data); apps.add(a); - //Toast.makeText(contextRef.get(), "shortcutdata", Toast.LENGTH_LONG).show(); } else { data = data.trim(); if (data.length()>0 ) { diff --git a/app/src/main/java/ru/henridellal/emerald/ShortcutData.java b/app/src/main/java/ru/henridellal/emerald/ShortcutData.java index 692ba81..9af9f01 100644 --- a/app/src/main/java/ru/henridellal/emerald/ShortcutData.java +++ b/app/src/main/java/ru/henridellal/emerald/ShortcutData.java @@ -3,6 +3,7 @@ import android.database.Cursor; import java.io.BufferedReader; +import java.io.BufferedWriter; import java.io.IOException; public class ShortcutData extends BaseData { @@ -54,24 +55,19 @@ public void read(BufferedReader reader, String firstLineOfData){ try { this.name = firstLineOfData.substring(1).trim(); this.uri = readLine(reader, SHORTCUT_URI).substring(1).trim(); - String componentLine = readLine(reader, SHORTCUT_COMPONENT).substring(1).trim(); - this.component = (componentLine.length() == 0) ? null : componentLine; } catch (IOException e) { } } - /*public void write(BufferedWriter writer) throws IOException { + public void write(BufferedWriter writer) throws IOException { writer.write(new StringBuilder(SHORTCUT_NAME) .append(this.name) .append("\n") .append(SHORTCUT_URI) .append(this.uri) - .append("\n") - .append(SHORTCUT_COMPONENT) - .append(this.component) .append("\n").toString()); - }*/ + } @Override public int hashCode() { return getUri().hashCode(); diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 086316d..f2c50e9 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -54,6 +54,7 @@ Переименовать Найти в магазине приложений Изменить список приложений + Изменить категории Изменить категории приложения Удалить Скрытые приложения diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8c345bc..13422ec 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -58,6 +58,7 @@ Rename Edit application list Find in app market + Edit categories Edit application categories Delete Set as home