diff options
Diffstat (limited to 'app/src')
3 files changed, 29 insertions, 9 deletions
diff --git a/app/src/main/java/com/javispedro/wallmotion/Renderer.java b/app/src/main/java/com/javispedro/wallmotion/Renderer.java index 2420277..0b9da5a 100644 --- a/app/src/main/java/com/javispedro/wallmotion/Renderer.java +++ b/app/src/main/java/com/javispedro/wallmotion/Renderer.java @@ -3,6 +3,7 @@ package com.javispedro.wallmotion; import android.content.Context; import android.content.ContextWrapper; import android.content.SharedPreferences; +import android.media.AudioManager; import android.media.MediaPlayer; import android.net.Uri; import android.os.Build; @@ -128,8 +129,8 @@ public class Renderer extends ContextWrapper { player.setOnPreparedListener(listener); player.setOnSeekCompleteListener(listener); player.setLooping(true); + player.setAudioStreamType(AudioManager.STREAM_SYSTEM); player.setVolume(0, 0); - player.setAudioSessionId(0); player.setSurface(surface); Log.d(TAG, "setting data source to " + uri.toString()); player.setDataSource(this, uri); diff --git a/app/src/main/java/com/javispedro/wallmotion/SettingsActivity.java b/app/src/main/java/com/javispedro/wallmotion/SettingsActivity.java index 5fee7df..5e9c5b0 100644 --- a/app/src/main/java/com/javispedro/wallmotion/SettingsActivity.java +++ b/app/src/main/java/com/javispedro/wallmotion/SettingsActivity.java @@ -75,10 +75,8 @@ public class SettingsActivity extends AppCompatActivity { @Override public void onStart() { super.onStart(); - Intent launchIntent = getActivity().getIntent(); - if (launchIntent != null && launchIntent.getAction().equals(ACTION_CHOOSE_FILE)) { + if (isOpenedForVideoFilePicker()) { openVideoFilePicker(); - getActivity().finish(); } } @@ -91,10 +89,25 @@ public class SettingsActivity extends AppCompatActivity { Uri uri = resultData.getData(); setVideoFile(uri); } + if (isOpenedForVideoFilePicker()) { + getActivity().finish(); + } break; } } + private boolean isOpenedForVideoFilePicker() { + Activity activity = getActivity(); + Intent launchIntent = activity.getIntent(); + if (launchIntent != null) { + String launchAction = launchIntent.getAction(); + if (launchAction != null) { + return launchAction.equals(ACTION_CHOOSE_FILE); + } + } + return false; + } + private void openVideoFilePicker() { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 3081e15..7724c90 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -6,6 +6,9 @@ android:layout_height="match_parent" tools:context=".MainActivity"> + <!-- This layout will overlap with the system windows, + so use it for the video window --> + <SurfaceView android:id="@+id/wallpaper_view" android:layout_width="match_parent" @@ -16,12 +19,14 @@ android:layout_height="match_parent" android:fitsSystemWindows="true"> + <!-- But everything here will not --> + <com.google.android.material.appbar.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/colorPrimaryTranslucent" - app:elevation="0dp" - android:theme="@style/AppTheme.AppBarOverlay"> + android:theme="@style/AppTheme.AppBarOverlay" + app:elevation="0dp"> <androidx.appcompat.widget.Toolbar android:id="@+id/toolbar" @@ -29,28 +34,29 @@ android:layout_height="?attr/actionBarSize" app:popupTheme="@style/AppTheme.PopupOverlay" /> - </com.google.android.material.appbar.AppBarLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" - android:layout_margin="@dimen/fab_margin" android:orientation="vertical"> <com.google.android.material.floatingactionbutton.FloatingActionButton android:id="@+id/set_file" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_marginHorizontal="@dimen/fab_margin" + android:layout_marginTop="@dimen/fab_margin" app:srcCompat="@drawable/ic_action_video_library" /> <com.google.android.material.floatingactionbutton.FloatingActionButton android:id="@+id/set_wallpaper" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="@dimen/fab_margin" + android:layout_margin="@dimen/fab_margin" app:srcCompat="@drawable/ic_action_wallpaper" /> + </LinearLayout> </FrameLayout> |