Commit 9991f998 authored by fpeterfalvi's avatar fpeterfalvi
Browse files

Choosing of question file improved.

The name of the chosen file is displayed and a default file is added if no file is chosen manually.
parent 5fe59cec
Hogyan írjuk arab számmal a következő római számot: CXLVII? 147
Mi az 10011 kettes számrendszerbeli szám tizes számrendszerbeli alakja? 19
Melyik évben volt a mohácsi csata? 1526
Melyik a legnagyobb egyjegyű prímszám? 7
Hány éle van egy kockának? 12
Hányadik kerületben van a BME? 11
Hány kétjegyű szám van? 90
Hány napos hónap április? 30
Ha egy négyzet oldalát kétszeresére növeljük, hányszorosára nő a területe? 4
Hányas számú metró közlekedik Kelenföld és a Keleti pályaudvar között? 4
......@@ -39,11 +39,15 @@ public class GameActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_game);
Bundle extras = getIntent().getExtras();
String questionFileName = extras.getString("QUESTION_FILE_NAME");
String questionFileName = extras.getString("QUESTION_FILE_NAME", null);
BufferedReader buffreader;
try {
buffreader = new BufferedReader(new InputStreamReader(new FileInputStream(new File(questionFileName))));
if (questionFileName == null) {
buffreader = new BufferedReader(new InputStreamReader(getAssets().open("defaultQuestions.txt")));
} else {
buffreader = new BufferedReader(new InputStreamReader(new FileInputStream(new File(questionFileName))));
}
String line;
while ((line = buffreader.readLine()) != null) {
String[] parts = line.split("\t");
......
......@@ -86,7 +86,7 @@ public class LobbyActivity extends AppCompatActivity {
HOSTNAME = "";
} else {
HOSTNAME = extras.getString("STRING_HOSTNAME");
questionFileName = extras.getString("QUESTION_FILE_NAME");
questionFileName = extras.getString("QUESTION_FILE_NAME", null);
}
} else {
HOSTNAME = (String) savedInstanceState.getSerializable("STRING_HOSTNAME");
......
......@@ -55,6 +55,8 @@ public class MainActivity extends AppCompatActivity implements FileDialog.OnFile
public void onFileSelected(FileDialog dialog, File file) {
try {
fileCanonicalPath = file.getCanonicalPath();
TextView questionFileTextView = (TextView) findViewById(R.id.QuestionFileTextView);
questionFileTextView.setText(fileCanonicalPath);
Log.d("MainActivity", fileCanonicalPath);
} catch (IOException e) {
e.printStackTrace();
......
......@@ -10,7 +10,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Server name!"
android:text="Server name:"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
......@@ -28,16 +28,37 @@
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.231" />
<Button
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Choose question file"
android:id="@+id/ChooseQuestionFile"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.433" />
app:layout_constraintVertical_bias="0.453">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Question file:" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=""
android:id="@+id/QuestionFileTextView" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Browse"
android:id="@+id/ChooseQuestionFile" />
</LinearLayout>
<Button
android:layout_width="wrap_content"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment