Skip to content

Commit

Permalink
Merge pull request #46 from s0llvan/master
Browse files Browse the repository at this point in the history
fixed: background video recording
  • Loading branch information
anonfaded authored Nov 21, 2024
2 parents dc6babb + 12903f0 commit 1940430
Show file tree
Hide file tree
Showing 24 changed files with 1,320 additions and 994 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.fadcam;

import static org.junit.Assert.assertEquals;

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
</provider>
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|uiMode"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -91,8 +93,6 @@
android:exported="false"
android:foregroundServiceType="camera|microphone" />



</application>

</manifest>
13 changes: 0 additions & 13 deletions app/src/main/java/com/fadcam/Constantes.java

This file was deleted.

40 changes: 40 additions & 0 deletions app/src/main/java/com/fadcam/Constants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.fadcam;

public abstract class Constants {

public static final int DEFAULT_VIDEO_FRAME_RATE = 30;

public static final String PREFS_NAME = "app_prefs";
public static final String LANGUAGE_KEY = "language";

public static final String PREF_VIDEO_QUALITY = "video_quality";
public static final String PREF_VIDEO_FRAME_RATE = "video_framerate";
public static final String PREF_CAMERA_SELECTION = "camera_selection";
public static final String PREF_IS_PREVIEW_ENABLED = "isPreviewEnabled";

public static final String CAMERA_FRONT = "front";
public static final String CAMERA_BACK = "back";

public static final String QUALITY_SD = "SD";
public static final String QUALITY_HD = "HD";
public static final String QUALITY_FHD = "FHD";

public static final String BROADCAST_ON_RECORDING_STARTED = "com.fadcam.ON_RECORDING_STARTED";
public static final String BROADCAST_ON_RECORDING_RESUMED = "com.fadcam.ON_RECORDING_RESUMED";
public static final String BROADCAST_ON_RECORDING_PAUSED = "com.fadcam.ON_RECORDING_PAUSED";
public static final String BROADCAST_ON_RECORDING_STOPPED = "com.fadcam.ON_RECORDING_STOPPED";
public static final String BROADCAST_ON_RECORDING_STATE_REQUEST = "com.fadcam.ON_RECORDING_STATE_REQUEST";
public static final String BROADCAST_ON_RECORDING_STATE_CALLBACK = "com.fadcam.ON_RECORDING_STATE_CALLBACK";

public static final String BROADCAST_EXTRA_RECORDING_STATE = "RECORDING_STATE";
public static final String BROADCAST_EXTRA_RECORDING_START_TIME = "RECORDING_START_TIME";

public static final String INTENT_ACTION_STOP_RECORDING = "ACTION_STOP_RECORDING";
public static final String INTENT_ACTION_CHANGE_SURFACE = "ACTION_CHANGE_SURFACE";
public static final String INTENT_ACTION_RESUME_RECORDING = "ACTION_RESUME_RECORDING";
public static final String INTENT_ACTION_PAUSE_RECORDING = "ACTION_PAUSE_RECORDING";
public static final String INTENT_ACTION_START_RECORDING = "ACTION_START_RECORDING";

public static final String RECORDING_DIRECTORY = "FadCam";
public static final String RECORDING_FILE_EXTENSION = "mp4";
}
31 changes: 16 additions & 15 deletions app/src/main/java/com/fadcam/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,23 @@ public class MainActivity extends AppCompatActivity {
private ViewPager2 viewPager;
private BottomNavigationView bottomNavigationView;

private static final String PREFS_NAME = "app_prefs";
private static final String LANGUAGE_KEY = "language";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Load and apply the saved language preference before anything else
SharedPreferences prefs = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
String savedLanguageCode = prefs.getString(LANGUAGE_KEY, Locale.getDefault().getLanguage());
SharedPreferences prefs = getSharedPreferences(Constants.PREFS_NAME, Context.MODE_PRIVATE);
String savedLanguageCode = prefs.getString(Constants.LANGUAGE_KEY, Locale.getDefault().getLanguage());

applyLanguage(savedLanguageCode); // Apply the language preference

AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); setContentView(R.layout.activity_main); //force dark theme even on light themed devices
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); //force dark theme even on light themed devices

// Check if current locale is Pashto
if (getResources().getConfiguration().locale.getLanguage().equals("ps")) {
getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_LTR);
}

setContentView(R.layout.activity_main);

viewPager = findViewById(R.id.view_pager);
Expand Down Expand Up @@ -90,8 +87,6 @@ public void onPageSelected(int position) {
File osmdroidTileCache = new File(osmdroidBasePath, "tiles");
org.osmdroid.config.Configuration.getInstance().setOsmdroidBasePath(osmdroidBasePath);
org.osmdroid.config.Configuration.getInstance().setOsmdroidTileCache(osmdroidTileCache);


}

public void applyLanguage(String languageCode) {
Expand All @@ -105,12 +100,8 @@ public void applyLanguage(String languageCode) {
Locale.setDefault(locale);

android.content.res.Configuration config = new android.content.res.Configuration();
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
config.setLocale(locale);
getApplicationContext().createConfigurationContext(config);
} else {
config.locale = locale;
}
config.setLocale(locale);
getApplicationContext().createConfigurationContext(config);

getResources().updateConfiguration(config, getResources().getDisplayMetrics());

Expand All @@ -120,4 +111,14 @@ public void applyLanguage(String languageCode) {
Log.d("MainActivity", "Language is already set to " + languageCode + "; no need to change.");
}
}

@Override
protected void onStart() {
super.onStart();
}

@Override
protected void onStop() {
super.onStop();
}
}
Loading

0 comments on commit 1940430

Please sign in to comment.