Skip to content

Commit

Permalink
fix #150 check for presence of DEM API Key on app launch
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrupczak3 committed Jul 9, 2024
1 parent 2e44ede commit b9ad6e9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/com/openathena/DemDownloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public void run()
consumer.accept("Download succeeded");
}
else {
consumer.accept("Download failed");
consumer.accept("Download failed. Please ensure OpenTopography API Key is valid!");
}
}
}
Expand Down
20 changes: 19 additions & 1 deletion app/src/main/java/com/openathena/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.AssetFileDescriptor;
Expand Down Expand Up @@ -273,7 +274,24 @@ protected void onCreate(Bundle savedInstanceState) {
athenaApp.demCache = new DemCache(getApplicationContext());
Log.d(TAG,"DemCache: total storage "+athenaApp.demCache.totalStorage());
Log.d(TAG,"DemCache: count "+athenaApp.demCache.count());


if (getDemApiKey().trim().isEmpty()) {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setMessage("Greetings! Thanks for installing OpenAthena™ for Android. Online features of this app (for downloading terrain elevation data) require you to obtain an OpenTopography.org API Key (passcode) and set it within this app");
builder.setPositiveButton("Take me there now!", (DialogInterface.OnClickListener) (dialog,which) -> {
Log.d(TAG, "MainActivity: user navigating to ManageDroneModelsAndAPIKeyActivity to input an API Key");
Intent intent = new Intent(getApplicationContext(), ManageDroneModelsAndAPIKeyActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
});
builder.setNegativeButton("No (load offline data only)", (DialogInterface.OnClickListener) (dialog,which) -> {
String userChoseOfflineStr = "Online features are disabled. All terrain data must be loaded manually. Navigate to \"Manage Drone Models and API Key\" at any time if you change your mind!";
Toast.makeText(this,userChoseOfflineStr,Toast.LENGTH_LONG).show();
appendText(userChoseOfflineStr + "\n");
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
}
} // onCreate


Expand Down

0 comments on commit b9ad6e9

Please sign in to comment.