mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-09-04 21:45:31 +02:00
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;
|
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||||
|
|
||||||
|
|
||||||
public class AbstractAppManagerFragment extends Fragment {
|
public abstract class AbstractAppManagerFragment extends Fragment {
|
||||||
public static final String ACTION_REFRESH_APPLIST
|
public static final String ACTION_REFRESH_APPLIST
|
||||||
= "nodomain.freeyourgadget.gadgetbridge.appmanager.action.refresh_applist";
|
= "nodomain.freeyourgadget.gadgetbridge.appmanager.action.refresh_applist";
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(AbstractAppManagerFragment.class);
|
private static final Logger LOG = LoggerFactory.getLogger(AbstractAppManagerFragment.class);
|
||||||
@ -83,12 +83,12 @@ public class AbstractAppManagerFragment extends Fragment {
|
|||||||
|
|
||||||
private Prefs prefs;
|
private Prefs prefs;
|
||||||
|
|
||||||
private final List<GBDeviceApp> appList = new ArrayList<>();
|
protected final List<GBDeviceApp> appList = new ArrayList<>();
|
||||||
private GBDeviceAppAdapter mGBDeviceAppAdapter;
|
private GBDeviceAppAdapter mGBDeviceAppAdapter;
|
||||||
private GBDeviceApp selectedApp = null;
|
private GBDeviceApp selectedApp = null;
|
||||||
private GBDevice mGBDevice = null;
|
private GBDevice mGBDevice = null;
|
||||||
|
|
||||||
private List<GBDeviceApp> getSystemApps() {
|
protected List<GBDeviceApp> getSystemApps() {
|
||||||
List<GBDeviceApp> systemApps = new ArrayList<>();
|
List<GBDeviceApp> systemApps = new ArrayList<>();
|
||||||
if (prefs.getBoolean("pebble_force_untested", false)) {
|
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));
|
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;
|
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<>();
|
List<GBDeviceApp> cachedAppList = new ArrayList<>();
|
||||||
File cachePath;
|
File cachePath;
|
||||||
try {
|
try {
|
||||||
@ -134,13 +140,16 @@ public class AbstractAppManagerFragment extends Fragment {
|
|||||||
return cachedAppList;
|
return cachedAppList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void refreshList() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
mGBDevice = ((AppManagerActivity) getActivity()).getGBDevice();
|
||||||
|
|
||||||
prefs = GBApplication.getPrefs();
|
prefs = GBApplication.getPrefs();
|
||||||
appList.addAll(getCachedApps());
|
|
||||||
|
|
||||||
appList.addAll(getSystemApps());
|
|
||||||
|
|
||||||
|
refreshList();
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
filter.addAction(GBApplication.ACTION_QUIT);
|
filter.addAction(GBApplication.ACTION_QUIT);
|
||||||
filter.addAction(ACTION_REFRESH_APPLIST);
|
filter.addAction(ACTION_REFRESH_APPLIST);
|
||||||
|
@ -14,6 +14,10 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
|||||||
public class AppManagerActivity extends AbstractGBFragmentActivity {
|
public class AppManagerActivity extends AbstractGBFragmentActivity {
|
||||||
private GBDevice mGBDevice = null;
|
private GBDevice mGBDevice = null;
|
||||||
|
|
||||||
|
public GBDevice getGBDevice() {
|
||||||
|
return mGBDevice;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
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.
|
// getItem is called to instantiate the fragment for the given page.
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case 0:
|
case 0:
|
||||||
|
return new AppManagerFragmentCache();
|
||||||
case 1:
|
case 1:
|
||||||
|
return new AppManagerFragmentInstalledApps();
|
||||||
case 2:
|
case 2:
|
||||||
AbstractAppManagerFragment fragment = new AbstractAppManagerFragment();
|
return new AppManagerFragmentInstalledWatchfaces();
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putParcelable("GBDevice", mGBDevice);
|
|
||||||
return fragment;
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -69,11 +72,11 @@ public class AppManagerActivity extends AbstractGBFragmentActivity {
|
|||||||
public CharSequence getPageTitle(int position) {
|
public CharSequence getPageTitle(int position) {
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case 0:
|
case 0:
|
||||||
return "test";
|
return "Apps in cache";
|
||||||
case 1:
|
case 1:
|
||||||
return "for";
|
return "Installed apps";
|
||||||
case 2:
|
case 2:
|
||||||
return "me";
|
return "Installed watchfaces";
|
||||||
case 3:
|
case 3:
|
||||||
}
|
}
|
||||||
return super.getPageTitle(position);
|
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);
|
deviceImageView.setImageResource(R.drawable.ic_activitytracker);
|
||||||
break;
|
break;
|
||||||
case APP_SYSTEM:
|
case APP_SYSTEM:
|
||||||
|
case WATCHFACE_SYSTEM:
|
||||||
deviceImageView.setImageResource(R.drawable.ic_systemapp);
|
deviceImageView.setImageResource(R.drawable.ic_systemapp);
|
||||||
break;
|
break;
|
||||||
case WATCHFACE:
|
case WATCHFACE:
|
||||||
|
@ -89,6 +89,7 @@ public class GBDeviceApp {
|
|||||||
public enum Type {
|
public enum Type {
|
||||||
UNKNOWN,
|
UNKNOWN,
|
||||||
WATCHFACE,
|
WATCHFACE,
|
||||||
|
WATCHFACE_SYSTEM,
|
||||||
APP_GENERIC,
|
APP_GENERIC,
|
||||||
APP_ACTIVITYTRACKER,
|
APP_ACTIVITYTRACKER,
|
||||||
APP_SYSTEM,
|
APP_SYSTEM,
|
||||||
|
Loading…
Reference in New Issue
Block a user