publish drivers for unresolved file page and featured search result item

This commit is contained in:
Akinwale Ariwodola 2020-05-22 03:37:12 +01:00
parent 2231119d36
commit 1d8f0dabe6
7 changed files with 81 additions and 12 deletions

View file

@ -1904,8 +1904,19 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
}
} else if (requestCode == REQUEST_VIDEO_CAPTURE || requestCode == REQUEST_TAKE_PHOTO) {
if (resultCode == RESULT_OK) {
PublishFragment publishFragment = null;
for (Fragment fragment : openNavFragments.values()) {
if (fragment instanceof PublishFragment) {
publishFragment = (PublishFragment) fragment;
break;
}
}
Map<String, Object> params = new HashMap<>();
params.put("directFilePath", cameraOutputFilename);
if (publishFragment != null) {
params.put("suggestedUrl", publishFragment.getSuggestedPublishUrl());
}
openFragment(PublishFormFragment.class, true, NavMenuItem.ID_ITEM_NEW_PUBLISH, params);
}
cameraOutputFilename = null;

View file

@ -82,7 +82,6 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen
private View buttonFollowUnfollow;
private int subCount;
private SolidIconView iconFollowUnfollow;
private View layoutNothingAtLocation;
private View layoutLoadingState;

View file

@ -66,6 +66,7 @@ import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
@ -87,6 +88,7 @@ import io.lbry.browser.model.Claim;
import io.lbry.browser.model.ClaimCacheKey;
import io.lbry.browser.model.Fee;
import io.lbry.browser.model.LbryFile;
import io.lbry.browser.model.NavMenuItem;
import io.lbry.browser.model.Tag;
import io.lbry.browser.model.UrlSuggestion;
import io.lbry.browser.model.lbryinc.Reward;
@ -109,6 +111,8 @@ import io.lbry.browser.tasks.lbryinc.FetchStatCountTask;
import io.lbry.browser.tasks.lbryinc.LogFileViewTask;
import io.lbry.browser.ui.BaseFragment;
import io.lbry.browser.ui.controls.SolidIconView;
import io.lbry.browser.ui.publish.PublishFormFragment;
import io.lbry.browser.ui.publish.PublishFragment;
import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry;
import io.lbry.browser.utils.LbryAnalytics;
@ -145,6 +149,7 @@ public class FileViewFragment extends BaseFragment implements
private long startTimeMillis;
private GetFileTask getFileTask;
private View buttonPublishSomething;
private View layoutLoadingState;
private View layoutNothingAtLocation;
private View layoutDisplayArea;
@ -158,6 +163,7 @@ public class FileViewFragment extends BaseFragment implements
layoutNothingAtLocation = root.findViewById(R.id.container_nothing_at_location);
layoutResolving = root.findViewById(R.id.file_view_loading_container);
layoutDisplayArea = root.findViewById(R.id.file_view_claim_display_area);
buttonPublishSomething = root.findViewById(R.id.nothing_at_location_publish_button);
initUi(root);
@ -282,10 +288,11 @@ public class FileViewFragment extends BaseFragment implements
}
private void renderNothingAtLocation() {
layoutLoadingState.setVisibility(View.VISIBLE);
layoutNothingAtLocation.setVisibility(View.VISIBLE);
layoutResolving.setVisibility(View.GONE);
layoutDisplayArea.setVisibility(View.INVISIBLE);
Helper.setViewVisibility(layoutLoadingState, View.VISIBLE);
Helper.setViewVisibility(layoutNothingAtLocation, View.VISIBLE);
Helper.setViewVisibility(buttonPublishSomething, View.VISIBLE);
Helper.setViewVisibility(layoutResolving, View.GONE);
Helper.setViewVisibility(layoutDisplayArea, View.INVISIBLE);
}
private void checkNewClaimAndUrl(Claim newClaim, String newUrl) {
@ -575,6 +582,21 @@ public class FileViewFragment extends BaseFragment implements
private void initUi(View root) {
initWebView(root);
buttonPublishSomething.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Context context = getContext();
if (!Helper.isNullOrEmpty(currentUrl) && context instanceof MainActivity) {
LbryUri uri = LbryUri.tryParse(currentUrl);
if (uri != null) {
Map<String, Object> params = new HashMap<>();
params.put("suggestedUrl", uri.getStreamName());
((MainActivity) context).openFragment(PublishFragment.class, true, NavMenuItem.ID_ITEM_NEW_PUBLISH, params);
}
}
}
});
root.findViewById(R.id.file_view_title_area).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

View file

