Skip to content

Commit

Permalink
- Attachment support
Browse files Browse the repository at this point in the history
 - Attachment preview for tablets
 - Bugfixing
  • Loading branch information
konradrenner committed May 2, 2016
1 parent 5d059fa commit e8ac599
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "org.kore.kolabnotes.android"
minSdkVersion 16
targetSdkVersion 23
versionCode 69
versionName "2.0.4"
versionCode 70
versionName "2.0.5"

//Running test
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down
12 changes: 0 additions & 12 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,6 @@
android:label="@string/title_activity_settings"
android:theme="@style/SettingsTheme"></activity>

<receiver
android:name=".security.AccountDeletionReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.accounts.LOGIN_ACCOUNTS_CHANGED" />
</intent-filter>

<meta-data
android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator" />
</receiver>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.IProfile;

import org.kore.kolab.notes.Attachment;
import org.kore.kolab.notes.AuditInformation;
import org.kore.kolab.notes.Colors;
import org.kore.kolab.notes.Identification;
Expand All @@ -76,8 +77,11 @@
import org.kore.kolabnotes.android.TagListActivity;
import org.kore.kolabnotes.android.Utils;
import org.kore.kolabnotes.android.adapter.NoteAdapter;
import org.kore.kolabnotes.android.content.AccountIdentifier;
import org.kore.kolabnotes.android.content.ActiveAccount;
import org.kore.kolabnotes.android.content.ActiveAccountRepository;
import org.kore.kolabnotes.android.content.AttachmentRepository;
import org.kore.kolabnotes.android.content.ModificationRepository;
import org.kore.kolabnotes.android.content.NoteRepository;
import org.kore.kolabnotes.android.content.NoteSorting;
import org.kore.kolabnotes.android.content.NoteTagRepository;
Expand Down Expand Up @@ -141,6 +145,8 @@ public class OverviewFragment extends Fragment implements /*NoteAdapter.NoteSele
private TagRepository tagRepository;
private NoteTagRepository notetagRepository;
private ActiveAccountRepository activeAccountRepository;
private AttachmentRepository attachmentRepository;
private ModificationRepository modificationRepository;
private Toolbar toolbar;

private Drawer mDrawer;
Expand Down Expand Up @@ -175,6 +181,8 @@ public void onAttach(Activity activity) {
tagRepository = new TagRepository(activity);
notetagRepository = new NoteTagRepository(activity);
activeAccountRepository = new ActiveAccountRepository(activity);
attachmentRepository = new AttachmentRepository(activity);
modificationRepository = new ModificationRepository(activity);
}

@Override
Expand All @@ -194,6 +202,16 @@ public void onActivityCreated(Bundle savedInstanceState) {
mAccountManager = AccountManager.get(activity);
Account[] accounts = mAccountManager.getAccountsByType(AuthenticatorActivity.ARG_ACCOUNT_TYPE);

Set<AccountIdentifier> allAccounts = activeAccountRepository.getAllAccounts();

if(allAccounts.size() == 0){
allAccounts = activeAccountRepository.initAccounts();
}

//For accounts cleanup
Set<AccountIdentifier> accountsForDeletion = new LinkedHashSet<>(allAccounts);
accountsForDeletion.remove(new AccountIdentifier("local","Notes"));

ProfileDrawerItem[] profiles = new ProfileDrawerItem[accounts.length+1];
profiles[0] = new ProfileDrawerItem().withName(getResources().getString(R.string.drawer_account_local)).withTag("Notes").withIcon(getResources().getDrawable(R.drawable.ic_local_account));

Expand Down Expand Up @@ -225,8 +243,13 @@ public void onActivityCreated(Bundle savedInstanceState) {
}

profiles[i+1] = item;

accountsForDeletion.remove(new AccountIdentifier(email,rootFolder));
}

cleanupAccounts(accountsForDeletion);


mAccount = new AccountHeaderBuilder()
.withActivity(this.activity)
.withHeaderBackground(R.drawable.drawer_header_background)
Expand Down Expand Up @@ -324,6 +347,37 @@ public void run() {
setListState();
}

private void cleanupAccounts(Set<AccountIdentifier> accountsForDeletion){
Thread cleanupThread = new Thread(new AccountsCleaner(accountsForDeletion));
cleanupThread.start();
}

final class AccountsCleaner implements Runnable{

private final Set<AccountIdentifier> accountsForDeletion;

public AccountsCleaner(Set<AccountIdentifier> accountsForDeletion){
this.accountsForDeletion = accountsForDeletion;
}

@Override
public void run() {
for(AccountIdentifier identifier : accountsForDeletion){
String email = identifier.getAccount();
String rootFolder = identifier.getRootFolder();
activeAccountRepository.deleteAccount(identifier.getAccount(),identifier.getRootFolder());

notesRepository.cleanAccount(email, rootFolder);
notetagRepository.cleanAccount(email,rootFolder);
tagRepository.cleanAccount(email,rootFolder);
attachmentRepository.cleanAccount(email, rootFolder);
modificationRepository.cleanAccount(email,rootFolder);

Log.d("AccountsCleaner","Cleaned account:"+identifier);
}
}
}

@Override
public void onPause() {
super.onPause();
Expand Down

This file was deleted.

0 comments on commit e8ac599

Please sign in to comment.