Fix potential leaks

This commit is contained in:
tom79 2020-04-08 12:42:15 +02:00
parent 39e6feb279
commit d7c39a9d99
80 changed files with 1534 additions and 1816 deletions

View File

@ -94,7 +94,7 @@ public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccou
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(AboutActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(AboutActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(AboutActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
@ -208,11 +208,11 @@ public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccou
lv_ux.setAdapter(accountSearchWebAdapterUxUiDesigners); lv_ux.setAdapter(accountSearchWebAdapterUxUiDesigners);
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) { if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
new RetrieveRemoteDataAsyncTask(getApplicationContext(), "fedilab", "toot.fedilab.app", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveRemoteDataAsyncTask(AboutActivity.this, "fedilab", "toot.fedilab.app", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new RetrieveRemoteDataAsyncTask(getApplicationContext(), "mmarif", "mastodon.social", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveRemoteDataAsyncTask(AboutActivity.this, "mmarif", "mastodon.social", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new RetrieveRemoteDataAsyncTask(getApplicationContext(), "PhotonQyv", "mastodon.xyz", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveRemoteDataAsyncTask(AboutActivity.this, "PhotonQyv", "mastodon.xyz", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new RetrieveRemoteDataAsyncTask(getApplicationContext(), "angrytux", "social.tchncs.de", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveRemoteDataAsyncTask(AboutActivity.this, "angrytux", "social.tchncs.de", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new RetrieveRemoteDataAsyncTask(getApplicationContext(), "guzzisti", "mastodon.social", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveRemoteDataAsyncTask(AboutActivity.this, "guzzisti", "mastodon.social", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else { } else {
SpannableString name = new SpannableString("@fedilab@toot.fedilab.app"); SpannableString name = new SpannableString("@fedilab@toot.fedilab.app");
name.setSpan(new UnderlineSpan(), 0, name.length(), 0); name.setSpan(new UnderlineSpan(), 0, name.length(), 0);
@ -251,7 +251,7 @@ public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccou
@Override @Override
public void onRetrieveRemoteAccount(Results results, boolean developerAccount) { public void onRetrieveRemoteAccount(Results results, boolean developerAccount) {
if (results == null) { if (results == null) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(AboutActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
return; return;
} }
List<Account> accounts = results.getAccounts(); List<Account> accounts = results.getAccounts();
@ -273,7 +273,7 @@ public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccou
accountSearchWebAdapterContributors.notifyDataSetChanged(); accountSearchWebAdapterContributors.notifyDataSetChanged();
break; break;
} }
new RetrieveRelationshipAsyncTask(getApplicationContext(), account.getId(), AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveRelationshipAsyncTask(AboutActivity.this, account.getId(), AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
} }
@ -283,17 +283,17 @@ public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccou
super.onResume(); super.onResume();
if (developers != null) { if (developers != null) {
for (Account account : developers) { for (Account account : developers) {
new RetrieveRelationshipAsyncTask(getApplicationContext(), account.getId(), AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveRelationshipAsyncTask(AboutActivity.this, account.getId(), AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
} }
if (contributors != null) { if (contributors != null) {
for (Account account : contributors) { for (Account account : contributors) {
new RetrieveRelationshipAsyncTask(getApplicationContext(), account.getId(), AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveRelationshipAsyncTask(AboutActivity.this, account.getId(), AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
} }
if (uxuidesigners != null) { if (uxuidesigners != null) {
for (Account account : uxuidesigners) { for (Account account : uxuidesigners) {
new RetrieveRelationshipAsyncTask(getApplicationContext(), account.getId(), AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveRelationshipAsyncTask(AboutActivity.this, account.getId(), AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
} }
} }

View File

@ -94,14 +94,14 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(AccountReportActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(AccountReportActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(AccountReportActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
ImageView toolbar_close = actionBar.getCustomView().findViewById(R.id.toolbar_close); ImageView toolbar_close = actionBar.getCustomView().findViewById(R.id.toolbar_close);
TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title); TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
toolbar_close.setOnClickListener(v -> finish()); toolbar_close.setOnClickListener(v -> finish());
toolbar_title.setText(String.format(getString(R.string.administration) + " %s", Helper.getLiveInstance(getApplicationContext()))); toolbar_title.setText(String.format(getString(R.string.administration) + " %s", Helper.getLiveInstance(AccountReportActivity.this)));
} }
setContentView(R.layout.activity_admin_report); setContentView(R.layout.activity_admin_report);
@ -116,8 +116,8 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
email_label = findViewById(R.id.email_label); email_label = findViewById(R.id.email_label);
allow_reject_group = findViewById(R.id.allow_reject_group); allow_reject_group = findViewById(R.id.allow_reject_group);
allow_reject_group.setVisibility(View.GONE); allow_reject_group.setVisibility(View.GONE);
allow.getBackground().setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.green_1), PorterDuff.Mode.MULTIPLY); allow.getBackground().setColorFilter(ContextCompat.getColor(AccountReportActivity.this, R.color.green_1), PorterDuff.Mode.MULTIPLY);
reject.getBackground().setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.red_1), PorterDuff.Mode.MULTIPLY); reject.getBackground().setColorFilter(ContextCompat.getColor(AccountReportActivity.this, R.color.red_1), PorterDuff.Mode.MULTIPLY);
comment_label = findViewById(R.id.comment_label); comment_label = findViewById(R.id.comment_label);
permissions = findViewById(R.id.permissions); permissions = findViewById(R.id.permissions);
username = findViewById(R.id.username); username = findViewById(R.id.username);
@ -132,13 +132,13 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
comment = findViewById(R.id.comment); comment = findViewById(R.id.comment);
if (account_id == null && report == null && targeted_account == null) { if (account_id == null && report == null && targeted_account == null) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(AccountReportActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
finish(); finish();
} }
assign.setVisibility(View.GONE); assign.setVisibility(View.GONE);
status.setVisibility(View.GONE); status.setVisibility(View.GONE);
if (account_id != null) { if (account_id != null) {
new PostAdminActionAsyncTask(getApplicationContext(), API.adminAction.GET_ONE_ACCOUNT, account_id, null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.GET_ONE_ACCOUNT, account_id, null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
return; return;
} }
if (report != null) { if (report != null) {
@ -156,7 +156,7 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
Group statuses_group = findViewById(R.id.statuses_group); Group statuses_group = findViewById(R.id.statuses_group);
statuses_group.setVisibility(View.VISIBLE); statuses_group.setVisibility(View.VISIBLE);
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) { if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
new PostAdminActionAsyncTask(getApplicationContext(), API.adminAction.GET_ONE_ACCOUNT, report.getTarget_account().getUsername(), null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.GET_ONE_ACCOUNT, report.getTarget_account().getUsername(), null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
} }
@ -187,7 +187,7 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
}); });
builderInner.show(); builderInner.show();
} else { } else {
Toasty.error(getApplicationContext(), apiResponse.getError().getError(), Toast.LENGTH_LONG).show(); Toasty.error(AccountReportActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
} }
return; return;
} }
@ -206,7 +206,7 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
private void fillReport(AccountAdmin accountAdmin) { private void fillReport(AccountAdmin accountAdmin) {
if (accountAdmin == null) { if (accountAdmin == null) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(AccountReportActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
return; return;
} }
if (!accountAdmin.isApproved() && MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA && (accountAdmin.getDomain() == null || accountAdmin.getDomain().equals("null"))) { if (!accountAdmin.isApproved() && MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA && (accountAdmin.getDomain() == null || accountAdmin.getDomain().equals("null"))) {
@ -216,13 +216,13 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
reject.setOnClickListener(view -> { reject.setOnClickListener(view -> {
AdminAction adminAction = new AdminAction(); AdminAction adminAction = new AdminAction();
adminAction.setType(REJECT); adminAction.setType(REJECT);
new PostAdminActionAsyncTask(getApplicationContext(), REJECT, account_id, adminAction, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostAdminActionAsyncTask(AccountReportActivity.this, REJECT, account_id, adminAction, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}); });
allow.setOnClickListener(view -> { allow.setOnClickListener(view -> {
AdminAction adminAction = new AdminAction(); AdminAction adminAction = new AdminAction();
adminAction.setType(APPROVE); adminAction.setType(APPROVE);
new PostAdminActionAsyncTask(getApplicationContext(), APPROVE, account_id, adminAction, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostAdminActionAsyncTask(AccountReportActivity.this, APPROVE, account_id, adminAction, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}); });
warn.setOnClickListener(view -> { warn.setOnClickListener(view -> {
@ -230,7 +230,7 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
adminAction.setType(NONE); adminAction.setType(NONE);
adminAction.setSend_email_notification(email_user.isChecked()); adminAction.setSend_email_notification(email_user.isChecked());
adminAction.setText(comment.getText().toString().trim()); adminAction.setText(comment.getText().toString().trim());
new PostAdminActionAsyncTask(getApplicationContext(), NONE, account_id, adminAction, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostAdminActionAsyncTask(AccountReportActivity.this, NONE, account_id, adminAction, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}); });
@ -245,9 +245,9 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
adminAction.setType(SILENCE); adminAction.setType(SILENCE);
adminAction.setSend_email_notification(email_user.isChecked()); adminAction.setSend_email_notification(email_user.isChecked());
adminAction.setText(comment.getText().toString().trim()); adminAction.setText(comment.getText().toString().trim());
new PostAdminActionAsyncTask(getApplicationContext(), SILENCE, account_id, adminAction, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostAdminActionAsyncTask(AccountReportActivity.this, SILENCE, account_id, adminAction, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else { } else {
new PostAdminActionAsyncTask(getApplicationContext(), API.adminAction.UNSILENCE, account_id, null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.UNSILENCE, account_id, null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
}); });
@ -262,9 +262,9 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
adminAction.setType(DISABLE); adminAction.setType(DISABLE);
adminAction.setSend_email_notification(email_user.isChecked()); adminAction.setSend_email_notification(email_user.isChecked());
adminAction.setText(comment.getText().toString().trim()); adminAction.setText(comment.getText().toString().trim());
new PostAdminActionAsyncTask(getApplicationContext(), DISABLE, account_id, adminAction, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostAdminActionAsyncTask(AccountReportActivity.this, DISABLE, account_id, adminAction, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else { } else {
new PostAdminActionAsyncTask(getApplicationContext(), API.adminAction.ENABLE, account_id, null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.ENABLE, account_id, null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
}); });
if (!accountAdmin.isSuspended()) { if (!accountAdmin.isSuspended()) {
@ -278,9 +278,9 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
adminAction.setType(SUSPEND); adminAction.setType(SUSPEND);
adminAction.setSend_email_notification(email_user.isChecked()); adminAction.setSend_email_notification(email_user.isChecked());
adminAction.setText(comment.getText().toString().trim()); adminAction.setText(comment.getText().toString().trim());
new PostAdminActionAsyncTask(getApplicationContext(), SUSPEND, account_id, adminAction, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostAdminActionAsyncTask(AccountReportActivity.this, SUSPEND, account_id, adminAction, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else { } else {
new PostAdminActionAsyncTask(getApplicationContext(), API.adminAction.UNSUSPEND, account_id, null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.UNSUSPEND, account_id, null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
}); });
@ -319,7 +319,7 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
break; break;
} }
if (message != null) { if (message != null) {
Toasty.success(getApplicationContext(), message, Toast.LENGTH_LONG).show(); Toasty.success(AccountReportActivity.this, message, Toast.LENGTH_LONG).show();
} }
comment.setText(""); comment.setText("");
InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
@ -411,9 +411,9 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
} }
assign.setOnClickListener(view -> { assign.setOnClickListener(view -> {
if (report.getAssigned_account() == null) { if (report.getAssigned_account() == null) {
new PostAdminActionAsyncTask(getApplicationContext(), API.adminAction.ASSIGN_TO_SELF, report.getId(), null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.ASSIGN_TO_SELF, report.getId(), null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else { } else {
new PostAdminActionAsyncTask(getApplicationContext(), API.adminAction.UNASSIGN, report.getId(), null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.UNASSIGN, report.getId(), null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
}); });
if (report.isAction_taken()) { if (report.isAction_taken()) {
@ -423,9 +423,9 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
} }
status.setOnClickListener(view -> { status.setOnClickListener(view -> {
if (report.isAction_taken()) { if (report.isAction_taken()) {
new PostAdminActionAsyncTask(getApplicationContext(), API.adminAction.REOPEN, report.getId(), null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.REOPEN, report.getId(), null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else { } else {
new PostAdminActionAsyncTask(getApplicationContext(), API.adminAction.RESOLVE, report.getId(), null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.RESOLVE, report.getId(), null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
}); });

View File

@ -73,14 +73,14 @@ public class AdminActivity extends BaseActivity {
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(AdminActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(AdminActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(AdminActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
ImageView toolbar_close = actionBar.getCustomView().findViewById(R.id.toolbar_close); ImageView toolbar_close = actionBar.getCustomView().findViewById(R.id.toolbar_close);
TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title); TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
toolbar_close.setOnClickListener(v -> finish()); toolbar_close.setOnClickListener(v -> finish());
toolbar_title.setText(String.format(getString(R.string.administration) + " %s", Helper.getLiveInstance(getApplicationContext()))); toolbar_title.setText(String.format(getString(R.string.administration) + " %s", Helper.getLiveInstance(AdminActivity.this)));
} }
setContentView(R.layout.activity_admin); setContentView(R.layout.activity_admin);
unresolved = local = active = true; unresolved = local = active = true;
@ -115,7 +115,7 @@ public class AdminActivity extends BaseActivity {
}); });
popup.setOnMenuItemClickListener(item -> { popup.setOnMenuItemClickListener(item -> {
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
item.setActionView(new View(getApplicationContext())); item.setActionView(new View(AdminActivity.this));
item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() { item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
@Override @Override
public boolean onMenuItemActionExpand(MenuItem item) { public boolean onMenuItemActionExpand(MenuItem item) {
@ -183,7 +183,7 @@ public class AdminActivity extends BaseActivity {
popup.setOnMenuItemClickListener(item -> { popup.setOnMenuItemClickListener(item -> {
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
item.setActionView(new View(getApplicationContext())); item.setActionView(new View(AdminActivity.this));
item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() { item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
@Override @Override
public boolean onMenuItemActionExpand(MenuItem item) { public boolean onMenuItemActionExpand(MenuItem item) {

View File

@ -137,7 +137,7 @@ public class BaseActivity extends CyaneaAppCompatActivity {
if (view != null) { if (view != null) {
Snackbar.make(view, message, Snackbar.LENGTH_SHORT).show(); Snackbar.make(view, message, Snackbar.LENGTH_SHORT).show();
} else { } else {
Toasty.info(getApplicationContext(), message, Toast.LENGTH_SHORT).show(); Toasty.info(BaseActivity.this, message, Toast.LENGTH_SHORT).show();
} }
} }

View File

@ -210,9 +210,9 @@ public abstract class BaseMainActivity extends BaseActivity
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext())); instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(BaseMainActivity.this));
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(BaseMainActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance); Account account = new AccountDAO(BaseMainActivity.this, db).getUniqAccount(userId, instance);
Intent intent = getIntent(); Intent intent = getIntent();
PackageManager pm = getPackageManager(); PackageManager pm = getPackageManager();
try { try {
@ -250,7 +250,7 @@ public abstract class BaseMainActivity extends BaseActivity
} }
if (account == null) { if (account == null) {
Helper.logout(getApplicationContext()); Helper.logout(BaseMainActivity.this);
Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class); Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class);
startActivity(myIntent); startActivity(myIntent);
finish(); finish();
@ -296,7 +296,7 @@ public abstract class BaseMainActivity extends BaseActivity
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
//Test if user is still log in //Test if user is still log in
if (!Helper.isLoggedIn(getApplicationContext())) { if (!Helper.isLoggedIn(BaseMainActivity.this)) {
//It is not, the user is redirected to the login page //It is not, the user is redirected to the login page
Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class); Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class);
startActivity(myIntent); startActivity(myIntent);
@ -310,12 +310,12 @@ public abstract class BaseMainActivity extends BaseActivity
//This task will allow to instance a static PeertubeInformation class //This task will allow to instance a static PeertubeInformation class
if (social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) { if (social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
try { try {
new RetrievePeertubeInformationAsyncTask(getApplicationContext()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrievePeertubeInformationAsyncTask(BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} catch (Exception ignored) { } catch (Exception ignored) {
} }
} }
//For old Mastodon releases that can't pin, this support could be removed //For old Mastodon releases that can't pin, this support could be removed
Helper.fillMapEmoji(getApplicationContext()); Helper.fillMapEmoji(BaseMainActivity.this);
//Here, the user is authenticated //Here, the user is authenticated
appBar = findViewById(R.id.appBar); appBar = findViewById(R.id.appBar);
Toolbar toolbar = findViewById(R.id.toolbar); Toolbar toolbar = findViewById(R.id.toolbar);
@ -337,9 +337,9 @@ public abstract class BaseMainActivity extends BaseActivity
ImageView icon = toolbar_search.findViewById(R.id.search_button); ImageView icon = toolbar_search.findViewById(R.id.search_button);
ImageView close = toolbar_search.findViewById(R.id.search_close_btn); ImageView close = toolbar_search.findViewById(R.id.search_close_btn);
if (icon != null) if (icon != null)
icon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_icon)); icon.setColorFilter(ContextCompat.getColor(BaseMainActivity.this, R.color.dark_icon));
if (close != null) if (close != null)
close.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_icon)); close.setColorFilter(ContextCompat.getColor(BaseMainActivity.this, R.color.dark_icon));
EditText editText = toolbar_search.findViewById(R.id.search_src_text); EditText editText = toolbar_search.findViewById(R.id.search_src_text);
editText.setHintTextColor(getResources().getColor(R.color.dark_icon)); editText.setHintTextColor(getResources().getColor(R.color.dark_icon));
editText.setTextColor(getResources().getColor(R.color.dark_icon)); editText.setTextColor(getResources().getColor(R.color.dark_icon));
@ -419,7 +419,7 @@ public abstract class BaseMainActivity extends BaseActivity
main_app_container = findViewById(R.id.main_app_container); main_app_container = findViewById(R.id.main_app_container);
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA || social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) { if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA || social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
new SyncTimelinesAsyncTask(BaseMainActivity.this, 0, Helper.canFetchList(getApplicationContext(), account), BaseMainActivity.this).execute(); new SyncTimelinesAsyncTask(BaseMainActivity.this, 0, Helper.canFetchList(BaseMainActivity.this, account), BaseMainActivity.this).execute();
} else if (social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) { } else if (social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
TabLayout.Tab pTabsub = tabLayout.newTab(); TabLayout.Tab pTabsub = tabLayout.newTab();
@ -435,11 +435,11 @@ public abstract class BaseMainActivity extends BaseActivity
pTabLocal.setCustomView(R.layout.tab_badge); pTabLocal.setCustomView(R.layout.tab_badge);
Helper.changeDrawableColor(getApplicationContext(), R.drawable.ic_subscriptions, R.attr.iconColorMenu); Helper.changeDrawableColor(BaseMainActivity.this, R.drawable.ic_subscriptions, R.attr.iconColorMenu);
Helper.changeDrawableColor(getApplicationContext(), R.drawable.ic_overview, R.attr.iconColorMenu); Helper.changeDrawableColor(BaseMainActivity.this, R.drawable.ic_overview, R.attr.iconColorMenu);
Helper.changeDrawableColor(getApplicationContext(), R.drawable.ic_trending_up, R.attr.iconColorMenu); Helper.changeDrawableColor(BaseMainActivity.this, R.drawable.ic_trending_up, R.attr.iconColorMenu);
Helper.changeDrawableColor(getApplicationContext(), R.drawable.ic_recently_added, R.attr.iconColorMenu); Helper.changeDrawableColor(BaseMainActivity.this, R.drawable.ic_recently_added, R.attr.iconColorMenu);
Helper.changeDrawableColor(getApplicationContext(), R.drawable.ic_home, R.attr.iconColorMenu); Helper.changeDrawableColor(BaseMainActivity.this, R.drawable.ic_home, R.attr.iconColorMenu);
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId") @SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
@ -532,9 +532,9 @@ public abstract class BaseMainActivity extends BaseActivity
//TabLayout.Tab pfTabDiscover = tabLayout.newTab(); //TabLayout.Tab pfTabDiscover = tabLayout.newTab();
Helper.changeDrawableColor(getApplicationContext(), R.drawable.ic_notifications, R.attr.iconColorMenu); Helper.changeDrawableColor(BaseMainActivity.this, R.drawable.ic_notifications, R.attr.iconColorMenu);
Helper.changeDrawableColor(getApplicationContext(), R.drawable.ic_people, R.attr.iconColorMenu); Helper.changeDrawableColor(BaseMainActivity.this, R.drawable.ic_people, R.attr.iconColorMenu);
Helper.changeDrawableColor(getApplicationContext(), R.drawable.ic_home, R.attr.iconColorMenu); Helper.changeDrawableColor(BaseMainActivity.this, R.drawable.ic_home, R.attr.iconColorMenu);
pfTabHome.setCustomView(R.layout.tab_badge); pfTabHome.setCustomView(R.layout.tab_badge);
pfTabLocal.setCustomView(R.layout.tab_badge); pfTabLocal.setCustomView(R.layout.tab_badge);
@ -643,10 +643,10 @@ public abstract class BaseMainActivity extends BaseActivity
Helper.startStreaming(BaseMainActivity.this); Helper.startStreaming(BaseMainActivity.this);
if (hidde_menu != null) if (hidde_menu != null)
LocalBroadcastManager.getInstance(getApplicationContext()).unregisterReceiver(hidde_menu); LocalBroadcastManager.getInstance(BaseMainActivity.this).unregisterReceiver(hidde_menu);
if (update_topbar != null) if (update_topbar != null)
LocalBroadcastManager.getInstance(getApplicationContext()).unregisterReceiver(update_topbar); LocalBroadcastManager.getInstance(BaseMainActivity.this).unregisterReceiver(update_topbar);
hidde_menu = new BroadcastReceiver() { hidde_menu = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
@ -710,8 +710,8 @@ public abstract class BaseMainActivity extends BaseActivity
new SyncTimelinesAsyncTask(BaseMainActivity.this, position, true, BaseMainActivity.this).execute(); new SyncTimelinesAsyncTask(BaseMainActivity.this, position, true, BaseMainActivity.this).execute();
} }
}; };
LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(hidde_menu, new IntentFilter(Helper.RECEIVE_HIDE_ITEM)); LocalBroadcastManager.getInstance(BaseMainActivity.this).registerReceiver(hidde_menu, new IntentFilter(Helper.RECEIVE_HIDE_ITEM));
LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(update_topbar, new IntentFilter(Helper.RECEIVE_UPDATE_TOPBAR)); LocalBroadcastManager.getInstance(BaseMainActivity.this).registerReceiver(update_topbar, new IntentFilter(Helper.RECEIVE_UPDATE_TOPBAR));
toolbar_search.setOnQueryTextListener(new SearchView.OnQueryTextListener() { toolbar_search.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override @Override
@ -873,11 +873,11 @@ public abstract class BaseMainActivity extends BaseActivity
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(BaseMainActivity.this, R.color.cyanea_primary))); getSupportActionBar().setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(BaseMainActivity.this, R.color.cyanea_primary)));
} }
//Defines the current locale of the device in a static variable //Defines the current locale of the device in a static variable
currentLocale = Helper.currentLocale(getApplicationContext()); currentLocale = Helper.currentLocale(BaseMainActivity.this);
if (social != UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) { if (social != UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
if (social != UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED) { if (social != UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED) {
toot.setOnClickListener(view -> { toot.setOnClickListener(view -> {
Intent intent13 = new Intent(getApplicationContext(), TootActivity.class); Intent intent13 = new Intent(BaseMainActivity.this, TootActivity.class);
startActivity(intent13); startActivity(intent13);
}); });
toot.setOnLongClickListener(v -> { toot.setOnLongClickListener(v -> {
@ -886,13 +886,13 @@ public abstract class BaseMainActivity extends BaseActivity
}); });
} else { } else {
toot.setOnClickListener(view -> { toot.setOnClickListener(view -> {
Intent intent12 = new Intent(getApplicationContext(), PixelfedComposeActivity.class); Intent intent12 = new Intent(BaseMainActivity.this, PixelfedComposeActivity.class);
startActivity(intent12); startActivity(intent12);
}); });
} }
} else { } else {
toot.setOnClickListener(view -> { toot.setOnClickListener(view -> {
Intent intent1 = new Intent(getApplicationContext(), PeertubeUploadActivity.class); Intent intent1 = new Intent(BaseMainActivity.this, PeertubeUploadActivity.class);
startActivity(intent1); startActivity(intent1);
}); });
} }
@ -937,7 +937,7 @@ public abstract class BaseMainActivity extends BaseActivity
AlertDialog.Builder dialogBuilderLogout = new AlertDialog.Builder(BaseMainActivity.this, style); AlertDialog.Builder dialogBuilderLogout = new AlertDialog.Builder(BaseMainActivity.this, style);
dialogBuilderLogout.setMessage(R.string.logout_confirmation); dialogBuilderLogout.setMessage(R.string.logout_confirmation);
dialogBuilderLogout.setPositiveButton(R.string.action_logout, (dialog, id) -> { dialogBuilderLogout.setPositiveButton(R.string.action_logout, (dialog, id) -> {
Helper.logout(getApplicationContext()); Helper.logout(BaseMainActivity.this);
Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class); Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class);
startActivity(myIntent); startActivity(myIntent);
dialog.dismiss(); dialog.dismiss();
@ -959,26 +959,26 @@ public abstract class BaseMainActivity extends BaseActivity
alertDialogLogoutAccount.show(); alertDialogLogoutAccount.show();
return true; return true;
case R.id.action_privacy: case R.id.action_privacy:
Intent intent14 = new Intent(getApplicationContext(), PrivacyActivity.class); Intent intent14 = new Intent(BaseMainActivity.this, PrivacyActivity.class);
startActivity(intent14); startActivity(intent14);
return true; return true;
case R.id.action_about_instance: case R.id.action_about_instance:
intent14 = new Intent(getApplicationContext(), InstanceActivity.class); intent14 = new Intent(BaseMainActivity.this, InstanceActivity.class);
startActivity(intent14); startActivity(intent14);
return true; return true;
case R.id.action_send_invitation: case R.id.action_send_invitation:
if (instanceClass != null) { if (instanceClass != null) {
if (instanceClass.isRegistration()) { if (instanceClass.isRegistration()) {
Intent sendIntent = new Intent(Intent.ACTION_SEND); Intent sendIntent = new Intent(Intent.ACTION_SEND);
String extra_text = getString(R.string.join_instance, Helper.getLiveInstance(getApplicationContext()), String extra_text = getString(R.string.join_instance, Helper.getLiveInstance(BaseMainActivity.this),
"https://f-droid.org/en/packages/fr.gouv.etalab.mastodon/", "https://f-droid.org/en/packages/fr.gouv.etalab.mastodon/",
"https://play.google.com/store/apps/details?id=app.fedilab.android", "https://play.google.com/store/apps/details?id=app.fedilab.android",
"https://fedilab.app/registration_helper/" + Helper.getLiveInstance(getApplicationContext())); "https://fedilab.app/registration_helper/" + Helper.getLiveInstance(BaseMainActivity.this));
sendIntent.putExtra(Intent.EXTRA_TEXT, extra_text); sendIntent.putExtra(Intent.EXTRA_TEXT, extra_text);
sendIntent.setType("text/plain"); sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, getString(R.string.share_with))); startActivity(Intent.createChooser(sendIntent, getString(R.string.share_with)));
} else { } else {
Toasty.info(getApplicationContext(), getString(R.string.registration_closed), Toast.LENGTH_SHORT).show(); Toasty.info(BaseMainActivity.this, getString(R.string.registration_closed), Toast.LENGTH_SHORT).show();
} }
} }
return true; return true;
@ -993,7 +993,7 @@ public abstract class BaseMainActivity extends BaseActivity
AlertDialog.Builder builder = new AlertDialog.Builder(BaseMainActivity.this, style); AlertDialog.Builder builder = new AlertDialog.Builder(BaseMainActivity.this, style);
builder.setTitle(R.string.text_size); builder.setTitle(R.string.text_size);
View popup_quick_settings = getLayoutInflater().inflate(R.layout.popup_text_size, new LinearLayout(getApplicationContext()), false); View popup_quick_settings = getLayoutInflater().inflate(R.layout.popup_text_size, new LinearLayout(BaseMainActivity.this), false);
builder.setView(popup_quick_settings); builder.setView(popup_quick_settings);
SeekBar set_text_size = popup_quick_settings.findViewById(R.id.set_text_size); SeekBar set_text_size = popup_quick_settings.findViewById(R.id.set_text_size);
@ -1054,12 +1054,12 @@ public abstract class BaseMainActivity extends BaseActivity
.show(); .show();
return true; return true;
case R.id.action_proxy: case R.id.action_proxy:
intent14 = new Intent(getApplicationContext(), ProxyActivity.class); intent14 = new Intent(BaseMainActivity.this, ProxyActivity.class);
startActivity(intent14); startActivity(intent14);
return true; return true;
case R.id.action_export: case R.id.action_export:
if (Build.VERSION.SDK_INT >= 23) { if (Build.VERSION.SDK_INT >= 23) {
if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { if (ContextCompat.checkSelfPermission(BaseMainActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(BaseMainActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Helper.EXTERNAL_STORAGE_REQUEST_CODE); ActivityCompat.requestPermissions(BaseMainActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Helper.EXTERNAL_STORAGE_REQUEST_CODE);
} else { } else {
Intent backupIntent = new Intent(BaseMainActivity.this, BackupStatusService.class); Intent backupIntent = new Intent(BaseMainActivity.this, BackupStatusService.class);
@ -1096,7 +1096,7 @@ public abstract class BaseMainActivity extends BaseActivity
return true; return true;
case R.id.action_export_data: case R.id.action_export_data:
if (Build.VERSION.SDK_INT >= 23) { if (Build.VERSION.SDK_INT >= 23) {
if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { if (ContextCompat.checkSelfPermission(BaseMainActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(BaseMainActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Helper.EXTERNAL_STORAGE_REQUEST_CODE); ActivityCompat.requestPermissions(BaseMainActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Helper.EXTERNAL_STORAGE_REQUEST_CODE);
return true; return true;
} }
@ -1111,7 +1111,7 @@ public abstract class BaseMainActivity extends BaseActivity
}); });
final ImageView optionInfo = headerLayout.findViewById(R.id.header_option_info); final ImageView optionInfo = headerLayout.findViewById(R.id.header_option_info);
optionInfo.setOnClickListener(view -> { optionInfo.setOnClickListener(view -> {
Intent intent15 = new Intent(getApplicationContext(), InstanceHealthActivity.class); Intent intent15 = new Intent(BaseMainActivity.this, InstanceHealthActivity.class);
startActivity(intent15); startActivity(intent15);
}); });
if (social != UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) if (social != UpdateAccountInfoAsyncTask.SOCIAL.MASTODON)
@ -1188,7 +1188,7 @@ public abstract class BaseMainActivity extends BaseActivity
AlertDialog.Builder dialogBuilderOptin = new AlertDialog.Builder(BaseMainActivity.this, style); AlertDialog.Builder dialogBuilderOptin = new AlertDialog.Builder(BaseMainActivity.this, style);
LayoutInflater inflater = getLayoutInflater(); LayoutInflater inflater = getLayoutInflater();
View dialogView = inflater.inflate(R.layout.popup_quick_settings, new LinearLayout(getApplicationContext()), false); View dialogView = inflater.inflate(R.layout.popup_quick_settings, new LinearLayout(BaseMainActivity.this), false);
dialogBuilderOptin.setView(dialogView); dialogBuilderOptin.setView(dialogView);
@ -1199,7 +1199,7 @@ public abstract class BaseMainActivity extends BaseActivity
android.R.layout.simple_spinner_dropdown_item, labels); android.R.layout.simple_spinner_dropdown_item, labels);
set_live_type.setAdapter(adapterLive); set_live_type.setAdapter(adapterLive);
TextView set_live_type_indication = dialogView.findViewById(R.id.set_live_type_indication); TextView set_live_type_indication = dialogView.findViewById(R.id.set_live_type_indication);
switch (Helper.liveNotifType(getApplicationContext())) { switch (Helper.liveNotifType(BaseMainActivity.this)) {
case Helper.NOTIF_LIVE: case Helper.NOTIF_LIVE:
set_live_type_indication.setText(R.string.live_notif_indication); set_live_type_indication.setText(R.string.live_notif_indication);
break; break;
@ -1210,7 +1210,7 @@ public abstract class BaseMainActivity extends BaseActivity
set_live_type_indication.setText(R.string.no_live_indication); set_live_type_indication.setText(R.string.no_live_indication);
break; break;
} }
set_live_type.setSelection(Helper.liveNotifType(getApplicationContext())); set_live_type.setSelection(Helper.liveNotifType(BaseMainActivity.this));
set_live_type.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { set_live_type.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
@ -1220,13 +1220,13 @@ public abstract class BaseMainActivity extends BaseActivity
editor.putBoolean(Helper.SET_LIVE_NOTIFICATIONS, true); editor.putBoolean(Helper.SET_LIVE_NOTIFICATIONS, true);
editor.putBoolean(Helper.SET_DELAYED_NOTIFICATIONS, false); editor.putBoolean(Helper.SET_DELAYED_NOTIFICATIONS, false);
editor.apply(); editor.apply();
Intent streamingIntent = new Intent(getApplicationContext(), LiveNotificationService.class); Intent streamingIntent = new Intent(BaseMainActivity.this, LiveNotificationService.class);
startService(streamingIntent); startService(streamingIntent);
break; break;
case Helper.NOTIF_DELAYED: case Helper.NOTIF_DELAYED:
editor.putBoolean(Helper.SET_LIVE_NOTIFICATIONS, false); editor.putBoolean(Helper.SET_LIVE_NOTIFICATIONS, false);
editor.putBoolean(Helper.SET_DELAYED_NOTIFICATIONS, true); editor.putBoolean(Helper.SET_DELAYED_NOTIFICATIONS, true);
streamingIntent = new Intent(getApplicationContext(), LiveNotificationDelayedService.class); streamingIntent = new Intent(BaseMainActivity.this, LiveNotificationDelayedService.class);
startService(streamingIntent); startService(streamingIntent);
editor.apply(); editor.apply();
break; break;
@ -1236,7 +1236,7 @@ public abstract class BaseMainActivity extends BaseActivity
editor.apply(); editor.apply();
break; break;
} }
switch (Helper.liveNotifType(getApplicationContext())) { switch (Helper.liveNotifType(BaseMainActivity.this)) {
case Helper.NOTIF_LIVE: case Helper.NOTIF_LIVE:
set_live_type_indication.setText(R.string.live_notif_indication); set_live_type_indication.setText(R.string.live_notif_indication);
break; break;
@ -1274,7 +1274,7 @@ public abstract class BaseMainActivity extends BaseActivity
int versionCode = BuildConfig.VERSION_CODE; int versionCode = BuildConfig.VERSION_CODE;
if (lastReleaseNoteRead != versionCode) { //Need to push release notes if (lastReleaseNoteRead != versionCode) { //Need to push release notes
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) { if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
new RetrieveRemoteDataAsyncTask(getApplicationContext(), BaseMainActivity.this).execute(); new RetrieveRemoteDataAsyncTask(BaseMainActivity.this, BaseMainActivity.this).execute();
} }
try (BufferedReader reader = new BufferedReader( try (BufferedReader reader = new BufferedReader(
new InputStreamReader(getAssets().open("changelogs/" + versionCode + ".txt")))) { new InputStreamReader(getAssets().open("changelogs/" + versionCode + ".txt")))) {
@ -1285,7 +1285,7 @@ public abstract class BaseMainActivity extends BaseActivity
} }
AlertDialog.Builder dialogBuilderOptin = new AlertDialog.Builder(BaseMainActivity.this, style); AlertDialog.Builder dialogBuilderOptin = new AlertDialog.Builder(BaseMainActivity.this, style);
LayoutInflater inflater = getLayoutInflater(); LayoutInflater inflater = getLayoutInflater();
dialogReleaseNoteView = inflater.inflate(R.layout.popup_release_notes, new LinearLayout(getApplicationContext()), false); dialogReleaseNoteView = inflater.inflate(R.layout.popup_release_notes, new LinearLayout(BaseMainActivity.this), false);
dialogBuilderOptin.setView(dialogReleaseNoteView); dialogBuilderOptin.setView(dialogReleaseNoteView);
TextView release_title = dialogReleaseNoteView.findViewById(R.id.release_title); TextView release_title = dialogReleaseNoteView.findViewById(R.id.release_title);
TextView release_notes = dialogReleaseNoteView.findViewById(R.id.release_notes); TextView release_notes = dialogReleaseNoteView.findViewById(R.id.release_notes);
@ -1315,10 +1315,10 @@ public abstract class BaseMainActivity extends BaseActivity
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA || social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) { if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA || social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
// Retrieves instance // Retrieves instance
new RetrieveInstanceAsyncTask(getApplicationContext(), BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveInstanceAsyncTask(BaseMainActivity.this, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
// Retrieves filters // Retrieves filters
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) { if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
new ManageFiltersAsyncTask(getApplicationContext(), GET_ALL_FILTER, null, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new ManageFiltersAsyncTask(BaseMainActivity.this, GET_ALL_FILTER, null, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
} }
@ -1328,12 +1328,12 @@ public abstract class BaseMainActivity extends BaseActivity
String dateString = Helper.dateToString(date); String dateString = Helper.dateToString(date);
new TimelineCacheDAO(BaseMainActivity.this, db).removeAfterDate(dateString); new TimelineCacheDAO(BaseMainActivity.this, db).removeAfterDate(dateString);
}); });
if (Helper.isLoggedIn(getApplicationContext())) { if (Helper.isLoggedIn(BaseMainActivity.this)) {
new UpdateAccountInfoByIDAsyncTask(getApplicationContext(), social, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new UpdateAccountInfoByIDAsyncTask(BaseMainActivity.this, social, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
mutedAccount = new TempMuteDAO(getApplicationContext(), db).getAllTimeMuted(account); mutedAccount = new TempMuteDAO(BaseMainActivity.this, db).getAllTimeMuted(account);
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA){ if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS, null, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveFeedsAsyncTask(BaseMainActivity.this, RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS, null, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
} }
@ -1392,11 +1392,11 @@ public abstract class BaseMainActivity extends BaseActivity
DisplayStatusFragment fragment = new DisplayStatusFragment(); DisplayStatusFragment fragment = new DisplayStatusFragment();
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.MYVIDEOS); bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.MYVIDEOS);
bundle.putString("instanceType", "PEERTUBE"); bundle.putString("instanceType", "PEERTUBE");
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(BaseMainActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext())); String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(BaseMainActivity.this));
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance); Account account = new AccountDAO(BaseMainActivity.this, db).getUniqAccount(userId, instance);
bundle.putString("targetedid", account.getUsername()); bundle.putString("targetedid", account.getUsername());
bundle.putBoolean("ownvideos", true); bundle.putBoolean("ownvideos", true);
fragment.setArguments(bundle); fragment.setArguments(bundle);
@ -1514,7 +1514,7 @@ public abstract class BaseMainActivity extends BaseActivity
} else { } else {
Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
if (imageUri != null) { if (imageUri != null) {
intent = new Intent(getApplicationContext(), TootActivity.class); intent = new Intent(BaseMainActivity.this, TootActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.putExtra("imageUri", imageUri.toString()); intent.putExtra("imageUri", imageUri.toString());
startActivity(intent); startActivity(intent);
@ -1578,7 +1578,7 @@ public abstract class BaseMainActivity extends BaseActivity
intent.setDataAndType(i.getData(), i.getType()); intent.setDataAndType(i.getData(), i.getType());
List<ResolveInfo> activities = getPackageManager().queryIntentActivities(intent, 0); List<ResolveInfo> activities = getPackageManager().queryIntentActivities(intent, 0);
ArrayList<Intent> targetIntents = new ArrayList<>(); ArrayList<Intent> targetIntents = new ArrayList<>();
String thisPackageName = getApplicationContext().getPackageName(); String thisPackageName = BaseMainActivity.this.getPackageName();
for (ResolveInfo currentInfo : activities) { for (ResolveInfo currentInfo : activities) {
String packageName = currentInfo.activityInfo.packageName; String packageName = currentInfo.activityInfo.packageName;
if (!thisPackageName.equals(packageName)) { if (!thisPackageName.equals(packageName)) {
@ -1641,7 +1641,7 @@ public abstract class BaseMainActivity extends BaseActivity
String datestr = sharedpreferences.getString(Helper.HOME_LAST_READ + userId + instance, null); String datestr = sharedpreferences.getString(Helper.HOME_LAST_READ + userId + instance, null);
if (timelines != null && timelines.size() > 0 && mPageReferenceMap != null && datestr != null) { if (timelines != null && timelines.size() > 0 && mPageReferenceMap != null && datestr != null) {
Date date = Helper.stringToDate(getApplicationContext(), datestr); Date date = Helper.stringToDate(BaseMainActivity.this, datestr);
Date dateAllowed = new Date(System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(30)); Date dateAllowed = new Date(System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(30));
//Refresh home if needed //Refresh home if needed
if (dateAllowed.after(date)) { if (dateAllowed.after(date)) {
@ -1677,7 +1677,7 @@ public abstract class BaseMainActivity extends BaseActivity
super.onDestroy(); super.onDestroy();
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
boolean clearCacheExit = sharedpreferences.getBoolean(Helper.SET_CLEAR_CACHE_EXIT, false); boolean clearCacheExit = sharedpreferences.getBoolean(Helper.SET_CLEAR_CACHE_EXIT, false);
WeakReference<Context> contextReference = new WeakReference<>(getApplicationContext()); WeakReference<Context> contextReference = new WeakReference<>(BaseMainActivity.this);
if (clearCacheExit) { if (clearCacheExit) {
AsyncTask.execute(() -> { AsyncTask.execute(() -> {
try { try {
@ -1693,9 +1693,9 @@ public abstract class BaseMainActivity extends BaseActivity
}); });
} }
if (hidde_menu != null) if (hidde_menu != null)
LocalBroadcastManager.getInstance(getApplicationContext()).unregisterReceiver(hidde_menu); LocalBroadcastManager.getInstance(BaseMainActivity.this).unregisterReceiver(hidde_menu);
if (update_topbar != null) if (update_topbar != null)
LocalBroadcastManager.getInstance(getApplicationContext()).unregisterReceiver(update_topbar); LocalBroadcastManager.getInstance(BaseMainActivity.this).unregisterReceiver(update_topbar);
if (mPageReferenceMap != null) if (mPageReferenceMap != null)
mPageReferenceMap = null; mPageReferenceMap = null;
PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean("isMainActivityRunning", false).apply(); PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean("isMainActivityRunning", false).apply();
@ -1722,15 +1722,15 @@ public abstract class BaseMainActivity extends BaseActivity
startActivity(myIntent); startActivity(myIntent);
return false; return false;
} else if (id == R.id.nav_drag_timelines) { } else if (id == R.id.nav_drag_timelines) {
Intent intent = new Intent(getApplicationContext(), ReorderTimelinesActivity.class); Intent intent = new Intent(BaseMainActivity.this, ReorderTimelinesActivity.class);
startActivity(intent); startActivity(intent);
return false; return false;
} else if (id == R.id.nav_administration) { } else if (id == R.id.nav_administration) {
Intent intent = new Intent(getApplicationContext(), AdminActivity.class); Intent intent = new Intent(BaseMainActivity.this, AdminActivity.class);
startActivity(intent); startActivity(intent);
return false; return false;
} else if (id == R.id.nav_about) { } else if (id == R.id.nav_about) {
Intent intent = new Intent(getApplicationContext(), AboutActivity.class); Intent intent = new Intent(BaseMainActivity.this, AboutActivity.class);
startActivity(intent); startActivity(intent);
return false; return false;
} else if (id == R.id.nav_opencollective) { } else if (id == R.id.nav_opencollective) {
@ -1743,23 +1743,23 @@ public abstract class BaseMainActivity extends BaseActivity
} }
return false; return false;
} else if (id == R.id.nav_upload) { } else if (id == R.id.nav_upload) {
Intent intent = new Intent(getApplicationContext(), PeertubeUploadActivity.class); Intent intent = new Intent(BaseMainActivity.this, PeertubeUploadActivity.class);
startActivity(intent); startActivity(intent);
return false; return false;
} else if (id == R.id.nav_partnership) { } else if (id == R.id.nav_partnership) {
Intent intent = new Intent(getApplicationContext(), PartnerShipActivity.class); Intent intent = new Intent(BaseMainActivity.this, PartnerShipActivity.class);
startActivity(intent); startActivity(intent);
return false; return false;
} else if (id == R.id.nav_settings) { } else if (id == R.id.nav_settings) {
Intent intent = new Intent(getApplicationContext(), SettingsActivity.class); Intent intent = new Intent(BaseMainActivity.this, SettingsActivity.class);
startActivity(intent); startActivity(intent);
return false; return false;
} else if (id == R.id.nav_blocked_domains) { } else if (id == R.id.nav_blocked_domains) {
Intent intent = new Intent(getApplicationContext(), MutedInstanceActivity.class); Intent intent = new Intent(BaseMainActivity.this, MutedInstanceActivity.class);
startActivity(intent); startActivity(intent);
return false; return false;
} else if (id == R.id.nav_bookmarks) { } else if (id == R.id.nav_bookmarks) {
Intent intent = new Intent(getApplicationContext(), BookmarkActivity.class); Intent intent = new Intent(BaseMainActivity.this, BookmarkActivity.class);
startActivity(intent); startActivity(intent);
return false; return false;
} }
@ -1826,10 +1826,10 @@ public abstract class BaseMainActivity extends BaseActivity
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.MYVIDEOS); bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.MYVIDEOS);
bundle.putString("instanceType", "PEERTUBE"); bundle.putString("instanceType", "PEERTUBE");
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(BaseMainActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext())); String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(BaseMainActivity.this));
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance); Account account = new AccountDAO(BaseMainActivity.this, db).getUniqAccount(userId, instance);
bundle.putString("targetedid", account.getUsername()); bundle.putString("targetedid", account.getUsername());
bundle.putBoolean("ownvideos", true); bundle.putBoolean("ownvideos", true);
fragment.setArguments(bundle); fragment.setArguments(bundle);
@ -1842,10 +1842,10 @@ public abstract class BaseMainActivity extends BaseActivity
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PEERTUBE_HISTORY); bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PEERTUBE_HISTORY);
bundle.putString("instanceType", "PEERTUBE"); bundle.putString("instanceType", "PEERTUBE");
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(BaseMainActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext())); String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(BaseMainActivity.this));
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance); Account account = new AccountDAO(BaseMainActivity.this, db).getUniqAccount(userId, instance);
bundle.putString("targetedid", account.getUsername()); bundle.putString("targetedid", account.getUsername());
fragment.setArguments(bundle); fragment.setArguments(bundle);
fragmentTag = "MY_HISTORY"; fragmentTag = "MY_HISTORY";
@ -1978,13 +1978,13 @@ public abstract class BaseMainActivity extends BaseActivity
public void onUpdateAccountInfo(boolean error) { public void onUpdateAccountInfo(boolean error) {
if (error) { if (error) {
//An error occurred, the user is redirected to the login page //An error occurred, the user is redirected to the login page
Helper.logout(getApplicationContext()); Helper.logout(BaseMainActivity.this);
Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class); Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class);
startActivity(myIntent); startActivity(myIntent);
finish(); finish();
} else { } else {
SQLiteDatabase db = Sqlite.getInstance(BaseMainActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(BaseMainActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance); Account account = new AccountDAO(BaseMainActivity.this, db).getUniqAccount(userId, instance);
Helper.updateHeaderAccountInfo(activity, account, headerLayout); Helper.updateHeaderAccountInfo(activity, account, headerLayout);
} }
} }
@ -1995,14 +1995,14 @@ public abstract class BaseMainActivity extends BaseActivity
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_IMPORT && resultCode == RESULT_OK) { if (requestCode == PICK_IMPORT && resultCode == RESULT_OK) {
if (data == null || data.getData() == null) { if (data == null || data.getData() == null) {
Toasty.error(getApplicationContext(), getString(R.string.toot_select_file_error), Toast.LENGTH_LONG).show(); Toasty.error(BaseMainActivity.this, getString(R.string.toot_select_file_error), Toast.LENGTH_LONG).show();
return; return;
} }
String filename = Helper.getFilePathFromURI(getApplicationContext(), data.getData()); String filename = Helper.getFilePathFromURI(BaseMainActivity.this, data.getData());
Sqlite.importDB(BaseMainActivity.this, filename); Sqlite.importDB(BaseMainActivity.this, filename);
} else if (requestCode == PICK_IMPORT) { } else if (requestCode == PICK_IMPORT) {
Toasty.error(getApplicationContext(), getString(R.string.toot_select_file_error), Toast.LENGTH_LONG).show(); Toasty.error(BaseMainActivity.this, getString(R.string.toot_select_file_error), Toast.LENGTH_LONG).show();
} }
} }
@ -2045,7 +2045,7 @@ public abstract class BaseMainActivity extends BaseActivity
intent.putExtras(b); intent.putExtras(b);
startActivity(intent); startActivity(intent);
} else if (statuses != null && statuses.size() > 0) { } else if (statuses != null && statuses.size() > 0) {
Intent intent = new Intent(getApplicationContext(), ShowConversationActivity.class); Intent intent = new Intent(BaseMainActivity.this, ShowConversationActivity.class);
Bundle b = new Bundle(); Bundle b = new Bundle();
b.putParcelable("status", statuses.get(0)); b.putParcelable("status", statuses.get(0));
intent.putExtras(b); intent.putExtras(b);
@ -2055,7 +2055,7 @@ public abstract class BaseMainActivity extends BaseActivity
if (accounts != null && accounts.size() > 0) { if (accounts != null && accounts.size() > 0) {
developers = new ArrayList<>(); developers = new ArrayList<>();
developers.addAll(accounts); developers.addAll(accounts);
new RetrieveRelationshipAsyncTask(getApplicationContext(), accounts.get(0).getId(), BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveRelationshipAsyncTask(BaseMainActivity.this, accounts.get(0).getId(), BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
} }
} }
@ -2367,6 +2367,28 @@ public abstract class BaseMainActivity extends BaseActivity
return toot.getVisibility() == View.VISIBLE; return toot.getVisibility() == View.VISIBLE;
} }
@Override
public void onRetrieveFeeds(APIResponse apiResponse) {
if (apiResponse != null && apiResponse.getAnnouncements() != null && apiResponse.getAnnouncements().size() > 0) {
int unread = 0;
for (Announcement announcement : apiResponse.getAnnouncements()) {
if (!announcement.isRead()) {
unread++;
}
}
final NavigationView navigationView = findViewById(R.id.nav_view);
MenuItem item = navigationView.getMenu().findItem(R.id.nav_announcements);
TextView actionView = item.getActionView().findViewById(R.id.counter);
if (actionView != null) {
if (unread > 0) {
actionView.setText(String.valueOf(unread));
actionView.setVisibility(View.VISIBLE);
} else {
actionView.setVisibility(View.GONE);
}
}
}
}
public enum iconLauncher { public enum iconLauncher {
BUBBLES, BUBBLES,
@ -2530,27 +2552,4 @@ public abstract class BaseMainActivity extends BaseActivity
return mNumOfTabs; return mNumOfTabs;
} }
} }
@Override
public void onRetrieveFeeds(APIResponse apiResponse) {
if( apiResponse != null && apiResponse.getAnnouncements() != null && apiResponse.getAnnouncements().size() > 0 ){
int unread = 0;
for(Announcement announcement: apiResponse.getAnnouncements()){
if( !announcement.isRead()){
unread++;
}
}
final NavigationView navigationView = findViewById(R.id.nav_view);
MenuItem item = navigationView.getMenu().findItem(R.id.nav_announcements);
TextView actionView = item.getActionView().findViewById(R.id.counter);
if(actionView != null) {
if (unread > 0) {
actionView.setText(String.valueOf(unread));
actionView.setVisibility(View.VISIBLE);
}else{
actionView.setVisibility(View.GONE);
}
}
}
}
} }

View File

@ -98,7 +98,7 @@ public class BookmarkActivity extends BaseActivity implements OnRetrieveFeedsInt
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.simple_action_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.simple_action_bar, new LinearLayout(BookmarkActivity.this), false);
toolbar.setBackgroundColor(ContextCompat.getColor(BookmarkActivity.this, R.color.cyanea_primary)); toolbar.setBackgroundColor(ContextCompat.getColor(BookmarkActivity.this, R.color.cyanea_primary));
view.setBackground(new ColorDrawable(ContextCompat.getColor(BookmarkActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(BookmarkActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
@ -114,19 +114,19 @@ public class BookmarkActivity extends BaseActivity implements OnRetrieveFeedsInt
setTitle(R.string.bookmarks); setTitle(R.string.bookmarks);
} }
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(BookmarkActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null); String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance); Account account = new AccountDAO(BookmarkActivity.this, db).getUniqAccount(userId, instance);
Helper.loadGiF(getApplicationContext(), account, pp_actionBar); Helper.loadGiF(BookmarkActivity.this, account, pp_actionBar);
lv_status = findViewById(R.id.lv_status); lv_status = findViewById(R.id.lv_status);
mainLoader = findViewById(R.id.loader); mainLoader = findViewById(R.id.loader);
textviewNoAction = findViewById(R.id.no_action); textviewNoAction = findViewById(R.id.no_action);
mainLoader.setVisibility(View.VISIBLE); mainLoader.setVisibility(View.VISIBLE);
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS, null, BookmarkActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveFeedsAsyncTask(BookmarkActivity.this, RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS, null, BookmarkActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }

View File

@ -97,7 +97,7 @@ public class CustomSharingActivity extends BaseActivity implements OnCustomShari
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.simple_action_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.simple_action_bar, new LinearLayout(CustomSharingActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(CustomSharingActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(CustomSharingActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
@ -111,12 +111,12 @@ public class CustomSharingActivity extends BaseActivity implements OnCustomShari
} else { } else {
setTitle(R.string.settings_title_custom_sharing); setTitle(R.string.settings_title_custom_sharing);
} }
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(CustomSharingActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null); String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance); Account account = new AccountDAO(CustomSharingActivity.this, db).getUniqAccount(userId, instance);
Helper.loadGiF(getApplicationContext(), account, pp_actionBar); Helper.loadGiF(CustomSharingActivity.this, account, pp_actionBar);
Bundle b = getIntent().getExtras(); Bundle b = getIntent().getExtras();
Status status = null; Status status = null;
if (b != null) { if (b != null) {
@ -186,7 +186,7 @@ public class CustomSharingActivity extends BaseActivity implements OnCustomShari
"http://example.net/add?token=YOUR_TOKEN&url=${url}&title=${title}" + "http://example.net/add?token=YOUR_TOKEN&url=${url}&title=${title}" +
"&source=${source}&id=${id}&description=${description}&keywords=${keywords}&creator=${creator}&thumbnailurl=${thumbnailurl}"); "&source=${source}&id=${id}&description=${description}&keywords=${keywords}&creator=${creator}&thumbnailurl=${thumbnailurl}");
encodedCustomSharingURL = encodeCustomSharingURL(); encodedCustomSharingURL = encodeCustomSharingURL();
new CustomSharingAsyncTask(getApplicationContext(), encodedCustomSharingURL, CustomSharingActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new CustomSharingAsyncTask(CustomSharingActivity.this, encodedCustomSharingURL, CustomSharingActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}); });
} }
@ -203,11 +203,11 @@ public class CustomSharingActivity extends BaseActivity implements OnCustomShari
public void onCustomSharing(CustomSharingResponse customSharingResponse) { public void onCustomSharing(CustomSharingResponse customSharingResponse) {
set_custom_sharing_save.setEnabled(true); set_custom_sharing_save.setEnabled(true);
if (customSharingResponse.getError() != null) { if (customSharingResponse.getError() != null) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(CustomSharingActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
return; return;
} }
String response = customSharingResponse.getResponse(); String response = customSharingResponse.getResponse();
Toasty.success(getApplicationContext(), response, Toast.LENGTH_LONG).show(); Toasty.success(CustomSharingActivity.this, response, Toast.LENGTH_LONG).show();
finish(); finish();
} }

View File

@ -124,7 +124,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.simple_action_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.simple_action_bar, new LinearLayout(EditProfileActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(EditProfileActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(EditProfileActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
@ -138,13 +138,13 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
} else { } else {
setTitle(R.string.settings_title_profile); setTitle(R.string.settings_title_profile);
} }
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(EditProfileActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null); String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance); Account account = new AccountDAO(EditProfileActivity.this, db).getUniqAccount(userId, instance);
Helper.loadGiF(getApplicationContext(), account, pp_actionBar); Helper.loadGiF(EditProfileActivity.this, account, pp_actionBar);
LinearLayout custom_fields_container = findViewById(R.id.custom_fields_container); LinearLayout custom_fields_container = findViewById(R.id.custom_fields_container);
set_profile_name = findViewById(R.id.set_profile_name); set_profile_name = findViewById(R.id.set_profile_name);
set_profile_description = findViewById(R.id.set_profile_description); set_profile_description = findViewById(R.id.set_profile_description);
@ -171,7 +171,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
set_profile_description.setEnabled(false); set_profile_description.setEnabled(false);
set_lock_account.setEnabled(false); set_lock_account.setEnabled(false);
set_sensitive_content.setEnabled(false); set_sensitive_content.setEnabled(false);
new RetrieveAccountInfoAsyncTask(getApplicationContext(), EditProfileActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveAccountInfoAsyncTask(EditProfileActivity.this, EditProfileActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
@ -188,7 +188,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
@Override @Override
public void onRetrieveAccount(Account account, Error error) { public void onRetrieveAccount(Account account, Error error) {
if (error != null) { if (error != null) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(EditProfileActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
return; return;
} }
set_profile_name.setText(account.getDisplay_name()); set_profile_name.setText(account.getDisplay_name());
@ -238,7 +238,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
String content = s.toString().substring(0, maxChar); String content = s.toString().substring(0, maxChar);
set_profile_description.setText(content); set_profile_description.setText(content);
set_profile_description.setSelection(set_profile_description.getText().length()); set_profile_description.setSelection(set_profile_description.getText().length());
Toasty.info(getApplicationContext(), getString(R.string.note_no_space), Toast.LENGTH_LONG).show(); Toasty.info(EditProfileActivity.this, getString(R.string.note_no_space), Toast.LENGTH_LONG).show();
} }
} }
}); });
@ -295,7 +295,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
String content = s.toString().substring(0, 30); String content = s.toString().substring(0, 30);
set_profile_name.setText(content); set_profile_name.setText(content);
set_profile_name.setSelection(set_profile_name.getText().length()); set_profile_name.setSelection(set_profile_name.getText().length());
Toasty.info(getApplicationContext(), getString(R.string.username_no_space), Toast.LENGTH_LONG).show(); Toasty.info(EditProfileActivity.this, getString(R.string.username_no_space), Toast.LENGTH_LONG).show();
} }
} }
}); });
@ -377,7 +377,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
} }
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(EditProfileActivity.this, style); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(EditProfileActivity.this, style);
LayoutInflater inflater = EditProfileActivity.this.getLayoutInflater(); LayoutInflater inflater = EditProfileActivity.this.getLayoutInflater();
View dialogView = inflater.inflate(R.layout.dialog_profile, new LinearLayout(getApplicationContext()), false); View dialogView = inflater.inflate(R.layout.dialog_profile, new LinearLayout(EditProfileActivity.this), false);
dialogBuilder.setView(dialogView); dialogBuilder.setView(dialogView);
ImageView back_ground_image = dialogView.findViewById(R.id.back_ground_image); ImageView back_ground_image = dialogView.findViewById(R.id.back_ground_image);
@ -390,13 +390,13 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
if (profile_note != null) if (profile_note != null)
dialog_profile_description.setText(profile_note); dialog_profile_description.setText(profile_note);
if (profile_header_bmp != null) { if (profile_header_bmp != null) {
BitmapDrawable background = new BitmapDrawable(getApplicationContext().getResources(), profile_header_bmp); BitmapDrawable background = new BitmapDrawable(EditProfileActivity.this.getResources(), profile_header_bmp);
back_ground_image.setBackground(background); back_ground_image.setBackground(background);
} else { } else {
back_ground_image.setBackground(set_header_picture.getDrawable()); back_ground_image.setBackground(set_header_picture.getDrawable());
} }
if (profile_picture_bmp != null) { if (profile_picture_bmp != null) {
BitmapDrawable background = new BitmapDrawable(getApplicationContext().getResources(), profile_picture_bmp); BitmapDrawable background = new BitmapDrawable(EditProfileActivity.this.getResources(), profile_picture_bmp);
dialog_profile_picture.setBackground(background); dialog_profile_picture.setBackground(background);
} else { } else {
dialog_profile_picture.setBackground(set_profile_picture.getDrawable()); dialog_profile_picture.setBackground(set_profile_picture.getDrawable());
@ -405,8 +405,8 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
sensitive = set_sensitive_content.isChecked(); sensitive = set_sensitive_content.isChecked();
dialogBuilder.setPositiveButton(R.string.save, (dialog, id) -> { dialogBuilder.setPositiveButton(R.string.save, (dialog, id) -> {
set_profile_save.setEnabled(false); set_profile_save.setEnabled(false);
new Thread(() -> Glide.get(getApplicationContext()).clearDiskCache()).start(); new Thread(() -> Glide.get(EditProfileActivity.this).clearDiskCache()).start();
Glide.get(getApplicationContext()).clearMemory(); Glide.get(EditProfileActivity.this).clearMemory();
HashMap<String, String> newCustomFields = new HashMap<>(); HashMap<String, String> newCustomFields = new HashMap<>();
String key1, key2, key3, key4, val1, val2, val3, val4; String key1, key2, key3, key4, val1, val2, val3, val4;
@ -425,7 +425,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
newCustomFields.put(key3, val3); newCustomFields.put(key3, val3);
newCustomFields.put(key4, val4); newCustomFields.put(key4, val4);
new UpdateCredentialAsyncTask(getApplicationContext(), newCustomFields, profile_username, profile_note, profile_picture, avatarName, header_picture, headerName, profile_privacy, sensitive, EditProfileActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new UpdateCredentialAsyncTask(EditProfileActivity.this, newCustomFields, profile_username, profile_note, profile_picture, avatarName, header_picture, headerName, profile_privacy, sensitive, EditProfileActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}); });
dialogBuilder.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss()); dialogBuilder.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss());
AlertDialog alertDialog = dialogBuilder.create(); AlertDialog alertDialog = dialogBuilder.create();
@ -466,13 +466,13 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_IMAGE_HEADER && resultCode == RESULT_OK) { if (requestCode == PICK_IMAGE_HEADER && resultCode == RESULT_OK) {
if (data == null || data.getData() == null) { if (data == null || data.getData() == null) {
Toasty.error(getApplicationContext(), getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show(); Toasty.error(EditProfileActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
return; return;
} }
Uri fileUri = data.getData(); Uri fileUri = data.getData();
headerName = Helper.getFileName(EditProfileActivity.this, fileUri); headerName = Helper.getFileName(EditProfileActivity.this, fileUri);
try { try {
InputStream inputStream = getApplicationContext().getContentResolver().openInputStream(fileUri); InputStream inputStream = EditProfileActivity.this.getContentResolver().openInputStream(fileUri);
assert inputStream != null; assert inputStream != null;
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream); BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
Bitmap bmp = BitmapFactory.decodeStream(bufferedInputStream); Bitmap bmp = BitmapFactory.decodeStream(bufferedInputStream);
@ -484,13 +484,13 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
header_picture = Helper.compressImage(EditProfileActivity.this, fileUri); header_picture = Helper.compressImage(EditProfileActivity.this, fileUri);
} else if (requestCode == PICK_IMAGE_PROFILE && resultCode == RESULT_OK) { } else if (requestCode == PICK_IMAGE_PROFILE && resultCode == RESULT_OK) {
if (data == null || data.getData() == null) { if (data == null || data.getData() == null) {
Toasty.error(getApplicationContext(), getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show(); Toasty.error(EditProfileActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
return; return;
} }
Uri fileUri = data.getData(); Uri fileUri = data.getData();
avatarName = Helper.getFileName(EditProfileActivity.this, fileUri); avatarName = Helper.getFileName(EditProfileActivity.this, fileUri);
try { try {
InputStream inputStream = getApplicationContext().getContentResolver().openInputStream(fileUri); InputStream inputStream = EditProfileActivity.this.getContentResolver().openInputStream(fileUri);
assert inputStream != null; assert inputStream != null;
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream); BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
Bitmap bmp = BitmapFactory.decodeStream(bufferedInputStream); Bitmap bmp = BitmapFactory.decodeStream(bufferedInputStream);
@ -507,10 +507,10 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
public void onUpdateCredential(APIResponse apiResponse) { public void onUpdateCredential(APIResponse apiResponse) {
set_profile_save.setEnabled(true); set_profile_save.setEnabled(true);
if (apiResponse.getError() != null) { if (apiResponse.getError() != null) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(EditProfileActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
return; return;
} }
Toasty.success(getApplicationContext(), getString(R.string.toast_update_credential_ok), Toast.LENGTH_LONG).show(); Toasty.success(EditProfileActivity.this, getString(R.string.toast_update_credential_ok), Toast.LENGTH_LONG).show();
finish(); finish();
} }

View File

@ -100,7 +100,7 @@ public class GroupActivity extends BaseActivity implements OnRetrieveFeedsInterf
max_id = null; max_id = null;
flag_loading = true; flag_loading = true;
firstLoad = true; firstLoad = true;
boolean isOnWifi = Helper.isOnWIFI(getApplicationContext()); boolean isOnWifi = Helper.isOnWIFI(GroupActivity.this);
swipeRefreshLayout = findViewById(R.id.swipeContainer); swipeRefreshLayout = findViewById(R.id.swipeContainer);
int c1 = getResources().getColor(R.color.cyanea_accent); int c1 = getResources().getColor(R.color.cyanea_accent);
int c2 = getResources().getColor(R.color.cyanea_primary_dark); int c2 = getResources().getColor(R.color.cyanea_primary_dark);
@ -131,7 +131,7 @@ public class GroupActivity extends BaseActivity implements OnRetrieveFeedsInterf
statuses = new ArrayList<>(); statuses = new ArrayList<>();
firstLoad = true; firstLoad = true;
flag_loading = true; flag_loading = true;
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.GNU_GROUP_TIMELINE, groupname, null, max_id, GroupActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveFeedsAsyncTask(GroupActivity.this, RetrieveFeedsAsyncTask.Type.GNU_GROUP_TIMELINE, groupname, null, max_id, GroupActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}); });
final LinearLayoutManager mLayoutManager; final LinearLayoutManager mLayoutManager;
mLayoutManager = new LinearLayoutManager(this); mLayoutManager = new LinearLayoutManager(this);
@ -145,7 +145,7 @@ public class GroupActivity extends BaseActivity implements OnRetrieveFeedsInterf
if (firstVisibleItem + visibleItemCount == totalItemCount) { if (firstVisibleItem + visibleItemCount == totalItemCount) {
if (!flag_loading) { if (!flag_loading) {
flag_loading = true; flag_loading = true;
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.GNU_GROUP_TIMELINE, groupname, null, max_id, GroupActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveFeedsAsyncTask(GroupActivity.this, RetrieveFeedsAsyncTask.Type.GNU_GROUP_TIMELINE, groupname, null, max_id, GroupActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
nextElementLoader.setVisibility(View.VISIBLE); nextElementLoader.setVisibility(View.VISIBLE);
} }
@ -155,7 +155,7 @@ public class GroupActivity extends BaseActivity implements OnRetrieveFeedsInterf
} }
} }
}); });
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.GNU_GROUP_TIMELINE, groupname, null, max_id, GroupActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveFeedsAsyncTask(GroupActivity.this, RetrieveFeedsAsyncTask.Type.GNU_GROUP_TIMELINE, groupname, null, max_id, GroupActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
@ -180,9 +180,9 @@ public class GroupActivity extends BaseActivity implements OnRetrieveFeedsInterf
nextElementLoader.setVisibility(View.GONE); nextElementLoader.setVisibility(View.GONE);
if (apiResponse == null || apiResponse.getError() != null) { if (apiResponse == null || apiResponse.getError() != null) {
if (apiResponse != null) { if (apiResponse != null) {
Toasty.error(getApplicationContext(), apiResponse.getError().getError(), Toast.LENGTH_LONG).show(); Toasty.error(GroupActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(GroupActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
} }
return; return;
} }

View File

@ -103,7 +103,7 @@ public class HashTagActivity extends BaseActivity implements OnRetrieveFeedsInte
max_id = null; max_id = null;
flag_loading = true; flag_loading = true;
firstLoad = true; firstLoad = true;
boolean isOnWifi = Helper.isOnWIFI(getApplicationContext()); boolean isOnWifi = Helper.isOnWIFI(HashTagActivity.this);
swipeRefreshLayout = findViewById(R.id.swipeContainer); swipeRefreshLayout = findViewById(R.id.swipeContainer);
int c1 = getResources().getColor(R.color.cyanea_accent); int c1 = getResources().getColor(R.color.cyanea_accent);
int c2 = getResources().getColor(R.color.cyanea_primary_dark); int c2 = getResources().getColor(R.color.cyanea_primary_dark);
@ -133,7 +133,7 @@ public class HashTagActivity extends BaseActivity implements OnRetrieveFeedsInte
statuses = new ArrayList<>(); statuses = new ArrayList<>();
firstLoad = true; firstLoad = true;
flag_loading = true; flag_loading = true;
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.TAG, tag, null, max_id, HashTagActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveFeedsAsyncTask(HashTagActivity.this, RetrieveFeedsAsyncTask.Type.TAG, tag, null, max_id, HashTagActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}); });
final LinearLayoutManager mLayoutManager; final LinearLayoutManager mLayoutManager;
mLayoutManager = new LinearLayoutManager(this); mLayoutManager = new LinearLayoutManager(this);
@ -147,7 +147,7 @@ public class HashTagActivity extends BaseActivity implements OnRetrieveFeedsInte
if (firstVisibleItem + visibleItemCount == totalItemCount) { if (firstVisibleItem + visibleItemCount == totalItemCount) {
if (!flag_loading) { if (!flag_loading) {
flag_loading = true; flag_loading = true;
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.TAG, tag, null, max_id, HashTagActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveFeedsAsyncTask(HashTagActivity.this, RetrieveFeedsAsyncTask.Type.TAG, tag, null, max_id, HashTagActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
nextElementLoader.setVisibility(View.VISIBLE); nextElementLoader.setVisibility(View.VISIBLE);
} }
@ -157,7 +157,7 @@ public class HashTagActivity extends BaseActivity implements OnRetrieveFeedsInte
} }
} }
}); });
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.TAG, tag, null, max_id, HashTagActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveFeedsAsyncTask(HashTagActivity.this, RetrieveFeedsAsyncTask.Type.TAG, tag, null, max_id, HashTagActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
@ -206,9 +206,9 @@ public class HashTagActivity extends BaseActivity implements OnRetrieveFeedsInte
nextElementLoader.setVisibility(View.GONE); nextElementLoader.setVisibility(View.GONE);
if (apiResponse == null || apiResponse.getError() != null) { if (apiResponse == null || apiResponse.getError() != null) {
if (apiResponse != null) if (apiResponse != null)
Toasty.error(getApplicationContext(), apiResponse.getError().getError(), Toast.LENGTH_LONG).show(); Toasty.error(HashTagActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
else else
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(HashTagActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
return; return;
} }
List<Status> statuses = apiResponse.getStatuses(); List<Status> statuses = apiResponse.getStatuses();

View File

@ -80,7 +80,7 @@ public class InstanceActivity extends BaseActivity implements OnRetrieveInstance
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(InstanceActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(InstanceActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(InstanceActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
@ -90,13 +90,13 @@ public class InstanceActivity extends BaseActivity implements OnRetrieveInstance
toolbar_title.setText(R.string.action_about_instance); toolbar_title.setText(R.string.action_about_instance);
} }
setContentView(R.layout.activity_instance); setContentView(R.layout.activity_instance);
Helper.changeDrawableColor(getApplicationContext(), R.drawable.ic_mail_outline, R.color.white); Helper.changeDrawableColor(InstanceActivity.this, R.drawable.ic_mail_outline, R.color.white);
instance_container = findViewById(R.id.instance_container); instance_container = findViewById(R.id.instance_container);
loader = findViewById(R.id.loader); loader = findViewById(R.id.loader);
instance_container.setVisibility(View.GONE); instance_container.setVisibility(View.GONE);
loader.setVisibility(View.VISIBLE); loader.setVisibility(View.VISIBLE);
setTitle(getString(R.string.action_about_instance)); setTitle(getString(R.string.action_about_instance));
new RetrieveInstanceAsyncTask(getApplicationContext(), InstanceActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveInstanceAsyncTask(InstanceActivity.this, InstanceActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
@ -115,12 +115,12 @@ public class InstanceActivity extends BaseActivity implements OnRetrieveInstance
instance_container.setVisibility(View.VISIBLE); instance_container.setVisibility(View.VISIBLE);
loader.setVisibility(View.GONE); loader.setVisibility(View.GONE);
if (apiResponse.getError() != null) { if (apiResponse.getError() != null) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(InstanceActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
return; return;
} }
final Instance instance = apiResponse.getInstance(); final Instance instance = apiResponse.getInstance();
if (instance == null) { if (instance == null) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(InstanceActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
return; return;
} }
TextView instance_title = findViewById(R.id.instance_title); TextView instance_title = findViewById(R.id.instance_title);

View File

@ -74,9 +74,9 @@ public class InstanceHealthActivity extends BaseActivity {
Bundle b = getIntent().getExtras(); Bundle b = getIntent().getExtras();
if (getSupportActionBar() != null) if (getSupportActionBar() != null)
getSupportActionBar().hide(); getSupportActionBar().hide();
instance = Helper.getLiveInstance(getApplicationContext()); instance = Helper.getLiveInstance(InstanceHealthActivity.this);
if (b != null) if (b != null)
instance = b.getString("instance", Helper.getLiveInstance(getApplicationContext())); instance = b.getString("instance", Helper.getLiveInstance(InstanceHealthActivity.this));
Button close = findViewById(R.id.close); Button close = findViewById(R.id.close);
name = findViewById(R.id.name); name = findViewById(R.id.name);
@ -129,21 +129,21 @@ public class InstanceHealthActivity extends BaseActivity {
parameters.put("name", instance.trim()); parameters.put("name", instance.trim());
final String response = new HttpsConnection(InstanceHealthActivity.this, instance).get("https://instances.social/api/1.0/instances/show", 5, parameters, Helper.THEKINRAR_SECRET_TOKEN); final String response = new HttpsConnection(InstanceHealthActivity.this, instance).get("https://instances.social/api/1.0/instances/show", 5, parameters, Helper.THEKINRAR_SECRET_TOKEN);
if (response != null) { if (response != null) {
instanceSocial = API.parseInstanceSocialResponse(getApplicationContext(), new JSONObject(response)); instanceSocial = API.parseInstanceSocialResponse(InstanceHealthActivity.this, new JSONObject(response));
} }
runOnUiThread(() -> { runOnUiThread(() -> {
if (instanceSocial.getThumbnail() != null && !instanceSocial.getThumbnail().equals("null")) if (instanceSocial.getThumbnail() != null && !instanceSocial.getThumbnail().equals("null"))
Glide.with(getApplicationContext()) Glide.with(InstanceHealthActivity.this)
.asBitmap() .asBitmap()
.load(instanceSocial.getThumbnail()) .load(instanceSocial.getThumbnail())
.into(back_ground_image); .into(back_ground_image);
name.setText(instanceSocial.getName()); name.setText(instanceSocial.getName());
if (instanceSocial.isUp()) { if (instanceSocial.isUp()) {
up.setText("Is up!"); up.setText("Is up!");
up.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.green_1)); up.setTextColor(ContextCompat.getColor(InstanceHealthActivity.this, R.color.green_1));
} else { } else {
up.setText("Is down!"); up.setText("Is down!");
up.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.red_1)); up.setTextColor(ContextCompat.getColor(InstanceHealthActivity.this, R.color.red_1));
} }
uptime.setText(String.format("Uptime: %.2f %%", (instanceSocial.getUptime() * 100))); uptime.setText(String.format("Uptime: %.2f %%", (instanceSocial.getUptime() * 100)));
if (instanceSocial.getChecked_at() != null) if (instanceSocial.getChecked_at() != null)

View File

@ -123,7 +123,7 @@ public class InstanceProfileActivity extends BaseActivity {
return; return;
} }
if (instanceNodeInfo.getThumbnail() != null && !instanceNodeInfo.getThumbnail().equals("null")) if (instanceNodeInfo.getThumbnail() != null && !instanceNodeInfo.getThumbnail().equals("null"))
Glide.with(getApplicationContext()) Glide.with(InstanceProfileActivity.this)
.asBitmap() .asBitmap()
.load(instanceNodeInfo.getThumbnail()) .load(instanceNodeInfo.getThumbnail())
.into(back_ground_image); .into(back_ground_image);

View File

@ -137,7 +137,7 @@ public class ListActivity extends BaseActivity implements OnListActionInterface
title = b.getString("title"); title = b.getString("title");
listId = b.getString("id"); listId = b.getString("id");
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.toast_error_search), Toast.LENGTH_LONG).show(); Toasty.error(ListActivity.this, getString(R.string.toast_error_search), Toast.LENGTH_LONG).show();
} }
if (getSupportActionBar() != null) if (getSupportActionBar() != null)
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@ -209,7 +209,7 @@ public class ListActivity extends BaseActivity implements OnListActionInterface
} }
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(ListActivity.this, style); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(ListActivity.this, style);
LayoutInflater inflater = getLayoutInflater(); LayoutInflater inflater = getLayoutInflater();
View dialogView = inflater.inflate(R.layout.add_list, new LinearLayout(getApplicationContext()), false); View dialogView = inflater.inflate(R.layout.add_list, new LinearLayout(ListActivity.this), false);
dialogBuilder.setView(dialogView); dialogBuilder.setView(dialogView);
final EditText editText = dialogView.findViewById(R.id.add_list); final EditText editText = dialogView.findViewById(R.id.add_list);
editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(255)}); editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(255)});
@ -247,7 +247,7 @@ public class ListActivity extends BaseActivity implements OnListActionInterface
//Discards 404 - error which can often happen due to toots which have been deleted //Discards 404 - error which can often happen due to toots which have been deleted
if (apiResponse.getError() != null) { if (apiResponse.getError() != null) {
if (!apiResponse.getError().getError().startsWith("404 -") && !apiResponse.getError().getError().startsWith("501 -")) if (!apiResponse.getError().getError().startsWith("404 -") && !apiResponse.getError().getError().startsWith("501 -"))
Toasty.error(getApplicationContext(), apiResponse.getError().getError(), Toast.LENGTH_LONG).show(); Toasty.error(ListActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
swipeRefreshLayout.setRefreshing(false); swipeRefreshLayout.setRefreshing(false);
swiped = false; swiped = false;
flag_loading = false; flag_loading = false;
@ -279,7 +279,7 @@ public class ListActivity extends BaseActivity implements OnListActionInterface
firstLoad = false; firstLoad = false;
} else if (actionType == ManageListsAsyncTask.action.UPDATE_LIST) { } else if (actionType == ManageListsAsyncTask.action.UPDATE_LIST) {
Intent intentUP = new Intent(Helper.RECEIVE_UPDATE_TOPBAR); Intent intentUP = new Intent(Helper.RECEIVE_UPDATE_TOPBAR);
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intentUP); LocalBroadcastManager.getInstance(ListActivity.this).sendBroadcast(intentUP);
} }
} }
} }

View File

@ -61,8 +61,8 @@ public class LiveNotificationSettingsAccountsActivity extends BaseActivity {
RecyclerView list_of_accounts = findViewById(R.id.list_of_accounts); RecyclerView list_of_accounts = findViewById(R.id.list_of_accounts);
ArrayList<Account> accounts = new ArrayList<>(); ArrayList<Account> accounts = new ArrayList<>();
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(LiveNotificationSettingsAccountsActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
List<Account> accountStreams = new AccountDAO(getApplicationContext(), db).getAllAccountCrossAction(); List<Account> accountStreams = new AccountDAO(LiveNotificationSettingsAccountsActivity.this, db).getAllAccountCrossAction();
if (accountStreams == null || accountStreams.size() == 0) { if (accountStreams == null || accountStreams.size() == 0) {
finish(); finish();
return; return;
@ -74,7 +74,7 @@ public class LiveNotificationSettingsAccountsActivity extends BaseActivity {
} }
AccountLiveAdapter accountLiveAdapter = new AccountLiveAdapter(accounts); AccountLiveAdapter accountLiveAdapter = new AccountLiveAdapter(accounts);
list_of_accounts.setAdapter(accountLiveAdapter); list_of_accounts.setAdapter(accountLiveAdapter);
LinearLayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext()); LinearLayoutManager mLayoutManager = new LinearLayoutManager(LiveNotificationSettingsAccountsActivity.this);
list_of_accounts.setLayoutManager(mLayoutManager); list_of_accounts.setLayoutManager(mLayoutManager);
} }

View File

@ -234,7 +234,7 @@ public class LoginActivity extends BaseActivity {
connectionButton = findViewById(R.id.login_button); connectionButton = findViewById(R.id.login_button);
ImageView info_instance = findViewById(R.id.info_instance); ImageView info_instance = findViewById(R.id.info_instance);
ImageView main_logo = findViewById(R.id.main_logo); ImageView main_logo = findViewById(R.id.main_logo);
main_logo.setImageResource(Helper.getMainLogo(getApplicationContext())); main_logo.setImageResource(Helper.getMainLogo(LoginActivity.this));
socialNetwork = UpdateAccountInfoAsyncTask.SOCIAL.MASTODON; socialNetwork = UpdateAccountInfoAsyncTask.SOCIAL.MASTODON;
//Manage instances //Manage instances
info_instance.setOnClickListener(v -> showcaseInstance(false)); info_instance.setOnClickListener(v -> showcaseInstance(false));
@ -273,9 +273,9 @@ public class LoginActivity extends BaseActivity {
} }
} }
} else if (instanceNodeInfo != null && instanceNodeInfo.isConnectionError()) { } else if (instanceNodeInfo != null && instanceNodeInfo.isConnectionError()) {
Toasty.error(getApplicationContext(), getString(R.string.connect_error), Toast.LENGTH_LONG).show(); Toasty.error(LoginActivity.this, getString(R.string.connect_error), Toast.LENGTH_LONG).show();
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.client_error), Toast.LENGTH_LONG).show(); Toasty.error(LoginActivity.this, getString(R.string.client_error), Toast.LENGTH_LONG).show();
} }
}); });
@ -451,7 +451,7 @@ public class LoginActivity extends BaseActivity {
try { try {
instance = URLEncoder.encode(host, "utf-8"); instance = URLEncoder.encode(host, "utf-8");
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
Toasty.error(getApplicationContext(), getString(R.string.client_error), Toast.LENGTH_LONG).show(); Toasty.error(LoginActivity.this, getString(R.string.client_error), Toast.LENGTH_LONG).show();
} }
if (socialNetwork == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) if (socialNetwork == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE)
actionToken = "/api/v1/oauth-clients/local"; actionToken = "/api/v1/oauth-clients/local";
@ -475,9 +475,9 @@ public class LoginActivity extends BaseActivity {
try { try {
String response; String response;
if (socialNetwork == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) if (socialNetwork == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE)
response = new HttpsConnection(LoginActivity.this, instance).get(Helper.instanceWithProtocol(getApplicationContext(), instance) + actionToken, 30, parameters, null); response = new HttpsConnection(LoginActivity.this, instance).get(Helper.instanceWithProtocol(LoginActivity.this, instance) + actionToken, 30, parameters, null);
else else
response = new HttpsConnection(LoginActivity.this, instance).post(Helper.instanceWithProtocol(getApplicationContext(), instance) + actionToken, 30, parameters, null); response = new HttpsConnection(LoginActivity.this, instance).post(Helper.instanceWithProtocol(LoginActivity.this, instance) + actionToken, 30, parameters, null);
runOnUiThread(() -> { runOnUiThread(() -> {
JSONObject resobj; JSONObject resobj;
try { try {
@ -512,7 +512,7 @@ public class LoginActivity extends BaseActivity {
} }
} else } else
message = getString(R.string.client_error); message = getString(R.string.client_error);
Toasty.error(getApplicationContext(), message, Toast.LENGTH_LONG).show(); Toasty.error(LoginActivity.this, message, Toast.LENGTH_LONG).show();
}); });
} }
@ -576,9 +576,9 @@ public class LoginActivity extends BaseActivity {
try { try {
String response; String response;
if (socialNetwork != UpdateAccountInfoAsyncTask.SOCIAL.GNU && socialNetwork != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) { if (socialNetwork != UpdateAccountInfoAsyncTask.SOCIAL.GNU && socialNetwork != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
response = new HttpsConnection(LoginActivity.this, instance).post(Helper.instanceWithProtocol(getApplicationContext(), instance) + finalOauthUrl, 30, parameters, null); response = new HttpsConnection(LoginActivity.this, instance).post(Helper.instanceWithProtocol(LoginActivity.this, instance) + finalOauthUrl, 30, parameters, null);
} else { } else {
response = new HttpsConnection(LoginActivity.this, instance).get(Helper.instanceWithProtocol(getApplicationContext(), instance) + finalOauthUrl, 30, null, basicAuth); response = new HttpsConnection(LoginActivity.this, instance).get(Helper.instanceWithProtocol(LoginActivity.this, instance) + finalOauthUrl, 30, null, basicAuth);
} }
runOnUiThread(() -> { runOnUiThread(() -> {
JSONObject resobj; JSONObject resobj;
@ -645,7 +645,7 @@ public class LoginActivity extends BaseActivity {
message = e.getMessage(); message = e.getMessage();
else else
message = getString(R.string.client_error); message = getString(R.string.client_error);
Toasty.error(getApplicationContext(), message, Toast.LENGTH_LONG).show(); Toasty.error(LoginActivity.this, message, Toast.LENGTH_LONG).show();
}); });
}); });
} }
@ -670,7 +670,7 @@ public class LoginActivity extends BaseActivity {
i.putExtra("instance", instance); i.putExtra("instance", instance);
startActivity(i); startActivity(i);
} else { } else {
String url = redirectUserToAuthorizeAndLogin(getApplicationContext(), client_id, instance); String url = redirectUserToAuthorizeAndLogin(LoginActivity.this, client_id, instance);
Helper.openBrowser(LoginActivity.this, url); Helper.openBrowser(LoginActivity.this, url);
} }
} }
@ -697,13 +697,13 @@ public class LoginActivity extends BaseActivity {
//noinspection SimplifiableIfStatement //noinspection SimplifiableIfStatement
if (id == R.id.action_about) { if (id == R.id.action_about) {
Intent intent = new Intent(getApplicationContext(), AboutActivity.class); Intent intent = new Intent(LoginActivity.this, AboutActivity.class);
startActivity(intent); startActivity(intent);
} else if (id == R.id.action_privacy) { } else if (id == R.id.action_privacy) {
Intent intent = new Intent(getApplicationContext(), PrivacyActivity.class); Intent intent = new Intent(LoginActivity.this, PrivacyActivity.class);
startActivity(intent); startActivity(intent);
} else if (id == R.id.action_proxy) { } else if (id == R.id.action_proxy) {
Intent intent = new Intent(getApplicationContext(), ProxyActivity.class); Intent intent = new Intent(LoginActivity.this, ProxyActivity.class);
startActivity(intent); startActivity(intent);
} else if (id == R.id.action_custom_tabs) { } else if (id == R.id.action_custom_tabs) {
item.setChecked(!item.isChecked()); item.setChecked(!item.isChecked());
@ -751,13 +751,13 @@ public class LoginActivity extends BaseActivity {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_IMPORT && resultCode == RESULT_OK) { if (requestCode == PICK_IMPORT && resultCode == RESULT_OK) {
if (data == null || data.getData() == null) { if (data == null || data.getData() == null) {
Toasty.error(getApplicationContext(), getString(R.string.toot_select_file_error), Toast.LENGTH_LONG).show(); Toasty.error(LoginActivity.this, getString(R.string.toot_select_file_error), Toast.LENGTH_LONG).show();
return; return;
} }
String filename = Helper.getFilePathFromURI(getApplicationContext(), data.getData()); String filename = Helper.getFilePathFromURI(LoginActivity.this, data.getData());
Sqlite.importDB(LoginActivity.this, filename); Sqlite.importDB(LoginActivity.this, filename);
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.toot_select_file_error), Toast.LENGTH_LONG).show(); Toasty.error(LoginActivity.this, getString(R.string.toot_select_file_error), Toast.LENGTH_LONG).show();
} }
} }

View File

@ -80,7 +80,7 @@ public class ManageAccountsInListActivity extends BaseActivity implements OnList
title = b.getString("title"); title = b.getString("title");
listId = b.getString("id"); listId = b.getString("id");
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(ManageAccountsInListActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
} }
main_account_container = findViewById(R.id.main_account_container); main_account_container = findViewById(R.id.main_account_container);
@ -162,7 +162,7 @@ public class ManageAccountsInListActivity extends BaseActivity implements OnList
loader.setVisibility(View.GONE); loader.setVisibility(View.GONE);
main_account_container.setVisibility(View.VISIBLE); main_account_container.setVisibility(View.VISIBLE);
if (apiResponse.getError() != null) { if (apiResponse.getError() != null) {
Toasty.error(getApplicationContext(), apiResponse.getError().getError(), Toast.LENGTH_LONG).show(); Toasty.error(ManageAccountsInListActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
return; return;
} }
if (actionType == ManageListsAsyncTask.action.GET_LIST_ACCOUNT) { if (actionType == ManageListsAsyncTask.action.GET_LIST_ACCOUNT) {

View File

@ -101,7 +101,7 @@ public class MastodonRegisterActivity extends BaseActivity implements OnRetrieve
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(MastodonRegisterActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(MastodonRegisterActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(MastodonRegisterActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
@ -173,23 +173,23 @@ public class MastodonRegisterActivity extends BaseActivity implements OnRetrieve
error_message.setVisibility(View.GONE); error_message.setVisibility(View.GONE);
if (username.getText().toString().trim().length() == 0 || email.getText().toString().trim().length() == 0 || if (username.getText().toString().trim().length() == 0 || email.getText().toString().trim().length() == 0 ||
password.getText().toString().trim().length() == 0 || password_confirm.getText().toString().trim().length() == 0 || !agreement.isChecked()) { password.getText().toString().trim().length() == 0 || password_confirm.getText().toString().trim().length() == 0 || !agreement.isChecked()) {
Toasty.error(getApplicationContext(), getString(R.string.all_field_filled)).show(); Toasty.error(MastodonRegisterActivity.this, getString(R.string.all_field_filled)).show();
return; return;
} }
if (!password.getText().toString().trim().equals(password_confirm.getText().toString().trim())) { if (!password.getText().toString().trim().equals(password_confirm.getText().toString().trim())) {
Toasty.error(getApplicationContext(), getString(R.string.password_error)).show(); Toasty.error(MastodonRegisterActivity.this, getString(R.string.password_error)).show();
return; return;
} }
if (!android.util.Patterns.EMAIL_ADDRESS.matcher(email.getText().toString().trim()).matches()) { if (!android.util.Patterns.EMAIL_ADDRESS.matcher(email.getText().toString().trim()).matches()) {
Toasty.error(getApplicationContext(), getString(R.string.email_error)).show(); Toasty.error(MastodonRegisterActivity.this, getString(R.string.email_error)).show();
return; return;
} }
if (password.getText().toString().trim().length() < 8) { if (password.getText().toString().trim().length() < 8) {
Toasty.error(getApplicationContext(), getString(R.string.password_too_short)).show(); Toasty.error(MastodonRegisterActivity.this, getString(R.string.password_too_short)).show();
return; return;
} }
if (username.getText().toString().matches("[a-zA-Z0-9_]")) { if (username.getText().toString().matches("[a-zA-Z0-9_]")) {
Toasty.error(getApplicationContext(), getString(R.string.username_error)).show(); Toasty.error(MastodonRegisterActivity.this, getString(R.string.username_error)).show();
return; return;
} }
signup.setEnabled(false); signup.setEnabled(false);
@ -212,7 +212,7 @@ public class MastodonRegisterActivity extends BaseActivity implements OnRetrieve
@Override @Override
public void onRetrieveInstance(APIResponse apiResponse) { public void onRetrieveInstance(APIResponse apiResponse) {
if (apiResponse.getError() != null || apiResponse.getInstanceRegs() == null) { if (apiResponse.getError() != null || apiResponse.getInstanceRegs() == null) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error_instance_reg), Toast.LENGTH_LONG).show(); Toasty.error(MastodonRegisterActivity.this, getString(R.string.toast_error_instance_reg), Toast.LENGTH_LONG).show();
return; return;
} }
List<InstanceReg> instanceRegs = apiResponse.getInstanceRegs(); List<InstanceReg> instanceRegs = apiResponse.getInstanceRegs();

View File

@ -95,7 +95,7 @@ public class MastodonShareRegisterActivity extends BaseActivity implements OnRet
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(MastodonShareRegisterActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(MastodonShareRegisterActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(MastodonShareRegisterActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
@ -140,23 +140,23 @@ public class MastodonShareRegisterActivity extends BaseActivity implements OnRet
error_message.setVisibility(View.GONE); error_message.setVisibility(View.GONE);
if (username.getText().toString().trim().length() == 0 || email.getText().toString().trim().length() == 0 || if (username.getText().toString().trim().length() == 0 || email.getText().toString().trim().length() == 0 ||
password.getText().toString().trim().length() == 0 || password_confirm.getText().toString().trim().length() == 0 || !agreement.isChecked()) { password.getText().toString().trim().length() == 0 || password_confirm.getText().toString().trim().length() == 0 || !agreement.isChecked()) {
Toasty.error(getApplicationContext(), getString(R.string.all_field_filled)).show(); Toasty.error(MastodonShareRegisterActivity.this, getString(R.string.all_field_filled)).show();
return; return;
} }
if (!password.getText().toString().trim().equals(password_confirm.getText().toString().trim())) { if (!password.getText().toString().trim().equals(password_confirm.getText().toString().trim())) {
Toasty.error(getApplicationContext(), getString(R.string.password_error)).show(); Toasty.error(MastodonShareRegisterActivity.this, getString(R.string.password_error)).show();
return; return;
} }
if (!android.util.Patterns.EMAIL_ADDRESS.matcher(email.getText().toString().trim()).matches()) { if (!android.util.Patterns.EMAIL_ADDRESS.matcher(email.getText().toString().trim()).matches()) {
Toasty.error(getApplicationContext(), getString(R.string.email_error)).show(); Toasty.error(MastodonShareRegisterActivity.this, getString(R.string.email_error)).show();
return; return;
} }
if (password.getText().toString().trim().length() < 8) { if (password.getText().toString().trim().length() < 8) {
Toasty.error(getApplicationContext(), getString(R.string.password_too_short)).show(); Toasty.error(MastodonShareRegisterActivity.this, getString(R.string.password_too_short)).show();
return; return;
} }
if (username.getText().toString().matches("[a-zA-Z0-9_]")) { if (username.getText().toString().matches("[a-zA-Z0-9_]")) {
Toasty.error(getApplicationContext(), getString(R.string.username_error)).show(); Toasty.error(MastodonShareRegisterActivity.this, getString(R.string.username_error)).show();
return; return;
} }
signup.setEnabled(false); signup.setEnabled(false);
@ -179,7 +179,7 @@ public class MastodonShareRegisterActivity extends BaseActivity implements OnRet
@Override @Override
public void onRetrieveInstance(APIResponse apiResponse) { public void onRetrieveInstance(APIResponse apiResponse) {
if (apiResponse.getError() != null || apiResponse.getInstanceRegs() == null) { if (apiResponse.getError() != null || apiResponse.getInstanceRegs() == null) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error_instance_reg), Toast.LENGTH_LONG).show(); Toasty.error(MastodonShareRegisterActivity.this, getString(R.string.toast_error_instance_reg), Toast.LENGTH_LONG).show();
return; return;
} }
List<InstanceReg> instanceRegs = apiResponse.getInstanceRegs(); List<InstanceReg> instanceRegs = apiResponse.getInstanceRegs();

View File

@ -112,7 +112,7 @@ public class MutedInstanceActivity extends BaseActivity implements OnRetrieveDom
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.simple_bar_muted_instance, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.simple_bar_muted_instance, new LinearLayout(MutedInstanceActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(MutedInstanceActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(MutedInstanceActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
@ -139,7 +139,7 @@ public class MutedInstanceActivity extends BaseActivity implements OnRetrieveDom
} }
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(MutedInstanceActivity.this, style); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(MutedInstanceActivity.this, style);
LayoutInflater inflater1 = getLayoutInflater(); LayoutInflater inflater1 = getLayoutInflater();
View dialogView = inflater1.inflate(R.layout.add_blocked_instance, new LinearLayout(getApplicationContext()), false); View dialogView = inflater1.inflate(R.layout.add_blocked_instance, new LinearLayout(MutedInstanceActivity.this), false);
dialogBuilder.setView(dialogView); dialogBuilder.setView(dialogView);
EditText add_domain = dialogView.findViewById(R.id.add_domain); EditText add_domain = dialogView.findViewById(R.id.add_domain);
@ -148,7 +148,7 @@ public class MutedInstanceActivity extends BaseActivity implements OnRetrieveDom
new PostActionAsyncTask(MutedInstanceActivity.this, API.StatusAction.BLOCK_DOMAIN, add_domain.getText().toString().trim(), MutedInstanceActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostActionAsyncTask(MutedInstanceActivity.this, API.StatusAction.BLOCK_DOMAIN, add_domain.getText().toString().trim(), MutedInstanceActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
dialog.dismiss(); dialog.dismiss();
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.toast_empty_content)).show(); Toasty.error(MutedInstanceActivity.this, getString(R.string.toast_empty_content)).show();
} }
}); });
dialogBuilder.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss()); dialogBuilder.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss());
@ -159,10 +159,10 @@ public class MutedInstanceActivity extends BaseActivity implements OnRetrieveDom
alertDialog.show(); alertDialog.show();
break; break;
case R.id.action_export_instances: case R.id.action_export_instances:
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(MutedInstanceActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext())); String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(MutedInstanceActivity.this));
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance); Account account = new AccountDAO(MutedInstanceActivity.this, db).getUniqAccount(userId, instance);
Helper.exportInstanceBlock(MutedInstanceActivity.this, account.getAcct() + "_" + account.getInstance()); Helper.exportInstanceBlock(MutedInstanceActivity.this, account.getAcct() + "_" + account.getInstance());
break; break;
case R.id.action_import_instances: case R.id.action_import_instances:
@ -297,7 +297,7 @@ public class MutedInstanceActivity extends BaseActivity implements OnRetrieveDom
mainLoader.setVisibility(View.GONE); mainLoader.setVisibility(View.GONE);
nextElementLoader.setVisibility(View.GONE); nextElementLoader.setVisibility(View.GONE);
if (apiResponse.getError() != null) { if (apiResponse.getError() != null) {
Toasty.error(getApplicationContext(), apiResponse.getError().getError(), Toast.LENGTH_LONG).show(); Toasty.error(MutedInstanceActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
swipeRefreshLayout.setRefreshing(false); swipeRefreshLayout.setRefreshing(false);
swiped = false; swiped = false;
flag_loading = false; flag_loading = false;
@ -335,7 +335,7 @@ public class MutedInstanceActivity extends BaseActivity implements OnRetrieveDom
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_IMPORT_INSTANCE && resultCode == RESULT_OK) { if (requestCode == PICK_IMPORT_INSTANCE && resultCode == RESULT_OK) {
if (data == null || data.getData() == null) { if (data == null || data.getData() == null) {
Toasty.error(getApplicationContext(), getString(R.string.toot_select_file_error), Toast.LENGTH_LONG).show(); Toasty.error(MutedInstanceActivity.this, getString(R.string.toot_select_file_error), Toast.LENGTH_LONG).show();
return; return;
} }
try { try {
@ -356,7 +356,7 @@ public class MutedInstanceActivity extends BaseActivity implements OnRetrieveDom
} }
Helper.importInstanceBlock(MutedInstanceActivity.this, resultList); Helper.importInstanceBlock(MutedInstanceActivity.this, resultList);
} catch (Exception e) { } catch (Exception e) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_SHORT).show(); Toasty.error(MutedInstanceActivity.this, getString(R.string.toast_error), Toast.LENGTH_SHORT).show();
} }
@ -367,9 +367,9 @@ public class MutedInstanceActivity extends BaseActivity implements OnRetrieveDom
public void onPostAction(int statusCode, API.StatusAction statusAction, String userId, Error error) { public void onPostAction(int statusCode, API.StatusAction statusAction, String userId, Error error) {
if (error != null) { if (error != null) {
if (error.getError().length() < 100) { if (error.getError().length() < 100) {
Toasty.error(getApplicationContext(), error.getError(), Toast.LENGTH_LONG).show(); Toasty.error(MutedInstanceActivity.this, error.getError(), Toast.LENGTH_LONG).show();
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.long_api_error, "\ud83d\ude05"), Toast.LENGTH_LONG).show(); Toasty.error(MutedInstanceActivity.this, getString(R.string.long_api_error, "\ud83d\ude05"), Toast.LENGTH_LONG).show();
} }
return; return;
} }

View File

@ -135,7 +135,7 @@ public class OwnerChartsActivity extends BaseActivity implements OnRetrieveChart
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.simple_action_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.simple_action_bar, new LinearLayout(OwnerChartsActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(OwnerChartsActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(OwnerChartsActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
@ -144,12 +144,12 @@ public class OwnerChartsActivity extends BaseActivity implements OnRetrieveChart
TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title); TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(OwnerChartsActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null); String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance); Account account = new AccountDAO(OwnerChartsActivity.this, db).getUniqAccount(userId, instance);
if (account != null) { if (account != null) {
Helper.loadGiF(getApplicationContext(), account, pp_actionBar); Helper.loadGiF(OwnerChartsActivity.this, account, pp_actionBar);
} }
toolbar_close.setOnClickListener(v -> finish()); toolbar_close.setOnClickListener(v -> finish());
@ -223,7 +223,7 @@ public class OwnerChartsActivity extends BaseActivity implements OnRetrieveChart
} }
CustomMarkerView mv = new CustomMarkerView(getApplicationContext(), R.layout.markerview); CustomMarkerView mv = new CustomMarkerView(OwnerChartsActivity.this, R.layout.markerview);
chart.setMarkerView(mv); chart.setMarkerView(mv);
validate.setOnClickListener(v -> loadGraph(dateIni, dateEnd)); validate.setOnClickListener(v -> loadGraph(dateIni, dateEnd));

View File

@ -168,7 +168,7 @@ public class OwnerNotificationActivity extends BaseActivity implements OnRetriev
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.toot_action_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.toot_action_bar, new LinearLayout(OwnerNotificationActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(OwnerNotificationActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(OwnerNotificationActivity.this, R.color.cyanea_primary)));
toolbar.setBackgroundColor(ContextCompat.getColor(OwnerNotificationActivity.this, R.color.cyanea_primary)); toolbar.setBackgroundColor(ContextCompat.getColor(OwnerNotificationActivity.this, R.color.cyanea_primary));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
@ -212,7 +212,7 @@ public class OwnerNotificationActivity extends BaseActivity implements OnRetriev
SQLiteDatabase db = Sqlite.getInstance(OwnerNotificationActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(OwnerNotificationActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
Account account = new AccountDAO(OwnerNotificationActivity.this, db).getUniqAccount(userId, instance); Account account = new AccountDAO(OwnerNotificationActivity.this, db).getUniqAccount(userId, instance);
Helper.loadGiF(getApplicationContext(), account, pp_actionBar); Helper.loadGiF(OwnerNotificationActivity.this, account, pp_actionBar);
swipeRefreshLayout = findViewById(R.id.swipeContainer); swipeRefreshLayout = findViewById(R.id.swipeContainer);
int c1 = getResources().getColor(R.color.cyanea_accent); int c1 = getResources().getColor(R.color.cyanea_accent);
@ -282,14 +282,14 @@ public class OwnerNotificationActivity extends BaseActivity implements OnRetriev
} }
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(OwnerNotificationActivity.this, style); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(OwnerNotificationActivity.this, style);
LayoutInflater inflater = this.getLayoutInflater(); LayoutInflater inflater = this.getLayoutInflater();
statsDialogView = inflater.inflate(R.layout.stats_owner_notifications, new LinearLayout(getApplicationContext()), false); statsDialogView = inflater.inflate(R.layout.stats_owner_notifications, new LinearLayout(OwnerNotificationActivity.this), false);
dialogBuilder.setView(statsDialogView); dialogBuilder.setView(statsDialogView);
dialogBuilder dialogBuilder
.setTitle(R.string.action_stats) .setTitle(R.string.action_stats)
.setPositiveButton(R.string.close, (dialog, which) -> dialog.dismiss()); .setPositiveButton(R.string.close, (dialog, which) -> dialog.dismiss());
dialogBuilder.create().show(); dialogBuilder.create().show();
if (statistics == null) { if (statistics == null) {
new RetrieveNotificationStatsAsyncTask(getApplicationContext(), OwnerNotificationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveNotificationStatsAsyncTask(OwnerNotificationActivity.this, OwnerNotificationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else { } else {
displayStats(); displayStats();
} }
@ -306,7 +306,7 @@ public class OwnerNotificationActivity extends BaseActivity implements OnRetriev
} }
dialogBuilder = new AlertDialog.Builder(OwnerNotificationActivity.this, style); dialogBuilder = new AlertDialog.Builder(OwnerNotificationActivity.this, style);
inflater = this.getLayoutInflater(); inflater = this.getLayoutInflater();
View dialogView = inflater.inflate(R.layout.filter_owner_notifications, new LinearLayout(getApplicationContext()), false); View dialogView = inflater.inflate(R.layout.filter_owner_notifications, new LinearLayout(OwnerNotificationActivity.this), false);
dialogBuilder.setView(dialogView); dialogBuilder.setView(dialogView);
@ -436,7 +436,7 @@ public class OwnerNotificationActivity extends BaseActivity implements OnRetriev
loader.setVisibility(View.GONE); loader.setVisibility(View.GONE);
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_SHORT).show(); Toasty.error(OwnerNotificationActivity.this, getString(R.string.toast_error), Toast.LENGTH_SHORT).show();
} }
} }
@ -446,7 +446,7 @@ public class OwnerNotificationActivity extends BaseActivity implements OnRetriev
nextElementLoader.setVisibility(View.GONE); nextElementLoader.setVisibility(View.GONE);
//Discards 404 - error which can often happen due to toots which have been deleted //Discards 404 - error which can often happen due to toots which have been deleted
if (apiResponse.getError() != null && apiResponse.getError().getStatusCode() != 404 && apiResponse.getError().getStatusCode() != 501) { if (apiResponse.getError() != null && apiResponse.getError().getStatusCode() != 404 && apiResponse.getError().getStatusCode() != 501) {
Toasty.error(getApplicationContext(), apiResponse.getError().getError(), Toast.LENGTH_LONG).show(); Toasty.error(OwnerNotificationActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
swipeRefreshLayout.setRefreshing(false); swipeRefreshLayout.setRefreshing(false);
swiped = false; swiped = false;
flag_loading = false; flag_loading = false;

View File

@ -142,7 +142,7 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.simple_action_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.simple_action_bar, new LinearLayout(OwnerNotificationChartsActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(OwnerNotificationChartsActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(OwnerNotificationChartsActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
@ -151,12 +151,12 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title); TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(OwnerNotificationChartsActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null); String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance); Account account = new AccountDAO(OwnerNotificationChartsActivity.this, db).getUniqAccount(userId, instance);
if (account != null) { if (account != null) {
Helper.loadGiF(getApplicationContext(), account, pp_actionBar); Helper.loadGiF(OwnerNotificationChartsActivity.this, account, pp_actionBar);
} }
toolbar_close.setOnClickListener(v -> finish()); toolbar_close.setOnClickListener(v -> finish());
@ -181,7 +181,7 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
dateIni = new NotificationCacheDAO(OwnerNotificationChartsActivity.this, db).getSmallerDate(); dateIni = new NotificationCacheDAO(OwnerNotificationChartsActivity.this, db).getSmallerDate();
dateEnd = new NotificationCacheDAO(OwnerNotificationChartsActivity.this, db).getGreaterDate(); dateEnd = new NotificationCacheDAO(OwnerNotificationChartsActivity.this, db).getGreaterDate();
} else { } else {
Status status = new StatusCacheDAO(getApplicationContext(), db).getStatus(status_id); Status status = new StatusCacheDAO(OwnerNotificationChartsActivity.this, db).getStatus(status_id);
if (status == null) { if (status == null) {
finish(); finish();
return; return;
@ -244,7 +244,7 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
} }
CustomMarkerView mv = new CustomMarkerView(getApplicationContext(), R.layout.markerview); CustomMarkerView mv = new CustomMarkerView(OwnerNotificationChartsActivity.this, R.layout.markerview);
chart.setMarkerView(mv); chart.setMarkerView(mv);
validate.setOnClickListener(v -> loadGraph(dateIni, dateEnd)); validate.setOnClickListener(v -> loadGraph(dateIni, dateEnd));

View File

@ -173,7 +173,7 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(android.content.Context.LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(android.content.Context.LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.toot_action_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.toot_action_bar, new LinearLayout(OwnerStatusActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(OwnerStatusActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(OwnerStatusActivity.this, R.color.cyanea_primary)));
toolbar.setBackgroundColor(ContextCompat.getColor(OwnerStatusActivity.this, R.color.cyanea_primary)); toolbar.setBackgroundColor(ContextCompat.getColor(OwnerStatusActivity.this, R.color.cyanea_primary));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
@ -221,7 +221,7 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
SQLiteDatabase db = Sqlite.getInstance(OwnerStatusActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(OwnerStatusActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
Account account = new AccountDAO(OwnerStatusActivity.this, db).getUniqAccount(userId, instance); Account account = new AccountDAO(OwnerStatusActivity.this, db).getUniqAccount(userId, instance);
Helper.loadGiF(getApplicationContext(), account, pp_actionBar); Helper.loadGiF(OwnerStatusActivity.this, account, pp_actionBar);
swipeRefreshLayout = findViewById(R.id.swipeContainer); swipeRefreshLayout = findViewById(R.id.swipeContainer);
int c1 = getResources().getColor(R.color.cyanea_accent); int c1 = getResources().getColor(R.color.cyanea_accent);
@ -291,14 +291,14 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
} }
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(OwnerStatusActivity.this, style); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(OwnerStatusActivity.this, style);
LayoutInflater inflater = this.getLayoutInflater(); LayoutInflater inflater = this.getLayoutInflater();
statsDialogView = inflater.inflate(R.layout.stats_owner_toots, new LinearLayout(getApplicationContext()), false); statsDialogView = inflater.inflate(R.layout.stats_owner_toots, new LinearLayout(OwnerStatusActivity.this), false);
dialogBuilder.setView(statsDialogView); dialogBuilder.setView(statsDialogView);
dialogBuilder dialogBuilder
.setTitle(R.string.action_stats) .setTitle(R.string.action_stats)
.setPositiveButton(R.string.close, (dialog, which) -> dialog.dismiss()); .setPositiveButton(R.string.close, (dialog, which) -> dialog.dismiss());
dialogBuilder.create().show(); dialogBuilder.create().show();
if (statistics == null) { if (statistics == null) {
new RetrieveStatsAsyncTask(getApplicationContext(), OwnerStatusActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveStatsAsyncTask(OwnerStatusActivity.this, OwnerStatusActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else { } else {
displayStats(); displayStats();
} }
@ -315,7 +315,7 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
} }
dialogBuilder = new AlertDialog.Builder(OwnerStatusActivity.this, style); dialogBuilder = new AlertDialog.Builder(OwnerStatusActivity.this, style);
inflater = this.getLayoutInflater(); inflater = this.getLayoutInflater();
View dialogView = inflater.inflate(R.layout.filter_owner_toots, new LinearLayout(getApplicationContext()), false); View dialogView = inflater.inflate(R.layout.filter_owner_toots, new LinearLayout(OwnerStatusActivity.this), false);
dialogBuilder.setView(dialogView); dialogBuilder.setView(dialogView);
@ -426,7 +426,7 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
nextElementLoader.setVisibility(View.GONE); nextElementLoader.setVisibility(View.GONE);
//Discards 404 - error which can often happen due to toots which have been deleted //Discards 404 - error which can often happen due to toots which have been deleted
if (apiResponse.getError() != null && apiResponse.getError().getStatusCode() != 404 && apiResponse.getError().getStatusCode() != 501) { if (apiResponse.getError() != null && apiResponse.getError().getStatusCode() != 404 && apiResponse.getError().getStatusCode() != 501) {
Toasty.error(getApplicationContext(), apiResponse.getError().getError(), Toast.LENGTH_LONG).show(); Toasty.error(OwnerStatusActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
swipeRefreshLayout.setRefreshing(false); swipeRefreshLayout.setRefreshing(false);
swiped = false; swiped = false;
flag_loading = false; flag_loading = false;
@ -540,7 +540,7 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
loader.setVisibility(View.GONE); loader.setVisibility(View.GONE);
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_SHORT).show(); Toasty.error(OwnerStatusActivity.this, getString(R.string.toast_error), Toast.LENGTH_SHORT).show();
} }
} }
} }

View File

@ -85,7 +85,7 @@ public class PartnerShipActivity extends BaseActivity implements OnRetrieveRemot
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(PartnerShipActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(PartnerShipActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(PartnerShipActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
@ -115,7 +115,7 @@ public class PartnerShipActivity extends BaseActivity implements OnRetrieveRemot
lv_mastohost.setAdapter(mastohostAdapter); lv_mastohost.setAdapter(mastohostAdapter);
new RetrieveRemoteDataAsyncTask(getApplicationContext(), "mastohost", "mastodon.social", PartnerShipActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveRemoteDataAsyncTask(PartnerShipActivity.this, "mastohost", "mastodon.social", PartnerShipActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
@Override @Override
@ -131,7 +131,7 @@ public class PartnerShipActivity extends BaseActivity implements OnRetrieveRemot
@Override @Override
public void onRetrieveRemoteAccount(Results results, boolean devAccount) { public void onRetrieveRemoteAccount(Results results, boolean devAccount) {
if (results == null) { if (results == null) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(PartnerShipActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
return; return;
} }
List<Account> accounts = results.getAccounts(); List<Account> accounts = results.getAccounts();
@ -143,7 +143,7 @@ public class PartnerShipActivity extends BaseActivity implements OnRetrieveRemot
mastohostAcct.add(account); mastohostAcct.add(account);
mastohostAdapter.notifyDataSetChanged(); mastohostAdapter.notifyDataSetChanged();
} }
new RetrieveRelationshipAsyncTask(getApplicationContext(), account.getId(), PartnerShipActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveRelationshipAsyncTask(PartnerShipActivity.this, account.getId(), PartnerShipActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
} }
@ -153,7 +153,7 @@ public class PartnerShipActivity extends BaseActivity implements OnRetrieveRemot
super.onResume(); super.onResume();
if (mastohostAcct != null) { if (mastohostAcct != null) {
for (Account account : mastohostAcct) { for (Account account : mastohostAcct) {
new RetrieveRelationshipAsyncTask(getApplicationContext(), account.getId(), PartnerShipActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveRelationshipAsyncTask(PartnerShipActivity.this, account.getId(), PartnerShipActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
} }
} }

View File

@ -204,7 +204,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
} }
}); });
Helper.changeDrawableColor(getApplicationContext(), send, R.color.cyanea_accent); Helper.changeDrawableColor(PeertubeActivity.this, send, R.color.cyanea_accent);
if (MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) { if (MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
write_comment_container.setVisibility(View.GONE); write_comment_container.setVisibility(View.GONE);
} }
@ -218,7 +218,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
public void onClick(View v) { public void onClick(View v) {
String comment = add_comment_write.getText().toString(); String comment = add_comment_write.getText().toString();
if (comment.trim().length() > 0) { if (comment.trim().length() > 0) {
new PostActionAsyncTask(getApplicationContext(), API.StatusAction.PEERTUBECOMMENT, peertube.getId(), null, comment, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostActionAsyncTask(PeertubeActivity.this, API.StatusAction.PEERTUBECOMMENT, peertube.getId(), null, comment, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
add_comment_write.setText(""); add_comment_write.setText("");
add_comment_read.setVisibility(View.VISIBLE); add_comment_read.setVisibility(View.VISIBLE);
add_comment_write.setVisibility(View.GONE); add_comment_write.setVisibility(View.GONE);
@ -228,11 +228,11 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
} }
}); });
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(PeertubeActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext())); instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(PeertubeActivity.this));
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance); Account account = new AccountDAO(PeertubeActivity.this, db).getUniqAccount(userId, instance);
Helper.loadGiF(getApplicationContext(), account, my_pp); Helper.loadGiF(PeertubeActivity.this, account, my_pp);
Bundle b = getIntent().getExtras(); Bundle b = getIntent().getExtras();
if (b != null) { if (b != null) {
peertubeInstance = b.getString("peertube_instance", null); peertubeInstance = b.getString("peertube_instance", null);
@ -244,7 +244,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(PeertubeActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(PeertubeActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(PeertubeActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
@ -384,7 +384,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
return true; return true;
case R.id.action_comment: case R.id.action_comment:
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) { if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
Toasty.info(getApplicationContext(), getString(R.string.retrieve_remote_status), Toast.LENGTH_LONG).show(); Toasty.info(PeertubeActivity.this, getString(R.string.retrieve_remote_status), Toast.LENGTH_LONG).show();
new AsyncTask<Void, Void, Void>() { new AsyncTask<Void, Void, Void>() {
private List<app.fedilab.android.client.Entities.Status> remoteStatuses; private List<app.fedilab.android.client.Entities.Status> remoteStatuses;
@ -421,7 +421,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) { } else if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
if (!peertube.isCommentsEnabled()) { if (!peertube.isCommentsEnabled()) {
Toasty.info(getApplicationContext(), getString(R.string.comment_no_allowed_peertube), Toast.LENGTH_LONG).show(); Toasty.info(PeertubeActivity.this, getString(R.string.comment_no_allowed_peertube), Toast.LENGTH_LONG).show();
return true; return true;
} }
int style; int style;
@ -454,7 +454,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
String comment = input.getText().toString(); String comment = input.getText().toString();
if (comment.trim().length() > 0) { if (comment.trim().length() > 0) {
new PostActionAsyncTask(getApplicationContext(), API.StatusAction.PEERTUBECOMMENT, peertube.getId(), null, comment, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostActionAsyncTask(PeertubeActivity.this, API.StatusAction.PEERTUBECOMMENT, peertube.getId(), null, comment, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
dialog.dismiss(); dialog.dismiss();
} }
} }
@ -479,12 +479,12 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
public void onRetrievePeertube(APIResponse apiResponse) { public void onRetrievePeertube(APIResponse apiResponse) {
if (apiResponse == null || (apiResponse.getError() != null) || apiResponse.getPeertubes() == null || apiResponse.getPeertubes().size() == 0) { if (apiResponse == null || (apiResponse.getError() != null) || apiResponse.getPeertubes() == null || apiResponse.getPeertubes().size() == 0) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(PeertubeActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
loader.setVisibility(View.GONE); loader.setVisibility(View.GONE);
return; return;
} }
if (apiResponse.getPeertubes() == null || apiResponse.getPeertubes().get(0) == null || apiResponse.getPeertubes().get(0).getFileUrl(null, apiResponse.getPeertubes().get(0).isStreamService()) == null) { if (apiResponse.getPeertubes() == null || apiResponse.getPeertubes().get(0) == null || apiResponse.getPeertubes().get(0).getFileUrl(null, apiResponse.getPeertubes().get(0).isStreamService()) == null) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(PeertubeActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
loader.setVisibility(View.GONE); loader.setVisibility(View.GONE);
return; return;
} }
@ -518,7 +518,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
item.setActionView(new View(getApplicationContext())); item.setActionView(new View(PeertubeActivity.this));
item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() { item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
@Override @Override
public boolean onMenuItemActionExpand(MenuItem item) { public boolean onMenuItemActionExpand(MenuItem item) {
@ -578,7 +578,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
@Override @Override
public void onClick(View v) { public void onClick(View v) {
String newState = peertube.getMyRating().equals("like") ? "none" : "like"; String newState = peertube.getMyRating().equals("like") ? "none" : "like";
new PostActionAsyncTask(getApplicationContext(), API.StatusAction.RATEVIDEO, peertube.getId(), null, newState, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostActionAsyncTask(PeertubeActivity.this, API.StatusAction.RATEVIDEO, peertube.getId(), null, newState, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
peertube.setMyRating(newState); peertube.setMyRating(newState);
changeColor(); changeColor();
} }
@ -587,7 +587,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
@Override @Override
public void onClick(View v) { public void onClick(View v) {
String newState = peertube.getMyRating().equals("dislike") ? "none" : "dislike"; String newState = peertube.getMyRating().equals("dislike") ? "none" : "dislike";
new PostActionAsyncTask(getApplicationContext(), API.StatusAction.RATEVIDEO, peertube.getId(), null, newState, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostActionAsyncTask(PeertubeActivity.this, API.StatusAction.RATEVIDEO, peertube.getId(), null, newState, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
peertube.setMyRating(newState); peertube.setMyRating(newState);
changeColor(); changeColor();
} }
@ -599,7 +599,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
String newState = peertube.getMyRating().equals("like") ? "none" : "like"; String newState = peertube.getMyRating().equals("like") ? "none" : "like";
Status status = new Status(); Status status = new Status();
status.setUri("https://" + peertube.getAccount().getHost() + "/videos/watch/" + peertube.getUuid()); status.setUri("https://" + peertube.getAccount().getHost() + "/videos/watch/" + peertube.getUuid());
CrossActions.doCrossAction(getApplicationContext(), RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE, status, null, API.StatusAction.FAVOURITE, null, PeertubeActivity.this, true); CrossActions.doCrossAction(PeertubeActivity.this, RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE, status, null, API.StatusAction.FAVOURITE, null, PeertubeActivity.this, true);
peertube.setMyRating(newState); peertube.setMyRating(newState);
changeColor(); changeColor();
} }
@ -610,7 +610,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
String newState = peertube.getMyRating().equals("dislike") ? "none" : "dislike"; String newState = peertube.getMyRating().equals("dislike") ? "none" : "dislike";
Status status = new Status(); Status status = new Status();
status.setUri("https://" + peertube.getAccount().getHost() + "/videos/watch/" + peertube.getUuid()); status.setUri("https://" + peertube.getAccount().getHost() + "/videos/watch/" + peertube.getUuid());
CrossActions.doCrossAction(getApplicationContext(), RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE, status, null, API.StatusAction.UNFAVOURITE, null, PeertubeActivity.this, true); CrossActions.doCrossAction(PeertubeActivity.this, RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE, status, null, API.StatusAction.UNFAVOURITE, null, PeertubeActivity.this, true);
peertube.setMyRating(newState); peertube.setMyRating(newState);
changeColor(); changeColor();
} }
@ -627,8 +627,8 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
if (mode == Helper.VIDEO_MODE_DIRECT) { if (mode == Helper.VIDEO_MODE_DIRECT) {
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getApplicationContext(), DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(PeertubeActivity.this,
Util.getUserAgent(getApplicationContext(), "Mastalab"), null); Util.getUserAgent(PeertubeActivity.this, "Mastalab"), null);
ExtractorMediaSource videoSource = new ExtractorMediaSource.Factory(dataSourceFactory) ExtractorMediaSource videoSource = new ExtractorMediaSource.Factory(dataSourceFactory)
.createMediaSource(Uri.parse(apiResponse.getPeertubes().get(0).getFileUrl(null, apiResponse.getPeertubes().get(0).isStreamService()))); .createMediaSource(Uri.parse(apiResponse.getPeertubes().get(0).getFileUrl(null, apiResponse.getPeertubes().get(0).isStreamService())));
@ -673,10 +673,10 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
List<Peertube> peertubes = new PeertubeFavoritesDAO(PeertubeActivity.this, db).getSinglePeertube(peertube); List<Peertube> peertubes = new PeertubeFavoritesDAO(PeertubeActivity.this, db).getSinglePeertube(peertube);
if (peertubes == null || peertubes.size() == 0) { if (peertubes == null || peertubes.size() == 0) {
new PeertubeFavoritesDAO(PeertubeActivity.this, db).insert(peertube); new PeertubeFavoritesDAO(PeertubeActivity.this, db).insert(peertube);
Toasty.success(getApplicationContext(), getString(R.string.bookmark_add_peertube), Toast.LENGTH_SHORT).show(); Toasty.success(PeertubeActivity.this, getString(R.string.bookmark_add_peertube), Toast.LENGTH_SHORT).show();
} else { } else {
new PeertubeFavoritesDAO(PeertubeActivity.this, db).remove(peertube); new PeertubeFavoritesDAO(PeertubeActivity.this, db).remove(peertube);
Toasty.success(getApplicationContext(), getString(R.string.bookmark_remove_peertube), Toast.LENGTH_SHORT).show(); Toasty.success(PeertubeActivity.this, getString(R.string.bookmark_remove_peertube), Toast.LENGTH_SHORT).show();
} }
if (peertubes != null && peertubes.size() > 0) //Was initially in cache if (peertubes != null && peertubes.size() > 0) //Was initially in cache
peertube_bookmark.setCompoundDrawablesWithIntrinsicBounds(null, ContextCompat.getDrawable(PeertubeActivity.this, R.drawable.ic_bookmark_peertube_border), null, null); peertube_bookmark.setCompoundDrawablesWithIntrinsicBounds(null, ContextCompat.getDrawable(PeertubeActivity.this, R.drawable.ic_bookmark_peertube_border), null, null);
@ -748,9 +748,9 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
public void onRetrievePeertubeComments(APIResponse apiResponse) { public void onRetrievePeertubeComments(APIResponse apiResponse) {
if (apiResponse == null || (apiResponse.getError() != null && apiResponse.getError().getStatusCode() != 404 && apiResponse.getError() != null && apiResponse.getError().getStatusCode() != 501)) { if (apiResponse == null || (apiResponse.getError() != null && apiResponse.getError().getStatusCode() != 404 && apiResponse.getError() != null && apiResponse.getError().getStatusCode() != 501)) {
if (apiResponse == null) if (apiResponse == null)
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(PeertubeActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
else else
Toasty.error(getApplicationContext(), apiResponse.getError().getError(), Toast.LENGTH_LONG).show(); Toasty.error(PeertubeActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
return; return;
} }
List<Status> statuses = apiResponse.getStatuses(); List<Status> statuses = apiResponse.getStatuses();
@ -848,8 +848,8 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
player = ExoPlayerFactory.newSimpleInstance(PeertubeActivity.this); player = ExoPlayerFactory.newSimpleInstance(PeertubeActivity.this);
playerView.setPlayer(player); playerView.setPlayer(player);
loader.setVisibility(View.GONE); loader.setVisibility(View.GONE);
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getApplicationContext(), DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(PeertubeActivity.this,
Util.getUserAgent(getApplicationContext(), "Mastalab"), null); Util.getUserAgent(PeertubeActivity.this, "Mastalab"), null);
ExtractorMediaSource videoSource = new ExtractorMediaSource.Factory(dataSourceFactory) ExtractorMediaSource videoSource = new ExtractorMediaSource.Factory(dataSourceFactory)
.createMediaSource(Uri.parse(peertube.getFileUrl(res, peertube.isStreamService()))); .createMediaSource(Uri.parse(peertube.getFileUrl(res, peertube.isStreamService())));

View File

@ -111,7 +111,7 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(PeertubeEditUploadActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(PeertubeEditUploadActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(PeertubeEditUploadActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
@ -167,7 +167,7 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
builderInner.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { builderInner.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
new PostActionAsyncTask(getApplicationContext(), API.StatusAction.PEERTUBEDELETEVIDEO, videoId, PeertubeEditUploadActivity.this).executeOnExecutor(THREAD_POOL_EXECUTOR); new PostActionAsyncTask(PeertubeEditUploadActivity.this, API.StatusAction.PEERTUBEDELETEVIDEO, videoId, PeertubeEditUploadActivity.this).executeOnExecutor(THREAD_POOL_EXECUTOR);
dialog.dismiss(); dialog.dismiss();
} }
}); });
@ -254,7 +254,7 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
set_upload_privacy.setAdapter(adapterPrivacies); set_upload_privacy.setAdapter(adapterPrivacies);
String peertubeInstance = Helper.getLiveInstance(getApplicationContext()); String peertubeInstance = Helper.getLiveInstance(PeertubeEditUploadActivity.this);
new RetrievePeertubeSingleAsyncTask(PeertubeEditUploadActivity.this, peertubeInstance, videoId, PeertubeEditUploadActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrievePeertubeSingleAsyncTask(PeertubeEditUploadActivity.this, peertubeInstance, videoId, PeertubeEditUploadActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
channels = new LinkedHashMap<>(); channels = new LinkedHashMap<>();
@ -267,9 +267,9 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
public void onRetrievePeertube(APIResponse apiResponse) { public void onRetrievePeertube(APIResponse apiResponse) {
if (apiResponse.getError() != null || apiResponse.getPeertubes() == null || apiResponse.getPeertubes().size() == 0) { if (apiResponse.getError() != null || apiResponse.getPeertubes() == null || apiResponse.getPeertubes().size() == 0) {
if (apiResponse.getError() != null && apiResponse.getError().getError() != null) if (apiResponse.getError() != null && apiResponse.getError().getError() != null)
Toasty.error(getApplicationContext(), apiResponse.getError().getError(), Toast.LENGTH_LONG).show(); Toasty.error(PeertubeEditUploadActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
else else
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(PeertubeEditUploadActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
set_upload_submit.setEnabled(true); set_upload_submit.setEnabled(true);
return; return;
} }
@ -278,7 +278,7 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
Peertube peertube = apiResponse.getPeertubes().get(0); Peertube peertube = apiResponse.getPeertubes().get(0);
if (peertube.isUpdate()) { if (peertube.isUpdate()) {
Toasty.success(getApplicationContext(), getString(R.string.toast_peertube_video_updated), Toast.LENGTH_LONG).show(); Toasty.success(PeertubeEditUploadActivity.this, getString(R.string.toast_peertube_video_updated), Toast.LENGTH_LONG).show();
peertube.setUpdate(false); peertube.setUpdate(false);
set_upload_submit.setEnabled(true); set_upload_submit.setEnabled(true);
} else { } else {
@ -577,9 +577,9 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
public void onRetrievePeertubeChannels(APIResponse apiResponse) { public void onRetrievePeertubeChannels(APIResponse apiResponse) {
if (apiResponse.getError() != null || apiResponse.getAccounts() == null || apiResponse.getAccounts().size() == 0) { if (apiResponse.getError() != null || apiResponse.getAccounts() == null || apiResponse.getAccounts().size() == 0) {
if (apiResponse.getError().getError() != null) if (apiResponse.getError().getError() != null)
Toasty.error(getApplicationContext(), apiResponse.getError().getError(), Toast.LENGTH_LONG).show(); Toasty.error(PeertubeEditUploadActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
else else
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(PeertubeEditUploadActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
return; return;
} }
@ -618,7 +618,7 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
@Override @Override
public void onPostAction(int statusCode, API.StatusAction statusAction, String userId, Error error) { public void onPostAction(int statusCode, API.StatusAction statusAction, String userId, Error error) {
Intent intent = new Intent(getApplicationContext(), MainActivity.class); Intent intent = new Intent(PeertubeEditUploadActivity.this, MainActivity.class);
intent.putExtra(Helper.INTENT_ACTION, Helper.RELOAD_MYVIDEOS); intent.putExtra(Helper.INTENT_ACTION, Helper.RELOAD_MYVIDEOS);
startActivity(intent); startActivity(intent);
finish(); finish();

View File

@ -93,7 +93,7 @@ public class PeertubeRegisterActivity extends BaseActivity implements OnRetrieve
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(PeertubeRegisterActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(PeertubeRegisterActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(PeertubeRegisterActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
@ -118,23 +118,23 @@ public class PeertubeRegisterActivity extends BaseActivity implements OnRetrieve
error_message.setVisibility(View.GONE); error_message.setVisibility(View.GONE);
if (username.getText().toString().trim().length() == 0 || email.getText().toString().trim().length() == 0 || if (username.getText().toString().trim().length() == 0 || email.getText().toString().trim().length() == 0 ||
password.getText().toString().trim().length() == 0 || password_confirm.getText().toString().trim().length() == 0 || !agreement.isChecked()) { password.getText().toString().trim().length() == 0 || password_confirm.getText().toString().trim().length() == 0 || !agreement.isChecked()) {
Toasty.error(getApplicationContext(), getString(R.string.all_field_filled)).show(); Toasty.error(PeertubeRegisterActivity.this, getString(R.string.all_field_filled)).show();
return; return;
} }
if (!password.getText().toString().trim().equals(password_confirm.getText().toString().trim())) { if (!password.getText().toString().trim().equals(password_confirm.getText().toString().trim())) {
Toasty.error(getApplicationContext(), getString(R.string.password_error)).show(); Toasty.error(PeertubeRegisterActivity.this, getString(R.string.password_error)).show();
return; return;
} }
if (!android.util.Patterns.EMAIL_ADDRESS.matcher(email.getText().toString().trim()).matches()) { if (!android.util.Patterns.EMAIL_ADDRESS.matcher(email.getText().toString().trim()).matches()) {
Toasty.error(getApplicationContext(), getString(R.string.email_error)).show(); Toasty.error(PeertubeRegisterActivity.this, getString(R.string.email_error)).show();
return; return;
} }
if (password.getText().toString().trim().length() < 8) { if (password.getText().toString().trim().length() < 8) {
Toasty.error(getApplicationContext(), getString(R.string.password_too_short)).show(); Toasty.error(PeertubeRegisterActivity.this, getString(R.string.password_too_short)).show();
return; return;
} }
if (username.getText().toString().matches("[a-zA-Z0-9_]")) { if (username.getText().toString().matches("[a-zA-Z0-9_]")) {
Toasty.error(getApplicationContext(), getString(R.string.username_error)).show(); Toasty.error(PeertubeRegisterActivity.this, getString(R.string.username_error)).show();
return; return;
} }
signup.setEnabled(false); signup.setEnabled(false);
@ -157,7 +157,7 @@ public class PeertubeRegisterActivity extends BaseActivity implements OnRetrieve
@Override @Override
public void onRetrieveInstance(APIResponse apiResponse) { public void onRetrieveInstance(APIResponse apiResponse) {
if (apiResponse.getError() != null) { if (apiResponse.getError() != null) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error_instance_reg), Toast.LENGTH_LONG).show(); Toasty.error(PeertubeRegisterActivity.this, getString(R.string.toast_error_instance_reg), Toast.LENGTH_LONG).show();
return; return;
} }
List<InstanceReg> instanceRegs = apiResponse.getInstanceRegs(); List<InstanceReg> instanceRegs = apiResponse.getInstanceRegs();

View File

@ -113,7 +113,7 @@ public class PeertubeUploadActivity extends BaseActivity implements OnRetrievePe
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(PeertubeUploadActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(PeertubeUploadActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(PeertubeUploadActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
@ -150,7 +150,7 @@ public class PeertubeUploadActivity extends BaseActivity implements OnRetrievePe
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_IVDEO && resultCode == Activity.RESULT_OK) { if (requestCode == PICK_IVDEO && resultCode == Activity.RESULT_OK) {
if (data == null || data.getData() == null) { if (data == null || data.getData() == null) {
Toasty.error(getApplicationContext(), getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show(); Toasty.error(PeertubeUploadActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
return; return;
} }
set_upload_submit.setEnabled(true); set_upload_submit.setEnabled(true);
@ -202,9 +202,9 @@ public class PeertubeUploadActivity extends BaseActivity implements OnRetrievePe
public void onRetrievePeertubeChannels(APIResponse apiResponse) { public void onRetrievePeertubeChannels(APIResponse apiResponse) {
if (apiResponse.getError() != null || apiResponse.getAccounts() == null || apiResponse.getAccounts().size() == 0) { if (apiResponse.getError() != null || apiResponse.getAccounts() == null || apiResponse.getAccounts().size() == 0) {
if (apiResponse.getError() != null && apiResponse.getError().getError() != null) if (apiResponse.getError() != null && apiResponse.getError().getError() != null)
Toasty.error(getApplicationContext(), apiResponse.getError().getError(), Toast.LENGTH_LONG).show(); Toasty.error(PeertubeUploadActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
else else
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(PeertubeUploadActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
return; return;
} }
@ -348,8 +348,8 @@ public class PeertubeUploadActivity extends BaseActivity implements OnRetrievePe
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null); String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
UploadNotificationConfig uploadConfig = new UploadNotificationConfig(); UploadNotificationConfig uploadConfig = new UploadNotificationConfig();
Intent in = new Intent(getApplicationContext(), PeertubeEditUploadActivity.class); Intent in = new Intent(PeertubeUploadActivity.this, PeertubeEditUploadActivity.class);
PendingIntent clickIntent = PendingIntent.getActivity(getApplicationContext(), 1, in, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent clickIntent = PendingIntent.getActivity(PeertubeUploadActivity.this, 1, in, PendingIntent.FLAG_UPDATE_CURRENT);
uploadConfig uploadConfig
.setClearOnActionForAllStatuses(true); .setClearOnActionForAllStatuses(true);

View File

@ -310,7 +310,7 @@ public class PhotoEditorActivity extends BaseActivity implements OnPhotoEditorLi
if (exit) { if (exit) {
Intent intentImage = new Intent(Helper.INTENT_SEND_MODIFIED_IMAGE); Intent intentImage = new Intent(Helper.INTENT_SEND_MODIFIED_IMAGE);
intentImage.putExtra("imgpath", imagePath); intentImage.putExtra("imgpath", imagePath);
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intentImage); LocalBroadcastManager.getInstance(PhotoEditorActivity.this).sendBroadcast(intentImage);
finish(); finish();
} }
} }

View File

@ -541,7 +541,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext())); instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(PixelfedComposeActivity.this));
final int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); final int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
switch (theme) { switch (theme) {
case Helper.THEME_LIGHT: case Helper.THEME_LIGHT:
@ -573,7 +573,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.toot_action_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.toot_action_bar, new LinearLayout(PixelfedComposeActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(PixelfedComposeActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(PixelfedComposeActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
@ -681,11 +681,11 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
}); });
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(PixelfedComposeActivity.this);
int iconColor = prefs.getInt("theme_icons_color", -1); int iconColor = prefs.getInt("theme_icons_color", -1);
if (iconColor != -1) { if (iconColor != -1) {
Helper.changeDrawableColor(getApplicationContext(), toot_visibility, iconColor); Helper.changeDrawableColor(PixelfedComposeActivity.this, toot_visibility, iconColor);
Helper.changeDrawableColor(getApplicationContext(), toot_emoji, iconColor); Helper.changeDrawableColor(PixelfedComposeActivity.this, toot_emoji, iconColor);
toot_sensitive.setButtonTintList(ColorStateList.valueOf(iconColor)); toot_sensitive.setButtonTintList(ColorStateList.valueOf(iconColor));
toot_sensitive.setTextColor(iconColor); toot_sensitive.setTextColor(iconColor);
} }
@ -693,7 +693,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
} }
Bundle b = getIntent().getExtras(); Bundle b = getIntent().getExtras();
ArrayList<Uri> sharedUri = new ArrayList<>(); ArrayList<Uri> sharedUri = new ArrayList<>();
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(PixelfedComposeActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
restored = -1; restored = -1;
if (b != null) { if (b != null) {
scheduledstatus = b.getParcelable("storedStatus"); scheduledstatus = b.getParcelable("storedStatus");
@ -702,7 +702,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
if (accountReplyToken != null) { if (accountReplyToken != null) {
String[] val = accountReplyToken.split("\\|"); String[] val = accountReplyToken.split("\\|");
if (val.length == 2) { if (val.length == 2) {
accountReply = new AccountDAO(getApplicationContext(), db).getUniqAccount(val[0], val[1]); accountReply = new AccountDAO(PixelfedComposeActivity.this, db).getUniqAccount(val[0], val[1]);
} }
} }
removed = b.getBoolean("removed"); removed = b.getBoolean("removed");
@ -740,7 +740,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
instanceReply = accountReply.getInstance(); instanceReply = accountReply.getInstance();
} }
if (accountReply == null) if (accountReply == null)
account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userIdReply, instanceReply); account = new AccountDAO(PixelfedComposeActivity.this, db).getUniqAccount(userIdReply, instanceReply);
else else
account = accountReply; account = accountReply;
@ -750,7 +750,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
toot_content.requestFocus(); toot_content.requestFocus();
Helper.loadGiF(getApplicationContext(), account, pp_actionBar); Helper.loadGiF(PixelfedComposeActivity.this, account, pp_actionBar);
if (visibility == null) { if (visibility == null) {
@ -863,7 +863,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
}); });
TextWatcher textWatcher = initializeTextWatcher(getApplicationContext(), social, toot_content, toot_space_left, pp_actionBar, pp_progress, PixelfedComposeActivity.this, PixelfedComposeActivity.this, PixelfedComposeActivity.this); TextWatcher textWatcher = initializeTextWatcher(PixelfedComposeActivity.this, social, toot_content, toot_space_left, pp_actionBar, pp_progress, PixelfedComposeActivity.this, PixelfedComposeActivity.this, PixelfedComposeActivity.this);
toot_content.addTextChangedListener(textWatcher); toot_content.addTextChangedListener(textWatcher);
@ -925,7 +925,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
} }
} }
} else { } else {
Toasty.success(getApplicationContext(), getString(R.string.added_to_story), Toast.LENGTH_LONG).show(); Toasty.success(PixelfedComposeActivity.this, getString(R.string.added_to_story), Toast.LENGTH_LONG).show();
} }
} }
@ -946,7 +946,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
if (mToast != null) { if (mToast != null) {
mToast.cancel(); mToast.cancel();
} }
mToast = Toasty.error(getApplicationContext(), message, Toast.LENGTH_SHORT); mToast = Toasty.error(PixelfedComposeActivity.this, message, Toast.LENGTH_SHORT);
mToast.show(); mToast.show();
} }
@ -964,12 +964,12 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
count++; count++;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Toasty.error(getApplicationContext(), getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show(); Toasty.error(PixelfedComposeActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
upload_media.setEnabled(true); upload_media.setEnabled(true);
toot_it.setEnabled(true); toot_it.setEnabled(true);
} }
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show(); Toasty.error(PixelfedComposeActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
} }
} }
} }
@ -983,7 +983,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
try { try {
photoFile = createImageFile(); photoFile = createImageFile();
} catch (IOException ignored) { } catch (IOException ignored) {
Toasty.error(getApplicationContext(), getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show(); Toasty.error(PixelfedComposeActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
} }
// Continue only if the File was successfully created // Continue only if the File was successfully created
if (photoFile != null) { if (photoFile != null) {
@ -1024,13 +1024,13 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
boolean photo_editor = sharedpreferences.getBoolean(Helper.SET_PHOTO_EDITOR, true); boolean photo_editor = sharedpreferences.getBoolean(Helper.SET_PHOTO_EDITOR, true);
if (requestCode == PICK_IMAGE && resultCode == RESULT_OK) { if (requestCode == PICK_IMAGE && resultCode == RESULT_OK) {
if (data == null) { if (data == null) {
Toasty.error(getApplicationContext(), getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show(); Toasty.error(PixelfedComposeActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
return; return;
} }
ClipData clipData = data.getClipData(); ClipData clipData = data.getClipData();
if (data.getData() == null && clipData == null) { if (data.getData() == null && clipData == null) {
Toasty.error(getApplicationContext(), getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show(); Toasty.error(PixelfedComposeActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
return; return;
} }
if (clipData != null) { if (clipData != null) {
@ -1060,7 +1060,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
} else if (mime != null && mime.toLowerCase().contains("audio")) { } else if (mime != null && mime.toLowerCase().contains("audio")) {
prepareUpload(PixelfedComposeActivity.this, data.getData(), filename, uploadReceiver); prepareUpload(PixelfedComposeActivity.this, data.getData(), filename, uploadReceiver);
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show(); Toasty.error(PixelfedComposeActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
} }
} }
@ -1092,9 +1092,9 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
@Override @Override
public void onPostAction(int statusCode, API.StatusAction statusAction, String userId, Error error) { public void onPostAction(int statusCode, API.StatusAction statusAction, String userId, Error error) {
if (error != null) { if (error != null) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(PixelfedComposeActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
} else { } else {
Toasty.success(getApplicationContext(), getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show(); Toasty.success(PixelfedComposeActivity.this, getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show();
resetForNextToot(); resetForNextToot();
} }
} }
@ -1108,7 +1108,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
@Override @Override
public void onError(Context context, UploadInfo uploadInfo, ServerResponse serverResponse, public void onError(Context context, UploadInfo uploadInfo, ServerResponse serverResponse,
Exception exception) { Exception exception) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(PixelfedComposeActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
if (attachments.size() == 0) { if (attachments.size() == 0) {
pickup_picture.setVisibility(View.VISIBLE); pickup_picture.setVisibility(View.VISIBLE);
imageSlider.setVisibility(View.GONE); imageSlider.setVisibility(View.GONE);
@ -1144,7 +1144,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
if (extras != null && extras.getString("imageUri") != null) { if (extras != null && extras.getString("imageUri") != null) {
Uri imageUri = Uri.parse(extras.getString("imageUri")); Uri imageUri = Uri.parse(extras.getString("imageUri"));
if (imageUri == null) { if (imageUri == null) {
Toasty.error(getApplicationContext(), getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show(); Toasty.error(PixelfedComposeActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
return; return;
} }
String filename = Helper.getFileName(PixelfedComposeActivity.this, imageUri); String filename = Helper.getFileName(PixelfedComposeActivity.this, imageUri);
@ -1179,7 +1179,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
return true; return true;
case R.id.action_schedule: case R.id.action_schedule:
if (toot_content.getText().toString().trim().length() == 0) { if (toot_content.getText().toString().trim().length() == 0) {
Toasty.error(getApplicationContext(), getString(R.string.toot_error_no_content), Toast.LENGTH_LONG).show(); Toasty.error(PixelfedComposeActivity.this, getString(R.string.toot_error_no_content), Toast.LENGTH_LONG).show();
return true; return true;
} }
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(PixelfedComposeActivity.this, style); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(PixelfedComposeActivity.this, style);
@ -1190,7 +1190,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
final DatePicker datePicker = dialogView.findViewById(R.id.date_picker); final DatePicker datePicker = dialogView.findViewById(R.id.date_picker);
final TimePicker timePicker = dialogView.findViewById(R.id.time_picker); final TimePicker timePicker = dialogView.findViewById(R.id.time_picker);
if (android.text.format.DateFormat.is24HourFormat(getApplicationContext())) if (android.text.format.DateFormat.is24HourFormat(PixelfedComposeActivity.this))
timePicker.setIs24HourView(true); timePicker.setIs24HourView(true);
Button date_time_cancel = dialogView.findViewById(R.id.date_time_cancel); Button date_time_cancel = dialogView.findViewById(R.id.date_time_cancel);
final ImageButton date_time_previous = dialogView.findViewById(R.id.date_time_previous); final ImageButton date_time_previous = dialogView.findViewById(R.id.date_time_previous);
@ -1243,7 +1243,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
final long[] time = {calendar.getTimeInMillis()}; final long[] time = {calendar.getTimeInMillis()};
if ((time[0] - new Date().getTime()) < 60000) { if ((time[0] - new Date().getTime()) < 60000) {
Toasty.warning(getApplicationContext(), getString(R.string.toot_scheduled_date), Toast.LENGTH_LONG).show(); Toasty.warning(PixelfedComposeActivity.this, getString(R.string.toot_scheduled_date), Toast.LENGTH_LONG).show();
} else { } else {
AlertDialog.Builder builderSingle = new AlertDialog.Builder(PixelfedComposeActivity.this, style); AlertDialog.Builder builderSingle = new AlertDialog.Builder(PixelfedComposeActivity.this, style);
builderSingle.setTitle(getString(R.string.choose_schedule)); builderSingle.setTitle(getString(R.string.choose_schedule));
@ -1279,7 +1279,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
private void sendToot(String timestamp) { private void sendToot(String timestamp) {
toot_it.setEnabled(false); toot_it.setEnabled(false);
if (toot_content.getText().toString().trim().length() == 0 && attachments.size() == 0) { if (toot_content.getText().toString().trim().length() == 0 && attachments.size() == 0) {
Toasty.error(getApplicationContext(), getString(R.string.toot_error_no_content), Toast.LENGTH_LONG).show(); Toasty.error(PixelfedComposeActivity.this, getString(R.string.toot_error_no_content), Toast.LENGTH_LONG).show();
toot_it.setEnabled(true); toot_it.setEnabled(true);
return; return;
} }
@ -1294,17 +1294,17 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
toot.setContent(PixelfedComposeActivity.this, tootContent); toot.setContent(PixelfedComposeActivity.this, tootContent);
if (timestamp == null) if (timestamp == null)
if (scheduledstatus == null) if (scheduledstatus == null)
new PostStatusAsyncTask(getApplicationContext(), social, account, toot, PixelfedComposeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostStatusAsyncTask(PixelfedComposeActivity.this, social, account, toot, PixelfedComposeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else { else {
toot.setScheduled_at(Helper.dateToString(scheduledstatus.getScheduled_date())); toot.setScheduled_at(Helper.dateToString(scheduledstatus.getScheduled_date()));
scheduledstatus.setStatus(toot); scheduledstatus.setStatus(toot);
isScheduled = true; isScheduled = true;
new PostActionAsyncTask(getApplicationContext(), API.StatusAction.DELETESCHEDULED, scheduledstatus, PixelfedComposeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostActionAsyncTask(PixelfedComposeActivity.this, API.StatusAction.DELETESCHEDULED, scheduledstatus, PixelfedComposeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new PostStatusAsyncTask(getApplicationContext(), social, account, toot, PixelfedComposeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostStatusAsyncTask(PixelfedComposeActivity.this, social, account, toot, PixelfedComposeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
else { else {
toot.setScheduled_at(timestamp); toot.setScheduled_at(timestamp);
new PostStatusAsyncTask(getApplicationContext(), social, account, toot, PixelfedComposeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostStatusAsyncTask(PixelfedComposeActivity.this, social, account, toot, PixelfedComposeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
} }
@ -1321,7 +1321,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
storeToot(false, false); storeToot(false, false);
isScheduled = true; isScheduled = true;
//Schedules the toot //Schedules the toot
ScheduledTootsSyncJob.schedule(getApplicationContext(), currentToId, time); ScheduledTootsSyncJob.schedule(PixelfedComposeActivity.this, currentToId, time);
resetForNextToot(); resetForNextToot();
} }
@ -1344,7 +1344,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
isSensitive = false; isSensitive = false;
toot_sensitive.setVisibility(View.GONE); toot_sensitive.setVisibility(View.GONE);
currentToId = -1; currentToId = -1;
Toasty.info(getApplicationContext(), getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show(); Toasty.info(PixelfedComposeActivity.this, getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show();
} }
@Override @Override
@ -1533,11 +1533,11 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
if (apiResponse.getError() == null || apiResponse.getError().getStatusCode() != -33) { if (apiResponse.getError() == null || apiResponse.getError().getStatusCode() != -33) {
if (restored != -1) { if (restored != -1) {
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(PixelfedComposeActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
new StatusStoredDAO(getApplicationContext(), db).remove(restored); new StatusStoredDAO(PixelfedComposeActivity.this, db).remove(restored);
} else if (currentToId != -1) { } else if (currentToId != -1) {
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(PixelfedComposeActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
new StatusStoredDAO(getApplicationContext(), db).remove(currentToId); new StatusStoredDAO(PixelfedComposeActivity.this, db).remove(currentToId);
} }
} }
//Clear the toot //Clear the toot
@ -1561,17 +1561,17 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
if (scheduledstatus == null && !isScheduled) { if (scheduledstatus == null && !isScheduled) {
boolean display_confirm = sharedpreferences.getBoolean(Helper.SET_DISPLAY_CONFIRM, true); boolean display_confirm = sharedpreferences.getBoolean(Helper.SET_DISPLAY_CONFIRM, true);
if (display_confirm) { if (display_confirm) {
Toasty.success(getApplicationContext(), getString(R.string.toot_sent), Toast.LENGTH_LONG).show(); Toasty.success(PixelfedComposeActivity.this, getString(R.string.toot_sent), Toast.LENGTH_LONG).show();
} }
} else } else
Toasty.success(getApplicationContext(), getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show(); Toasty.success(PixelfedComposeActivity.this, getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show();
} else { } else {
if (apiResponse.getError().getStatusCode() == -33) if (apiResponse.getError().getStatusCode() == -33)
Toasty.info(getApplicationContext(), getString(R.string.toast_toot_saved_error), Toast.LENGTH_LONG).show(); Toasty.info(PixelfedComposeActivity.this, getString(R.string.toast_toot_saved_error), Toast.LENGTH_LONG).show();
} }
toot_it.setEnabled(true); toot_it.setEnabled(true);
//It's a reply, so the user will be redirect to its answer //It's a reply, so the user will be redirect to its answer
Intent intent = new Intent(getApplicationContext(), MainActivity.class); Intent intent = new Intent(PixelfedComposeActivity.this, MainActivity.class);
intent.putExtra(Helper.INTENT_ACTION, Helper.HOME_TIMELINE_INTENT); intent.putExtra(Helper.INTENT_ACTION, Helper.HOME_TIMELINE_INTENT);
startActivity(intent); startActivity(intent);
finish(); finish();
@ -1764,7 +1764,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
} }
private void restoreToot(long id) { private void restoreToot(long id) {
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(PixelfedComposeActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
StoredStatus draft = new StatusStoredDAO(PixelfedComposeActivity.this, db).getStatus(id); StoredStatus draft = new StatusStoredDAO(PixelfedComposeActivity.this, db).getStatus(id);
if (draft == null) if (draft == null)
return; return;
@ -1890,12 +1890,12 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
String url = attachment.getPreview_url(); String url = attachment.getPreview_url();
if (url == null || url.trim().equals("")) if (url == null || url.trim().equals(""))
url = attachment.getUrl(); url = attachment.getUrl();
final ImageView imageView = new ImageView(getApplicationContext()); final ImageView imageView = new ImageView(PixelfedComposeActivity.this);
imageView.setId(Integer.parseInt(attachment.getId())); imageView.setId(Integer.parseInt(attachment.getId()));
LinearLayout.LayoutParams imParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); LinearLayout.LayoutParams imParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
imParams.setMargins(20, 5, 20, 5); imParams.setMargins(20, 5, 20, 5);
imParams.height = (int) Helper.convertDpToPixel(100, getApplicationContext()); imParams.height = (int) Helper.convertDpToPixel(100, PixelfedComposeActivity.this);
imageView.setAdjustViewBounds(true); imageView.setAdjustViewBounds(true);
imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setScaleType(ImageView.ScaleType.FIT_XY);
@ -1983,7 +1983,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
toot.setContent(PixelfedComposeActivity.this, currentContent); toot.setContent(PixelfedComposeActivity.this, currentContent);
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(PixelfedComposeActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
try { try {
if (currentToId == -1) { if (currentToId == -1) {
currentToId = new StatusStoredDAO(PixelfedComposeActivity.this, db).insertStatus(toot, null); currentToId = new StatusStoredDAO(PixelfedComposeActivity.this, db).insertStatus(toot, null);
@ -1997,10 +1997,10 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
} }
} }
if (message) if (message)
Toasty.success(getApplicationContext(), getString(R.string.toast_toot_saved), Toast.LENGTH_LONG).show(); Toasty.success(PixelfedComposeActivity.this, getString(R.string.toast_toot_saved), Toast.LENGTH_LONG).show();
} catch (Exception e) { } catch (Exception e) {
if (message) if (message)
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(PixelfedComposeActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
} }
} }

View File

@ -96,7 +96,7 @@ public class PlaylistsActivity extends BaseActivity implements OnPlaylistActionI
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(PlaylistsActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(PlaylistsActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(PlaylistsActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
@ -152,7 +152,7 @@ public class PlaylistsActivity extends BaseActivity implements OnPlaylistActionI
if (b != null) { if (b != null) {
playlist = b.getParcelable("playlist"); playlist = b.getParcelable("playlist");
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.toast_error_search), Toast.LENGTH_LONG).show(); Toasty.error(PlaylistsActivity.this, getString(R.string.toast_error_search), Toast.LENGTH_LONG).show();
return; return;
} }
if (getSupportActionBar() != null) if (getSupportActionBar() != null)
@ -217,7 +217,7 @@ public class PlaylistsActivity extends BaseActivity implements OnPlaylistActionI
//Discards 404 - error which can often happen due to toots which have been deleted //Discards 404 - error which can often happen due to toots which have been deleted
if (apiResponse.getError() != null) { if (apiResponse.getError() != null) {
if (!apiResponse.getError().getError().startsWith("404 -") && !apiResponse.getError().getError().startsWith("501 -")) if (!apiResponse.getError().getError().startsWith("404 -") && !apiResponse.getError().getError().startsWith("501 -"))
Toasty.error(getApplicationContext(), apiResponse.getError().getError(), Toast.LENGTH_LONG).show(); Toasty.error(PlaylistsActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
swipeRefreshLayout.setRefreshing(false); swipeRefreshLayout.setRefreshing(false);
swiped = false; swiped = false;
flag_loading = false; flag_loading = false;

View File

@ -61,7 +61,7 @@ public class PrivacyActivity extends BaseActivity {
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(PrivacyActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(PrivacyActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(PrivacyActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);

View File

@ -131,7 +131,7 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.simple_bar_add, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.simple_bar_add, new LinearLayout(ReorderTimelinesActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(ReorderTimelinesActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(ReorderTimelinesActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
@ -171,7 +171,7 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
dialogBuilder.setPositiveButton(R.string.validate, new DialogInterface.OnClickListener() { dialogBuilder.setPositiveButton(R.string.validate, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(ReorderTimelinesActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
String instanceName = instance_list.getText().toString().trim().replace("@", ""); String instanceName = instance_list.getText().toString().trim().replace("@", "");
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
@ -223,7 +223,7 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
e.printStackTrace(); e.printStackTrace();
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
Toasty.warning(getApplicationContext(), getString(R.string.toast_instance_unavailable), Toast.LENGTH_LONG).show(); Toasty.warning(ReorderTimelinesActivity.this, getString(R.string.toast_instance_unavailable), Toast.LENGTH_LONG).show();
} }
}); });
} }
@ -353,8 +353,8 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
updated = false; updated = false;
RecyclerView lv_reorder_tabs = findViewById(R.id.lv_reorder_tabs); RecyclerView lv_reorder_tabs = findViewById(R.id.lv_reorder_tabs);
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(ReorderTimelinesActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
timelines = new TimelinesDAO(getApplicationContext(), db).getAllTimelines(); timelines = new TimelinesDAO(ReorderTimelinesActivity.this, db).getAllTimelines();
adapter = new ReorderTabAdapter(timelines, ReorderTimelinesActivity.this, ReorderTimelinesActivity.this); adapter = new ReorderTabAdapter(timelines, ReorderTimelinesActivity.this, ReorderTimelinesActivity.this);
ItemTouchHelper.Callback callback = ItemTouchHelper.Callback callback =
@ -365,7 +365,7 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
undo_action = findViewById(R.id.undo_action); undo_action = findViewById(R.id.undo_action);
undo_container = findViewById(R.id.undo_container); undo_container = findViewById(R.id.undo_container);
lv_reorder_tabs.setAdapter(adapter); lv_reorder_tabs.setAdapter(adapter);
LinearLayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext()); LinearLayoutManager mLayoutManager = new LinearLayoutManager(ReorderTimelinesActivity.this);
lv_reorder_tabs.setLayoutManager(mLayoutManager); lv_reorder_tabs.setLayoutManager(mLayoutManager);
} }
@ -394,20 +394,20 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
@Override @Override
public void run() { public void run() {
undo_container.setVisibility(View.GONE); undo_container.setVisibility(View.GONE);
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(ReorderTimelinesActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
switch (manageTimelines.getType()) { switch (manageTimelines.getType()) {
case TAG: case TAG:
new SearchDAO(getApplicationContext(), db).remove(manageTimelines.getTagTimeline().getName()); new SearchDAO(ReorderTimelinesActivity.this, db).remove(manageTimelines.getTagTimeline().getName());
new TimelinesDAO(getApplicationContext(), db).remove(manageTimelines); new TimelinesDAO(ReorderTimelinesActivity.this, db).remove(manageTimelines);
break; break;
case INSTANCE: case INSTANCE:
new InstancesDAO(getApplicationContext(), db).remove(manageTimelines.getRemoteInstance().getHost()); new InstancesDAO(ReorderTimelinesActivity.this, db).remove(manageTimelines.getRemoteInstance().getHost());
new TimelinesDAO(getApplicationContext(), db).remove(manageTimelines); new TimelinesDAO(ReorderTimelinesActivity.this, db).remove(manageTimelines);
break; break;
case LIST: case LIST:
timeline = manageTimelines; timeline = manageTimelines;
new ManageListsAsyncTask(getApplicationContext(), ManageListsAsyncTask.action.DELETE_LIST, null, null, manageTimelines.getListTimeline().getId(), null, ReorderTimelinesActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new ManageListsAsyncTask(ReorderTimelinesActivity.this, ManageListsAsyncTask.action.DELETE_LIST, null, null, manageTimelines.getListTimeline().getId(), null, ReorderTimelinesActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new TimelinesDAO(getApplicationContext(), db).remove(timeline); new TimelinesDAO(ReorderTimelinesActivity.this, db).remove(timeline);
refresh_list = true; refresh_list = true;
break; break;
} }

View File

@ -88,11 +88,11 @@ public class SearchResultActivity extends BaseActivity implements OnRetrieveSear
if (b != null) { if (b != null) {
search = b.getString("search"); search = b.getString("search");
if (search != null) if (search != null)
new RetrieveSearchAsyncTask(getApplicationContext(), search.trim(), SearchResultActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveSearchAsyncTask(SearchResultActivity.this, search.trim(), SearchResultActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else else
Toasty.error(getApplicationContext(), getString(R.string.toast_error_search), Toast.LENGTH_LONG).show(); Toasty.error(SearchResultActivity.this, getString(R.string.toast_error_search), Toast.LENGTH_LONG).show();
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.toast_error_search), Toast.LENGTH_LONG).show(); Toasty.error(SearchResultActivity.this, getString(R.string.toast_error_search), Toast.LENGTH_LONG).show();
} }
if (search.compareTo("fedilab_trend") == 0) { if (search.compareTo("fedilab_trend") == 0) {
forTrends = true; forTrends = true;
@ -103,7 +103,7 @@ public class SearchResultActivity extends BaseActivity implements OnRetrieveSear
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(SearchResultActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(SearchResultActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(SearchResultActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
@ -150,12 +150,12 @@ public class SearchResultActivity extends BaseActivity implements OnRetrieveSear
if (apiResponse.getError() != null) { if (apiResponse.getError() != null) {
if (apiResponse.getError().getError() != null) { if (apiResponse.getError().getError() != null) {
if (apiResponse.getError().getError().length() < 100) { if (apiResponse.getError().getError().length() < 100) {
Toasty.error(getApplicationContext(), apiResponse.getError().getError(), Toast.LENGTH_LONG).show(); Toasty.error(SearchResultActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.long_api_error, "\ud83d\ude05"), Toast.LENGTH_LONG).show(); Toasty.error(SearchResultActivity.this, getString(R.string.long_api_error, "\ud83d\ude05"), Toast.LENGTH_LONG).show();
} }
} else } else
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(SearchResultActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
return; return;
} }
lv_search.setVisibility(View.VISIBLE); lv_search.setVisibility(View.VISIBLE);
@ -191,9 +191,9 @@ public class SearchResultActivity extends BaseActivity implements OnRetrieveSear
loader.setVisibility(View.GONE); loader.setVisibility(View.GONE);
if (apiResponse.getError() != null) { if (apiResponse.getError() != null) {
if (error.getError().length() < 100) { if (error.getError().length() < 100) {
Toasty.error(getApplicationContext(), error.getError(), Toast.LENGTH_LONG).show(); Toasty.error(SearchResultActivity.this, error.getError(), Toast.LENGTH_LONG).show();
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.long_api_error, "\ud83d\ude05"), Toast.LENGTH_LONG).show(); Toasty.error(SearchResultActivity.this, getString(R.string.long_api_error, "\ud83d\ude05"), Toast.LENGTH_LONG).show();
} }
return; return;
} }

View File

@ -89,9 +89,9 @@ public class SearchResultTabActivity extends BaseActivity {
if (b != null) { if (b != null) {
search = b.getString("search"); search = b.getString("search");
if (search == null) if (search == null)
Toasty.error(getApplicationContext(), getString(R.string.toast_error_search), Toast.LENGTH_LONG).show(); Toasty.error(SearchResultTabActivity.this, getString(R.string.toast_error_search), Toast.LENGTH_LONG).show();
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.toast_error_search), Toast.LENGTH_LONG).show(); Toasty.error(SearchResultTabActivity.this, getString(R.string.toast_error_search), Toast.LENGTH_LONG).show();
} }
if (search == null) if (search == null)
finish(); finish();
@ -107,7 +107,7 @@ public class SearchResultTabActivity extends BaseActivity {
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.simple_bar_search, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.simple_bar_search, new LinearLayout(SearchResultTabActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(SearchResultTabActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(SearchResultTabActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
@ -142,6 +142,7 @@ public class SearchResultTabActivity extends BaseActivity {
toolbar_search.setIconified(true); toolbar_search.setIconified(true);
return false; return false;
} }
@Override @Override
public boolean onQueryTextChange(String newText) { public boolean onQueryTextChange(String newText) {
return false; return false;
@ -163,14 +164,17 @@ public class SearchResultTabActivity extends BaseActivity {
@Override @Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
} }
@Override @Override
public void onPageSelected(int position) { public void onPageSelected(int position) {
TabLayout.Tab tab = tabLayout.getTabAt(position); TabLayout.Tab tab = tabLayout.getTabAt(position);
if (tab != null) if (tab != null)
tab.select(); tab.select();
} }
@Override @Override
public void onPageScrollStateChanged(int state) {} public void onPageScrollStateChanged(int state) {
}
}); });
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {

View File

@ -80,7 +80,7 @@ public class SettingsActivity extends BaseActivity {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(SettingsActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(SettingsActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(SettingsActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
@ -158,9 +158,9 @@ public class SettingsActivity extends BaseActivity {
dialogBuilder.setMessage(R.string.restart_message); dialogBuilder.setMessage(R.string.restart_message);
dialogBuilder.setTitle(R.string.apply_changes); dialogBuilder.setTitle(R.string.apply_changes);
dialogBuilder.setPositiveButton(R.string.restart, (dialog, id) -> { dialogBuilder.setPositiveButton(R.string.restart, (dialog, id) -> {
Intent mStartActivity = new Intent(getApplicationContext(), MainActivity.class); Intent mStartActivity = new Intent(SettingsActivity.this, MainActivity.class);
int mPendingIntentId = 123456; int mPendingIntentId = 123456;
PendingIntent mPendingIntent = PendingIntent.getActivity(getApplicationContext(), mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT); PendingIntent mPendingIntent = PendingIntent.getActivity(SettingsActivity.this, mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager mgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE); AlarmManager mgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
assert mgr != null; assert mgr != null;
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent); mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent);

View File

@ -204,18 +204,18 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
ischannel = b.getBoolean("ischannel", false); ischannel = b.getBoolean("ischannel", false);
peertubeAccount = b.getBoolean("peertubeaccount", false); peertubeAccount = b.getBoolean("peertubeaccount", false);
if (account == null) { if (account == null) {
accountAsync = new RetrieveAccountAsyncTask(getApplicationContext(), accountId, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); accountAsync = new RetrieveAccountAsyncTask(ShowAccountActivity.this, accountId, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.toast_error_loading_account), Toast.LENGTH_LONG).show(); Toasty.error(ShowAccountActivity.this, getString(R.string.toast_error_loading_account), Toast.LENGTH_LONG).show();
} }
accountUrl = null; accountUrl = null;
show_boosts = sharedpreferences.getBoolean(Helper.SHOW_ACCOUNT_BOOSTS, true); show_boosts = sharedpreferences.getBoolean(Helper.SHOW_ACCOUNT_BOOSTS, true);
show_replies = sharedpreferences.getBoolean(Helper.SHOW_ACCOUNT_REPLIES, true); show_replies = sharedpreferences.getBoolean(Helper.SHOW_ACCOUNT_REPLIES, true);
statuses = new ArrayList<>(); statuses = new ArrayList<>();
boolean isOnWifi = Helper.isOnWIFI(getApplicationContext()); boolean isOnWifi = Helper.isOnWIFI(ShowAccountActivity.this);
StatusDrawerParams statusDrawerParams = new StatusDrawerParams(); StatusDrawerParams statusDrawerParams = new StatusDrawerParams();
statusDrawerParams.setType(RetrieveFeedsAsyncTask.Type.USER); statusDrawerParams.setType(RetrieveFeedsAsyncTask.Type.USER);
statusDrawerParams.setTargetedId(accountId); statusDrawerParams.setTargetedId(accountId);
@ -295,7 +295,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) { if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
accountIdRelation = account.getAcct(); accountIdRelation = account.getAcct();
} }
retrieveRelationship = new RetrieveRelationshipAsyncTask(getApplicationContext(), accountIdRelation, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); retrieveRelationship = new RetrieveRelationshipAsyncTask(ShowAccountActivity.this, accountIdRelation, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
if (account.getId() != null && account.getId().equals(userId) && (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED)) { if (account.getId() != null && account.getId().equals(userId) && (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED)) {
account_follow.setVisibility(View.GONE); account_follow.setVisibility(View.GONE);
@ -352,7 +352,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
actionbar_title.setText(account.getAcct()); actionbar_title.setText(account.getAcct());
ImageView pp_actionBar = findViewById(R.id.pp_actionBar); ImageView pp_actionBar = findViewById(R.id.pp_actionBar);
if (account.getAvatar() != null) { if (account.getAvatar() != null) {
Helper.loadGiF(getApplicationContext(), account, pp_actionBar); Helper.loadGiF(ShowAccountActivity.this, account, pp_actionBar);
} }
final AppBarLayout appBar = findViewById(R.id.appBar); final AppBarLayout appBar = findViewById(R.id.appBar);
@ -372,11 +372,11 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
//Timed muted account //Timed muted account
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null); String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
final SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); final SQLiteDatabase db = Sqlite.getInstance(ShowAccountActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
final Account authenticatedAccount = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance); final Account authenticatedAccount = new AccountDAO(ShowAccountActivity.this, db).getUniqAccount(userId, instance);
boolean isTimedMute = new TempMuteDAO(getApplicationContext(), db).isTempMuted(authenticatedAccount, accountId); boolean isTimedMute = new TempMuteDAO(ShowAccountActivity.this, db).isTempMuted(authenticatedAccount, accountId);
if (isTimedMute) { if (isTimedMute) {
String date_mute = new TempMuteDAO(getApplicationContext(), db).getMuteDateByID(authenticatedAccount, accountId); String date_mute = new TempMuteDAO(ShowAccountActivity.this, db).getMuteDateByID(authenticatedAccount, accountId);
if (date_mute != null) { if (date_mute != null) {
final TextView temp_mute = findViewById(R.id.temp_mute); final TextView temp_mute = findViewById(R.id.temp_mute);
temp_mute.setVisibility(View.VISIBLE); temp_mute.setVisibility(View.VISIBLE);
@ -384,9 +384,9 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
content_temp_mute.setSpan(new UnderlineSpan(), 0, content_temp_mute.length(), 0); content_temp_mute.setSpan(new UnderlineSpan(), 0, content_temp_mute.length(), 0);
temp_mute.setText(content_temp_mute); temp_mute.setText(content_temp_mute);
temp_mute.setOnClickListener(view -> { temp_mute.setOnClickListener(view -> {
new TempMuteDAO(getApplicationContext(), db).remove(authenticatedAccount, accountId); new TempMuteDAO(ShowAccountActivity.this, db).remove(authenticatedAccount, accountId);
mutedAccount.remove(accountId); mutedAccount.remove(accountId);
Toasty.success(getApplicationContext(), getString(R.string.toast_unmute), Toast.LENGTH_LONG).show(); Toasty.success(ShowAccountActivity.this, getString(R.string.toast_unmute), Toast.LENGTH_LONG).show();
temp_mute.setVisibility(View.GONE); temp_mute.setVisibility(View.GONE);
}); });
} }
@ -599,9 +599,9 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
String account_id = account.getAcct(); String account_id = account.getAcct();
if (account_id.split("@").length == 1) if (account_id.split("@").length == 1)
account_id += "@" + Helper.getLiveInstance(getApplicationContext()); account_id += "@" + Helper.getLiveInstance(ShowAccountActivity.this);
ClipData clip = ClipData.newPlainText("mastodon_account_id", "@" + account_id); ClipData clip = ClipData.newPlainText("mastodon_account_id", "@" + account_id);
Toasty.info(getApplicationContext(), getString(R.string.account_id_clipbloard), Toast.LENGTH_SHORT).show(); Toasty.info(ShowAccountActivity.this, getString(R.string.account_id_clipbloard), Toast.LENGTH_SHORT).show();
assert clipboard != null; assert clipboard != null;
clipboard.setPrimaryClip(clip); clipboard.setPrimaryClip(clip);
return false; return false;
@ -668,7 +668,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
}); });
popup.setOnMenuItemClickListener(item -> { popup.setOnMenuItemClickListener(item -> {
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
item.setActionView(new View(getApplicationContext())); item.setActionView(new View(ShowAccountActivity.this));
item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() { item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
@Override @Override
public boolean onMenuItemActionExpand(MenuItem item) { public boolean onMenuItemActionExpand(MenuItem item) {
@ -717,7 +717,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
} }
Helper.loadGiF(getApplicationContext(), account, account_pp); Helper.loadGiF(ShowAccountActivity.this, account, account_pp);
account_pp.setOnClickListener(v -> { account_pp.setOnClickListener(v -> {
Intent intent = new Intent(ShowAccountActivity.this, SlideMediaActivity.class); Intent intent = new Intent(ShowAccountActivity.this, SlideMediaActivity.class);
Bundle b = new Bundle(); Bundle b = new Bundle();
@ -741,10 +741,10 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
String finalTarget = target; String finalTarget = target;
account_follow.setOnClickListener(v -> { account_follow.setOnClickListener(v -> {
if (doAction == action.NOTHING) { if (doAction == action.NOTHING) {
Toasty.info(getApplicationContext(), getString(R.string.nothing_to_do), Toast.LENGTH_LONG).show(); Toasty.info(ShowAccountActivity.this, getString(R.string.nothing_to_do), Toast.LENGTH_LONG).show();
} else if (doAction == action.FOLLOW) { } else if (doAction == action.FOLLOW) {
account_follow.setEnabled(false); account_follow.setEnabled(false);
new PostActionAsyncTask(getApplicationContext(), API.StatusAction.FOLLOW, finalTarget, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.FOLLOW, finalTarget, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else if (doAction == action.UNFOLLOW) { } else if (doAction == action.UNFOLLOW) {
boolean confirm_unfollow = sharedpreferences.getBoolean(Helper.SET_UNFOLLOW_VALIDATION, true); boolean confirm_unfollow = sharedpreferences.getBoolean(Helper.SET_UNFOLLOW_VALIDATION, true);
if (confirm_unfollow) { if (confirm_unfollow) {
@ -754,18 +754,18 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
unfollowConfirm.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss()); unfollowConfirm.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
unfollowConfirm.setPositiveButton(R.string.yes, (dialog, which) -> { unfollowConfirm.setPositiveButton(R.string.yes, (dialog, which) -> {
account_follow.setEnabled(false); account_follow.setEnabled(false);
new PostActionAsyncTask(getApplicationContext(), API.StatusAction.UNFOLLOW, finalTarget, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.UNFOLLOW, finalTarget, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
dialog.dismiss(); dialog.dismiss();
}); });
unfollowConfirm.show(); unfollowConfirm.show();
} else { } else {
account_follow.setEnabled(false); account_follow.setEnabled(false);
new PostActionAsyncTask(getApplicationContext(), API.StatusAction.UNFOLLOW, finalTarget, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.UNFOLLOW, finalTarget, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
} else if (doAction == action.UNBLOCK) { } else if (doAction == action.UNBLOCK) {
account_follow.setEnabled(false); account_follow.setEnabled(false);
new PostActionAsyncTask(getApplicationContext(), API.StatusAction.UNBLOCK, finalTarget, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.UNBLOCK, finalTarget, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
}); });
account_follow.setOnLongClickListener(v -> { account_follow.setOnLongClickListener(v -> {
@ -773,7 +773,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
return false; return false;
}); });
UserNote userNote = new NotesDAO(getApplicationContext(), db).getUserNote(account.getAcct()); UserNote userNote = new NotesDAO(ShowAccountActivity.this, db).getUserNote(account.getAcct());
if (userNote != null) { if (userNote != null) {
account_personal_note.setVisibility(View.VISIBLE); account_personal_note.setVisibility(View.VISIBLE);
@ -791,13 +791,13 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
builderInner.setView(input); builderInner.setView(input);
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss()); builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
builderInner.setPositiveButton(R.string.validate, (dialog, which) -> { builderInner.setPositiveButton(R.string.validate, (dialog, which) -> {
UserNote userNote1 = new NotesDAO(getApplicationContext(), db).getUserNote(account.getAcct()); UserNote userNote1 = new NotesDAO(ShowAccountActivity.this, db).getUserNote(account.getAcct());
if (userNote1 == null) { if (userNote1 == null) {
userNote1 = new UserNote(); userNote1 = new UserNote();
userNote1.setAcct(account.getAcct()); userNote1.setAcct(account.getAcct());
} }
userNote1.setNote(input.getText().toString()); userNote1.setNote(input.getText().toString());
new NotesDAO(getApplicationContext(), db).insertInstance(userNote1); new NotesDAO(ShowAccountActivity.this, db).insertInstance(userNote1);
if (input.getText().toString().trim().length() > 0) { if (input.getText().toString().trim().length() > 0) {
account_personal_note.setVisibility(View.VISIBLE); account_personal_note.setVisibility(View.VISIBLE);
} else { } else {
@ -814,7 +814,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
account_date.setVisibility(View.VISIBLE); account_date.setVisibility(View.VISIBLE);
new Thread(() -> { new Thread(() -> {
String instance1 = getLiveInstance(getApplicationContext()); String instance1 = getLiveInstance(ShowAccountActivity.this);
if (account.getAcct().split("@").length > 1) { if (account.getAcct().split("@").length > 1) {
instance1 = account.getAcct().split("@")[1]; instance1 = account.getAcct().split("@")[1];
} }
@ -827,7 +827,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
instance_info.setVisibility(View.VISIBLE); instance_info.setVisibility(View.VISIBLE);
instance_info.setOnClickListener(v -> { instance_info.setOnClickListener(v -> {
Intent intent = new Intent(getApplicationContext(), InstanceProfileActivity.class); Intent intent = new Intent(ShowAccountActivity.this, InstanceProfileActivity.class);
Bundle b = new Bundle(); Bundle b = new Bundle();
b.putString("instance", finalInstance); b.putString("instance", finalInstance);
intent.putExtras(b); intent.putExtras(b);
@ -852,7 +852,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
@Override @Override
public void onRetrieveFeeds(APIResponse apiResponse) { public void onRetrieveFeeds(APIResponse apiResponse) {
if (apiResponse.getError() != null) { if (apiResponse.getError() != null) {
Toasty.error(getApplicationContext(), apiResponse.getError().getError(), Toast.LENGTH_LONG).show(); Toasty.error(ShowAccountActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
return; return;
} }
pins = apiResponse.getStatuses(); pins = apiResponse.getStatuses();
@ -871,9 +871,9 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
if (error != null) { if (error != null) {
if (error.getError().length() < 100) { if (error.getError().length() < 100) {
Toasty.error(getApplicationContext(), error.getError(), Toast.LENGTH_LONG).show(); Toasty.error(ShowAccountActivity.this, error.getError(), Toast.LENGTH_LONG).show();
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.long_api_error, "\ud83d\ude05"), Toast.LENGTH_LONG).show(); Toasty.error(ShowAccountActivity.this, getString(R.string.long_api_error, "\ud83d\ude05"), Toast.LENGTH_LONG).show();
} }
return; return;
} }
@ -1104,14 +1104,14 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
} else { } else {
style = R.style.Dialog; style = R.style.Dialog;
} }
final SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); final SQLiteDatabase db = Sqlite.getInstance(ShowAccountActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.action_follow_instance: case R.id.action_follow_instance:
String finalInstanceName = splitAcct[1]; String finalInstanceName = splitAcct[1];
List<RemoteInstance> remoteInstances = new InstancesDAO(ShowAccountActivity.this, db).getInstanceByName(finalInstanceName); List<RemoteInstance> remoteInstances = new InstancesDAO(ShowAccountActivity.this, db).getInstanceByName(finalInstanceName);
if (remoteInstances != null && remoteInstances.size() > 0) { if (remoteInstances != null && remoteInstances.size() > 0) {
Toasty.info(getApplicationContext(), getString(R.string.toast_instance_already_added), Toast.LENGTH_LONG).show(); Toasty.info(ShowAccountActivity.this, getString(R.string.toast_instance_already_added), Toast.LENGTH_LONG).show();
Intent intent = new Intent(getApplicationContext(), MainActivity.class); Intent intent = new Intent(ShowAccountActivity.this, MainActivity.class);
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putInt(Helper.INTENT_ACTION, Helper.SEARCH_INSTANCE); bundle.putInt(Helper.INTENT_ACTION, Helper.SEARCH_INSTANCE);
bundle.putString(Helper.INSTANCE_NAME, finalInstanceName); bundle.putString(Helper.INSTANCE_NAME, finalInstanceName);
@ -1137,8 +1137,8 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
new InstancesDAO(ShowAccountActivity.this, db).insertInstance(finalInstanceName, "MASTODON"); new InstancesDAO(ShowAccountActivity.this, db).insertInstance(finalInstanceName, "MASTODON");
else else
new InstancesDAO(ShowAccountActivity.this, db).insertInstance(finalInstanceName, "PEERTUBE"); new InstancesDAO(ShowAccountActivity.this, db).insertInstance(finalInstanceName, "PEERTUBE");
Toasty.success(getApplicationContext(), getString(R.string.toast_instance_followed), Toast.LENGTH_LONG).show(); Toasty.success(ShowAccountActivity.this, getString(R.string.toast_instance_followed), Toast.LENGTH_LONG).show();
Intent intent = new Intent(getApplicationContext(), MainActivity.class); Intent intent = new Intent(ShowAccountActivity.this, MainActivity.class);
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putInt(Helper.INTENT_ACTION, Helper.SEARCH_INSTANCE); bundle.putInt(Helper.INTENT_ACTION, Helper.SEARCH_INSTANCE);
bundle.putString(Helper.INSTANCE_NAME, finalInstanceName); bundle.putString(Helper.INSTANCE_NAME, finalInstanceName);
@ -1147,7 +1147,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
}); });
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
runOnUiThread(() -> Toasty.warning(getApplicationContext(), getString(R.string.toast_instance_unavailable), Toast.LENGTH_LONG).show()); runOnUiThread(() -> Toasty.warning(ShowAccountActivity.this, getString(R.string.toast_instance_unavailable), Toast.LENGTH_LONG).show());
} }
}).start(); }).start();
return true; return true;
@ -1186,21 +1186,21 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
case R.id.action_endorse: case R.id.action_endorse:
if (relationship != null) if (relationship != null)
if (relationship.isEndorsed()) { if (relationship.isEndorsed()) {
new PostActionAsyncTask(getApplicationContext(), API.StatusAction.UNENDORSE, account.getId(), ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.UNENDORSE, account.getId(), ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else { } else {
new PostActionAsyncTask(getApplicationContext(), API.StatusAction.ENDORSE, account.getId(), ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.ENDORSE, account.getId(), ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
return true; return true;
case R.id.action_hide_boost: case R.id.action_hide_boost:
if (relationship != null) if (relationship != null)
if (relationship.isShowing_reblogs()) { if (relationship.isShowing_reblogs()) {
new PostActionAsyncTask(getApplicationContext(), API.StatusAction.HIDE_BOOST, account.getId(), ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.HIDE_BOOST, account.getId(), ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else { } else {
new PostActionAsyncTask(getApplicationContext(), API.StatusAction.SHOW_BOOST, account.getId(), ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.SHOW_BOOST, account.getId(), ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
return true; return true;
case R.id.action_direct_message: case R.id.action_direct_message:
Intent intent = new Intent(getApplicationContext(), TootActivity.class); Intent intent = new Intent(ShowAccountActivity.this, TootActivity.class);
Bundle b = new Bundle(); Bundle b = new Bundle();
b.putString("mentionAccount", account.getAcct()); b.putString("mentionAccount", account.getAcct());
b.putString("visibility", "direct"); b.putString("visibility", "direct");
@ -1218,7 +1218,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
} }
} }
if (!hasLists) { if (!hasLists) {
Toasty.info(getApplicationContext(), getString(R.string.action_lists_empty), Toast.LENGTH_SHORT).show(); Toasty.info(ShowAccountActivity.this, getString(R.string.action_lists_empty), Toast.LENGTH_SHORT).show();
return true; return true;
} }
AlertDialog.Builder builderSingle = new AlertDialog.Builder(ShowAccountActivity.this, style); AlertDialog.Builder builderSingle = new AlertDialog.Builder(ShowAccountActivity.this, style);
@ -1232,7 +1232,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
app.fedilab.android.client.Entities.List list = timeline.getListTimeline(); app.fedilab.android.client.Entities.List list = timeline.getListTimeline();
if (relationship == null || !relationship.isFollowing()) { if (relationship == null || !relationship.isFollowing()) {
addToList = list.getId(); addToList = list.getId();
new PostActionAsyncTask(getApplicationContext(), API.StatusAction.FOLLOW, account.getId(), ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.FOLLOW, account.getId(), ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else { } else {
new ManageListsAsyncTask(ShowAccountActivity.this, ManageListsAsyncTask.action.ADD_USERS, new String[]{account.getId()}, null, list.getId(), null, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new ManageListsAsyncTask(ShowAccountActivity.this, ManageListsAsyncTask.action.ADD_USERS, new String[]{account.getId()}, null, list.getId(), null, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
@ -1251,7 +1251,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
} }
return true; return true;
case R.id.action_mention: case R.id.action_mention:
intent = new Intent(getApplicationContext(), TootActivity.class); intent = new Intent(ShowAccountActivity.this, TootActivity.class);
b = new Bundle(); b = new Bundle();
b.putString("mentionAccount", account.getAcct()); b.putString("mentionAccount", account.getAcct());
intent.putExtras(b); intent.putExtras(b);
@ -1284,13 +1284,13 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
String comment = null; String comment = null;
if (input.getText() != null) if (input.getText() != null)
comment = input.getText().toString(); comment = input.getText().toString();
new PostActionAsyncTask(getApplicationContext(), doActionAccount, account.getId(), null, comment, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostActionAsyncTask(ShowAccountActivity.this, doActionAccount, account.getId(), null, comment, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
dialog.dismiss(); dialog.dismiss();
}); });
builderInner.show(); builderInner.show();
return true; return true;
case R.id.action_add_notes: case R.id.action_add_notes:
UserNote userNote = new NotesDAO(getApplicationContext(), db).getUserNote(account.getAcct()); UserNote userNote = new NotesDAO(ShowAccountActivity.this, db).getUserNote(account.getAcct());
builderInner = new AlertDialog.Builder(ShowAccountActivity.this, style); builderInner = new AlertDialog.Builder(ShowAccountActivity.this, style);
builderInner.setTitle(R.string.note_for_account); builderInner.setTitle(R.string.note_for_account);
input = new EditText(ShowAccountActivity.this); input = new EditText(ShowAccountActivity.this);
@ -1306,13 +1306,13 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
builderInner.setView(input); builderInner.setView(input);
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss()); builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
builderInner.setPositiveButton(R.string.validate, (dialog, which) -> { builderInner.setPositiveButton(R.string.validate, (dialog, which) -> {
UserNote userNote1 = new NotesDAO(getApplicationContext(), db).getUserNote(account.getAcct()); UserNote userNote1 = new NotesDAO(ShowAccountActivity.this, db).getUserNote(account.getAcct());
if (userNote1 == null) { if (userNote1 == null) {
userNote1 = new UserNote(); userNote1 = new UserNote();
userNote1.setAcct(account.getAcct()); userNote1.setAcct(account.getAcct());
} }
userNote1.setNote(input.getText().toString()); userNote1.setNote(input.getText().toString());
new NotesDAO(getApplicationContext(), db).insertInstance(userNote1); new NotesDAO(ShowAccountActivity.this, db).insertInstance(userNote1);
if (input.getText().toString().trim().length() > 0) { if (input.getText().toString().trim().length() > 0) {
account_personal_note.setVisibility(View.VISIBLE); account_personal_note.setVisibility(View.VISIBLE);
} else { } else {
@ -1344,7 +1344,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
} else { } else {
targetedId = account.getId(); targetedId = account.getId();
} }
new PostActionAsyncTask(getApplicationContext(), doActionAccount, targetedId, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostActionAsyncTask(ShowAccountActivity.this, doActionAccount, targetedId, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
dialog.dismiss(); dialog.dismiss();
}); });
builderInner.show(); builderInner.show();
@ -1377,16 +1377,16 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
if (error != null) { if (error != null) {
if (error.getError().length() < 100) { if (error.getError().length() < 100) {
Toasty.error(getApplicationContext(), error.getError(), Toast.LENGTH_LONG).show(); Toasty.error(ShowAccountActivity.this, error.getError(), Toast.LENGTH_LONG).show();
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.long_api_error, "\ud83d\ude05"), Toast.LENGTH_LONG).show(); Toasty.error(ShowAccountActivity.this, getString(R.string.long_api_error, "\ud83d\ude05"), Toast.LENGTH_LONG).show();
} }
return; return;
} }
if (addToList != null) { if (addToList != null) {
new ManageListsAsyncTask(ShowAccountActivity.this, ManageListsAsyncTask.action.ADD_USERS, new String[]{account.getId()}, null, addToList, null, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new ManageListsAsyncTask(ShowAccountActivity.this, ManageListsAsyncTask.action.ADD_USERS, new String[]{account.getId()}, null, addToList, null, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else { } else {
Helper.manageMessageStatusCode(getApplicationContext(), statusCode, statusAction); Helper.manageMessageStatusCode(ShowAccountActivity.this, statusCode, statusAction);
} }
String target = account.getId(); String target = account.getId();
//IF action is unfollow or mute, sends an intent to remove statuses //IF action is unfollow or mute, sends an intent to remove statuses
@ -1398,7 +1398,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
} }
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE)
target = account.getAcct(); target = account.getAcct();
retrieveRelationship = new RetrieveRelationshipAsyncTask(getApplicationContext(), target, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); retrieveRelationship = new RetrieveRelationshipAsyncTask(ShowAccountActivity.this, target, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
@Override @Override
@ -1406,11 +1406,11 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
if (error != null || account == null || account.getAcct() == null) { if (error != null || account == null || account.getAcct() == null) {
if (error == null) if (error == null)
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(ShowAccountActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
else if (error.getError().length() < 100) { else if (error.getError().length() < 100) {
Toasty.error(getApplicationContext(), error.getError(), Toast.LENGTH_LONG).show(); Toasty.error(ShowAccountActivity.this, error.getError(), Toast.LENGTH_LONG).show();
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.long_api_error, "\ud83d\ude05"), Toast.LENGTH_LONG).show(); Toasty.error(ShowAccountActivity.this, getString(R.string.long_api_error, "\ud83d\ude05"), Toast.LENGTH_LONG).show();
} }
return; return;
} }
@ -1422,13 +1422,14 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
public void onActionDone(ManageListsAsyncTask.action actionType, APIResponse apiResponse, int statusCode) { public void onActionDone(ManageListsAsyncTask.action actionType, APIResponse apiResponse, int statusCode) {
if (apiResponse.getError() != null) { if (apiResponse.getError() != null) {
if (!apiResponse.getError().getError().startsWith("404 -") && !apiResponse.getError().getError().startsWith("501 -")) if (!apiResponse.getError().getError().startsWith("404 -") && !apiResponse.getError().getError().startsWith("501 -"))
Toasty.error(getApplicationContext(), apiResponse.getError().getError(), Toast.LENGTH_LONG).show(); Toasty.error(ShowAccountActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
return; return;
} }
if (actionType == ManageListsAsyncTask.action.ADD_USERS) { if (actionType == ManageListsAsyncTask.action.ADD_USERS) {
Toasty.success(getApplicationContext(), getString(R.string.action_lists_add_user), Toast.LENGTH_LONG).show(); Toasty.success(ShowAccountActivity.this, getString(R.string.action_lists_add_user), Toast.LENGTH_LONG).show();
} }
} }
@Override @Override
public void onIdentityProof(APIResponse apiResponse) { public void onIdentityProof(APIResponse apiResponse) {
if (apiResponse == null) { if (apiResponse == null) {

View File

@ -112,7 +112,7 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) { if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
if (receive_action != null) if (receive_action != null)
LocalBroadcastManager.getInstance(getApplicationContext()).unregisterReceiver(receive_action); LocalBroadcastManager.getInstance(ShowConversationActivity.this).unregisterReceiver(receive_action);
receive_action = new BroadcastReceiver() { receive_action = new BroadcastReceiver() {
@Override @Override
public void onReceive(android.content.Context context, Intent intent) { public void onReceive(android.content.Context context, Intent intent) {
@ -124,7 +124,7 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
} }
} }
}; };
LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(receive_action, new IntentFilter(Helper.RECEIVE_ACTION)); LocalBroadcastManager.getInstance(ShowConversationActivity.this).registerReceiver(receive_action, new IntentFilter(Helper.RECEIVE_ACTION));
} }
Toolbar actionBar = findViewById(R.id.toolbar); Toolbar actionBar = findViewById(R.id.toolbar);
if (actionBar != null) { if (actionBar != null) {
@ -210,15 +210,15 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
} }
}); });
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(ShowConversationActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null); String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance); Account account = new AccountDAO(ShowConversationActivity.this, db).getUniqAccount(userId, instance);
if (account.getAvatar() == null) { if (account.getAvatar() == null) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(ShowConversationActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
finish(); finish();
} }
Helper.loadGiF(getApplicationContext(), account, pp_actionBar); Helper.loadGiF(ShowConversationActivity.this, account, pp_actionBar);
swipeRefreshLayout = findViewById(R.id.swipeContainer); swipeRefreshLayout = findViewById(R.id.swipeContainer);
@ -229,7 +229,7 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
swipeRefreshLayout.setColorSchemeColors( swipeRefreshLayout.setColorSchemeColors(
c1, c2, c1 c1, c2, c1
); );
boolean isOnWifi = Helper.isOnWIFI(getApplicationContext()); boolean isOnWifi = Helper.isOnWIFI(ShowConversationActivity.this);
if (initialStatus != null) if (initialStatus != null)
statuses.add(initialStatus); statuses.add(initialStatus);
else else
@ -257,7 +257,7 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
if (conversationId != null) if (conversationId != null)
statusIdToFetch = conversationId; statusIdToFetch = conversationId;
new RetrieveContextAsyncTask(getApplicationContext(), expanded, detailsStatus.getVisibility().equals("direct"), statusIdToFetch, ShowConversationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveContextAsyncTask(ShowConversationActivity.this, expanded, detailsStatus.getVisibility().equals("direct"), statusIdToFetch, ShowConversationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
swipeRefreshLayout.setDistanceToTriggerSync(500); swipeRefreshLayout.setDistanceToTriggerSync(500);
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override @Override
@ -306,7 +306,7 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
if (receive_action != null) if (receive_action != null)
LocalBroadcastManager.getInstance(getApplicationContext()).unregisterReceiver(receive_action); LocalBroadcastManager.getInstance(ShowConversationActivity.this).unregisterReceiver(receive_action);
} }
@Override @Override
@ -315,9 +315,9 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
loader.setVisibility(View.GONE); loader.setVisibility(View.GONE);
if (apiResponse.getError() != null) { if (apiResponse.getError() != null) {
if (apiResponse.getError().getError() != null) { if (apiResponse.getError().getError() != null) {
Toasty.error(getApplicationContext(), apiResponse.getError().getError(), Toast.LENGTH_LONG).show(); Toasty.error(ShowConversationActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(ShowConversationActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
} }
return; return;
} }
@ -365,7 +365,7 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
} }
i++; i++;
} }
boolean isOnWifi = Helper.isOnWIFI(getApplicationContext()); boolean isOnWifi = Helper.isOnWIFI(ShowConversationActivity.this);
for (Status status : apiResponse.getContext().getAncestors()) { for (Status status : apiResponse.getContext().getAncestors()) {
statuses.add(0, status); statuses.add(0, status);
} }

View File

@ -138,7 +138,7 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
//actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(SlideMediaActivity.this, R.color.cyanea_primary))); //actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(SlideMediaActivity.this, R.color.cyanea_primary)));
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.media_action_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.media_action_bar, new LinearLayout(SlideMediaActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(SlideMediaActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(SlideMediaActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);

View File

@ -698,7 +698,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext())); instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(TootActivity.this));
final int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); final int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
switch (theme) { switch (theme) {
case Helper.THEME_LIGHT: case Helper.THEME_LIGHT:
@ -727,7 +727,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.toot_action_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.toot_action_bar, new LinearLayout(TootActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(TootActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(TootActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
@ -803,13 +803,13 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
poll_action = findViewById(R.id.poll_action); poll_action = findViewById(R.id.poll_action);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(TootActivity.this);
int iconColor = prefs.getInt("theme_icons_color", -1); int iconColor = prefs.getInt("theme_icons_color", -1);
if (iconColor != -1) { if (iconColor != -1) {
Helper.changeDrawableColor(getApplicationContext(), toot_emoji, iconColor); Helper.changeDrawableColor(TootActivity.this, toot_emoji, iconColor);
Helper.changeDrawableColor(getApplicationContext(), toot_visibility, iconColor); Helper.changeDrawableColor(TootActivity.this, toot_visibility, iconColor);
Helper.changeDrawableColor(getApplicationContext(), poll_action, iconColor); Helper.changeDrawableColor(TootActivity.this, poll_action, iconColor);
Helper.changeDrawableColor(getApplicationContext(), toot_picture, iconColor); Helper.changeDrawableColor(TootActivity.this, toot_picture, iconColor);
} }
isScheduled = false; isScheduled = false;
@ -883,7 +883,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
pp_progress.setVisibility(View.VISIBLE); pp_progress.setVisibility(View.VISIBLE);
pp_actionBar.setVisibility(View.GONE); pp_actionBar.setVisibility(View.GONE);
} }
new RetrieveSearchAccountsAsyncTask(getApplicationContext(), search, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveSearchAccountsAsyncTask(TootActivity.this, search, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else { } else {
mt = tPattern.matcher(searchIn); mt = tPattern.matcher(searchIn);
if (mt.matches()) { if (mt.matches()) {
@ -925,22 +925,22 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
drawer_layout.getViewTreeObserver().addOnGlobalLayoutListener(() -> { drawer_layout.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
int heightDiff = drawer_layout.getRootView().getHeight() - drawer_layout.getHeight(); int heightDiff = drawer_layout.getRootView().getHeight() - drawer_layout.getHeight();
if (heightDiff > Helper.convertDpToPixel(200, getApplicationContext())) { if (heightDiff > Helper.convertDpToPixel(200, TootActivity.this)) {
ViewGroup.LayoutParams params = toot_picture_container.getLayoutParams(); ViewGroup.LayoutParams params = toot_picture_container.getLayoutParams();
params.height = (int) Helper.convertDpToPixel(50, getApplicationContext()); params.height = (int) Helper.convertDpToPixel(50, TootActivity.this);
params.width = (int) Helper.convertDpToPixel(50, getApplicationContext()); params.width = (int) Helper.convertDpToPixel(50, TootActivity.this);
toot_picture_container.setLayoutParams(params); toot_picture_container.setLayoutParams(params);
} else { } else {
ViewGroup.LayoutParams params = toot_picture_container.getLayoutParams(); ViewGroup.LayoutParams params = toot_picture_container.getLayoutParams();
params.height = (int) Helper.convertDpToPixel(100, getApplicationContext()); params.height = (int) Helper.convertDpToPixel(100, TootActivity.this);
params.width = (int) Helper.convertDpToPixel(100, getApplicationContext()); params.width = (int) Helper.convertDpToPixel(100, TootActivity.this);
toot_picture_container.setLayoutParams(params); toot_picture_container.setLayoutParams(params);
} }
}); });
Bundle b = getIntent().getExtras(); Bundle b = getIntent().getExtras();
ArrayList<Uri> sharedUri = new ArrayList<>(); ArrayList<Uri> sharedUri = new ArrayList<>();
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(TootActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
restored = -1; restored = -1;
if (b != null) { if (b != null) {
tootReply = b.getParcelable("tootReply"); tootReply = b.getParcelable("tootReply");
@ -950,7 +950,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (accountReplyToken != null) { if (accountReplyToken != null) {
String[] val = accountReplyToken.split("\\|"); String[] val = accountReplyToken.split("\\|");
if (val.length == 2) { if (val.length == 2) {
accountReply = new AccountDAO(getApplicationContext(), db).getUniqAccount(val[0], val[1]); accountReply = new AccountDAO(TootActivity.this, db).getUniqAccount(val[0], val[1]);
} }
} }
tootMention = b.getString("tootMention", null); tootMention = b.getString("tootMention", null);
@ -986,7 +986,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (tootReply.getAccount() != null && tootReply.getAccount().getMoved_to_account() != null) { if (tootReply.getAccount() != null && tootReply.getAccount().getMoved_to_account() != null) {
warning_message.setVisibility(View.VISIBLE); warning_message.setVisibility(View.VISIBLE);
} }
new RetrieveRelationshipAsyncTask(getApplicationContext(), tootReply.getAccount().getId(), TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveRelationshipAsyncTask(TootActivity.this, tootReply.getAccount().getId(), TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
if (scheduledstatus != null) if (scheduledstatus != null)
toot_it.setText(R.string.modify); toot_it.setText(R.string.modify);
@ -1003,7 +1003,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
instanceReply = accountReply.getInstance(); instanceReply = accountReply.getInstance();
} }
if (accountReply == null) if (accountReply == null)
account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userIdReply, instanceReply); account = new AccountDAO(TootActivity.this, db).getUniqAccount(userIdReply, instanceReply);
else else
account = accountReply; account = accountReply;
@ -1070,7 +1070,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
initialContent = displayWYSIWYG() ? wysiwyg.getContentAsHTML() : toot_content.getText().toString(); initialContent = displayWYSIWYG() ? wysiwyg.getContentAsHTML() : toot_content.getText().toString();
Helper.loadGiF(getApplicationContext(), account, pp_actionBar); Helper.loadGiF(TootActivity.this, account, pp_actionBar);
if (sharedContent != null) { //Shared content if (sharedContent != null) { //Shared content
@ -1231,7 +1231,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
} }
}); });
TextWatcher textWatcher = initializeTextWatcher(getApplicationContext(), social, null, toot_content, toot_cw_content, toot_space_left, pp_actionBar, pp_progress, TootActivity.this, TootActivity.this, TootActivity.this); TextWatcher textWatcher = initializeTextWatcher(TootActivity.this, social, null, toot_content, toot_cw_content, toot_space_left, pp_actionBar, pp_progress, TootActivity.this, TootActivity.this, TootActivity.this);
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA)
toot_content.addTextChangedListener(textWatcher); toot_content.addTextChangedListener(textWatcher);
@ -1296,7 +1296,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
url = attachment.getUrl(); url = attachment.getUrl();
final ImageView imageView = new ImageView(getApplicationContext()); final ImageView imageView = new ImageView(TootActivity.this);
imageView.setId(Integer.parseInt(attachment.getId())); imageView.setId(Integer.parseInt(attachment.getId()));
if (social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) { if (social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
if (successfullyUploadedFiles != null && successfullyUploadedFiles.size() > 0) { if (successfullyUploadedFiles != null && successfullyUploadedFiles.size() > 0) {
@ -1351,7 +1351,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
LinearLayout.LayoutParams imParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); LinearLayout.LayoutParams imParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
imParams.setMargins(20, 5, 20, 5); imParams.setMargins(20, 5, 20, 5);
imParams.height = (int) Helper.convertDpToPixel(100, getApplicationContext()); imParams.height = (int) Helper.convertDpToPixel(100, TootActivity.this);
imageView.setAdjustViewBounds(true); imageView.setAdjustViewBounds(true);
imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setScaleType(ImageView.ScaleType.FIT_XY);
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
@ -1413,7 +1413,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (mToast != null) { if (mToast != null) {
mToast.cancel(); mToast.cancel();
} }
mToast = Toasty.error(getApplicationContext(), message, Toast.LENGTH_SHORT); mToast = Toasty.error(TootActivity.this, message, Toast.LENGTH_SHORT);
mToast.show(); mToast.show();
} }
@ -1432,12 +1432,12 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
count++; count++;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Toasty.error(getApplicationContext(), getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show(); Toasty.error(TootActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
toot_picture.setEnabled(true); toot_picture.setEnabled(true);
toot_it.setEnabled(true); toot_it.setEnabled(true);
} }
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show(); Toasty.error(TootActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
} }
} }
} }
@ -1451,7 +1451,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
try { try {
photoFile = createImageFile(); photoFile = createImageFile();
} catch (IOException ignored) { } catch (IOException ignored) {
Toasty.error(getApplicationContext(), getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show(); Toasty.error(TootActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
} }
// Continue only if the File was successfully created // Continue only if the File was successfully created
if (photoFile != null) { if (photoFile != null) {
@ -1492,13 +1492,13 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
boolean photo_editor = sharedpreferences.getBoolean(Helper.SET_PHOTO_EDITOR, true); boolean photo_editor = sharedpreferences.getBoolean(Helper.SET_PHOTO_EDITOR, true);
if (requestCode == PICK_IMAGE && resultCode == RESULT_OK) { if (requestCode == PICK_IMAGE && resultCode == RESULT_OK) {
if (data == null) { if (data == null) {
Toasty.error(getApplicationContext(), getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show(); Toasty.error(TootActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
return; return;
} }
ClipData clipData = data.getClipData(); ClipData clipData = data.getClipData();
if (data.getData() == null && clipData == null) { if (data.getData() == null && clipData == null) {
Toasty.error(getApplicationContext(), getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show(); Toasty.error(TootActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
return; return;
} }
if (clipData != null) { if (clipData != null) {
@ -1528,7 +1528,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
} else if (mime != null && mime.toLowerCase().contains("audio")) { } else if (mime != null && mime.toLowerCase().contains("audio")) {
prepareUpload(TootActivity.this, data.getData(), filename, uploadReceiver); prepareUpload(TootActivity.this, data.getData(), filename, uploadReceiver);
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show(); Toasty.error(TootActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
} }
} }
@ -1562,9 +1562,9 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
@Override @Override
public void onPostAction(int statusCode, API.StatusAction statusAction, String userId, Error error) { public void onPostAction(int statusCode, API.StatusAction statusAction, String userId, Error error) {
if (error != null) { if (error != null) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(TootActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
} else { } else {
Toasty.success(getApplicationContext(), getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show(); Toasty.success(TootActivity.this, getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show();
resetForNextToot(); resetForNextToot();
} }
} }
@ -1577,7 +1577,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
@Override @Override
public void onError(Context context, UploadInfo uploadInfo, ServerResponse serverResponse, public void onError(Context context, UploadInfo uploadInfo, ServerResponse serverResponse,
Exception exception) { Exception exception) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(TootActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
if (attachments.size() == 0) if (attachments.size() == 0)
toot_picture_container.setVisibility(View.GONE); toot_picture_container.setVisibility(View.GONE);
toot_picture.setEnabled(true); toot_picture.setEnabled(true);
@ -1618,7 +1618,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (extras != null && extras.getString("imageUri") != null) { if (extras != null && extras.getString("imageUri") != null) {
Uri imageUri = Uri.parse(extras.getString("imageUri")); Uri imageUri = Uri.parse(extras.getString("imageUri"));
if (imageUri == null) { if (imageUri == null) {
Toasty.error(getApplicationContext(), getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show(); Toasty.error(TootActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
return; return;
} }
String filename = Helper.getFileName(TootActivity.this, imageUri); String filename = Helper.getFileName(TootActivity.this, imageUri);
@ -1631,7 +1631,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
@Override @Override
public boolean onOptionsItemSelected(@NotNull MenuItem item) { public boolean onOptionsItemSelected(@NotNull MenuItem item) {
final SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); final SQLiteDatabase db = Sqlite.getInstance(TootActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
int style; int style;
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
@ -1663,7 +1663,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
input.setText(Html.fromHtml(content)); input.setText(Html.fromHtml(content));
alert.setPositiveButton(R.string.close, (dialog, whichButton) -> dialog.dismiss()); alert.setPositiveButton(R.string.close, (dialog, whichButton) -> dialog.dismiss());
alert.setNegativeButton(R.string.accounts, (dialog, whichButton) -> { alert.setNegativeButton(R.string.accounts, (dialog, whichButton) -> {
new RetrieveAccountsForReplyAsyncTask(getApplicationContext(), tootReply.getReblog() != null ? tootReply.getReblog() : tootReply, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveAccountsForReplyAsyncTask(TootActivity.this, tootReply.getReblog() != null ? tootReply.getReblog() : tootReply, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
dialog.dismiss(); dialog.dismiss();
}); });
alert.show(); alert.show();
@ -1683,10 +1683,10 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
return true; return true;
String dateString = sharedpreferences.getString(Helper.LAST_TRANSLATION_TIME, null); String dateString = sharedpreferences.getString(Helper.LAST_TRANSLATION_TIME, null);
if (dateString != null) { if (dateString != null) {
Date dateCompare = Helper.stringToDate(getApplicationContext(), dateString); Date dateCompare = Helper.stringToDate(TootActivity.this, dateString);
Date date = new Date(); Date date = new Date();
if (date.before(dateCompare)) { if (date.before(dateCompare)) {
Toasty.info(getApplicationContext(), getString(R.string.please_wait), Toast.LENGTH_SHORT).show(); Toasty.info(TootActivity.this, getString(R.string.please_wait), Toast.LENGTH_SHORT).show();
return true; return true;
} }
} }
@ -1695,7 +1695,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
AlertDialog.Builder transAlert = new AlertDialog.Builder(TootActivity.this, style); AlertDialog.Builder transAlert = new AlertDialog.Builder(TootActivity.this, style);
transAlert.setTitle(R.string.translate_toot); transAlert.setTitle(R.string.translate_toot);
popup_trans = getLayoutInflater().inflate(R.layout.popup_translate, new LinearLayout(getApplicationContext()), false); popup_trans = getLayoutInflater().inflate(R.layout.popup_translate, new LinearLayout(TootActivity.this), false);
transAlert.setView(popup_trans); transAlert.setView(popup_trans);
SharedPreferences.Editor editor = sharedpreferences.edit(); SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.LAST_TRANSLATION_TIME, Helper.dateToString(new Date(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(Helper.SECONDES_BETWEEN_TRANSLATE)))); editor.putString(Helper.LAST_TRANSLATION_TIME, Helper.dateToString(new Date(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(Helper.SECONDES_BETWEEN_TRANSLATE))));
@ -1729,14 +1729,14 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
cw_trans.setText(translate.getTranslatedContent()); cw_trans.setText(translate.getTranslatedContent());
} }
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show(); Toasty.error(TootActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
} }
if (trans_progress_cw != null && trans_progress_toot != null && trans_progress_cw.getVisibility() == View.GONE && trans_progress_toot.getVisibility() == View.GONE) if (trans_progress_cw != null && trans_progress_toot != null && trans_progress_cw.getVisibility() == View.GONE && trans_progress_toot.getVisibility() == View.GONE)
if (dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE) != null) if (dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE) != null)
dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE).setEnabled(true); dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE).setEnabled(true);
} }
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show(); Toasty.error(TootActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
} }
} }
@ -1770,14 +1770,14 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
toot_trans.setText(translate.getTranslatedContent()); toot_trans.setText(translate.getTranslatedContent());
} }
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show(); Toasty.error(TootActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
} }
if (trans_progress_cw != null && trans_progress_toot != null && trans_progress_cw.getVisibility() == View.GONE && trans_progress_toot.getVisibility() == View.GONE) if (trans_progress_cw != null && trans_progress_toot != null && trans_progress_cw.getVisibility() == View.GONE && trans_progress_toot.getVisibility() == View.GONE)
if (dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE) != null) if (dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE) != null)
dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE).setEnabled(true); dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE).setEnabled(true);
} }
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show(); Toasty.error(TootActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
} }
} }
@ -1817,7 +1817,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
emojis.clear(); emojis.clear();
emojis = null; emojis = null;
} }
emojis = new CustomEmojiDAO(getApplicationContext(), db).getAllEmojis(account.getInstance()); emojis = new CustomEmojiDAO(TootActivity.this, db).getAllEmojis(account.getInstance());
final AlertDialog.Builder builder = new AlertDialog.Builder(this, style); final AlertDialog.Builder builder = new AlertDialog.Builder(this, style);
int paddingPixel = 15; int paddingPixel = 15;
float density = getResources().getDisplayMetrics().density; float density = getResources().getDisplayMetrics().density;
@ -1853,7 +1853,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
builderSingle.setTitle(getString(R.string.select_accounts)); builderSingle.setTitle(getString(R.string.select_accounts));
LayoutInflater inflater = getLayoutInflater(); LayoutInflater inflater = getLayoutInflater();
View dialogView = inflater.inflate(R.layout.popup_contact, new LinearLayout(getApplicationContext()), false); View dialogView = inflater.inflate(R.layout.popup_contact, new LinearLayout(TootActivity.this), false);
loader = dialogView.findViewById(R.id.loader); loader = dialogView.findViewById(R.id.loader);
EditText search_account = dialogView.findViewById(R.id.search_account); EditText search_account = dialogView.findViewById(R.id.search_account);
@ -1933,7 +1933,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
try { try {
final List<StoredStatus> drafts = new StatusStoredDAO(TootActivity.this, db).getAllDrafts(); final List<StoredStatus> drafts = new StatusStoredDAO(TootActivity.this, db).getAllDrafts();
if (drafts == null || drafts.size() == 0) { if (drafts == null || drafts.size() == 0) {
Toasty.info(getApplicationContext(), getString(R.string.no_draft), Toast.LENGTH_LONG).show(); Toasty.info(TootActivity.this, getString(R.string.no_draft), Toast.LENGTH_LONG).show();
return true; return true;
} }
builderSingle = new AlertDialog.Builder(TootActivity.this, style); builderSingle = new AlertDialog.Builder(TootActivity.this, style);
@ -1951,7 +1951,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
builder1.setTitle(R.string.delete_all); builder1.setTitle(R.string.delete_all);
builder1.setIcon(android.R.drawable.ic_dialog_alert) builder1.setIcon(android.R.drawable.ic_dialog_alert)
.setPositiveButton(R.string.yes, (dialogConfirm, which1) -> { .setPositiveButton(R.string.yes, (dialogConfirm, which1) -> {
new StatusStoredDAO(getApplicationContext(), db).removeAllDrafts(); new StatusStoredDAO(TootActivity.this, db).removeAllDrafts();
dialogConfirm.dismiss(); dialogConfirm.dismiss();
dialog.dismiss(); dialog.dismiss();
}) })
@ -1967,24 +1967,24 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
}); });
builderSingle.show(); builderSingle.show();
} catch (Exception e) { } catch (Exception e) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(TootActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
} }
return true; return true;
case R.id.action_schedule: case R.id.action_schedule:
if (toot_content.getText().toString().trim().length() == 0) { if (toot_content.getText().toString().trim().length() == 0) {
Toasty.error(getApplicationContext(), getString(R.string.toot_error_no_content), Toast.LENGTH_LONG).show(); Toasty.error(TootActivity.this, getString(R.string.toot_error_no_content), Toast.LENGTH_LONG).show();
return true; return true;
} }
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(TootActivity.this, style); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(TootActivity.this, style);
inflater = this.getLayoutInflater(); inflater = this.getLayoutInflater();
dialogView = inflater.inflate(R.layout.datetime_picker, new LinearLayout(getApplicationContext()), false); dialogView = inflater.inflate(R.layout.datetime_picker, new LinearLayout(TootActivity.this), false);
dialogBuilder.setView(dialogView); dialogBuilder.setView(dialogView);
final AlertDialog alertDialog = dialogBuilder.create(); final AlertDialog alertDialog = dialogBuilder.create();
final DatePicker datePicker = dialogView.findViewById(R.id.date_picker); final DatePicker datePicker = dialogView.findViewById(R.id.date_picker);
final TimePicker timePicker = dialogView.findViewById(R.id.time_picker); final TimePicker timePicker = dialogView.findViewById(R.id.time_picker);
if (android.text.format.DateFormat.is24HourFormat(getApplicationContext())) if (android.text.format.DateFormat.is24HourFormat(TootActivity.this))
timePicker.setIs24HourView(true); timePicker.setIs24HourView(true);
Button date_time_cancel = dialogView.findViewById(R.id.date_time_cancel); Button date_time_cancel = dialogView.findViewById(R.id.date_time_cancel);
final ImageButton date_time_previous = dialogView.findViewById(R.id.date_time_previous); final ImageButton date_time_previous = dialogView.findViewById(R.id.date_time_previous);
@ -2024,7 +2024,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
final long[] time = {calendar.getTimeInMillis()}; final long[] time = {calendar.getTimeInMillis()};
if ((time[0] - new Date().getTime()) < 60000) { if ((time[0] - new Date().getTime()) < 60000) {
Toasty.warning(getApplicationContext(), getString(R.string.toot_scheduled_date), Toast.LENGTH_LONG).show(); Toasty.warning(TootActivity.this, getString(R.string.toot_scheduled_date), Toast.LENGTH_LONG).show();
} else { } else {
AlertDialog.Builder builderSingle1 = new AlertDialog.Builder(TootActivity.this, style); AlertDialog.Builder builderSingle1 = new AlertDialog.Builder(TootActivity.this, style);
builderSingle1.setTitle(getString(R.string.choose_schedule)); builderSingle1.setTitle(getString(R.string.choose_schedule));
@ -2052,12 +2052,12 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
private void sendToot(String timestamp, String content_type) { private void sendToot(String timestamp, String content_type) {
toot_it.setEnabled(false); toot_it.setEnabled(false);
if (!displayWYSIWYG() && toot_content.getText().toString().trim().length() == 0 && attachments.size() == 0) { if (!displayWYSIWYG() && toot_content.getText().toString().trim().length() == 0 && attachments.size() == 0) {
Toasty.error(getApplicationContext(), getString(R.string.toot_error_no_content), Toast.LENGTH_LONG).show(); Toasty.error(TootActivity.this, getString(R.string.toot_error_no_content), Toast.LENGTH_LONG).show();
toot_it.setEnabled(true); toot_it.setEnabled(true);
return; return;
} }
if (displayWYSIWYG() && wysiwyg.getContent().toString().trim().length() == 0 && attachments.size() == 0) { if (displayWYSIWYG() && wysiwyg.getContent().toString().trim().length() == 0 && attachments.size() == 0) {
Toasty.error(getApplicationContext(), getString(R.string.toot_error_no_content), Toast.LENGTH_LONG).show(); Toasty.error(TootActivity.this, getString(R.string.toot_error_no_content), Toast.LENGTH_LONG).show();
toot_it.setEnabled(true); toot_it.setEnabled(true);
return; return;
} }
@ -2088,7 +2088,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
AlertDialog.Builder builderInner = new AlertDialog.Builder(TootActivity.this, style); AlertDialog.Builder builderInner = new AlertDialog.Builder(TootActivity.this, style);
builderInner.setTitle(R.string.message_preview); builderInner.setTitle(R.string.message_preview);
View preview = getLayoutInflater().inflate(R.layout.popup_message_preview, new LinearLayout(getApplicationContext()), false); View preview = getLayoutInflater().inflate(R.layout.popup_message_preview, new LinearLayout(TootActivity.this), false);
builderInner.setView(preview); builderInner.setView(preview);
//Text for report //Text for report
@ -2164,17 +2164,17 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
} }
if (timestamp == null) if (timestamp == null)
if (scheduledstatus == null) if (scheduledstatus == null)
new PostStatusAsyncTask(getApplicationContext(), social, account, toot, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostStatusAsyncTask(TootActivity.this, social, account, toot, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else { else {
toot.setScheduled_at(Helper.dateToString(scheduledstatus.getScheduled_date())); toot.setScheduled_at(Helper.dateToString(scheduledstatus.getScheduled_date()));
scheduledstatus.setStatus(toot); scheduledstatus.setStatus(toot);
isScheduled = true; isScheduled = true;
new PostActionAsyncTask(getApplicationContext(), API.StatusAction.DELETESCHEDULED, scheduledstatus, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostActionAsyncTask(TootActivity.this, API.StatusAction.DELETESCHEDULED, scheduledstatus, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new PostStatusAsyncTask(getApplicationContext(), social, account, toot, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostStatusAsyncTask(TootActivity.this, social, account, toot, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
else { else {
toot.setScheduled_at(timestamp); toot.setScheduled_at(timestamp);
new PostStatusAsyncTask(getApplicationContext(), social, account, toot, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostStatusAsyncTask(TootActivity.this, social, account, toot, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
} }
@ -2189,7 +2189,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
storeToot(false, false); storeToot(false, false);
isScheduled = true; isScheduled = true;
//Schedules the toot //Schedules the toot
ScheduledTootsSyncJob.schedule(getApplicationContext(), currentToId, time); ScheduledTootsSyncJob.schedule(TootActivity.this, currentToId, time);
resetForNextToot(); resetForNextToot();
} }
@ -2212,7 +2212,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
isSensitive = false; isSensitive = false;
toot_sensitive.setVisibility(View.GONE); toot_sensitive.setVisibility(View.GONE);
currentToId = -1; currentToId = -1;
Toasty.info(getApplicationContext(), getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show(); Toasty.info(TootActivity.this, getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show();
} }
@Override @Override
@ -2238,8 +2238,8 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
} }
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
MenuItem itemEmoji = menu.findItem(R.id.action_emoji); MenuItem itemEmoji = menu.findItem(R.id.action_emoji);
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(TootActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
final List<Emojis> emojis = new CustomEmojiDAO(getApplicationContext(), db).getAllEmojis(); final List<Emojis> emojis = new CustomEmojiDAO(TootActivity.this, db).getAllEmojis();
//Displays button only if custom emojis //Displays button only if custom emojis
if (emojis != null && emojis.size() > 0) { if (emojis != null && emojis.size() > 0) {
itemEmoji.setVisible(true); itemEmoji.setVisible(true);
@ -2314,14 +2314,14 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
AlertDialog.Builder builderInner = new AlertDialog.Builder(TootActivity.this, style); AlertDialog.Builder builderInner = new AlertDialog.Builder(TootActivity.this, style);
builderInner.setTitle(R.string.upload_form_description); builderInner.setTitle(R.string.upload_form_description);
View popup_media_description = getLayoutInflater().inflate(R.layout.popup_media_description, new LinearLayout(getApplicationContext()), false); View popup_media_description = getLayoutInflater().inflate(R.layout.popup_media_description, new LinearLayout(TootActivity.this), false);
builderInner.setView(popup_media_description); builderInner.setView(popup_media_description);
//Text for report //Text for report
final EditText input = popup_media_description.findViewById(R.id.media_description); final EditText input = popup_media_description.findViewById(R.id.media_description);
input.setFilters(new InputFilter[]{new InputFilter.LengthFilter(420)}); input.setFilters(new InputFilter[]{new InputFilter.LengthFilter(420)});
final ImageView media_picture = popup_media_description.findViewById(R.id.media_picture); final ImageView media_picture = popup_media_description.findViewById(R.id.media_picture);
Glide.with(getApplicationContext()) Glide.with(TootActivity.this)
.asBitmap() .asBitmap()
.load(attachment.getUrl()) .load(attachment.getUrl())
.into(new SimpleTarget<Bitmap>() { .into(new SimpleTarget<Bitmap>() {
@ -2340,7 +2340,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
input.setSelection(input.getText().length()); input.setSelection(input.getText().length());
} }
builderInner.setPositiveButton(R.string.validate, (dialog, which) -> { builderInner.setPositiveButton(R.string.validate, (dialog, which) -> {
new UpdateDescriptionAttachmentAsyncTask(getApplicationContext(), attachment.getId(), input.getText().toString(), account, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new UpdateDescriptionAttachmentAsyncTask(TootActivity.this, attachment.getId(), input.getText().toString(), account, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
attachment.setDescription(input.getText().toString()); attachment.setDescription(input.getText().toString());
addBorder(); addBorder();
dialog.dismiss(); dialog.dismiss();
@ -2515,17 +2515,17 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (apiResponse.getStatuses() != null && apiResponse.getStatuses().size() > 0) if (apiResponse.getStatuses() != null && apiResponse.getStatuses().size() > 0)
toot.setIn_reply_to_id(apiResponse.getStatuses().get(0).getId()); toot.setIn_reply_to_id(apiResponse.getStatuses().get(0).getId());
toot.setContent(TootActivity.this, tootContent); toot.setContent(TootActivity.this, tootContent);
new PostStatusAsyncTask(getApplicationContext(), social, account, toot, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostStatusAsyncTask(TootActivity.this, social, account, toot, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
return; return;
} }
if (apiResponse.getError() == null || apiResponse.getError().getStatusCode() != -33) { if (apiResponse.getError() == null || apiResponse.getError().getStatusCode() != -33) {
if (restored != -1) { if (restored != -1) {
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(TootActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
new StatusStoredDAO(getApplicationContext(), db).remove(restored); new StatusStoredDAO(TootActivity.this, db).remove(restored);
} else if (currentToId != -1) { } else if (currentToId != -1) {
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(TootActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
new StatusStoredDAO(getApplicationContext(), db).remove(currentToId); new StatusStoredDAO(TootActivity.this, db).remove(currentToId);
} }
} }
//Clear the toot //Clear the toot
@ -2550,13 +2550,13 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (scheduledstatus == null && !isScheduled) { if (scheduledstatus == null && !isScheduled) {
boolean display_confirm = sharedpreferences.getBoolean(Helper.SET_DISPLAY_CONFIRM, true); boolean display_confirm = sharedpreferences.getBoolean(Helper.SET_DISPLAY_CONFIRM, true);
if (display_confirm) { if (display_confirm) {
Toasty.success(getApplicationContext(), getString(R.string.toot_sent), Toast.LENGTH_LONG).show(); Toasty.success(TootActivity.this, getString(R.string.toot_sent), Toast.LENGTH_LONG).show();
} }
} else } else
Toasty.success(getApplicationContext(), getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show(); Toasty.success(TootActivity.this, getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show();
} else { } else {
if (apiResponse.getError().getStatusCode() == -33) if (apiResponse.getError().getStatusCode() == -33)
Toasty.info(getApplicationContext(), getString(R.string.toast_toot_saved_error), Toast.LENGTH_LONG).show(); Toasty.info(TootActivity.this, getString(R.string.toast_toot_saved_error), Toast.LENGTH_LONG).show();
} }
toot_it.setEnabled(true); toot_it.setEnabled(true);
//It's a reply, so the user will be redirect to its answer //It's a reply, so the user will be redirect to its answer
@ -2565,7 +2565,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (statuses != null && statuses.size() > 0) { if (statuses != null && statuses.size() > 0) {
Status status = statuses.get(0); Status status = statuses.get(0);
if (status != null) { if (status != null) {
Intent intent = new Intent(getApplicationContext(), ShowConversationActivity.class); Intent intent = new Intent(TootActivity.this, ShowConversationActivity.class);
Bundle b = new Bundle(); Bundle b = new Bundle();
if (idRedirect == null) if (idRedirect == null)
b.putParcelable("status", status); b.putParcelable("status", status);
@ -2578,7 +2578,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
} }
} }
} else { } else {
Intent intent = new Intent(getApplicationContext(), MainActivity.class); Intent intent = new Intent(TootActivity.this, MainActivity.class);
intent.putExtra(Helper.INTENT_ACTION, Helper.HOME_TIMELINE_INTENT); intent.putExtra(Helper.INTENT_ACTION, Helper.HOME_TIMELINE_INTENT);
startActivity(intent); startActivity(intent);
finish(); finish();
@ -2937,7 +2937,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
} }
private void restoreToot(long id) { private void restoreToot(long id) {
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(TootActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
StoredStatus draft = new StatusStoredDAO(TootActivity.this, db).getStatus(id); StoredStatus draft = new StatusStoredDAO(TootActivity.this, db).getStatus(id);
if (draft == null) if (draft == null)
return; return;
@ -2997,12 +2997,12 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
String url = attachment.getPreview_url(); String url = attachment.getPreview_url();
if (url == null || url.trim().equals("")) if (url == null || url.trim().equals(""))
url = attachment.getUrl(); url = attachment.getUrl();
final ImageView imageView = new ImageView(getApplicationContext()); final ImageView imageView = new ImageView(TootActivity.this);
imageView.setId(Integer.parseInt(attachment.getId())); imageView.setId(Integer.parseInt(attachment.getId()));
LinearLayout.LayoutParams imParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); LinearLayout.LayoutParams imParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
imParams.setMargins(20, 5, 20, 5); imParams.setMargins(20, 5, 20, 5);
imParams.height = (int) Helper.convertDpToPixel(100, getApplicationContext()); imParams.height = (int) Helper.convertDpToPixel(100, TootActivity.this);
imageView.setAdjustViewBounds(true); imageView.setAdjustViewBounds(true);
imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setScaleType(ImageView.ScaleType.FIT_XY);
toot_picture_container.addView(imageView, i, imParams); toot_picture_container.addView(imageView, i, imParams);
@ -3140,12 +3140,12 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
String url = attachment.getPreview_url(); String url = attachment.getPreview_url();
if (url == null || url.trim().equals("")) if (url == null || url.trim().equals(""))
url = attachment.getUrl(); url = attachment.getUrl();
final ImageView imageView = new ImageView(getApplicationContext()); final ImageView imageView = new ImageView(TootActivity.this);
imageView.setId(Integer.parseInt(attachment.getId())); imageView.setId(Integer.parseInt(attachment.getId()));
LinearLayout.LayoutParams imParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); LinearLayout.LayoutParams imParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
imParams.setMargins(20, 5, 20, 5); imParams.setMargins(20, 5, 20, 5);
imParams.height = (int) Helper.convertDpToPixel(100, getApplicationContext()); imParams.height = (int) Helper.convertDpToPixel(100, TootActivity.this);
imageView.setAdjustViewBounds(true); imageView.setAdjustViewBounds(true);
imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setScaleType(ImageView.ScaleType.FIT_XY);
toot_picture_container.addView(imageView, i, imParams); toot_picture_container.addView(imageView, i, imParams);
@ -3317,7 +3317,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
} }
if (tootReply != null) { if (tootReply != null) {
manageMentions(getApplicationContext(), social, userIdReply, toot_content, toot_cw_content, toot_space_left, tootReply); manageMentions(TootActivity.this, social, userIdReply, toot_content, toot_cw_content, toot_space_left, tootReply);
} }
boolean forwardTags = sharedpreferences.getBoolean(Helper.SET_FORWARD_TAGS_IN_REPLY, false); boolean forwardTags = sharedpreferences.getBoolean(Helper.SET_FORWARD_TAGS_IN_REPLY, false);
if (tootReply != null && forwardTags && tootReply.getTags() != null && tootReply.getTags().size() > 0) { if (tootReply != null && forwardTags && tootReply.getTags() != null && tootReply.getTags().size() > 0) {
@ -3487,7 +3487,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
String choice2 = choice_2.getText().toString().trim(); String choice2 = choice_2.getText().toString().trim();
if (choice1.isEmpty() && choice2.isEmpty()) { if (choice1.isEmpty() && choice2.isEmpty()) {
Toasty.error(getApplicationContext(), getString(R.string.poll_invalid_choices), Toast.LENGTH_SHORT).show(); Toasty.error(TootActivity.this, getString(R.string.poll_invalid_choices), Toast.LENGTH_SHORT).show();
} else { } else {
poll = new Poll(); poll = new Poll();
poll.setMultiple(poll_choice_pos != 0); poll.setMultiple(poll_choice_pos != 0);
@ -3549,7 +3549,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
poll.setOptionsList(pollOptions); poll.setOptionsList(pollOptions);
dialog.dismiss(); dialog.dismiss();
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.poll_duplicated_entry), Toast.LENGTH_SHORT).show(); Toasty.error(TootActivity.this, getString(R.string.poll_duplicated_entry), Toast.LENGTH_SHORT).show();
} }
} }
poll_action.setVisibility(View.VISIBLE); poll_action.setVisibility(View.VISIBLE);
@ -3589,7 +3589,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
toot.setPoll(poll); toot.setPoll(poll);
if (tootReply != null) if (tootReply != null)
toot.setIn_reply_to_id(tootReply.getId()); toot.setIn_reply_to_id(tootReply.getId());
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(TootActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
try { try {
if (currentToId == -1) { if (currentToId == -1) {
currentToId = new StatusStoredDAO(TootActivity.this, db).insertStatus(toot, tootReply); currentToId = new StatusStoredDAO(TootActivity.this, db).insertStatus(toot, tootReply);
@ -3603,10 +3603,10 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
} }
} }
if (message) if (message)
Toasty.success(getApplicationContext(), getString(R.string.toast_toot_saved), Toast.LENGTH_LONG).show(); Toasty.success(TootActivity.this, getString(R.string.toast_toot_saved), Toast.LENGTH_LONG).show();
} catch (Exception e) { } catch (Exception e) {
if (message) if (message)
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(TootActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
} }
} }
@ -3730,7 +3730,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
findViewById(R.id.action_bulleted).setOnClickListener(v -> wysiwyg.insertList(false)); findViewById(R.id.action_bulleted).setOnClickListener(v -> wysiwyg.insertList(false));
findViewById(R.id.action_color).setOnClickListener(v -> new ColorPickerPopup.Builder(getApplicationContext()) findViewById(R.id.action_color).setOnClickListener(v -> new ColorPickerPopup.Builder(TootActivity.this)
.enableAlpha(false) .enableAlpha(false)
.okTitle(getString(R.string.validate)) .okTitle(getString(R.string.validate))
.cancelTitle(getString(R.string.cancel)) .cancelTitle(getString(R.string.cancel))

View File

@ -75,7 +75,7 @@ public class TootInfoActivity extends BaseActivity {
toot_favorites_count = b.getInt("toot_favorites_count", 0); toot_favorites_count = b.getInt("toot_favorites_count", 0);
} }
if (toot_id == null) { if (toot_id == null) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_SHORT).show(); Toasty.error(TootInfoActivity.this, getString(R.string.toast_error), Toast.LENGTH_SHORT).show();
finish(); finish();
} }
tabLayout = findViewById(R.id.tabLayout); tabLayout = findViewById(R.id.tabLayout);

View File

@ -241,7 +241,7 @@ public class WebviewActivity extends BaseActivity {
builder.setAdapter(arrayAdapter, (dialog, which) -> { builder.setAdapter(arrayAdapter, (dialog, which) -> {
String strName = arrayAdapter.getItem(which); String strName = arrayAdapter.getItem(which);
assert strName != null; assert strName != null;
Toasty.info(getApplicationContext(), strName, Toast.LENGTH_LONG).show(); Toasty.info(WebviewActivity.this, strName, Toast.LENGTH_LONG).show();
}); });
builder.show(); builder.show();
@ -251,11 +251,11 @@ public class WebviewActivity extends BaseActivity {
try { try {
startActivity(browserIntent); startActivity(browserIntent);
} catch (Exception e) { } catch (Exception e) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(WebviewActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
} }
return true; return true;
case R.id.action_comment: case R.id.action_comment:
Toasty.info(getApplicationContext(), getString(R.string.retrieve_remote_status), Toast.LENGTH_LONG).show(); Toasty.info(WebviewActivity.this, getString(R.string.retrieve_remote_status), Toast.LENGTH_LONG).show();
new connnectAsync(new WeakReference<>(WebviewActivity.this), url, peertubeLinkToFetch).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new connnectAsync(new WeakReference<>(WebviewActivity.this), url, peertubeLinkToFetch).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
return true; return true;
default: default:

View File

@ -112,7 +112,7 @@ public class WebviewConnectActivity extends BaseActivity {
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
assert inflater != null; assert inflater != null;
View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(getApplicationContext()), false); View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(WebviewConnectActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(WebviewConnectActivity.this, R.color.cyanea_primary))); view.setBackground(new ColorDrawable(ContextCompat.getColor(WebviewConnectActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
@ -122,7 +122,7 @@ public class WebviewConnectActivity extends BaseActivity {
toolbar_title.setText(R.string.add_account); toolbar_title.setText(R.string.add_account);
} }
webView = findViewById(R.id.webviewConnect); webView = findViewById(R.id.webviewConnect);
clearCookies(getApplicationContext()); clearCookies(WebviewConnectActivity.this);
webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setJavaScriptEnabled(true);
String user_agent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, null); String user_agent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, null);
if (user_agent != null) { if (user_agent != null) {
@ -157,7 +157,7 @@ public class WebviewConnectActivity extends BaseActivity {
if (url.contains(Helper.REDIRECT_CONTENT_WEB)) { if (url.contains(Helper.REDIRECT_CONTENT_WEB)) {
String[] val = url.split("code="); String[] val = url.split("code=");
if (val.length < 2) { if (val.length < 2) {
Toasty.error(getApplicationContext(), getString(R.string.toast_code_error), Toast.LENGTH_LONG).show(); Toasty.error(WebviewConnectActivity.this, getString(R.string.toast_code_error), Toast.LENGTH_LONG).show();
Intent myIntent = new Intent(WebviewConnectActivity.this, LoginActivity.class); Intent myIntent = new Intent(WebviewConnectActivity.this, LoginActivity.class);
startActivity(myIntent); startActivity(myIntent);
finish(); finish();
@ -173,7 +173,7 @@ public class WebviewConnectActivity extends BaseActivity {
parameters.put("code", code); parameters.put("code", code);
new Thread(() -> { new Thread(() -> {
try { try {
final String response = new HttpsConnection(WebviewConnectActivity.this, instance).post(Helper.instanceWithProtocol(getApplicationContext(), instance) + action, 30, parameters, null); final String response = new HttpsConnection(WebviewConnectActivity.this, instance).post(Helper.instanceWithProtocol(WebviewConnectActivity.this, instance) + action, 30, parameters, null);
JSONObject resobj; JSONObject resobj;
try { try {
resobj = new JSONObject(response); resobj = new JSONObject(response);
@ -198,7 +198,7 @@ public class WebviewConnectActivity extends BaseActivity {
} }
}); });
webView.loadUrl(LoginActivity.redirectUserToAuthorizeAndLogin(getApplicationContext(), clientId, instance)); webView.loadUrl(LoginActivity.redirectUserToAuthorizeAndLogin(WebviewConnectActivity.this, clientId, instance));
} }
@Override @Override
@ -217,7 +217,7 @@ public class WebviewConnectActivity extends BaseActivity {
alert.dismiss(); alert.dismiss();
alert = null; alert = null;
} }
if( webView != null){ if (webView != null) {
webView.destroy(); webView.destroy();
} }
} }

View File

@ -141,7 +141,7 @@ public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoTo
return; return;
} }
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_SHORT).show(); Toasty.error(WhoToFollowActivity.this, getString(R.string.toast_error), Toast.LENGTH_SHORT).show();
return; return;
} }
@ -186,7 +186,7 @@ public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoTo
account.setInstance(val[1]); account.setInstance(val[1]);
new PostActionAsyncTask(WhoToFollowActivity.this, null, account, API.StatusAction.FOLLOW, WhoToFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostActionAsyncTask(WhoToFollowActivity.this, null, account, API.StatusAction.FOLLOW, WhoToFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else { } else {
Toasty.error(getApplicationContext(), getString(R.string.toast_impossible_to_follow), Toast.LENGTH_LONG).show(); Toasty.error(WhoToFollowActivity.this, getString(R.string.toast_impossible_to_follow), Toast.LENGTH_LONG).show();
follow_accounts.setEnabled(true); follow_accounts.setEnabled(true);
follow_accounts_select.setEnabled(true); follow_accounts_select.setEnabled(true);
progess_action.setVisibility(View.GONE); progess_action.setVisibility(View.GONE);

View File

@ -179,9 +179,9 @@ public class PostActionAsyncTask extends AsyncTask<Void, Void, Void> {
} else { } else {
statusCode = api.reportAction(targetedId, comment); statusCode = api.reportAction(targetedId, comment);
} }
}else if (apiAction == API.StatusAction.ADD_REACTION || apiAction == API.StatusAction.REMOVE_REACTION || apiAction == API.StatusAction.ADD_PLEROMA_REACTION || apiAction == API.StatusAction.REMOVE_PLEROMA_REACTION) { } else if (apiAction == API.StatusAction.ADD_REACTION || apiAction == API.StatusAction.REMOVE_REACTION || apiAction == API.StatusAction.ADD_PLEROMA_REACTION || apiAction == API.StatusAction.REMOVE_PLEROMA_REACTION) {
statusCode = api.postAction(apiAction, targetedId, comment); statusCode = api.postAction(apiAction, targetedId, comment);
}else if (apiAction == API.StatusAction.CREATESTATUS) } else if (apiAction == API.StatusAction.CREATESTATUS)
statusCode = api.statusAction(status); statusCode = api.statusAction(status);
else if (apiAction == API.StatusAction.UPDATESERVERSCHEDULE) { else if (apiAction == API.StatusAction.UPDATESERVERSCHEDULE) {
api.scheduledAction("PUT", storedStatus.getStatus(), null, storedStatus.getScheduledServerdId()); api.scheduledAction("PUT", storedStatus.getStatus(), null, storedStatus.getScheduledServerdId());

View File

@ -122,13 +122,6 @@ public class API {
private Error APIError; private Error APIError;
private List<String> domains; private List<String> domains;
enum filterFor{
STATUSES_ACCOUNT,
HOME,
LOCAL,
PUBLIC
}
public API(Context context) { public API(Context context) {
this.context = context; this.context = context;
if (context == null) { if (context == null) {
@ -161,7 +154,6 @@ public class API {
APIError = null; APIError = null;
} }
public API(Context context, String instance, String token) { public API(Context context, String instance, String token) {
this.context = context; this.context = context;
if (context == null) { if (context == null) {
@ -528,7 +520,6 @@ public class API {
return statuses; return statuses;
} }
/** /**
* Parse json response for several reactions * Parse json response for several reactions
* *
@ -553,6 +544,7 @@ public class API {
/** /**
* Parse a reaction * Parse a reaction
*
* @param resobj JSONObject * @param resobj JSONObject
* @return Reaction * @return Reaction
*/ */
@ -562,7 +554,7 @@ public class API {
reaction.setName(resobj.getString("name")); reaction.setName(resobj.getString("name"));
reaction.setCount(resobj.getInt("count")); reaction.setCount(resobj.getInt("count"));
reaction.setMe(resobj.getBoolean("me")); reaction.setMe(resobj.getBoolean("me"));
if( resobj.has("url")){ if (resobj.has("url")) {
reaction.setUrl(resobj.getString("url")); reaction.setUrl(resobj.getString("url"));
} }
} catch (JSONException e) { } catch (JSONException e) {
@ -595,8 +587,10 @@ public class API {
} }
return announcements; return announcements;
} }
/** /**
* Parse an annoucement * Parse an annoucement
*
* @param context Context * @param context Context
* @param resobj JSONObject * @param resobj JSONObject
* @return Announcement * @return Announcement
@ -614,16 +608,16 @@ public class API {
announcement.setAccount(account); announcement.setAccount(account);
announcement.setId(resobj.getString("id")); announcement.setId(resobj.getString("id"));
announcement.setContent(context, resobj.getString("content")); announcement.setContent(context, resobj.getString("content"));
if( resobj.getString("published_at").compareTo("null") != 0) { if (resobj.getString("published_at").compareTo("null") != 0) {
announcement.setCreated_at(Helper.mstStringToDate(context, resobj.getString("published_at"))); announcement.setCreated_at(Helper.mstStringToDate(context, resobj.getString("published_at")));
} }
if( resobj.getString("updated_at").compareTo("null") != 0) { if (resobj.getString("updated_at").compareTo("null") != 0) {
announcement.setUpdatedAt(Helper.mstStringToDate(context, resobj.getString("updated_at"))); announcement.setUpdatedAt(Helper.mstStringToDate(context, resobj.getString("updated_at")));
} }
if( resobj.getString("starts_at").compareTo("null") != 0) { if (resobj.getString("starts_at").compareTo("null") != 0) {
announcement.setStartAt(Helper.mstStringToDate(context, resobj.getString("starts_at"))); announcement.setStartAt(Helper.mstStringToDate(context, resobj.getString("starts_at")));
} }
if( resobj.getString("ends_at").compareTo("null") != 0) { if (resobj.getString("ends_at").compareTo("null") != 0) {
announcement.setEndAt(Helper.mstStringToDate(context, resobj.getString("ends_at"))); announcement.setEndAt(Helper.mstStringToDate(context, resobj.getString("ends_at")));
} }
@ -633,7 +627,6 @@ public class API {
announcement.setReactions(parseReaction(resobj.getJSONArray("reactions"))); announcement.setReactions(parseReaction(resobj.getJSONArray("reactions")));
List<Tag> tags = new ArrayList<>(); List<Tag> tags = new ArrayList<>();
JSONArray arrayTag = resobj.getJSONArray("tags"); JSONArray arrayTag = resobj.getJSONArray("tags");
for (int j = 0; j < arrayTag.length(); j++) { for (int j = 0; j < arrayTag.length(); j++) {
@ -683,6 +676,7 @@ public class API {
/** /**
* Parse a poll * Parse a poll
*
* @param context Context * @param context Context
* @param resobj JSONObject * @param resobj JSONObject
* @return Poll * @return Poll
@ -739,10 +733,10 @@ public class API {
status.setCreated_at(new Date()); status.setCreated_at(new Date());
} }
if( !resobj.isNull("in_reply_to_id") ) { if (!resobj.isNull("in_reply_to_id")) {
status.setIn_reply_to_id(resobj.get("in_reply_to_id").toString()); status.setIn_reply_to_id(resobj.get("in_reply_to_id").toString());
} }
if( !resobj.isNull("in_reply_to_account_id") ) { if (!resobj.isNull("in_reply_to_account_id")) {
status.setIn_reply_to_account_id(resobj.get("in_reply_to_account_id").toString()); status.setIn_reply_to_account_id(resobj.get("in_reply_to_account_id").toString());
} }
status.setSensitive(Boolean.parseBoolean(resobj.get("sensitive").toString())); status.setSensitive(Boolean.parseBoolean(resobj.get("sensitive").toString()));
@ -759,10 +753,11 @@ public class API {
} }
List<Reaction> reactions = new ArrayList<>(); List<Reaction> reactions = new ArrayList<>();
if (resobj.has("pleroma") && resobj.getJSONObject("pleroma").has("emoji_reactions") ) { if (resobj.has("pleroma") && resobj.getJSONObject("pleroma").has("emoji_reactions")) {
try { try {
reactions = parseReaction(resobj.getJSONObject("pleroma").getJSONArray("emoji_reactions")); reactions = parseReaction(resobj.getJSONObject("pleroma").getJSONArray("emoji_reactions"));
}catch (Exception ignored){} } catch (Exception ignored) {
}
} }
status.setReactions(reactions); status.setReactions(reactions);
@ -1491,7 +1486,6 @@ public class API {
return account; return account;
} }
/** /**
* Parse json response an unique account * Parse json response an unique account
* *
@ -1860,7 +1854,8 @@ public class API {
} else { } else {
try { try {
id = URLEncoder.encode(id, "UTF-8"); id = URLEncoder.encode(id, "UTF-8");
} catch (UnsupportedEncodingException ignored) {} } catch (UnsupportedEncodingException ignored) {
}
params = new HashMap<>(); params = new HashMap<>();
params.put("query", id); params.put("query", id);
endpoint = "/admin/users"; endpoint = "/admin/users";
@ -2257,7 +2252,6 @@ public class API {
return instanceNodeInfo; return instanceNodeInfo;
} }
public InstanceNodeInfo instanceInfo(String domain) { public InstanceNodeInfo instanceInfo(String domain) {
String response; String response;
@ -2750,7 +2744,7 @@ public class API {
try { try {
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance); HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl(String.format("/accounts/%s/statuses", accountId)), 10, params, prefKeyOauthTokenT); String response = httpsConnection.get(getAbsoluteUrl(String.format("/accounts/%s/statuses", accountId)), 10, params, prefKeyOauthTokenT);
statuses = parseStatuses(context, filterFor.STATUSES_ACCOUNT ,new JSONArray(response)); statuses = parseStatuses(context, filterFor.STATUSES_ACCOUNT, new JSONArray(response));
apiResponse.setSince_id(httpsConnection.getSince_id()); apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id()); apiResponse.setMax_id(httpsConnection.getMax_id());
} catch (HttpsConnection.HttpsConnectionException e) { } catch (HttpsConnection.HttpsConnectionException e) {
@ -3040,7 +3034,6 @@ public class API {
return getHomeTimeline(null, since_id, null, tootPerPage); return getHomeTimeline(null, since_id, null, tootPerPage);
} }
/** /**
* Retrieves home timeline from cache the account *synchronously* * Retrieves home timeline from cache the account *synchronously*
* *
@ -3158,7 +3151,6 @@ public class API {
return apiResponse; return apiResponse;
} }
/** /**
* Retrieves public GNU timeline for the account *synchronously* * Retrieves public GNU timeline for the account *synchronously*
* *
@ -3400,7 +3392,6 @@ public class API {
return apiResponse; return apiResponse;
} }
/** /**
* Retrieves Nitter timeline from accounts *synchronously* * Retrieves Nitter timeline from accounts *synchronously*
* *
@ -3558,7 +3549,7 @@ public class API {
String response = httpsConnection.get(url, 10, params, prefKeyOauthTokenT); String response = httpsConnection.get(url, 10, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id()); apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id()); apiResponse.setMax_id(httpsConnection.getMax_id());
statuses = parseStatuses(context, local?filterFor.LOCAL:filterFor.PUBLIC, new JSONArray(response)); statuses = parseStatuses(context, local ? filterFor.LOCAL : filterFor.PUBLIC, new JSONArray(response));
} catch (HttpsConnection.HttpsConnectionException e) { } catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e); setError(e.getStatusCode(), e);
e.printStackTrace(); e.printStackTrace();
@ -3920,7 +3911,6 @@ public class API {
return apiResponse; return apiResponse;
} }
/** /**
* Retrieves blocked domains for the authenticated account *synchronously* * Retrieves blocked domains for the authenticated account *synchronously*
* *
@ -4066,6 +4056,7 @@ public class API {
/** /**
* Retrieves announcements for the authenticated account *synchronously* * Retrieves announcements for the authenticated account *synchronously*
*
* @return APIResponse * @return APIResponse
*/ */
public APIResponse getAnnouncements() { public APIResponse getAnnouncements() {
@ -4084,7 +4075,6 @@ public class API {
return apiResponse; return apiResponse;
} }
/** /**
* Retrieves bookmarked status for the authenticated account *synchronously* * Retrieves bookmarked status for the authenticated account *synchronously*
* *
@ -4136,8 +4126,6 @@ public class API {
return postAction(statusAction, targetedId, null, comment); return postAction(statusAction, targetedId, null, comment);
} }
//Pleroma admin calls
/** /**
* Makes the post action for a status * Makes the post action for a status
* *
@ -4162,6 +4150,8 @@ public class API {
return actionCode; return actionCode;
} }
//Pleroma admin calls
/** /**
* Makes the post action * Makes the post action
* *
@ -4377,7 +4367,7 @@ public class API {
} catch (NoSuchAlgorithmException | IOException | KeyManagementException e) { } catch (NoSuchAlgorithmException | IOException | KeyManagementException e) {
e.printStackTrace(); e.printStackTrace();
} }
} else if(statusAction == StatusAction.ADD_REACTION || statusAction == StatusAction.ADD_PLEROMA_REACTION){ } else if (statusAction == StatusAction.ADD_REACTION || statusAction == StatusAction.ADD_PLEROMA_REACTION) {
try { try {
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance); HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
httpsConnection.put(getAbsoluteUrl(action), 10, null, prefKeyOauthTokenT); httpsConnection.put(getAbsoluteUrl(action), 10, null, prefKeyOauthTokenT);
@ -4392,7 +4382,7 @@ public class API {
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance); HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
httpsConnection.delete(getAbsoluteUrl(action), 10, null, prefKeyOauthTokenT); httpsConnection.delete(getAbsoluteUrl(action), 10, null, prefKeyOauthTokenT);
actionCode = httpsConnection.getActionCode(); actionCode = httpsConnection.getActionCode();
if( statusAction != StatusAction.REMOVE_REACTION && statusAction != StatusAction.REMOVE_PLEROMA_REACTION) { 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, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
new TimelineCacheDAO(context, db).remove(targetedId); new TimelineCacheDAO(context, db).remove(targetedId);
} }
@ -4902,7 +4892,6 @@ public class API {
return apiResponse; return apiResponse;
} }
/** /**
* Retrieves trends for Mastodon *synchronously* * Retrieves trends for Mastodon *synchronously*
* *
@ -5222,8 +5211,6 @@ public class API {
return apiResponse; return apiResponse;
} }
/** /**
* Retrieves list timeline *synchronously* * Retrieves list timeline *synchronously*
* *
@ -5576,7 +5563,6 @@ public class API {
return peertubes; return peertubes;
} }
/** /**
* Parse json response for several trends * Parse json response for several trends
* *
@ -5631,7 +5617,6 @@ public class API {
return trend; return trend;
} }
/** /**
* Parse json response for several conversations * Parse json response for several conversations
* *
@ -5832,7 +5817,6 @@ public class API {
return emojis; return emojis;
} }
/** /**
* Parse Filters * Parse Filters
* *
@ -5998,7 +5982,6 @@ public class API {
return accounts; return accounts;
} }
/** /**
* Parse json response an unique relationship * Parse json response an unique relationship
* *
@ -6168,6 +6151,13 @@ public class API {
return "https://communitywiki.org/trunk/api/v1" + action; return "https://communitywiki.org/trunk/api/v1" + action;
} }
enum filterFor {
STATUSES_ACCOUNT,
HOME,
LOCAL,
PUBLIC
}
public enum searchType { public enum searchType {
TAGS, TAGS,
STATUSES, STATUSES,

View File

@ -970,7 +970,7 @@ public class Account implements Parcelable {
try { try {
Glide.with(context) Glide.with(context)
.asDrawable() .asDrawable()
.load(disableAnimatedEmoji?emoji.getStatic_url():emoji.getUrl()) .load(disableAnimatedEmoji ? emoji.getStatic_url() : emoji.getUrl())
.into(new SimpleTarget<Drawable>() { .into(new SimpleTarget<Drawable>() {
@Override @Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {

View File

@ -15,9 +15,8 @@ package app.fedilab.android.client.Entities;
* see <http://www.gnu.org/licenses>. */ * see <http://www.gnu.org/licenses>. */
import java.util.Date; import java.util.Date;
import java.util.List;
public class Announcement extends Status{ public class Announcement extends Status {
private Date startAt; private Date startAt;
private Date endAt; private Date endAt;
private boolean all_day; private boolean all_day;

View File

@ -18,11 +18,32 @@ import android.os.Parcelable;
* You should have received a copy of the GNU General Public License along with Fedilab; if not, * You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */ * see <http://www.gnu.org/licenses>. */
public class Reaction implements Parcelable { public class Reaction implements Parcelable {
public static final Creator<Reaction> CREATOR = new Creator<Reaction>() {
@Override
public Reaction createFromParcel(Parcel source) {
return new Reaction(source);
}
@Override
public Reaction[] newArray(int size) {
return new Reaction[size];
}
};
private String name; private String name;
private int count; private int count;
private boolean me; private boolean me;
private String url; private String url;
public Reaction() {
}
protected Reaction(Parcel in) {
this.name = in.readString();
this.count = in.readInt();
this.me = in.readByte() != 0;
this.url = in.readString();
}
public String getName() { public String getName() {
return name; return name;
} }
@ -47,9 +68,6 @@ public class Reaction implements Parcelable {
this.me = me; this.me = me;
} }
public Reaction() {
}
public String getUrl() { public String getUrl() {
return url; return url;
} }
@ -70,23 +88,4 @@ public class Reaction implements Parcelable {
dest.writeByte(this.me ? (byte) 1 : (byte) 0); dest.writeByte(this.me ? (byte) 1 : (byte) 0);
dest.writeString(this.url); dest.writeString(this.url);
} }
protected Reaction(Parcel in) {
this.name = in.readString();
this.count = in.readInt();
this.me = in.readByte() != 0;
this.url = in.readString();
}
public static final Creator<Reaction> CREATOR = new Creator<Reaction>() {
@Override
public Reaction createFromParcel(Parcel source) {
return new Reaction(source);
}
@Override
public Reaction[] newArray(int size) {
return new Reaction[size];
}
};
} }

View File

@ -58,6 +58,7 @@ import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.SimpleTarget; import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.target.Target; import com.bumptech.glide.request.target.Target;
import com.bumptech.glide.request.transition.Transition; import com.bumptech.glide.request.transition.Transition;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.ArrayList; import java.util.ArrayList;
@ -499,6 +500,7 @@ public class Status implements Parcelable {
context.startActivity(intent); context.startActivity(intent);
} }
} }
@Override @Override
public void updateDrawState(@NonNull TextPaint ds) { public void updateDrawState(@NonNull TextPaint ds) {
super.updateDrawState(ds); super.updateDrawState(ds);
@ -619,6 +621,7 @@ public class Status implements Parcelable {
} }
} }
@Override @Override
public void onLongClick(@NonNull View textView) { public void onLongClick(@NonNull View textView) {
PopupMenu popup = new PopupMenu(context, textView); PopupMenu popup = new PopupMenu(context, textView);
@ -937,7 +940,7 @@ public class Status implements Parcelable {
for (final Emojis emoji : emojis) { for (final Emojis emoji : emojis) {
Glide.with(context) Glide.with(context)
.asDrawable() .asDrawable()
.load(disableAnimatedEmoji?emoji.getStatic_url():emoji.getUrl()) .load(disableAnimatedEmoji ? emoji.getStatic_url() : emoji.getUrl())
.listener(new RequestListener<Drawable>() { .listener(new RequestListener<Drawable>() {
@Override @Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) { public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
@ -1031,7 +1034,7 @@ public class Status implements Parcelable {
int finalInc = inc; int finalInc = inc;
Glide.with(context) Glide.with(context)
.asDrawable() .asDrawable()
.load(disableAnimatedEmoji?emoji.getStatic_url():emoji.getUrl()) .load(disableAnimatedEmoji ? emoji.getStatic_url() : emoji.getUrl())
.listener(new RequestListener<Drawable>() { .listener(new RequestListener<Drawable>() {
@Override @Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) { public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {

View File

@ -350,7 +350,6 @@ public class GNUAPI {
} }
/** /**
* Parse json response an unique account * Parse json response an unique account
* *
@ -867,8 +866,6 @@ public class GNUAPI {
} }
public APIResponse getCustomArtTimelineSinceId(boolean local, String tag, String since_id, List<String> any, List<String> all, List<String> none) { public APIResponse getCustomArtTimelineSinceId(boolean local, String tag, String since_id, List<String> any, List<String> all, List<String> none) {
return getArtTimeline(local, tag, null, since_id, any, all, none); return getArtTimeline(local, tag, null, since_id, any, all, none);
} }
@ -1136,7 +1133,6 @@ public class GNUAPI {
} }
/** /**
* Retrieves public timeline for the account *synchronously* * Retrieves public timeline for the account *synchronously*
* *
@ -1791,7 +1787,6 @@ public class GNUAPI {
} }
/** /**
* Retrieves Accounts and feeds when searching *synchronously* * Retrieves Accounts and feeds when searching *synchronously*
* *
@ -1924,8 +1919,6 @@ public class GNUAPI {
} }
/** /**
* Parse json response for list of accounts * Parse json response for list of accounts
* *
@ -2052,7 +2045,6 @@ public class GNUAPI {
} }
private String getAbsoluteRemoteUrl(String instance, String action) { private String getAbsoluteRemoteUrl(String instance, String action) {
return Helper.instanceWithProtocol(this.context, instance) + "/api" + action; return Helper.instanceWithProtocol(this.context, instance) + "/api" + action;
} }

View File

@ -55,6 +55,7 @@ import java.util.Map;
import java.util.Scanner; import java.util.Scanner;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.HttpsURLConnection;
import app.fedilab.android.R; import app.fedilab.android.R;
@ -311,7 +312,7 @@ public class HttpsConnection {
getSinceMaxId(); getSinceMaxId();
httpsURLConnection.getInputStream().close(); httpsURLConnection.getInputStream().close();
return response; return response;
}else{ } else {
if (proxy != null) if (proxy != null)
httpURLConnection = (HttpURLConnection) url.openConnection(proxy); httpURLConnection = (HttpURLConnection) url.openConnection(proxy);
else else

View File

@ -30,6 +30,7 @@ import androidx.annotation.Nullable;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.SimpleTarget; import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition; import com.bumptech.glide.request.transition.Transition;
import java.util.List; import java.util.List;
import app.fedilab.android.R; import app.fedilab.android.R;
@ -83,7 +84,7 @@ public class CustomEmojiAdapter extends BaseAdapter {
SharedPreferences sharedpreferences = parent.getContext().getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); SharedPreferences sharedpreferences = parent.getContext().getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
boolean disableAnimatedEmoji = sharedpreferences.getBoolean(Helper.SET_DISABLE_ANIMATED_EMOJI, false); boolean disableAnimatedEmoji = sharedpreferences.getBoolean(Helper.SET_DISABLE_ANIMATED_EMOJI, false);
Glide.with(parent.getContext()) Glide.with(parent.getContext())
.load(!disableAnimatedEmoji?emoji.getUrl():emoji.getStatic_url()) .load(!disableAnimatedEmoji ? emoji.getUrl() : emoji.getStatic_url())
.thumbnail(0.1f) .thumbnail(0.1f)
.into(new SimpleTarget<Drawable>() { .into(new SimpleTarget<Drawable>() {
@Override @Override

View File

@ -21,10 +21,12 @@ import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import java.util.List; import java.util.List;
import app.fedilab.android.R; import app.fedilab.android.R;
import app.fedilab.android.client.Entities.Reaction; import app.fedilab.android.client.Entities.Reaction;
import app.fedilab.android.helper.Helper; import app.fedilab.android.helper.Helper;
@ -55,17 +57,17 @@ public class ReactionAdapter extends RecyclerView.Adapter {
ViewHolder holder = (ViewHolder) viewHolder; ViewHolder holder = (ViewHolder) viewHolder;
holder.reaction_count.setText(String.valueOf(reaction.getCount())); holder.reaction_count.setText(String.valueOf(reaction.getCount()));
if(reaction.isMe()) { if (reaction.isMe()) {
holder.reaction_container.setBackgroundResource(R.drawable.reaction_voted); holder.reaction_container.setBackgroundResource(R.drawable.reaction_voted);
}else{ } else {
holder.reaction_container.setBackgroundResource(R.drawable.reaction_border); holder.reaction_container.setBackgroundResource(R.drawable.reaction_border);
} }
if(reaction.getUrl() != null){ if (reaction.getUrl() != null) {
holder.reaction_name.setVisibility(View.GONE); holder.reaction_name.setVisibility(View.GONE);
holder.reaction_emoji.setVisibility(View.VISIBLE); holder.reaction_emoji.setVisibility(View.VISIBLE);
holder.reaction_emoji.setContentDescription(reaction.getName()); holder.reaction_emoji.setContentDescription(reaction.getName());
Helper.loadGiF(holder.itemView.getContext(), reaction.getUrl(), holder.reaction_emoji); Helper.loadGiF(holder.itemView.getContext(), reaction.getUrl(), holder.reaction_emoji);
}else{ } else {
holder.reaction_name.setText(reaction.getName()); holder.reaction_name.setText(reaction.getName());
holder.reaction_name.setVisibility(View.VISIBLE); holder.reaction_name.setVisibility(View.VISIBLE);
holder.reaction_emoji.setVisibility(View.GONE); holder.reaction_emoji.setVisibility(View.GONE);

View File

@ -132,7 +132,7 @@ public class SearchListAdapter extends BaseAdapter {
else else
holder.status_search_title.setVisibility(View.GONE); holder.status_search_title.setVisibility(View.GONE);
final float scale = context.getResources().getDisplayMetrics().density; final float scale = context.getResources().getDisplayMetrics().density;
if ((status.getIn_reply_to_account_id() !=null && !status.getIn_reply_to_account_id().equals("null")) || (status.getIn_reply_to_id() != null && !status.getIn_reply_to_id().equals("null"))) { if ((status.getIn_reply_to_account_id() != null && !status.getIn_reply_to_account_id().equals("null")) || (status.getIn_reply_to_id() != null && !status.getIn_reply_to_id().equals("null"))) {
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_reply); Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_reply);
assert img != null; assert img != null;
img.setBounds(0, 0, (int) (20 * scale + 0.5f), (int) (15 * scale + 0.5f)); img.setBounds(0, 0, (int) (20 * scale + 0.5f), (int) (15 * scale + 0.5f));

View File

@ -579,9 +579,9 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
if (social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED && type == RetrieveFeedsAsyncTask.Type.CONTEXT) { if (social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED && type == RetrieveFeedsAsyncTask.Type.CONTEXT) {
return COMPACT_STATUS; return COMPACT_STATUS;
} else { } else {
if( instanceType == null || instanceType.compareTo("NITTER") != 0 ) { if (instanceType == null || instanceType.compareTo("NITTER") != 0) {
return statuses.get(position).getViewType(); return statuses.get(position).getViewType();
}else{ } else {
return COMPACT_STATUS; return COMPACT_STATUS;
} }
} }
@ -1009,8 +1009,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
iconColor = ThemeHelper.getAttColor(context, R.attr.iconColor); iconColor = ThemeHelper.getAttColor(context, R.attr.iconColor);
} }
if( type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA ){ if (type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
if( type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS ) { if (type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS) {
holder.status_account_profile.setVisibility(View.GONE); holder.status_account_profile.setVisibility(View.GONE);
holder.status_account_displayname_owner.setVisibility(View.GONE); holder.status_account_displayname_owner.setVisibility(View.GONE);
holder.status_account_username.setVisibility(View.GONE); holder.status_account_username.setVisibility(View.GONE);
@ -1033,18 +1033,18 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
}).setOnEmojiClickListener((emoji, imageView) -> { }).setOnEmojiClickListener((emoji, imageView) -> {
String emojiStr = imageView.getUnicode(); String emojiStr = imageView.getUnicode();
boolean alreadyAdded = false; boolean alreadyAdded = false;
for(Reaction reaction: status.getReactions()){ for (Reaction reaction : status.getReactions()) {
if( reaction.getName().compareTo(emojiStr) == 0){ if (reaction.getName().compareTo(emojiStr) == 0) {
alreadyAdded = true; alreadyAdded = true;
reaction.setCount(reaction.getCount()-1); reaction.setCount(reaction.getCount() - 1);
if( reaction.getCount() == 0) { if (reaction.getCount() == 0) {
status.getReactions().remove(reaction); status.getReactions().remove(reaction);
} }
notifyStatusChanged(status); notifyStatusChanged(status);
break; break;
} }
} }
if( !alreadyAdded){ if (!alreadyAdded) {
Reaction reaction = new Reaction(); Reaction reaction = new Reaction();
reaction.setMe(true); reaction.setMe(true);
reaction.setCount(1); reaction.setCount(1);
@ -1053,17 +1053,17 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
notifyStatusChanged(status); notifyStatusChanged(status);
} }
API.StatusAction statusAction; API.StatusAction statusAction;
if( type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS ) { if (type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS) {
statusAction = alreadyAdded ? API.StatusAction.REMOVE_REACTION : API.StatusAction.ADD_REACTION; statusAction = alreadyAdded ? API.StatusAction.REMOVE_REACTION : API.StatusAction.ADD_REACTION;
}else{ } else {
statusAction = alreadyAdded ? API.StatusAction.REMOVE_PLEROMA_REACTION : API.StatusAction.ADD_PLEROMA_REACTION; statusAction = alreadyAdded ? API.StatusAction.REMOVE_PLEROMA_REACTION : API.StatusAction.ADD_PLEROMA_REACTION;
} }
new PostActionAsyncTask(context, statusAction, status.getId(), null,emojiStr, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostActionAsyncTask(context, statusAction, status.getId(), null, emojiStr, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}) })
.build(holder.fake_edittext); .build(holder.fake_edittext);
emojiPopup.toggle(); emojiPopup.toggle();
}); });
if( social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) { if (social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
holder.status_add_custom_emoji.setVisibility(View.GONE); holder.status_add_custom_emoji.setVisibility(View.GONE);
} }
holder.status_add_custom_emoji.setOnClickListener(v -> { holder.status_add_custom_emoji.setOnClickListener(v -> {
@ -1090,18 +1090,18 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
gridView.setNumColumns(5); gridView.setNumColumns(5);
gridView.setOnItemClickListener((parent, view, position, id) -> { gridView.setOnItemClickListener((parent, view, position, id) -> {
boolean alreadyAdded = false; boolean alreadyAdded = false;
for(Reaction reaction: status.getReactions()){ for (Reaction reaction : status.getReactions()) {
if( reaction.getName().compareTo(emojis.get(position).getShortcode()) == 0){ if (reaction.getName().compareTo(emojis.get(position).getShortcode()) == 0) {
alreadyAdded = true; alreadyAdded = true;
reaction.setCount(reaction.getCount()-1); reaction.setCount(reaction.getCount() - 1);
if( reaction.getCount() == 0) { if (reaction.getCount() == 0) {
status.getReactions().remove(reaction); status.getReactions().remove(reaction);
} }
notifyStatusChanged(status); notifyStatusChanged(status);
break; break;
} }
} }
if( !alreadyAdded){ if (!alreadyAdded) {
Reaction reaction = new Reaction(); Reaction reaction = new Reaction();
reaction.setMe(true); reaction.setMe(true);
reaction.setCount(1); reaction.setCount(1);
@ -1111,9 +1111,9 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
notifyStatusChanged(status); notifyStatusChanged(status);
} }
API.StatusAction statusAction; API.StatusAction statusAction;
if( type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS ) { if (type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS) {
statusAction = alreadyAdded ? API.StatusAction.REMOVE_REACTION : API.StatusAction.ADD_REACTION; statusAction = alreadyAdded ? API.StatusAction.REMOVE_REACTION : API.StatusAction.ADD_REACTION;
}else{ } else {
statusAction = alreadyAdded ? API.StatusAction.REMOVE_PLEROMA_REACTION : API.StatusAction.ADD_PLEROMA_REACTION; statusAction = alreadyAdded ? API.StatusAction.REMOVE_PLEROMA_REACTION : API.StatusAction.ADD_PLEROMA_REACTION;
} }
new PostActionAsyncTask(context, statusAction, status.getId(), null, emojis.get(position).getShortcode(), StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostActionAsyncTask(context, statusAction, status.getId(), null, emojis.get(position).getShortcode(), StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

View File

@ -4,7 +4,6 @@ import android.Manifest;
import android.app.AlarmManager; import android.app.AlarmManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
@ -94,30 +93,19 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
assert context != null; assert context != null;
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
dialogBuilder.setMessage(R.string.restore_default_theme); dialogBuilder.setMessage(R.string.restore_default_theme);
dialogBuilder.setPositiveButton(R.string.restore, new DialogInterface.OnClickListener() { dialogBuilder.setPositiveButton(R.string.restore, (dialog, id) -> {
@Override
public void onClick(DialogInterface dialog, int id) {
reset(); reset();
dialog.dismiss(); dialog.dismiss();
restart(); restart();
}
}); });
dialogBuilder.setNegativeButton(R.string.store_before, new DialogInterface.OnClickListener() { dialogBuilder.setNegativeButton(R.string.store_before, (dialog, id) -> {
@Override
public void onClick(DialogInterface dialog, int id) {
exportColors(); exportColors();
reset(); reset();
dialog.dismiss(); dialog.dismiss();
restart(); restart();
}
});
dialogBuilder.setNeutralButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
}); });
dialogBuilder.setNeutralButton(R.string.cancel, (dialog, id) -> dialog.dismiss());
AlertDialog alertDialog = dialogBuilder.create(); AlertDialog alertDialog = dialogBuilder.create();
alertDialog.setCancelable(false); alertDialog.setCancelable(false);
alertDialog.show(); alertDialog.show();
@ -152,13 +140,13 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_IMPORT_THEME && resultCode == RESULT_OK) { if (requestCode == PICK_IMPORT_THEME && resultCode == RESULT_OK) {
if (data == null || data.getData() == null) { if (data == null || data.getData() == null) {
Toasty.error(getActivity(), getString(R.string.theme_file_error), Toast.LENGTH_LONG).show(); Toasty.error(Objects.requireNonNull(getActivity()), getString(R.string.theme_file_error), Toast.LENGTH_LONG).show();
return; return;
} }
if (data.getData() != null) { if (data.getData() != null) {
BufferedReader br = null; BufferedReader br = null;
try { try {
InputStream inputStream = getActivity().getContentResolver().openInputStream(data.getData()); InputStream inputStream = Objects.requireNonNull(getActivity()).getContentResolver().openInputStream(data.getData());
assert inputStream != null; assert inputStream != null;
br = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); br = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
String sCurrentLine; String sCurrentLine;
@ -196,18 +184,8 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity()); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
dialogBuilder.setMessage(R.string.restart_message); dialogBuilder.setMessage(R.string.restart_message);
dialogBuilder.setTitle(R.string.apply_changes); dialogBuilder.setTitle(R.string.apply_changes);
dialogBuilder.setPositiveButton(R.string.restart, new DialogInterface.OnClickListener() { dialogBuilder.setPositiveButton(R.string.restart, (dialog, id) -> restart());
@Override dialogBuilder.setNegativeButton(R.string.no, (dialog, id) -> dialog.dismiss());
public void onClick(DialogInterface dialog, int id) {
restart();
}
});
dialogBuilder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
AlertDialog alertDialog = dialogBuilder.create(); AlertDialog alertDialog = dialogBuilder.create();
alertDialog.setCancelable(false); alertDialog.setCancelable(false);
alertDialog.show(); alertDialog.show();
@ -222,7 +200,7 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
} }
} else { } else {
Toasty.error(getActivity(), getString(R.string.theme_file_error), Toast.LENGTH_LONG).show(); Toasty.error(Objects.requireNonNull(getActivity()), getString(R.string.theme_file_error), Toast.LENGTH_LONG).show();
} }
} }
@ -233,7 +211,7 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
Intent mStartActivity = new Intent(getActivity(), MainActivity.class); Intent mStartActivity = new Intent(getActivity(), MainActivity.class);
int mPendingIntentId = 123456; int mPendingIntentId = 123456;
PendingIntent mPendingIntent = PendingIntent.getActivity(getActivity(), mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT); PendingIntent mPendingIntent = PendingIntent.getActivity(getActivity(), mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager mgr = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE); AlarmManager mgr = (AlarmManager) Objects.requireNonNull(getActivity()).getSystemService(Context.ALARM_SERVICE);
assert mgr != null; assert mgr != null;
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent); mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent);
System.exit(0); System.exit(0);
@ -311,7 +289,7 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
pref_import.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { pref_import.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE) != if (ContextCompat.checkSelfPermission(Objects.requireNonNull(getActivity()), Manifest.permission.READ_EXTERNAL_STORAGE) !=
PackageManager.PERMISSION_GRANTED) { PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(getActivity(), ActivityCompat.requestPermissions(getActivity(),
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
@ -336,37 +314,26 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
} }
}); });
reset_pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { reset_pref.setOnPreferenceClickListener(preference -> {
@Override
public boolean onPreferenceClick(Preference preference) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
dialogBuilder.setMessage(R.string.reset_color); dialogBuilder.setMessage(R.string.reset_color);
dialogBuilder.setPositiveButton(R.string.reset, new DialogInterface.OnClickListener() { dialogBuilder.setPositiveButton(R.string.reset, (dialog, id) -> {
@Override
public void onClick(DialogInterface dialog, int id) {
reset(); reset();
dialog.dismiss(); dialog.dismiss();
setPreferenceScreen(null); setPreferenceScreen(null);
addPreferencesFromResource(R.xml.fragment_settings_color); addPreferencesFromResource(R.xml.fragment_settings_color);
}
});
dialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
}); });
dialogBuilder.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss());
AlertDialog alertDialog = dialogBuilder.create(); AlertDialog alertDialog = dialogBuilder.create();
alertDialog.setCancelable(false); alertDialog.setCancelable(false);
alertDialog.show(); alertDialog.show();
return true; return true;
}
}); });
} }
private void reset() { private void reset() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Objects.requireNonNull(getActivity()));
SharedPreferences.Editor editor = prefs.edit(); SharedPreferences.Editor editor = prefs.edit();
editor.remove("theme_boost_header_color"); editor.remove("theme_boost_header_color");
editor.remove("theme_text_header_1_line"); editor.remove("theme_text_header_1_line");
@ -386,7 +353,7 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
private void exportColors() { private void exportColors() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Objects.requireNonNull(getActivity()));
try { try {
String fileName = "Fedilab_color_export_" + Helper.dateFileToString(getActivity(), new Date()) + ".csv"; String fileName = "Fedilab_color_export_" + Helper.dateFileToString(getActivity(), new Date()) + ".csv";
String filePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath(); String filePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath();

View File

@ -69,11 +69,12 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
private String targetedId, instance, name; private String targetedId, instance, name;
private boolean swiped; private boolean swiped;
private RecyclerView lv_accounts; private RecyclerView lv_accounts;
private View rootView;
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_accounts, container, false); rootView = inflater.inflate(R.layout.fragment_accounts, container, false);
context = getContext(); context = getContext();
Bundle bundle = this.getArguments(); Bundle bundle = this.getArguments();
@ -114,7 +115,7 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
mLayoutManager = new LinearLayoutManager(context); mLayoutManager = new LinearLayoutManager(context);
lv_accounts.setLayoutManager(mLayoutManager); lv_accounts.setLayoutManager(mLayoutManager);
lv_accounts.addOnScrollListener(new RecyclerView.OnScrollListener() { lv_accounts.addOnScrollListener(new RecyclerView.OnScrollListener() {
public void onScrolled(RecyclerView recyclerView, int dx, int dy) { public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
if (dy > 0) { if (dy > 0) {
int visibleItemCount = mLayoutManager.getChildCount(); int visibleItemCount = mLayoutManager.getChildCount();
int totalItemCount = mLayoutManager.getItemCount(); int totalItemCount = mLayoutManager.getItemCount();
@ -136,9 +137,7 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
} }
} }
}); });
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { swipeRefreshLayout.setOnRefreshListener(() -> {
@Override
public void onRefresh() {
max_id = null; max_id = null;
accounts = new ArrayList<>(); accounts = new ArrayList<>();
firstLoad = true; firstLoad = true;
@ -150,7 +149,6 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
asyncTask = new RetrieveAccountsAsyncTask(context, instance, name, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); asyncTask = new RetrieveAccountsAsyncTask(context, instance, name, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else else
asyncTask = new RetrieveAccountsAsyncTask(context, type, max_id, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); asyncTask = new RetrieveAccountsAsyncTask(context, type, max_id, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}); });
if (type == RetrieveAccountsAsyncTask.Type.SEARCH || type == RetrieveAccountsAsyncTask.Type.FOLLOWERS || type == RetrieveAccountsAsyncTask.Type.FOLLOWING || type == RetrieveAccountsAsyncTask.Type.REBLOGGED || type == RetrieveAccountsAsyncTask.Type.FAVOURITED) if (type == RetrieveAccountsAsyncTask.Type.SEARCH || type == RetrieveAccountsAsyncTask.Type.FOLLOWERS || type == RetrieveAccountsAsyncTask.Type.FOLLOWING || type == RetrieveAccountsAsyncTask.Type.REBLOGGED || type == RetrieveAccountsAsyncTask.Type.FAVOURITED)
@ -163,6 +161,12 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
return rootView; return rootView;
} }
@Override
public void onDestroyView() {
super.onDestroyView();
rootView = null;
}
@Override @Override
public void onCreate(Bundle saveInstance) { public void onCreate(Bundle saveInstance) {
super.onCreate(saveInstance); super.onCreate(saveInstance);
@ -170,7 +174,7 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
@Override @Override
public void onAttach(Context context) { public void onAttach(@NonNull Context context) {
super.onAttach(context); super.onAttach(context);
this.context = context; this.context = context;
} }
@ -216,7 +220,7 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
if (type == RetrieveAccountsAsyncTask.Type.SEARCH) { if (type == RetrieveAccountsAsyncTask.Type.SEARCH) {
if (max_id == null) if (max_id == null)
max_id = "0"; max_id = "0";
max_id = String.valueOf(Integer.valueOf(max_id) + 20); max_id = String.valueOf(Integer.parseInt(max_id) + 20);
} else { } else {
max_id = apiResponse.getMax_id(); max_id = apiResponse.getMax_id();
} }

View File

@ -27,8 +27,11 @@ import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
import app.fedilab.android.R; import app.fedilab.android.R;
import app.fedilab.android.asynctasks.RetrieveFeedsAsyncTask; import app.fedilab.android.asynctasks.RetrieveFeedsAsyncTask;
import app.fedilab.android.client.APIResponse; import app.fedilab.android.client.APIResponse;
@ -61,7 +64,7 @@ public class DisplayAnnouncementsFragment extends Fragment implements OnRetrieve
mainLoader.setVisibility(View.VISIBLE); mainLoader.setVisibility(View.VISIBLE);
LinearLayoutManager mLayoutManager = new LinearLayoutManager(context); LinearLayoutManager mLayoutManager = new LinearLayoutManager(context);
lv_annoucements.setLayoutManager(mLayoutManager); lv_annoucements.setLayoutManager(mLayoutManager);
asyncTask = new RetrieveFeedsAsyncTask(context, RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS, null,DisplayAnnouncementsFragment.this).execute(); asyncTask = new RetrieveFeedsAsyncTask(context, RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS, null, DisplayAnnouncementsFragment.this).execute();
return rootView; return rootView;
} }
@ -72,6 +75,7 @@ public class DisplayAnnouncementsFragment extends Fragment implements OnRetrieve
if (asyncTask != null && asyncTask.getStatus() == AsyncTask.Status.RUNNING) if (asyncTask != null && asyncTask.getStatus() == AsyncTask.Status.RUNNING)
asyncTask.cancel(true); asyncTask.cancel(true);
} }
@Override @Override
public void onCreate(Bundle saveInstance) { public void onCreate(Bundle saveInstance) {
super.onCreate(saveInstance); super.onCreate(saveInstance);
@ -91,7 +95,7 @@ public class DisplayAnnouncementsFragment extends Fragment implements OnRetrieve
if (apiResponse == null) { if (apiResponse == null) {
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
return; return;
}else { } else {
if (apiResponse.getError() != null) { if (apiResponse.getError() != null) {
if (apiResponse.getError().getError().length() < 100) { if (apiResponse.getError().getError().length() < 100) {
Toasty.error(context, apiResponse.getError().getError(), Toast.LENGTH_LONG).show(); Toasty.error(context, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
@ -102,7 +106,7 @@ public class DisplayAnnouncementsFragment extends Fragment implements OnRetrieve
} }
} }
announcements = apiResponse.getAnnouncements(); announcements = apiResponse.getAnnouncements();
if( announcements == null || announcements.size() == 0 ){ if (announcements == null || announcements.size() == 0) {
textviewNoAction.setVisibility(View.VISIBLE); textviewNoAction.setVisibility(View.VISIBLE);
return; return;
} }

View File

@ -88,6 +88,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
private SharedPreferences sharedpreferences; private SharedPreferences sharedpreferences;
private BroadcastReceiver receive_action; private BroadcastReceiver receive_action;
private BroadcastReceiver receive_data; private BroadcastReceiver receive_data;
private View rootView;
public DisplayNotificationsFragment() { public DisplayNotificationsFragment() {
} }
@ -95,7 +96,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_notifications, container, false); rootView = inflater.inflate(R.layout.fragment_notifications, container, false);
max_id = null; max_id = null;
context = getContext(); context = getContext();
firstLoad = true; firstLoad = true;
@ -210,6 +211,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
return rootView; return rootView;
} }
@Override @Override
public void onCreate(Bundle saveInstance) { public void onCreate(Bundle saveInstance) {
super.onCreate(saveInstance); super.onCreate(saveInstance);
@ -239,6 +241,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
lv_notifications.setAdapter(null); lv_notifications.setAdapter(null);
} }
super.onDestroyView(); super.onDestroyView();
rootView = null;
} }
@Override @Override

View File

@ -144,6 +144,7 @@ public class DisplayStatusFragment extends Fragment implements OnPostActionInter
private Date lastReadTootDate, initialBookMarkDate, updatedBookMarkDate; private Date lastReadTootDate, initialBookMarkDate, updatedBookMarkDate;
private int timelineId; private int timelineId;
private String currentfilter; private String currentfilter;
private View rootView;
public DisplayStatusFragment() { public DisplayStatusFragment() {
} }
@ -151,7 +152,7 @@ public class DisplayStatusFragment extends Fragment implements OnPostActionInter
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_status, container, false); rootView = inflater.inflate(R.layout.fragment_status, container, false);
statuses = new ArrayList<>(); statuses = new ArrayList<>();
peertubes = new ArrayList<>(); peertubes = new ArrayList<>();
context = getContext(); context = getContext();
@ -607,21 +608,21 @@ public class DisplayStatusFragment extends Fragment implements OnPostActionInter
} }
} }
apiResponse.setStatuses(statusesConversations); apiResponse.setStatuses(statusesConversations);
}else if( type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS){ } else if (type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS) {
if( apiResponse.getAnnouncements() != null && apiResponse.getAnnouncements().size() > 0 ){ if (apiResponse.getAnnouncements() != null && apiResponse.getAnnouncements().size() > 0) {
List<Status> statusesAnnouncements = new ArrayList<>(); List<Status> statusesAnnouncements = new ArrayList<>();
apiResponse.setStatuses(statusesAnnouncements); apiResponse.setStatuses(statusesAnnouncements);
for(Announcement announcement: apiResponse.getAnnouncements()){ for (Announcement announcement : apiResponse.getAnnouncements()) {
statusesAnnouncements.add(0,announcement); statusesAnnouncements.add(0, announcement);
if( !announcement.isRead()){ if (!announcement.isRead()) {
new PostActionAsyncTask(context, API.StatusAction.DISMISS_ANNOUNCEMENT, announcement.getId(), DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new PostActionAsyncTask(context, API.StatusAction.DISMISS_ANNOUNCEMENT, announcement.getId(), DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
} }
} }
final NavigationView navigationView = ((MainActivity)context).findViewById(R.id.nav_view); final NavigationView navigationView = ((MainActivity) context).findViewById(R.id.nav_view);
MenuItem item = navigationView.getMenu().findItem(R.id.nav_announcements); MenuItem item = navigationView.getMenu().findItem(R.id.nav_announcements);
TextView actionView = item.getActionView().findViewById(R.id.counter); TextView actionView = item.getActionView().findViewById(R.id.counter);
if(actionView != null) { if (actionView != null) {
actionView.setVisibility(View.GONE); actionView.setVisibility(View.GONE);
} }
} }
@ -752,6 +753,7 @@ public class DisplayStatusFragment extends Fragment implements OnPostActionInter
} }
} }
super.onDestroyView(); super.onDestroyView();
rootView = null;
} }
@Override @Override

View File

@ -55,7 +55,7 @@ import es.dmoral.toasty.Toasty;
public class DisplayStoriesFragment extends Fragment implements OnRetrieveStoriesInterface { public class DisplayStoriesFragment extends Fragment implements OnRetrieveStoriesInterface {
LinearLayoutManager mLayoutManager; private LinearLayoutManager mLayoutManager;
private boolean flag_loading; private boolean flag_loading;
private Context context; private Context context;
private AsyncTask<Void, Void, Void> asyncTask; private AsyncTask<Void, Void, Void> asyncTask;
@ -68,6 +68,7 @@ public class DisplayStoriesFragment extends Fragment implements OnRetrieveStorie
private boolean swiped; private boolean swiped;
private RecyclerView lv_stories; private RecyclerView lv_stories;
private RetrieveStoriesAsyncTask.type type; private RetrieveStoriesAsyncTask.type type;
private View rootView;
public DisplayStoriesFragment() { public DisplayStoriesFragment() {
} }
@ -76,7 +77,7 @@ public class DisplayStoriesFragment extends Fragment implements OnRetrieveStorie
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_stories, container, false); rootView = inflater.inflate(R.layout.fragment_stories, container, false);
Bundle bundle = this.getArguments(); Bundle bundle = this.getArguments();
if (bundle != null) { if (bundle != null) {
@ -243,6 +244,7 @@ public class DisplayStoriesFragment extends Fragment implements OnRetrieveStorie
lv_stories.setAdapter(null); lv_stories.setAdapter(null);
} }
super.onDestroyView(); super.onDestroyView();
rootView = null;
} }
@Override @Override

View File

@ -104,13 +104,14 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
private TextView timerView; private TextView timerView;
private ImageButton playView; private ImageButton playView;
private GLAudioVisualizationView visualizerView; private GLAudioVisualizationView visualizerView;
private View rootView;
public MediaSliderFragment() { public MediaSliderFragment() {
} }
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_slide_media, container, false); rootView = inflater.inflate(R.layout.fragment_slide_media, container, false);
context = getContext(); context = getContext();
Bundle bundle = this.getArguments(); Bundle bundle = this.getArguments();
@ -459,6 +460,12 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
super.onDestroy(); super.onDestroy();
} }
@Override
public void onDestroyView() {
super.onDestroyView();
rootView = null;
}
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
@ -470,7 +477,8 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
} }
try { try {
visualizerView.onResume(); visualizerView.onResume();
} catch (Exception ignored) {} } catch (Exception ignored) {
}
} }
public boolean canSwipe() { public boolean canSwipe() {

View File

@ -30,7 +30,7 @@ public class CountDrawable extends Drawable {
float mTextSize = context.getResources().getDimension(R.dimen.badge_count_textsize); float mTextSize = context.getResources().getDimension(R.dimen.badge_count_textsize);
mBadgePaint = new Paint(); mBadgePaint = new Paint();
mBadgePaint.setColor(ContextCompat.getColor(context.getApplicationContext(), R.color.red_1)); mBadgePaint.setColor(ContextCompat.getColor(context, R.color.red_1));
mBadgePaint.setAntiAlias(true); mBadgePaint.setAntiAlias(true);
mBadgePaint.setStyle(Paint.Style.FILL); mBadgePaint.setStyle(Paint.Style.FILL);

View File

@ -1184,8 +1184,8 @@ public class Helper {
DownloadManager dm = (DownloadManager) context.getSystemService(DOWNLOAD_SERVICE); DownloadManager dm = (DownloadManager) context.getSystemService(DOWNLOAD_SERVICE);
assert dm != null; assert dm != null;
return dm.enqueue(request); return dm.enqueue(request);
}catch (IllegalStateException e){ } catch (IllegalStateException e) {
Toasty.error(context,context.getString(R.string.error_destination_path), Toast.LENGTH_LONG).show(); Toasty.error(context, context.getString(R.string.error_destination_path), Toast.LENGTH_LONG).show();
e.printStackTrace(); e.printStackTrace();
return -1; return -1;
} }
@ -1563,7 +1563,7 @@ public class Helper {
} }
if (!url.equals("null")) if (!url.equals("null"))
Glide.with(navigationView.getContext()) Glide.with(navigationView.getContext())
.load(!disableGif?account.getAvatar():account.getAvatar_static()) .load(!disableGif ? account.getAvatar() : account.getAvatar_static())
.into(new SimpleTarget<Drawable>() { .into(new SimpleTarget<Drawable>() {
@Override @Override
public void onResourceReady(@NonNull Drawable resource, Transition<? super Drawable> transition) { public void onResourceReady(@NonNull Drawable resource, Transition<? super Drawable> transition) {
@ -1588,7 +1588,7 @@ public class Helper {
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
if (!activity.isFinishing()) { if (!activity.isFinishing()) {
menuAccountsOpened = false; menuAccountsOpened = false;
Toasty.info(activity.getApplicationContext(), activity.getString(R.string.toast_account_changed, "@" + account.getAcct() + "@" + account.getInstance()), Toast.LENGTH_LONG).show(); Toasty.info(activity, activity.getString(R.string.toast_account_changed, "@" + account.getAcct() + "@" + account.getInstance()), Toast.LENGTH_LONG).show();
changeUser(activity, account.getId(), account.getInstance(), false); changeUser(activity, account.getId(), account.getInstance(), false);
arrow.setImageResource(R.drawable.ic_arrow_drop_down); arrow.setImageResource(R.drawable.ic_arrow_drop_down);
return true; return true;
@ -2016,7 +2016,7 @@ public class Helper {
return false; return false;
} }
}) })
.load(!disableGif?accountChoice.getAvatar():accountChoice.getAvatar_static()) .load(!disableGif ? accountChoice.getAvatar() : accountChoice.getAvatar_static())
.into(new SimpleTarget<Drawable>() { .into(new SimpleTarget<Drawable>() {
@Override @Override
public void onResourceReady(@NonNull Drawable resource, Transition<? super Drawable> transition) { public void onResourceReady(@NonNull Drawable resource, Transition<? super Drawable> transition) {
@ -2051,10 +2051,10 @@ public class Helper {
if (!accountChoice.getAvatar().startsWith("http")) if (!accountChoice.getAvatar().startsWith("http"))
accountChoice.setAvatar("https://" + accountChoice.getInstance() + accountChoice.getAvatar()); accountChoice.setAvatar("https://" + accountChoice.getInstance() + accountChoice.getAvatar());
ImageView itemIconAcc = new ImageView(activity); ImageView itemIconAcc = new ImageView(activity);
Glide.with(activity.getApplicationContext()) Glide.with(activity)
.asDrawable() .asDrawable()
.apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(270))) .apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(270)))
.load(!disableGif?accountChoice.getAvatar():accountChoice.getAvatar_static()) .load(!disableGif ? accountChoice.getAvatar() : accountChoice.getAvatar_static())
.listener(new RequestListener<Drawable>() { .listener(new RequestListener<Drawable>() {
@Override @Override
@ -2099,7 +2099,7 @@ public class Helper {
editor.putBoolean(Helper.PREF_IS_ADMINISTRATOR, accountChoice.isAdmin()); editor.putBoolean(Helper.PREF_IS_ADMINISTRATOR, accountChoice.isAdmin());
editor.commit(); editor.commit();
if (accountChoice.getSocial() != null && accountChoice.getSocial().equals("PEERTUBE")) if (accountChoice.getSocial() != null && accountChoice.getSocial().equals("PEERTUBE"))
Toasty.info(activity.getApplicationContext(), activity.getString(R.string.toast_account_changed, "@" + accountChoice.getAcct()), Toast.LENGTH_LONG).show(); Toasty.info(activity, activity.getString(R.string.toast_account_changed, "@" + accountChoice.getAcct()), Toast.LENGTH_LONG).show();
else else
Toasty.info(activity, activity.getString(R.string.toast_account_changed, "@" + accountChoice.getUsername() + "@" + accountChoice.getInstance()), Toast.LENGTH_LONG).show(); Toasty.info(activity, activity.getString(R.string.toast_account_changed, "@" + accountChoice.getUsername() + "@" + accountChoice.getInstance()), Toast.LENGTH_LONG).show();
Intent changeAccount = new Intent(activity, MainActivity.class); Intent changeAccount = new Intent(activity, MainActivity.class);
@ -2181,7 +2181,7 @@ public class Helper {
if (account == null) { if (account == null) {
Helper.logout(activity); Helper.logout(activity);
Intent myIntent = new Intent(activity, LoginActivity.class); Intent myIntent = new Intent(activity, LoginActivity.class);
Toasty.error(activity.getApplicationContext(), activity.getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(activity, activity.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
activity.startActivity(myIntent); activity.startActivity(myIntent);
activity.finish(); //User is logged out to get a new token activity.finish(); //User is logged out to get a new token
} else { } else {
@ -2189,7 +2189,7 @@ public class Helper {
username.setText(String.format("@%s", account.getUsername() + "@" + account.getInstance())); username.setText(String.format("@%s", account.getUsername() + "@" + account.getInstance()));
displayedName.setText(account.getdisplayNameSpan(), TextView.BufferType.SPANNABLE); displayedName.setText(account.getdisplayNameSpan(), TextView.BufferType.SPANNABLE);
loadGiF(activity, account, profilePicture); loadGiF(activity, account, profilePicture);
String urlHeader = !disableGif?account.getHeader():account.getHeader_static(); String urlHeader = !disableGif ? account.getHeader() : account.getHeader_static();
if (urlHeader.startsWith("/")) { if (urlHeader.startsWith("/")) {
urlHeader = Helper.getLiveInstanceWithProtocol(activity) + account.getHeader(); urlHeader = Helper.getLiveInstanceWithProtocol(activity) + account.getHeader();
} }
@ -2198,7 +2198,7 @@ public class Helper {
ImageView header_option_menu = headerLayout.findViewById(R.id.header_option_menu); ImageView header_option_menu = headerLayout.findViewById(R.id.header_option_menu);
if (!urlHeader.contains("missing.png")) { if (!urlHeader.contains("missing.png")) {
ImageView backgroundImage = headerLayout.findViewById(R.id.back_ground_image); ImageView backgroundImage = headerLayout.findViewById(R.id.back_ground_image);
Glide.with(activity.getApplicationContext()) Glide.with(activity)
.asDrawable() .asDrawable()
.load(urlHeader) .load(urlHeader)
.into(new SimpleTarget<Drawable>() { .into(new SimpleTarget<Drawable>() {
@ -3278,11 +3278,10 @@ public class Helper {
} }
public static void loadGiF(final Context context, Account account, final ImageView imageView) { public static void loadGiF(final Context context, Account account, final ImageView imageView) {
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
boolean disableGif = sharedpreferences.getBoolean(SET_DISABLE_GIF, false); boolean disableGif = sharedpreferences.getBoolean(SET_DISABLE_GIF, false);
String url = disableGif?account.getAvatar_static():account.getAvatar(); String url = disableGif ? account.getAvatar_static() : account.getAvatar();
if (url != null && url.startsWith("/")) { if (url != null && url.startsWith("/")) {
url = Helper.getLiveInstanceWithProtocol(context) + url; url = Helper.getLiveInstanceWithProtocol(context) + url;
} }
@ -3291,14 +3290,14 @@ public class Helper {
} }
try { try {
assert url != null; assert url != null;
if( disableGif || (!url.endsWith(".gif") && account.getAvatar_static().compareTo(account.getAvatar()) == 0 )) { if (disableGif || (!url.endsWith(".gif") && account.getAvatar_static().compareTo(account.getAvatar()) == 0)) {
Glide.with(imageView.getContext()) Glide.with(imageView.getContext())
.asDrawable() .asDrawable()
.load(url) .load(url)
.thumbnail(0.1f) .thumbnail(0.1f)
.apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10))) .apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
.into(imageView); .into(imageView);
}else{ } else {
Glide.with(imageView.getContext()) Glide.with(imageView.getContext())
.asGif() .asGif()
.load(url) .load(url)
@ -3664,7 +3663,7 @@ public class Helper {
String selection = null; String selection = null;
String[] selectionArgs = null; String[] selectionArgs = null;
// Uri is different in versions after KITKAT (Android 4.4), we need to // Uri is different in versions after KITKAT (Android 4.4), we need to
if (Build.VERSION.SDK_INT >= 19 && DocumentsContract.isDocumentUri(context.getApplicationContext(), uri)) { if (Build.VERSION.SDK_INT >= 19 && DocumentsContract.isDocumentUri(context, uri)) {
if (isExternalStorageDocument(uri)) { if (isExternalStorageDocument(uri)) {
final String docId = DocumentsContract.getDocumentId(uri); final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":"); final String[] split = docId.split(":");

View File

@ -97,7 +97,7 @@ public class BackupNotificationInDataBaseService extends IntentService {
@Override @Override
public void run() { public void run() {
if (finalToastMessage) { if (finalToastMessage) {
Toasty.info(getApplicationContext(), getString(R.string.data_export_start), Toast.LENGTH_LONG).show(); Toasty.info(BackupNotificationInDataBaseService.this, getString(R.string.data_export_start), Toast.LENGTH_LONG).show();
} }
} }
}); });
@ -106,7 +106,7 @@ public class BackupNotificationInDataBaseService extends IntentService {
@Override @Override
public void run() { public void run() {
if (finalToastMessage) { if (finalToastMessage) {
Toasty.info(getApplicationContext(), getString(R.string.data_export_running), Toast.LENGTH_LONG).show(); Toasty.info(BackupNotificationInDataBaseService.this, getString(R.string.data_export_running), Toast.LENGTH_LONG).show();
} }
} }
}); });
@ -115,8 +115,8 @@ public class BackupNotificationInDataBaseService extends IntentService {
instanceRunning++; instanceRunning++;
String message; String message;
SQLiteDatabase db = Sqlite.getInstance(BackupNotificationInDataBaseService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(BackupNotificationInDataBaseService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance); Account account = new AccountDAO(BackupNotificationInDataBaseService.this, db).getUniqAccount(userId, instance);
API api = new API(getApplicationContext(), account.getInstance(), account.getToken()); API api = new API(BackupNotificationInDataBaseService.this, account.getInstance(), account.getToken());
try { try {
//Starts from the last recorded ID //Starts from the last recorded ID
String lastId = new NotificationCacheDAO(BackupNotificationInDataBaseService.this, db).getLastNotificationIDCache(userId, instance); String lastId = new NotificationCacheDAO(BackupNotificationInDataBaseService.this, db).getLastNotificationIDCache(userId, instance);
@ -154,8 +154,8 @@ public class BackupNotificationInDataBaseService extends IntentService {
String title = getString(R.string.data_backup_toots, account.getAcct()); String title = getString(R.string.data_backup_toots, account.getAcct());
if (finalToastMessage) { if (finalToastMessage) {
Helper.notify_user(getApplicationContext(), account, mainActivity, BitmapFactory.decodeResource(getResources(), Helper.notify_user(BackupNotificationInDataBaseService.this, account, mainActivity, BitmapFactory.decodeResource(getResources(),
Helper.getMainLogo(getApplicationContext())), Helper.NotifType.BACKUP, title, message); Helper.getMainLogo(BackupNotificationInDataBaseService.this)), Helper.NotifType.BACKUP, title, message);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -165,7 +165,7 @@ public class BackupNotificationInDataBaseService extends IntentService {
@Override @Override
public void run() { public void run() {
if (finalToastMessage) { if (finalToastMessage) {
Toasty.error(getApplicationContext(), finalMessage, Toast.LENGTH_LONG).show(); Toasty.error(BackupNotificationInDataBaseService.this, finalMessage, Toast.LENGTH_LONG).show();
} }
} }
}); });

View File

@ -98,7 +98,7 @@ public class BackupStatusInDataBaseService extends IntentService {
@Override @Override
public void run() { public void run() {
if (finalToastMessage) { if (finalToastMessage) {
Toasty.info(getApplicationContext(), getString(R.string.data_export_start), Toast.LENGTH_LONG).show(); Toasty.info(BackupStatusInDataBaseService.this, getString(R.string.data_export_start), Toast.LENGTH_LONG).show();
} }
} }
}); });
@ -107,7 +107,7 @@ public class BackupStatusInDataBaseService extends IntentService {
@Override @Override
public void run() { public void run() {
if (finalToastMessage) { if (finalToastMessage) {
Toasty.info(getApplicationContext(), getString(R.string.data_export_running), Toast.LENGTH_LONG).show(); Toasty.info(BackupStatusInDataBaseService.this, getString(R.string.data_export_running), Toast.LENGTH_LONG).show();
} }
} }
}); });
@ -116,8 +116,8 @@ public class BackupStatusInDataBaseService extends IntentService {
instanceRunning++; instanceRunning++;
String message; String message;
SQLiteDatabase db = Sqlite.getInstance(BackupStatusInDataBaseService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(BackupStatusInDataBaseService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance); Account account = new AccountDAO(BackupStatusInDataBaseService.this, db).getUniqAccount(userId, instance);
API api = new API(getApplicationContext(), account.getInstance(), account.getToken()); API api = new API(BackupStatusInDataBaseService.this, account.getInstance(), account.getToken());
try { try {
//Starts from the last recorded ID //Starts from the last recorded ID
Date sinceDate = new StatusCacheDAO(BackupStatusInDataBaseService.this, db).getLastTootDateCache(StatusCacheDAO.ARCHIVE_CACHE, userId, instance); Date sinceDate = new StatusCacheDAO(BackupStatusInDataBaseService.this, db).getLastTootDateCache(StatusCacheDAO.ARCHIVE_CACHE, userId, instance);
@ -152,8 +152,8 @@ public class BackupStatusInDataBaseService extends IntentService {
mainActivity.putExtra(Helper.INTENT_ACTION, Helper.BACKUP_INTENT); mainActivity.putExtra(Helper.INTENT_ACTION, Helper.BACKUP_INTENT);
String title = getString(R.string.data_backup_toots, account.getAcct()); String title = getString(R.string.data_backup_toots, account.getAcct());
if (finalToastMessage) { if (finalToastMessage) {
Helper.notify_user(getApplicationContext(), account, mainActivity, BitmapFactory.decodeResource(getResources(), Helper.notify_user(BackupStatusInDataBaseService.this, account, mainActivity, BitmapFactory.decodeResource(getResources(),
Helper.getMainLogo(getApplicationContext())), Helper.NotifType.BACKUP, title, message); Helper.getMainLogo(BackupStatusInDataBaseService.this)), Helper.NotifType.BACKUP, title, message);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -163,7 +163,7 @@ public class BackupStatusInDataBaseService extends IntentService {
@Override @Override
public void run() { public void run() {
if (finalToastMessage) { if (finalToastMessage) {
Toasty.error(getApplicationContext(), finalMessage, Toast.LENGTH_LONG).show(); Toasty.error(BackupStatusInDataBaseService.this, finalMessage, Toast.LENGTH_LONG).show();
} }
} }
}); });

View File

@ -89,14 +89,14 @@ public class BackupStatusService extends IntentService {
new Handler(Looper.getMainLooper()).post(new Runnable() { new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override @Override
public void run() { public void run() {
Toasty.info(getApplicationContext(), getString(R.string.data_export_start), Toast.LENGTH_LONG).show(); Toasty.info(BackupStatusService.this, getString(R.string.data_export_start), Toast.LENGTH_LONG).show();
} }
}); });
} else { } else {
new Handler(Looper.getMainLooper()).post(new Runnable() { new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override @Override
public void run() { public void run() {
Toasty.info(getApplicationContext(), getString(R.string.data_export_running), Toast.LENGTH_LONG).show(); Toasty.info(BackupStatusService.this, getString(R.string.data_export_running), Toast.LENGTH_LONG).show();
} }
}); });
return; return;
@ -107,8 +107,8 @@ public class BackupStatusService extends IntentService {
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, 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(BackupStatusService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance); Account account = new AccountDAO(BackupStatusService.this, db).getUniqAccount(userId, instance);
API api = new API(getApplicationContext(), account.getInstance(), account.getToken()); API api = new API(BackupStatusService.this, account.getInstance(), account.getToken());
try { try {
String fullPath; String fullPath;
Intent intentOpen; Intent intentOpen;
@ -128,7 +128,7 @@ public class BackupStatusService extends IntentService {
} }
} while (max_id != null); } while (max_id != null);
String fileName = account.getAcct() + "@" + account.getInstance() + Helper.dateFileToString(getApplicationContext(), new Date()) + ".csv"; String fileName = account.getAcct() + "@" + account.getInstance() + Helper.dateFileToString(BackupStatusService.this, new Date()) + ".csv";
String filePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath(); String filePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath();
fullPath = filePath + "/" + fileName; fullPath = filePath + "/" + fileName;
PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(new File(fullPath)), StandardCharsets.UTF_8)); PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(new File(fullPath)), StandardCharsets.UTF_8));
@ -167,7 +167,7 @@ public class BackupStatusService extends IntentService {
//noinspection deprecation //noinspection deprecation
content = Html.fromHtml(status.getContent()).toString(); content = Html.fromHtml(status.getContent()).toString();
builder.append("\"").append(content.replace("\"", "'").replace("\n", " ")).append("\"").append(','); builder.append("\"").append(content.replace("\"", "'").replace("\n", " ")).append("\"").append(',');
builder.append("\"").append(Helper.shortDateTime(getApplicationContext(), status.getCreated_at())).append("\"").append(','); builder.append("\"").append(Helper.shortDateTime(BackupStatusService.this, status.getCreated_at())).append("\"").append(',');
builder.append("\"").append(status.getReblogs_count()).append("\"").append(','); builder.append("\"").append(status.getReblogs_count()).append("\"").append(',');
builder.append("\"").append(status.getFavourites_count()).append("\"").append(','); builder.append("\"").append(status.getFavourites_count()).append("\"").append(',');
builder.append("\"").append(status.isSensitive()).append("\"").append(','); builder.append("\"").append(status.isSensitive()).append("\"").append(',');
@ -192,8 +192,8 @@ public class BackupStatusService extends IntentService {
Uri uri = Uri.parse("file://" + fullPath); Uri uri = Uri.parse("file://" + fullPath);
intentOpen.setDataAndType(uri, "text/csv"); intentOpen.setDataAndType(uri, "text/csv");
String title = getString(R.string.data_export_toots, account.getAcct()); String title = getString(R.string.data_export_toots, account.getAcct());
Helper.notify_user(getApplicationContext(), account, intentOpen, BitmapFactory.decodeResource(getResources(), Helper.notify_user(BackupStatusService.this, account, intentOpen, BitmapFactory.decodeResource(getResources(),
Helper.getMainLogo(getApplicationContext())), Helper.NotifType.BACKUP, title, message); Helper.getMainLogo(BackupStatusService.this)), Helper.NotifType.BACKUP, title, message);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
message = getString(R.string.data_export_error, account.getAcct()); message = getString(R.string.data_export_error, account.getAcct());
@ -201,7 +201,7 @@ public class BackupStatusService extends IntentService {
new Handler(Looper.getMainLooper()).post(new Runnable() { new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override @Override
public void run() { public void run() {
Toasty.error(getApplicationContext(), finalMessage, Toast.LENGTH_LONG).show(); Toasty.error(BackupStatusService.this, finalMessage, Toast.LENGTH_LONG).show();
} }
}); });
} }

View File

@ -99,8 +99,8 @@ public class LiveNotificationDelayedService extends Service {
((NotificationManager) Objects.requireNonNull(getSystemService(Context.NOTIFICATION_SERVICE))).createNotificationChannel(channel); ((NotificationManager) Objects.requireNonNull(getSystemService(Context.NOTIFICATION_SERVICE))).createNotificationChannel(channel);
} }
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(LiveNotificationDelayedService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
List<Account> accountStreams = new AccountDAO(getApplicationContext(), db).getAllAccountCrossAction(); List<Account> accountStreams = new AccountDAO(LiveNotificationDelayedService.this, db).getAllAccountCrossAction();
totalAccount = 0; totalAccount = 0;
if (accountStreams != null) { if (accountStreams != null) {
for (Account account : accountStreams) { for (Account account : accountStreams) {
@ -112,9 +112,9 @@ public class LiveNotificationDelayedService extends Service {
} }
if (Build.VERSION.SDK_INT >= 26) { if (Build.VERSION.SDK_INT >= 26) {
Intent myIntent = new Intent(getApplicationContext(), MainActivity.class); Intent myIntent = new Intent(LiveNotificationDelayedService.this, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity( PendingIntent pendingIntent = PendingIntent.getActivity(
getApplicationContext(), LiveNotificationDelayedService.this,
0, 0,
myIntent, myIntent,
PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent.FLAG_UPDATE_CURRENT);
@ -123,7 +123,7 @@ public class LiveNotificationDelayedService extends Service {
.setShowWhen(false) .setShowWhen(false)
.setContentIntent(pendingIntent) .setContentIntent(pendingIntent)
.setContentTitle(getString(R.string.top_notification)) .setContentTitle(getString(R.string.top_notification))
.setSmallIcon(getNotificationIcon(getApplicationContext())) .setSmallIcon(getNotificationIcon(LiveNotificationDelayedService.this))
.setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build(); .setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build();
startForeground(1, notification); startForeground(1, notification);
} }
@ -180,9 +180,9 @@ public class LiveNotificationDelayedService extends Service {
private void startStream() { private void startStream() {
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(LiveNotificationDelayedService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
if (Helper.liveNotifType(getApplicationContext()) == Helper.NOTIF_DELAYED) { if (Helper.liveNotifType(LiveNotificationDelayedService.this) == Helper.NOTIF_DELAYED) {
List<Account> accountStreams = new AccountDAO(getApplicationContext(), db).getAllAccountCrossAction(); List<Account> accountStreams = new AccountDAO(LiveNotificationDelayedService.this, db).getAllAccountCrossAction();
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
fetch = true; fetch = true;
if (accountStreams != null) { if (accountStreams != null) {
@ -213,7 +213,7 @@ public class LiveNotificationDelayedService extends Service {
public void run() { public void run() {
while (fetch) { while (fetch) {
taks(accountStream); taks(accountStream);
fetch = (Helper.liveNotifType(getApplicationContext()) == Helper.NOTIF_DELAYED); fetch = (Helper.liveNotifType(LiveNotificationDelayedService.this) == Helper.NOTIF_DELAYED);
if (sleeps.containsKey(key) && sleeps.get(key) != null) { if (sleeps.containsKey(key) && sleeps.get(key) != null) {
try { try {
Thread.sleep(sleeps.get(key)); Thread.sleep(sleeps.get(key));
@ -247,11 +247,11 @@ public class LiveNotificationDelayedService extends Service {
try { try {
if (account.getSocial().compareTo("FRIENDICA") != 0 && account.getSocial().compareTo("GNU") != 0) { if (account.getSocial().compareTo("FRIENDICA") != 0 && account.getSocial().compareTo("GNU") != 0) {
API api; API api;
api = new API(getApplicationContext(), account.getInstance(), account.getToken()); api = new API(LiveNotificationDelayedService.this, account.getInstance(), account.getToken());
apiResponse = api.getNotificationsSince(DisplayNotificationsFragment.Type.ALL, last_notifid, false); apiResponse = api.getNotificationsSince(DisplayNotificationsFragment.Type.ALL, last_notifid, false);
} else { } else {
GNUAPI gnuApi; GNUAPI gnuApi;
gnuApi = new GNUAPI(getApplicationContext(), account.getInstance(), account.getToken()); gnuApi = new GNUAPI(LiveNotificationDelayedService.this, account.getInstance(), account.getToken());
apiResponse = gnuApi.getNotificationsSince(DisplayNotificationsFragment.Type.ALL, last_notifid); apiResponse = gnuApi.getNotificationsSince(DisplayNotificationsFragment.Type.ALL, last_notifid);
} }
} catch (Exception ignored) { } catch (Exception ignored) {
@ -309,14 +309,14 @@ public class LiveNotificationDelayedService extends Service {
android.app.Notification notificationChannel = new NotificationCompat.Builder(this, CHANNEL_ID) android.app.Notification notificationChannel = new NotificationCompat.Builder(this, CHANNEL_ID)
.setShowWhen(false) .setShowWhen(false)
.setContentTitle(getString(R.string.top_notification)) .setContentTitle(getString(R.string.top_notification))
.setSmallIcon(getNotificationIcon(getApplicationContext())) .setSmallIcon(getNotificationIcon(LiveNotificationDelayedService.this))
.setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build(); .setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build();
startForeground(1, notificationChannel); startForeground(1, notificationChannel);
} }
event = Helper.EventStreaming.NOTIFICATION; event = Helper.EventStreaming.NOTIFICATION;
boolean canNotify = Helper.canNotify(getApplicationContext()); boolean canNotify = Helper.canNotify(LiveNotificationDelayedService.this);
boolean notify = sharedpreferences.getBoolean(Helper.SET_NOTIFY, true); boolean notify = sharedpreferences.getBoolean(Helper.SET_NOTIFY, true);
String targeted_account = null; String targeted_account = null;
Helper.NotifType notifType = Helper.NotifType.MENTION; Helper.NotifType notifType = Helper.NotifType.MENTION;
@ -421,7 +421,7 @@ public class LiveNotificationDelayedService extends Service {
} }
//Some others notification //Some others notification
final Intent intent = new Intent(getApplicationContext(), MainActivity.class); final Intent intent = new Intent(LiveNotificationDelayedService.this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(Helper.INTENT_ACTION, Helper.NOTIFICATION_INTENT); intent.putExtra(Helper.INTENT_ACTION, Helper.NOTIFICATION_INTENT);
intent.putExtra(Helper.PREF_KEY_ID, account.getId()); intent.putExtra(Helper.PREF_KEY_ID, account.getId());
@ -436,7 +436,7 @@ public class LiveNotificationDelayedService extends Service {
@Override @Override
public void run() { public void run() {
if (finalMessage != null) { if (finalMessage != null) {
Glide.with(getApplicationContext()) Glide.with(LiveNotificationDelayedService.this)
.asBitmap() .asBitmap()
.load(notification.getAccount().getAvatar()) .load(notification.getAccount().getAvatar())
.listener(new RequestListener<Bitmap>() { .listener(new RequestListener<Bitmap>() {
@ -447,8 +447,8 @@ public class LiveNotificationDelayedService extends Service {
@Override @Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
Helper.notify_user(getApplicationContext(), account, intent, BitmapFactory.decodeResource(getResources(), Helper.notify_user(LiveNotificationDelayedService.this, account, intent, BitmapFactory.decodeResource(getResources(),
getMainLogo(getApplicationContext())), finalNotifType, "@" + notification.getAccount().getAcct(), finalMessage); getMainLogo(LiveNotificationDelayedService.this)), finalNotifType, "@" + notification.getAccount().getAcct(), finalMessage);
return false; return false;
} }
}) })
@ -456,7 +456,7 @@ public class LiveNotificationDelayedService extends Service {
@Override @Override
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) { public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
Helper.notify_user(getApplicationContext(), account, intent, resource, finalNotifType, "@" + notification.getAccount().getAcct(), finalMessage); Helper.notify_user(LiveNotificationDelayedService.this, account, intent, resource, finalNotifType, "@" + notification.getAccount().getAcct(), finalMessage);
} }
}); });
} }
@ -472,7 +472,7 @@ public class LiveNotificationDelayedService extends Service {
intentBC.putExtra("eventStreaming", event); intentBC.putExtra("eventStreaming", event);
intentBC.putExtras(b); intentBC.putExtras(b);
b.putParcelable("data", notification); b.putParcelable("data", notification);
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intentBC); LocalBroadcastManager.getInstance(LiveNotificationDelayedService.this).sendBroadcast(intentBC);
SharedPreferences.Editor editor = sharedpreferences.edit(); SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + account.getId() + account.getInstance(), notification.getId()); editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + account.getId() + account.getInstance(), notification.getId());
editor.apply(); editor.apply();

View File

@ -117,8 +117,8 @@ public class LiveNotificationService extends Service implements NetworkStateRece
((NotificationManager) Objects.requireNonNull(getSystemService(Context.NOTIFICATION_SERVICE))).createNotificationChannel(channel); ((NotificationManager) Objects.requireNonNull(getSystemService(Context.NOTIFICATION_SERVICE))).createNotificationChannel(channel);
} }
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(LiveNotificationService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
List<Account> accountStreams = new AccountDAO(getApplicationContext(), db).getAllAccountCrossAction(); List<Account> accountStreams = new AccountDAO(LiveNotificationService.this, db).getAllAccountCrossAction();
totalAccount = 0; totalAccount = 0;
if (accountStreams != null) { if (accountStreams != null) {
for (Account account : accountStreams) { for (Account account : accountStreams) {
@ -131,16 +131,16 @@ public class LiveNotificationService extends Service implements NetworkStateRece
} }
} }
if (Build.VERSION.SDK_INT >= 26) { if (Build.VERSION.SDK_INT >= 26) {
Intent myIntent = new Intent(getApplicationContext(), MainActivity.class); Intent myIntent = new Intent(LiveNotificationService.this, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity( PendingIntent pendingIntent = PendingIntent.getActivity(
getApplicationContext(), LiveNotificationService.this,
0, 0,
myIntent, myIntent,
PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent.FLAG_UPDATE_CURRENT);
android.app.Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID) android.app.Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle(getString(R.string.top_notification)) .setContentTitle(getString(R.string.top_notification))
.setContentIntent(pendingIntent) .setContentIntent(pendingIntent)
.setSmallIcon(getNotificationIcon(getApplicationContext())) .setSmallIcon(getNotificationIcon(LiveNotificationService.this))
.setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build(); .setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build();
startForeground(1, notification); startForeground(1, notification);
@ -158,9 +158,9 @@ public class LiveNotificationService extends Service implements NetworkStateRece
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
boolean liveNotifications = sharedpreferences.getBoolean(Helper.SET_LIVE_NOTIFICATIONS, true); boolean liveNotifications = sharedpreferences.getBoolean(Helper.SET_LIVE_NOTIFICATIONS, true);
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(LiveNotificationService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
if (liveNotifications) { if (liveNotifications) {
List<Account> accountStreams = new AccountDAO(getApplicationContext(), db).getAllAccountCrossAction(); List<Account> accountStreams = new AccountDAO(LiveNotificationService.this, db).getAllAccountCrossAction();
if (accountStreams != null) { if (accountStreams != null) {
for (final Account accountStream : accountStreams) { for (final Account accountStream : accountStreams) {
if (accountStream.getSocial() == null || accountStream.getSocial().equals("MASTODON") || accountStream.getSocial().equals("PLEROMA")) { if (accountStream.getSocial() == null || accountStream.getSocial().equals("MASTODON") || accountStream.getSocial().equals("PLEROMA")) {
@ -329,20 +329,20 @@ public class LiveNotificationService extends Service implements NetworkStateRece
((NotificationManager) Objects.requireNonNull(getSystemService(Context.NOTIFICATION_SERVICE))).createNotificationChannel(channel); ((NotificationManager) Objects.requireNonNull(getSystemService(Context.NOTIFICATION_SERVICE))).createNotificationChannel(channel);
android.app.Notification notificationChannel = new NotificationCompat.Builder(this, CHANNEL_ID) android.app.Notification notificationChannel = new NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle(getString(R.string.top_notification)) .setContentTitle(getString(R.string.top_notification))
.setSmallIcon(getNotificationIcon(getApplicationContext())) .setSmallIcon(getNotificationIcon(LiveNotificationService.this))
.setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build(); .setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build();
startForeground(1, notificationChannel); startForeground(1, notificationChannel);
} }
event = Helper.EventStreaming.NOTIFICATION; event = Helper.EventStreaming.NOTIFICATION;
notification = API.parseNotificationResponse(getApplicationContext(), new JSONObject(response.get("payload").toString())); notification = API.parseNotificationResponse(LiveNotificationService.this, new JSONObject(response.get("payload").toString()));
if (notification == null) { if (notification == null) {
return; return;
} }
b.putParcelable("data", notification); b.putParcelable("data", notification);
boolean liveNotifications = sharedpreferences.getBoolean(Helper.SET_LIVE_NOTIFICATIONS, true); boolean liveNotifications = sharedpreferences.getBoolean(Helper.SET_LIVE_NOTIFICATIONS, true);
boolean canNotify = Helper.canNotify(getApplicationContext()); boolean canNotify = Helper.canNotify(LiveNotificationService.this);
boolean notify = sharedpreferences.getBoolean(Helper.SET_NOTIFY, true); boolean notify = sharedpreferences.getBoolean(Helper.SET_NOTIFY, true);
String targeted_account = null; String targeted_account = null;
Helper.NotifType notifType = Helper.NotifType.MENTION; Helper.NotifType notifType = Helper.NotifType.MENTION;
@ -456,7 +456,7 @@ public class LiveNotificationService extends Service implements NetworkStateRece
default: default:
} }
//Some others notification //Some others notification
final Intent intent = new Intent(getApplicationContext(), MainActivity.class); final Intent intent = new Intent(LiveNotificationService.this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(Helper.INTENT_ACTION, Helper.NOTIFICATION_INTENT); intent.putExtra(Helper.INTENT_ACTION, Helper.NOTIFICATION_INTENT);
intent.putExtra(Helper.PREF_KEY_ID, account.getId()); intent.putExtra(Helper.PREF_KEY_ID, account.getId());
@ -471,7 +471,7 @@ public class LiveNotificationService extends Service implements NetworkStateRece
@Override @Override
public void run() { public void run() {
if (finalMessage != null) { if (finalMessage != null) {
Glide.with(getApplicationContext()) Glide.with(LiveNotificationService.this)
.asBitmap() .asBitmap()
.load(notification.getAccount().getAvatar()) .load(notification.getAccount().getAvatar())
.listener(new RequestListener<Bitmap>() { .listener(new RequestListener<Bitmap>() {
@ -482,8 +482,8 @@ public class LiveNotificationService extends Service implements NetworkStateRece
@Override @Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
Helper.notify_user(getApplicationContext(), account, intent, BitmapFactory.decodeResource(getResources(), Helper.notify_user(LiveNotificationService.this, account, intent, BitmapFactory.decodeResource(getResources(),
getMainLogo(getApplicationContext())), finalNotifType, "@" + notification.getAccount().getAcct(), finalMessage); getMainLogo(LiveNotificationService.this)), finalNotifType, "@" + notification.getAccount().getAcct(), finalMessage);
return false; return false;
} }
}) })
@ -491,7 +491,7 @@ public class LiveNotificationService extends Service implements NetworkStateRece
@Override @Override
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) { public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
Helper.notify_user(getApplicationContext(), account, intent, resource, finalNotifType, "@" + notification.getAccount().getAcct(), finalMessage); Helper.notify_user(LiveNotificationService.this, account, intent, resource, finalNotifType, "@" + notification.getAccount().getAcct(), finalMessage);
} }
}); });
} }
@ -507,7 +507,7 @@ public class LiveNotificationService extends Service implements NetworkStateRece
intentBC.putExtra("eventStreaming", event); intentBC.putExtra("eventStreaming", event);
intentBC.putExtras(b); intentBC.putExtras(b);
b.putParcelable("data", notification); b.putParcelable("data", notification);
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intentBC); LocalBroadcastManager.getInstance(LiveNotificationService.this).sendBroadcast(intentBC);
SharedPreferences.Editor editor = sharedpreferences.edit(); SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + account.getId() + account.getInstance(), notification.getId()); editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + account.getId() + account.getInstance(), notification.getId());
editor.apply(); editor.apply();

View File

@ -35,13 +35,13 @@ public class RestartLiveNotificationReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
int type = Helper.liveNotifType(context); int type = Helper.liveNotifType(context);
if (type == Helper.NOTIF_DELAYED) { if (type == Helper.NOTIF_DELAYED) {
Intent streamingServiceIntent = new Intent(context.getApplicationContext(), LiveNotificationDelayedService.class); Intent streamingServiceIntent = new Intent(context, LiveNotificationDelayedService.class);
try { try {
context.startService(streamingServiceIntent); context.startService(streamingServiceIntent);
} catch (Exception ignored) { } catch (Exception ignored) {
} }
} else if (type == Helper.NOTIF_LIVE) { } else if (type == Helper.NOTIF_LIVE) {
Intent streamingServiceIntent = new Intent(context.getApplicationContext(), LiveNotificationService.class); Intent streamingServiceIntent = new Intent(context, LiveNotificationService.class);
try { try {
context.startService(streamingServiceIntent); context.startService(streamingServiceIntent);
} catch (Exception ignored) { } catch (Exception ignored) {

View File

@ -30,7 +30,7 @@ public class StopDelayedNotificationReceiver extends BroadcastReceiver {
@SuppressLint("UnsafeProtectedBroadcastReceiver") @SuppressLint("UnsafeProtectedBroadcastReceiver")
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
Intent streamingServiceIntent = new Intent(context.getApplicationContext(), LiveNotificationDelayedService.class); Intent streamingServiceIntent = new Intent(context, LiveNotificationDelayedService.class);
streamingServiceIntent.putExtra("stop", true); streamingServiceIntent.putExtra("stop", true);
try { try {
context.startService(streamingServiceIntent); context.startService(streamingServiceIntent);

View File

@ -30,7 +30,7 @@ public class StopLiveNotificationReceiver extends BroadcastReceiver {
@SuppressLint("UnsafeProtectedBroadcastReceiver") @SuppressLint("UnsafeProtectedBroadcastReceiver")
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
Intent streamingServiceIntent = new Intent(context.getApplicationContext(), LiveNotificationService.class); Intent streamingServiceIntent = new Intent(context, LiveNotificationService.class);
streamingServiceIntent.putExtra("stop", true); streamingServiceIntent.putExtra("stop", true);
try { try {
context.startService(streamingServiceIntent); context.startService(streamingServiceIntent);

View File

@ -87,7 +87,7 @@ public class StreamingFederatedTimelineService extends IntentService {
} }
SharedPreferences.Editor editor = sharedpreferences.edit(); SharedPreferences.Editor editor = sharedpreferences.edit();
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext())); String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(StreamingFederatedTimelineService.this));
editor.putBoolean(Helper.SHOULD_CONTINUE_STREAMING_FEDERATED + userId + instance, true); editor.putBoolean(Helper.SHOULD_CONTINUE_STREAMING_FEDERATED + userId + instance, true);
editor.apply(); editor.apply();
} }
@ -100,8 +100,8 @@ public class StreamingFederatedTimelineService extends IntentService {
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null); String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
Account accountStream = null; Account accountStream = null;
if (userId != null) { if (userId != null) {
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(StreamingFederatedTimelineService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
accountStream = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance); accountStream = new AccountDAO(StreamingFederatedTimelineService.this, db).getUniqAccount(userId, instance);
} }
if (accountStream != null) { if (accountStream != null) {
Headers headers = new Headers(); Headers headers = new Headers();
@ -155,14 +155,14 @@ public class StreamingFederatedTimelineService extends IntentService {
Bundle b = new Bundle(); Bundle b = new Bundle();
try { try {
if (response.get("event").toString().equals("update")) { if (response.get("event").toString().equals("update")) {
status = API.parseStatuses(getApplicationContext(), new JSONObject(response.get("payload").toString())); status = API.parseStatuses(StreamingFederatedTimelineService.this, new JSONObject(response.get("payload").toString()));
status.setNew(true); status.setNew(true);
b.putParcelable("data", status); b.putParcelable("data", status);
if (account != null) if (account != null)
b.putString("userIdService", account.getId()); b.putString("userIdService", account.getId());
Intent intentBC = new Intent(Helper.RECEIVE_FEDERATED_DATA); Intent intentBC = new Intent(Helper.RECEIVE_FEDERATED_DATA);
intentBC.putExtras(b); intentBC.putExtras(b);
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intentBC); LocalBroadcastManager.getInstance(StreamingFederatedTimelineService.this).sendBroadcast(intentBC);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -87,7 +87,7 @@ public class StreamingHomeTimelineService extends IntentService {
} }
SharedPreferences.Editor editor = sharedpreferences.edit(); SharedPreferences.Editor editor = sharedpreferences.edit();
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext())); String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(StreamingHomeTimelineService.this));
editor.putBoolean(Helper.SHOULD_CONTINUE_STREAMING_HOME + userId + instance, true); editor.putBoolean(Helper.SHOULD_CONTINUE_STREAMING_HOME + userId + instance, true);
editor.apply(); editor.apply();
} }
@ -100,8 +100,8 @@ public class StreamingHomeTimelineService extends IntentService {
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null); String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
Account accountStream = null; Account accountStream = null;
if (userId != null) { if (userId != null) {
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(StreamingHomeTimelineService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
accountStream = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance); accountStream = new AccountDAO(StreamingHomeTimelineService.this, db).getUniqAccount(userId, instance);
} }
if (accountStream != null) { if (accountStream != null) {
Headers headers = new Headers(); Headers headers = new Headers();
@ -155,14 +155,14 @@ public class StreamingHomeTimelineService extends IntentService {
Bundle b = new Bundle(); Bundle b = new Bundle();
try { try {
if (response.get("event").toString().equals("update")) { if (response.get("event").toString().equals("update")) {
status = API.parseStatuses(getApplicationContext(), new JSONObject(response.get("payload").toString())); status = API.parseStatuses(StreamingHomeTimelineService.this, new JSONObject(response.get("payload").toString()));
status.setNew(true); status.setNew(true);
b.putParcelable("data", status); b.putParcelable("data", status);
if (account != null) if (account != null)
b.putString("userIdService", account.getId()); b.putString("userIdService", account.getId());
Intent intentBC = new Intent(Helper.RECEIVE_HOME_DATA); Intent intentBC = new Intent(Helper.RECEIVE_HOME_DATA);
intentBC.putExtras(b); intentBC.putExtras(b);
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intentBC); LocalBroadcastManager.getInstance(StreamingHomeTimelineService.this).sendBroadcast(intentBC);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -87,7 +87,7 @@ public class StreamingLocalTimelineService extends IntentService {
} }
SharedPreferences.Editor editor = sharedpreferences.edit(); SharedPreferences.Editor editor = sharedpreferences.edit();
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext())); String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(StreamingLocalTimelineService.this));
editor.putBoolean(Helper.SHOULD_CONTINUE_STREAMING_LOCAL + userId + instance, true); editor.putBoolean(Helper.SHOULD_CONTINUE_STREAMING_LOCAL + userId + instance, true);
editor.apply(); editor.apply();
} }
@ -100,8 +100,8 @@ public class StreamingLocalTimelineService extends IntentService {
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null); String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
Account accountStream = null; Account accountStream = null;
if (userId != null) { if (userId != null) {
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(StreamingLocalTimelineService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
accountStream = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance); accountStream = new AccountDAO(StreamingLocalTimelineService.this, db).getUniqAccount(userId, instance);
} }
if (accountStream != null) { if (accountStream != null) {
@ -155,14 +155,14 @@ public class StreamingLocalTimelineService extends IntentService {
Bundle b = new Bundle(); Bundle b = new Bundle();
try { try {
if (response.get("event").toString().equals("update")) { if (response.get("event").toString().equals("update")) {
status = API.parseStatuses(getApplicationContext(), new JSONObject(response.get("payload").toString())); status = API.parseStatuses(StreamingLocalTimelineService.this, new JSONObject(response.get("payload").toString()));
status.setNew(true); status.setNew(true);
b.putParcelable("data", status); b.putParcelable("data", status);
if (account != null) if (account != null)
b.putString("userIdService", account.getId()); b.putString("userIdService", account.getId());
Intent intentBC = new Intent(Helper.RECEIVE_LOCAL_DATA); Intent intentBC = new Intent(Helper.RECEIVE_LOCAL_DATA);
intentBC.putExtras(b); intentBC.putExtras(b);
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intentBC); LocalBroadcastManager.getInstance(StreamingLocalTimelineService.this).sendBroadcast(intentBC);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -337,7 +337,7 @@ public class Sqlite extends SQLiteOpenHelper {
Helper.logoutCurrentUser(activity); Helper.logoutCurrentUser(activity);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Toasty.error(activity.getApplicationContext(), activity.getString(R.string.data_import_error_simple), Toast.LENGTH_LONG).show(); Toasty.error(activity, activity.getString(R.string.data_import_error_simple), Toast.LENGTH_LONG).show();
} }
} }