Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "21.1.2"

buildToolsVersion = project.ANDROID_BUILD_TOOLS_VERSION
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)

defaultConfig {
applicationId "net.rehacktive.waspdbexample"
minSdkVersion 14
targetSdkVersion 22
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
versionCode 2
versionName "1.1"
}
Expand All @@ -18,14 +19,13 @@ android {
}
}


lintOptions {
abortOnError false
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile project(':waspdb')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation project(':waspdb')
}
208 changes: 107 additions & 101 deletions app/src/main/java/net/rehacktive/waspdbexample/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.rehacktive.waspdbexample;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand All @@ -17,104 +17,110 @@
import java.util.ArrayList;
import java.util.List;

public class MainActivity extends ActionBarActivity {

ProgressBar progressBar;
// wasp objects
WaspDb db;
WaspHash hash;
WaspObserver observer;

UserAdapter adapter;

@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

progressBar = (ProgressBar) findViewById(R.id.progressBar);

ListView userList = (ListView) findViewById(R.id.userlist);
adapter = new UserAdapter(this);
userList.setAdapter(adapter);

if(db==null) {
progressBar.setVisibility(View.VISIBLE);
WaspFactory.openOrCreateDatabase(getFilesDir().getPath(), "example", "Passw0rd", new WaspListener<WaspDb>() {
@Override
public void onDone(WaspDb waspDb) {
db = waspDb;
hash = db.openOrCreateHash("users");

progressBar.setVisibility(View.INVISIBLE);

getUsers();

observer = new WaspObserver() {
@Override
public void onChange() {
List<User> users = hash.getAllValues();
adapter.setUsers(users);
adapter.notifyDataSetChanged();
}
};

hash.register(observer);
}
});
}
}

private void getUsers() {
List<User> users = hash.getAllValues();
if(users==null)
users = new ArrayList<>();

adapter.setUsers(users);
adapter.notifyDataSetChanged();
}

private void addUser() {
User user = new User("user "+System.currentTimeMillis(), "");
hash.put(user.getUser_name(),user);
}

private void flushUsers() {
hash.flush();
}

@Override
protected void onDestroy() {
super.onDestroy();
hash.unregister(observer);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == R.id.add_user) {
addUser();
return true;
}

if (id == R.id.flush_user) {
flushUsers();
return true;
}

return super.onOptionsItemSelected(item);
}
/**
* Edited by AndroidMarv
* Removed ActionBarActivity
* reason Deprecation
*/

public class MainActivity extends Activity {

ProgressBar progressBar;
// wasp objects
WaspDb db;
WaspHash hash;
WaspObserver observer;

UserAdapter adapter;

@Override
protected void onCreate (Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

progressBar = (ProgressBar) findViewById(R.id.progressBar);

ListView userList = (ListView) findViewById(R.id.userlist);
adapter = new UserAdapter(this);
userList.setAdapter(adapter);

if ( db == null ) {
progressBar.setVisibility(View.VISIBLE);
WaspFactory.openOrCreateDatabase(getFilesDir().getPath(), "example", "Passw0rd", new WaspListener<WaspDb>() {
@Override
public void onDone (WaspDb waspDb) {
db = waspDb;
hash = db.openOrCreateHash("users");

progressBar.setVisibility(View.INVISIBLE);

getUsers();

observer = new WaspObserver() {
@Override
public void onChange () {
List<User> users = hash.getAllValues();
adapter.setUsers(users);
adapter.notifyDataSetChanged();
}
};

hash.register(observer);
}
});
}
}

private void getUsers () {
List<User> users = hash.getAllValues();
if ( users == null )
users = new ArrayList<>();

adapter.setUsers(users);
adapter.notifyDataSetChanged();
}

private void addUser () {
User user = new User("user " + System.currentTimeMillis(), "");
hash.put(user.getUser_name(), user);
}

private void flushUsers () {
hash.flush();
}

@Override
protected void onDestroy () {
super.onDestroy();
hash.unregister(observer);
}

@Override
public boolean onCreateOptionsMenu (Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected (MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if ( id == R.id.add_user ) {
addUser();
return true;
}

if ( id == R.id.flush_user ) {
flushUsers();
return true;
}

return super.onOptionsItemSelected(item);
}
}
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.android.tools.build:gradle:3.5.0-alpha06'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand All @@ -14,5 +15,6 @@ buildscript {
allprojects {
repositories {
jcenter()
google()
}
}
8 changes: 6 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
org.gradle.parallel=true

ANDROID_BUILD_TARGET_SDK_VERSION=28
ANDROID_BUILD_TOOLS_VERSION=28.0.3
ANDROID_BUILD_SDK_VERSION=28
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue May 10 18:13:21 BST 2016
#Mon Mar 11 15:27:29 IST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
14 changes: 7 additions & 7 deletions waspdb/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ android {
exclude 'META-INF/LGPL2.1'
}

compileSdkVersion 22
buildToolsVersion "21.1.2"
buildToolsVersion = project.ANDROID_BUILD_TOOLS_VERSION
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)

defaultConfig {
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
versionCode 2
versionName "1.0.1"
}

lintOptions {
Expand All @@ -51,8 +51,8 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.esotericsoftware:kryo:3.0.3'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.esotericsoftware:kryo:3.0.3'
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,7 @@ public class CipherManager {
protected static CipherManager instance = null;

private CipherManager() {
// Security.insertProviderAt(new org.spongycastle.jce.provider.BouncyCastleProvider(), 1);
// Provider[] providers = Security.getProviders();
// for (Provider provider : providers) {
// Log.i("CRYPTO","provider: "+provider.getName());
// Set<Provider.Service> services = provider.getServices();
// for (Provider.Service service : services) {
// Log.i("CRYPTO"," key_algorithm: "+service.getAlgorithm());
// }
// }
// Empty constructor
}

public static CipherManager getInstance(char[] p, byte[] s) {
Expand Down