Removed Widget.

This commit is contained in:
Dennis Guse
2019-09-10 19:55:02 +02:00
parent 96dab8c81b
commit fc6d5f1f23
14 changed files with 3 additions and 1634 deletions
+3 -2
View File
@@ -1,10 +1,11 @@
(tbd): OpenTracks
Changes:
-
- Removed Widget
Bugfix:
-
Developer:
- Fixed (some) test cases
- Fixed (some) test cases
- Major cleanup and reformatting
-20
View File
@@ -136,13 +136,6 @@ limitations under the License.
<activity android:name=".settings.RecordingSettingsActivity" />
<activity android:name=".settings.SettingsActivity" />
<activity android:name=".settings.StatsSettingsActivity" />
<activity
android:name=".widgets.TrackWidgetConfigActivity"
android:label="@string/track_widget_config_title">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
</activity>
<service
android:name=".services.ControlRecordingService"
@@ -159,19 +152,6 @@ limitations under the License.
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<receiver android:name=".widgets.TrackWidgetProvider">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="TRACK_PAUSED" />
<action android:name="TRACK_RESUMED" />
<action android:name="TRACK_STARTED" />
<action android:name="TRACK_STOPPED" />
<action android:name="TRACK_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/track_widget_info" />
</receiver>
<!-- Providers -->
<provider
android:name=".content.ShareContentProvider"
@@ -27,12 +27,10 @@ import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import de.dennisguse.opentracks.R;
import de.dennisguse.opentracks.widgets.TrackWidgetProvider;
/**
* A service to control starting and stopping of a recording.
* This service, through the AndroidManifest.xml, is configured to only allow components of the same application to invoke it.
* Thus this service can be used by the app widget, {@link TrackWidgetProvider}, but not by other applications.
* This application delegates starting and stopping a recording to {@link TrackRecordingService} using RPC calls.
*
* @author Jimmy Shih
@@ -1,122 +0,0 @@
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package de.dennisguse.opentracks.widgets;
import android.app.Activity;
import android.appwidget.AppWidgetManager;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import de.dennisguse.opentracks.R;
import de.dennisguse.opentracks.util.PreferencesUtils;
/**
* Activity to configure the track widget.
*
* @author Jimmy Shih
*/
public class TrackWidgetConfigActivity extends Activity {
private int appWidgetId;
private Spinner item1;
private Spinner item2;
private Spinner item3;
private Spinner item4;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/*
* Set the result to CANCELED. This will cause the widget host to cancel out
* of the widget placement if they press the back button.
*/
setResult(RESULT_CANCELED);
setContentView(R.layout.track_widget_config);
item1 = findViewById(R.id.track_widget_config_item1);
item2 = findViewById(R.id.track_widget_config_item2);
item3 = findViewById(R.id.track_widget_config_item3);
item4 = findViewById(R.id.track_widget_config_item4);
boolean reportSpeed = PreferencesUtils.isReportSpeed(this);
List<CharSequence> list = new ArrayList<>();
addItem(list, R.string.stats_distance);
addItem(list, R.string.stats_total_time);
addItem(list, reportSpeed ? R.string.stats_average_speed : R.string.stats_average_pace);
addItem(list, R.string.stats_moving_time);
addItem(list, reportSpeed ? R.string.stats_average_moving_speed : R.string.stats_average_moving_pace);
configSpinner(item1, list, PreferencesUtils.getInt(this, R.string.track_widget_item1, PreferencesUtils.TRACK_WIDGET_ITEM1_DEFAULT));
configSpinner(item2, list, PreferencesUtils.getInt(this, R.string.track_widget_item2, PreferencesUtils.TRACK_WIDGET_ITEM2_DEFAULT));
configSpinner(item3, list, PreferencesUtils.getInt(this, R.string.track_widget_item3, PreferencesUtils.TRACK_WIDGET_ITEM3_DEFAULT));
configSpinner(item4, list, PreferencesUtils.getInt(this, R.string.track_widget_item4, PreferencesUtils.TRACK_WIDGET_ITEM4_DEFAULT));
findViewById(R.id.track_widget_config_add).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Push widget update to surface with newly set prefix
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(TrackWidgetConfigActivity.this);
TrackWidgetProvider.updateAppWidget(TrackWidgetConfigActivity.this, appWidgetManager, appWidgetId, -1L);
PreferencesUtils.setInt(TrackWidgetConfigActivity.this, R.string.track_widget_item1, item1.getSelectedItemPosition());
PreferencesUtils.setInt(TrackWidgetConfigActivity.this, R.string.track_widget_item2, item2.getSelectedItemPosition());
PreferencesUtils.setInt(TrackWidgetConfigActivity.this, R.string.track_widget_item3, item3.getSelectedItemPosition());
PreferencesUtils.setInt(TrackWidgetConfigActivity.this, R.string.track_widget_item4, item4.getSelectedItemPosition());
// Make sure we pass back the original appWidgetId
Intent resultValue = new Intent();
resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
setResult(RESULT_OK, resultValue);
finish();
}
});
findViewById(R.id.track_widget_config_cancel).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
// Find the app widget id from the intent.
Intent intent = getIntent();
Bundle extras = intent.getExtras();
appWidgetId = extras != null ? extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID) : AppWidgetManager.INVALID_APPWIDGET_ID;
// If they gave us an intent without the widget id, just bail.
if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
finish();
}
}
private void addItem(List<CharSequence> list, int id) {
list.add(getString(id).toUpperCase(Locale.getDefault()));
}
private void configSpinner(Spinner spinner, List<CharSequence> list, int position) {
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, list);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
spinner.setSelection(position);
}
}
@@ -1,461 +0,0 @@
/*
* Copyright 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package de.dennisguse.opentracks.widgets;
import android.annotation.TargetApi;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.appwidget.AppWidgetProviderInfo;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.SystemClock;
import android.view.View;
import android.widget.RemoteViews;
import androidx.core.app.TaskStackBuilder;
import de.dennisguse.opentracks.R;
import de.dennisguse.opentracks.TrackDetailActivity;
import de.dennisguse.opentracks.TrackListActivity;
import de.dennisguse.opentracks.content.ContentProviderUtils;
import de.dennisguse.opentracks.content.Track;
import de.dennisguse.opentracks.services.ControlRecordingService;
import de.dennisguse.opentracks.stats.TripStatistics;
import de.dennisguse.opentracks.util.IntentUtils;
import de.dennisguse.opentracks.util.PreferencesUtils;
import de.dennisguse.opentracks.util.StringUtils;
/**
* A track widget to start/stop/pause/resume recording, launch the main activity, and display track statistics (total distance, total time, average speed, and moving time) for the recording track, the selected track or the last track.
*
* @author Sandor Dornbush
* @author Paul R. Saxman
*/
public class TrackWidgetProvider extends AppWidgetProvider {
public static final int HOME_SCREEN_DEFAULT_SIZE = 2;
private static final String APP_WIDGET_SIZE_KEY = "app_widget_size_key";
private static final int TWO_CELLS = 110;
private static final int THREE_CELLS = 180;
private static final int FOUR_CELLS = 250;
private static final int[] ITEM1_IDS = {R.id.track_widget_item1_label, R.id.track_widget_item1_value, R.id.track_widget_item1_unit, R.id.track_widget_item1_chronometer};
private static final int[] ITEM2_IDS = {R.id.track_widget_item2_label, R.id.track_widget_item2_value, R.id.track_widget_item2_unit, R.id.track_widget_item2_chronometer};
private static final int[] ITEM3_IDS = {R.id.track_widget_item3_label, R.id.track_widget_item3_value, R.id.track_widget_item3_unit, R.id.track_widget_item3_chronometer};
private static final int[] ITEM4_IDS = {R.id.track_widget_item4_label, R.id.track_widget_item4_value, R.id.track_widget_item4_unit, R.id.track_widget_item4_chronometer};
/**
* Updates an app widget.
*
* @param context the context
* @param appWidgetManager the app widget manager
* @param appWidgetId the app widget id
* @param trackId the track id. -1L to not specify one
*/
public static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId, long trackId) {
int size = getAppWidgetSize(appWidgetManager, appWidgetId);
RemoteViews remoteViews = getRemoteViews(context, trackId, size);
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
}
/**
* Updates all app widgets.
*
* @param context the context
* @param trackId track id
*/
private static void updateAllAppWidgets(Context context, long trackId) {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, TrackWidgetProvider.class));
for (int appWidgetId : appWidgetIds) {
updateAppWidget(context, appWidgetManager, appWidgetId, trackId);
}
}
/**
* Gets the remote views.
*
* @param context the context
* @param trackId the track id
* @param heightSize the layout height size
*/
private static RemoteViews getRemoteViews(Context context, long trackId, int heightSize) {
int layout;
switch (heightSize) {
case 4:
layout = R.layout.track_widget_4x4;
break;
case 3:
layout = R.layout.track_widget_4x3;
break;
case 2:
layout = R.layout.track_widget_4x2;
break;
case 1:
layout = R.layout.track_widget_4x1;
break;
default:
layout = R.layout.track_widget_4x2;
break;
}
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), layout);
// Get the preferences
long recordingTrackId = PreferencesUtils.getLong(context, R.string.recording_track_id_key);
boolean isRecording = recordingTrackId != PreferencesUtils.RECORDING_TRACK_ID_DEFAULT;
boolean isPaused = PreferencesUtils.getBoolean(context, R.string.recording_track_paused_key, PreferencesUtils.RECORDING_TRACK_PAUSED_DEFAULT);
boolean metricUnits = PreferencesUtils.isMetricUnits(context);
boolean reportSpeed = PreferencesUtils.isReportSpeed(context);
int item1 = PreferencesUtils.getInt(context, R.string.track_widget_item1, PreferencesUtils.TRACK_WIDGET_ITEM1_DEFAULT);
int item2 = PreferencesUtils.getInt(context, R.string.track_widget_item2, PreferencesUtils.TRACK_WIDGET_ITEM2_DEFAULT);
// Get track and trip statistics
ContentProviderUtils contentProviderUtils = ContentProviderUtils.Factory.get(context);
if (trackId == -1L) {
trackId = recordingTrackId;
}
Track track = trackId != -1L ? contentProviderUtils.getTrack(trackId) : contentProviderUtils.getLastTrack();
TripStatistics tripStatistics = track == null ? null : track.getTripStatistics();
updateStatisticsContainer(context, remoteViews, track);
setItem(context, remoteViews, ITEM1_IDS, item1, tripStatistics, isRecording, isPaused, metricUnits, reportSpeed);
setItem(context, remoteViews, ITEM2_IDS, item2, tripStatistics, isRecording, isPaused, metricUnits, reportSpeed);
updateRecordButton(context, remoteViews, isRecording, isPaused);
updateStopButton(context, remoteViews, isRecording);
if (heightSize > 1) {
int item3 = PreferencesUtils.getInt(context, R.string.track_widget_item3, PreferencesUtils.TRACK_WIDGET_ITEM3_DEFAULT);
int item4 = PreferencesUtils.getInt(context, R.string.track_widget_item4, PreferencesUtils.TRACK_WIDGET_ITEM4_DEFAULT);
setItem(context, remoteViews, ITEM3_IDS, item3, tripStatistics, isRecording, isPaused, metricUnits, reportSpeed);
setItem(context, remoteViews, ITEM4_IDS, item4, tripStatistics, isRecording, isPaused, metricUnits, reportSpeed);
updateRecordStatus(context, remoteViews, isRecording, isPaused);
}
return remoteViews;
}
/**
* Gets the app widget size.
*
* @param appWidgetManager the app widget manager
* @param appWidgetId the app widget id
*/
private static int getAppWidgetSize(AppWidgetManager appWidgetManager, int appWidgetId) {
Bundle bundle = appWidgetManager.getAppWidgetOptions(appWidgetId);
return bundle.getInt(APP_WIDGET_SIZE_KEY, HOME_SCREEN_DEFAULT_SIZE);
}
/**
* Sets a widget item.
*
* @param context the context
* @param remoteViews the remote view
* @param ids the item's ids
* @param value the item value
* @param tripStatistics the trip statistics
* @param metricUnits true to use metric units
* @param reportSpeed try to report speed
*/
private static void setItem(Context context, RemoteViews remoteViews, int[] ids, int value, TripStatistics tripStatistics, boolean isRecording, boolean isPaused, boolean metricUnits, boolean reportSpeed) {
switch (value) {
case 0:
updateDistance(context, remoteViews, ids, tripStatistics, metricUnits);
break;
case 1:
updateTotalTime(context, remoteViews, ids, tripStatistics, isRecording, isPaused);
break;
case 2:
updateAverageSpeed(context, remoteViews, ids, tripStatistics, metricUnits, reportSpeed);
break;
case 3:
updateMovingTime(context, remoteViews, ids, tripStatistics);
break;
case 4:
updateAverageMovingSpeed(context, remoteViews, ids, tripStatistics, metricUnits, reportSpeed);
break;
default:
updateDistance(context, remoteViews, ids, tripStatistics, metricUnits);
break;
}
if (value != 1) {
remoteViews.setViewVisibility(ids[1], View.VISIBLE);
remoteViews.setViewVisibility(ids[2], View.VISIBLE);
remoteViews.setViewVisibility(ids[3], View.GONE);
remoteViews.setChronometer(ids[3], SystemClock.elapsedRealtime(), null, false);
}
}
/**
* Updates the statistics container.
*
* @param context the context
* @param remoteViews the remote views
* @param track the track
*/
private static void updateStatisticsContainer(Context context, RemoteViews remoteViews, Track track) {
PendingIntent pendingIntent;
if (track != null) {
Intent intent = IntentUtils.newIntent(context, TrackDetailActivity.class)
.putExtra(TrackDetailActivity.EXTRA_TRACK_ID, track.getId());
pendingIntent = TaskStackBuilder.create(context)
.addParentStack(TrackDetailActivity.class).addNextIntent(intent).getPendingIntent(0, 0);
} else {
Intent intent = IntentUtils.newIntent(context, TrackListActivity.class);
pendingIntent = TaskStackBuilder.create(context).addNextIntent(intent).getPendingIntent(0, 0);
}
remoteViews.setOnClickPendingIntent(R.id.track_widget_stats_container, pendingIntent);
}
/**
* Updates distance.
*
* @param context the context
* @param remoteViews the remote views
* @param ids the item's ids
* @param tripStatistics the trip statistics
* @param metricUnits true to use metric units
*/
private static void updateDistance(Context context, RemoteViews remoteViews, int[] ids, TripStatistics tripStatistics, boolean metricUnits) {
double totalDistance = tripStatistics == null ? Double.NaN : tripStatistics.getTotalDistance();
String[] totalDistanceParts = StringUtils.getDistanceParts(context, totalDistance, metricUnits);
if (totalDistanceParts[0] == null) {
totalDistanceParts[0] = context.getString(R.string.value_unknown);
}
remoteViews.setTextViewText(ids[0], context.getString(R.string.stats_distance));
remoteViews.setTextViewText(ids[1], totalDistanceParts[0]);
remoteViews.setTextViewText(ids[2], totalDistanceParts[1]);
}
/**
* Updates total time.
*
* @param context the context
* @param remoteViews the remote views
* @param ids the item's ids
* @param tripStatistics the trip statistics
*/
private static void updateTotalTime(Context context, RemoteViews remoteViews, int[] ids, TripStatistics tripStatistics, boolean isRecording, boolean isPaused) {
if (isRecording && !isPaused && tripStatistics != null) {
long time = tripStatistics.getTotalTime() + System.currentTimeMillis() - tripStatistics.getStopTime();
remoteViews.setChronometer(ids[3], SystemClock.elapsedRealtime() - time, null, true);
remoteViews.setViewVisibility(ids[1], View.GONE);
remoteViews.setViewVisibility(ids[2], View.GONE);
remoteViews.setViewVisibility(ids[3], View.VISIBLE);
} else {
remoteViews.setChronometer(ids[3], SystemClock.elapsedRealtime(), null, false);
remoteViews.setViewVisibility(ids[1], View.VISIBLE);
remoteViews.setViewVisibility(ids[2], View.GONE);
remoteViews.setViewVisibility(ids[3], View.GONE);
String totalTime = tripStatistics == null ? context.getString(R.string.value_unknown) : StringUtils.formatElapsedTime(tripStatistics.getTotalTime());
remoteViews.setTextViewText(ids[0], context.getString(R.string.stats_total_time));
remoteViews.setTextViewText(ids[1], totalTime);
}
}
/**
* Updates average speed.
*
* @param context the context
* @param remoteViews the remote views
* @param ids the item's ids
* @param tripStatistics the trip statistics
* @param metricUnits true to use metric units
* @param reportSpeed true to report speed
*/
private static void updateAverageSpeed(Context context, RemoteViews remoteViews, int[] ids, TripStatistics tripStatistics, boolean metricUnits, boolean reportSpeed) {
String averageSpeedLabel = context.getString(reportSpeed ? R.string.stats_average_speed : R.string.stats_average_pace);
remoteViews.setTextViewText(ids[0], averageSpeedLabel);
double speed = tripStatistics == null ? Double.NaN : tripStatistics.getAverageSpeed();
String[] speedParts = StringUtils.getSpeedParts(context, speed, metricUnits, reportSpeed);
if (speedParts[0] == null) {
speedParts[0] = context.getString(R.string.value_unknown);
}
remoteViews.setTextViewText(ids[1], speedParts[0]);
remoteViews.setTextViewText(ids[2], speedParts[1]);
}
/**
* Updates moving time.
*
* @param context the context
* @param remoteViews the remote views
* @param ids the item's ids
* @param tripStatistics the trip statistics
*/
private static void updateMovingTime(Context context, RemoteViews remoteViews, int[] ids, TripStatistics tripStatistics) {
String movingTime = tripStatistics == null ? context.getString(R.string.value_unknown) : StringUtils.formatElapsedTime(tripStatistics.getMovingTime());
remoteViews.setTextViewText(ids[0], context.getString(R.string.stats_moving_time));
remoteViews.setTextViewText(ids[1], movingTime);
remoteViews.setViewVisibility(ids[2], View.GONE);
}
/**
* Updates average moving speed.
*
* @param context the context
* @param remoteViews the remote views
* @param ids the item's ids
* @param tripStatistics the trip statistics
* @param metricUnits true to use metric units
* @param reportSpeed true to report speed
*/
private static void updateAverageMovingSpeed(Context context, RemoteViews remoteViews, int[] ids, TripStatistics tripStatistics, boolean metricUnits, boolean reportSpeed) {
String averageMovingSpeedLabel = context.getString(reportSpeed ? R.string.stats_average_moving_speed : R.string.stats_average_moving_pace);
remoteViews.setTextViewText(ids[0], averageMovingSpeedLabel);
double speed = tripStatistics == null ? Double.NaN : tripStatistics.getAverageMovingSpeed();
String[] speedParts = StringUtils.getSpeedParts(context, speed, metricUnits, reportSpeed);
if (speedParts[0] == null) {
speedParts[0] = context.getString(R.string.value_unknown);
}
remoteViews.setTextViewText(ids[1], speedParts[0]);
remoteViews.setTextViewText(ids[2], speedParts[1]);
}
/**
* Updates the record button.
*
* @param context the context
* @param remoteViews the remote views
* @param isRecording true if recording
* @param recordingTrackPaused true if recording track is paused
*/
private static void updateRecordButton(Context context, RemoteViews remoteViews, boolean isRecording, boolean recordingTrackPaused) {
remoteViews.setImageViewResource(R.id.track_widget_record_button, isRecording && !recordingTrackPaused ? R.drawable.button_pause : R.drawable.button_record);
int recordActionId;
if (isRecording) {
recordActionId = recordingTrackPaused ? R.string.track_action_resume : R.string.track_action_pause;
} else {
recordActionId = R.string.track_action_start;
}
Intent intent = new Intent(context, ControlRecordingService.class).setAction(context.getString(recordActionId));
PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
remoteViews.setOnClickPendingIntent(R.id.track_widget_record_button, pendingIntent);
}
/**
* Updates the stop button.
*
* @param context the context
* @param remoteViews the remote views
* @param isRecording true if recording
*/
private static void updateStopButton(Context context, RemoteViews remoteViews, boolean isRecording) {
remoteViews.setImageViewResource(R.id.track_widget_stop_button, isRecording ? R.drawable.button_stop : R.drawable.ic_button_stop_disabled);
remoteViews.setBoolean(R.id.track_widget_stop_button, "setEnabled", isRecording);
if (isRecording) {
Intent intent = new Intent(context, ControlRecordingService.class).setAction(context.getString(R.string.track_action_end));
PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
remoteViews.setOnClickPendingIntent(R.id.track_widget_stop_button, pendingIntent);
}
}
/**
* Updates recording status.
*
* @param context the context
* @param remoteViews the remote views
* @param isRecording true if recording
* @param recordingTrackPaused true if recording track is paused
*/
private static void updateRecordStatus(Context context, RemoteViews remoteViews, boolean isRecording, boolean recordingTrackPaused) {
String status;
int colorId;
if (isRecording) {
status = context.getString(recordingTrackPaused ? R.string.generic_paused : R.string.generic_recording);
colorId = recordingTrackPaused ? android.R.color.white : R.color.recording_text;
} else {
status = "";
colorId = android.R.color.white;
}
remoteViews.setTextColor(R.id.track_widget_record_status, context.getResources().getColor(colorId));
remoteViews.setTextViewText(R.id.track_widget_record_status, status);
}
@Override
public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
String action = intent.getAction();
if (context.getString(R.string.track_paused_broadcast_action).equals(action)
|| context.getString(R.string.track_resumed_broadcast_action).equals(action)
|| context.getString(R.string.track_started_broadcast_action).equals(action)
|| context.getString(R.string.track_stopped_broadcast_action).equals(action)
|| context.getString(R.string.track_update_broadcast_action).equals(action)) {
long trackId = intent.getLongExtra(context.getString(R.string.track_id_broadcast_extra), -1L);
updateAllAppWidgets(context, trackId);
}
}
@Override
public void onEnabled(Context context) {
super.onEnabled(context);
// Need to update all app widgets after phone reboot
updateAllAppWidgets(context, -1L);
}
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
super.onUpdate(context, appWidgetManager, appWidgetIds);
// Need to update all app widgets after software update
updateAllAppWidgets(context, -1L);
}
@TargetApi(16)
@Override
public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions) {
super.onAppWidgetOptionsChanged(context, appWidgetManager, appWidgetId, newOptions);
if (newOptions != null) {
int newSize;
if (newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, -1) == AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD) {
newSize = 1;
} else {
int height = newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT);
if (height == 0) {
newSize = 2;
} else if (height >= FOUR_CELLS) {
newSize = 4;
} else if (height >= THREE_CELLS) {
newSize = 3;
} else if (height >= TWO_CELLS) {
newSize = 2;
} else {
newSize = 1;
}
}
int size = getAppWidgetSize(appWidgetManager, appWidgetId);
if (size != newSize) {
Bundle bundle = new Bundle();
bundle.putInt(APP_WIDGET_SIZE_KEY, size);
appWidgetManager.updateAppWidgetOptions(appWidgetId, bundle);
updateAppWidget(context, appWidgetManager, appWidgetId, -1L);
}
}
}
}
-123
View File
@@ -1,123 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2012 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/TrackWidgetBoundingBox">
<!-- android:orientation="horizontal", override from the style -->
<LinearLayout
style="@style/TrackWidgetFrame"
android:orientation="horizontal"
android:paddingTop="4dp"
android:paddingBottom="4dp">
<LinearLayout
style="@style/TrackWidgetVerticalSpacer"
android:layout_weight="1" />
<ImageButton
android:id="@+id/track_widget_record_button"
style="@style/TrackWidgetButton"
android:contentDescription="@string/image_record"
android:src="@drawable/button_record" />
<LinearLayout
android:id="@+id/track_widget_stats_container"
style="@style/TrackWidgetStatsContainer"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="18"
android:padding="0dp">
<LinearLayout style="@style/TrackWidgetStatsSection">
<!-- item1 -->
<LinearLayout style="@style/TrackWidgetItemContainer">
<TextView
android:id="@+id/track_widget_item1_label"
style="@style/TrackWidgetLabel" />
<LinearLayout style="@style/TrackWidgetValueContainer">
<TextView
android:id="@+id/track_widget_item1_value"
style="@style/TrackWidgetValue" />
<TextView
android:id="@+id/track_widget_item1_unit"
style="@style/TrackWidgetUnit" />
<Chronometer
android:id="@+id/track_widget_item1_chronometer"
style="@style/TrackWidgetValue" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<!-- horizontal separator -->
<LinearLayout
style="@style/TrackWidgetHorizontalSeparator"
android:baselineAligned="false">
<LinearLayout
style="@style/TrackWidgetHorizontalSpacer"
android:layout_weight="1" />
<LinearLayout
style="@style/TrackWidgetHorizontalLine"
android:layout_weight="38" />
<LinearLayout
style="@style/TrackWidgetHorizontalSpacer"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout style="@style/TrackWidgetStatsSection">
<LinearLayout style="@style/TrackWidgetItemContainer">
<!-- item2 -->
<TextView
android:id="@+id/track_widget_item2_label"
style="@style/TrackWidgetLabel" />
<LinearLayout style="@style/TrackWidgetValueContainer">
<TextView
android:id="@+id/track_widget_item2_value"
style="@style/TrackWidgetValue" />
<TextView
android:id="@+id/track_widget_item2_unit"
style="@style/TrackWidgetUnit" />
<Chronometer
android:id="@+id/track_widget_item2_chronometer"
style="@style/TrackWidgetValue" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<ImageButton
android:id="@+id/track_widget_stop_button"
style="@style/TrackWidgetButton"
android:contentDescription="@string/image_stop"
android:src="@drawable/ic_button_stop_disabled" />
<LinearLayout
style="@style/TrackWidgetVerticalSpacer"
android:layout_weight="1" />
</LinearLayout>
<ImageView style="@style/TrackWidgetLogo" />
</RelativeLayout>
-196
View File
@@ -1,196 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2012 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/TrackWidgetBoundingBox">
<LinearLayout
style="@style/TrackWidgetFrame"
android:baselineAligned="false">
<LinearLayout
android:id="@+id/track_widget_stats_container"
style="@style/TrackWidgetStatsContainer"
android:layout_weight="1"
android:baselineAligned="false">
<LinearLayout style="@style/TrackWidgetStatsSection">
<!-- item1 -->
<LinearLayout style="@style/TrackWidgetItemContainer4x2">
<TextView
android:id="@+id/track_widget_item1_label"
style="@style/TrackWidgetLabel" />
<LinearLayout style="@style/TrackWidgetValueContainer">
<TextView
android:id="@+id/track_widget_item1_value"
style="@style/TrackWidgetValue" />
<TextView
android:id="@+id/track_widget_item1_unit"
style="@style/TrackWidgetUnit" />
<Chronometer
android:id="@+id/track_widget_item1_chronometer"
style="@style/TrackWidgetValue" />
</LinearLayout>
</LinearLayout>
<!-- vertical separator -->
<LinearLayout
style="@style/TrackWidgetVerticalSeparator"
android:baselineAligned="false">
<LinearLayout
style="@style/TrackWidgetVerticalSpacer"
android:layout_weight="2" />
<LinearLayout
style="@style/TrackWidgetVerticalLine"
android:layout_weight="1" />
</LinearLayout>
<!-- item3 -->
<LinearLayout style="@style/TrackWidgetItemContainer4x2">
<TextView
android:id="@+id/track_widget_item3_label"
style="@style/TrackWidgetLabel" />
<LinearLayout style="@style/TrackWidgetValueContainer">
<TextView
android:id="@+id/track_widget_item3_value"
style="@style/TrackWidgetValue" />
<TextView
android:id="@+id/track_widget_item3_unit"
style="@style/TrackWidgetUnit" />
<Chronometer
android:id="@+id/track_widget_item3_chronometer"
style="@style/TrackWidgetValue" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<!-- horizontal separator -->
<LinearLayout
style="@style/TrackWidgetHorizontalSeparator"
android:baselineAligned="false">
<LinearLayout
style="@style/TrackWidgetHorizontalSpacer"
android:layout_weight="1" />
<LinearLayout
style="@style/TrackWidgetHorizontalLine"
android:layout_weight="38" />
<LinearLayout
style="@style/TrackWidgetHorizontalSpacer"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout style="@style/TrackWidgetStatsSection">
<!-- item2 -->
<LinearLayout style="@style/TrackWidgetItemContainer4x2">
<TextView
android:id="@+id/track_widget_item2_label"
style="@style/TrackWidgetLabel" />
<LinearLayout style="@style/TrackWidgetValueContainer">
<TextView
android:id="@+id/track_widget_item2_value"
style="@style/TrackWidgetValue" />
<TextView
android:id="@+id/track_widget_item2_unit"
style="@style/TrackWidgetUnit" />
<Chronometer
android:id="@+id/track_widget_item2_chronometer"
style="@style/TrackWidgetValue" />
</LinearLayout>
</LinearLayout>
<!-- vertical separator -->
<LinearLayout
style="@style/TrackWidgetVerticalSeparator"
android:baselineAligned="false">
<LinearLayout
style="@style/TrackWidgetVerticalLine"
android:layout_weight="1" />
<LinearLayout
style="@style/TrackWidgetVerticalSpacer"
android:layout_weight="2" />
</LinearLayout>
<!-- item4 -->
<LinearLayout style="@style/TrackWidgetItemContainer4x2">
<TextView
android:id="@+id/track_widget_item4_label"
style="@style/TrackWidgetLabel" />
<LinearLayout style="@style/TrackWidgetValueContainer">
<TextView
android:id="@+id/track_widget_item4_value"
style="@style/TrackWidgetValue" />
<TextView
android:id="@+id/track_widget_item4_unit"
style="@style/TrackWidgetUnit" />
<Chronometer
android:id="@+id/track_widget_item4_chronometer"
style="@style/TrackWidgetValue" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout style="@style/TrackWidgetButtonContainer">
<LinearLayout
style="@style/TrackWidgetVerticalSpacer"
android:layout_weight="1" />
<ImageButton
android:id="@+id/track_widget_record_button"
style="@style/TrackWidgetButton"
android:contentDescription="@string/image_record"
android:src="@drawable/button_record" />
<TextView
android:id="@+id/track_widget_record_status"
style="@style/TrackWidgetRecordStatus" />
<ImageButton
android:id="@+id/track_widget_stop_button"
style="@style/TrackWidgetButton"
android:contentDescription="@string/image_stop"
android:src="@drawable/ic_button_stop_disabled" />
<LinearLayout
style="@style/TrackWidgetVerticalSpacer"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
<ImageView style="@style/TrackWidgetLogo" />
</RelativeLayout>
-196
View File
@@ -1,196 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2012 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/TrackWidgetBoundingBox">
<LinearLayout
style="@style/TrackWidgetFrame"
android:baselineAligned="false">
<LinearLayout
android:id="@+id/track_widget_stats_container"
style="@style/TrackWidgetStatsContainer"
android:layout_weight="2"
android:baselineAligned="false">
<LinearLayout style="@style/TrackWidgetStatsSection">
<!-- item1 -->
<LinearLayout style="@style/TrackWidgetItemContainer4x3">
<TextView
android:id="@+id/track_widget_item1_label"
style="@style/TrackWidgetLabel" />
<LinearLayout style="@style/TrackWidgetValueContainer4x3">
<TextView
android:id="@+id/track_widget_item1_value"
style="@style/TrackWidgetValue4x3" />
<TextView
android:id="@+id/track_widget_item1_unit"
style="@style/TrackWidgetUnit4x3" />
<Chronometer
android:id="@+id/track_widget_item1_chronometer"
style="@style/TrackWidgetValue4x3" />
</LinearLayout>
</LinearLayout>
<!-- vertical separator -->
<LinearLayout
style="@style/TrackWidgetVerticalSeparator"
android:baselineAligned="false">
<LinearLayout
style="@style/TrackWidgetVerticalSpacer"
android:layout_weight="2" />
<LinearLayout
style="@style/TrackWidgetVerticalLine"
android:layout_weight="1" />
</LinearLayout>
<!-- item3 -->
<LinearLayout style="@style/TrackWidgetItemContainer4x3">
<TextView
android:id="@+id/track_widget_item3_label"
style="@style/TrackWidgetLabel" />
<LinearLayout style="@style/TrackWidgetValueContainer4x3">
<TextView
android:id="@+id/track_widget_item3_value"
style="@style/TrackWidgetValue4x3" />
<TextView
android:id="@+id/track_widget_item3_unit"
style="@style/TrackWidgetUnit4x3" />
<Chronometer
android:id="@+id/track_widget_item3_chronometer"
style="@style/TrackWidgetValue4x3" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<!-- horizontal separator -->
<LinearLayout
style="@style/TrackWidgetHorizontalSeparator"
android:baselineAligned="false">
<LinearLayout
style="@style/TrackWidgetHorizontalSpacer"
android:layout_weight="1" />
<LinearLayout
style="@style/TrackWidgetHorizontalLine"
android:layout_weight="38" />
<LinearLayout
style="@style/TrackWidgetHorizontalSpacer"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout style="@style/TrackWidgetStatsSection">
<!-- item2 -->
<LinearLayout style="@style/TrackWidgetItemContainer4x3">
<TextView
android:id="@+id/track_widget_item2_label"
style="@style/TrackWidgetLabel" />
<LinearLayout style="@style/TrackWidgetValueContainer4x3">
<TextView
android:id="@+id/track_widget_item2_value"
style="@style/TrackWidgetValue4x3" />
<TextView
android:id="@+id/track_widget_item2_unit"
style="@style/TrackWidgetUnit4x3" />
<Chronometer
android:id="@+id/track_widget_item2_chronometer"
style="@style/TrackWidgetValue4x3" />
</LinearLayout>
</LinearLayout>
<!-- vertical separator -->
<LinearLayout
style="@style/TrackWidgetVerticalSeparator"
android:baselineAligned="false">
<LinearLayout
style="@style/TrackWidgetVerticalLine"
android:layout_weight="1" />
<LinearLayout
style="@style/TrackWidgetVerticalSpacer"
android:layout_weight="2" />
</LinearLayout>
<!-- item4 -->
<LinearLayout style="@style/TrackWidgetItemContainer4x3">
<TextView
android:id="@+id/track_widget_item4_label"
style="@style/TrackWidgetLabel" />
<LinearLayout style="@style/TrackWidgetValueContainer4x3">
<TextView
android:id="@+id/track_widget_item4_value"
style="@style/TrackWidgetValue4x3" />
<TextView
android:id="@+id/track_widget_item4_unit"
style="@style/TrackWidgetUnit4x3" />
<Chronometer
android:id="@+id/track_widget_item4_chronometer"
style="@style/TrackWidgetValue4x3" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout style="@style/TrackWidgetButtonContainer">
<LinearLayout
style="@style/TrackWidgetVerticalSpacer"
android:layout_weight="1" />
<ImageButton
android:id="@+id/track_widget_record_button"
style="@style/TrackWidgetButton"
android:contentDescription="@string/image_record"
android:src="@drawable/button_record" />
<TextView
android:id="@+id/track_widget_record_status"
style="@style/TrackWidgetRecordStatus" />
<ImageButton
android:id="@+id/track_widget_stop_button"
style="@style/TrackWidgetButton"
android:contentDescription="@string/image_stop"
android:src="@drawable/ic_button_stop_disabled" />
<LinearLayout
style="@style/TrackWidgetVerticalSpacer"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
<ImageView style="@style/TrackWidgetLogo" />
</RelativeLayout>
-203
View File
@@ -1,203 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2012 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/TrackWidgetBoundingBox">
<LinearLayout
style="@style/TrackWidgetFrame"
android:baselineAligned="false">
<LinearLayout
android:id="@+id/track_widget_stats_container"
style="@style/TrackWidgetStatsContainer"
android:layout_weight="3"
android:baselineAligned="false">
<LinearLayout style="@style/TrackWidgetStatsSection">
<!-- item1 -->
<LinearLayout style="@style/TrackWidgetItemContainer4x4">
<TextView
android:id="@+id/track_widget_item1_label"
style="@style/TrackWidgetLabel4x4" />
<LinearLayout style="@style/TrackWidgetValueContainer4x3">
<TextView
android:id="@+id/track_widget_item1_value"
style="@style/TrackWidgetValue4x4" />
<TextView
android:id="@+id/track_widget_item1_unit"
style="@style/TrackWidgetUnit4x4" />
<Chronometer
android:id="@+id/track_widget_item1_chronometer"
style="@style/TrackWidgetValue4x4" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<!-- horizontal separator -->
<LinearLayout
style="@style/TrackWidgetHorizontalSeparator"
android:baselineAligned="false">
<LinearLayout
style="@style/TrackWidgetHorizontalSpacer"
android:layout_weight="1" />
<LinearLayout
style="@style/TrackWidgetHorizontalLine"
android:layout_weight="4" />
<LinearLayout
style="@style/TrackWidgetHorizontalSpacer"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout style="@style/TrackWidgetStatsSection">
<!-- item3 -->
<LinearLayout style="@style/TrackWidgetItemContainer4x4">
<TextView
android:id="@+id/track_widget_item3_label"
style="@style/TrackWidgetLabel4x4" />
<LinearLayout style="@style/TrackWidgetValueContainer4x3">
<TextView
android:id="@+id/track_widget_item3_value"
style="@style/TrackWidgetValue4x4" />
<TextView
android:id="@+id/track_widget_item3_unit"
style="@style/TrackWidgetUnit4x4" />
<Chronometer
android:id="@+id/track_widget_item3_chronometer"
style="@style/TrackWidgetValue4x4" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
style="@style/TrackWidgetHorizontalSeparator"
android:baselineAligned="false">
<LinearLayout
style="@style/TrackWidgetHorizontalSpacer"
android:layout_weight="1" />
<LinearLayout
style="@style/TrackWidgetHorizontalLine"
android:layout_weight="38" />
<LinearLayout
style="@style/TrackWidgetHorizontalSpacer"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout style="@style/TrackWidgetStatsSection">
<!-- item2 -->
<LinearLayout style="@style/TrackWidgetItemContainer4x3">
<TextView
android:id="@+id/track_widget_item2_label"
style="@style/TrackWidgetLabel4x4" />
<LinearLayout style="@style/TrackWidgetValueContainer4x3">
<TextView
android:id="@+id/track_widget_item2_value"
style="@style/TrackWidgetValue4x3" />
<TextView
android:id="@+id/track_widget_item2_unit"
style="@style/TrackWidgetUnit4x3" />
<Chronometer
android:id="@+id/track_widget_item2_chronometer"
style="@style/TrackWidgetValue4x3" />
</LinearLayout>
</LinearLayout>
<!-- vertical separator -->
<LinearLayout
style="@style/TrackWidgetVerticalSeparator"
android:baselineAligned="false">
<LinearLayout
style="@style/TrackWidgetVerticalLine"
android:layout_weight="1" />
<LinearLayout
style="@style/TrackWidgetVerticalSpacer"
android:layout_weight="2" />
</LinearLayout>
<!-- item4 -->
<LinearLayout style="@style/TrackWidgetItemContainer4x3">
<TextView
android:id="@+id/track_widget_item4_label"
style="@style/TrackWidgetLabel4x4" />
<LinearLayout style="@style/TrackWidgetValueContainer4x3">
<TextView
android:id="@+id/track_widget_item4_value"
style="@style/TrackWidgetValue4x3" />
<TextView
android:id="@+id/track_widget_item4_unit"
style="@style/TrackWidgetUnit4x3" />
<Chronometer
android:id="@+id/track_widget_item4_chronometer"
style="@style/TrackWidgetValue4x3" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout style="@style/TrackWidgetButtonContainer">
<LinearLayout
style="@style/TrackWidgetVerticalSpacer"
android:layout_weight="1" />
<ImageButton
android:id="@+id/track_widget_record_button"
style="@style/TrackWidgetButton"
android:contentDescription="@string/image_record"
android:src="@drawable/button_record" />
<TextView
android:id="@+id/track_widget_record_status"
style="@style/TrackWidgetRecordStatus" />
<ImageButton
android:id="@+id/track_widget_stop_button"
style="@style/TrackWidgetButton"
android:contentDescription="@string/image_stop"
android:src="@drawable/ic_button_stop_disabled" />
<LinearLayout
style="@style/TrackWidgetVerticalSpacer"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
<ImageView style="@style/TrackWidgetLogo4x4" />
</RelativeLayout>
@@ -1,53 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2012 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView style="@style/ScrollView.WithBottomButtons">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp">
<Spinner
android:id="@+id/track_widget_config_item1"
style="@style/TrackWidgetConfigSpinner" />
<Spinner
android:id="@+id/track_widget_config_item2"
style="@style/TrackWidgetConfigSpinner" />
<Spinner
android:id="@+id/track_widget_config_item3"
style="@style/TrackWidgetConfigSpinner" />
<Spinner
android:id="@+id/track_widget_config_item4"
style="@style/TrackWidgetConfigSpinner" />
</LinearLayout>
</ScrollView>
<View style="@style/BottomButtonDivider" />
<LinearLayout style="@style/BottomButtonBar">
<include layout="@layout/track_widget_config_buttons" />
</LinearLayout>
</LinearLayout>
@@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2012 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<!-- In v14, postive button on the right. -->
<Button
android:id="@+id/track_widget_config_cancel"
style="@style/BottomButton"
android:layout_gravity="left"
android:text="@string/generic_cancel" />
<Button
android:id="@+id/track_widget_config_add"
style="@style/BottomButton"
android:layout_gravity="right"
android:text="@string/generic_add" />
</merge>
-4
View File
@@ -35,10 +35,6 @@ limitations under the License.
<string name="stats_units_key" translatable="false">statsUnits</string>
<string name="trackdetail_show_on_lockscreen_while_recording_key" translatable="false">trackdetail_show_on_lockscreen_while_recording</string>
<string name="track_name_key" translatable="false">trackName</string>
<string name="track_widget_item1" translatable="false">trackWidgetItem1</string>
<string name="track_widget_item2" translatable="false">trackWidgetItem2</string>
<string name="track_widget_item3" translatable="false">trackWidgetItem3</string>
<string name="track_widget_item4" translatable="false">trackWidgetItem4</string>
<string name="voice_frequency_key" translatable="false">voiceFrequency</string>
<!-- Keys for persistend preferences. But they should not get backed up or restored. -->
<string name="auto_resume_track_current_retry_key" translatable="false">autoResumeTrackCurrentRetry</string>
-197
View File
@@ -269,201 +269,4 @@ limitations under the License.
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
</style>
<!-- track widget bounding box -->
<style name="TrackWidgetBoundingBox">
<item name="android:background">@drawable/track_widget_background</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_width">match_parent</item>
<item name="android:padding">@dimen/widget_margin</item>
</style>
<!-- track widget button -->
<style name="TrackWidgetButton">
<item name="android:background">@android:color/transparent</item>
<item name="android:layout_gravity">center_vertical</item>
<item name="android:layout_height">63dp</item>
<item name="android:layout_width">63dp</item>
<item name="android:scaleType">fitXY</item>
</style>
<!-- track widget button container -->
<style name="TrackWidgetButtonContainer">
<item name="android:gravity">center_vertical</item>
<item name="android:layout_height">0dp</item>
<item name="android:layout_weight">1</item>
<item name="android:layout_width">match_parent</item>
<item name="android:paddingBottom">4dp</item>
<item name="android:paddingTop">4dp</item>
</style>
<!-- track widget config spiner -->
<style name="TrackWidgetConfigSpinner">
<item name="android:layout_gravity">center_horizontal</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_margin">8dp</item>
<item name="android:layout_width">match_parent</item>
</style>
<!-- Track widget frame -->
<style name="TrackWidgetFrame">
<item name="android:layout_alignParentTop">true</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_width">match_parent</item>
<item name="android:orientation">vertical</item>
</style>
<!-- track widget horizontal line -->
<style name="TrackWidgetHorizontalLine">
<item name="android:background">@color/stats_separator</item>
<item name="android:layout_height">1dp</item>
<item name="android:layout_width">0dp</item>
</style>
<!-- track widget horizontal spacer -->
<style name="TrackWidgetHorizontalSpacer">
<item name="android:layout_height">1dp</item>
<item name="android:layout_width">0dp</item>
</style>
<!-- track widget horizontal separator -->
<style name="TrackWidgetHorizontalSeparator">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">match_parent</item>
</style>
<!-- track widget item container -->
<style name="TrackWidgetItemContainer">
<item name="android:layout_gravity">center_horizontal</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_weight">1</item>
<item name="android:layout_width">0dp</item>
<item name="android:orientation">vertical</item>
<item name="android:paddingBottom">2dp</item>
<item name="android:paddingTop">2dp</item>
</style>
<!-- track widget item container 4x2 -->
<style name="TrackWidgetItemContainer4x2" parent="@style/TrackWidgetItemContainer">
<item name="android:paddingBottom">4dp</item>
<item name="android:paddingTop">4dp</item>
</style>
<!-- track widget item container 4x3 -->
<style name="TrackWidgetItemContainer4x3" parent="@style/TrackWidgetItemContainer">
<item name="android:paddingBottom">6dp</item>
<item name="android:paddingTop">12dp</item>
</style>
<!-- track widget item container 4x4 -->
<style name="TrackWidgetItemContainer4x4" parent="@style/TrackWidgetItemContainer">
<item name="android:paddingBottom">12dp</item>
<item name="android:paddingTop">12dp</item>
</style>
<style name="TrackWidgetLabel">
<!-- same as TrackWidgetLabel in values/styles.xml except adding textAllCaps -->
<item name="android:layout_gravity">center_horizontal</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:singleLine">true</item>
<item name="android:textColor">@color/stats_large_label</item>
<item name="android:textSize">10dp</item>
<item name="android:textStyle">bold</item>
<item name="android:textAllCaps">true</item>
</style>
<style name="TrackWidgetLabel4x4" parent="@style/TrackWidgetLabel">
<item name="android:textSize">14dp</item>
</style>
<!-- track widget logo -->
<style name="TrackWidgetLogo">
<item name="android:layout_alignParentRight">true</item>
<item name="android:layout_alignParentTop">true</item>
<item name="android:layout_height">24dp</item>
<item name="android:layout_width">24dp</item>
<item name="android:padding">4dp</item>
<item name="android:scaleType">fitXY</item>
<item name="android:src">@drawable/ic_logo</item>
</style>
<!-- track widget logo 4x4 -->
<style name="TrackWidgetLogo4x4" parent="@style/TrackWidgetLogo">
<item name="android:layout_height">30dp</item>
<item name="android:layout_width">30dp</item>
</style>
<!-- track widget record status -->
<style name="TrackWidgetRecordStatus" parent="@style/TextSmall">
<item name="android:layout_gravity">center_vertical</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginLeft">8dp</item>
<item name="android:layout_weight">2</item>
<item name="android:layout_width">0dp</item>
<item name="android:singleLine">true</item>
</style>
<!-- track widget stats container -->
<style name="TrackWidgetStatsContainer">
<item name="android:clickable">true</item>
<item name="android:layout_height">0dp</item>
<item name="android:layout_width">match_parent</item>
<item name="android:orientation">vertical</item>
<item name="android:padding">4dp</item>
</style>
<!-- track widget stats section -->
<style name="TrackWidgetStatsSection">
<item name="android:gravity">center_vertical</item>
<item name="android:layout_height">0dp</item>
<item name="android:layout_weight">1</item>
<item name="android:layout_width">match_parent</item>
</style>
<!-- track widget unit -->
<style name="TrackWidgetUnit">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_weight">1</item>
<item name="android:layout_width">0dp</item>
<item name="android:paddingLeft">4dp</item>
<item name="android:singleLine">true</item>
<item name="android:textSize">10dp</item>
</style>
<!-- track widget unit 4x3 -->
<style name="TrackWidgetUnit4x3" parent="@style/TrackWidgetUnit">
<item name="android:textSize">14dp</item>
</style>
<!-- track widget unit 4x4 -->
<style name="TrackWidgetUnit4x4" parent="@style/TrackWidgetUnit">
<item name="android:textSize">18dp</item>
</style>
<!-- track widget value -->
<style name="TrackWidgetValue">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_weight">2</item>
<item name="android:layout_width">0dp</item>
<item name="android:singleLine">true</item>
<item name="android:textColor">@android:color/white</item>
<item name="android:textSize">18dp</item>
<item name="android:textStyle">bold</item>
</style>
<!-- track widget value 4x3 -->
<style name="TrackWidgetValue4x3" parent="@style/TrackWidgetValue">
<item name="android:textSize">28dp</item>
</style>
<!-- track widget value 4x4 -->
<style name="TrackWidgetValue4x4" parent="@style/TrackWidgetValue">
<item name="android:textSize">36dp</item>
</style>
<!-- track widget value container -->
<style name="TrackWidgetValueContainer">
<item name="android:layout_gravity">center_horizontal</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginTop">-4dp</item>
<item name="android:layout_width">wrap_content</item>
</style>
<!-- track widget value container 4x3 -->
<style name="TrackWidgetValueContainer4x3" parent="@style/TrackWidgetValueContainer">
<item name="android:layout_marginTop">-2dp</item>
</style>
<!-- track widget vertical line -->
<style name="TrackWidgetVerticalLine">
<item name="android:background">@color/stats_separator</item>
<item name="android:layout_height">0dp</item>
<item name="android:layout_width">1dp</item>
</style>
<!-- track widget vertical spacer -->
<style name="TrackWidgetVerticalSpacer">
<item name="android:layout_height">0dp</item>
<item name="android:layout_width">1dp</item>
</style>
<!-- track widget vertical separator -->
<style name="TrackWidgetVerticalSeparator">
<item name="android:layout_height">match_parent</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:orientation">vertical</item>
</style>
</resources>
-26
View File
@@ -1,26 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2011 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:configure="de.dennisguse.opentracks.widgets.TrackWidgetConfigActivity"
android:initialKeyguardLayout="@layout/track_widget_4x1"
android:initialLayout="@layout/track_widget_4x2"
android:minWidth="250dp"
android:minHeight="110dp"
android:minResizeWidth="250dp"
android:minResizeHeight="40dp"
android:resizeMode="vertical"
android:updatePeriodMillis="0"
android:widgetCategory="keyguard|home_screen" />