mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-28 14:57:12 +00:00
TRACKING APP: cleanup
This commit is contained in:
1 parent
09e5ebed98
commit
739f4dae6f
6 files changed
+22
-299
No files matched your search
@@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.sap.sailing.android.tracking.app.test"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-sdk android:minSdkVersion="14" />
|
||||
|
||||
<instrumentation
|
||||
android:name="android.test.InstrumentationTestRunner"
|
||||
android:targetPackage="com.sap.sailing.android.tracking.app" />
|
||||
|
||||
<application
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name" >
|
||||
<uses-library android:name="android.test.runner" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
+1
-1
@@ -165,7 +165,7 @@ public class TrackingService extends Service implements ConnectionCallbacks,
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
|
||||
|
||||
reportGPSQualityBearingAndSpeed(location.getAccuracy(), location.getBearing(), location.getSpeed());
|
||||
|
||||
DatabaseHelper.getInstance(this).insertGPSFix(location.getLatitude(),
|
||||
|
||||
+21
-30
@@ -19,9 +19,8 @@ import com.sap.sailing.android.tracking.app.utils.AppPreferences;
|
||||
import com.sap.sailing.android.tracking.app.utils.SqlDebugHelper;
|
||||
|
||||
public class BaseActivity extends ActionBarActivity {
|
||||
private static final String TAG = SendingServiceAwareActivity.class
|
||||
.getName();
|
||||
|
||||
private static final String TAG = BaseActivity.class.getName();
|
||||
|
||||
protected AppPreferences prefs;
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
@@ -37,7 +36,7 @@ public class BaseActivity extends ActionBarActivity {
|
||||
inflater.inflate(R.menu.options_menu, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
@@ -53,10 +52,10 @@ public class BaseActivity extends ActionBarActivity {
|
||||
ExLog.i(this, TAG, "Clicked SETTINGS.");
|
||||
startActivity(new Intent(this, SettingsActivity.class));
|
||||
return true;
|
||||
// case R.id.options_menu_info:
|
||||
// ExLog.i(this, TAG, "Clicked INFO.");
|
||||
// startActivity(new Intent(this, SystemInformationActivity.class));
|
||||
// return true;
|
||||
// case R.id.options_menu_info:
|
||||
// ExLog.i(this, TAG, "Clicked INFO.");
|
||||
// startActivity(new Intent(this, SystemInformationActivity.class));
|
||||
// return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
@@ -77,38 +76,30 @@ public class BaseActivity extends ActionBarActivity {
|
||||
progressDialog.setMessage(message);
|
||||
progressDialog.show();
|
||||
}
|
||||
|
||||
public void showProgressDialog(int string1Id, int string2Id)
|
||||
{
|
||||
|
||||
public void showProgressDialog(int string1Id, int string2Id) {
|
||||
showProgressDialog(getString(string1Id), getString(string2Id));
|
||||
}
|
||||
|
||||
public void dismissProgressDialog()
|
||||
{
|
||||
if (progressDialog.isShowing())
|
||||
{
|
||||
progressDialog.dismiss();
|
||||
|
||||
public void dismissProgressDialog() {
|
||||
if (progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
public void showErrorPopup(String title, String message) {
|
||||
AlertDialog dialog = new AlertDialog.Builder(this)
|
||||
.setTitle(title)
|
||||
.setMessage(message)
|
||||
AlertDialog dialog = new AlertDialog.Builder(this).setTitle(title).setMessage(message)
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setPositiveButton(android.R.string.ok,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,
|
||||
int whichButton) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
}).create();
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
}).create();
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public void showErrorPopup(int string1Id, int string2Id)
|
||||
{
|
||||
|
||||
public void showErrorPopup(int string1Id, int string2Id) {
|
||||
showErrorPopup(getString(string1Id), getString(string2Id));
|
||||
}
|
||||
}
|
||||
-141
@@ -1,141 +0,0 @@
|
||||
package com.sap.sailing.android.tracking.app.ui.activities;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.sap.sailing.android.shared.R;
|
||||
import com.sap.sailing.android.shared.logging.ExLog;
|
||||
import com.sap.sailing.android.shared.ui.activities.ResilientActivity;
|
||||
import com.sap.sailing.android.shared.util.PrefUtils;
|
||||
import com.sap.sailing.android.tracking.app.services.sending.MessageSendingService;
|
||||
import com.sap.sailing.android.tracking.app.services.sending.MessageSendingService.MessageSendingBinder;
|
||||
import com.sap.sailing.android.tracking.app.services.sending.MessageSendingService.MessageSendingServiceLogger;
|
||||
|
||||
public abstract class SendingServiceAwareActivity extends ResilientActivity {
|
||||
|
||||
private class MessageSendingServiceConnection implements ServiceConnection, MessageSendingServiceLogger {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName className, IBinder service) {
|
||||
MessageSendingBinder binder = (MessageSendingBinder) service;
|
||||
sendingService = binder.getService();
|
||||
boundSendingService = true;
|
||||
sendingService.setMessageSendingServiceLogger(this);
|
||||
updateSendingServiceInformation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName arg) {
|
||||
boundSendingService = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessageSentSuccessful() {
|
||||
updateSendingServiceInformation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessageSentFailed() {
|
||||
updateSendingServiceInformation();
|
||||
}
|
||||
}
|
||||
|
||||
private static final String TAG = SendingServiceAwareActivity.class.getName();
|
||||
|
||||
protected MenuItem menuItemLive;
|
||||
protected int menuItemLiveId = -1;
|
||||
|
||||
protected boolean boundSendingService = false;
|
||||
protected MessageSendingService sendingService;
|
||||
private MessageSendingServiceConnection sendingServiceConnection;
|
||||
|
||||
private String sendingServiceStatus = "";
|
||||
|
||||
public SendingServiceAwareActivity() {
|
||||
this.sendingServiceConnection = new MessageSendingServiceConnection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
Intent intent = new Intent(this, MessageSendingService.class);
|
||||
bindService(intent, sendingServiceConnection, Context.BIND_AUTO_CREATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
|
||||
if (boundSendingService) {
|
||||
unbindService(sendingServiceConnection);
|
||||
boundSendingService = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateSendingServiceInformation() {
|
||||
if (menuItemLive == null)
|
||||
return;
|
||||
|
||||
if (!boundSendingService)
|
||||
return;
|
||||
|
||||
int errorCount = this.sendingService.getDelayedIntentsCount();
|
||||
if (errorCount > 0) {
|
||||
menuItemLive.setIcon(R.drawable.ic_menu_share_red);
|
||||
Date lastSuccessfulSend = this.sendingService.getLastSuccessfulSend();
|
||||
sendingServiceStatus = String.format("Currently %d events waiting to be sent.\nLast successful sent was at %s",
|
||||
errorCount, lastSuccessfulSend == null ? "never" : lastSuccessfulSend);
|
||||
} else {
|
||||
menuItemLive.setIcon(R.drawable.ic_menu_share);
|
||||
sendingServiceStatus = String.format("Currently no event waiting to be sent.", errorCount);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the resource ID for the options menu, {@code 0} if none.
|
||||
* The menu item displaying the connection status is added automatically.
|
||||
*/
|
||||
protected abstract int getOptionsMenuResId();
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.options_menu_live_status, menu);
|
||||
menuItemLive = menu.findItem(R.id.options_menu_live);
|
||||
if (getOptionsMenuResId() != 0) {
|
||||
inflater.inflate(getOptionsMenuResId(), menu);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (R.id.options_menu_live == item.getItemId()) {
|
||||
ExLog.i(this, TAG, "Clicked LIVE.");
|
||||
Toast.makeText(this, getLiveIconText(), Toast.LENGTH_LONG).show();
|
||||
return true;
|
||||
} else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
updateSendingServiceInformation();
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
private String getLiveIconText() {
|
||||
return String.format("Connected to: %s\n%s", PrefUtils.getString(this, R.string.preference_server_url_key,
|
||||
R.string.preference_server_url_default), sendingServiceStatus);
|
||||
}
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
package com.sap.sailing.android.tracking.app.ui.activities;
|
||||
|
||||
|
||||
public class SystemInformationActivity extends BaseActivity {
|
||||
// private SystemInformationActivityHelper helper;
|
||||
|
||||
// @Override
|
||||
// public void onCreate(Bundle savedInstanceState) {
|
||||
// super.onCreate(savedInstanceState);
|
||||
// helper = new SystemInformationActivityHelper(this, prefs.getDeviceIdentifier());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void updateSendingServiceInformation() {
|
||||
// helper.updateSendingServiceInformation();
|
||||
// super.updateSendingServiceInformation();
|
||||
// }
|
||||
|
||||
}
|
||||
-89
@@ -1,89 +0,0 @@
|
||||
package com.sap.sailing.android.tracking.app.ui.activities;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.text.format.DateFormat;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.sap.sailing.android.shared.R;
|
||||
import com.sap.sailing.android.shared.util.AppUtils;
|
||||
|
||||
public class SystemInformationActivityHelper {
|
||||
private final SendingServiceAwareActivity activity;
|
||||
|
||||
public SystemInformationActivityHelper(SendingServiceAwareActivity activity, String deviceIdentifier) {
|
||||
this.activity = activity;
|
||||
activity.setContentView(R.layout.system_information_view);
|
||||
setupVersionView(deviceIdentifier);
|
||||
setupInstalledView();
|
||||
setupPersistenceView();
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the SendingServiceInformation with this content, and then call parent.
|
||||
*/
|
||||
public void updateSendingServiceInformation() {
|
||||
TextView statusView = (TextView) activity.findViewById(R.id.system_information_persistence_status);
|
||||
//ListView waitingView = (ListView) activity.findViewById(R.id.system_information_persistence_waiting);
|
||||
if (activity.boundSendingService) {
|
||||
Date lastSuccessfulSend = activity.sendingService.getLastSuccessfulSend();
|
||||
statusView.setText(String.format(
|
||||
"Currently %d events waiting to be sent.\nLast successful sent was at: %s.",
|
||||
activity.sendingService.getDelayedIntentsCount(), lastSuccessfulSend == null ? "never"
|
||||
: lastSuccessfulSend));
|
||||
|
||||
// waitingView.setAdapter(new ArrayAdapter<String>(activity,
|
||||
// android.R.layout.simple_list_item_1,
|
||||
// activity.sendingService.getDelayedIntensContent()));
|
||||
} else {
|
||||
statusView.setText(activity.getString(R.string.generic_error));
|
||||
}
|
||||
}
|
||||
|
||||
private void setupPersistenceView() {
|
||||
// status and list view is updated by updateSendingServiceInformation
|
||||
Button clearButton = (Button) activity.findViewById(R.id.system_information_persistence_clear);
|
||||
clearButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (activity.boundSendingService) {
|
||||
activity.sendingService.clearDelayedIntents();
|
||||
} else {
|
||||
Toast.makeText(activity.getApplicationContext(), "", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setupVersionView(String deviceIdentifier) {
|
||||
TextView identifierView = (TextView) activity.findViewById(R.id.system_information_application_identifier);
|
||||
identifierView.setText(deviceIdentifier);
|
||||
|
||||
TextView versionView = (TextView) activity.findViewById(R.id.system_information_application_version);
|
||||
PackageInfo info = AppUtils.getPackageInfo(activity);
|
||||
if (info == null) {
|
||||
versionView.setText(activity.getString(R.string.generic_error));
|
||||
} else {
|
||||
versionView.setText(String.format("%s (Code %s)", info.versionName, info.versionCode));
|
||||
}
|
||||
}
|
||||
|
||||
private void setupInstalledView() {
|
||||
TextView installView = (TextView) activity.findViewById(R.id.system_information_application_install);
|
||||
PackageInfo info = AppUtils.getPackageInfo(activity.getApplication());
|
||||
if (info == null) {
|
||||
installView.setText(activity.getString(R.string.generic_error));
|
||||
} else {
|
||||
Date installDate = new Date(info.lastUpdateTime);
|
||||
installView.setText(String.format("%s - %s", DateFormat.getLongDateFormat(activity).format(installDate),
|
||||
DateFormat.getTimeFormat(activity).format(installDate)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user