-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 5274342..58314b4 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,10 +2,7 @@
-
-
-
-
+
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
deleted file mode 100644
index 7f68460..0000000
--- a/.idea/runConfigurations.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/README.md b/README.md
index 7973aed..956c98c 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
# AndroidLame
-[](https://jitpack.io/#naman14/TAndroidLame)
+[](https://jitpack.io/#naman14/TAndroidLame) [Maven](https://mvnrepository.com/artifact/com.github.naman14/TAndroidLame)
-AndroidLame is a wrapper Library for Android/Java around Lame MP3 encoder (http://lame.sourceforge.net/)
+AndroidLame is a wrapper Library for Android/Java around Lame MP3 encoder (https://lame.sourceforge.io/)
Built using NDK and Andorid studio with experimental gradle plugin.
## Gradle dependency
@@ -10,19 +10,17 @@ Built using NDK and Andorid studio with experimental gradle plugin.
```gradle
allprojects {
repositories {
- ...
+ mavenCentral()
maven { url "https://jitpack.io" }
}
}
```
#### app/build.gradle
```gradle
-apply plugin: 'com.github.dcendents.android-maven' //add it to top of app level build.gradle
-
dependencies {
- compile 'com.github.naman14:TAndroidLame:1.1'
- }
-```
+ implementation 'com.github.naman14:TAndroidLame:1.1'
+}
+```
# Usage
@@ -133,3 +131,4 @@ A wrapper class for actual native implementation and encoding
>This software 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 app. If not, see .
+
diff --git a/androidlame/.gitignore b/androidlame/.gitignore
index 796b96d..42afabf 100644
--- a/androidlame/.gitignore
+++ b/androidlame/.gitignore
@@ -1 +1 @@
-/build
+/build
\ No newline at end of file
diff --git a/androidlame/androidlame.iml b/androidlame/androidlame.iml
deleted file mode 100644
index 292bf92..0000000
--- a/androidlame/androidlame.iml
+++ /dev/null
@@ -1,137 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- generateDebugSources
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/androidlame/build.gradle b/androidlame/build.gradle
index 4f425a5..667fc97 100644
--- a/androidlame/build.gradle
+++ b/androidlame/build.gradle
@@ -1,34 +1,48 @@
-apply plugin: 'com.android.library'
-apply plugin: 'com.github.dcendents.android-maven'
+plugins {
+ id 'com.android.library'
+}
android {
- compileSdkVersion 26
- buildToolsVersion "26.0.2"
+ namespace 'com.naman14.androidlame'
+ compileSdk 34
defaultConfig {
- minSdkVersion 16
- targetSdkVersion 26
+ minSdk 21
+ targetSdk 34
versionCode 1
- versionName "1.0"
+ versionName "1.2"
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ consumerProguardFiles "consumer-rules.pro"
+ externalNativeBuild {
+ cmake {
+ cppFlags ""
+ }
+ }
}
buildTypes {
release {
minifyEnabled false
- proguardFiles.add(file("proguard-rules.pro"))
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
-
externalNativeBuild {
ndkBuild {
path 'src/main/jni/Android.mk'
}
}
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_17
+ targetCompatibility JavaVersion.VERSION_17
+ }
}
-
-
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- compile 'com.android.support:appcompat-v7:26.1.0'
-}
+
+ implementation 'androidx.appcompat:appcompat:1.7.0'
+ implementation 'com.google.android.material:material:1.12.0'
+ testImplementation 'junit:junit:4.13.2'
+ androidTestImplementation 'androidx.test.ext:junit:1.2.1'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
+}
\ No newline at end of file
diff --git a/androidlame/consumer-rules.pro b/androidlame/consumer-rules.pro
new file mode 100644
index 0000000..e69de29
diff --git a/androidlame/proguard-rules.pro b/androidlame/proguard-rules.pro
index 9372bdd..481bb43 100644
--- a/androidlame/proguard-rules.pro
+++ b/androidlame/proguard-rules.pro
@@ -1,17 +1,21 @@
# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /Users/naman/sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
-# Add any project specific keep options here:
-
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/androidlame/src/androidTest/java/com/naman14/androidlame/ApplicationTest.java b/androidlame/src/androidTest/java/com/naman14/androidlame/ApplicationTest.java
deleted file mode 100644
index 4be84f4..0000000
--- a/androidlame/src/androidTest/java/com/naman14/androidlame/ApplicationTest.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.naman14.androidlame;
-
-import android.app.Application;
-import android.test.ApplicationTestCase;
-
-/**
- * Testing Fundamentals
- */
-public class ApplicationTest extends ApplicationTestCase {
- public ApplicationTest() {
- super(Application.class);
- }
-}
\ No newline at end of file
diff --git a/androidlame/src/androidTest/java/com/naman14/androidlame/ExampleInstrumentedTest.java b/androidlame/src/androidTest/java/com/naman14/androidlame/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..5cc648a
--- /dev/null
+++ b/androidlame/src/androidTest/java/com/naman14/androidlame/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package com.naman14.androidlame;
+
+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 Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+ assertEquals("com.naman14.androidlame.test", appContext.getPackageName());
+ }
+}
\ No newline at end of file
diff --git a/androidlame/src/main/jni/libmp3lame/VbrTag.c b/androidlame/src/main/jni/libmp3lame/VbrTag.c
index 8a23464..5800a44 100644
--- a/androidlame/src/main/jni/libmp3lame/VbrTag.c
+++ b/androidlame/src/main/jni/libmp3lame/VbrTag.c
@@ -607,7 +607,7 @@ UpdateMusicCRC(uint16_t * crc, unsigned char const *buffer, int size)
* Paramters:
* pbtStreamBuffer : pointer to output buffer
* id3v2size : size of id3v2 tag in bytes
- * crc : computation of crc-16 of LameBuilder Tag so far (starting at frame sync)
+ * crc : computation of crc-16 of Lame Tag so far (starting at frame sync)
*
****************************************************************************
*/
@@ -643,7 +643,7 @@ PutLameVBR(lame_global_flags const *gfp, size_t nMusicLength, uint8_t * pbtStrea
uint8_t nVBR;
uint8_t nRevision = 0x00;
uint8_t nRevMethod;
- uint8_t vbr_type_translator[] = { 1, 5, 3, 2, 4, 0, 3 }; /*numbering different in vbr_mode vs. LameBuilder tag */
+ uint8_t vbr_type_translator[] = { 1, 5, 3, 2, 4, 0, 3 }; /*numbering different in vbr_mode vs. Lame tag */
uint8_t nLowpass =
(((cfg->lowpassfreq / 100.0) + .5) > 255 ? 255 : (cfg->lowpassfreq / 100.0) + .5);
diff --git a/androidlame/src/main/jni/libmp3lame/lame.h b/androidlame/src/main/jni/libmp3lame/lame.h
index 83264a9..5196690 100644
--- a/androidlame/src/main/jni/libmp3lame/lame.h
+++ b/androidlame/src/main/jni/libmp3lame/lame.h
@@ -84,7 +84,7 @@ typedef enum preset_mode_e {
ABR_8 = 8,
ABR_320 = 320,
- V9 = 410, /*Vx to match LameBuilder and VBR_xx to match FhG*/
+ V9 = 410, /*Vx to match Lame and VBR_xx to match FhG*/
VBR_10 = 410,
V8 = 420,
VBR_20 = 420,
diff --git a/androidlame/src/main/jni/libmp3lame/set_get.c b/androidlame/src/main/jni/libmp3lame/set_get.c
index 2c61f48..f763900 100755
--- a/androidlame/src/main/jni/libmp3lame/set_get.c
+++ b/androidlame/src/main/jni/libmp3lame/set_get.c
@@ -20,7 +20,7 @@
* Boston, MA 02111-1307, USA.
*/
-/* $Id: set_get.c,v 1.98 2011/05/07 16:05:17 rbrito Exp $ */
+/* $Id: set_get.c,v 1.104 2017/09/06 15:07:30 robert Exp $ */
#ifdef HAVE_CONFIG_H
# include
@@ -68,6 +68,8 @@ int
lame_set_in_samplerate(lame_global_flags * gfp, int in_samplerate)
{
if (is_lame_global_flags_valid(gfp)) {
+ if (in_samplerate < 1)
+ return -1;
/* input sample rate in Hz, default = 44100 Hz */
gfp->samplerate_in = in_samplerate;
return 0;
@@ -91,7 +93,7 @@ lame_set_num_channels(lame_global_flags * gfp, int num_channels)
{
if (is_lame_global_flags_valid(gfp)) {
/* default = 2 */
- if (2 < num_channels || 0 == num_channels) {
+ if (2 < num_channels || 0 >= num_channels) {
return -1; /* we don't support more than 2 channels */
}
gfp->num_channels = num_channels;
@@ -193,6 +195,11 @@ lame_set_out_samplerate(lame_global_flags * gfp, int out_samplerate)
*
* (not used by decoding routines)
*/
+ if (out_samplerate != 0) {
+ int v=0;
+ if (SmpFrqIndex(out_samplerate, &v) < 0)
+ return -1;
+ }
gfp->samplerate_out = out_samplerate;
return 0;
}
@@ -2127,25 +2134,44 @@ lame_get_totalframes(const lame_global_flags * gfp)
unsigned long const pcm_samples_per_frame = 576 * cfg->mode_gr;
unsigned long pcm_samples_to_encode = gfp->num_samples;
unsigned long end_padding = 0;
+ int frames = 0;
+
+ if (pcm_samples_to_encode == (0ul-1ul))
+ return 0; /* unknown */
/* estimate based on user set num_samples: */
- if (pcm_samples_to_encode == (0ul-1ul)) {
- return 0;
+ if (cfg->samplerate_in != cfg->samplerate_out) {
+ /* resampling, estimate new samples_to_encode */
+ double resampled_samples_to_encode = 0.0, frames_f = 0.0;
+ if (cfg->samplerate_in > 0) {
+ resampled_samples_to_encode = pcm_samples_to_encode;
+ resampled_samples_to_encode *= cfg->samplerate_out;
+ resampled_samples_to_encode /= cfg->samplerate_in;
+ }
+ if (resampled_samples_to_encode <= 0.0)
+ return 0; /* unlikely to happen, so what, no estimate! */
+ frames_f = floor(resampled_samples_to_encode / pcm_samples_per_frame);
+ if (frames_f >= (INT_MAX-2))
+ return 0; /* overflow, happens eventually, no estimate! */
+ frames = frames_f;
+ resampled_samples_to_encode -= frames * pcm_samples_per_frame;
+ pcm_samples_to_encode = ceil(resampled_samples_to_encode);
}
- if (gfp->samplerate_in != gfp->samplerate_out && gfp->samplerate_in > 0) {
- double const q = (double)gfp->samplerate_out / gfp->samplerate_in;
- pcm_samples_to_encode *= q;
+ else {
+ frames = pcm_samples_to_encode / pcm_samples_per_frame;
+ pcm_samples_to_encode -= frames * pcm_samples_per_frame;
}
- pcm_samples_to_encode += 576;
+ pcm_samples_to_encode += 576ul;
end_padding = pcm_samples_per_frame - (pcm_samples_to_encode % pcm_samples_per_frame);
- if (end_padding < 576) {
+ if (end_padding < 576ul) {
end_padding += pcm_samples_per_frame;
}
pcm_samples_to_encode += end_padding;
+ frames += (pcm_samples_to_encode / pcm_samples_per_frame);
/* check to see if we underestimated totalframes */
/* if (totalframes < gfp->frameNum) */
/* totalframes = gfp->frameNum; */
- return pcm_samples_to_encode / pcm_samples_per_frame;
+ return frames;
}
}
return 0;
@@ -2275,3 +2301,46 @@ lame_set_preset_notune(lame_global_flags * gfp, int preset_notune)
(void) preset_notune;
return 0;
}
+
+static int
+calc_maximum_input_samples_for_buffer_size(lame_internal_flags const* gfc, size_t buffer_size)
+{
+ SessionConfig_t const *const cfg = &gfc->cfg;
+ int const pcm_samples_per_frame = 576 * cfg->mode_gr;
+ int frames_per_buffer = 0, input_samples_per_buffer = 0;
+ int kbps = 320;
+
+ if (cfg->samplerate_out < 16000)
+ kbps = 64;
+ else if (cfg->samplerate_out < 32000)
+ kbps = 160;
+ else
+ kbps = 320;
+ if (cfg->free_format)
+ kbps = cfg->avg_bitrate;
+ else if (cfg->vbr == vbr_off) {
+ kbps = cfg->avg_bitrate;
+ }
+ {
+ int const pad = 1;
+ int const bpf = ((cfg->version + 1) * 72000 * kbps / cfg->samplerate_out + pad);
+ frames_per_buffer = buffer_size / bpf;
+ }
+ {
+ double ratio = (double) cfg->samplerate_in / cfg->samplerate_out;
+ input_samples_per_buffer = pcm_samples_per_frame * frames_per_buffer * ratio;
+ }
+ return input_samples_per_buffer;
+}
+
+int
+lame_get_maximum_number_of_samples(lame_t gfp, size_t buffer_size)
+{
+ if (is_lame_global_flags_valid(gfp)) {
+ lame_internal_flags const *const gfc = gfp->internal_flags;
+ if (is_lame_internal_flags_valid(gfc)) {
+ return calc_maximum_input_samples_for_buffer_size(gfc, buffer_size);
+ }
+ }
+ return LAME_GENERICERROR;
+}
diff --git a/androidlame/src/test/java/com/naman14/androidlame/ExampleUnitTest.java b/androidlame/src/test/java/com/naman14/androidlame/ExampleUnitTest.java
index 95dd323..9bc3029 100644
--- a/androidlame/src/test/java/com/naman14/androidlame/ExampleUnitTest.java
+++ b/androidlame/src/test/java/com/naman14/androidlame/ExampleUnitTest.java
@@ -5,11 +5,13 @@
import static org.junit.Assert.*;
/**
- * To work on unit tests, switch the Test Artifact in the Build Variants view.
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
*/
public class ExampleUnitTest {
@Test
- public void addition_isCorrect() throws Exception {
+ public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
diff --git a/app/.gitignore b/app/.gitignore
index 796b96d..42afabf 100644
--- a/app/.gitignore
+++ b/app/.gitignore
@@ -1 +1 @@
-/build
+/build
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 53a3afe..b35e044 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,37 +1,41 @@
-apply plugin: 'com.android.application'
+plugins {
+ id 'com.android.application'
+}
android {
-
- compileSdkVersion 26
- buildToolsVersion "26.0.2"
+ namespace 'com.naman14.tandroidlame'
+ compileSdk 34
defaultConfig {
applicationId "com.naman14.tandroidlame"
- minSdkVersion 16
- targetSdkVersion 26
+ minSdk 21
+ targetSdk 34
versionCode 1
- versionName "1.0"
+ versionName "1.2"
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
- proguardFiles.add(file("proguard-rules.pro"))
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
-
- externalNativeBuild {
- ndkBuild {
- path '../androidlame/src/main/jni/Android.mk'
- }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_17
+ targetCompatibility JavaVersion.VERSION_17
}
}
-
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- compile 'com.android.support:appcompat-v7:26.1.0'
- compile 'com.android.support:recyclerview-v7:26.1.0'
- compile project(':androidlame')
-}
+ implementation 'androidx.appcompat:appcompat:1.7.0'
+ implementation 'com.google.android.material:material:1.12.0'
+ implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
+ implementation 'androidx.recyclerview:recyclerview:1.3.2'
+ implementation project(':androidlame')
+ testImplementation 'junit:junit:4.13.2'
+ androidTestImplementation 'androidx.test.ext:junit:1.2.1'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
+}
\ No newline at end of file
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
index 9372bdd..481bb43 100644
--- a/app/proguard-rules.pro
+++ b/app/proguard-rules.pro
@@ -1,17 +1,21 @@
# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /Users/naman/sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
-# Add any project specific keep options here:
-
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/app/src/androidTest/java/com/naman14/tandroidlame/ApplicationTest.java b/app/src/androidTest/java/com/naman14/tandroidlame/ApplicationTest.java
deleted file mode 100644
index c5ed861..0000000
--- a/app/src/androidTest/java/com/naman14/tandroidlame/ApplicationTest.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.naman14.tandroidlame;
-
-import android.app.Application;
-import android.test.ApplicationTestCase;
-
-/**
- * Testing Fundamentals
- */
-public class ApplicationTest extends ApplicationTestCase {
- public ApplicationTest() {
- super(Application.class);
- }
-}
\ No newline at end of file
diff --git a/app/src/androidTest/java/com/naman14/tandroidlame/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/naman14/tandroidlame/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..2bbeb3f
--- /dev/null
+++ b/app/src/androidTest/java/com/naman14/tandroidlame/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package com.naman14.tandroidlame;
+
+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 Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+ assertEquals("com.naman14.tandroidlame", appContext.getPackageName());
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 2a72906..8429233 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -11,7 +11,7 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
-
+
diff --git a/app/src/main/java/com/naman14/tandroidlame/EncodeActivity.java b/app/src/main/java/com/naman14/tandroidlame/EncodeActivity.java
index dd96d45..70e54eb 100644
--- a/app/src/main/java/com/naman14/tandroidlame/EncodeActivity.java
+++ b/app/src/main/java/com/naman14/tandroidlame/EncodeActivity.java
@@ -20,8 +20,6 @@
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
-import android.support.annotation.Nullable;
-import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
@@ -36,6 +34,9 @@
import java.io.FileOutputStream;
import java.io.IOException;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+
public class EncodeActivity extends AppCompatActivity {
@@ -226,7 +227,7 @@ public void run() {
public String getRealPathFromURI(Uri contentUri) {
String[] proj = {MediaStore.Audio.Media.DATA};
- Cursor cursor = managedQuery(contentUri, proj, null, null, null);
+ Cursor cursor = getContentResolver().query(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
diff --git a/app/src/main/java/com/naman14/tandroidlame/LogFragment.java b/app/src/main/java/com/naman14/tandroidlame/LogFragment.java
index 873aaf3..10738dd 100644
--- a/app/src/main/java/com/naman14/tandroidlame/LogFragment.java
+++ b/app/src/main/java/com/naman14/tandroidlame/LogFragment.java
@@ -15,15 +15,16 @@
package com.naman14.tandroidlame;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
import java.util.ArrayList;
import java.util.List;
diff --git a/app/src/main/java/com/naman14/tandroidlame/MainActivity.java b/app/src/main/java/com/naman14/tandroidlame/MainActivity.java
index b3e9b21..d487e0c 100644
--- a/app/src/main/java/com/naman14/tandroidlame/MainActivity.java
+++ b/app/src/main/java/com/naman14/tandroidlame/MainActivity.java
@@ -5,14 +5,15 @@
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v4.app.ActivityCompat;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.app.ActivityCompat;
+import androidx.core.content.ContextCompat;
+
public class MainActivity extends AppCompatActivity {
@@ -65,6 +66,7 @@ private void checkPermissions() {
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults);
switch (requestCode) {
diff --git a/app/src/main/java/com/naman14/tandroidlame/Mp3AudioRecordActivity.java b/app/src/main/java/com/naman14/tandroidlame/Mp3AudioRecordActivity.java
index 5f1eea1..bd39a24 100644
--- a/app/src/main/java/com/naman14/tandroidlame/Mp3AudioRecordActivity.java
+++ b/app/src/main/java/com/naman14/tandroidlame/Mp3AudioRecordActivity.java
@@ -19,8 +19,6 @@
import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.Environment;
-import android.support.annotation.Nullable;
-import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
@@ -34,12 +32,15 @@
import java.io.FileOutputStream;
import java.io.IOException;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+
public class Mp3AudioRecordActivity extends AppCompatActivity {
int minBuffer;
int inSamplerate = 8000;
- String filePath = Environment.getExternalStorageDirectory() + "/testrecord.mp3";
+ String filePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + "/testrecord.mp3";
boolean isRecording = false;
@@ -95,10 +96,14 @@ private void startRecording() {
AudioFormat.ENCODING_PCM_16BIT);
addLog("Initialising audio recorder..");
- audioRecord = new AudioRecord(
- MediaRecorder.AudioSource.MIC, inSamplerate,
- AudioFormat.CHANNEL_IN_MONO,
- AudioFormat.ENCODING_PCM_16BIT, minBuffer * 2);
+ try {
+ audioRecord = new AudioRecord(
+ MediaRecorder.AudioSource.MIC, inSamplerate,
+ AudioFormat.CHANNEL_IN_MONO,
+ AudioFormat.ENCODING_PCM_16BIT, minBuffer * 2);
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ }
//5 seconds data
addLog("creating short buffer array");
diff --git a/app/src/main/res/layout/fragment_log.xml b/app/src/main/res/layout/fragment_log.xml
index 554e1a7..8d3a2cc 100644
--- a/app/src/main/res/layout/fragment_log.xml
+++ b/app/src/main/res/layout/fragment_log.xml
@@ -4,7 +4,7 @@
android:layout_height="match_parent"
android:orientation="vertical">
-
diff --git a/app/src/test/java/com/naman14/tandroidlame/ExampleUnitTest.java b/app/src/test/java/com/naman14/tandroidlame/ExampleUnitTest.java
index 4ae86e1..ab1cce8 100644
--- a/app/src/test/java/com/naman14/tandroidlame/ExampleUnitTest.java
+++ b/app/src/test/java/com/naman14/tandroidlame/ExampleUnitTest.java
@@ -5,11 +5,13 @@
import static org.junit.Assert.*;
/**
- * To work on unit tests, switch the Test Artifact in the Build Variants view.
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
*/
public class ExampleUnitTest {
@Test
- public void addition_isCorrect() throws Exception {
+ public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 6b0e4f3..7e5e64c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,29 +1,5 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
-
-buildscript {
-
- repositories {
- google()
- jcenter()
- }
-
- dependencies {
- classpath 'com.android.tools.build:gradle:3.0.0'
- classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' //necessary for jitpack.io with android studio 3
-
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
- }
-}
-
-allprojects {
-
- repositories {
- google()
- jcenter()
- }
-}
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
+plugins {
+id 'com.android.application' version '8.2.2' apply false
+ id 'com.android.library' version '8.2.2' apply false
+}
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
index 1d3591c..47631c9 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,18 +1,24 @@
# Project-wide Gradle settings.
-
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
-
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
-
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
-# Default value: -Xmx10248m -XX:MaxPermSize=256m
-# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
-
+org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
\ No newline at end of file
+# org.gradle.parallel=true
+# AndroidX package structure to make it clearer which packages are bundled with the
+# Android operating system, and which are packaged with your app's APK
+# https://developer.android.com/topic/libraries/support-library/androidx-rn
+android.useAndroidX=true
+# Enables namespacing of each library's R class so that its R class includes only the
+# resources declared in the library itself and none from the library's dependencies,
+# thereby reducing the size of the R class for that library
+android.nonTransitiveRClass=true
+
+# Use Java 17
+org.gradle.java.home=/Library/Java/JavaVirtualMachines/openjdk-17.jdk/Contents/Home
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 05ef575..e708b1c 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index c3dd323..27c7966 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Wed Nov 01 22:00:58 CET 2017
+#Mon Jul 15 11:38:17 IDT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
diff --git a/gradlew b/gradlew
index 9d82f78..4f906e0 100755
--- a/gradlew
+++ b/gradlew
@@ -1,4 +1,20 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
##############################################################################
##
@@ -6,20 +22,38 @@
##
##############################################################################
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
-warn ( ) {
+warn () {
echo "$*"
}
-die ( ) {
+die () {
echo
echo "$*"
echo
@@ -30,6 +64,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
+nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
@@ -40,28 +75,14 @@ case "`uname`" in
MINGW* )
msys=true
;;
+ NONSTOP* )
+ nonstop=true
+ ;;
esac
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -85,7 +106,7 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -105,10 +126,11 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
@@ -134,27 +156,30 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
- i=$((i+1))
+ i=`expr $i + 1`
done
case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index aec9973..ac1b06f 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -8,20 +24,23 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
+if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -35,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-if exist "%JAVA_EXE%" goto init
+if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -45,34 +64,14 @@ echo location of your Java installation.
goto fail
-:init
-@rem Get command-line arguments, handling Windowz variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
-
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
diff --git a/settings.gradle b/settings.gradle
index ae0d59a..981a51c 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1,18 @@
-include ':app', ':androidlame'
+pluginManagement {
+ repositories {
+ google()
+ mavenCentral()
+ gradlePluginPortal()
+ }
+}
+dependencyResolutionManagement {
+ repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
+ repositories {
+ google()
+ mavenCentral()
+ }
+}
+
+rootProject.name = "TAndroidLame"
+include ':app'
+include ':androidlame'