Some fixes
This commit is contained in:
parent
fa2c2654da
commit
af32fad854
|
@ -211,7 +211,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
|
||||
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(BaseMainActivity.this));
|
||||
SQLiteDatabase db = Sqlite.getInstance(BaseMainActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(BaseMainActivity.this, db).getUniqAccount(userId, instance);
|
||||
Intent intent = getIntent();
|
||||
PackageManager pm = getPackageManager();
|
||||
|
@ -1376,7 +1376,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
DisplayStatusFragment fragment = new DisplayStatusFragment();
|
||||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.MYVIDEOS);
|
||||
bundle.putString("instanceType", "PEERTUBE");
|
||||
SQLiteDatabase db = Sqlite.getInstance(BaseMainActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(BaseMainActivity.this));
|
||||
|
@ -1670,7 +1670,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
if (dir.isDirectory()) {
|
||||
Helper.deleteDir(dir);
|
||||
}
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new TimelineCacheDAO(contextReference.get(), db).removeAll();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
@ -1813,7 +1813,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.MYVIDEOS);
|
||||
bundle.putString("instanceType", "PEERTUBE");
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
SQLiteDatabase db = Sqlite.getInstance(BaseMainActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(BaseMainActivity.this));
|
||||
Account account = new AccountDAO(BaseMainActivity.this, db).getUniqAccount(userId, instance);
|
||||
|
@ -1829,7 +1829,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PEERTUBE_HISTORY);
|
||||
bundle.putString("instanceType", "PEERTUBE");
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
SQLiteDatabase db = Sqlite.getInstance(BaseMainActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(BaseMainActivity.this));
|
||||
Account account = new AccountDAO(BaseMainActivity.this, db).getUniqAccount(userId, instance);
|
||||
|
@ -1970,7 +1970,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
startActivity(myIntent);
|
||||
finish();
|
||||
} else {
|
||||
SQLiteDatabase db = Sqlite.getInstance(BaseMainActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(BaseMainActivity.this, db).getUniqAccount(userId, instance);
|
||||
Helper.updateHeaderAccountInfo(activity, account, headerLayout);
|
||||
}
|
||||
|
@ -2274,7 +2274,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
}
|
||||
|
||||
public void manageTab(RetrieveFeedsAsyncTask.Type type, int value) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(BaseMainActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<ManageTimelines> tls = new TimelinesDAO(BaseMainActivity.this, db).getDisplayedTimelines();
|
||||
for (ManageTimelines tl : tls) {
|
||||
if (type == ManageTimelines.transform(BaseMainActivity.this, tl.getType())) {
|
||||
|
|
|
@ -114,7 +114,7 @@ public class BookmarkActivity extends BaseActivity implements OnRetrieveFeedsInt
|
|||
setTitle(R.string.bookmarks);
|
||||
}
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(BookmarkActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account account = new AccountDAO(BookmarkActivity.this, db).getUniqAccount(userId, instance);
|
||||
|
|
|
@ -111,7 +111,7 @@ public class CustomSharingActivity extends BaseActivity implements OnCustomShari
|
|||
} else {
|
||||
setTitle(R.string.settings_title_custom_sharing);
|
||||
}
|
||||
SQLiteDatabase db = Sqlite.getInstance(CustomSharingActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account account = new AccountDAO(CustomSharingActivity.this, db).getUniqAccount(userId, instance);
|
||||
|
|
|
@ -138,7 +138,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
|
|||
} else {
|
||||
setTitle(R.string.settings_title_profile);
|
||||
}
|
||||
SQLiteDatabase db = Sqlite.getInstance(EditProfileActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account account = new AccountDAO(EditProfileActivity.this, db).getUniqAccount(userId, instance);
|
||||
|
|
|
@ -171,7 +171,7 @@ public class HashTagActivity extends BaseActivity implements OnRetrieveFeedsInte
|
|||
public boolean onCreateOptionsMenu(@NotNull Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.tag_pin, menu);
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(HashTagActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<String> searchInDb = new SearchDAO(HashTagActivity.this, db).getSearchByKeyword(tag.trim());
|
||||
if (searchInDb != null && searchInDb.size() > 0) {
|
||||
menu.findItem(R.id.action_pin).setVisible(false);
|
||||
|
@ -186,7 +186,7 @@ public class HashTagActivity extends BaseActivity implements OnRetrieveFeedsInte
|
|||
finish();
|
||||
return true;
|
||||
case R.id.action_pin:
|
||||
SQLiteDatabase db = Sqlite.getInstance(HashTagActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new SearchDAO(HashTagActivity.this, db).insertSearch(tag);
|
||||
Intent intent = new Intent(HashTagActivity.this, MainActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
|
|
@ -61,7 +61,7 @@ public class LiveNotificationSettingsAccountsActivity extends BaseActivity {
|
|||
RecyclerView list_of_accounts = findViewById(R.id.list_of_accounts);
|
||||
|
||||
ArrayList<Account> accounts = new ArrayList<>();
|
||||
SQLiteDatabase db = Sqlite.getInstance(LiveNotificationSettingsAccountsActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<Account> accountStreams = new AccountDAO(LiveNotificationSettingsAccountsActivity.this, db).getAllAccountCrossAction();
|
||||
if (accountStreams == null || accountStreams.size() == 0) {
|
||||
finish();
|
||||
|
|
|
@ -608,7 +608,7 @@ public class LoginActivity extends BaseActivity {
|
|||
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, basicAuth);
|
||||
account.setInstance(instance);
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(LoginActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
boolean userExists = new AccountDAO(LoginActivity.this, db).userExist(account);
|
||||
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
||||
editor.putBoolean(Helper.PREF_IS_MODERATOR, account.isModerator());
|
||||
|
|
|
@ -144,7 +144,7 @@ public class OwnerChartsActivity extends BaseActivity implements OnRetrieveChart
|
|||
TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
|
||||
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(OwnerChartsActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account account = new AccountDAO(OwnerChartsActivity.this, db).getUniqAccount(userId, instance);
|
||||
|
@ -169,7 +169,7 @@ public class OwnerChartsActivity extends BaseActivity implements OnRetrieveChart
|
|||
loader = findViewById(R.id.loader);
|
||||
validate = findViewById(R.id.validate);
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(OwnerChartsActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
dateIni = new StatusCacheDAO(OwnerChartsActivity.this, db).getSmallerDate(StatusCacheDAO.ARCHIVE_CACHE);
|
||||
dateEnd = new StatusCacheDAO(OwnerChartsActivity.this, db).getGreaterDate(StatusCacheDAO.ARCHIVE_CACHE);
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ public class OwnerNotificationActivity extends BaseActivity implements OnRetriev
|
|||
style = R.style.Dialog;
|
||||
}
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(OwnerNotificationActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(OwnerNotificationActivity.this, db).getUniqAccount(userId, instance);
|
||||
|
||||
Helper.loadGiF(OwnerNotificationActivity.this, account, pp_actionBar);
|
||||
|
@ -310,7 +310,7 @@ public class OwnerNotificationActivity extends BaseActivity implements OnRetriev
|
|||
dialogBuilder.setView(dialogView);
|
||||
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(OwnerNotificationActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
if (dateIni == null)
|
||||
dateIni = new NotificationCacheDAO(OwnerNotificationActivity.this, db).getSmallerDate();
|
||||
if (dateEnd == null)
|
||||
|
|
|
@ -151,7 +151,7 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
|
|||
TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
|
||||
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(OwnerNotificationChartsActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account account = new AccountDAO(OwnerNotificationChartsActivity.this, db).getUniqAccount(userId, instance);
|
||||
|
@ -176,7 +176,7 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
|
|||
loader = findViewById(R.id.loader);
|
||||
validate = findViewById(R.id.validate);
|
||||
LinearLayout date_container = findViewById(R.id.date_container);
|
||||
SQLiteDatabase db = Sqlite.getInstance(OwnerNotificationChartsActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
if (status_id == null) {
|
||||
dateIni = new NotificationCacheDAO(OwnerNotificationChartsActivity.this, db).getSmallerDate();
|
||||
dateEnd = new NotificationCacheDAO(OwnerNotificationChartsActivity.this, db).getGreaterDate();
|
||||
|
|
|
@ -218,7 +218,7 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
|
|||
style = R.style.Dialog;
|
||||
}
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(OwnerStatusActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(OwnerStatusActivity.this, db).getUniqAccount(userId, instance);
|
||||
|
||||
Helper.loadGiF(OwnerStatusActivity.this, account, pp_actionBar);
|
||||
|
@ -319,7 +319,7 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
|
|||
dialogBuilder.setView(dialogView);
|
||||
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(OwnerStatusActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
if (dateIni == null)
|
||||
dateIni = new StatusCacheDAO(OwnerStatusActivity.this, db).getSmallerDate(StatusCacheDAO.ARCHIVE_CACHE);
|
||||
if (dateEnd == null)
|
||||
|
|
|
@ -220,7 +220,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
}
|
||||
});
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(PeertubeActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(PeertubeActivity.this));
|
||||
Account account = new AccountDAO(PeertubeActivity.this, db).getUniqAccount(userId, instance);
|
||||
|
@ -609,7 +609,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
Helper.manageDownloads(PeertubeActivity.this, peertube.getFileDownloadUrl(null, peertube.isStreamService()));
|
||||
}
|
||||
});
|
||||
SQLiteDatabase db = Sqlite.getInstance(PeertubeActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<Peertube> peertubes = new PeertubeFavoritesDAO(PeertubeActivity.this, db).getSinglePeertube(peertube);
|
||||
|
||||
Drawable img;
|
||||
|
|
|
@ -668,7 +668,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
}
|
||||
Bundle b = getIntent().getExtras();
|
||||
ArrayList<Uri> sharedUri = new ArrayList<>();
|
||||
SQLiteDatabase db = Sqlite.getInstance(PixelfedComposeActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
restored = -1;
|
||||
if (b != null) {
|
||||
scheduledstatus = b.getParcelable("storedStatus");
|
||||
|
@ -1452,10 +1452,10 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
|
||||
if (apiResponse.getError() == null || apiResponse.getError().getStatusCode() != -33) {
|
||||
if (restored != -1) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(PixelfedComposeActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new StatusStoredDAO(PixelfedComposeActivity.this, db).remove(restored);
|
||||
} else if (currentToId != -1) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(PixelfedComposeActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new StatusStoredDAO(PixelfedComposeActivity.this, db).remove(currentToId);
|
||||
}
|
||||
}
|
||||
|
@ -1673,7 +1673,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
}
|
||||
|
||||
private void restoreToot(long id) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(PixelfedComposeActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
StoredStatus draft = new StatusStoredDAO(PixelfedComposeActivity.this, db).getStatus(id);
|
||||
if (draft == null)
|
||||
return;
|
||||
|
@ -1886,7 +1886,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
toot.setContent(PixelfedComposeActivity.this, currentContent);
|
||||
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(PixelfedComposeActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
try {
|
||||
if (currentToId == -1) {
|
||||
currentToId = new StatusStoredDAO(PixelfedComposeActivity.this, db).insertStatus(toot, null);
|
||||
|
|
|
@ -171,7 +171,7 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
|
|||
dialogBuilder.setPositiveButton(R.string.validate, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(ReorderTimelinesActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String instanceName = instance_list.getText().toString().trim().replace("@", "");
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
|
@ -353,7 +353,7 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
|
|||
updated = false;
|
||||
RecyclerView lv_reorder_tabs = findViewById(R.id.lv_reorder_tabs);
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(ReorderTimelinesActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
timelines = new TimelinesDAO(ReorderTimelinesActivity.this, db).getAllTimelines();
|
||||
adapter = new ReorderTabAdapter(timelines, ReorderTimelinesActivity.this, ReorderTimelinesActivity.this);
|
||||
|
||||
|
@ -394,7 +394,7 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
|
|||
@Override
|
||||
public void run() {
|
||||
undo_container.setVisibility(View.GONE);
|
||||
SQLiteDatabase db = Sqlite.getInstance(ReorderTimelinesActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
switch (manageTimelines.getType()) {
|
||||
case TAG:
|
||||
new SearchDAO(ReorderTimelinesActivity.this, db).remove(manageTimelines.getTagTimeline().getName());
|
||||
|
|
|
@ -378,7 +378,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
//Timed muted account
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
final SQLiteDatabase db = Sqlite.getInstance(ShowAccountActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final Account authenticatedAccount = new AccountDAO(ShowAccountActivity.this, db).getUniqAccount(userId, instance);
|
||||
boolean isTimedMute = new TempMuteDAO(ShowAccountActivity.this, db).isTempMuted(authenticatedAccount, accountId);
|
||||
if (isTimedMute) {
|
||||
|
@ -1110,7 +1110,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
} else {
|
||||
style = R.style.Dialog;
|
||||
}
|
||||
final SQLiteDatabase db = Sqlite.getInstance(ShowAccountActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_follow_instance:
|
||||
String finalInstanceName = splitAcct[1];
|
||||
|
|
|
@ -199,7 +199,7 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
|
|||
|
||||
});
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(ShowConversationActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account account = new AccountDAO(ShowConversationActivity.this, db).getUniqAccount(userId, instance);
|
||||
|
|
|
@ -66,7 +66,7 @@ public class TagCacheActivity extends BaseActivity {
|
|||
setContentView(R.layout.activity_tag_cache);
|
||||
|
||||
tag_list = findViewById(R.id.tag_list);
|
||||
SQLiteDatabase db = Sqlite.getInstance(TagCacheActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
EditText tag_add = findViewById(R.id.tag_add);
|
||||
ImageButton save_tag = findViewById(R.id.save_tag);
|
||||
|
||||
|
|
|
@ -942,7 +942,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
|
||||
Bundle b = getIntent().getExtras();
|
||||
ArrayList<Uri> sharedUri = new ArrayList<>();
|
||||
SQLiteDatabase db = Sqlite.getInstance(TootActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
restored = -1;
|
||||
if (b != null) {
|
||||
tootReply = b.getParcelable("tootReply");
|
||||
|
@ -1643,7 +1643,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NotNull MenuItem item) {
|
||||
final SQLiteDatabase db = Sqlite.getInstance(TootActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
int style;
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||
|
@ -2250,7 +2250,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
}
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
MenuItem itemEmoji = menu.findItem(R.id.action_emoji);
|
||||
SQLiteDatabase db = Sqlite.getInstance(TootActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final List<Emojis> emojis = new CustomEmojiDAO(TootActivity.this, db).getAllEmojis();
|
||||
//Displays button only if custom emojis
|
||||
if (emojis != null && emojis.size() > 0) {
|
||||
|
@ -2538,10 +2538,10 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
}
|
||||
if (apiResponse.getError() == null || apiResponse.getError().getStatusCode() != -33) {
|
||||
if (restored != -1) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(TootActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new StatusStoredDAO(TootActivity.this, db).remove(restored);
|
||||
} else if (currentToId != -1) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(TootActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new StatusStoredDAO(TootActivity.this, db).remove(currentToId);
|
||||
}
|
||||
}
|
||||
|
@ -2954,7 +2954,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
}
|
||||
|
||||
private void restoreToot(long id) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(TootActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
StoredStatus draft = new StatusStoredDAO(TootActivity.this, db).getStatus(id);
|
||||
if (draft == null)
|
||||
return;
|
||||
|
@ -3616,7 +3616,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
toot.setPoll(poll);
|
||||
if (tootReply != null)
|
||||
toot.setIn_reply_to_id(tootReply.getId());
|
||||
SQLiteDatabase db = Sqlite.getInstance(TootActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
try {
|
||||
if (currentToId == -1) {
|
||||
currentToId = new StatusStoredDAO(TootActivity.this, db).insertStatus(toot, tootReply);
|
||||
|
|
|
@ -151,7 +151,7 @@ public class WebviewActivity extends BaseActivity {
|
|||
url = "http://" + url;
|
||||
if (trackingDomains == null) {
|
||||
AsyncTask.execute(() -> {
|
||||
SQLiteDatabase db = Sqlite.getInstance(WebviewActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
trackingDomains = new DomainBlockDAO(WebviewActivity.this, db).getAll();
|
||||
if (trackingDomains == null)
|
||||
trackingDomains = new ArrayList<>();
|
||||
|
|
|
@ -71,7 +71,7 @@ public class DownloadTrackingDomainsAsyncTask extends AsyncTask<Void, Void, Bool
|
|||
br.close();
|
||||
connection.disconnect();
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new DomainBlockDAO(context.get(), db).set(domains);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -61,7 +61,7 @@ public class ManagePlaylistsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
SharedPreferences sharedpreferences = contextReference.get().getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(contextReference.get()));
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(contextReference.get(), db).getUniqAccount(userId, instance);
|
||||
if (apiAction == action.GET_PLAYLIST) {
|
||||
apiResponse = new PeertubeAPI(contextReference.get()).getPlayists(account.getUsername());
|
||||
|
|
|
@ -190,7 +190,7 @@ public class PostActionAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
} else if (apiAction == API.StatusAction.MUTE_NOTIFICATIONS) {
|
||||
statusCode = api.muteNotifications(targetedId, muteNotifications);
|
||||
} else if (apiAction == API.StatusAction.UNBOOKMARK && targetedId == null) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<app.fedilab.android.client.Entities.Status> bookmarks = new StatusCacheDAO(contextReference.get(), db).getAllStatus(StatusCacheDAO.BOOKMARK_CACHE);
|
||||
for (app.fedilab.android.client.Entities.Status status : bookmarks) {
|
||||
statusCode = api.postAction(apiAction, status.getId());
|
||||
|
|
|
@ -104,7 +104,7 @@ public class PostStatusAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
public void run() {
|
||||
String content = status.getContent();
|
||||
if (content != null && content.length() > 0) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Matcher matcher = Helper.hashtagPattern.matcher(content);
|
||||
while (matcher.find()) {
|
||||
int matchStart = matcher.start(1);
|
||||
|
|
|
@ -41,7 +41,7 @@ public class RemoveAccountAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(activityReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(activityReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new AccountDAO(activityReference.get(), db).removeUser(account);
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ public class RetrieveAccountsForReplyAsyncTask extends AsyncTask<Void, Void, Voi
|
|||
|
||||
private boolean canBeAdded(String acct) {
|
||||
final SharedPreferences sharedpreferences = this.contextReference.get().getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SQLiteDatabase db = Sqlite.getInstance(this.contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(this.contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account currentAccount = new AccountDAO(this.contextReference.get(), db).getUniqAccount(userId, instance);
|
||||
|
|
|
@ -52,7 +52,7 @@ public class RetrieveChartsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
charts = new StatusCacheDAO(contextReference.get(), db).getCharts(dateIni, dateEnd);
|
||||
|
||||
return null;
|
||||
|
|
|
@ -48,7 +48,7 @@ public class RetrieveEmojiAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
emojis = new CustomEmojiDAO(contextReference.get(), db).getEmojiStartingBy(shortcode);
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -177,7 +177,7 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
API api = new API(this.contextReference.get());
|
||||
SQLiteDatabase db = Sqlite.getInstance(this.contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(this.contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
if (action == null)
|
||||
return null;
|
||||
switch (action) {
|
||||
|
@ -365,7 +365,7 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
break;
|
||||
case CACHE_BOOKMARKS:
|
||||
apiResponse = new APIResponse();
|
||||
db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<app.fedilab.android.client.Entities.Status> statuses = new StatusCacheDAO(contextReference.get(), db).getAllStatus(StatusCacheDAO.BOOKMARK_CACHE);
|
||||
for (app.fedilab.android.client.Entities.Status status : statuses) {
|
||||
app.fedilab.android.client.Entities.Status.fillSpan(contextReference.get(), status);
|
||||
|
@ -376,13 +376,13 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
break;
|
||||
case CACHE_BOOKMARKS_PEERTUBE:
|
||||
apiResponse = new APIResponse();
|
||||
db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<Peertube> peertubes = new PeertubeFavoritesDAO(contextReference.get(), db).getAllPeertube();
|
||||
apiResponse.setPeertubes(peertubes);
|
||||
break;
|
||||
case CACHE_STATUS:
|
||||
apiResponse = new APIResponse();
|
||||
db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
statuses = new StatusCacheDAO(contextReference.get(), db).getStatusFromID(StatusCacheDAO.ARCHIVE_CACHE, filterToots, max_id);
|
||||
if (statuses != null && statuses.size() > 0) {
|
||||
apiResponse.setStatuses(statuses);
|
||||
|
|
|
@ -96,7 +96,7 @@ public class RetrieveMissingFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
else if (type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE)
|
||||
apiResponse = api.getInstanceTimelineSinceId(remoteInstance, since_id);
|
||||
else if (type == RetrieveFeedsAsyncTask.Type.TAG) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
ManageTimelines manageTimelines = new TimelinesDAO(contextReference.get(), db).getById(timelineId);
|
||||
if (manageTimelines != null && manageTimelines.getTagTimeline() != null) {
|
||||
TagTimeline tagTimeline = manageTimelines.getTagTimeline();
|
||||
|
@ -146,7 +146,7 @@ public class RetrieveMissingFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
else if (type == RetrieveFeedsAsyncTask.Type.GNU_WHOLE)
|
||||
apiResponse = gnuapi.getPublicTimelineSinceId(false, since_id);
|
||||
else if (type == RetrieveFeedsAsyncTask.Type.GNU_TAG) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<TagTimeline> tagTimelines = new SearchDAO(contextReference.get(), db).getTimelineInfo(remoteInstance);
|
||||
if (tagTimelines != null && tagTimelines.size() > 0) {
|
||||
TagTimeline tagTimeline = tagTimelines.get(0);
|
||||
|
|
|
@ -54,7 +54,7 @@ public class RetrieveNotificationChartsAsyncTask extends AsyncTask<Void, Void, V
|
|||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
charts = new NotificationCacheDAO(contextReference.get(), db).getChartsEvolution(status_id, dateIni, dateEnd);
|
||||
|
||||
return null;
|
||||
|
|
|
@ -47,7 +47,7 @@ public class RetrieveNotificationStatsAsyncTask extends AsyncTask<Void, Void, Vo
|
|||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
statistics = new NotificationCacheDAO(contextReference.get(), db).getStat();
|
||||
|
||||
return null;
|
||||
|
|
|
@ -52,7 +52,7 @@ public class RetrieveNotificationsCacheAsyncTask extends AsyncTask<Void, Void, V
|
|||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<Notification> notifications = new NotificationCacheDAO(contextReference.get(), db).getNotificationsFromID(filterNotifications, max_id);
|
||||
apiResponse = new APIResponse();
|
||||
apiResponse.setNotifications(notifications);
|
||||
|
|
|
@ -51,7 +51,7 @@ public class RetrievePeertubeChannelsAsyncTask extends AsyncTask<Void, Void, Voi
|
|||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
PeertubeAPI peertubeAPI = new PeertubeAPI(this.contextReference.get());
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SharedPreferences sharedpreferences = contextReference.get().getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(contextReference.get()));
|
||||
|
|
|
@ -58,7 +58,7 @@ public class RetrieveScheduledTootsAsyncTask extends AsyncTask<Void, Void, Void>
|
|||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(this.contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(this.contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
//Retrieves job asked by the user
|
||||
if (type == DisplayScheduledTootsFragment.typeOfSchedule.TOOT)
|
||||
storedStatuses = new StatusStoredDAO(this.contextReference.get(), db).getAllScheduled();
|
||||
|
|
|
@ -121,7 +121,7 @@ public class RetrieveSearchAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
else {
|
||||
//search tags only
|
||||
apiResponse = api.search(query);
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<String> cachedTags = new TagsCacheDAO(contextReference.get(), db).getBy(query);
|
||||
if (apiResponse != null && apiResponse.getResults() != null && apiResponse.getResults().getHashtags() != null) {
|
||||
//If cache contains matching tags
|
||||
|
|
|
@ -47,7 +47,7 @@ public class RetrieveStatsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
statistics = new StatusCacheDAO(contextReference.get(), db).getStat();
|
||||
|
||||
return null;
|
||||
|
|
|
@ -49,7 +49,7 @@ public class SyncBookmarksAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
if (type == sync.IMPORT) {
|
||||
String max_id = null;
|
||||
do {
|
||||
|
|
|
@ -66,7 +66,7 @@ public class SyncTimelinesAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
manageTimelines = new TimelinesDAO(contextReference.get(), db).getAllTimelines();
|
||||
//First time that the timeline is created
|
||||
int i = 0;
|
||||
|
|
|
@ -89,7 +89,7 @@ public class UpdateAccountInfoAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
account.setClient_secret(client_secret);
|
||||
account.setRefresh_token(refresh_token);
|
||||
account.setInstance(instance);
|
||||
SQLiteDatabase db = Sqlite.getInstance(this.contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(this.contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
boolean userExists = new AccountDAO(this.contextReference.get(), db).userExist(account);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
||||
|
|
|
@ -69,7 +69,7 @@ public class UpdateAccountInfoByIDAsyncTask extends AsyncTask<Void, Void, Void>
|
|||
if (account == null)
|
||||
return null;
|
||||
account.setInstance(Helper.getLiveInstance(contextReference.get()));
|
||||
SQLiteDatabase db = Sqlite.getInstance(this.contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(this.contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
boolean userExists = new AccountDAO(this.contextReference.get(), db).userExist(account);
|
||||
if (userExists) {
|
||||
Account accountDb = new AccountDAO(this.contextReference.get(), db).getUniqAccount(userId, instance);
|
||||
|
|
|
@ -139,7 +139,7 @@ public class API {
|
|||
if (Helper.getLiveInstance(context) != null)
|
||||
this.instance = Helper.getLiveInstance(context);
|
||||
else {
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(context));
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
|
@ -2452,7 +2452,7 @@ public class API {
|
|||
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||
e.printStackTrace();
|
||||
if (e.getStatusCode() == 401 || e.getStatusCode() == 403) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account targetedAccount = new AccountDAO(context, db).getAccountByToken(prefKeyOauthTokenT);
|
||||
if (targetedAccount == null)
|
||||
return null;
|
||||
|
@ -2843,7 +2843,7 @@ public class API {
|
|||
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
|
||||
String response = httpsConnection.get(getAbsoluteUrl(String.format("/statuses/%s", statusId)), 10, null, prefKeyOauthTokenT);
|
||||
Status status = parseStatuses(context, new JSONObject(response));
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(context, db).getAccountByToken(prefKeyOauthTokenT);
|
||||
new TimelineCacheDAO(context, db).update(status.getId(), response, account.getId(), account.getInstance());
|
||||
statuses.add(status);
|
||||
|
@ -3030,7 +3030,7 @@ public class API {
|
|||
*/
|
||||
public APIResponse getHomeTimelineCache(String max_id) {
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
statuses = new TimelineCacheDAO(context, db).get(max_id);
|
||||
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
|
@ -4341,7 +4341,7 @@ public class API {
|
|||
Intent intentBC = new Intent(Helper.RECEIVE_ACTION);
|
||||
intentBC.putExtras(b);
|
||||
LocalBroadcastManager.getInstance(context).sendBroadcast(intentBC);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(context, db).getAccountByToken(prefKeyOauthTokenT);
|
||||
Status indb = new TimelineCacheDAO(context, db).getSingle(targetedId);
|
||||
if (indb != null) {
|
||||
|
@ -4371,7 +4371,7 @@ public class API {
|
|||
httpsConnection.delete(getAbsoluteUrl(action), 10, null, prefKeyOauthTokenT);
|
||||
actionCode = httpsConnection.getActionCode();
|
||||
if (statusAction != StatusAction.REMOVE_REACTION && statusAction != StatusAction.REMOVE_PLEROMA_REACTION) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new TimelineCacheDAO(context, db).remove(targetedId);
|
||||
}
|
||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||
|
@ -4533,7 +4533,7 @@ public class API {
|
|||
b.putParcelable("status", status);
|
||||
Intent intentBC = new Intent(Helper.RECEIVE_ACTION);
|
||||
intentBC.putExtras(b);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Status alreadyCached = new TimelineCacheDAO(context, db).getSingle(status.getId());
|
||||
Account account = new AccountDAO(context, db).getAccountByToken(prefKeyOauthTokenT);
|
||||
if (alreadyCached != null) {
|
||||
|
@ -5655,7 +5655,7 @@ public class API {
|
|||
* @return List<Status>
|
||||
*/
|
||||
private List<Status> parseStatusesForCache(Context context, JSONArray jsonArray) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(context, db).getAccountByToken(prefKeyOauthTokenT);
|
||||
List<Status> statuses = new ArrayList<>();
|
||||
try {
|
||||
|
|
|
@ -678,7 +678,7 @@ public class ManageTimelines {
|
|||
PopupMenu popup = new PopupMenu(context, tabStrip.getChildAt(position));
|
||||
TabLayout tabLayout = ((MainActivity) context).findViewById(R.id.tabLayout);
|
||||
tabLayout.setBackgroundColor(ContextCompat.getColor(Objects.requireNonNull(context), R.color.cyanea_primary));
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||
int style;
|
||||
|
@ -879,7 +879,7 @@ public class ManageTimelines {
|
|||
|
||||
|
||||
PopupMenu popup = new PopupMenu(context, tabStrip.getChildAt(position));
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||
int style;
|
||||
|
|
|
@ -17,6 +17,7 @@ package app.fedilab.android.client.Entities;
|
|||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
|
|
@ -24,6 +24,17 @@ import java.util.List;
|
|||
|
||||
public class Poll implements Parcelable {
|
||||
|
||||
public static final Creator<Poll> CREATOR = new Creator<Poll>() {
|
||||
@Override
|
||||
public Poll createFromParcel(Parcel source) {
|
||||
return new Poll(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Poll[] newArray(int size) {
|
||||
return new Poll[size];
|
||||
}
|
||||
};
|
||||
private String id;
|
||||
private Date expires_at;
|
||||
private int expires_in;
|
||||
|
@ -39,6 +50,22 @@ public class Poll implements Parcelable {
|
|||
public Poll() {
|
||||
}
|
||||
|
||||
protected Poll(Parcel in) {
|
||||
this.id = in.readString();
|
||||
long tmpExpires_at = in.readLong();
|
||||
this.expires_at = tmpExpires_at == -1 ? null : new Date(tmpExpires_at);
|
||||
this.expires_in = in.readInt();
|
||||
this.expired = in.readByte() != 0;
|
||||
this.multiple = in.readByte() != 0;
|
||||
this.votes_count = in.readInt();
|
||||
this.voters_count = in.readInt();
|
||||
this.voted = in.readByte() != 0;
|
||||
this.optionsList = in.createTypedArrayList(PollOptions.CREATOR);
|
||||
this.emojis = in.createTypedArrayList(Emojis.CREATOR);
|
||||
this.own_votes = new ArrayList<>();
|
||||
in.readList(this.own_votes, Integer.class.getClassLoader());
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -146,32 +173,4 @@ public class Poll implements Parcelable {
|
|||
dest.writeTypedList(this.emojis);
|
||||
dest.writeList(this.own_votes);
|
||||
}
|
||||
|
||||
protected Poll(Parcel in) {
|
||||
this.id = in.readString();
|
||||
long tmpExpires_at = in.readLong();
|
||||
this.expires_at = tmpExpires_at == -1 ? null : new Date(tmpExpires_at);
|
||||
this.expires_in = in.readInt();
|
||||
this.expired = in.readByte() != 0;
|
||||
this.multiple = in.readByte() != 0;
|
||||
this.votes_count = in.readInt();
|
||||
this.voters_count = in.readInt();
|
||||
this.voted = in.readByte() != 0;
|
||||
this.optionsList = in.createTypedArrayList(PollOptions.CREATOR);
|
||||
this.emojis = in.createTypedArrayList(Emojis.CREATOR);
|
||||
this.own_votes = new ArrayList<>();
|
||||
in.readList(this.own_votes, Integer.class.getClassLoader());
|
||||
}
|
||||
|
||||
public static final Creator<Poll> CREATOR = new Creator<Poll>() {
|
||||
@Override
|
||||
public Poll createFromParcel(Parcel source) {
|
||||
return new Poll(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Poll[] newArray(int size) {
|
||||
return new Poll[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ public class GNUAPI {
|
|||
if (Helper.getLiveInstance(context) != null)
|
||||
this.instance = Helper.getLiveInstance(context);
|
||||
else {
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(context));
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
if (account == null) {
|
||||
|
@ -1598,11 +1598,11 @@ public class GNUAPI {
|
|||
Intent intentBC = new Intent(Helper.RECEIVE_ACTION);
|
||||
intentBC.putExtras(b);
|
||||
LocalBroadcastManager.getInstance(context).sendBroadcast(intentBC);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(context, db).getAccountByToken(prefKeyOauthTokenT);
|
||||
new TimelineCacheDAO(context, db).update(targetedId, resp, account.getId(), account.getToken());
|
||||
} else if (statusAction == API.StatusAction.UNSTATUS) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new TimelineCacheDAO(context, db).remove(targetedId);
|
||||
}
|
||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||
|
@ -1640,7 +1640,7 @@ public class GNUAPI {
|
|||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
//Current user
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account currentAccount = new AccountDAO(context, db).getUniqAccount(userId, Helper.getLiveInstance(context));
|
||||
params.put("user_id", currentAccount.getId());
|
||||
params.put("screen_name", currentAccount.getAcct());
|
||||
|
@ -1727,7 +1727,7 @@ public class GNUAPI {
|
|||
String url = null;
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
//Current user
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(context));
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
|
|
|
@ -81,7 +81,7 @@ public class PeertubeAPI {
|
|||
if (Helper.getLiveInstance(context) != null)
|
||||
this.instance = Helper.getLiveInstance(context);
|
||||
else {
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(context));
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
|
@ -662,7 +662,7 @@ public class PeertubeAPI {
|
|||
e.printStackTrace();
|
||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||
if (e.getStatusCode() == 401 || e.getStatusCode() == 403) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account targetedAccount = new AccountDAO(context, db).getAccountByToken(prefKeyOauthTokenT);
|
||||
if (targetedAccount != null) {
|
||||
HashMap<String, String> values = refreshToken(targetedAccount.getClient_id(), targetedAccount.getClient_secret(), targetedAccount.getRefresh_token());
|
||||
|
@ -1057,7 +1057,7 @@ public class PeertubeAPI {
|
|||
return getTL("/users/me/subscriptions/videos", "-publishedAt", null, max_id, null, null);
|
||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||
if (e.getStatusCode() == 401 || e.getStatusCode() == 403) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account targetedAccount = new AccountDAO(context, db).getAccountByToken(prefKeyOauthTokenT);
|
||||
HashMap<String, String> values = refreshToken(targetedAccount.getClient_id(), targetedAccount.getClient_secret(), targetedAccount.getRefresh_token());
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
|
|
|
@ -54,7 +54,7 @@ public class PixelfedAPI {
|
|||
if (Helper.getLiveInstance(context) != null)
|
||||
this.instance = Helper.getLiveInstance(context);
|
||||
else {
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(context));
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
|
|
|
@ -305,7 +305,7 @@ public class AccountsListAdapter extends RecyclerView.Adapter implements OnPostA
|
|||
}
|
||||
if (statusAction == API.StatusAction.FOLLOW) {
|
||||
if (action == RetrieveAccountsAsyncTask.Type.CHANNELS) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new InstancesDAO(context, db).insertInstance(accounts.get(0).getAcct().split("@")[1], accounts.get(0).getAcct().split("@")[0], "PEERTUBE_CHANNEL");
|
||||
} else {
|
||||
for (Account account : accounts) {
|
||||
|
|
|
@ -144,7 +144,7 @@ public class AccountsSearchAdapter extends ArrayAdapter<Account> implements Filt
|
|||
|
||||
if (owner) {
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account currentAccount = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
|
|
|
@ -218,7 +218,7 @@ public class ArtListAdapter extends RecyclerView.Adapter implements OnPostAction
|
|||
if (status.getId().equals(targetedId)) {
|
||||
statuses.remove(status);
|
||||
statusListAdapter.notifyItemRemoved(position);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
//Remove the status from cache also
|
||||
try {
|
||||
new StatusCacheDAO(context, db).remove(StatusCacheDAO.ARCHIVE_CACHE, status);
|
||||
|
|
|
@ -105,7 +105,7 @@ public class DraftsListAdapter extends BaseAdapter {
|
|||
}
|
||||
|
||||
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
|
||||
if (this.clickable) {
|
||||
if (draft.getStatus().getContent().length() > 300)
|
||||
|
|
|
@ -14,6 +14,7 @@ package app.fedilab.android.drawers;
|
|||
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
|
@ -128,7 +129,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
private NotificationsListAdapter.ViewHolder holder;
|
||||
private int style;
|
||||
private RecyclerView mRecyclerView;
|
||||
private List<NotificationsListAdapter.ViewHolder> lstHolders;
|
||||
|
||||
private Runnable updateAnimatedEmoji = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -136,17 +137,11 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
if (mRecyclerView != null && (mRecyclerView.getLayoutManager()) != null) {
|
||||
int firstPosition = ((LinearLayoutManager) mRecyclerView.getLayoutManager()).findFirstCompletelyVisibleItemPosition();
|
||||
int lastPosition = ((LinearLayoutManager) mRecyclerView.getLayoutManager()).findLastCompletelyVisibleItemPosition();
|
||||
|
||||
for (NotificationsListAdapter.ViewHolder holder : lstHolders) {
|
||||
|
||||
if (holder.getLayoutPosition() >= firstPosition && holder.getLayoutPosition() <= lastPosition) {
|
||||
holder.updateAnimatedEmoji();
|
||||
for (int i = firstPosition; i <= lastPosition; i++) {
|
||||
if (mRecyclerView.findViewHolderForAdapterPosition(i) != null) {
|
||||
((ViewHolder) Objects.requireNonNull(mRecyclerView.findViewHolderForAdapterPosition(i))).updateAnimatedEmoji();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (NotificationsListAdapter.ViewHolder holder : lstHolders) {
|
||||
holder.updateAnimatedEmoji();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -159,8 +154,6 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
notificationsListAdapter = this;
|
||||
this.isOnWifi = isOnWifi;
|
||||
this.behaviorWithAttachments = behaviorWithAttachments;
|
||||
lstHolders = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -184,6 +177,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
return new ViewHolder(layoutInflater.inflate(R.layout.drawer_notification, parent, false));
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
|
||||
|
||||
|
@ -191,9 +185,6 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
context = holder.status_document_container.getContext();
|
||||
|
||||
|
||||
synchronized (lock) {
|
||||
lstHolders.add(holder);
|
||||
}
|
||||
holder.startUpdateTimer();
|
||||
final Notification notification = notifications.get(position);
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
|
@ -687,9 +678,6 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
holder.status_reblog_count.setVisibility(View.VISIBLE);
|
||||
holder.spark_button_reblog.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
default:
|
||||
holder.status_reblog_count.setVisibility(View.VISIBLE);
|
||||
holder.spark_button_reblog.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -330,7 +330,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
|||
public void onRetrieveFeeds(APIResponse apiResponse) {
|
||||
if (apiResponse.getStatuses() != null && apiResponse.getStatuses().size() > 0) {
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
long id = new StatusStoredDAO(context, db).insertStatus(toot, apiResponse.getStatuses().get(0));
|
||||
Intent intentToot = new Intent(context, PixelfedComposeActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
|
@ -470,7 +470,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
|||
comment_content.setInputType(newInputType);
|
||||
in_reply_to_status = status.getReblog() != null ? status.getReblog().getId() : status.getId();
|
||||
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
|
||||
|
@ -750,7 +750,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
|||
case R.id.action_bookmark:
|
||||
if (type != RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS) {
|
||||
status.setBookmarked(!status.isBookmarked());
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
try {
|
||||
if (status.isBookmarked()) {
|
||||
new StatusCacheDAO(context, db).insertStatus(StatusCacheDAO.BOOKMARK_CACHE, status);
|
||||
|
@ -770,7 +770,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
|||
if (statustmp.getId().equals(status.getId())) {
|
||||
statuses.remove(status);
|
||||
pixelfedListAdapter.notifyItemRemoved(position);
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new StatusCacheDAO(context, db).remove(StatusCacheDAO.BOOKMARK_CACHE, statustmp);
|
||||
Toasty.success(context, context.getString(R.string.status_unbookmarked), Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
|
@ -899,7 +899,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
|||
} else if (status.getReblog() != null && status.getReblog().getPoll() != null) {
|
||||
toot.setPoll(status.getPoll());
|
||||
}
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
long id = new StatusStoredDAO(context, db).insertStatus(toot, null);
|
||||
Intent intentToot = new Intent(context, PixelfedComposeActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
|
@ -1114,7 +1114,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
|||
tootContent = comment_content.getText().toString().trim();
|
||||
Status toot = new Status();
|
||||
toot.setSensitive(false);
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
toot.setVisibility(visibility);
|
||||
toot.setIn_reply_to_id(in_reply_to_status);
|
||||
|
@ -1148,7 +1148,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
|||
if (status.getId().equals(targetedId)) {
|
||||
statuses.remove(status);
|
||||
pixelfedListAdapter.notifyItemRemoved(position);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
//Remove the status from cache also
|
||||
try {
|
||||
new StatusCacheDAO(context, db).remove(StatusCacheDAO.ARCHIVE_CACHE, status);
|
||||
|
@ -1235,7 +1235,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
|||
//Store the toot as draft first
|
||||
String targeted_id = status.getAccount().getId();
|
||||
Date date_mute = new Date(time);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
|
|
|
@ -172,7 +172,7 @@ public class ReorderTabAdapter extends RecyclerView.Adapter<ReorderTabAdapter.It
|
|||
}
|
||||
|
||||
holder.hideView.setOnClickListener(v -> {
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
int count = new TimelinesDAO(context, db).countVisibleTimelines();
|
||||
if (count > 2 || !tl.isDisplayed()) {
|
||||
tl.setDisplayed(!tl.isDisplayed());
|
||||
|
@ -216,7 +216,7 @@ public class ReorderTabAdapter extends RecyclerView.Adapter<ReorderTabAdapter.It
|
|||
public boolean onItemMove(int fromPosition, int toPosition) {
|
||||
Collections.swap(mItems, fromPosition, toPosition);
|
||||
notifyItemMoved(fromPosition, toPosition);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
int i = 0;
|
||||
for (ManageTimelines timelines : mItems) {
|
||||
timelines.setPosition(i);
|
||||
|
|
|
@ -165,7 +165,7 @@ public class ScheduledTootsListAdapter extends BaseAdapter implements OnPostActi
|
|||
holder.scheduled_toot_privacy.setImageResource(R.drawable.ic_mail_outline);
|
||||
break;
|
||||
}
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
int style;
|
||||
if (theme == Helper.THEME_DARK) {
|
||||
style = R.style.DialogDark;
|
||||
|
|
|
@ -108,6 +108,7 @@ import java.util.Date;
|
|||
import java.util.GregorianCalendar;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.regex.Matcher;
|
||||
|
@ -223,10 +224,10 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
private Status tootReply;
|
||||
private long currentToId;
|
||||
private RecyclerView mRecyclerView;
|
||||
private List<ViewHolder> lstHolders;
|
||||
private List<Emojis> emojisPicker;
|
||||
private Status statusForQuickReply;
|
||||
private String instanceType;
|
||||
|
||||
private Runnable updateAnimatedEmoji = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -234,15 +235,11 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
if (mRecyclerView != null && (mRecyclerView.getLayoutManager()) != null) {
|
||||
int firstPosition = ((LinearLayoutManager) mRecyclerView.getLayoutManager()).findFirstCompletelyVisibleItemPosition();
|
||||
int lastPosition = ((LinearLayoutManager) mRecyclerView.getLayoutManager()).findLastCompletelyVisibleItemPosition();
|
||||
for (ViewHolder holder : lstHolders) {
|
||||
if (holder.getLayoutPosition() >= firstPosition && holder.getLayoutPosition() <= lastPosition) {
|
||||
holder.updateAnimatedEmoji();
|
||||
for (int i = firstPosition; i <= lastPosition; i++) {
|
||||
if (mRecyclerView.findViewHolderForAdapterPosition(i) != null) {
|
||||
((ViewHolder) Objects.requireNonNull(mRecyclerView.findViewHolderForAdapterPosition(i))).updateAnimatedEmoji();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (ViewHolder holder : lstHolders) {
|
||||
holder.updateAnimatedEmoji();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -259,7 +256,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
tagTimeline = statusDrawerParams.getTagTimeline();
|
||||
conversationPosition = statusDrawerParams.getPosition();
|
||||
redraft = false;
|
||||
lstHolders = new ArrayList<>();
|
||||
toot_content = null;
|
||||
toot_cw_content = null;
|
||||
tootReply = null;
|
||||
|
@ -318,7 +314,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
@Override
|
||||
public void onRefresh(Status refreshedStatus) {
|
||||
if (refreshedStatus.getCreated_at() == null) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new TimelineCacheDAO(context, db).remove(refreshedStatus.getId());
|
||||
new PostActionAsyncTask(context, API.StatusAction.UNSTATUS, refreshedStatus.getId(), StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
@ -500,7 +496,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
if (apiResponse.getStatuses() != null && apiResponse.getStatuses().size() > 0)
|
||||
toot.setIn_reply_to_id(apiResponse.getStatuses().get(0).getId());
|
||||
toot.setContent(context, tootContent);
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
new PostStatusAsyncTask(context, social, account, toot, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
return;
|
||||
|
@ -606,7 +602,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
return new ViewHolderEmpty(layoutInflater.inflate(R.layout.drawer_empty, parent, false));
|
||||
}
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
@SuppressLint({"SetJavaScriptEnabled", "ClickableViewAccessibility"})
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, int i) {
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
|
@ -614,10 +610,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
context = viewHolder.itemView.getContext();
|
||||
if (viewHolder.getItemViewType() != HIDDEN_STATUS) {
|
||||
final ViewHolder holder = (ViewHolder) viewHolder;
|
||||
synchronized (lock) {
|
||||
lstHolders.add(holder);
|
||||
}
|
||||
|
||||
|
||||
holder.startUpdateTimer();
|
||||
final Status status = statuses.get(i);
|
||||
|
@ -927,7 +919,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
style = R.style.Dialog;
|
||||
}
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
emojisPicker = new CustomEmojiDAO(context, db).getAllEmojis(Helper.getLiveInstance(context));
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(context, style);
|
||||
int paddingPixel = 15;
|
||||
|
@ -1070,7 +1062,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
holder.status_add_custom_emoji.setVisibility(View.GONE);
|
||||
}
|
||||
holder.status_add_custom_emoji.setOnClickListener(v -> {
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
List<Emojis> emojis = new CustomEmojiDAO(context, db).getAllEmojis(account.getInstance());
|
||||
|
@ -1661,7 +1653,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
holder.fetch_more.setEnabled(false);
|
||||
holder.fetch_more.setVisibility(View.GONE);
|
||||
if (context instanceof BaseMainActivity) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<ManageTimelines> timelines = new TimelinesDAO(context, db).getDisplayedTimelines();
|
||||
for (ManageTimelines tl : timelines) {
|
||||
if (tl.getType() == ManageTimelines.Type.HOME && mPageReferenceMap != null) {
|
||||
|
@ -1680,7 +1672,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
holder.fetch_more.setEnabled(false);
|
||||
holder.fetch_more.setVisibility(View.GONE);
|
||||
if (context instanceof BaseMainActivity) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<ManageTimelines> timelines = new TimelinesDAO(context, db).getDisplayedTimelines();
|
||||
for (ManageTimelines tl : timelines) {
|
||||
if (tl.getType() == ManageTimelines.Type.HOME && mPageReferenceMap != null) {
|
||||
|
@ -2409,7 +2401,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
in_reply_to_status = status.getReblog() != null ? status.getReblog().getId() : status.getId();
|
||||
tootReply = status;
|
||||
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
|
||||
|
@ -2626,7 +2618,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
toot.setSpoiler_text(status.getSpoiler_text().trim());
|
||||
toot.setVisibility(status.getVisibility());
|
||||
toot.setContent(context, status.getContent());
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
long id = new StatusStoredDAO(context, db).insertStatus(toot, null);
|
||||
Intent intentToot = new Intent(context, TootActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
|
@ -2820,7 +2812,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
case R.id.action_bookmark:
|
||||
if (type != RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS) {
|
||||
status.setBookmarked(!status.isBookmarked());
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
try {
|
||||
if (status.isBookmarked()) {
|
||||
new StatusCacheDAO(context, db).insertStatus(StatusCacheDAO.BOOKMARK_CACHE, status);
|
||||
|
@ -2840,7 +2832,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
if (statustmp.getId().equals(status.getId())) {
|
||||
statuses.remove(status);
|
||||
statusListAdapter.notifyItemRemoved(position);
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new StatusCacheDAO(context, db).remove(StatusCacheDAO.BOOKMARK_CACHE, statustmp);
|
||||
Toasty.success(context, context.getString(R.string.status_unbookmarked), Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
|
@ -3002,7 +2994,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
} else if (status.getReblog() != null && status.getReblog().getPoll() != null) {
|
||||
toot.setPoll(status.getPoll());
|
||||
}
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
long id = new StatusStoredDAO(context, db).insertStatus(toot, null);
|
||||
Intent intentToot = new Intent(context, TootActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
|
@ -3346,6 +3338,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
DrawableTransitionOptions.withCrossFade();
|
||||
imageView.setImageBitmap(resource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
|
||||
|
@ -3361,7 +3354,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
.thumbnail(0.1f)
|
||||
// .override(640, 480)
|
||||
.apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(10)))
|
||||
.transition(DrawableTransitionOptions.withCrossFade())
|
||||
// .transition(DrawableTransitionOptions.withCrossFade())
|
||||
.into(imageView);
|
||||
} else {
|
||||
Glide.with(imageView.getContext())
|
||||
|
@ -3369,7 +3362,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
.thumbnail(0.1f)
|
||||
// .override(640, 480)
|
||||
.apply(new RequestOptions().transform(new BlurTransformation(50, 3), new RoundedCorners(10)))
|
||||
.transition(DrawableTransitionOptions.withCrossFade())
|
||||
// .transition(DrawableTransitionOptions.withCrossFade())
|
||||
.into(imageView);
|
||||
}
|
||||
}
|
||||
|
@ -3511,7 +3504,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
//Store the toot as draft first
|
||||
String targeted_id = status.getAccount().getId();
|
||||
Date date_mute = new Date(time);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
|
@ -3728,7 +3721,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
if (content_type != null)
|
||||
toot.setContentType(content_type);
|
||||
toot.setSensitive(false);
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
if (toot_cw_content.getText().toString().trim().length() > 0)
|
||||
toot.setSpoiler_text(toot_cw_content.getText().toString().trim());
|
||||
|
@ -3748,7 +3741,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
|
||||
if (apiResponse.getStatuses() != null && apiResponse.getStatuses().size() > 0) {
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
long id = new StatusStoredDAO(context, db).insertStatus(toot, apiResponse.getStatuses().get(0));
|
||||
Intent intentToot = new Intent(context, TootActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
|
@ -3807,7 +3800,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
if (status.getId().equals(targetedId)) {
|
||||
statuses.remove(status);
|
||||
statusListAdapter.notifyItemRemoved(position);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
//Remove the status from cache also
|
||||
try {
|
||||
new StatusCacheDAO(context, db).remove(StatusCacheDAO.ARCHIVE_CACHE, status);
|
||||
|
@ -3972,7 +3965,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
}
|
||||
|
||||
toot.setIn_reply_to_id(tootReply.getId());
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
try {
|
||||
if (currentToId == -1) {
|
||||
currentToId = new StatusStoredDAO(context, db).insertStatus(toot, tootReply);
|
||||
|
@ -4241,9 +4234,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
}
|
||||
|
||||
void updateAnimatedEmoji() {
|
||||
if (type != RetrieveFeedsAsyncTask.Type.CONVERSATION) {
|
||||
status_account_displayname.invalidate();
|
||||
}
|
||||
status_content.invalidate();
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public class TagsEditAdapter extends RecyclerView.Adapter {
|
|||
final String[] tag = {tags.get(viewHolder.getAdapterPosition())};
|
||||
ViewHolder holder = (ViewHolder) viewHolder;
|
||||
holder.tag_name.setText(String.format("#%s", tag[0]));
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
holder.save_tag.setOnClickListener(v -> {
|
||||
if (holder.tag_name.getText() != null && holder.tag_name.getText().toString().trim().replaceAll("#", "").length() > 0) {
|
||||
String tagToInsert = holder.tag_name.getText().toString().trim().replaceAll("#", "");
|
||||
|
|
|
@ -442,7 +442,7 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
|
|||
String title = getString(R.string.data_export_theme);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getActivity()));
|
||||
SQLiteDatabase db = Sqlite.getInstance(getActivity(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getActivity().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(getActivity(), db).getUniqAccount(userId, instance);
|
||||
Helper.notify_user(getActivity(), account, intentOpen, BitmapFactory.decodeResource(getResources(),
|
||||
Helper.getMainLogo(getActivity())), Helper.NotifType.BACKUP, title, message);
|
||||
|
|
|
@ -1521,7 +1521,7 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
|
|||
|
||||
|
||||
LinearLayout toot_visibility_container = rootView.findViewById(R.id.toot_visibility_container);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
|
||||
final Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
final ImageView set_toot_visibility = rootView.findViewById(R.id.set_toot_visibility);
|
||||
|
|
|
@ -97,7 +97,7 @@ public class DisplayBookmarksPixelfedFragment extends Fragment implements OnRetr
|
|||
@Override
|
||||
public void onRetrieveFeeds(APIResponse apiResponse) {
|
||||
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
mainLoader.setVisibility(View.GONE);
|
||||
FloatingActionButton delete_all = null;
|
||||
try {
|
||||
|
|
|
@ -73,7 +73,7 @@ public class DisplayDraftsFragment extends Fragment {
|
|||
} else {
|
||||
Helper.changeDrawableColor(context, R.drawable.ic_cancel, R.color.black);
|
||||
}
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
//Removes all scheduled toots that have sent
|
||||
new StatusStoredDAO(context, db).removeAllSent();
|
||||
drafts = new StatusStoredDAO(context, db).getAllDrafts();
|
||||
|
|
|
@ -98,7 +98,7 @@ public class DisplayFavoritesPeertubeFragment extends Fragment implements OnRetr
|
|||
@Override
|
||||
public void onRetrieveFeeds(APIResponse apiResponse) {
|
||||
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
mainLoader.setVisibility(View.GONE);
|
||||
FloatingActionButton delete_all = null;
|
||||
try {
|
||||
|
|
|
@ -266,7 +266,7 @@ public class DisplayFiltersFragment extends Fragment implements OnFilterActionIn
|
|||
}
|
||||
}
|
||||
MainActivity.filters = apiResponse.getFilters();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<ManageTimelines> timelines = new TimelinesDAO(context, db).getDisplayedTimelines();
|
||||
if (mPageReferenceMap == null) {
|
||||
return;
|
||||
|
|
|
@ -312,7 +312,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(context));
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account accountdb = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
LiveNotificationDelayedService.since_ids.put(accountdb.getAcct() + "@" + accountdb.getInstance(), notifications.get(0).getId());
|
||||
}
|
||||
|
@ -440,7 +440,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(context));
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
if (MainActivity.lastNotificationId != null && notifications.get(0).getId().compareTo(MainActivity.lastNotificationId) > 0) {
|
||||
LiveNotificationDelayedService.since_ids.put(account.getAcct() + "@" + account.getInstance(), notifications.get(0).getId());
|
||||
|
|
|
@ -93,7 +93,7 @@ public class DisplayScheduledTootsFragment extends Fragment implements OnRetriev
|
|||
mainLoader.setVisibility(View.VISIBLE);
|
||||
storedStatuses = new ArrayList<>();
|
||||
//Removes all scheduled toots that have sent
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
if (type == typeOfSchedule.TOOT)
|
||||
new StatusStoredDAO(context, db).removeAllSent();
|
||||
else if (type == typeOfSchedule.BOOST)
|
||||
|
|
|
@ -183,7 +183,7 @@ public class DisplayStatusFragment extends Fragment implements OnPostActionInter
|
|||
type = RetrieveFeedsAsyncTask.Type.CHANNEL;
|
||||
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
//instanceType should not be null only for Peertube accounts
|
||||
|
||||
if (remoteInstance != null && !remoteInstance.equals("") && instanceType == null) {
|
||||
|
@ -750,7 +750,8 @@ public class DisplayStatusFragment extends Fragment implements OnPostActionInter
|
|||
if (lv_status != null) {
|
||||
try {
|
||||
lv_status.setAdapter(null);
|
||||
} catch (Exception ignored) {}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
super.onDestroyView();
|
||||
rootView = null;
|
||||
|
|
|
@ -16,7 +16,6 @@ package app.fedilab.android.helper;
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
|
@ -76,7 +75,7 @@ public class CrossActions {
|
|||
*/
|
||||
private static List<Account> connectedAccounts(Context context, Status status, boolean limitedToOwner) {
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<Account> accountstmp = new AccountDAO(context, db).getAllAccountCrossAction();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
|
@ -148,7 +147,7 @@ public class CrossActions {
|
|||
if ((type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE || type == RetrieveFeedsAsyncTask.Type.NEWS) && limitedToOwner) {
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account currentAccount = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
if (confirmation && status.getContent() != null)
|
||||
displayConfirmationDialogCrossAction(context, currentAccount, doAction, status, onPostActionInterface, baseAdapter);
|
||||
|
@ -228,19 +227,12 @@ public class CrossActions {
|
|||
accountArray[i] = account;
|
||||
i++;
|
||||
}
|
||||
builderSingle.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builderSingle.setAdapter(accountsSearchAdapter, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
builderSingle.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
||||
builderSingle.setAdapter(accountsSearchAdapter, (dialog, which) -> {
|
||||
Account selectedAccount = accountArray[which];
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account loggedAccount = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
if (targetedAccount == null) {
|
||||
if (loggedAccount.getInstance().equals(selectedAccount.getInstance())) {
|
||||
|
@ -274,7 +266,6 @@ public class CrossActions {
|
|||
}
|
||||
}
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builderSingle.show();
|
||||
}
|
||||
|
@ -318,7 +309,7 @@ public class CrossActions {
|
|||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
|
@ -410,7 +401,7 @@ public class CrossActions {
|
|||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
|
@ -459,7 +450,7 @@ public class CrossActions {
|
|||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
|
@ -506,7 +497,7 @@ public class CrossActions {
|
|||
if (accounts.size() == 1 || limitedToOwner) {
|
||||
status.setBookmarked(!status.isBookmarked());
|
||||
try {
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
if (status.isBookmarked()) {
|
||||
doAction = API.StatusAction.BOOKMARK;
|
||||
new StatusCacheDAO(context, db).insertStatus(StatusCacheDAO.BOOKMARK_CACHE, status);
|
||||
|
@ -532,16 +523,9 @@ public class CrossActions {
|
|||
accountArray[i] = account;
|
||||
i++;
|
||||
}
|
||||
builderSingle.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builderSingle.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
||||
Status finalStatus = status;
|
||||
builderSingle.setAdapter(accountsSearchAdapter, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final DialogInterface dialog, int which) {
|
||||
builderSingle.setAdapter(accountsSearchAdapter, (dialog, which) -> {
|
||||
final Account account = accountArray[which];
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
Results response;
|
||||
|
@ -568,25 +552,24 @@ public class CrossActions {
|
|||
}
|
||||
List<app.fedilab.android.client.Entities.Status> statuses = response.getStatuses();
|
||||
if (statuses != null && statuses.size() > 0) {
|
||||
final SQLiteDatabase db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final SQLiteDatabase db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
app.fedilab.android.client.Entities.Status statusBookmarked = new StatusCacheDAO(contextReference.get(), db).getStatus(StatusCacheDAO.BOOKMARK_CACHE, statuses.get(0).getId(), account.getId(), account.getInstance());
|
||||
API.StatusAction doAction;
|
||||
API.StatusAction doAction1;
|
||||
if (statusBookmarked == null) {
|
||||
doAction = API.StatusAction.BOOKMARK;
|
||||
doAction1 = API.StatusAction.BOOKMARK;
|
||||
new StatusCacheDAO(contextReference.get(), db).insertStatus(StatusCacheDAO.BOOKMARK_CACHE, statuses.get(0), account.getId(), account.getInstance());
|
||||
Toasty.success(contextReference.get(), contextReference.get().getString(R.string.status_bookmarked), Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
doAction = API.StatusAction.UNBOOKMARK;
|
||||
doAction1 = API.StatusAction.UNBOOKMARK;
|
||||
new StatusCacheDAO(contextReference.get(), db).remove(StatusCacheDAO.BOOKMARK_CACHE, statuses.get(0), account.getId(), account.getInstance());
|
||||
Toasty.success(contextReference.get(), contextReference.get().getString(R.string.status_unbookmarked), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
new PostActionAsyncTask(context, account, finalStatus, doAction, null).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
new PostActionAsyncTask(context, account, finalStatus, doAction1, null).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
statusListAdapter.notifyStatusChanged(statuses.get(0));
|
||||
}
|
||||
}
|
||||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
||||
}
|
||||
});
|
||||
builderSingle.show();
|
||||
}
|
||||
|
@ -624,15 +607,8 @@ public class CrossActions {
|
|||
accountArray[i] = account;
|
||||
i++;
|
||||
}
|
||||
builderSingle.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builderSingle.setAdapter(accountsSearchAdapter, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final DialogInterface dialog, int which) {
|
||||
builderSingle.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
||||
builderSingle.setAdapter(accountsSearchAdapter, (dialog, which) -> {
|
||||
final Account account = accountArray[which];
|
||||
if (status != null) {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
|
@ -710,14 +686,13 @@ public class CrossActions {
|
|||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
builderSingle.show();
|
||||
} else {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
|
@ -789,15 +764,8 @@ public class CrossActions {
|
|||
accountArray[i] = account;
|
||||
i++;
|
||||
}
|
||||
builderSingle.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builderSingle.setAdapter(accountsSearchAdapter, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final DialogInterface dialog, int which) {
|
||||
builderSingle.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
||||
builderSingle.setAdapter(accountsSearchAdapter, (dialog, which) -> {
|
||||
final Account account = accountArray[which];
|
||||
Intent intentToot = new Intent(context, TootActivity.class);
|
||||
bundle.putString("accountReplyToken", account.getId() + "|" + account.getInstance());
|
||||
|
@ -805,7 +773,6 @@ public class CrossActions {
|
|||
context.startActivity(intentToot);
|
||||
((BaseActivity) context).finish();
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builderSingle.show();
|
||||
}
|
||||
|
@ -839,13 +806,10 @@ public class CrossActions {
|
|||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
builder.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY));
|
||||
else
|
||||
//noinspection deprecation
|
||||
builder.setMessage(Html.fromHtml(status.getContent()));
|
||||
builder.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setTitle(title)
|
||||
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
.setPositiveButton(R.string.yes, (dialog, which) -> {
|
||||
if (action == API.StatusAction.REBLOG || action == API.StatusAction.UNREBLOG)
|
||||
reblogAction(context, status, onPostActionInterface);
|
||||
else if (action == API.StatusAction.FAVOURITE || action == API.StatusAction.UNFAVOURITE)
|
||||
|
@ -879,15 +843,8 @@ public class CrossActions {
|
|||
((StatusListAdapter) baseAdapter).notifyStatusChanged(status);
|
||||
}
|
||||
dialog.dismiss();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
|
||||
})
|
||||
.setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss())
|
||||
.show();
|
||||
}
|
||||
|
||||
|
@ -920,13 +877,10 @@ public class CrossActions {
|
|||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
builder.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY));
|
||||
else
|
||||
//noinspection deprecation
|
||||
builder.setMessage(Html.fromHtml(status.getContent()));
|
||||
builder.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setTitle(title)
|
||||
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
.setPositiveButton(R.string.yes, (dialog, which) -> {
|
||||
if (action == API.StatusAction.FAVOURITE || action == API.StatusAction.UNFAVOURITE) {
|
||||
if (action == API.StatusAction.FAVOURITE) {
|
||||
status.setFavourited(true);
|
||||
|
@ -954,34 +908,11 @@ public class CrossActions {
|
|||
}
|
||||
new PostActionAsyncTask(context, currentAccount, status, action, onPostActionInterface).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
dialog.dismiss();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
|
||||
})
|
||||
.setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss())
|
||||
.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Follow/Unfollow an account
|
||||
*
|
||||
* @param account Account
|
||||
*/
|
||||
private static void followAction(Context context, Account account, RecyclerView.Adapter baseAdapter, OnPostActionInterface onPostActionInterface) {
|
||||
if (account.isFollowing()) {
|
||||
new PostActionAsyncTask(context, API.StatusAction.UNFOLLOW, account.getId(), onPostActionInterface).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
account.setFollowing(false);
|
||||
} else {
|
||||
new PostActionAsyncTask(context, API.StatusAction.FOLLOW, account.getId(), onPostActionInterface).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
account.setFollowing(true);
|
||||
}
|
||||
baseAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Favourites/Unfavourites a status
|
||||
*
|
||||
|
|
|
@ -137,7 +137,6 @@ import net.gotev.uploadservice.okhttp.OkHttpStack;
|
|||
import org.conscrypt.Conscrypt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
|
@ -147,7 +146,6 @@ import java.io.FileOutputStream;
|
|||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Type;
|
||||
|
@ -580,7 +578,6 @@ public class Helper {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/***
|
||||
* Check if the user is connected to Internet
|
||||
* @return boolean
|
||||
|
@ -627,7 +624,7 @@ public class Helper {
|
|||
public static void logoutCurrentUser(Activity activity) {
|
||||
SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
//Current user
|
||||
SQLiteDatabase db = Sqlite.getInstance(activity, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(activity.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(activity));
|
||||
Account account = new AccountDAO(activity, db).getUniqAccount(userId, instance);
|
||||
|
@ -1302,7 +1299,7 @@ public class Helper {
|
|||
final SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
if (!menuAccountsOpened) {
|
||||
arrow.setImageResource(R.drawable.ic_arrow_drop_up);
|
||||
SQLiteDatabase db = Sqlite.getInstance(activity, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(activity.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final List<Account> accounts = new AccountDAO(activity, db).getAllAccount();
|
||||
String lastInstance = "";
|
||||
navigationView.getMenu().clear();
|
||||
|
@ -1462,7 +1459,7 @@ public class Helper {
|
|||
}
|
||||
|
||||
} else {
|
||||
SQLiteDatabase db = Sqlite.getInstance(activity, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(activity.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
MainMenuItem mainMenuItem = new MainMenuDAO(activity, db).getMainMenu();
|
||||
if (mainMenuItem == null) {
|
||||
mainMenuItem = new MainMenuItem();
|
||||
|
@ -1546,7 +1543,7 @@ public class Helper {
|
|||
navigationView.inflateMenu(R.menu.activity_main_drawer);
|
||||
hideMenuItem(activity, navigationView.getMenu());
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(activity, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(activity.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(activity, db).getUniqAccount(userID, instance);
|
||||
//Can happen when an account has been deleted and there is a click on an old notification
|
||||
if (account == null)
|
||||
|
@ -1698,7 +1695,7 @@ public class Helper {
|
|||
ImageView icon;
|
||||
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(activity, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(activity.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final List<Account> accounts = new AccountDAO(activity, db).getAllAccount();
|
||||
if (activity.isFinishing())
|
||||
return;
|
||||
|
@ -2870,7 +2867,7 @@ public class Helper {
|
|||
TabLayout tableLayout = activity.findViewById(R.id.tabLayout);
|
||||
String userID = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
SQLiteDatabase db = Sqlite.getInstance(activity, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(activity.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(activity, db).getUniqAccount(userID, instance);
|
||||
if (account != null) {
|
||||
if (social != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA && social != UpdateAccountInfoAsyncTask.SOCIAL.GNU) {
|
||||
|
@ -3698,6 +3695,7 @@ public class Helper {
|
|||
private static void removeOnGlobalLayoutListener(View v, ViewTreeObserver.OnGlobalLayoutListener listener) {
|
||||
v.getViewTreeObserver().removeOnGlobalLayoutListener(listener);
|
||||
}
|
||||
|
||||
public static int languageSpinnerPosition(Context context) {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
String defaultLocaleString = sharedpreferences.getString(Helper.SET_DEFAULT_LOCALE_NEW, "NOT_DEFINED");
|
||||
|
@ -3902,7 +3900,7 @@ public class Helper {
|
|||
intent.setAction(android.content.Intent.ACTION_VIEW);
|
||||
Uri uri = Uri.parse("file://" + file.getAbsolutePath());
|
||||
intent.setDataAndType(uri, mime);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(context));
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
|
@ -3986,7 +3984,7 @@ public class Helper {
|
|||
intent.setAction(Intent.ACTION_VIEW);
|
||||
Uri uri = Uri.fromFile(backupFile);
|
||||
intent.setDataAndType(uri, mime);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(context));
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
|
@ -4000,7 +3998,8 @@ public class Helper {
|
|||
shareIntent.setType(mime);
|
||||
try {
|
||||
context.startActivity(shareIntent);
|
||||
} catch (Exception ignored) {}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
|
@ -4229,7 +4228,7 @@ public class Helper {
|
|||
intent.setAction(Intent.ACTION_VIEW);
|
||||
Uri uri = Uri.fromFile(new File(filename));
|
||||
intent.setDataAndType(uri, "text/csv");
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(context));
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
|
@ -4506,7 +4505,7 @@ public class Helper {
|
|||
if (dir.isDirectory()) {
|
||||
Helper.deleteDir(dir);
|
||||
}
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new StatusCacheDAO(contextReference.get(), db).removeDuplicate();
|
||||
if (clean_all.isChecked()) {
|
||||
if (cache_timeline.isChecked()) {
|
||||
|
|
|
@ -84,7 +84,7 @@ public class BackupNotificationsSyncJob extends Job {
|
|||
* Task in background starts here.
|
||||
*/
|
||||
private void backupService() {
|
||||
SQLiteDatabase db = Sqlite.getInstance(getContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getContext().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final List<Account> accounts = new AccountDAO(getContext(), db).getAllAccount();
|
||||
SharedPreferences sharedpreferences = getContext().getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
for (Account account : accounts) {
|
||||
|
|
|
@ -83,7 +83,7 @@ public class BackupStatusesSyncJob extends Job {
|
|||
* Task in background starts here.
|
||||
*/
|
||||
private void backupService() {
|
||||
SQLiteDatabase db = Sqlite.getInstance(getContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getContext().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final List<Account> accounts = new AccountDAO(getContext(), db).getAllAccount();
|
||||
SharedPreferences sharedpreferences = getContext().getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
for (Account account : accounts) {
|
||||
|
|
|
@ -118,7 +118,7 @@ public class NotificationsSyncJob extends Job {
|
|||
if (liveNotifications != Helper.NOTIF_NONE) {
|
||||
return;
|
||||
}
|
||||
SQLiteDatabase db = Sqlite.getInstance(getContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getContext().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
//If an Internet connection and user agrees with notification refresh
|
||||
final SharedPreferences sharedpreferences = getContext().getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
//Check which notifications the user wants to see
|
||||
|
|
|
@ -52,7 +52,7 @@ public class ScheduledBoostsSyncJob extends Job {
|
|||
|
||||
long startMs = (timestampScheduling - new Date().getTime());
|
||||
long endMs = startMs + TimeUnit.MINUTES.toMillis(5);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
|
||||
int jobId = new JobRequest.Builder(ScheduledBoostsSyncJob.SCHEDULED_BOOST)
|
||||
.setExecutionWindow(startMs, endMs)
|
||||
|
@ -69,7 +69,7 @@ public class ScheduledBoostsSyncJob extends Job {
|
|||
|
||||
long startMs = (timestampScheduling - new Date().getTime());
|
||||
long endMs = startMs + TimeUnit.MINUTES.toMillis(5);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
|
||||
int jobId = new JobRequest.Builder(ScheduledTootsSyncJob.SCHEDULED_TOOT)
|
||||
.setExecutionWindow(startMs, endMs)
|
||||
|
@ -87,7 +87,7 @@ public class ScheduledBoostsSyncJob extends Job {
|
|||
protected Result onRunJob(@NonNull Params params) {
|
||||
//Code refresh here
|
||||
int jobId = params.getId();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getContext().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
//Retrieves the stored status
|
||||
StoredStatus storedStatus = new BoostScheduleDAO(getContext(), db).getStatusScheduled(jobId);
|
||||
if (storedStatus != null) {
|
||||
|
|
|
@ -52,7 +52,7 @@ public class ScheduledTootsSyncJob extends Job {
|
|||
|
||||
long startMs = (timestampScheduling - new Date().getTime());
|
||||
long endMs = startMs + TimeUnit.MINUTES.toMillis(5);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
|
||||
int jobId = new JobRequest.Builder(ScheduledTootsSyncJob.SCHEDULED_TOOT)
|
||||
.setExecutionWindow(startMs, endMs)
|
||||
|
@ -70,7 +70,7 @@ public class ScheduledTootsSyncJob extends Job {
|
|||
protected Result onRunJob(@NonNull Params params) {
|
||||
//Code refresh here
|
||||
int jobId = params.getId();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getContext().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
//Retrieves the stored status
|
||||
StoredStatus storedStatus = new StatusStoredDAO(getContext(), db).getStatusScheduled(jobId);
|
||||
if (storedStatus != null) {
|
||||
|
|
|
@ -114,7 +114,7 @@ public class BackupNotificationInDataBaseService extends IntentService {
|
|||
}
|
||||
instanceRunning++;
|
||||
String message;
|
||||
SQLiteDatabase db = Sqlite.getInstance(BackupNotificationInDataBaseService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(BackupNotificationInDataBaseService.this, db).getUniqAccount(userId, instance);
|
||||
API api = new API(BackupNotificationInDataBaseService.this, account.getInstance(), account.getToken());
|
||||
try {
|
||||
|
|
|
@ -115,7 +115,7 @@ public class BackupStatusInDataBaseService extends IntentService {
|
|||
}
|
||||
instanceRunning++;
|
||||
String message;
|
||||
SQLiteDatabase db = Sqlite.getInstance(BackupStatusInDataBaseService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(BackupStatusInDataBaseService.this, db).getUniqAccount(userId, instance);
|
||||
API api = new API(BackupStatusInDataBaseService.this, account.getInstance(), account.getToken());
|
||||
try {
|
||||
|
|
|
@ -106,7 +106,7 @@ public class BackupStatusService extends IntentService {
|
|||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
SQLiteDatabase db = Sqlite.getInstance(BackupStatusService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(BackupStatusService.this, db).getUniqAccount(userId, instance);
|
||||
API api = new API(BackupStatusService.this, account.getInstance(), account.getToken());
|
||||
try {
|
||||
|
|
|
@ -100,7 +100,7 @@ public class LiveNotificationDelayedService extends Service {
|
|||
((NotificationManager) Objects.requireNonNull(getSystemService(Context.NOTIFICATION_SERVICE))).createNotificationChannel(channel);
|
||||
}
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(LiveNotificationDelayedService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<Account> accountStreams = new AccountDAO(LiveNotificationDelayedService.this, db).getAllAccountCrossAction();
|
||||
totalAccount = 0;
|
||||
if (accountStreams != null) {
|
||||
|
@ -181,7 +181,7 @@ public class LiveNotificationDelayedService extends Service {
|
|||
|
||||
private void startStream() {
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(LiveNotificationDelayedService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
if (Helper.liveNotifType(LiveNotificationDelayedService.this) == Helper.NOTIF_DELAYED) {
|
||||
List<Account> accountStreams = new AccountDAO(LiveNotificationDelayedService.this, db).getAllAccountCrossAction();
|
||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
|
|
|
@ -114,7 +114,7 @@ public class LiveNotificationService extends Service implements NetworkStateRece
|
|||
|
||||
((NotificationManager) Objects.requireNonNull(getSystemService(Context.NOTIFICATION_SERVICE))).createNotificationChannel(channel);
|
||||
}
|
||||
SQLiteDatabase db = Sqlite.getInstance(LiveNotificationService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<Account> accountStreams = new AccountDAO(LiveNotificationService.this, db).getAllAccountCrossAction();
|
||||
totalAccount = 0;
|
||||
if (accountStreams != null) {
|
||||
|
@ -155,7 +155,7 @@ public class LiveNotificationService extends Service implements NetworkStateRece
|
|||
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
boolean liveNotifications = sharedpreferences.getBoolean(Helper.SET_LIVE_NOTIFICATIONS, true);
|
||||
SQLiteDatabase db = Sqlite.getInstance(LiveNotificationService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
if (liveNotifications) {
|
||||
List<Account> accountStreams = new AccountDAO(LiveNotificationService.this, db).getAllAccountCrossAction();
|
||||
if (accountStreams != null) {
|
||||
|
|
|
@ -100,7 +100,7 @@ public class StreamingFederatedTimelineService extends IntentService {
|
|||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account accountStream = null;
|
||||
if (userId != null) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(StreamingFederatedTimelineService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
accountStream = new AccountDAO(StreamingFederatedTimelineService.this, db).getUniqAccount(userId, instance);
|
||||
}
|
||||
if (accountStream != null) {
|
||||
|
|
|
@ -100,7 +100,7 @@ public class StreamingHomeTimelineService extends IntentService {
|
|||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account accountStream = null;
|
||||
if (userId != null) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(StreamingHomeTimelineService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
accountStream = new AccountDAO(StreamingHomeTimelineService.this, db).getUniqAccount(userId, instance);
|
||||
}
|
||||
if (accountStream != null) {
|
||||
|
|
|
@ -100,7 +100,7 @@ public class StreamingLocalTimelineService extends IntentService {
|
|||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account accountStream = null;
|
||||
if (userId != null) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(StreamingLocalTimelineService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
accountStream = new AccountDAO(StreamingLocalTimelineService.this, db).getUniqAccount(userId, instance);
|
||||
}
|
||||
|
||||
|
|
|
@ -360,7 +360,7 @@ public class Sqlite extends SQLiteOpenHelper {
|
|||
intent.setAction(android.content.Intent.ACTION_VIEW);
|
||||
Uri uri = Uri.fromFile(dbDest);
|
||||
intent.setDataAndType(uri, "*/*");
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(context));
|
||||
|
@ -555,8 +555,6 @@ public class Sqlite extends SQLiteOpenHelper {
|
|||
if (db != null && db.isOpen()) {
|
||||
db.close();
|
||||
}
|
||||
sInstance = null;
|
||||
db = null;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue