2021-06-20 14:17:18 +02:00
/ * Copyright ( C ) 2021 Arjan Schrijver
This file is part of Gadgetbridge .
Gadgetbridge is free software : you can redistribute it and / or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation , either version 3 of the License , or
( at your option ) any later version .
Gadgetbridge is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU Affero General Public License for more details .
You should have received a copy of the GNU Affero General Public License
along with this program . If not , see < http : //www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.qhybrid ;
2021-07-11 20:51:44 +02:00
import android.content.Context ;
import android.graphics.Bitmap ;
import android.graphics.BitmapFactory ;
import java.io.IOException ;
2021-07-14 22:40:02 +02:00
import java.util.LinkedHashMap ;
2021-07-11 20:51:44 +02:00
2021-07-16 12:12:58 +02:00
import nodomain.freeyourgadget.gadgetbridge.R ;
2021-07-16 15:11:45 +02:00
import static nodomain.freeyourgadget.gadgetbridge.util.BitmapUtil.invertBitmapColors ;
2021-06-20 14:17:18 +02:00
public class HybridHRWatchfaceWidget {
private String widgetType ;
private int posX ;
private int posY ;
2021-07-16 15:11:45 +02:00
private int color = 0 ;
2021-08-08 22:47:25 +02:00
private String timezone ;
2021-07-16 15:11:45 +02:00
2021-07-22 13:07:09 +02:00
public static int COLOR_WHITE = 0 ;
public static int COLOR_BLACK = 1 ;
2021-06-20 14:17:18 +02:00
2021-07-16 15:11:45 +02:00
public HybridHRWatchfaceWidget ( String widgetType , int posX , int posY , int color ) {
2021-06-20 14:17:18 +02:00
this . widgetType = widgetType ;
this . posX = posX ;
this . posY = posY ;
2021-07-16 15:11:45 +02:00
this . color = color ;
2021-06-20 14:17:18 +02:00
}
2021-08-08 22:47:25 +02:00
public HybridHRWatchfaceWidget ( String widgetType , int posX , int posY , int color , String timezone ) {
this ( widgetType , posX , posY , color ) ;
this . timezone = timezone ;
}
2021-06-20 14:17:18 +02:00
2021-07-14 22:40:02 +02:00
public static LinkedHashMap < String , String > getAvailableWidgetTypes ( Context context ) {
LinkedHashMap < String , String > widgetTypes = new LinkedHashMap < > ( ) ;
2021-07-16 12:12:58 +02:00
widgetTypes . put ( " widgetDate " , context . getString ( R . string . watchface_widget_type_date ) ) ;
widgetTypes . put ( " widgetWeather " , context . getString ( R . string . watchface_widget_type_weather ) ) ;
widgetTypes . put ( " widgetSteps " , context . getString ( R . string . watchface_widget_type_steps ) ) ;
widgetTypes . put ( " widgetHR " , context . getString ( R . string . watchface_widget_type_heart_rate ) ) ;
2021-07-27 14:50:06 +02:00
widgetTypes . put ( " widgetBattery " , context . getString ( R . string . watchface_widget_type_battery ) ) ;
widgetTypes . put ( " widgetCalories " , context . getString ( R . string . watchface_widget_type_calories ) ) ;
2021-07-28 16:09:51 +02:00
widgetTypes . put ( " widget2ndTZ " , context . getString ( R . string . watchface_widget_type_2nd_tz ) ) ;
widgetTypes . put ( " widgetActiveMins " , context . getString ( R . string . watchface_widget_type_active_mins ) ) ;
2021-11-12 15:34:57 +01:00
widgetTypes . put ( " widgetCustom " , context . getString ( R . string . watchface_widget_type_custom ) ) ;
2021-07-28 16:09:51 +02:00
// widgetTypes.put("widgetChanceOfRain", context.getString(R.string.watchface_widget_type_chance_rain)); // Disabled due to missing support in Gadgetbridge
2021-07-14 22:40:02 +02:00
return widgetTypes ;
}
2021-06-20 14:17:18 +02:00
public String getWidgetType ( ) {
return widgetType ;
}
2021-07-11 20:51:44 +02:00
public Bitmap getPreviewImage ( Context context ) throws IOException {
2021-07-16 15:11:45 +02:00
Bitmap preview = BitmapFactory . decodeStream ( context . getAssets ( ) . open ( " fossil_hr/ " + widgetType + " _preview.png " ) ) ;
2021-07-22 13:07:09 +02:00
if ( color = = COLOR_WHITE ) {
2021-07-16 15:11:45 +02:00
return preview ;
} else {
return invertBitmapColors ( preview ) ;
}
2021-07-11 20:51:44 +02:00
}
2021-06-20 14:17:18 +02:00
public int getPosX ( ) {
return posX ;
}
public int getPosY ( ) {
return posY ;
}
2021-07-16 11:36:46 +02:00
public void setPosX ( int posX ) {
this . posX = posX ;
}
public void setPosY ( int posY ) {
this . posY = posY ;
}
2021-07-16 15:11:45 +02:00
public int getColor ( ) {
return color ;
}
2021-08-08 22:47:25 +02:00
public String getTimezone ( ) {
return timezone ;
}
2021-06-20 14:17:18 +02:00
}