main
h4h13 2019-01-28 16:13:44 +05:30
parent d573be0a39
commit 63c417cd61
26 changed files with 235 additions and 268 deletions

Binary file not shown.

View File

@ -2,14 +2,14 @@ package code.name.monkey.retromusic.model;
import android.content.Context;
import android.os.Parcel;
import androidx.annotation.NonNull;
import java.util.ArrayList;
import androidx.annotation.NonNull;
import code.name.monkey.models.Song;
import io.reactivex.Observable;
public abstract class AbsCustomPlaylist extends Playlist {
public AbsCustomPlaylist(int id, String name) {
super(id, name);

View File

@ -1,10 +1,10 @@
package code.name.monkey.retromusic.model
package code.name.monkey.models
import java.util.*
class Album {
val songs: ArrayList<Song>?
val songs: ArrayList<code.name.monkey.models.Song>?
val id: Int
get() = safeGetFirstSong().albumId
@ -27,7 +27,7 @@ class Album {
val songCount: Int
get() = songs!!.size
constructor(songs: ArrayList<Song>) {
constructor(songs: ArrayList<code.name.monkey.models.Song>) {
this.songs = songs
}
@ -35,7 +35,7 @@ class Album {
this.songs = ArrayList()
}
fun safeGetFirstSong(): Song {
return if (songs!!.isEmpty()) Song.EMPTY_SONG else songs[0]
fun safeGetFirstSong(): code.name.monkey.models.Song {
return if (songs!!.isEmpty()) code.name.monkey.models.Song.EMPTY_SONG else songs[0]
}
}

View File

@ -30,9 +30,9 @@ class Artist {
val albumCount: Int
get() = albums!!.size
val songs: ArrayList<Song>
val songs: ArrayList<code.name.monkey.models.Song>
get() {
val songs = ArrayList<Song>()
val songs = ArrayList<code.name.monkey.models.Song>()
for (album in albums!!) {
songs.addAll(album.songs!!)
}

View File

@ -1,4 +1,4 @@
package code.name.monkey.retromusic.model;
package code.name.monkey.models;
import android.os.Parcel;
import android.os.Parcelable;

View File

@ -2,6 +2,8 @@ package code.name.monkey.retromusic.model;
import android.os.Parcel;
import code.name.monkey.models.Song;
public class PlaylistSong extends Song {
public static PlaylistSong EMPTY_PLAYLIST_SONG = new PlaylistSong(-1, "", -1, -1, -1, "", -1, -1, "", -1, "", -1, -1);

View File

@ -1,7 +1,7 @@
package code.name.monkey.retromusic.model.lyrics;
package code.name.monkey.models.lyrics;
import code.name.monkey.retromusic.model.Song;
import code.name.monkey.models.Song;
import java.util.ArrayList;

View File

@ -1,4 +1,4 @@
package code.name.monkey.retromusic.model.smartplaylist;
package code.name.monkey.models.smartplaylist;
import android.content.Context;
import android.os.Parcel;

View File

@ -7,9 +7,10 @@ import androidx.annotation.NonNull;
import java.util.ArrayList;
import code.name.monkey.models.Song;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.loaders.TopAndRecentlyPlayedTracksLoader;
import code.name.monkey.retromusic.model.Song;
import code.name.monkey.retromusic.providers.HistoryStore;
import io.reactivex.Observable;

View File

@ -8,7 +8,7 @@ import androidx.annotation.NonNull;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.loaders.LastAddedSongsLoader;
import code.name.monkey.retromusic.model.Song;
import code.name.monkey.models.Song;
import java.util.ArrayList;

View File

@ -8,7 +8,7 @@ import androidx.annotation.NonNull;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.loaders.TopAndRecentlyPlayedTracksLoader;
import code.name.monkey.retromusic.model.Song;
import code.name.monkey.models.Song;
import code.name.monkey.retromusic.providers.SongPlayCountStore;
import java.util.ArrayList;

View File

@ -8,7 +8,7 @@ import androidx.annotation.NonNull;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.loaders.SongLoader;
import code.name.monkey.retromusic.model.Song;
import code.name.monkey.models.Song;
import java.util.ArrayList;

View File

@ -1,96 +0,0 @@
package code.name.monkey.retromusic.util;
import android.animation.Animator;
import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Build;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.PathInterpolator;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.core.view.ViewCompat;
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import code.name.monkey.appthemehelper.util.ColorUtil;
import code.name.monkey.appthemehelper.util.MaterialValueHelper;
public class ViewUtil {
public final static int RETRO_MUSIC_ANIM_TIME = 1000;
public static Animator createTextColorTransition(final TextView v, @ColorInt final int startColor, @ColorInt final int endColor) {
return createColorAnimator(v, "textColor", startColor, endColor);
}
private static Animator createColorAnimator(Object target, String propertyName, @ColorInt int startColor, @ColorInt int endColor) {
ObjectAnimator animator;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
animator = ObjectAnimator.ofArgb(target, propertyName, startColor, endColor);
} else {
animator = ObjectAnimator.ofInt(target, propertyName, startColor, endColor);
animator.setEvaluator(new ArgbEvaluator());
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
animator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f));
}
animator.setDuration(RETRO_MUSIC_ANIM_TIME);
return animator;
}
public static void setStatusBarHeight(final Context context, View statusBar) {
ViewGroup.LayoutParams lp = statusBar.getLayoutParams();
lp.height = getStatusBarHeight(context);
statusBar.requestLayout();
}
public static int getStatusBarHeight(final Context context) {
int result = 0;
int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
result = context.getResources().getDimensionPixelSize(resourceId);
}
return result;
}
public static boolean hitTest(View v, int x, int y) {
final int tx = (int) (ViewCompat.getTranslationX(v) + 0.5f);
final int ty = (int) (ViewCompat.getTranslationY(v) + 0.5f);
final int left = v.getLeft() + tx;
final int right = v.getRight() + tx;
final int top = v.getTop() + ty;
final int bottom = v.getBottom() + ty;
return (x >= left) && (x <= right) && (y >= top) && (y <= bottom);
}
public static void setUpFastScrollRecyclerViewColor(Context context,
FastScrollRecyclerView recyclerView, int accentColor) {
recyclerView.setPopupBgColor(accentColor);
recyclerView.setPopupTextColor(
MaterialValueHelper.INSTANCE.getPrimaryTextColor(context, ColorUtil.INSTANCE.isColorLight(accentColor)));
recyclerView.setThumbColor(accentColor);
recyclerView.setTrackColor(Color.TRANSPARENT);
//recyclerView.setTrackColor(ColorUtil.withAlpha(ATHUtil.resolveColor(context, R.attr.colorControlNormal), 0.12f));
}
public static float convertDpToPixel(float dp, Resources resources) {
DisplayMetrics metrics = resources.getDisplayMetrics();
return dp * metrics.density;
}
@NotNull
public static Animator createBackgroundColorTransition(@Nullable View colorGradientBackground, int lastColor, int newColor) {
return null;
}
}

View File

@ -0,0 +1,96 @@
package code.name.monkey.retromusic.util
import android.animation.Animator
import android.animation.ArgbEvaluator
import android.animation.ObjectAnimator
import android.content.Context
import android.content.res.Resources
import android.graphics.Color
import android.graphics.PorterDuff
import android.os.Build
import android.util.DisplayMetrics
import android.view.View
import android.view.ViewGroup
import android.view.animation.PathInterpolator
import android.widget.SeekBar
import android.widget.TextView
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
import androidx.annotation.ColorInt
import androidx.core.view.ViewCompat
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper
object ViewUtil {
val RETRO_MUSIC_ANIM_TIME = 1000
fun createTextColorTransition(v: TextView, @ColorInt startColor: Int, @ColorInt endColor: Int): Animator {
return createColorAnimator(v, "textColor", startColor, endColor)
}
fun setProgressDrawable(progressSlider: SeekBar, newColor: Int) {}
private fun createColorAnimator(target: Any, propertyName: String, @ColorInt startColor: Int, @ColorInt endColor: Int): Animator {
val animator: ObjectAnimator
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
animator = ObjectAnimator.ofArgb(target, propertyName, startColor, endColor)
} else {
animator = ObjectAnimator.ofInt(target, propertyName, startColor, endColor)
animator.setEvaluator(ArgbEvaluator())
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
animator.interpolator = PathInterpolator(0.4f, 0f, 1f, 1f)
}
animator.duration = RETRO_MUSIC_ANIM_TIME.toLong()
return animator
}
fun setStatusBarHeight(context: Context, statusBar: View) {
val lp = statusBar.layoutParams
lp.height = getStatusBarHeight(context)
statusBar.requestLayout()
}
fun getStatusBarHeight(context: Context): Int {
var result = 0
val resourceId = context.resources.getIdentifier("status_bar_height", "dimen", "android")
if (resourceId > 0) {
result = context.resources.getDimensionPixelSize(resourceId)
}
return result
}
fun hitTest(v: View, x: Int, y: Int): Boolean {
val tx = (ViewCompat.getTranslationX(v) + 0.5f).toInt()
val ty = (ViewCompat.getTranslationY(v) + 0.5f).toInt()
val left = v.left + tx
val right = v.right + tx
val top = v.top + ty
val bottom = v.bottom + ty
return x >= left && x <= right && y >= top && y <= bottom
}
fun setUpFastScrollRecyclerViewColor(context: Context,
recyclerView: FastScrollRecyclerView, accentColor: Int) {
recyclerView.setPopupBgColor(accentColor)
recyclerView.setPopupTextColor(
MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(accentColor)))
recyclerView.setThumbColor(accentColor)
recyclerView.setTrackColor(Color.TRANSPARENT)
//recyclerView.setTrackColor(ColorUtil.withAlpha(ATHUtil.resolveColor(context, R.attr.colorControlNormal), 0.12f));
}
fun convertDpToPixel(dp: Float, resources: Resources): Float {
val metrics = resources.displayMetrics
return dp * metrics.density
}
fun createBackgroundColorTransition(colorGradientBackground: View?, lastColor: Int, newColor: Int): Animator {
return null
}
}

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M2.5,4v3h5v12h3L10.5,7h5L15.5,4h-13zM21.5,9h-9v3h3v7h3v-7h3L21.5,9z"/>
</vector>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -1,155 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<code.name.monkey.retromusic.views.IconImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:tint="@color/md_white_1000"
app:srcCompat="@drawable/ic_format_color_fill" />
<code.name.monkey.appthemehelper.common.views.ATEPrimaryTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="@string/base_color_theme"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
android:textColor="@color/md_white_1000" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<code.name.monkey.retromusic.views.IconImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:tint="@color/md_white_1000"
app:srcCompat="@drawable/ic_theme_palette_white_24dp" />
<code.name.monkey.appthemehelper.common.views.ATEPrimaryTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="@string/now_playing_themes"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
android:textColor="@color/md_white_1000" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<code.name.monkey.retromusic.views.IconImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:tint="@color/md_white_1000"
app:srcCompat="@drawable/ic_view_carousel_black_24dp" />
<code.name.monkey.appthemehelper.common.views.ATEPrimaryTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="@string/carousal_effect_on_now_playing_screen"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
android:textColor="@color/md_white_1000" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<code.name.monkey.retromusic.views.IconImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:tint="@color/md_white_1000"
app:srcCompat="@drawable/ic_rounded_corner" />
<code.name.monkey.appthemehelper.common.views.ATEPrimaryTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="@string/window_corner_edges"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
android:textColor="@color/md_white_1000" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<code.name.monkey.retromusic.views.IconImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:tint="@color/md_white_1000"
app:srcCompat="@drawable/ic_favorite_white_24dp" />
<code.name.monkey.appthemehelper.common.views.ATEPrimaryTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="@string/support_development"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
android:textColor="@color/md_white_1000" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.google.android.material.button.MaterialButton
android:id="@+id/restoreButton"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_weight="1"
android:text="@string/restore"
app:strokeColor="@color/md_red_500"
app:strokeWidth="1dp" />
<com.google.android.material.button.MaterialButton
android:id="@+id/purchaseButton"
style="@style/Widget.MaterialComponents.Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_weight="1"
android:text="@string/purchase" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

1
models/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build

34
models/build.gradle Normal file
View File

@ -0,0 +1,34 @@
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

21
models/proguard-rules.pro vendored Normal file
View File

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# 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
# 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

View File

@ -0,0 +1,26 @@
package code.name.monkey.models;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.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 <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("code.name.monkey.models.test", appContext.getPackageName());
}
}

View File

@ -0,0 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="code.name.monkey.models" />

View File

@ -0,0 +1,2 @@
package code.name.monkey.models

View File

@ -0,0 +1,3 @@
<resources>
<string name="app_name">models</string>
</resources>

View File

@ -0,0 +1,17 @@
package code.name.monkey.models;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}