-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 23 | ||
buildToolsVersion "23.0.3" | ||
|
||
defaultConfig { | ||
applicationId "org.secuso.privacyfriendlynotes" | ||
minSdkVersion 16 | ||
targetSdkVersion 23 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
testCompile 'junit:junit:4.12' | ||
compile 'com.android.support:appcompat-v7:23.4.0' | ||
compile 'com.android.support:design:23.4.0' | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in C:\Users\Robin\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.secuso.privacyfriendlynotes; | ||
|
||
import android.app.Application; | ||
import android.test.ApplicationTestCase; | ||
|
||
/** | ||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> | ||
*/ | ||
public class ApplicationTest extends ApplicationTestCase<Application> { | ||
public ApplicationTest() { | ||
super(Application.class); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="org.secuso.privacyfriendlynotes"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme.NoActionBar"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".CreateTextNoteActivity" | ||
android:parentActivityName=".MainActivity"></activity> | ||
</application> | ||
|
||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.secuso.privacyfriendlynotes; | ||
|
||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.EditText; | ||
import android.widget.Toast; | ||
|
||
public class CreateTextNoteActivity extends AppCompatActivity implements View.OnClickListener{ | ||
|
||
EditText etName; | ||
EditText etContent; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_create_text_note); | ||
findViewById(R.id.btn_save).setOnClickListener(this); | ||
|
||
etName = (EditText) findViewById(R.id.etName); | ||
etContent = (EditText) findViewById(R.id.etContent); | ||
} | ||
|
||
@Override | ||
public void onClick(View v) { | ||
switch (v.getId()) { | ||
case R.id.btn_save: | ||
saveNote(); | ||
break; | ||
default: | ||
} | ||
} | ||
|
||
private void saveNote(){ | ||
//TODO | ||
DbAccess.saveTextNote(getBaseContext(), etName.getText().toString(), etContent.getText().toString()); | ||
Toast.makeText(getApplicationContext(), "TODO: Saving...", Toast.LENGTH_SHORT).show(); | ||
finish(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.secuso.privacyfriendlynotes; | ||
|
||
import android.content.ContentValues; | ||
import android.content.Context; | ||
import android.database.Cursor; | ||
import android.database.sqlite.SQLiteDatabase; | ||
import org.secuso.privacyfriendlynotes.NotesContract.*; | ||
|
||
/** | ||
* Created by Robin on 11.06.2016. | ||
*/ | ||
public class DbAccess { | ||
public static void saveTextNote(Context c, String name, String content){ | ||
DbOpenHelper dbHelper = new DbOpenHelper(c); | ||
SQLiteDatabase db = dbHelper.getWritableDatabase(); | ||
|
||
ContentValues values = new ContentValues(); | ||
values.put(NoteEntry.COLUMN_NAME_NAME, name); | ||
values.put(NoteEntry.COLUMN_NAME_CONTENT, content); | ||
db.insert(NoteEntry.TABLE_NAME, null, values); | ||
} | ||
|
||
public static Cursor getCursorAllNotes(Context c) { | ||
DbOpenHelper dbHelper = new DbOpenHelper(c); | ||
SQLiteDatabase db = dbHelper.getReadableDatabase(); | ||
|
||
String[] projection = {NoteEntry.COLUMN_NAME_ID, NoteEntry.COLUMN_NAME_NAME, NoteEntry.COLUMN_NAME_CONTENT}; | ||
|
||
String sortOrder = NoteEntry.COLUMN_NAME_ID + " DESC"; | ||
|
||
return db.query(NoteEntry.TABLE_NAME, // Table name | ||
projection, // SELECT | ||
null, // Columns for WHERE | ||
null, // Values for WHERE | ||
null, // Group | ||
null, // Filter by Group | ||
null); // Sort Order | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.secuso.privacyfriendlynotes; | ||
|
||
import android.content.Context; | ||
import android.database.sqlite.SQLiteDatabase; | ||
import android.database.sqlite.SQLiteOpenHelper; | ||
|
||
/** | ||
* Created by Robin on 11.06.2016. | ||
*/ | ||
public class DbOpenHelper extends SQLiteOpenHelper { | ||
|
||
private static final int DATABASE_VERSION = 1; | ||
private static final String DATABASE_NAME = "allthenotes"; | ||
|
||
private static final String NOTES_TABLE_CREATE = | ||
"CREATE TABLE " + NotesContract.NoteEntry.TABLE_NAME + " (" + | ||
NotesContract.NoteEntry.COLUMN_NAME_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + | ||
NotesContract.NoteEntry.COLUMN_NAME_NAME + " TEXT NOT NULL, " + | ||
NotesContract.NoteEntry.COLUMN_NAME_CONTENT + " TEXT NOT NULL);"; | ||
|
||
DbOpenHelper(Context context) { | ||
super(context, DATABASE_NAME, null, DATABASE_VERSION); | ||
} | ||
|
||
@Override | ||
public void onCreate(SQLiteDatabase db) { | ||
db.execSQL(NOTES_TABLE_CREATE); | ||
} | ||
|
||
@Override | ||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { | ||
db.execSQL("DROP TABLE IF EXISTS" + NotesContract.NoteEntry.TABLE_NAME + ";"); | ||
onCreate(db); | ||
} | ||
} |