Skip to content

Commit

Permalink
Issue #360 link to "apps by this dev"
Browse files Browse the repository at this point in the history
  • Loading branch information
yeriomin committed Dec 30, 2017
1 parent 1d688f2 commit 03023fe
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.github.yeriomin.yalpstore.task.ForegroundInstalledAppsTask;
import com.github.yeriomin.yalpstore.view.InstalledAppBadge;
import com.github.yeriomin.yalpstore.view.ListItem;
import com.github.yeriomin.yalpstore.view.UpdatableAppBadge;

public class InstalledAppsActivity extends AppListActivity {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

public class SearchActivity extends EndlessScrollActivity {

public static final String PUB_PREFIX = "pub:";

private String query;

static protected boolean actionIs(Intent intent, String action) {
Expand All @@ -38,7 +40,7 @@ protected void onNewIntent(Intent intent) {
if (null != newQuery && !newQuery.equals(this.query)) {
clearApps();
this.query = newQuery;
setTitle(getString(R.string.activity_title_search, query));
setTitle(getTitleString());
if (looksLikeAPackageId(query)) {
Log.i(getClass().getSimpleName(), query + " looks like a package id");
checkPackageId(query);
Expand All @@ -63,6 +65,13 @@ protected SearchTask getTask() {
return task;
}

private String getTitleString() {
return query.startsWith(PUB_PREFIX)
? getString(R.string.apps_by, query.substring(PUB_PREFIX.length()))
: getString(R.string.activity_title_search, query)
;
}

private String getQuery(Intent intent) {
if (intent.getScheme() != null
&& (intent.getScheme().equals("market")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.github.yeriomin.yalpstore.fragment.details;

import android.app.SearchManager;
import android.content.Intent;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
Expand All @@ -9,6 +12,7 @@
import com.github.yeriomin.yalpstore.ClusterActivity;
import com.github.yeriomin.yalpstore.DetailsActivity;
import com.github.yeriomin.yalpstore.R;
import com.github.yeriomin.yalpstore.SearchActivity;
import com.github.yeriomin.yalpstore.model.App;

public class AppLists extends Abstract {
Expand All @@ -20,9 +24,16 @@ public AppLists(DetailsActivity activity, App app) {
@Override
public void draw() {
LinearLayout relatedLinksLayout = (LinearLayout) activity.findViewById(R.id.related_links);
boolean developerLinkFound = false;
for (final String label: app.getRelatedLinks().keySet()) {
relatedLinksLayout.setVisibility(View.VISIBLE);
relatedLinksLayout.addView(buildLinkView(label, app.getRelatedLinks().get(label)));
if (label.contains(app.getDeveloperName())) {
developerLinkFound = true;
}
}
if (!developerLinkFound && !TextUtils.isEmpty(app.getDeveloperName())) {
addAppsByThisDeveloper();
}
}

Expand All @@ -41,4 +52,20 @@ public void onClick(View v) {
});
return linkView;
}

private void addAppsByThisDeveloper() {
TextView textView = activity.findViewById(R.id.apps_by_same_developer);
textView.setText(activity.getString(R.string.apps_by, app.getDeveloperName()));
textView.setVisibility(View.VISIBLE);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(activity, SearchActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setAction(Intent.ACTION_SEARCH);
intent.putExtra(SearchManager.QUERY, SearchActivity.PUB_PREFIX + app.getDeveloperName());
activity.startActivity(intent);
}
});
}
}
12 changes: 12 additions & 0 deletions app/src/main/res/layout/details_activity_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,18 @@

</LinearLayout>

<TextView
android:id="@+id/apps_by_same_developer"
android:focusable="true"
android:drawableLeft="@drawable/ic_chevron_right"
android:drawableStart="@drawable/ic_chevron_right"
android:textSize="20sp"
android:gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="6dip"
android:visibility="gone" />

<TextView
android:id="@+id/to_play_store"
android:focusable="true"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,5 @@
<string name="flag_impersonation_copycat">Плагиат и присвоение чужого имени</string>
<string name="flagging_title">Пожаловаться</string>
<string name="content_flagged">Возражение отправлено.</string>
<string name="apps_by">"Приложения от %1$s"</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,5 @@
<string name="flag_impersonation_copycat">Copycat or impersonation</string>
<string name="flagging_title">Flag as inappropriate</string>
<string name="content_flagged">Objection submitted.</string>
<string name="apps_by">Apps by %1$s</string>
</resources>

0 comments on commit 03023fe

Please sign in to comment.