Some bug fixes

This commit is contained in:
stom79 2018-04-28 16:54:06 +02:00
parent 08d51360fd
commit 2ea3e6971e
14 changed files with 105 additions and 87 deletions

View File

@ -177,7 +177,7 @@ public class InstanceHealthActivity extends BaseActivity {
up.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.red));
}
uptime.setText(String.format("Uptime: %.2f %%", (instanceSocial.getUptime()*100)));
checked_at.setText(String.format("Checked at: %s", Helper.dateToString(getApplicationContext(), instanceSocial.getChecked_at())));
checked_at.setText(String.format("Checked at: %s", Helper.dateToString(instanceSocial.getChecked_at())));
values.setText(String.format("version: %s \n %s users - %s statuses", instanceSocial.getVersion(), withSuffix(instanceSocial.getUsers()), withSuffix(instanceSocial.getStatuses())));
instance_container.setVisibility(View.VISIBLE);
loader.setVisibility(View.GONE);

View File

@ -364,8 +364,8 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
filterToots.setV_private(filter_visibility_private.isChecked());
filterToots.setV_direct(filter_visibility_direct.isChecked());
filterToots.setDateIni(Helper.dateToString(OwnerStatusActivity.this,dateIni));
filterToots.setDateEnd(Helper.dateToString(OwnerStatusActivity.this,dateEnd));
filterToots.setDateIni(Helper.dateToString(dateIni));
filterToots.setDateEnd(Helper.dateToString(dateEnd));
if( filter_keywords.getText() != null && filter_keywords.getText().toString().trim().length() > 0)
filterToots.setFilter(filter_keywords.getText().toString());

View File

