commit
247189f769
327 changed files with 14754 additions and 12580 deletions
|
@ -16,8 +16,8 @@ android {
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
|
|
||||||
applicationId "code.name.monkey.retromusic"
|
applicationId "code.name.monkey.retromusic"
|
||||||
versionCode 10445
|
versionCode 10448
|
||||||
versionName '3.6.100' + "_" + getDate()
|
versionName '3.6.300' + "_" + getDate()
|
||||||
|
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
|
|
||||||
|
@ -167,3 +167,5 @@ dependencies {
|
||||||
implementation 'org.jsoup:jsoup:1.11.1'
|
implementation 'org.jsoup:jsoup:1.11.1'
|
||||||
debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'
|
debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apply from: '../spotless.gradle'
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Lennart Glamann",
|
"name": "Lennart Glamann",
|
||||||
"summary": "Play Store banner and Images",
|
"summary": "Play Store Banner & Images",
|
||||||
"link": "https://t.me/FlixbusLennart",
|
"link": "https://t.me/FlixbusLennart",
|
||||||
"image": "https://i.imgur.com/Q5Nsx1R.jpg"
|
"image": "https://i.imgur.com/Q5Nsx1R.jpg"
|
||||||
},
|
},
|
||||||
|
@ -22,5 +22,11 @@
|
||||||
"summary": "Support Representative & Moderator",
|
"summary": "Support Representative & Moderator",
|
||||||
"link": "https://t.me/MilindGoel15",
|
"link": "https://t.me/MilindGoel15",
|
||||||
"image": "https://i.imgur.com/Bz4De21_d.jpg"
|
"image": "https://i.imgur.com/Bz4De21_d.jpg"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Haythem Gataa",
|
||||||
|
"summary": "App Logo Designer",
|
||||||
|
"link": "https://dribbble.com/haythemgataa",
|
||||||
|
"image": "https://i.imgur.com/g5RuIZq.jpg"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 18 KiB |
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 Hemanth Savarala.
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU General Public License v3
|
* Licensed under the GNU General Public License v3
|
||||||
*
|
*
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
* This is free software: you can redistribute it and/or modify it
|
||||||
* the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package code.name.monkey.retromusic
|
package code.name.monkey.retromusic
|
||||||
|
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 Hemanth Savarala.
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU General Public License v3
|
* Licensed under the GNU General Public License v3
|
||||||
*
|
*
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
* This is free software: you can redistribute it and/or modify it
|
||||||
* the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package code.name.monkey.retromusic
|
package code.name.monkey.retromusic
|
||||||
|
|
||||||
import android.provider.BaseColumns
|
import android.provider.BaseColumns
|
||||||
|
@ -47,9 +47,9 @@ object Constants {
|
||||||
MediaStore.Audio.AudioColumns.ALBUM_ID, // 7
|
MediaStore.Audio.AudioColumns.ALBUM_ID, // 7
|
||||||
MediaStore.Audio.AudioColumns.ALBUM, // 8
|
MediaStore.Audio.AudioColumns.ALBUM, // 8
|
||||||
MediaStore.Audio.AudioColumns.ARTIST_ID, // 9
|
MediaStore.Audio.AudioColumns.ARTIST_ID, // 9
|
||||||
MediaStore.Audio.AudioColumns.ARTIST,// 10
|
MediaStore.Audio.AudioColumns.ARTIST, // 10
|
||||||
MediaStore.Audio.AudioColumns.COMPOSER,// 11
|
MediaStore.Audio.AudioColumns.COMPOSER, // 11
|
||||||
"album_artist"//12
|
"album_artist" // 12
|
||||||
)
|
)
|
||||||
const val NUMBER_OF_TOP_TRACKS = 99
|
const val NUMBER_OF_TOP_TRACKS = 99
|
||||||
}
|
}
|
||||||
|
@ -108,6 +108,7 @@ const val INITIALIZED_BLACKLIST = "initialized_blacklist"
|
||||||
const val ARTIST_SORT_ORDER = "artist_sort_order"
|
const val ARTIST_SORT_ORDER = "artist_sort_order"
|
||||||
const val ARTIST_ALBUM_SORT_ORDER = "artist_album_sort_order"
|
const val ARTIST_ALBUM_SORT_ORDER = "artist_album_sort_order"
|
||||||
const val ALBUM_SORT_ORDER = "album_sort_order"
|
const val ALBUM_SORT_ORDER = "album_sort_order"
|
||||||
|
const val PLAYLIST_SORT_ORDER = "playlist_sort_order"
|
||||||
const val ALBUM_SONG_SORT_ORDER = "album_song_sort_order"
|
const val ALBUM_SONG_SORT_ORDER = "album_song_sort_order"
|
||||||
const val ARTIST_SONG_SORT_ORDER = "artist_song_sort_order"
|
const val ARTIST_SONG_SORT_ORDER = "artist_song_sort_order"
|
||||||
const val ALBUM_GRID_SIZE = "album_grid_size"
|
const val ALBUM_GRID_SIZE = "album_grid_size"
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic
|
package code.name.monkey.retromusic
|
||||||
|
|
||||||
import androidx.annotation.IntDef
|
import androidx.annotation.IntDef
|
||||||
|
|
|
@ -5,39 +5,37 @@ import android.content.ContextWrapper;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.LocaleList;
|
import android.os.LocaleList;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import code.name.monkey.appthemehelper.util.VersionUtils;
|
import code.name.monkey.appthemehelper.util.VersionUtils;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class LanguageContextWrapper extends ContextWrapper {
|
public class LanguageContextWrapper extends ContextWrapper {
|
||||||
|
|
||||||
public LanguageContextWrapper(Context base) {
|
public LanguageContextWrapper(Context base) {
|
||||||
super(base);
|
super(base);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LanguageContextWrapper wrap(Context context, Locale newLocale) {
|
||||||
|
Resources res = context.getResources();
|
||||||
|
Configuration configuration = res.getConfiguration();
|
||||||
|
|
||||||
|
if (VersionUtils.INSTANCE.hasNougatMR()) {
|
||||||
|
configuration.setLocale(newLocale);
|
||||||
|
|
||||||
|
LocaleList localeList = new LocaleList(newLocale);
|
||||||
|
LocaleList.setDefault(localeList);
|
||||||
|
configuration.setLocales(localeList);
|
||||||
|
|
||||||
|
context = context.createConfigurationContext(configuration);
|
||||||
|
|
||||||
|
} else if (VersionUtils.INSTANCE.hasLollipop()) {
|
||||||
|
configuration.setLocale(newLocale);
|
||||||
|
context = context.createConfigurationContext(configuration);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
configuration.locale = newLocale;
|
||||||
|
res.updateConfiguration(configuration, res.getDisplayMetrics());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LanguageContextWrapper wrap(Context context, Locale newLocale) {
|
return new LanguageContextWrapper(context);
|
||||||
Resources res = context.getResources();
|
}
|
||||||
Configuration configuration = res.getConfiguration();
|
|
||||||
|
|
||||||
if (VersionUtils.INSTANCE.hasNougatMR()) {
|
|
||||||
configuration.setLocale(newLocale);
|
|
||||||
|
|
||||||
LocaleList localeList = new LocaleList(newLocale);
|
|
||||||
LocaleList.setDefault(localeList);
|
|
||||||
configuration.setLocales(localeList);
|
|
||||||
|
|
||||||
context = context.createConfigurationContext(configuration);
|
|
||||||
|
|
||||||
} else if (VersionUtils.INSTANCE.hasLollipop()) {
|
|
||||||
configuration.setLocale(newLocale);
|
|
||||||
context = context.createConfigurationContext(configuration);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
configuration.locale = newLocale;
|
|
||||||
res.updateConfiguration(configuration, res.getDisplayMetrics());
|
|
||||||
}
|
|
||||||
|
|
||||||
return new LanguageContextWrapper(context);
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -4,36 +4,32 @@ import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
|
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
|
||||||
public class RetroBottomSheetBehavior<V extends View> extends BottomSheetBehavior<V> {
|
public class RetroBottomSheetBehavior<V extends View> extends BottomSheetBehavior<V> {
|
||||||
|
|
||||||
private static final String TAG = "RetroBottomSheetBehavior";
|
private static final String TAG = "RetroBottomSheetBehavior";
|
||||||
|
|
||||||
private boolean allowDragging = true;
|
private boolean allowDragging = true;
|
||||||
|
|
||||||
public RetroBottomSheetBehavior() {
|
public RetroBottomSheetBehavior() {}
|
||||||
}
|
|
||||||
|
public RetroBottomSheetBehavior(Context context, AttributeSet attrs) {
|
||||||
public RetroBottomSheetBehavior(Context context, AttributeSet attrs) {
|
super(context, attrs);
|
||||||
super(context, attrs);
|
}
|
||||||
}
|
|
||||||
|
public void setAllowDragging(boolean allowDragging) {
|
||||||
public void setAllowDragging(boolean allowDragging) {
|
this.allowDragging = allowDragging;
|
||||||
this.allowDragging = allowDragging;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public boolean onInterceptTouchEvent(
|
||||||
public boolean onInterceptTouchEvent(@NotNull CoordinatorLayout parent, @NotNull V child, @NotNull MotionEvent event) {
|
@NotNull CoordinatorLayout parent, @NotNull V child, @NotNull MotionEvent event) {
|
||||||
if (!allowDragging) {
|
if (!allowDragging) {
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
return super.onInterceptTouchEvent(parent, child, event);
|
|
||||||
}
|
}
|
||||||
|
return super.onInterceptTouchEvent(parent, child, event);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2020 Hemanth Savarala.
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU General Public License v3
|
* Licensed under the GNU General Public License v3
|
||||||
*
|
*
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
* This is free software: you can redistribute it and/or modify it
|
||||||
* the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package code.name.monkey.retromusic.activities
|
package code.name.monkey.retromusic.activities
|
||||||
|
|
||||||
import android.animation.ObjectAnimator
|
import android.animation.ObjectAnimator
|
||||||
|
|
|
@ -18,82 +18,86 @@ import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
import code.name.monkey.appthemehelper.ThemeStore;
|
import code.name.monkey.appthemehelper.ThemeStore;
|
||||||
import code.name.monkey.appthemehelper.util.ATHUtil;
|
import code.name.monkey.appthemehelper.util.ATHUtil;
|
||||||
import code.name.monkey.appthemehelper.util.ColorUtil;
|
import code.name.monkey.appthemehelper.util.ColorUtil;
|
||||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
|
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
|
||||||
import code.name.monkey.retromusic.R;
|
import code.name.monkey.retromusic.R;
|
||||||
import code.name.monkey.retromusic.activities.base.AbsBaseActivity;
|
import code.name.monkey.retromusic.activities.base.AbsBaseActivity;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
/**
|
/** Created by hemanths on 2019-09-27. */
|
||||||
* Created by hemanths on 2019-09-27.
|
|
||||||
*/
|
|
||||||
public class LicenseActivity extends AbsBaseActivity {
|
public class LicenseActivity extends AbsBaseActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
setDrawUnderStatusBar();
|
setDrawUnderStatusBar();
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_license);
|
setContentView(R.layout.activity_license);
|
||||||
setStatusbarColorAuto();
|
setStatusbarColorAuto();
|
||||||
setNavigationbarColorAuto();
|
setNavigationbarColorAuto();
|
||||||
setLightNavigationBar(true);
|
setLightNavigationBar(true);
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
ToolbarContentTintHelper.colorBackButton(toolbar);
|
ToolbarContentTintHelper.colorBackButton(toolbar);
|
||||||
toolbar.setBackgroundColor(ATHUtil.INSTANCE.resolveColor(this, R.attr.colorSurface));
|
toolbar.setBackgroundColor(ATHUtil.INSTANCE.resolveColor(this, R.attr.colorSurface));
|
||||||
WebView webView = findViewById(R.id.license);
|
WebView webView = findViewById(R.id.license);
|
||||||
try {
|
try {
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
InputStream json = getAssets().open("oldindex.html");
|
InputStream json = getAssets().open("oldindex.html");
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(json, StandardCharsets.UTF_8));
|
BufferedReader in = new BufferedReader(new InputStreamReader(json, StandardCharsets.UTF_8));
|
||||||
String str;
|
String str;
|
||||||
while ((str = in.readLine()) != null) {
|
while ((str = in.readLine()) != null) {
|
||||||
buf.append(str);
|
buf.append(str);
|
||||||
}
|
}
|
||||||
in.close();
|
in.close();
|
||||||
|
|
||||||
// Inject color values for WebView body background and links
|
// Inject color values for WebView body background and links
|
||||||
final boolean isDark = ATHUtil.INSTANCE.isWindowBackgroundDark(this);
|
final boolean isDark = ATHUtil.INSTANCE.isWindowBackgroundDark(this);
|
||||||
final String backgroundColor = colorToCSS(ATHUtil.INSTANCE.resolveColor(this, R.attr.colorSurface,
|
final String backgroundColor =
|
||||||
Color.parseColor(isDark ? "#424242" : "#ffffff")));
|
colorToCSS(
|
||||||
final String contentColor = colorToCSS(Color.parseColor(isDark ? "#ffffff" : "#000000"));
|
ATHUtil.INSTANCE.resolveColor(
|
||||||
final String changeLog = buf.toString()
|
this, R.attr.colorSurface, Color.parseColor(isDark ? "#424242" : "#ffffff")));
|
||||||
.replace("{style-placeholder}",
|
final String contentColor = colorToCSS(Color.parseColor(isDark ? "#ffffff" : "#000000"));
|
||||||
String.format("body { background-color: %s; color: %s; }", backgroundColor, contentColor))
|
final String changeLog =
|
||||||
.replace("{link-color}", colorToCSS(ThemeStore.Companion.accentColor(this)))
|
buf.toString()
|
||||||
.replace("{link-color-active}",
|
.replace(
|
||||||
colorToCSS(ColorUtil.INSTANCE.lightenColor(ThemeStore.Companion.accentColor(this))));
|
"{style-placeholder}",
|
||||||
|
String.format(
|
||||||
webView.loadData(changeLog, "text/html", "UTF-8");
|
"body { background-color: %s; color: %s; }", backgroundColor, contentColor))
|
||||||
} catch (Throwable e) {
|
.replace("{link-color}", colorToCSS(ThemeStore.Companion.accentColor(this)))
|
||||||
webView.loadData("<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", "UTF-8");
|
.replace(
|
||||||
}
|
"{link-color-active}",
|
||||||
|
colorToCSS(
|
||||||
|
ColorUtil.INSTANCE.lightenColor(ThemeStore.Companion.accentColor(this))));
|
||||||
|
|
||||||
|
webView.loadData(changeLog, "text/html", "UTF-8");
|
||||||
|
} catch (Throwable e) {
|
||||||
|
webView.loadData(
|
||||||
|
"<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", "UTF-8");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
if (item.getItemId() == android.R.id.home) {
|
if (item.getItemId() == android.R.id.home) {
|
||||||
onBackPressed();
|
onBackPressed();
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
private String colorToCSS(int color) {
|
private String colorToCSS(int color) {
|
||||||
return String.format("rgb(%d, %d, %d)", Color.red(color), Color.green(color),
|
return String.format(
|
||||||
Color.blue(color)); // on API 29, WebView doesn't load with hex colors
|
"rgb(%d, %d, %d)",
|
||||||
}
|
Color.red(color),
|
||||||
|
Color.green(color),
|
||||||
|
Color.blue(color)); // on API 29, WebView doesn't load with hex colors
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.activities
|
package code.name.monkey.retromusic.activities
|
||||||
|
|
||||||
import android.app.KeyguardManager
|
import android.app.KeyguardManager
|
||||||
|
|
|
@ -1,10 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.activities
|
package code.name.monkey.retromusic.activities
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
|
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
import code.name.monkey.appthemehelper.ThemeStore
|
||||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||||
|
@ -23,7 +37,6 @@ import com.google.android.material.transition.platform.MaterialContainerTransfor
|
||||||
import com.google.android.material.transition.platform.MaterialContainerTransformSharedElementCallback
|
import com.google.android.material.transition.platform.MaterialContainerTransformSharedElementCallback
|
||||||
import kotlinx.android.synthetic.main.activity_lyrics.*
|
import kotlinx.android.synthetic.main.activity_lyrics.*
|
||||||
|
|
||||||
|
|
||||||
class LyricsActivity : AbsMusicServiceActivity(), MusicProgressViewUpdateHelper.Callback {
|
class LyricsActivity : AbsMusicServiceActivity(), MusicProgressViewUpdateHelper.Callback {
|
||||||
private lateinit var updateHelper: MusicProgressViewUpdateHelper
|
private lateinit var updateHelper: MusicProgressViewUpdateHelper
|
||||||
|
|
||||||
|
@ -38,25 +51,20 @@ class LyricsActivity : AbsMusicServiceActivity(), MusicProgressViewUpdateHelper.
|
||||||
return baseUrl
|
return baseUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildContainerTransform( ): MaterialContainerTransform {
|
private fun buildContainerTransform(): MaterialContainerTransform {
|
||||||
val transform = MaterialContainerTransform()
|
val transform = MaterialContainerTransform()
|
||||||
transform.setAllContainerColors(
|
transform.setAllContainerColors(
|
||||||
MaterialColors.getColor(findViewById(android.R.id.content), R.attr.colorSurface)
|
MaterialColors.getColor(findViewById(R.id.container), R.attr.colorSurface)
|
||||||
)
|
)
|
||||||
transform.addTarget(android.R.id.content)
|
transform.addTarget(R.id.container)
|
||||||
transform.duration = 300
|
transform.duration = 300
|
||||||
transform.interpolator = FastOutSlowInInterpolator()
|
|
||||||
transform.pathMotion = MaterialArcMotion()
|
|
||||||
return transform
|
return transform
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
findViewById<View>(android.R.id.content).transitionName = "lyrics"
|
|
||||||
setEnterSharedElementCallback(MaterialContainerTransformSharedElementCallback())
|
|
||||||
window.sharedElementEnterTransition = buildContainerTransform( )
|
|
||||||
window.sharedElementReturnTransition = buildContainerTransform( )
|
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_lyrics)
|
setContentView(R.layout.activity_lyrics)
|
||||||
|
ViewCompat.setTransitionName(container, "lyrics")
|
||||||
setStatusbarColorAuto()
|
setStatusbarColorAuto()
|
||||||
setTaskDescriptionColorAuto()
|
setTaskDescriptionColorAuto()
|
||||||
setNavigationbarColorAuto()
|
setNavigationbarColorAuto()
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.activities
|
package code.name.monkey.retromusic.activities
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
@ -9,7 +23,32 @@ import android.provider.MediaStore
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.navigation.ui.NavigationUI
|
import androidx.navigation.ui.NavigationUI
|
||||||
import code.name.monkey.retromusic.*
|
import code.name.monkey.retromusic.ADAPTIVE_COLOR_APP
|
||||||
|
import code.name.monkey.retromusic.ALBUM_COVER_STYLE
|
||||||
|
import code.name.monkey.retromusic.ALBUM_COVER_TRANSFORM
|
||||||
|
import code.name.monkey.retromusic.BANNER_IMAGE_PATH
|
||||||
|
import code.name.monkey.retromusic.BLACK_THEME
|
||||||
|
import code.name.monkey.retromusic.CAROUSEL_EFFECT
|
||||||
|
import code.name.monkey.retromusic.CIRCULAR_ALBUM_ART
|
||||||
|
import code.name.monkey.retromusic.DESATURATED_COLOR
|
||||||
|
import code.name.monkey.retromusic.EXTRA_SONG_INFO
|
||||||
|
import code.name.monkey.retromusic.GENERAL_THEME
|
||||||
|
import code.name.monkey.retromusic.HOME_ARTIST_GRID_STYLE
|
||||||
|
import code.name.monkey.retromusic.KEEP_SCREEN_ON
|
||||||
|
import code.name.monkey.retromusic.LANGUAGE_NAME
|
||||||
|
import code.name.monkey.retromusic.LIBRARY_CATEGORIES
|
||||||
|
import code.name.monkey.retromusic.NOW_PLAYING_SCREEN_ID
|
||||||
|
import code.name.monkey.retromusic.PROFILE_IMAGE_PATH
|
||||||
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.ROUND_CORNERS
|
||||||
|
import code.name.monkey.retromusic.TAB_TEXT_MODE
|
||||||
|
import code.name.monkey.retromusic.TOGGLE_ADD_CONTROLS
|
||||||
|
import code.name.monkey.retromusic.TOGGLE_FULL_SCREEN
|
||||||
|
import code.name.monkey.retromusic.TOGGLE_GENRE
|
||||||
|
import code.name.monkey.retromusic.TOGGLE_HOME_BANNER
|
||||||
|
import code.name.monkey.retromusic.TOGGLE_SEPARATE_LINE
|
||||||
|
import code.name.monkey.retromusic.TOGGLE_VOLUME
|
||||||
|
import code.name.monkey.retromusic.USER_NAME
|
||||||
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
|
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
|
||||||
import code.name.monkey.retromusic.extensions.findNavController
|
import code.name.monkey.retromusic.extensions.findNavController
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
|
@ -47,7 +86,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), OnSharedPreferenceChangeLis
|
||||||
AppRater.appLaunched(this)
|
AppRater.appLaunched(this)
|
||||||
updateTabs()
|
updateTabs()
|
||||||
|
|
||||||
//NavigationUI.setupWithNavController(getBottomNavigationView(), findNavController(R.id.fragment_container))
|
// NavigationUI.setupWithNavController(getBottomNavigationView(), findNavController(R.id.fragment_container))
|
||||||
setupNavigationController()
|
setupNavigationController()
|
||||||
if (!hasPermissions()) {
|
if (!hasPermissions()) {
|
||||||
findNavController(R.id.fragment_container).navigate(R.id.permissionFragment)
|
findNavController(R.id.fragment_container).navigate(R.id.permissionFragment)
|
||||||
|
@ -66,7 +105,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), OnSharedPreferenceChangeLis
|
||||||
navController.graph = navGraph
|
navController.graph = navGraph
|
||||||
NavigationUI.setupWithNavController(getBottomNavigationView(), navController)
|
NavigationUI.setupWithNavController(getBottomNavigationView(), navController)
|
||||||
navController.addOnDestinationChangedListener { _, _, _ ->
|
navController.addOnDestinationChangedListener { _, _, _ ->
|
||||||
//appBarLayout.setExpanded(true, true)
|
// appBarLayout.setExpanded(true, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,11 +195,11 @@ class MainActivity : AbsSlidingMusicPanelActivity(), OnSharedPreferenceChangeLis
|
||||||
setIntent(Intent())
|
setIntent(Intent())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseLongFromIntent(
|
private fun parseLongFromIntent(
|
||||||
intent: Intent, longKey: String,
|
intent: Intent,
|
||||||
|
longKey: String,
|
||||||
stringKey: String
|
stringKey: String
|
||||||
): Long {
|
): Long {
|
||||||
var id = intent.getLongExtra(longKey, -1)
|
var id = intent.getLongExtra(longKey, -1)
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.activities
|
package code.name.monkey.retromusic.activities
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
@ -15,7 +29,6 @@ import code.name.monkey.retromusic.util.RingtoneManager
|
||||||
import kotlinx.android.synthetic.main.activity_permission.*
|
import kotlinx.android.synthetic.main.activity_permission.*
|
||||||
import kotlinx.android.synthetic.main.fragment_library.appNameText
|
import kotlinx.android.synthetic.main.fragment_library.appNameText
|
||||||
|
|
||||||
|
|
||||||
class PermissionActivity : AbsMusicServiceActivity() {
|
class PermissionActivity : AbsMusicServiceActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
@ -39,7 +52,7 @@ class PermissionActivity : AbsMusicServiceActivity() {
|
||||||
}
|
}
|
||||||
finish.accentBackgroundColor()
|
finish.accentBackgroundColor()
|
||||||
finish.setOnClickListener {
|
finish.setOnClickListener {
|
||||||
if (hasPermissions() ) {
|
if (hasPermissions()) {
|
||||||
startActivity(
|
startActivity(
|
||||||
Intent(this, MainActivity::class.java).addFlags(
|
Intent(this, MainActivity::class.java).addFlags(
|
||||||
Intent.FLAG_ACTIVITY_NEW_TASK or
|
Intent.FLAG_ACTIVITY_NEW_TASK or
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.activities
|
package code.name.monkey.retromusic.activities
|
||||||
|
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.activities
|
package code.name.monkey.retromusic.activities
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
@ -17,8 +31,8 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
||||||
import com.anjlab.android.iab.v3.BillingProcessor
|
import com.anjlab.android.iab.v3.BillingProcessor
|
||||||
import com.anjlab.android.iab.v3.TransactionDetails
|
import com.anjlab.android.iab.v3.TransactionDetails
|
||||||
import kotlinx.android.synthetic.main.activity_pro_version.*
|
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
|
import kotlinx.android.synthetic.main.activity_pro_version.*
|
||||||
|
|
||||||
class PurchaseActivity : AbsBaseActivity(), BillingProcessor.IBillingHandler {
|
class PurchaseActivity : AbsBaseActivity(), BillingProcessor.IBillingHandler {
|
||||||
|
|
||||||
|
@ -47,7 +61,6 @@ class PurchaseActivity : AbsBaseActivity(), BillingProcessor.IBillingHandler {
|
||||||
if (restorePurchaseAsyncTask == null || restorePurchaseAsyncTask!!.status != AsyncTask.Status.RUNNING) {
|
if (restorePurchaseAsyncTask == null || restorePurchaseAsyncTask!!.status != AsyncTask.Status.RUNNING) {
|
||||||
restorePurchase()
|
restorePurchase()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
purchaseButton.setOnClickListener {
|
purchaseButton.setOnClickListener {
|
||||||
billingProcessor.purchase(this@PurchaseActivity, PRO_VERSION_PRODUCT_ID)
|
billingProcessor.purchase(this@PurchaseActivity, PRO_VERSION_PRODUCT_ID)
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.activities
|
package code.name.monkey.retromusic.activities
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
@ -49,7 +63,6 @@ class SettingsActivity : AbsBaseActivity(), ColorChooserDialog.ColorCallback {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onColorChooserDismissed(dialog: ColorChooserDialog) {
|
override fun onColorChooserDismissed(dialog: ColorChooserDialog) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2020 Hemanth Savarala.
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU General Public License v3
|
* Licensed under the GNU General Public License v3
|
||||||
*
|
*
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
* This is free software: you can redistribute it and/or modify it
|
||||||
* the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package code.name.monkey.retromusic.activities
|
package code.name.monkey.retromusic.activities
|
||||||
|
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.activities
|
package code.name.monkey.retromusic.activities
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
@ -28,9 +42,9 @@ import code.name.monkey.retromusic.extensions.textColorSecondary
|
||||||
import com.anjlab.android.iab.v3.BillingProcessor
|
import com.anjlab.android.iab.v3.BillingProcessor
|
||||||
import com.anjlab.android.iab.v3.SkuDetails
|
import com.anjlab.android.iab.v3.SkuDetails
|
||||||
import com.anjlab.android.iab.v3.TransactionDetails
|
import com.anjlab.android.iab.v3.TransactionDetails
|
||||||
import kotlinx.android.synthetic.main.activity_donation.*
|
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import kotlinx.android.synthetic.main.activity_donation.*
|
||||||
|
|
||||||
class SupportDevelopmentActivity : AbsBaseActivity(), BillingProcessor.IBillingHandler {
|
class SupportDevelopmentActivity : AbsBaseActivity(), BillingProcessor.IBillingHandler {
|
||||||
|
|
||||||
|
@ -91,7 +105,7 @@ class SupportDevelopmentActivity : AbsBaseActivity(), BillingProcessor.IBillingH
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onProductPurchased(productId: String, details: TransactionDetails?) {
|
override fun onProductPurchased(productId: String, details: TransactionDetails?) {
|
||||||
//loadSkuDetails();
|
// loadSkuDetails();
|
||||||
Toast.makeText(this, R.string.thank_you, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, R.string.thank_you, Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +114,7 @@ class SupportDevelopmentActivity : AbsBaseActivity(), BillingProcessor.IBillingH
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPurchaseHistoryRestored() {
|
override fun onPurchaseHistoryRestored() {
|
||||||
//loadSkuDetails();
|
// loadSkuDetails();
|
||||||
Toast.makeText(this, R.string.restored_previous_purchases, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, R.string.restored_previous_purchases, Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +124,7 @@ class SupportDevelopmentActivity : AbsBaseActivity(), BillingProcessor.IBillingH
|
||||||
}
|
}
|
||||||
if (requestCode == TEZ_REQUEST_CODE) {
|
if (requestCode == TEZ_REQUEST_CODE) {
|
||||||
// Process based on the data in response.
|
// Process based on the data in response.
|
||||||
//Log.d("result", data!!.getStringExtra("Status"))
|
// Log.d("result", data!!.getStringExtra("Status"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +179,8 @@ private class SkuDetailsLoadAsyncTask(supportDevelopmentActivity: SupportDevelop
|
||||||
}
|
}
|
||||||
|
|
||||||
class SkuDetailsAdapter(
|
class SkuDetailsAdapter(
|
||||||
private var donationsDialog: SupportDevelopmentActivity, objects: List<SkuDetails>
|
private var donationsDialog: SupportDevelopmentActivity,
|
||||||
|
objects: List<SkuDetails>
|
||||||
) : RecyclerView.Adapter<SkuDetailsAdapter.ViewHolder>() {
|
) : RecyclerView.Adapter<SkuDetailsAdapter.ViewHolder>() {
|
||||||
|
|
||||||
private var skuDetailsList: List<SkuDetails> = ArrayList()
|
private var skuDetailsList: List<SkuDetails> = ArrayList()
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.activities
|
package code.name.monkey.retromusic.activities
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
@ -27,15 +41,15 @@ import com.bumptech.glide.request.RequestListener
|
||||||
import com.bumptech.glide.request.target.Target
|
import com.bumptech.glide.request.target.Target
|
||||||
import com.github.dhaval2404.imagepicker.ImagePicker
|
import com.github.dhaval2404.imagepicker.ImagePicker
|
||||||
import com.github.dhaval2404.imagepicker.constant.ImageProvider
|
import com.github.dhaval2404.imagepicker.constant.ImageProvider
|
||||||
|
import java.io.BufferedOutputStream
|
||||||
|
import java.io.File
|
||||||
|
import java.io.FileOutputStream
|
||||||
|
import java.io.IOException
|
||||||
import kotlinx.android.synthetic.main.activity_user_info.*
|
import kotlinx.android.synthetic.main.activity_user_info.*
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import java.io.BufferedOutputStream
|
|
||||||
import java.io.File
|
|
||||||
import java.io.FileOutputStream
|
|
||||||
import java.io.IOException
|
|
||||||
|
|
||||||
class UserInfoActivity : AbsBaseActivity() {
|
class UserInfoActivity : AbsBaseActivity() {
|
||||||
|
|
||||||
|
@ -114,7 +128,6 @@ class UserInfoActivity : AbsBaseActivity() {
|
||||||
.start(PICK_IMAGE_REQUEST)
|
.start(PICK_IMAGE_REQUEST)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
super.onActivityResult(requestCode, resultCode, data)
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
if (resultCode == Activity.RESULT_OK && requestCode == PICK_IMAGE_REQUEST) {
|
if (resultCode == Activity.RESULT_OK && requestCode == PICK_IMAGE_REQUEST) {
|
||||||
|
@ -209,7 +222,6 @@ class UserInfoActivity : AbsBaseActivity() {
|
||||||
.into(userImage)
|
.into(userImage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val PICK_IMAGE_REQUEST = 9002
|
private const val PICK_IMAGE_REQUEST = 9002
|
||||||
private const val PICK_BANNER_REQUEST = 9004
|
private const val PICK_BANNER_REQUEST = 9004
|
||||||
|
|
|
@ -1,23 +1,14 @@
|
||||||
package code.name.monkey.retromusic.activities;
|
package code.name.monkey.retromusic.activities;
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import code.name.monkey.appthemehelper.ThemeStore;
|
import code.name.monkey.appthemehelper.ThemeStore;
|
||||||
import code.name.monkey.appthemehelper.util.ATHUtil;
|
import code.name.monkey.appthemehelper.util.ATHUtil;
|
||||||
import code.name.monkey.appthemehelper.util.ColorUtil;
|
import code.name.monkey.appthemehelper.util.ColorUtil;
|
||||||
|
@ -26,65 +17,95 @@ import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
|
||||||
import code.name.monkey.retromusic.R;
|
import code.name.monkey.retromusic.R;
|
||||||
import code.name.monkey.retromusic.activities.base.AbsBaseActivity;
|
import code.name.monkey.retromusic.activities.base.AbsBaseActivity;
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil;
|
import code.name.monkey.retromusic.util.PreferenceUtil;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class WhatsNewActivity extends AbsBaseActivity {
|
public class WhatsNewActivity extends AbsBaseActivity {
|
||||||
|
|
||||||
private static String colorToCSS(int color) {
|
private static String colorToCSS(int color) {
|
||||||
return String.format(Locale.getDefault(), "rgba(%d, %d, %d, %d)", Color.red(color), Color.green(color),
|
return String.format(
|
||||||
Color.blue(color), Color.alpha(color)); // on API 29, WebView doesn't load with hex colors
|
Locale.getDefault(),
|
||||||
|
"rgba(%d, %d, %d, %d)",
|
||||||
|
Color.red(color),
|
||||||
|
Color.green(color),
|
||||||
|
Color.blue(color),
|
||||||
|
Color.alpha(color)); // on API 29, WebView doesn't load with hex colors
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setChangelogRead(@NonNull Context context) {
|
||||||
|
try {
|
||||||
|
PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
|
||||||
|
int currentVersion = pInfo.versionCode;
|
||||||
|
PreferenceUtil.INSTANCE.setLastVersion(currentVersion);
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void setChangelogRead(@NonNull Context context) {
|
@Override
|
||||||
try {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
|
setDrawUnderStatusBar();
|
||||||
int currentVersion = pInfo.versionCode;
|
super.onCreate(savedInstanceState);
|
||||||
PreferenceUtil.INSTANCE.setLastVersion(currentVersion);
|
setContentView(R.layout.activity_whats_new);
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
setStatusbarColorAuto();
|
||||||
e.printStackTrace();
|
setNavigationbarColorAuto();
|
||||||
}
|
setTaskDescriptionColorAuto();
|
||||||
}
|
|
||||||
|
WebView webView = findViewById(R.id.webView);
|
||||||
@Override
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
toolbar.setBackgroundColor(ATHUtil.INSTANCE.resolveColor(this, R.attr.colorSurface));
|
||||||
setDrawUnderStatusBar();
|
toolbar.setNavigationOnClickListener(v -> onBackPressed());
|
||||||
super.onCreate(savedInstanceState);
|
ToolbarContentTintHelper.colorBackButton(toolbar);
|
||||||
setContentView(R.layout.activity_whats_new);
|
|
||||||
setStatusbarColorAuto();
|
try {
|
||||||
setNavigationbarColorAuto();
|
StringBuilder buf = new StringBuilder();
|
||||||
setTaskDescriptionColorAuto();
|
InputStream json = getAssets().open("retro-changelog.html");
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(json, StandardCharsets.UTF_8));
|
||||||
WebView webView = findViewById(R.id.webView);
|
String str;
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
while ((str = in.readLine()) != null) {
|
||||||
toolbar.setBackgroundColor(ATHUtil.INSTANCE.resolveColor(this, R.attr.colorSurface));
|
buf.append(str);
|
||||||
toolbar.setNavigationOnClickListener(v -> onBackPressed());
|
}
|
||||||
ToolbarContentTintHelper.colorBackButton(toolbar);
|
in.close();
|
||||||
|
|
||||||
try {
|
// Inject color values for WebView body background and links
|
||||||
StringBuilder buf = new StringBuilder();
|
final boolean isDark = ATHUtil.INSTANCE.isWindowBackgroundDark(this);
|
||||||
InputStream json = getAssets().open("retro-changelog.html");
|
final int accentColor = ThemeStore.Companion.accentColor(this);
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(json, StandardCharsets.UTF_8));
|
final String backgroundColor =
|
||||||
String str;
|
colorToCSS(
|
||||||
while ((str = in.readLine()) != null) {
|
ATHUtil.INSTANCE.resolveColor(
|
||||||
buf.append(str);
|
this, R.attr.colorSurface, Color.parseColor(isDark ? "#424242" : "#ffffff")));
|
||||||
}
|
final String contentColor = colorToCSS(Color.parseColor(isDark ? "#ffffff" : "#000000"));
|
||||||
in.close();
|
final String textColor = colorToCSS(Color.parseColor(isDark ? "#60FFFFFF" : "#80000000"));
|
||||||
|
final String accentColorString = colorToCSS(ThemeStore.Companion.accentColor(this));
|
||||||
// Inject color values for WebView body background and links
|
final String accentTextColor =
|
||||||
final boolean isDark = ATHUtil.INSTANCE.isWindowBackgroundDark(this);
|
colorToCSS(
|
||||||
final int accentColor = ThemeStore.Companion.accentColor(this);
|
MaterialValueHelper.getPrimaryTextColor(
|
||||||
final String backgroundColor = colorToCSS(ATHUtil.INSTANCE.resolveColor(this, R.attr.colorSurface, Color.parseColor(isDark ? "#424242" : "#ffffff")));
|
this, ColorUtil.INSTANCE.isColorLight(accentColor)));
|
||||||
final String contentColor = colorToCSS(Color.parseColor(isDark ? "#ffffff" : "#000000"));
|
final String changeLog =
|
||||||
final String textColor = colorToCSS(Color.parseColor(isDark ? "#60FFFFFF" : "#80000000"));
|
buf.toString()
|
||||||
final String accentColorString = colorToCSS(ThemeStore.Companion.accentColor(this));
|
.replace(
|
||||||
final String accentTextColor = colorToCSS(MaterialValueHelper.getPrimaryTextColor(this, ColorUtil.INSTANCE.isColorLight(accentColor)));
|
"{style-placeholder}",
|
||||||
final String changeLog = buf.toString()
|
String.format(
|
||||||
.replace("{style-placeholder}", String.format("body { background-color: %s; color: %s; } li {color: %s;} .colorHeader {background-color: %s; color: %s;} .tag {color: %s;}", backgroundColor, contentColor, textColor, accentColorString, accentTextColor, accentColorString))
|
"body { background-color: %s; color: %s; } li {color: %s;} .colorHeader {background-color: %s; color: %s;} .tag {color: %s;}",
|
||||||
.replace("{link-color}", colorToCSS(ThemeStore.Companion.accentColor(this)))
|
backgroundColor,
|
||||||
.replace("{link-color-active}", colorToCSS(ColorUtil.INSTANCE.lightenColor(ThemeStore.Companion.accentColor(this))));
|
contentColor,
|
||||||
webView.loadData(changeLog, "text/html", "UTF-8");
|
textColor,
|
||||||
} catch (Throwable e) {
|
accentColorString,
|
||||||
webView.loadData("<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", "UTF-8");
|
accentTextColor,
|
||||||
}
|
accentColorString))
|
||||||
setChangelogRead(this);
|
.replace("{link-color}", colorToCSS(ThemeStore.Companion.accentColor(this)))
|
||||||
|
.replace(
|
||||||
|
"{link-color-active}",
|
||||||
|
colorToCSS(
|
||||||
|
ColorUtil.INSTANCE.lightenColor(ThemeStore.Companion.accentColor(this))));
|
||||||
|
webView.loadData(changeLog, "text/html", "UTF-8");
|
||||||
|
} catch (Throwable e) {
|
||||||
|
webView.loadData(
|
||||||
|
"<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", "UTF-8");
|
||||||
}
|
}
|
||||||
|
setChangelogRead(this);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.activities.base
|
package code.name.monkey.retromusic.activities.base
|
||||||
|
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
|
@ -46,7 +60,7 @@ abstract class AbsBaseActivity : AbsThemeActivity() {
|
||||||
override fun onPostCreate(savedInstanceState: Bundle?) {
|
override fun onPostCreate(savedInstanceState: Bundle?) {
|
||||||
super.onPostCreate(savedInstanceState)
|
super.onPostCreate(savedInstanceState)
|
||||||
if (!hasPermissions()) {
|
if (!hasPermissions()) {
|
||||||
//requestPermissions()
|
// requestPermissions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +121,7 @@ abstract class AbsBaseActivity : AbsThemeActivity() {
|
||||||
this@AbsBaseActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE
|
this@AbsBaseActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
//User has deny from permission dialog
|
// User has deny from permission dialog
|
||||||
Snackbar.make(
|
Snackbar.make(
|
||||||
snackBarContainer,
|
snackBarContainer,
|
||||||
permissionDeniedMessage!!,
|
permissionDeniedMessage!!,
|
||||||
|
|
|
@ -1,7 +1,26 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.activities.base
|
package code.name.monkey.retromusic.activities.base
|
||||||
|
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
import android.content.*
|
import android.content.BroadcastReceiver
|
||||||
|
import android.content.ComponentName
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.IntentFilter
|
||||||
|
import android.content.ServiceConnection
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
@ -11,11 +30,11 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import code.name.monkey.retromusic.interfaces.IMusicServiceEventListener
|
import code.name.monkey.retromusic.interfaces.IMusicServiceEventListener
|
||||||
import code.name.monkey.retromusic.repository.RealRepository
|
import code.name.monkey.retromusic.repository.RealRepository
|
||||||
import code.name.monkey.retromusic.service.MusicService.*
|
import code.name.monkey.retromusic.service.MusicService.*
|
||||||
|
import java.lang.ref.WeakReference
|
||||||
|
import java.util.*
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.koin.android.ext.android.inject
|
import org.koin.android.ext.android.inject
|
||||||
import java.lang.ref.WeakReference
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
abstract class AbsMusicServiceActivity : AbsBaseActivity(), IMusicServiceEventListener {
|
abstract class AbsMusicServiceActivity : AbsBaseActivity(), IMusicServiceEventListener {
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.activities.base
|
package code.name.monkey.retromusic.activities.base
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
|
@ -15,7 +29,12 @@ import code.name.monkey.appthemehelper.util.ATHUtil
|
||||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.RetroBottomSheetBehavior
|
import code.name.monkey.retromusic.RetroBottomSheetBehavior
|
||||||
import code.name.monkey.retromusic.extensions.*
|
import code.name.monkey.retromusic.extensions.dip
|
||||||
|
import code.name.monkey.retromusic.extensions.hide
|
||||||
|
import code.name.monkey.retromusic.extensions.peekHeightAnimate
|
||||||
|
import code.name.monkey.retromusic.extensions.show
|
||||||
|
import code.name.monkey.retromusic.extensions.translateXAnimate
|
||||||
|
import code.name.monkey.retromusic.extensions.whichFragment
|
||||||
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
||||||
import code.name.monkey.retromusic.fragments.MiniPlayerFragment
|
import code.name.monkey.retromusic.fragments.MiniPlayerFragment
|
||||||
import code.name.monkey.retromusic.fragments.NowPlayingScreen
|
import code.name.monkey.retromusic.fragments.NowPlayingScreen
|
||||||
|
@ -40,9 +59,9 @@ import code.name.monkey.retromusic.fragments.player.simple.SimplePlayerFragment
|
||||||
import code.name.monkey.retromusic.fragments.player.tiny.TinyPlayerFragment
|
import code.name.monkey.retromusic.fragments.player.tiny.TinyPlayerFragment
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import code.name.monkey.retromusic.model.CategoryInfo
|
import code.name.monkey.retromusic.model.CategoryInfo
|
||||||
import code.name.monkey.retromusic.state.NowPlayingPanelState.*
|
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import code.name.monkey.retromusic.views.BottomNavigationBarTinted
|
import code.name.monkey.retromusic.views.BottomNavigationBarTinted
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior.*
|
import com.google.android.material.bottomsheet.BottomSheetBehavior.*
|
||||||
import kotlinx.android.synthetic.main.sliding_music_panel_layout.*
|
import kotlinx.android.synthetic.main.sliding_music_panel_layout.*
|
||||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||||
|
@ -98,13 +117,13 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
chooseFragmentForTheme()
|
chooseFragmentForTheme()
|
||||||
setupSlidingUpPanel()
|
setupSlidingUpPanel()
|
||||||
setupBottomSheet()
|
setupBottomSheet()
|
||||||
updatePanelState()
|
|
||||||
updateColor()
|
updateColor()
|
||||||
|
|
||||||
val themeColor = ATHUtil.resolveColor(this, android.R.attr.windowBackground, Color.GRAY)
|
val themeColor = ATHUtil.resolveColor(this, android.R.attr.windowBackground, Color.GRAY)
|
||||||
dimBackground.setBackgroundColor(ColorUtil.withAlpha(themeColor, 0.5f))
|
dimBackground.setBackgroundColor(ColorUtil.withAlpha(themeColor, 0.5f))
|
||||||
dimBackground.setOnClickListener {
|
dimBackground.setOnClickListener {
|
||||||
libraryViewModel.setPanelState(COLLAPSED_WITH)
|
println("dimBackground")
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,6 +137,9 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
if (nowPlayingScreen != PreferenceUtil.nowPlayingScreen) {
|
if (nowPlayingScreen != PreferenceUtil.nowPlayingScreen) {
|
||||||
postRecreate()
|
postRecreate()
|
||||||
}
|
}
|
||||||
|
if (bottomSheetBehavior.state == BottomSheetBehavior.STATE_EXPANDED) {
|
||||||
|
setMiniPlayerAlphaProgress(1f)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
|
@ -141,6 +163,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
|
|
||||||
fun expandPanel() {
|
fun expandPanel() {
|
||||||
bottomSheetBehavior.state = STATE_EXPANDED
|
bottomSheetBehavior.state = STATE_EXPANDED
|
||||||
|
setMiniPlayerAlphaProgress(1f)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setMiniPlayerAlphaProgress(progress: Float) {
|
private fun setMiniPlayerAlphaProgress(progress: Float) {
|
||||||
|
@ -148,7 +171,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
miniPlayerFragment?.view?.alpha = alpha
|
miniPlayerFragment?.view?.alpha = alpha
|
||||||
miniPlayerFragment?.view?.visibility = if (alpha == 0f) View.GONE else View.VISIBLE
|
miniPlayerFragment?.view?.visibility = if (alpha == 0f) View.GONE else View.VISIBLE
|
||||||
bottomNavigationView.translationY = progress * 500
|
bottomNavigationView.translationY = progress * 500
|
||||||
//bottomNavigationView.alpha = alpha
|
// bottomNavigationView.alpha = alpha
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun onPanelCollapsed() {
|
open fun onPanelCollapsed() {
|
||||||
|
@ -177,7 +200,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
STATE_EXPANDED -> onPanelExpanded()
|
STATE_EXPANDED -> onPanelExpanded()
|
||||||
STATE_COLLAPSED -> onPanelCollapsed()
|
STATE_COLLAPSED -> onPanelCollapsed()
|
||||||
else -> {
|
else -> {
|
||||||
//playerFragment!!.onHide()
|
// playerFragment!!.onHide()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,11 +218,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
ViewTreeObserver.OnGlobalLayoutListener {
|
ViewTreeObserver.OnGlobalLayoutListener {
|
||||||
override fun onGlobalLayout() {
|
override fun onGlobalLayout() {
|
||||||
slidingPanel.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
slidingPanel.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
||||||
if (bottomNavigationView.isVisible) {
|
hideBottomBar(false)
|
||||||
libraryViewModel.setPanelState(COLLAPSED_WITH)
|
|
||||||
} else {
|
|
||||||
libraryViewModel.setPanelState(COLLAPSED_WITHOUT)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} // don't call hideBottomBar(true) here as it causes a bug with the SlidingUpPanelLayout
|
} // don't call hideBottomBar(true) here as it causes a bug with the SlidingUpPanelLayout
|
||||||
|
@ -207,15 +226,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
|
|
||||||
override fun onQueueChanged() {
|
override fun onQueueChanged() {
|
||||||
super.onQueueChanged()
|
super.onQueueChanged()
|
||||||
if (MusicPlayerRemote.playingQueue.isEmpty()) {
|
hideBottomBar(MusicPlayerRemote.playingQueue.isEmpty())
|
||||||
libraryViewModel.setPanelState(HIDE)
|
|
||||||
} else {
|
|
||||||
if (bottomNavigationView.isVisible) {
|
|
||||||
libraryViewModel.setPanelState(COLLAPSED_WITH)
|
|
||||||
} else {
|
|
||||||
libraryViewModel.setPanelState(COLLAPSED_WITHOUT)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
|
@ -318,53 +329,35 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updatePanelState() {
|
fun setBottomBarVisibility(visible: Int) {
|
||||||
libraryViewModel.panelState.observe(this, { state ->
|
bottomNavigationView.visibility = visible
|
||||||
val isQueueEmpty = MusicPlayerRemote.playingQueue.isEmpty()
|
hideBottomBar(MusicPlayerRemote.playingQueue.isEmpty())
|
||||||
when (state) {
|
}
|
||||||
EXPAND -> {
|
|
||||||
println("EXPAND")
|
private fun hideBottomBar(hide: Boolean) {
|
||||||
expandPanel()
|
val heightOfBar = dip(R.dimen.mini_player_height)
|
||||||
}
|
val heightOfBarWithTabs = dip(R.dimen.mini_player_height_expanded)
|
||||||
HIDE -> {
|
val isVisible = bottomNavigationView.isVisible
|
||||||
println("HIDE")
|
if (hide) {
|
||||||
|
bottomSheetBehavior.isHideable = true
|
||||||
|
bottomSheetBehavior.peekHeight = 0
|
||||||
|
ViewCompat.setElevation(slidingPanel, 0f)
|
||||||
|
ViewCompat.setElevation(bottomNavigationView, 10f)
|
||||||
|
collapsePanel()
|
||||||
|
} else {
|
||||||
|
if (MusicPlayerRemote.playingQueue.isNotEmpty()) {
|
||||||
|
bottomSheetBehavior.isHideable = false
|
||||||
|
if (isVisible) {
|
||||||
|
bottomSheetBehavior.peekHeightAnimate(heightOfBarWithTabs)
|
||||||
bottomNavigationView.translateXAnimate(0f)
|
bottomNavigationView.translateXAnimate(0f)
|
||||||
bottomSheetBehavior.isHideable = true
|
} else {
|
||||||
bottomSheetBehavior.peekHeightAnimate(0)
|
bottomSheetBehavior.peekHeightAnimate(heightOfBar)
|
||||||
bottomSheetBehavior.state = STATE_COLLAPSED
|
bottomNavigationView.translateXAnimate(500f)
|
||||||
ViewCompat.setElevation(slidingPanel, 0f)
|
|
||||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
|
||||||
}
|
|
||||||
COLLAPSED_WITH -> {
|
|
||||||
println("COLLAPSED_WITH")
|
|
||||||
val heightOfBar = bottomNavigationView.height
|
|
||||||
val height = if (isQueueEmpty) 0 else (heightOfBar * 2) - 24
|
|
||||||
ViewCompat.setElevation(bottomNavigationView, 20f)
|
|
||||||
ViewCompat.setElevation(slidingPanel, 20f)
|
|
||||||
bottomSheetBehavior.isHideable = false
|
|
||||||
bottomSheetBehavior.peekHeightAnimate(height)
|
|
||||||
bottomNavigationView.translateXAnimate(0f)
|
|
||||||
}
|
|
||||||
COLLAPSED_WITHOUT -> {
|
|
||||||
println("COLLAPSED_WITHOUT")
|
|
||||||
val heightOfBar = bottomNavigationView.height
|
|
||||||
val height = if (isQueueEmpty) 0 else heightOfBar - 24
|
|
||||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
|
||||||
ViewCompat.setElevation(slidingPanel, 10f)
|
|
||||||
bottomSheetBehavior.isHideable = false
|
|
||||||
bottomSheetBehavior.peekHeightAnimate(height)
|
|
||||||
bottomNavigationView.translateXAnimate(150f)
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
println("else")
|
|
||||||
bottomSheetBehavior.isHideable = true
|
|
||||||
bottomSheetBehavior.peekHeight = 0
|
|
||||||
collapsePanel()
|
|
||||||
ViewCompat.setElevation(slidingPanel, 0f)
|
|
||||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
|
||||||
}
|
}
|
||||||
|
ViewCompat.setElevation(slidingPanel, 10f)
|
||||||
|
ViewCompat.setElevation(bottomNavigationView, 10f)
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun chooseFragmentForTheme() {
|
private fun chooseFragmentForTheme() {
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.activities.base
|
package code.name.monkey.retromusic.activities.base
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
@ -37,7 +51,6 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
|
||||||
MaterialDialogsUtil.updateMaterialDialogsThemeSingleton(this)
|
MaterialDialogsUtil.updateMaterialDialogsThemeSingleton(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun updateTheme() {
|
private fun updateTheme() {
|
||||||
setTheme(ThemeManager.getThemeResValue(this))
|
setTheme(ThemeManager.getThemeResValue(this))
|
||||||
setDefaultNightMode(ThemeManager.getNightMode(this))
|
setDefaultNightMode(ThemeManager.getNightMode(this))
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.activities.bugreport
|
package code.name.monkey.retromusic.activities.bugreport
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
@ -31,6 +45,7 @@ import code.name.monkey.retromusic.misc.DialogAsyncTask
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
import com.google.android.material.textfield.TextInputLayout
|
import com.google.android.material.textfield.TextInputLayout
|
||||||
|
import java.io.IOException
|
||||||
import kotlinx.android.synthetic.main.activity_bug_report.*
|
import kotlinx.android.synthetic.main.activity_bug_report.*
|
||||||
import kotlinx.android.synthetic.main.bug_report_card_device_info.*
|
import kotlinx.android.synthetic.main.bug_report_card_device_info.*
|
||||||
import kotlinx.android.synthetic.main.bug_report_card_report.*
|
import kotlinx.android.synthetic.main.bug_report_card_report.*
|
||||||
|
@ -38,7 +53,6 @@ import org.eclipse.egit.github.core.Issue
|
||||||
import org.eclipse.egit.github.core.client.GitHubClient
|
import org.eclipse.egit.github.core.client.GitHubClient
|
||||||
import org.eclipse.egit.github.core.client.RequestException
|
import org.eclipse.egit.github.core.client.RequestException
|
||||||
import org.eclipse.egit.github.core.service.IssueService
|
import org.eclipse.egit.github.core.service.IssueService
|
||||||
import java.io.IOException
|
|
||||||
|
|
||||||
private const val RESULT_SUCCESS = "RESULT_OK"
|
private const val RESULT_SUCCESS = "RESULT_OK"
|
||||||
private const val RESULT_BAD_CREDENTIALS = "RESULT_BAD_CREDENTIALS"
|
private const val RESULT_BAD_CREDENTIALS = "RESULT_BAD_CREDENTIALS"
|
||||||
|
@ -306,7 +320,6 @@ open class BugReportActivity : AbsThemeActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun report(
|
fun report(
|
||||||
|
|
|
@ -5,126 +5,196 @@ import android.content.Context;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
|
||||||
import androidx.annotation.IntRange;
|
import androidx.annotation.IntRange;
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtil;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil;
|
|
||||||
|
|
||||||
public class DeviceInfo {
|
public class DeviceInfo {
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private final String[] abis = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ?
|
private final String[] abis =
|
||||||
Build.SUPPORTED_ABIS : new String[]{Build.CPU_ABI, Build.CPU_ABI2};
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
|
||||||
|
? Build.SUPPORTED_ABIS
|
||||||
|
: new String[] {Build.CPU_ABI, Build.CPU_ABI2};
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
private final String[] abis32Bits = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ?
|
private final String[] abis32Bits =
|
||||||
Build.SUPPORTED_32_BIT_ABIS : null;
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? Build.SUPPORTED_32_BIT_ABIS : null;
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
private final String[] abis64Bits = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ?
|
private final String[] abis64Bits =
|
||||||
Build.SUPPORTED_64_BIT_ABIS : null;
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? Build.SUPPORTED_64_BIT_ABIS : null;
|
||||||
|
|
||||||
private final String baseTheme;
|
private final String baseTheme;
|
||||||
|
|
||||||
private final String brand = Build.BRAND;
|
private final String brand = Build.BRAND;
|
||||||
|
|
||||||
private final String buildID = Build.DISPLAY;
|
private final String buildID = Build.DISPLAY;
|
||||||
|
|
||||||
private final String buildVersion = Build.VERSION.INCREMENTAL;
|
private final String buildVersion = Build.VERSION.INCREMENTAL;
|
||||||
|
|
||||||
private final String device = Build.DEVICE;
|
private final String device = Build.DEVICE;
|
||||||
|
|
||||||
private final String hardware = Build.HARDWARE;
|
private final String hardware = Build.HARDWARE;
|
||||||
|
|
||||||
private final boolean isAdaptive;
|
private final boolean isAdaptive;
|
||||||
|
|
||||||
private final String manufacturer = Build.MANUFACTURER;
|
private final String manufacturer = Build.MANUFACTURER;
|
||||||
|
|
||||||
private final String model = Build.MODEL;
|
private final String model = Build.MODEL;
|
||||||
|
|
||||||
private final String nowPlayingTheme;
|
private final String nowPlayingTheme;
|
||||||
|
|
||||||
private final String product = Build.PRODUCT;
|
private final String product = Build.PRODUCT;
|
||||||
|
|
||||||
private final String releaseVersion = Build.VERSION.RELEASE;
|
private final String releaseVersion = Build.VERSION.RELEASE;
|
||||||
|
|
||||||
@IntRange(from = 0)
|
@IntRange(from = 0)
|
||||||
private final int sdkVersion = Build.VERSION.SDK_INT;
|
private final int sdkVersion = Build.VERSION.SDK_INT;
|
||||||
|
|
||||||
private final int versionCode;
|
private final int versionCode;
|
||||||
|
|
||||||
private final String versionName;
|
private final String versionName;
|
||||||
private final String selectedLang;
|
private final String selectedLang;
|
||||||
|
|
||||||
public DeviceInfo(Context context) {
|
public DeviceInfo(Context context) {
|
||||||
PackageInfo packageInfo;
|
PackageInfo packageInfo;
|
||||||
try {
|
try {
|
||||||
packageInfo = context.getPackageManager()
|
packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
|
||||||
.getPackageInfo(context.getPackageName(), 0);
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
packageInfo = null;
|
||||||
packageInfo = null;
|
|
||||||
}
|
|
||||||
if (packageInfo != null) {
|
|
||||||
versionCode = packageInfo.versionCode;
|
|
||||||
versionName = packageInfo.versionName;
|
|
||||||
} else {
|
|
||||||
versionCode = -1;
|
|
||||||
versionName = null;
|
|
||||||
}
|
|
||||||
baseTheme = PreferenceUtil.INSTANCE.getBaseTheme();
|
|
||||||
nowPlayingTheme = context.getString(PreferenceUtil.INSTANCE.getNowPlayingScreen().getTitleRes());
|
|
||||||
isAdaptive = PreferenceUtil.INSTANCE.isAdaptiveColor();
|
|
||||||
selectedLang = PreferenceUtil.INSTANCE.getLanguageCode();
|
|
||||||
}
|
}
|
||||||
|
if (packageInfo != null) {
|
||||||
public String toMarkdown() {
|
versionCode = packageInfo.versionCode;
|
||||||
return "Device info:\n"
|
versionName = packageInfo.versionName;
|
||||||
+ "---\n"
|
} else {
|
||||||
+ "<table>\n"
|
versionCode = -1;
|
||||||
+ "<tr><td><b>App version</b></td><td>" + versionName + "</td></tr>\n"
|
versionName = null;
|
||||||
+ "<tr><td>App version code</td><td>" + versionCode + "</td></tr>\n"
|
|
||||||
+ "<tr><td>Android build version</td><td>" + buildVersion + "</td></tr>\n"
|
|
||||||
+ "<tr><td>Android release version</td><td>" + releaseVersion + "</td></tr>\n"
|
|
||||||
+ "<tr><td>Android SDK version</td><td>" + sdkVersion + "</td></tr>\n"
|
|
||||||
+ "<tr><td>Android build ID</td><td>" + buildID + "</td></tr>\n"
|
|
||||||
+ "<tr><td>Device brand</td><td>" + brand + "</td></tr>\n"
|
|
||||||
+ "<tr><td>Device manufacturer</td><td>" + manufacturer + "</td></tr>\n"
|
|
||||||
+ "<tr><td>Device name</td><td>" + device + "</td></tr>\n"
|
|
||||||
+ "<tr><td>Device model</td><td>" + model + "</td></tr>\n"
|
|
||||||
+ "<tr><td>Device product name</td><td>" + product + "</td></tr>\n"
|
|
||||||
+ "<tr><td>Device hardware name</td><td>" + hardware + "</td></tr>\n"
|
|
||||||
+ "<tr><td>ABIs</td><td>" + Arrays.toString(abis) + "</td></tr>\n"
|
|
||||||
+ "<tr><td>ABIs (32bit)</td><td>" + Arrays.toString(abis32Bits) + "</td></tr>\n"
|
|
||||||
+ "<tr><td>ABIs (64bit)</td><td>" + Arrays.toString(abis64Bits) + "</td></tr>\n"
|
|
||||||
+ "<tr><td>Language</td><td>" + selectedLang + "</td></tr>\n"
|
|
||||||
+ "</table>\n";
|
|
||||||
}
|
}
|
||||||
|
baseTheme = PreferenceUtil.INSTANCE.getBaseTheme();
|
||||||
|
nowPlayingTheme =
|
||||||
|
context.getString(PreferenceUtil.INSTANCE.getNowPlayingScreen().getTitleRes());
|
||||||
|
isAdaptive = PreferenceUtil.INSTANCE.isAdaptiveColor();
|
||||||
|
selectedLang = PreferenceUtil.INSTANCE.getLanguageCode();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public String toMarkdown() {
|
||||||
public String toString() {
|
return "Device info:\n"
|
||||||
return "App version: " + versionName + "\n"
|
+ "---\n"
|
||||||
+ "App version code: " + versionCode + "\n"
|
+ "<table>\n"
|
||||||
+ "Android build version: " + buildVersion + "\n"
|
+ "<tr><td><b>App version</b></td><td>"
|
||||||
+ "Android release version: " + releaseVersion + "\n"
|
+ versionName
|
||||||
+ "Android SDK version: " + sdkVersion + "\n"
|
+ "</td></tr>\n"
|
||||||
+ "Android build ID: " + buildID + "\n"
|
+ "<tr><td>App version code</td><td>"
|
||||||
+ "Device brand: " + brand + "\n"
|
+ versionCode
|
||||||
+ "Device manufacturer: " + manufacturer + "\n"
|
+ "</td></tr>\n"
|
||||||
+ "Device name: " + device + "\n"
|
+ "<tr><td>Android build version</td><td>"
|
||||||
+ "Device model: " + model + "\n"
|
+ buildVersion
|
||||||
+ "Device product name: " + product + "\n"
|
+ "</td></tr>\n"
|
||||||
+ "Device hardware name: " + hardware + "\n"
|
+ "<tr><td>Android release version</td><td>"
|
||||||
+ "ABIs: " + Arrays.toString(abis) + "\n"
|
+ releaseVersion
|
||||||
+ "ABIs (32bit): " + Arrays.toString(abis32Bits) + "\n"
|
+ "</td></tr>\n"
|
||||||
+ "ABIs (64bit): " + Arrays.toString(abis64Bits) + "\n"
|
+ "<tr><td>Android SDK version</td><td>"
|
||||||
+ "Base theme: " + baseTheme + "\n"
|
+ sdkVersion
|
||||||
+ "Now playing theme: " + nowPlayingTheme + "\n"
|
+ "</td></tr>\n"
|
||||||
+ "Adaptive: " + isAdaptive + "\n"
|
+ "<tr><td>Android build ID</td><td>"
|
||||||
+ "System language: " + Locale.getDefault().toLanguageTag() + "\n"
|
+ buildID
|
||||||
+ "In-App Language: " + selectedLang;
|
+ "</td></tr>\n"
|
||||||
}
|
+ "<tr><td>Device brand</td><td>"
|
||||||
|
+ brand
|
||||||
|
+ "</td></tr>\n"
|
||||||
|
+ "<tr><td>Device manufacturer</td><td>"
|
||||||
|
+ manufacturer
|
||||||
|
+ "</td></tr>\n"
|
||||||
|
+ "<tr><td>Device name</td><td>"
|
||||||
|
+ device
|
||||||
|
+ "</td></tr>\n"
|
||||||
|
+ "<tr><td>Device model</td><td>"
|
||||||
|
+ model
|
||||||
|
+ "</td></tr>\n"
|
||||||
|
+ "<tr><td>Device product name</td><td>"
|
||||||
|
+ product
|
||||||
|
+ "</td></tr>\n"
|
||||||
|
+ "<tr><td>Device hardware name</td><td>"
|
||||||
|
+ hardware
|
||||||
|
+ "</td></tr>\n"
|
||||||
|
+ "<tr><td>ABIs</td><td>"
|
||||||
|
+ Arrays.toString(abis)
|
||||||
|
+ "</td></tr>\n"
|
||||||
|
+ "<tr><td>ABIs (32bit)</td><td>"
|
||||||
|
+ Arrays.toString(abis32Bits)
|
||||||
|
+ "</td></tr>\n"
|
||||||
|
+ "<tr><td>ABIs (64bit)</td><td>"
|
||||||
|
+ Arrays.toString(abis64Bits)
|
||||||
|
+ "</td></tr>\n"
|
||||||
|
+ "<tr><td>Language</td><td>"
|
||||||
|
+ selectedLang
|
||||||
|
+ "</td></tr>\n"
|
||||||
|
+ "</table>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "App version: "
|
||||||
|
+ versionName
|
||||||
|
+ "\n"
|
||||||
|
+ "App version code: "
|
||||||
|
+ versionCode
|
||||||
|
+ "\n"
|
||||||
|
+ "Android build version: "
|
||||||
|
+ buildVersion
|
||||||
|
+ "\n"
|
||||||
|
+ "Android release version: "
|
||||||
|
+ releaseVersion
|
||||||
|
+ "\n"
|
||||||
|
+ "Android SDK version: "
|
||||||
|
+ sdkVersion
|
||||||
|
+ "\n"
|
||||||
|
+ "Android build ID: "
|
||||||
|
+ buildID
|
||||||
|
+ "\n"
|
||||||
|
+ "Device brand: "
|
||||||
|
+ brand
|
||||||
|
+ "\n"
|
||||||
|
+ "Device manufacturer: "
|
||||||
|
+ manufacturer
|
||||||
|
+ "\n"
|
||||||
|
+ "Device name: "
|
||||||
|
+ device
|
||||||
|
+ "\n"
|
||||||
|
+ "Device model: "
|
||||||
|
+ model
|
||||||
|
+ "\n"
|
||||||
|
+ "Device product name: "
|
||||||
|
+ product
|
||||||
|
+ "\n"
|
||||||
|
+ "Device hardware name: "
|
||||||
|
+ hardware
|
||||||
|
+ "\n"
|
||||||
|
+ "ABIs: "
|
||||||
|
+ Arrays.toString(abis)
|
||||||
|
+ "\n"
|
||||||
|
+ "ABIs (32bit): "
|
||||||
|
+ Arrays.toString(abis32Bits)
|
||||||
|
+ "\n"
|
||||||
|
+ "ABIs (64bit): "
|
||||||
|
+ Arrays.toString(abis64Bits)
|
||||||
|
+ "\n"
|
||||||
|
+ "Base theme: "
|
||||||
|
+ baseTheme
|
||||||
|
+ "\n"
|
||||||
|
+ "Now playing theme: "
|
||||||
|
+ nowPlayingTheme
|
||||||
|
+ "\n"
|
||||||
|
+ "Adaptive: "
|
||||||
|
+ isAdaptive
|
||||||
|
+ "\n"
|
||||||
|
+ "System language: "
|
||||||
|
+ Locale.getDefault().toLanguageTag()
|
||||||
|
+ "\n"
|
||||||
|
+ "In-App Language: "
|
||||||
|
+ selectedLang;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,33 +1,34 @@
|
||||||
package code.name.monkey.retromusic.activities.bugreport.model;
|
package code.name.monkey.retromusic.activities.bugreport.model;
|
||||||
|
|
||||||
|
|
||||||
import code.name.monkey.retromusic.activities.bugreport.model.github.ExtraInfo;
|
import code.name.monkey.retromusic.activities.bugreport.model.github.ExtraInfo;
|
||||||
|
|
||||||
public class Report {
|
public class Report {
|
||||||
|
|
||||||
private final String description;
|
private final String description;
|
||||||
|
|
||||||
private final DeviceInfo deviceInfo;
|
private final DeviceInfo deviceInfo;
|
||||||
|
|
||||||
private final ExtraInfo extraInfo;
|
private final ExtraInfo extraInfo;
|
||||||
|
|
||||||
private final String title;
|
private final String title;
|
||||||
|
|
||||||
public Report(String title, String description, DeviceInfo deviceInfo, ExtraInfo extraInfo) {
|
public Report(String title, String description, DeviceInfo deviceInfo, ExtraInfo extraInfo) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.deviceInfo = deviceInfo;
|
this.deviceInfo = deviceInfo;
|
||||||
this.extraInfo = extraInfo;
|
this.extraInfo = extraInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description + "\n\n"
|
return description
|
||||||
+ "-\n\n"
|
+ "\n\n"
|
||||||
+ deviceInfo.toMarkdown() + "\n\n"
|
+ "-\n\n"
|
||||||
+ extraInfo.toMarkdown();
|
+ deviceInfo.toMarkdown()
|
||||||
}
|
+ "\n\n"
|
||||||
|
+ extraInfo.toMarkdown();
|
||||||
|
}
|
||||||
|
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,58 +5,57 @@ import java.util.Map;
|
||||||
|
|
||||||
public class ExtraInfo {
|
public class ExtraInfo {
|
||||||
|
|
||||||
private final Map<String, String> extraInfo = new LinkedHashMap<>();
|
private final Map<String, String> extraInfo = new LinkedHashMap<>();
|
||||||
|
|
||||||
public void put(String key, String value) {
|
public void put(String key, String value) {
|
||||||
extraInfo.put(key, value);
|
extraInfo.put(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void put(String key, boolean value) {
|
||||||
|
extraInfo.put(key, Boolean.toString(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void put(String key, double value) {
|
||||||
|
extraInfo.put(key, Double.toString(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void put(String key, float value) {
|
||||||
|
extraInfo.put(key, Float.toString(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void put(String key, long value) {
|
||||||
|
extraInfo.put(key, Long.toString(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void put(String key, int value) {
|
||||||
|
extraInfo.put(key, Integer.toString(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void put(String key, Object value) {
|
||||||
|
extraInfo.put(key, String.valueOf(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(String key) {
|
||||||
|
extraInfo.remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toMarkdown() {
|
||||||
|
if (extraInfo.isEmpty()) {
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void put(String key, boolean value) {
|
StringBuilder output = new StringBuilder();
|
||||||
extraInfo.put(key, Boolean.toString(value));
|
output.append("Extra info:\n" + "---\n" + "<table>\n");
|
||||||
|
for (String key : extraInfo.keySet()) {
|
||||||
|
output
|
||||||
|
.append("<tr><td>")
|
||||||
|
.append(key)
|
||||||
|
.append("</td><td>")
|
||||||
|
.append(extraInfo.get(key))
|
||||||
|
.append("</td></tr>\n");
|
||||||
}
|
}
|
||||||
|
output.append("</table>\n");
|
||||||
|
|
||||||
public void put(String key, double value) {
|
return output.toString();
|
||||||
extraInfo.put(key, Double.toString(value));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void put(String key, float value) {
|
|
||||||
extraInfo.put(key, Float.toString(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void put(String key, long value) {
|
|
||||||
extraInfo.put(key, Long.toString(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void put(String key, int value) {
|
|
||||||
extraInfo.put(key, Integer.toString(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void put(String key, Object value) {
|
|
||||||
extraInfo.put(key, String.valueOf(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void remove(String key) {
|
|
||||||
extraInfo.remove(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toMarkdown() {
|
|
||||||
if (extraInfo.isEmpty()) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
StringBuilder output = new StringBuilder();
|
|
||||||
output.append("Extra info:\n"
|
|
||||||
+ "---\n"
|
|
||||||
+ "<table>\n");
|
|
||||||
for (String key : extraInfo.keySet()) {
|
|
||||||
output.append("<tr><td>")
|
|
||||||
.append(key)
|
|
||||||
.append("</td><td>")
|
|
||||||
.append(extraInfo.get(key))
|
|
||||||
.append("</td></tr>\n");
|
|
||||||
}
|
|
||||||
output.append("</table>\n");
|
|
||||||
|
|
||||||
return output.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,38 +4,37 @@ import android.text.TextUtils;
|
||||||
|
|
||||||
public class GithubLogin {
|
public class GithubLogin {
|
||||||
|
|
||||||
private final String apiToken;
|
private final String apiToken;
|
||||||
|
|
||||||
private final String password;
|
private final String password;
|
||||||
|
|
||||||
private final String username;
|
private final String username;
|
||||||
|
|
||||||
public GithubLogin(String username, String password) {
|
public GithubLogin(String username, String password) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
this.apiToken = null;
|
this.apiToken = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GithubLogin(String apiToken) {
|
public GithubLogin(String apiToken) {
|
||||||
this.username = null;
|
this.username = null;
|
||||||
this.password = null;
|
this.password = null;
|
||||||
this.apiToken = apiToken;
|
this.apiToken = apiToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getApiToken() {
|
public String getApiToken() {
|
||||||
return apiToken;
|
return apiToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldUseApiToken() {
|
|
||||||
return TextUtils.isEmpty(username) || TextUtils.isEmpty(password);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public boolean shouldUseApiToken() {
|
||||||
|
return TextUtils.isEmpty(username) || TextUtils.isEmpty(password);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,20 +2,20 @@ package code.name.monkey.retromusic.activities.bugreport.model.github;
|
||||||
|
|
||||||
public class GithubTarget {
|
public class GithubTarget {
|
||||||
|
|
||||||
private final String repository;
|
private final String repository;
|
||||||
|
|
||||||
private final String username;
|
private final String username;
|
||||||
|
|
||||||
public GithubTarget(String username, String repository) {
|
public GithubTarget(String username, String repository) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRepository() {
|
public String getRepository() {
|
||||||
return repository;
|
return repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,57 +16,58 @@ package code.name.monkey.retromusic.activities.saf;
|
||||||
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import code.name.monkey.retromusic.R;
|
||||||
import com.heinrichreimersoftware.materialintro.app.IntroActivity;
|
import com.heinrichreimersoftware.materialintro.app.IntroActivity;
|
||||||
import com.heinrichreimersoftware.materialintro.slide.SimpleSlide;
|
import com.heinrichreimersoftware.materialintro.slide.SimpleSlide;
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R;
|
/** Created by hemanths on 2019-07-31. */
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by hemanths on 2019-07-31.
|
|
||||||
*/
|
|
||||||
public class SAFGuideActivity extends IntroActivity {
|
public class SAFGuideActivity extends IntroActivity {
|
||||||
|
|
||||||
public static final int REQUEST_CODE_SAF_GUIDE = 98;
|
public static final int REQUEST_CODE_SAF_GUIDE = 98;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setButtonCtaVisible(false);
|
setButtonCtaVisible(false);
|
||||||
setButtonNextVisible(false);
|
setButtonNextVisible(false);
|
||||||
setButtonBackVisible(false);
|
setButtonBackVisible(false);
|
||||||
|
|
||||||
setButtonCtaTintMode(BUTTON_CTA_TINT_MODE_TEXT);
|
setButtonCtaTintMode(BUTTON_CTA_TINT_MODE_TEXT);
|
||||||
|
|
||||||
String title = String.format(getString(R.string.saf_guide_slide1_title), getString(R.string.app_name));
|
String title =
|
||||||
|
String.format(getString(R.string.saf_guide_slide1_title), getString(R.string.app_name));
|
||||||
|
|
||||||
addSlide(new SimpleSlide.Builder()
|
addSlide(
|
||||||
.title(title)
|
new SimpleSlide.Builder()
|
||||||
.description(Build.VERSION.SDK_INT <= Build.VERSION_CODES.N_MR1
|
.title(title)
|
||||||
? R.string.saf_guide_slide1_description_before_o : R.string.saf_guide_slide1_description)
|
.description(
|
||||||
.image(R.drawable.saf_guide_1)
|
Build.VERSION.SDK_INT <= Build.VERSION_CODES.N_MR1
|
||||||
.background(R.color.md_deep_purple_300)
|
? R.string.saf_guide_slide1_description_before_o
|
||||||
.backgroundDark(R.color.md_deep_purple_400)
|
: R.string.saf_guide_slide1_description)
|
||||||
.layout(R.layout.fragment_simple_slide_large_image)
|
.image(R.drawable.saf_guide_1)
|
||||||
.build());
|
.background(R.color.md_deep_purple_300)
|
||||||
addSlide(new SimpleSlide.Builder()
|
.backgroundDark(R.color.md_deep_purple_400)
|
||||||
.title(R.string.saf_guide_slide2_title)
|
.layout(R.layout.fragment_simple_slide_large_image)
|
||||||
.description(R.string.saf_guide_slide2_description)
|
.build());
|
||||||
.image(R.drawable.saf_guide_2)
|
addSlide(
|
||||||
.background(R.color.md_deep_purple_500)
|
new SimpleSlide.Builder()
|
||||||
.backgroundDark(R.color.md_deep_purple_600)
|
.title(R.string.saf_guide_slide2_title)
|
||||||
.layout(R.layout.fragment_simple_slide_large_image)
|
.description(R.string.saf_guide_slide2_description)
|
||||||
.build());
|
.image(R.drawable.saf_guide_2)
|
||||||
addSlide(new SimpleSlide.Builder()
|
.background(R.color.md_deep_purple_500)
|
||||||
.title(R.string.saf_guide_slide3_title)
|
.backgroundDark(R.color.md_deep_purple_600)
|
||||||
.description(R.string.saf_guide_slide3_description)
|
.layout(R.layout.fragment_simple_slide_large_image)
|
||||||
.image(R.drawable.saf_guide_3)
|
.build());
|
||||||
.background(R.color.md_deep_purple_700)
|
addSlide(
|
||||||
.backgroundDark(R.color.md_deep_purple_800)
|
new SimpleSlide.Builder()
|
||||||
.layout(R.layout.fragment_simple_slide_large_image)
|
.title(R.string.saf_guide_slide3_title)
|
||||||
.build());
|
.description(R.string.saf_guide_slide3_description)
|
||||||
}
|
.image(R.drawable.saf_guide_3)
|
||||||
|
.background(R.color.md_deep_purple_700)
|
||||||
|
.backgroundDark(R.color.md_deep_purple_800)
|
||||||
|
.layout(R.layout.fragment_simple_slide_large_image)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.activities.tageditor
|
package code.name.monkey.retromusic.activities.tageditor
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
@ -28,13 +42,13 @@ import code.name.monkey.retromusic.util.RetroUtil
|
||||||
import code.name.monkey.retromusic.util.SAFUtil
|
import code.name.monkey.retromusic.util.SAFUtil
|
||||||
import com.google.android.material.button.MaterialButton
|
import com.google.android.material.button.MaterialButton
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
import java.io.File
|
||||||
|
import java.util.*
|
||||||
import kotlinx.android.synthetic.main.activity_album_tag_editor.*
|
import kotlinx.android.synthetic.main.activity_album_tag_editor.*
|
||||||
import org.jaudiotagger.audio.AudioFile
|
import org.jaudiotagger.audio.AudioFile
|
||||||
import org.jaudiotagger.audio.AudioFileIO
|
import org.jaudiotagger.audio.AudioFileIO
|
||||||
import org.jaudiotagger.tag.FieldKey
|
import org.jaudiotagger.tag.FieldKey
|
||||||
import org.koin.android.ext.android.inject
|
import org.koin.android.ext.android.inject
|
||||||
import java.io.File
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
abstract class AbsTagEditorActivity : AbsBaseActivity() {
|
abstract class AbsTagEditorActivity : AbsBaseActivity() {
|
||||||
val repository by inject<Repository>()
|
val repository by inject<Repository>()
|
||||||
|
@ -324,7 +338,8 @@ abstract class AbsTagEditorActivity : AbsBaseActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun writeValuesToFiles(
|
protected fun writeValuesToFiles(
|
||||||
fieldKeyValueMap: Map<FieldKey, String>, artworkInfo: ArtworkInfo?
|
fieldKeyValueMap: Map<FieldKey, String>,
|
||||||
|
artworkInfo: ArtworkInfo?
|
||||||
) {
|
) {
|
||||||
RetroUtil.hideSoftKeyboard(this)
|
RetroUtil.hideSoftKeyboard(this)
|
||||||
|
|
||||||
|
@ -405,5 +420,4 @@ abstract class AbsTagEditorActivity : AbsBaseActivity() {
|
||||||
private val TAG = AbsTagEditorActivity::class.java.simpleName
|
private val TAG = AbsTagEditorActivity::class.java.simpleName
|
||||||
private const val REQUEST_CODE_SELECT_IMAGE = 1000
|
private const val REQUEST_CODE_SELECT_IMAGE = 1000
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.activities.tageditor
|
package code.name.monkey.retromusic.activities.tageditor
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
@ -26,9 +40,9 @@ import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import com.bumptech.glide.request.animation.GlideAnimation
|
import com.bumptech.glide.request.animation.GlideAnimation
|
||||||
import com.bumptech.glide.request.target.SimpleTarget
|
import com.bumptech.glide.request.target.SimpleTarget
|
||||||
|
import java.util.*
|
||||||
import kotlinx.android.synthetic.main.activity_album_tag_editor.*
|
import kotlinx.android.synthetic.main.activity_album_tag_editor.*
|
||||||
import org.jaudiotagger.tag.FieldKey
|
import org.jaudiotagger.tag.FieldKey
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
|
class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
|
||||||
|
|
||||||
|
@ -155,7 +169,7 @@ class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
|
||||||
override fun save() {
|
override fun save() {
|
||||||
val fieldKeyValueMap = EnumMap<FieldKey, String>(FieldKey::class.java)
|
val fieldKeyValueMap = EnumMap<FieldKey, String>(FieldKey::class.java)
|
||||||
fieldKeyValueMap[FieldKey.ALBUM] = albumText.text.toString()
|
fieldKeyValueMap[FieldKey.ALBUM] = albumText.text.toString()
|
||||||
//android seems not to recognize album_artist field so we additionally write the normal artist field
|
// android seems not to recognize album_artist field so we additionally write the normal artist field
|
||||||
fieldKeyValueMap[FieldKey.ARTIST] = albumArtistText.text.toString()
|
fieldKeyValueMap[FieldKey.ARTIST] = albumArtistText.text.toString()
|
||||||
fieldKeyValueMap[FieldKey.ALBUM_ARTIST] = albumArtistText.text.toString()
|
fieldKeyValueMap[FieldKey.ALBUM_ARTIST] = albumArtistText.text.toString()
|
||||||
fieldKeyValueMap[FieldKey.GENRE] = genreTitle.text.toString()
|
fieldKeyValueMap[FieldKey.GENRE] = genreTitle.text.toString()
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.activities.tageditor
|
package code.name.monkey.retromusic.activities.tageditor
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
@ -9,10 +23,10 @@ import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.extensions.appHandleColor
|
import code.name.monkey.retromusic.extensions.appHandleColor
|
||||||
import code.name.monkey.retromusic.repository.SongRepository
|
import code.name.monkey.retromusic.repository.SongRepository
|
||||||
|
import java.util.*
|
||||||
import kotlinx.android.synthetic.main.activity_song_tag_editor.*
|
import kotlinx.android.synthetic.main.activity_song_tag_editor.*
|
||||||
import org.jaudiotagger.tag.FieldKey
|
import org.jaudiotagger.tag.FieldKey
|
||||||
import org.koin.android.ext.android.inject
|
import org.koin.android.ext.android.inject
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class SongTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
|
class SongTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
|
||||||
|
|
||||||
|
@ -111,5 +125,3 @@ class SongTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
|
||||||
val TAG: String = SongTagEditorActivity::class.java.simpleName
|
val TAG: String = SongTagEditorActivity::class.java.simpleName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,19 +7,14 @@ import android.graphics.Bitmap;
|
||||||
import android.media.MediaScannerConnection;
|
import android.media.MediaScannerConnection;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import code.name.monkey.retromusic.R;
|
||||||
|
import code.name.monkey.retromusic.misc.DialogAsyncTask;
|
||||||
|
import code.name.monkey.retromusic.misc.UpdateToastMediaScannerCompletionListener;
|
||||||
|
import code.name.monkey.retromusic.util.MusicUtil;
|
||||||
|
import code.name.monkey.retromusic.util.SAFUtil;
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
|
|
||||||
import org.jaudiotagger.audio.AudioFile;
|
|
||||||
import org.jaudiotagger.audio.AudioFileIO;
|
|
||||||
import org.jaudiotagger.tag.FieldKey;
|
|
||||||
import org.jaudiotagger.tag.Tag;
|
|
||||||
import org.jaudiotagger.tag.images.Artwork;
|
|
||||||
import org.jaudiotagger.tag.images.ArtworkFactory;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -27,166 +22,171 @@ import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import org.jaudiotagger.audio.AudioFile;
|
||||||
|
import org.jaudiotagger.audio.AudioFileIO;
|
||||||
|
import org.jaudiotagger.tag.FieldKey;
|
||||||
|
import org.jaudiotagger.tag.Tag;
|
||||||
|
import org.jaudiotagger.tag.images.Artwork;
|
||||||
|
import org.jaudiotagger.tag.images.ArtworkFactory;
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R;
|
public class WriteTagsAsyncTask
|
||||||
import code.name.monkey.retromusic.misc.DialogAsyncTask;
|
extends DialogAsyncTask<WriteTagsAsyncTask.LoadingInfo, Integer, String[]> {
|
||||||
import code.name.monkey.retromusic.misc.UpdateToastMediaScannerCompletionListener;
|
|
||||||
import code.name.monkey.retromusic.util.MusicUtil;
|
|
||||||
import code.name.monkey.retromusic.util.SAFUtil;
|
|
||||||
|
|
||||||
public class WriteTagsAsyncTask extends DialogAsyncTask<WriteTagsAsyncTask.LoadingInfo, Integer, String[]> {
|
private WeakReference<Activity> activity;
|
||||||
|
|
||||||
private WeakReference<Activity> activity;
|
public WriteTagsAsyncTask(@NonNull Activity activity) {
|
||||||
|
super(activity);
|
||||||
|
this.activity = new WeakReference<>(activity);
|
||||||
|
}
|
||||||
|
|
||||||
public WriteTagsAsyncTask(@NonNull Activity activity) {
|
@NonNull
|
||||||
super(activity);
|
@Override
|
||||||
this.activity = new WeakReference<>(activity);
|
protected Dialog createDialog(@NonNull Context context) {
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
return new MaterialAlertDialogBuilder(context)
|
||||||
@Override
|
.setTitle(R.string.saving_changes)
|
||||||
protected Dialog createDialog(@NonNull Context context) {
|
.setCancelable(false)
|
||||||
|
.setView(R.layout.loading)
|
||||||
|
.create();
|
||||||
|
}
|
||||||
|
|
||||||
return new MaterialAlertDialogBuilder(context)
|
@Override
|
||||||
.setTitle(R.string.saving_changes)
|
protected String[] doInBackground(LoadingInfo... params) {
|
||||||
.setCancelable(false)
|
try {
|
||||||
.setView(R.layout.loading)
|
LoadingInfo info = params[0];
|
||||||
.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
Artwork artwork = null;
|
||||||
protected String[] doInBackground(LoadingInfo... params) {
|
File albumArtFile = null;
|
||||||
|
if (info.artworkInfo != null && info.artworkInfo.getArtwork() != null) {
|
||||||
try {
|
try {
|
||||||
LoadingInfo info = params[0];
|
albumArtFile = MusicUtil.INSTANCE.createAlbumArtFile().getCanonicalFile();
|
||||||
|
info.artworkInfo
|
||||||
Artwork artwork = null;
|
.getArtwork()
|
||||||
File albumArtFile = null;
|
.compress(Bitmap.CompressFormat.PNG, 0, new FileOutputStream(albumArtFile));
|
||||||
if (info.artworkInfo != null && info.artworkInfo.getArtwork() != null) {
|
artwork = ArtworkFactory.createArtworkFromFile(albumArtFile);
|
||||||
try {
|
} catch (IOException e) {
|
||||||
albumArtFile = MusicUtil.INSTANCE.createAlbumArtFile().getCanonicalFile();
|
e.printStackTrace();
|
||||||
info.artworkInfo.getArtwork()
|
|
||||||
.compress(Bitmap.CompressFormat.PNG, 0, new FileOutputStream(albumArtFile));
|
|
||||||
artwork = ArtworkFactory.createArtworkFromFile(albumArtFile);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int counter = 0;
|
|
||||||
boolean wroteArtwork = false;
|
|
||||||
boolean deletedArtwork = false;
|
|
||||||
for (String filePath : info.filePaths) {
|
|
||||||
publishProgress(++counter, info.filePaths.size());
|
|
||||||
try {
|
|
||||||
Uri safUri = null;
|
|
||||||
if (filePath.contains(SAFUtil.SEPARATOR)) {
|
|
||||||
String[] fragments = filePath.split(SAFUtil.SEPARATOR);
|
|
||||||
filePath = fragments[0];
|
|
||||||
safUri = Uri.parse(fragments[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
AudioFile audioFile = AudioFileIO.read(new File(filePath));
|
|
||||||
Tag tag = audioFile.getTagOrCreateAndSetDefault();
|
|
||||||
|
|
||||||
if (info.fieldKeyValueMap != null) {
|
|
||||||
for (Map.Entry<FieldKey, String> entry : info.fieldKeyValueMap.entrySet()) {
|
|
||||||
try {
|
|
||||||
tag.setField(entry.getKey(), entry.getValue());
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (info.artworkInfo != null) {
|
|
||||||
if (info.artworkInfo.getArtwork() == null) {
|
|
||||||
tag.deleteArtworkField();
|
|
||||||
deletedArtwork = true;
|
|
||||||
} else if (artwork != null) {
|
|
||||||
tag.deleteArtworkField();
|
|
||||||
tag.setField(artwork);
|
|
||||||
wroteArtwork = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Activity activity = this.activity.get();
|
|
||||||
SAFUtil.write(activity, audioFile, safUri);
|
|
||||||
|
|
||||||
} catch (@NonNull Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Context context = getContext();
|
|
||||||
if (context != null) {
|
|
||||||
if (wroteArtwork) {
|
|
||||||
MusicUtil.INSTANCE.insertAlbumArt(context, info.artworkInfo.getAlbumId(), albumArtFile.getPath());
|
|
||||||
} else if (deletedArtwork) {
|
|
||||||
MusicUtil.INSTANCE.deleteAlbumArt(context, info.artworkInfo.getAlbumId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Collection<String> paths = info.filePaths;
|
|
||||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
|
|
||||||
paths = new ArrayList<>(info.filePaths.size());
|
|
||||||
for (String path : info.filePaths) {
|
|
||||||
if (path.contains(SAFUtil.SEPARATOR)) {
|
|
||||||
path = path.split(SAFUtil.SEPARATOR)[0];
|
|
||||||
}
|
|
||||||
paths.add(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return paths.toArray(new String[paths.size()]);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
int counter = 0;
|
||||||
protected void onCancelled(String[] toBeScanned) {
|
boolean wroteArtwork = false;
|
||||||
super.onCancelled(toBeScanned);
|
boolean deletedArtwork = false;
|
||||||
scan(toBeScanned);
|
for (String filePath : info.filePaths) {
|
||||||
}
|
publishProgress(++counter, info.filePaths.size());
|
||||||
|
try {
|
||||||
|
Uri safUri = null;
|
||||||
|
if (filePath.contains(SAFUtil.SEPARATOR)) {
|
||||||
|
String[] fragments = filePath.split(SAFUtil.SEPARATOR);
|
||||||
|
filePath = fragments[0];
|
||||||
|
safUri = Uri.parse(fragments[1]);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
AudioFile audioFile = AudioFileIO.read(new File(filePath));
|
||||||
protected void onPostExecute(String[] toBeScanned) {
|
Tag tag = audioFile.getTagOrCreateAndSetDefault();
|
||||||
super.onPostExecute(toBeScanned);
|
|
||||||
scan(toBeScanned);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
if (info.fieldKeyValueMap != null) {
|
||||||
protected void onProgressUpdate(@NonNull Dialog dialog, Integer... values) {
|
for (Map.Entry<FieldKey, String> entry : info.fieldKeyValueMap.entrySet()) {
|
||||||
super.onProgressUpdate(dialog, values);
|
try {
|
||||||
//((MaterialDialog) dialog).setMaxProgress(values[1]);
|
tag.setField(entry.getKey(), entry.getValue());
|
||||||
//((MaterialDialog) dialog).setProgress(values[0]);
|
} catch (Exception e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void scan(String[] toBeScanned) {
|
if (info.artworkInfo != null) {
|
||||||
Activity activity = this.activity.get();
|
if (info.artworkInfo.getArtwork() == null) {
|
||||||
if (activity != null) {
|
tag.deleteArtworkField();
|
||||||
MediaScannerConnection.scanFile(activity, toBeScanned, null,
|
deletedArtwork = true;
|
||||||
new UpdateToastMediaScannerCompletionListener(activity, toBeScanned));
|
} else if (artwork != null) {
|
||||||
|
tag.deleteArtworkField();
|
||||||
|
tag.setField(artwork);
|
||||||
|
wroteArtwork = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Activity activity = this.activity.get();
|
||||||
|
SAFUtil.write(activity, audioFile, safUri);
|
||||||
|
|
||||||
|
} catch (@NonNull Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class LoadingInfo {
|
Context context = getContext();
|
||||||
|
if (context != null) {
|
||||||
@Nullable
|
if (wroteArtwork) {
|
||||||
final Map<FieldKey, String> fieldKeyValueMap;
|
MusicUtil.INSTANCE.insertAlbumArt(
|
||||||
|
context, info.artworkInfo.getAlbumId(), albumArtFile.getPath());
|
||||||
final Collection<String> filePaths;
|
} else if (deletedArtwork) {
|
||||||
|
MusicUtil.INSTANCE.deleteAlbumArt(context, info.artworkInfo.getAlbumId());
|
||||||
@Nullable
|
|
||||||
private AbsTagEditorActivity.ArtworkInfo artworkInfo;
|
|
||||||
|
|
||||||
public LoadingInfo(Collection<String> filePaths,
|
|
||||||
@Nullable Map<FieldKey, String> fieldKeyValueMap,
|
|
||||||
@Nullable AbsTagEditorActivity.ArtworkInfo artworkInfo) {
|
|
||||||
this.filePaths = filePaths;
|
|
||||||
this.fieldKeyValueMap = fieldKeyValueMap;
|
|
||||||
this.artworkInfo = artworkInfo;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Collection<String> paths = info.filePaths;
|
||||||
|
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
|
||||||
|
paths = new ArrayList<>(info.filePaths.size());
|
||||||
|
for (String path : info.filePaths) {
|
||||||
|
if (path.contains(SAFUtil.SEPARATOR)) {
|
||||||
|
path = path.split(SAFUtil.SEPARATOR)[0];
|
||||||
|
}
|
||||||
|
paths.add(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return paths.toArray(new String[paths.size()]);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCancelled(String[] toBeScanned) {
|
||||||
|
super.onCancelled(toBeScanned);
|
||||||
|
scan(toBeScanned);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(String[] toBeScanned) {
|
||||||
|
super.onPostExecute(toBeScanned);
|
||||||
|
scan(toBeScanned);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onProgressUpdate(@NonNull Dialog dialog, Integer... values) {
|
||||||
|
super.onProgressUpdate(dialog, values);
|
||||||
|
// ((MaterialDialog) dialog).setMaxProgress(values[1]);
|
||||||
|
// ((MaterialDialog) dialog).setProgress(values[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void scan(String[] toBeScanned) {
|
||||||
|
Activity activity = this.activity.get();
|
||||||
|
if (activity != null) {
|
||||||
|
MediaScannerConnection.scanFile(
|
||||||
|
activity,
|
||||||
|
toBeScanned,
|
||||||
|
null,
|
||||||
|
new UpdateToastMediaScannerCompletionListener(activity, toBeScanned));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class LoadingInfo {
|
||||||
|
|
||||||
|
@Nullable final Map<FieldKey, String> fieldKeyValueMap;
|
||||||
|
|
||||||
|
final Collection<String> filePaths;
|
||||||
|
|
||||||
|
@Nullable private AbsTagEditorActivity.ArtworkInfo artworkInfo;
|
||||||
|
|
||||||
|
public LoadingInfo(
|
||||||
|
Collection<String> filePaths,
|
||||||
|
@Nullable Map<FieldKey, String> fieldKeyValueMap,
|
||||||
|
@Nullable AbsTagEditorActivity.ArtworkInfo artworkInfo) {
|
||||||
|
this.filePaths = filePaths;
|
||||||
|
this.fieldKeyValueMap = fieldKeyValueMap;
|
||||||
|
this.artworkInfo = artworkInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -22,116 +22,119 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.google.android.material.checkbox.MaterialCheckBox;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import code.name.monkey.appthemehelper.ThemeStore;
|
import code.name.monkey.appthemehelper.ThemeStore;
|
||||||
import code.name.monkey.retromusic.R;
|
import code.name.monkey.retromusic.R;
|
||||||
import code.name.monkey.retromusic.model.CategoryInfo;
|
import code.name.monkey.retromusic.model.CategoryInfo;
|
||||||
import code.name.monkey.retromusic.util.SwipeAndDragHelper;
|
import code.name.monkey.retromusic.util.SwipeAndDragHelper;
|
||||||
|
import com.google.android.material.checkbox.MaterialCheckBox;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class CategoryInfoAdapter extends RecyclerView.Adapter<CategoryInfoAdapter.ViewHolder>
|
public class CategoryInfoAdapter extends RecyclerView.Adapter<CategoryInfoAdapter.ViewHolder>
|
||||||
implements SwipeAndDragHelper.ActionCompletionContract {
|
implements SwipeAndDragHelper.ActionCompletionContract {
|
||||||
|
|
||||||
private List<CategoryInfo> categoryInfos;
|
private List<CategoryInfo> categoryInfos;
|
||||||
private ItemTouchHelper touchHelper;
|
private ItemTouchHelper touchHelper;
|
||||||
|
|
||||||
public CategoryInfoAdapter() {
|
public CategoryInfoAdapter() {
|
||||||
SwipeAndDragHelper swipeAndDragHelper = new SwipeAndDragHelper(this);
|
SwipeAndDragHelper swipeAndDragHelper = new SwipeAndDragHelper(this);
|
||||||
touchHelper = new ItemTouchHelper(swipeAndDragHelper);
|
touchHelper = new ItemTouchHelper(swipeAndDragHelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attachToRecyclerView(RecyclerView recyclerView) {
|
public void attachToRecyclerView(RecyclerView recyclerView) {
|
||||||
touchHelper.attachToRecyclerView(recyclerView);
|
touchHelper.attachToRecyclerView(recyclerView);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public List<CategoryInfo> getCategoryInfos() {
|
public List<CategoryInfo> getCategoryInfos() {
|
||||||
return categoryInfos;
|
return categoryInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCategoryInfos(@NonNull List<CategoryInfo> categoryInfos) {
|
public void setCategoryInfos(@NonNull List<CategoryInfo> categoryInfos) {
|
||||||
this.categoryInfos = categoryInfos;
|
this.categoryInfos = categoryInfos;
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return categoryInfos.size();
|
return categoryInfos.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull CategoryInfoAdapter.ViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull CategoryInfoAdapter.ViewHolder holder, int position) {
|
||||||
CategoryInfo categoryInfo = categoryInfos.get(position);
|
CategoryInfo categoryInfo = categoryInfos.get(position);
|
||||||
|
|
||||||
holder.checkBox.setChecked(categoryInfo.isVisible());
|
holder.checkBox.setChecked(categoryInfo.isVisible());
|
||||||
holder.title.setText(holder.title.getResources().getString(categoryInfo.getCategory().getStringRes()));
|
holder.title.setText(
|
||||||
|
holder.title.getResources().getString(categoryInfo.getCategory().getStringRes()));
|
||||||
|
|
||||||
holder.itemView.setOnClickListener(v -> {
|
holder.itemView.setOnClickListener(
|
||||||
if (!(categoryInfo.isVisible() && isLastCheckedCategory(categoryInfo))) {
|
v -> {
|
||||||
categoryInfo.setVisible(!categoryInfo.isVisible());
|
if (!(categoryInfo.isVisible() && isLastCheckedCategory(categoryInfo))) {
|
||||||
holder.checkBox.setChecked(categoryInfo.isVisible());
|
categoryInfo.setVisible(!categoryInfo.isVisible());
|
||||||
} else {
|
holder.checkBox.setChecked(categoryInfo.isVisible());
|
||||||
Toast.makeText(holder.itemView.getContext(), R.string.you_have_to_select_at_least_one_category,
|
} else {
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.makeText(
|
||||||
}
|
holder.itemView.getContext(),
|
||||||
|
R.string.you_have_to_select_at_least_one_category,
|
||||||
|
Toast.LENGTH_SHORT)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
holder.dragView.setOnTouchListener((view, event) -> {
|
holder.dragView.setOnTouchListener(
|
||||||
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
(view, event) -> {
|
||||||
touchHelper.startDrag(holder);
|
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
||||||
}
|
touchHelper.startDrag(holder);
|
||||||
return false;
|
}
|
||||||
}
|
return false;
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NonNull
|
@NonNull
|
||||||
public CategoryInfoAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public CategoryInfoAdapter.ViewHolder onCreateViewHolder(
|
||||||
View view = LayoutInflater.from(parent.getContext())
|
@NonNull ViewGroup parent, int viewType) {
|
||||||
.inflate(R.layout.preference_dialog_library_categories_listitem, parent, false);
|
View view =
|
||||||
return new ViewHolder(view);
|
LayoutInflater.from(parent.getContext())
|
||||||
}
|
.inflate(R.layout.preference_dialog_library_categories_listitem, parent, false);
|
||||||
|
return new ViewHolder(view);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewMoved(int oldPosition, int newPosition) {
|
public void onViewMoved(int oldPosition, int newPosition) {
|
||||||
CategoryInfo categoryInfo = categoryInfos.get(oldPosition);
|
CategoryInfo categoryInfo = categoryInfos.get(oldPosition);
|
||||||
categoryInfos.remove(oldPosition);
|
categoryInfos.remove(oldPosition);
|
||||||
categoryInfos.add(newPosition, categoryInfo);
|
categoryInfos.add(newPosition, categoryInfo);
|
||||||
notifyItemMoved(oldPosition, newPosition);
|
notifyItemMoved(oldPosition, newPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isLastCheckedCategory(CategoryInfo categoryInfo) {
|
private boolean isLastCheckedCategory(CategoryInfo categoryInfo) {
|
||||||
if (categoryInfo.isVisible()) {
|
if (categoryInfo.isVisible()) {
|
||||||
for (CategoryInfo c : categoryInfos) {
|
for (CategoryInfo c : categoryInfos) {
|
||||||
if (c != categoryInfo && c.isVisible()) {
|
if (c != categoryInfo && c.isVisible()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
private MaterialCheckBox checkBox;
|
private MaterialCheckBox checkBox;
|
||||||
private View dragView;
|
private View dragView;
|
||||||
private TextView title;
|
private TextView title;
|
||||||
|
|
||||||
ViewHolder(View view) {
|
ViewHolder(View view) {
|
||||||
super(view);
|
super(view);
|
||||||
checkBox = view.findViewById(R.id.checkbox);
|
checkBox = view.findViewById(R.id.checkbox);
|
||||||
checkBox.setButtonTintList(
|
checkBox.setButtonTintList(
|
||||||
ColorStateList.valueOf(ThemeStore.Companion.accentColor(checkBox.getContext())));
|
ColorStateList.valueOf(ThemeStore.Companion.accentColor(checkBox.getContext())));
|
||||||
title = view.findViewById(R.id.title);
|
title = view.findViewById(R.id.title);
|
||||||
dragView = view.findViewById(R.id.drag_view);
|
dragView = view.findViewById(R.id.drag_view);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.adapter
|
package code.name.monkey.retromusic.adapter
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.adapter
|
package code.name.monkey.retromusic.adapter
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.adapter
|
package code.name.monkey.retromusic.adapter
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
@ -121,7 +135,6 @@ class HomeAdapter(
|
||||||
viewHolder.bind(home)
|
viewHolder.bind(home)
|
||||||
}
|
}
|
||||||
PLAYLISTS -> {
|
PLAYLISTS -> {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,7 +194,6 @@ class HomeAdapter(
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.build()
|
.build()
|
||||||
.into(itemView.findViewById(id))
|
.into(itemView.findViewById(id))
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.adapter
|
package code.name.monkey.retromusic.adapter
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
@ -60,7 +74,7 @@ class SearchAdapter(
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
when (getItemViewType(position)) {
|
when (getItemViewType(position)) {
|
||||||
ALBUM -> {
|
ALBUM -> {
|
||||||
holder. imageTextContainer?.isVisible = true
|
holder.imageTextContainer?.isVisible = true
|
||||||
val album = dataSet[position] as Album
|
val album = dataSet[position] as Album
|
||||||
holder.title?.text = album.title
|
holder.title?.text = album.title
|
||||||
holder.text?.text = album.artistName
|
holder.text?.text = album.artistName
|
||||||
|
@ -68,7 +82,7 @@ class SearchAdapter(
|
||||||
.checkIgnoreMediaStore().build().into(holder.image)
|
.checkIgnoreMediaStore().build().into(holder.image)
|
||||||
}
|
}
|
||||||
ARTIST -> {
|
ARTIST -> {
|
||||||
holder. imageTextContainer?.isVisible = true
|
holder.imageTextContainer?.isVisible = true
|
||||||
val artist = dataSet[position] as Artist
|
val artist = dataSet[position] as Artist
|
||||||
holder.title?.text = artist.name
|
holder.title?.text = artist.name
|
||||||
holder.text?.text = MusicUtil.getArtistInfoString(activity, artist)
|
holder.text?.text = MusicUtil.getArtistInfoString(activity, artist)
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2019 Google LLC
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the GNU General Public License v3
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
*
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
package code.name.monkey.retromusic.adapter
|
package code.name.monkey.retromusic.adapter
|
||||||
|
|
||||||
|
@ -33,11 +32,11 @@ import code.name.monkey.retromusic.util.RetroUtil
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import com.bumptech.glide.signature.MediaStoreSignature
|
import com.bumptech.glide.signature.MediaStoreSignature
|
||||||
import me.zhanghai.android.fastscroll.PopupTextProvider
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
import kotlin.math.log10
|
import kotlin.math.log10
|
||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
|
import me.zhanghai.android.fastscroll.PopupTextProvider
|
||||||
|
|
||||||
class SongFileAdapter(
|
class SongFileAdapter(
|
||||||
private val activity: AppCompatActivity,
|
private val activity: AppCompatActivity,
|
||||||
|
@ -148,7 +147,6 @@ class SongFileAdapter(
|
||||||
return MusicUtil.getSectionName(dataSet[position].name)
|
return MusicUtil.getSectionName(dataSet[position].name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inner class ViewHolder(itemView: View) : MediaEntryViewHolder(itemView) {
|
inner class ViewHolder(itemView: View) : MediaEntryViewHolder(itemView) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.adapter
|
package code.name.monkey.retromusic.adapter
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.adapter.album
|
package code.name.monkey.retromusic.adapter.album
|
||||||
|
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
|
@ -129,7 +143,8 @@ open class AlbumAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMultipleItemAction(
|
override fun onMultipleItemAction(
|
||||||
menuItem: MenuItem, selection: List<Album>
|
menuItem: MenuItem,
|
||||||
|
selection: List<Album>
|
||||||
) {
|
) {
|
||||||
SongsMenuHelper.handleMenuClick(activity, getSongList(selection), menuItem.itemId)
|
SongsMenuHelper.handleMenuClick(activity, getSongList(selection), menuItem.itemId)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,29 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.adapter.album
|
package code.name.monkey.retromusic.adapter.album
|
||||||
|
|
||||||
import android.content.Intent
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import androidx.core.app.ActivityOptionsCompat
|
import androidx.core.view.ViewCompat
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.activities.LyricsActivity
|
|
||||||
import code.name.monkey.retromusic.fragments.AlbumCoverStyle
|
import code.name.monkey.retromusic.fragments.AlbumCoverStyle
|
||||||
import code.name.monkey.retromusic.fragments.NowPlayingScreen.*
|
import code.name.monkey.retromusic.fragments.NowPlayingScreen.*
|
||||||
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
||||||
|
@ -91,15 +103,10 @@ class AlbumCoverPagerAdapter(
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View? {
|
): View? {
|
||||||
val view = inflater.inflate(getLayoutWithPlayerTheme(), container, false)
|
val view = inflater.inflate(getLayoutWithPlayerTheme(), container, false)
|
||||||
|
ViewCompat.setTransitionName(view, "lyrics")
|
||||||
albumCover = view.findViewById(R.id.player_image)
|
albumCover = view.findViewById(R.id.player_image)
|
||||||
albumCover.setOnClickListener {
|
view.setOnClickListener {
|
||||||
val intent = Intent(requireContext(), LyricsActivity::class.java)
|
showLyricsDialog()
|
||||||
val activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(
|
|
||||||
requireActivity(),
|
|
||||||
it,
|
|
||||||
"lyrics"
|
|
||||||
)
|
|
||||||
startActivity(intent, activityOptions.toBundle())
|
|
||||||
}
|
}
|
||||||
return view
|
return view
|
||||||
}
|
}
|
||||||
|
@ -205,4 +212,3 @@ class AlbumCoverPagerAdapter(
|
||||||
val TAG: String = AlbumCoverPagerAdapter::class.java.simpleName
|
val TAG: String = AlbumCoverPagerAdapter::class.java.simpleName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.adapter.album
|
package code.name.monkey.retromusic.adapter.album
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
@ -29,8 +43,8 @@ class HorizontalAlbumAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setColors(color: MediaNotificationProcessor, holder: ViewHolder) {
|
override fun setColors(color: MediaNotificationProcessor, holder: ViewHolder) {
|
||||||
//holder.title?.setTextColor(ATHUtil.resolveColor(activity, android.R.attr.textColorPrimary))
|
// holder.title?.setTextColor(ATHUtil.resolveColor(activity, android.R.attr.textColorPrimary))
|
||||||
//holder.text?.setTextColor(ATHUtil.resolveColor(activity, android.R.attr.textColorSecondary))
|
// holder.text?.setTextColor(ATHUtil.resolveColor(activity, android.R.attr.textColorSecondary))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadAlbumCover(album: Album, holder: ViewHolder) {
|
override fun loadAlbumCover(album: Album, holder: ViewHolder) {
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.adapter.artist
|
package code.name.monkey.retromusic.adapter.artist
|
||||||
|
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
|
@ -22,8 +36,8 @@ import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import me.zhanghai.android.fastscroll.PopupTextProvider
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import me.zhanghai.android.fastscroll.PopupTextProvider
|
||||||
|
|
||||||
class ArtistAdapter(
|
class ArtistAdapter(
|
||||||
val activity: FragmentActivity,
|
val activity: FragmentActivity,
|
||||||
|
@ -107,7 +121,8 @@ class ArtistAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMultipleItemAction(
|
override fun onMultipleItemAction(
|
||||||
menuItem: MenuItem, selection: List<Artist>
|
menuItem: MenuItem,
|
||||||
|
selection: List<Artist>
|
||||||
) {
|
) {
|
||||||
SongsMenuHelper.handleMenuClick(activity, getSongList(selection), menuItem.itemId)
|
SongsMenuHelper.handleMenuClick(activity, getSongList(selection), menuItem.itemId)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,132 +3,127 @@ package code.name.monkey.retromusic.adapter.base;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import androidx.annotation.MenuRes;
|
import androidx.annotation.MenuRes;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import code.name.monkey.retromusic.R;
|
||||||
|
import code.name.monkey.retromusic.interfaces.ICabHolder;
|
||||||
import com.afollestad.materialcab.MaterialCab;
|
import com.afollestad.materialcab.MaterialCab;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R;
|
public abstract class AbsMultiSelectAdapter<V extends RecyclerView.ViewHolder, I>
|
||||||
import code.name.monkey.retromusic.interfaces.ICabHolder;
|
extends RecyclerView.Adapter<V> implements MaterialCab.Callback {
|
||||||
|
|
||||||
|
@Nullable private final ICabHolder ICabHolder;
|
||||||
|
private final Context context;
|
||||||
|
private MaterialCab cab;
|
||||||
|
private List<I> checked;
|
||||||
|
private int menuRes;
|
||||||
|
|
||||||
public abstract class AbsMultiSelectAdapter<V extends RecyclerView.ViewHolder, I> extends RecyclerView.Adapter<V>
|
public AbsMultiSelectAdapter(
|
||||||
implements MaterialCab.Callback {
|
@NonNull Context context, @Nullable ICabHolder ICabHolder, @MenuRes int menuRes) {
|
||||||
|
this.ICabHolder = ICabHolder;
|
||||||
|
checked = new ArrayList<>();
|
||||||
|
this.menuRes = menuRes;
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Override
|
||||||
private final ICabHolder ICabHolder;
|
public boolean onCabCreated(MaterialCab materialCab, Menu menu) {
|
||||||
private final Context context;
|
return true;
|
||||||
private MaterialCab cab;
|
}
|
||||||
private List<I> checked;
|
|
||||||
private int menuRes;
|
|
||||||
|
|
||||||
public AbsMultiSelectAdapter(@NonNull Context context, @Nullable ICabHolder ICabHolder, @MenuRes int menuRes) {
|
@Override
|
||||||
this.ICabHolder = ICabHolder;
|
public boolean onCabFinished(MaterialCab materialCab) {
|
||||||
checked = new ArrayList<>();
|
clearChecked();
|
||||||
this.menuRes = menuRes;
|
return true;
|
||||||
this.context = context;
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCabItemClicked(MenuItem menuItem) {
|
||||||
|
if (menuItem.getItemId() == R.id.action_multi_select_adapter_check_all) {
|
||||||
|
checkAll();
|
||||||
|
} else {
|
||||||
|
onMultipleItemAction(menuItem, new ArrayList<>(checked));
|
||||||
|
cab.finish();
|
||||||
|
clearChecked();
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
protected void checkAll() {
|
||||||
public boolean onCabCreated(MaterialCab materialCab, Menu menu) {
|
if (ICabHolder != null) {
|
||||||
return true;
|
checked.clear();
|
||||||
}
|
for (int i = 0; i < getItemCount(); i++) {
|
||||||
|
I identifier = getIdentifier(i);
|
||||||
@Override
|
if (identifier != null) {
|
||||||
public boolean onCabFinished(MaterialCab materialCab) {
|
checked.add(identifier);
|
||||||
clearChecked();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCabItemClicked(MenuItem menuItem) {
|
|
||||||
if (menuItem.getItemId() == R.id.action_multi_select_adapter_check_all) {
|
|
||||||
checkAll();
|
|
||||||
} else {
|
|
||||||
onMultipleItemAction(menuItem, new ArrayList<>(checked));
|
|
||||||
cab.finish();
|
|
||||||
clearChecked();
|
|
||||||
}
|
}
|
||||||
return true;
|
}
|
||||||
|
notifyDataSetChanged();
|
||||||
|
updateCab();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void checkAll() {
|
@Nullable
|
||||||
if (ICabHolder != null) {
|
protected abstract I getIdentifier(int position);
|
||||||
checked.clear();
|
|
||||||
for (int i = 0; i < getItemCount(); i++) {
|
|
||||||
I identifier = getIdentifier(i);
|
|
||||||
if (identifier != null) {
|
|
||||||
checked.add(identifier);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
notifyDataSetChanged();
|
|
||||||
updateCab();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
protected String getName(I object) {
|
||||||
protected abstract I getIdentifier(int position);
|
return object.toString();
|
||||||
|
}
|
||||||
|
|
||||||
protected String getName(I object) {
|
protected boolean isChecked(I identifier) {
|
||||||
return object.toString();
|
return checked.contains(identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isChecked(I identifier) {
|
protected boolean isInQuickSelectMode() {
|
||||||
return checked.contains(identifier);
|
return cab != null && cab.isActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isInQuickSelectMode() {
|
protected abstract void onMultipleItemAction(MenuItem menuItem, List<I> selection);
|
||||||
return cab != null && cab.isActive();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void onMultipleItemAction(MenuItem menuItem, List<I> selection);
|
protected void setMultiSelectMenuRes(@MenuRes int menuRes) {
|
||||||
|
this.menuRes = menuRes;
|
||||||
|
}
|
||||||
|
|
||||||
protected void setMultiSelectMenuRes(@MenuRes int menuRes) {
|
protected boolean toggleChecked(final int position) {
|
||||||
this.menuRes = menuRes;
|
if (ICabHolder != null) {
|
||||||
}
|
I identifier = getIdentifier(position);
|
||||||
|
if (identifier == null) {
|
||||||
protected boolean toggleChecked(final int position) {
|
|
||||||
if (ICabHolder != null) {
|
|
||||||
I identifier = getIdentifier(position);
|
|
||||||
if (identifier == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!checked.remove(identifier)) {
|
|
||||||
checked.add(identifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyItemChanged(position);
|
|
||||||
updateCab();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearChecked() {
|
if (!checked.remove(identifier)) {
|
||||||
checked.clear();
|
checked.add(identifier);
|
||||||
notifyDataSetChanged();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void updateCab() {
|
notifyItemChanged(position);
|
||||||
if (ICabHolder != null) {
|
updateCab();
|
||||||
if (cab == null || !cab.isActive()) {
|
return true;
|
||||||
cab = ICabHolder.openCab(menuRes, this);
|
|
||||||
}
|
|
||||||
final int size = checked.size();
|
|
||||||
if (size <= 0) {
|
|
||||||
cab.finish();
|
|
||||||
} else if (size == 1) {
|
|
||||||
cab.setTitle(getName(checked.get(0)));
|
|
||||||
} else {
|
|
||||||
cab.setTitle(context.getString(R.string.x_selected, size));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clearChecked() {
|
||||||
|
checked.clear();
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCab() {
|
||||||
|
if (ICabHolder != null) {
|
||||||
|
if (cab == null || !cab.isActive()) {
|
||||||
|
cab = ICabHolder.openCab(menuRes, this);
|
||||||
|
}
|
||||||
|
final int size = checked.size();
|
||||||
|
if (size <= 0) {
|
||||||
|
cab.finish();
|
||||||
|
} else if (size == 1) {
|
||||||
|
cab.setTitle(getName(checked.get(0)));
|
||||||
|
} else {
|
||||||
|
cab.setTitle(context.getString(R.string.x_selected, size));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,123 +19,101 @@ import android.view.View;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import code.name.monkey.retromusic.R;
|
||||||
import com.google.android.material.card.MaterialCardView;
|
import com.google.android.material.card.MaterialCardView;
|
||||||
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractDraggableSwipeableItemViewHolder;
|
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractDraggableSwipeableItemViewHolder;
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R;
|
|
||||||
|
|
||||||
public class MediaEntryViewHolder extends AbstractDraggableSwipeableItemViewHolder
|
public class MediaEntryViewHolder extends AbstractDraggableSwipeableItemViewHolder
|
||||||
implements View.OnLongClickListener, View.OnClickListener {
|
implements View.OnLongClickListener, View.OnClickListener {
|
||||||
|
|
||||||
@Nullable
|
@Nullable public View dragView;
|
||||||
public View dragView;
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable public View dummyContainer;
|
||||||
public View dummyContainer;
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable public ImageView image;
|
||||||
public ImageView image;
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable public ImageView artistImage;
|
||||||
public ImageView artistImage;
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable public ImageView playerImage;
|
||||||
public ImageView playerImage;
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable public MaterialCardView imageContainerCard;
|
||||||
public MaterialCardView imageContainerCard;
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable public TextView imageText;
|
||||||
public TextView imageText;
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable public MaterialCardView imageTextContainer;
|
||||||
public MaterialCardView imageTextContainer;
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable public View mask;
|
||||||
public View mask;
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable public View menu;
|
||||||
public View menu;
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable public View paletteColorContainer;
|
||||||
public View paletteColorContainer;
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable public ImageButton playSongs;
|
||||||
public ImageButton playSongs;
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable public RecyclerView recyclerView;
|
||||||
public RecyclerView recyclerView;
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable public TextView text;
|
||||||
public TextView text;
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable public TextView text2;
|
||||||
public TextView text2;
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable public TextView time;
|
||||||
public TextView time;
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable public TextView title;
|
||||||
public TextView title;
|
|
||||||
|
|
||||||
public MediaEntryViewHolder(@NonNull View itemView) {
|
public MediaEntryViewHolder(@NonNull View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
title = itemView.findViewById(R.id.title);
|
title = itemView.findViewById(R.id.title);
|
||||||
text = itemView.findViewById(R.id.text);
|
text = itemView.findViewById(R.id.text);
|
||||||
text2 = itemView.findViewById(R.id.text2);
|
text2 = itemView.findViewById(R.id.text2);
|
||||||
|
|
||||||
image = itemView.findViewById(R.id.image);
|
image = itemView.findViewById(R.id.image);
|
||||||
artistImage = itemView.findViewById(R.id.artistImage);
|
artistImage = itemView.findViewById(R.id.artistImage);
|
||||||
playerImage = itemView.findViewById(R.id.player_image);
|
playerImage = itemView.findViewById(R.id.player_image);
|
||||||
time = itemView.findViewById(R.id.time);
|
time = itemView.findViewById(R.id.time);
|
||||||
|
|
||||||
imageText = itemView.findViewById(R.id.imageText);
|
imageText = itemView.findViewById(R.id.imageText);
|
||||||
imageTextContainer = itemView.findViewById(R.id.imageTextContainer);
|
imageTextContainer = itemView.findViewById(R.id.imageTextContainer);
|
||||||
imageContainerCard = itemView.findViewById(R.id.imageContainerCard);
|
imageContainerCard = itemView.findViewById(R.id.imageContainerCard);
|
||||||
|
|
||||||
menu = itemView.findViewById(R.id.menu);
|
menu = itemView.findViewById(R.id.menu);
|
||||||
dragView = itemView.findViewById(R.id.drag_view);
|
dragView = itemView.findViewById(R.id.drag_view);
|
||||||
paletteColorContainer = itemView.findViewById(R.id.paletteColorContainer);
|
paletteColorContainer = itemView.findViewById(R.id.paletteColorContainer);
|
||||||
recyclerView = itemView.findViewById(R.id.recycler_view);
|
recyclerView = itemView.findViewById(R.id.recycler_view);
|
||||||
mask = itemView.findViewById(R.id.mask);
|
mask = itemView.findViewById(R.id.mask);
|
||||||
playSongs = itemView.findViewById(R.id.playSongs);
|
playSongs = itemView.findViewById(R.id.playSongs);
|
||||||
dummyContainer = itemView.findViewById(R.id.dummy_view);
|
dummyContainer = itemView.findViewById(R.id.dummy_view);
|
||||||
|
|
||||||
if (imageContainerCard != null) {
|
if (imageContainerCard != null) {
|
||||||
imageContainerCard.setCardBackgroundColor(Color.TRANSPARENT);
|
imageContainerCard.setCardBackgroundColor(Color.TRANSPARENT);
|
||||||
}
|
|
||||||
itemView.setOnClickListener(this);
|
|
||||||
itemView.setOnLongClickListener(this);
|
|
||||||
}
|
}
|
||||||
|
itemView.setOnClickListener(this);
|
||||||
|
itemView.setOnLongClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View getSwipeableContainerView() {
|
public View getSwipeableContainerView() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {}
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
@Override
|
return false;
|
||||||
public boolean onLongClick(View v) {
|
}
|
||||||
return false;
|
|
||||||
}
|
public void setImageTransitionName(@NonNull String transitionName) {
|
||||||
|
itemView.setTransitionName(transitionName);
|
||||||
public void setImageTransitionName(@NonNull String transitionName) {
|
/* if (imageContainerCard != null) {
|
||||||
itemView.setTransitionName(transitionName);
|
imageContainerCard.setTransitionName(transitionName);
|
||||||
/* if (imageContainerCard != null) {
|
|
||||||
imageContainerCard.setTransitionName(transitionName);
|
|
||||||
}
|
|
||||||
if (image != null) {
|
|
||||||
image.setTransitionName(transitionName);
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
if (image != null) {
|
||||||
|
image.setTransitionName(transitionName);
|
||||||
|
}*/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.adapter.playlist
|
package code.name.monkey.retromusic.adapter.playlist
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
|
|
@ -1,21 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.adapter.playlist
|
package code.name.monkey.retromusic.adapter.playlist
|
||||||
|
|
||||||
import android.graphics.Bitmap
|
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.os.AsyncTask
|
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.widget.PopupMenu
|
import androidx.appcompat.widget.PopupMenu
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.view.ViewCompat
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import androidx.navigation.findNavController
|
import androidx.lifecycle.lifecycleScope
|
||||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||||
import code.name.monkey.appthemehelper.util.TintHelper
|
import code.name.monkey.appthemehelper.util.TintHelper
|
||||||
import code.name.monkey.retromusic.EXTRA_PLAYLIST
|
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.adapter.base.AbsMultiSelectAdapter
|
import code.name.monkey.retromusic.adapter.base.AbsMultiSelectAdapter
|
||||||
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
|
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
|
||||||
|
@ -28,18 +39,21 @@ import code.name.monkey.retromusic.extensions.show
|
||||||
import code.name.monkey.retromusic.helper.menu.PlaylistMenuHelper
|
import code.name.monkey.retromusic.helper.menu.PlaylistMenuHelper
|
||||||
import code.name.monkey.retromusic.helper.menu.SongsMenuHelper
|
import code.name.monkey.retromusic.helper.menu.SongsMenuHelper
|
||||||
import code.name.monkey.retromusic.interfaces.ICabHolder
|
import code.name.monkey.retromusic.interfaces.ICabHolder
|
||||||
import code.name.monkey.retromusic.model.Playlist
|
import code.name.monkey.retromusic.interfaces.IPlaylistClickListener
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.repository.PlaylistSongsLoader
|
|
||||||
import code.name.monkey.retromusic.util.AutoGeneratedPlaylistBitmap
|
import code.name.monkey.retromusic.util.AutoGeneratedPlaylistBitmap
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.RetroColorUtil
|
import kotlinx.coroutines.Dispatchers.IO
|
||||||
|
import kotlinx.coroutines.Dispatchers.Main
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
class PlaylistAdapter(
|
class PlaylistAdapter(
|
||||||
private val activity: FragmentActivity,
|
private val activity: FragmentActivity,
|
||||||
var dataSet: List<PlaylistWithSongs>,
|
private var dataSet: List<PlaylistWithSongs>,
|
||||||
private var itemLayoutRes: Int,
|
private var itemLayoutRes: Int,
|
||||||
ICabHolder: ICabHolder?
|
ICabHolder: ICabHolder?,
|
||||||
|
private val listener: IPlaylistClickListener
|
||||||
) : AbsMultiSelectAdapter<PlaylistAdapter.ViewHolder, PlaylistWithSongs>(
|
) : AbsMultiSelectAdapter<PlaylistAdapter.ViewHolder, PlaylistWithSongs>(
|
||||||
activity,
|
activity,
|
||||||
ICabHolder,
|
ICabHolder,
|
||||||
|
@ -56,7 +70,7 @@ class PlaylistAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemId(position: Int): Long {
|
override fun getItemId(position: Int): Long {
|
||||||
return dataSet[position].playlistEntity.playListId.toLong()
|
return dataSet[position].playlistEntity.playListId
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
|
@ -88,7 +102,7 @@ class PlaylistAdapter(
|
||||||
} else {
|
} else {
|
||||||
holder.menu?.show()
|
holder.menu?.show()
|
||||||
}
|
}
|
||||||
//PlaylistBitmapLoader(this, holder, playlist).execute()
|
//playlistBitmapLoader(activity, holder, playlist)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getIconRes(): Drawable = TintHelper.createTintedDrawable(
|
private fun getIconRes(): Drawable = TintHelper.createTintedDrawable(
|
||||||
|
@ -158,10 +172,8 @@ class PlaylistAdapter(
|
||||||
if (isInQuickSelectMode) {
|
if (isInQuickSelectMode) {
|
||||||
toggleChecked(layoutPosition)
|
toggleChecked(layoutPosition)
|
||||||
} else {
|
} else {
|
||||||
activity.findNavController(R.id.fragment_container).navigate(
|
ViewCompat.setTransitionName(itemView, "playlist")
|
||||||
R.id.playlistDetailsFragment,
|
listener.onPlaylistClick(dataSet[layoutPosition], itemView)
|
||||||
bundleOf(EXTRA_PLAYLIST to dataSet[layoutPosition])
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,28 +183,35 @@ class PlaylistAdapter(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PlaylistBitmapLoader(
|
private fun playlistBitmapLoader(
|
||||||
private var adapter: PlaylistAdapter,
|
activity: FragmentActivity,
|
||||||
private var viewHolder: ViewHolder,
|
viewHolder: ViewHolder,
|
||||||
private var playlist: Playlist
|
playlist: PlaylistWithSongs
|
||||||
) : AsyncTask<Void, Void, Bitmap>() {
|
) {
|
||||||
|
|
||||||
override fun doInBackground(vararg params: Void?): Bitmap {
|
activity.lifecycleScope.launch(IO) {
|
||||||
val songs = PlaylistSongsLoader.getPlaylistSongList(adapter.activity, playlist)
|
val songs = playlist.songs.toSongs()
|
||||||
return AutoGeneratedPlaylistBitmap.getBitmap(adapter.activity, songs, false, false)
|
val bitmap = AutoGeneratedPlaylistBitmap.getBitmap(activity, songs, false, false)
|
||||||
|
withContext(Main) { viewHolder.image?.setImageBitmap(bitmap) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPostExecute(result: Bitmap?) {
|
/*
|
||||||
super.onPostExecute(result)
|
override fun doInBackground(vararg params: Void?): Bitmap {
|
||||||
viewHolder.image?.setImageBitmap(result)
|
val songs = playlist.songs.toSongs()
|
||||||
val color = RetroColorUtil.getColor(
|
return AutoGeneratedPlaylistBitmap.getBitmap(activity, songs, false, false)
|
||||||
RetroColorUtil.generatePalette(
|
}
|
||||||
result
|
|
||||||
),
|
override fun onPostExecute(result: Bitmap?) {
|
||||||
ATHUtil.resolveColor(adapter.activity, R.attr.colorSurface)
|
super.onPostExecute(result)
|
||||||
)
|
viewHolder.image?.setImageBitmap(result)
|
||||||
viewHolder.paletteColorContainer?.setBackgroundColor(color)
|
val color = RetroColorUtil.getColor(
|
||||||
}
|
RetroColorUtil.generatePalette(
|
||||||
|
result
|
||||||
|
),
|
||||||
|
ATHUtil.resolveColor(activity, R.attr.colorSurface)
|
||||||
|
)
|
||||||
|
viewHolder.paletteColorContainer?.setBackgroundColor(color)
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.adapter.song
|
package code.name.monkey.retromusic.adapter.song
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.adapter.song
|
package code.name.monkey.retromusic.adapter.song
|
||||||
|
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.adapter.song
|
package code.name.monkey.retromusic.adapter.song
|
||||||
|
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
|
@ -5,6 +19,8 @@ import android.view.View
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
||||||
|
import code.name.monkey.retromusic.glide.SongGlideRequest
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote.isPlaying
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote.isPlaying
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote.playNextSong
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote.playNextSong
|
||||||
|
@ -12,6 +28,8 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote.removeFromQueue
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.ViewUtil
|
import code.name.monkey.retromusic.util.ViewUtil
|
||||||
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
|
import com.bumptech.glide.Glide
|
||||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemAdapter
|
import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemAdapter
|
||||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.ItemDraggableRange
|
import com.h6ah4i.android.widget.advrecyclerview.draggable.ItemDraggableRange
|
||||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.annotation.DraggableItemStateFlags
|
import com.h6ah4i.android.widget.advrecyclerview.draggable.annotation.DraggableItemStateFlags
|
||||||
|
@ -41,8 +59,8 @@ class PlayingQueueAdapter(
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: SongAdapter.ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: SongAdapter.ViewHolder, position: Int) {
|
||||||
super.onBindViewHolder(holder, position)
|
super.onBindViewHolder(holder, position)
|
||||||
holder.imageText?.text = (position - current).toString()
|
val song = dataSet[position]
|
||||||
holder.time?.text = MusicUtil.getReadableDurationString(dataSet[position].duration)
|
holder.time?.text = MusicUtil.getReadableDurationString(song.duration)
|
||||||
if (holder.itemViewType == HISTORY || holder.itemViewType == CURRENT) {
|
if (holder.itemViewType == HISTORY || holder.itemViewType == CURRENT) {
|
||||||
setAlpha(holder, 0.5f)
|
setAlpha(holder, 0.5f)
|
||||||
}
|
}
|
||||||
|
@ -58,7 +76,17 @@ class PlayingQueueAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadAlbumCover(song: Song, holder: SongAdapter.ViewHolder) {
|
override fun loadAlbumCover(song: Song, holder: SongAdapter.ViewHolder) {
|
||||||
// We don't want to load it in this adapter
|
if (holder.image == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
SongGlideRequest.Builder.from(Glide.with(activity), song)
|
||||||
|
.checkIgnoreMediaStore(activity)
|
||||||
|
.generatePalette(activity).build()
|
||||||
|
.into(object : RetroMusicColoredTarget(holder.image!!) {
|
||||||
|
override fun onColorReady(colors: MediaNotificationProcessor) {
|
||||||
|
//setColors(colors, holder)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fun swapDataSet(dataSet: List<Song>, position: Int) {
|
fun swapDataSet(dataSet: List<Song>, position: Int) {
|
||||||
|
@ -76,7 +104,6 @@ class PlayingQueueAdapter(
|
||||||
holder.image?.alpha = alpha
|
holder.image?.alpha = alpha
|
||||||
holder.title?.alpha = alpha
|
holder.title?.alpha = alpha
|
||||||
holder.text?.alpha = alpha
|
holder.text?.alpha = alpha
|
||||||
holder.imageText?.alpha = alpha
|
|
||||||
holder.paletteColorContainer?.alpha = alpha
|
holder.paletteColorContainer?.alpha = alpha
|
||||||
holder.dragView?.alpha = alpha
|
holder.dragView?.alpha = alpha
|
||||||
holder.menu?.alpha = alpha
|
holder.menu?.alpha = alpha
|
||||||
|
@ -129,7 +156,6 @@ class PlayingQueueAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
imageText?.visibility = View.VISIBLE
|
|
||||||
dragView?.visibility = View.VISIBLE
|
dragView?.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,17 +222,17 @@ class PlayingQueueAdapter(
|
||||||
private val isPlaying: Boolean = MusicPlayerRemote.isPlaying
|
private val isPlaying: Boolean = MusicPlayerRemote.isPlaying
|
||||||
private val songProgressMillis = 0
|
private val songProgressMillis = 0
|
||||||
override fun onPerformAction() {
|
override fun onPerformAction() {
|
||||||
//currentlyShownSnackbar = null
|
// currentlyShownSnackbar = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSlideAnimationEnd() {
|
override fun onSlideAnimationEnd() {
|
||||||
//initializeSnackBar(adapter, position, activity, isPlaying)
|
// initializeSnackBar(adapter, position, activity, isPlaying)
|
||||||
songToRemove = adapter.dataSet[position]
|
songToRemove = adapter.dataSet[position]
|
||||||
//If song removed was the playing song, then play the next song
|
// If song removed was the playing song, then play the next song
|
||||||
if (isPlaying(songToRemove!!)) {
|
if (isPlaying(songToRemove!!)) {
|
||||||
playNextSong()
|
playNextSong()
|
||||||
}
|
}
|
||||||
//Swipe animation is much smoother when we do the heavy lifting after it's completed
|
// Swipe animation is much smoother when we do the heavy lifting after it's completed
|
||||||
adapter.setSongToRemove(songToRemove!!)
|
adapter.setSongToRemove(songToRemove!!)
|
||||||
removeFromQueue(songToRemove!!)
|
removeFromQueue(songToRemove!!)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.adapter.song
|
package code.name.monkey.retromusic.adapter.song
|
||||||
|
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.adapter.song
|
package code.name.monkey.retromusic.adapter.song
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.adapter.song
|
package code.name.monkey.retromusic.adapter.song
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.adapter.song
|
package code.name.monkey.retromusic.adapter.song
|
||||||
|
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
|
@ -163,7 +177,6 @@ open class SongAdapter(
|
||||||
get() = dataSet[layoutPosition]
|
get() = dataSet[layoutPosition]
|
||||||
|
|
||||||
init {
|
init {
|
||||||
setImageTransitionName(activity.getString(R.string.transition_album_art))
|
|
||||||
menu?.setOnClickListener(object : SongMenuHelper.OnClickSongMenu(activity) {
|
menu?.setOnClickListener(object : SongMenuHelper.OnClickSongMenu(activity) {
|
||||||
override val song: Song
|
override val song: Song
|
||||||
get() = this@ViewHolder.song
|
get() = this@ViewHolder.song
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 Hemanth Savarala.
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU General Public License v3
|
* Licensed under the GNU General Public License v3
|
||||||
*
|
*
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
* This is free software: you can redistribute it and/or modify it
|
||||||
* the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package code.name.monkey.retromusic.appshortcuts
|
package code.name.monkey.retromusic.appshortcuts
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
@ -60,7 +60,10 @@ object AppShortcutIconGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun generateThemedIcon(
|
private fun generateThemedIcon(
|
||||||
context: Context, iconId: Int, foregroundColor: Int, backgroundColor: Int
|
context: Context,
|
||||||
|
iconId: Int,
|
||||||
|
foregroundColor: Int,
|
||||||
|
backgroundColor: Int
|
||||||
): Icon {
|
): Icon {
|
||||||
// Get and tint foreground and background drawables
|
// Get and tint foreground and background drawables
|
||||||
val vectorDrawable = RetroUtil.getTintedVectorDrawable(context, iconId, foregroundColor)
|
val vectorDrawable = RetroUtil.getTintedVectorDrawable(context, iconId, foregroundColor)
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 Hemanth Savarala.
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU General Public License v3
|
* Licensed under the GNU General Public License v3
|
||||||
*
|
*
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
* This is free software: you can redistribute it and/or modify it
|
||||||
* the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package code.name.monkey.retromusic.appshortcuts
|
package code.name.monkey.retromusic.appshortcuts
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 Hemanth Savarala.
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU General Public License v3
|
* Licensed under the GNU General Public License v3
|
||||||
*
|
*
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
* This is free software: you can redistribute it and/or modify it
|
||||||
* the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package code.name.monkey.retromusic.appshortcuts
|
package code.name.monkey.retromusic.appshortcuts
|
||||||
|
|
||||||
import android.annotation.TargetApi
|
import android.annotation.TargetApi
|
||||||
|
@ -39,9 +39,9 @@ class DynamicShortcutManager(private val context: Context) {
|
||||||
)
|
)
|
||||||
|
|
||||||
fun initDynamicShortcuts() {
|
fun initDynamicShortcuts() {
|
||||||
//if (shortcutManager.dynamicShortcuts.size == 0) {
|
// if (shortcutManager.dynamicShortcuts.size == 0) {
|
||||||
shortcutManager.dynamicShortcuts = defaultShortcuts
|
shortcutManager.dynamicShortcuts = defaultShortcuts
|
||||||
//}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateDynamicShortcuts() {
|
fun updateDynamicShortcuts() {
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 Hemanth Savarala.
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU General Public License v3
|
* Licensed under the GNU General Public License v3
|
||||||
*
|
*
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
* This is free software: you can redistribute it and/or modify it
|
||||||
* the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package code.name.monkey.retromusic.appshortcuts.shortcuttype
|
package code.name.monkey.retromusic.appshortcuts.shortcuttype
|
||||||
|
|
||||||
import android.annotation.TargetApi
|
import android.annotation.TargetApi
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 Hemanth Savarala.
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU General Public License v3
|
* Licensed under the GNU General Public License v3
|
||||||
*
|
*
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
* This is free software: you can redistribute it and/or modify it
|
||||||
* the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package code.name.monkey.retromusic.appshortcuts.shortcuttype
|
package code.name.monkey.retromusic.appshortcuts.shortcuttype
|
||||||
|
|
||||||
import android.annotation.TargetApi
|
import android.annotation.TargetApi
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 Hemanth Savarala.
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU General Public License v3
|
* Licensed under the GNU General Public License v3
|
||||||
*
|
*
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
* This is free software: you can redistribute it and/or modify it
|
||||||
* the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package code.name.monkey.retromusic.appshortcuts.shortcuttype
|
package code.name.monkey.retromusic.appshortcuts.shortcuttype
|
||||||
|
|
||||||
import android.annotation.TargetApi
|
import android.annotation.TargetApi
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 Hemanth Savarala.
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU General Public License v3
|
* Licensed under the GNU General Public License v3
|
||||||
*
|
*
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
* This is free software: you can redistribute it and/or modify it
|
||||||
* the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package code.name.monkey.retromusic.appshortcuts.shortcuttype
|
package code.name.monkey.retromusic.appshortcuts.shortcuttype
|
||||||
|
|
||||||
import android.annotation.TargetApi
|
import android.annotation.TargetApi
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 Hemanth Savarala.
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU General Public License v3
|
* Licensed under the GNU General Public License v3
|
||||||
*
|
*
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
* This is free software: you can redistribute it and/or modify it
|
||||||
* the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package code.name.monkey.retromusic.appwidgets
|
package code.name.monkey.retromusic.appwidgets
|
||||||
|
|
||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
|
@ -30,6 +30,7 @@ import code.name.monkey.retromusic.appwidgets.base.BaseAppWidget
|
||||||
import code.name.monkey.retromusic.glide.SongGlideRequest
|
import code.name.monkey.retromusic.glide.SongGlideRequest
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.service.MusicService.*
|
import code.name.monkey.retromusic.service.MusicService.*
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import code.name.monkey.retromusic.util.RetroUtil
|
import code.name.monkey.retromusic.util.RetroUtil
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.request.animation.GlideAnimation
|
import com.bumptech.glide.request.animation.GlideAnimation
|
||||||
|
@ -193,8 +194,11 @@ class AppWidgetBig : BaseAppWidget() {
|
||||||
* Link up various button actions using [PendingIntent].
|
* Link up various button actions using [PendingIntent].
|
||||||
*/
|
*/
|
||||||
private fun linkButtons(context: Context, views: RemoteViews) {
|
private fun linkButtons(context: Context, views: RemoteViews) {
|
||||||
val action =
|
val action = Intent(context, MainActivity::class.java)
|
||||||
Intent(context, MainActivity::class.java).putExtra(MainActivity.EXPAND_PANEL, true)
|
.putExtra(
|
||||||
|
MainActivity.EXPAND_PANEL,
|
||||||
|
PreferenceUtil.isExpandPanel
|
||||||
|
)
|
||||||
var pendingIntent: PendingIntent
|
var pendingIntent: PendingIntent
|
||||||
|
|
||||||
val serviceName = ComponentName(context, MusicService::class.java)
|
val serviceName = ComponentName(context, MusicService::class.java)
|
||||||
|
@ -229,6 +233,5 @@ class AppWidgetBig : BaseAppWidget() {
|
||||||
}
|
}
|
||||||
return mInstance!!
|
return mInstance!!
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 Hemanth Savarala.
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU General Public License v3
|
* Licensed under the GNU General Public License v3
|
||||||
*
|
*
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
* This is free software: you can redistribute it and/or modify it
|
||||||
* the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package code.name.monkey.retromusic.appwidgets
|
package code.name.monkey.retromusic.appwidgets
|
||||||
|
|
||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
|
@ -32,6 +32,7 @@ import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.service.MusicService.*
|
import code.name.monkey.retromusic.service.MusicService.*
|
||||||
import code.name.monkey.retromusic.util.ImageUtil
|
import code.name.monkey.retromusic.util.ImageUtil
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import code.name.monkey.retromusic.util.RetroUtil
|
import code.name.monkey.retromusic.util.RetroUtil
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.request.animation.GlideAnimation
|
import com.bumptech.glide.request.animation.GlideAnimation
|
||||||
|
@ -217,7 +218,11 @@ class AppWidgetCard : BaseAppWidget() {
|
||||||
* Link up various button actions using [PendingIntent].
|
* Link up various button actions using [PendingIntent].
|
||||||
*/
|
*/
|
||||||
private fun linkButtons(context: Context, views: RemoteViews) {
|
private fun linkButtons(context: Context, views: RemoteViews) {
|
||||||
val action: Intent = Intent(context, MainActivity::class.java).putExtra("expand", true)
|
val action = Intent(context, MainActivity::class.java)
|
||||||
|
.putExtra(
|
||||||
|
MainActivity.EXPAND_PANEL,
|
||||||
|
PreferenceUtil.isExpandPanel
|
||||||
|
)
|
||||||
var pendingIntent: PendingIntent
|
var pendingIntent: PendingIntent
|
||||||
|
|
||||||
val serviceName = ComponentName(context, MusicService::class.java)
|
val serviceName = ComponentName(context, MusicService::class.java)
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 Hemanth Savarala.
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU General Public License v3
|
* Licensed under the GNU General Public License v3
|
||||||
*
|
*
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
* This is free software: you can redistribute it and/or modify it
|
||||||
* the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package code.name.monkey.retromusic.appwidgets
|
package code.name.monkey.retromusic.appwidgets
|
||||||
|
|
||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
|
@ -33,6 +33,7 @@ import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.service.MusicService.*
|
import code.name.monkey.retromusic.service.MusicService.*
|
||||||
import code.name.monkey.retromusic.util.ImageUtil
|
import code.name.monkey.retromusic.util.ImageUtil
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import code.name.monkey.retromusic.util.RetroUtil
|
import code.name.monkey.retromusic.util.RetroUtil
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.request.animation.GlideAnimation
|
import com.bumptech.glide.request.animation.GlideAnimation
|
||||||
|
@ -49,7 +50,6 @@ class AppWidgetClassic : BaseAppWidget() {
|
||||||
override fun defaultAppWidget(context: Context, appWidgetIds: IntArray) {
|
override fun defaultAppWidget(context: Context, appWidgetIds: IntArray) {
|
||||||
val appWidgetView = RemoteViews(context.packageName, R.layout.app_widget_classic)
|
val appWidgetView = RemoteViews(context.packageName, R.layout.app_widget_classic)
|
||||||
|
|
||||||
|
|
||||||
appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE)
|
appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE)
|
||||||
appWidgetView.setImageViewResource(R.id.image, R.drawable.default_audio_art)
|
appWidgetView.setImageViewResource(R.id.image, R.drawable.default_audio_art)
|
||||||
appWidgetView.setImageViewBitmap(
|
appWidgetView.setImageViewBitmap(
|
||||||
|
@ -208,7 +208,11 @@ class AppWidgetClassic : BaseAppWidget() {
|
||||||
* Link up various button actions using [PendingIntent].
|
* Link up various button actions using [PendingIntent].
|
||||||
*/
|
*/
|
||||||
private fun linkButtons(context: Context, views: RemoteViews) {
|
private fun linkButtons(context: Context, views: RemoteViews) {
|
||||||
val action = Intent(context, MainActivity::class.java).putExtra("expand", true)
|
val action = Intent(context, MainActivity::class.java)
|
||||||
|
.putExtra(
|
||||||
|
MainActivity.EXPAND_PANEL,
|
||||||
|
PreferenceUtil.isExpandPanel
|
||||||
|
)
|
||||||
var pendingIntent: PendingIntent
|
var pendingIntent: PendingIntent
|
||||||
|
|
||||||
val serviceName = ComponentName(context, MusicService::class.java)
|
val serviceName = ComponentName(context, MusicService::class.java)
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 Hemanth Savarala.
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU General Public License v3
|
* Licensed under the GNU General Public License v3
|
||||||
*
|
*
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
* This is free software: you can redistribute it and/or modify it
|
||||||
* the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package code.name.monkey.retromusic.appwidgets
|
package code.name.monkey.retromusic.appwidgets
|
||||||
|
|
||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
|
@ -31,6 +31,7 @@ import code.name.monkey.retromusic.glide.SongGlideRequest
|
||||||
import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
|
import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.service.MusicService.*
|
import code.name.monkey.retromusic.service.MusicService.*
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import code.name.monkey.retromusic.util.RetroUtil
|
import code.name.monkey.retromusic.util.RetroUtil
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.request.animation.GlideAnimation
|
import com.bumptech.glide.request.animation.GlideAnimation
|
||||||
|
@ -192,7 +193,11 @@ class AppWidgetSmall : BaseAppWidget() {
|
||||||
* Link up various button actions using [PendingIntent].
|
* Link up various button actions using [PendingIntent].
|
||||||
*/
|
*/
|
||||||
private fun linkButtons(context: Context, views: RemoteViews) {
|
private fun linkButtons(context: Context, views: RemoteViews) {
|
||||||
val action = Intent(context, MainActivity::class.java).putExtra("expand", true)
|
val action = Intent(context, MainActivity::class.java)
|
||||||
|
.putExtra(
|
||||||
|
MainActivity.EXPAND_PANEL,
|
||||||
|
PreferenceUtil.isExpandPanel
|
||||||
|
)
|
||||||
var pendingIntent: PendingIntent
|
var pendingIntent: PendingIntent
|
||||||
|
|
||||||
val serviceName = ComponentName(context, MusicService::class.java)
|
val serviceName = ComponentName(context, MusicService::class.java)
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 Hemanth Savarala.
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU General Public License v3
|
* Licensed under the GNU General Public License v3
|
||||||
*
|
*
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
* This is free software: you can redistribute it and/or modify it
|
||||||
* the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package code.name.monkey.retromusic.appwidgets
|
package code.name.monkey.retromusic.appwidgets
|
||||||
|
|
||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
|
@ -28,6 +28,7 @@ import code.name.monkey.retromusic.activities.MainActivity
|
||||||
import code.name.monkey.retromusic.appwidgets.base.BaseAppWidget
|
import code.name.monkey.retromusic.appwidgets.base.BaseAppWidget
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.service.MusicService.*
|
import code.name.monkey.retromusic.service.MusicService.*
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import code.name.monkey.retromusic.util.RetroUtil
|
import code.name.monkey.retromusic.util.RetroUtil
|
||||||
|
|
||||||
class AppWidgetText : BaseAppWidget() {
|
class AppWidgetText : BaseAppWidget() {
|
||||||
|
@ -77,7 +78,11 @@ class AppWidgetText : BaseAppWidget() {
|
||||||
* Link up various button actions using [PendingIntent].
|
* Link up various button actions using [PendingIntent].
|
||||||
*/
|
*/
|
||||||
private fun linkButtons(context: Context, views: RemoteViews) {
|
private fun linkButtons(context: Context, views: RemoteViews) {
|
||||||
val action = Intent(context, MainActivity::class.java).putExtra("expand", true)
|
val action = Intent(context, MainActivity::class.java)
|
||||||
|
.putExtra(
|
||||||
|
MainActivity.EXPAND_PANEL,
|
||||||
|
PreferenceUtil.isExpandPanel
|
||||||
|
)
|
||||||
var pendingIntent: PendingIntent
|
var pendingIntent: PendingIntent
|
||||||
|
|
||||||
val serviceName = ComponentName(context, MusicService::class.java)
|
val serviceName = ComponentName(context, MusicService::class.java)
|
||||||
|
@ -153,10 +158,7 @@ class AppWidgetText : BaseAppWidget() {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pushUpdate(service.applicationContext, appWidgetIds, appWidgetView)
|
pushUpdate(service.applicationContext, appWidgetIds, appWidgetView)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 Hemanth Savarala.
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU General Public License v3
|
* Licensed under the GNU General Public License v3
|
||||||
*
|
*
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
* This is free software: you can redistribute it and/or modify it
|
||||||
* the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package code.name.monkey.retromusic.appwidgets
|
package code.name.monkey.retromusic.appwidgets
|
||||||
|
|
||||||
import android.appwidget.AppWidgetManager
|
import android.appwidget.AppWidgetManager
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 Hemanth Savarala.
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU General Public License v3
|
* Licensed under the GNU General Public License v3
|
||||||
*
|
*
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
* This is free software: you can redistribute it and/or modify it
|
||||||
* the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package code.name.monkey.retromusic.appwidgets.base
|
package code.name.monkey.retromusic.appwidgets.base
|
||||||
|
|
||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
|
@ -40,7 +40,9 @@ abstract class BaseAppWidget : AppWidgetProvider() {
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
override fun onUpdate(
|
override fun onUpdate(
|
||||||
context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray
|
context: Context,
|
||||||
|
appWidgetManager: AppWidgetManager,
|
||||||
|
appWidgetIds: IntArray
|
||||||
) {
|
) {
|
||||||
defaultAppWidget(context, appWidgetIds)
|
defaultAppWidget(context, appWidgetIds)
|
||||||
val updateIntent = Intent(APP_WIDGET_UPDATE)
|
val updateIntent = Intent(APP_WIDGET_UPDATE)
|
||||||
|
@ -62,7 +64,9 @@ abstract class BaseAppWidget : AppWidgetProvider() {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun pushUpdate(
|
protected fun pushUpdate(
|
||||||
context: Context, appWidgetIds: IntArray?, views: RemoteViews
|
context: Context,
|
||||||
|
appWidgetIds: IntArray?,
|
||||||
|
views: RemoteViews
|
||||||
) {
|
) {
|
||||||
val appWidgetManager = AppWidgetManager.getInstance(context)
|
val appWidgetManager = AppWidgetManager.getInstance(context)
|
||||||
if (appWidgetIds != null) {
|
if (appWidgetIds != null) {
|
||||||
|
@ -86,7 +90,9 @@ abstract class BaseAppWidget : AppWidgetProvider() {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun buildPendingIntent(
|
protected fun buildPendingIntent(
|
||||||
context: Context, action: String, serviceName: ComponentName
|
context: Context,
|
||||||
|
action: String,
|
||||||
|
serviceName: ComponentName
|
||||||
): PendingIntent {
|
): PendingIntent {
|
||||||
val intent = Intent(action)
|
val intent = Intent(action)
|
||||||
intent.component = serviceName
|
intent.component = serviceName
|
||||||
|
@ -169,7 +175,11 @@ abstract class BaseAppWidget : AppWidgetProvider() {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun composeRoundedRectPath(
|
protected fun composeRoundedRectPath(
|
||||||
rect: RectF, tl: Float, tr: Float, bl: Float, br: Float
|
rect: RectF,
|
||||||
|
tl: Float,
|
||||||
|
tr: Float,
|
||||||
|
bl: Float,
|
||||||
|
br: Float
|
||||||
): Path {
|
): Path {
|
||||||
val path = Path()
|
val path = Path()
|
||||||
path.moveTo(rect.left + tl, rect.top)
|
path.moveTo(rect.left + tl, rect.top)
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.db
|
package code.name.monkey.retromusic.db
|
||||||
|
|
||||||
import androidx.room.*
|
import androidx.room.*
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.db
|
package code.name.monkey.retromusic.db
|
||||||
|
|
||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.db
|
package code.name.monkey.retromusic.db
|
||||||
|
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.db
|
package code.name.monkey.retromusic.db
|
||||||
|
|
||||||
import androidx.room.ColumnInfo
|
import androidx.room.ColumnInfo
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.db
|
package code.name.monkey.retromusic.db
|
||||||
|
|
||||||
import androidx.room.*
|
import androidx.room.*
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.db
|
package code.name.monkey.retromusic.db
|
||||||
|
|
||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.db
|
package code.name.monkey.retromusic.db
|
||||||
|
|
||||||
import androidx.room.*
|
import androidx.room.*
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.db
|
package code.name.monkey.retromusic.db
|
||||||
|
|
||||||
import androidx.room.ColumnInfo
|
import androidx.room.ColumnInfo
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.db
|
package code.name.monkey.retromusic.db
|
||||||
|
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
|
@ -45,12 +59,9 @@ interface PlaylistDao {
|
||||||
@Delete
|
@Delete
|
||||||
suspend fun deletePlaylistSongs(songs: List<SongEntity>)
|
suspend fun deletePlaylistSongs(songs: List<SongEntity>)
|
||||||
|
|
||||||
|
|
||||||
@Query("SELECT * FROM SongEntity WHERE playlist_creator_id= :playlistId")
|
@Query("SELECT * FROM SongEntity WHERE playlist_creator_id= :playlistId")
|
||||||
fun favoritesSongsLiveData(playlistId: Long): LiveData<List<SongEntity>>
|
fun favoritesSongsLiveData(playlistId: Long): LiveData<List<SongEntity>>
|
||||||
|
|
||||||
@Query("SELECT * FROM SongEntity WHERE playlist_creator_id= :playlistId")
|
@Query("SELECT * FROM SongEntity WHERE playlist_creator_id= :playlistId")
|
||||||
fun favoritesSongs(playlistId: Long): List<SongEntity>
|
fun favoritesSongs(playlistId: Long): List<SongEntity>
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.db
|
package code.name.monkey.retromusic.db
|
||||||
|
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.db
|
package code.name.monkey.retromusic.db
|
||||||
|
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
|
@ -14,4 +28,3 @@ data class PlaylistWithSongs(
|
||||||
)
|
)
|
||||||
val songs: List<SongEntity>
|
val songs: List<SongEntity>
|
||||||
) : Parcelable
|
) : Parcelable
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.db
|
package code.name.monkey.retromusic.db
|
||||||
|
|
||||||
import androidx.room.Database
|
import androidx.room.Database
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.db
|
package code.name.monkey.retromusic.db
|
||||||
|
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
|
@ -36,4 +50,3 @@ class SongEntity(
|
||||||
@ColumnInfo(name = "album_artist")
|
@ColumnInfo(name = "album_artist")
|
||||||
val albumArtist: String?
|
val albumArtist: String?
|
||||||
) : Parcelable
|
) : Parcelable
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.db
|
package code.name.monkey.retromusic.db
|
||||||
|
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
|
@ -137,4 +151,3 @@ fun List<Song>.toSongsEntity(playlistEntity: PlaylistEntity): List<SongEntity> {
|
||||||
it.toSongEntity(playlistEntity.playListId)
|
it.toSongEntity(playlistEntity.playListId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.dialogs
|
package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
|
@ -47,7 +61,6 @@ class AddToPlaylistDialog : DialogFragment() {
|
||||||
return adapter
|
return adapter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
val playlistEntities = extraNotNull<List<PlaylistEntity>>(EXTRA_PLAYLISTS).value
|
val playlistEntities = extraNotNull<List<PlaylistEntity>>(EXTRA_PLAYLISTS).value
|
||||||
val songs = extraNotNull<List<Song>>(EXTRA_SONG).value
|
val songs = extraNotNull<List<Song>>(EXTRA_SONG).value
|
||||||
|
|
|
@ -7,150 +7,149 @@ import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.fragment.app.DialogFragment;
|
import androidx.fragment.app.DialogFragment;
|
||||||
|
import code.name.monkey.retromusic.R;
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R;
|
public class BlacklistFolderChooserDialog extends DialogFragment
|
||||||
|
implements MaterialDialog.ListCallback {
|
||||||
|
|
||||||
public class BlacklistFolderChooserDialog extends DialogFragment implements MaterialDialog.ListCallback {
|
String initialPath = Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||||
|
private File parentFolder;
|
||||||
|
private File[] parentContents;
|
||||||
|
private boolean canGoUp = false;
|
||||||
|
private FolderCallback callback;
|
||||||
|
|
||||||
String initialPath = Environment.getExternalStorageDirectory().getAbsolutePath();
|
public static BlacklistFolderChooserDialog create() {
|
||||||
private File parentFolder;
|
return new BlacklistFolderChooserDialog();
|
||||||
private File[] parentContents;
|
}
|
||||||
private boolean canGoUp = false;
|
|
||||||
private FolderCallback callback;
|
|
||||||
|
|
||||||
public static BlacklistFolderChooserDialog create() {
|
private String[] getContentsArray() {
|
||||||
return new BlacklistFolderChooserDialog();
|
if (parentContents == null) {
|
||||||
|
if (canGoUp) {
|
||||||
|
return new String[] {".."};
|
||||||
|
}
|
||||||
|
return new String[] {};
|
||||||
}
|
}
|
||||||
|
String[] results = new String[parentContents.length + (canGoUp ? 1 : 0)];
|
||||||
private String[] getContentsArray() {
|
if (canGoUp) {
|
||||||
if (parentContents == null) {
|
results[0] = "..";
|
||||||
if (canGoUp) {
|
|
||||||
return new String[]{".."};
|
|
||||||
}
|
|
||||||
return new String[]{};
|
|
||||||
}
|
|
||||||
String[] results = new String[parentContents.length + (canGoUp ? 1 : 0)];
|
|
||||||
if (canGoUp) {
|
|
||||||
results[0] = "..";
|
|
||||||
}
|
|
||||||
for (int i = 0; i < parentContents.length; i++) {
|
|
||||||
results[canGoUp ? i + 1 : i] = parentContents[i].getName();
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < parentContents.length; i++) {
|
||||||
private File[] listFiles() {
|
results[canGoUp ? i + 1 : i] = parentContents[i].getName();
|
||||||
File[] contents = parentFolder.listFiles();
|
|
||||||
List<File> results = new ArrayList<>();
|
|
||||||
if (contents != null) {
|
|
||||||
for (File fi : contents) {
|
|
||||||
if (fi.isDirectory()) {
|
|
||||||
results.add(fi);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Collections.sort(results, new FolderSorter());
|
|
||||||
return results.toArray(new File[results.size()]);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
private File[] listFiles() {
|
||||||
@Override
|
File[] contents = parentFolder.listFiles();
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
List<File> results = new ArrayList<>();
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
if (contents != null) {
|
||||||
&& ActivityCompat.checkSelfPermission(
|
for (File fi : contents) {
|
||||||
|
if (fi.isDirectory()) {
|
||||||
|
results.add(fi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Collections.sort(results, new FolderSorter());
|
||||||
|
return results.toArray(new File[results.size()]);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
||||||
|
&& ActivityCompat.checkSelfPermission(
|
||||||
requireActivity(), Manifest.permission.READ_EXTERNAL_STORAGE)
|
requireActivity(), Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
!= PackageManager.PERMISSION_GRANTED) {
|
||||||
return new MaterialDialog.Builder(requireActivity())
|
return new MaterialDialog.Builder(requireActivity())
|
||||||
.title(R.string.md_error_label)
|
.title(R.string.md_error_label)
|
||||||
.content(R.string.md_storage_perm_error)
|
.content(R.string.md_storage_perm_error)
|
||||||
.positiveText(android.R.string.ok)
|
.positiveText(android.R.string.ok)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
savedInstanceState = new Bundle();
|
savedInstanceState = new Bundle();
|
||||||
}
|
}
|
||||||
if (!savedInstanceState.containsKey("current_path")) {
|
if (!savedInstanceState.containsKey("current_path")) {
|
||||||
savedInstanceState.putString("current_path", initialPath);
|
savedInstanceState.putString("current_path", initialPath);
|
||||||
}
|
}
|
||||||
parentFolder = new File(savedInstanceState.getString("current_path", File.pathSeparator));
|
parentFolder = new File(savedInstanceState.getString("current_path", File.pathSeparator));
|
||||||
checkIfCanGoUp();
|
checkIfCanGoUp();
|
||||||
parentContents = listFiles();
|
parentContents = listFiles();
|
||||||
MaterialDialog.Builder builder = new MaterialDialog.Builder(requireContext())
|
MaterialDialog.Builder builder =
|
||||||
.title(parentFolder.getAbsolutePath())
|
new MaterialDialog.Builder(requireContext())
|
||||||
.items((CharSequence[]) getContentsArray())
|
.title(parentFolder.getAbsolutePath())
|
||||||
.itemsCallback(this)
|
.items((CharSequence[]) getContentsArray())
|
||||||
.autoDismiss(false)
|
.itemsCallback(this)
|
||||||
.onPositive((dialog, which) -> {
|
.autoDismiss(false)
|
||||||
callback.onFolderSelection(BlacklistFolderChooserDialog.this, parentFolder);
|
.onPositive(
|
||||||
dismiss();
|
(dialog, which) -> {
|
||||||
|
callback.onFolderSelection(BlacklistFolderChooserDialog.this, parentFolder);
|
||||||
|
dismiss();
|
||||||
})
|
})
|
||||||
.onNegative((materialDialog, dialogAction) -> dismiss())
|
.onNegative((materialDialog, dialogAction) -> dismiss())
|
||||||
.positiveText(R.string.add_action)
|
.positiveText(R.string.add_action)
|
||||||
.negativeText(android.R.string.cancel);
|
.negativeText(android.R.string.cancel);
|
||||||
return builder.build();
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSelection(MaterialDialog materialDialog, View view, int i, CharSequence s) {
|
||||||
|
if (canGoUp && i == 0) {
|
||||||
|
parentFolder = parentFolder.getParentFile();
|
||||||
|
if (parentFolder.getAbsolutePath().equals("/storage/emulated")) {
|
||||||
|
parentFolder = parentFolder.getParentFile();
|
||||||
|
}
|
||||||
|
checkIfCanGoUp();
|
||||||
|
} else {
|
||||||
|
parentFolder = parentContents[canGoUp ? i - 1 : i];
|
||||||
|
canGoUp = true;
|
||||||
|
if (parentFolder.getAbsolutePath().equals("/storage/emulated")) {
|
||||||
|
parentFolder = Environment.getExternalStorageDirectory();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkIfCanGoUp() {
|
||||||
|
canGoUp = parentFolder.getParent() != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reload() {
|
||||||
|
parentContents = listFiles();
|
||||||
|
MaterialDialog dialog = (MaterialDialog) getDialog();
|
||||||
|
dialog.setTitle(parentFolder.getAbsolutePath());
|
||||||
|
dialog.setItems((CharSequence[]) getContentsArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putString("current_path", parentFolder.getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCallback(FolderCallback callback) {
|
||||||
|
this.callback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface FolderCallback {
|
||||||
|
void onFolderSelection(@NonNull BlacklistFolderChooserDialog dialog, @NonNull File folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class FolderSorter implements Comparator<File> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSelection(MaterialDialog materialDialog, View view, int i, CharSequence s) {
|
public int compare(File lhs, File rhs) {
|
||||||
if (canGoUp && i == 0) {
|
return lhs.getName().compareTo(rhs.getName());
|
||||||
parentFolder = parentFolder.getParentFile();
|
|
||||||
if (parentFolder.getAbsolutePath().equals("/storage/emulated")) {
|
|
||||||
parentFolder = parentFolder.getParentFile();
|
|
||||||
}
|
|
||||||
checkIfCanGoUp();
|
|
||||||
} else {
|
|
||||||
parentFolder = parentContents[canGoUp ? i - 1 : i];
|
|
||||||
canGoUp = true;
|
|
||||||
if (parentFolder.getAbsolutePath().equals("/storage/emulated")) {
|
|
||||||
parentFolder = Environment.getExternalStorageDirectory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkIfCanGoUp() {
|
|
||||||
canGoUp = parentFolder.getParent() != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void reload() {
|
|
||||||
parentContents = listFiles();
|
|
||||||
MaterialDialog dialog = (MaterialDialog) getDialog();
|
|
||||||
dialog.setTitle(parentFolder.getAbsolutePath());
|
|
||||||
dialog.setItems((CharSequence[]) getContentsArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
|
||||||
super.onSaveInstanceState(outState);
|
|
||||||
outState.putString("current_path", parentFolder.getAbsolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCallback(FolderCallback callback) {
|
|
||||||
this.callback = callback;
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface FolderCallback {
|
|
||||||
void onFolderSelection(@NonNull BlacklistFolderChooserDialog dialog, @NonNull File folder);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class FolderSorter implements Comparator<File> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compare(File lhs, File rhs) {
|
|
||||||
return lhs.getName().compareTo(rhs.getName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.dialogs
|
package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
|
@ -54,17 +68,8 @@ class CreatePlaylistDialog : DialogFragment() {
|
||||||
) { _, _ ->
|
) { _, _ ->
|
||||||
val playlistName = playlistView.text.toString()
|
val playlistName = playlistView.text.toString()
|
||||||
if (!TextUtils.isEmpty(playlistName)) {
|
if (!TextUtils.isEmpty(playlistName)) {
|
||||||
lifecycleScope.launch(Dispatchers.IO) {
|
libraryViewModel.addToPlaylist(playlistName, songs)
|
||||||
if (libraryViewModel.checkPlaylistExists(playlistName).isEmpty()) {
|
|
||||||
val playlistId: Long =
|
|
||||||
libraryViewModel.createPlaylist(PlaylistEntity(playlistName = playlistName))
|
|
||||||
libraryViewModel.insertSongs(songs.map { it.toSongEntity(playlistId) })
|
|
||||||
libraryViewModel.forceReload(Playlists)
|
|
||||||
} else {
|
|
||||||
Toast.makeText(requireContext(), "Playlist exists", Toast.LENGTH_SHORT)
|
|
||||||
.show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
playlistContainer.error = "Playlist is can't be empty"
|
playlistContainer.error = "Playlist is can't be empty"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.dialogs
|
package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
|
@ -65,5 +79,4 @@ class DeletePlaylistDialog : DialogFragment() {
|
||||||
.create()
|
.create()
|
||||||
.colorButtons()
|
.colorButtons()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.dialogs
|
package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.dialogs
|
package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.dialogs
|
package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
|
@ -12,7 +26,6 @@ import code.name.monkey.retromusic.extensions.colorButtons
|
||||||
import code.name.monkey.retromusic.extensions.extraNotNull
|
import code.name.monkey.retromusic.extensions.extraNotNull
|
||||||
import code.name.monkey.retromusic.extensions.materialDialog
|
import code.name.monkey.retromusic.extensions.materialDialog
|
||||||
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
||||||
import code.name.monkey.retromusic.fragments.ReloadType.Playlists
|
|
||||||
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||||
|
|
||||||
class RemoveSongFromPlaylistDialog : DialogFragment() {
|
class RemoveSongFromPlaylistDialog : DialogFragment() {
|
||||||
|
@ -60,7 +73,6 @@ class RemoveSongFromPlaylistDialog : DialogFragment() {
|
||||||
.setMessage(pair.second)
|
.setMessage(pair.second)
|
||||||
.setPositiveButton(R.string.remove_action) { _, _ ->
|
.setPositiveButton(R.string.remove_action) { _, _ ->
|
||||||
libraryViewModel.deleteSongsInPlaylist(songs)
|
libraryViewModel.deleteSongsInPlaylist(songs)
|
||||||
libraryViewModel.forceReload(Playlists)
|
|
||||||
}
|
}
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
.create()
|
.create()
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.dialogs
|
package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
|
*
|
||||||
|
* Licensed under the GNU General Public License v3
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.dialogs
|
package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
|
@ -19,7 +33,6 @@ import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
|
|
||||||
class SavePlaylistDialog : DialogFragment() {
|
class SavePlaylistDialog : DialogFragment() {
|
||||||
companion object {
|
companion object {
|
||||||
fun create(playlistWithSongs: PlaylistWithSongs): SavePlaylistDialog {
|
fun create(playlistWithSongs: PlaylistWithSongs): SavePlaylistDialog {
|
||||||
|
@ -41,7 +54,6 @@ class SavePlaylistDialog : DialogFragment() {
|
||||||
arrayOf<String>(file.path),
|
arrayOf<String>(file.path),
|
||||||
null
|
null
|
||||||
) { _, _ ->
|
) { _, _ ->
|
||||||
|
|
||||||
}
|
}
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 Hemanth Savarala.
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU General Public License v3
|
* Licensed under the GNU General Public License v3
|
||||||
*
|
*
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
* This is free software: you can redistribute it and/or modify it
|
||||||
* the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package code.name.monkey.retromusic.dialogs
|
package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
|
@ -130,7 +130,6 @@ class SleepTimerDialog : DialogFragment() {
|
||||||
}
|
}
|
||||||
.create()
|
.create()
|
||||||
.colorButtons()
|
.colorButtons()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateTimeDisplayTime() {
|
private fun updateTimeDisplayTime() {
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 Hemanth Savarala.
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU General Public License v3
|
* Licensed under the GNU General Public License v3
|
||||||
*
|
*
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
* This is free software: you can redistribute it and/or modify it
|
||||||
* the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package code.name.monkey.retromusic.dialogs
|
package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
|
@ -31,13 +31,13 @@ import code.name.monkey.retromusic.extensions.colorButtons
|
||||||
import code.name.monkey.retromusic.extensions.materialDialog
|
import code.name.monkey.retromusic.extensions.materialDialog
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
|
import java.io.File
|
||||||
|
import java.io.IOException
|
||||||
import org.jaudiotagger.audio.AudioFileIO
|
import org.jaudiotagger.audio.AudioFileIO
|
||||||
import org.jaudiotagger.audio.exceptions.CannotReadException
|
import org.jaudiotagger.audio.exceptions.CannotReadException
|
||||||
import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
|
import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
|
||||||
import org.jaudiotagger.audio.exceptions.ReadOnlyFileException
|
import org.jaudiotagger.audio.exceptions.ReadOnlyFileException
|
||||||
import org.jaudiotagger.tag.TagException
|
import org.jaudiotagger.tag.TagException
|
||||||
import java.io.File
|
|
||||||
import java.io.IOException
|
|
||||||
|
|
||||||
class SongDetailDialog : DialogFragment() {
|
class SongDetailDialog : DialogFragment() {
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 Hemanth Savarala.
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU General Public License v3
|
* Licensed under the GNU General Public License v3
|
||||||
*
|
*
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
* This is free software: you can redistribute it and/or modify it
|
||||||
* the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package code.name.monkey.retromusic.dialogs
|
package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
|
|
|
@ -1,20 +1,21 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 Hemanth Savarala.
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU General Public License v3
|
* Licensed under the GNU General Public License v3
|
||||||
*
|
*
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
* This is free software: you can redistribute it and/or modify it
|
||||||
* the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package code.name.monkey.retromusic.extensions
|
package code.name.monkey.retromusic.extensions
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
import androidx.annotation.DimenRes
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||||
import com.google.android.material.appbar.MaterialToolbar
|
import com.google.android.material.appbar.MaterialToolbar
|
||||||
|
@ -34,3 +35,7 @@ inline fun <reified T : Any> Activity.extraNotNull(key: String, default: T? = nu
|
||||||
val value = intent?.extras?.get(key)
|
val value = intent?.extras?.get(key)
|
||||||
requireNotNull(if (value is T) value else default) { key }
|
requireNotNull(if (value is T) value else default) { key }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Activity.dip(@DimenRes id: Int): Int {
|
||||||
|
return resources.getDimensionPixelSize(id)
|
||||||
|
}
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 Hemanth Savarala.
|
* Copyright (c) 2020 Hemanth Savarla.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU General Public License v3
|
* Licensed under the GNU General Public License v3
|
||||||
*
|
*
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
* This is free software: you can redistribute it and/or modify it
|
||||||
* the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package code.name.monkey.retromusic.extensions
|
package code.name.monkey.retromusic.extensions
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
|
@ -180,7 +180,6 @@ fun ProgressIndicator.applyColor(color: Int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun TextInputEditText.accentColor() {
|
fun TextInputEditText.accentColor() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun AppCompatImageView.accentColor(): Int {
|
fun AppCompatImageView.accentColor(): Int {
|
||||||
|
@ -203,4 +202,3 @@ fun Drawable.tint(context: Context, @ColorRes color: Int): Drawable {
|
||||||
fun Context.getColorCompat(@ColorRes colorRes: Int): Int {
|
fun Context.getColorCompat(@ColorRes colorRes: Int): Int {
|
||||||
return ContextCompat.getColor(this, colorRes)
|
return ContextCompat.getColor(this, colorRes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue