Skip to content

Commit

Permalink
New Process...Work Range added
Browse files Browse the repository at this point in the history
  • Loading branch information
kennest committed Aug 10, 2018
1 parent bfb1854 commit 59eb41e
Show file tree
Hide file tree
Showing 18 changed files with 488 additions and 195 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,6 @@ dependencies {
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
implementation 'com.github.pwittchen:reactivenetwork-rx2:2.0.0'
implementation 'com.yahoo.mobile.client.android.util.rangeseekbar:rangeseekbar-library:0.1.0'
implementation 'com.android.support:multidex:1.0.1'
}
apply plugin: 'io.objectbox'
46 changes: 45 additions & 1 deletion app/objectbox-models/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,53 @@
}
],
"relations": []
},
{
"id": "5:5458691512334468289",
"lastPropertyId": "4:3866100854606404167",
"name": "Recipient",
"properties": [
{
"id": "1:2267756761353089022",
"name": "id"
},
{
"id": "2:8052005738943339787",
"name": "raw_id"
},
{
"id": "3:1704602959266788579",
"name": "username"
},
{
"id": "4:3866100854606404167",
"name": "avatar"
}
],
"relations": []
},
{
"id": "6:3937519838963811958",
"lastPropertyId": "3:3438700273260876943",
"name": "Category",
"properties": [
{
"id": "1:7295815938678112657",
"name": "id"
},
{
"id": "2:6471884807502023377",
"name": "raw_id"
},
{
"id": "3:3438700273260876943",
"name": "label"
}
],
"relations": []
}
],
"lastEntityId": "4:7114969522061860556",
"lastEntityId": "6:3937519838963811958",
"lastIndexId": "1:5365895495544662746",
"lastRelationId": "1:7494428906578484118",
"lastSequenceId": "0:0",
Expand Down
35 changes: 30 additions & 5 deletions app/objectbox-models/default.json.bak
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
},
{
"id": "4:7114969522061860556",
"lastPropertyId": "4:4081180469839927916",
"lastPropertyId": "5:5605347812394964495",
"name": "Location",
"properties": [
{
Expand All @@ -75,14 +75,38 @@
"name": "longitude"
},
{
"id": "4:4081180469839927916",
"name": "date"
"id": "5:5605347812394964495",
"name": "created_at"
}
],
"relations": []
},
{
"id": "5:5458691512334468289",
"lastPropertyId": "4:3866100854606404167",
"name": "Recipient",
"properties": [
{
"id": "1:2267756761353089022",
"name": "id"
},
{
"id": "2:8052005738943339787",
"name": "raw_id"
},
{
"id": "3:1704602959266788579",
"name": "username"
},
{
"id": "4:3866100854606404167",
"name": "avatar"
}
],
"relations": []
}
],
"lastEntityId": "4:7114969522061860556",
"lastEntityId": "5:5458691512334468289",
"lastIndexId": "1:5365895495544662746",
"lastRelationId": "1:7494428906578484118",
"lastSequenceId": "0:0",
Expand All @@ -93,7 +117,8 @@
],
"retiredIndexUids": [],
"retiredPropertyUids": [
6944909853456882489
6944909853456882489,
4081180469839927916
],
"retiredRelationUids": [],
"version": 1
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@

<service
android:name=".tracking.NavigationService"
android:enabled="true"
android:exported="true"/>
android:enabled="true" />
<service android:name=".services.OfflineService"
android:enabled="true" />
</application>

</manifest>
104 changes: 100 additions & 4 deletions app/src/main/java/com/wefly/wealert/activities/BootActivity.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.wefly.wealert.activities;

