play around with fragments
This commit is contained in:
parent
1d6a697000
commit
3418543c31
|
@ -40,7 +40,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.PebbleUtils;
|
|||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
|
||||
|
||||
public class AbstractAppManagerFragment extends Fragment {
|
||||
public abstract class AbstractAppManagerFragment extends Fragment {
|
||||
public static final String ACTION_REFRESH_APPLIST
|
||||
= "nodomain.freeyourgadget.gadgetbridge.appmanager.action.refresh_applist";
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AbstractAppManagerFragment.class);
|
||||
|
@ -83,12 +83,12 @@ public class AbstractAppManagerFragment extends Fragment {
|
|||
|
||||
private Prefs prefs;
|
||||
|
||||
private final List<GBDeviceApp> appList = new ArrayList<>();
|
||||
protected final List<GBDeviceApp> appList = new ArrayList<>();
|
||||
private GBDeviceAppAdapter mGBDeviceAppAdapter;
|
||||
private GBDeviceApp selectedApp = null;
|
||||
private GBDevice mGBDevice = null;
|
||||
|
||||
private List<GBDeviceApp> getSystemApps() {
|
||||
protected List<GBDeviceApp> getSystemApps() {
|
||||
List<GBDeviceApp> systemApps = new ArrayList<>();
|
||||
if (prefs.getBoolean("pebble_force_untested", false)) {
|
||||
systemApps.add(new GBDeviceApp(UUID.fromString("4dab81a6-d2fc-458a-992c-7a1f3b96a970"), "Sports (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM));
|
||||
|
@ -101,7 +101,13 @@ public class AbstractAppManagerFragment extends Fragment {
|
|||
return systemApps;
|
||||
}
|
||||
|
||||
private List<GBDeviceApp> getCachedApps() {
|
||||
protected List<GBDeviceApp> getSystemWatchfaces() {
|
||||
List<GBDeviceApp> systemWatchfaces = new ArrayList<>();
|
||||
systemWatchfaces.add(new GBDeviceApp(UUID.fromString("8f3c8686-31a1-4f5f-91f5-01600c9bdc59"), "Tic Toc (System)", "Pebble Inc.", "", GBDeviceApp.Type.WATCHFACE_SYSTEM));
|
||||
return systemWatchfaces;
|
||||
}
|
||||
|
||||
protected List<GBDeviceApp> getCachedApps() {
|
||||
List<GBDeviceApp> cachedAppList = new ArrayList<>();
|
||||
File cachePath;
|
||||
try {
|
||||
|
@ -134,13 +140,16 @@ public class AbstractAppManagerFragment extends Fragment {
|
|||
return cachedAppList;
|
||||
}
|
||||
|
||||
public void refreshList() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
mGBDevice = ((AppManagerActivity) getActivity()).getGBDevice();
|
||||
|
||||
prefs = GBApplication.getPrefs();
|
||||
appList.addAll(getCachedApps());
|
||||
|
||||
appList.addAll(getSystemApps());
|
||||
|
||||
refreshList();
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(GBApplication.ACTION_QUIT);
|
||||
filter.addAction(ACTION_REFRESH_APPLIST);
|
||||
|
|
|
@ -14,6 +14,10 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
|||
public class AppManagerActivity extends AbstractGBFragmentActivity {
|
||||
private GBDevice mGBDevice = null;
|
||||
|
||||
public GBDevice getGBDevice() {
|
||||
return mGBDevice;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
|
@ -50,12 +54,11 @@ public class AppManagerActivity extends AbstractGBFragmentActivity {
|
|||
// getItem is called to instantiate the fragment for the given page.
|
||||
switch (position) {
|
||||
case 0:
|
||||
return new AppManagerFragmentCache();
|
||||
case 1:
|
||||
return new AppManagerFragmentInstalledApps();
|
||||
case 2:
|
||||
AbstractAppManagerFragment fragment = new AbstractAppManagerFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("GBDevice", mGBDevice);
|
||||
return fragment;
|
||||
return new AppManagerFragmentInstalledWatchfaces();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -69,11 +72,11 @@ public class AppManagerActivity extends AbstractGBFragmentActivity {
|
|||
public CharSequence getPageTitle(int position) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
return "test";
|
||||
return "Apps in cache";
|
||||
case 1:
|
||||
return "for";
|
||||
return "Installed apps";
|
||||
case 2:
|
||||
return "me";
|
||||
return "Installed watchfaces";
|
||||
case 3:
|
||||
}
|
||||
return super.getPageTitle(position);
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package nodomain.freeyourgadget.gadgetbridge.activities.appmanager;
|
||||
|
||||
public class AppManagerFragmentInstalledApps extends AbstractAppManagerFragment {
|
||||
@Override
|
||||
public void refreshList() {
|
||||
appList.addAll(getSystemApps());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package nodomain.freeyourgadget.gadgetbridge.activities.appmanager;
|
||||
|
||||
public class AppManagerFragmentInstalledWatchfaces extends AbstractAppManagerFragment {
|
||||
@Override
|
||||
public void refreshList() {
|
||||
appList.addAll(getSystemWatchfaces());
|
||||
}
|
||||
}
|
|
@ -58,6 +58,7 @@ public class GBDeviceAppAdapter extends ArrayAdapter<GBDeviceApp> {
|
|||
deviceImageView.setImageResource(R.drawable.ic_activitytracker);
|
||||
break;
|
||||
case APP_SYSTEM:
|
||||
case WATCHFACE_SYSTEM:
|
||||
deviceImageView.setImageResource(R.drawable.ic_systemapp);
|
||||
break;
|
||||
case WATCHFACE:
|
||||
|
|
|
@ -89,6 +89,7 @@ public class GBDeviceApp {
|
|||
public enum Type {
|
||||
UNKNOWN,
|
||||
WATCHFACE,
|
||||
WATCHFACE_SYSTEM,
|
||||
APP_GENERIC,
|
||||
APP_ACTIVITYTRACKER,
|
||||
APP_SYSTEM,
|
||||
|
|
Loading…
Reference in New Issue