Skip to content

Commit

Permalink
Change GPS coordinates String.format to use float so you can change t…
Browse files Browse the repository at this point in the history
…he number of decimal places.
  • Loading branch information
pla1 committed Sep 15, 2019
1 parent 349183e commit a67a49d
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 11 deletions.
116 changes: 116 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
applicationId "com.fediphoto"
minSdkVersion 26
targetSdkVersion 28
versionCode 9
versionName "1.8"
versionCode 10
versionName "1.9"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand All @@ -20,10 +20,10 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
implementation 'androidx.exifinterface:exifinterface:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/fediphoto/StatusConfigActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class StatusConfigActivity extends AppCompatActivity {
private JsonObject settings;
private JsonObject status;

private final String DEFAULT_GPS_COORDINATES_FORMAT = "https://www.google.com/maps/search/?api=1&query=%s,%s";
private final String DEFAULT_GPS_COORDINATES_FORMAT = "https://www.google.com/maps/search/?api=1&query=%.5f,%.5f";
private final String DEFAULT_DATE_FORMAT = "EEEE MMMM dd, yyyy hh:mm:ss a z";

private void setup() {
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/com/fediphoto/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ public static int getInt(String s) {
return 0;
}

public static void main(String[] args) {
double latitude = 12.123456789;
double longitude = 21.123456789;
String stringFormat = "Test %.3f %.3f";
System.out.format(stringFormat, latitude, longitude );
System.out.format("%nQuantity of percent symbols %d%n", stringFormat.split("[%]").length);

}
public static JsonObject getAccountSelectedFromSettings(Context context) {
JsonObject settings = getSettings(context);
int accountSelectedIndex = Utils.getInt(Utils.getProperty(settings, MainActivity.Literals.accountIndexSelected.name()));
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/java/com/fediphoto/WorkerPostStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Environment;
Expand Down Expand Up @@ -85,10 +86,16 @@ public Result doWork() {
} catch (IOException e) {
e.printStackTrace();
}
boolean isDebuggable = ( 0 != ( context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE ) );
if (isDebuggable) {
latitude = 19.677821;
longitude = -155.596364;
Log.i(TAG, String.format("Debug mode with hard coded lat and long %.3f %.3f", latitude, longitude));
}
Log.i(TAG, String.format("Latitude %f longitude %f", latitude, longitude));
if (latitude != 0) {
String gpsCoordinatesFormat = Utils.getProperty(statusConfig, MainActivity.Literals.gpsCoordinatesFormat.name());
if (gpsCoordinatesFormat.split("%s").length == 2) {
if (gpsCoordinatesFormat.split("%").length == 3) {
sb.append("\n").append(String.format(gpsCoordinatesFormat, latitude, longitude));
} else {
sb.append("\n").append(latitude).append(",").append(longitude);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/fediphoto/WorkerUpload.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public Result doWork() {
PrintWriter writer = null;
try {
URL url = new URL(urlString);
Log.i(TAG, String.format("URL: %s", url.toString()));
urlConnection = (HttpsURLConnection) url.openConnection();
urlConnection.setRequestProperty("Cache-Control", "no-cache");
urlConnection.setRequestProperty("User-Agent", "FediPhoto");
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {

}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.android.tools.build:gradle:3.5.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
2 changes: 1 addition & 1 deletion fastlane/metadata/android/en-US/keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ pleroma
mastodon
photo
camera

fediphoto
5 changes: 2 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#Thu Jul 25 19:42:31 EDT 2019
#Sun Sep 01 05:53:56 EDT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
distributionSha256Sum=53b71812f18cdb2777e9f1b2a0f2038683907c90bdc406bc64d8b400e1fb2c3b
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

0 comments on commit a67a49d

Please sign in to comment.