@ -247,100 +247,9 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
if ( savedInstanceState ! = null )
if ( savedInstanceState ! = null )
drawerToggle . setDrawerIndicatorEnabled ( savedInstanceState . getBoolean ( "toggle" ) ) ;
drawerToggle . setDrawerIndicatorEnabled ( savedInstanceState . getBoolean ( "toggle" ) ) ;
new SimpleTask < Long > ( ) {
@Override
protected Long onLoad ( Context context , Bundle args ) throws Throwable {
File file = new File ( context . getCacheDir ( ) , "crash.log" ) ;
if ( file . exists ( ) ) {
/ / Get version info
StringBuilder sb = new StringBuilder ( ) ;
sb . append ( context . getString ( R . string . title_crash_info_remark ) + "\n\n\n\n" ) ;
sb . append ( String . format ( "%s: %s\r\n" , context . getString ( R . string . app_name ) , BuildConfig . VERSION_NAME ) ) ;
sb . append ( String . format ( "Android: %s (SDK %d)\r\n" , Build . VERSION . RELEASE , Build . VERSION . SDK_INT ) ) ;
sb . append ( "\r\n" ) ;
/ / Get device info
sb . append ( String . format ( "Brand: %s\r\n" , Build . BRAND ) ) ;
sb . append ( String . format ( "Manufacturer: %s\r\n" , Build . MANUFACTURER ) ) ;
sb . append ( String . format ( "Model: %s\r\n" , Build . MODEL ) ) ;
sb . append ( String . format ( "Product: %s\r\n" , Build . PRODUCT ) ) ;
sb . append ( String . format ( "Device: %s\r\n" , Build . DEVICE ) ) ;
sb . append ( String . format ( "Host: %s\r\n" , Build . HOST ) ) ;
sb . append ( String . format ( "Display: %s\r\n" , Build . DISPLAY ) ) ;
sb . append ( String . format ( "Id: %s\r\n" , Build . ID ) ) ;
sb . append ( "\r\n" ) ;
BufferedReader in = null ;
try {
String line ;
in = new BufferedReader ( new FileReader ( file ) ) ;
while ( ( line = in . readLine ( ) ) ! = null )
sb . append ( line ) . append ( "\r\n" ) ;
} finally {
if ( in ! = null )
in . close ( ) ;
}
file . delete ( ) ;
String body = "<pre>" + sb . toString ( ) . replaceAll ( "\\r?\\n" , "<br />" ) + "</pre>" ;
EntityMessage draft = null ;
DB db = DB . getInstance ( context ) ;
try {
db . beginTransaction ( ) ;
EntityFolder drafts = db . folder ( ) . getPrimaryDrafts ( ) ;
if ( drafts ! = null ) {
draft = new EntityMessage ( ) ;
draft . account = drafts . account ;
draft . folder = drafts . id ;
draft . msgid = EntityMessage . generateMessageId ( ) ;
draft . to = new Address [ ] { Helper . myAddress ( ) } ;
draft . subject = context . getString ( R . string . app_name ) + " " + BuildConfig . VERSION_NAME + " crash log" ;
draft . content = true ;
draft . received = new Date ( ) . getTime ( ) ;
draft . seen = false ;
draft . ui_seen = false ;
draft . flagged = false ;
draft . ui_flagged = false ;
draft . ui_hide = false ;
draft . ui_found = false ;
draft . id = db . message ( ) . insertMessage ( draft ) ;
draft . write ( context , body ) ;
}
EntityOperation . queue ( db , draft , EntityOperation . ADD ) ;
db . setTransactionSuccessful ( ) ;
} finally {
db . endTransaction ( ) ;
}
EntityOperation . process ( context ) ;
return ( draft = = null ? null : draft . id ) ;
}
return null ;
}
@Override
protected void onLoaded ( Bundle args , Long id ) {
if ( id ! = null )
startActivity (
new Intent ( ActivityView . this , ActivityCompose . class )
. putExtra ( "action" , "edit" )
. putExtra ( "id" , id ) ) ;
}
} . load ( this , new Bundle ( ) ) ;
checkFirst ( ) ;
checkIntent ( getIntent ( ) ) ;
checkIntent ( getIntent ( ) ) ;
checkCrash ( ) ;
if ( ! Helper . isPlayStoreInstall ( this ) )
if ( ! Helper . isPlayStoreInstall ( this ) )
checkUpdate ( ) ;
checkUpdate ( ) ;
}
}
@ -433,6 +342,115 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
}
}
}
}
private void checkFirst ( ) {
final SharedPreferences prefs = PreferenceManager . getDefaultSharedPreferences ( this ) ;
if ( prefs . getBoolean ( "first" , true ) ) {
new AlertDialog . Builder ( this )
. setMessage ( getString ( R . string . title_hint_sync ) )
. setPositiveButton ( android . R . string . ok , new DialogInterface . OnClickListener ( ) {
@Override
public void onClick ( DialogInterface dialog , int which ) {
prefs . edit ( ) . putBoolean ( "first" , false ) . apply ( ) ;
}
} )
. show ( ) ;
}
}
private void checkCrash ( ) {
new SimpleTask < Long > ( ) {
@Override
protected Long onLoad ( Context context , Bundle args ) throws Throwable {
File file = new File ( context . getCacheDir ( ) , "crash.log" ) ;
if ( file . exists ( ) ) {
/ / Get version info
StringBuilder sb = new StringBuilder ( ) ;
sb . append ( context . getString ( R . string . title_crash_info_remark ) + "\n\n\n\n" ) ;
sb . append ( String . format ( "%s: %s\r\n" , context . getString ( R . string . app_name ) , BuildConfig . VERSION_NAME ) ) ;
sb . append ( String . format ( "Android: %s (SDK %d)\r\n" , Build . VERSION . RELEASE , Build . VERSION . SDK_INT ) ) ;
sb . append ( "\r\n" ) ;
/ / Get device info
sb . append ( String . format ( "Brand: %s\r\n" , Build . BRAND ) ) ;
sb . append ( String . format ( "Manufacturer: %s\r\n" , Build . MANUFACTURER ) ) ;
sb . append ( String . format ( "Model: %s\r\n" , Build . MODEL ) ) ;
sb . append ( String . format ( "Product: %s\r\n" , Build . PRODUCT ) ) ;
sb . append ( String . format ( "Device: %s\r\n" , Build . DEVICE ) ) ;
sb . append ( String . format ( "Host: %s\r\n" , Build . HOST ) ) ;
sb . append ( String . format ( "Display: %s\r\n" , Build . DISPLAY ) ) ;
sb . append ( String . format ( "Id: %s\r\n" , Build . ID ) ) ;
sb . append ( "\r\n" ) ;
BufferedReader in = null ;
try {
String line ;
in = new BufferedReader ( new FileReader ( file ) ) ;
while ( ( line = in . readLine ( ) ) ! = null )
sb . append ( line ) . append ( "\r\n" ) ;
} finally {
if ( in ! = null )
in . close ( ) ;
}
file . delete ( ) ;
String body = "<pre>" + sb . toString ( ) . replaceAll ( "\\r?\\n" , "<br />" ) + "</pre>" ;
EntityMessage draft = null ;
DB db = DB . getInstance ( context ) ;
try {
db . beginTransaction ( ) ;
EntityFolder drafts = db . folder ( ) . getPrimaryDrafts ( ) ;
if ( drafts ! = null ) {
draft = new EntityMessage ( ) ;
draft . account = drafts . account ;
draft . folder = drafts . id ;
draft . msgid = EntityMessage . generateMessageId ( ) ;
draft . to = new Address [ ] { Helper . myAddress ( ) } ;
draft . subject = context . getString ( R . string . app_name ) + " " + BuildConfig . VERSION_NAME + " crash log" ;
draft . content = true ;
draft . received = new Date ( ) . getTime ( ) ;
draft . seen = false ;
draft . ui_seen = false ;
draft . flagged = false ;
draft . ui_flagged = false ;
draft . ui_hide = false ;
draft . ui_found = false ;
draft . id = db . message ( ) . insertMessage ( draft ) ;
draft . write ( context , body ) ;
}
EntityOperation . queue ( db , draft , EntityOperation . ADD ) ;
db . setTransactionSuccessful ( ) ;
} finally {
db . endTransaction ( ) ;
}
EntityOperation . process ( context ) ;
return ( draft = = null ? null : draft . id ) ;
}
return null ;
}
@Override
protected void onLoaded ( Bundle args , Long id ) {
if ( id ! = null )
startActivity (
new Intent ( ActivityView . this , ActivityCompose . class )
. putExtra ( "action" , "edit" )
. putExtra ( "id" , id ) ) ;
}
} . load ( this , new Bundle ( ) ) ;
}
private void checkIntent ( Intent intent ) {
private void checkIntent ( Intent intent ) {
Log . i ( Helper . TAG , "View intent=" + intent + " action=" + intent . getAction ( ) ) ;
Log . i ( Helper . TAG , "View intent=" + intent + " action=" + intent . getAction ( ) ) ;
String action = intent . getAction ( ) ;
String action = intent . getAction ( ) ;