Commit 13a1a2a7 authored by Thomas's avatar Thomas
Browse files

Message history

parent 0189dad4
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -156,6 +156,11 @@
        <activity
            android:name=".activities.WebviewConnectActivity"
            android:configChanges="keyboardHidden|orientation|screenSize" />
        <activity
            android:name=".activities.StatusHistoryActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:label="@string/status_history"
            android:theme="@style/AppThemeBar" />
        <activity
            android:name=".activities.ContextActivity"
            android:configChanges="keyboardHidden|orientation|screenSize" />
+85 −0
Original line number Diff line number Diff line
package app.fedilab.android.activities;
/* Copyright 2022 Thomas Schneider
 *
 * This file is a part of Fedilab
 *
 * This program is free software; you can redistribute it and/or modify it under the terms of the
 * GNU General Public License as published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 *
 * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with Fedilab; if not,
 * see <http://www.gnu.org/licenses>. */


import android.content.res.Resources;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.MenuItem;

import androidx.core.content.ContextCompat;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;

import app.fedilab.android.R;
import app.fedilab.android.databinding.ActivityStatusHistoryBinding;
import app.fedilab.android.helper.Helper;
import app.fedilab.android.helper.ThemeHelper;
import app.fedilab.android.ui.drawer.StatusHistoryAdapter;
import app.fedilab.android.viewmodel.mastodon.StatusesVM;
import es.dmoral.toasty.Toasty;


public class StatusHistoryActivity extends BaseActivity {

    public static Resources.Theme theme;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ThemeHelper.applyTheme(this);
        ActivityStatusHistoryBinding binding = ActivityStatusHistoryBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());


        if (getSupportActionBar() != null) {
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            getSupportActionBar().setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(this, R.color.cyanea_primary)));
        }

        Bundle b = getIntent().getExtras();
        String statusId;
        if (b != null) {
            statusId = b.getString(Helper.ARG_STATUS_ID);
        } else {
            finish();
            return;
        }
        StatusesVM statusesVM = new ViewModelProvider(StatusHistoryActivity.this).get(StatusesVM.class);
        statusesVM.getStatusHistory(MainActivity.currentInstance, MainActivity.currentToken, statusId).observe(this, statuses -> {
            if (statuses != null && statuses.size() > 0) {
                StatusHistoryAdapter statusHistoryAdapter = new StatusHistoryAdapter(statuses);
                binding.recyclerView.setAdapter(statusHistoryAdapter);
                binding.recyclerView.setLayoutManager(new LinearLayoutManager(this));
            } else {
                Toasty.error(this, getString(R.string.toast_error), Toasty.LENGTH_LONG).show();
                finish();
            }
        });

    }


    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            finish();
            return true;
        }
        return true;
    }

}
 No newline at end of file
+5 −0
Original line number Diff line number Diff line
@@ -67,6 +67,11 @@ public interface MastodonStatusesService {
            @Header("Authorization") String token,
            @Path("id") String id);

    @GET("statuses/{id}/history")
    Call<List<Status>> getStatusHistory(
            @Header("Authorization") String token,
            @Path("id") String id);

    //Post a status
    @FormUrlEncoded
    @PUT("statuses/{id}")
+2 −0
Original line number Diff line number Diff line
@@ -378,6 +378,8 @@ public class Timeline {
        TREND_TAG("TREND_TAG"),
        @SerializedName("TREND_MESSAGE")
        TREND_MESSAGE("TREND_MESSAGE"),
        @SerializedName("STATUS_HISTORY")
        STATUS_HISTORY("STATUS_HISTORY"),
        @SerializedName("ACCOUNT_TIMELINE")
        ACCOUNT_TIMELINE("ACCOUNT_TIMELINE"),
        @SerializedName("MUTED_TIMELINE")
+6 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ import app.fedilab.android.activities.MainActivity;
import app.fedilab.android.activities.MediaActivity;
import app.fedilab.android.activities.ProfileActivity;
import app.fedilab.android.activities.ReportActivity;
import app.fedilab.android.activities.StatusHistoryActivity;
import app.fedilab.android.activities.StatusInfoActivity;
import app.fedilab.android.client.entities.api.Attachment;
import app.fedilab.android.client.entities.api.Poll;
@@ -983,6 +984,11 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>

            if (statusToDeal.edited_at != null) {
                holder.binding.time.setText(context.getString(R.string.full_date_edited, Helper.longDateToString(status.created_at), Helper.longDateToString(status.edited_at)));
                holder.binding.time.setOnClickListener(v -> {
                    Intent historyIntent = new Intent(context, StatusHistoryActivity.class);
                    historyIntent.putExtra(Helper.ARG_STATUS_ID, statusToDeal.id);
                    context.startActivity(historyIntent);
                });
            } else {
                holder.binding.time.setText(Helper.longDateToString(status.created_at));
            }
Loading