diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/InstanceInfoActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/InstanceInfoActivity.java index e4158636..b8d48036 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/InstanceInfoActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/InstanceInfoActivity.java @@ -50,9 +50,12 @@ import io.noties.markwon.MarkwonConfiguration; import io.noties.markwon.MarkwonPlugin; import io.noties.markwon.core.MarkwonTheme; import io.noties.markwon.recycler.MarkwonAdapter; +import retrofit2.Retrofit; public class InstanceInfoActivity extends BaseActivity { + public static final String INSTANCE_INFO_DOMAIN = "instance_info_domain"; + @Inject @Named("default") SharedPreferences mSharedPreferences; @@ -93,6 +96,8 @@ public class InstanceInfoActivity extends BaseActivity { private MarkwonAdapter mMarkwonAdapter; private Markwon mPostDetailMarkwon; private AdminRecyclerViewAdapter mAdminAdapter; + private Retrofit mRetrofit; + private String mInstanceDomain; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { @@ -105,6 +110,21 @@ public class InstanceInfoActivity extends BaseActivity { setContentView(view); setSupportActionBar(mInstanceInfoActivityViewBinding.toolbarInstanceInfoActivity); + if (savedInstanceState != null) { + mInstanceDomain = savedInstanceState.getString(INSTANCE_INFO_DOMAIN); + } else { + mInstanceDomain = getIntent().getStringExtra(INSTANCE_INFO_DOMAIN); + } + + if (mInstanceDomain == null) { + mRetrofit = mRetorifitHolder.getRetrofit(); + } else { + String originalBaseUrl = mRetorifitHolder.getBaseURL(); + mRetorifitHolder.setBaseURL("https://" + mInstanceDomain); + mRetrofit = mRetorifitHolder.getRetrofit(); + mRetorifitHolder.setBaseURL(originalBaseUrl); + } + setUpBindings(); applyCustomTheme(); @@ -169,7 +189,7 @@ public class InstanceInfoActivity extends BaseActivity { } private void fetchInstanceInfo() { - FetchSiteInfo.fetchSiteInfo(mRetorifitHolder.getRetrofit(), null, new FetchSiteInfo.FetchSiteInfoListener() { + FetchSiteInfo.fetchSiteInfo(mRetrofit, null, new FetchSiteInfo.FetchSiteInfoListener() { @Override public void onFetchSiteInfoSuccess(SiteInfo siteInfo, MyUserInfo myUserInfo) { mLoadingConstraintLayout.setVisibility(View.GONE); @@ -264,4 +284,16 @@ public class InstanceInfoActivity extends BaseActivity { } return false; } + + @Override + protected void onSaveInstanceState(@NonNull Bundle outState) { + super.onSaveInstanceState(outState); + outState.putString(INSTANCE_INFO_DOMAIN, mInstanceDomain); + } + + @Override + protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) { + super.onRestoreInstanceState(savedInstanceState); + mInstanceDomain = savedInstanceState.getString(INSTANCE_INFO_DOMAIN); + } } diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewSubredditDetailActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewSubredditDetailActivity.java index 98d8d1e8..02fe4f1f 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewSubredditDetailActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewSubredditDetailActivity.java @@ -1321,6 +1321,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp } else if (itemId == R.id.action_add_to_home_screen_view_subreddit_detail_activity) { Bitmap icon = subredditIconBitmap == null ? decodeResource(getResources(), R.drawable.subreddit_default_icon) : subredditIconBitmap; return ShortcutManager.requestPinShortcut(this, qualifiedName, icon); + } else if (itemId == R.id.action_view_instance_view_subreddit_detail_activity) { + String instance = communityData.getActorId().split("/")[2]; + Intent intent = new Intent(this,InstanceInfoActivity.class); + intent.putExtra(InstanceInfoActivity.INSTANCE_INFO_DOMAIN, instance); + startActivity(intent); } return false; } diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewUserDetailActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewUserDetailActivity.java index 10e0fb6f..33abdd9f 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewUserDetailActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewUserDetailActivity.java @@ -1323,6 +1323,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele Toast.makeText(ViewUserDetailActivity.this, R.string.unblock_user_failed, Toast.LENGTH_SHORT).show(); } }); + } else if (itemId == R.id.action_view_instance_view_user_detail_activity) { + String instance = mUserData.getActorId().split("/")[2]; + Intent intent = new Intent(this, InstanceInfoActivity.class); + intent.putExtra(InstanceInfoActivity.INSTANCE_INFO_DOMAIN, instance); + startActivity(intent); } return false; } diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/adapters/BlockedInstancesRecyclerViewAdapter.java b/app/src/main/java/eu/toldi/infinityforlemmy/adapters/BlockedInstancesRecyclerViewAdapter.java index 6ed34d56..ba1f7564 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/adapters/BlockedInstancesRecyclerViewAdapter.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/adapters/BlockedInstancesRecyclerViewAdapter.java @@ -1,5 +1,7 @@ package eu.toldi.infinityforlemmy.adapters; +import android.app.Activity; +import android.content.Intent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -20,6 +22,7 @@ import butterknife.ButterKnife; import eu.toldi.infinityforlemmy.R; import eu.toldi.infinityforlemmy.RedditDataRoomDatabase; import eu.toldi.infinityforlemmy.activities.BaseActivity; +import eu.toldi.infinityforlemmy.activities.InstanceInfoActivity; import eu.toldi.infinityforlemmy.blockedinstances.BlockedInstanceData; import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper; import jp.wasabeef.glide.transformations.RoundedCornersTransformation; @@ -145,9 +148,16 @@ public class BlockedInstancesRecyclerViewAdapter extends RecyclerView.Adapter { + if (mBlockedInstanceData != null) { + BlockedInstanceData instanceData = mBlockedInstanceData.get(viewHolder.getBindingAdapterPosition()); + Intent intent = new Intent(mActivity, InstanceInfoActivity.class); + intent.putExtra(InstanceInfoActivity.INSTANCE_INFO_DOMAIN, instanceData.getDomain()); + mActivity.startActivity(intent); + } + }); + if (iconUrl == null || iconUrl.equals("")) { ((InstanceViewHolder) viewHolder).iconGifImageView.setVisibility(View.GONE); diff --git a/app/src/main/res/menu/view_subreddit_detail_activity.xml b/app/src/main/res/menu/view_subreddit_detail_activity.xml index 3c8e0f8c..829704c1 100644 --- a/app/src/main/res/menu/view_subreddit_detail_activity.xml +++ b/app/src/main/res/menu/view_subreddit_detail_activity.xml @@ -60,9 +60,9 @@ app:showAsAction="never" /> + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 48f48266..edaba9a8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1325,4 +1325,5 @@ New Comments Instances No blocked instances + View Instance \ No newline at end of file