Refresh button (#11)

* Added a refresh button to bin the previous database, copy the new one, and reload it into the UI.   Saves having to kill the app and re-open to see the latest changes. Should address "Issue #8 Reload Play Music Files"

* Pull Request actions.

* Fixed Typo and Translation
This commit is contained in:
Mark Gillespie 2017-03-09 15:08:51 +00:00 committed by GitHub
parent 67d6fd5ffb
commit 7dafd21843
7 changed files with 63 additions and 5 deletions

View file

@ -40,9 +40,12 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.Toast;
import de.arcus.framework.logger.Logger;
import de.arcus.framework.crashhandler.CrashHandler;
import de.arcus.playmusiclib.exceptions.CouldNotOpenDatabaseException;
import de.arcus.playmusiclib.exceptions.NoSuperUserException;
import re.jcg.playmusicexporter.R;
import re.jcg.playmusicexporter.fragments.MusicTrackListFragment;
import re.jcg.playmusicexporter.fragments.MusicContainerListFragment;
@ -325,8 +328,26 @@ public class MusicContainerListActivity extends AppCompatActivity
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.music_track_list, menu);
MenuItem itemRefreshLibrary = menu.findItem(R.id.action_refresh);
itemRefreshLibrary.setOnMenuItemClickListener(item ->
{
try
{
mPlayMusicManager.reloadDatabase();
mPlayMusicManager = null;
loadPlayMusicExporter();
Toast.makeText( this, R.string.database_reloaded, Toast.LENGTH_SHORT).show();
}
catch (NoSuperUserException | CouldNotOpenDatabaseException e)
{
Toast.makeText( this, R.string.dialog_superuser_access_denied_title, Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
return true;
});
// Finds the search item and create the search view
MenuItem itemSearch = menu.findItem(R.id.action_search);
MenuItem itemSearch = menu. findItem(R.id.action_search);
mSearchView = (SearchView)MenuItemCompat.getActionView(itemSearch);
if (mSearchView != null) {

View file

@ -0,0 +1,25 @@
<!--
Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:pathData="M17.6,6.4C16.2,4.9 14.2,4 12,4c-4.4,0 -8,3.6 -8,8s3.6,8 8,8c3.7,0 6.8,-2.6 7.7,-6l-2.1,0c-0.8,2.3 -3,4 -5.6,4c-3.3,0 -6,-2.7 -6,-6s2.7,-6 6,-6c1.7,0 3.1,0.7 4.2,1.8L13,11l7,0L20,4L17.6,6.4z"
android:fillColor="@color/white"/>
</vector>

View file

@ -29,4 +29,10 @@
app:showAsAction="always"
app:actionViewClass="android.support.v7.widget.SearchView"
/>
<item android:id="@+id/action_refresh"
android:title="@string/action_refesh"
android:icon="@drawable/ic_menu_refresh"
app:showAsAction="always" />
</menu>

View file

@ -104,6 +104,8 @@
<string name="settings_auto_export_different_structure_dialog_title">Verzeichnisbaum</string>
<string name="settings_export_overwrite_existing">Bestehende Dateien überschreiben</string>
<string name="file_handling_category">Dateiverarbeitung</string>
<string name="overwrite_summary">Überschreiben Sie die exportierte Datei immer, auch wenn sie bereits existiert.</string>
<string name="overwrite_title">Bestehende Dateien überschreiben.</string>
<string name="overwrite_summary">Überschreiben Sie die exportierte Datei immer, auch wenn sie bereits existiert</string>
<string name="overwrite_title">Bestehende Dateien überschreiben</string>
<string name="action_refesh">Datenbank neu laden</string>
<string name="database_reloaded">Datenbank neu geladen</string>
</resources>

View file

@ -44,4 +44,6 @@
<color name="button_navigation_drawer_active">#11000000</color>
<color name="button_navigation_drawer_text">#88000000</color>
<color name="button_navigation_drawer_text_active">#ef6c00</color>
<color name="white">#ffffffff</color>
<color name="black">#ff000000</color>
</resources>

View file

@ -144,6 +144,8 @@
<string name="debug_trigger_export_all_title">Trigger ExportAllService now</string>
<string name="file_handling_category">File Handling</string>
<string name="overwrite_summary">Always overwrite the exported file, even if it already exists.</string>
<string name="overwrite_summary">Always overwrite the exported file, even if it already exists</string>
<string name="overwrite_title">Overwrite Existing Files</string>
<string name="action_refesh">Refresh</string>
<string name="database_reloaded">Music Database Reloaded</string>
</resources>

View file

@ -373,7 +373,7 @@ public class PlayMusicManager {
* @throws NoSuperUserException No super user permissions
* @throws CouldNotOpenDatabaseException Could not open the database
*/
public void realoadDatabase() throws NoSuperUserException, CouldNotOpenDatabaseException {
public void reloadDatabase() throws NoSuperUserException, CouldNotOpenDatabaseException {
// Reload database
loadDatabase();
}