@ -702,7 +702,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
bnvActions . getMenu ( ) . findItem ( R . id . action_delete ) . setVisible (
bnvActions . getMenu ( ) . findItem ( R . id . action_delete ) . setVisible (
( inTrash & & message . msgid ! = null ) | |
( inTrash & & message . msgid ! = null ) | |
( ! inTrash & & hasTrash & & message . uid ! = null ) | |
( ! inTrash & & hasTrash & & message . uid ! = null ) | |
( inOutbox & & !TextUtils . isEmpty ( message . error ) ) ) ;
( inOutbox & & (message . ui_snoozed ! = null | | !TextUtils . isEmpty ( message . error ) ) ) ) ;
bnvActions . getMenu ( ) . findItem ( R . id . action_delete ) . setTitle ( inTrash ? R . string . title_delete : R . string . title_trash ) ;
bnvActions . getMenu ( ) . findItem ( R . id . action_delete ) . setTitle ( inTrash ? R . string . title_delete : R . string . title_trash ) ;
bnvActions . getMenu ( ) . findItem ( R . id . action_move ) . setVisible ( message . uid ! = null ) ;
bnvActions . getMenu ( ) . findItem ( R . id . action_move ) . setVisible ( message . uid ! = null ) ;
bnvActions . getMenu ( ) . findItem ( R . id . action_archive ) . setVisible ( message . uid ! = null & & ! inArchive & & hasArchive ) ;
bnvActions . getMenu ( ) . findItem ( R . id . action_archive ) . setVisible ( message . uid ! = null & & ! inArchive & & hasArchive ) ;
@ -774,6 +774,53 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
}
}
}
private void onShowSnoozed ( TupleMessageEx message ) {
if ( message . ui_snoozed ! = null )
Toast . makeText ( context , new Date ( message . ui_snoozed ) . toString ( ) , Toast . LENGTH_LONG ) . show ( ) ;
}
private void onToggleFlag ( TupleMessageEx message ) {
Bundle args = new Bundle ( ) ;
args . putLong ( "id" , message . id ) ;
args . putBoolean ( "flagged" , ! message . ui_flagged ) ;
args . putBoolean ( "thread" , viewType ! = ViewType . THREAD ) ;
Log . i ( "Set message id=" + message . id + " flagged=" + ! message . ui_flagged ) ;
new SimpleTask < Void > ( ) {
@Override
protected Void onExecute ( Context context , Bundle args ) {
long id = args . getLong ( "id" ) ;
boolean flagged = args . getBoolean ( "flagged" ) ;
boolean thread = args . getBoolean ( "thread" ) ;
DB db = DB . getInstance ( context ) ;
try {
db . beginTransaction ( ) ;
EntityMessage message = db . message ( ) . getMessage ( id ) ;
if ( message = = null )
return null ;
List < EntityMessage > messages = db . message ( ) . getMessageByThread (
message . account , message . thread , threading & & thread ? null : id , message . folder ) ;
for ( EntityMessage threaded : messages )
EntityOperation . queue ( context , db , threaded , EntityOperation . FLAG , flagged ) ;
db . setTransactionSuccessful ( ) ;
} finally {
db . endTransaction ( ) ;
}
return null ;
}
@Override
protected void onException ( Bundle args , Throwable ex ) {
Helper . unexpectedError ( context , owner , ex ) ;
}
} . execute ( context , owner , args , "message:flag" ) ;
}
private void onAddContact ( TupleMessageEx message ) {
private void onAddContact ( TupleMessageEx message ) {
for ( Address address : message . from ) {
for ( Address address : message . from ) {
InternetAddress ia = ( InternetAddress ) address ;
InternetAddress ia = ( InternetAddress ) address ;
@ -1139,26 +1186,26 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
switch ( item . getItemId ( ) ) {
switch ( item . getItemId ( ) ) {
case R . id . action_more :
case R . id . action_more :
on More( data ) ;
on Action More( data ) ;
return true ;
return true ;
case R . id . action_delete :
case R . id . action_delete :
on Delete( data ) ;
on Action Delete( data ) ;
return true ;
return true ;
case R . id . action_move :
case R . id . action_move :
on Move( data ) ;
on Action Move( data ) ;
return true ;
return true ;
case R . id . action_archive :
case R . id . action_archive :
onA rchive( data ) ;
onA ctionA rchive( data ) ;
return true ;
return true ;
case R . id . action_reply :
case R . id . action_reply :
on Reply( data , false ) ;
on Action Reply( data , false ) ;
return true ;
return true ;
default :
default :
return false ;
return false ;
}
}
}
}
private void on Junk( final ActionData data ) {
private void on Menu Junk( final ActionData data ) {
new DialogBuilderLifecycle ( context , owner )
new DialogBuilderLifecycle ( context , owner )
. setMessage ( R . string . title_ask_spam )
. setMessage ( R . string . title_ask_spam )
. setPositiveButton ( android . R . string . ok , new DialogInterface . OnClickListener ( ) {
. setPositiveButton ( android . R . string . ok , new DialogInterface . OnClickListener ( ) {
@ -1202,7 +1249,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
. show ( ) ;
. show ( ) ;
}
}
private void on Forward( final ActionData data , final boolean raw ) {
private void on Menu Forward( final ActionData data , final boolean raw ) {
Bundle args = new Bundle ( ) ;
Bundle args = new Bundle ( ) ;
args . putLong ( "id" , data . message . id ) ;
args . putLong ( "id" , data . message . id ) ;
@ -1245,7 +1292,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} . execute ( context , owner , args , "message:forward" ) ;
} . execute ( context , owner , args , "message:forward" ) ;
}
}
private void on Answer( final ActionData data ) {
private void on Menu Answer( final ActionData data ) {
new SimpleTask < List < EntityAnswer > > ( ) {
new SimpleTask < List < EntityAnswer > > ( ) {
@Override
@Override
protected List < EntityAnswer > onExecute ( Context context , Bundle args ) {
protected List < EntityAnswer > onExecute ( Context context , Bundle args ) {
@ -1313,7 +1360,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} . execute ( context , owner , new Bundle ( ) , "message:answer" ) ;
} . execute ( context , owner , new Bundle ( ) , "message:answer" ) ;
}
}
private void on Unseen( final ActionData data ) {
private void on Menu Unseen( final ActionData data ) {
Bundle args = new Bundle ( ) ;
Bundle args = new Bundle ( ) ;
args . putLong ( "id" , data . message . id ) ;
args . putLong ( "id" , data . message . id ) ;
@ -1353,54 +1400,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} . execute ( context , owner , args , "message:unseen" ) ;
} . execute ( context , owner , args , "message:unseen" ) ;
}
}
private void onShowSnoozed ( TupleMessageEx message ) {
private void onMenuShare ( ActionData data ) {
if ( message . ui_snoozed ! = null )
Toast . makeText ( context , new Date ( message . ui_snoozed ) . toString ( ) , Toast . LENGTH_LONG ) . show ( ) ;
}
private void onToggleFlag ( TupleMessageEx message ) {
Bundle args = new Bundle ( ) ;
args . putLong ( "id" , message . id ) ;
args . putBoolean ( "flagged" , ! message . ui_flagged ) ;
args . putBoolean ( "thread" , viewType ! = ViewType . THREAD ) ;
Log . i ( "Set message id=" + message . id + " flagged=" + ! message . ui_flagged ) ;
new SimpleTask < Void > ( ) {
@Override
protected Void onExecute ( Context context , Bundle args ) {
long id = args . getLong ( "id" ) ;
boolean flagged = args . getBoolean ( "flagged" ) ;
boolean thread = args . getBoolean ( "thread" ) ;
DB db = DB . getInstance ( context ) ;
try {
db . beginTransaction ( ) ;
EntityMessage message = db . message ( ) . getMessage ( id ) ;
if ( message = = null )
return null ;
List < EntityMessage > messages = db . message ( ) . getMessageByThread (
message . account , message . thread , threading & & thread ? null : id , message . folder ) ;
for ( EntityMessage threaded : messages )
EntityOperation . queue ( context , db , threaded , EntityOperation . FLAG , flagged ) ;
db . setTransactionSuccessful ( ) ;
} finally {
db . endTransaction ( ) ;
}
return null ;
}
@Override
protected void onException ( Bundle args , Throwable ex ) {
Helper . unexpectedError ( context , owner , ex ) ;
}
} . execute ( context , owner , args , "message:flag" ) ;
}
private void onShare ( ActionData data ) {
Bundle args = new Bundle ( ) ;
Bundle args = new Bundle ( ) ;
args . putLong ( "id" , data . message . id ) ;
args . putLong ( "id" , data . message . id ) ;
@ -1452,7 +1452,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} . execute ( context , owner , args , "message:share" ) ;
} . execute ( context , owner , args , "message:share" ) ;
}
}
private void on ShowHeaders( ActionData data ) {
private void on Menu ShowHeaders( ActionData data ) {
boolean show_headers = ! properties . getValue ( "headers" , data . message . id ) ;
boolean show_headers = ! properties . getValue ( "headers" , data . message . id ) ;
properties . setValue ( "headers" , data . message . id , show_headers ) ;
properties . setValue ( "headers" , data . message . id , show_headers ) ;
if ( show_headers & & data . message . headers = = null ) {
if ( show_headers & & data . message . headers = = null ) {
@ -1496,7 +1496,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
notifyDataSetChanged ( ) ;
notifyDataSetChanged ( ) ;
}
}
private void onM anageKeywords( ActionData data ) {
private void onM enuM anageKeywords( ActionData data ) {
if ( ! Helper . isPro ( context ) ) {
if ( ! Helper . isPro ( context ) ) {
LocalBroadcastManager lbm = LocalBroadcastManager . getInstance ( context ) ;
LocalBroadcastManager lbm = LocalBroadcastManager . getInstance ( context ) ;
lbm . sendBroadcast ( new Intent ( ActivityView . ACTION_SHOW_PRO ) ) ;
lbm . sendBroadcast ( new Intent ( ActivityView . ACTION_SHOW_PRO ) ) ;
@ -1627,14 +1627,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} . execute ( context , owner , args , "message:keywords" ) ;
} . execute ( context , owner , args , "message:keywords" ) ;
}
}
private void on Decrypt( ActionData data ) {
private void on Menu Decrypt( ActionData data ) {
LocalBroadcastManager lbm = LocalBroadcastManager . getInstance ( context ) ;
LocalBroadcastManager lbm = LocalBroadcastManager . getInstance ( context ) ;
lbm . sendBroadcast (
lbm . sendBroadcast (
new Intent ( ActivityView . ACTION_DECRYPT )
new Intent ( ActivityView . ACTION_DECRYPT )
. putExtra ( "id" , data . message . id ) ) ;
. putExtra ( "id" , data . message . id ) ) ;
}
}
private void on More( final ActionData data ) {
private void on Action More( final ActionData data ) {
boolean show_headers = properties . getValue ( "headers" , data . message . id ) ;
boolean show_headers = properties . getValue ( "headers" , data . message . id ) ;
View anchor = bnvActions . findViewById ( R . id . action_more ) ;
View anchor = bnvActions . findViewById ( R . id . action_more ) ;
@ -1668,34 +1668,34 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
public boolean onMenuItemClick ( MenuItem target ) {
public boolean onMenuItemClick ( MenuItem target ) {
switch ( target . getItemId ( ) ) {
switch ( target . getItemId ( ) ) {
case R . id . menu_junk :
case R . id . menu_junk :
on Junk( data ) ;
on Menu Junk( data ) ;
return true ;
return true ;
case R . id . menu_forward :
case R . id . menu_forward :
on Forward( data , false ) ;
on Menu Forward( data , false ) ;
return true ;
return true ;
case R . id . menu_forward_raw :
case R . id . menu_forward_raw :
on Forward( data , true ) ;
on Menu Forward( data , true ) ;
return true ;
return true ;
case R . id . menu_reply_all :
case R . id . menu_reply_all :
on Reply( data , true ) ;
on Action Reply( data , true ) ;
return true ;
return true ;
case R . id . menu_answer :
case R . id . menu_answer :
on Answer( data ) ;
on Menu Answer( data ) ;
return true ;
return true ;
case R . id . menu_unseen :
case R . id . menu_unseen :
on Unseen( data ) ;
on Menu Unseen( data ) ;
return true ;
return true ;
case R . id . menu_share :
case R . id . menu_share :
on Share( data ) ;
on Menu Share( data ) ;
return true ;
return true ;
case R . id . menu_show_headers :
case R . id . menu_show_headers :
on ShowHeaders( data ) ;
on Menu ShowHeaders( data ) ;
return true ;
return true ;
case R . id . menu_manage_keywords :
case R . id . menu_manage_keywords :
onM anageKeywords( data ) ;
onM enuM anageKeywords( data ) ;
return true ;
return true ;
case R . id . menu_decrypt :
case R . id . menu_decrypt :
on Decrypt( data ) ;
on Menu Decrypt( data ) ;
return true ;
return true ;
default :
default :
return false ;
return false ;
@ -1705,7 +1705,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
popupMenu . show ( ) ;
popupMenu . show ( ) ;
}
}
private void on Delete( final ActionData data ) {
private void on Action Delete( final ActionData data ) {
if ( data . delete ) {
if ( data . delete ) {
// No trash or is trash
// No trash or is trash
new DialogBuilderLifecycle ( context , owner )
new DialogBuilderLifecycle ( context , owner )
@ -1729,8 +1729,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if ( message = = null )
if ( message = = null )
return null ;
return null ;
if ( message . uid = = null & & ! TextUtils . isEmpty ( message . error ) ) {
EntityFolder folder = db . folder ( ) . getFolder ( message . folder ) ;
// outbox
if ( EntityFolder . OUTBOX . equals ( folder . type ) & &
( message . ui_snoozed ! = null | | ! TextUtils . isEmpty ( message . error ) ) ) {
db . message ( ) . deleteMessage ( id ) ;
db . message ( ) . deleteMessage ( id ) ;
db . folder ( ) . setFolderError ( message . folder , null ) ;
db . folder ( ) . setFolderError ( message . folder , null ) ;
@ -1762,7 +1764,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
properties . move ( data . message . id , EntityFolder . TRASH , true ) ;
properties . move ( data . message . id , EntityFolder . TRASH , true ) ;
}
}
private void on Move( ActionData data ) {
private void on Action Move( ActionData data ) {
Bundle args = new Bundle ( ) ;
Bundle args = new Bundle ( ) ;
args . putLong ( "id" , data . message . id ) ;
args . putLong ( "id" , data . message . id ) ;
@ -1848,11 +1850,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} . execute ( context , owner , args , "message:move:list" ) ;
} . execute ( context , owner , args , "message:move:list" ) ;
}
}
private void onA rchive( ActionData data ) {
private void onA ctionA rchive( ActionData data ) {
properties . move ( data . message . id , EntityFolder . ARCHIVE , true ) ;
properties . move ( data . message . id , EntityFolder . ARCHIVE , true ) ;
}
}
private void on Reply( final ActionData data , final boolean all ) {
private void on Action Reply( final ActionData data , final boolean all ) {
Bundle args = new Bundle ( ) ;
Bundle args = new Bundle ( ) ;
args . putLong ( "id" , data . message . id ) ;
args . putLong ( "id" , data . message . id ) ;