mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-01 14:32:54 +01:00
Xiaomi: Keep only watchface tab in app management
This commit is contained in:
parent
a895a6aae7
commit
1b645f44d7
@ -45,6 +45,7 @@ import nodomain.freeyourgadget.gadgetbridge.R;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractFragmentPagerAdapter;
|
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractFragmentPagerAdapter;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractGBFragmentActivity;
|
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractGBFragmentActivity;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.FwAppInstallerActivity;
|
import nodomain.freeyourgadget.gadgetbridge.activities.FwAppInstallerActivity;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
||||||
|
|
||||||
@ -56,6 +57,8 @@ public class AppManagerActivity extends AbstractGBFragmentActivity {
|
|||||||
|
|
||||||
private GBDevice mGBDevice = null;
|
private GBDevice mGBDevice = null;
|
||||||
|
|
||||||
|
private List<String> enabledTabsList;
|
||||||
|
|
||||||
public GBDevice getGBDevice() {
|
public GBDevice getGBDevice() {
|
||||||
return mGBDevice;
|
return mGBDevice;
|
||||||
}
|
}
|
||||||
@ -75,6 +78,20 @@ public class AppManagerActivity extends AbstractGBFragmentActivity {
|
|||||||
throw new IllegalArgumentException("Must provide a device when invoking this activity");
|
throw new IllegalArgumentException("Must provide a device when invoking this activity");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final DeviceCoordinator coordinator = mGBDevice.getDeviceCoordinator();
|
||||||
|
|
||||||
|
enabledTabsList = new ArrayList<>();
|
||||||
|
|
||||||
|
if (coordinator.supportsCachedAppManagement(mGBDevice)) {
|
||||||
|
enabledTabsList.add("cache");
|
||||||
|
}
|
||||||
|
if (coordinator.supportsInstalledAppManagement(mGBDevice)) {
|
||||||
|
enabledTabsList.add("apps");
|
||||||
|
}
|
||||||
|
if (coordinator.supportsWatchfaceManagement(mGBDevice)) {
|
||||||
|
enabledTabsList.add("watchfaces");
|
||||||
|
}
|
||||||
|
|
||||||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||||
assert fab != null;
|
assert fab != null;
|
||||||
fab.setOnClickListener(new View.OnClickListener() {
|
fab.setOnClickListener(new View.OnClickListener() {
|
||||||
@ -114,12 +131,12 @@ public class AppManagerActivity extends AbstractGBFragmentActivity {
|
|||||||
@Override
|
@Override
|
||||||
public Fragment getItem(int position) {
|
public Fragment getItem(int position) {
|
||||||
// getItem is called to instantiate the fragment for the given page.
|
// getItem is called to instantiate the fragment for the given page.
|
||||||
switch (position) {
|
switch (enabledTabsList.get(position)) {
|
||||||
case 0:
|
case "cache":
|
||||||
return new AppManagerFragmentCache();
|
return new AppManagerFragmentCache();
|
||||||
case 1:
|
case "apps":
|
||||||
return new AppManagerFragmentInstalledApps();
|
return new AppManagerFragmentInstalledApps();
|
||||||
case 2:
|
case "watchfaces":
|
||||||
return new AppManagerFragmentInstalledWatchfaces();
|
return new AppManagerFragmentInstalledWatchfaces();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -127,19 +144,18 @@ public class AppManagerActivity extends AbstractGBFragmentActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return 3;
|
return enabledTabsList.toArray().length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getPageTitle(int position) {
|
public CharSequence getPageTitle(int position) {
|
||||||
switch (position) {
|
switch (enabledTabsList.get(position)) {
|
||||||
case 0:
|
case "cache":
|
||||||
return getString(R.string.appmanager_cached_watchapps_watchfaces);
|
return getString(R.string.appmanager_cached_watchapps_watchfaces);
|
||||||
case 1:
|
case "apps":
|
||||||
return getString(R.string.appmanager_installed_watchapps);
|
return getString(R.string.appmanager_installed_watchapps);
|
||||||
case 2:
|
case "watchfaces":
|
||||||
return getString(R.string.appmanager_installed_watchfaces);
|
return getString(R.string.appmanager_installed_watchfaces);
|
||||||
case 3:
|
|
||||||
}
|
}
|
||||||
return super.getPageTitle(position);
|
return super.getPageTitle(position);
|
||||||
}
|
}
|
||||||
|
@ -314,6 +314,27 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsCachedAppManagement(final GBDevice device) {
|
||||||
|
try {
|
||||||
|
return supportsAppsManagement(device) && getAppCacheDir() != null;
|
||||||
|
} catch (final Exception e) {
|
||||||
|
// we failed, but still tried, so it's supported..
|
||||||
|
LOG.error("Failed to get app cache dir", e);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsInstalledAppManagement(final GBDevice device) {
|
||||||
|
return supportsAppsManagement(device);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsWatchfaceManagement(final GBDevice device) {
|
||||||
|
return supportsAppsManagement(device);
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Activity> getAppsManagementActivity() {
|
public Class<? extends Activity> getAppsManagementActivity() {
|
||||||
|
@ -353,6 +353,10 @@ public interface DeviceCoordinator {
|
|||||||
*/
|
*/
|
||||||
boolean supportsAppsManagement(GBDevice device);
|
boolean supportsAppsManagement(GBDevice device);
|
||||||
|
|
||||||
|
boolean supportsCachedAppManagement(GBDevice device);
|
||||||
|
boolean supportsInstalledAppManagement(GBDevice device);
|
||||||
|
boolean supportsWatchfaceManagement(GBDevice device);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Activity class that will be used to manage device apps.
|
* Returns the Activity class that will be used to manage device apps.
|
||||||
*
|
*
|
||||||
|
@ -134,6 +134,21 @@ public abstract class XiaomiCoordinator extends AbstractBLEDeviceCoordinator {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsCachedAppManagement(GBDevice device) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsInstalledAppManagement(GBDevice device) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsWatchfaceManagement(GBDevice device) {
|
||||||
|
return supportsAppsManagement(device);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Activity> getAppsManagementActivity() {
|
public Class<? extends Activity> getAppsManagementActivity() {
|
||||||
return AppManagerActivity.class;
|
return AppManagerActivity.class;
|
||||||
|
Loading…
Reference in New Issue
Block a user