Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 15 additions & 22 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ buildscript {
mavenLocal()
maven { url "https://jitpack.io" }
}

dependencies {
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.google.gms:google-services:4.3.15'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.5'
classpath 'de.undercouch:gradle-download-task:4.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// Other dependencies can be added here

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()
mavenLocal()
mavenCentral()
maven { url "https://jitpack.io" }
}
}
Expand All @@ -35,40 +35,33 @@ task clean(type: Delete) {
delete rootProject.buildDir
}

task checkStyle(type:JavaExec) {
task checkStyle(type: JavaExec) {
workingDir = "utils"
classpath = files("utils/google-java-format-1.7-all-deps.jar")
FileTree tree = fileTree('app/src/main/java') {
include '**/*.java'
}
args(["-n","--set-exit-if-changed"]) // -n prints filename if using wrong style
tree.each {args += it}
//color codes: "\u001B[33m" - yellow, "\u001B[32m" - green, "\u001B[0m" - reset (Unix)
args(["-n", "--set-exit-if-changed"])
tree.each { args += it }
doFirst {
println("You can fix the style of the files below (if any) with "
+ "\u001B[33m" + "./gradlew applyStyle" + "\u001B[0m")
}
doLast { // will only execute on success (exitcode=0)
println ("\u001B[32m" + " -> All java files follow the correct style." + "\u001B[0m")
doLast {
println("\u001B[32m" + " -> All java files follow the correct style." + "\u001B[0m")
}
}

task checkStyleUnix(type:Exec) {
workingDir 'utils'
commandLine './checkStyle.sh'
}

task applyStyle(type:JavaExec) {
task applyStyle(type: JavaExec) {
workingDir = "utils"
classpath = files("utils/google-java-format-1.7-all-deps.jar")
FileTree tree = fileTree('app/src/main/java') {
include '**/*.java'
}
args("-r") // replace cmd, means write changes back to source file
tree.each {args += it}
args("-r")
tree.each { args += it }
}

task applyStyleUnix(type:Exec) {
workingDir 'utils'
commandLine './applyStyle.sh'
}
apply plugin: 'com.google.gms.google-services'


1 change: 0 additions & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#Thu Sep 19 11:12:47 IST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
Expand Down
2 changes: 1 addition & 1 deletion android/robot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,4 @@ dependencies {
exclude group: 'org.apache.httpcomponents'
exclude module: 'guava-jdk5'
}
}
}
69 changes: 59 additions & 10 deletions android/robot/src/main/java/org/openbot/OpenBotApplication.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
package org.openbot;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;

import androidx.annotation.NonNull;
import androidx.preference.PreferenceManager;

import org.jetbrains.annotations.NotNull;
import org.openbot.vehicle.Vehicle;

import java.util.Locale;

import timber.log.Timber;

public class OpenBotApplication extends Application {

static Context context;
private static Context context;
public static Vehicle vehicle;

public static Context getContext() {
Expand All @@ -23,21 +32,61 @@ public void onCreate() {
super.onCreate();
context = getApplicationContext();

// Retrieve selected language from SharedPreferences
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
String languageCode = sharedPreferences.getString("language", "en"); // Default to English
setLocale(languageCode); // Apply the language setting

int baudRate = Integer.parseInt(sharedPreferences.getString("baud_rate", "115200"));
vehicle = new Vehicle(this, baudRate);
vehicle.initBle();
vehicle.connectUsb();
vehicle.initBle();

// Setup Timber for logging in debug mode
if (BuildConfig.DEBUG) {
Timber.plant(
new Timber.DebugTree() {
@NonNull
@Override
protected String createStackElementTag(@NotNull StackTraceElement element) {
return super.createStackElementTag(element) + ":" + element.getLineNumber();
}
});
Timber.plant(new Timber.DebugTree() {
@NonNull
@Override
protected String createStackElementTag(@NotNull StackTraceElement element) {
return super.createStackElementTag(element) + ":" + element.getLineNumber();
}
});
}
}

// Set the locale for the application
public void setLocale(String languageCode) {
Locale locale = new Locale(languageCode);
Locale.setDefault(locale);
Resources resources = getResources();
Configuration config = resources.getConfiguration();

// Update the configuration based on the version
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
config.setLocale(locale);
config.setLayoutDirection(locale);
getApplicationContext().createConfigurationContext(config);
} else {
config.locale = locale;
config.setLayoutDirection(locale);
}

resources.updateConfiguration(config, resources.getDisplayMetrics());
}

// Method to dynamically refresh the app's language
public void refreshAppLanguage(String languageCode) {
// Save the new language preference
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("language", languageCode); // Store the new language code
editor.apply();

// Set the locale and refresh the UI
setLocale(languageCode);
if (context instanceof Activity) {
Activity activity = (Activity) context;
activity.recreate(); // Restart the activity to apply the new locale settings
}
}

Expand Down
131 changes: 45 additions & 86 deletions android/robot/src/main/java/org/openbot/common/FeatureList.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.openbot.common;

import android.content.Context;
import java.util.ArrayList;
import org.jetbrains.annotations.NotNull;
import org.openbot.R;
import org.openbot.model.Category;
import org.openbot.model.SubCategory;
Expand All @@ -10,62 +10,65 @@ public class FeatureList {
// region Properties

// Global
public static final String ALL = "All";
public static final String GENERAL = "General";
public static final String LEGACY = "Legacy";
public static final String DEFAULT = "Default";
public static final String PROJECTS = "Projects";
public static final String CONTROLLER = "Controller";
public static final String CONTROLLER_MAPPING = "Controller Mapping";
public static final String ROBOT_INFO = "Robot Info";
public static final int ALL = R.string.all;
public static final int GENERAL = R.string.general;
public static final int LEGACY = R.string.legacy;
public static final int DEFAULT = R.string.default_t;
public static final int PROJECTS = R.string.projects;
public static final int CONTROLLER = R.string.controller;
public static final int CONTROLLER_MAPPING = R.string.controller_mapping;
public static final int ROBOT_INFO = R.string.robot_info;

// Game
public static final String GAME = "Game";
public static final String FREE_ROAM = "Free Roam";
public static final String AR_MODE = "AR Mode";
public static final int GAME = R.string.game;
public static final int FREE_ROAM = R.string.free_roam;
public static final int AR_MODE = R.string.ar_mode;

// Data Collection
public static final String DATA_COLLECTION = "Data Collection";
public static final String LOCAL_SAVE_ON_PHONE = "Local (save On Phone)";
public static final String EDGE_LOCAL_NETWORK = "Edge (local Network)";
public static final String CLOUD_FIREBASE = "Cloud (firebase)";
public static final String CROWD_SOURCE = "Crowd-source (post/accept Data Collection Tasks)";
public static final int DATA_COLLECTION = R.string.data_collection;
public static final int LOCAL_SAVE_ON_PHONE = R.string.local_save_on_phone;
public static final int EDGE_LOCAL_NETWORK = R.string.edge_local_network;
public static final int CLOUD_FIREBASE = R.string.cloud_firebase;
public static final int CROWD_SOURCE = R.string.crowd_source;

// AI
public static final String AI = "AI";
public static final String AUTOPILOT = "Autopilot";
public static final String PERSON_FOLLOWING = "Person Following";
public static final String OBJECT_NAV = "Object Tracking";
public static final String MODEL_MANAGEMENT = "Model Management";
public static final String POINT_GOAL_NAVIGATION = "Point Goal Navigation";
public static final String AUTONOMOUS_DRIVING = "Autonomous Driving";
public static final String VISUAL_GOALS = "Visual Goals";
public static final String SMART_VOICE = "Smart Voice (left/right/straight, Ar Core)";
public static final int AI = R.string.ai;
public static final int AUTOPILOT = R.string.autopilot;
public static final int PERSON_FOLLOWING = R.string.person_following;
public static final int OBJECT_NAV = R.string.object_nav;
public static final int MODEL_MANAGEMENT = R.string.model_management;
public static final int POINT_GOAL_NAVIGATION = R.string.point_goal_navigation;
public static final int AUTONOMOUS_DRIVING = R.string.autonomous_driving;
public static final int VISUAL_GOALS = R.string.visual_goals;
public static final int SMART_VOICE = R.string.smart_voice;

// Remote Access
public static final String REMOTE_ACCESS = "Remote Access";
public static final String WEB_INTERFACE = "Web Interface";
public static final String ROS = "ROS";
public static final String FLEET_MANAGEMENT = "Fleet Management";
public static final int REMOTE_ACCESS = R.string.remote_access;
public static final int WEB_INTERFACE = R.string.web_interface;
public static final int ROS = R.string.ros;
public static final int FLEET_MANAGEMENT = R.string.fleet_management;

// Coding
public static final String CODING = "Coding";
public static final String BLOCK_BASED_PROGRAMMING = "Block-Based Programming";
public static final String SCRIPTS = "Scripts";
public static final int CODING = R.string.coding;
public static final int BLOCK_BASED_PROGRAMMING = R.string.block_based_programming;
public static final int SCRIPTS = R.string.scripts;

// Research
public static final String RESEARCH = "Research";
public static final String CLASSICAL_ROBOTICS_ALGORITHMS = "Classical Robotics Algorithms";
public static final String BACKEND_FOR_LEARNING = "Backend For Learning";
public static final int RESEARCH = R.string.research;
public static final int CLASSICAL_ROBOTICS_ALGORITHMS = R.string.classical_robotics_algorithms;
public static final int BACKEND_FOR_LEARNING = R.string.backend_for_learning;

// Monitoring
public static final String MONITORING = "Monitoring";
public static final String SENSORS_FROM_CAR = "Sensors from Car";
public static final String SENSORS_FROM_PHONE = "Sensors from Phone";
public static final String MAP_VIEW = "Map View";
public static final int MONITORING = R.string.monitoring;
public static final int SENSORS_FROM_CAR = R.string.sensors_from_car;
public static final int SENSORS_FROM_PHONE = R.string.sensors_from_phone;
public static final int MAP_VIEW = R.string.map_view;
// endregion

@NotNull
public static String getString(Context context, int resourceId) {
return context.getString(resourceId);
}

public static ArrayList<Category> getCategories() {
ArrayList<Category> categories = new ArrayList<>();

Expand All @@ -82,58 +85,14 @@ public static ArrayList<Category> getCategories() {
subCategories = new ArrayList<>();
subCategories.add(new SubCategory(AUTOPILOT, R.drawable.ic_autopilot, "#44525F"));
subCategories.add(new SubCategory(OBJECT_NAV, R.drawable.ic_person_search, "#E7CE88"));
subCategories.add(
new SubCategory(POINT_GOAL_NAVIGATION, R.drawable.ic_baseline_golf_course, "#1BBFBF"));
subCategories.add(new SubCategory(POINT_GOAL_NAVIGATION, R.drawable.ic_baseline_golf_course, "#1BBFBF"));
subCategories.add(new SubCategory(MODEL_MANAGEMENT, R.drawable.ic_list_bulleted_48, "#BC7680"));
categories.add(new Category(AI, subCategories));

subCategories = new ArrayList<>();
subCategories.add(new SubCategory(DEFAULT, R.drawable.ic_legacy_car, "#F86363"));
categories.add(new Category(LEGACY, subCategories));

/*
subCategories = new ArrayList<>();
subCategories.add(new SubCategory(SMART_VOICE, R.drawable.ic_voice_over));
subCategories.add(new SubCategory(VISUAL_GOALS, R.drawable.openbot_icon));
categories.add(new Category(AI, subCategories));

subCategories = new ArrayList<>();
subCategories.add(new SubCategory(CONTROLLER, R.drawable.ic_controller));
subCategories.add(new SubCategory(FREE_ROAM, R.drawable.ic_game, "#FFFF6D00"));
subCategories.add(new SubCategory(AR_MODE, R.drawable.ic_game, "#B3FF6D00"));
categories.add(new Category(GAME, subCategories));

subCategories = new ArrayList<>();
subCategories.add(new SubCategory(LOCAL_SAVE_ON_PHONE, R.drawable.ic_storage, "#93C47D"));
subCategories.add(new SubCategory(EDGE_LOCAL_NETWORK, R.drawable.ic_network));
subCategories.add(new SubCategory(CLOUD_FIREBASE, R.drawable.ic_cloud_upload));
subCategories.add(new SubCategory(CROWD_SOURCE, R.drawable.openbot_icon));
categories.add(new Category(DATA_COLLECTION, subCategories));

subCategories = new ArrayList<>();
subCategories.add(new SubCategory(WEB_INTERFACE, R.drawable.openbot_icon));
subCategories.add(new SubCategory(ROS, R.drawable.openbot_icon));
subCategories.add(new SubCategory(FLEET_MANAGEMENT, R.drawable.openbot_icon));
categories.add(new Category(REMOTE_ACCESS, subCategories));

subCategories = new ArrayList<>();
subCategories.add(new SubCategory(BLOCK_BASED_PROGRAMMING, R.drawable.ic_code));
subCategories.add(new SubCategory(SCRIPTS, R.drawable.ic_code));
categories.add(new Category(CODING, subCategories));

subCategories = new ArrayList<>();
subCategories.add(
new SubCategory(CLASSICAL_ROBOTICS_ALGORITHMS, R.drawable.openbot_icon));
subCategories.add(new SubCategory(BACKEND_FOR_LEARNING, R.drawable.openbot_icon));
categories.add(new Category(RESEARCH, subCategories));

subCategories = new ArrayList<>();
subCategories.add(new SubCategory(SENSORS_FROM_CAR, R.drawable.ic_electric_car));
subCategories.add(new SubCategory(SENSORS_FROM_PHONE, R.drawable.ic_phonelink));
subCategories.add(new SubCategory(MAP_VIEW, R.drawable.ic_map));
categories.add(new Category(MONITORING, subCategories));
*/

return categories;
}
}
Loading