Skip to content

Commit

Permalink
minor bug fixes
Browse files Browse the repository at this point in the history
videos playing with incorrect aspect ratio
duplicate presets in library
  • Loading branch information
Shaji Khan committed Jun 6, 2024
1 parent 083baf6 commit 2f21036
Show file tree
Hide file tree
Showing 15 changed files with 183 additions and 50 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
applicationId "com.shajikhan.ladspa.amprack"
minSdk 24
targetSdk 33
versionCode 97
versionName '4.33'
versionCode 99
versionName '4.41'

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/cpp/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,9 @@ std::string Engine::tuneLatency () {
if (! mIsEffectOn)
return std::string ("Turn on audio engine first") ;

mRecordingStream->setBufferSizeInFrames(mRecordingStream->getFramesPerBurst() * 2);
mPlayStream->setBufferSizeInFrames(mPlayStream->getFramesPerBurst() * 2);

latencyTuner->requestReset();
oboe::Result result = latencyTuner->tune() ;
latencyTunerOut->requestReset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,15 @@ public void onComplete(@NonNull Task<QuerySnapshot> task) {
Log.d(TAG, "onComplete: skipping empty preset " + preset.get("name"));
continue;
}

preset.put("path", document.getReference().getPath());

if (shared && presetsAdapter.contains(preset)) {
Log.d(TAG, String.format ("[skip duplicate preset]: %s", preset));
continue;
}

// Log.d(TAG, String.format ("[preset]: %s", preset));
presetsAdapter.addPreset(preset);
// lastStamp = (String) preset.get(presetsAdapter.sortBy);
}
Expand Down
22 changes: 19 additions & 3 deletions app/src/main/java/com/shajikhan/ladspa/amprack/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -933,11 +933,20 @@ void showMediaPlayerDialog() {

ConstraintLayout constraintLayout = (ConstraintLayout) inflater.inflate(R.layout.media_player_dialog, null);
SurfaceView surface = constraintLayout.findViewById(R.id.video_player_dialog);

LinearLayout surfaceLayout = constraintLayout.findViewById(R.id.surface_ll);

mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
int w = mp.getVideoWidth(), h = mp.getVideoHeight() ;
surface.getHolder().setFixedSize(w, h);
if (lastRecordedFileName.endsWith(".mp4")) {
int w = mp.getVideoWidth(), h = mp.getVideoHeight();
surfaceLayout.setVisibility(View.VISIBLE);
surface.getHolder().setFixedSize(w, h);
Log.d(TAG, "onPrepared: ends with mp4");
} else {
surfaceLayout.setVisibility(View.GONE);
}
}
});

Expand Down Expand Up @@ -989,7 +998,14 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if (b) {
Uri uri = Uri.parse(lastRecordedFileName);
try {
surface.setVisibility(View.VISIBLE);
if (lastRecordedFileName.endsWith(".mp4")) {
surfaceLayout.setVisibility(View.VISIBLE);
Log.d(TAG, "onCheckedChanged: ends with mp4");
} else {
surfaceLayout.setVisibility(View.GONE);
Log.d(TAG, "onCheckedChanged: no end");
}

mediaPlayer.stop();
mediaPlayer.reset();
mediaPlayer.setDataSource(getApplicationContext(), uri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.ToggleButton;
Expand All @@ -26,6 +28,7 @@ public class MediaPlayerDialog {
MainActivity mainActivity ;
MediaPlayer mediaPlayer ;
AlertDialog dialog ;
String TAG = getClass().getSimpleName();

MediaPlayerDialog (MainActivity activity, MediaPlayer player) {
mainActivity = activity;
Expand Down Expand Up @@ -82,6 +85,15 @@ public void onClick(View view) {
TextView textView = constraintLayout.findViewById(R.id.media_filename);
File file = new File(mainActivity.lastRecordedFileName);
textView.setText(file.getName());

LinearLayout surfaceLayout = constraintLayout.findViewById(R.id.surface_ll);
mediaPlayer.setOnVideoSizeChangedListener(new MediaPlayer.OnVideoSizeChangedListener() {
@Override
public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
surface.getHolder().setFixedSize(width, height);
}
});

toggleButton.setButtonDrawable(R.drawable.ic_baseline_play_arrow_24);
toggleButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
Expand All @@ -90,7 +102,14 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
mainActivity.tracks.tracksAdapter.add(mainActivity.lastRecordedFileName);
Uri uri = Uri.parse(mainActivity.lastRecordedFileName);
try {
surface.setVisibility(View.VISIBLE);
if (mainActivity.lastRecordedFileName.endsWith(".mp4")) {
surface.setVisibility(View.VISIBLE);
Log.d(TAG, "onCheckedChanged: ends with mp4");
} else {
surface.setVisibility(View.GONE);
Log.d(TAG, "onCheckedChanged: no end");
}

mediaPlayer.stop();
mediaPlayer.reset();
mediaPlayer.setDataSource(mainActivity.getApplicationContext(), uri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,14 @@ public void showOnlyFavorites (boolean show) {

notifyDataSetChanged();
}

boolean contains (Map preset) {
for (Map p:
allPresets) {
if (preset.get("name").equals(p.get("name")) && preset.get("uid").equals(p.get("uid")))
return true;
}

return false;
}
}
6 changes: 6 additions & 0 deletions app/src/main/java/com/shajikhan/ladspa/amprack/Rack.java
Original file line number Diff line number Diff line change
Expand Up @@ -801,8 +801,14 @@ public void run() {
});
}
mixer.setVisibility(View.VISIBLE);
((TextView) mainActivity.findViewById(R.id.m_camera)).setVisibility(View.VISIBLE);
((TextView) mainActivity.findViewById(R.id.m_on)).setVisibility(View.VISIBLE);
((TextView) mainActivity.findViewById(R.id.m_mixer)).setVisibility(View.VISIBLE);
} else {
mixer.setVisibility(View.GONE);
((TextView) mainActivity.findViewById(R.id.m_camera)).setVisibility(View.GONE);
((TextView) mainActivity.findViewById(R.id.m_on)).setVisibility(View.GONE);
((TextView) mainActivity.findViewById(R.id.m_mixer)).setVisibility(View.GONE);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ public boolean onPreferenceClick(Preference preference) {
}
});

findPreference("cool").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
MainActivity.about();
return false;
}
});
}
}

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/shajikhan/ladspa/amprack/Tracks.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
});

player = new ExoPlayer.Builder(context).build();
player.setVideoScalingMode (C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);
player.setVideoScalingMode (C.VIDEO_SCALING_MODE_SCALE_TO_FIT);
tracksAdapter.player = player;

playPause = view.findViewById(R.id.tracks_play);
Expand Down Expand Up @@ -191,6 +191,7 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
@Override
public void onVideoSizeChanged(VideoSize videoSize) {
Player.Listener.super.onVideoSizeChanged(videoSize);
Log.d(TAG, String.format ("[video size]: %d x %d", videoSize.width, videoSize.height));
surfaceView.getHolder().setFixedSize(videoSize.width, videoSize.height);
}
@Override
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/baseline_auto_graph_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">

<path android:fillColor="@android:color/white" android:pathData="M14.06,9.94L12,9l2.06,-0.94L15,6l0.94,2.06L18,9l-2.06,0.94L15,12L14.06,9.94zM4,14l0.94,-2.06L7,11l-2.06,-0.94L4,8l-0.94,2.06L1,11l2.06,0.94L4,14zM8.5,9l1.09,-2.41L12,5.5L9.59,4.41L8.5,2L7.41,4.41L5,5.5l2.41,1.09L8.5,9zM4.5,20.5l6,-6.01l4,4L23,8.93l-1.41,-1.41l-7.09,7.97l-4,-4L3,19L4.5,20.5z"/>

</vector>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_purchase2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/MaterialAlertDialog.MaterialComponents.Title.Text"
android:text="$2"
android:text=""
android:textAlignment="center"
android:id="@+id/price"
android:textColor="@color/white"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/media_player_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:id="@+id/surface_ll"
android:layout_height="match_parent">
<SurfaceView
android:layout_width="match_parent"
Expand Down
131 changes: 91 additions & 40 deletions app/src/main/res/layout/rack.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,39 +66,73 @@
android:layout_height="wrap_content"/>


