Merge pull request #257 from sschueller/testing

Merge testing back into dev
This commit is contained in:
Stefan Schüller 2021-01-23 21:50:01 +01:00 committed by GitHub
commit 10ae4a3ea9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 0 deletions

View File

@ -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;
}
});
}
}
}

View File

@ -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>

View File

@ -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">