Skip to content

Commit

Permalink
Merge pull request #359 from jmpascal/master
Browse files Browse the repository at this point in the history
ANDROID-216
  • Loading branch information
JM.PASCAL committed Nov 5, 2015
2 parents 60db631 + 15e965f commit 3b5371a
Show file tree
Hide file tree
Showing 25 changed files with 580 additions and 88 deletions.
4 changes: 4 additions & 0 deletions alfresco-mobile-android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,10 @@
android:name="org.alfresco.mobile.android.platform.io.FileCleanerService"
android:exported="false" />

<service
android:name="org.alfresco.mobile.android.async.UploadRetryService"
android:exported="false" />

<!-- *************************************************************** -->
<!-- EXTENSION : SAMSUNG -->
<!-- *************************************************************** -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,21 @@
import org.alfresco.mobile.android.platform.security.DataProtectionManager;
import org.alfresco.mobile.android.platform.utils.ConnectivityUtils;
import org.alfresco.mobile.android.sync.SyncContentManager;
import org.alfresco.mobile.android.sync.SyncContentProvider;
import org.alfresco.mobile.android.ui.RefreshFragment;
import org.alfresco.mobile.android.ui.fragments.AlfrescoFragment;
import org.alfresco.mobile.android.ui.node.browse.NodeBrowserTemplate;
import org.alfresco.mobile.android.ui.utils.UIUtils;

import android.accounts.Account;
import android.annotation.TargetApi;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.SyncInfo;
import android.content.res.Configuration;
import android.net.ConnectivityManager;
import android.os.Build;
Expand Down Expand Up @@ -970,7 +974,16 @@ public void onAccountLoaded(LoadAccountCompletedEvent event)

// Activate Automatic Sync for Sync Content & Favorite
SyncContentManager.getInstance(this).setActivateSync(getCurrentAccount(), true);
if (SyncContentManager.getInstance(this).canSync(getCurrentAccount()))
{
SyncContentManager.getInstance(this).sync(getCurrentAccount());
}

FavoritesManager.getInstance(this).setActivateSync(getCurrentAccount(), true);
if (FavoritesManager.getInstance(this).canSync(getCurrentAccount()))
{
FavoritesManager.getInstance(this).sync(getCurrentAccount());
}

invalidateOptionsMenu();
}
Expand Down Expand Up @@ -1058,9 +1071,15 @@ else if (sessionState == SESSION_ERROR && getCurrentSession() == null)
}
invalidateOptionsMenu();

if (getCurrentAccount() != null && SyncContentManager.hasPendingSync(context, getCurrentAccount()))
// If connectivity is better (or reopen) we can try to sync all pending request
if (getCurrentSession() != null && SyncContentManager.hasPendingSync(context, getCurrentAccount()))
{
SyncContentManager.getInstance(context).sync(getCurrentAccount());
if (!isSyncActive(AlfrescoAccountManager.getInstance(context)
.getAndroidAccount(getCurrentAccount().getId()), SyncContentProvider.AUTHORITY))
{
Log.e(TAG, "[Sync NETWORK]");
SyncContentManager.getInstance(context).sync(getCurrentAccount());
}
}

}
Expand All @@ -1073,6 +1092,15 @@ else if (sessionState == SESSION_ERROR && getCurrentSession() == null)
}
}

private static boolean isSyncActive(Account account, String authority)
{
for (SyncInfo syncInfo : ContentResolver.getCurrentSyncs())
{
if (syncInfo.account.equals(account) && syncInfo.authority.equals(authority)) { return true; }
}
return false;
}

