Some improvements
This commit is contained in:
parent
1e76c1dbec
commit
56e74e3120
|
@ -1,3 +1,5 @@
|
|||
Changed:
|
||||
- One logout entry in menu (it will removed the account from the app)
|
||||
- One logout entry in the menu (it will remove the account from the app)
|
||||
- Improve memory management
|
||||
- Improve scroll
|
||||
- Clear push notifications when visiting notifications tab
|
|
@ -1378,6 +1378,9 @@ public class API {
|
|||
account.setUsername(resobj.get("username").toString());
|
||||
account.setAcct(resobj.get("acct").toString());
|
||||
account.setDisplay_name(resobj.get("display_name").toString());
|
||||
if( account.getDisplay_name() == null || account.getDisplay_name().compareTo("") == 0){
|
||||
account.setDisplay_name(resobj.get("username").toString());
|
||||
}
|
||||
account.setLocked(Boolean.parseBoolean(resobj.get("locked").toString()));
|
||||
if (resobj.has("created_at") && !resobj.isNull("created_at")) {
|
||||
account.setCreated_at(Helper.mstStringToDate(resobj.get("created_at").toString()));
|
||||
|
|
|
@ -1328,11 +1328,13 @@ public class Helper {
|
|||
}
|
||||
if (!url.equals("null"))
|
||||
Glide.with(navigationView.getContext())
|
||||
.load(!disableGif ? account.getAvatar() : account.getAvatar_static())
|
||||
.into(new SimpleTarget<Drawable>() {
|
||||
.asBitmap()
|
||||
.load(account.getAvatar())
|
||||
.into(new SimpleTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, Transition<? super Drawable> transition) {
|
||||
item.setIcon(resource);
|
||||
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
|
||||
Drawable drawable = new BitmapDrawable(activity.getResources(), resource);
|
||||
item.setIcon(drawable);
|
||||
item.getIcon().setColorFilter(0xFFFFFFFF, PorterDuff.Mode.MULTIPLY);
|
||||
}
|
||||
});
|
||||
|
@ -1358,32 +1360,6 @@ public class Helper {
|
|||
}
|
||||
return false;
|
||||
});
|
||||
item.setActionView(R.layout.update_account);
|
||||
ImageView deleteButton = item.getActionView().findViewById(R.id.account_remove_button);
|
||||
deleteButton.setOnClickListener(v -> {
|
||||
final SharedPreferences sharedpreferences1 = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
int theme1 = sharedpreferences1.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||
int style;
|
||||
if (theme1 == Helper.THEME_DARK) {
|
||||
style = R.style.DialogDark;
|
||||
} else if (theme1 == Helper.THEME_BLACK) {
|
||||
style = R.style.DialogBlack;
|
||||
} else {
|
||||
style = R.style.Dialog;
|
||||
}
|
||||
new AlertDialog.Builder(activity, style)
|
||||
.setTitle(activity.getString(R.string.delete_account_title))
|
||||
.setMessage(activity.getString(R.string.delete_account_message, "@" + account.getAcct() + "@" + account.getInstance()))
|
||||
.setPositiveButton(android.R.string.yes, (dialog, which) -> {
|
||||
new RemoveAccountAsyncTask(activity, account).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
item.setVisible(false);
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, (dialog, which) -> {
|
||||
// do nothing
|
||||
})
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.show();
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,10 +47,6 @@ 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 com.koushikdutta.async.ByteBufferList;
|
||||
import com.koushikdutta.async.DataEmitter;
|
||||
import com.koushikdutta.async.callback.CompletedCallback;
|
||||
import com.koushikdutta.async.callback.DataCallback;
|
||||
import com.koushikdutta.async.http.AsyncHttpClient;
|
||||
import com.koushikdutta.async.http.AsyncHttpRequest;
|
||||
import com.koushikdutta.async.http.Headers;
|
||||
|
@ -242,38 +238,28 @@ public class LiveNotificationService extends Service implements NetworkStateRece
|
|||
}
|
||||
String key = account.getAcct() + "@" + account.getInstance();
|
||||
if (webSocketFutures.get(key) == null || !Objects.requireNonNull(webSocketFutures.get(key)).isOpen()) {
|
||||
AsyncHttpClient.getDefaultInstance().websocket("wss://" + account.getInstance() + "/api/v1/streaming/?stream=" + notif_url + "&access_token=" + account.getToken(), "wss", new AsyncHttpClient.WebSocketConnectCallback() {
|
||||
@Override
|
||||
public void onCompleted(Exception ex, WebSocket webSocket) {
|
||||
AsyncHttpClient.getDefaultInstance().websocket("wss://" + account.getInstance() + "/api/v1/streaming/?stream=" + notif_url + "&access_token=" + account.getToken(), "wss", (ex, webSocket) -> {
|
||||
webSocketFutures.put(account.getAcct() + "@" + account.getInstance(), webSocket);
|
||||
if (ex != null) {
|
||||
return;
|
||||
}
|
||||
webSocket.setStringCallback(new WebSocket.StringCallback() {
|
||||
public void onStringAvailable(String s) {
|
||||
webSocket.setStringCallback(s -> {
|
||||
try {
|
||||
JSONObject eventJson = new JSONObject(s);
|
||||
onRetrieveStreaming(account, eventJson);
|
||||
} catch (JSONException ignored) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
webSocket.setClosedCallback(new CompletedCallback() {
|
||||
@Override
|
||||
public void onCompleted(Exception ex) {
|
||||
webSocket.setClosedCallback(ex1 -> {
|
||||
if (networkStateReceiver.connected) {
|
||||
startWork(account);
|
||||
}
|
||||
}
|
||||
});
|
||||
webSocket.setDataCallback(new DataCallback() {
|
||||
public void onDataAvailable(DataEmitter emitter, ByteBufferList byteBufferList) {
|
||||
webSocket.setDataCallback((emitter, byteBufferList) -> {
|
||||
// note that this data has been read
|
||||
byteBufferList.recycle();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -337,9 +323,6 @@ public class LiveNotificationService extends Service implements NetworkStateRece
|
|||
|
||||
event = Helper.EventStreaming.NOTIFICATION;
|
||||
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(LiveNotificationService.this);
|
||||
|
@ -467,9 +450,7 @@ public class LiveNotificationService extends Service implements NetworkStateRece
|
|||
final String finalMessage = message;
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
Helper.NotifType finalNotifType = notifType;
|
||||
Runnable myRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Runnable myRunnable = () -> {
|
||||
if (finalMessage != null) {
|
||||
Glide.with(LiveNotificationService.this)
|
||||
.asBitmap()
|
||||
|
@ -495,7 +476,6 @@ public class LiveNotificationService extends Service implements NetworkStateRece
|
|||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
mainHandler.post(myRunnable);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue