Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into develop
  • Loading branch information
forrestguice committed Aug 11, 2018
2 parents 90cbddf + 93a9834 commit 3c506f1
Show file tree
Hide file tree
Showing 223 changed files with 744 additions and 122 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
### ~

### ~

* changes default sun data source to time4a-time4j (supporting altitude based refinements).
* enhances the data source selector; now tags the default source, and sources loaded via plugin.
* adds elevation to all default locations; default 'en' location changed to New York City, default 'en-US' location changed to Phoenix.
* adds elevation UI to Location settings, main ActionBar, and widget title substitutions.
* adds app pref "Use Elevation"; apply altitude based refinements; defaults true.
* adds app pref "On Date Long Press"; defaults to "Show Calendar".
* adds permissions READ_CALENDAR, WRITE_CALENDAR; needed to interact w/ Calendar app (add/remove events in custom calendars).
* adds permissions READ_SYNC_STATS, WRITE_SYNC_SETTINGS; needed to provide custom calendars (add/remove calendars via SyncAdapter).
Expand All @@ -12,6 +18,7 @@
* adds world map dialog to app; shows sunlight (day/night) and moonlight over an equirectangular map.
* adds theme "Dark (translucent)"; default theme with semitransparent widget background.
* adds to theming; custom background option (simple background color supporting transparency).
* updates dependency (Time4A 3.44.2-2018b).

### v0.8.6 (2018-07-05)
* updates translation to French (fr) (#220 by Aloha68).
Expand Down
2 changes: 1 addition & 1 deletion SuntimesWidget.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="SuntimesWidget" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.id="SuntimesWidget" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ dependencies
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.github.forrestguice:sunrisesunsetlib-java:SunriseSunsetCalculator-1.2-p0-fixdst'
compile 'com.github.caarmen.SunriseSunset:lib-sunrise-sunset:1.1.0'
compile group: 'net.time4j', name: 'time4j-android', version: '3.40-2018b'
compile group: 'net.time4j', name: 'time4j-android', version: '3.44.2-2018e'
compile 'com.github.QuadFlask:colorpicker:0.0.13'

testCompile 'junit:junit:4.12'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,21 @@ public void test_locationModePref()
assertTrue("location does not match default! " + pref0, pref0.equals(testloc0));
}

@Test public void test_locationAltitudeEnabledPref()
{
WidgetSettings.saveLocationAltitudeEnabledPref(context, appWidgetId, true);
boolean isEnabled0 = WidgetSettings.loadLocationAltitudeEnabledPref(context, appWidgetId);
assertTrue("value does not match! " + isEnabled0, isEnabled0);

WidgetSettings.saveLocationAltitudeEnabledPref(context, appWidgetId, false);
boolean isEnabled1 = WidgetSettings.loadLocationAltitudeEnabledPref(context, appWidgetId);
assertTrue("value does not match! " + isEnabled1, !isEnabled1);

WidgetSettings.deleteLocationAltitudeEnabledPref(context, appWidgetId);
boolean isEnabled2 = WidgetSettings.loadLocationAltitudeEnabledPref(context, appWidgetId);
assertTrue("value does not match! " + isEnabled2, isEnabled2 == WidgetSettings.PREF_DEF_LOCATOION_ALTITUDE_ENABLED);
}

///////////////////////////////////////////////////////////////////////////

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public class LocationConfigView extends LinearLayout
public static final String KEY_LOCATION_MODE = "locationMode";
public static final String KEY_LOCATION_LATITUDE = "locationLatitude";
public static final String KEY_LOCATION_LONGITUDE = "locationLongitude";
public static final String KEY_LOCATION_ALTITUDE = "locationAltitude";
public static final String KEY_LOCATION_LABEL = "locationLabel";

private FragmentActivity myParent;
Expand Down Expand Up @@ -109,6 +110,7 @@ public WidgetSettings.Location getLocation()
String name = text_locationName.getText().toString();
String latitude = text_locationLat.getText().toString();
String longitude = text_locationLon.getText().toString();
String altitude = text_locationAlt.getText().toString();

try {
@SuppressWarnings("UnusedAssignment")
Expand All @@ -117,14 +119,18 @@ public WidgetSettings.Location getLocation()
@SuppressWarnings("UnusedAssignment")
BigDecimal lon = new BigDecimal(longitude);

@SuppressWarnings("UnusedAssignment")
BigDecimal alt = new BigDecimal(altitude);

} catch (NumberFormatException e) {
Log.e("getLocation", "invalid location! falling back to default; " + e.toString());
name = WidgetSettings.PREF_DEF_LOCATION_LABEL;
latitude = WidgetSettings.PREF_DEF_LOCATION_LATITUDE;
longitude = WidgetSettings.PREF_DEF_LOCATION_LONGITUDE;
altitude = WidgetSettings.PREF_DEF_LOCATION_ALTITUDE;
}

return new WidgetSettings.Location(name, latitude, longitude);
return new WidgetSettings.Location(name, latitude, longitude, altitude);
}

public WidgetSettings.LocationMode getLocationMode()
Expand Down Expand Up @@ -195,6 +201,8 @@ public void setMode( LocationViewMode mode )
text_locationLon.setEnabled(false);
labl_locationLat.setEnabled(false);
text_locationLat.setEnabled(false);
labl_locationAlt.setEnabled(false);
text_locationAlt.setEnabled(false);
inputOverlay.setVisibility(View.VISIBLE);

labl_locationName.setEnabled(false);
Expand All @@ -216,6 +224,8 @@ public void setMode( LocationViewMode mode )
text_locationLon.setEnabled(true);
labl_locationLat.setEnabled(true);
text_locationLat.setEnabled(true);
labl_locationAlt.setEnabled(true);
text_locationAlt.setEnabled(true);
inputOverlay.setVisibility(View.GONE);

labl_locationName.setEnabled(true);
Expand All @@ -236,6 +246,8 @@ public void setMode( LocationViewMode mode )
text_locationLon.setEnabled(false);
labl_locationLat.setEnabled(false);
text_locationLat.setEnabled(false);
labl_locationAlt.setEnabled(false);
text_locationAlt.setEnabled(false);
inputOverlay.setVisibility(View.VISIBLE);

labl_locationName.setEnabled(true);
Expand All @@ -254,6 +266,9 @@ public void setMode( LocationViewMode mode )
private ViewFlipper flipper, flipper2;
private Spinner spinner_locationMode;

private TextView labl_locationAlt;
private EditText text_locationAlt;

private TextView labl_locationLat;
private EditText text_locationLat;

Expand All @@ -279,6 +294,7 @@ public void enableUI(boolean value)
text_locationName.requestFocus();
text_locationLat.setEnabled(value);
text_locationLon.setEnabled(value);
text_locationAlt.setEnabled(value);
text_locationName.setEnabled(value);
}

Expand All @@ -288,6 +304,7 @@ public void updateUI(Location... locations)
DecimalFormat formatter = WidgetSettings.Location.decimalDegreesFormatter();
text_locationLat.setText( formatter.format(locations[0].getLatitude()) );
text_locationLon.setText( formatter.format(locations[0].getLongitude()) );
text_locationAlt.setText( formatter.format(locations[0].getAltitude()) );
}

@Override
Expand Down Expand Up @@ -320,6 +337,7 @@ public void enableUI(boolean value)
{
text_locationLat.setEnabled(false);
text_locationLon.setEnabled(false);
text_locationAlt.setEnabled(false);
text_locationName.setEnabled(false);
}

Expand All @@ -329,6 +347,7 @@ public void updateUI(Location... locations)
DecimalFormat formatter = WidgetSettings.Location.decimalDegreesFormatter();
text_locationLat.setText( formatter.format(locations[0].getLatitude()) );
text_locationLon.setText( formatter.format(locations[0].getLongitude()) );
text_locationAlt.setText( formatter.format(locations[0].getAltitude()) );
}

@Override
Expand Down Expand Up @@ -396,9 +415,6 @@ protected void initViews( Context context )
spin_locationName.setAdapter(getFixAdapter);
spin_locationName.setOnItemSelectedListener(onCustomLocationSelected);

labl_locationLat = (TextView)findViewById(R.id.appwidget_location_lat_label);
text_locationLat = (EditText)findViewById(R.id.appwidget_location_lat);

inputOverlay = findViewById(R.id.appwidget_location_latlon_overlay);
inputOverlay.setVisibility(View.GONE);
inputOverlay.setOnClickListener(new OnClickListener()
Expand All @@ -413,9 +429,15 @@ public void onClick(View view)
}
});

labl_locationLat = (TextView)findViewById(R.id.appwidget_location_lat_label);
text_locationLat = (EditText)findViewById(R.id.appwidget_location_lat);

labl_locationLon = (TextView)findViewById(R.id.appwidget_location_lon_label);
text_locationLon = (EditText)findViewById(R.id.appwidget_location_lon);

labl_locationAlt = (TextView)findViewById(R.id.appwidget_location_alt_label);
text_locationAlt = (EditText)findViewById(R.id.appwidget_location_alt);

// custom mode: toggle edit mode
button_edit = (ImageButton)findViewById(R.id.appwidget_location_edit);
button_edit.setOnClickListener(onEditButtonClicked);
Expand Down Expand Up @@ -483,6 +505,7 @@ private void updateViews(WidgetSettings.Location location)
text_locationLat.setText(location.getLatitude());
text_locationLon.setText(location.getLongitude());
text_locationName.setText(location.getLabel());
text_locationAlt.setText(location.getAltitude());
}

/**
Expand Down Expand Up @@ -534,10 +557,13 @@ protected void loadSettings(Context context, Bundle bundle )
String label = bundle.getString(KEY_LOCATION_LABEL);
String longitude = bundle.getString(KEY_LOCATION_LONGITUDE);
String latitude = bundle.getString(KEY_LOCATION_LATITUDE);
String altitude = bundle.getString(KEY_LOCATION_ALTITUDE);
WidgetSettings.Location location;
if (longitude != null && latitude != null)
{
location = new WidgetSettings.Location(label, latitude, longitude);
if (altitude != null)
location = new WidgetSettings.Location(label, latitude, longitude, altitude);
else location = new WidgetSettings.Location(label, latitude, longitude);

} else {
Log.w("LocationConfigView", "Bundle contained null lat or lon; falling back to saved prefs.");
Expand Down Expand Up @@ -586,8 +612,9 @@ protected boolean saveSettings(Context context)
{
String latitude = text_locationLat.getText().toString();
String longitude = text_locationLon.getText().toString();
String altitude = text_locationAlt.getText().toString();
String name = text_locationName.getText().toString();
WidgetSettings.Location location = new WidgetSettings.Location(name, latitude, longitude);
WidgetSettings.Location location = new WidgetSettings.Location(name, latitude, longitude, altitude);
WidgetSettings.saveLocationPref(context, appWidgetId, location);
return true;
}
Expand All @@ -605,12 +632,14 @@ protected boolean saveSettings(Bundle bundle)
WidgetSettings.LocationMode locationMode = getLocationMode();
String latitude = text_locationLat.getText().toString();
String longitude = text_locationLon.getText().toString();
String altitude = text_locationAlt.getText().toString();
String name = text_locationName.getText().toString();

bundle.putString(KEY_DIALOGMODE, mode.name());
bundle.putString(KEY_LOCATION_MODE, locationMode.name());
bundle.putString(KEY_LOCATION_LATITUDE, latitude);
bundle.putString(KEY_LOCATION_LONGITUDE, longitude);
bundle.putString(KEY_LOCATION_ALTITUDE, altitude);
bundle.putString(KEY_LOCATION_LABEL, name);

getFixHelper.saveSettings(bundle);
Expand All @@ -621,6 +650,7 @@ public static Bundle bundleData( Uri data, String label )
{
String lat = "";
String lon = "";
String alt = "";

if (data.getScheme().equals("geo"))
{
Expand All @@ -634,6 +664,11 @@ public static Bundle bundleData( Uri data, String label )
{
lat = geoParts[0];
lon = geoParts[1];

if (geoParts.length >= 3)
{
alt = geoParts[2];
}
}
}
}
Expand All @@ -643,6 +678,7 @@ public static Bundle bundleData( Uri data, String label )
bundle.putString(KEY_LOCATION_MODE, WidgetSettings.LocationMode.CUSTOM_LOCATION.name());
bundle.putString(KEY_LOCATION_LATITUDE, lat);
bundle.putString(KEY_LOCATION_LONGITUDE, lon);
bundle.putString(KEY_LOCATION_ALTITUDE, alt);
bundle.putString(KEY_LOCATION_LABEL, label);
return bundle;
}
Expand Down Expand Up @@ -783,6 +819,18 @@ public boolean validateInput()
text_locationLon.setError(myParent.getString(R.string.location_dialog_error_lon));
}

String altitude = text_locationAlt.getText().toString();
if (!altitude.trim().isEmpty())
{
try {
BigDecimal alt = new BigDecimal(altitude);

} catch (NumberFormatException e3) {
isValid = false;
text_locationAlt.setError(myParent.getString(R.string.location_dialog_error_alt));
}
}

return isValid;
}

Expand Down Expand Up @@ -895,9 +943,9 @@ public void onItemSelected(AdapterView<?> parent, View view, int position, long
Cursor cursor = getFixAdapter.getCursor();
cursor.moveToPosition(position);

if (cursor.getColumnCount() >= 3)
if (cursor.getColumnCount() >= 4)
{
updateViews(new WidgetSettings.Location(cursor.getString(1), cursor.getString(2), cursor.getString(3)));
updateViews(new WidgetSettings.Location(cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4)));
}
}
public void onNothingSelected(AdapterView<?> parent) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ protected void loadWidgetMode1x1(Context context)
spinner_1x1mode.setSelection(mode1x1.ordinal());
}

@Override
protected String defaultCalculator()
{
return WidgetSettings.PREF_DEF_GENERAL_CALCULATOR_MOON;
}

@Override
protected SuntimesCalculatorDescriptor[] supportingCalculators()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ protected void initViews( Context context )
super.initViews(context);
setConfigActivityTitle(getString(R.string.configLabel_solsticewidget0));

hideOptionUseAltitude();
hideOptionCompareAgainst();
hideOption1x1LayoutMode();
showOptionWeeks(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@

import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.style.ImageSpan;
Expand Down Expand Up @@ -1569,7 +1570,20 @@ protected void updateViews( Context context )

location = WidgetSettings.loadLocationPref(context, AppWidgetManager.INVALID_APPWIDGET_ID);
String locationTitle = location.getLabel();
String locationSubtitle = location.toString();

SpannableString locationSubtitle;
String locationString = getString(R.string.location_format_latlon, location.getLatitude(), location.getLongitude());
boolean supportsAltitude = dataset.calculatorMode().hasRequestedFeature(SuntimesCalculator.FEATURE_ALTITUDE);
if (supportsAltitude && location.getAltitudeAsInteger() != 0)
{
String altitudeUnits = getString(R.string.units_meters_short); // TODO: support display in feet
String altitudeString = getString(R.string.location_format_alt, ("" + location.getAltitudeAsInteger()), altitudeUnits);
String altitudeTag = getString(R.string.location_format_alttag, altitudeString);
String displayString = getString(R.string.location_format_latlonalt, locationString, altitudeTag);
locationSubtitle = SuntimesUtils.createRelativeSpan(null, displayString, altitudeTag, 0.5f);
} else {
locationSubtitle = new SpannableString(locationString);
}

if (actionBar != null)
{
Expand Down
Loading

0 comments on commit 3c506f1

Please sign in to comment.