fix(instance-info-fragment): readd three dot menu

This commit is contained in:
LucasGGamerM 2023-10-02 12:18:43 -03:00
parent 2e184589e6
commit fb8a38e77b
1 changed files with 45 additions and 0 deletions

View File

@ -1,18 +1,25 @@
package org.joinmastodon.android.fragments.settings; package org.joinmastodon.android.fragments.settings;
import android.app.Activity;
import android.app.Fragment; import android.app.Fragment;
import android.content.Intent;
import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
import android.view.WindowInsets; import android.view.WindowInsets;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.TextView; import android.widget.TextView;
import android.view.Menu;
import android.view.MenuInflater;
import org.joinmastodon.android.R; import org.joinmastodon.android.R;
import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.api.session.AccountSessionManager;
import org.joinmastodon.android.fragments.CustomLocalTimelineFragment;
import org.joinmastodon.android.model.Instance; import org.joinmastodon.android.model.Instance;
import org.joinmastodon.android.ui.SimpleViewHolder; import org.joinmastodon.android.ui.SimpleViewHolder;
import org.joinmastodon.android.ui.tabs.TabLayout; import org.joinmastodon.android.ui.tabs.TabLayout;
@ -25,6 +32,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager2.widget.ViewPager2; import androidx.viewpager2.widget.ViewPager2;
import me.grishka.appkit.Nav;
import me.grishka.appkit.fragments.AppKitFragment; import me.grishka.appkit.fragments.AppKitFragment;
import me.grishka.appkit.utils.V; import me.grishka.appkit.utils.V;
@ -129,6 +137,43 @@ public class SettingsServerFragment extends AppKitFragment{
}; };
} }
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){
if (instance != null) {
inflater.inflate(R.menu.instance_info, menu);
UiUtils.enableOptionsMenuIcons(getActivity(), menu);
menu.findItem(R.id.share).setTitle(R.string.button_share);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item){
int id=item.getItemId();
if(id==R.id.share){
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, Uri.parse(instance.uri).getHost());
startActivity(Intent.createChooser(intent, item.getTitle()));
} else if (id==R.id.open_timeline) {
Bundle args=new Bundle();
args.putString("account", accountID);
args.putString("domain", Uri.parse(instance.uri).getHost());
Nav.go(getActivity(), CustomLocalTimelineFragment.class, args);
} /* else if (id==R.id.moderated_servers) {
Bundle args=new Bundle();
args.putParcelable("instance", Parcels.wrap(instance));
Nav.go(getActivity(), InstanceBlockListFragment.class, args);
} */
return true;
}
@Override
public void onAttach(Activity activity){
super.onAttach(activity);
setHasOptionsMenu(true);
}
@Override @Override
public void onApplyWindowInsets(WindowInsets insets){ public void onApplyWindowInsets(WindowInsets insets){
if(contentView!=null){ if(contentView!=null){