private boolean isCurrentAccountToLoad(LoadAccountCompletedEvent event)
{
return getCurrentAccount() != null && event != null && (getCurrentAccount().getId() == event.account.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,18 @@
import org.alfresco.mobile.android.application.fragments.signin.WelcomeFragment;
import org.alfresco.mobile.android.platform.intent.PrivateIntent;
import org.alfresco.mobile.android.platform.utils.BundleUtils;
import org.alfresco.mobile.android.platform.utils.ConnectivityUtils;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.PopupMenu;
import android.text.Html;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;

import de.keyboardsurfer.android.widget.crouton.Crouton;
import de.keyboardsurfer.android.widget.crouton.Style;

/**
* A login screen that offers login via email/password.
Expand Down Expand Up @@ -104,7 +110,17 @@ public void signIn(View v)

public void signInOnline(View v)
{
AccountOAuthFragment.with(this).isCreation(true).display();
if (ConnectivityUtils.hasNetwork(this))
{
AccountOAuthFragment.with(this).isCreation(true).display();
}
else
{
Crouton.cancelAllCroutons();
Crouton.showText(this,
Html.fromHtml(getString(org.alfresco.mobile.android.foundation.R.string.error_session_nodata)),
Style.ALERT, (ViewGroup) (findViewById(R.id.content_frame)));
}
}

public boolean isCreation()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,32 @@ protected void onItemUnselected(ActivityEntry unSelectedObject)
@Override
public void onListItemClick(GridView g, View v, int position, long id)
{
onItemSelected((ActivityEntry) g.getItemAtPosition(position));
ActivityEntry entry = (ActivityEntry) g.getItemAtPosition(position);

Boolean hideDetails = false;
if (!selectedEntry.isEmpty())
{
hideDetails = selectedEntry.get(0).equals(entry);
}
g.setItemChecked(position, true);

selectedEntry.clear();
if (!hideDetails && DisplayUtils.hasCentralPane(getActivity()))
{
selectedEntry.add(entry);
}

if (hideDetails)
{
selectedEntry.clear();
onItemUnselected(entry);
displayTitle();
}
else
{
onItemSelected(entry);
}
adapter.notifyDataSetChanged();
}

protected void onItemSelected(ActivityEntry item)
Expand Down Expand Up @@ -163,8 +188,7 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
protected ArrayAdapter<ActivityEntry> onAdapterCreation()
{
return new ActivityFeedAdapter(this, R.layout.row_two_lines_caption_divider_circle,
new ArrayList<ActivityEntry>(0),
selectedEntry);
new ArrayList<ActivityEntry>(0), selectedEntry);
}

@Subscribe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,7 @@ public void select(Node updatedNode)

public void highLight(Node updatedNode)
{
unselect();
selectedItems.add(updatedNode);
adapter.notifyDataSetChanged();
}
Expand Down Expand Up @@ -1242,8 +1243,11 @@ public void displayTitle()
public void onDocumentUpdated(UpdateNodeEvent event)
{
if (event.hasException) { return; }
if (event.parentFolder == null || parentFolder == null
|| !event.parentFolder.getIdentifier().equals(parentFolder.getIdentifier())) { return; }
Node updatedNode = event.data;
remove(event.initialNode);

if (adapter != null)
{
((ProgressNodeAdapter) adapter).replaceNode(updatedNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;

Expand Down Expand Up @@ -221,6 +222,26 @@ public void onCreateComment(CreateCommentEvent result)
refresh();
}

@Override
protected void prepareEmptyInitialView(View ev, ImageView emptyImageView, TextView firstEmptyMessage,
TextView secondEmptyMessage)
{
emptyImageView.setLayoutParams(DisplayUtils.resizeLayout(getActivity(), 275, 275));
emptyImageView.setImageResource(R.drawable.alfresco_background_logo);
firstEmptyMessage.setVisibility(View.GONE);
secondEmptyMessage.setVisibility(View.GONE);
}

protected void prepareEmptyView(View ev, ImageView emptyImageView, TextView firstEmptyMessage,
TextView secondEmptyMessage)
{
emptyImageView.setLayoutParams(DisplayUtils.resizeLayout(getActivity(), 275, 275));
emptyImageView.setImageResource(R.drawable.alfresco_background_logo);
firstEmptyMessage.setVisibility(View.VISIBLE);
firstEmptyMessage.setText(R.string.empty_comment);
secondEmptyMessage.setVisibility(View.GONE);
}

// ///////////////////////////////////////////////////////////////////////////
// BUILDER
// ///////////////////////////////////////////////////////////////////////////
Expand Down
Loading

0 comments on commit 3b5371a

Please sign in to comment.