Skip to content

Commit

Permalink
fix dock content duplication and shortcuts addition to dock
Browse files Browse the repository at this point in the history
  • Loading branch information
HenriDellal committed Sep 23, 2018
1 parent 093c8d0 commit fa31a96
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
5 changes: 2 additions & 3 deletions app/src/main/java/ru/henridellal/emerald/Apps.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>(this, android.R.layout.simple_list_item_1, commands),
new DialogInterface.OnClickListener(){
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/ru/henridellal/emerald/Dock.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()) {
Expand All @@ -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 ) {
Expand Down
10 changes: 3 additions & 7 deletions app/src/main/java/ru/henridellal/emerald/ShortcutData.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<string name="rename">Переименовать</string>
<string name="findInMarket">Найти в магазине приложений</string>
<string name="editAppList">Изменить список приложений</string>
<string name="editCategories">Изменить категории</string>
<string name="editAppCategories">Изменить категории приложения</string>
<string name="delete">Удалить</string>
<string name="accessHidden">Скрытые приложения</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<string name="rename">Rename</string>
<string name="editAppList">Edit application list</string>
<string name="findInMarket">Find in app market</string>
<string name="editCategories">Edit categories</string>
<string name="editAppCategories">Edit application categories</string>
<string name="delete">Delete</string>
<string name="setHome">Set as home</string>
Expand Down

0 comments on commit fa31a96

Please sign in to comment.