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
1 change: 1 addition & 0 deletions .idea/.name

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

463 changes: 463 additions & 0 deletions .idea/dbnavigator.xml

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion .idea/gradle.xml

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

6 changes: 6 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.

39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
# AndroidOracle
# AndroidOracle

## Preview
1. This project uses jdk 8;
2. Navigation is built on activities;
3. Use Service and Binding and use HandlerThread for generate result in your question.

## Features
☑️Main screen with buttons:
- Ask a question,
- Settings,
- Quit;

<br>☑️Settings screen that allows you to edit user information:
- name (text field),
- last name (text field),
- date of birth (display in text, change the date using DatePickerDialog),
- gender (RadioButton);

<br>☑️Screen for questions:
- the user enters a question and clicks the "Generate" button,
- the program responds with one of the following options: "Yes", "No", "Of course", "Maybe", "Are you sure?", "Great", "Wonderful", "Right?", "Maybe we should not?", "Please, repeat", "No more words, silence", "Are you sleeping now?", "Don't know", "Who cares"
- the answer is generated based on the following data: entered question, information about user, current date.
- for the same input data, the answer must be the same.

## Launch guide
To run this project you will need to install this project in phone with Android Operating System.

## Program testing
### Main Menu
![Main Menu](app/src/main/res/img/main.jpg)
![Main Menu](app/src/main/res/img/main_land.jpg)
### Settings
![Settings](app/src/main/res/img/setting.jpg)
![Settings](app/src/main/res/img/setting_land.jpg)
### Ask a question
![Ask a question](app/src/main/res/img/ask_a_question_done.jpg)
![Ask a question](app/src/main/res/img/ask_a_question_done_land.jpg)
13 changes: 6 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android {
buildToolsVersion "30.0.2"

defaultConfig {
applicationId "ua.gura.com.example.andriodoracle"
applicationId "ua.gura.com.example.androidoracle"
minSdkVersion 19
targetSdkVersion 30
versionCode 1
Expand All @@ -29,11 +29,10 @@ android {
}

dependencies {

implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ua.gura.com.example.andriodoracle;
package ua.gura.com.example.androidoracle;

import android.content.Context;

Expand All @@ -21,6 +21,6 @@ public class ExampleInstrumentedTest {
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("ua.gura.com.example.andriodoracle", appContext.getPackageName());
assertEquals("ua.gura.com.example.androidoracle", appContext.getPackageName());
}
}
21 changes: 18 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ua.gura.com.example.andriodoracle">
package="ua.gura.com.example.androidoracle">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AndriodOracle">
<activity android:name=".MainActivity">
android:theme="@style/Theme.AndroidOracle">
<activity android:name=".activities.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activities.MenuActivity"
android:label="MenuActivity" />
<activity
android:name=".activities.SettingActivity"
android:label="Settings" />
<activity
android:name=".activities.QuestionActivity"
android:label="Question" />
<activity
android:name=".activities.BaseActivity"
android:label="BaseActivity" />

<service android:name=".generator.GenerateAnswerService" />

</application>

</manifest>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package ua.gura.com.example.androidoracle.activities;

import androidx.appcompat.app.AppCompatActivity;

public class BaseActivity extends AppCompatActivity {
public void cancel() {
finish();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package ua.gura.com.example.androidoracle.activities;

import androidx.annotation.Nullable;

import android.content.Intent;
import android.os.Bundle;

import ua.gura.com.example.androidoracle.R;

public class MainActivity extends BaseActivity {

@Override
protected void onCreate(@Nullable Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); // устанавливается разметка
if (savedInstanceState == null) {
Intent intent = new Intent(this, MenuActivity.class);
startActivity(intent);
}
cancel();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package ua.gura.com.example.androidoracle.activities;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.Nullable;

import ua.gura.com.example.androidoracle.BuildConfig;
import ua.gura.com.example.androidoracle.R;
import ua.gura.com.example.androidoracle.model.User;


public class MenuActivity extends BaseActivity {
private Button setQuestion;
private User user;

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
Bundle bundle = getIntent().getExtras();
if (bundle != null) {
user = (User) bundle.get("USER");
}
findViewById(R.id.settingButton)
.setOnClickListener(v -> {
Intent intent = new Intent(this, SettingActivity.class);
startActivity(intent);
});
findViewById(R.id.quitButton)
.setOnClickListener(v -> {
cancel();
});

setQuestion = findViewById(R.id.setQuestionButton);
setQuestion.setOnClickListener(v -> {
System.out.println(user);
Intent intent = new Intent(this, QuestionActivity.class);
intent.putExtra("USER", user);
startActivity(intent);
});

TextView versionEditText = findViewById(R.id.versionTextView);

if (versionEditText != null) {
versionEditText.setText(getString(
R.string.app_version,
BuildConfig.VERSION_NAME
));
}
updateView();
}

private void updateView() {
System.out.println(user);
setQuestion.setEnabled(user != null
&& user.isValid());
}
}
Loading