Skip to content

Commit

Permalink
0.9.9 Release
Browse files Browse the repository at this point in the history
Added signup, tests checking
  • Loading branch information
asoluter committed Nov 23, 2015
1 parent d919267 commit 75e79c3
Show file tree
Hide file tree
Showing 34 changed files with 559 additions and 111 deletions.
2 changes: 1 addition & 1 deletion .idea/dbnavigator.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 9 additions & 16 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -65,39 +65,32 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/cardview-v7/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/cardview-v7/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/resources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="cardview-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.0.1" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.1.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.1.1" level="project" />
<orderEntry type="library" exported="" name="cardview-v7-23.1.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" />
<orderEntry type="library" exported="" name="design-23.0.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.0.1" level="project" />
</component>
</module>
18 changes: 12 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
android:allowBackup="true"
Expand All @@ -20,19 +20,19 @@
<activity
android:name=".LoginActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.Dark"
android:screenOrientation="portrait">
android:screenOrientation="portrait"
android:theme="@style/AppTheme.Dark" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />


<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SignupActivity"
android:label="@string/title_activity_signup"
android:parentActivityName=".LoginActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.Dark" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
Expand All @@ -48,8 +48,7 @@
</activity>
<activity
android:name=".TestActivity"
android:label="@string/title_activity_test"
android:parentActivityName=".ChooseTestActivity" >
android:label="@string/title_activity_test">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.asoluter.litest.ChooseTestActivity" />
Expand All @@ -62,6 +61,13 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="com.asoluter.litest.MainActivity" />
</activity>
<activity
android:name=".AnsverActivity"
android:label="@string/title_activity_ansver"

android:theme="@style/AppTheme" >

</activity>
</application>

</manifest>
35 changes: 35 additions & 0 deletions app/src/main/java/com/asoluter/litest/AnsverActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.asoluter.litest;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;

import com.asoluter.litest.Objects.Strings;

public class AnsverActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ansver);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

TextView ansText=(TextView)findViewById(R.id.ansText);
ansText.setText(getIntent().getStringExtra(Strings.TEST_RESULT));

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
// .setAction("Action", null).show();
}
});
}

}

This file was deleted.

76 changes: 65 additions & 11 deletions app/src/main/java/com/asoluter/litest/ChooseTestActivity.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.asoluter.litest;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
Expand All @@ -12,29 +16,51 @@
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.asoluter.litest.Objects.AnsObject;
import com.asoluter.litest.Objects.AuthObject;
import com.asoluter.litest.Objects.Pair;
import com.asoluter.litest.Objects.Strings;
import com.asoluter.litest.Objects.TypingObject;
import com.asoluter.litest.Services.Broadcasts.Broadcasts;
import com.asoluter.litest.Services.DBHelper.DBHelper;
import com.asoluter.litest.Services.ServerRequest;
import com.asoluter.litest.Tests.TestsCover;

import java.util.ArrayList;


public class ChooseTestActivity extends AppCompatActivity {

private Toolbar toolbar;
private ListView chooseList;
Context context;
private Context contextt;
private ArrayAdapter<String> dataAdapter;
private int cont_pos;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_choose_test);
context=this;
contextt =this;

initToolbar();

chooseList=(ListView)findViewById(R.id.choose_test_list);

setTests(getIntent().getIntExtra(
getString(R.string.contest_pos)
,0));
getString(R.string.contest_pos),0));

BroadcastReceiver ansReceiver=new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {

Intent ansIntent=new Intent(contextt,AnsverActivity.class);
ansIntent.putExtra(Strings.TEST_RESULT,intent.getStringExtra(Strings.TEST_RESULT));
startActivity(ansIntent);
}
};
IntentFilter filter=new IntentFilter(Broadcasts.BROADCAST_ANSVER);
registerReceiver(ansReceiver,filter);
}

@Override
Expand All @@ -52,9 +78,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();

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


