Skip to content
Merged
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
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ apply plugin: 'com.android.application'

android {
namespace 'org.sil.hearthis'
compileSdk 35
compileSdk 36

defaultConfig {
applicationId "org.sil.hearthis"
minSdk 21
targetSdk 35
targetSdk 36

testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/org/sil/hearthis/ChooseBookActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
Expand All @@ -19,8 +25,19 @@ public class ChooseBookActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
EdgeToEdge.enable(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_choose_book);

View mainLayout = findViewById(R.id.booksFlow);
if (mainLayout != null) {
ViewCompat.setOnApplyWindowInsetsListener(mainLayout, (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets;
});
}

IScriptProvider scripture = ServiceLocator.getServiceLocator().init(this).getScriptProvider();
Project project = new Project("Sample", scripture);
getSupportActionBar().setTitle(R.string.choose_book);
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/org/sil/hearthis/ChooseChapterActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -14,8 +20,19 @@
public class ChooseChapterActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
EdgeToEdge.enable(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chapters);

View mainLayout = findViewById(R.id.chapsFlow);
if (mainLayout != null) {
ViewCompat.setOnApplyWindowInsetsListener(mainLayout, (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets;
});
}

getSupportActionBar().setTitle(R.string.choose_chapter);
ServiceLocator.getServiceLocator().init(this);
Intent intent = getIntent();
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/org/sil/hearthis/ChooseProjectActivity.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package org.sil.hearthis;

import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
Expand All @@ -16,8 +22,19 @@ public class ChooseProjectActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
EdgeToEdge.enable(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_choose_project);

View mainLayout = findViewById(R.id.projects_list);
if (mainLayout != null) {
ViewCompat.setOnApplyWindowInsetsListener(mainLayout, (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets;
});
}

getSupportActionBar().setTitle(R.string.choose_project);
ServiceLocator.getServiceLocator().init(this);
final ArrayList<String> rootDirs = getProjectRootDirectories();
Expand Down
26 changes: 14 additions & 12 deletions app/src/main/java/org/sil/hearthis/RecordActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import android.media.MediaRecorder.AudioSource;
import android.media.MediaRecorder.OutputFormat;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
Expand Down Expand Up @@ -367,7 +369,7 @@ public void run() {
recorder.setAudioEncodingBitRate(44100);
File file = new File(_recordingFilePath);
File dir = file.getParentFile();
if (!dir.exists())
if (!dir.exists())
dir.mkdirs();
recorder.setOutputFile(file.getAbsolutePath());
try {
Expand Down Expand Up @@ -414,20 +416,20 @@ private boolean requestRecordAudioPermission() {
@Override
public void onRequestPermissionsResult(
int requestCode,
String permissions[],
int[] grantResults) {
switch (requestCode) {
case RECORD_ACTIVITY_RECORD_PERMISSION:
if (grantResults.length > 0) {
@NonNull String[] permissions,
@NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == RECORD_ACTIVITY_RECORD_PERMISSION) {
if (grantResults.length > 0) {
// We seem to get spurious callbacks with no results at all, before the user
// even responds. This might be because multiple events on the record button
// result in multiple requests. So just ignore any callback with no results.
if (grantResults[0] != PackageManager.PERMISSION_GRANTED) {
// The user denied permission to record audio. We can't do much useful.
// This toast just might help.
Toast.makeText(this, R.string.no_use_without_record, Toast.LENGTH_LONG).show();
}
if (grantResults[0] != PackageManager.PERMISSION_GRANTED) {
// The user denied permission to record audio. We can't do much useful.
// This toast just might help.
Toast.makeText(this, R.string.no_use_without_record, Toast.LENGTH_LONG).show();
}
}
}
}

Expand Down Expand Up @@ -464,7 +466,7 @@ else if (recorder != null) {
// Press not long enough; treat as failure.
new AlertDialog.Builder(this)
//.setTitle("Too short!")
.setMessage("Hold down the record button while talking, and only let it go when you're done.")
.setMessage(R.string.record_too_short)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// nothing to do
Expand Down
22 changes: 3 additions & 19 deletions app/src/main/java/org/sil/hearthis/SyncActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,27 +255,12 @@ private String getOurIpAddress() {
} catch (SocketException e) {
// TODO Auto-generated catch block
e.printStackTrace();
ip += "Something Wrong! " + e.toString() + "\n";
ip = getString(R.string.ip_error, e.toString());
}

return ip;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}

return super.onOptionsItemSelected(item);
}

@Override
public void onNotification(String message) {
AcceptNotificationHandler.removeNotificationListener(this);
Expand All @@ -297,7 +282,6 @@ public void run() {
}

Date lastProgress = new Date();
boolean stopUpdatingProgress = false;

@Override
public void receivingFile(final String name) {
Expand All @@ -306,15 +290,15 @@ public void receivingFile(final String name) {
if (new Date().getTime() - lastProgress.getTime() < 1000)
return;
lastProgress = new Date();
setProgress("receiving " + name);
setProgress(getString(R.string.receiving_file, name));
}

@Override
public void sendingFile(final String name) {
if (new Date().getTime() - lastProgress.getTime() < 1000)
return;
lastProgress = new Date();
setProgress("sending " + name);
setProgress(getString(R.string.sending_file, name));
}

// This class is responsible to send one message packet to the IP address we
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/sil/hearthis/SyncService.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private void createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel serviceChannel = new NotificationChannel(
CHANNEL_ID,
"Sync Service Channel",
getString(R.string.sync_service_channel_name),
NotificationManager.IMPORTANCE_LOW
);
NotificationManager manager = getSystemService(NotificationManager.class);
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@
<string name="need_permissions">Permission wanted</string>
<string name="ok">OK</string>
<string name="cancel">Cancel</string>
<string name="record_too_short">Hold down the record button while talking, and only let it go when you\'re done.</string>
<string name="sync_service_channel_name">Sync Service Channel</string>
<string name="receiving_file">receiving %1$s</string>
<string name="sending_file">sending %1$s</string>
<string name="ip_error">Something Wrong! %1$s</string>
</resources>