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: 0 additions & 1 deletion .idea/misc.xml

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

11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Quest Weaver

Einleitung: ChatGPT zu einen Dungeons and Dragons Dungeon Master gemacht, der anhand der deines Charakters, der in den Einstellungen erstellt wird, eine DnD Session mit dir macht.

Anforderungen: Eine DnD Session mit seinem Charakter automatisch, ohne dass der User jedes Mal auf neues ChatGPT sein Character sagen muss.

Umsetzung: Weitere Einstellungen hinzugefügt für den Namen und Geschlecht des Charakters und ein Drop Down für der Klasse. Diese werden ausgelesen und an ChatGPT als „System" Nachricht immer beim Erstellen eines neun Chat gegeben damit ChatGPT diese Informationen immer zu Verfügung hat. Da es System Nachrichten sind kann der User sie auch nicht sehen. Außerdem wurde ChatGPT gesagt das er wie ein Dungeon Master handeln soll und auch dein Charakter leveln soll und man ggf. einen D20 würfeln muss, und je nach Ergebnis bestimmte Aktion erfolgreich oder nicht erfolgreich ausführen zu können. Der Name der App sowohl als auch das Icon wurde entsprechend angepasst.

Probleme/Lessons learned: Zeitdruck; zu viel angesetzt für die kurze Zeit. Speichern der Sessions war geplant aber leider in dem Zeitumfang nicht umsetzbar. Automatisches Starten der Session anstatt einer Nachricht mit „Starte" zu senden hatte sich als komplizierter herausgestellt als gedacht. Übersetzung von der App vom Englischen ins Deutsche war wegen dem Zeitdruck und teils Hardgecodeten Strings auch nicht möglich.

