Skip to content

Commit

Permalink
Merge pull request #25 from Crazy-Marvin/rc-1.4
Browse files Browse the repository at this point in the history
Release 1.4
  • Loading branch information
CrazyMarvin authored Jan 11, 2020
2 parents 4359d36 + 681a774 commit a581bdd
Show file tree
Hide file tree
Showing 19 changed files with 726 additions and 105 deletions.
22 changes: 13 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
compileSdkVersion 29
defaultConfig {
applicationId "rocks.poopjournal.morse"
minSdkVersion 19
targetSdkVersion 28
versionCode 3
versionName "1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
targetSdkVersion 29
versionCode 4
versionName "1.4"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
Expand All @@ -20,9 +20,13 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'


implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
}
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".PhraseBookActivity" />
</application>

</manifest>
101 changes: 101 additions & 0 deletions app/src/main/java/rocks/poopjournal/morse/DBHelper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package rocks.poopjournal.morse;


import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;


import java.util.ArrayList;
import java.util.Calendar;

public class DBHelper extends SQLiteOpenHelper {


private static final String DATABASE_NAME = "morse";
private static final int DATABASE_VERSION = 1;

// table name
private static final String TABLE_PHRASEBOOK = "phrasebook";


private static final String KEY_ID = "id";
private static final String TAG = "DBhandler";

public DBHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}

@Override
public void onCreate(SQLiteDatabase db) {

String CREATE_NOTES_PHRASEBOOK = "CREATE TABLE IF NOT EXISTS "
+ TABLE_PHRASEBOOK + "("
+ KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,"
+ "sentence" + " TEXT,"
+ "morse" + " TEXT);";
db.execSQL(CREATE_NOTES_PHRASEBOOK);
}

@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

}
public void addPhrase(String text, String morse){

for (PhrasebookModel model: getAllPhrases()){
if (model.text.trim().equals(text.trim())){
deleteNote(model.id);
Log.d("debug_star","deleted note, now returning");
return;
}
}

Log.d("debug_star","adding note, now returning");
SQLiteDatabase db = this.getWritableDatabase();

ContentValues values = new ContentValues();
values.put("sentence", text);
values.put("morse",morse);

db.insert(TABLE_PHRASEBOOK, null,values);
db.close(); // Closing database connection
}





public void deleteNote(int id){

SQLiteDatabase db = this.getWritableDatabase();
db.delete(TABLE_PHRASEBOOK,"id= " + id,null);
db.close(); // Closing database connection

}

public ArrayList<PhrasebookModel> getAllPhrases() {
String selectQuery = "SELECT * FROM " + TABLE_PHRASEBOOK;
ArrayList<PhrasebookModel> mList = new ArrayList<PhrasebookModel>();

try {
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
while (cursor.moveToNext()) {
mList.add(new PhrasebookModel(cursor.getInt(0),cursor.getString(1),cursor.getString(2)));
// Log.d(TAG, "title"+cursor.getString(3)+" notes="+cursor.getString(4));
}
db.close();
return mList;

} catch (Exception e) {
e.printStackTrace();
}
return null;
}


}
4 changes: 3 additions & 1 deletion app/src/main/java/rocks/poopjournal/morse/EditTextTouch.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package rocks.poopjournal.morse;

import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.EditText;

public class EditTextTouch extends android.support.v7.widget.AppCompatEditText {
@SuppressLint("AppCompatCustomView")
public class EditTextTouch extends EditText {
public EditTextTouch(Context context) {
super(context);
}
Expand Down
Loading

0 comments on commit a581bdd

Please sign in to comment.