Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Commit

Permalink
feat(helpdesk): add main page (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelje authored and ajsb85 committed Jul 18, 2017
1 parent 784eb68 commit f08db95
Show file tree
Hide file tree
Showing 19 changed files with 529 additions and 217 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ android:
- android-$ANDROID_API
- extra-android-m2repository
install:
- rvm install 2.3.4
- gem install fastlane
- rvm install 2.3.4
- gem install fastlane
after_success:
- "./ci/deploy.sh"
- "./ci/deploy.sh"
notifications:
webhooks: https://fathomless-fjord-24024.herokuapp.com/notify
env:
Expand All @@ -18,5 +18,5 @@ env:
- secure: AWlCndEn3Aiax6wEMp392YiWyzm1cy+olTvEx176ww6FWXc2Gwu1znauXcGkcCEB1d9V0t/6osCSKHtZssEtddPvBkavMEw45W45PylTVJFE3MBQmTUy9wLIKQll2+1LhrVPkjMBMKHFprqgkuDZ78cs2B3EgGvejYt+8D298PseaEmkSo4zWD0AwAwVJ8jJQC2A48lN1Hx9bewRE4pTW9KGh87z4GmcX/pADzkAEIZ2SrZj5msH6ghGoFUlKCE5VpjO8iKrI6i4PTbxBylJQsbpNvwnbuWN0sQaeMjQqjAokx6UpzX9YNyJPt2rWvJnwjUF3Up0TltU1avKr14Jv3pgizFi95/W10AEj9l0VuQxdWXOgIeuCUmbvmD2BQw6IX3v4qzoorw888W53bJGYy9W1XNbUJ+5KOzVkbZjr3AtjuX8v0PSmP/gqDkWTIEeUTP9btHYajAfIpPunedHe+g7mZ9APTfyagAof8+AKlVNzt/5l40Fn+iQ9dNijwDDKOVzzSHFUplv8YKbCibN4Rsq2S2liWZqPJYyE2xRPtn5XlqDM2w/Q6c4fMbknXjfAtwXKhDBH8u9mMX9z8tjWxVQpUUtOx4FRREwC1V5ongvzsyzEMLDZrwnChvDZz6P4OgegSxwhZhAnwk3Rmd9W8sa9mrkBcvnFHheC01rCZY=
- secure: aoYBJcY4gpvfeTtPmu5j5Vr+rt+7RnsZeWwl0z5iSIty+M8eSA+p3B4JHOQoa90aW+eLZIgA/XsnJUm5+wOGjlz8BGPdAyVVlMBF4qrAJKj12fP+M1n+AK59N+wuN+m9EraXlCf2JE2Ty1ioaxWhWlauFI4Ihw5hY6QKHot4frtNq7VCiJ9kQWSFMrIrSJTMAQNZG7wfweGE/CUKSHWeJ/L/YFvbLRjgYEcqkG4lDWYt/noDCElu1OFLKeFiPYVhxrDMf4H+HsxPQYu61H8JKtOFaiusjcEpvvOAlCX1kzM0wsMK4U846nUw+WENd36WMN6YcWiP5CtHt0vOloyhOLVHWELSUbLfw+TRtT+HeOZ/jxueQ8BfLygj6Pb5TClKLK3ENlrqTlafT4PMgMZNsLQ3e0++UJoyRKrHleFArzqR+Bk6MN3xibZAkiy1DPidjQPLvmuSmoACvcjnr5h4etli9bdUo50UagbRORSxCLItn3JePHwlNpLvKEld5zSK0C5lPexCAbLFVAhVw1pO5CCHJeX4FuSbdIhiOsY8GmZg6ZAccgW91tDyhtijwmf1NxiGr+0PcHCHl92jg+U4RgQTmInveOnStRYpEOO+MJaInfuQkxrY+PJbnlR37/QtjOX6lsVcv0c7nfp0BA0IWK4sg3DEdI2D8jBbVgwYS58=
before_install:
- openssl aes-256-cbc -K $encrypted_fbe35f3d891b_key -iv $encrypted_fbe35f3d891b_iv
-in google.tar.gz.enc -out ci/google.tar.gz -d
- openssl aes-256-cbc -K $encrypted_fbe35f3d891b_key -iv $encrypted_fbe35f3d891b_iv
-in google.tar.gz.enc -out ci/google.tar.gz -d
13 changes: 7 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,20 @@ repositories {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.1'
compile ('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2') {
compile('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2') {
exclude module: 'support-v4'
transitive=true
transitive = true
}

compile "com.android.support:appcompat-v7:22.2.0"
compile 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.1'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:design:22.2.0'
compile 'com.madgag.spongycastle:core:1.54.0.0'
compile 'com.madgag.spongycastle:prov:1.54.0.0'
compile 'com.madgag.spongycastle:pkix:1.54.0.0'
compile 'com.orhanobut:logger:2.1.0'
compile 'com.flyvemdm:inventory:1.0.2@aar'
compile 'com.android.support:support-v4:22.2.0'
}

import java.util.regex.Pattern
Expand All @@ -71,11 +73,10 @@ task('incrementVersionName') << {
def majorVersion = Integer.parseInt(matcherVersionNumber.group(1))
def minorVersion = Integer.parseInt(matcherVersionNumber.group(2))
def pointVersion = Integer.parseInt(matcherVersionNumber.group(3))
def mNextVersionName = majorVersion + "." + minorVersion + "." + (pointVersion+1)
def mNextVersionName = majorVersion + "." + minorVersion + "." + (pointVersion + 1)
def manifestContent = matcherVersionNumber.replaceAll("versionName=\"" + mNextVersionName + "\"")
manifestFile.write(manifestContent)
}

tasks.whenTaskAdded { task ->
if (task.name == 'generateReleaseBuildConfig' || task.name == 'generateDebugBuildConfig') {
task.dependsOn 'increaseVersionCode'
Expand Down
62 changes: 28 additions & 34 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.flyve.mdm.agent"
android:versionName="1.0.11"
android:versionCode="9">
android:versionCode="40"
android:versionName="1.0.42">

<!-- For writing logfiles -->
<uses-permission android:name="android.permisson.READ_EXTERNAL_STORAGE" />
Expand All @@ -11,70 +11,66 @@
<!-- For restart service -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

<!--for location information-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<!-- for location information -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<application
android:name=".FlyveMDMApp"
android:name=".MDMAgent"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity android:name=".SplashActivity"
<activity
android:name=".SplashActivity"
android:configChanges="orientation|screenSize"
android:theme="@style/NoActionBar"
>
android:theme="@style/NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity" android:configChanges="orientation|screenSize">
<activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize">
</activity>

<activity android:name=".EnrollmentActivity"
android:configChanges="orientation|screenSize"
>
<activity
android:name=".EnrollmentActivity"
android:configChanges="orientation|screenSize">
</activity>

<activity android:name=".StartEnrollmentActivity"
<activity
android:name=".StartEnrollmentActivity"
android:configChanges="orientation|screenSize"
android:launchMode="singleTask"
>

<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:scheme="flyve"
android:host="register"
/>
android:scheme="flyve" />
</intent-filter>

</activity>

<service android:name="org.eclipse.paho.android.service.MqttService" >
<service android:name="org.eclipse.paho.android.service.MqttService">
</service>

<service
android:name=".services.MQTTService"
android:enabled="true"
android:exported="false"
>
android:exported="false">
</service>

<!--This receiver is for restart MQTT on reboot device -->
<!-- This receiver is for restart MQTT on reboot device -->
<receiver
android:name=".services.MQTTRestarterBroadcastReceiver"
android:enabled="true"
Expand All @@ -85,14 +81,13 @@
</intent-filter>
</receiver>

<!--This receiver is for Device Admin Policies -->
<!-- This receiver is for Device Admin Policies -->
<receiver
android:name=".security.FlyveAdminReceiver"
android:permission="android.permission.BIND_DEVICE_ADMIN" >

android:permission="android.permission.BIND_DEVICE_ADMIN">
<meta-data
android:name="android.app.device_admin"
android:resource="@xml/device_admin" >
android:resource="@xml/device_admin">
</meta-data>

<intent-filter>
Expand All @@ -106,7 +101,7 @@
</intent-filter>
</receiver>

<!--This receiver is for information about Wifi or Bluetooth-->
<!-- This receiver is for information about Wifi or Bluetooth -->
<receiver
android:name=".services.MQTTConnectivityReceiver"
android:exported="false">
Expand All @@ -116,7 +111,6 @@
<action android:name="android.location.PROVIDERS_CHANGED" />
</intent-filter>
</receiver>

</application>

</manifest>
32 changes: 32 additions & 0 deletions app/src/main/java/org/flyve/mdm/agent/FragmentInformation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.flyve.mdm.agent;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import org.flyve.mdm.agent.data.DataStorage;


public class FragmentInformation extends Fragment {

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_information, container, false);

DataStorage cache = new DataStorage(FragmentInformation.this.getActivity());

TextView txtName = (TextView) v.findViewById(R.id.txtNameUser);
txtName.setText(cache.getUserFirstName() + " " + cache.getUserLastName());

TextView txtEmail = (TextView) v.findViewById(R.id.txtDescriptionUser);
txtEmail.setText(cache.getUserEmail());

return v;
}

}
152 changes: 152 additions & 0 deletions app/src/main/java/org/flyve/mdm/agent/FragmentLog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/*
* Copyright © 2017 Teclib. All rights reserved.
*
* This file is part of flyve-mdm-android-agent
*
* flyve-mdm-android-agent is a subproject of Flyve MDM. Flyve MDM is a mobile
* device management software.
*
* Flyve MDM is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* Flyve MDM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ------------------------------------------------------------------------------
* @author Rafael Hernandez
* @date 02/06/2017
* @copyright Copyright © ${YEAR} Teclib. All rights reserved.
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/flyve-mdm/flyve-mdm-android-agent
* @link https://flyve-mdm.com
* ------------------------------------------------------------------------------
*/

package org.flyve.mdm.agent;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.content.LocalBroadcastManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TextView;

import org.flyve.mdm.agent.adapter.LogAdapter;
import org.flyve.mdm.agent.utils.FlyveLog;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;


/**
* This is the main activity of the app
*/
public class FragmentLog extends Fragment {

private TextView txtMessage;
private TextView txtTitle;
private ArrayList<HashMap<String, String>> arr_data;
private LogAdapter mAdapter;
private IntentFilter mIntent;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_log, container, false);

txtMessage = (TextView) v.findViewById(R.id.txtMessage);
txtTitle = (TextView) v.findViewById(R.id.txtTitle);

arr_data = new ArrayList<HashMap<String, String>>();

ListView lst = (ListView) v.findViewById(R.id.lst);
mAdapter = new LogAdapter(FragmentLog.this.getActivity(), arr_data);
lst.setAdapter(mAdapter);

return v;
}

@Override
public void onPause() {
// unregister the broadcast
if(mIntent != null) {
getActivity().unregisterReceiver(broadcastReceivedMessage);
getActivity().unregisterReceiver(broadcastReceivedLog);
getActivity().unregisterReceiver(broadcastServiceStatus);
mIntent = null;
}
super.onPause();
}

@Override
public void onResume() {
// register the broadcast
super.onResume();
LocalBroadcastManager.getInstance(FragmentLog.this.getActivity()).registerReceiver(broadcastReceivedMessage, new IntentFilter("flyve.mqtt.msg"));
LocalBroadcastManager.getInstance(FragmentLog.this.getActivity()).registerReceiver(broadcastReceivedLog, new IntentFilter("flyve.mqtt.log"));
LocalBroadcastManager.getInstance(FragmentLog.this.getActivity()).registerReceiver(broadcastServiceStatus, new IntentFilter("flyve.mqtt.status"));
}

/**
* broadcastReceiverMessage instance that receive all the message from MQTTService
*/
private BroadcastReceiver broadcastReceivedLog = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String msg = intent.getStringExtra("message");

try {
HashMap<String, String> map = new HashMap<String, String>();

JSONObject json = new JSONObject(msg);

map.put("type", json.getString("type"));
map.put("title", json.getString("title"));
map.put("body", json.getString("body"));
map.put("date", json.getString("date"));

arr_data.add(map);
mAdapter.notifyDataSetChanged();
} catch (Exception ex) {
FlyveLog.d("ERROR" + ex.getMessage());
}
}
};

/**
* broadcastReceiverMessage instance that receive all the message from MQTTService
*/
private BroadcastReceiver broadcastReceivedMessage = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String msg = intent.getStringExtra("message");
txtTitle.setText(msg);
}
};

/**
* broadcastServiceStatus instance that receive service status from MQTTService
*/
private BroadcastReceiver broadcastServiceStatus = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String msg = intent.getStringExtra("message");

if(Boolean.parseBoolean(msg)) {
txtMessage.setText("Online");
} else {
txtMessage.setText("Offline");
}
}
};
}
Loading

0 comments on commit f08db95

Please sign in to comment.