@ -866,7 +866,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
popup_trans = getLayoutInflater().inflate( R.layout.popup_translate, null );
transAlert.setView(popup_trans);
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.LAST_TRANSLATION_TIME, Helper.dateToString(getApplicationContext(), new Date( System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(Helper.SECONDES_BETWEEN_TRANSLATE))));
editor.putString(Helper.LAST_TRANSLATION_TIME, Helper.dateToString(new Date( System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(Helper.SECONDES_BETWEEN_TRANSLATE))));
editor.apply();
TextView yandex_translate = popup_trans.findViewById(R.id.yandex_translate);
yandex_translate.setOnClickListener(new View.OnClickListener() {

View File

@ -23,6 +23,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.text.Html;
@ -446,6 +447,9 @@ public class Status implements Parcelable{
if( ((Activity)context).isFinishing() || status == null)
return;
SpannableString spannableStringContent, spannableStringCW;
if( (status.getReblog() != null && status.getReblog().getContent() == null) || (status.getReblog() == null && status.getContent() == null))
return;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
spannableStringContent = new SpannableString(Html.fromHtml(status.getReblog() != null ?status.getReblog().getContent():status.getContent(), Html.FROM_HTML_MODE_LEGACY));
else
@ -467,6 +471,8 @@ public class Status implements Parcelable{
if( ((Activity)context).isFinishing() || status == null)
return;
if( (status.getReblog() != null && status.getReblog().getContent() == null) || (status.getReblog() == null && status.getContent() == null))
return;
SpannableString spannableStringTranslated;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
spannableStringTranslated = new SpannableString(Html.fromHtml(status.getContentTranslated(), Html.FROM_HTML_MODE_LEGACY));
@ -483,6 +489,7 @@ public class Status implements Parcelable{
if( ((Activity)context).isFinishing() )
return;
final List<Emojis> emojis = status.getReblog() != null ? status.getReblog().getEmojis() : status.getEmojis();
if( emojis != null && emojis.size() > 0 ) {
final int[] i = {0};
@ -507,13 +514,14 @@ public class Status implements Parcelable{
})
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
final String targetedEmoji = ":" + emoji.getShortcode() + ":";
if (contentSpan.toString().contains(targetedEmoji)) {
//emojis can be used several times so we have to loop
for (int startPosition = -1; (startPosition = contentSpan.toString().indexOf(targetedEmoji, startPosition + 1)) != -1; startPosition++) {
final int endPosition = startPosition + targetedEmoji.length();
contentSpan.setSpan(
if( startPosition >= 0 && endPosition <= contentSpan.toString().length() && endPosition >= startPosition)
contentSpan.setSpan(
new ImageSpan(context,
Bitmap.createScaledBitmap(resource, (int) Helper.convertDpToPixel(20, context),
(int) Helper.convertDpToPixel(20, context), false)), startPosition,
@ -524,7 +532,8 @@ public class Status implements Parcelable{
//emojis can be used several times so we have to loop
for (int startPosition = -1; (startPosition = contentSpanCW.toString().indexOf(targetedEmoji, startPosition + 1)) != -1; startPosition++) {
final int endPosition = startPosition + targetedEmoji.length();
contentSpanCW.setSpan(
if( startPosition >= 0 && endPosition <= contentSpan.toString().length() && endPosition >= startPosition)
contentSpanCW.setSpan(
new ImageSpan(context,
Bitmap.createScaledBitmap(resource, (int) Helper.convertDpToPixel(20, context),
(int) Helper.convertDpToPixel(20, context), false)), startPosition,
@ -591,7 +600,8 @@ public class Status implements Parcelable{
//emojis can be used several times so we have to loop
for (int startPosition = -1; (startPosition = finalSpannableStringTranslated.toString().indexOf(targetedEmoji, startPosition + 1)) != -1; startPosition++) {
final int endPosition = startPosition + targetedEmoji.length();
finalSpannableStringTranslated.setSpan(
if( startPosition >= 0 && endPosition <= finalSpannableStringTranslated.toString().length() && endPosition >= startPosition)
finalSpannableStringTranslated.setSpan(
new ImageSpan(context,
Bitmap.createScaledBitmap(resource, (int) Helper.convertDpToPixel(20, context),
(int) Helper.convertDpToPixel(20, context), false)), startPosition,
@ -632,23 +642,25 @@ public class Status implements Parcelable{
int matchStart = matcher.start(1);
int matchEnd = matcher.end();
final String url = spannableString.toString().substring(matchStart, matchEnd);
spannableString.setSpan(new ClickableSpan() {
@Override
public void onClick(View textView) {
String finalUrl = url;
if( !url.startsWith("http://") && ! url.startsWith("https://"))
finalUrl = "http://" + url;
Helper.openBrowser(context, finalUrl);
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
ds.setUnderlineText(false);
}
},
matchStart, matchEnd,
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
spannableString.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, theme==Helper.THEME_DARK?R.color.mastodonC2:R.color.mastodonC4)), matchStart, matchEnd,
if( matchStart >= 0 && matchEnd <= spannableString.toString().length() && matchEnd >= matchStart)
spannableString.setSpan(new ClickableSpan() {
@Override
public void onClick(View textView) {
String finalUrl = url;
if( !url.startsWith("http://") && ! url.startsWith("https://"))
finalUrl = "http://" + url;
Helper.openBrowser(context, finalUrl);
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
ds.setUnderlineText(false);
}
},
matchStart, matchEnd,
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
if( matchStart >= 0 && matchEnd <= spannableString.toString().length() && matchEnd >= matchStart)
spannableString.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, theme==Helper.THEME_DARK?R.color.mastodonC2:R.color.mastodonC4)), matchStart, matchEnd,
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
}
@ -662,7 +674,8 @@ public class Status implements Parcelable{
//Accounts can be mentioned several times so we have to loop
for(int startPosition = -1 ; (startPosition = spannableString.toString().indexOf(targetedAccount, startPosition + 1)) != -1 ; startPosition++){
int endPosition = startPosition + targetedAccount.length();
spannableString.setSpan(new ClickableSpan() {
if( startPosition >= 0 && endPosition <= spannableString.toString().length() && endPosition >= startPosition)
spannableString.setSpan(new ClickableSpan() {
@Override
public void onClick(View textView) {
Intent intent = new Intent(context, ShowAccountActivity.class);
@ -679,7 +692,8 @@ public class Status implements Parcelable{
},
startPosition, endPosition,
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
spannableString.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, theme==Helper.THEME_DARK?R.color.mastodonC2:R.color.mastodonC4)), startPosition, endPosition,
if( startPosition >= 0 && endPosition <= spannableString.toString().length() && endPosition >= startPosition)
spannableString.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, theme==Helper.THEME_DARK?R.color.mastodonC2:R.color.mastodonC4)), startPosition, endPosition,
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
}
}
@ -691,22 +705,24 @@ public class Status implements Parcelable{
int matchStart = matcher.start(1);
int matchEnd = matcher.end();
final String tag = spannableString.toString().substring(matchStart, matchEnd);
spannableString.setSpan(new ClickableSpan() {
@Override
public void onClick(View textView) {
Intent intent = new Intent(context, HashTagActivity.class);
Bundle b = new Bundle();
b.putString("tag", tag.substring(1));
intent.putExtras(b);
context.startActivity(intent);
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
ds.setUnderlineText(false);
}
}, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
spannableString.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, theme==Helper.THEME_DARK?R.color.mastodonC2:R.color.mastodonC4)), matchStart, matchEnd,
if( matchStart >= 0 && matchEnd <= spannableString.toString().length() && matchEnd >= matchStart)
spannableString.setSpan(new ClickableSpan() {
@Override
public void onClick(View textView) {
Intent intent = new Intent(context, HashTagActivity.class);
Bundle b = new Bundle();
b.putString("tag", tag.substring(1));
intent.putExtras(b);
context.startActivity(intent);
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
ds.setUnderlineText(false);
}
}, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
if( matchStart >= 0 && matchEnd <= spannableString.toString().length() && matchEnd >= matchStart)
spannableString.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, theme==Helper.THEME_DARK?R.color.mastodonC2:R.color.mastodonC4)), matchStart, matchEnd,
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
}
return spannableString;

View File

@ -133,13 +133,13 @@ public class DraftsListAdapter extends BaseAdapter {
}else{
changeDrawableColor(context, holder.draft_delete, R.color.black);
}
holder.draft_date.setText(Helper.dateToString(context, draft.getCreation_date()));
holder.draft_date.setText(Helper.dateToString(draft.getCreation_date()));
holder.draft_delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage(draft.getStatus().getContent() + '\n' + Helper.dateToString(context, draft.getCreation_date()));
builder.setMessage(draft.getStatus().getContent() + '\n' + Helper.dateToString(draft.getCreation_date()));
builder.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle(R.string.remove_draft)
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {

View File

@ -155,7 +155,7 @@ public class ScheduledTootsListAdapter extends BaseAdapter {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage(status.getContent() + '\n' + Helper.dateToString(context, storedStatus.getCreation_date()));
builder.setMessage(status.getContent() + '\n' + Helper.dateToString(storedStatus.getCreation_date()));
builder.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle(R.string.remove_scheduled)
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@ -190,8 +190,8 @@ public class ScheduledTootsListAdapter extends BaseAdapter {
holder.scheduled_toot_failed.setVisibility(View.VISIBLE);
}
holder.scheduled_toot_media_count.setText(context.getString(R.string.media_count, status.getMedia_attachments().size()));
holder.scheduled_toot_date_creation.setText(Helper.dateToString(context, storedStatus.getCreation_date()));
holder.scheduled_toot_date.setText(Helper.dateToString(context, storedStatus.getScheduled_date()));
holder.scheduled_toot_date_creation.setText(Helper.dateToString(storedStatus.getCreation_date()));
holder.scheduled_toot_date.setText(Helper.dateToString(storedStatus.getScheduled_date()));
holder.scheduled_toot_date.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

View File

@ -1394,7 +1394,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
timedMute = new ArrayList<>();
timedMute.add(targeted_id);
}
Toast.makeText(context,context.getString(R.string.timed_mute_date,status.getAccount().getAcct(),Helper.dateToString(context, date_mute)), Toast.LENGTH_LONG).show();
Toast.makeText(context,context.getString(R.string.timed_mute_date,status.getAccount().getAcct(),Helper.dateToString(date_mute)), Toast.LENGTH_LONG).show();
alertDialog.dismiss();
notifyDataSetChanged();
}

View File

@ -477,19 +477,11 @@ public class Helper {
/**
* Convert a date in String -> format yyyy-MM-dd HH:mm:ss
* @param context Context
* @param date Date
* @return String
*/
public static String dateToString(Context context, Date date) {
Locale userLocale;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
userLocale = context.getResources().getConfiguration().getLocales().get(0);
} else {
//noinspection deprecation
userLocale = context.getResources().getConfiguration().locale;
}
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",userLocale);
public static String dateToString(Date date) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",Locale.getDefault());
return dateFormat.format(date);
}
@ -1965,8 +1957,7 @@ public class Helper {
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
if( resource != null)
imageView.setImageBitmap(resource);
imageView.setImageBitmap(resource);
}
});
}
@ -2117,16 +2108,27 @@ public class Helper {
Cursor returnCursor =
resolver.query(uri, null, null, null, null);
assert returnCursor != null;
int nameIndex = returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
returnCursor.moveToFirst();
String name = returnCursor.getString(nameIndex);
returnCursor.close();
Random r = new Random();
int suf = r.nextInt(9999 - 1000) + 1000;
return String.valueOf(suf)+name;
try {
int nameIndex = returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
returnCursor.moveToFirst();
String name = returnCursor.getString(nameIndex);
returnCursor.close();
Random r = new Random();
int suf = r.nextInt(9999 - 1000) + 1000;
return String.valueOf(suf)+name;
}catch (Exception e){
Random r = new Random();
int suf = r.nextInt(9999 - 1000) + 1000;
ContentResolver cr = context.getContentResolver();
String mime = cr.getType(uri);
if( mime != null && mime.split("/").length > 1)
return "__" + String.valueOf(suf)+"."+mime.split("/")[1];
else
return "__" + String.valueOf(suf)+".jpg";
}
}
@SuppressWarnings("WeakerAccess")
@SuppressWarnings({"WeakerAccess", "unused"})
public static void largeLog(String content) {
if (content.length() > 4000) {
Log.v(Helper.TAG, content.substring(0, 4000));

View File

@ -66,7 +66,7 @@ public class AccountDAO {
values.put(Sqlite.COL_AVATAR_STATIC,account.getAvatar_static());
values.put(Sqlite.COL_HEADER,account.getHeader());
values.put(Sqlite.COL_HEADER_STATIC,account.getHeader_static());
values.put(Sqlite.COL_CREATED_AT, Helper.dateToString(context, account.getCreated_at()));
values.put(Sqlite.COL_CREATED_AT, Helper.dateToString(account.getCreated_at()));
values.put(Sqlite.COL_INSTANCE, account.getInstance());
if( account.getToken() != null)
values.put(Sqlite.COL_OAUTHTOKEN, account.getToken());
@ -102,7 +102,7 @@ public class AccountDAO {
values.put(Sqlite.COL_AVATAR_STATIC,account.getAvatar_static());
values.put(Sqlite.COL_HEADER,account.getHeader());
values.put(Sqlite.COL_HEADER_STATIC,account.getHeader_static());
values.put(Sqlite.COL_CREATED_AT, Helper.dateToString(context, account.getCreated_at()));
values.put(Sqlite.COL_CREATED_AT, Helper.dateToString(account.getCreated_at()));
values.put(Sqlite.COL_INSTANCE, account.getInstance());
if( account.getToken() != null)
values.put(Sqlite.COL_OAUTHTOKEN, account.getToken());

View File

@ -57,7 +57,7 @@ public class CustomEmojiDAO {
values.put(Sqlite.COL_INSTANCE, instance);
values.put(Sqlite.COL_URL, emoji.getUrl());
values.put(Sqlite.COL_URL_STATIC, emoji.getStatic_url());
values.put(Sqlite.COL_DATE_CREATION, Helper.dateToString(context, new Date()));
values.put(Sqlite.COL_DATE_CREATION, Helper.dateToString(new Date()));
//Inserts emoji
try{
db.insert(Sqlite.TABLE_CUSTOM_EMOJI, null, values);
@ -75,7 +75,7 @@ public class CustomEmojiDAO {
String instance = Helper.getLiveInstance(context);
values.put(Sqlite.COL_URL, emoji.getUrl());
values.put(Sqlite.COL_URL_STATIC, emoji.getStatic_url());
values.put(Sqlite.COL_DATE_CREATION, Helper.dateToString(context, new Date()));
values.put(Sqlite.COL_DATE_CREATION, Helper.dateToString(new Date()));
db.update(Sqlite.TABLE_CUSTOM_EMOJI,
values, Sqlite.COL_SHORTCODE + " = ? AND " + Sqlite.COL_INSTANCE + " = ? ",
new String[]{emoji.getShortcode(), instance});

View File

@ -56,7 +56,7 @@ public class SearchDAO {
ContentValues values = new ContentValues();
values.put(Sqlite.COL_KEYWORDS, keyword);
values.put(Sqlite.COL_USER_ID, userId);
values.put(Sqlite.COL_DATE_CREATION, Helper.dateToString(context, new Date()));
values.put(Sqlite.COL_DATE_CREATION, Helper.dateToString(new Date()));
//Inserts search
try{
db.insert(Sqlite.TABLE_SEARCH, null, values);

View File

@ -79,8 +79,8 @@ public class StatusCacheDAO {
values.put(Sqlite.COL_REBLOGGED, status.isReblogged());
values.put(Sqlite.COL_FAVOURITED, status.isFavourited());
values.put(Sqlite.COL_MUTED, status.isMuted());
values.put(Sqlite.COL_CREATED_AT, Helper.dateToString(context, status.getCreated_at()));
values.put(Sqlite.COL_DATE_BACKUP, Helper.dateToString(context, new Date()));
values.put(Sqlite.COL_CREATED_AT, Helper.dateToString(status.getCreated_at()));
values.put(Sqlite.COL_DATE_BACKUP, Helper.dateToString(new Date()));
values.put(Sqlite.COL_SENSITIVE, status.isSensitive());
values.put(Sqlite.COL_SPOILER_TEXT, status.getSpoiler_text());
values.put(Sqlite.COL_VISIBILITY, status.getVisibility());

View File

@ -66,7 +66,7 @@ public class StatusStoredDAO {
values.put(Sqlite.COL_STATUS_REPLY_SERIALIZED, serializedStatusReply);
}
values.put(Sqlite.COL_STATUS_SERIALIZED, serializedStatus);
values.put(Sqlite.COL_DATE_CREATION, Helper.dateToString(context, new Date()));
values.put(Sqlite.COL_DATE_CREATION, Helper.dateToString(new Date()));
values.put(Sqlite.COL_IS_SCHEDULED, 0);
values.put(Sqlite.COL_INSTANCE, instance);
values.put(Sqlite.COL_USER_ID, userId);
@ -93,7 +93,7 @@ public class StatusStoredDAO {
String serializedStatus = Helper.statusToStringStorage(status);
values.put(Sqlite.COL_STATUS_SERIALIZED, serializedStatus);
values.put(Sqlite.COL_DATE_CREATION, Helper.dateToString(context, new Date()));
values.put(Sqlite.COL_DATE_CREATION, Helper.dateToString(new Date()));
return db.update(Sqlite.TABLE_STATUSES_STORED,
values, Sqlite.COL_ID + " = ? ",
new String[]{String.valueOf(id)});
@ -123,7 +123,7 @@ public class StatusStoredDAO {
public int scheduleStatus(long id, int jobId, Date date_scheduled ) {
ContentValues values = new ContentValues();
values.put(Sqlite.COL_IS_SCHEDULED, jobId);
values.put(Sqlite.COL_DATE_SCHEDULED, Helper.dateToString(context, date_scheduled));
values.put(Sqlite.COL_DATE_SCHEDULED, Helper.dateToString(date_scheduled));
return db.update(Sqlite.TABLE_STATUSES_STORED,
values, Sqlite.COL_ID + " = ? ",
new String[]{String.valueOf(id)});
@ -136,7 +136,7 @@ public class StatusStoredDAO {
*/
public int updateScheduledDate(int jobid, Date scheduled_date) {
ContentValues values = new ContentValues();
values.put(Sqlite.COL_DATE_SCHEDULED, Helper.dateToString(context, scheduled_date));
values.put(Sqlite.COL_DATE_SCHEDULED, Helper.dateToString(scheduled_date));
return db.update(Sqlite.TABLE_STATUSES_STORED,
values, Sqlite.COL_IS_SCHEDULED + " = ? ",
new String[]{String.valueOf(jobid)});
@ -150,7 +150,7 @@ public class StatusStoredDAO {
*/
public int updateScheduledDone(int jobid, Date date_sent) {
ContentValues values = new ContentValues();
values.put(Sqlite.COL_DATE_SENT, Helper.dateToString(context, date_sent));
values.put(Sqlite.COL_DATE_SENT, Helper.dateToString(date_sent));
values.put(Sqlite.COL_SENT, 1);
return db.update(Sqlite.TABLE_STATUSES_STORED,
values, Sqlite.COL_IS_SCHEDULED + " = ? ",

View File

@ -55,8 +55,8 @@ public class TempMuteDAO {
values.put(Sqlite.COL_TARGETED_USER_ID, targeted_id);
values.put(Sqlite.COL_ACCT, account.getAcct());
values.put(Sqlite.COL_INSTANCE, account.getInstance());
values.put(Sqlite.COL_DATE_CREATION, Helper.dateToString(context, new Date()));
values.put(Sqlite.COL_DATE_END, Helper.dateToString(context, date));
values.put(Sqlite.COL_DATE_CREATION, Helper.dateToString(new Date()));
values.put(Sqlite.COL_DATE_END, Helper.dateToString(date));
//Inserts temp mute
try{
db.insert(Sqlite.TABLE_TEMP_MUTE, null, values);
@ -77,7 +77,7 @@ public class TempMuteDAO {
* Remove mute by its id
*/
public void removeOld(){
db.delete(Sqlite.TABLE_TEMP_MUTE, Sqlite.COL_DATE_END + " < \"" + Helper.dateToString(context, new Date())+ "\"", null);
db.delete(Sqlite.TABLE_TEMP_MUTE, Sqlite.COL_DATE_END + " < \"" + Helper.dateToString(new Date())+ "\"", null);
}
//------- GETTERS -------
@ -88,7 +88,7 @@ public class TempMuteDAO {
*/
public List<String> getAllTimeMuted(Account account){
try {
Cursor c = db.query(Sqlite.TABLE_TEMP_MUTE, null, Sqlite.COL_DATE_END + " >= \"" + Helper.dateToString(context, new Date())+ "\" AND " + Sqlite.COL_ACCT + " = \"" + account.getAcct()+ "\" AND " + Sqlite.COL_INSTANCE + " = \"" + account.getInstance()+ "\"", null, null, null, null, null);
Cursor c = db.query(Sqlite.TABLE_TEMP_MUTE, null, Sqlite.COL_DATE_END + " >= \"" + Helper.dateToString(new Date())+ "\" AND " + Sqlite.COL_ACCT + " = \"" + account.getAcct()+ "\" AND " + Sqlite.COL_INSTANCE + " = \"" + account.getInstance()+ "\"", null, null, null, null, null);
return cursorToTimeMute(c);
} catch (Exception e) {
return null;
@ -102,7 +102,7 @@ public class TempMuteDAO {
*/
public boolean isTempMuted(Account account, String targeted_id){
try {
Cursor c = db.query(Sqlite.TABLE_TEMP_MUTE, null, Sqlite.COL_TARGETED_USER_ID + " = \"" + targeted_id + "\" AND " + Sqlite.COL_DATE_END + " >= \"" + Helper.dateToString(context, new Date())+ "\" AND " + Sqlite.COL_ACCT + " = \"" + account.getAcct()+ "\" AND " + Sqlite.COL_INSTANCE + " = \"" + account.getInstance()+ "\"", null, null, null, null, null);
Cursor c = db.query(Sqlite.TABLE_TEMP_MUTE, null, Sqlite.COL_TARGETED_USER_ID + " = \"" + targeted_id + "\" AND " + Sqlite.COL_DATE_END + " >= \"" + Helper.dateToString(new Date())+ "\" AND " + Sqlite.COL_ACCT + " = \"" + account.getAcct()+ "\" AND " + Sqlite.COL_INSTANCE + " = \"" + account.getInstance()+ "\"", null, null, null, null, null);
return cursorToTimeMute(c) != null;
} catch (Exception e) {
return false;
@ -116,7 +116,7 @@ public class TempMuteDAO {
*/
public String getMuteDateByID(Account account, String targeted_id){
try {
Cursor c = db.query(Sqlite.TABLE_TEMP_MUTE, null, Sqlite.COL_TARGETED_USER_ID + " = \"" + targeted_id + "\" AND " + Sqlite.COL_DATE_END + " >= \"" + Helper.dateToString(context, new Date())+ "\" AND " + Sqlite.COL_ACCT + " = \"" + account.getAcct()+ "\" AND " + Sqlite.COL_INSTANCE + " = \"" + account.getInstance()+ "\"", null, null, null, Sqlite.COL_DATE_END + " DESC", "1");
Cursor c = db.query(Sqlite.TABLE_TEMP_MUTE, null, Sqlite.COL_TARGETED_USER_ID + " = \"" + targeted_id + "\" AND " + Sqlite.COL_DATE_END + " >= \"" + Helper.dateToString(new Date())+ "\" AND " + Sqlite.COL_ACCT + " = \"" + account.getAcct()+ "\" AND " + Sqlite.COL_INSTANCE + " = \"" + account.getInstance()+ "\"", null, null, null, Sqlite.COL_DATE_END + " DESC", "1");
return cursorToDate(c);
} catch (Exception e) {
e.printStackTrace();