Skip to content

Commit b704bc7

Browse files
committed
add entry id debug options
1 parent 29381b7 commit b704bc7

File tree

4 files changed

+36
-15
lines changed

4 files changed

+36
-15
lines changed

app/src/main/java/rocks/tbog/tblauncher/entry/EntryItem.java

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.content.Context;
44
import android.view.View;
5+
import android.widget.Toast;
56

67
import androidx.annotation.CallSuper;
78
import androidx.annotation.LayoutRes;
@@ -20,6 +21,7 @@
2021
import rocks.tbog.tblauncher.result.ResultHelper;
2122
import rocks.tbog.tblauncher.ui.LinearAdapter;
2223
import rocks.tbog.tblauncher.ui.ListPopup;
24+
import rocks.tbog.tblauncher.utils.ClipboardUtils;
2325
import rocks.tbog.tblauncher.utils.DebugInfo;
2426
import rocks.tbog.tblauncher.utils.FuzzyScore;
2527
import rocks.tbog.tblauncher.utils.Utilities;
@@ -273,27 +275,31 @@ ListPopup inflatePopupMenu(@NonNull Context context, @NonNull LinearAdapter adap
273275
}
274276

275277
if (DebugInfo.itemRelevance(context)) {
276-
String debugTitle = context.getString(R.string.popup_title_debug);
277-
int pos = -1;
278-
// find title
279-
for (int i = 0; i < adapter.getCount(); i += 1) {
280-
if (debugTitle.equals(adapter.getItem(i).toString())) {
281-
pos = i + 1;
282-
break;
283-
}
284-
}
285-
// if title not found, add title
286-
if (pos == -1) {
287-
adapter.add(new LinearAdapter.ItemTitle(debugTitle));
288-
pos = adapter.getCount();
289-
}
290-
// add debug data after title
278+
int pos = addDebugTitleOnce(context, adapter);
291279
adapter.add(pos, new LinearAdapter.ItemString("Relevance: " + getRelevance()));
292280
}
293281

282+
if (DebugInfo.itemShowId(context)) {
283+
int pos = addDebugTitleOnce(context, adapter);
284+
adapter.add(pos, new LinearAdapter.ItemString(id));
285+
}
286+
294287
return menu;
295288
}
296289

290+
int addDebugTitleOnce(@NonNull Context context, @NonNull LinearAdapter adapter) {
291+
String debugTitle = context.getString(R.string.popup_title_debug);
292+
// find title
293+
for (int i = 0; i < adapter.getCount(); i += 1) {
294+
if (debugTitle.equals(adapter.getItem(i).toString())) {
295+
return i + 1;
296+
}
297+
}
298+
// if title not found, add title
299+
adapter.add(new LinearAdapter.ItemTitle(debugTitle));
300+
return adapter.getCount();
301+
}
302+
297303
/**
298304
* How to display the popup menu
299305
*
@@ -343,6 +349,10 @@ boolean popupMenuClickHandler(@NonNull View view, @NonNull LinearAdapter.MenuIte
343349
} else if (R.string.menu_popup_quick_list_customize == stringId) {
344350
TBApplication.behaviour(context).launchEditQuickListDialog(context);
345351
return true;
352+
} else if (id.equals(item.toString())) {
353+
ClipboardUtils.setClipboard(context, id);
354+
Toast.makeText(context, context.getString(R.string.copy_confirmation, id), Toast.LENGTH_SHORT).show();
355+
return true;
346356
}
347357

348358
// FullscreenActivity mainActivity = (FullscreenActivity) context;

app/src/main/java/rocks/tbog/tblauncher/utils/DebugInfo.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,9 @@ public static boolean itemIconInfo(Context context) {
4141
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
4242
return prefs.getBoolean("debug-item-icon-info", false);
4343
}
44+
45+
public static boolean itemShowId(Context context) {
46+
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
47+
return prefs.getBoolean("debug-item-id", false);
48+
}
4449
}

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@
218218
<string name="debug_widget_info">Long press for extra widget info</string>
219219
<string name="debug_item_relevance">Search relevance</string>
220220
<string name="debug_item_icon_info">Icon info</string>
221+
<string name="debug_item_id">Show item id</string>
221222
<string name="shortcut_section">Shortcut</string>
222223
<string name="shortcut_pin_auto_confirm">Auto-confirm shortcut</string>
223224
<string name="shortcut_show_badge">Show app badge</string>

app/src/main/res/xml/preferences.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,11 @@
11711171
android:key="debug-item-icon-info"
11721172
android:title="@string/debug_item_icon_info" />
11731173

1174+
<androidx.preference.SwitchPreference
1175+
android:defaultValue="false"
1176+
android:key="debug-item-id"
1177+
android:title="@string/debug_item_id" />
1178+
11741179
<androidx.preference.SwitchPreference
11751180
android:defaultValue="false"
11761181
android:key="debug-ksh-touch"

0 commit comments

Comments
 (0)