Fix potential leaks
This commit is contained in:
parent
39e6feb279
commit
d7c39a9d99
|
@ -94,7 +94,7 @@ public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccou
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
|
@ -208,11 +208,11 @@ public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccou
|
|||
lv_ux.setAdapter(accountSearchWebAdapterUxUiDesigners);
|
||||
|
||||
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(getApplicationContext(), "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(getApplicationContext(), "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, "fedilab", "toot.fedilab.app", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
new RetrieveRemoteDataAsyncTask(AboutActivity.this, "mmarif", "mastodon.social", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
new RetrieveRemoteDataAsyncTask(AboutActivity.this, "PhotonQyv", "mastodon.xyz", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
new RetrieveRemoteDataAsyncTask(AboutActivity.this, "angrytux", "social.tchncs.de", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
new RetrieveRemoteDataAsyncTask(AboutActivity.this, "guzzisti", "mastodon.social", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
} else {
|
||||
SpannableString name = new SpannableString("@fedilab@toot.fedilab.app");
|
||||
name.setSpan(new UnderlineSpan(), 0, name.length(), 0);
|
||||
|
@ -251,7 +251,7 @@ public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccou
|
|||
@Override
|
||||
public void onRetrieveRemoteAccount(Results results, boolean developerAccount) {
|
||||
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;
|
||||
}
|
||||
List<Account> accounts = results.getAccounts();
|
||||
|
@ -273,7 +273,7 @@ public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccou
|
|||
accountSearchWebAdapterContributors.notifyDataSetChanged();
|
||||
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();
|
||||
if (developers != null) {
|
||||
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) {
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,14 +94,14 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
ImageView toolbar_close = actionBar.getCustomView().findViewById(R.id.toolbar_close);
|
||||
TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
|
||||
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);
|
||||
|
||||
|
@ -116,8 +116,8 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
|
|||
email_label = findViewById(R.id.email_label);
|
||||
allow_reject_group = findViewById(R.id.allow_reject_group);
|
||||
allow_reject_group.setVisibility(View.GONE);
|
||||
allow.getBackground().setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.green_1), PorterDuff.Mode.MULTIPLY);
|
||||
reject.getBackground().setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.red_1), PorterDuff.Mode.MULTIPLY);
|
||||
allow.getBackground().setColorFilter(ContextCompat.getColor(AccountReportActivity.this, R.color.green_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);
|
||||
permissions = findViewById(R.id.permissions);
|
||||
username = findViewById(R.id.username);
|
||||
|
@ -132,13 +132,13 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
|
|||
comment = findViewById(R.id.comment);
|
||||
|
||||
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();
|
||||
}
|
||||
assign.setVisibility(View.GONE);
|
||||
status.setVisibility(View.GONE);
|
||||
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;
|
||||
}
|
||||
if (report != null) {
|
||||
|
@ -156,7 +156,7 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
|
|||
Group statuses_group = findViewById(R.id.statuses_group);
|
||||
statuses_group.setVisibility(View.VISIBLE);
|
||||
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();
|
||||
} else {
|
||||
Toasty.error(getApplicationContext(), apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
||||
Toasty.error(AccountReportActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
|
|||
private void fillReport(AccountAdmin accountAdmin) {
|
||||
|
||||
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;
|
||||
}
|
||||
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 -> {
|
||||
AdminAction adminAction = new AdminAction();
|
||||
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 -> {
|
||||
AdminAction adminAction = new AdminAction();
|
||||
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 -> {
|
||||
|
@ -230,7 +230,7 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
|
|||
adminAction.setType(NONE);
|
||||
adminAction.setSend_email_notification(email_user.isChecked());
|
||||
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.setSend_email_notification(email_user.isChecked());
|
||||
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 {
|
||||
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.setSend_email_notification(email_user.isChecked());
|
||||
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 {
|
||||
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()) {
|
||||
|
@ -278,9 +278,9 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
|
|||
adminAction.setType(SUSPEND);
|
||||
adminAction.setSend_email_notification(email_user.isChecked());
|
||||
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 {
|
||||
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;
|
||||
}
|
||||
if (message != null) {
|
||||
Toasty.success(getApplicationContext(), message, Toast.LENGTH_LONG).show();
|
||||
Toasty.success(AccountReportActivity.this, message, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
comment.setText("");
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
|
||||
|
@ -411,9 +411,9 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
|
|||
}
|
||||
assign.setOnClickListener(view -> {
|
||||
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 {
|
||||
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()) {
|
||||
|
@ -423,9 +423,9 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
|
|||
}
|
||||
status.setOnClickListener(view -> {
|
||||
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 {
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -73,14 +73,14 @@ public class AdminActivity extends BaseActivity {
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
ImageView toolbar_close = actionBar.getCustomView().findViewById(R.id.toolbar_close);
|
||||
TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
|
||||
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);
|
||||
unresolved = local = active = true;
|
||||
|
@ -115,7 +115,7 @@ public class AdminActivity extends BaseActivity {
|
|||
});
|
||||
popup.setOnMenuItemClickListener(item -> {
|
||||
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() {
|
||||
@Override
|
||||
public boolean onMenuItemActionExpand(MenuItem item) {
|
||||
|
@ -183,7 +183,7 @@ public class AdminActivity extends BaseActivity {
|
|||
popup.setOnMenuItemClickListener(item -> {
|
||||
|
||||
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() {
|
||||
@Override
|
||||
public boolean onMenuItemActionExpand(MenuItem item) {
|
||||
|
|
|
@ -137,7 +137,7 @@ public class BaseActivity extends CyaneaAppCompatActivity {
|
|||
if (view != null) {
|
||||
Snackbar.make(view, message, Snackbar.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toasty.info(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
|
||||
Toasty.info(BaseActivity.this, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -210,9 +210,9 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
|
||||
|
||||
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext()));
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
|
||||
instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(BaseMainActivity.this));
|
||||
SQLiteDatabase db = Sqlite.getInstance(BaseMainActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(BaseMainActivity.this, db).getUniqAccount(userId, instance);
|
||||
Intent intent = getIntent();
|
||||
PackageManager pm = getPackageManager();
|
||||
try {
|
||||
|
@ -250,7 +250,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
}
|
||||
|
||||
if (account == null) {
|
||||
Helper.logout(getApplicationContext());
|
||||
Helper.logout(BaseMainActivity.this);
|
||||
Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class);
|
||||
startActivity(myIntent);
|
||||
finish();
|
||||
|
@ -296,7 +296,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
setContentView(R.layout.activity_main);
|
||||
|
||||
//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
|
||||
Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class);
|
||||
startActivity(myIntent);
|
||||
|
@ -310,12 +310,12 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
//This task will allow to instance a static PeertubeInformation class
|
||||
if (social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
|
||||
try {
|
||||
new RetrievePeertubeInformationAsyncTask(getApplicationContext()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
new RetrievePeertubeInformationAsyncTask(BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
//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
|
||||
appBar = findViewById(R.id.appBar);
|
||||
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 close = toolbar_search.findViewById(R.id.search_close_btn);
|
||||
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)
|
||||
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.setHintTextColor(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);
|
||||
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) {
|
||||
TabLayout.Tab pTabsub = tabLayout.newTab();
|
||||
|
@ -435,11 +435,11 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
pTabLocal.setCustomView(R.layout.tab_badge);
|
||||
|
||||
|
||||
Helper.changeDrawableColor(getApplicationContext(), R.drawable.ic_subscriptions, R.attr.iconColorMenu);
|
||||
Helper.changeDrawableColor(getApplicationContext(), R.drawable.ic_overview, R.attr.iconColorMenu);
|
||||
Helper.changeDrawableColor(getApplicationContext(), R.drawable.ic_trending_up, R.attr.iconColorMenu);
|
||||
Helper.changeDrawableColor(getApplicationContext(), 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_subscriptions, R.attr.iconColorMenu);
|
||||
Helper.changeDrawableColor(BaseMainActivity.this, R.drawable.ic_overview, R.attr.iconColorMenu);
|
||||
Helper.changeDrawableColor(BaseMainActivity.this, R.drawable.ic_trending_up, R.attr.iconColorMenu);
|
||||
Helper.changeDrawableColor(BaseMainActivity.this, R.drawable.ic_recently_added, R.attr.iconColorMenu);
|
||||
Helper.changeDrawableColor(BaseMainActivity.this, R.drawable.ic_home, R.attr.iconColorMenu);
|
||||
|
||||
|
||||
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
||||
|
@ -532,9 +532,9 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
//TabLayout.Tab pfTabDiscover = tabLayout.newTab();
|
||||
|
||||
|
||||
Helper.changeDrawableColor(getApplicationContext(), R.drawable.ic_notifications, R.attr.iconColorMenu);
|
||||
Helper.changeDrawableColor(getApplicationContext(), R.drawable.ic_people, R.attr.iconColorMenu);
|
||||
Helper.changeDrawableColor(getApplicationContext(), R.drawable.ic_home, R.attr.iconColorMenu);
|
||||
Helper.changeDrawableColor(BaseMainActivity.this, R.drawable.ic_notifications, R.attr.iconColorMenu);
|
||||
Helper.changeDrawableColor(BaseMainActivity.this, R.drawable.ic_people, R.attr.iconColorMenu);
|
||||
Helper.changeDrawableColor(BaseMainActivity.this, R.drawable.ic_home, R.attr.iconColorMenu);
|
||||
|
||||
pfTabHome.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);
|
||||
|
||||
if (hidde_menu != null)
|
||||
LocalBroadcastManager.getInstance(getApplicationContext()).unregisterReceiver(hidde_menu);
|
||||
LocalBroadcastManager.getInstance(BaseMainActivity.this).unregisterReceiver(hidde_menu);
|
||||
|
||||
if (update_topbar != null)
|
||||
LocalBroadcastManager.getInstance(getApplicationContext()).unregisterReceiver(update_topbar);
|
||||
LocalBroadcastManager.getInstance(BaseMainActivity.this).unregisterReceiver(update_topbar);
|
||||
hidde_menu = new BroadcastReceiver() {
|
||||
@Override
|
||||
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();
|
||||
}
|
||||
};
|
||||
LocalBroadcastManager.getInstance(getApplicationContext()).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(hidde_menu, new IntentFilter(Helper.RECEIVE_HIDE_ITEM));
|
||||
LocalBroadcastManager.getInstance(BaseMainActivity.this).registerReceiver(update_topbar, new IntentFilter(Helper.RECEIVE_UPDATE_TOPBAR));
|
||||
|
||||
toolbar_search.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
|
@ -873,11 +873,11 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(BaseMainActivity.this, R.color.cyanea_primary)));
|
||||
}
|
||||
//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.PIXELFED) {
|
||||
toot.setOnClickListener(view -> {
|
||||
Intent intent13 = new Intent(getApplicationContext(), TootActivity.class);
|
||||
Intent intent13 = new Intent(BaseMainActivity.this, TootActivity.class);
|
||||
startActivity(intent13);
|
||||
});
|
||||
toot.setOnLongClickListener(v -> {
|
||||
|
@ -886,13 +886,13 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
});
|
||||
} else {
|
||||
toot.setOnClickListener(view -> {
|
||||
Intent intent12 = new Intent(getApplicationContext(), PixelfedComposeActivity.class);
|
||||
Intent intent12 = new Intent(BaseMainActivity.this, PixelfedComposeActivity.class);
|
||||
startActivity(intent12);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
toot.setOnClickListener(view -> {
|
||||
Intent intent1 = new Intent(getApplicationContext(), PeertubeUploadActivity.class);
|
||||
Intent intent1 = new Intent(BaseMainActivity.this, PeertubeUploadActivity.class);
|
||||
startActivity(intent1);
|
||||
});
|
||||
}
|
||||
|
@ -937,7 +937,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
AlertDialog.Builder dialogBuilderLogout = new AlertDialog.Builder(BaseMainActivity.this, style);
|
||||
dialogBuilderLogout.setMessage(R.string.logout_confirmation);
|
||||
dialogBuilderLogout.setPositiveButton(R.string.action_logout, (dialog, id) -> {
|
||||
Helper.logout(getApplicationContext());
|
||||
Helper.logout(BaseMainActivity.this);
|
||||
Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class);
|
||||
startActivity(myIntent);
|
||||
dialog.dismiss();
|
||||
|
@ -959,26 +959,26 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
alertDialogLogoutAccount.show();
|
||||
return true;
|
||||
case R.id.action_privacy:
|
||||
Intent intent14 = new Intent(getApplicationContext(), PrivacyActivity.class);
|
||||
Intent intent14 = new Intent(BaseMainActivity.this, PrivacyActivity.class);
|
||||
startActivity(intent14);
|
||||
return true;
|
||||
case R.id.action_about_instance:
|
||||
intent14 = new Intent(getApplicationContext(), InstanceActivity.class);
|
||||
intent14 = new Intent(BaseMainActivity.this, InstanceActivity.class);
|
||||
startActivity(intent14);
|
||||
return true;
|
||||
case R.id.action_send_invitation:
|
||||
if (instanceClass != null) {
|
||||
if (instanceClass.isRegistration()) {
|
||||
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://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.setType("text/plain");
|
||||
startActivity(Intent.createChooser(sendIntent, getString(R.string.share_with)));
|
||||
} 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;
|
||||
|
@ -993,7 +993,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
AlertDialog.Builder builder = new AlertDialog.Builder(BaseMainActivity.this, style);
|
||||
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);
|
||||
|
||||
SeekBar set_text_size = popup_quick_settings.findViewById(R.id.set_text_size);
|
||||
|
@ -1054,12 +1054,12 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
.show();
|
||||
return true;
|
||||
case R.id.action_proxy:
|
||||
intent14 = new Intent(getApplicationContext(), ProxyActivity.class);
|
||||
intent14 = new Intent(BaseMainActivity.this, ProxyActivity.class);
|
||||
startActivity(intent14);
|
||||
return true;
|
||||
case R.id.action_export:
|
||||
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);
|
||||
} else {
|
||||
Intent backupIntent = new Intent(BaseMainActivity.this, BackupStatusService.class);
|
||||
|
@ -1096,7 +1096,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
return true;
|
||||
case R.id.action_export_data:
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
@ -1111,7 +1111,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
});
|
||||
final ImageView optionInfo = headerLayout.findViewById(R.id.header_option_info);
|
||||
optionInfo.setOnClickListener(view -> {
|
||||
Intent intent15 = new Intent(getApplicationContext(), InstanceHealthActivity.class);
|
||||
Intent intent15 = new Intent(BaseMainActivity.this, InstanceHealthActivity.class);
|
||||
startActivity(intent15);
|
||||
});
|
||||
if (social != UpdateAccountInfoAsyncTask.SOCIAL.MASTODON)
|
||||
|
@ -1188,7 +1188,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
|
||||
AlertDialog.Builder dialogBuilderOptin = new AlertDialog.Builder(BaseMainActivity.this, style);
|
||||
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);
|
||||
|
||||
|
||||
|
@ -1199,7 +1199,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
android.R.layout.simple_spinner_dropdown_item, labels);
|
||||
set_live_type.setAdapter(adapterLive);
|
||||
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:
|
||||
set_live_type_indication.setText(R.string.live_notif_indication);
|
||||
break;
|
||||
|
@ -1210,7 +1210,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
set_live_type_indication.setText(R.string.no_live_indication);
|
||||
break;
|
||||
}
|
||||
set_live_type.setSelection(Helper.liveNotifType(getApplicationContext()));
|
||||
set_live_type.setSelection(Helper.liveNotifType(BaseMainActivity.this));
|
||||
set_live_type.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
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_DELAYED_NOTIFICATIONS, false);
|
||||
editor.apply();
|
||||
Intent streamingIntent = new Intent(getApplicationContext(), LiveNotificationService.class);
|
||||
Intent streamingIntent = new Intent(BaseMainActivity.this, LiveNotificationService.class);
|
||||
startService(streamingIntent);
|
||||
break;
|
||||
case Helper.NOTIF_DELAYED:
|
||||
editor.putBoolean(Helper.SET_LIVE_NOTIFICATIONS, false);
|
||||
editor.putBoolean(Helper.SET_DELAYED_NOTIFICATIONS, true);
|
||||
streamingIntent = new Intent(getApplicationContext(), LiveNotificationDelayedService.class);
|
||||
streamingIntent = new Intent(BaseMainActivity.this, LiveNotificationDelayedService.class);
|
||||
startService(streamingIntent);
|
||||
editor.apply();
|
||||
break;
|
||||
|
@ -1236,7 +1236,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
editor.apply();
|
||||
break;
|
||||
}
|
||||
switch (Helper.liveNotifType(getApplicationContext())) {
|
||||
switch (Helper.liveNotifType(BaseMainActivity.this)) {
|
||||
case Helper.NOTIF_LIVE:
|
||||
set_live_type_indication.setText(R.string.live_notif_indication);
|
||||
break;
|
||||
|
@ -1274,7 +1274,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
int versionCode = BuildConfig.VERSION_CODE;
|
||||
if (lastReleaseNoteRead != versionCode) { //Need to push release notes
|
||||
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(
|
||||
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);
|
||||
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);
|
||||
TextView release_title = dialogReleaseNoteView.findViewById(R.id.release_title);
|
||||
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) {
|
||||
|
||||
// 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
|
||||
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);
|
||||
new TimelineCacheDAO(BaseMainActivity.this, db).removeAfterDate(dateString);
|
||||
});
|
||||
if (Helper.isLoggedIn(getApplicationContext())) {
|
||||
new UpdateAccountInfoByIDAsyncTask(getApplicationContext(), social, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
if (Helper.isLoggedIn(BaseMainActivity.this)) {
|
||||
new UpdateAccountInfoByIDAsyncTask(BaseMainActivity.this, social, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
mutedAccount = new TempMuteDAO(getApplicationContext(), db).getAllTimeMuted(account);
|
||||
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA){
|
||||
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS, null, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
mutedAccount = new TempMuteDAO(BaseMainActivity.this, db).getAllTimeMuted(account);
|
||||
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
|
||||
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();
|
||||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.MYVIDEOS);
|
||||
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);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext()));
|
||||
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(BaseMainActivity.this));
|
||||
Account account = new AccountDAO(BaseMainActivity.this, db).getUniqAccount(userId, instance);
|
||||
bundle.putString("targetedid", account.getUsername());
|
||||
bundle.putBoolean("ownvideos", true);
|
||||
fragment.setArguments(bundle);
|
||||
|
@ -1514,7 +1514,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
} else {
|
||||
Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
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.putExtra("imageUri", imageUri.toString());
|
||||
startActivity(intent);
|
||||
|
@ -1578,7 +1578,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
intent.setDataAndType(i.getData(), i.getType());
|
||||
List<ResolveInfo> activities = getPackageManager().queryIntentActivities(intent, 0);
|
||||
ArrayList<Intent> targetIntents = new ArrayList<>();
|
||||
String thisPackageName = getApplicationContext().getPackageName();
|
||||
String thisPackageName = BaseMainActivity.this.getPackageName();
|
||||
for (ResolveInfo currentInfo : activities) {
|
||||
String packageName = currentInfo.activityInfo.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);
|
||||
|
||||
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));
|
||||
//Refresh home if needed
|
||||
if (dateAllowed.after(date)) {
|
||||
|
@ -1677,7 +1677,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
super.onDestroy();
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
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) {
|
||||
AsyncTask.execute(() -> {
|
||||
try {
|
||||
|
@ -1693,9 +1693,9 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
});
|
||||
}
|
||||
if (hidde_menu != null)
|
||||
LocalBroadcastManager.getInstance(getApplicationContext()).unregisterReceiver(hidde_menu);
|
||||
LocalBroadcastManager.getInstance(BaseMainActivity.this).unregisterReceiver(hidde_menu);
|
||||
if (update_topbar != null)
|
||||
LocalBroadcastManager.getInstance(getApplicationContext()).unregisterReceiver(update_topbar);
|
||||
LocalBroadcastManager.getInstance(BaseMainActivity.this).unregisterReceiver(update_topbar);
|
||||
if (mPageReferenceMap != null)
|
||||
mPageReferenceMap = null;
|
||||
PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean("isMainActivityRunning", false).apply();
|
||||
|
@ -1722,15 +1722,15 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
startActivity(myIntent);
|
||||
return false;
|
||||
} 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);
|
||||
return false;
|
||||
} else if (id == R.id.nav_administration) {
|
||||
Intent intent = new Intent(getApplicationContext(), AdminActivity.class);
|
||||
Intent intent = new Intent(BaseMainActivity.this, AdminActivity.class);
|
||||
startActivity(intent);
|
||||
return false;
|
||||
} else if (id == R.id.nav_about) {
|
||||
Intent intent = new Intent(getApplicationContext(), AboutActivity.class);
|
||||
Intent intent = new Intent(BaseMainActivity.this, AboutActivity.class);
|
||||
startActivity(intent);
|
||||
return false;
|
||||
} else if (id == R.id.nav_opencollective) {
|
||||
|
@ -1743,23 +1743,23 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
}
|
||||
return false;
|
||||
} else if (id == R.id.nav_upload) {
|
||||
Intent intent = new Intent(getApplicationContext(), PeertubeUploadActivity.class);
|
||||
Intent intent = new Intent(BaseMainActivity.this, PeertubeUploadActivity.class);
|
||||
startActivity(intent);
|
||||
return false;
|
||||
} else if (id == R.id.nav_partnership) {
|
||||
Intent intent = new Intent(getApplicationContext(), PartnerShipActivity.class);
|
||||
Intent intent = new Intent(BaseMainActivity.this, PartnerShipActivity.class);
|
||||
startActivity(intent);
|
||||
return false;
|
||||
} else if (id == R.id.nav_settings) {
|
||||
Intent intent = new Intent(getApplicationContext(), SettingsActivity.class);
|
||||
Intent intent = new Intent(BaseMainActivity.this, SettingsActivity.class);
|
||||
startActivity(intent);
|
||||
return false;
|
||||
} 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);
|
||||
return false;
|
||||
} else if (id == R.id.nav_bookmarks) {
|
||||
Intent intent = new Intent(getApplicationContext(), BookmarkActivity.class);
|
||||
Intent intent = new Intent(BaseMainActivity.this, BookmarkActivity.class);
|
||||
startActivity(intent);
|
||||
return false;
|
||||
}
|
||||
|
@ -1826,10 +1826,10 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.MYVIDEOS);
|
||||
bundle.putString("instanceType", "PEERTUBE");
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
SQLiteDatabase db = Sqlite.getInstance(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 instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext()));
|
||||
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(BaseMainActivity.this));
|
||||
Account account = new AccountDAO(BaseMainActivity.this, db).getUniqAccount(userId, instance);
|
||||
bundle.putString("targetedid", account.getUsername());
|
||||
bundle.putBoolean("ownvideos", true);
|
||||
fragment.setArguments(bundle);
|
||||
|
@ -1842,10 +1842,10 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PEERTUBE_HISTORY);
|
||||
bundle.putString("instanceType", "PEERTUBE");
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
SQLiteDatabase db = Sqlite.getInstance(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 instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext()));
|
||||
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(BaseMainActivity.this));
|
||||
Account account = new AccountDAO(BaseMainActivity.this, db).getUniqAccount(userId, instance);
|
||||
bundle.putString("targetedid", account.getUsername());
|
||||
fragment.setArguments(bundle);
|
||||
fragmentTag = "MY_HISTORY";
|
||||
|
@ -1978,13 +1978,13 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
public void onUpdateAccountInfo(boolean error) {
|
||||
if (error) {
|
||||
//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);
|
||||
startActivity(myIntent);
|
||||
finish();
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -1995,14 +1995,14 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == PICK_IMPORT && resultCode == RESULT_OK) {
|
||||
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;
|
||||
}
|
||||
String filename = Helper.getFilePathFromURI(getApplicationContext(), data.getData());
|
||||
String filename = Helper.getFilePathFromURI(BaseMainActivity.this, data.getData());
|
||||
Sqlite.importDB(BaseMainActivity.this, filename);
|
||||
|
||||
} 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);
|
||||
startActivity(intent);
|
||||
} 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();
|
||||
b.putParcelable("status", statuses.get(0));
|
||||
intent.putExtras(b);
|
||||
|
@ -2055,7 +2055,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
if (accounts != null && accounts.size() > 0) {
|
||||
developers = new ArrayList<>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2214,7 +2214,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
if (faveFrag != null && faveFrag.isVisible()) {
|
||||
faveFrag.scrollToTop();
|
||||
}
|
||||
} else if (navigationView.getMenu().findItem(R.id.nav_blocked) != null && navigationView.getMenu().findItem(R.id.nav_blocked).isChecked()) {
|
||||
} else if (navigationView.getMenu().findItem(R.id.nav_blocked) != null && navigationView.getMenu().findItem(R.id.nav_blocked).isChecked()) {
|
||||
DisplayAccountsFragment blockFrag = (DisplayAccountsFragment) fragmentManager.findFragmentByTag("BLOCKS");
|
||||
|
||||
if (blockFrag != null && blockFrag.isVisible()) {
|
||||
|
@ -2367,6 +2367,28 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
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 {
|
||||
BUBBLES,
|
||||
|
@ -2530,27 +2552,4 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -98,7 +98,7 @@ public class BookmarkActivity extends BaseActivity implements OnRetrieveFeedsInt
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
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));
|
||||
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));
|
||||
|
@ -114,19 +114,19 @@ public class BookmarkActivity extends BaseActivity implements OnRetrieveFeedsInt
|
|||
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 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);
|
||||
|
||||
mainLoader = findViewById(R.id.loader);
|
||||
textviewNoAction = findViewById(R.id.no_action);
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ public class CustomSharingActivity extends BaseActivity implements OnCustomShari
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
|
@ -111,12 +111,12 @@ public class CustomSharingActivity extends BaseActivity implements OnCustomShari
|
|||
} else {
|
||||
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 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();
|
||||
Status status = 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}" +
|
||||
"&source=${source}&id=${id}&description=${description}&keywords=${keywords}&creator=${creator}&thumbnailurl=${thumbnailurl}");
|
||||
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) {
|
||||
set_custom_sharing_save.setEnabled(true);
|
||||
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;
|
||||
}
|
||||
String response = customSharingResponse.getResponse();
|
||||
Toasty.success(getApplicationContext(), response, Toast.LENGTH_LONG).show();
|
||||
Toasty.success(CustomSharingActivity.this, response, Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
}
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
|
@ -138,13 +138,13 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
|
|||
} else {
|
||||
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 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);
|
||||
set_profile_name = findViewById(R.id.set_profile_name);
|
||||
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_lock_account.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
|
||||
public void onRetrieveAccount(Account account, Error error) {
|
||||
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;
|
||||
}
|
||||
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);
|
||||
set_profile_description.setText(content);
|
||||
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);
|
||||
set_profile_name.setText(content);
|
||||
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();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -363,7 +363,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
|
|||
else
|
||||
profile_username = null;
|
||||
|
||||
if (set_profile_description != null && set_profile_description.getHint() != null && set_profile_description.getText() != null && !set_profile_description.getText().toString().contentEquals(set_profile_description.getHint()))
|
||||
if (set_profile_description != null && set_profile_description.getHint() != null && set_profile_description.getText() != null && !set_profile_description.getText().toString().contentEquals(set_profile_description.getHint()))
|
||||
profile_note = set_profile_description.getText().toString().trim();
|
||||
else
|
||||
profile_note = null;
|
||||
|
@ -377,7 +377,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
|
|||
}
|
||||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(EditProfileActivity.this, style);
|
||||
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);
|
||||
|
||||
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)
|
||||
dialog_profile_description.setText(profile_note);
|
||||
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);
|
||||
} else {
|
||||
back_ground_image.setBackground(set_header_picture.getDrawable());
|
||||
}
|
||||
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);
|
||||
} else {
|
||||
dialog_profile_picture.setBackground(set_profile_picture.getDrawable());
|
||||
|
@ -405,8 +405,8 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
|
|||
sensitive = set_sensitive_content.isChecked();
|
||||
dialogBuilder.setPositiveButton(R.string.save, (dialog, id) -> {
|
||||
set_profile_save.setEnabled(false);
|
||||
new Thread(() -> Glide.get(getApplicationContext()).clearDiskCache()).start();
|
||||
Glide.get(getApplicationContext()).clearMemory();
|
||||
new Thread(() -> Glide.get(EditProfileActivity.this).clearDiskCache()).start();
|
||||
Glide.get(EditProfileActivity.this).clearMemory();
|
||||
HashMap<String, String> newCustomFields = new HashMap<>();
|
||||
|
||||
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(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());
|
||||
AlertDialog alertDialog = dialogBuilder.create();
|
||||
|
@ -466,13 +466,13 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
|
|||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == PICK_IMAGE_HEADER && resultCode == RESULT_OK) {
|
||||
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;
|
||||
}
|
||||
Uri fileUri = data.getData();
|
||||
headerName = Helper.getFileName(EditProfileActivity.this, fileUri);
|
||||
try {
|
||||
InputStream inputStream = getApplicationContext().getContentResolver().openInputStream(fileUri);
|
||||
InputStream inputStream = EditProfileActivity.this.getContentResolver().openInputStream(fileUri);
|
||||
assert inputStream != null;
|
||||
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
|
||||
Bitmap bmp = BitmapFactory.decodeStream(bufferedInputStream);
|
||||
|
@ -484,13 +484,13 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
|
|||
header_picture = Helper.compressImage(EditProfileActivity.this, fileUri);
|
||||
} else if (requestCode == PICK_IMAGE_PROFILE && resultCode == RESULT_OK) {
|
||||
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;
|
||||
}
|
||||
Uri fileUri = data.getData();
|
||||
avatarName = Helper.getFileName(EditProfileActivity.this, fileUri);
|
||||
try {
|
||||
InputStream inputStream = getApplicationContext().getContentResolver().openInputStream(fileUri);
|
||||
InputStream inputStream = EditProfileActivity.this.getContentResolver().openInputStream(fileUri);
|
||||
assert inputStream != null;
|
||||
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
|
||||
Bitmap bmp = BitmapFactory.decodeStream(bufferedInputStream);
|
||||
|
@ -507,10 +507,10 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
|
|||
public void onUpdateCredential(APIResponse apiResponse) {
|
||||
set_profile_save.setEnabled(true);
|
||||
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;
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ public class GroupActivity extends BaseActivity implements OnRetrieveFeedsInterf
|
|||
max_id = null;
|
||||
flag_loading = true;
|
||||
firstLoad = true;
|
||||
boolean isOnWifi = Helper.isOnWIFI(getApplicationContext());
|
||||
boolean isOnWifi = Helper.isOnWIFI(GroupActivity.this);
|
||||
swipeRefreshLayout = findViewById(R.id.swipeContainer);
|
||||
int c1 = getResources().getColor(R.color.cyanea_accent);
|
||||
int c2 = getResources().getColor(R.color.cyanea_primary_dark);
|
||||
|
@ -131,7 +131,7 @@ public class GroupActivity extends BaseActivity implements OnRetrieveFeedsInterf
|
|||
statuses = new ArrayList<>();
|
||||
firstLoad = 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;
|
||||
mLayoutManager = new LinearLayoutManager(this);
|
||||
|
@ -145,7 +145,7 @@ public class GroupActivity extends BaseActivity implements OnRetrieveFeedsInterf
|
|||
if (firstVisibleItem + visibleItemCount == totalItemCount) {
|
||||
if (!flag_loading) {
|
||||
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);
|
||||
}
|
||||
|
@ -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);
|
||||
if (apiResponse == null || apiResponse.getError() != 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 {
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ public class HashTagActivity extends BaseActivity implements OnRetrieveFeedsInte
|
|||
max_id = null;
|
||||
flag_loading = true;
|
||||
firstLoad = true;
|
||||
boolean isOnWifi = Helper.isOnWIFI(getApplicationContext());
|
||||
boolean isOnWifi = Helper.isOnWIFI(HashTagActivity.this);
|
||||
swipeRefreshLayout = findViewById(R.id.swipeContainer);
|
||||
int c1 = getResources().getColor(R.color.cyanea_accent);
|
||||
int c2 = getResources().getColor(R.color.cyanea_primary_dark);
|
||||
|
@ -133,7 +133,7 @@ public class HashTagActivity extends BaseActivity implements OnRetrieveFeedsInte
|
|||
statuses = new ArrayList<>();
|
||||
firstLoad = 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;
|
||||
mLayoutManager = new LinearLayoutManager(this);
|
||||
|
@ -147,7 +147,7 @@ public class HashTagActivity extends BaseActivity implements OnRetrieveFeedsInte
|
|||
if (firstVisibleItem + visibleItemCount == totalItemCount) {
|
||||
if (!flag_loading) {
|
||||
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);
|
||||
}
|
||||
|
@ -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);
|
||||
if (apiResponse == null || apiResponse.getError() != 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
|
||||
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;
|
||||
}
|
||||
List<Status> statuses = apiResponse.getStatuses();
|
||||
|
|
|
@ -80,7 +80,7 @@ public class InstanceActivity extends BaseActivity implements OnRetrieveInstance
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
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);
|
||||
}
|
||||
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);
|
||||
loader = findViewById(R.id.loader);
|
||||
instance_container.setVisibility(View.GONE);
|
||||
loader.setVisibility(View.VISIBLE);
|
||||
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);
|
||||
loader.setVisibility(View.GONE);
|
||||
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;
|
||||
}
|
||||
final Instance instance = apiResponse.getInstance();
|
||||
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;
|
||||
}
|
||||
TextView instance_title = findViewById(R.id.instance_title);
|
||||
|
|
|
@ -74,9 +74,9 @@ public class InstanceHealthActivity extends BaseActivity {
|
|||
Bundle b = getIntent().getExtras();
|
||||
if (getSupportActionBar() != null)
|
||||
getSupportActionBar().hide();
|
||||
instance = Helper.getLiveInstance(getApplicationContext());
|
||||
instance = Helper.getLiveInstance(InstanceHealthActivity.this);
|
||||
if (b != null)
|
||||
instance = b.getString("instance", Helper.getLiveInstance(getApplicationContext()));
|
||||
instance = b.getString("instance", Helper.getLiveInstance(InstanceHealthActivity.this));
|
||||
|
||||
Button close = findViewById(R.id.close);
|
||||
name = findViewById(R.id.name);
|
||||
|
@ -129,21 +129,21 @@ public class InstanceHealthActivity extends BaseActivity {
|
|||
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);
|
||||
if (response != null) {
|
||||
instanceSocial = API.parseInstanceSocialResponse(getApplicationContext(), new JSONObject(response));
|
||||
instanceSocial = API.parseInstanceSocialResponse(InstanceHealthActivity.this, new JSONObject(response));
|
||||
}
|
||||
runOnUiThread(() -> {
|
||||
if (instanceSocial.getThumbnail() != null && !instanceSocial.getThumbnail().equals("null"))
|
||||
Glide.with(getApplicationContext())
|
||||
Glide.with(InstanceHealthActivity.this)
|
||||
.asBitmap()
|
||||
.load(instanceSocial.getThumbnail())
|
||||
.into(back_ground_image);
|
||||
name.setText(instanceSocial.getName());
|
||||
if (instanceSocial.isUp()) {
|
||||
up.setText("Is up!");
|
||||
up.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.green_1));
|
||||
up.setTextColor(ContextCompat.getColor(InstanceHealthActivity.this, R.color.green_1));
|
||||
} else {
|
||||
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)));
|
||||
if (instanceSocial.getChecked_at() != null)
|
||||
|
|
|
@ -123,7 +123,7 @@ public class InstanceProfileActivity extends BaseActivity {
|
|||
return;
|
||||
}
|
||||
if (instanceNodeInfo.getThumbnail() != null && !instanceNodeInfo.getThumbnail().equals("null"))
|
||||
Glide.with(getApplicationContext())
|
||||
Glide.with(InstanceProfileActivity.this)
|
||||
.asBitmap()
|
||||
.load(instanceNodeInfo.getThumbnail())
|
||||
.into(back_ground_image);
|
||||
|
|
|
@ -137,7 +137,7 @@ public class ListActivity extends BaseActivity implements OnListActionInterface
|
|||
title = b.getString("title");
|
||||
listId = b.getString("id");
|
||||
} 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)
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
@ -209,7 +209,7 @@ public class ListActivity extends BaseActivity implements OnListActionInterface
|
|||
}
|
||||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(ListActivity.this, style);
|
||||
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);
|
||||
final EditText editText = dialogView.findViewById(R.id.add_list);
|
||||
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
|
||||
if (apiResponse.getError() != null) {
|
||||
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);
|
||||
swiped = false;
|
||||
flag_loading = false;
|
||||
|
@ -279,7 +279,7 @@ public class ListActivity extends BaseActivity implements OnListActionInterface
|
|||
firstLoad = false;
|
||||
} else if (actionType == ManageListsAsyncTask.action.UPDATE_LIST) {
|
||||
Intent intentUP = new Intent(Helper.RECEIVE_UPDATE_TOPBAR);
|
||||
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intentUP);
|
||||
LocalBroadcastManager.getInstance(ListActivity.this).sendBroadcast(intentUP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,8 +61,8 @@ public class LiveNotificationSettingsAccountsActivity extends BaseActivity {
|
|||
RecyclerView list_of_accounts = findViewById(R.id.list_of_accounts);
|
||||
|
||||
ArrayList<Account> accounts = new ArrayList<>();
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<Account> accountStreams = new AccountDAO(getApplicationContext(), db).getAllAccountCrossAction();
|
||||
SQLiteDatabase db = Sqlite.getInstance(LiveNotificationSettingsAccountsActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<Account> accountStreams = new AccountDAO(LiveNotificationSettingsAccountsActivity.this, db).getAllAccountCrossAction();
|
||||
if (accountStreams == null || accountStreams.size() == 0) {
|
||||
finish();
|
||||
return;
|
||||
|
@ -74,7 +74,7 @@ public class LiveNotificationSettingsAccountsActivity extends BaseActivity {
|
|||
}
|
||||
AccountLiveAdapter accountLiveAdapter = new AccountLiveAdapter(accounts);
|
||||
list_of_accounts.setAdapter(accountLiveAdapter);
|
||||
LinearLayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
|
||||
LinearLayoutManager mLayoutManager = new LinearLayoutManager(LiveNotificationSettingsAccountsActivity.this);
|
||||
list_of_accounts.setLayoutManager(mLayoutManager);
|
||||
}
|
||||
|
||||
|
|
|
@ -234,7 +234,7 @@ public class LoginActivity extends BaseActivity {
|
|||
connectionButton = findViewById(R.id.login_button);
|
||||
ImageView info_instance = findViewById(R.id.info_instance);
|
||||
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;
|
||||
//Manage instances
|
||||
info_instance.setOnClickListener(v -> showcaseInstance(false));
|
||||
|
@ -273,9 +273,9 @@ public class LoginActivity extends BaseActivity {
|
|||
}
|
||||
}
|
||||
} 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 {
|
||||
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 {
|
||||
instance = URLEncoder.encode(host, "utf-8");
|
||||
} 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)
|
||||
actionToken = "/api/v1/oauth-clients/local";
|
||||
|
@ -475,9 +475,9 @@ public class LoginActivity extends BaseActivity {
|
|||
try {
|
||||
String response;
|
||||
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
|
||||
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(() -> {
|
||||
JSONObject resobj;
|
||||
try {
|
||||
|
@ -512,7 +512,7 @@ public class LoginActivity extends BaseActivity {
|
|||
}
|
||||
} else
|
||||
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 {
|
||||
String response;
|
||||
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 {
|
||||
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(() -> {
|
||||
JSONObject resobj;
|
||||
|
@ -645,7 +645,7 @@ public class LoginActivity extends BaseActivity {
|
|||
message = e.getMessage();
|
||||
else
|
||||
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);
|
||||
startActivity(i);
|
||||
} else {
|
||||
String url = redirectUserToAuthorizeAndLogin(getApplicationContext(), client_id, instance);
|
||||
String url = redirectUserToAuthorizeAndLogin(LoginActivity.this, client_id, instance);
|
||||
Helper.openBrowser(LoginActivity.this, url);
|
||||
}
|
||||
}
|
||||
|
@ -697,13 +697,13 @@ public class LoginActivity extends BaseActivity {
|
|||
|
||||
//noinspection SimplifiableIfStatement
|
||||
if (id == R.id.action_about) {
|
||||
Intent intent = new Intent(getApplicationContext(), AboutActivity.class);
|
||||
Intent intent = new Intent(LoginActivity.this, AboutActivity.class);
|
||||
startActivity(intent);
|
||||
} else if (id == R.id.action_privacy) {
|
||||
Intent intent = new Intent(getApplicationContext(), PrivacyActivity.class);
|
||||
Intent intent = new Intent(LoginActivity.this, PrivacyActivity.class);
|
||||
startActivity(intent);
|
||||
} else if (id == R.id.action_proxy) {
|
||||
Intent intent = new Intent(getApplicationContext(), ProxyActivity.class);
|
||||
Intent intent = new Intent(LoginActivity.this, ProxyActivity.class);
|
||||
startActivity(intent);
|
||||
} else if (id == R.id.action_custom_tabs) {
|
||||
item.setChecked(!item.isChecked());
|
||||
|
@ -751,13 +751,13 @@ public class LoginActivity extends BaseActivity {
|
|||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == PICK_IMPORT && resultCode == RESULT_OK) {
|
||||
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;
|
||||
}
|
||||
String filename = Helper.getFilePathFromURI(getApplicationContext(), data.getData());
|
||||
String filename = Helper.getFilePathFromURI(LoginActivity.this, data.getData());
|
||||
Sqlite.importDB(LoginActivity.this, filename);
|
||||
} 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ public class ManageAccountsInListActivity extends BaseActivity implements OnList
|
|||
title = b.getString("title");
|
||||
listId = b.getString("id");
|
||||
} 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);
|
||||
|
@ -162,7 +162,7 @@ public class ManageAccountsInListActivity extends BaseActivity implements OnList
|
|||
loader.setVisibility(View.GONE);
|
||||
main_account_container.setVisibility(View.VISIBLE);
|
||||
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;
|
||||
}
|
||||
if (actionType == ManageListsAsyncTask.action.GET_LIST_ACCOUNT) {
|
||||
|
|
|
@ -101,7 +101,7 @@ public class MastodonRegisterActivity extends BaseActivity implements OnRetrieve
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
|
@ -173,23 +173,23 @@ public class MastodonRegisterActivity extends BaseActivity implements OnRetrieve
|
|||
error_message.setVisibility(View.GONE);
|
||||
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()) {
|
||||
Toasty.error(getApplicationContext(), getString(R.string.all_field_filled)).show();
|
||||
Toasty.error(MastodonRegisterActivity.this, getString(R.string.all_field_filled)).show();
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
signup.setEnabled(false);
|
||||
|
@ -212,7 +212,7 @@ public class MastodonRegisterActivity extends BaseActivity implements OnRetrieve
|
|||
@Override
|
||||
public void onRetrieveInstance(APIResponse apiResponse) {
|
||||
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;
|
||||
}
|
||||
List<InstanceReg> instanceRegs = apiResponse.getInstanceRegs();
|
||||
|
|
|
@ -95,7 +95,7 @@ public class MastodonShareRegisterActivity extends BaseActivity implements OnRet
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
|
@ -140,23 +140,23 @@ public class MastodonShareRegisterActivity extends BaseActivity implements OnRet
|
|||
error_message.setVisibility(View.GONE);
|
||||
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()) {
|
||||
Toasty.error(getApplicationContext(), getString(R.string.all_field_filled)).show();
|
||||
Toasty.error(MastodonShareRegisterActivity.this, getString(R.string.all_field_filled)).show();
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
signup.setEnabled(false);
|
||||
|
@ -179,7 +179,7 @@ public class MastodonShareRegisterActivity extends BaseActivity implements OnRet
|
|||
@Override
|
||||
public void onRetrieveInstance(APIResponse apiResponse) {
|
||||
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;
|
||||
}
|
||||
List<InstanceReg> instanceRegs = apiResponse.getInstanceRegs();
|
||||
|
|
|
@ -112,7 +112,7 @@ public class MutedInstanceActivity extends BaseActivity implements OnRetrieveDom
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
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);
|
||||
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);
|
||||
|
||||
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);
|
||||
dialog.dismiss();
|
||||
} 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());
|
||||
|
@ -159,10 +159,10 @@ public class MutedInstanceActivity extends BaseActivity implements OnRetrieveDom
|
|||
alertDialog.show();
|
||||
break;
|
||||
case R.id.action_export_instances:
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext()));
|
||||
SQLiteDatabase db = Sqlite.getInstance(MutedInstanceActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(MutedInstanceActivity.this));
|
||||
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());
|
||||
break;
|
||||
case R.id.action_import_instances:
|
||||
|
@ -297,7 +297,7 @@ public class MutedInstanceActivity extends BaseActivity implements OnRetrieveDom
|
|||
mainLoader.setVisibility(View.GONE);
|
||||
nextElementLoader.setVisibility(View.GONE);
|
||||
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);
|
||||
swiped = false;
|
||||
flag_loading = false;
|
||||
|
@ -335,7 +335,7 @@ public class MutedInstanceActivity extends BaseActivity implements OnRetrieveDom
|
|||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == PICK_IMPORT_INSTANCE && resultCode == RESULT_OK) {
|
||||
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;
|
||||
}
|
||||
try {
|
||||
|
@ -356,7 +356,7 @@ public class MutedInstanceActivity extends BaseActivity implements OnRetrieveDom
|
|||
}
|
||||
Helper.importInstanceBlock(MutedInstanceActivity.this, resultList);
|
||||
} 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) {
|
||||
if (error != null) {
|
||||
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 {
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ public class OwnerChartsActivity extends BaseActivity implements OnRetrieveChart
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
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);
|
||||
|
||||
|
||||
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 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) {
|
||||
Helper.loadGiF(getApplicationContext(), account, pp_actionBar);
|
||||
Helper.loadGiF(OwnerChartsActivity.this, account, pp_actionBar);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
validate.setOnClickListener(v -> loadGraph(dateIni, dateEnd));
|
||||
|
|
|
@ -168,7 +168,7 @@ public class OwnerNotificationActivity extends BaseActivity implements OnRetriev
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
toolbar.setBackgroundColor(ContextCompat.getColor(OwnerNotificationActivity.this, R.color.cyanea_primary));
|
||||
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();
|
||||
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);
|
||||
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);
|
||||
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
|
||||
.setTitle(R.string.action_stats)
|
||||
.setPositiveButton(R.string.close, (dialog, which) -> dialog.dismiss());
|
||||
dialogBuilder.create().show();
|
||||
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 {
|
||||
displayStats();
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ public class OwnerNotificationActivity extends BaseActivity implements OnRetriev
|
|||
}
|
||||
dialogBuilder = new AlertDialog.Builder(OwnerNotificationActivity.this, style);
|
||||
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);
|
||||
|
||||
|
||||
|
@ -436,7 +436,7 @@ public class OwnerNotificationActivity extends BaseActivity implements OnRetriev
|
|||
loader.setVisibility(View.GONE);
|
||||
|
||||
} 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);
|
||||
//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) {
|
||||
Toasty.error(getApplicationContext(), apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
||||
Toasty.error(OwnerNotificationActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
swiped = false;
|
||||
flag_loading = false;
|
||||
|
|
|
@ -142,7 +142,7 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
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);
|
||||
|
||||
|
||||
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 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) {
|
||||
Helper.loadGiF(getApplicationContext(), account, pp_actionBar);
|
||||
Helper.loadGiF(OwnerNotificationChartsActivity.this, account, pp_actionBar);
|
||||
}
|
||||
|
||||
toolbar_close.setOnClickListener(v -> finish());
|
||||
|
@ -181,7 +181,7 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
|
|||
dateIni = new NotificationCacheDAO(OwnerNotificationChartsActivity.this, db).getSmallerDate();
|
||||
dateEnd = new NotificationCacheDAO(OwnerNotificationChartsActivity.this, db).getGreaterDate();
|
||||
} else {
|
||||
Status status = new StatusCacheDAO(getApplicationContext(), db).getStatus(status_id);
|
||||
Status status = new StatusCacheDAO(OwnerNotificationChartsActivity.this, db).getStatus(status_id);
|
||||
if (status == null) {
|
||||
finish();
|
||||
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);
|
||||
|
||||
validate.setOnClickListener(v -> loadGraph(dateIni, dateEnd));
|
||||
|
|
|
@ -173,7 +173,7 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(android.content.Context.LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
toolbar.setBackgroundColor(ContextCompat.getColor(OwnerStatusActivity.this, R.color.cyanea_primary));
|
||||
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();
|
||||
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);
|
||||
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);
|
||||
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
|
||||
.setTitle(R.string.action_stats)
|
||||
.setPositiveButton(R.string.close, (dialog, which) -> dialog.dismiss());
|
||||
dialogBuilder.create().show();
|
||||
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 {
|
||||
displayStats();
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
|
|||
}
|
||||
dialogBuilder = new AlertDialog.Builder(OwnerStatusActivity.this, style);
|
||||
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);
|
||||
|
||||
|
||||
|
@ -426,7 +426,7 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
|
|||
nextElementLoader.setVisibility(View.GONE);
|
||||
//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) {
|
||||
Toasty.error(getApplicationContext(), apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
||||
Toasty.error(OwnerStatusActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
swiped = false;
|
||||
flag_loading = false;
|
||||
|
@ -540,7 +540,7 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
|
|||
loader.setVisibility(View.GONE);
|
||||
|
||||
} 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ public class PartnerShipActivity extends BaseActivity implements OnRetrieveRemot
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
|
@ -115,7 +115,7 @@ public class PartnerShipActivity extends BaseActivity implements OnRetrieveRemot
|
|||
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
|
||||
|
@ -131,7 +131,7 @@ public class PartnerShipActivity extends BaseActivity implements OnRetrieveRemot
|
|||
@Override
|
||||
public void onRetrieveRemoteAccount(Results results, boolean devAccount) {
|
||||
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;
|
||||
}
|
||||
List<Account> accounts = results.getAccounts();
|
||||
|
@ -143,7 +143,7 @@ public class PartnerShipActivity extends BaseActivity implements OnRetrieveRemot
|
|||
mastohostAcct.add(account);
|
||||
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();
|
||||
if (mastohostAcct != null) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
write_comment_container.setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
public void onClick(View v) {
|
||||
String comment = add_comment_write.getText().toString();
|
||||
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_read.setVisibility(View.VISIBLE);
|
||||
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);
|
||||
instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext()));
|
||||
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
|
||||
Helper.loadGiF(getApplicationContext(), account, my_pp);
|
||||
instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(PeertubeActivity.this));
|
||||
Account account = new AccountDAO(PeertubeActivity.this, db).getUniqAccount(userId, instance);
|
||||
Helper.loadGiF(PeertubeActivity.this, account, my_pp);
|
||||
Bundle b = getIntent().getExtras();
|
||||
if (b != null) {
|
||||
peertubeInstance = b.getString("peertube_instance", null);
|
||||
|
@ -244,7 +244,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
|
@ -384,7 +384,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
return true;
|
||||
case R.id.action_comment:
|
||||
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>() {
|
||||
|
||||
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);
|
||||
} else if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
|
||||
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;
|
||||
}
|
||||
int style;
|
||||
|
@ -454,7 +454,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
public void onClick(DialogInterface dialog, int which) {
|
||||
String comment = input.getText().toString();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -479,12 +479,12 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
public void onRetrievePeertube(APIResponse apiResponse) {
|
||||
|
||||
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);
|
||||
return;
|
||||
}
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
@ -518,7 +518,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
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() {
|
||||
@Override
|
||||
public boolean onMenuItemActionExpand(MenuItem item) {
|
||||
|
@ -578,7 +578,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
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);
|
||||
changeColor();
|
||||
}
|
||||
|
@ -587,7 +587,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
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);
|
||||
changeColor();
|
||||
}
|
||||
|
@ -599,7 +599,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
String newState = peertube.getMyRating().equals("like") ? "none" : "like";
|
||||
Status status = new Status();
|
||||
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);
|
||||
changeColor();
|
||||
}
|
||||
|
@ -610,7 +610,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
String newState = peertube.getMyRating().equals("dislike") ? "none" : "dislike";
|
||||
Status status = new Status();
|
||||
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);
|
||||
changeColor();
|
||||
}
|
||||
|
@ -627,8 +627,8 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
|
||||
if (mode == Helper.VIDEO_MODE_DIRECT) {
|
||||
|
||||
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getApplicationContext(),
|
||||
Util.getUserAgent(getApplicationContext(), "Mastalab"), null);
|
||||
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(PeertubeActivity.this,
|
||||
Util.getUserAgent(PeertubeActivity.this, "Mastalab"), null);
|
||||
|
||||
ExtractorMediaSource videoSource = new ExtractorMediaSource.Factory(dataSourceFactory)
|
||||
.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);
|
||||
if (peertubes == null || peertubes.size() == 0) {
|
||||
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 {
|
||||
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
|
||||
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) {
|
||||
if (apiResponse == null || (apiResponse.getError() != null && apiResponse.getError().getStatusCode() != 404 && apiResponse.getError() != null && apiResponse.getError().getStatusCode() != 501)) {
|
||||
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
|
||||
Toasty.error(getApplicationContext(), apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
||||
Toasty.error(PeertubeActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
List<Status> statuses = apiResponse.getStatuses();
|
||||
|
@ -848,8 +848,8 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
player = ExoPlayerFactory.newSimpleInstance(PeertubeActivity.this);
|
||||
playerView.setPlayer(player);
|
||||
loader.setVisibility(View.GONE);
|
||||
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getApplicationContext(),
|
||||
Util.getUserAgent(getApplicationContext(), "Mastalab"), null);
|
||||
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(PeertubeActivity.this,
|
||||
Util.getUserAgent(PeertubeActivity.this, "Mastalab"), null);
|
||||
|
||||
ExtractorMediaSource videoSource = new ExtractorMediaSource.Factory(dataSourceFactory)
|
||||
.createMediaSource(Uri.parse(peertube.getFileUrl(res, peertube.isStreamService())));
|
||||
|
|
|
@ -111,7 +111,7 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
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() {
|
||||
@Override
|
||||
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();
|
||||
}
|
||||
});
|
||||
|
@ -254,7 +254,7 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
|
|||
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);
|
||||
|
||||
channels = new LinkedHashMap<>();
|
||||
|
@ -267,9 +267,9 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
|
|||
public void onRetrievePeertube(APIResponse apiResponse) {
|
||||
if (apiResponse.getError() != null || apiResponse.getPeertubes() == null || apiResponse.getPeertubes().size() == 0) {
|
||||
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
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
|
|||
Peertube peertube = apiResponse.getPeertubes().get(0);
|
||||
|
||||
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);
|
||||
set_upload_submit.setEnabled(true);
|
||||
} else {
|
||||
|
@ -577,9 +577,9 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
|
|||
public void onRetrievePeertubeChannels(APIResponse apiResponse) {
|
||||
if (apiResponse.getError() != null || apiResponse.getAccounts() == null || apiResponse.getAccounts().size() == 0) {
|
||||
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
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -618,7 +618,7 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
|
|||
|
||||
@Override
|
||||
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);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
|
|
|
@ -93,7 +93,7 @@ public class PeertubeRegisterActivity extends BaseActivity implements OnRetrieve
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
|
@ -118,23 +118,23 @@ public class PeertubeRegisterActivity extends BaseActivity implements OnRetrieve
|
|||
error_message.setVisibility(View.GONE);
|
||||
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()) {
|
||||
Toasty.error(getApplicationContext(), getString(R.string.all_field_filled)).show();
|
||||
Toasty.error(PeertubeRegisterActivity.this, getString(R.string.all_field_filled)).show();
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
signup.setEnabled(false);
|
||||
|
@ -157,7 +157,7 @@ public class PeertubeRegisterActivity extends BaseActivity implements OnRetrieve
|
|||
@Override
|
||||
public void onRetrieveInstance(APIResponse apiResponse) {
|
||||
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;
|
||||
}
|
||||
List<InstanceReg> instanceRegs = apiResponse.getInstanceRegs();
|
||||
|
|
|
@ -113,7 +113,7 @@ public class PeertubeUploadActivity extends BaseActivity implements OnRetrievePe
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
|
@ -150,7 +150,7 @@ public class PeertubeUploadActivity extends BaseActivity implements OnRetrievePe
|
|||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == PICK_IVDEO && resultCode == Activity.RESULT_OK) {
|
||||
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;
|
||||
}
|
||||
set_upload_submit.setEnabled(true);
|
||||
|
@ -202,9 +202,9 @@ public class PeertubeUploadActivity extends BaseActivity implements OnRetrievePe
|
|||
public void onRetrievePeertubeChannels(APIResponse apiResponse) {
|
||||
if (apiResponse.getError() != null || apiResponse.getAccounts() == null || apiResponse.getAccounts().size() == 0) {
|
||||
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
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -348,8 +348,8 @@ public class PeertubeUploadActivity extends BaseActivity implements OnRetrievePe
|
|||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
||||
UploadNotificationConfig uploadConfig = new UploadNotificationConfig();
|
||||
Intent in = new Intent(getApplicationContext(), PeertubeEditUploadActivity.class);
|
||||
PendingIntent clickIntent = PendingIntent.getActivity(getApplicationContext(), 1, in, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
Intent in = new Intent(PeertubeUploadActivity.this, PeertubeEditUploadActivity.class);
|
||||
PendingIntent clickIntent = PendingIntent.getActivity(PeertubeUploadActivity.this, 1, in, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
uploadConfig
|
||||
.setClearOnActionForAllStatuses(true);
|
||||
|
||||
|
|
|
@ -310,7 +310,7 @@ public class PhotoEditorActivity extends BaseActivity implements OnPhotoEditorLi
|
|||
if (exit) {
|
||||
Intent intentImage = new Intent(Helper.INTENT_SEND_MODIFIED_IMAGE);
|
||||
intentImage.putExtra("imgpath", imagePath);
|
||||
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intentImage);
|
||||
LocalBroadcastManager.getInstance(PhotoEditorActivity.this).sendBroadcast(intentImage);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -541,7 +541,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
super.onCreate(savedInstanceState);
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
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);
|
||||
switch (theme) {
|
||||
case Helper.THEME_LIGHT:
|
||||
|
@ -573,7 +573,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
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) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(PixelfedComposeActivity.this);
|
||||
int iconColor = prefs.getInt("theme_icons_color", -1);
|
||||
if (iconColor != -1) {
|
||||
Helper.changeDrawableColor(getApplicationContext(), toot_visibility, iconColor);
|
||||
Helper.changeDrawableColor(getApplicationContext(), toot_emoji, iconColor);
|
||||
Helper.changeDrawableColor(PixelfedComposeActivity.this, toot_visibility, iconColor);
|
||||
Helper.changeDrawableColor(PixelfedComposeActivity.this, toot_emoji, iconColor);
|
||||
toot_sensitive.setButtonTintList(ColorStateList.valueOf(iconColor));
|
||||
toot_sensitive.setTextColor(iconColor);
|
||||
}
|
||||
|
@ -693,7 +693,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
}
|
||||
Bundle b = getIntent().getExtras();
|
||||
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;
|
||||
if (b != null) {
|
||||
scheduledstatus = b.getParcelable("storedStatus");
|
||||
|
@ -702,7 +702,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
if (accountReplyToken != null) {
|
||||
String[] val = accountReplyToken.split("\\|");
|
||||
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");
|
||||
|
@ -740,7 +740,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
instanceReply = accountReply.getInstance();
|
||||
}
|
||||
if (accountReply == null)
|
||||
account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userIdReply, instanceReply);
|
||||
account = new AccountDAO(PixelfedComposeActivity.this, db).getUniqAccount(userIdReply, instanceReply);
|
||||
else
|
||||
account = accountReply;
|
||||
|
||||
|
@ -750,7 +750,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
toot_content.requestFocus();
|
||||
|
||||
|
||||
Helper.loadGiF(getApplicationContext(), account, pp_actionBar);
|
||||
Helper.loadGiF(PixelfedComposeActivity.this, account, pp_actionBar);
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
|
@ -925,7 +925,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
}
|
||||
}
|
||||
} 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) {
|
||||
mToast.cancel();
|
||||
}
|
||||
mToast = Toasty.error(getApplicationContext(), message, Toast.LENGTH_SHORT);
|
||||
mToast = Toasty.error(PixelfedComposeActivity.this, message, Toast.LENGTH_SHORT);
|
||||
mToast.show();
|
||||
}
|
||||
|
||||
|
@ -964,12 +964,12 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
count++;
|
||||
} catch (Exception e) {
|
||||
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);
|
||||
toot_it.setEnabled(true);
|
||||
}
|
||||
} 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 {
|
||||
photoFile = createImageFile();
|
||||
} 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
|
||||
if (photoFile != null) {
|
||||
|
@ -1024,13 +1024,13 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
boolean photo_editor = sharedpreferences.getBoolean(Helper.SET_PHOTO_EDITOR, true);
|
||||
if (requestCode == PICK_IMAGE && resultCode == RESULT_OK) {
|
||||
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;
|
||||
}
|
||||
|
||||
ClipData clipData = data.getClipData();
|
||||
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;
|
||||
}
|
||||
if (clipData != null) {
|
||||
|
@ -1060,7 +1060,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
} else if (mime != null && mime.toLowerCase().contains("audio")) {
|
||||
prepareUpload(PixelfedComposeActivity.this, data.getData(), filename, uploadReceiver);
|
||||
} 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
|
||||
public void onPostAction(int statusCode, API.StatusAction statusAction, String userId, Error error) {
|
||||
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 {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -1108,7 +1108,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
@Override
|
||||
public void onError(Context context, UploadInfo uploadInfo, ServerResponse serverResponse,
|
||||
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) {
|
||||
pickup_picture.setVisibility(View.VISIBLE);
|
||||
imageSlider.setVisibility(View.GONE);
|
||||
|
@ -1144,7 +1144,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
if (extras != null && extras.getString("imageUri") != null) {
|
||||
Uri imageUri = Uri.parse(extras.getString("imageUri"));
|
||||
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;
|
||||
}
|
||||
String filename = Helper.getFileName(PixelfedComposeActivity.this, imageUri);
|
||||
|
@ -1179,7 +1179,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
return true;
|
||||
case R.id.action_schedule:
|
||||
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;
|
||||
}
|
||||
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 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);
|
||||
Button date_time_cancel = dialogView.findViewById(R.id.date_time_cancel);
|
||||
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()};
|
||||
|
||||
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 {
|
||||
AlertDialog.Builder builderSingle = new AlertDialog.Builder(PixelfedComposeActivity.this, style);
|
||||
builderSingle.setTitle(getString(R.string.choose_schedule));
|
||||
|
@ -1279,7 +1279,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
private void sendToot(String timestamp) {
|
||||
toot_it.setEnabled(false);
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
@ -1294,17 +1294,17 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
toot.setContent(PixelfedComposeActivity.this, tootContent);
|
||||
if (timestamp == 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 {
|
||||
toot.setScheduled_at(Helper.dateToString(scheduledstatus.getScheduled_date()));
|
||||
scheduledstatus.setStatus(toot);
|
||||
isScheduled = true;
|
||||
new PostActionAsyncTask(getApplicationContext(), 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 PostActionAsyncTask(PixelfedComposeActivity.this, API.StatusAction.DELETESCHEDULED, scheduledstatus, PixelfedComposeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
new PostStatusAsyncTask(PixelfedComposeActivity.this, social, account, toot, PixelfedComposeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
else {
|
||||
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);
|
||||
isScheduled = true;
|
||||
//Schedules the toot
|
||||
ScheduledTootsSyncJob.schedule(getApplicationContext(), currentToId, time);
|
||||
ScheduledTootsSyncJob.schedule(PixelfedComposeActivity.this, currentToId, time);
|
||||
resetForNextToot();
|
||||
}
|
||||
|
||||
|
@ -1344,7 +1344,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
isSensitive = false;
|
||||
toot_sensitive.setVisibility(View.GONE);
|
||||
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
|
||||
|
@ -1533,11 +1533,11 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
|
||||
if (apiResponse.getError() == null || apiResponse.getError().getStatusCode() != -33) {
|
||||
if (restored != -1) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new StatusStoredDAO(getApplicationContext(), db).remove(restored);
|
||||
SQLiteDatabase db = Sqlite.getInstance(PixelfedComposeActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new StatusStoredDAO(PixelfedComposeActivity.this, db).remove(restored);
|
||||
} else if (currentToId != -1) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new StatusStoredDAO(getApplicationContext(), db).remove(currentToId);
|
||||
SQLiteDatabase db = Sqlite.getInstance(PixelfedComposeActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new StatusStoredDAO(PixelfedComposeActivity.this, db).remove(currentToId);
|
||||
}
|
||||
}
|
||||
//Clear the toot
|
||||
|
@ -1561,17 +1561,17 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
if (scheduledstatus == null && !isScheduled) {
|
||||
boolean display_confirm = sharedpreferences.getBoolean(Helper.SET_DISPLAY_CONFIRM, true);
|
||||
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
|
||||
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 {
|
||||
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);
|
||||
//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);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
|
@ -1764,7 +1764,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
}
|
||||
|
||||
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);
|
||||
if (draft == null)
|
||||
return;
|
||||
|
@ -1890,12 +1890,12 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
String url = attachment.getPreview_url();
|
||||
if (url == null || url.trim().equals(""))
|
||||
url = attachment.getUrl();
|
||||
final ImageView imageView = new ImageView(getApplicationContext());
|
||||
final ImageView imageView = new ImageView(PixelfedComposeActivity.this);
|
||||
imageView.setId(Integer.parseInt(attachment.getId()));
|
||||
|
||||
LinearLayout.LayoutParams imParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
|
||||
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.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||
|
||||
|
@ -1983,7 +1983,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
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 {
|
||||
if (currentToId == -1) {
|
||||
currentToId = new StatusStoredDAO(PixelfedComposeActivity.this, db).insertStatus(toot, null);
|
||||
|
@ -1997,10 +1997,10 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
}
|
||||
}
|
||||
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) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ public class PlaylistsActivity extends BaseActivity implements OnPlaylistActionI
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
|
@ -152,7 +152,7 @@ public class PlaylistsActivity extends BaseActivity implements OnPlaylistActionI
|
|||
if (b != null) {
|
||||
playlist = b.getParcelable("playlist");
|
||||
} 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;
|
||||
}
|
||||
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
|
||||
if (apiResponse.getError() != null) {
|
||||
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);
|
||||
swiped = false;
|
||||
flag_loading = false;
|
||||
|
|
|
@ -61,7 +61,7 @@ public class PrivacyActivity extends BaseActivity {
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
|
|
|
@ -131,7 +131,7 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
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() {
|
||||
@Override
|
||||
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("@", "");
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
|
@ -223,7 +223,7 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
|
|||
e.printStackTrace();
|
||||
runOnUiThread(new Runnable() {
|
||||
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;
|
||||
RecyclerView lv_reorder_tabs = findViewById(R.id.lv_reorder_tabs);
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
timelines = new TimelinesDAO(getApplicationContext(), db).getAllTimelines();
|
||||
SQLiteDatabase db = Sqlite.getInstance(ReorderTimelinesActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
timelines = new TimelinesDAO(ReorderTimelinesActivity.this, db).getAllTimelines();
|
||||
adapter = new ReorderTabAdapter(timelines, ReorderTimelinesActivity.this, ReorderTimelinesActivity.this);
|
||||
|
||||
ItemTouchHelper.Callback callback =
|
||||
|
@ -365,7 +365,7 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
|
|||
undo_action = findViewById(R.id.undo_action);
|
||||
undo_container = findViewById(R.id.undo_container);
|
||||
lv_reorder_tabs.setAdapter(adapter);
|
||||
LinearLayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
|
||||
LinearLayoutManager mLayoutManager = new LinearLayoutManager(ReorderTimelinesActivity.this);
|
||||
lv_reorder_tabs.setLayoutManager(mLayoutManager);
|
||||
}
|
||||
|
||||
|
@ -394,20 +394,20 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
|
|||
@Override
|
||||
public void run() {
|
||||
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()) {
|
||||
case TAG:
|
||||
new SearchDAO(getApplicationContext(), db).remove(manageTimelines.getTagTimeline().getName());
|
||||
new TimelinesDAO(getApplicationContext(), db).remove(manageTimelines);
|
||||
new SearchDAO(ReorderTimelinesActivity.this, db).remove(manageTimelines.getTagTimeline().getName());
|
||||
new TimelinesDAO(ReorderTimelinesActivity.this, db).remove(manageTimelines);
|
||||
break;
|
||||
case INSTANCE:
|
||||
new InstancesDAO(getApplicationContext(), db).remove(manageTimelines.getRemoteInstance().getHost());
|
||||
new TimelinesDAO(getApplicationContext(), db).remove(manageTimelines);
|
||||
new InstancesDAO(ReorderTimelinesActivity.this, db).remove(manageTimelines.getRemoteInstance().getHost());
|
||||
new TimelinesDAO(ReorderTimelinesActivity.this, db).remove(manageTimelines);
|
||||
break;
|
||||
case LIST:
|
||||
timeline = manageTimelines;
|
||||
new ManageListsAsyncTask(getApplicationContext(), ManageListsAsyncTask.action.DELETE_LIST, null, null, manageTimelines.getListTimeline().getId(), null, ReorderTimelinesActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
new TimelinesDAO(getApplicationContext(), db).remove(timeline);
|
||||
new ManageListsAsyncTask(ReorderTimelinesActivity.this, ManageListsAsyncTask.action.DELETE_LIST, null, null, manageTimelines.getListTimeline().getId(), null, ReorderTimelinesActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
new TimelinesDAO(ReorderTimelinesActivity.this, db).remove(timeline);
|
||||
refresh_list = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -88,11 +88,11 @@ public class SearchResultActivity extends BaseActivity implements OnRetrieveSear
|
|||
if (b != null) {
|
||||
search = b.getString("search");
|
||||
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
|
||||
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 {
|
||||
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) {
|
||||
forTrends = true;
|
||||
|
@ -103,7 +103,7 @@ public class SearchResultActivity extends BaseActivity implements OnRetrieveSear
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
|
@ -150,12 +150,12 @@ public class SearchResultActivity extends BaseActivity implements OnRetrieveSear
|
|||
if (apiResponse.getError() != null) {
|
||||
if (apiResponse.getError().getError() != null) {
|
||||
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 {
|
||||
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
|
||||
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;
|
||||
}
|
||||
lv_search.setVisibility(View.VISIBLE);
|
||||
|
@ -191,9 +191,9 @@ public class SearchResultActivity extends BaseActivity implements OnRetrieveSear
|
|||
loader.setVisibility(View.GONE);
|
||||
if (apiResponse.getError() != null) {
|
||||
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 {
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -89,9 +89,9 @@ public class SearchResultTabActivity extends BaseActivity {
|
|||
if (b != null) {
|
||||
search = b.getString("search");
|
||||
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 {
|
||||
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)
|
||||
finish();
|
||||
|
@ -107,7 +107,7 @@ public class SearchResultTabActivity extends BaseActivity {
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
|
@ -125,27 +125,28 @@ public class SearchResultTabActivity extends BaseActivity {
|
|||
|
||||
toolbar_search.setIconified(true);
|
||||
toolbar_search.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
||||
assert imm != null;
|
||||
imm.hideSoftInputFromWindow(toolbar_search.getWindowToken(), 0);
|
||||
query = query.replaceAll("^#+", "");
|
||||
search = query.trim();
|
||||
PagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
|
||||
search_viewpager.setAdapter(mPagerAdapter);
|
||||
toolbar_search.clearFocus();
|
||||
toolbar_title.setText(search);
|
||||
toolbar_title.setVisibility(View.VISIBLE);
|
||||
toolbar_title.requestFocus();
|
||||
toolbar_search.setIconified(true);
|
||||
toolbar_search.setIconified(true);
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
||||
assert imm != null;
|
||||
imm.hideSoftInputFromWindow(toolbar_search.getWindowToken(), 0);
|
||||
query = query.replaceAll("^#+", "");
|
||||
search = query.trim();
|
||||
PagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
|
||||
search_viewpager.setAdapter(mPagerAdapter);
|
||||
toolbar_search.clearFocus();
|
||||
toolbar_title.setText(search);
|
||||
toolbar_title.setVisibility(View.VISIBLE);
|
||||
toolbar_title.requestFocus();
|
||||
toolbar_search.setIconified(true);
|
||||
toolbar_search.setIconified(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
toolbar_search.setOnCloseListener(() -> {
|
||||
toolbar_title.setText(search);
|
||||
|
@ -163,14 +164,17 @@ public class SearchResultTabActivity extends BaseActivity {
|
|||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
TabLayout.Tab tab = tabLayout.getTabAt(position);
|
||||
if (tab != null)
|
||||
tab.select();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {}
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
}
|
||||
});
|
||||
|
||||
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||
|
|
|
@ -80,7 +80,7 @@ public class SettingsActivity extends BaseActivity {
|
|||
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
|
@ -158,9 +158,9 @@ public class SettingsActivity extends BaseActivity {
|
|||
dialogBuilder.setMessage(R.string.restart_message);
|
||||
dialogBuilder.setTitle(R.string.apply_changes);
|
||||
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;
|
||||
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);
|
||||
assert mgr != null;
|
||||
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent);
|
||||
|
|
|
@ -204,18 +204,18 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
ischannel = b.getBoolean("ischannel", false);
|
||||
peertubeAccount = b.getBoolean("peertubeaccount", false);
|
||||
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);
|
||||
|
||||
} 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;
|
||||
show_boosts = sharedpreferences.getBoolean(Helper.SHOW_ACCOUNT_BOOSTS, true);
|
||||
show_replies = sharedpreferences.getBoolean(Helper.SHOW_ACCOUNT_REPLIES, true);
|
||||
statuses = new ArrayList<>();
|
||||
boolean isOnWifi = Helper.isOnWIFI(getApplicationContext());
|
||||
boolean isOnWifi = Helper.isOnWIFI(ShowAccountActivity.this);
|
||||
StatusDrawerParams statusDrawerParams = new StatusDrawerParams();
|
||||
statusDrawerParams.setType(RetrieveFeedsAsyncTask.Type.USER);
|
||||
statusDrawerParams.setTargetedId(accountId);
|
||||
|
@ -295,7 +295,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
|
||||
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)) {
|
||||
account_follow.setVisibility(View.GONE);
|
||||
|
@ -352,7 +352,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
actionbar_title.setText(account.getAcct());
|
||||
ImageView pp_actionBar = findViewById(R.id.pp_actionBar);
|
||||
if (account.getAvatar() != null) {
|
||||
Helper.loadGiF(getApplicationContext(), account, pp_actionBar);
|
||||
Helper.loadGiF(ShowAccountActivity.this, account, pp_actionBar);
|
||||
|
||||
}
|
||||
final AppBarLayout appBar = findViewById(R.id.appBar);
|
||||
|
@ -372,11 +372,11 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
//Timed muted account
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
final SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final Account authenticatedAccount = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
|
||||
boolean isTimedMute = new TempMuteDAO(getApplicationContext(), db).isTempMuted(authenticatedAccount, accountId);
|
||||
final SQLiteDatabase db = Sqlite.getInstance(ShowAccountActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final Account authenticatedAccount = new AccountDAO(ShowAccountActivity.this, db).getUniqAccount(userId, instance);
|
||||
boolean isTimedMute = new TempMuteDAO(ShowAccountActivity.this, db).isTempMuted(authenticatedAccount, accountId);
|
||||
if (isTimedMute) {
|
||||
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) {
|
||||
final TextView temp_mute = findViewById(R.id.temp_mute);
|
||||
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);
|
||||
temp_mute.setText(content_temp_mute);
|
||||
temp_mute.setOnClickListener(view -> {
|
||||
new TempMuteDAO(getApplicationContext(), db).remove(authenticatedAccount, accountId);
|
||||
new TempMuteDAO(ShowAccountActivity.this, db).remove(authenticatedAccount, 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);
|
||||
});
|
||||
}
|
||||
|
@ -599,9 +599,9 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
String account_id = account.getAcct();
|
||||
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);
|
||||
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;
|
||||
clipboard.setPrimaryClip(clip);
|
||||
return false;
|
||||
|
@ -668,7 +668,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
});
|
||||
popup.setOnMenuItemClickListener(item -> {
|
||||
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() {
|
||||
@Override
|
||||
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 -> {
|
||||
Intent intent = new Intent(ShowAccountActivity.this, SlideMediaActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
|
@ -741,10 +741,10 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
String finalTarget = target;
|
||||
account_follow.setOnClickListener(v -> {
|
||||
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) {
|
||||
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) {
|
||||
boolean confirm_unfollow = sharedpreferences.getBoolean(Helper.SET_UNFOLLOW_VALIDATION, true);
|
||||
if (confirm_unfollow) {
|
||||
|
@ -754,18 +754,18 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
unfollowConfirm.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
||||
unfollowConfirm.setPositiveButton(R.string.yes, (dialog, which) -> {
|
||||
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();
|
||||
});
|
||||
unfollowConfirm.show();
|
||||
} else {
|
||||
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) {
|
||||
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 -> {
|
||||
|
@ -773,7 +773,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
return false;
|
||||
});
|
||||
|
||||
UserNote userNote = new NotesDAO(getApplicationContext(), db).getUserNote(account.getAcct());
|
||||
UserNote userNote = new NotesDAO(ShowAccountActivity.this, db).getUserNote(account.getAcct());
|
||||
if (userNote != null) {
|
||||
|
||||
account_personal_note.setVisibility(View.VISIBLE);
|
||||
|
@ -791,13 +791,13 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
builderInner.setView(input);
|
||||
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
||||
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) {
|
||||
userNote1 = new UserNote();
|
||||
userNote1.setAcct(account.getAcct());
|
||||
}
|
||||
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) {
|
||||
account_personal_note.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
|
@ -814,7 +814,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
account_date.setVisibility(View.VISIBLE);
|
||||
new Thread(() -> {
|
||||
|
||||
String instance1 = getLiveInstance(getApplicationContext());
|
||||
String instance1 = getLiveInstance(ShowAccountActivity.this);
|
||||
if (account.getAcct().split("@").length > 1) {
|
||||
instance1 = account.getAcct().split("@")[1];
|
||||
}
|
||||
|
@ -827,7 +827,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
instance_info.setVisibility(View.VISIBLE);
|
||||
|
||||
instance_info.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(getApplicationContext(), InstanceProfileActivity.class);
|
||||
Intent intent = new Intent(ShowAccountActivity.this, InstanceProfileActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putString("instance", finalInstance);
|
||||
intent.putExtras(b);
|
||||
|
@ -852,7 +852,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
@Override
|
||||
public void onRetrieveFeeds(APIResponse apiResponse) {
|
||||
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;
|
||||
}
|
||||
pins = apiResponse.getStatuses();
|
||||
|
@ -871,9 +871,9 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
|
||||
if (error != null) {
|
||||
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 {
|
||||
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;
|
||||
}
|
||||
|
@ -1104,14 +1104,14 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
} else {
|
||||
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()) {
|
||||
case R.id.action_follow_instance:
|
||||
String finalInstanceName = splitAcct[1];
|
||||
List<RemoteInstance> remoteInstances = new InstancesDAO(ShowAccountActivity.this, db).getInstanceByName(finalInstanceName);
|
||||
if (remoteInstances != null && remoteInstances.size() > 0) {
|
||||
Toasty.info(getApplicationContext(), getString(R.string.toast_instance_already_added), Toast.LENGTH_LONG).show();
|
||||
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
|
||||
Toasty.info(ShowAccountActivity.this, getString(R.string.toast_instance_already_added), Toast.LENGTH_LONG).show();
|
||||
Intent intent = new Intent(ShowAccountActivity.this, MainActivity.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(Helper.INTENT_ACTION, Helper.SEARCH_INSTANCE);
|
||||
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");
|
||||
else
|
||||
new InstancesDAO(ShowAccountActivity.this, db).insertInstance(finalInstanceName, "PEERTUBE");
|
||||
Toasty.success(getApplicationContext(), getString(R.string.toast_instance_followed), Toast.LENGTH_LONG).show();
|
||||
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
|
||||
Toasty.success(ShowAccountActivity.this, getString(R.string.toast_instance_followed), Toast.LENGTH_LONG).show();
|
||||
Intent intent = new Intent(ShowAccountActivity.this, MainActivity.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(Helper.INTENT_ACTION, Helper.SEARCH_INSTANCE);
|
||||
bundle.putString(Helper.INSTANCE_NAME, finalInstanceName);
|
||||
|
@ -1147,7 +1147,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
});
|
||||
} catch (final Exception e) {
|
||||
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();
|
||||
return true;
|
||||
|
@ -1186,21 +1186,21 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
case R.id.action_endorse:
|
||||
if (relationship != null)
|
||||
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 {
|
||||
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;
|
||||
case R.id.action_hide_boost:
|
||||
if (relationship != null)
|
||||
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 {
|
||||
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;
|
||||
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();
|
||||
b.putString("mentionAccount", account.getAcct());
|
||||
b.putString("visibility", "direct");
|
||||
|
@ -1218,7 +1218,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
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();
|
||||
if (relationship == null || !relationship.isFollowing()) {
|
||||
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 {
|
||||
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;
|
||||
case R.id.action_mention:
|
||||
intent = new Intent(getApplicationContext(), TootActivity.class);
|
||||
intent = new Intent(ShowAccountActivity.this, TootActivity.class);
|
||||
b = new Bundle();
|
||||
b.putString("mentionAccount", account.getAcct());
|
||||
intent.putExtras(b);
|
||||
|
@ -1284,13 +1284,13 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
String comment = null;
|
||||
if (input.getText() != null)
|
||||
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();
|
||||
});
|
||||
builderInner.show();
|
||||
return true;
|
||||
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.setTitle(R.string.note_for_account);
|
||||
input = new EditText(ShowAccountActivity.this);
|
||||
|
@ -1306,13 +1306,13 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
builderInner.setView(input);
|
||||
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
||||
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) {
|
||||
userNote1 = new UserNote();
|
||||
userNote1.setAcct(account.getAcct());
|
||||
}
|
||||
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) {
|
||||
account_personal_note.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
|
@ -1344,7 +1344,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
} else {
|
||||
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();
|
||||
});
|
||||
builderInner.show();
|
||||
|
@ -1377,16 +1377,16 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
|
||||
if (error != null) {
|
||||
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 {
|
||||
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;
|
||||
}
|
||||
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);
|
||||
} else {
|
||||
Helper.manageMessageStatusCode(getApplicationContext(), statusCode, statusAction);
|
||||
Helper.manageMessageStatusCode(ShowAccountActivity.this, statusCode, statusAction);
|
||||
}
|
||||
String target = account.getId();
|
||||
//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)
|
||||
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
|
||||
|
@ -1406,11 +1406,11 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
|
||||
if (error != null || account == null || account.getAcct() == 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) {
|
||||
Toasty.error(getApplicationContext(), error.getError(), Toast.LENGTH_LONG).show();
|
||||
Toasty.error(ShowAccountActivity.this, error.getError(), Toast.LENGTH_LONG).show();
|
||||
} 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;
|
||||
}
|
||||
|
@ -1422,13 +1422,14 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
public void onActionDone(ManageListsAsyncTask.action actionType, APIResponse apiResponse, int statusCode) {
|
||||
if (apiResponse.getError() != null) {
|
||||
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;
|
||||
}
|
||||
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
|
||||
public void onIdentityProof(APIResponse apiResponse) {
|
||||
if (apiResponse == null) {
|
||||
|
|
|
@ -112,7 +112,7 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
|
|||
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
|
||||
|
||||
if (receive_action != null)
|
||||
LocalBroadcastManager.getInstance(getApplicationContext()).unregisterReceiver(receive_action);
|
||||
LocalBroadcastManager.getInstance(ShowConversationActivity.this).unregisterReceiver(receive_action);
|
||||
receive_action = new BroadcastReceiver() {
|
||||
@Override
|
||||
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);
|
||||
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 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) {
|
||||
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();
|
||||
}
|
||||
Helper.loadGiF(getApplicationContext(), account, pp_actionBar);
|
||||
Helper.loadGiF(ShowConversationActivity.this, account, pp_actionBar);
|
||||
|
||||
|
||||
swipeRefreshLayout = findViewById(R.id.swipeContainer);
|
||||
|
@ -229,7 +229,7 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
|
|||
swipeRefreshLayout.setColorSchemeColors(
|
||||
c1, c2, c1
|
||||
);
|
||||
boolean isOnWifi = Helper.isOnWIFI(getApplicationContext());
|
||||
boolean isOnWifi = Helper.isOnWIFI(ShowConversationActivity.this);
|
||||
if (initialStatus != null)
|
||||
statuses.add(initialStatus);
|
||||
else
|
||||
|
@ -257,7 +257,7 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
|
|||
if (conversationId != null)
|
||||
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.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
|
@ -306,7 +306,7 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
|
|||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (receive_action != null)
|
||||
LocalBroadcastManager.getInstance(getApplicationContext()).unregisterReceiver(receive_action);
|
||||
LocalBroadcastManager.getInstance(ShowConversationActivity.this).unregisterReceiver(receive_action);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -315,9 +315,9 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
|
|||
loader.setVisibility(View.GONE);
|
||||
if (apiResponse.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 {
|
||||
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;
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
|
|||
}
|
||||
i++;
|
||||
}
|
||||
boolean isOnWifi = Helper.isOnWIFI(getApplicationContext());
|
||||
boolean isOnWifi = Helper.isOnWIFI(ShowConversationActivity.this);
|
||||
for (Status status : apiResponse.getContext().getAncestors()) {
|
||||
statuses.add(0, status);
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
|
|||
//actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(SlideMediaActivity.this, R.color.cyanea_primary)));
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
|
|
|
@ -698,7 +698,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
super.onCreate(savedInstanceState);
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
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);
|
||||
switch (theme) {
|
||||
case Helper.THEME_LIGHT:
|
||||
|
@ -727,7 +727,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
|
@ -803,13 +803,13 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
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);
|
||||
if (iconColor != -1) {
|
||||
Helper.changeDrawableColor(getApplicationContext(), toot_emoji, iconColor);
|
||||
Helper.changeDrawableColor(getApplicationContext(), toot_visibility, iconColor);
|
||||
Helper.changeDrawableColor(getApplicationContext(), poll_action, iconColor);
|
||||
Helper.changeDrawableColor(getApplicationContext(), toot_picture, iconColor);
|
||||
Helper.changeDrawableColor(TootActivity.this, toot_emoji, iconColor);
|
||||
Helper.changeDrawableColor(TootActivity.this, toot_visibility, iconColor);
|
||||
Helper.changeDrawableColor(TootActivity.this, poll_action, iconColor);
|
||||
Helper.changeDrawableColor(TootActivity.this, toot_picture, iconColor);
|
||||
}
|
||||
|
||||
isScheduled = false;
|
||||
|
@ -883,7 +883,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
pp_progress.setVisibility(View.VISIBLE);
|
||||
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 {
|
||||
mt = tPattern.matcher(searchIn);
|
||||
if (mt.matches()) {
|
||||
|
@ -925,22 +925,22 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
|
||||
drawer_layout.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
|
||||
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();
|
||||
params.height = (int) Helper.convertDpToPixel(50, getApplicationContext());
|
||||
params.width = (int) Helper.convertDpToPixel(50, getApplicationContext());
|
||||
params.height = (int) Helper.convertDpToPixel(50, TootActivity.this);
|
||||
params.width = (int) Helper.convertDpToPixel(50, TootActivity.this);
|
||||
toot_picture_container.setLayoutParams(params);
|
||||
} else {
|
||||
ViewGroup.LayoutParams params = toot_picture_container.getLayoutParams();
|
||||
params.height = (int) Helper.convertDpToPixel(100, getApplicationContext());
|
||||
params.width = (int) Helper.convertDpToPixel(100, getApplicationContext());
|
||||
params.height = (int) Helper.convertDpToPixel(100, TootActivity.this);
|
||||
params.width = (int) Helper.convertDpToPixel(100, TootActivity.this);
|
||||
toot_picture_container.setLayoutParams(params);
|
||||
}
|
||||
});
|
||||
|
||||
Bundle b = getIntent().getExtras();
|
||||
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;
|
||||
if (b != null) {
|
||||
tootReply = b.getParcelable("tootReply");
|
||||
|
@ -950,7 +950,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
if (accountReplyToken != null) {
|
||||
String[] val = accountReplyToken.split("\\|");
|
||||
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);
|
||||
|
@ -986,7 +986,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
if (tootReply.getAccount() != null && tootReply.getAccount().getMoved_to_account() != null) {
|
||||
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)
|
||||
toot_it.setText(R.string.modify);
|
||||
|
@ -1003,7 +1003,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
instanceReply = accountReply.getInstance();
|
||||
}
|
||||
if (accountReply == null)
|
||||
account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userIdReply, instanceReply);
|
||||
account = new AccountDAO(TootActivity.this, db).getUniqAccount(userIdReply, instanceReply);
|
||||
else
|
||||
account = accountReply;
|
||||
|
||||
|
@ -1070,7 +1070,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
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
|
||||
|
@ -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)
|
||||
toot_content.addTextChangedListener(textWatcher);
|
||||
|
||||
|
@ -1296,7 +1296,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
url = attachment.getUrl();
|
||||
|
||||
|
||||
final ImageView imageView = new ImageView(getApplicationContext());
|
||||
final ImageView imageView = new ImageView(TootActivity.this);
|
||||
imageView.setId(Integer.parseInt(attachment.getId()));
|
||||
if (social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
|
||||
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);
|
||||
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.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
|
@ -1413,7 +1413,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
if (mToast != null) {
|
||||
mToast.cancel();
|
||||
}
|
||||
mToast = Toasty.error(getApplicationContext(), message, Toast.LENGTH_SHORT);
|
||||
mToast = Toasty.error(TootActivity.this, message, Toast.LENGTH_SHORT);
|
||||
mToast.show();
|
||||
}
|
||||
|
||||
|
@ -1432,12 +1432,12 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
count++;
|
||||
} catch (Exception e) {
|
||||
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_it.setEnabled(true);
|
||||
}
|
||||
} 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 {
|
||||
photoFile = createImageFile();
|
||||
} 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
|
||||
if (photoFile != null) {
|
||||
|
@ -1492,13 +1492,13 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
boolean photo_editor = sharedpreferences.getBoolean(Helper.SET_PHOTO_EDITOR, true);
|
||||
if (requestCode == PICK_IMAGE && resultCode == RESULT_OK) {
|
||||
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;
|
||||
}
|
||||
|
||||
ClipData clipData = data.getClipData();
|
||||
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;
|
||||
}
|
||||
if (clipData != null) {
|
||||
|
@ -1528,7 +1528,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
} else if (mime != null && mime.toLowerCase().contains("audio")) {
|
||||
prepareUpload(TootActivity.this, data.getData(), filename, uploadReceiver);
|
||||
} 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
|
||||
public void onPostAction(int statusCode, API.StatusAction statusAction, String userId, Error error) {
|
||||
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 {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -1577,7 +1577,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
@Override
|
||||
public void onError(Context context, UploadInfo uploadInfo, ServerResponse serverResponse,
|
||||
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)
|
||||
toot_picture_container.setVisibility(View.GONE);
|
||||
toot_picture.setEnabled(true);
|
||||
|
@ -1618,7 +1618,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
if (extras != null && extras.getString("imageUri") != null) {
|
||||
Uri imageUri = Uri.parse(extras.getString("imageUri"));
|
||||
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;
|
||||
}
|
||||
String filename = Helper.getFileName(TootActivity.this, imageUri);
|
||||
|
@ -1631,7 +1631,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
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;
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
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));
|
||||
alert.setPositiveButton(R.string.close, (dialog, whichButton) -> dialog.dismiss());
|
||||
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();
|
||||
});
|
||||
alert.show();
|
||||
|
@ -1683,10 +1683,10 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
return true;
|
||||
String dateString = sharedpreferences.getString(Helper.LAST_TRANSLATION_TIME, null);
|
||||
if (dateString != null) {
|
||||
Date dateCompare = Helper.stringToDate(getApplicationContext(), dateString);
|
||||
Date dateCompare = Helper.stringToDate(TootActivity.this, dateString);
|
||||
Date date = new Date();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -1695,7 +1695,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
AlertDialog.Builder transAlert = new AlertDialog.Builder(TootActivity.this, style);
|
||||
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);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
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());
|
||||
}
|
||||
} 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 (dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE) != null)
|
||||
dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE).setEnabled(true);
|
||||
}
|
||||
} 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());
|
||||
}
|
||||
} 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 (dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE) != null)
|
||||
dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE).setEnabled(true);
|
||||
}
|
||||
} 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 = 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);
|
||||
int paddingPixel = 15;
|
||||
float density = getResources().getDisplayMetrics().density;
|
||||
|
@ -1853,7 +1853,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
|
||||
builderSingle.setTitle(getString(R.string.select_accounts));
|
||||
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);
|
||||
EditText search_account = dialogView.findViewById(R.id.search_account);
|
||||
|
@ -1933,7 +1933,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
try {
|
||||
final List<StoredStatus> drafts = new StatusStoredDAO(TootActivity.this, db).getAllDrafts();
|
||||
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;
|
||||
}
|
||||
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.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setPositiveButton(R.string.yes, (dialogConfirm, which1) -> {
|
||||
new StatusStoredDAO(getApplicationContext(), db).removeAllDrafts();
|
||||
new StatusStoredDAO(TootActivity.this, db).removeAllDrafts();
|
||||
dialogConfirm.dismiss();
|
||||
dialog.dismiss();
|
||||
})
|
||||
|
@ -1967,24 +1967,24 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
});
|
||||
builderSingle.show();
|
||||
} 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;
|
||||
|
||||
case R.id.action_schedule:
|
||||
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;
|
||||
}
|
||||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(TootActivity.this, style);
|
||||
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);
|
||||
final AlertDialog alertDialog = dialogBuilder.create();
|
||||
|
||||
final DatePicker datePicker = dialogView.findViewById(R.id.date_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);
|
||||
Button date_time_cancel = dialogView.findViewById(R.id.date_time_cancel);
|
||||
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()};
|
||||
|
||||
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 {
|
||||
AlertDialog.Builder builderSingle1 = new AlertDialog.Builder(TootActivity.this, style);
|
||||
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) {
|
||||
toot_it.setEnabled(false);
|
||||
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);
|
||||
return;
|
||||
}
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
@ -2088,7 +2088,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
AlertDialog.Builder builderInner = new AlertDialog.Builder(TootActivity.this, style);
|
||||
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);
|
||||
|
||||
//Text for report
|
||||
|
@ -2164,17 +2164,17 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
}
|
||||
if (timestamp == 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 {
|
||||
toot.setScheduled_at(Helper.dateToString(scheduledstatus.getScheduled_date()));
|
||||
scheduledstatus.setStatus(toot);
|
||||
isScheduled = true;
|
||||
new PostActionAsyncTask(getApplicationContext(), 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 PostActionAsyncTask(TootActivity.this, API.StatusAction.DELETESCHEDULED, scheduledstatus, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
new PostStatusAsyncTask(TootActivity.this, social, account, toot, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
else {
|
||||
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);
|
||||
isScheduled = true;
|
||||
//Schedules the toot
|
||||
ScheduledTootsSyncJob.schedule(getApplicationContext(), currentToId, time);
|
||||
ScheduledTootsSyncJob.schedule(TootActivity.this, currentToId, time);
|
||||
resetForNextToot();
|
||||
}
|
||||
|
||||
|
@ -2212,7 +2212,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
isSensitive = false;
|
||||
toot_sensitive.setVisibility(View.GONE);
|
||||
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
|
||||
|
@ -2238,8 +2238,8 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
}
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
MenuItem itemEmoji = menu.findItem(R.id.action_emoji);
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final List<Emojis> emojis = new CustomEmojiDAO(getApplicationContext(), db).getAllEmojis();
|
||||
SQLiteDatabase db = Sqlite.getInstance(TootActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final List<Emojis> emojis = new CustomEmojiDAO(TootActivity.this, db).getAllEmojis();
|
||||
//Displays button only if custom emojis
|
||||
if (emojis != null && emojis.size() > 0) {
|
||||
itemEmoji.setVisible(true);
|
||||
|
@ -2314,14 +2314,14 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
AlertDialog.Builder builderInner = new AlertDialog.Builder(TootActivity.this, style);
|
||||
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);
|
||||
|
||||
//Text for report
|
||||
final EditText input = popup_media_description.findViewById(R.id.media_description);
|
||||
input.setFilters(new InputFilter[]{new InputFilter.LengthFilter(420)});
|
||||
final ImageView media_picture = popup_media_description.findViewById(R.id.media_picture);
|
||||
Glide.with(getApplicationContext())
|
||||
Glide.with(TootActivity.this)
|
||||
.asBitmap()
|
||||
.load(attachment.getUrl())
|
||||
.into(new SimpleTarget<Bitmap>() {
|
||||
|
@ -2340,7 +2340,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
input.setSelection(input.getText().length());
|
||||
}
|
||||
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());
|
||||
addBorder();
|
||||
dialog.dismiss();
|
||||
|
@ -2515,17 +2515,17 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
if (apiResponse.getStatuses() != null && apiResponse.getStatuses().size() > 0)
|
||||
toot.setIn_reply_to_id(apiResponse.getStatuses().get(0).getId());
|
||||
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;
|
||||
|
||||
}
|
||||
if (apiResponse.getError() == null || apiResponse.getError().getStatusCode() != -33) {
|
||||
if (restored != -1) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new StatusStoredDAO(getApplicationContext(), db).remove(restored);
|
||||
SQLiteDatabase db = Sqlite.getInstance(TootActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new StatusStoredDAO(TootActivity.this, db).remove(restored);
|
||||
} else if (currentToId != -1) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new StatusStoredDAO(getApplicationContext(), db).remove(currentToId);
|
||||
SQLiteDatabase db = Sqlite.getInstance(TootActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new StatusStoredDAO(TootActivity.this, db).remove(currentToId);
|
||||
}
|
||||
}
|
||||
//Clear the toot
|
||||
|
@ -2550,13 +2550,13 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
if (scheduledstatus == null && !isScheduled) {
|
||||
boolean display_confirm = sharedpreferences.getBoolean(Helper.SET_DISPLAY_CONFIRM, true);
|
||||
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
|
||||
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 {
|
||||
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);
|
||||
//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) {
|
||||
Status status = statuses.get(0);
|
||||
if (status != null) {
|
||||
Intent intent = new Intent(getApplicationContext(), ShowConversationActivity.class);
|
||||
Intent intent = new Intent(TootActivity.this, ShowConversationActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
if (idRedirect == null)
|
||||
b.putParcelable("status", status);
|
||||
|
@ -2578,7 +2578,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
}
|
||||
}
|
||||
} 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);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
|
@ -2937,7 +2937,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
}
|
||||
|
||||
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);
|
||||
if (draft == null)
|
||||
return;
|
||||
|
@ -2997,12 +2997,12 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
String url = attachment.getPreview_url();
|
||||
if (url == null || url.trim().equals(""))
|
||||
url = attachment.getUrl();
|
||||
final ImageView imageView = new ImageView(getApplicationContext());
|
||||
final ImageView imageView = new ImageView(TootActivity.this);
|
||||
imageView.setId(Integer.parseInt(attachment.getId()));
|
||||
|
||||
LinearLayout.LayoutParams imParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
|
||||
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.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||
toot_picture_container.addView(imageView, i, imParams);
|
||||
|
@ -3140,12 +3140,12 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
String url = attachment.getPreview_url();
|
||||
if (url == null || url.trim().equals(""))
|
||||
url = attachment.getUrl();
|
||||
final ImageView imageView = new ImageView(getApplicationContext());
|
||||
final ImageView imageView = new ImageView(TootActivity.this);
|
||||
imageView.setId(Integer.parseInt(attachment.getId()));
|
||||
|
||||
LinearLayout.LayoutParams imParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
|
||||
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.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||
toot_picture_container.addView(imageView, i, imParams);
|
||||
|
@ -3317,7 +3317,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
}
|
||||
|
||||
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);
|
||||
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();
|
||||
|
||||
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 {
|
||||
poll = new Poll();
|
||||
poll.setMultiple(poll_choice_pos != 0);
|
||||
|
@ -3549,7 +3549,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
poll.setOptionsList(pollOptions);
|
||||
dialog.dismiss();
|
||||
} 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);
|
||||
|
@ -3589,7 +3589,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
toot.setPoll(poll);
|
||||
if (tootReply != null)
|
||||
toot.setIn_reply_to_id(tootReply.getId());
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SQLiteDatabase db = Sqlite.getInstance(TootActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
try {
|
||||
if (currentToId == -1) {
|
||||
currentToId = new StatusStoredDAO(TootActivity.this, db).insertStatus(toot, tootReply);
|
||||
|
@ -3603,10 +3603,10 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
}
|
||||
}
|
||||
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) {
|
||||
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_color).setOnClickListener(v -> new ColorPickerPopup.Builder(getApplicationContext())
|
||||
findViewById(R.id.action_color).setOnClickListener(v -> new ColorPickerPopup.Builder(TootActivity.this)
|
||||
.enableAlpha(false)
|
||||
.okTitle(getString(R.string.validate))
|
||||
.cancelTitle(getString(R.string.cancel))
|
||||
|
|
|
@ -75,7 +75,7 @@ public class TootInfoActivity extends BaseActivity {
|
|||
toot_favorites_count = b.getInt("toot_favorites_count", 0);
|
||||
}
|
||||
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();
|
||||
}
|
||||
tabLayout = findViewById(R.id.tabLayout);
|
||||
|
|
|
@ -241,7 +241,7 @@ public class WebviewActivity extends BaseActivity {
|
|||
builder.setAdapter(arrayAdapter, (dialog, which) -> {
|
||||
String strName = arrayAdapter.getItem(which);
|
||||
assert strName != null;
|
||||
Toasty.info(getApplicationContext(), strName, Toast.LENGTH_LONG).show();
|
||||
Toasty.info(WebviewActivity.this, strName, Toast.LENGTH_LONG).show();
|
||||
});
|
||||
builder.show();
|
||||
|
||||
|
@ -251,11 +251,11 @@ public class WebviewActivity extends BaseActivity {
|
|||
try {
|
||||
startActivity(browserIntent);
|
||||
} 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;
|
||||
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);
|
||||
return true;
|
||||
default:
|
||||
|
|
|
@ -112,7 +112,7 @@ public class WebviewConnectActivity extends BaseActivity {
|
|||
if (actionBar != null) {
|
||||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
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)));
|
||||
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
|
@ -122,7 +122,7 @@ public class WebviewConnectActivity extends BaseActivity {
|
|||
toolbar_title.setText(R.string.add_account);
|
||||
}
|
||||
webView = findViewById(R.id.webviewConnect);
|
||||
clearCookies(getApplicationContext());
|
||||
clearCookies(WebviewConnectActivity.this);
|
||||
webView.getSettings().setJavaScriptEnabled(true);
|
||||
String user_agent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, null);
|
||||
if (user_agent != null) {
|
||||
|
@ -157,7 +157,7 @@ public class WebviewConnectActivity extends BaseActivity {
|
|||
if (url.contains(Helper.REDIRECT_CONTENT_WEB)) {
|
||||
String[] val = url.split("code=");
|
||||
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);
|
||||
startActivity(myIntent);
|
||||
finish();
|
||||
|
@ -173,7 +173,7 @@ public class WebviewConnectActivity extends BaseActivity {
|
|||
parameters.put("code", code);
|
||||
new Thread(() -> {
|
||||
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;
|
||||
try {
|
||||
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
|
||||
|
@ -217,7 +217,7 @@ public class WebviewConnectActivity extends BaseActivity {
|
|||
alert.dismiss();
|
||||
alert = null;
|
||||
}
|
||||
if( webView != null){
|
||||
if (webView != null) {
|
||||
webView.destroy();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoTo
|
|||
return;
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoTo
|
|||
account.setInstance(val[1]);
|
||||
new PostActionAsyncTask(WhoToFollowActivity.this, null, account, API.StatusAction.FOLLOW, WhoToFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
} 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_select.setEnabled(true);
|
||||
progess_action.setVisibility(View.GONE);
|
||||
|
|
|
@ -179,9 +179,9 @@ public class PostActionAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
} else {
|
||||
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);
|
||||
}else if (apiAction == API.StatusAction.CREATESTATUS)
|
||||
} else if (apiAction == API.StatusAction.CREATESTATUS)
|
||||
statusCode = api.statusAction(status);
|
||||
else if (apiAction == API.StatusAction.UPDATESERVERSCHEDULE) {
|
||||
api.scheduledAction("PUT", storedStatus.getStatus(), null, storedStatus.getScheduledServerdId());
|
||||
|
|
|
@ -122,13 +122,6 @@ public class API {
|
|||
private Error APIError;
|
||||
private List<String> domains;
|
||||
|
||||
enum filterFor{
|
||||
STATUSES_ACCOUNT,
|
||||
HOME,
|
||||
LOCAL,
|
||||
PUBLIC
|
||||
}
|
||||
|
||||
public API(Context context) {
|
||||
this.context = context;
|
||||
if (context == null) {
|
||||
|
@ -161,7 +154,6 @@ public class API {
|
|||
APIError = null;
|
||||
}
|
||||
|
||||
|
||||
public API(Context context, String instance, String token) {
|
||||
this.context = context;
|
||||
if (context == null) {
|
||||
|
@ -528,7 +520,6 @@ public class API {
|
|||
return statuses;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse json response for several reactions
|
||||
*
|
||||
|
@ -553,6 +544,7 @@ public class API {
|
|||
|
||||
/**
|
||||
* Parse a reaction
|
||||
*
|
||||
* @param resobj JSONObject
|
||||
* @return Reaction
|
||||
*/
|
||||
|
@ -562,7 +554,7 @@ public class API {
|
|||
reaction.setName(resobj.getString("name"));
|
||||
reaction.setCount(resobj.getInt("count"));
|
||||
reaction.setMe(resobj.getBoolean("me"));
|
||||
if( resobj.has("url")){
|
||||
if (resobj.has("url")) {
|
||||
reaction.setUrl(resobj.getString("url"));
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
|
@ -595,10 +587,12 @@ public class API {
|
|||
}
|
||||
return announcements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse an annoucement
|
||||
*
|
||||
* @param context Context
|
||||
* @param resobj JSONObject
|
||||
* @param resobj JSONObject
|
||||
* @return Announcement
|
||||
*/
|
||||
private static Announcement parseAnnouncement(Context context, JSONObject resobj) {
|
||||
|
@ -614,16 +608,16 @@ public class API {
|
|||
announcement.setAccount(account);
|
||||
announcement.setId(resobj.getString("id"));
|
||||
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")));
|
||||
}
|
||||
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")));
|
||||
}
|
||||
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")));
|
||||
}
|
||||
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")));
|
||||
}
|
||||
|
||||
|
@ -633,7 +627,6 @@ public class API {
|
|||
announcement.setReactions(parseReaction(resobj.getJSONArray("reactions")));
|
||||
|
||||
|
||||
|
||||
List<Tag> tags = new ArrayList<>();
|
||||
JSONArray arrayTag = resobj.getJSONArray("tags");
|
||||
for (int j = 0; j < arrayTag.length(); j++) {
|
||||
|
@ -683,8 +676,9 @@ public class API {
|
|||
|
||||
/**
|
||||
* Parse a poll
|
||||
*
|
||||
* @param context Context
|
||||
* @param resobj JSONObject
|
||||
* @param resobj JSONObject
|
||||
* @return Poll
|
||||
*/
|
||||
private static Poll parsePoll(Context context, JSONObject resobj) {
|
||||
|
@ -739,10 +733,10 @@ public class API {
|
|||
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());
|
||||
}
|
||||
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.setSensitive(Boolean.parseBoolean(resobj.get("sensitive").toString()));
|
||||
|
@ -759,10 +753,11 @@ public class API {
|
|||
}
|
||||
|
||||
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 {
|
||||
reactions = parseReaction(resobj.getJSONObject("pleroma").getJSONArray("emoji_reactions"));
|
||||
}catch (Exception ignored){}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
status.setReactions(reactions);
|
||||
|
||||
|
@ -1491,7 +1486,6 @@ public class API {
|
|||
return account;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse json response an unique account
|
||||
*
|
||||
|
@ -1860,7 +1854,8 @@ public class API {
|
|||
} else {
|
||||
try {
|
||||
id = URLEncoder.encode(id, "UTF-8");
|
||||
} catch (UnsupportedEncodingException ignored) {}
|
||||
} catch (UnsupportedEncodingException ignored) {
|
||||
}
|
||||
params = new HashMap<>();
|
||||
params.put("query", id);
|
||||
endpoint = "/admin/users";
|
||||
|
@ -2257,7 +2252,6 @@ public class API {
|
|||
return instanceNodeInfo;
|
||||
}
|
||||
|
||||
|
||||
public InstanceNodeInfo instanceInfo(String domain) {
|
||||
|
||||
String response;
|
||||
|
@ -2750,7 +2744,7 @@ public class API {
|
|||
try {
|
||||
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
|
||||
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.setMax_id(httpsConnection.getMax_id());
|
||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||
|
@ -3040,7 +3034,6 @@ public class API {
|
|||
return getHomeTimeline(null, since_id, null, tootPerPage);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves home timeline from cache the account *synchronously*
|
||||
*
|
||||
|
@ -3158,7 +3151,6 @@ public class API {
|
|||
return apiResponse;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves public GNU timeline for the account *synchronously*
|
||||
*
|
||||
|
@ -3400,7 +3392,6 @@ public class API {
|
|||
return apiResponse;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves Nitter timeline from accounts *synchronously*
|
||||
*
|
||||
|
@ -3558,7 +3549,7 @@ public class API {
|
|||
String response = httpsConnection.get(url, 10, params, prefKeyOauthTokenT);
|
||||
apiResponse.setSince_id(httpsConnection.getSince_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) {
|
||||
setError(e.getStatusCode(), e);
|
||||
e.printStackTrace();
|
||||
|
@ -3920,7 +3911,6 @@ public class API {
|
|||
return apiResponse;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves blocked domains for the authenticated account *synchronously*
|
||||
*
|
||||
|
@ -4066,6 +4056,7 @@ public class API {
|
|||
|
||||
/**
|
||||
* Retrieves announcements for the authenticated account *synchronously*
|
||||
*
|
||||
* @return APIResponse
|
||||
*/
|
||||
public APIResponse getAnnouncements() {
|
||||
|
@ -4084,7 +4075,6 @@ public class API {
|
|||
return apiResponse;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves bookmarked status for the authenticated account *synchronously*
|
||||
*
|
||||
|
@ -4136,8 +4126,6 @@ public class API {
|
|||
return postAction(statusAction, targetedId, null, comment);
|
||||
}
|
||||
|
||||
//Pleroma admin calls
|
||||
|
||||
/**
|
||||
* Makes the post action for a status
|
||||
*
|
||||
|
@ -4162,6 +4150,8 @@ public class API {
|
|||
return actionCode;
|
||||
}
|
||||
|
||||
//Pleroma admin calls
|
||||
|
||||
/**
|
||||
* Makes the post action
|
||||
*
|
||||
|
@ -4197,7 +4187,7 @@ public class API {
|
|||
* @param comment String comment for the report
|
||||
* @return in status code - Should be equal to 200 when action is done
|
||||
*/
|
||||
private int postAction(StatusAction statusAction, String targetedId, Status status, String comment) {
|
||||
private int postAction(StatusAction statusAction, String targetedId, Status status, String comment) {
|
||||
|
||||
String action;
|
||||
HashMap<String, String> params = null;
|
||||
|
@ -4291,7 +4281,7 @@ public class API {
|
|||
break;
|
||||
case REMOVE_PLEROMA_REACTION:
|
||||
case ADD_PLEROMA_REACTION:
|
||||
action = String.format("/pleroma/statuses/%s/reactions/%s", targetedId, comment);
|
||||
action = String.format("/pleroma/statuses/%s/reactions/%s", targetedId, comment);
|
||||
break;
|
||||
case DISMISS_ANNOUNCEMENT:
|
||||
action = String.format("/announcements/%s/dismiss", targetedId);
|
||||
|
@ -4347,8 +4337,8 @@ public class API {
|
|||
return -1;
|
||||
}
|
||||
if (statusAction != StatusAction.UNSTATUS
|
||||
&& statusAction != StatusAction.ADD_REACTION && statusAction != StatusAction.REMOVE_REACTION
|
||||
&& statusAction != StatusAction.ADD_PLEROMA_REACTION && statusAction != StatusAction.REMOVE_PLEROMA_REACTION) {
|
||||
&& statusAction != StatusAction.ADD_REACTION && statusAction != StatusAction.REMOVE_REACTION
|
||||
&& statusAction != StatusAction.ADD_PLEROMA_REACTION && statusAction != StatusAction.REMOVE_PLEROMA_REACTION) {
|
||||
try {
|
||||
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
|
||||
String resp = httpsConnection.post(getAbsoluteUrl(action), 10, params, prefKeyOauthTokenT);
|
||||
|
@ -4377,7 +4367,7 @@ public class API {
|
|||
} catch (NoSuchAlgorithmException | IOException | KeyManagementException e) {
|
||||
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 {
|
||||
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
|
||||
httpsConnection.put(getAbsoluteUrl(action), 10, null, prefKeyOauthTokenT);
|
||||
|
@ -4392,7 +4382,7 @@ public class API {
|
|||
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
|
||||
httpsConnection.delete(getAbsoluteUrl(action), 10, null, prefKeyOauthTokenT);
|
||||
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();
|
||||
new TimelineCacheDAO(context, db).remove(targetedId);
|
||||
}
|
||||
|
@ -4514,7 +4504,7 @@ public class API {
|
|||
/**
|
||||
* Public api call to submit a vote
|
||||
*
|
||||
* @param pollId String
|
||||
* @param pollId String
|
||||
* @param choices int[]
|
||||
* @return Poll
|
||||
*/
|
||||
|
@ -4902,7 +4892,6 @@ public class API {
|
|||
return apiResponse;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves trends for Mastodon *synchronously*
|
||||
*
|
||||
|
@ -5222,8 +5211,6 @@ public class API {
|
|||
return apiResponse;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves list timeline *synchronously*
|
||||
*
|
||||
|
@ -5576,7 +5563,6 @@ public class API {
|
|||
return peertubes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse json response for several trends
|
||||
*
|
||||
|
@ -5631,7 +5617,6 @@ public class API {
|
|||
return trend;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse json response for several conversations
|
||||
*
|
||||
|
@ -5832,7 +5817,6 @@ public class API {
|
|||
return emojis;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse Filters
|
||||
*
|
||||
|
@ -5998,7 +5982,6 @@ public class API {
|
|||
return accounts;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse json response an unique relationship
|
||||
*
|
||||
|
@ -6168,6 +6151,13 @@ public class API {
|
|||
return "https://communitywiki.org/trunk/api/v1" + action;
|
||||
}
|
||||
|
||||
enum filterFor {
|
||||
STATUSES_ACCOUNT,
|
||||
HOME,
|
||||
LOCAL,
|
||||
PUBLIC
|
||||
}
|
||||
|
||||
public enum searchType {
|
||||
TAGS,
|
||||
STATUSES,
|
||||
|
|
|
@ -970,7 +970,7 @@ public class Account implements Parcelable {
|
|||
try {
|
||||
Glide.with(context)
|
||||
.asDrawable()
|
||||
.load(disableAnimatedEmoji?emoji.getStatic_url():emoji.getUrl())
|
||||
.load(disableAnimatedEmoji ? emoji.getStatic_url() : emoji.getUrl())
|
||||
.into(new SimpleTarget<Drawable>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||
|
|
|
@ -15,9 +15,8 @@ package app.fedilab.android.client.Entities;
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class Announcement extends Status{
|
||||
public class Announcement extends Status {
|
||||
private Date startAt;
|
||||
private Date endAt;
|
||||
private boolean all_day;
|
||||
|
|
|
@ -797,7 +797,7 @@ public class ManageTimelines {
|
|||
case R.id.action_all:
|
||||
dialogBuilder = new AlertDialog.Builder(context, style);
|
||||
inflater = ((MainActivity) context).getLayoutInflater();
|
||||
dialogView = inflater.inflate(R.layout.tags_all, new LinearLayout(context), false);
|
||||
dialogView = inflater.inflate(R.layout.tags_all, new LinearLayout(context), false);
|
||||
dialogBuilder.setView(dialogView);
|
||||
final EditText editTextAll = dialogView.findViewById(R.id.filter_all);
|
||||
if (tagTimeline.getAll() != null) {
|
||||
|
|
|
@ -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,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
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 int count;
|
||||
private boolean me;
|
||||
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() {
|
||||
return name;
|
||||
}
|
||||
|
@ -47,9 +68,6 @@ public class Reaction implements Parcelable {
|
|||
this.me = me;
|
||||
}
|
||||
|
||||
public Reaction() {
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
@ -70,23 +88,4 @@ public class Reaction implements Parcelable {
|
|||
dest.writeByte(this.me ? (byte) 1 : (byte) 0);
|
||||
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];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ import com.bumptech.glide.request.RequestListener;
|
|||
import com.bumptech.glide.request.target.SimpleTarget;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -499,6 +500,7 @@ public class Status implements Parcelable {
|
|||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
|
@ -532,26 +534,26 @@ public class Status implements Parcelable {
|
|||
//Accounts can be mentioned several times so we have to loop
|
||||
if (endPosition <= spannableStringT.toString().length() && endPosition >= startPosition)
|
||||
spannableStringT.setSpan(new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View textView) {
|
||||
if (account.getId() == null) {
|
||||
CrossActions.doCrossProfile(context, account);
|
||||
} else {
|
||||
Intent intent = new Intent(context, ShowAccountActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putString("accountId", account.getId());
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onClick(@NonNull View textView) {
|
||||
if (account.getId() == null) {
|
||||
CrossActions.doCrossProfile(context, account);
|
||||
} else {
|
||||
Intent intent = new Intent(context, ShowAccountActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putString("accountId", account.getId());
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
ds.setUnderlineText(false);
|
||||
ds.setColor(link_color);
|
||||
}
|
||||
},
|
||||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
ds.setUnderlineText(false);
|
||||
ds.setColor(link_color);
|
||||
}
|
||||
},
|
||||
startPosition, endPosition,
|
||||
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
|
@ -580,152 +582,153 @@ public class Status implements Parcelable {
|
|||
}
|
||||
if (endPosition <= spannableStringT.toString().length() && endPosition >= startPosition) {
|
||||
spannableStringT.setSpan(new LongClickableSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View textView) {
|
||||
String finalUrl = url;
|
||||
Pattern link = Pattern.compile("https?://([\\da-z.-]+\\.[a-z.]{2,10})/(@[\\w._-]*[0-9]*)(/[0-9]+)?$");
|
||||
Matcher matcherLink = link.matcher(url);
|
||||
if (matcherLink.find() && !url.contains("medium.com")) {
|
||||
if (matcherLink.group(3) != null && Objects.requireNonNull(matcherLink.group(3)).length() > 0) { //It's a toot
|
||||
CrossActions.doCrossConversation(context, finalUrl);
|
||||
} else {//It's an account
|
||||
Account account = new Account();
|
||||
String acct = matcherLink.group(2);
|
||||
if (acct != null) {
|
||||
if (acct.startsWith("@"))
|
||||
acct = acct.substring(1);
|
||||
account.setAcct(acct);
|
||||
account.setInstance(matcherLink.group(1));
|
||||
CrossActions.doCrossProfile(context, account);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
link = Pattern.compile("(https?://[\\da-z.-]+\\.[a-z.]{2,10})/videos/watch/(\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12})$");
|
||||
matcherLink = link.matcher(url);
|
||||
if (matcherLink.find()) { //Peertubee video
|
||||
Intent intent = new Intent(context, PeertubeActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
String url = matcherLink.group(1) + "/videos/watch/" + matcherLink.group(2);
|
||||
b.putString("peertubeLinkToFetch", url);
|
||||
b.putString("peertube_instance", Objects.requireNonNull(matcherLink.group(1)).replace("https://", "").replace("http://", ""));
|
||||
b.putString("video_id", matcherLink.group(2));
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
} else {
|
||||
if (!url.toLowerCase().startsWith("http://") && !url.toLowerCase().startsWith("https://"))
|
||||
finalUrl = "http://" + url;
|
||||
Helper.openBrowser(context, finalUrl);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onLongClick(@NonNull View textView) {
|
||||
PopupMenu popup = new PopupMenu(context, textView);
|
||||
popup.getMenuInflater()
|
||||
.inflate(R.menu.links_popup, popup.getMenu());
|
||||
int style;
|
||||
if (theme == Helper.THEME_DARK) {
|
||||
style = R.style.DialogDark;
|
||||
} else if (theme == Helper.THEME_BLACK) {
|
||||
style = R.style.DialogBlack;
|
||||
} else {
|
||||
style = R.style.Dialog;
|
||||
}
|
||||
popup.setOnMenuItemClickListener(item -> {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_show_link:
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context, style);
|
||||
builder.setMessage(url);
|
||||
builder.setTitle(context.getString(R.string.display_full_link));
|
||||
builder.setPositiveButton(R.string.close, (dialog, which) -> dialog.dismiss())
|
||||
.show();
|
||||
break;
|
||||
case R.id.action_share_link:
|
||||
Intent sendIntent = new Intent(Intent.ACTION_SEND);
|
||||
sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.shared_via));
|
||||
sendIntent.putExtra(Intent.EXTRA_TEXT, url);
|
||||
sendIntent.setType("text/plain");
|
||||
context.startActivity(Intent.createChooser(sendIntent, context.getString(R.string.share_with)));
|
||||
break;
|
||||
|
||||
case R.id.action_open_other_app:
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(url));
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
break;
|
||||
case R.id.action_copy_link:
|
||||
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText(Helper.CLIP_BOARD, url);
|
||||
if (clipboard != null) {
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toasty.info(context, context.getString(R.string.clipboard_url), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
break;
|
||||
case R.id.action_unshorten:
|
||||
Thread thread = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
String response = new HttpsConnection(context, null).checkUrl(url);
|
||||
|
||||
Handler mainHandler = new Handler(context.getMainLooper());
|
||||
|
||||
Runnable myRunnable = () -> {
|
||||
AlertDialog.Builder builder1 = new AlertDialog.Builder(context, style);
|
||||
if (response != null) {
|
||||
builder1.setMessage(context.getString(R.string.redirect_detected, url, response));
|
||||
builder1.setNegativeButton(R.string.copy_link, (dialog, which) -> {
|
||||
ClipboardManager clipboard1 = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip1 = ClipData.newPlainText(Helper.CLIP_BOARD, response);
|
||||
if (clipboard1 != null) {
|
||||
clipboard1.setPrimaryClip(clip1);
|
||||
Toasty.info(context, context.getString(R.string.clipboard_url), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
builder1.setNeutralButton(R.string.share_link, (dialog, which) -> {
|
||||
Intent sendIntent1 = new Intent(Intent.ACTION_SEND);
|
||||
sendIntent1.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.shared_via));
|
||||
sendIntent1.putExtra(Intent.EXTRA_TEXT, url);
|
||||
sendIntent1.setType("text/plain");
|
||||
context.startActivity(Intent.createChooser(sendIntent1, context.getString(R.string.share_with)));
|
||||
dialog.dismiss();
|
||||
});
|
||||
} else {
|
||||
builder1.setMessage(R.string.no_redirect);
|
||||
@Override
|
||||
public void onClick(@NonNull View textView) {
|
||||
String finalUrl = url;
|
||||
Pattern link = Pattern.compile("https?://([\\da-z.-]+\\.[a-z.]{2,10})/(@[\\w._-]*[0-9]*)(/[0-9]+)?$");
|
||||
Matcher matcherLink = link.matcher(url);
|
||||
if (matcherLink.find() && !url.contains("medium.com")) {
|
||||
if (matcherLink.group(3) != null && Objects.requireNonNull(matcherLink.group(3)).length() > 0) { //It's a toot
|
||||
CrossActions.doCrossConversation(context, finalUrl);
|
||||
} else {//It's an account
|
||||
Account account = new Account();
|
||||
String acct = matcherLink.group(2);
|
||||
if (acct != null) {
|
||||
if (acct.startsWith("@"))
|
||||
acct = acct.substring(1);
|
||||
account.setAcct(acct);
|
||||
account.setInstance(matcherLink.group(1));
|
||||
CrossActions.doCrossProfile(context, account);
|
||||
}
|
||||
builder1.setTitle(context.getString(R.string.check_redirect));
|
||||
builder1.setPositiveButton(R.string.close, (dialog, which) -> dialog.dismiss())
|
||||
.show();
|
||||
|
||||
};
|
||||
mainHandler.post(myRunnable);
|
||||
}
|
||||
} else {
|
||||
link = Pattern.compile("(https?://[\\da-z.-]+\\.[a-z.]{2,10})/videos/watch/(\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12})$");
|
||||
matcherLink = link.matcher(url);
|
||||
if (matcherLink.find()) { //Peertubee video
|
||||
Intent intent = new Intent(context, PeertubeActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
String url = matcherLink.group(1) + "/videos/watch/" + matcherLink.group(2);
|
||||
b.putString("peertubeLinkToFetch", url);
|
||||
b.putString("peertube_instance", Objects.requireNonNull(matcherLink.group(1)).replace("https://", "").replace("http://", ""));
|
||||
b.putString("video_id", matcherLink.group(2));
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
} else {
|
||||
if (!url.toLowerCase().startsWith("http://") && !url.toLowerCase().startsWith("https://"))
|
||||
finalUrl = "http://" + url;
|
||||
Helper.openBrowser(context, finalUrl);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
thread.start();
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
popup.setOnDismissListener(menu -> BaseActivity.canShowActionMode = true);
|
||||
popup.show();
|
||||
textView.clearFocus();
|
||||
BaseActivity.canShowActionMode = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongClick(@NonNull View textView) {
|
||||
PopupMenu popup = new PopupMenu(context, textView);
|
||||
popup.getMenuInflater()
|
||||
.inflate(R.menu.links_popup, popup.getMenu());
|
||||
int style;
|
||||
if (theme == Helper.THEME_DARK) {
|
||||
style = R.style.DialogDark;
|
||||
} else if (theme == Helper.THEME_BLACK) {
|
||||
style = R.style.DialogBlack;
|
||||
} else {
|
||||
style = R.style.Dialog;
|
||||
}
|
||||
popup.setOnMenuItemClickListener(item -> {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_show_link:
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context, style);
|
||||
builder.setMessage(url);
|
||||
builder.setTitle(context.getString(R.string.display_full_link));
|
||||
builder.setPositiveButton(R.string.close, (dialog, which) -> dialog.dismiss())
|
||||
.show();
|
||||
break;
|
||||
case R.id.action_share_link:
|
||||
Intent sendIntent = new Intent(Intent.ACTION_SEND);
|
||||
sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.shared_via));
|
||||
sendIntent.putExtra(Intent.EXTRA_TEXT, url);
|
||||
sendIntent.setType("text/plain");
|
||||
context.startActivity(Intent.createChooser(sendIntent, context.getString(R.string.share_with)));
|
||||
break;
|
||||
|
||||
case R.id.action_open_other_app:
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(url));
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
break;
|
||||
case R.id.action_copy_link:
|
||||
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText(Helper.CLIP_BOARD, url);
|
||||
if (clipboard != null) {
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toasty.info(context, context.getString(R.string.clipboard_url), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
break;
|
||||
case R.id.action_unshorten:
|
||||
Thread thread = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
String response = new HttpsConnection(context, null).checkUrl(url);
|
||||
|
||||
Handler mainHandler = new Handler(context.getMainLooper());
|
||||
|
||||
Runnable myRunnable = () -> {
|
||||
AlertDialog.Builder builder1 = new AlertDialog.Builder(context, style);
|
||||
if (response != null) {
|
||||
builder1.setMessage(context.getString(R.string.redirect_detected, url, response));
|
||||
builder1.setNegativeButton(R.string.copy_link, (dialog, which) -> {
|
||||
ClipboardManager clipboard1 = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip1 = ClipData.newPlainText(Helper.CLIP_BOARD, response);
|
||||
if (clipboard1 != null) {
|
||||
clipboard1.setPrimaryClip(clip1);
|
||||
Toasty.info(context, context.getString(R.string.clipboard_url), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
builder1.setNeutralButton(R.string.share_link, (dialog, which) -> {
|
||||
Intent sendIntent1 = new Intent(Intent.ACTION_SEND);
|
||||
sendIntent1.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.shared_via));
|
||||
sendIntent1.putExtra(Intent.EXTRA_TEXT, url);
|
||||
sendIntent1.setType("text/plain");
|
||||
context.startActivity(Intent.createChooser(sendIntent1, context.getString(R.string.share_with)));
|
||||
dialog.dismiss();
|
||||
});
|
||||
} else {
|
||||
builder1.setMessage(R.string.no_redirect);
|
||||
}
|
||||
builder1.setTitle(context.getString(R.string.check_redirect));
|
||||
builder1.setPositiveButton(R.string.close, (dialog, which) -> dialog.dismiss())
|
||||
.show();
|
||||
|
||||
};
|
||||
mainHandler.post(myRunnable);
|
||||
|
||||
}
|
||||
};
|
||||
thread.start();
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
popup.setOnDismissListener(menu -> BaseActivity.canShowActionMode = true);
|
||||
popup.show();
|
||||
textView.clearFocus();
|
||||
BaseActivity.canShowActionMode = false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
ds.setUnderlineText(false);
|
||||
ds.setColor(link_color);
|
||||
}
|
||||
},
|
||||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
ds.setUnderlineText(false);
|
||||
ds.setColor(link_color);
|
||||
}
|
||||
},
|
||||
startPosition, endPosition,
|
||||
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
|
@ -827,21 +830,21 @@ public class Status implements Parcelable {
|
|||
final String url = contentSpanTranslated.toString().substring(matcherALink.start(1), matcherALink.end(1));
|
||||
if (matchEnd <= contentSpanTranslated.toString().length() && matchEnd >= matchStart)
|
||||
contentSpanTranslated.setSpan(new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View textView) {
|
||||
String finalUrl = url;
|
||||
if (!url.toLowerCase().startsWith("http://") && !url.toLowerCase().startsWith("https://"))
|
||||
finalUrl = "http://" + url;
|
||||
Helper.openBrowser(context, finalUrl);
|
||||
}
|
||||
@Override
|
||||
public void onClick(@NonNull View textView) {
|
||||
String finalUrl = url;
|
||||
if (!url.toLowerCase().startsWith("http://") && !url.toLowerCase().startsWith("https://"))
|
||||
finalUrl = "http://" + url;
|
||||
Helper.openBrowser(context, finalUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
ds.setUnderlineText(false);
|
||||
ds.setColor(link_color);
|
||||
}
|
||||
},
|
||||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
ds.setUnderlineText(false);
|
||||
ds.setColor(link_color);
|
||||
}
|
||||
},
|
||||
matchStart, matchEnd,
|
||||
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
|
||||
|
@ -937,7 +940,7 @@ public class Status implements Parcelable {
|
|||
for (final Emojis emoji : emojis) {
|
||||
Glide.with(context)
|
||||
.asDrawable()
|
||||
.load(disableAnimatedEmoji?emoji.getStatic_url():emoji.getUrl())
|
||||
.load(disableAnimatedEmoji ? emoji.getStatic_url() : emoji.getUrl())
|
||||
.listener(new RequestListener<Drawable>() {
|
||||
@Override
|
||||
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;
|
||||
Glide.with(context)
|
||||
.asDrawable()
|
||||
.load(disableAnimatedEmoji?emoji.getStatic_url():emoji.getUrl())
|
||||
.load(disableAnimatedEmoji ? emoji.getStatic_url() : emoji.getUrl())
|
||||
.listener(new RequestListener<Drawable>() {
|
||||
@Override
|
||||
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
|
||||
|
|
|
@ -350,7 +350,6 @@ public class GNUAPI {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
return getArtTimeline(local, tag, null, since_id, any, all, none);
|
||||
}
|
||||
|
@ -1136,7 +1133,6 @@ public class GNUAPI {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves public timeline for the account *synchronously*
|
||||
*
|
||||
|
@ -1451,7 +1447,7 @@ public class GNUAPI {
|
|||
/**
|
||||
* Makes the post action
|
||||
*
|
||||
* @param status Status object related to the status
|
||||
* @param status Status object related to the status
|
||||
* @return in status code - Should be equal to 200 when action is done
|
||||
*/
|
||||
public int reportAction(Status status) {
|
||||
|
@ -1791,7 +1787,6 @@ public class GNUAPI {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves Accounts and feeds when searching *synchronously*
|
||||
*
|
||||
|
@ -1924,8 +1919,6 @@ public class GNUAPI {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Parse json response for list of accounts
|
||||
*
|
||||
|
@ -2052,7 +2045,6 @@ public class GNUAPI {
|
|||
}
|
||||
|
||||
|
||||
|
||||
private String getAbsoluteRemoteUrl(String instance, String action) {
|
||||
return Helper.instanceWithProtocol(this.context, instance) + "/api" + action;
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ import java.util.Map;
|
|||
import java.util.Scanner;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
|
@ -136,9 +137,9 @@ public class HttpsConnection {
|
|||
* @param paramaters HashMap<String, String> paramaters
|
||||
* @param token String token
|
||||
* @return String
|
||||
* @throws IOException IOException
|
||||
* @throws IOException IOException
|
||||
* @throws NoSuchAlgorithmException NoSuchAlgorithmException
|
||||
* @throws KeyManagementException KeyManagementException
|
||||
* @throws KeyManagementException KeyManagementException
|
||||
* @throws HttpsConnectionException HttpsConnectionException
|
||||
*/
|
||||
public String get(String urlConnection, int timeout, HashMap<String, String> paramaters, String token) throws IOException, NoSuchAlgorithmException, KeyManagementException, HttpsConnectionException {
|
||||
|
@ -311,7 +312,7 @@ public class HttpsConnection {
|
|||
getSinceMaxId();
|
||||
httpsURLConnection.getInputStream().close();
|
||||
return response;
|
||||
}else{
|
||||
} else {
|
||||
if (proxy != null)
|
||||
httpURLConnection = (HttpURLConnection) url.openConnection(proxy);
|
||||
else
|
||||
|
|
|
@ -30,6 +30,7 @@ import androidx.annotation.Nullable;
|
|||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.target.SimpleTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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);
|
||||
boolean disableAnimatedEmoji = sharedpreferences.getBoolean(Helper.SET_DISABLE_ANIMATED_EMOJI, false);
|
||||
Glide.with(parent.getContext())
|
||||
.load(!disableAnimatedEmoji?emoji.getUrl():emoji.getStatic_url())
|
||||
.load(!disableAnimatedEmoji ? emoji.getUrl() : emoji.getStatic_url())
|
||||
.thumbnail(0.1f)
|
||||
.into(new SimpleTarget<Drawable>() {
|
||||
@Override
|
||||
|
|
|
@ -21,10 +21,12 @@ import android.view.ViewGroup;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.client.Entities.Reaction;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
|
@ -55,17 +57,17 @@ public class ReactionAdapter extends RecyclerView.Adapter {
|
|||
ViewHolder holder = (ViewHolder) viewHolder;
|
||||
|
||||
holder.reaction_count.setText(String.valueOf(reaction.getCount()));
|
||||
if(reaction.isMe()) {
|
||||
if (reaction.isMe()) {
|
||||
holder.reaction_container.setBackgroundResource(R.drawable.reaction_voted);
|
||||
}else{
|
||||
} else {
|
||||
holder.reaction_container.setBackgroundResource(R.drawable.reaction_border);
|
||||
}
|
||||
if(reaction.getUrl() != null){
|
||||
if (reaction.getUrl() != null) {
|
||||
holder.reaction_name.setVisibility(View.GONE);
|
||||
holder.reaction_emoji.setVisibility(View.VISIBLE);
|
||||
holder.reaction_emoji.setContentDescription(reaction.getName());
|
||||
Helper.loadGiF(holder.itemView.getContext(), reaction.getUrl(), holder.reaction_emoji);
|
||||
}else{
|
||||
} else {
|
||||
holder.reaction_name.setText(reaction.getName());
|
||||
holder.reaction_name.setVisibility(View.VISIBLE);
|
||||
holder.reaction_emoji.setVisibility(View.GONE);
|
||||
|
|
|
@ -132,7 +132,7 @@ public class SearchListAdapter extends BaseAdapter {
|
|||
else
|
||||
holder.status_search_title.setVisibility(View.GONE);
|
||||
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);
|
||||
assert img != null;
|
||||
img.setBounds(0, 0, (int) (20 * scale + 0.5f), (int) (15 * scale + 0.5f));
|
||||
|
|
|
@ -579,9 +579,9 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
if (social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED && type == RetrieveFeedsAsyncTask.Type.CONTEXT) {
|
||||
return COMPACT_STATUS;
|
||||
} else {
|
||||
if( instanceType == null || instanceType.compareTo("NITTER") != 0 ) {
|
||||
if (instanceType == null || instanceType.compareTo("NITTER") != 0) {
|
||||
return statuses.get(position).getViewType();
|
||||
}else{
|
||||
} else {
|
||||
return COMPACT_STATUS;
|
||||
}
|
||||
}
|
||||
|
@ -1009,8 +1009,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
iconColor = ThemeHelper.getAttColor(context, R.attr.iconColor);
|
||||
}
|
||||
|
||||
if( type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA ){
|
||||
if( type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS ) {
|
||||
if (type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
|
||||
if (type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS) {
|
||||
holder.status_account_profile.setVisibility(View.GONE);
|
||||
holder.status_account_displayname_owner.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) -> {
|
||||
String emojiStr = imageView.getUnicode();
|
||||
boolean alreadyAdded = false;
|
||||
for(Reaction reaction: status.getReactions()){
|
||||
if( reaction.getName().compareTo(emojiStr) == 0){
|
||||
for (Reaction reaction : status.getReactions()) {
|
||||
if (reaction.getName().compareTo(emojiStr) == 0) {
|
||||
alreadyAdded = true;
|
||||
reaction.setCount(reaction.getCount()-1);
|
||||
if( reaction.getCount() == 0) {
|
||||
reaction.setCount(reaction.getCount() - 1);
|
||||
if (reaction.getCount() == 0) {
|
||||
status.getReactions().remove(reaction);
|
||||
}
|
||||
notifyStatusChanged(status);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( !alreadyAdded){
|
||||
if (!alreadyAdded) {
|
||||
Reaction reaction = new Reaction();
|
||||
reaction.setMe(true);
|
||||
reaction.setCount(1);
|
||||
|
@ -1053,17 +1053,17 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
notifyStatusChanged(status);
|
||||
}
|
||||
API.StatusAction statusAction;
|
||||
if( type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS ) {
|
||||
if (type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS) {
|
||||
statusAction = alreadyAdded ? API.StatusAction.REMOVE_REACTION : API.StatusAction.ADD_REACTION;
|
||||
}else{
|
||||
} else {
|
||||
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);
|
||||
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.setOnClickListener(v -> {
|
||||
|
@ -1090,18 +1090,18 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
gridView.setNumColumns(5);
|
||||
gridView.setOnItemClickListener((parent, view, position, id) -> {
|
||||
boolean alreadyAdded = false;
|
||||
for(Reaction reaction: status.getReactions()){
|
||||
if( reaction.getName().compareTo(emojis.get(position).getShortcode()) == 0){
|
||||
for (Reaction reaction : status.getReactions()) {
|
||||
if (reaction.getName().compareTo(emojis.get(position).getShortcode()) == 0) {
|
||||
alreadyAdded = true;
|
||||
reaction.setCount(reaction.getCount()-1);
|
||||
if( reaction.getCount() == 0) {
|
||||
reaction.setCount(reaction.getCount() - 1);
|
||||
if (reaction.getCount() == 0) {
|
||||
status.getReactions().remove(reaction);
|
||||
}
|
||||
notifyStatusChanged(status);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( !alreadyAdded){
|
||||
if (!alreadyAdded) {
|
||||
Reaction reaction = new Reaction();
|
||||
reaction.setMe(true);
|
||||
reaction.setCount(1);
|
||||
|
@ -1111,12 +1111,12 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
notifyStatusChanged(status);
|
||||
}
|
||||
API.StatusAction statusAction;
|
||||
if( type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS ) {
|
||||
if (type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS) {
|
||||
statusAction = alreadyAdded ? API.StatusAction.REMOVE_REACTION : API.StatusAction.ADD_REACTION;
|
||||
}else{
|
||||
} else {
|
||||
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);
|
||||
alertDialogEmoji.dismiss();
|
||||
});
|
||||
gridView.setPadding(paddingDp, paddingDp, paddingDp, paddingDp);
|
||||
|
@ -3365,7 +3365,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
Glide.with(imageView.getContext())
|
||||
.load(!attachment.getType().toLowerCase().equals("audio") ? url : R.drawable.ic_audio_wave)
|
||||
.thumbnail(0.1f)
|
||||
// .override(640, 480)
|
||||
// .override(640, 480)
|
||||
.apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(10)))
|
||||
.transition(DrawableTransitionOptions.withCrossFade())
|
||||
.into(imageView);
|
||||
|
@ -3373,7 +3373,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
Glide.with(imageView.getContext())
|
||||
.load(!attachment.getType().toLowerCase().equals("audio") ? url : R.drawable.ic_audio_wave)
|
||||
.thumbnail(0.1f)
|
||||
// .override(640, 480)
|
||||
// .override(640, 480)
|
||||
.apply(new RequestOptions().transform(new BlurTransformation(50, 3), new RoundedCorners(10)))
|
||||
.transition(DrawableTransitionOptions.withCrossFade())
|
||||
.into(imageView);
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.Manifest;
|
|||
import android.app.AlarmManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
|
@ -94,30 +93,19 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
|
|||
assert context != null;
|
||||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
|
||||
dialogBuilder.setMessage(R.string.restore_default_theme);
|
||||
dialogBuilder.setPositiveButton(R.string.restore, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
reset();
|
||||
dialog.dismiss();
|
||||
restart();
|
||||
}
|
||||
dialogBuilder.setPositiveButton(R.string.restore, (dialog, id) -> {
|
||||
reset();
|
||||
dialog.dismiss();
|
||||
restart();
|
||||
});
|
||||
dialogBuilder.setNegativeButton(R.string.store_before, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialogBuilder.setNegativeButton(R.string.store_before, (dialog, id) -> {
|
||||
|
||||
exportColors();
|
||||
reset();
|
||||
dialog.dismiss();
|
||||
restart();
|
||||
}
|
||||
});
|
||||
dialogBuilder.setNeutralButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
exportColors();
|
||||
reset();
|
||||
dialog.dismiss();
|
||||
restart();
|
||||
});
|
||||
dialogBuilder.setNeutralButton(R.string.cancel, (dialog, id) -> dialog.dismiss());
|
||||
AlertDialog alertDialog = dialogBuilder.create();
|
||||
alertDialog.setCancelable(false);
|
||||
alertDialog.show();
|
||||
|
@ -152,13 +140,13 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
|
|||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == PICK_IMPORT_THEME && resultCode == RESULT_OK) {
|
||||
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;
|
||||
}
|
||||
if (data.getData() != null) {
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
InputStream inputStream = getActivity().getContentResolver().openInputStream(data.getData());
|
||||
InputStream inputStream = Objects.requireNonNull(getActivity()).getContentResolver().openInputStream(data.getData());
|
||||
assert inputStream != null;
|
||||
br = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
|
||||
String sCurrentLine;
|
||||
|
@ -196,18 +184,8 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
|
|||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
|
||||
dialogBuilder.setMessage(R.string.restart_message);
|
||||
dialogBuilder.setTitle(R.string.apply_changes);
|
||||
dialogBuilder.setPositiveButton(R.string.restart, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
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();
|
||||
}
|
||||
});
|
||||
dialogBuilder.setPositiveButton(R.string.restart, (dialog, id) -> restart());
|
||||
dialogBuilder.setNegativeButton(R.string.no, (dialog, id) -> dialog.dismiss());
|
||||
AlertDialog alertDialog = dialogBuilder.create();
|
||||
alertDialog.setCancelable(false);
|
||||
alertDialog.show();
|
||||
|
@ -222,7 +200,7 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
|
|||
}
|
||||
|
||||
} 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);
|
||||
int mPendingIntentId = 123456;
|
||||
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;
|
||||
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent);
|
||||
System.exit(0);
|
||||
|
@ -311,7 +289,7 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
|
|||
pref_import.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
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) {
|
||||
ActivityCompat.requestPermissions(getActivity(),
|
||||
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
||||
|
@ -336,37 +314,26 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
|
|||
}
|
||||
});
|
||||
|
||||
reset_pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
|
||||
dialogBuilder.setMessage(R.string.reset_color);
|
||||
dialogBuilder.setPositiveButton(R.string.reset, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
reset();
|
||||
dialog.dismiss();
|
||||
setPreferenceScreen(null);
|
||||
addPreferencesFromResource(R.xml.fragment_settings_color);
|
||||
reset_pref.setOnPreferenceClickListener(preference -> {
|
||||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
|
||||
dialogBuilder.setMessage(R.string.reset_color);
|
||||
dialogBuilder.setPositiveButton(R.string.reset, (dialog, id) -> {
|
||||
reset();
|
||||
dialog.dismiss();
|
||||
setPreferenceScreen(null);
|
||||
addPreferencesFromResource(R.xml.fragment_settings_color);
|
||||
|
||||
}
|
||||
});
|
||||
dialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
AlertDialog alertDialog = dialogBuilder.create();
|
||||
alertDialog.setCancelable(false);
|
||||
alertDialog.show();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
dialogBuilder.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss());
|
||||
AlertDialog alertDialog = dialogBuilder.create();
|
||||
alertDialog.setCancelable(false);
|
||||
alertDialog.show();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private void reset() {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Objects.requireNonNull(getActivity()));
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.remove("theme_boost_header_color");
|
||||
editor.remove("theme_text_header_1_line");
|
||||
|
@ -386,7 +353,7 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
|
|||
|
||||
|
||||
private void exportColors() {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Objects.requireNonNull(getActivity()));
|
||||
try {
|
||||
String fileName = "Fedilab_color_export_" + Helper.dateFileToString(getActivity(), new Date()) + ".csv";
|
||||
String filePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath();
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -69,11 +69,12 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
|||
private String targetedId, instance, name;
|
||||
private boolean swiped;
|
||||
private RecyclerView lv_accounts;
|
||||
private View rootView;
|
||||
|
||||
@Override
|
||||
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();
|
||||
Bundle bundle = this.getArguments();
|
||||
|
@ -114,7 +115,7 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
|||
mLayoutManager = new LinearLayoutManager(context);
|
||||
lv_accounts.setLayoutManager(mLayoutManager);
|
||||
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) {
|
||||
int visibleItemCount = mLayoutManager.getChildCount();
|
||||
int totalItemCount = mLayoutManager.getItemCount();
|
||||
|
@ -136,21 +137,18 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
|||
}
|
||||
}
|
||||
});
|
||||
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
max_id = null;
|
||||
accounts = new ArrayList<>();
|
||||
firstLoad = true;
|
||||
flag_loading = true;
|
||||
swiped = true;
|
||||
if (type == RetrieveAccountsAsyncTask.Type.SEARCH || type == RetrieveAccountsAsyncTask.Type.FOLLOWERS || type == RetrieveAccountsAsyncTask.Type.FOLLOWING || type == RetrieveAccountsAsyncTask.Type.REBLOGGED || type == RetrieveAccountsAsyncTask.Type.FAVOURITED)
|
||||
asyncTask = new RetrieveAccountsAsyncTask(context, type, targetedId, max_id, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
else if (type == RetrieveAccountsAsyncTask.Type.CHANNELS)
|
||||
asyncTask = new RetrieveAccountsAsyncTask(context, instance, name, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
else
|
||||
asyncTask = new RetrieveAccountsAsyncTask(context, type, max_id, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
swipeRefreshLayout.setOnRefreshListener(() -> {
|
||||
max_id = null;
|
||||
accounts = new ArrayList<>();
|
||||
firstLoad = true;
|
||||
flag_loading = true;
|
||||
swiped = true;
|
||||
if (type == RetrieveAccountsAsyncTask.Type.SEARCH || type == RetrieveAccountsAsyncTask.Type.FOLLOWERS || type == RetrieveAccountsAsyncTask.Type.FOLLOWING || type == RetrieveAccountsAsyncTask.Type.REBLOGGED || type == RetrieveAccountsAsyncTask.Type.FAVOURITED)
|
||||
asyncTask = new RetrieveAccountsAsyncTask(context, type, targetedId, max_id, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
else if (type == RetrieveAccountsAsyncTask.Type.CHANNELS)
|
||||
asyncTask = new RetrieveAccountsAsyncTask(context, instance, name, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
else
|
||||
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)
|
||||
|
@ -163,6 +161,12 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
|||
return rootView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
rootView = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle saveInstance) {
|
||||
super.onCreate(saveInstance);
|
||||
|
@ -170,7 +174,7 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
|||
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
this.context = context;
|
||||
}
|
||||
|
@ -216,7 +220,7 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
|||
if (type == RetrieveAccountsAsyncTask.Type.SEARCH) {
|
||||
if (max_id == null)
|
||||
max_id = "0";
|
||||
max_id = String.valueOf(Integer.valueOf(max_id) + 20);
|
||||
max_id = String.valueOf(Integer.parseInt(max_id) + 20);
|
||||
} else {
|
||||
max_id = apiResponse.getMax_id();
|
||||
}
|
||||
|
|
|
@ -27,8 +27,11 @@ import androidx.annotation.NonNull;
|
|||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.asynctasks.RetrieveFeedsAsyncTask;
|
||||
import app.fedilab.android.client.APIResponse;
|
||||
|
@ -61,7 +64,7 @@ public class DisplayAnnouncementsFragment extends Fragment implements OnRetrieve
|
|||
mainLoader.setVisibility(View.VISIBLE);
|
||||
LinearLayoutManager mLayoutManager = new LinearLayoutManager(context);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -72,6 +75,7 @@ public class DisplayAnnouncementsFragment extends Fragment implements OnRetrieve
|
|||
if (asyncTask != null && asyncTask.getStatus() == AsyncTask.Status.RUNNING)
|
||||
asyncTask.cancel(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle saveInstance) {
|
||||
super.onCreate(saveInstance);
|
||||
|
@ -91,7 +95,7 @@ public class DisplayAnnouncementsFragment extends Fragment implements OnRetrieve
|
|||
if (apiResponse == null) {
|
||||
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}else {
|
||||
} else {
|
||||
if (apiResponse.getError() != null) {
|
||||
if (apiResponse.getError().getError().length() < 100) {
|
||||
Toasty.error(context, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
||||
|
@ -102,7 +106,7 @@ public class DisplayAnnouncementsFragment extends Fragment implements OnRetrieve
|
|||
}
|
||||
}
|
||||
announcements = apiResponse.getAnnouncements();
|
||||
if( announcements == null || announcements.size() == 0 ){
|
||||
if (announcements == null || announcements.size() == 0) {
|
||||
textviewNoAction.setVisibility(View.VISIBLE);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -88,6 +88,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
private SharedPreferences sharedpreferences;
|
||||
private BroadcastReceiver receive_action;
|
||||
private BroadcastReceiver receive_data;
|
||||
private View rootView;
|
||||
|
||||
public DisplayNotificationsFragment() {
|
||||
}
|
||||
|
@ -95,7 +96,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
@Override
|
||||
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;
|
||||
context = getContext();
|
||||
firstLoad = true;
|
||||
|
@ -210,6 +211,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
return rootView;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle saveInstance) {
|
||||
super.onCreate(saveInstance);
|
||||
|
@ -239,6 +241,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
lv_notifications.setAdapter(null);
|
||||
}
|
||||
super.onDestroyView();
|
||||
rootView = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -144,6 +144,7 @@ public class DisplayStatusFragment extends Fragment implements OnPostActionInter
|
|||
private Date lastReadTootDate, initialBookMarkDate, updatedBookMarkDate;
|
||||
private int timelineId;
|
||||
private String currentfilter;
|
||||
private View rootView;
|
||||
|
||||
public DisplayStatusFragment() {
|
||||
}
|
||||
|
@ -151,7 +152,7 @@ public class DisplayStatusFragment extends Fragment implements OnPostActionInter
|
|||
|
||||
@Override
|
||||
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<>();
|
||||
peertubes = new ArrayList<>();
|
||||
context = getContext();
|
||||
|
@ -607,21 +608,21 @@ public class DisplayStatusFragment extends Fragment implements OnPostActionInter
|
|||
}
|
||||
}
|
||||
apiResponse.setStatuses(statusesConversations);
|
||||
}else if( type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS){
|
||||
if( apiResponse.getAnnouncements() != null && apiResponse.getAnnouncements().size() > 0 ){
|
||||
} else if (type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS) {
|
||||
if (apiResponse.getAnnouncements() != null && apiResponse.getAnnouncements().size() > 0) {
|
||||
List<Status> statusesAnnouncements = new ArrayList<>();
|
||||
apiResponse.setStatuses(statusesAnnouncements);
|
||||
for(Announcement announcement: apiResponse.getAnnouncements()){
|
||||
statusesAnnouncements.add(0,announcement);
|
||||
if( !announcement.isRead()){
|
||||
new PostActionAsyncTask(context, API.StatusAction.DISMISS_ANNOUNCEMENT, announcement.getId(), DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
for (Announcement announcement : apiResponse.getAnnouncements()) {
|
||||
statusesAnnouncements.add(0, announcement);
|
||||
if (!announcement.isRead()) {
|
||||
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);
|
||||
TextView actionView = item.getActionView().findViewById(R.id.counter);
|
||||
if(actionView != null) {
|
||||
if (actionView != null) {
|
||||
actionView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
@ -752,6 +753,7 @@ public class DisplayStatusFragment extends Fragment implements OnPostActionInter
|
|||
}
|
||||
}
|
||||
super.onDestroyView();
|
||||
rootView = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -55,7 +55,7 @@ import es.dmoral.toasty.Toasty;
|
|||
public class DisplayStoriesFragment extends Fragment implements OnRetrieveStoriesInterface {
|
||||
|
||||
|
||||
LinearLayoutManager mLayoutManager;
|
||||
private LinearLayoutManager mLayoutManager;
|
||||
private boolean flag_loading;
|
||||
private Context context;
|
||||
private AsyncTask<Void, Void, Void> asyncTask;
|
||||
|
@ -68,6 +68,7 @@ public class DisplayStoriesFragment extends Fragment implements OnRetrieveStorie
|
|||
private boolean swiped;
|
||||
private RecyclerView lv_stories;
|
||||
private RetrieveStoriesAsyncTask.type type;
|
||||
private View rootView;
|
||||
|
||||
public DisplayStoriesFragment() {
|
||||
}
|
||||
|
@ -76,7 +77,7 @@ public class DisplayStoriesFragment extends Fragment implements OnRetrieveStorie
|
|||
@Override
|
||||
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();
|
||||
if (bundle != null) {
|
||||
|
@ -243,6 +244,7 @@ public class DisplayStoriesFragment extends Fragment implements OnRetrieveStorie
|
|||
lv_stories.setAdapter(null);
|
||||
}
|
||||
super.onDestroyView();
|
||||
rootView = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -104,13 +104,14 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
|||
private TextView timerView;
|
||||
private ImageButton playView;
|
||||
private GLAudioVisualizationView visualizerView;
|
||||
private View rootView;
|
||||
|
||||
public MediaSliderFragment() {
|
||||
}
|
||||
|
||||
@Override
|
||||
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();
|
||||
Bundle bundle = this.getArguments();
|
||||
|
@ -459,6 +460,12 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
|||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
rootView = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
@ -470,7 +477,8 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
|||
}
|
||||
try {
|
||||
visualizerView.onResume();
|
||||
} catch (Exception ignored) {}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canSwipe() {
|
||||
|
|
|
@ -30,7 +30,7 @@ public class CountDrawable extends Drawable {
|
|||
float mTextSize = context.getResources().getDimension(R.dimen.badge_count_textsize);
|
||||
|
||||
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.setStyle(Paint.Style.FILL);
|
||||
|
||||
|
|
|
@ -1184,8 +1184,8 @@ public class Helper {
|
|||
DownloadManager dm = (DownloadManager) context.getSystemService(DOWNLOAD_SERVICE);
|
||||
assert dm != null;
|
||||
return dm.enqueue(request);
|
||||
}catch (IllegalStateException e){
|
||||
Toasty.error(context,context.getString(R.string.error_destination_path), Toast.LENGTH_LONG).show();
|
||||
} catch (IllegalStateException e) {
|
||||
Toasty.error(context, context.getString(R.string.error_destination_path), Toast.LENGTH_LONG).show();
|
||||
e.printStackTrace();
|
||||
return -1;
|
||||
}
|
||||
|
@ -1563,7 +1563,7 @@ public class Helper {
|
|||
}
|
||||
if (!url.equals("null"))
|
||||
Glide.with(navigationView.getContext())
|
||||
.load(!disableGif?account.getAvatar():account.getAvatar_static())
|
||||
.load(!disableGif ? account.getAvatar() : account.getAvatar_static())
|
||||
.into(new SimpleTarget<Drawable>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, Transition<? super Drawable> transition) {
|
||||
|
@ -1588,7 +1588,7 @@ public class Helper {
|
|||
public boolean onMenuItemClick(MenuItem item) {
|
||||
if (!activity.isFinishing()) {
|
||||
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);
|
||||
arrow.setImageResource(R.drawable.ic_arrow_drop_down);
|
||||
return true;
|
||||
|
@ -2016,7 +2016,7 @@ public class Helper {
|
|||
return false;
|
||||
}
|
||||
})
|
||||
.load(!disableGif?accountChoice.getAvatar():accountChoice.getAvatar_static())
|
||||
.load(!disableGif ? accountChoice.getAvatar() : accountChoice.getAvatar_static())
|
||||
.into(new SimpleTarget<Drawable>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, Transition<? super Drawable> transition) {
|
||||
|
@ -2051,10 +2051,10 @@ public class Helper {
|
|||
if (!accountChoice.getAvatar().startsWith("http"))
|
||||
accountChoice.setAvatar("https://" + accountChoice.getInstance() + accountChoice.getAvatar());
|
||||
ImageView itemIconAcc = new ImageView(activity);
|
||||
Glide.with(activity.getApplicationContext())
|
||||
Glide.with(activity)
|
||||
.asDrawable()
|
||||
.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>() {
|
||||
|
||||
@Override
|
||||
|
@ -2099,7 +2099,7 @@ public class Helper {
|
|||
editor.putBoolean(Helper.PREF_IS_ADMINISTRATOR, accountChoice.isAdmin());
|
||||
editor.commit();
|
||||
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
|
||||
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);
|
||||
|
@ -2181,7 +2181,7 @@ public class Helper {
|
|||
if (account == null) {
|
||||
Helper.logout(activity);
|
||||
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.finish(); //User is logged out to get a new token
|
||||
} else {
|
||||
|
@ -2189,7 +2189,7 @@ public class Helper {
|
|||
username.setText(String.format("@%s", account.getUsername() + "@" + account.getInstance()));
|
||||
displayedName.setText(account.getdisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
loadGiF(activity, account, profilePicture);
|
||||
String urlHeader = !disableGif?account.getHeader():account.getHeader_static();
|
||||
String urlHeader = !disableGif ? account.getHeader() : account.getHeader_static();
|
||||
if (urlHeader.startsWith("/")) {
|
||||
urlHeader = Helper.getLiveInstanceWithProtocol(activity) + account.getHeader();
|
||||
}
|
||||
|
@ -2198,7 +2198,7 @@ public class Helper {
|
|||
ImageView header_option_menu = headerLayout.findViewById(R.id.header_option_menu);
|
||||
if (!urlHeader.contains("missing.png")) {
|
||||
ImageView backgroundImage = headerLayout.findViewById(R.id.back_ground_image);
|
||||
Glide.with(activity.getApplicationContext())
|
||||
Glide.with(activity)
|
||||
.asDrawable()
|
||||
.load(urlHeader)
|
||||
.into(new SimpleTarget<Drawable>() {
|
||||
|
@ -3278,11 +3278,10 @@ public class Helper {
|
|||
}
|
||||
|
||||
|
||||
|
||||
public static void loadGiF(final Context context, Account account, final ImageView imageView) {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
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("/")) {
|
||||
url = Helper.getLiveInstanceWithProtocol(context) + url;
|
||||
}
|
||||
|
@ -3291,14 +3290,14 @@ public class Helper {
|
|||
}
|
||||
try {
|
||||
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())
|
||||
.asDrawable()
|
||||
.load(url)
|
||||
.thumbnail(0.1f)
|
||||
.apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
|
||||
.into(imageView);
|
||||
}else{
|
||||
} else {
|
||||
Glide.with(imageView.getContext())
|
||||
.asGif()
|
||||
.load(url)
|
||||
|
@ -3664,7 +3663,7 @@ public class Helper {
|
|||
String selection = null;
|
||||
String[] selectionArgs = null;
|
||||
// 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)) {
|
||||
final String docId = DocumentsContract.getDocumentId(uri);
|
||||
final String[] split = docId.split(":");
|
||||
|
|
|
@ -97,7 +97,7 @@ public class BackupNotificationInDataBaseService extends IntentService {
|
|||
@Override
|
||||
public void run() {
|
||||
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
|
||||
public void run() {
|
||||
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++;
|
||||
String message;
|
||||
SQLiteDatabase db = Sqlite.getInstance(BackupNotificationInDataBaseService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
|
||||
API api = new API(getApplicationContext(), account.getInstance(), account.getToken());
|
||||
Account account = new AccountDAO(BackupNotificationInDataBaseService.this, db).getUniqAccount(userId, instance);
|
||||
API api = new API(BackupNotificationInDataBaseService.this, account.getInstance(), account.getToken());
|
||||
try {
|
||||
//Starts from the last recorded ID
|
||||
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());
|
||||
if (finalToastMessage) {
|
||||
|
||||
Helper.notify_user(getApplicationContext(), account, mainActivity, BitmapFactory.decodeResource(getResources(),
|
||||
Helper.getMainLogo(getApplicationContext())), Helper.NotifType.BACKUP, title, message);
|
||||
Helper.notify_user(BackupNotificationInDataBaseService.this, account, mainActivity, BitmapFactory.decodeResource(getResources(),
|
||||
Helper.getMainLogo(BackupNotificationInDataBaseService.this)), Helper.NotifType.BACKUP, title, message);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -165,7 +165,7 @@ public class BackupNotificationInDataBaseService extends IntentService {
|
|||
@Override
|
||||
public void run() {
|
||||
if (finalToastMessage) {
|
||||
Toasty.error(getApplicationContext(), finalMessage, Toast.LENGTH_LONG).show();
|
||||
Toasty.error(BackupNotificationInDataBaseService.this, finalMessage, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -98,7 +98,7 @@ public class BackupStatusInDataBaseService extends IntentService {
|
|||
@Override
|
||||
public void run() {
|
||||
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
|
||||
public void run() {
|
||||
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++;
|
||||
String message;
|
||||
SQLiteDatabase db = Sqlite.getInstance(BackupStatusInDataBaseService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
|
||||
API api = new API(getApplicationContext(), account.getInstance(), account.getToken());
|
||||
Account account = new AccountDAO(BackupStatusInDataBaseService.this, db).getUniqAccount(userId, instance);
|
||||
API api = new API(BackupStatusInDataBaseService.this, account.getInstance(), account.getToken());
|
||||
try {
|
||||
//Starts from the last recorded ID
|
||||
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);
|
||||
String title = getString(R.string.data_backup_toots, account.getAcct());
|
||||
if (finalToastMessage) {
|
||||
Helper.notify_user(getApplicationContext(), account, mainActivity, BitmapFactory.decodeResource(getResources(),
|
||||
Helper.getMainLogo(getApplicationContext())), Helper.NotifType.BACKUP, title, message);
|
||||
Helper.notify_user(BackupStatusInDataBaseService.this, account, mainActivity, BitmapFactory.decodeResource(getResources(),
|
||||
Helper.getMainLogo(BackupStatusInDataBaseService.this)), Helper.NotifType.BACKUP, title, message);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -163,7 +163,7 @@ public class BackupStatusInDataBaseService extends IntentService {
|
|||
@Override
|
||||
public void run() {
|
||||
if (finalToastMessage) {
|
||||
Toasty.error(getApplicationContext(), finalMessage, Toast.LENGTH_LONG).show();
|
||||
Toasty.error(BackupStatusInDataBaseService.this, finalMessage, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -89,14 +89,14 @@ public class BackupStatusService extends IntentService {
|
|||
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
||||
@Override
|
||||
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 {
|
||||
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
||||
@Override
|
||||
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;
|
||||
|
@ -107,8 +107,8 @@ public class BackupStatusService extends IntentService {
|
|||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
SQLiteDatabase db = Sqlite.getInstance(BackupStatusService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
|
||||
API api = new API(getApplicationContext(), account.getInstance(), account.getToken());
|
||||
Account account = new AccountDAO(BackupStatusService.this, db).getUniqAccount(userId, instance);
|
||||
API api = new API(BackupStatusService.this, account.getInstance(), account.getToken());
|
||||
try {
|
||||
String fullPath;
|
||||
Intent intentOpen;
|
||||
|
@ -128,7 +128,7 @@ public class BackupStatusService extends IntentService {
|
|||
}
|
||||
} 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();
|
||||
fullPath = filePath + "/" + fileName;
|
||||
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
|
||||
content = Html.fromHtml(status.getContent()).toString();
|
||||
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.getFavourites_count()).append("\"").append(',');
|
||||
builder.append("\"").append(status.isSensitive()).append("\"").append(',');
|
||||
|
@ -192,8 +192,8 @@ public class BackupStatusService extends IntentService {
|
|||
Uri uri = Uri.parse("file://" + fullPath);
|
||||
intentOpen.setDataAndType(uri, "text/csv");
|
||||
String title = getString(R.string.data_export_toots, account.getAcct());
|
||||
Helper.notify_user(getApplicationContext(), account, intentOpen, BitmapFactory.decodeResource(getResources(),
|
||||
Helper.getMainLogo(getApplicationContext())), Helper.NotifType.BACKUP, title, message);
|
||||
Helper.notify_user(BackupStatusService.this, account, intentOpen, BitmapFactory.decodeResource(getResources(),
|
||||
Helper.getMainLogo(BackupStatusService.this)), Helper.NotifType.BACKUP, title, message);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
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() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toasty.error(getApplicationContext(), finalMessage, Toast.LENGTH_LONG).show();
|
||||
Toasty.error(BackupStatusService.this, finalMessage, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -99,8 +99,8 @@ public class LiveNotificationDelayedService extends Service {
|
|||
((NotificationManager) Objects.requireNonNull(getSystemService(Context.NOTIFICATION_SERVICE))).createNotificationChannel(channel);
|
||||
}
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<Account> accountStreams = new AccountDAO(getApplicationContext(), db).getAllAccountCrossAction();
|
||||
SQLiteDatabase db = Sqlite.getInstance(LiveNotificationDelayedService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<Account> accountStreams = new AccountDAO(LiveNotificationDelayedService.this, db).getAllAccountCrossAction();
|
||||
totalAccount = 0;
|
||||
if (accountStreams != null) {
|
||||
for (Account account : accountStreams) {
|
||||
|
@ -112,9 +112,9 @@ public class LiveNotificationDelayedService extends Service {
|
|||
}
|
||||
|
||||
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(
|
||||
getApplicationContext(),
|
||||
LiveNotificationDelayedService.this,
|
||||
0,
|
||||
myIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
@ -123,7 +123,7 @@ public class LiveNotificationDelayedService extends Service {
|
|||
.setShowWhen(false)
|
||||
.setContentIntent(pendingIntent)
|
||||
.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();
|
||||
startForeground(1, notification);
|
||||
}
|
||||
|
@ -180,9 +180,9 @@ public class LiveNotificationDelayedService extends Service {
|
|||
|
||||
private void startStream() {
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
if (Helper.liveNotifType(getApplicationContext()) == Helper.NOTIF_DELAYED) {
|
||||
List<Account> accountStreams = new AccountDAO(getApplicationContext(), db).getAllAccountCrossAction();
|
||||
SQLiteDatabase db = Sqlite.getInstance(LiveNotificationDelayedService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
if (Helper.liveNotifType(LiveNotificationDelayedService.this) == Helper.NOTIF_DELAYED) {
|
||||
List<Account> accountStreams = new AccountDAO(LiveNotificationDelayedService.this, db).getAllAccountCrossAction();
|
||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
fetch = true;
|
||||
if (accountStreams != null) {
|
||||
|
@ -213,7 +213,7 @@ public class LiveNotificationDelayedService extends Service {
|
|||
public void run() {
|
||||
while (fetch) {
|
||||
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) {
|
||||
try {
|
||||
Thread.sleep(sleeps.get(key));
|
||||
|
@ -247,11 +247,11 @@ public class LiveNotificationDelayedService extends Service {
|
|||
try {
|
||||
if (account.getSocial().compareTo("FRIENDICA") != 0 && account.getSocial().compareTo("GNU") != 0) {
|
||||
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);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
|
@ -309,14 +309,14 @@ public class LiveNotificationDelayedService extends Service {
|
|||
android.app.Notification notificationChannel = new NotificationCompat.Builder(this, CHANNEL_ID)
|
||||
.setShowWhen(false)
|
||||
.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();
|
||||
|
||||
startForeground(1, notificationChannel);
|
||||
}
|
||||
|
||||
event = Helper.EventStreaming.NOTIFICATION;
|
||||
boolean canNotify = Helper.canNotify(getApplicationContext());
|
||||
boolean canNotify = Helper.canNotify(LiveNotificationDelayedService.this);
|
||||
boolean notify = sharedpreferences.getBoolean(Helper.SET_NOTIFY, true);
|
||||
String targeted_account = null;
|
||||
Helper.NotifType notifType = Helper.NotifType.MENTION;
|
||||
|
@ -421,7 +421,7 @@ public class LiveNotificationDelayedService extends Service {
|
|||
}
|
||||
|
||||
//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.putExtra(Helper.INTENT_ACTION, Helper.NOTIFICATION_INTENT);
|
||||
intent.putExtra(Helper.PREF_KEY_ID, account.getId());
|
||||
|
@ -436,7 +436,7 @@ public class LiveNotificationDelayedService extends Service {
|
|||
@Override
|
||||
public void run() {
|
||||
if (finalMessage != null) {
|
||||
Glide.with(getApplicationContext())
|
||||
Glide.with(LiveNotificationDelayedService.this)
|
||||
.asBitmap()
|
||||
.load(notification.getAccount().getAvatar())
|
||||
.listener(new RequestListener<Bitmap>() {
|
||||
|
@ -447,8 +447,8 @@ public class LiveNotificationDelayedService extends Service {
|
|||
|
||||
@Override
|
||||
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
|
||||
Helper.notify_user(getApplicationContext(), account, intent, BitmapFactory.decodeResource(getResources(),
|
||||
getMainLogo(getApplicationContext())), finalNotifType, "@" + notification.getAccount().getAcct(), finalMessage);
|
||||
Helper.notify_user(LiveNotificationDelayedService.this, account, intent, BitmapFactory.decodeResource(getResources(),
|
||||
getMainLogo(LiveNotificationDelayedService.this)), finalNotifType, "@" + notification.getAccount().getAcct(), finalMessage);
|
||||
return false;
|
||||
}
|
||||
})
|
||||
|
@ -456,7 +456,7 @@ public class LiveNotificationDelayedService extends Service {
|
|||
@Override
|
||||
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.putExtras(b);
|
||||
b.putParcelable("data", notification);
|
||||
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intentBC);
|
||||
LocalBroadcastManager.getInstance(LiveNotificationDelayedService.this).sendBroadcast(intentBC);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + account.getId() + account.getInstance(), notification.getId());
|
||||
editor.apply();
|
||||
|
|
|
@ -117,8 +117,8 @@ public class LiveNotificationService extends Service implements NetworkStateRece
|
|||
|
||||
((NotificationManager) Objects.requireNonNull(getSystemService(Context.NOTIFICATION_SERVICE))).createNotificationChannel(channel);
|
||||
}
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<Account> accountStreams = new AccountDAO(getApplicationContext(), db).getAllAccountCrossAction();
|
||||
SQLiteDatabase db = Sqlite.getInstance(LiveNotificationService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<Account> accountStreams = new AccountDAO(LiveNotificationService.this, db).getAllAccountCrossAction();
|
||||
totalAccount = 0;
|
||||
if (accountStreams != null) {
|
||||
for (Account account : accountStreams) {
|
||||
|
@ -131,16 +131,16 @@ public class LiveNotificationService extends Service implements NetworkStateRece
|
|||
}
|
||||
}
|
||||
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(
|
||||
getApplicationContext(),
|
||||
LiveNotificationService.this,
|
||||
0,
|
||||
myIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
android.app.Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
|
||||
.setContentTitle(getString(R.string.top_notification))
|
||||
.setContentIntent(pendingIntent)
|
||||
.setSmallIcon(getNotificationIcon(getApplicationContext()))
|
||||
.setSmallIcon(getNotificationIcon(LiveNotificationService.this))
|
||||
.setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build();
|
||||
|
||||
startForeground(1, notification);
|
||||
|
@ -158,9 +158,9 @@ public class LiveNotificationService extends Service implements NetworkStateRece
|
|||
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
boolean liveNotifications = sharedpreferences.getBoolean(Helper.SET_LIVE_NOTIFICATIONS, true);
|
||||
SQLiteDatabase db = Sqlite.getInstance(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) {
|
||||
List<Account> accountStreams = new AccountDAO(getApplicationContext(), db).getAllAccountCrossAction();
|
||||
List<Account> accountStreams = new AccountDAO(LiveNotificationService.this, db).getAllAccountCrossAction();
|
||||
if (accountStreams != null) {
|
||||
for (final Account accountStream : accountStreams) {
|
||||
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);
|
||||
android.app.Notification notificationChannel = new NotificationCompat.Builder(this, CHANNEL_ID)
|
||||
.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();
|
||||
|
||||
startForeground(1, notificationChannel);
|
||||
}
|
||||
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
b.putParcelable("data", notification);
|
||||
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);
|
||||
String targeted_account = null;
|
||||
Helper.NotifType notifType = Helper.NotifType.MENTION;
|
||||
|
@ -456,7 +456,7 @@ public class LiveNotificationService extends Service implements NetworkStateRece
|
|||
default:
|
||||
}
|
||||
//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.putExtra(Helper.INTENT_ACTION, Helper.NOTIFICATION_INTENT);
|
||||
intent.putExtra(Helper.PREF_KEY_ID, account.getId());
|
||||
|
@ -471,7 +471,7 @@ public class LiveNotificationService extends Service implements NetworkStateRece
|
|||
@Override
|
||||
public void run() {
|
||||
if (finalMessage != null) {
|
||||
Glide.with(getApplicationContext())
|
||||
Glide.with(LiveNotificationService.this)
|
||||
.asBitmap()
|
||||
.load(notification.getAccount().getAvatar())
|
||||
.listener(new RequestListener<Bitmap>() {
|
||||
|
@ -482,8 +482,8 @@ public class LiveNotificationService extends Service implements NetworkStateRece
|
|||
|
||||
@Override
|
||||
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
|
||||
Helper.notify_user(getApplicationContext(), account, intent, BitmapFactory.decodeResource(getResources(),
|
||||
getMainLogo(getApplicationContext())), finalNotifType, "@" + notification.getAccount().getAcct(), finalMessage);
|
||||
Helper.notify_user(LiveNotificationService.this, account, intent, BitmapFactory.decodeResource(getResources(),
|
||||
getMainLogo(LiveNotificationService.this)), finalNotifType, "@" + notification.getAccount().getAcct(), finalMessage);
|
||||
return false;
|
||||
}
|
||||
})
|
||||
|
@ -491,7 +491,7 @@ public class LiveNotificationService extends Service implements NetworkStateRece
|
|||
@Override
|
||||
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.putExtras(b);
|
||||
b.putParcelable("data", notification);
|
||||
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intentBC);
|
||||
LocalBroadcastManager.getInstance(LiveNotificationService.this).sendBroadcast(intentBC);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + account.getId() + account.getInstance(), notification.getId());
|
||||
editor.apply();
|
||||
|
|
|
@ -35,13 +35,13 @@ public class RestartLiveNotificationReceiver extends BroadcastReceiver {
|
|||
public void onReceive(Context context, Intent intent) {
|
||||
int type = Helper.liveNotifType(context);
|
||||
if (type == Helper.NOTIF_DELAYED) {
|
||||
Intent streamingServiceIntent = new Intent(context.getApplicationContext(), LiveNotificationDelayedService.class);
|
||||
Intent streamingServiceIntent = new Intent(context, LiveNotificationDelayedService.class);
|
||||
try {
|
||||
context.startService(streamingServiceIntent);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
} else if (type == Helper.NOTIF_LIVE) {
|
||||
Intent streamingServiceIntent = new Intent(context.getApplicationContext(), LiveNotificationService.class);
|
||||
Intent streamingServiceIntent = new Intent(context, LiveNotificationService.class);
|
||||
try {
|
||||
context.startService(streamingServiceIntent);
|
||||
} catch (Exception ignored) {
|
||||
|
|
|
@ -30,7 +30,7 @@ public class StopDelayedNotificationReceiver extends BroadcastReceiver {
|
|||
@SuppressLint("UnsafeProtectedBroadcastReceiver")
|
||||
@Override
|
||||
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);
|
||||
try {
|
||||
context.startService(streamingServiceIntent);
|
||||
|
|
|
@ -30,7 +30,7 @@ public class StopLiveNotificationReceiver extends BroadcastReceiver {
|
|||
@SuppressLint("UnsafeProtectedBroadcastReceiver")
|
||||
@Override
|
||||
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);
|
||||
try {
|
||||
context.startService(streamingServiceIntent);
|
||||
|
|
|
@ -87,7 +87,7 @@ public class StreamingFederatedTimelineService extends IntentService {
|
|||
}
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
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.apply();
|
||||
}
|
||||
|
@ -100,8 +100,8 @@ public class StreamingFederatedTimelineService extends IntentService {
|
|||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account accountStream = null;
|
||||
if (userId != null) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
accountStream = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
|
||||
SQLiteDatabase db = Sqlite.getInstance(StreamingFederatedTimelineService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
accountStream = new AccountDAO(StreamingFederatedTimelineService.this, db).getUniqAccount(userId, instance);
|
||||
}
|
||||
if (accountStream != null) {
|
||||
Headers headers = new Headers();
|
||||
|
@ -155,14 +155,14 @@ public class StreamingFederatedTimelineService extends IntentService {
|
|||
Bundle b = new Bundle();
|
||||
try {
|
||||
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);
|
||||
b.putParcelable("data", status);
|
||||
if (account != null)
|
||||
b.putString("userIdService", account.getId());
|
||||
Intent intentBC = new Intent(Helper.RECEIVE_FEDERATED_DATA);
|
||||
intentBC.putExtras(b);
|
||||
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intentBC);
|
||||
LocalBroadcastManager.getInstance(StreamingFederatedTimelineService.this).sendBroadcast(intentBC);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -87,7 +87,7 @@ public class StreamingHomeTimelineService extends IntentService {
|
|||
}
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
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.apply();
|
||||
}
|
||||
|
@ -100,8 +100,8 @@ public class StreamingHomeTimelineService extends IntentService {
|
|||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account accountStream = null;
|
||||
if (userId != null) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
accountStream = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
|
||||
SQLiteDatabase db = Sqlite.getInstance(StreamingHomeTimelineService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
accountStream = new AccountDAO(StreamingHomeTimelineService.this, db).getUniqAccount(userId, instance);
|
||||
}
|
||||
if (accountStream != null) {
|
||||
Headers headers = new Headers();
|
||||
|
@ -155,14 +155,14 @@ public class StreamingHomeTimelineService extends IntentService {
|
|||
Bundle b = new Bundle();
|
||||
try {
|
||||
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);
|
||||
b.putParcelable("data", status);
|
||||
if (account != null)
|
||||
b.putString("userIdService", account.getId());
|
||||
Intent intentBC = new Intent(Helper.RECEIVE_HOME_DATA);
|
||||
intentBC.putExtras(b);
|
||||
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intentBC);
|
||||
LocalBroadcastManager.getInstance(StreamingHomeTimelineService.this).sendBroadcast(intentBC);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -87,7 +87,7 @@ public class StreamingLocalTimelineService extends IntentService {
|
|||
}
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
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.apply();
|
||||
}
|
||||
|
@ -100,8 +100,8 @@ public class StreamingLocalTimelineService extends IntentService {
|
|||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account accountStream = null;
|
||||
if (userId != null) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
accountStream = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
|
||||
SQLiteDatabase db = Sqlite.getInstance(StreamingLocalTimelineService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
accountStream = new AccountDAO(StreamingLocalTimelineService.this, db).getUniqAccount(userId, instance);
|
||||
}
|
||||
|
||||
if (accountStream != null) {
|
||||
|
@ -155,14 +155,14 @@ public class StreamingLocalTimelineService extends IntentService {
|
|||
Bundle b = new Bundle();
|
||||
try {
|
||||
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);
|
||||
b.putParcelable("data", status);
|
||||
if (account != null)
|
||||
b.putString("userIdService", account.getId());
|
||||
Intent intentBC = new Intent(Helper.RECEIVE_LOCAL_DATA);
|
||||
intentBC.putExtras(b);
|
||||
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intentBC);
|
||||
LocalBroadcastManager.getInstance(StreamingLocalTimelineService.this).sendBroadcast(intentBC);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -337,7 +337,7 @@ public class Sqlite extends SQLiteOpenHelper {
|
|||
Helper.logoutCurrentUser(activity);
|
||||
} catch (Exception e) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue