mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-06 05:24:46 +01:00
add post-export option to email logs; remove export
No point in exporting only to create a file, so export-and-email as one step
This commit is contained in:
parent
f083ba9897
commit
a0f1f1d045
12 changed files with 71 additions and 21 deletions
|
@ -56,6 +56,7 @@ public class DlgDelegate {
|
|||
QUARANTINE_DELETE,
|
||||
APPLY_CONFIG,
|
||||
LAUNCH_THEME_CONFIG,
|
||||
SEND_LOGS,
|
||||
|
||||
// BoardDelegate
|
||||
UNDO_LAST_ACTION,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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] );
|
||||
|
|
|
@ -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 ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -135,8 +135,8 @@
|
|||
<item android:id="@+id/games_menu_disableLogStorage"
|
||||
android:title="@string/gamel_menu_logstore_off"
|
||||
/>
|
||||
<item android:id="@+id/games_menu_dumpLogStorage"
|
||||
android:title="@string/gamel_menu_logstore_dump"
|
||||
<item android:id="@+id/games_menu_emailLogs"
|
||||
android:title="@string/gamel_menu_logstore_email"
|
||||
/>
|
||||
<item android:id="@+id/games_menu_clearLogStorage"
|
||||
android:title="@string/gamel_menu_logstore_clear"
|
||||
|
|
|
@ -1671,8 +1671,15 @@
|
|||
<string name="board_menu_file_email">Email author…</string>
|
||||
<!-- -->
|
||||
<string name="email_author_subject">Comment about CrossWords</string>
|
||||
<!-- appended to email message sending logs (debug only) -->
|
||||
<string name="email_logs_msg">Logs attached</string>
|
||||
<!-- Subject of email containing logs (debug only) -->
|
||||
<string name="email_logs_subject">CrossWords Logs</string>
|
||||
<!-- -->
|
||||
<string name="email_author_chooser">Send comment via</string>
|
||||
<!-- Used to pick email app when sending logs, maybe on some
|
||||
Android versions. Debug only -->
|
||||
<string name="email_logs_chooser">Send logs via</string>
|
||||
<!-- Default text for email body generated by "email author" menuitem -->
|
||||
<string name="email_body_rev_fmt">(If relevant, please include the
|
||||
version (“%1$s”) of CrossDbg, the make/model (“%2$s”) and OS
|
||||
|
@ -2653,12 +2660,16 @@
|
|||
<string name="gamel_menu_logstore_off">Disable log storage</string>
|
||||
<!-- Debug-build-only menu to clear/delete saved logs -->
|
||||
<string name="gamel_menu_logstore_clear">Clear stored logs</string>
|
||||
<!-- Debug-build-only menu to write saved logs to a world-readable file -->
|
||||
<string name="gamel_menu_logstore_dump">Write stored logs to file</string>
|
||||
<!-- Debug-build-only menuitem to email logs -->
|
||||
<string name="gamel_menu_logstore_email">Email logs</string>
|
||||
<!-- Debug-build-only status message shown after logs successfully written to file -->
|
||||
<string name="logstore_dumped_fmt">Logs written to file %1$s</string>
|
||||
<!-- shown as toast when export/compression of log entries begins -->
|
||||
<string name="logstore_dumping_fmt">Compressing %1$d log entries</string>
|
||||
<!-- Debug-build-only status message shown when unable to write logs -->
|
||||
<string name="logstore_notdumped">Unable to write logs</string>
|
||||
<!-- Button shown after logs are exported, kicks off email with logs attached -->
|
||||
<string name="button_send_logs">Send to author</string>
|
||||
<!-- Debug-build-only status message shown after logs successfully cleared -->
|
||||
<string name="logstore_cleared_fmt">%1$d log entries deleted</string>
|
||||
<!-- Debug-build-only question asked to confirm deletion of saved logs -->
|
||||
|
|
|
@ -3080,7 +3080,6 @@ pour la langue</string>
|
|||
<string name="logstore_cleared_fmt">%1$d entrées de logs supprimées</string>
|
||||
<string name="logstore_notdumped">Impossible d\'écrire les logs</string>
|
||||
<string name="logstore_dumped_fmt">Logs écrits dans le fichier %1$s</string>
|
||||
<string name="gamel_menu_logstore_dump">Écrire dans un fichier les logs stockés</string>
|
||||
<string name="gamel_menu_logstore_clear">Effacer les logs stockés</string>
|
||||
<string name="gamel_menu_logstore_off">Désactiver le stockage des logs</string>
|
||||
<string name="gamel_menu_logstore_on">Activer le stockage des logs</string>
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
<string name="logstore_cleared_fmt">%1$d log cancellati</string>
|
||||
<string name="logstore_notdumped">Impossibile scrivere i log</string>
|
||||
<string name="logstore_dumped_fmt">Log scritti sul file %1$s</string>
|
||||
<string name="gamel_menu_logstore_dump">Scrivi log salvati su file</string>
|
||||
<string name="gamel_menu_logstore_clear">Elimina log salvati</string>
|
||||
<string name="gamel_menu_logstore_off">Disattivo archivio per i log</string>
|
||||
<string name="gamel_menu_logstore_on">Attiva archivio per i Log</string>
|
||||
|
|
|
@ -934,7 +934,6 @@ WiFi ダイレクト経由で接続可能なデバイスはありません。</s
|
|||
<string name="logstore_cleared_fmt">%1$d ログエントリーを削除しました</string>
|
||||
<string name="logstore_notdumped">ログの書き込みができません</string>
|
||||
<string name="logstore_dumped_fmt">ログをファイル %1$s に書き込みました</string>
|
||||
<string name="gamel_menu_logstore_dump">保存されたログをファイルに書き込む</string>
|
||||
<string name="gamel_menu_logstore_clear">保存されたログを消去する</string>
|
||||
<string name="gamel_menu_logstore_off">ログの保存を無効にする</string>
|
||||
<string name="gamel_menu_logstore_on">ログの保存を有効にする</string>
|
||||
|
|
|
@ -930,7 +930,6 @@
|
|||
\n</string>
|
||||
<string name="logstore_cleared_fmt">%1$d loggenheter sletter</string>
|
||||
<string name="logstore_notdumped">Kunne ikke skrive logger</string>
|
||||
<string name="gamel_menu_logstore_dump">Skriv lagrede logger til fil</string>
|
||||
<string name="gamel_menu_logstore_clear">Tøm loggføring</string>
|
||||
<string name="gamel_menu_logstore_off">Skru av loggføring</string>
|
||||
<string name="gamel_menu_logstore_on">Skru på loggføring</string>
|
||||
|
|
|
@ -632,7 +632,6 @@
|
|||
<string name="logstore_clear_confirm">Tem certeza que quer apagar seus logs de debug\? Esta ação não pode ser desfeita.</string>
|
||||
<string name="logstore_notdumped">Incapaz de escrever logs</string>
|
||||
<string name="logstore_dumped_fmt">Logs escritos no arquivo %1$s</string>
|
||||
<string name="gamel_menu_logstore_dump">Escrever logs armazenados no arquivo</string>
|
||||
<string name="gamel_menu_logstore_clear">Limpar logs armazenados</string>
|
||||
<string name="gamel_menu_logstore_off">Desativar armazenamento de logs</string>
|
||||
<string name="gamel_menu_logstore_on">Ativar armazenamento de logs</string>
|
||||
|
|
|
@ -1668,7 +1668,6 @@
|
|||
<string name="logstore_cleared_fmt">%1$d entradas de log deletadas</string>
|
||||
<string name="logstore_notdumped">Incapaz de escrever logs</string>
|
||||
<string name="logstore_dumped_fmt">Logs escritos no ficheiro %1$s</string>
|
||||
<string name="gamel_menu_logstore_dump">Escrever logs armazenados no ficheiro</string>
|
||||
<string name="gamel_menu_logstore_clear">Limpar logs armazenados</string>
|
||||
<string name="gamel_menu_logstore_off">Desativar armazenamento de logs</string>
|
||||
<string name="gamel_menu_logstore_on">Ativar armazenamento de logs</string>
|
||||
|
|
Loading…
Reference in a new issue