commit
ca540da5f4
|
@ -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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
<string name="pref_accept_insecure" translatable="false">pref_accept_insecure</string>
|
||||
|
||||
<string name ="pref_clear_history_key" translatable="false">pref_clear_history</string>
|
||||
<!-- defaults -->
|
||||
<string name="pref_default_api_base_url" formatted="false" translatable="false">https://troll.tv</string>
|
||||
<string name="app_default_theme" translatable="false">AppTheme.BLUE</string>
|
||||
|
|
|
@ -84,6 +84,13 @@
|
|||
app:title="@string/pref_title_accept_insecure"
|
||||
app:iconSpaceReserved="false"/>
|
||||
|
||||
<Preference
|
||||
app:title="@string/clear_search_history"
|
||||
app:key="@string/pref_clear_history_key"
|
||||
app:summary="@string/clear_search_history_prompt"
|
||||
app:iconSpaceReserved="false"/>
|
||||
/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory app:title="@string/settings_activity_about_category_title" app:iconSpaceReserved="false">
|
||||
|
|
Loading…
Reference in New Issue