@ -18,7 +18,9 @@ import androidx.recyclerview.widget.RecyclerView;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.lbry.browser.MainActivity;
import io.lbry.browser.R;
@ -27,11 +29,13 @@ import io.lbry.browser.listener.DownloadActionListener;
import io.lbry.browser.model.Claim;
import io.lbry.browser.model.ClaimCacheKey;
import io.lbry.browser.model.LbryFile;
import io.lbry.browser.model.NavMenuItem;
import io.lbry.browser.tasks.claim.ClaimListResultHandler;
import io.lbry.browser.tasks.claim.ClaimSearchResultHandler;
import io.lbry.browser.tasks.LighthouseSearchTask;
import io.lbry.browser.tasks.claim.ResolveTask;
import io.lbry.browser.ui.BaseFragment;
import io.lbry.browser.ui.publish.PublishFragment;
import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry;
import io.lbry.browser.utils.LbryAnalytics;
@ -272,13 +276,20 @@ public class SearchFragment extends BaseFragment implements
return;
}
Context context = getContext();
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
if (claim.isUnresolved()) {
// open the publish page
Map<String, Object> params = new HashMap<>();
params.put("suggestedUrl", claim.getName());
activity.openFragment(PublishFragment.class, true, NavMenuItem.ID_ITEM_NEW_PUBLISH, params);
} else if (claim.getName().startsWith("@")) {
((MainActivity) getContext()).openChannelUrl(claim.getPermanentUrl());
activity.openChannelUrl(claim.getPermanentUrl());
} else {
// not a channel
((MainActivity) getContext()).openFileClaim(claim);
activity.openFileClaim(claim);
}
}
}

View file

@ -514,6 +514,10 @@ public class PublishFormFragment extends BaseFragment implements
} else if (params.containsKey("directFilePath")) {
currentFilePath = (String) params.get("directFilePath");
}
if (this.currentClaim == null && params.containsKey("suggestedUrl")) {
Helper.setViewText(inputAddress, (String) params.get("suggestedUrl"));
}
} else {
// shouldn't actually happen
cancelOnFatalCondition(getString(R.string.no_file_found));
@ -843,6 +847,7 @@ public class PublishFormFragment extends BaseFragment implements
}
Context context = getContext();
Helper.setWunderbarValue(null, context);
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
LbryAnalytics.setCurrentScreen(activity, "Channel Form", "ChannelForm");

View file

@ -237,6 +237,7 @@ public class PublishFragment extends BaseFragment implements
public void onResume() {
super.onResume();
Context context = getContext();
Helper.setWunderbarValue(null, context);
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
LbryAnalytics.setCurrentScreen(activity, "Publish", "Publish");
@ -306,6 +307,7 @@ public class PublishFragment extends BaseFragment implements
if (context instanceof MainActivity) {
Map<String, Object> params = new HashMap<>();
params.put("galleryItem", item);
params.put("suggestedUrl", getSuggestedPublishUrl());
((MainActivity) context).openFragment(PublishFormFragment.class, true, NavMenuItem.ID_ITEM_NEW_PUBLISH, params);
}
}
@ -398,6 +400,14 @@ public class PublishFragment extends BaseFragment implements
).show();
}
public String getSuggestedPublishUrl() {
Map<String, Object> params = getParams();
if (params != null && params.containsKey("suggestedUrl")) {
return (String) params.get("suggestedUrl");
}
return null;
}
@Override
public boolean shouldHideGlobalPlayer() {
return true;
@ -414,6 +424,7 @@ public class PublishFragment extends BaseFragment implements
if (context instanceof MainActivity) {
Map<String, Object> params = new HashMap<>();
params.put("directFilePath", filePath);
params.put("suggestedUrl", getSuggestedPublishUrl());
((MainActivity) context).openFragment(PublishFormFragment.class, true, NavMenuItem.ID_ITEM_NEW_PUBLISH, params);
}
}

View file

@ -44,6 +44,7 @@ import io.lbry.browser.tasks.wallet.TransactionListTask;
import io.lbry.browser.tasks.wallet.WalletAddressUnusedTask;
import io.lbry.browser.tasks.wallet.WalletSendTask;
import io.lbry.browser.ui.BaseFragment;
import io.lbry.browser.ui.publish.PublishFragment;
import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry;
import io.lbry.browser.utils.LbryAnalytics;
@ -239,6 +240,15 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W
itemDecoration.setDrawable(ContextCompat.getDrawable(context, R.drawable.thin_divider));
recentTransactionsList.addItemDecoration(itemDecoration);
textEarnMoreTips.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (context instanceof MainActivity) {
((MainActivity) context).openFragment(PublishFragment.class, true, NavMenuItem.ID_ITEM_NEW_PUBLISH);
}
}
});
buttonSignUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {