Update track widget icons.
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 36 KiB |
@@ -0,0 +1,29 @@
|
||||
<?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.
|
||||
-->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle" >
|
||||
<solid android:color="@android:color/transparent" />
|
||||
<padding
|
||||
android:bottom="8dp"
|
||||
android:left="8dp"
|
||||
android:right="8dp"
|
||||
android:top="8dp" />
|
||||
<corners android:radius="8dp" />
|
||||
<stroke
|
||||
android:color="@android:color/white"
|
||||
android:width="2dp" />
|
||||
</shape>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?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.
|
||||
-->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle" >
|
||||
<solid android:color="@color/track_widget_red" />
|
||||
<padding
|
||||
android:bottom="8dp"
|
||||
android:left="8dp"
|
||||
android:right="8dp"
|
||||
android:top="8dp" />
|
||||
<corners android:radius="8dp" />
|
||||
</shape>
|
||||
@@ -19,18 +19,18 @@ limitations under the License.
|
||||
android:layout_width="fill_parent"
|
||||
android:padding="@dimen/widget_margin" >
|
||||
<LinearLayout
|
||||
android:background="@drawable/app_widget_background"
|
||||
android:background="@drawable/track_widget_background"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_width="fill_parent"
|
||||
android:orientation="horizontal" >
|
||||
<ImageButton
|
||||
android:background="@android:color/transparent"
|
||||
android:contentDescription="@string/my_tracks_app_name"
|
||||
android:id="@+id/track_widget_button"
|
||||
android:id="@+id/track_widget_icon"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:padding="8dp"
|
||||
android:src="@drawable/app_widget_button_disabled" />
|
||||
android:src="@drawable/my_tracks_icon" />
|
||||
<LinearLayout
|
||||
android:clickable="true"
|
||||
android:id="@+id/track_widget_statistics"
|
||||
@@ -80,6 +80,18 @@ limitations under the License.
|
||||
android:id="@+id/track_widget_speed_label"
|
||||
style="@style/TrackWidgetLabel" />
|
||||
</LinearLayout>
|
||||
<ImageButton
|
||||
android:background="@drawable/track_widget_record_button_background"
|
||||
android:contentDescription="@string/menu_record_track"
|
||||
android:id="@+id/track_widget_record_button"
|
||||
android:src="@drawable/track_widget_record_button"
|
||||
style="@style/TrackWidgetButton" />
|
||||
<ImageButton
|
||||
android:background="@drawable/track_widget_stop_button_background"
|
||||
android:contentDescription="@string/menu_stop_recording"
|
||||
android:id="@+id/track_widget_stop_button"
|
||||
android:src="@drawable/track_widget_stop_button"
|
||||
style="@style/TrackWidgetButton" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
@@ -51,6 +51,9 @@ limitations under the License.
|
||||
<!-- track widget line -->
|
||||
<color name="track_widget_line">#99999999</color>
|
||||
|
||||
<!-- track widget red -->
|
||||
<color name="track_widget_red">#FFCA1F25</color>
|
||||
|
||||
<!-- dynamic track slow path, green -->
|
||||
<color name="slow_path">#F774DF00</color>
|
||||
|
||||
|
||||
@@ -184,6 +184,14 @@ limitations under the License.
|
||||
<style name="TrackWidgetLabel" parent="@style/TextSmall">
|
||||
<item name="android:width">100dp</item>
|
||||
</style>
|
||||
<!-- The style for the track widget button -->
|
||||
<style name="TrackWidgetButton">
|
||||
<item name="android:layout_gravity">center_horizontal</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:layout_marginTop">8dp</item>
|
||||
<item name="android:layout_width">fill_parent</item>
|
||||
<item name="android:padding">8dp</item>
|
||||
</style>
|
||||
<!-- The style for the track widget value -->
|
||||
<style name="TrackWidgetValue" parent="@style/TextSmall">
|
||||
<item name="android:layout_weight">1</item>
|
||||
|
||||
@@ -41,6 +41,7 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
import android.database.ContentObserver;
|
||||
import android.os.Handler;
|
||||
import android.support.v4.app.TaskStackBuilder;
|
||||
import android.view.View;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
/**
|
||||
@@ -178,7 +179,7 @@ public class TrackWidgetProvider extends AppWidgetProvider
|
||||
if (action != null) {
|
||||
updateButton(remoteViews, action);
|
||||
}
|
||||
updateStatistics(remoteViews);
|
||||
updateView(remoteViews);
|
||||
|
||||
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
|
||||
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(
|
||||
@@ -195,25 +196,25 @@ public class TrackWidgetProvider extends AppWidgetProvider
|
||||
* @param action the action
|
||||
*/
|
||||
private void updateButton(RemoteViews remoteViews, String action) {
|
||||
int trackAction = trackStartedBroadcastAction.equals(action) ? R.string.track_action_end
|
||||
: R.string.track_action_start;
|
||||
boolean isRecording = trackStartedBroadcastAction.equals(action);
|
||||
remoteViews.setViewVisibility(R.id.track_widget_record_button, isRecording ? View.GONE
|
||||
: View.VISIBLE);
|
||||
remoteViews.setViewVisibility(R.id.track_widget_stop_button, isRecording ? View.VISIBLE
|
||||
: View.INVISIBLE);
|
||||
Intent intent = new Intent(context, ControlRecordingService.class).setAction(
|
||||
context.getString(trackAction));
|
||||
context.getString(isRecording ? R.string.track_action_end : R.string.track_action_start));
|
||||
PendingIntent pendingIntent = PendingIntent.getService(
|
||||
context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
remoteViews.setOnClickPendingIntent(R.id.track_widget_button, pendingIntent);
|
||||
|
||||
int icon = trackStartedBroadcastAction.equals(action) ? R.drawable.app_widget_button_enabled
|
||||
: R.drawable.app_widget_button_disabled;
|
||||
remoteViews.setImageViewResource(R.id.track_widget_button, icon);
|
||||
remoteViews.setOnClickPendingIntent(isRecording ? R.id.track_widget_stop_button
|
||||
: R.id.track_widget_record_button, pendingIntent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates statistics.
|
||||
* Updates view.
|
||||
*
|
||||
* @param remoteViews the remote views
|
||||
*/
|
||||
private void updateStatistics(RemoteViews remoteViews) {
|
||||
private void updateView(RemoteViews remoteViews) {
|
||||
Track track = selectedTrackId != PreferencesUtils.SELECTED_TRACK_ID_DEFAULT
|
||||
? myTracksProviderUtils.getTrack(selectedTrackId) : myTracksProviderUtils.getLastTrack();
|
||||
TripStatistics tripStatistics = track == null ? null : track.getTripStatistics();
|
||||
@@ -249,7 +250,9 @@ public class TrackWidgetProvider extends AppWidgetProvider
|
||||
}
|
||||
TaskStackBuilder taskStackBuilder = TaskStackBuilder.from(context);
|
||||
taskStackBuilder.addNextIntent(intent);
|
||||
PendingIntent pendingIntent = taskStackBuilder.getPendingIntent(0, 0);
|
||||
remoteViews.setOnClickPendingIntent(
|
||||
R.id.track_widget_statistics, taskStackBuilder.getPendingIntent(0, 0));
|
||||
R.id.track_widget_statistics, pendingIntent);
|
||||
remoteViews.setOnClickPendingIntent(R.id.track_widget_icon, pendingIntent);
|
||||
}
|
||||
}
|
||||
|
||||