Skip to content

Commit

Permalink
Rewritten transitions
Browse files Browse the repository at this point in the history
Ended splash screen
Some other fixes
  • Loading branch information
nt4f04uNd committed Feb 21, 2020
1 parent 7d20388 commit 4c045ae
Show file tree
Hide file tree
Showing 31 changed files with 1,263 additions and 449 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"catcher","dependencies":["fluttertoast","device_info","package_info","flutter_local_notifications","flutter_mailer"]},{"name":"device_info","dependencies":[]},{"name":"flutter_local_notifications","dependencies":[]},{"name":"flutter_mailer","dependencies":[]},{"name":"fluttertoast","dependencies":[]},{"name":"package_info","dependencies":[]},{"name":"path_provider","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"shared_preferences","dependencies":[]}]}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"catcher","path":"C:\\\\Users\\\\danya\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\catcher-0.2.4\\\\","dependencies":["fluttertoast","device_info","package_info","flutter_local_notifications","flutter_mailer"]},{"name":"device_info","path":"C:\\\\Users\\\\danya\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\device_info-0.4.0+2\\\\","dependencies":[]},{"name":"flutter_local_notifications","path":"C:\\\\Users\\\\danya\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_local_notifications-0.8.3\\\\","dependencies":[]},{"name":"flutter_mailer","path":"C:\\\\Users\\\\danya\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_mailer-0.4.1+2\\\\","dependencies":[]},{"name":"fluttertoast","path":"C:\\\\Users\\\\danya\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\fluttertoast-3.1.3\\\\","dependencies":[]},{"name":"package_info","path":"C:\\\\Users\\\\danya\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\package_info-0.4.0+6\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\Users\\\\danya\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.3.0\\\\","dependencies":[]},{"name":"permission_handler","path":"C:\\\\Users\\\\danya\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler-3.2.2\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\Users\\\\danya\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.3+4\\\\","dependencies":[]}],"android":[{"name":"catcher","path":"C:\\\\Users\\\\danya\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\catcher-0.2.4\\\\","dependencies":["fluttertoast","device_info","package_info","flutter_local_notifications","flutter_mailer"]},{"name":"device_info","path":"C:\\\\Users\\\\danya\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\device_info-0.4.0+2\\\\","dependencies":[]},{"name":"flutter_local_notifications","path":"C:\\\\Users\\\\danya\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_local_notifications-0.8.3\\\\","dependencies":[]},{"name":"flutter_mailer","path":"C:\\\\Users\\\\danya\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_mailer-0.4.1+2\\\\","dependencies":[]},{"name":"fluttertoast","path":"C:\\\\Users\\\\danya\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\fluttertoast-3.1.3\\\\","dependencies":[]},{"name":"package_info","path":"C:\\\\Users\\\\danya\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\package_info-0.4.0+6\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\Users\\\\danya\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.3.0\\\\","dependencies":[]},{"name":"permission_handler","path":"C:\\\\Users\\\\danya\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler-3.2.2\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\Users\\\\danya\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.3+4\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"catcher","dependencies":["fluttertoast","device_info","package_info","flutter_local_notifications","flutter_mailer"]},{"name":"device_info","dependencies":[]},{"name":"flutter_local_notifications","dependencies":[]},{"name":"flutter_mailer","dependencies":[]},{"name":"fluttertoast","dependencies":[]},{"name":"package_info","dependencies":[]},{"name":"path_provider","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"shared_preferences","dependencies":[]}],"date_created":"2020-02-21 02:55:47.419943","version":"1.15.4-pre.83"}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,6 @@
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages


google-services.json
1 change: 1 addition & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ if (flutterVersionName == null) {
}

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services' // Google Services plugin
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

// repositories {
Expand Down
3 changes: 1 addition & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="@style/LaunchThemeSystemUILight"
android:theme="@style/LaunchThemeSystemUI"
android:windowSoftInputMode="adjustNothing">
<!-- android:theme="@style/LaunchThemeSystemUILight"-->

<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,46 +24,45 @@ public static void init() {
mediaSession.setCallback(new MediaSession.Callback() {

// TODO: implement remaining methods
final String prefix = "PREFIX PREFIX PREFIX PREFIX PREFIX";

@Override
public void onFastForward() {
GeneralHandler.print(prefix + "FAST_FORWARD");
PlayerHandler.fastForward();
}

@Override
public void onPause() {
GeneralHandler.print(prefix + "PAUSE");
PlayerHandler.pause();
}

@Override
public void onPlay() {
GeneralHandler.print(prefix + "PLAY");
PlayerHandler.resume();
}

@Override
public void onRewind() {
GeneralHandler.print(prefix + "REWIND");
PlayerHandler.rewind();
}

@Override
public void onSeekTo(long pos) {
GeneralHandler.print(prefix + "SEEK");
PlayerHandler.seek((int) pos);
}

@Override
public void onSkipToNext() {
GeneralHandler.print(prefix + "SKIP_NEXT");
PlayerHandler.playNext();
}

@Override
public void onSkipToPrevious() {
GeneralHandler.print(prefix + "SKIP_PREV");
PlayerHandler.playPrev();
}

@Override
public void onStop() {
GeneralHandler.print(prefix + "STOP");
PlayerHandler.pause();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ public static byte[] getArtPlaceholder() {
public static void getLastPlaylist() {
if (songs == null) { // Songs will be rested to null every time app activity starts
songs = SerializationHandler.getPlaylistSongs();

Song song = songs.get(7);
GeneralHandler.print("wfwfwfwfwfwfwfwfwfwfwfwfwfwfwfwfwfwfwf, ID"
+ song.id + " TITLE "
+ song.title + " ALBUM "
+ song.album + " ALB_ID "
+ song.albumId + " ALB_KEY "
+ song.albumKey + " ALB_URI "
+ song.albumArtUri
);
//
// // Song song = songs.get(7);
// GeneralHandler.print("wfwfwfwfwfwfwfwfwfwfwfwfwfwfwfwfwfwfwf, ID"
// + song.id + " TITLE "
// + song.title + " ALBUM "
// + song.album + " ALB_ID "
// + song.albumId + " ALB_KEY "
// + song.albumKey + " ALB_URI "
// + song.albumArtUri
// );
}
}

Expand Down Expand Up @@ -144,13 +144,21 @@ private static Integer getCurrentSongIndex() {
}

public static Song getNextSong() {
int new_id = getCurrentSongIndex() + 1 > songs.size() - 1 ? 0 : getCurrentSongIndex() + 1;
return songs.get(new_id);
Integer new_idx = getCurrentSongIndex();
if (new_idx == null)
new_idx = 0;
else
new_idx = new_idx + 1 > songs.size() - 1 ? 0 : new_idx + 1;
return songs.get(new_idx);
}

public static Song getPrevSong() {
int new_id = getCurrentSongIndex() - 1 < 0 ? songs.size() - 1 : getCurrentSongIndex() - 1;
return songs.get(new_id);
Integer new_idx = getCurrentSongIndex();
if (new_idx == null)
new_idx = 0;
else
new_idx = new_idx - 1 < 0 ? songs.size() - 1 : new_idx - 1;
return songs.get(new_idx);
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.nt4f04uNd.sweyer.handlers;

import android.content.Context;
import android.os.PowerManager;

import com.nt4f04uNd.sweyer.Constants;

public abstract class WakelockHandler {
private static PowerManager.WakeLock wl;

public static void acquire() {
if (wl == null) {
PowerManager powerManager = (PowerManager) GeneralHandler.getAppContext().getSystemService(Context.POWER_SERVICE);
if (powerManager == null) return;
wl = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, Constants.PACKAGE_NAME + ":wakeLockTag");
wl.acquire();

}
}

public static void release() {
if (wl != null && wl.isHeld()) {
wl.release();
wl = null;
}
}
}
31 changes: 21 additions & 10 deletions android/app/src/main/java/com/nt4f04uNd/sweyer/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,20 @@
/**
* Basic wrapper over media player, very raw
*/
public class Player extends PlayerAbstract implements MediaPlayer.OnPreparedListener, MediaPlayer.OnCompletionListener {
public class Player extends PlayerAbstract implements MediaPlayer.OnPreparedListener, MediaPlayer.OnCompletionListener, MediaPlayer.OnBufferingUpdateListener {
// TODO: logging
//private Logger LOGGER = Logger.getLogger(Player.class.getCanonicalName());

// public Player(Context appContext) {
// PowerManager powerManager = (PowerManager) appContext.getSystemService(Context.POWER_SERVICE);
// PowerManager.WakeLock wl = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, Constants.PACKAGE_NAME + ":wakeLockTag");
// // wl.acquire();
// // ..screen will stay on during this section..
//// / / wl.release();
//
// }

private Uri uri;
private double volume = 1.0;
private boolean respectSilence;
private boolean stayAwake;
private ReleaseMode releaseMode = ReleaseMode.RELEASE;
private boolean released = true;
private boolean prepared = false;
private boolean preparing = false;
private boolean playing = false;
private Uri pendingUri = null;

private int shouldSeekTo = -1;

Expand All @@ -70,12 +63,16 @@ public void setUri(Uri uri) {
} else if (this.prepared) {
this.player.reset();
this.prepared = false;
} else if (preparing) {
pendingUri = uri;
return;
}

this.setSource(GeneralHandler.getAppContext(), uri);
this.player.setVolume((float) volume, (float) volume);
this.player.setLooping(this.releaseMode == ReleaseMode.LOOP);
this.player.prepareAsync();
this.preparing = true;

}
}
Expand Down Expand Up @@ -128,6 +125,7 @@ public int getDuration() {

@Override
public int getCurrentPosition() {
if (player == null) return 0;
return this.player.getCurrentPosition();
}

Expand Down Expand Up @@ -163,6 +161,7 @@ public void play(Context appContext) {
this.player = createPlayer();
this.setSource(appContext, uri);
this.player.prepareAsync();
this.preparing = true;
} else if (this.prepared) {
this.player.start();
PlayerHandler.startPositionUpdates();
Expand Down Expand Up @@ -233,6 +232,7 @@ public void seek(int position) {
@Override
public void onPrepared(final MediaPlayer mediaPlayer) {
this.prepared = true;
this.preparing = false;
PlayerHandler.handleDuration(this);
if (this.playing) {
mediaPlayer.start();
Expand All @@ -244,6 +244,7 @@ public void onPrepared(final MediaPlayer mediaPlayer) {
}
}


@Override
public void onCompletion(final MediaPlayer mediaPlayer) {
if (releaseMode != ReleaseMode.LOOP) {
Expand All @@ -252,6 +253,15 @@ public void onCompletion(final MediaPlayer mediaPlayer) {
PlayerHandler.handleCompletion();
}

@Override
public void onBufferingUpdate(MediaPlayer mediaPlayer, int percent) {
if (pendingUri != null) {
mediaPlayer.release();
setUri(pendingUri);
pendingUri = null;
}
}


/**
* Internal logic. Private methods
Expand All @@ -261,6 +271,7 @@ private MediaPlayer createPlayer() {
MediaPlayer player = new MediaPlayer();
player.setOnPreparedListener(this);
player.setOnCompletionListener(this);
player.setOnBufferingUpdateListener(this);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
player.setAudioAttributes(new AudioAttributes.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.nt4f04uNd.sweyer.handlers.PlayerHandler;
import com.nt4f04uNd.sweyer.handlers.PlaylistHandler;
import com.nt4f04uNd.sweyer.handlers.PrefsHandler;
import com.nt4f04uNd.sweyer.handlers.WakelockHandler;
import com.nt4f04uNd.sweyer.receivers.BecomingNoisyReceiver;
import com.nt4f04uNd.sweyer.receivers.NotificationReceiver;

Expand All @@ -39,15 +40,20 @@ public void onCreate() {
isRunning = true;

PlaylistHandler.initCurrentSong();
if(!GeneralHandler.activityExists() && PrefsHandler.getSongIsPlaying()){
// Start playing if flag is playing is set to true
// This is just a handling for sticky service
PlayerHandler.playPause();
GeneralHandler.print("wfqfwqkifjwqjfwq");

Boolean savedPlaying = null;
if (!GeneralHandler.activityExists()) {
savedPlaying = PrefsHandler.getSongIsPlaying();
if (savedPlaying) {
// Start playing if flag is playing is set to true
// This is just a handling for sticky service
PlayerHandler.playPause();
}
}

// Initializing handlers
GeneralHandler.init(getApplicationContext());
WakelockHandler.acquire();
PlayerHandler.init();
AudioFocusHandler.init();
NotificationHandler.init();
Expand All @@ -62,7 +68,12 @@ public void onCreate() {
if (PlaylistHandler.getCurrentSong() != null)
startForeground(
NotificationHandler.NOTIFICATION_ID,
NotificationHandler.getNotification(PlayerHandler.isPlaying(), PlayerHandler.isLooping())
NotificationHandler.getNotification(
// If activity exists then set true as start playing button, as service is meant to start only together with playback
// Else check saved playing
savedPlaying == null ? true : savedPlaying,
PlayerHandler.isLooping()
)
);
else stopSelf();
}
Expand All @@ -78,8 +89,9 @@ public void onDestroy() {
isRunning = false;

// Handlers
// These two one may affect user interaction with other apps if I won't destroy them
// These may affect user interaction with other apps if I won't destroy them
// Other handlers seem to be not necessary to clear them
WakelockHandler.release();
AudioFocusHandler.abandonFocus();
PlaylistHandler.resetPlaylist();
MediaSessionHandler.release();
Expand Down
11 changes: 6 additions & 5 deletions android/app/src/main/res/drawable/launch_background_dark.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<?xml version="1.0" encoding="utf-8"?><!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- You can insert your own image assets here -->
<item android:drawable="@color/main_dark" />-->
<!-- You can insert your own image assets here -->
<item android:drawable="@color/main_dark" />
<item>
<bitmap android:gravity="center" android:src="@drawable/screen_dark" />
<bitmap
android:gravity="center"
android:src="@drawable/screen_dark" />
</item>
</layer-list>
16 changes: 16 additions & 0 deletions android/app/src/main/res/values-night/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">

<style name="LaunchThemeSystemUI" parent="@android:style/Theme.Black.NoTitleBar">
<!-- <item name="android:navigationBarColor">@color/main_dark</item>-->
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background_dark</item>
</style>


<color name="main_light">#fff</color>

<color name="main_dark">#262626</color>

</resources>
12 changes: 3 additions & 9 deletions android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">

<style name="LaunchThemeSystemUILight" parent="@android:style/Theme.Black.NoTitleBar">
<style name="LaunchThemeSystemUI" parent="@android:style/Theme.Black.NoTitleBar">
<!-- <item name="android:navigationBarColor">@color/main_light</item>-->
<item name="android:windowBackground">@drawable/launch_background_light</item>
</style>

<style name="LaunchThemeSystemUIDark" parent="@android:style/Theme.Black.NoTitleBar">
<!-- <item name="android:navigationBarColor">@color/main_dark</item>-->
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<!-- TODO:make theme respectful splash screen -->
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background_light</item>
</style>


<color name="main_light">#fff</color>

<color name="main_dark">#262626</color>
<color name="main_dark_">#000</color>

</resources>
3 changes: 2 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.3' // Google Services plugin
}
}

Expand Down
Loading

0 comments on commit 4c045ae

Please sign in to comment.