use of nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp in project Gadgetbridge by Freeyourgadget.
the class PBWInstallHandler method validateInstallation.
@Override
public void validateInstallation(InstallActivity installActivity, GBDevice device) {
if (device.isBusy()) {
installActivity.setInfoText(device.getBusyTask());
installActivity.setInstallEnabled(false);
return;
}
if (device.getType() != DeviceType.PEBBLE || !device.isConnected()) {
installActivity.setInfoText("Element cannot be installed");
installActivity.setInstallEnabled(false);
return;
}
String platformName = PebbleUtils.getPlatformName(device.getModel());
try {
mPBWReader = new PBWReader(mUri, mContext, platformName);
} catch (FileNotFoundException e) {
installActivity.setInfoText("file not found");
installActivity.setInstallEnabled(false);
return;
} catch (IOException e) {
installActivity.setInfoText("error reading file");
installActivity.setInstallEnabled(false);
return;
}
if (!mPBWReader.isValid()) {
installActivity.setInfoText("pbw/pbz is broken or incompatible with your Hardware or Firmware.");
installActivity.setInstallEnabled(false);
return;
}
GenericItem installItem = new GenericItem();
// FIXME: do not set twice
installItem.setIcon(R.drawable.ic_watchapp);
if (mPBWReader.isFirmware()) {
installItem.setIcon(R.drawable.ic_firmware);
String hwRevision = mPBWReader.getHWRevision();
if (hwRevision != null && hwRevision.equals(device.getModel())) {
installItem.setName(mContext.getString(R.string.pbw_installhandler_pebble_firmware, ""));
installItem.setDetails(mContext.getString(R.string.pbwinstallhandler_correct_hw_revision));
installActivity.setInfoText(mContext.getString(R.string.firmware_install_warning, hwRevision));
installActivity.setInstallEnabled(true);
} else {
if (hwRevision != null) {
installItem.setName(mContext.getString(R.string.pbw_installhandler_pebble_firmware, hwRevision));
installItem.setDetails(mContext.getString(R.string.pbwinstallhandler_incorrect_hw_revision));
}
installActivity.setInfoText(mContext.getString(R.string.pbw_install_handler_hw_revision_mismatch));
installActivity.setInstallEnabled(false);
}
} else {
GBDeviceApp app = mPBWReader.getGBDeviceApp();
if (app != null) {
installItem.setName(app.getName());
installItem.setDetails(mContext.getString(R.string.pbwinstallhandler_app_item, app.getCreator(), app.getVersion()));
int drawable;
if (mPBWReader.isLanguage()) {
drawable = R.drawable.ic_languagepack;
} else {
switch(app.getType()) {
case WATCHFACE:
drawable = R.drawable.ic_watchface;
break;
case APP_ACTIVITYTRACKER:
drawable = R.drawable.ic_activitytracker;
break;
default:
drawable = R.drawable.ic_watchapp;
}
}
installItem.setIcon(drawable);
installActivity.setInfoText(mContext.getString(R.string.app_install_info, app.getName(), app.getVersion(), app.getCreator()));
installActivity.setInstallEnabled(true);
} else {
installActivity.setInfoText(mContext.getString(R.string.pbw_install_handler_unable_to_install, mUri.getPath()));
installActivity.setInstallEnabled(false);
}
}
if (installItem.getName() != null) {
installActivity.setInstallItem(installItem);
}
}
use of nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp in project Gadgetbridge by Freeyourgadget.
the class AbstractAppManagerFragment method refreshListFromDevice.
private void refreshListFromDevice(Intent intent) {
appList.clear();
int appCount = intent.getIntExtra("app_count", 0);
for (int i = 0; i < appCount; i++) {
String appName = intent.getStringExtra("app_name" + i);
String appCreator = intent.getStringExtra("app_creator" + i);
UUID uuid = UUID.fromString(intent.getStringExtra("app_uuid" + i));
GBDeviceApp.Type appType = GBDeviceApp.Type.values()[intent.getIntExtra("app_type" + i, 0)];
GBDeviceApp app = new GBDeviceApp(uuid, appName, appCreator, "", appType);
app.setOnDevice(true);
if (filterApp(app)) {
appList.add(app);
}
}
}
use of nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp in project Gadgetbridge by Freeyourgadget.
the class AbstractAppManagerFragment method openPopupMenu.
public boolean openPopupMenu(View view, GBDeviceApp deviceApp) {
PopupMenu popupMenu = new PopupMenu(getContext(), view);
popupMenu.getMenuInflater().inflate(R.menu.appmanager_context, popupMenu.getMenu());
Menu menu = popupMenu.getMenu();
final GBDeviceApp selectedApp = deviceApp;
if (!selectedApp.isInCache()) {
menu.removeItem(R.id.appmanager_app_edit);
menu.removeItem(R.id.appmanager_app_reinstall);
menu.removeItem(R.id.appmanager_app_delete_cache);
}
if (!PebbleProtocol.UUID_PEBBLE_HEALTH.equals(selectedApp.getUUID())) {
menu.removeItem(R.id.appmanager_health_activate);
menu.removeItem(R.id.appmanager_health_deactivate);
}
if (!PebbleProtocol.UUID_WORKOUT.equals(selectedApp.getUUID())) {
menu.removeItem(R.id.appmanager_hrm_activate);
menu.removeItem(R.id.appmanager_hrm_deactivate);
}
if (!PebbleProtocol.UUID_WEATHER.equals(selectedApp.getUUID())) {
menu.removeItem(R.id.appmanager_weather_activate);
menu.removeItem(R.id.appmanager_weather_deactivate);
menu.removeItem(R.id.appmanager_weather_install_provider);
}
if (selectedApp.getType() == GBDeviceApp.Type.APP_SYSTEM || selectedApp.getType() == GBDeviceApp.Type.WATCHFACE_SYSTEM) {
menu.removeItem(R.id.appmanager_app_delete);
}
if (!selectedApp.isConfigurable()) {
menu.removeItem(R.id.appmanager_app_configure);
}
if (PebbleProtocol.UUID_WEATHER.equals(selectedApp.getUUID())) {
PackageManager pm = getActivity().getPackageManager();
try {
pm.getPackageInfo("ru.gelin.android.weather.notification", PackageManager.GET_ACTIVITIES);
menu.removeItem(R.id.appmanager_weather_install_provider);
} catch (PackageManager.NameNotFoundException e) {
menu.removeItem(R.id.appmanager_weather_activate);
menu.removeItem(R.id.appmanager_weather_deactivate);
}
}
if ((mGBDevice.getType() != DeviceType.FOSSILQHYBRID) || (selectedApp.getType() != GBDeviceApp.Type.WATCHFACE)) {
menu.removeItem(R.id.appmanager_app_edit);
}
if (mGBDevice.getType() == DeviceType.PEBBLE) {
switch(selectedApp.getType()) {
case WATCHFACE:
case APP_GENERIC:
case APP_ACTIVITYTRACKER:
break;
default:
menu.removeItem(R.id.appmanager_app_openinstore);
}
} else {
menu.removeItem(R.id.appmanager_app_openinstore);
}
// menu.setHeaderTitle(selectedApp.getName());
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
return onContextItemSelected(item, selectedApp);
}
});
popupMenu.show();
return true;
}
use of nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp in project Gadgetbridge by Freeyourgadget.
the class AppManagerFragmentInstalledWatchfaces method getSystemAppsInCategory.
@Override
protected List<GBDeviceApp> getSystemAppsInCategory() {
List<GBDeviceApp> systemWatchfaces = new ArrayList<>();
if (mGBDevice.getType() != DeviceType.PEBBLE) {
return systemWatchfaces;
}
systemWatchfaces.add(new GBDeviceApp(UUID.fromString("8f3c8686-31a1-4f5f-91f5-01600c9bdc59"), "Tic Toc (System)", "Pebble Inc.", "", GBDeviceApp.Type.WATCHFACE_SYSTEM));
systemWatchfaces.add(new GBDeviceApp(UUID.fromString("3af858c3-16cb-4561-91e7-f1ad2df8725f"), "Kickstart (System)", "Pebble Inc.", "", GBDeviceApp.Type.WATCHFACE_SYSTEM));
return systemWatchfaces;
}
Aggregations