Skip to content
Draft
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
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ android {


dependencies {
implementation 'com.humanware:KeySoftSDK:latest.release'

//implementation 'androidx.core:core-ktx:1.7.0'
//implementation 'androidx.appcompat:appcompat:1.6.0'
Expand Down
32 changes: 25 additions & 7 deletions app/src/main/java/ca/mcgill/a11y/image/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
import androidx.core.os.LocaleListCompat;
import androidx.core.view.GestureDetectorCompat;

import com.humanware.keysoftsdk.selfbrailling.SelfBraillingManager;
import com.humanware.keysoftsdk.ui.menu.AbstractMenuActivity;
import com.humanware.keysoftsdk.ui.menu.AccessibleListView;

import org.json.JSONException;
import org.xml.sax.SAXException;

Expand All @@ -78,11 +82,11 @@
import timber.log.Timber;

// Base activity which is extended by all other activities. Implements functionality common to all/most activities
public class BaseActivity extends AppCompatActivity {
static BrailleDisplay brailleServiceObj = null;
public class BaseActivity extends AbstractMenuActivity {
private SelfBraillingManager brailleServiceObj = null;
@SuppressLint("WrongConstant")
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

/*Configuration newConfig = new Configuration();
Expand All @@ -92,13 +96,14 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
AppCompatDelegate.setApplicationLocales(appLocale);

// View Actions
setContentView(R.layout.activity_main);
//setContentView(R.layout.activity_main);
if(ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED){
checkPermission();
}

if (DataAndMethods.brailleServiceObj==null) {
brailleServiceObj = (BrailleDisplay) getSystemService(BrailleDisplay.BRAILLE_DISPLAY_SERVICE);
brailleServiceObj = new SelfBraillingManager(this);
brailleServiceObj.bindService(); // TODO: You may need to put this in onResume instead. Usually we bind service in onResume but I'm unsure of the workflow of your app so I put it here for now.
DataAndMethods.initialize(brailleServiceObj, getApplicationContext(), findViewById(android.R.id.content), getResources());
}
else{
Expand All @@ -117,6 +122,17 @@ public void handleOnBackPressed() {
this.getOnBackPressedDispatcher().addCallback(onBackPressedCallback);*/

}

@Override
public int getTitleId() {
return R.string.app_name;
}

@Override
public AccessibleListView.Sort initialize() { // TODO: Remove
return null;
}

// check permissions required for voice recognition
private void checkPermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Expand All @@ -125,7 +141,9 @@ private void checkPermission() {
}

@Override
protected void onDestroy() {
public void onDestroy() {
brailleServiceObj.unbindService();
brailleServiceObj = null;
super.onDestroy();
}

Expand Down Expand Up @@ -195,7 +213,7 @@ public boolean onTouchEvent(MotionEvent event) {
}

@Override
protected void onResume() {
public void onResume() {
super.onResume();
}

Expand Down
146 changes: 58 additions & 88 deletions app/src/main/java/ca/mcgill/a11y/image/DataAndMethods.java

Large diffs are not rendered by default.

21 changes: 14 additions & 7 deletions app/src/main/java/ca/mcgill/a11y/image/FollowUpQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
import android.view.KeyEvent;
import android.view.MotionEvent;

import com.humanware.keysoftsdk.selfbrailling.SelfBraillingManager;
import com.humanware.keysoftsdk.selfbrailling.widget.SelfBraillingWidget;

import org.json.JSONException;
import org.xml.sax.SAXException;

Expand All @@ -54,9 +57,11 @@ public class FollowUpQuery extends BaseActivity implements GestureDetector.OnGes

Integer[] region = null;
private GestureDetectorCompat mDetector;
private BrailleDisplay brailleServiceObj = null;
private SelfBraillingManager brailleServiceObj = null;
private SelfBraillingWidget widget = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
public void onCreate(Bundle savedInstanceState) {
Timber.d("ACTIVITY: "+ "FollowUpQuery Created");
super.onCreate(savedInstanceState);
brailleServiceObj = DataAndMethods.brailleServiceObj;
Expand All @@ -69,7 +74,7 @@ public void updateState() {
case 0:
// Log.d("QUERY", query);
try {
brailleServiceObj.display(DataAndMethods.getBitmaps(DataAndMethods.getfreshDoc(), DataAndMethods.presentLayer, false));
brailleServiceObj.displayDots(DataAndMethods.getBitmaps(DataAndMethods.getfreshDoc(), DataAndMethods.presentLayer, false));
} catch (IOException | XPathExpressionException | ParserConfigurationException |
SAXException e) {
Timber.e(e, "EXCEPTION");
Expand Down Expand Up @@ -275,7 +280,7 @@ public boolean onSingleTapConfirmed(MotionEvent event) {
}

@Override
protected void onResume() {
public void onResume() {
Timber.d("ACTIVITY: "+ "FollowUpQuery Resumed");
intent = getIntent();
query = intent.getStringExtra("query");
Expand All @@ -293,17 +298,19 @@ protected void onResume() {

return false;
};
brailleServiceObj.registerMotionEventHandler(DataAndMethods.handler);
widget = new SelfBraillingWidget(this);
setContentView(widget);
//brailleServiceObj.registerMotionEventHandler(DataAndMethods.handler);

state = -1;
updateState();
super.onResume();
}
@Override
protected void onPause() {
public void onPause() {
Timber.d("ACTIVITY: "+ "FollowUpQuery Paused");
DataAndMethods.presentLayer--;
brailleServiceObj.unregisterMotionEventHandler(DataAndMethods.handler);
//brailleServiceObj.unregisterMotionEventHandler(DataAndMethods.handler);
super.onPause();
}
}
16 changes: 9 additions & 7 deletions app/src/main/java/ca/mcgill/a11y/image/ShowFollowUp.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

import androidx.core.view.GestureDetectorCompat;

import com.humanware.keysoftsdk.selfbrailling.SelfBraillingManager;

import org.json.JSONException;
import org.xml.sax.SAXException;

Expand All @@ -49,9 +51,9 @@ public class ShowFollowUp extends BaseActivity implements GestureDetector.OnGest
Intent intent;
String mainGraphic;
private GestureDetectorCompat mDetector;
private BrailleDisplay brailleServiceObj = null;
private SelfBraillingManager brailleServiceObj = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
public void onCreate(Bundle savedInstanceState) {
Timber.d("ACTIVITY: "+ "FollowUpQuery Created");
super.onCreate(savedInstanceState);
brailleServiceObj = DataAndMethods.brailleServiceObj;
Expand Down Expand Up @@ -180,12 +182,12 @@ public boolean onSingleTapConfirmed(MotionEvent event) {
}

@Override
protected void onResume() {
public void onResume() {
Timber.d("ACTIVITY: "+ "FollowUpQuery Resumed");
intent = getIntent();
mainGraphic = intent.getStringExtra("image");
try {
brailleServiceObj.display(DataAndMethods.getBitmaps(DataAndMethods.getfreshDoc(), 0, true));
brailleServiceObj.displayDots(DataAndMethods.getBitmaps(DataAndMethods.getfreshDoc(), 0, true));
} catch (IOException | XPathExpressionException | ParserConfigurationException | SAXException e) {
Timber.e(e, "EXCEPTION");
throw new RuntimeException(e);
Expand All @@ -203,11 +205,11 @@ protected void onResume() {

return false;
};
brailleServiceObj.registerMotionEventHandler(DataAndMethods.handler);
//brailleServiceObj.registerMotionEventHandler(DataAndMethods.handler);
super.onResume();
}
@Override
protected void onPause() {
public void onPause() {
Timber.d("ACTIVITY: "+ "FollowUpQuery Paused");
DataAndMethods.image = mainGraphic;
resetGraphicParams();
Expand All @@ -220,7 +222,7 @@ protected void onPause() {
DataAndMethods.tempImage = "";
DataAndMethods.followup = false;
DataAndMethods.presentLayer--;
brailleServiceObj.unregisterMotionEventHandler(DataAndMethods.handler);
//brailleServiceObj.unregisterMotionEventHandler(DataAndMethods.handler);
super.onPause();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
import android.view.GestureDetector;
import android.view.KeyEvent;
import android.view.MotionEvent;

import com.humanware.keysoftsdk.selfbrailling.SelfBraillingManager;

import org.xml.sax.SAXException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
Expand All @@ -49,12 +52,12 @@
// renders graphic currently stored in string 'image'
public class BasicPhotoMapRenderer extends BaseActivity implements GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener, MediaPlayer.OnCompletionListener {

private BrailleDisplay brailleServiceObj = null;
private SelfBraillingManager brailleServiceObj = null;

private GestureDetectorCompat mDetector;

@Override
protected void onCreate(Bundle savedInstanceState) {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_basic_photo_renderer);
brailleServiceObj = DataAndMethods.brailleServiceObj;
Expand Down Expand Up @@ -204,7 +207,7 @@ public boolean onSingleTapConfirmed(MotionEvent event) {
}

@Override
protected void onResume() {
public void onResume() {
Timber.d("ACTIVITY: "+ "Exploration Resumed");

DataAndMethods.displayGraphic(DataAndMethods.confirmButton, "Exploration", silentStart);
Expand All @@ -224,13 +227,13 @@ protected void onResume() {

return false;
};
brailleServiceObj.registerMotionEventHandler(DataAndMethods.handler);
//brailleServiceObj.registerMotionEventHandler(DataAndMethods.handler);
super.onResume();
}
@Override
protected void onPause() {
public void onPause() {
Timber.d("ACTIVITY: "+ "BasicPhotoMapRenderer Paused");
brailleServiceObj.unregisterMotionEventHandler(DataAndMethods.handler);
//brailleServiceObj.unregisterMotionEventHandler(DataAndMethods.handler);
super.onPause();
}
}
Loading