diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DlgDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DlgDelegate.java index 10c2b428a..63b59aafd 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DlgDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DlgDelegate.java @@ -56,6 +56,7 @@ public class DlgDelegate { QUARANTINE_DELETE, APPLY_CONFIG, LAUNCH_THEME_CONFIG, + SEND_LOGS, // BoardDelegate UNDO_LAST_ACTION, diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java index 45177f516..cbbc46f32 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java @@ -1,6 +1,6 @@ /* -*- compile-command: "find-and-gradle.sh inXw4dDeb"; -*- */ /* - * Copyright 2009 - 2020 by Eric House (xwords@eehouse.org). All rights + * Copyright 2009 - 2021 by Eric House (xwords@eehouse.org). All rights * reserved. * * This program is free software; you can redistribute it and/or @@ -1399,6 +1399,17 @@ public class GamesListDelegate extends ListDelegateBase } // Log.ResultProcs interface + @Override + public void onDumping( final int nRecords ) + { + runOnUiThread( new Runnable() { + @Override + public void run() { + Utils.showToast( m_activity, R.string.logstore_dumping_fmt, nRecords ); + } + } ); + } + @Override public void onDumped( final File logLoc ) { @@ -1414,7 +1425,11 @@ public class GamesListDelegate extends ListDelegateBase .getString( m_activity, R.string.logstore_dumped_fmt, logLoc.getPath() ); } - makeOkOnlyBuilder( dumpMsg ).show(); + makeOkOnlyBuilder( dumpMsg ) + .setParams( logLoc ) + .setPosButton( android.R.string.cancel ) + .setActionPair( Action.SEND_LOGS, R.string.button_send_logs ) + .show(); } } ); } @@ -1561,6 +1576,11 @@ public class GamesListDelegate extends ListDelegateBase CommonPrefs.loadColorPrefs( m_activity, data ); break; + case SEND_LOGS: + File logLoc = (File)params[0]; + Utils.emailLogFile( m_activity, logLoc ); + break; + default: handled = super.onPosButton( action, params ); } @@ -1725,6 +1745,7 @@ public class GamesListDelegate extends ListDelegateBase enable = Log.getStoreLogs(); Utils.setItemVisible( menu, R.id.games_menu_enableLogStorage, !enable ); Utils.setItemVisible( menu, R.id.games_menu_disableLogStorage, enable ); + Utils.setItemVisible( menu, R.id.games_menu_emailLogs, enable ); Assert.assertTrue( m_menuPrepared ); } @@ -1843,7 +1864,7 @@ public class GamesListDelegate extends ListDelegateBase .setPosButton( R.string.loc_item_clear ) .show(); break; - case R.id.games_menu_dumpLogStorage: + case R.id.games_menu_emailLogs: Perms23.tryGetPerms( this, Perm.STORAGE, null, Action.WRITE_LOG_DB ); break; diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Log.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Log.java index 1d4fedd86..35755b391 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Log.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Log.java @@ -1,6 +1,6 @@ /* -*- compile-command: "find-and-gradle.sh inXw4dDeb"; -*- */ /* - * Copyright 2009 - 2020 by Eric House (xwords@eehouse.org). All rights + * Copyright 2009 - 2021 by Eric House (xwords@eehouse.org). All rights * reserved. * * This program is free software; you can redistribute it and/or @@ -95,6 +95,7 @@ public class Log { } interface ResultProcs { + void onDumping( int nRecords ); void onDumped( File db ); void onCleared( int nCleared ); } @@ -309,9 +310,11 @@ public class Log { String selection = null; String orderBy = COL_ROWID; Cursor cursor = getReadableDatabase().query( LOGS_TABLE_NAME, columns, - selection, null, null, null, - orderBy ); - llog( "dumpToFile(): got %d results", cursor.getCount() ); + selection, null, null, + null, orderBy ); + procs.onDumping( cursor.getCount() ); + + llog( "dumpToFile(): db=%s; got %d results", db, cursor.getCount() ); int[] indices = new int[columns.length]; for ( int ii = 0; ii < indices.length; ++ii ) { indices[ii] = cursor.getColumnIndex( columns[ii] ); diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Utils.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Utils.java index f477297a5..af243f003 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Utils.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Utils.java @@ -194,15 +194,36 @@ public class Utils { } public static void emailAuthor( Context context, String msg ) + { + emailAuthorImpl( context, msg, R.string.email_author_subject, + R.string.email_author_chooser, null ); + } + + public static void emailLogFile( Context context, File attachment ) + { + String msg = LocUtils.getString( context, R.string.email_logs_msg ); + emailAuthorImpl( context, msg, R.string.email_logs_subject, + R.string.email_logs_chooser, attachment ); + } + + private static void emailAuthorImpl( Context context, String msg, int subject, + int chooser, File attachment ) { Intent intent = new Intent( Intent.ACTION_SEND ); intent.setType( "message/rfc822" ); // force email intent.putExtra( Intent.EXTRA_SUBJECT, - LocUtils.getString( context, - R.string.email_author_subject ) ); + LocUtils.getString( context, subject ) ); String[] addrs = { LocUtils.getString( context, R.string.email_author_email ) }; intent.putExtra( Intent.EXTRA_EMAIL, addrs ); + + if ( null != attachment ) { + Uri uri = FileProvider.getUriForFile( context, + context.getPackageName() + ".provider", + attachment ); + intent.putExtra( Intent.EXTRA_STREAM, uri ); + } + String devID = XwJNI.dvc_getMQTTDevID( null ); String body = LocUtils.getString( context, R.string.email_body_rev_fmt, BuildConfig.GIT_REV, Build.MODEL, @@ -211,8 +232,7 @@ public class Utils { body += "\n\n" + msg; } intent.putExtra( Intent.EXTRA_TEXT, body ); - String chooserMsg = LocUtils.getString( context, - R.string.email_author_chooser ); + String chooserMsg = LocUtils.getString( context, chooser ); context.startActivity( Intent.createChooser( intent, chooserMsg ) ); } diff --git a/xwords4/android/app/src/main/res/menu/games_list_menu.xml b/xwords4/android/app/src/main/res/menu/games_list_menu.xml index 51542e5f6..6d66200e5 100644 --- a/xwords4/android/app/src/main/res/menu/games_list_menu.xml +++ b/xwords4/android/app/src/main/res/menu/games_list_menu.xml @@ -135,8 +135,8 @@ - Email author… Comment about CrossWords + + Logs attached + + CrossWords Logs Send comment via + + Send logs via (If relevant, please include the version (“%1$s”) of CrossDbg, the make/model (“%2$s”) and OS @@ -2653,12 +2660,16 @@ Disable log storage Clear stored logs - - Write stored logs to file + + Email logs Logs written to file %1$s + + Compressing %1$d log entries Unable to write logs + + Send to author %1$d log entries deleted diff --git a/xwords4/android/res_src/values-fr/strings.xml b/xwords4/android/res_src/values-fr/strings.xml index 6831d2ee7..37bbec4b1 100644 --- a/xwords4/android/res_src/values-fr/strings.xml +++ b/xwords4/android/res_src/values-fr/strings.xml @@ -3080,7 +3080,6 @@ pour la langue %1$d entrées de logs supprimées Impossible d\'écrire les logs Logs écrits dans le fichier %1$s - Écrire dans un fichier les logs stockés Effacer les logs stockés Désactiver le stockage des logs Activer le stockage des logs diff --git a/xwords4/android/res_src/values-it/strings.xml b/xwords4/android/res_src/values-it/strings.xml index 475cc60fc..c93d05deb 100644 --- a/xwords4/android/res_src/values-it/strings.xml +++ b/xwords4/android/res_src/values-it/strings.xml @@ -32,7 +32,6 @@ %1$d log cancellati Impossibile scrivere i log Log scritti sul file %1$s - Scrivi log salvati su file Elimina log salvati Disattivo archivio per i log Attiva archivio per i Log diff --git a/xwords4/android/res_src/values-ja/strings.xml b/xwords4/android/res_src/values-ja/strings.xml index 654299915..a9328e2ba 100644 --- a/xwords4/android/res_src/values-ja/strings.xml +++ b/xwords4/android/res_src/values-ja/strings.xml @@ -934,7 +934,6 @@ WiFi ダイレクト経由で接続可能なデバイスはありません。%1$d ログエントリーを削除しました ログの書き込みができません ログをファイル %1$s に書き込みました - 保存されたログをファイルに書き込む 保存されたログを消去する ログの保存を無効にする ログの保存を有効にする diff --git a/xwords4/android/res_src/values-nb-rNO/strings.xml b/xwords4/android/res_src/values-nb-rNO/strings.xml index d074745f7..fc90944e6 100644 --- a/xwords4/android/res_src/values-nb-rNO/strings.xml +++ b/xwords4/android/res_src/values-nb-rNO/strings.xml @@ -930,7 +930,6 @@ \n %1$d loggenheter sletter Kunne ikke skrive logger - Skriv lagrede logger til fil Tøm loggføring Skru av loggføring Skru på loggføring diff --git a/xwords4/android/res_src/values-pt-rBR/strings.xml b/xwords4/android/res_src/values-pt-rBR/strings.xml index fbc3e1c1b..c81cb087a 100644 --- a/xwords4/android/res_src/values-pt-rBR/strings.xml +++ b/xwords4/android/res_src/values-pt-rBR/strings.xml @@ -632,7 +632,6 @@ Tem certeza que quer apagar seus logs de debug\? Esta ação não pode ser desfeita. Incapaz de escrever logs Logs escritos no arquivo %1$s - Escrever logs armazenados no arquivo Limpar logs armazenados Desativar armazenamento de logs Ativar armazenamento de logs diff --git a/xwords4/android/res_src/values-pt/strings.xml b/xwords4/android/res_src/values-pt/strings.xml index e2549814e..d4aae2530 100644 --- a/xwords4/android/res_src/values-pt/strings.xml +++ b/xwords4/android/res_src/values-pt/strings.xml @@ -1668,7 +1668,6 @@ %1$d entradas de log deletadas Incapaz de escrever logs Logs escritos no ficheiro %1$s - Escrever logs armazenados no ficheiro Limpar logs armazenados Desativar armazenamento de logs Ativar armazenamento de logs