Skip to content

Commit

Permalink
Merge pull request #174 from jmpascal/master
Browse files Browse the repository at this point in the history
MOBILE-2187
  • Loading branch information
JM.PASCAL committed Jan 15, 2014
2 parents d44b24d + a237d88 commit f91b6b6
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ public abstract class BaseActivity extends Activity
protected BroadcastReceiver utilsReceiver;

protected List<BroadcastReceiver> receivers = new ArrayList<BroadcastReceiver>(2);

protected List<BroadcastReceiver> publicReceivers = new ArrayList<BroadcastReceiver>(2);

protected Account currentAccount;

protected RenditionManager renditionManager;
Expand Down Expand Up @@ -115,12 +116,12 @@ protected void onStop()
{
broadcastManager.unregisterReceiver(bReceiver);
}

for (BroadcastReceiver bReceiver : publicReceivers)
{
unregisterReceiver(bReceiver);
}

receivers.clear();
publicReceivers.clear();
}
Expand Down Expand Up @@ -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; }
Expand All @@ -260,14 +274,41 @@ 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));
FragmentDisplayer.replaceFragment(this, frag, DisplayUtils.getLeftFragmentId(this),
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);
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -549,7 +564,7 @@ else if (nActions == null)
{
if (item.isFolder())
{
addNavigationFragment(currentSiteParameter, (Folder) item);
((BaseActivity) getActivity()).addNavigationFragment(currentSiteParameter, (Folder) item, isShortcut());
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ public class NodeLoader extends AbstractBaseLoader<LoaderResult<Node>>
private String uri;

private Account selectAccount;

private Account acc;

public NodeLoader(Activity context, Account acc, AlfrescoSession session, String nodeIdentifier)
{
super(context);
Expand Down Expand Up @@ -119,16 +119,13 @@ public LoaderResult<Node> 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)
Expand All @@ -138,11 +135,11 @@ public LoaderResult<Node> 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<String, String> properties = retrievePropertiesMap(syncCursor);
n = new NodeSyncPlaceHolder(properties);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit f91b6b6

Please sign in to comment.