diff --git a/alfresco-mobile-android/src/org/alfresco/mobile/android/application/accounts/AccountManager.java b/alfresco-mobile-android/src/org/alfresco/mobile/android/application/accounts/AccountManager.java index 3549f0f0..206c8cde 100644 --- a/alfresco-mobile-android/src/org/alfresco/mobile/android/application/accounts/AccountManager.java +++ b/alfresco-mobile-android/src/org/alfresco/mobile/android/application/accounts/AccountManager.java @@ -317,7 +317,8 @@ else if (account != null) broadManager.sendBroadcast(new Intent(IntentIntegrator.ACTION_LOAD_ACCOUNT_COMPLETED).putExtra( IntentIntegrator.EXTRA_ACCOUNT_ID, accountToLoad.getId())); } - else if (appManager.getCurrentAccount() == null || accountToLoad.getId() != appManager.getCurrentAccount().getId()) + else if (appManager.getCurrentAccount() == null + || accountToLoad.getId() != appManager.getCurrentAccount().getId()) { // Create the session for the specific account createSession(accountToLoad); @@ -364,8 +365,11 @@ private void getCount() { Cursor cursor = appContext.getContentResolver() .query(AccountProvider.CONTENT_URI, COLUMN_ALL, null, null, null); - accountsSize = cursor.getCount(); - cursor.close(); + if (cursor != null) + { + accountsSize = cursor.getCount(); + cursor.close(); + } } public void clear() diff --git a/alfresco-mobile-android/src/org/alfresco/mobile/android/application/activity/BaseActivity.java b/alfresco-mobile-android/src/org/alfresco/mobile/android/application/activity/BaseActivity.java index a0417af9..c428b0e4 100644 --- a/alfresco-mobile-android/src/org/alfresco/mobile/android/application/activity/BaseActivity.java +++ b/alfresco-mobile-android/src/org/alfresco/mobile/android/application/activity/BaseActivity.java @@ -69,8 +69,9 @@ public abstract class BaseActivity extends Activity protected BroadcastReceiver utilsReceiver; protected List receivers = new ArrayList(2); + protected List publicReceivers = new ArrayList(2); - + protected Account currentAccount; protected RenditionManager renditionManager; @@ -115,12 +116,12 @@ protected void onStop() { broadcastManager.unregisterReceiver(bReceiver); } - + for (BroadcastReceiver bReceiver : publicReceivers) { unregisterReceiver(bReceiver); } - + receivers.clear(); publicReceivers.clear(); } @@ -250,6 +251,19 @@ public void addNavigationFragment(Folder f) ChildrenBrowserFragment.TAG, true); } + public void addNavigationFragment(Folder f, boolean isShortcut) + { + if (f == null) { return; } + + ChildrenBrowserFragment mFragment = (ChildrenBrowserFragment) getFragment(ChildrenBrowserFragment.TAG); + if (mFragment != null && f.getIdentifier().equals(mFragment.getParent().getIdentifier())) { return; } + + BaseFragment frag = ChildrenBrowserFragment.newInstance(f, isShortcut); + frag.setSession(SessionUtils.getSession(this)); + FragmentDisplayer.replaceFragment(this, frag, DisplayUtils.getLeftFragmentId(this), + ChildrenBrowserFragment.TAG, true); + } + public void addNavigationFragment(Site site, Folder f) { if (f == null) { return; } @@ -260,7 +274,8 @@ public void addNavigationFragment(Site site, Folder f) } ChildrenBrowserFragment mFragment = (ChildrenBrowserFragment) getFragment(ChildrenBrowserFragment.TAG); - if (mFragment != null && mFragment.getParent() != null && f.getIdentifier().equals(mFragment.getParent().getIdentifier())) { return; } + if (mFragment != null && mFragment.getParent() != null + && f.getIdentifier().equals(mFragment.getParent().getIdentifier())) { return; } BaseFragment frag = ChildrenBrowserFragment.newInstance(site, f); frag.setSession(SessionUtils.getSession(this)); @@ -268,6 +283,32 @@ public void addNavigationFragment(Site site, Folder f) ChildrenBrowserFragment.TAG, true); } + public void addNavigationFragment(Site site, Folder f, boolean isShortcut) + { + if (!isShortcut) + { + addNavigationFragment(site, f); + } + else + { + if (f == null) { return; } + if (site == null) + { + addNavigationFragment(f); + return; + } + + ChildrenBrowserFragment mFragment = (ChildrenBrowserFragment) getFragment(ChildrenBrowserFragment.TAG); + if (mFragment != null && mFragment.getParent() != null + && f.getIdentifier().equals(mFragment.getParent().getIdentifier())) { return; } + + BaseFragment frag = ChildrenBrowserFragment.newInstance(site, f, isShortcut); + frag.setSession(SessionUtils.getSession(this)); + FragmentDisplayer.replaceFragment(this, frag, DisplayUtils.getLeftFragmentId(this), + ChildrenBrowserFragment.TAG, true); + } + } + public void addNavigationFragment(Site s) { BaseFragment frag = ChildrenBrowserFragment.newInstance(s); @@ -294,7 +335,7 @@ public void registerPrivateReceiver(BroadcastReceiver receiver, IntentFilter fil receivers.add(receiver); } } - + public void registerPublicReceiver(BroadcastReceiver receiver, IntentFilter filter) { if (receiver != null && filter != null) diff --git a/alfresco-mobile-android/src/org/alfresco/mobile/android/application/activity/MainActivity.java b/alfresco-mobile-android/src/org/alfresco/mobile/android/application/activity/MainActivity.java index 8e880d7d..c84e4867 100644 --- a/alfresco-mobile-android/src/org/alfresco/mobile/android/application/activity/MainActivity.java +++ b/alfresco-mobile-android/src/org/alfresco/mobile/android/application/activity/MainActivity.java @@ -627,6 +627,13 @@ public void addNavigationFragment(Folder f) clearCentralPane(); super.addNavigationFragment(f); } + + public void addNavigationFragment(Folder f, boolean isShortCut) + { + clearScreen(); + clearCentralPane(); + super.addNavigationFragment(f, isShortCut); + } public void addNavigationFragment(String path) { diff --git a/alfresco-mobile-android/src/org/alfresco/mobile/android/application/fragments/browser/ChildrenBrowserFragment.java b/alfresco-mobile-android/src/org/alfresco/mobile/android/application/fragments/browser/ChildrenBrowserFragment.java index 83a875d3..8aa48807 100644 --- a/alfresco-mobile-android/src/org/alfresco/mobile/android/application/fragments/browser/ChildrenBrowserFragment.java +++ b/alfresco-mobile-android/src/org/alfresco/mobile/android/application/fragments/browser/ChildrenBrowserFragment.java @@ -152,6 +152,11 @@ public static ChildrenBrowserFragment newInstance(Folder folder) { return newInstance(folder, null, null); } + + public static ChildrenBrowserFragment newInstance(Folder folder, boolean isShortcut) + { + return newInstance(folder, null, null, isShortcut); + } public static ChildrenBrowserFragment newInstance(String folderPath) { @@ -179,15 +184,25 @@ public static ChildrenBrowserFragment newInstance(Site site, Folder folder) { return newInstance(folder, null, site); } + + public static ChildrenBrowserFragment newInstance(Site site, Folder folder, boolean isShortCut) + { + return newInstance(folder, null, site, isShortCut); + } private static ChildrenBrowserFragment newInstance(Folder parentFolder, String pathFolder, Site site) + { + return newInstance(parentFolder, pathFolder, site, pathFolder != null || parentFolder instanceof CloudFolderImpl); + } + + private static ChildrenBrowserFragment newInstance(Folder parentFolder, String pathFolder, Site site, boolean isShortcut) { ChildrenBrowserFragment bf = new ChildrenBrowserFragment(); ListingContext lc = new ListingContext(); lc.setSortProperty(DocumentFolderService.SORT_PROPERTY_NAME); lc.setIsSortAscending(true); Bundle b = createBundleArgs(parentFolder, pathFolder, site); - b.putBoolean(PARAM_IS_SHORTCUT, pathFolder != null || parentFolder instanceof CloudFolderImpl); + b.putBoolean(PARAM_IS_SHORTCUT, isShortcut); b.putAll(createBundleArgs(lc, LOAD_AUTO)); bf.setArguments(b); return bf; @@ -549,7 +564,7 @@ else if (nActions == null) { if (item.isFolder()) { - addNavigationFragment(currentSiteParameter, (Folder) item); + ((BaseActivity) getActivity()).addNavigationFragment(currentSiteParameter, (Folder) item, isShortcut()); } else { diff --git a/alfresco-mobile-android/src/org/alfresco/mobile/android/application/fragments/properties/DetailsFragment.java b/alfresco-mobile-android/src/org/alfresco/mobile/android/application/fragments/properties/DetailsFragment.java index 2be4dbff..b640dd5c 100644 --- a/alfresco-mobile-android/src/org/alfresco/mobile/android/application/fragments/properties/DetailsFragment.java +++ b/alfresco-mobile-android/src/org/alfresco/mobile/android/application/fragments/properties/DetailsFragment.java @@ -452,7 +452,7 @@ private void refresh() { vRoot.findViewById(R.id.properties_details).setVisibility(View.VISIBLE); vRoot.findViewById(R.id.progressbar).setVisibility(View.GONE); - if (node instanceof Document) + if (node instanceof Document || node instanceof Folder) { display(node); } diff --git a/alfresco-mobile-android/src/org/alfresco/mobile/android/application/fragments/properties/NodeLoader.java b/alfresco-mobile-android/src/org/alfresco/mobile/android/application/fragments/properties/NodeLoader.java index deb36cdc..9fb725aa 100644 --- a/alfresco-mobile-android/src/org/alfresco/mobile/android/application/fragments/properties/NodeLoader.java +++ b/alfresco-mobile-android/src/org/alfresco/mobile/android/application/fragments/properties/NodeLoader.java @@ -82,9 +82,9 @@ public class NodeLoader extends AbstractBaseLoader> private String uri; private Account selectAccount; - + private Account acc; - + public NodeLoader(Activity context, Account acc, AlfrescoSession session, String nodeIdentifier) { super(context); @@ -119,16 +119,13 @@ public LoaderResult loadInBackground() // Retrieve Node n = session.getServiceRegistry().getDocumentFolderService().getNodeByIdentifier(identifier); - if (n.isDocument()) + try { - try - { - parentFolder = session.getServiceRegistry().getDocumentFolderService().getParentFolder(n); - } - catch (Exception e) - { - Log.w(TAG, Log.getStackTraceString(e)); - } + parentFolder = session.getServiceRegistry().getDocumentFolderService().getParentFolder(n); + } + catch (Exception e) + { + Log.w(TAG, Log.getStackTraceString(e)); } } catch (Exception e) @@ -138,11 +135,11 @@ public LoaderResult loadInBackground() { // Retrieve Sync Cursor for the specified node Uri localUri = syncManager.getUri(acc, identifier); - Cursor syncCursor = getContext().getContentResolver().query(localUri, SynchroSchema.COLUMN_ALL, null, null, - null); + Cursor syncCursor = getContext().getContentResolver().query(localUri, SynchroSchema.COLUMN_ALL, null, + null, null); if (syncCursor.getCount() == 1 && syncCursor.moveToFirst()) { - //syncCursor.getString(BatchOperationSchema.COLUMN_PROPERTIES_ID) + // syncCursor.getString(BatchOperationSchema.COLUMN_PROPERTIES_ID) Map properties = retrievePropertiesMap(syncCursor); n = new NodeSyncPlaceHolder(properties); } diff --git a/alfresco-mobile-android/src/org/alfresco/mobile/android/application/fragments/properties/UpdateDialogFragment.java b/alfresco-mobile-android/src/org/alfresco/mobile/android/application/fragments/properties/UpdateDialogFragment.java index 1b87ea16..0776bb5f 100644 --- a/alfresco-mobile-android/src/org/alfresco/mobile/android/application/fragments/properties/UpdateDialogFragment.java +++ b/alfresco-mobile-android/src/org/alfresco/mobile/android/application/fragments/properties/UpdateDialogFragment.java @@ -147,6 +147,10 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) tsize.setText(Formatter.formatFileSize(getActivity(), ((Document) node).getContentStreamLength())); tsize.setVisibility(View.VISIBLE); } + else + { + tsize.setVisibility(View.GONE); + } if (RepositoryVersionHelper.isAlfrescoProduct(alfSession) && node.getProperty(ContentModel.PROP_DESCRIPTION) != null diff --git a/alfresco-mobile-android/src/org/alfresco/mobile/android/application/fragments/search/DocumentFolderSearchFragment.java b/alfresco-mobile-android/src/org/alfresco/mobile/android/application/fragments/search/DocumentFolderSearchFragment.java index 8f3d210c..5e2cbd19 100644 --- a/alfresco-mobile-android/src/org/alfresco/mobile/android/application/fragments/search/DocumentFolderSearchFragment.java +++ b/alfresco-mobile-android/src/org/alfresco/mobile/android/application/fragments/search/DocumentFolderSearchFragment.java @@ -270,7 +270,7 @@ public void onListItemClick(GridView l, View v, int position, long id) } else { - ((MainActivity) getActivity()).addNavigationFragment((Folder) item); + ((MainActivity) getActivity()).addNavigationFragment((Folder) item, true); } }