diff --git a/app/src/main/java/net/schueller/peertube/activity/SettingsActivity.java b/app/src/main/java/net/schueller/peertube/activity/SettingsActivity.java
index 147a3c6..fdc65e5 100644
--- a/app/src/main/java/net/schueller/peertube/activity/SettingsActivity.java
+++ b/app/src/main/java/net/schueller/peertube/activity/SettingsActivity.java
@@ -20,6 +20,7 @@ import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
+import android.provider.SearchRecentSuggestions;
import android.util.Log;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog.Builder;
@@ -30,6 +31,7 @@ import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.SwitchPreference;
import net.schueller.peertube.BuildConfig;
import net.schueller.peertube.R;
+import net.schueller.peertube.provider.SearchSuggestionsProvider;
public class SettingsActivity extends CommonActivity {
@@ -108,6 +110,28 @@ public class SettingsActivity extends CommonActivity {
return true;
});
}
+ //clear search history buttonish
+ Preference button = findPreference(getString(R.string.pref_clear_history_key));
+ button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ new Builder(preference.getContext())
+ .setTitle(R.string.clear_search_history)
+ .setMessage(R.string.clear_search_history_prompt)
+ .setIcon(R.drawable.ic_info_black_24dp)
+ .setNegativeButton(R.string.pref_insecure_confirm_no, (dialog, whichButton) -> {
+ // do nothing
+ })
+ .setPositiveButton(R.string.pref_insecure_confirm_yes, (dialog, whichButton) -> {
+ // OK has been pressed
+ SearchRecentSuggestions suggestions = new SearchRecentSuggestions(getContext(),
+ SearchSuggestionsProvider.AUTHORITY,
+ SearchSuggestionsProvider.MODE);
+ suggestions.clearHistory();
+ }).create().show();
+ return true;
+ }
+ });
}
}
}
\ No newline at end of file
diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java
index 0571fe9..f73041c 100644
--- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java
+++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java
@@ -71,7 +71,6 @@ public class VideoPlayActivity extends AppCompatActivity {
private static final String TAG = "VideoPlayActivity";
static boolean floatMode = false;
- static boolean fullStop=true;
private static final int REQUEST_CODE = 101;
private BroadcastReceiver receiver;
@@ -139,7 +138,6 @@ public class VideoPlayActivity extends AppCompatActivity {
receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- fullStop=true;
String action = intent.getAction();
assert action != null;
if (action.equals(ACTION_PAUSE)) {
@@ -152,12 +150,11 @@ public class VideoPlayActivity extends AppCompatActivity {
}
if (action.equals(getString(R.string.app_background_audio))) {
- safeUnregisterReceiver();
- fullStop=false;
+ unregisterReceiver(receiver);
finish();
}
if (action.equals(ACTION_STOP)) {
- safeUnregisterReceiver();
+ unregisterReceiver(receiver);
finishAndRemoveTask();
}
}
@@ -176,7 +173,7 @@ public class VideoPlayActivity extends AppCompatActivity {
assert videoPlayerFragment != null;
videoPlayerFragment.showControls(true);
if (receiver != null) {
- safeUnregisterReceiver();
+ unregisterReceiver(receiver);
}
Log.v(TAG, "switched to normal");
floatMode = false;
@@ -336,13 +333,9 @@ public class VideoPlayActivity extends AppCompatActivity {
getSupportFragmentManager().findFragmentById(R.id.video_player_fragment);
assert videoPlayerFragment != null;
+ videoPlayerFragment.stopVideo();
+
Log.v(TAG, "onStop()...");
- safeUnregisterReceiver();
- if (fullStop) {
- stopService(new Intent(this, VideoPlayerService.class));
- finishAndRemoveTask();
- }
- finish();
}
@Override
@@ -505,12 +498,5 @@ public class VideoPlayActivity extends AppCompatActivity {
Log.e(TAG, "videoPlayerFragment is NULL");
}
}
- private void safeUnregisterReceiver()
- {
- try {
- unregisterReceiver(receiver);
- } catch (Exception e) {
- Log.e("VideoPlayerService", "attempted to unregister a nonregistered service");
- }
- }
+
}
diff --git a/app/src/main/res/values/constants.xml b/app/src/main/res/values/constants.xml
index 7feb602..72c48d6 100644
--- a/app/src/main/res/values/constants.xml
+++ b/app/src/main/res/values/constants.xml
@@ -17,6 +17,7 @@
pref_accept_insecure
+ pref_clear_history
https://troll.tv
AppTheme.BLUE
diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml
index 96736b3..949d57f 100644
--- a/app/src/main/res/xml/root_preferences.xml
+++ b/app/src/main/res/xml/root_preferences.xml
@@ -84,6 +84,13 @@
app:title="@string/pref_title_accept_insecure"
app:iconSpaceReserved="false"/>
+
+ />
+