Fix Pebble appstore search and use RebbleAppStoreActivity if possible

This commit is contained in:
Arjan Schrijver
2025-12-25 14:45:08 +01:00
committed by Arjan Schrijver
parent 5a6bdace66
commit c3c99f77ba
2 changed files with 16 additions and 8 deletions
@@ -657,10 +657,17 @@ public abstract class AbstractAppManagerFragment extends Fragment {
startActivity(startIntent);
return true;
} else if (itemId == R.id.appmanager_app_openinstore) {
final String url = "https://apps.rebble.io/en_US/search/" + ((selectedApp.getType() == GBDeviceApp.Type.WATCHFACE) ? "watchfaces" : "watchapps") + "/1/?native=true&?query=" + Uri.encode(selectedApp.getName());
final String url = "https://apps.rebble.io/en_US/search/" + ((selectedApp.getType() == GBDeviceApp.Type.WATCHFACE) ? "watchfaces" : "watchapps") + "/1/?native=true&query=" + Uri.encode(selectedApp.getUUID().toString());
if (WebViewSingleton.getInstance().ensureInternetHelperBound()) {
final Intent startIntent = new Intent(getContext().getApplicationContext(), RebbleAppStoreActivity.class);
startIntent.putExtra(DeviceService.EXTRA_URI, url);
startIntent.putExtra(GBDevice.EXTRA_DEVICE, mGBDevice);
startActivity(startIntent);
} else {
final Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
}
return true;
} else if (itemId == R.id.appmanager_app_edit) {
final Intent editWatchfaceIntent = new Intent(getContext(), watchfaceDesignerActivity);
@@ -40,6 +40,7 @@ import nodomain.freeyourgadget.gadgetbridge.R
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractGBActivity
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice
import nodomain.freeyourgadget.gadgetbridge.model.DeviceService
import nodomain.freeyourgadget.gadgetbridge.util.Capsule
import nodomain.freeyourgadget.gadgetbridge.util.GB
import nodomain.freeyourgadget.internethelper.aidl.http.HttpGetRequest
@@ -64,6 +65,7 @@ class RebbleAppStoreActivity : AbstractGBActivity() {
val LOG: Logger = LoggerFactory.getLogger(RebbleAppStoreActivity::class.java)
private var mGBDevice: GBDevice? = null
private var webView: WebView? = null
private var url = "https://apps.rebble.io/en_US/watchfaces"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -81,6 +83,7 @@ class RebbleAppStoreActivity : AbstractGBActivity() {
val extras = intent.extras
if (extras != null) {
mGBDevice = extras.getParcelable(GBDevice.EXTRA_DEVICE)
url = extras.getString(DeviceService.EXTRA_URI, url)
}
requireNotNull(mGBDevice) { "Must provide a device when invoking this activity" }
initViews()
@@ -161,9 +164,9 @@ class RebbleAppStoreActivity : AbstractGBActivity() {
}
private fun downloadInstallWatchappById(storeId: String) {
val url = "https://appstore-api.rebble.io/api/v1/apps/id/$storeId"
val appUrl = "https://appstore-api.rebble.io/api/v1/apps/id/$storeId"
val httpHeaders = HttpHeaders()
val httpGetRequest = HttpGetRequest(url, httpHeaders)
val httpGetRequest = HttpGetRequest(appUrl, httpHeaders)
iHttpService!!.get(httpGetRequest, object : IHttpCallback.Stub() {
override fun onResponse(response: HttpResponse) {
val contentType = response.headers["content-type"]?.split(";")?.get(0)
@@ -195,8 +198,6 @@ class RebbleAppStoreActivity : AbstractGBActivity() {
settings.loadWithOverviewMode = true
settings.useWideViewPort = true
val url = "https://apps.rebble.io/en_US/watchfaces"
webView!!.webViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(
wv: WebView,