Skip to content

Commit

Permalink
Add persistent account and fixed some errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
j4rvis committed Jun 8, 2017
1 parent 70cdeef commit 696270c
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 39 deletions.
43 changes: 33 additions & 10 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,20 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
Expand All @@ -90,6 +90,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/multi-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
Expand Down Expand Up @@ -117,13 +118,35 @@
<orderEntry type="library" exported="" name="constraint-layout-1.0.2" level="project" />
<orderEntry type="library" exported="" name="support-core-utils-24.2.1" level="project" />
<orderEntry type="library" exported="" name="rxandroid-1.1.0" level="project" />
<orderEntry type="library" exported="" name="commons-cli-1.2" level="project" />
<orderEntry type="library" exported="" name="stetho-1.5.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-24.2.1" level="project" />
<orderEntry type="library" exported="" name="multidex-1.0.1" level="project" />
<orderEntry type="library" exported="" name="cardview-v7-24.2.1" level="project" />
<orderEntry type="library" exported="" name="jsr305-2.0.1" level="project" />
<orderEntry type="library" exported="" name="design-24.2.1" level="project" />
<orderEntry type="module" module-name="api" exported="" />
<orderEntry type="library" exported="" scope="TEST" name="runner-0.5" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="espresso-idling-resource-2.2.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-library-1.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-integration-1.3" level="project" />
<orderEntry type="library" exported="" name="sharkfw-core-1.0-SNAPSHOT" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="jsr305-2.0.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="espresso-core-2.2.2" level="project" />
<orderEntry type="library" exported="" name="guava-18.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="exposed-instrumentation-api-publish-0.5" level="project" />
<orderEntry type="library" exported="" name="sqldroid-1.0.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="rules-0.5" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="uiautomator-v18-2.1.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="javax.annotation-api-1.2" level="project" />
<orderEntry type="library" exported="" name="lorem-2.1" level="project" />
<orderEntry type="library" exported="" name="sqlite-jdbc-3.16.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="javax.inject-1" level="project" />
<orderEntry type="library" exported="" name="annotations-2.0.1" level="project" />
<orderEntry type="library" exported="" name="rxjava-1.1.0" level="project" />
<orderEntry type="library" exported="" name="android-activation-1.5.5" level="project" />
<orderEntry type="library" exported="" name="android-mail-1.5.5" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="javawriter-2.1.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
<orderEntry type="library" exported="" name="javassist-3.18.2-GA" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
<orderEntry type="library" exported="" name="reflections-0.9.10" level="project" />
</component>
</module>
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,5 @@ dependencies {
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.facebook.stetho:stetho:1.5.0'
compile project(':api')
}
12 changes: 2 additions & 10 deletions app/src/main/java/net/sharksystem/sharknet/SharkApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import android.support.multidex.MultiDex;
import android.support.multidex.MultiDexApplication;

import com.facebook.stetho.Stetho;

import net.sharksystem.api.models.Chat;
import net.sharksystem.api.models.Contact;
import net.sharksystem.api.models.Message;
Expand All @@ -30,12 +28,6 @@ public SharkApp() {
MultiDex.install(this);
}

@Override
public void onCreate() {
super.onCreate();
Stetho.initializeWithDefaults(this);
}

public static Context getContext() {
return instance;
}
Expand Down Expand Up @@ -84,11 +76,11 @@ public void resetMessage() {
this.message = null;
}

public void activateDummy(){
public void activateDummy() {
isDummy = true;
}

public boolean isDummy(){
public boolean isDummy() {
return isDummy;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ public void onClick(DialogInterface dialog,int id) {
} else {
if(getSharkApp().isDummy()) onCreateDummyDataSelected();
}

if(mApi.getAccount()!=null){
mStartupFragment.showOldUSerButton();
}
}


Expand Down Expand Up @@ -144,7 +148,7 @@ public void onError(Throwable error) {

@Override
public void onUsePreviousProfileSelected() {
Toast.makeText(this, "This is not yet supported.", Toast.LENGTH_SHORT).show();
onSuccess();
}

@Override
Expand All @@ -168,6 +172,7 @@ public void onCreateProfile(final Contact contact) {
Single<Object> single = Single.fromCallable(new Callable<Object>() {
@Override
public Object call() throws Exception {
mApi.clearDbs();
mApi.setAccount(contact);
getSharkApp().setAccount(mApi.getAccount());
mApi.initPki();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

public class StartupFragment extends Fragment implements View.OnClickListener {

private View mPreviousAccount;

public interface StartupFragmentButtonListener{
void onCreateNewProfileSelected();
void onCreateDummyDataSelected();
Expand Down Expand Up @@ -43,7 +45,9 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
View view = inflater.inflate(R.layout.main_startup_fragment, container, false);

// view.findViewById(R.id.button_create_dummy_data).setOnClickListener(this);
view.findViewById(R.id.button_use_previous_profile).setOnClickListener(this);
mPreviousAccount = view.findViewById(R.id.button_use_previous_profile);
mPreviousAccount.setOnClickListener(this);
mPreviousAccount.setVisibility(View.GONE);
view.findViewById(R.id.button_create_new_profile).setOnClickListener(this);

return view;
Expand All @@ -65,4 +69,7 @@ public void onClick(View v) {
break;
}
}
public void showOldUSerButton(){
mPreviousAccount.setVisibility(View.VISIBLE);
}
}
32 changes: 17 additions & 15 deletions app/src/main/java/net/sharksystem/sharknet/nfc/NFCActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,21 +135,23 @@ public void run() {
onPublicKeyDialog.dismiss();
}

AlertDialog.Builder builder = new AlertDialog.Builder(NFCActivity.this);
builder.setMessage("We received " + certificates.size() + " certificates from " + certificates.get(0).getSigner().getName() + ". There where also " + contacts.size() + " Contacts" + ". Do you want to include them?").setTitle("New Certificates and Contacts");
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mNfcPkiPortEventListener.onCertificatesDecision(true);
}
}).setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mNfcPkiPortEventListener.onCertificatesDecision(false);
}
});
onCertificateDialog = builder.create();
onCertificateDialog.show();
if(!certificates.isEmpty()){
AlertDialog.Builder builder = new AlertDialog.Builder(NFCActivity.this);
builder.setMessage("We received " + certificates.size() + " certificates from " + certificates.get(0).getSigner().getName() + ". There where also " + contacts.size() + " Contacts" + ". Do you want to include them?").setTitle("New Certificates and Contacts");
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mNfcPkiPortEventListener.onCertificatesDecision(true);
}
}).setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mNfcPkiPortEventListener.onCertificatesDecision(false);
}
});
onCertificateDialog = builder.create();
onCertificateDialog.show();
}
}
});
}
Expand Down

0 comments on commit 696270c

Please sign in to comment.