Some fixes & improvements
This commit is contained in:
parent
398d1a4fe7
commit
9bb26aa22c
|
@ -1331,7 +1331,9 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
Handler handler = new Handler();
|
||||
handler.postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
dialogBuilderOptin.show();
|
||||
if (!BaseMainActivity.this.isFinishing()) {
|
||||
dialogBuilderOptin.show();
|
||||
}
|
||||
}
|
||||
}, 1000);
|
||||
} catch (Exception ignored) {}
|
||||
|
|
|
@ -243,7 +243,7 @@ public class SettingsActivity extends BaseActivity {
|
|||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 8;
|
||||
return 9;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -434,8 +434,9 @@ public class ManageTimelines {
|
|||
public void onDismiss(PopupMenu menu) {
|
||||
if (mPageReferenceMap != null) {
|
||||
TabLayoutNotificationsFragment tabLayoutNotificationsFragment = (TabLayoutNotificationsFragment) mPageReferenceMap.get(tl.getPosition());
|
||||
assert tabLayoutNotificationsFragment != null;
|
||||
tabLayoutNotificationsFragment.refreshAll();
|
||||
if (tabLayoutNotificationsFragment != null) {
|
||||
tabLayoutNotificationsFragment.refreshAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -735,6 +735,29 @@ public class Status implements Parcelable {
|
|||
AlertDialog.Builder builder = new AlertDialog.Builder(context, style);
|
||||
if( response != null ) {
|
||||
builder.setMessage(context.getString(R.string.redirect_detected,url,response));
|
||||
builder.setNegativeButton(R.string.copy_link, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText(Helper.CLIP_BOARD, response);
|
||||
if (clipboard != null) {
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toasty.info(context, context.getString(R.string.clipboard_url), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builder.setNeutralButton(R.string.share_link, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
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)));
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
}else{
|
||||
builder.setMessage(R.string.no_redirect);
|
||||
}
|
||||
|
@ -744,7 +767,9 @@ public class Status implements Parcelable {
|
|||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
}).show();
|
||||
})
|
||||
.show();
|
||||
|
||||
}
|
||||
};
|
||||
mainHandler.post(myRunnable);
|
||||
|
|
|
@ -286,7 +286,15 @@ public class HttpsConnection {
|
|||
}
|
||||
}
|
||||
httpsURLConnection.getInputStream().close();
|
||||
return redirect != null && redirect.compareTo(urlConnection)!=0?redirect:null;
|
||||
if (redirect != null && redirect.compareTo(urlConnection)!=0){
|
||||
URL redirectURL = new URL(redirect);
|
||||
String host = redirectURL.getHost();
|
||||
String protocol = redirectURL.getProtocol();
|
||||
if( protocol == null || host == null){
|
||||
redirect = null;
|
||||
}
|
||||
}
|
||||
return redirect;
|
||||
} catch (IOException | NoSuchAlgorithmException | KeyManagementException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -821,34 +821,38 @@ public class PeertubeAPI {
|
|||
if (e.getStatusCode() == 401 || e.getStatusCode() == 403) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account targetedAccount = new AccountDAO(context, db).getAccountByToken(prefKeyOauthTokenT);
|
||||
HashMap<String, String> values = refreshToken(targetedAccount.getClient_id(), targetedAccount.getClient_secret(), targetedAccount.getRefresh_token());
|
||||
if (values.containsKey("access_token") && values.get("access_token") != null) {
|
||||
targetedAccount.setToken(values.get("access_token"));
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
||||
//This account is currently logged in, the token is updated
|
||||
if (prefKeyOauthTokenT != null && prefKeyOauthTokenT.equals(token)) {
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, targetedAccount.getToken());
|
||||
editor.apply();
|
||||
if (targetedAccount != null) {
|
||||
HashMap<String, String> values = refreshToken(targetedAccount.getClient_id(), targetedAccount.getClient_secret(), targetedAccount.getRefresh_token());
|
||||
if (values.containsKey("access_token") && values.get("access_token") != null) {
|
||||
targetedAccount.setToken(values.get("access_token"));
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
||||
//This account is currently logged in, the token is updated
|
||||
if (prefKeyOauthTokenT != null && prefKeyOauthTokenT.equals(token)) {
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, targetedAccount.getToken());
|
||||
editor.apply();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (values.containsKey("refresh_token") && values.get("refresh_token") != null)
|
||||
targetedAccount.setRefresh_token(values.get("refresh_token"));
|
||||
new AccountDAO(context, db).updateAccount(targetedAccount);
|
||||
if (values.containsKey("refresh_token") && values.get("refresh_token") != null)
|
||||
targetedAccount.setRefresh_token(values.get("refresh_token"));
|
||||
new AccountDAO(context, db).updateAccount(targetedAccount);
|
||||
|
||||
String response;
|
||||
try {
|
||||
response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/users/me"), 60, null, targetedAccount.getToken());
|
||||
JSONObject accountObject = new JSONObject(response).getJSONObject("account");
|
||||
account = parseAccountResponsePeertube(context, accountObject);
|
||||
if (social != null) {
|
||||
account.setSocial(social.toUpperCase());
|
||||
String response;
|
||||
try {
|
||||
response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/users/me"), 60, null, targetedAccount.getToken());
|
||||
JSONObject accountObject = new JSONObject(response).getJSONObject("account");
|
||||
account = parseAccountResponsePeertube(context, accountObject);
|
||||
if (social != null) {
|
||||
account.setSocial(social.toUpperCase());
|
||||
}
|
||||
} catch (IOException | NoSuchAlgorithmException | KeyManagementException | JSONException e1) {
|
||||
e1.printStackTrace();
|
||||
} catch (HttpsConnection.HttpsConnectionException e1) {
|
||||
e1.printStackTrace();
|
||||
setError(e.getStatusCode(), e);
|
||||
}
|
||||
} catch (IOException | NoSuchAlgorithmException | KeyManagementException | JSONException e1) {
|
||||
e1.printStackTrace();
|
||||
} catch (HttpsConnection.HttpsConnectionException e1) {
|
||||
e1.printStackTrace();
|
||||
}else{
|
||||
setError(e.getStatusCode(), e);
|
||||
}
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -132,13 +132,13 @@ public class AccountSearchDevAdapter extends BaseAdapter implements OnPostAction
|
|||
//Profile picture
|
||||
|
||||
if (account.getAvatar().startsWith("http")) {
|
||||
if( !((Activity)context).isFinishing()) {
|
||||
if( !((Activity)context).isFinishing() && !((Activity)context).isDestroyed()) {
|
||||
Glide.with(context)
|
||||
.load(account.getAvatar())
|
||||
.into(holder.account_pp);
|
||||
}
|
||||
} else if (account.getSocial() != null && account.getSocial().contains("OPENCOLLECTIVE")) {
|
||||
if( !((Activity)context).isFinishing()) {
|
||||
if( !((Activity)context).isFinishing() && !((Activity)context).isDestroyed()) {
|
||||
Glide.with(context)
|
||||
.load(R.drawable.missing)
|
||||
.into(holder.account_pp);
|
||||
|
|
|
@ -1771,7 +1771,9 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
|
|||
|
||||
boolean allow_live_notifications = sharedpreferences.getBoolean(Helper.SET_ALLOW_STREAM + userId + instance, true);
|
||||
TextView set_allow_live_notifications_title = rootView.findViewById(R.id.set_allow_live_notifications_title);
|
||||
set_allow_live_notifications_title.setText(context.getString(R.string.set_allow_live_notifications, account.getAcct() + "@" + account.getInstance()));
|
||||
if (account != null) {
|
||||
set_allow_live_notifications_title.setText(context.getString(R.string.set_allow_live_notifications, account.getAcct() + "@" + account.getInstance()));
|
||||
}
|
||||
final SwitchCompat set_allow_live_notifications = rootView.findViewById(R.id.set_allow_live_notifications);
|
||||
set_allow_live_notifications.setChecked(allow_live_notifications);
|
||||
set_allow_live_notifications.setOnClickListener(new View.OnClickListener() {
|
||||
|
|
Loading…
Reference in New Issue