import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.AlarmManager;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
Expand All @@ -10,11 +12,13 @@
import android.graphics.Bitmap;
import android.location.Address;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.provider.MediaStore;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.v4.app.NotificationCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
Expand All @@ -38,6 +42,8 @@
import com.wefly.wealert.adapters.DrawerListAdapter;
import com.wefly.wealert.adapters.RecipientAdapter;
import com.wefly.wealert.adapters.ViewPagerAdapter;
import com.wefly.wealert.dbstore.Category;
import com.wefly.wealert.services.OfflineService;
import com.wefly.wealert.tracking.NavigationService;
import com.wefly.wealert.events.AlertSentEvent;
import com.wefly.wealert.events.BeforeSendAlertEvent;
Expand Down Expand Up @@ -68,6 +74,7 @@
import java.io.File;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -150,6 +157,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

startTracking();



//Launch Camera
dispatchTakePictureIntent();

Expand Down Expand Up @@ -182,8 +191,37 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
alert_loader_text = findViewById(R.id.alertloadertext);
piece_loader_text = findViewById(R.id.pieceloadertext);

loadCategorieRx();
loadRecipientRx();
Log.e(getLocalClassName(),"Title txt:"+edObject.getText().toString());

Box<com.wefly.wealert.dbstore.Recipient> recipientBox = AppController.boxStore.boxFor(com.wefly.wealert.dbstore.Recipient.class);
if (recipientBox.count() == 0) {
loadRecipientRx();
} else {
List<Recipient> recList=new ArrayList<>();
for (com.wefly.wealert.dbstore.Recipient r : recipientBox.getAll()) {
Recipient item = new Recipient();
item.setAvatarUrl(r.getAvatar());
item.setUserName(r.getUsername());
item.setRecipientId(r.getRaw_id());
recList.add(item);
}
recipientList = vRecipient.findViewById(R.id.recipientList);
recipientList.setAdapter(new RecipientAdapter(getApplicationContext(), recList));
}

Box<com.wefly.wealert.dbstore.Category> categoryBox = AppController.boxStore.boxFor(com.wefly.wealert.dbstore.Category.class);
if (categoryBox.count() == 0) {
loadCategorieRx();
} else {
List<String> categorielist = new ArrayList<>();
for (Category c : categoryBox.getAll()) {
categorielist.add(c.getLabel());
}
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getApplicationContext(), android.R.layout.simple_spinner_item, categorielist);
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
category.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START);
category.setAdapter(spinnerAdapter);
}

recordBtn.setOnClickListener(v -> {
LaunchRecord();
Expand Down Expand Up @@ -343,6 +381,7 @@ private void InitSideMenu() {
mMenuOptions.add("Terms and conditions");
mMenuOptions.add("Policy privacy");
mMenuOptions.add("About");
mMenuOptions.add("Logout");
mMenuOptions.add("Quit");

drawerLayout.setDrawerListener(drawerToggle);
Expand Down Expand Up @@ -370,7 +409,7 @@ public void onOptionClicked(int position, Object objectClicked) {
restart();
break;
case 1:
Toast.makeText(getApplicationContext(), String.valueOf(position)+"Not Implemented Yet!", Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(), String.valueOf(position) + "Not Implemented Yet!", Toast.LENGTH_LONG).show();
break;
case 2:
startActivity(new Intent(BootActivity.this, WorkRangeActivity.class).addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT));
Expand All @@ -388,6 +427,11 @@ public void onOptionClicked(int position, Object objectClicked) {
startActivity(new Intent(BootActivity.this, MenuActivity.class));
break;
case 6:
clearAppData();
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0);
break;
case 7:
finishAffinity();
}
}
Expand Down Expand Up @@ -445,7 +489,7 @@ private void LaunchRecord() {
/****************SendFragment*********************/

private void saveInput() throws NullPointerException {
if (alert != null) {
if (alert != null && edObject.getText().toString()!="" && edContent.getText().toString()!="") {
alert.setObject(edObject.getText().toString().trim());
alert.setContent(edContent.getText().toString().trim());
alert.setCategory(category.getSelectedItem().toString());
Expand Down Expand Up @@ -646,16 +690,22 @@ public void onComplete() {
public void loadCategorieRx() {
Observer mObserver = new Observer<String>() {
List<String> categorielist = new ArrayList<>();
Box<com.wefly.wealert.dbstore.Category> categoryBox = appController.boxStore.boxFor(com.wefly.wealert.dbstore.Category.class);

@Override
public void onSubscribe(Disposable d) {
//Toast.makeText(BootActivity.this, "onSubscribe called", Toast.LENGTH_SHORT).show();
categoryBox.removeAll();
}

@Override
public void onNext(String s) {
//Toast.makeText(BootActivity.this, "onNext called: " + s, Toast.LENGTH_SHORT).show();
categorielist.add(s);

Category c = new Category();
c.setLabel(s);
categoryBox.put(c);
}

@Override
Expand Down Expand Up @@ -683,16 +733,24 @@ public void onComplete() {
public void loadRecipientRx() {
Observer mObserver = new Observer<Recipient>() {
List<Recipient> recipients = new ArrayList<>();
Box<com.wefly.wealert.dbstore.Recipient> recipientBox = appController.boxStore.boxFor(com.wefly.wealert.dbstore.Recipient.class);

@Override
public void onSubscribe(Disposable d) {
// Toast.makeText(BootActivity.this, "onSubscribe called", Toast.LENGTH_SHORT).show();
recipientBox.removeAll();
}

@Override
public void onNext(Recipient r) {
//Toast.makeText(BootActivity.this, "onNext called: " + r.getLastName(), Toast.LENGTH_SHORT).show();
recipients.add(r);

com.wefly.wealert.dbstore.Recipient recipient = new com.wefly.wealert.dbstore.Recipient();
recipient.setRaw_id(r.getRecipientId());
recipient.setAvatar(r.getAvatarUrl());
recipient.setUsername(r.getUserName());
recipientBox.put(recipient);
}

@Override
Expand Down Expand Up @@ -734,6 +792,7 @@ public void onError(Throwable e) {

@Override
public void onComplete() {
showNotification("Alert Sended!");
Toast.makeText(BootActivity.this, "Alert Sended!", Toast.LENGTH_SHORT).show();
uploadRx();
}
Expand Down Expand Up @@ -768,6 +827,7 @@ public void onError(Throwable e) {
@Override
public void onComplete() {
Toast.makeText(BootActivity.this, "Piece Sended!", Toast.LENGTH_SHORT).show();
showNotification("Piece Sended!");
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Expand Down Expand Up @@ -798,8 +858,44 @@ private void startTracking() {
//Calendar calendar = Calendar.getInstance();
//calendar.set(Calendar.SECOND,1);
Intent intent = new Intent(getApplicationContext(), NavigationService.class);
Intent offline = new Intent(getApplicationContext(), OfflineService.class);
// manager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME,calendar.getTimeInMillis(),manager.INTERVAL_HALF_HOUR,intent);
stopService(intent);
stopService(offline);

startService(intent);
startService(offline);
}

private void clearAppData() {
try {
// clearing app data
if (Build.VERSION_CODES.KITKAT <= Build.VERSION.SDK_INT) {
((ActivityManager) getSystemService(ACTIVITY_SERVICE)).clearApplicationUserData(); // note: it has a return value!
} else {
String packageName = getApplicationContext().getPackageName();
Runtime runtime = Runtime.getRuntime();
runtime.exec("pm clear " + packageName);
}

} catch (Exception e) {
e.printStackTrace();
}
}

public void showNotification(String msg) {
//Get an instance of NotificationManager//
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.drawable.ic_logo)
.setContentTitle("Wefly locate")
.setContentText(msg);

// Gets an instance of the NotificationManager service//

NotificationManager mNotificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);

// NotificationManager.notify().
mNotificationManager.notify(001, mBuilder.build());
}
}
Loading

0 comments on commit 59eb41e

Please sign in to comment.