<ToggleButton
android:layout_width="48dp"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textOff=""
android:textOn=""
android:padding="5dp"
android:drawableRight="@drawable/ic_baseline_volume_up_24"
android:gravity="right"
android:layout_marginRight="5dp"
android:id="@+id/mixer_toggle"
android:background="@color/fui_transparent"
android:layout_gravity="right"
android:fontFamily="@font/comfortaa"/>
android:orientation="vertical">
<ToggleButton
android:layout_width="40dp"
android:layout_height="wrap_content"
android:textOff=""
android:textOn=""
android:padding="5dp"
android:drawableRight="@drawable/ic_baseline_volume_up_24"
android:gravity="right"
android:layout_marginRight="5dp"
android:id="@+id/mixer_toggle"
android:background="@color/fui_transparent"
android:layout_gravity="right"
android:fontFamily="@font/comfortaa"/>
<TextView
android:id="@+id/m_mixer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mixer"
android:layout_gravity="center"
android:textAlignment="center"
android:fontFamily="@font/gruppo"
android:textStyle="bold"
android:foregroundTint="@color/white"
android:textSize="14dp"/>
</LinearLayout>

<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/onoff"
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp" />
android:id="@+id/on_ll"
android:layout_height="wrap_content">

<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/onoff"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp" />
<ToggleButton
android:id="@+id/onofftoggle"
android:visibility="gone"
android:textOn=""
android:layout_gravity="right"
android:gravity="center|center_vertical"
android:textOff=""
android:background="@color/fui_transparent"
android:layout_width="48dp"
android:padding="5dp"
android:paddingLeft="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp" />
<TextView
android:id="@+id/m_on"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="On"
android:layout_gravity="center"
android:textAlignment="center"
android:fontFamily="@font/gruppo"
android:textStyle="bold"
android:foregroundTint="@color/white"
android:textSize="14dp"/>
</LinearLayout>

<ToggleButton
android:id="@+id/onofftoggle"
android:visibility="gone"
android:textOn=""
android:layout_gravity="right"
android:gravity="center|center_vertical"
android:textOff=""
android:background="@color/fui_transparent"
android:layout_width="48dp"
android:padding="5dp"
android:paddingLeft="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp" />
<com.google.android.material.button.MaterialButton
android:id="@+id/settings"
android:layout_width="30dp"
Expand All @@ -119,18 +153,35 @@
android:textOn="Off" />


<ToggleButton
android:padding="0dp"
android:textOn=""
android:textOff=""
android:layout_marginTop="0dp"
android:id="@+id/video_button"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:layout_width="30dp"
android:background="@color/fui_transparent"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="@drawable/baseline_add_a_photo_24"/>
android:orientation="vertical">
<ToggleButton
android:padding="0dp"
android:textOn=""
android:textOff=""
android:layout_marginTop="0dp"
android:id="@+id/video_button"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:layout_width="30dp"
android:background="@color/fui_transparent"
android:layout_height="wrap_content"
android:drawableRight="@drawable/baseline_add_a_photo_24"/>

<TextView
android:id="@+id/m_camera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Video"
android:layout_gravity="center"
android:textAlignment="center"
android:fontFamily="@font/gruppo"
android:textStyle="bold"
android:foregroundTint="@color/white"
android:textSize="14dp"/>
</LinearLayout>

<com.google.android.material.button.MaterialButton
android:id="@+id/menu_button"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<resources>
<string name="app_name">Amp Rack</string>
<string name="app_version">Version 4 Razor</string>
<string name="build_id">631</string>
<string name="build_id">634</string>
<string name="onboard_description">
[new] Video Recorder\n\n
Welcome to Version 4: \n\n
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/res/xml/header_preferences.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">

<Preference
app:fragment="com.shajikhan.ladspa.amprack.SettingsActivity$ProfileFragment"
Expand Down Expand Up @@ -54,4 +55,9 @@
app:title="Privacy Policy"
app:summary="View Privacy Policy and License (Apache License 2.0) Information"/>

<Preference
app:key="cool"
android:icon="@drawable/baseline_auto_graph_24"
android:title="Build Variant: Cool 😎"
android:summary="Powered by Rock and Roll"/>
</PreferenceScreen>

0 comments on commit 2f21036

Please sign in to comment.