Commit d5a5f087 authored by Thomas's avatar Thomas
Browse files

Instance directory

parent e03c02cc
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -249,6 +249,11 @@
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:label="@string/Suggestions"
            android:theme="@style/AppThemeBar" />
        <activity
            android:name=".activities.DirectoryActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:label="@string/Directory"
            android:theme="@style/AppThemeBar" />
        <activity
            android:name=".activities.PartnerShipActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
+4 −0
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@ import app.fedilab.android.activities.BaseActivity;
import app.fedilab.android.activities.CacheActivity;
import app.fedilab.android.activities.ComposeActivity;
import app.fedilab.android.activities.ContextActivity;
import app.fedilab.android.activities.DirectoryActivity;
import app.fedilab.android.activities.DraftActivity;
import app.fedilab.android.activities.FilterActivity;
import app.fedilab.android.activities.FollowRequestActivity;
@@ -409,6 +410,9 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
            } else if (id == R.id.nav_suggestions) {
                Intent intent = new Intent(this, SuggestionActivity.class);
                startActivity(intent);
            } else if (id == R.id.nav_directory) {
                Intent intent = new Intent(this, DirectoryActivity.class);
                startActivity(intent);
            } else if (id == R.id.nav_cache) {
                Intent intent = new Intent(BaseMainActivity.this, CacheActivity.class);
                startActivity(intent);
+83 −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 static app.fedilab.android.client.entities.app.Timeline.TimeLineEnum.ACCOUNT_DIRECTORY;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

import org.jetbrains.annotations.NotNull;

import app.fedilab.android.R;
import app.fedilab.android.databinding.ActivityDirectoryBinding;
import app.fedilab.android.helper.Helper;
import app.fedilab.android.ui.fragment.timeline.FragmentMastodonAccount;


public class DirectoryActivity extends BaseBarActivity {

    private static boolean local = false;
    private static String order = "active";
    private FragmentMastodonAccount fragmentMastodonAccount;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        ActivityDirectoryBinding binding = ActivityDirectoryBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        if (getSupportActionBar() != null) {
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
        fragmentMastodonAccount = new FragmentMastodonAccount();
        Bundle bundle = new Bundle();
        bundle.putBoolean(Helper.ARG_DIRECTORY_LOCAL, local);
        bundle.putString(Helper.ARG_DIRECTORY_ORDER, order);
        bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, ACCOUNT_DIRECTORY);
        Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_directory, fragmentMastodonAccount, bundle, null, null);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_directory, menu);
        if (order.equals("active")) {
            menu.findItem(R.id.order_active).setChecked(true);
        } else {
            menu.findItem(R.id.order_new).setChecked(true);
        }
        menu.findItem(R.id.action_local).setChecked(local);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(@NotNull MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            finish();
            return true;
        } else if (item.getItemId() == R.id.action_local) {
            item.setChecked(!item.isChecked());
            local = item.isChecked();
        } else if (item.getItemId() == R.id.order_active) {
            order = "active";
        } else if (item.getItemId() == R.id.order_new) {
            order = "new";
        }
        recreate();
        return super.onOptionsItemSelected(item);
    }

}
+11 −0
Original line number Diff line number Diff line
@@ -417,4 +417,15 @@ public interface MastodonAccountsService {
            @Header("Authorization") String token,
            @Path("account_id") String account_id
    );


    //Get user suggestions
    @GET("directory")
    Call<List<Account>> getDirectory(
            @Header("Authorization") String token,
            @Query("offset") Integer offset,
            @Query("limit") Integer limit,
            @Query("order") String order,
            @Query("local") Boolean local
    );
}
+2 −0
Original line number Diff line number Diff line
@@ -382,6 +382,8 @@ public class Timeline {
        TREND_MESSAGE("TREND_MESSAGE"),
        @SerializedName("ACCOUNT_SUGGESTION")
        ACCOUNT_SUGGESTION("ACCOUNT_SUGGESTION"),
        @SerializedName("ACCOUNT_DIRECTORY")
        ACCOUNT_DIRECTORY("ACCOUNT_DIRECTORY"),
        @SerializedName("PUBLIC_TREND_MESSAGE")
        TREND_MESSAGE_PUBLIC("TREND_MESSAGE_PUBLIC"),
        @SerializedName("STATUS_HISTORY")
Loading