Skip to content

Commit

Permalink
Reformat code (closes #3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustl22 committed Nov 13, 2020
1 parent 967d3e7 commit 58ec835
Show file tree
Hide file tree
Showing 91 changed files with 967 additions and 743 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;

/**
* Instrumented test, which will execute on an Android device.
Expand Down
88 changes: 65 additions & 23 deletions tree-app-android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
xmlns:tools="http://schemas.android.com/tools"
package="de.lmu.treeapp">

<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" />
<uses-feature
android:name="android.hardware.camera"
android:required="true" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />

<application
android:allowBackup="true"
Expand All @@ -16,42 +20,80 @@
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning,LockedOrientationActivity">

<activity android:name=".activities.minigames.chooseAnswer.GameActivity_ChooseAnswer" android:parentActivityName="activities.GameSelectionActivity">
<meta-data android:name="android.support.PARENT_ACTIVITY" android:value="activities.MainActivity" />
</activity>
<activity android:name=".activities.minigames.inputString.GameActivity_InputString" android:parentActivityName="activities.GameSelectionActivity">
<meta-data android:name="android.support.PARENT_ACTIVITY" android:value="activities.MainActivity" />
<activity
android:name=".activities.minigames.chooseAnswer.GameActivity_ChooseAnswer"
android:parentActivityName="activities.GameSelectionActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="activities.MainActivity" />
</activity>
<activity android:name=".activities.minigames.takePicture.GameActivity_TakePicture" android:parentActivityName="activities.GameSelectionActivity">
<meta-data android:name="android.support.PARENT_ACTIVITY" android:value="activities.MainActivity" />
<activity
android:name=".activities.minigames.inputString.GameActivity_InputString"
android:parentActivityName="activities.GameSelectionActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="activities.MainActivity" />
</activity>
<activity android:name=".activities.minigames.dragDrop.GameActivity_DragDrop" android:parentActivityName="activities.GameSelectionActivity">
<meta-data android:name="android.support.PARENT_ACTIVITY" android:value="activities.MainActivity" />
<activity
android:name=".activities.minigames.takePicture.GameActivity_TakePicture"
android:parentActivityName="activities.GameSelectionActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="activities.MainActivity" />
</activity>
<activity android:name=".activities.minigames.onlyDescription.GameActivity_OnlyDescription" android:parentActivityName="activities.GameSelectionActivity">
<meta-data android:name="android.support.PARENT_ACTIVITY" android:value="activities.MainActivity" />
<activity
android:name=".activities.minigames.dragDrop.GameActivity_DragDrop"
android:parentActivityName="activities.GameSelectionActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="activities.MainActivity" />
</activity>
<activity android:name=".activities.minigames.baumory.GameActivity_Baumory" android:parentActivityName="activities.GameSelectionActivity">
<meta-data android:name="android.support.PARENT_ACTIVITY" android:value="activities.MainActivity" />
<activity
android:name=".activities.minigames.onlyDescription.GameActivity_OnlyDescription"
android:parentActivityName="activities.GameSelectionActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="activities.MainActivity" />
</activity>
<activity android:name=".activities.GameSelectionActivity" android:parentActivityName="activities.MainActivity">
<meta-data android:name="android.support.PARENT_ACTIVITY" android:value="activities.MainActivity" />
<activity
android:name=".activities.minigames.baumory.GameActivity_Baumory"
android:parentActivityName="activities.GameSelectionActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="activities.MainActivity" />
</activity>
<activity android:name=".activities.MainActivity" android:launchMode="singleTop"
android:screenOrientation="portrait">
<activity
android:name=".activities.GameSelectionActivity"
android:parentActivityName="activities.MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="activities.MainActivity" />
</activity>
<activity android:name=".activities.SplashScreen" android:launchMode="singleTop"
<activity
android:name=".activities.MainActivity"
android:launchMode="singleTop"
android:screenOrientation="portrait"></activity>
<activity
android:name=".activities.SplashScreen"
android:launchMode="singleTop"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activities.Imprint" android:parentActivityName="activities.MainActivity">
<meta-data android:name="android.support.PARENT_ACTIVITY" android:value="activities.MainActivity" />
<activity
android:name=".activities.Imprint"
android:parentActivityName="activities.MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="activities.MainActivity" />
</activity>
<activity android:name=".activities.BarcodeCaptureActivity" android:theme="@style/Theme.AppCompat.NoActionBar" />
<activity
android:name=".activities.BarcodeCaptureActivity"
android:theme="@style/Theme.AppCompat.NoActionBar" />
<activity android:name=".activities.WantedPosterDetailsActivity" />

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="de.lmu.treeapp.fileprovider"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private void requestCameraPermission() {

/**
* Creates and starts the camera.
*
* <p>
* Suppressing InlinedApi since there is a check that the minimum version is met before using
* the constant.
*/
Expand Down Expand Up @@ -222,6 +222,7 @@ public void onRequestPermissionsResult(int requestCode,
" Result code = " + (grantResults.length > 0 ? grantResults[0] : "(empty)"));

DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
finish();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.lmu.treeapp.activities;
package de.lmu.treeapp.activities;

import android.content.Intent;
import android.os.Bundle;
Expand Down Expand Up @@ -29,7 +29,8 @@ public class GameSelectionActivity extends AppCompatActivity {

/**
* On creation of this Activity, get the current tree and category we need to display and set-up the RecyclerView and Actionbar.
* @param savedInstanceState Bundle containing the tree and category ids.
*
* @param savedInstanceState Bundle containing the tree and category ids.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -41,7 +42,7 @@ protected void onCreate(Bundle savedInstanceState) {
category = (Tree.GameCategories) b.get("Category");
this.gameIds = DataManager.getInstance(getApplicationContext()).GetTree(treeId).GetGameIds(category);
// Set ActionBar-Content
if(getSupportActionBar() != null) {
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(R.string.game_selection_title);
}
Expand All @@ -64,7 +65,8 @@ private void setupOverviewRecyclerView() {

/**
* Handle the Back/Home-Button -> Go back to MainActivity.
* @param item The item of the menu, which was clicked. We are only interested in the home-item.
*
* @param item The item of the menu, which was clicked. We are only interested in the home-item.
*/
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package de.lmu.treeapp.activities;

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

import androidx.appcompat.app.AppCompatActivity;

import de.lmu.treeapp.R;
import de.lmu.treeapp.service.FragmentManagerService;


public class Imprint extends AppCompatActivity {
Expand Down Expand Up @@ -44,14 +40,14 @@ protected void onCreate(Bundle savedInstanceState) {

// Remove the current activity from the stack to switch to the previous one
@Override
public boolean onSupportNavigateUp(){
public boolean onSupportNavigateUp() {
finish();
return true;
}

// Android hardware back button is pressed
@Override
public void onBackPressed(){
public void onBackPressed() {
finish();
super.onBackPressed();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import com.google.android.material.floatingactionbutton.FloatingActionButton;

import de.lmu.treeapp.R;

import de.lmu.treeapp.contentClasses.trees.Tree;
import de.lmu.treeapp.contentData.DataManager;
import de.lmu.treeapp.fragments.OverviewFragment;
Expand All @@ -32,7 +31,7 @@
public class MainActivity extends AppCompatActivity {

private DataManager dm; // The Singleton holding all the data of the CMS and Database
private FragmentManagerService fragmentManager = FragmentManagerService.getInstance(getSupportFragmentManager()); // The FragmentManager we need to register and launch fragments
private final FragmentManagerService fragmentManager = FragmentManagerService.getInstance(getSupportFragmentManager()); // The FragmentManager we need to register and launch fragments
private final Fragment treeSelectionFragment = new TreeSelectionFragment(); // The Trees-Detail-Fragment (The one were we can see the trees in big and click on games or the profile)
private final Fragment overviewFragment = new OverviewFragment(fragmentManager, treeSelectionFragment); // The Trees-Overview-Fragment (The one which all the trees in small squares on one screen)
private BottomNavigationView bottomNavigationView; // The NavigationBar on the bottom
Expand Down Expand Up @@ -97,8 +96,9 @@ private void setOnClickListener() {
* Register the Fragments with the custom FragmentManager.
*/
Fragment[] bottomNavigationFragments;

private void registerFragmentManagerTransactions() {
bottomNavigationFragments = new Fragment[]{ this.overviewFragment, this.treeSelectionFragment };
bottomNavigationFragments = new Fragment[]{this.overviewFragment, this.treeSelectionFragment};
fragmentManager.registerTransactions(bottomNavigationFragments);
}

Expand Down Expand Up @@ -126,11 +126,12 @@ public void onClick(View v) {
};
}

/** Override of OnActivityResult that handles the return of the QR-Activity.
/**
* Override of OnActivityResult that handles the return of the QR-Activity.
*
* @param requestCode RequestCode coming from the QR-Activity.
* @param resultCode ResultCode coming from the QR-Activity.
* @param data Data coming from the QR-Activity (containing the name of the found tree).
* @param requestCode RequestCode coming from the QR-Activity.
* @param resultCode ResultCode coming from the QR-Activity.
* @param data Data coming from the QR-Activity (containing the name of the found tree).
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Expand Down Expand Up @@ -158,10 +159,12 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {

/**
* Helper function to show a Toast from any thread.
*
* @param toastText String containing the text to toast.
*/
private void showToast(final String toastText) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(getApplicationContext(), toastText, Toast.LENGTH_LONG).show();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ protected void onMeasure(int widthSpec, int heightSpec) {
super.onMeasure(widthSpec, heightSpec);
if (columnWidth > 0) {
int spanCount;
if(OverviewRecyclerViewAdapter.isImprint==true){
if (OverviewRecyclerViewAdapter.isImprint == true) {
spanCount = 1;
}
else{
} else {
spanCount = 3;
}
manager.setSpanCount(spanCount);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package de.lmu.treeapp.activities;

public class SliderItem {
private int image;
private final int image;

SliderItem(int image){
SliderItem(int image) {
this.image = image;
}

public int getImage(){
public int getImage() {
return image;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

import de.lmu.treeapp.R;

public class SplashScreen extends AppCompatActivity {
Expand All @@ -25,9 +25,9 @@ protected void onCreate(Bundle savedInstanceState) {
ImageView image_logos = findViewById(R.id.image_logos);
TextView splash_screen_text = findViewById(R.id.splash_screen_text);

new Handler().postDelayed(new Runnable(){
new Handler().postDelayed(new Runnable() {
@Override
public void run(){
public void run() {
Intent intent = new Intent(SplashScreen.this, MainActivity.class);
startActivity(intent);
finish();
Expand Down
Loading

0 comments on commit 58ec835

Please sign in to comment.