From e4e20715abbeab1b0d85466e32fee7e8c4c7bdaa Mon Sep 17 00:00:00 2001 From: Konrad Renner Date: Mon, 2 May 2016 07:44:59 +0200 Subject: [PATCH] - Attachment support - Attachment preview for tablets - Bugfixing --- app/build.gradle | 4 +-- .../android/content/DatabaseHelper.java | 33 +++++++++++++------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index cccc524..1945301 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId "org.kore.kolabnotes.android" minSdkVersion 16 targetSdkVersion 23 - versionCode 67 - versionName "2.0.1" + versionCode 68 + versionName "2.0.2" //Running test testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" diff --git a/app/src/main/java/org/kore/kolabnotes/android/content/DatabaseHelper.java b/app/src/main/java/org/kore/kolabnotes/android/content/DatabaseHelper.java index f771052..d704f24 100644 --- a/app/src/main/java/org/kore/kolabnotes/android/content/DatabaseHelper.java +++ b/app/src/main/java/org/kore/kolabnotes/android/content/DatabaseHelper.java @@ -145,6 +145,12 @@ public class DatabaseHelper extends SQLiteOpenHelper { + COLUMN_ROOT_FOLDER + " )" + "VALUES ('local','Notes');"; + private static final String INIT_ACCOUNTS = "insert into " + + TABLE_ACCOUNTS + + "(" + COLUMN_ACCOUNT + ", " + + COLUMN_ROOT_FOLDER + " )" + + "VALUES ('local','Notes');"; + private final Context context; public DatabaseHelper(Context context) { @@ -161,6 +167,9 @@ public void onCreate(SQLiteDatabase database) { database.execSQL(CREATE_ATTACHMENT); database.execSQL(CREATE_ACTIVEACCOUNT); database.execSQL(INIT_ACTIVEACCOUNT); + + database.execSQL(CREATE_ACCOUNTS); + database.execSQL(INIT_ACCOUNTS); } @Override @@ -184,19 +193,23 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL(CREATE_ATTACHMENT); } if(oldVersion < 7){ - db.execSQL(CREATE_ACCOUNTS); - final ActiveAccountRepository activeAccountRepository = new ActiveAccountRepository(context); - activeAccountRepository.insertAccount(db, "local", "Notes"); + createAccountsTable(db); + } + } + + 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(); + 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); + 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); - } + activeAccountRepository.insertAccount(db, email, rootFolder); } }