mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-30 15:57:11 +00:00
# readded settings activity
This commit is contained in:
1 parent
f5493d2a98
commit
a8713a3e29
5 files changed
+105
-75
No files matched your search
@@ -45,7 +45,7 @@
|
||||
android:name=".ui.activities.RacingActivity">
|
||||
</activity>
|
||||
|
||||
<service
|
||||
<activity android:name=".ui.activities.SettingsActivity"></activity><service
|
||||
android:name="com.sap.sailing.racecommittee.app.services.RaceStateService"
|
||||
android:enabled="true"
|
||||
android:exported="false" >
|
||||
@@ -63,6 +63,7 @@
|
||||
</service>
|
||||
|
||||
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
+3
@@ -29,6 +29,9 @@ public class EventSenderTask extends AsyncTask<Intent, Void, Pair<Intent, Intege
|
||||
protected Pair<Intent, Integer> doInBackground(Intent... params) {
|
||||
|
||||
Intent intent = params[0];
|
||||
if (intent == null) {
|
||||
return Pair.create(intent, -1);
|
||||
}
|
||||
|
||||
Bundle extras = intent.getExtras();
|
||||
Serializable serializedEvent = extras.getSerializable(AppConstants.EXTRAS_JSON_KEY);
|
||||
|
||||
+75
-73
@@ -1,87 +1,89 @@
|
||||
package com.sap.sailing.racecommittee.app.ui.activities;
|
||||
|
||||
import com.sap.sailing.racecommittee.app.AppConstants;
|
||||
import com.sap.sailing.racecommittee.app.R;
|
||||
import com.sap.sailing.racecommittee.app.logging.ExLog;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* Base activity for all race committee cockpit activities enabling basic
|
||||
* menu functionality.
|
||||
* Base activity for all race committee cockpit activities enabling basic menu functionality.
|
||||
*/
|
||||
public abstract class BaseActivity extends Activity {
|
||||
|
||||
protected MenuItem menuItemLive;
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
/*MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.options_menu, menu);
|
||||
menuItemLive = menu.findItem(R.id.LiveIcon);*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle item selection
|
||||
switch (item.getItemId()) {
|
||||
/*case R.id.SystemInfo:
|
||||
fadeActivity(InformationActivity.class);
|
||||
return true;
|
||||
case R.id.OptionsSettings:
|
||||
fadeActivity(SettingsActivity.class);
|
||||
return true;
|
||||
case R.id.LiveIcon:
|
||||
Toast.makeText(this, AppConstants.getURL(this), Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
case R.id.WindLog:
|
||||
//fadeActivity(WindActivity.class);
|
||||
return false;*/
|
||||
case android.R.id.home:
|
||||
return onHomeClicked();
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean onHomeClicked() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
updateLiveIcon();
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
updateLiveIcon();
|
||||
}
|
||||
protected MenuItem menuItemLive;
|
||||
|
||||
private void updateLiveIcon() {
|
||||
/*if (menuItemLive == null)
|
||||
return;
|
||||
|
||||
ExLog.i("OptionsMenu", "Querying remote status.");
|
||||
if (AppConstants.getURL(this).indexOf("sapsailing.com") != -1) {
|
||||
ExLog.i("OptionsMenu", "It's remote.");
|
||||
menuItemLive.setIcon(R.drawable.ic_menu_share_sapsailing);
|
||||
} else {
|
||||
ExLog.i("OptionsMenu", "It's local.");
|
||||
menuItemLive.setIcon(R.drawable.ic_menu_share_local);
|
||||
}*/
|
||||
}
|
||||
|
||||
protected void fadeActivity(Class<?> activity) {
|
||||
Intent intent = new Intent(getBaseContext(), activity);
|
||||
fadeActivity(intent);
|
||||
}
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.options_menu, menu);
|
||||
menuItemLive = menu.findItem(R.id.LiveIcon);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void fadeActivity(Intent intent) {
|
||||
startActivity(intent);
|
||||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||
}
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle item selection
|
||||
switch (item.getItemId()) {
|
||||
/*
|
||||
* case R.id.SystemInfo: fadeActivity(InformationActivity.class); return true;
|
||||
*/
|
||||
case R.id.OptionsSettings:
|
||||
fadeActivity(SettingsActivity.class);
|
||||
return true;
|
||||
case R.id.LiveIcon:
|
||||
Toast.makeText(this, AppConstants.getServerBaseURL(this), Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
case R.id.WindLog: // fadeActivity(WindActivity.class); return false;
|
||||
case android.R.id.home:
|
||||
return onHomeClicked();
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean onHomeClicked() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
updateLiveIcon();
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
updateLiveIcon();
|
||||
}
|
||||
|
||||
private void updateLiveIcon() {
|
||||
if (menuItemLive == null)
|
||||
return;
|
||||
|
||||
ExLog.i("OptionsMenu", "Querying remote status.");
|
||||
if (AppConstants.getServerBaseURL(this).indexOf("sapsailing.com") != -1) {
|
||||
ExLog.i("OptionsMenu", "It's remote.");
|
||||
menuItemLive.setIcon(R.drawable.ic_menu_share_sapsailing);
|
||||
} else {
|
||||
ExLog.i("OptionsMenu", "It's local.");
|
||||
menuItemLive.setIcon(R.drawable.ic_menu_share_local);
|
||||
}
|
||||
}
|
||||
|
||||
protected void fadeActivity(Class<?> activity) {
|
||||
Intent intent = new Intent(getBaseContext(), activity);
|
||||
fadeActivity(intent);
|
||||
}
|
||||
|
||||
protected void fadeActivity(Intent intent) {
|
||||
startActivity(intent);
|
||||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.sap.sailing.racecommittee.app.ui.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceActivity;
|
||||
|
||||
import com.sap.sailing.racecommittee.app.R;
|
||||
|
||||
/**
|
||||
* @author Basil Hess (basil.hess@sap.com)
|
||||
*
|
||||
*/
|
||||
public class SettingsActivity extends PreferenceActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.layout.settings_view);
|
||||
}
|
||||
}
|
||||
+6
-1
@@ -103,7 +103,12 @@ public abstract class NamedListFragment<T extends Named> extends ListFragment im
|
||||
|
||||
public void onLoadFailed(Exception reason) {
|
||||
showProgressBar(false);
|
||||
showLoadFailedDialog(reason.getMessage());
|
||||
|
||||
String message = reason.getMessage();
|
||||
if (message == null) {
|
||||
message = reason.toString();
|
||||
}
|
||||
showLoadFailedDialog(message);
|
||||
}
|
||||
|
||||
private void showProgressBar(boolean visible) {
|
||||
|
||||
Reference in new issue
Block a user