Commit f512e44b authored by LucienZ's avatar LucienZ
Browse files
parents 80414a5e b089622b
......@@ -33,7 +33,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.skyfishjy.ripplebackground:library:1.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
......@@ -47,4 +47,8 @@ dependencies {
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
//Animation dependencie
implementation 'com.skyfishjy.ripplebackground:library:1.0.1'
}
......@@ -6,22 +6,24 @@
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".SettingsActivity"></activity>
<activity android:name=".RadarActivity" />
<activity android:name=".StartActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.nearby.messages.API_KEY"
android:value="AIzaSyDBoavQ4FlMZBRHi0MiRFw-Pli3u7Cseec" />
<activity android:name=".RadarActivity" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
......
......@@ -2,6 +2,7 @@ package ch.hevs.divoc;
import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -10,13 +11,13 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
public class Languages_Fragment extends Fragment {
public class Languages_Fragment extends PreferenceFragment {
@Nullable
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_languages,container,false);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);
}
}
package ch.hevs.divoc;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.NotificationManagerCompat;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageButton;
import android.widget.Toast;
import java.util.Locale;
public class MainActivity extends AppCompatActivity {
private ImageButton imageButton;
//Notifications
public static final String CHANNEL_1_ID = "channel1";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// check the language, set the one selecte throughout the app
changeLanguage();
createNotificationChannel();
imageButton = findViewById(R.id.imageHomeButton);
imageButton.setOnClickListener(new View.OnClickListener() {
......@@ -45,27 +64,52 @@ public class MainActivity extends AppCompatActivity {
switch (item.getItemId()) {
case R.id.action_manage_trusts:
//Toast.makeText(MainActivity.this, "Test", Toast.LENGTH_LONG).show();
getSupportFragmentManager().beginTransaction().replace(android.R.id.content, new ManageFragment()).addToBackStack(null).commit();
return true;
case R.id.action_perf:
//Toast.makeText(MainActivity.this, "Test", Toast.LENGTH_LONG).show();
getSupportFragmentManager().beginTransaction().replace(android.R.id.content, new PerformanceFragment()).addToBackStack(null).commit();
return true;
case R.id.action_tips:
//Toast.makeText(MainActivity.this, "Test", Toast.LENGTH_LONG).show();
getSupportFragmentManager().beginTransaction().replace(android.R.id.content, new TipsFragment()).addToBackStack(null).commit();
return true;
case R.id.action_languages:
//Toast.makeText(MainActivity.this, "Test", Toast.LENGTH_LONG).show();
getSupportFragmentManager().beginTransaction().replace(android.R.id.content, new Languages_Fragment()).addToBackStack(null).commit();
Intent intent1 = new Intent(MainActivity.this, SettingsActivity.class);
MainActivity.this.startActivity(intent1);
return true;
case R.id.action_legal:
//Toast.makeText(MainActivity.this, "Test", Toast.LENGTH_LONG).show();
getSupportFragmentManager().beginTransaction().replace(android.R.id.content, new Legal_Fragment()).addToBackStack(null).commit();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
// to change the local language of the application
public void changeLanguage() {
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
String lang = sharedPrefs.getString("pref_lang", "de-rCH");
Locale myLocale = new Locale(lang);
Locale.setDefault(myLocale);
Resources resources = getBaseContext().getResources();
Configuration config = resources.getConfiguration();
config.locale = myLocale;
resources.updateConfiguration(config, resources.getDisplayMetrics());
}
private void createNotificationChannel(){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
NotificationChannel channel1 = new NotificationChannel(
CHANNEL_1_ID,
"Channel 1",
NotificationManager.IMPORTANCE_HIGH
);
channel1.setDescription("This is Channel 1");
NotificationManager manager = getSystemService(NotificationManager.class);
manager.createNotificationChannel(channel1);
}
}
}
package ch.hevs.divoc;
import android.app.Notification;
import android.content.Intent;
import android.media.Image;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.Animation;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import com.skyfishjy.library.RippleBackground;
import ch.hevs.divoc.ScoreDatabase.ScoreViewModel;
import ch.hevs.divoc.ScoreDatabase.TrustedDevicesViewModel;
import ch.hevs.divoc.utils.ScoreCalculator;
import static ch.hevs.divoc.MainActivity.CHANNEL_1_ID;
public class RadarActivity extends AppCompatActivity {
private TextView scoreValue;
......@@ -27,11 +27,17 @@ public class RadarActivity extends AppCompatActivity {
private RippleBackground radarAnimation;
private ImageButton startTrackingButton;
//Notification
private NotificationManagerCompat notificationManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_radar);
notificationManager = NotificationManagerCompat.from(this);
// create ScoreCalculator
scoreCalculator = new ScoreCalculator();
......@@ -58,10 +64,23 @@ public class RadarActivity extends AppCompatActivity {
@Override
public void onClick(View v) {
startTracking(v);
sendNotification(v);
}
});
}
public void sendNotification(View v){
Notification notification = new NotificationCompat.Builder(this, CHANNEL_1_ID)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("Warning")
.setContentText("Someone is very close !")
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setCategory(NotificationCompat.CATEGORY_ALARM)
.build();
notificationManager.notify(1, notification);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
......@@ -95,8 +114,8 @@ public class RadarActivity extends AppCompatActivity {
getSupportFragmentManager().beginTransaction().replace(android.R.id.content, new TipsFragment()).addToBackStack(null).commit();
return true;
case R.id.action_languages:
//Toast.makeText(MainActivity.this, "Test", Toast.LENGTH_LONG).show();
getSupportFragmentManager().beginTransaction().replace(android.R.id.content, new Languages_Fragment()).addToBackStack(null).commit();
Intent intent1 = new Intent(RadarActivity.this, SettingsActivity.class);
RadarActivity.this.startActivity(intent1);
return true;
case R.id.action_legal:
//Toast.makeText(MainActivity.this, "Test", Toast.LENGTH_LONG).show();
......
......@@ -2,14 +2,44 @@ package ch.hevs.divoc;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class SettingsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new Languages_Fragment())
.commit();
}
//insert action - toolbar
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.top_actionbar2, 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.
switch (item.getItemId()) {
case R.id.action_back:
Intent i = new Intent(SettingsActivity.this, MainActivity.class);
SettingsActivity.this.startActivity(i);
this.finish();
break;
}
return true;
}
}
package ch.hevs.divoc;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class StartActivity extends AppCompatActivity {
private static int SPLASH_TIME_OUT = 3000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start);
//Delay the launch of the app to see the logo
new Handler().postDelayed(new Runnable(){
@Override
public void run(){
//Start the LoginMenuActivity
Intent homeIntent = new Intent(StartActivity.this, MainActivity.class);
startActivity(homeIntent);
finish();
}
},SPLASH_TIME_OUT);
}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/constraintLayout"
......@@ -76,24 +77,24 @@
</com.skyfishjy.library.RippleBackground>
<Button
android:id="@+id/homeButton"
android:layout_width="411dp"
android:layout_height="wrap_content"
android:id="@+id/addTrustButton"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="16dp"
android:onClick="startTracking"
android:text="@string/bouton_home"
app:layout_constraintBottom_toTopOf="@+id/addTrustButton"
android:text="@string/add_trusts"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/addTrustButton"
android:id="@+id/homeButton"
android:layout_width="411dp"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="@string/add_trusts"
app:layout_constraintBottom_toBottomOf="parent"
android:onClick="startTracking"
android:text="@string/bouton_home"
app:layout_constraintBottom_toTopOf="@+id/addTrustButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" />
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorWhite"
tools:context=".StartActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/divoclogofinal"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -17,4 +17,5 @@
tools:layout_editor_absoluteX="113dp"
tools:layout_editor_absoluteY="66dp"
android:gravity="center_horizontal" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -19,7 +19,7 @@
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="113dp" />
<MultiAutoCompleteTextView
<TextView
android:id="@+id/multiAutoCompleteTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......@@ -42,7 +42,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/multiAutoCompleteTextView" />
<MultiAutoCompleteTextView
<TextView
android:id="@+id/multiAutoCompleteTextView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Search, should appear as action button
<item android:id="@+id/action_search"
android:icon="@drawable/ic_search_white_24dp"
android:title="@string/action_search"
app:showAsAction="ifRoom" />
-->
<item
android:id="@+id/action_back"
android:icon="@drawable/save"
android:title="@string/about"
app:showAsAction="ifRoom|withText" />
</menu>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
\ No newline at end of file
Markdown is supported
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