diff options
author | ByteHamster <info@bytehamster.com> | 2021-07-26 20:58:10 +0200 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2021-07-26 20:58:10 +0200 |
commit | bc59d50804328f3c5a293079a33576ff260022ea (patch) | |
tree | c369253e816e85337af1aa51f820452698e99ff7 /app | |
parent | dbac6cae4666f89e3ccb8ecbc2f1c5b06e381fa5 (diff) | |
parent | 8b183915bee1419a0577196b19414529fca75432 (diff) | |
download | AntennaPod-bc59d50804328f3c5a293079a33576ff260022ea.zip |
Merge branch 'master' into develop
Diffstat (limited to 'app')
9 files changed, 132 insertions, 61 deletions
diff --git a/app/build.gradle b/app/build.gradle index 4b074bed6..8141107c7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,8 +11,8 @@ android { // Version code schema: // "1.2.3-beta4" -> 1020304 // "1.2.3" -> 1020395 - versionCode 2030002 - versionName "2.3.0-beta2" + versionCode 2030195 + versionName "2.3.1" def commit = "" try { diff --git a/app/src/main/java/de/danoeh/antennapod/activity/BugReportActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/BugReportActivity.java index 50794ba5b..aa59e4e96 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/BugReportActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/BugReportActivity.java @@ -99,10 +99,6 @@ public class BugReportActivity extends AppCompatActivity { private void exportLog() { try { File filename = new File(UserPreferences.getDataFolder(null), "full-logs.txt"); - boolean success = filename.createNewFile(); - if (!success) { - throw new IOException("Unable to create output file"); - } String cmd = "logcat -d -f " + filename.getAbsolutePath(); Runtime.getRuntime().exec(cmd); //share file diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/TagSettingsDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/TagSettingsDialog.java index de9f4d504..8ef01590f 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/TagSettingsDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/TagSettingsDialog.java @@ -3,7 +3,11 @@ package de.danoeh.antennapod.dialog; import android.app.Dialog; import android.os.Bundle; import android.text.TextUtils; +import android.util.Log; +import android.view.MotionEvent; +import android.view.View; import android.view.ViewGroup; +import android.widget.ArrayAdapter; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; @@ -12,10 +16,15 @@ import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.chip.Chip; import de.danoeh.antennapod.R; +import de.danoeh.antennapod.core.storage.DBReader; +import de.danoeh.antennapod.core.storage.NavDrawerData; import de.danoeh.antennapod.model.feed.FeedPreferences; import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.databinding.EditTagsDialogBinding; import de.danoeh.antennapod.view.ItemOffsetDecoration; +import io.reactivex.Observable; +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.schedulers.Schedulers; import java.util.ArrayList; import java.util.List; @@ -53,6 +62,17 @@ public class TagSettingsDialog extends DialogFragment { viewBinding.newTagButton.setOnClickListener(v -> addTag(viewBinding.newTagEditText.getText().toString().trim())); + loadTags(); + viewBinding.newTagEditText.setThreshold(1); + viewBinding.newTagEditText.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + viewBinding.newTagEditText.showDropDown(); + viewBinding.newTagEditText.requestFocus(); + return false; + } + }); + AlertDialog.Builder dialog = new AlertDialog.Builder(getContext()); dialog.setView(viewBinding.getRoot()); dialog.setTitle(R.string.feed_folders_label); @@ -69,6 +89,31 @@ public class TagSettingsDialog extends DialogFragment { return dialog.create(); } + private void loadTags() { + Observable.fromCallable( + () -> { + NavDrawerData data = DBReader.getNavDrawerData(); + List<NavDrawerData.DrawerItem> items = data.items; + List<String> folders = new ArrayList<String>(); + for (NavDrawerData.DrawerItem item : items) { + if (item.type == NavDrawerData.DrawerItem.Type.FOLDER) { + folders.add(item.getTitle()); + } + } + return folders; + }) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe( + result -> { + ArrayAdapter<String> acAdapter = new ArrayAdapter<String>(getContext(), + R.layout.single_tag_text_view, result); + viewBinding.newTagEditText.setAdapter(acAdapter); + }, error -> { + Log.e(TAG, Log.getStackTraceString(error)); + }); + } + private void addTag(String name) { if (TextUtils.isEmpty(name) || displayedTags.contains(name)) { return; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java index 86ab163e7..168133c7a 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java @@ -253,14 +253,16 @@ public class AudioPlayerFragment extends Fragment implements butPlaybackSpeed.setSpeed(speed); } - private void loadMediaInfo() { + private void loadMediaInfo(boolean includingChapters) { if (disposable != null) { disposable.dispose(); } - disposable = Maybe.create(emitter -> { + disposable = Maybe.<Playable>create(emitter -> { Playable media = controller.getMedia(); if (media != null) { - ChapterUtils.loadChapters(media, getContext()); + if (includingChapters) { + ChapterUtils.loadChapters(media, getContext()); + } emitter.onSuccess(media); } else { emitter.onComplete(); @@ -268,9 +270,13 @@ public class AudioPlayerFragment extends Fragment implements }) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe(media -> updateUi((Playable) media), - error -> Log.e(TAG, Log.getStackTraceString(error)), - () -> updateUi(null)); + .subscribe(media -> { + updateUi(media); + if (media.getChapters() == null && !includingChapters) { + loadMediaInfo(true); + } + }, error -> Log.e(TAG, Log.getStackTraceString(error)), + () -> updateUi(null)); } private PlaybackController newPlaybackController() { @@ -313,7 +319,7 @@ public class AudioPlayerFragment extends Fragment implements @Override public void onSleepTimerUpdate() { - AudioPlayerFragment.this.loadMediaInfo(); + AudioPlayerFragment.this.loadMediaInfo(false); } @Override @@ -323,7 +329,7 @@ public class AudioPlayerFragment extends Fragment implements @Override public void loadMediaInfo() { - AudioPlayerFragment.this.loadMediaInfo(); + AudioPlayerFragment.this.loadMediaInfo(false); } @Override @@ -360,7 +366,7 @@ public class AudioPlayerFragment extends Fragment implements super.onStart(); controller = newPlaybackController(); controller.init(); - loadMediaInfo(); + loadMediaInfo(false); EventBus.getDefault().register(this); txtvRev.setText(NumberFormat.getInstance().format(UserPreferences.getRewindSecs())); txtvFF.setText(NumberFormat.getInstance().format(UserPreferences.getFastForwardSecs())); @@ -410,7 +416,7 @@ public class AudioPlayerFragment extends Fragment implements @Subscribe(threadMode = ThreadMode.MAIN) public void favoritesChanged(FavoritesEvent event) { - AudioPlayerFragment.this.loadMediaInfo(); + AudioPlayerFragment.this.loadMediaInfo(false); } @Override diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java index 0dd97098e..5dbadaefa 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java @@ -124,14 +124,16 @@ public class CoverFragment extends Fragment { configureForOrientation(getResources().getConfiguration()); } - private void loadMediaInfo() { + private void loadMediaInfo(boolean includingChapters) { if (disposable != null) { disposable.dispose(); } disposable = Maybe.<Playable>create(emitter -> { Playable media = controller.getMedia(); if (media != null) { - ChapterUtils.loadChapters(media, getContext()); + if (includingChapters) { + ChapterUtils.loadChapters(media, getContext()); + } emitter.onSuccess(media); } else { emitter.onComplete(); @@ -141,6 +143,9 @@ public class CoverFragment extends Fragment { .subscribe(media -> { this.media = media; displayMediaInfo(media); + if (media.getChapters() == null && !includingChapters) { + loadMediaInfo(true); + } }, error -> Log.e(TAG, Log.getStackTraceString(error))); } @@ -161,7 +166,9 @@ public class CoverFragment extends Fragment { int animUnit = 1500; if (lines > txtvEpisodeTitle.getMaxLines()) { ObjectAnimator verticalMarquee = ObjectAnimator.ofInt( - txtvEpisodeTitle, "scrollY", 0, txtvEpisodeTitle.getHeight()) + txtvEpisodeTitle, "scrollY", 0, (lines - txtvEpisodeTitle.getMaxLines()) * ( + (txtvEpisodeTitle.getHeight() - txtvEpisodeTitle.getPaddingTop() + - txtvEpisodeTitle.getPaddingBottom()) / txtvEpisodeTitle.getMaxLines())) .setDuration(lines * animUnit); ObjectAnimator fadeOut = ObjectAnimator.ofFloat( txtvEpisodeTitle, "alpha", 0); @@ -186,17 +193,22 @@ public class CoverFragment extends Fragment { } private void updateChapterControlVisibility() { + boolean chapterControlVisible = false; if (media.getChapters() != null) { - boolean chapterControlVisible = media.getChapters().size() > 0; - int newVisibility = chapterControlVisible ? View.VISIBLE : View.GONE; - if (chapterControl.getVisibility() != newVisibility) { - chapterControl.setVisibility(newVisibility); - ObjectAnimator.ofFloat(chapterControl, - "alpha", - chapterControlVisible ? 0 : 1, - chapterControlVisible ? 1 : 0) - .start(); - } + chapterControlVisible = media.getChapters().size() > 0; + } else if (media instanceof FeedMedia) { + FeedMedia fm = ((FeedMedia) media); + // If an item has chapters but they are not loaded yet, still display the button. + chapterControlVisible = fm.getItem() != null && fm.getItem().hasChapters(); + } + int newVisibility = chapterControlVisible ? View.VISIBLE : View.GONE; + if (chapterControl.getVisibility() != newVisibility) { + chapterControl.setVisibility(newVisibility); + ObjectAnimator.ofFloat(chapterControl, + "alpha", + chapterControlVisible ? 0 : 1, + chapterControlVisible ? 1 : 0) + .start(); } } @@ -262,11 +274,11 @@ public class CoverFragment extends Fragment { controller = new PlaybackController(getActivity()) { @Override public void loadMediaInfo() { - CoverFragment.this.loadMediaInfo(); + CoverFragment.this.loadMediaInfo(false); } }; controller.init(); - loadMediaInfo(); + loadMediaInfo(false); EventBus.getDefault().register(this); } diff --git a/app/src/main/java/de/danoeh/antennapod/view/ChapterSeekBar.java b/app/src/main/java/de/danoeh/antennapod/view/ChapterSeekBar.java index ba7acb847..7c6b64e2c 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/ChapterSeekBar.java +++ b/app/src/main/java/de/danoeh/antennapod/view/ChapterSeekBar.java @@ -62,6 +62,7 @@ public class ChapterSeekBar extends androidx.appcompat.widget.AppCompatSeekBar { } else { this.dividerPos = null; } + invalidate(); } public void highlightCurrentChapter() { diff --git a/app/src/main/res/layout/cover_fragment.xml b/app/src/main/res/layout/cover_fragment.xml index 8333ded1e..548e55774 100644 --- a/app/src/main/res/layout/cover_fragment.xml +++ b/app/src/main/res/layout/cover_fragment.xml @@ -4,10 +4,10 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:squareImageView="http://schemas.android.com/apk/de.danoeh.antennapod" xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/cover_fragment" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" - android:id="@+id/cover_fragment" android:padding="8dp" android:gravity="center"> @@ -57,7 +57,6 @@ android:id="@+id/txtvEpisodeTitle" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="?android:selectableItemBackground" android:ellipsize="none" android:gravity="center_horizontal" android:maxLines="2" @@ -125,6 +124,7 @@ android:text="@string/shownotes_label" android:textColor="?android:attr/textColorSecondary" android:textSize="16sp" /> + </LinearLayout> <LinearLayout @@ -168,6 +168,7 @@ android:contentDescription="@string/next_chapter" android:scaleType="fitCenter" app:srcCompat="@drawable/ic_chapter_next" /> + </LinearLayout> </LinearLayout> diff --git a/app/src/main/res/layout/edit_tags_dialog.xml b/app/src/main/res/layout/edit_tags_dialog.xml index 2e7774cea..57e3c412f 100644 --- a/app/src/main/res/layout/edit_tags_dialog.xml +++ b/app/src/main/res/layout/edit_tags_dialog.xml @@ -1,41 +1,43 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" - android:padding="16dp"> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:padding="16dp"> <androidx.recyclerview.widget.RecyclerView - android:id="@+id/tagsRecycler" - android:layout_width="match_parent" - android:layout_height="wrap_content"/> + android:id="@+id/tagsRecycler" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> <CheckBox - android:id="@+id/rootFolderCheckbox" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:text="@string/feed_folders_include_root" /> + android:id="@+id/rootFolderCheckbox" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/feed_folders_include_root" /> <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="horizontal"> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal"> - <EditText - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_weight="1" - android:inputType="text" - android:ems="10" - android:id="@+id/newTagEditText"/> + <AutoCompleteTextView + android:id="@+id/newTagEditText" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:inputType="text" + android:ems="10" /> <ImageButton - android:layout_width="wrap_content" - android:layout_height="wrap_content" - app:srcCompat="@drawable/ic_add" - android:contentDescription="@string/new_label" - android:id="@+id/newTagButton"/> + android:id="@+id/newTagButton" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:contentDescription="@string/new_label" + app:srcCompat="@drawable/ic_add" /> + </LinearLayout> </LinearLayout> diff --git a/app/src/main/res/layout/single_tag_text_view.xml b/app/src/main/res/layout/single_tag_text_view.xml new file mode 100644 index 000000000..67410a20e --- /dev/null +++ b/app/src/main/res/layout/single_tag_text_view.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<TextView + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:scrollbars="vertical" + android:padding="10dp" + android:ems="10" /> |