diff --git a/ClimateGoApp/app/.gitignore b/ClimateGoApp/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/ClimateGoApp/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/ClimateGoApp/app/build.gradle b/ClimateGoApp/app/build.gradle new file mode 100644 index 0000000..45d8b9c --- /dev/null +++ b/ClimateGoApp/app/build.gradle @@ -0,0 +1,44 @@ +plugins { + id 'com.android.application' +} + +android { + compileSdk 32 + + defaultConfig { + applicationId "de.cdaut.climategoapp" + minSdk 23 + targetSdk 32 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + buildFeatures { + viewBinding true + } +} + +dependencies { + + implementation 'androidx.appcompat:appcompat:1.3.0' + implementation 'com.google.android.material:material:1.5.0' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + implementation 'androidx.navigation:navigation-fragment:2.3.5' + implementation 'androidx.navigation:navigation-ui:2.3.5' + implementation 'com.google.android.material:material:1.6.0-alpha03' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' +} \ No newline at end of file diff --git a/ClimateGoApp/app/proguard-rules.pro b/ClimateGoApp/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/ClimateGoApp/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/ClimateGoApp/app/src/androidTest/java/de/cdaut/climategoapp/ExampleInstrumentedTest.java b/ClimateGoApp/app/src/androidTest/java/de/cdaut/climategoapp/ExampleInstrumentedTest.java new file mode 100644 index 0000000..2fc3f8a --- /dev/null +++ b/ClimateGoApp/app/src/androidTest/java/de/cdaut/climategoapp/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package de.cdaut.climategoapp; + +import android.content.Context; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("de.cdaut.climategoapp", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/ClimateGoApp/app/src/main/AndroidManifest.xml b/ClimateGoApp/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..4555de0 --- /dev/null +++ b/ClimateGoApp/app/src/main/AndroidManifest.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ClimateGoApp/app/src/main/java/de/cdaut/climategoapp/DebugFragment.java b/ClimateGoApp/app/src/main/java/de/cdaut/climategoapp/DebugFragment.java new file mode 100644 index 0000000..1d9487d --- /dev/null +++ b/ClimateGoApp/app/src/main/java/de/cdaut/climategoapp/DebugFragment.java @@ -0,0 +1,39 @@ +package de.cdaut.climategoapp; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; + +import de.cdaut.climategoapp.databinding.FragmentDebugBinding; + +public class DebugFragment extends Fragment { + + private FragmentDebugBinding binding; + + @Override + public View onCreateView( + @NonNull LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState + ) { + + binding = FragmentDebugBinding.inflate(inflater, container, false); + + return binding.getRoot(); + + } + + @Override + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + binding = null; + } +} diff --git a/ClimateGoApp/app/src/main/java/de/cdaut/climategoapp/HomeFragment.java b/ClimateGoApp/app/src/main/java/de/cdaut/climategoapp/HomeFragment.java new file mode 100644 index 0000000..7f47487 --- /dev/null +++ b/ClimateGoApp/app/src/main/java/de/cdaut/climategoapp/HomeFragment.java @@ -0,0 +1,40 @@ +package de.cdaut.climategoapp; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; + +import de.cdaut.climategoapp.databinding.FragmentHomeBinding; + +public class HomeFragment extends Fragment { + + private FragmentHomeBinding binding; + + @Override + public View onCreateView( + @NonNull LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState + ) { + + binding = FragmentHomeBinding.inflate(inflater, container, false); + + return binding.getRoot(); + + } + + @Override + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + binding = null; + } + +} \ No newline at end of file diff --git a/ClimateGoApp/app/src/main/java/de/cdaut/climategoapp/activities/DebugActivity.java b/ClimateGoApp/app/src/main/java/de/cdaut/climategoapp/activities/DebugActivity.java new file mode 100644 index 0000000..62dcaea --- /dev/null +++ b/ClimateGoApp/app/src/main/java/de/cdaut/climategoapp/activities/DebugActivity.java @@ -0,0 +1,87 @@ +package de.cdaut.climategoapp.activities; + +import android.os.Bundle; + + +import androidx.appcompat.app.ActionBarDrawerToggle; +import androidx.appcompat.app.AppCompatActivity; + +import androidx.drawerlayout.widget.DrawerLayout; +import androidx.navigation.NavController; +import androidx.navigation.Navigation; +import androidx.navigation.ui.AppBarConfiguration; +import androidx.navigation.ui.NavigationUI; + +import de.cdaut.climategoapp.R; +import de.cdaut.climategoapp.databinding.ActivityDebugBinding; + +import android.view.Menu; +import android.view.MenuItem; + +public class DebugActivity extends AppCompatActivity { + + private AppBarConfiguration appBarConfiguration; + private ActivityDebugBinding binding; + public DrawerLayout drawerLayout; + public ActionBarDrawerToggle actionBarDrawerToggle; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + binding = ActivityDebugBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); + + setSupportActionBar(binding.toolbar); + + + // drawer layout instance to toggle the menu icon to open + // drawer and back button to close drawer + drawerLayout = findViewById(R.id.my_drawer_layout); + actionBarDrawerToggle = new ActionBarDrawerToggle(this, + drawerLayout, + R.string.nav_open, + R.string.nav_close); + + // pass the Open and Close toggle for the drawer layout listener + // to toggle the button + drawerLayout.addDrawerListener(actionBarDrawerToggle); + actionBarDrawerToggle.syncState(); + + // to make the Navigation drawer icon always appear on the action bar + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_main, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + if (actionBarDrawerToggle.onOptionsItemSelected(item)) { + return true; + } + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } + + @Override + public boolean onSupportNavigateUp() { + NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_nav); + return NavigationUI.navigateUp(navController, appBarConfiguration) + || super.onSupportNavigateUp(); + } +} \ No newline at end of file diff --git a/ClimateGoApp/app/src/main/java/de/cdaut/climategoapp/activities/HomeActivity.java b/ClimateGoApp/app/src/main/java/de/cdaut/climategoapp/activities/HomeActivity.java new file mode 100644 index 0000000..06e0302 --- /dev/null +++ b/ClimateGoApp/app/src/main/java/de/cdaut/climategoapp/activities/HomeActivity.java @@ -0,0 +1,126 @@ +package de.cdaut.climategoapp.activities; + +import android.content.Intent; +import android.os.Bundle; + + +import androidx.annotation.NonNull; +import androidx.appcompat.app.ActionBarDrawerToggle; +import androidx.appcompat.app.AppCompatActivity; + +import androidx.drawerlayout.widget.DrawerLayout; +import androidx.navigation.NavController; +import androidx.navigation.Navigation; +import androidx.navigation.ui.AppBarConfiguration; +import androidx.navigation.ui.NavigationUI; + +import de.cdaut.climategoapp.R; +import de.cdaut.climategoapp.databinding.ActivityHomeBinding; + +import android.view.Menu; +import android.view.MenuItem; + +import com.google.android.material.navigation.NavigationView; + +public class HomeActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { + + private AppBarConfiguration appBarConfiguration; + private ActivityHomeBinding binding; + public DrawerLayout drawerLayout; + public ActionBarDrawerToggle actionBarDrawerToggle; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + binding = ActivityHomeBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); + + setSupportActionBar(binding.toolbar); + + // drawer layout instance to toggle the menu icon to open + // drawer and back button to close drawer + drawerLayout = findViewById(R.id.home_drawer_layout); + actionBarDrawerToggle = new ActionBarDrawerToggle(this, + drawerLayout, + R.string.nav_open, + R.string.nav_close); + + // pass the Open and Close toggle for the drawer layout listener + // to toggle the button + drawerLayout.addDrawerListener(actionBarDrawerToggle); + actionBarDrawerToggle.syncState(); + + // to make the Navigation drawer icon always appear on the action bar + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + setNavigationViewListener(); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_main, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + if (actionBarDrawerToggle.onOptionsItemSelected(item)) { + return true; + } + + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } + + @Override + public boolean onSupportNavigateUp() { + NavController navController = Navigation.findNavController(this, + R.id.nav_host_fragment_content_nav + ); + return NavigationUI.navigateUp(navController, appBarConfiguration) + || super.onSupportNavigateUp(); + } + + @Override + public boolean onNavigationItemSelected(@NonNull MenuItem item) { + + Class targetActivityClass; + + switch (item.getItemId()) { + case R.id.nav_main: + targetActivityClass = HomeActivity.class; + break; + case R.id.nav_debug: + targetActivityClass = DebugActivity.class; + break; + default: + throw new IllegalAccessError("Illegal activity met in nav drawer"); + } + + if(targetActivityClass.equals(this.getClass())) { + drawerLayout.closeDrawers(); + return false; + } + + Intent targetIntent = new Intent(this, targetActivityClass); + startActivity(targetIntent); + + return false; + } + + private void setNavigationViewListener() { + NavigationView navigationView = findViewById(R.id.nav_drawer); + navigationView.setNavigationItemSelectedListener(this); + } + +} \ No newline at end of file diff --git a/ClimateGoApp/app/src/main/java/de/cdaut/climategoapp/sensor/SensorDebugUtils.java b/ClimateGoApp/app/src/main/java/de/cdaut/climategoapp/sensor/SensorDebugUtils.java new file mode 100644 index 0000000..fd52678 --- /dev/null +++ b/ClimateGoApp/app/src/main/java/de/cdaut/climategoapp/sensor/SensorDebugUtils.java @@ -0,0 +1,16 @@ +package de.cdaut.climategoapp.sensor; + +import java.util.ArrayList; +import java.util.List; + +public final class SensorDebugUtils { + private SensorDebugUtils() { + throw new IllegalAccessError("Utility Class"); + } + + public static List readSensorData(){ + ArrayList data = new ArrayList<>(); + data.add("Test"); + return data; + } +} diff --git a/ClimateGoApp/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/ClimateGoApp/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/ClimateGoApp/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ClimateGoApp/app/src/main/res/drawable/ic_launcher_background.xml b/ClimateGoApp/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/ClimateGoApp/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ClimateGoApp/app/src/main/res/layout/activity_debug.xml b/ClimateGoApp/app/src/main/res/layout/activity_debug.xml new file mode 100644 index 0000000..14532c5 --- /dev/null +++ b/ClimateGoApp/app/src/main/res/layout/activity_debug.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ClimateGoApp/app/src/main/res/layout/activity_home.xml b/ClimateGoApp/app/src/main/res/layout/activity_home.xml new file mode 100644 index 0000000..1b84f38 --- /dev/null +++ b/ClimateGoApp/app/src/main/res/layout/activity_home.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ClimateGoApp/app/src/main/res/layout/content_nav.xml b/ClimateGoApp/app/src/main/res/layout/content_nav.xml new file mode 100644 index 0000000..482b09b --- /dev/null +++ b/ClimateGoApp/app/src/main/res/layout/content_nav.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/ClimateGoApp/app/src/main/res/layout/fragment_debug.xml b/ClimateGoApp/app/src/main/res/layout/fragment_debug.xml new file mode 100644 index 0000000..934f2c7 --- /dev/null +++ b/ClimateGoApp/app/src/main/res/layout/fragment_debug.xml @@ -0,0 +1,29 @@ + + + +