Fazit: Besser Einschätzen, Viel Zeitdruck
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
minSdk 27
targetSdk 34
versionCode 1
versionName "1.0"
versionName "69.420"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@drawable/openai_logomark"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@drawable/openai_logomark"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.ChatGpt"
tools:targetApi="31">
Expand Down
Binary file added app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 15 additions & 12 deletions app/src/main/java/de/fhdw/app_entwicklung/chatgpt/MainFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import de.fhdw.app_entwicklung.chatgpt.model.Author;
import de.fhdw.app_entwicklung.chatgpt.model.Chat;
import de.fhdw.app_entwicklung.chatgpt.model.Message;
import de.fhdw.app_entwicklung.chatgpt.openai.ChatGpt;
import de.fhdw.app_entwicklung.chatgpt.openai.IChatGpt;
import de.fhdw.app_entwicklung.chatgpt.openai.MockChatGpt;
import de.fhdw.app_entwicklung.chatgpt.speech.LaunchSpeechRecognition;
Expand All @@ -33,19 +34,21 @@ public class MainFragment extends Fragment {
private TextToSpeechTool textToSpeech;
private Chat chat;

private boolean first = true;

private final ActivityResultLauncher<LaunchSpeechRecognition.SpeechRecognitionArgs> getTextFromSpeech = registerForActivityResult(
new LaunchSpeechRecognition(),
query -> {
Message userMessage = new Message(Author.User, query);
chat.addMessage(userMessage);
if (chat.getMessages().size() > 1) {
getTextView().append(CHAT_SEPARATOR);
}
getTextView().append(toString(userMessage));
scrollToEnd();
Message userMessage = new Message(Author.User, query);
chat.addMessage(userMessage);
if (chat.getMessages().size() > 1) {
getTextView().append(CHAT_SEPARATOR);
}
getTextView().append(toString(userMessage));
scrollToEnd();

MainActivity.backgroundExecutorService.execute(() -> {
IChatGpt chatGpt = new MockChatGpt(prefs.getApiToken(), prefs.getModel());
ChatGpt chatGpt = new ChatGpt(prefs.getApiToken(), prefs.getModel());
String answer = chatGpt.getChatCompletion(chat);

Message answerMessage = new Message(Author.Assistant, answer);
Expand Down Expand Up @@ -77,20 +80,20 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat

prefs = new PrefsFacade(requireContext());
textToSpeech = new TextToSpeechTool(requireContext(), prefs.getLocale());

if (savedInstanceState != null) {
chat = savedInstanceState.getParcelable(EXTRA_DATA_CHAT);
} else {
chat = createNewChat();
}
getAskButton().setOnClickListener(v ->
getTextFromSpeech.launch(new LaunchSpeechRecognition.SpeechRecognitionArgs(prefs.getLocale())));

getAskButton().setOnClickListener(v ->
getTextFromSpeech.launch(new LaunchSpeechRecognition.SpeechRecognitionArgs(prefs.getLocale())));
getResetButton().setOnClickListener(v -> {
chat = createNewChat();
updateTextView();
});
updateTextView();
getTextView().setText("To start the game press ’Ask’ and then say Start!");
}

@Override
Expand Down Expand Up @@ -135,7 +138,7 @@ private void scrollToEnd() {

private Chat createNewChat() {
Chat chat = new Chat();
chat.addMessage(new Message(Author.System, prefs.getSpeakingStyle()));
chat.addMessage(new Message(Author.System,"You are an Dungeon Master for the Game ’Dungeons and Dragons’. You will behave like a Dungeon Master. I Have a "+ prefs.getGender() +" Level 1 " + prefs.getUserClass() + " character named ’"+ prefs.getName()+"’ that is starting a new quest that you are creating. Make Sure that the player can earn Experience and Level up, aswell as that he has to roll on certian actions to see if he succeeded in the action or not."));
return chat;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ public String getSpeakingStyle() {
throw new RuntimeException("Speaking style not supported: " + style);
}
}
public String getUserClass() {
return PreferenceManager.getDefaultSharedPreferences(context).getString("UserClass", "None");
}
public String getName() {
return PreferenceManager.getDefaultSharedPreferences(context).getString("Name", "None");
}
public String getGender() {
return PreferenceManager.getDefaultSharedPreferences(context).getString("Gender", "");
}

public String getModel() {
return PreferenceManager.getDefaultSharedPreferences(context).getString("model_type", "gpt-3.5-turbo");
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/fragment_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ask"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/button_reset"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/button_reset"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/scrollview" />

<Button
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/res/layout/settings_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
<FrameLayout
android:id="@+id/settings"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent" >


</FrameLayout>
</LinearLayout>
5 changes: 5 additions & 0 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
5 changes: 5 additions & 0 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
Binary file added app/src/main/res/mipmap-hdpi/ic_launcher.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-mdpi/ic_launcher.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xhdpi/ic_launcher.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
<string name="api_configuration">API-Konfiguration</string>
<string name="api_token">API-Token</string>
<string name="openai_model">OpenAI-Modell</string>
<string name="Userclass">Klasse</string>
<string name="gender">Geschlecht</string>
</resources>
20 changes: 20 additions & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,26 @@
<item>en</item>
</string-array>

<string-array name="Userclass">
<item>Barbarian</item>
<item>Bard</item>
<item>Cleric</item>
<item>Druid</item>
<item>Fighter</item>
<item>Monk</item>
<item>Paladin</item>
<item>Ranger</item>
<item>Rouge</item>
<item>Sorcerer</item>
<item>Warlock</item>
<item>Wizard</item>
</string-array>

<string-array name="gender">
<item>Male</item>
<item>Female</item>
</string-array>

<!-- Speaking styles -->
<string-array name="speaking_style_entries">
<item>Neutral</item>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#FFFFFF</color>
</resources>
4 changes: 3 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<resources>
<string name="app_name" translatable="false">ChatGpt</string>
<string name="ask">Ask</string>
<string name="settings">Settings</string>
<string name="reset">Reset</string>
Expand All @@ -11,4 +10,7 @@
<string name="api_configuration">API configuration</string>
<string name="api_token">API token</string>
<string name="openai_model">OpenAI model</string>
<string name="Userclass">Class</string>
<string name="gender">Gender</string>
<string name="app_name" translatable="false">Quest Weaver</string>
</resources>
39 changes: 26 additions & 13 deletions app/src/main/res/xml/root_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,36 @@
app:key="language"
app:title="@string/language"
app:useSimpleSummaryProvider="true" />
<ListPreference
android:defaultValue="neutral"
android:entries="@array/speaking_style_entries"
android:entryValues="@array/speaking_style_values"
android:key="speaking_style"
android:title="@string/style_of_speaking"
app:useSimpleSummaryProvider="true" />
<EditTextPreference
android:key="custom_speaking_style"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/custom_style_of_speaking"
app:useSimpleSummaryProvider="true" />
<CheckBoxPreference
android:defaultValue="true"
android:key="read_out_loud"
android:title="@string/read_chatgpt_s_answer_out_loud" />
<EditTextPreference
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:key="Name"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="Name"
app:useSimpleSummaryProvider="true" />
<ListPreference
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:defaultValue="neutral"
android:entries="@array/Userclass"
android:entryValues="@array/Userclass"
android:key="UserClass"
android:title="@string/Userclass"
app:useSimpleSummaryProvider="true" />
<ListPreference
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:defaultValue="none"
android:entries="@array/gender"
android:entryValues="@array/gender"
android:key="Gender"
android:title="@string/gender"
app:useSimpleSummaryProvider="true" />

</PreferenceCategory>

Expand Down