Make it possible to copy analysis information to the clipboard

The analysis information is copied as text to the clipboard. The full
text is copied, so the "truncate variations" and "hide statistics"
settings have no effect on the text put in the clipboard.
This commit is contained in:
Peter Osterlund 2020-02-08 14:33:48 +01:00
parent 2e7b345de0
commit 9face3a9f7
2 changed files with 25 additions and 7 deletions

View File

@ -2822,15 +2822,17 @@ public class DroidFish extends Activity
}
private Dialog thinkingMenuDialog() {
final int ADD_ANALYSIS = 0;
final int MULTIPV_SET = 1;
final int SHOW_WHOLE_VARS = 2;
final int TRUNCATE_VARS = 3;
final int HIDE_STATISTICS = 4;
final int SHOW_STATISTICS = 5;
final int ADD_ANALYSIS = 0;
final int COPY_TO_CLIPBOARD = 1;
final int MULTIPV_SET = 2;
final int SHOW_WHOLE_VARS = 3;
final int TRUNCATE_VARS = 4;
final int HIDE_STATISTICS = 5;
final int SHOW_STATISTICS = 6;
List<String> lst = new ArrayList<>();
final List<Integer> actions = new ArrayList<>();
lst.add(getString(R.string.add_analysis)); actions.add(ADD_ANALYSIS);
lst.add(getString(R.string.add_analysis)); actions.add(ADD_ANALYSIS);
lst.add(getString(R.string.copy_to_clipboard)); actions.add(COPY_TO_CLIPBOARD);
int numPV = this.numPV;
final int maxPV = ctrl.maxPV();
if (gameMode.analysisMode()) {
@ -2878,6 +2880,21 @@ public class DroidFish extends Activity
}
break;
}
case COPY_TO_CLIPBOARD: {
StringBuilder sb = new StringBuilder();
if (!thinkingStr1.isEmpty()) {
sb.append(thinkingStr1);
if (!thinkingStr2.isEmpty())
sb.append('\n');
}
sb.append(thinkingStr2);
ClipboardManager clipboard = (ClipboardManager)getSystemService(CLIPBOARD_SERVICE);
ClipData cd = new ClipData("DroidFish game",
new String[]{ ClipDescription.MIMETYPE_TEXT_PLAIN },
new ClipData.Item(sb.toString()));
clipboard.setPrimaryClip(cd);
break;
}
case MULTIPV_SET: {
MultiPVSet m = new MultiPVSet();
m.multiPVDialog(numPVF, maxPV);

View File

@ -183,6 +183,7 @@ If you are running on battery power, it is recommended that you change settings
<string name="failed_to_read_pgn_data">Failed to read PGN data</string>
<string name="variation">Var:</string>
<string name="add_analysis">Add Analysis</string>
<string name="copy_to_clipboard">Copy to Clipboard</string>
<string name="num_variations">Number of Variations</string>
<string name="hide_statistics">Hide statistics</string>
<string name="show_statistics">Show statistics</string>