AndroidX lib refactor
This commit is contained in:
parent
b3eb12aebd
commit
08f0b5e76e
581 changed files with 5470 additions and 6070 deletions
|
@ -1,11 +1,11 @@
|
|||
package code.name.monkey.retromusic.dialogs;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.DefaultItemAnimator;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
|
@ -6,9 +6,6 @@ import android.content.pm.PackageManager;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.View;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
|
@ -19,6 +16,9 @@ import java.util.Collections;
|
|||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import code.name.monkey.retromusic.R;
|
||||
|
||||
/**
|
||||
|
@ -26,13 +26,15 @@ import code.name.monkey.retromusic.R;
|
|||
*/
|
||||
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() {
|
||||
return new BlacklistFolderChooserDialog();
|
||||
}
|
||||
|
||||
private String[] getContentsArray() {
|
||||
if (parentContents == null) {
|
||||
|
@ -66,10 +68,6 @@ public class BlacklistFolderChooserDialog extends DialogFragment implements Mate
|
|||
return null;
|
||||
}
|
||||
|
||||
public static BlacklistFolderChooserDialog create() {
|
||||
return new BlacklistFolderChooserDialog();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
|
|
|
@ -1 +1 @@
|
|||
package code.name.monkey.retromusic.dialogs;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import com.afollestad.materialdialogs.internal.ThemeSingleton;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Objects;
import butterknife.BindView;
import butterknife.ButterKnife;
import code.name.monkey.appthemehelper.util.ATHUtil;
import code.name.monkey.appthemehelper.util.ColorUtil;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.util.PreferenceUtil;
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment;
public class ChangelogDialog extends RoundedBottomSheetDialogFragment {
@BindView(R.id.web_view)
WebView webView;
public static ChangelogDialog create() {
return new ChangelogDialog();
}
public static void setChangelogRead(@NonNull Context context) {
try {
PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
int currentVersion = pInfo.versionCode;
PreferenceUtil.getInstance(context).setLastChangeLogVersion(currentVersion);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
private static String colorToHex(int color) {
return Integer.toHexString(color).substring(2);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View layout = inflater.inflate(R.layout.dialog_changelog, container, false);
ButterKnife.bind(this, layout);
return layout;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
try {
// Load from phonograph-changelog.html in the assets folder
StringBuilder buf = new StringBuilder();
InputStream json = Objects.requireNonNull(getActivity()).getAssets().open
("retro-changelog.html");
BufferedReader in = new BufferedReader(new InputStreamReader(json, "UTF-8"));
String str;
while ((str = in.readLine()) != null)
buf.append(str);
in.close();
// Inject color values for WebView body background and links
final String backgroundColor = colorToHex(ATHUtil.resolveColor(getActivity(), R.attr.md_background_color, Color.parseColor(ThemeSingleton.get().darkTheme ? "#424242" : "#ffffff")));
final String contentColor = ThemeSingleton.get().darkTheme ? "#ffffff" : "#000000";
webView.loadData(buf.toString()
.replace("{style-placeholder}",
String.format("body { background-color: %s; color: %s; }", backgroundColor, contentColor))
.replace("{link-color}", colorToHex(ThemeSingleton.get().positiveColor.getDefaultColor()))
.replace("{link-color-active}", colorToHex(ColorUtil.lightenColor(ThemeSingleton.get().positiveColor.getDefaultColor())))
, "text/html", "UTF-8");
} catch (Throwable e) {
webView.loadData("<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", "UTF-8");
}
setChangelogRead(getActivity());
}
}
|
||||
package code.name.monkey.retromusic.dialogs;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import com.afollestad.materialdialogs.internal.ThemeSingleton;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Objects;
import butterknife.BindView;
import butterknife.ButterKnife;
import code.name.monkey.appthemehelper.util.ATHUtil;
import code.name.monkey.appthemehelper.util.ColorUtil;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.util.PreferenceUtil;
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment;
public class ChangelogDialog extends RoundedBottomSheetDialogFragment {
@BindView(R.id.web_view)
WebView webView;
public static ChangelogDialog create() {
return new ChangelogDialog();
}
private static void setChangelogRead(@NonNull Context context) {
try {
PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
int currentVersion = pInfo.versionCode;
PreferenceUtil.getInstance(context).setLastChangeLogVersion(currentVersion);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
private static String colorToHex(int color) {
return Integer.toHexString(color).substring(2);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View layout = inflater.inflate(R.layout.dialog_changelog, container, false);
ButterKnife.bind(this, layout);
return layout;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
try {
// Load from phonograph-changelog.html in the assets folder
StringBuilder buf = new StringBuilder();
InputStream json = Objects.requireNonNull(getActivity()).getAssets().open
("retro-changelog.html");
BufferedReader in = new BufferedReader(new InputStreamReader(json, "UTF-8"));
String str;
while ((str = in.readLine()) != null)
buf.append(str);
in.close();
// Inject color values for WebView body background and links
final String backgroundColor = colorToHex(ATHUtil.resolveColor(getActivity(), R.attr.md_background_color, Color.parseColor(ThemeSingleton.get().darkTheme ? "#424242" : "#ffffff")));
final String contentColor = ThemeSingleton.get().darkTheme ? "#ffffff" : "#000000";
webView.loadData(buf.toString()
.replace("{style-placeholder}",
String.format("body { background-color: %s; color: %s; }", backgroundColor, contentColor))
.replace("{link-color}", colorToHex(ThemeSingleton.get().positiveColor.getDefaultColor()))
.replace("{link-color-active}", colorToHex(ColorUtil.lightenColor(ThemeSingleton.get().positiveColor.getDefaultColor())))
, "text/html", "UTF-8");
} catch (Throwable e) {
webView.loadData("<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", "UTF-8");
}
setChangelogRead(getActivity());
}
}
|
|
@ -2,8 +2,8 @@ package code.name.monkey.retromusic.dialogs;
|
|||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import android.text.Html;
|
||||
|
||||
import com.afollestad.materialdialogs.DialogAction;
|
||||
|
|
|
@ -1,24 +1,25 @@
|
|||
package code.name.monkey.retromusic.dialogs;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.TextInputEditText;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import code.name.monkey.appthemehelper.ThemeStore;
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil;
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.model.Song;
|
||||
import code.name.monkey.retromusic.util.PlaylistsUtil;
|
||||
|
@ -32,14 +33,17 @@ public class CreatePlaylistDialog extends RoundedBottomSheetDialogFragment {
|
|||
@BindView(R.id.option_1)
|
||||
TextInputEditText playlistName;
|
||||
|
||||
@BindView(R.id.action_new_playlist)
|
||||
TextInputLayout textInputLayout;
|
||||
|
||||
@BindView(R.id.action_cancel)
|
||||
TextView actionCancel;
|
||||
MaterialButton actionCancel;
|
||||
|
||||
@BindView(R.id.action_create)
|
||||
TextView actionCreate;
|
||||
MaterialButton actionCreate;
|
||||
|
||||
@BindView(R.id.action_create_container)
|
||||
CardView actionCreateContainer;
|
||||
@BindView(R.id.title)
|
||||
TextView title;
|
||||
|
||||
@NonNull
|
||||
public static CreatePlaylistDialog create() {
|
||||
|
@ -76,16 +80,17 @@ public class CreatePlaylistDialog extends RoundedBottomSheetDialogFragment {
|
|||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
int accentColor = ThemeStore.accentColor(Objects.requireNonNull(getContext()));
|
||||
actionCreateContainer.setCardBackgroundColor(ThemeStore.accentColor(getContext()));
|
||||
actionCreate.setBackgroundTintList(ColorStateList.valueOf(accentColor));
|
||||
actionCancel.setStrokeColor(ColorStateList.valueOf(accentColor));
|
||||
actionCancel.setTextColor(accentColor);
|
||||
playlistName.setHintTextColor(ColorStateList.valueOf(accentColor));
|
||||
|
||||
int primaryTextColor = MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil
|
||||
.isColorLight(accentColor));
|
||||
int secondaryTextColor = MaterialValueHelper.getSecondaryTextColor(getContext(), ColorUtil
|
||||
.isColorLight(accentColor));
|
||||
|
||||
actionCreate.setTextColor(primaryTextColor);
|
||||
actionCancel.setTextColor(secondaryTextColor);
|
||||
textInputLayout.setBoxStrokeColor(accentColor);
|
||||
textInputLayout.setDefaultHintTextColor(ColorStateList.valueOf(accentColor));
|
||||
|
||||
playlistName.setHintTextColor(accentColor);
|
||||
playlistName.setTextColor(ThemeStore.textColorPrimary(getContext()));
|
||||
title.setTextColor(ThemeStore.textColorPrimary(getContext()));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,19 +1,24 @@
|
|||
package code.name.monkey.retromusic.dialogs;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import code.name.monkey.appthemehelper.ThemeStore;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.model.Playlist;
|
||||
import code.name.monkey.retromusic.util.PlaylistsUtil;
|
||||
|
@ -23,11 +28,13 @@ import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment;
|
|||
public class DeletePlaylistDialog extends RoundedBottomSheetDialogFragment {
|
||||
|
||||
@BindView(R.id.action_delete)
|
||||
TextView delete;
|
||||
MaterialButton actionDelete;
|
||||
|
||||
@BindView(R.id.title)
|
||||
TextView title;
|
||||
|
||||
@BindView(R.id.action_cancel)
|
||||
TextView cancel;
|
||||
MaterialButton actionCancel;
|
||||
|
||||
@NonNull
|
||||
public static DeletePlaylistDialog create(Playlist playlist) {
|
||||
|
@ -47,12 +54,14 @@ public class DeletePlaylistDialog extends RoundedBottomSheetDialogFragment {
|
|||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View layout = inflater.inflate(R.layout.dialog_delete_playlist, container, false);
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View layout = inflater.inflate(R.layout.dialog_delete, container, false);
|
||||
ButterKnife.bind(this, layout);
|
||||
return layout;
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
@ -68,8 +77,16 @@ public class DeletePlaylistDialog extends RoundedBottomSheetDialogFragment {
|
|||
title = R.string.delete_playlist_title;
|
||||
content = Html.fromHtml(getString(R.string.delete_playlist_x, playlists.get(0).name));
|
||||
}
|
||||
this.title.setText(title);
|
||||
this.delete.setText(content);
|
||||
this.title.setText(content);
|
||||
this.actionDelete.setText(title);
|
||||
|
||||
this.title.setTextColor(ThemeStore.textColorPrimary(getContext()));
|
||||
|
||||
int accentColor = ThemeStore.accentColor(Objects.requireNonNull(getContext()));
|
||||
actionDelete.setBackgroundTintList(ColorStateList.valueOf(accentColor));
|
||||
actionCancel.setStrokeColor(ColorStateList.valueOf(accentColor));
|
||||
actionCancel.setTextColor(accentColor);
|
||||
|
||||
}
|
||||
|
||||
@OnClick({R.id.action_cancel, R.id.action_delete})
|
||||
|
|
|
@ -1,14 +1,20 @@
|
|||
package code.name.monkey.retromusic.dialogs;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
@ -18,17 +24,15 @@ import code.name.monkey.retromusic.model.Song;
|
|||
import code.name.monkey.retromusic.util.MusicUtil;
|
||||
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class DeleteSongsDialog extends RoundedBottomSheetDialogFragment {
|
||||
@BindView(R.id.action_delete)
|
||||
MaterialButton actionDelete;
|
||||
|
||||
@BindView(R.id.title)
|
||||
TextView title;
|
||||
|
||||
@BindView(R.id.action_delete)
|
||||
TextView delete;
|
||||
|
||||
@BindView(R.id.action_cancel)
|
||||
TextView cancel;
|
||||
MaterialButton actionCancel;
|
||||
|
||||
@NonNull
|
||||
public static DeleteSongsDialog create(Song song) {
|
||||
|
@ -70,9 +74,10 @@ public class DeleteSongsDialog extends RoundedBottomSheetDialogFragment {
|
|||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
title.setTextColor(ThemeStore.textColorPrimary(getContext()));
|
||||
delete.setTextColor(ThemeStore.textColorPrimary(getContext()));
|
||||
cancel.setTextColor(ThemeStore.textColorPrimary(getContext()));
|
||||
|
||||
int accentColor = ThemeStore.accentColor(Objects.requireNonNull(getContext()));
|
||||
actionDelete.setBackgroundTintList(ColorStateList.valueOf(accentColor));
|
||||
actionCancel.setStrokeColor(ColorStateList.valueOf(accentColor));
|
||||
actionCancel.setTextColor(accentColor);
|
||||
|
||||
//noinspection unchecked,ConstantConditions
|
||||
final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs");
|
||||
|
@ -91,7 +96,7 @@ public class DeleteSongsDialog extends RoundedBottomSheetDialogFragment {
|
|||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View layout = inflater.inflate(R.layout.dialog_delete_songs, container, false);
|
||||
View layout = inflater.inflate(R.layout.dialog_delete, container, false);
|
||||
ButterKnife.bind(this, layout);
|
||||
return layout;
|
||||
}
|
||||
|
|
|
@ -2,10 +2,10 @@ package code.name.monkey.retromusic.dialogs;
|
|||
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.AppCompatTextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -40,10 +40,12 @@ import static code.name.monkey.retromusic.Constants.USER_PROFILE;
|
|||
public class HomeOptionDialog extends RoundedBottomSheetDialogFragment {
|
||||
|
||||
private static final String TAG = "HomeOptionDialog";
|
||||
static ButterKnife.Setter<TextView, Integer> textColor = (view, value, index) -> view.setTextColor(value.intValue());
|
||||
private static ButterKnife.Setter<TextView, Integer> textColor = (view, value, index) -> view.setTextColor(value.intValue());
|
||||
Unbinder mUnbinder;
|
||||
|
||||
@BindView(R.id.user_image_bottom)
|
||||
CircularImageView userImageBottom;
|
||||
|
||||
@BindView(R.id.title_welcome)
|
||||
AppCompatTextView titleWelcome;
|
||||
@BindViews({R.id.tv_about, R.id.title_welcome, R.id.text, R.id.tv_buy_pro, R.id.tv_rate_app,
|
||||
|
@ -68,8 +70,7 @@ public class HomeOptionDialog extends RoundedBottomSheetDialogFragment {
|
|||
super.onViewCreated(view, savedInstanceState);
|
||||
loadImageFromStorage();
|
||||
//noinspection ConstantConditions
|
||||
titleWelcome.setText(String.format("%s, %s!", getTimeOfTheDay(),
|
||||
PreferenceUtil.getInstance(getContext()).getUserName()));
|
||||
titleWelcome.setText(String.format("%s, %s!", getTimeOfTheDay(), PreferenceUtil.getInstance(getContext()).getUserName()));
|
||||
}
|
||||
|
||||
private String getTimeOfTheDay() {
|
||||
|
@ -109,7 +110,6 @@ public class HomeOptionDialog extends RoundedBottomSheetDialogFragment {
|
|||
case R.id.action_rate:
|
||||
NavigationUtil.goToPlayStore(getActivity());
|
||||
break;
|
||||
|
||||
case R.id.action_settings:
|
||||
NavigationUtil.goToSettings(getActivity());
|
||||
break;
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
package code.name.monkey.retromusic.dialogs;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.ui.activities.MainActivity;
|
||||
|
||||
public class MainOptionsBottomSheetDialogFragment extends BottomSheetDialogFragment implements NavigationView.OnNavigationItemSelectedListener {
|
||||
|
||||
@BindView(R.id.navigation_view)
|
||||
NavigationView navigationView;
|
||||
|
||||
public static MainOptionsBottomSheetDialogFragment newInstance(int home) {
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("selected", home);
|
||||
MainOptionsBottomSheetDialogFragment fragment = new MainOptionsBottomSheetDialogFragment();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View layout = inflater.inflate(R.layout.fragment_main_options, container, false);
|
||||
ButterKnife.bind(this, layout);
|
||||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
switch (getArguments().getInt("selected")) {
|
||||
default:
|
||||
case MainActivity.HOME:
|
||||
navigationView.setCheckedItem(R.id.action_home);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
|
||||
switch (menuItem.getItemId()) {
|
||||
case R.id.action_home:
|
||||
Toast.makeText(getContext(), menuItem.getTitle(), Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package code.name.monkey.retromusic.dialogs;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.BottomSheetDialogFragment;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -24,8 +24,10 @@ import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment;
|
|||
public class RemoveFromPlaylistDialog extends RoundedBottomSheetDialogFragment {
|
||||
@BindView(R.id.action_remove)
|
||||
TextView remove;
|
||||
|
||||
@BindView(R.id.title)
|
||||
TextView title;
|
||||
|
||||
@BindView(R.id.action_cancel)
|
||||
TextView cancel;
|
||||
|
||||
|
|
|
@ -1,79 +1,101 @@
|
|||
package code.name.monkey.retromusic.dialogs;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import code.name.monkey.appthemehelper.ThemeStore;
|
||||
import code.name.monkey.appthemehelper.util.TintHelper;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.util.PlaylistsUtil;
|
||||
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid), Aidan Follestad (afollestad)
|
||||
*/
|
||||
public class RenamePlaylistDialog extends RoundedBottomSheetDialogFragment {
|
||||
|
||||
@BindView(R.id.option_1)
|
||||
EditText playlistName;
|
||||
@BindView(R.id.action_cancel)
|
||||
Button cancel;
|
||||
@BindView(R.id.action_rename)
|
||||
Button rename;
|
||||
@BindView(R.id.title)
|
||||
TextView title;
|
||||
|
||||
@NonNull
|
||||
public static RenamePlaylistDialog create(long playlistId) {
|
||||
RenamePlaylistDialog dialog = new RenamePlaylistDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("playlist_id", playlistId);
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
@BindView(R.id.option_1)
|
||||
TextInputEditText playlistName;
|
||||
|
||||
@OnClick({R.id.action_cancel, R.id.action_rename})
|
||||
void actions(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.action_cancel:
|
||||
dismiss();
|
||||
break;
|
||||
case R.id.action_rename:
|
||||
if (!playlistName.toString().trim().equals("")) {
|
||||
long playlistId = getArguments().getLong("playlist_id");
|
||||
PlaylistsUtil.renamePlaylist(getActivity(), playlistId,
|
||||
playlistName.getText().toString());
|
||||
}
|
||||
break;
|
||||
@BindView(R.id.action_new_playlist)
|
||||
TextInputLayout textInputLayout;
|
||||
|
||||
@BindView(R.id.action_cancel)
|
||||
MaterialButton actionCancel;
|
||||
|
||||
@BindView(R.id.action_rename)
|
||||
MaterialButton rename;
|
||||
|
||||
@NonNull
|
||||
public static RenamePlaylistDialog create(long playlistId) {
|
||||
RenamePlaylistDialog dialog = new RenamePlaylistDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("playlist_id", playlistId);
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View layout = inflater.inflate(R.layout.dialog_playlist_rename, container, false);
|
||||
ButterKnife.bind(this, layout);
|
||||
return layout;
|
||||
}
|
||||
@OnClick({R.id.action_cancel, R.id.action_rename})
|
||||
void actions(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.action_cancel:
|
||||
dismiss();
|
||||
break;
|
||||
case R.id.action_rename:
|
||||
if (!playlistName.toString().trim().equals("")) {
|
||||
long playlistId = getArguments().getLong("playlist_id");
|
||||
PlaylistsUtil.renamePlaylist(getActivity(), playlistId,
|
||||
playlistName.getText().toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
int accentColor = ThemeStore.accentColor(Objects.requireNonNull(getContext()));
|
||||
TintHelper.setTintAuto(playlistName, accentColor, true);
|
||||
TintHelper.setTintAuto(rename, accentColor, true);
|
||||
cancel.setTextColor(accentColor);
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View layout = inflater.inflate(R.layout.dialog_playlist_rename, container, false);
|
||||
ButterKnife.bind(this, layout);
|
||||
return layout;
|
||||
}
|
||||
|
||||
long playlistId = getArguments().getLong("playlist_id");
|
||||
playlistName.setText(PlaylistsUtil.getNameForPlaylist(getActivity(), playlistId));
|
||||
}
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
int accentColor = ThemeStore.accentColor(Objects.requireNonNull(getContext()));
|
||||
rename.setBackgroundTintList(ColorStateList.valueOf(accentColor));
|
||||
actionCancel.setStrokeColor(ColorStateList.valueOf(accentColor));
|
||||
actionCancel.setTextColor(accentColor);
|
||||
playlistName.setHintTextColor(ColorStateList.valueOf(accentColor));
|
||||
|
||||
textInputLayout.setBoxStrokeColor(accentColor);
|
||||
textInputLayout.setDefaultHintTextColor(ColorStateList.valueOf(accentColor));
|
||||
|
||||
playlistName.setHintTextColor(accentColor);
|
||||
|
||||
playlistName.setTextColor(ThemeStore.textColorPrimary(getContext()));
|
||||
title.setTextColor(ThemeStore.textColorPrimary(getContext()));
|
||||
|
||||
long playlistId = 0;
|
||||
if (getArguments() != null) {
|
||||
playlistId = getArguments().getLong("playlist_id");
|
||||
}
|
||||
playlistName.setText(PlaylistsUtil.getNameForPlaylist(getActivity(), playlistId));
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -5,14 +5,13 @@ import android.app.PendingIntent;
|
|||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.ClipDrawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.SystemClock;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -20,8 +19,14 @@ import android.widget.SeekBar;
|
|||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.Locale;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
@ -37,15 +42,18 @@ import static code.name.monkey.retromusic.Constants.ACTION_QUIT;
|
|||
public class SleepTimerDialog extends RoundedBottomSheetDialogFragment {
|
||||
@BindView(R.id.seek_arc)
|
||||
SeekBar seekArc;
|
||||
|
||||
@BindView(R.id.timer_display)
|
||||
TextView timerDisplay;
|
||||
@BindView(R.id.action_set)
|
||||
TextView setButton;
|
||||
@BindView(R.id.action_cancel)
|
||||
TextView cancelButton;
|
||||
@BindView(R.id.action_cancel_container)
|
||||
View cancelButtonContainer;
|
||||
|
||||
@BindView(R.id.action_set)
|
||||
MaterialButton setButton;
|
||||
|
||||
@BindView(R.id.action_cancel)
|
||||
MaterialButton cancelButton;
|
||||
|
||||
@BindView(R.id.title)
|
||||
TextView title;
|
||||
private int seekArcProgress;
|
||||
private TimerUpdater timerUpdater;
|
||||
|
||||
|
@ -81,6 +89,14 @@ public class SleepTimerDialog extends RoundedBottomSheetDialogFragment {
|
|||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
int accentColor = ThemeStore.accentColor(Objects.requireNonNull(getContext()));
|
||||
setButton.setBackgroundTintList(ColorStateList.valueOf(accentColor));
|
||||
cancelButton.setStrokeColor(ColorStateList.valueOf(accentColor));
|
||||
cancelButton.setTextColor(accentColor);
|
||||
|
||||
title.setTextColor(ThemeStore.textColorPrimary(getContext()));
|
||||
timerDisplay.setTextColor(ThemeStore.textColorSecondary(getContext()));
|
||||
|
||||
timerUpdater = new TimerUpdater();
|
||||
|
||||
seekArcProgress = PreferenceUtil.getInstance(getActivity()).getLastSleepTimerValue();
|
||||
|
@ -174,7 +190,7 @@ public class SleepTimerDialog extends RoundedBottomSheetDialogFragment {
|
|||
@Override
|
||||
public void onFinish() {
|
||||
cancelButton.setText(null);
|
||||
cancelButtonContainer.setVisibility(View.GONE);
|
||||
cancelButton.setVisibility(View.GONE);
|
||||
//materialDialog.setActionButton(DialogAction.NEUTRAL, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,6 @@ package code.name.monkey.retromusic.dialogs;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.BottomSheetDialogFragment;
|
||||
import android.text.Html;
|
||||
import android.text.Spanned;
|
||||
import android.util.Log;
|
||||
|
@ -25,7 +22,8 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import butterknife.BindViews;
|
||||
import butterknife.ButterKnife;
|
||||
import code.name.monkey.appthemehelper.ThemeStore;
|
||||
|
@ -40,6 +38,15 @@ import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment;
|
|||
public class SongDetailDialog extends RoundedBottomSheetDialogFragment {
|
||||
|
||||
public static final String TAG = SongDetailDialog.class.getSimpleName();
|
||||
@BindViews({R.id.title,
|
||||
R.id.file_name,
|
||||
R.id.file_path,
|
||||
R.id.file_size,
|
||||
R.id.file_format,
|
||||
R.id.track_length,
|
||||
R.id.bitrate,
|
||||
R.id.sampling_rate})
|
||||
List<TextView> textViews;
|
||||
|
||||
@NonNull
|
||||
public static SongDetailDialog create(Song song) {
|
||||
|
@ -67,16 +74,6 @@ public class SongDetailDialog extends RoundedBottomSheetDialogFragment {
|
|||
}
|
||||
}
|
||||
|
||||
@BindViews({R.id.title,
|
||||
R.id.file_name,
|
||||
R.id.file_path,
|
||||
R.id.file_size,
|
||||
R.id.file_format,
|
||||
R.id.track_length,
|
||||
R.id.bitrate,
|
||||
R.id.sampling_rate})
|
||||
List<TextView> textViews;
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Nullable
|
||||
@Override
|
||||
|
|
|
@ -3,9 +3,9 @@ package code.name.monkey.retromusic.dialogs;
|
|||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.BottomSheetDialogFragment;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue