mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-23 12:33:53 +00:00
Added settings activity with server syncronisation intervall option
This commit is contained in:
1 parent
1be2c1013a
commit
09e93d9a8a
13 files changed
+166
-46
No files matched your search
@@ -1,25 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.sap.sailing.android.buoy.positioning.app"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
package="com.sap.sailing.android.buoy.positioning.app"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="14"
|
||||
android:targetSdkVersion="22"/>
|
||||
android:targetSdkVersion="22" />
|
||||
|
||||
<!-- <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> -->
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
|
||||
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
|
||||
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
|
||||
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
|
||||
|
||||
<uses-feature
|
||||
android:glEsVersion="0x00020000"
|
||||
android:required="true"/>
|
||||
android:required="true" />
|
||||
|
||||
<android:uses-permission
|
||||
android:name="android.permission.READ_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="18" />
|
||||
|
||||
<application
|
||||
android:name="com.sap.sailing.android.shared.application.LoggableApplication"
|
||||
@@ -27,71 +32,70 @@
|
||||
android:hardwareAccelerated="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme">
|
||||
android:theme="@style/AppTheme" >
|
||||
<meta-data
|
||||
android:name="com.google.android.gms.version"
|
||||
android:value="@integer/google_play_services_version"/>
|
||||
android:value="@integer/google_play_services_version" />
|
||||
<meta-data
|
||||
android:name="com.google.android.maps.v2.API_KEY"
|
||||
android:value="AIzaSyDH-Dwy5yFlyBa2-VUgiZ3qGGUO8M_0MPY"/>
|
||||
|
||||
android:value="AIzaSyDH-Dwy5yFlyBa2-VUgiZ3qGGUO8M_0MPY" />
|
||||
|
||||
<activity
|
||||
android:name=".ui.activities.StartActivity"
|
||||
android:label="@string/app_name"
|
||||
android:screenOrientation="portrait">
|
||||
android:screenOrientation="portrait" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data
|
||||
android:host="*"
|
||||
android:pathPattern=".*buoy-tender/checkin.*"
|
||||
android:scheme="http"/>
|
||||
android:scheme="http" />
|
||||
<data
|
||||
android:host="*"
|
||||
android:pathPattern=".*buoy-tender/checkin.*"
|
||||
android:scheme="http"/>
|
||||
android:scheme="http" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".ui.activities.RegattaActivity"
|
||||
android:screenOrientation="portrait">
|
||||
|
||||
android:screenOrientation="portrait" >
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".ui.activities.PositioningActivity"
|
||||
android:screenOrientation="portrait">
|
||||
|
||||
android:screenOrientation="portrait" >
|
||||
</activity>
|
||||
|
||||
<service
|
||||
android:name="com.sap.sailing.android.shared.services.sending.MessageSendingService"
|
||||
android:exported="false">
|
||||
android:exported="false" >
|
||||
<intent-filter>
|
||||
<action android:name="com.sap.sailing.android.tracking.app.action.sendSavedIntents"/>
|
||||
<action android:name="com.sap.sailing.android.tracking.app.action.sendMessage"/>
|
||||
<action android:name="com.sap.sailing.android.tracking.app.action.sendSavedIntents" />
|
||||
<action android:name="com.sap.sailing.android.tracking.app.action.sendMessage" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name=".service.MarkerService"
|
||||
android:exported="false"/>
|
||||
android:exported="false" />
|
||||
|
||||
<provider
|
||||
android:name="com.sap.sailing.android.buoy.positioning.app.provider.AnalyticsProvider"
|
||||
android:name=".provider.AnalyticsProvider"
|
||||
android:authorities="com.sap.sailing.android.buoy.positioning.app.provider.db"
|
||||
android:exported="false"/>
|
||||
android:exported="false" />
|
||||
|
||||
<activity
|
||||
android:name=".ui.activities.SettingActivity"
|
||||
android:label="@string/title_activity_settings" >
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
</manifest>
|
||||
@@ -3,4 +3,7 @@
|
||||
<item
|
||||
android:id="@+id/about"
|
||||
android:title="@string/about"/>
|
||||
<item
|
||||
android:id="@+id/settings"
|
||||
android:title="@string/settings"/>
|
||||
</menu>
|
||||
@@ -4,6 +4,10 @@
|
||||
android:id="@+id/refresh"
|
||||
android:title="@string/options_refresh"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/settings"
|
||||
android:title="@string/settings"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/about"
|
||||
android:title="@string/about"/>
|
||||
|
||||
@@ -12,5 +12,9 @@
|
||||
<string name="accuracy">Genauigkeit</string>
|
||||
<string name="position_set">Die Position wurde gesetzt</string>
|
||||
<string name="no_information">Keine Information</string>
|
||||
<string name="settings">Einstellungen</string>
|
||||
|
||||
<string name="server">Server</string>
|
||||
<string name="server_sync_settings">Server Synchronisations Intervall in Sekunden</string>
|
||||
|
||||
</resources>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="preference_data_refresh_interval_millis_key" translatable="false">messageResendIntervalMillis</string>
|
||||
<integer name="preference_data_refresh_interval_millis_default">120000</integer>
|
||||
<string name="preference_data_refresh_interval_seconds_key" translatable="false">data_refresh_interval_millis</string>
|
||||
<integer name="preference_data_refresh_interval_seconds_default">120</integer>
|
||||
<string name="check_in_url_key" translatable="false">check_in_url</string>
|
||||
</resources>
|
||||
@@ -16,5 +16,13 @@
|
||||
<string name="accuracy">Accuracy</string>
|
||||
<string name="position_set">The position has been set</string>
|
||||
<string name="no_information">No information</string>
|
||||
<string name="title_activity_settings">Settings</string>
|
||||
|
||||
<string name="hello_world">Hello world!</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="settings">Settings</string>
|
||||
|
||||
<string name="server">Server</string>
|
||||
<string name="server_sync_settings">Interval of server synchronisation in seconds</string>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- Energy Saving -->
|
||||
<PreferenceCategory android:title="@string/server">
|
||||
<EditTextPreference
|
||||
android:defaultValue="@integer/preference_data_refresh_interval_seconds_default"
|
||||
android:key="@string/preference_data_refresh_interval_seconds_key"
|
||||
android:title="@string/server_sync_settings"
|
||||
android:inputType="number"
|
||||
/>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
+1
-1
@@ -87,7 +87,7 @@ public class MarkerService extends Service implements CheckinManager.DataChange
|
||||
while (running) {
|
||||
long timeDiff = Calendar.getInstance().getTimeInMillis() - lastCheck;
|
||||
|
||||
if(timeDiff > preferences.getDataRefreshInterval()) {
|
||||
if(timeDiff > preferences.getDataRefreshInterval() * 1000) {
|
||||
manager.callServerAndGenerateCheckinData();
|
||||
lastCheck = Calendar.getInstance().getTimeInMillis();
|
||||
}
|
||||
|
||||
+3
@@ -134,6 +134,9 @@ public class RegattaActivity extends AbstractRegattaActivity {
|
||||
AboutDialog aboutDialog = new AboutDialog(this);
|
||||
aboutDialog.show();
|
||||
return true;
|
||||
case R.id.settings:
|
||||
startActivity(new Intent(this, SettingActivity.class));
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.sap.sailing.android.buoy.positioning.app.ui.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
import com.sap.sailing.android.buoy.positioning.app.R;
|
||||
import com.sap.sailing.android.buoy.positioning.app.ui.fragments.GeneralPreferenceFragment;
|
||||
|
||||
public class SettingActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.pref_with_actionbar);
|
||||
|
||||
setupToolbar();
|
||||
|
||||
getFragmentManager().beginTransaction().replace(R.id.content_frame, new GeneralPreferenceFragment()).commit();
|
||||
}
|
||||
|
||||
private void setupToolbar() {
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
toolbar.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
|
||||
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
ActionBar supportActionBar = getSupportActionBar();
|
||||
if (supportActionBar != null) {
|
||||
supportActionBar.setDisplayHomeAsUpEnabled(true);
|
||||
supportActionBar.setHomeButtonEnabled(true);
|
||||
supportActionBar.setTitle(R.string.settings);
|
||||
toolbar.setNavigationIcon(R.drawable.sap_logo_64_sq);
|
||||
toolbar.setPadding(20, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+3
@@ -43,6 +43,9 @@ public class StartActivity extends AbstractStartActivity {
|
||||
AboutDialog aboutDialog = new AboutDialog(this);
|
||||
aboutDialog.show();
|
||||
return true;
|
||||
case R.id.settings:
|
||||
startActivity(new Intent(this, SettingActivity.class));
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.sap.sailing.android.buoy.positioning.app.ui.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.EditTextPreference;
|
||||
import android.preference.Preference;
|
||||
import com.sap.sailing.android.buoy.positioning.app.R;
|
||||
import com.sap.sailing.android.buoy.positioning.app.util.AppPreferences;
|
||||
import com.sap.sailing.android.shared.ui.fragments.preference.BasePreferenceFragment;
|
||||
|
||||
public class GeneralPreferenceFragment extends BasePreferenceFragment {
|
||||
|
||||
private EditTextPreference prefServerSync;
|
||||
private AppPreferences prefs;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
prefs = new AppPreferences(getActivity());
|
||||
addPreferencesFromResource(R.xml.preference_general);
|
||||
prefServerSync = findPreference(R.string.preference_data_refresh_interval_seconds_key);
|
||||
prefServerSync.setSummary("" + prefs.getDataRefreshInterval());
|
||||
prefServerSync.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
preference.setSummary("" + newValue);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
prefs.setDataRefreshInterval(Long.parseLong(prefServerSync.getText()));
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -28,13 +28,13 @@ public class AppPreferences extends BaseAppPreferences {
|
||||
}
|
||||
|
||||
public void setDataRefreshInterval(long interval){
|
||||
preferences.edit().putLong(context.getString(R.string.preference_data_refresh_interval_millis_key), interval)
|
||||
preferences.edit().putLong(context.getString(R.string.preference_data_refresh_interval_seconds_key), interval)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public long getDataRefreshInterval(){
|
||||
return preferences.getLong(context.getString(R.string.preference_data_refresh_interval_millis_key),
|
||||
context.getResources().getInteger(R.integer.preference_data_refresh_interval_millis_default));
|
||||
return preferences.getLong(context.getString(R.string.preference_data_refresh_interval_seconds_key),
|
||||
context.getResources().getInteger(R.integer.preference_data_refresh_interval_seconds_default));
|
||||
}
|
||||
|
||||
public static boolean getPrintDatabaseOperationDebugMessages() {
|
||||
|
||||
Reference in new issue
Block a user