Skip to content

Commit

Permalink
Android SDK Update, Background Recording Support, Permission Fixes, U…
Browse files Browse the repository at this point in the history
…I changes, Added Time Durations, Minor Bug Fixes and Save File with Custom Name as requested by the client.
  • Loading branch information
jenisha010 committed Mar 19, 2024
1 parent 79d591c commit 978dfda
Show file tree
Hide file tree
Showing 31 changed files with 1,079 additions and 200 deletions.
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/migrations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 21 additions & 11 deletions SaidIt/build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
buildscript {
repositories {
google()
mavenCentral()
maven { url "https://repo.maven.apache.org/maven2" }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.11.+'
classpath 'com.android.tools.build:gradle:8.2.2'
}
}
apply plugin: 'android'
apply plugin: 'com.android.application'

repositories {
jcenter()
mavenCentral()
maven { url "https://maven.google.com" }
}

android {
compileSdkVersion 21
buildToolsVersion "21.0.2"
namespace 'eu.mrogalski.saidit'
compileSdk 34

defaultConfig{
applicationId "eu.mrogalski.saidit"
minSdk 21
targetSdk 34
versionCode 14
versionName "1.3.39"
}

signingConfigs {
release {
Expand All @@ -28,14 +38,14 @@ android {

buildTypes {
release {
runProguard true
minifyEnabled true
proguardFile file('proguard.cfg')
proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
signingConfig signingConfigs.release
}

debug {
signingConfig signingConfigs.release
//signingConfig signingConfigs.release
}
}
lintOptions {
Expand All @@ -47,8 +57,8 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.android.support:support-v4:21.0.3'
implementation fileTree(dir: 'libs', include: '*.jar')
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
}
44 changes: 29 additions & 15 deletions SaidIt/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="eu.mrogalski.saidit"
android:versionCode="14"
android:versionName="1.3.39"
android:installLocation="internalOnly">

<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<!-- Basic functionality -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" android:minSdkVersion="29" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />

<supports-screens
android:largeScreens="true"
Expand All @@ -21,12 +18,14 @@
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:requestLegacyExternalStorage="true"
android:label="@string/app_name"
android:largeHeap="true"
android:theme="@style/Theme" >
<activity
android:name=".SaidItActivity"
android:label="@string/app_name" >
android:label="@string/app_name"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand All @@ -49,16 +48,19 @@

<service
android:name=".SaidItService"
android:foregroundServiceType="microphone"
android:enabled="true"
android:exported="true" >
android:exported="false">
</service>
<service

<!-- <service
android:name=".FakeService"
android:enabled="true"
android:exported="false" >
</service>
</service>-->

<receiver android:name=".BroadcastReceiver" >
<receiver android:name=".BroadcastReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
Expand All @@ -71,6 +73,18 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="SaidItActivity" />
</activity>

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/path_provider">

</meta-data>
</provider>
</application>

</manifest>
50 changes: 45 additions & 5 deletions SaidIt/src/main/java/eu/mrogalski/saidit/FakeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,63 @@
/**
* Created by marek on 15.12.13.
*/
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.Service;
import android.content.Intent;
import android.os.Build;
import android.os.IBinder;

public class FakeService extends Service {
private static final int NOTIFICATION_ID = 42;
private static final String CHANNEL_ID = "ForegroundServiceChannel";

@Override
public IBinder onBind(Intent intent) {
return null;
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
startForeground(NOTIFICATION_ID, createNotification());


Notification note = new Notification( 0, null, System.currentTimeMillis() );
note.flags |= Notification.FLAG_NO_CLEAR;
startForeground(42, note);
stopForeground(true);

stopSelf();

return super.onStartCommand(intent, flags, startId);
}

private Notification createNotification() {
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(
CHANNEL_ID,
"Foreground Service Channel",
NotificationManager.IMPORTANCE_DEFAULT
);
if (notificationManager != null) {
notificationManager.createNotificationChannel(channel);
}
}

Notification.Builder builder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
builder = new Notification.Builder(this, CHANNEL_ID);
} else {
builder = new Notification.Builder(this);
}

Notification notification = builder
.setSmallIcon(android.R.drawable.ic_dialog_info)
.setContentTitle("Foreground Service")
.setContentText("Service is running in the background")
.setPriority(Notification.PRIORITY_DEFAULT) // Set appropriate priority
.build();

return notification;
}
}

42 changes: 35 additions & 7 deletions SaidIt/src/main/java/eu/mrogalski/saidit/RecordingDoneDialog.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package eu.mrogalski.saidit;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import androidx.core.content.FileProvider;

import java.io.File;
import java.net.URLConnection;
Expand Down Expand Up @@ -64,10 +70,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
root.findViewById(R.id.recording_done_open_dir).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.fromFile(file.getParentFile());
intent.setData(uri);
startActivity(Intent.createChooser(intent, "Open folder"));
openFolder();
}
});

Expand All @@ -76,9 +79,12 @@ public void onClick(View v) {
public void onClick(View v) {
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
shareIntent.setType(URLConnection.guessContentTypeFromName(file.getAbsolutePath()));
Uri fileUri = FileProvider.getUriForFile(activity, BuildConfig.APPLICATION_ID + ".provider", file);
shareIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
shareIntent.setType(activity.getContentResolver().getType(fileUri)); // Get MIME type from content resolver
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); // Grant read permission
startActivity(Intent.createChooser(shareIntent, "Send to"));

}
});

Expand All @@ -87,7 +93,10 @@ public void onClick(View v) {
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "audio/*");
Uri fileUri = FileProvider.getUriForFile(activity, BuildConfig.APPLICATION_ID + ".provider", file);
intent.setDataAndType(fileUri, "audio/*");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); // Grant read permission
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
});
Expand All @@ -104,4 +113,23 @@ public RecordingDoneDialog setRuntime(float runtime) {
this.runtime = runtime;
return this;
}

public void openFolder() {
File folder = file.getParentFile();
if (folder.exists() && folder.isDirectory()) {
Uri uri = Uri.parse(folder.getAbsolutePath());
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(uri, "*/*");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} else {
Log.e("OpenFolder", "Folder does not exist or is not a directory");
}
}


private static boolean isExternalStorageWritable() {
String state = Environment.getExternalStorageState();
return Environment.MEDIA_MOUNTED.equals(state);
}
}
Loading

0 comments on commit 978dfda

Please sign in to comment.