@ -24,6 +24,8 @@ import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.DialogUtilities ;
import com.todoroo.andlib.utility.Preferences ;
import com.todoroo.andlib.utility.TodorooPreferenceActivity ;
import com.todoroo.astrid.actfm.sync.ActFmSyncService ;
import com.todoroo.astrid.actfm.sync.ActFmSyncThread ;
import com.todoroo.astrid.dao.Database ;
import com.todoroo.astrid.data.Task ;
import com.todoroo.astrid.gcal.GCalHelper ;
@ -43,6 +45,8 @@ public class OldTaskPreferences extends TodorooPreferenceActivity {
@Autowired MetadataService metadataService ;
@Autowired Database database ;
@Autowired ActFmSyncService actFmSyncService ;
ProgressDialog pd ;
@Override
@ -65,6 +69,15 @@ public class OldTaskPreferences extends TodorooPreferenceActivity {
}
} ) ;
preference = screen . findPreference ( getString ( R . string . EPr_reset_sync_state ) ) ;
preference . setOnPreferenceClickListener ( new OnPreferenceClickListener ( ) {
@Override
public boolean onPreferenceClick ( Preference p ) {
showResetSyncStateDialog ( ) ;
return true ;
}
} ) ;
preference = screen . findPreference ( getString ( R . string . EPr_manage_purge_deleted ) ) ;
preference . setOnPreferenceClickListener ( new OnPreferenceClickListener ( ) {
public boolean onPreferenceClick ( Preference p ) {
@ -287,6 +300,22 @@ public class OldTaskPreferences extends TodorooPreferenceActivity {
} , null ) ;
}
private void showResetSyncStateDialog ( ) {
DialogUtilities . okCancelDialog ( this , getString ( R . string . EPr_reset_sync_state_detailed ) , new OnClickListener ( ) {
@Override
public void onClick ( DialogInterface dialog , int which ) {
pd = DialogUtilities . runWithProgressDialog ( OldTaskPreferences . this , new Runnable ( ) {
@Override
public void run ( ) {
actFmSyncService . refreshToken ( ) ;
ActFmSyncThread . clearTablePushedAtValues ( ) ;
//TODO: Maybe clear outstanding tables?
}
} ) ;
}
} , null ) ;
}
protected void showResult ( int resourceText , int result ) {
DialogUtilities . okDialog ( this , getString ( resourceText , result ) , null ) ;
}