return super.onOptionsItemSelected(item);
}
Expand All @@ -63,37 +87,67 @@ protected void setTests(int position){
dataAdapter=new ArrayAdapter<String>(getApplicationContext(),
R.layout.contest_list,
TestsCover.getTests(position));

cont_pos=position;
chooseList.setAdapter(dataAdapter);

chooseList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent testStart=new Intent(context,TestActivity.class);
Intent testStart=new Intent(contextt,TestActivity.class);
testStart.putExtra(getString(R.string.test_pos), position);
testStart.putExtra(getString(R.string.contest_pos), cont_pos);
testStart.putExtra(getString(R.string.quest),
TestsCover.quests.get(position));
startActivity(testStart);
}
});
}

private static final String GET_ANSVERS="select cont_id,test_id,ans_id from ansvers where ((user=?)and(cont_id=?))";

protected void initToolbar(){
toolbar=(Toolbar)findViewById(R.id.choose_test_toolbar);

setSupportActionBar(toolbar);

if(getSupportActionBar()!=null){
getSupportActionBar().setTitle(R.string.app_name);
getSupportActionBar().setTitle(R.string.tests);

}

toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()){
case R.id.action_send:{
SQLiteDatabase database=new DBHelper(contextt).getReadableDatabase();

String login=getSharedPreferences("login",MODE_PRIVATE).getString("login", "");
AuthObject auth_obj=new AuthObject(login,getSharedPreferences("login",MODE_PRIVATE).getString("pass",""));

Cursor cursor=database.rawQuery(GET_ANSVERS, new String[]{login, String.valueOf(cont_pos)});
cursor.moveToFirst();

ArrayList<AnsObject> ansvers=new ArrayList<>();
if (cursor.getCount()>0)
do{
ansvers.add(new AnsObject(cursor.getInt(0),cursor.getInt(1),cursor.getInt(2)));
}while (cursor.moveToNext());

cursor.close();

TypingObject typingObject=new TypingObject(Strings.TEST,new Pair(auth_obj,ansvers));
Intent intent=new Intent(contextt, ServerRequest.class);
intent.putExtra(Strings.COMMAND,typingObject);
startService(intent);

break;
}
}
return false;
}
});

toolbar.inflateMenu(R.menu.menu_toolbar);
toolbar.inflateMenu(R.menu.menu_choose_test);
}
}
9 changes: 6 additions & 3 deletions app/src/main/java/com/asoluter/litest/LoginActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ protected void onCreate(Bundle savedInstanceState) {
loginButton=(Button)findViewById(R.id.loginButton);
signupButton=(Button)findViewById(R.id.signupButon);


mail.setText(getSharedPreferences("login", MODE_PRIVATE).getString("login", ""));
pass.setText(getSharedPreferences("login",MODE_PRIVATE).getString("pass",""));

initToolbar();

cyclingAsync=new CyclingAsync(this);
Expand Down Expand Up @@ -149,13 +153,12 @@ private void onLogin(){

saveCreds();


TypingObject context=new TypingObject(Strings.AUTH, new NullObject());
TypingObject typingObject=new TypingObject(Strings.AUTH, new NullObject());

//cyclingAsync.execute();

service=new Intent(this,ServerRequest.class);
service.putExtra(Strings.COMMAND, context);
service.putExtra(Strings.COMMAND, typingObject);
startService(service);

}
Expand Down
34 changes: 33 additions & 1 deletion app/src/main/java/com/asoluter/litest/Objects/AnsObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,38 @@
import java.io.Serializable;

public class AnsObject implements Serializable {
//TODO: Make object for answers
private int cont_id;
private int test_id;
private int ans_id;

public int getCont_id() {
return cont_id;
}

public void setCont_id(int cont_id) {
this.cont_id = cont_id;
}

public int getTest_id() {
return test_id;
}

public void setTest_id(int test_id) {
this.test_id = test_id;
}

public int getAns_id() {
return ans_id;
}

public void setAns_id(int ans_id) {
this.ans_id = ans_id;
}

public AnsObject(int cont_id, int test_id, int ans_id) {
this.cont_id = cont_id;

this.test_id = test_id;
this.ans_id = ans_id;
}
}
Loading

0 comments on commit 75e79c3

Please sign in to comment.