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 e4e2071 commit d902aa8
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
minSdkVersion 16
targetSdkVersion 23
versionCode 68
versionName "2.0.2"
versionName "2.0.3"

//Running test
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@
<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>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package org.kore.kolabnotes.android.content;

import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import org.kore.kolabnotes.android.Utils;
import org.kore.kolabnotes.android.security.AuthenticatorActivity;

import java.sql.Timestamp;
import java.util.ArrayList;
Expand Down Expand Up @@ -49,6 +52,27 @@ public Set<AccountIdentifier> getAllAccounts() {
return accounts;
}

public Set<AccountIdentifier> initAccounts() {
LinkedHashSet<AccountIdentifier> ret = new LinkedHashSet<>();
final SQLiteDatabase db = ConnectionManager.getDatabase(context);

insertAccount(db, "local", "Notes");
ret.add(new AccountIdentifier("local","Notes"));

final AccountManager accountManager = AccountManager.get(context);
final Account[] accounts = accountManager.getAccounts();

for(Account account : accounts){
String email = accountManager.getUserData(account, AuthenticatorActivity.KEY_EMAIL);
String rootFolder = accountManager.getUserData(account,AuthenticatorActivity.KEY_ROOT_FOLDER);

insertAccount(db, email, rootFolder);
ret.add(new AccountIdentifier(email, rootFolder));
}

return ret;
}

public void insertAccount(String account, String rootFolder) {
insertAccount(ConnectionManager.getDatabase(context), account, rootFolder);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,24 +193,7 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL(CREATE_ATTACHMENT);
}
if(oldVersion < 7){
createAccountsTable(db);
db.execSQL(CREATE_ACCOUNTS);
}
}

private void createAccountsTable(SQLiteDatabase db) {
db.execSQL(CREATE_ACCOUNTS);
final ActiveAccountRepository activeAccountRepository = new ActiveAccountRepository(context);
activeAccountRepository.insertAccount(db, "local", "Notes");

final AccountManager accountManager = AccountManager.get(context);
final Account[] accounts = accountManager.getAccounts();

for(Account account : accounts){
String email = accountManager.getUserData(account, AuthenticatorActivity.KEY_EMAIL);
String rootFolder = accountManager.getUserData(account,AuthenticatorActivity.KEY_ROOT_FOLDER);

activeAccountRepository.insertAccount(db, email, rootFolder);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ public void onReceive(Context context, Intent intent) {
final AccountManager accountManager = AccountManager.get(context);
final Account[] accounts = accountManager.getAccounts();

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

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

Set<AccountIdentifier> accountsForDeletion = new LinkedHashSet<>(allAccounts);

for(Account account : accounts){
Expand Down

0 comments on commit d902aa8

Please sign in to comment.