-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a78f3c0
commit 9a2e5db
Showing
8 changed files
with
307 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...src/androidTest/java/com/bellande_api/bellande_storage_usage/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Copyright (C) 2024 Bellande Application UI UX Research Innovation Center, Ronaldson Bellande | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
**/ | ||
|
||
package com.bellande_api.bellande_storage_usage; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); | ||
assertEquals("com.bellande_api.bellande_storage_usage", appContext.getPackageName()); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
...rc/main/java/com/bellande_api/bellande_storage_usage/bellande_storage_usage_activity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** | ||
* Copyright (C) 2024 Bellande Application UI UX Research Innovation Center, Ronaldson Bellande | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
**/ | ||
package com.bellande_api.bellande_storage_usage; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.content.Context; | ||
import android.util.Log; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import com.bellande_api.bellande_storage_usage.bellande_storage_usage_usage_service; | ||
import com.bellande_api.bellande_storage_usage.bellande_storage_usage_usage_api; | ||
import com.google.firebase.crashlytics.buildtools.reloc.com.google.common.reflect.TypeToken; | ||
import com.google.gson.Gson; | ||
import com.google.gson.reflect.*; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.lang.reflect.Type; | ||
import java.util.Map; | ||
|
||
import retrofit2.Retrofit; | ||
import retrofit2.converter.gson.GsonConverterFactory; | ||
|
||
public class bellande_storage_usage_usage_activity extends AppCompatActivity { | ||
private bellande_storage_usage_usage_service bellande_storage_usage_usage_service; | ||
|
||
public bellande_storage_usage_usage_activity(Context context) { | ||
Map<String, Object> config = loadConfigFromFile(context); | ||
String apiUrl = (String) config.get("url"); | ||
String endpointPath = (String) ((Map<String, Object>) config.get("endpoint_path")).get("prediction"); | ||
String apiAccessKey = (String) config.get("Bellande_Framework_Access_Key"); | ||
|
||
bellande_storage_usage_usage_api bellande_storage_usage_usage_api = new Retrofit.Builder() | ||
.baseUrl(apiUrl + endpointPath) | ||
.addConverterFactory(GsonConverterFactory.create()) | ||
.build() | ||
.create(bellande_storage_usage_usage_api.class); | ||
|
||
bellande_storage_usage_usage_service = new bellande_storage_usage_usage_service(apiUrl, endpointPath, apiAccessKey, bellande_storage_usage_usage_api); | ||
} | ||
|
||
@SuppressLint("LongLogTag") | ||
private Map<String, Object> loadConfigFromFile(Context context) { | ||
try { | ||
InputStream inputStream = context.getAssets().open("configs.json"); | ||
InputStreamReader reader = new InputStreamReader(inputStream); | ||
Type type = new TypeToken<Map<String, Object>>() {}.getType(); | ||
return new Gson().fromJson(reader, type); | ||
} catch (IOException e) { | ||
Log.e("bellande_network_usage_activity", "Error reading config file: " + e.getMessage()); | ||
} | ||
return null; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...age/src/main/java/com/bellande_api/bellande_storage_usage/bellande_storage_usage_api.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* Copyright (C) 2024 Bellande Application UI UX Research Innovation Center, Ronaldson Bellande | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
**/ | ||
|
||
package com.bellande_api.bellande_storage_usage; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
|
||
import okhttp3.MultipartBody; | ||
import retrofit2.Call; | ||
import retrofit2.http.Body; | ||
import retrofit2.http.Multipart; | ||
import retrofit2.http.POST; | ||
import retrofit2.http.Part; | ||
|
||
public interface bellande_storage_usage_usage_api { | ||
@Multipart | ||
@POST("prediction") | ||
Call<BellandeResponse> getPrediction(@Part MultipartBody.Part pointCloud); | ||
|
||
class RequestBody { | ||
private final MultipartBody.Part pointCloud; | ||
|
||
public RequestBody(MultipartBody.Part pointCloud) { | ||
this.pointCloud = pointCloud; | ||
} | ||
|
||
public MultipartBody.Part getPointCloud() { | ||
return pointCloud; | ||
} | ||
} | ||
|
||
class BellandeResponse { | ||
@SerializedName("prediction") | ||
public String prediction; | ||
|
||
@SerializedName("confidence") | ||
public double confidence; | ||
} | ||
} |
Oops, something went wrong.