Adding referrer information when launching market intent
Bug: 72331091 Change-Id: I75ed764fd9964b58de97c287b8a26d24a0caa3fc
This commit is contained in:
parent
08af6b7984
commit
67e75e20cc
|
@ -70,7 +70,7 @@ public class InfoDropTarget extends UninstallDropTarget {
|
||||||
Rect sourceBounds, Bundle opts) {
|
Rect sourceBounds, Bundle opts) {
|
||||||
if (info instanceof PromiseAppInfo) {
|
if (info instanceof PromiseAppInfo) {
|
||||||
PromiseAppInfo promiseAppInfo = (PromiseAppInfo) info;
|
PromiseAppInfo promiseAppInfo = (PromiseAppInfo) info;
|
||||||
context.startActivity(promiseAppInfo.getMarketIntent());
|
context.startActivity(promiseAppInfo.getMarketIntent(context));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ComponentName componentName = null;
|
ComponentName componentName = null;
|
||||||
|
|
|
@ -1739,7 +1739,7 @@ public class Launcher extends BaseActivity
|
||||||
|
|
||||||
private void startMarketIntentForPackage(View v, String packageName) {
|
private void startMarketIntentForPackage(View v, String packageName) {
|
||||||
ItemInfo item = (ItemInfo) v.getTag();
|
ItemInfo item = (ItemInfo) v.getTag();
|
||||||
Intent intent = PackageManagerHelper.getMarketIntent(packageName);
|
Intent intent = new PackageManagerHelper(v.getContext()).getMarketIntent(packageName);
|
||||||
startActivitySafely(v, intent, item);
|
startActivitySafely(v, intent, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1804,7 +1804,7 @@ public class Launcher extends BaseActivity
|
||||||
Intent intent;
|
Intent intent;
|
||||||
if (item instanceof PromiseAppInfo) {
|
if (item instanceof PromiseAppInfo) {
|
||||||
PromiseAppInfo promiseAppInfo = (PromiseAppInfo) item;
|
PromiseAppInfo promiseAppInfo = (PromiseAppInfo) item;
|
||||||
intent = promiseAppInfo.getMarketIntent();
|
intent = promiseAppInfo.getMarketIntent(this);
|
||||||
} else {
|
} else {
|
||||||
intent = item.getIntent();
|
intent = item.getIntent();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package com.android.launcher3;
|
package com.android.launcher3;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
|
@ -46,7 +47,7 @@ public class PromiseAppInfo extends AppInfo {
|
||||||
return shortcut;
|
return shortcut;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Intent getMarketIntent() {
|
public Intent getMarketIntent(Context context) {
|
||||||
return PackageManagerHelper.getMarketIntent(componentName.getPackageName());
|
return new PackageManagerHelper(context).getMarketIntent(componentName.getPackageName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,8 +115,8 @@ public abstract class SystemShortcut extends ItemInfo {
|
||||||
|
|
||||||
public View.OnClickListener createOnClickListener(Launcher launcher, ItemInfo itemInfo) {
|
public View.OnClickListener createOnClickListener(Launcher launcher, ItemInfo itemInfo) {
|
||||||
return view -> {
|
return view -> {
|
||||||
Intent intent = PackageManagerHelper.getMarketIntent(itemInfo
|
Intent intent = new PackageManagerHelper(view.getContext()).getMarketIntent(
|
||||||
.getTargetComponent().getPackageName());
|
itemInfo.getTargetComponent().getPackageName());
|
||||||
launcher.startActivitySafely(view, intent, itemInfo);
|
launcher.startActivitySafely(view, intent, itemInfo);
|
||||||
AbstractFloatingView.closeAllOpenViews(launcher);
|
AbstractFloatingView.closeAllOpenViews(launcher);
|
||||||
};
|
};
|
||||||
|
|
|
@ -143,13 +143,15 @@ public class PackageManagerHelper {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Intent getMarketIntent(String packageName) {
|
public Intent getMarketIntent(String packageName) {
|
||||||
return new Intent(Intent.ACTION_VIEW)
|
return new Intent(Intent.ACTION_VIEW)
|
||||||
.setData(new Uri.Builder()
|
.setData(new Uri.Builder()
|
||||||
.scheme("market")
|
.scheme("market")
|
||||||
.authority("details")
|
.authority("details")
|
||||||
.appendQueryParameter("id", packageName)
|
.appendQueryParameter("id", packageName)
|
||||||
.build());
|
.build())
|
||||||
|
.putExtra(Intent.EXTRA_REFERRER, new Uri.Builder().scheme("android-app")
|
||||||
|
.authority(mContext.getPackageName()).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue