Use AlertDialog.Builder instead of BookmarkDialog class for the same look.
Use "rename" string instead of "save" string.
This commit is contained in:
parent
8712310ad9
commit
a117e459b0
4 changed files with 17 additions and 95 deletions
|
@ -1,9 +1,11 @@
|
|||
package org.schabi.newpipe.local.bookmark;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.util.Log;
|
||||
import android.widget.EditText;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
@ -22,7 +24,6 @@ import org.schabi.newpipe.database.playlist.PlaylistLocalItem;
|
|||
import org.schabi.newpipe.database.playlist.PlaylistMetadataEntry;
|
||||
import org.schabi.newpipe.database.playlist.model.PlaylistRemoteEntity;
|
||||
import org.schabi.newpipe.local.BaseLocalListFragment;
|
||||
import org.schabi.newpipe.local.dialog.BookmarkDialog;
|
||||
import org.schabi.newpipe.local.playlist.LocalPlaylistManager;
|
||||
import org.schabi.newpipe.local.playlist.RemotePlaylistManager;
|
||||
import org.schabi.newpipe.report.UserAction;
|
||||
|
@ -254,20 +255,23 @@ public final class BookmarkFragment
|
|||
}
|
||||
|
||||
private void showLocalDialog(PlaylistMetadataEntry selectedItem) {
|
||||
BookmarkDialog dialog = new BookmarkDialog(getContext(),
|
||||
selectedItem.name, new BookmarkDialog.OnClickListener() {
|
||||
@Override
|
||||
public void onDeleteClicked() {
|
||||
View dialogView = View.inflate(getContext(), R.layout.dialog_bookmark, null);
|
||||
EditText editText = dialogView.findViewById(R.id.playlist_name_edit_text);
|
||||
editText.setText(selectedItem.name);
|
||||
|
||||
Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setView(dialogView)
|
||||
.setPositiveButton(R.string.rename_playlist, (dialog, which) -> {
|
||||
changeLocalPlaylistName(selectedItem.uid, editText.getText().toString());
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setNeutralButton(R.string.delete, (dialog, which) -> {
|
||||
showDeleteDialog(selectedItem.name,
|
||||
localPlaylistManager.deletePlaylist(selectedItem.uid));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveClicked(@NonNull String name) {
|
||||
changeLocalPlaylistName(selectedItem.uid, name);
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
dialog.dismiss();
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
|
||||
private void showDeleteDialog(final String name, final Single<Integer> deleteReactor) {
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
package org.schabi.newpipe.local.dialog
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.Window
|
||||
import android.widget.Button
|
||||
import android.widget.EditText
|
||||
import org.schabi.newpipe.R
|
||||
|
||||
class BookmarkDialog(
|
||||
context: Context,
|
||||
private val playlistName: String,
|
||||
val listener: OnClickListener)
|
||||
: Dialog(context) {
|
||||
|
||||
private lateinit var editText: EditText
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
setContentView(R.layout.dialog_bookmark)
|
||||
initListeners()
|
||||
}
|
||||
|
||||
private fun initListeners() {
|
||||
editText = findViewById(R.id.playlist_name_edit_text);
|
||||
editText.setText(playlistName)
|
||||
|
||||
findViewById<Button>(R.id.bookmark_delete).setOnClickListener {
|
||||
listener.onDeleteClicked()
|
||||
dismiss()
|
||||
}
|
||||
findViewById<Button>(R.id.bookmark_cancel).setOnClickListener {
|
||||
dismiss()
|
||||
}
|
||||
findViewById<Button>(R.id.bookmark_save).setOnClickListener {
|
||||
listener.onSaveClicked(editText.text.toString())
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
interface OnClickListener {
|
||||
fun onDeleteClicked()
|
||||
fun onSaveClicked(name: String)
|
||||
}
|
||||
}
|
|
@ -14,38 +14,4 @@
|
|||
android:layout_margin="10dp"
|
||||
android:hint="@string/playlist_name_input"/>
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="10dp"
|
||||
android:padding="5dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/bookmark_delete"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:text="@string/delete" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bookmark_cancel"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toStartOf="@+id/bookmark_save"
|
||||
android:text="@android:string/cancel" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bookmark_save"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:text="@string/save" />
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -590,7 +590,6 @@
|
|||
<string name="downloads_storage_use_saf_title">Use SAF</string>
|
||||
<string name="downloads_storage_use_saf_summary">The Storage Access Framework allows downloads to an external SD card.\nNote: some devices are not compatible</string>
|
||||
<string name="choose_instance_prompt">Choose an instance</string>
|
||||
<string name="save">save</string>
|
||||
<string name="app_language_title">App language</string>
|
||||
<string name="systems_language">System default</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue