Skip to content

Commit

Permalink
6.2: Moved around some variables to make other activities independent of
Browse files Browse the repository at this point in the history
main activity; Workaround for Android bug so that returning to last
opened activity works; Made clear that current shows are NOT updated
when archived shows are listed and vice versa (strings changed).
  • Loading branch information
ltGuillaume authored and ltGuillaume committed Nov 26, 2015
1 parent 939ad41 commit 9730009
Show file tree
Hide file tree
Showing 14 changed files with 197 additions and 161 deletions.
2 changes: 1 addition & 1 deletion AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="nl.asymmetrics.droidshows"
android:versionCode="61" android:versionName="6.1">
android:versionCode="62" android:versionName="6.2">
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="11"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Expand Down
12 changes: 6 additions & 6 deletions res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<string name="layout_seasons_no_items">No hay temporadas que mostrar.</string>
<string name="archive">Archivo</string>
<string name="addserie_hint">Nombre de la serie</string>
<string name="search_hint">Buscar...</string>
<string name="search_hint">Buscar&#x2026;</string>
<string name="menu_undo">Deshacer</string>
<string name="menu_add_serie">Añadir una serie</string>
<string name="menu_update_all">Actualizar todas las series</string>
<string name="menu_update">Actualizar las series</string>
<string name="menu_search">Buscar series</string>
<string name="menu_sort_az">Ordenar por nombre</string>
<string name="menu_sort_last_unseen">Ordenar por no visto</string>
Expand Down Expand Up @@ -40,7 +40,7 @@
<string name="dialog_delete">¿Seguro que desea borrar %s?</string>
<string name="dialog_Cancel">Cancelar</string>
<string name="dialog_search">Texto buscado:</string>
<string name="dialog_update_all_series">¿Seguro que desea actualizar todas las series ahora mismo?</string>
<string name="dialog_update_series">¿Seguro que desea actualizar las series ahora mismo?</string>
<string name="dialog_update_speedup">\n\nPuede acelerar este proceso con la opción en Menú > Opciones.</string>
<string name="dialog_last_season">Solo actualizar la última temporada de cada serie</string>
<string name="dialog_include_specials">Contar los especiales como episodios no vistos</string>
Expand All @@ -60,12 +60,12 @@
\n&#187; Toque la puntuación en IMDb para verla en IMDb</string>
<string name="menu_archive">Archivo</string>
<string name="menu_unarchive">Recuperar</string>
<string name="messages_title_updating_all_series">Actualizando todas las series</string>
<string name="messages_title_updating_series">Actualizando las series</string>
<string name="messages_title_updating_db">Actualizando base de datos</string>
<string name="messages_update_serie">Obteniendo información de la serie…</string>
<string name="messages_no_internet">La conexión a internet no está disponible</string>
<string name="messages_title_update_all_series">Actualiza todas las series</string>
<string name="messages_update_all_series">Consiguiendo información de las series. Esta operación puede tardar un poco...</string>
<string name="messages_title_update_series">Actualiza todas las series</string>
<string name="messages_update_series">Consiguiendo información de las series. Esta operación puede tardar un poco&#x2026;</string>
<string name="messages_episodes">episodios</string>
<string name="messages_new_episodes">nuevos episodios</string>
<string name="messages_new_episode">nuevo episodio</string>
Expand Down
14 changes: 7 additions & 7 deletions res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<string name="layout_search_no_items">Geen series gevonden.</string>
<string name="layout_seasons_no_items">Geen seizoenen gevonden.</string>
<string name="archive">Archief</string>
<string name="addserie_hint">Nieuwe serie zoeken...</string>
<string name="search_hint">Zoeken...</string>
<string name="addserie_hint">Nieuwe serie zoeken&#x2026;</string>
<string name="search_hint">Zoeken&#x2026;</string>
<string name="menu_undo">Ongedaan maken</string>
<string name="menu_add_serie">Serie toevoegen</string>
<string name="menu_update_all">Alle series bijwerken</string>
<string name="menu_update">Series bijwerken</string>
<string name="menu_search">Serie zoeken</string>
<string name="menu_sort_az">Sorteren op naam</string>
<string name="menu_sort_last_unseen">Sorteren op datum</string>
Expand Down Expand Up @@ -40,7 +40,7 @@
<string name="dialog_delete">Weet je zeker dat je de serie %s wilt verwijderen?</string>
<string name="dialog_Cancel">Annuleren</string>
<string name="dialog_search">Zoekterm:</string>
<string name="dialog_update_all_series">Weet je zeker dat je alle series nu wilt bijwerken?</string>
<string name="dialog_update_series">Weet je zeker dat je alle series in deze lijst nu wilt bijwerken?</string>
<string name="dialog_update_speedup">\n\nDit kan sneller met de optie in Menu > Opties.</string>
<string name="dialog_last_season">Alleen laatste seizoenen bijwerken</string>
<string name="dialog_include_specials">Specials meetellen in overzicht</string>
Expand All @@ -60,12 +60,12 @@
\n&#187; Klik op IMDb-score voor IMDb-pagina</string>
<string name="menu_archive">Archiveren</string>
<string name="menu_unarchive">Terughalen</string>
<string name="messages_title_updating_all_series">Alle series bijwerken</string>
<string name="messages_title_updating_series">Series bijwerken</string>
<string name="messages_title_updating_db">Database bijwerken</string>
<string name="messages_update_serie">Downloaden nieuwe gegevens…</string>
<string name="messages_no_internet">Er is geen internetverbinding</string>
<string name="messages_title_update_all_series">Alle series bijwerken</string>
<string name="messages_update_all_series">Bezig met downloaden van nieuwe gegevens. Even geduld…</string>
<string name="messages_title_update_series">Series bijwerken</string>
<string name="messages_update_series">Bezig met downloaden van nieuwe gegevens. Even geduld…</string>
<string name="messages_episodes">afleveringen</string>
<string name="messages_new_episodes">afleveringen</string>
<string name="messages_new_episode">aflevering</string>
Expand Down
7 changes: 7 additions & 0 deletions res/values/donottranslate.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="copyright">DroidShows v{v}
\n&#169;2010 C. Limpinho, P. Cabido: code.google.com/p/droidseries
\nForked by M. Berthe: gitorious.org/droidseries/mckaels-droidseries
\n&#169;2014-{y} Guillaume (GPLv3): ltGuillaume.github.io/DroidShows
\nReleases: github.com/ltGuillaume/DroidShows/releases
\nForum/Changelog: forum.xda-developers.com/showthread.php?p=58437755
\n\nNew icon file is a mix of iconeasy.com/icon/tv-shows-2-icon (Thrasos Varnava) and wallalay.com/wallpapers-for-android-67-177682-desktop-background.html (Taenggo)</string>
<string-array name="languages">
<item> עברית</item>
<item>čeština</item>
Expand Down
23 changes: 8 additions & 15 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="copyright" translatable="false">DroidShows v{v}
\nltGuillaume.github.io/DroidShows
\nXDA/Changelog: tiny.cc/DroidShows
\n&#169;2010 Carlos Limpinho, Paulo Cabido:\ncode.google.com/p/droidseries
\nForked by Mikael Berthe
\n&#169;2014-{y} Guillaume (GPLv3):\ngithub.com/ltGuillaume/DroidShows
\n\nNew icon file is a mix of\niconeasy.com/icon/tv-shows-2-icon (Thrasos Varnava) and\nwallalay.com/wallpapers-for-android-67-177682-desktop-background.html (Taenggo)</string>
<string name="lang_code">en</string>
<string name="layout_app_name">DroidShows</string>
<string name="layout_main_no_items">No shows found.</string>
<string name="layout_search_no_items">No shows found.</string>
<string name="layout_seasons_no_items">No seasons to display.</string>
<string name="archive">Archive</string>
<string name="addserie_hint">Show to add...</string>
<string name="search_hint">Search...</string>
<string name="addserie_hint">Show to add&#x2026;</string>
<string name="search_hint">Search&#x2026;</string>
<string name="menu_undo">Undo</string>
<string name="menu_add_serie">Add a show</string>
<string name="menu_update_all">Update all shows</string>
<string name="menu_update">Update shows</string>
<string name="menu_search">Search shows</string>
<string name="menu_sort_az">Sort by name</string>
<string name="menu_sort_last_unseen">Sort by unseen</string>
Expand Down Expand Up @@ -47,13 +40,13 @@
<string name="dialog_delete">Are you sure you want to delete %s?</string>
<string name="dialog_Cancel">Cancel</string>
<string name="dialog_search">Search string:</string>
<string name="dialog_update_all_series">Are you sure you want to update all the shows now?</string>
<string name="dialog_update_series">Are you sure you want to update all listed shows now?</string>
<string name="dialog_update_speedup">\n\nYou can speed up this process with the option in Menu > Options.</string>
<string name="dialog_last_season">Update shows\' last season only</string>
<string name="dialog_include_specials">Include specials in unwatched count</string>
<string name="dialog_full_line_check">Use entire line to mark episode</string>
<string name="dialog_switch_swipe_direction">Swipe right-to-left to go back</string>
<string name="dialog_help">&#187; Don\'t forget to update all shows regularly
<string name="dialog_help">&#187; Don\'t forget to update shows regularly
\n&#187; Long-press items for more options
\n&#187; Swipe left-to-right to go back
\n\nIn Shows Overview:
Expand All @@ -67,12 +60,12 @@
\n&#187; Tap IMDb rating to view in IMDb</string>
<string name="menu_archive">Archive</string>
<string name="menu_unarchive">Recover</string>
<string name="messages_title_updating_all_series">Updating all shows</string>
<string name="messages_title_updating_series">Updating shows</string>
<string name="messages_title_updating_db">Updating database</string>
<string name="messages_update_serie">Gathering show information…</string>
<string name="messages_no_internet">No Internet connection is available</string>
<string name="messages_title_update_all_series">Update all shows</string>
<string name="messages_update_all_series">Gathering shows information. This operation will take a while…</string>
<string name="messages_title_update_series">Update shows</string>
<string name="messages_update_series">Gathering shows information. This operation will take a while…</string>
<string name="messages_episodes">episodes</string>
<string name="messages_new_episodes">new episodes</string>
<string name="messages_new_episode">new episode</string>
Expand Down
59 changes: 24 additions & 35 deletions src/nl/asymmetrics/droidshows/DroidShows.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import android.content.SharedPreferences;
import android.content.pm.PackageManager.NameNotFoundException;
import android.database.Cursor;
import android.database.SQLException;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
Expand Down Expand Up @@ -74,7 +73,6 @@

public class DroidShows extends ListActivity
{
public static String VERSION = "0.1.5-7G";
/* Menus */
private static final int UNDO_MENU_ITEM = Menu.FIRST;
private static final int ADD_SERIE_MENU_ITEM = UNDO_MENU_ITEM + 1;
Expand All @@ -94,7 +92,6 @@ public class DroidShows extends ListActivity
private static final int DELETE_CONTEXT = UPDATE_CONTEXT + 1;
public static String on;
private static AlertDialog m_AlertDlg;
public static final String TAG = "DroidShows";
private static ProgressDialog m_ProgressDialog = null;
private static ProgressDialog updateAllSeriesPD = null;
public static SeriesAdapter seriesAdapter;
Expand All @@ -103,7 +100,7 @@ public class DroidShows extends ListActivity
private static int oldListPosition = -1;
private static TheTVDB theTVDB;
private Utils utils = new Utils();
private Update updateDS = new Update();
private Update updateDS;
private static final String PREF_NAME = "DroidShowsPref";
private SharedPreferences sharedPrefs;
private static final String SORT_PREF_NAME = "sort";
Expand Down Expand Up @@ -139,28 +136,20 @@ public class DroidShows extends ListActivity
private int padding;
public static int showArchive;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
db = new SQLiteStore(this);
try {
db.openDataBase();
} catch (SQLException sqle) {
try {
db.createDataBase();
db.close();
try {
db.openDataBase();
} catch (SQLException sqle2) {
Log.e(TAG, sqle2.getMessage());
}
} catch (IOException e) {
Log.e(TAG, "Unable to create database");
if (!isTaskRoot()) { // Prevent multiple instances: http://stackoverflow.com/a/11042163
final Intent intent = getIntent();
if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(intent.getAction())) {
finish();
return;
}
}
setContentView(R.layout.main);
db = SQLiteStore.getInstance(this);

updateDS = new Update(this);
if(updateDS.updateDroidShows())
db.updateShowStats();

Expand Down Expand Up @@ -252,7 +241,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, SEARCH_MENU_ITEM, 0, getString(R.string.menu_search)).setIcon(android.R.drawable.ic_menu_search);
menu.add(0, TOGGLE_ARCHIVE_MENU_ITEM, 0, getString(R.string.menu_show_archive));
menu.add(0, SORT_MENU_ITEM, 0, getString(R.string.menu_sort_last_unseen));
menu.add(0, UPDATEALL_MENU_ITEM, 0, getString(R.string.menu_update_all)).setIcon(android.R.drawable.ic_menu_upload);
menu.add(0, UPDATEALL_MENU_ITEM, 0, getString(R.string.menu_update)).setIcon(android.R.drawable.ic_menu_upload);
menu.add(0, OPTIONS_MENU_ITEM, 0, getString(R.string.menu_about)).setIcon(android.R.drawable.ic_menu_manage);
menu.add(0, EXIT_MENU_ITEM, 0, getString(R.string.menu_exit)).setIcon(android.R.drawable.ic_menu_close_clear_cancel);
return super.onCreateOptionsMenu(menu);
Expand Down Expand Up @@ -753,21 +742,21 @@ public void updatePosterThumb(String serieId, Serie sToUpdate) {
new File(posterThumbPath).delete();
posterThumbPath = getApplicationContext().getFilesDir().getAbsolutePath() +"/thumbs"+ posterURL.getFile().toString();
} catch (MalformedURLException e) {
Log.e(TAG, "Show "+ serieId +" doesn't have poster URL");
Log.e(SQLiteStore.TAG, "Show "+ serieId +" doesn't have poster URL");
e.printStackTrace();
return;
}
File posterThumbFile = new File(posterThumbPath);
try {
FileUtils.copyURLToFile(posterURL, posterThumbFile);
} catch (IOException e) {
Log.e(TAG, "Could not download poster: "+ posterURL);
Log.e(SQLiteStore.TAG, "Could not download poster: "+ posterURL);
e.printStackTrace();
return;
}
Bitmap posterThumb = BitmapFactory.decodeFile(posterThumbPath);
if (posterThumb == null) {
Log.e(TAG, "Corrupt or unknown poster file type:"+ posterThumbPath);
Log.e(SQLiteStore.TAG, "Corrupt or unknown poster file type:"+ posterThumbPath);
return;
}
int width = getWindowManager().getDefaultDisplay().getWidth();
Expand All @@ -783,9 +772,9 @@ public void updatePosterThumb(String serieId, Serie sToUpdate) {
fOut.close();
db.execQuery("UPDATE series SET posterInCache='true', poster='"+ poster
+"', posterThumb='"+ posterThumbPath +"' WHERE id='"+ serieId +"'");
Log.d(TAG, "Updated poster thumb for "+ sToUpdate.getSerieName());
Log.d(SQLiteStore.TAG, "Updated poster thumb for "+ sToUpdate.getSerieName());
} catch (FileNotFoundException e) {
Log.e(TAG, "File not found:"+ posterThumbFile);
Log.e(SQLiteStore.TAG, "File not found:"+ posterThumbFile);
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
Expand Down Expand Up @@ -825,12 +814,12 @@ public void run() {
public void run() {
theTVDB = new TheTVDB("8AC675886350B3C3");
for (int i = 0; i < series.size(); i++) {
Log.d(TAG, "Getting updated info from TheTVDB for TV show " + series.get(i).getName() +" ["+ i +"/"+ (series.size()-1) +"]");
Log.d(SQLiteStore.TAG, "Getting updated info from TheTVDB for TV show " + series.get(i).getName() +" ["+ i +"/"+ (series.size()-1) +"]");
toastMessage = series.get(i).getName() + "\u2026";
runOnUiThread(updateMessage);
Serie sToUpdate = theTVDB.getSerie(series.get(i).getSerieId(), langCode);
if (sToUpdate != null) {
Log.d(TAG, "Updating the database");
Log.d(SQLiteStore.TAG, "Updating the database");
try {
db.updateSerie(sToUpdate, lastSeasonOption == UPDATE_LAST_SEASON_ONLY);
updatePosterThumb(series.get(i).getSerieId(), sToUpdate);
Expand All @@ -839,7 +828,7 @@ public void run() {
}
updateAllSeriesPD.incrementProgressBy(1);
} else {
Log.e(TAG, "Skipped this show (no data received)");
Log.e(SQLiteStore.TAG, "Skipped this show (no data received)");
}
}
if (showArchive == 2) // If coming from restore
Expand All @@ -851,16 +840,16 @@ public void run() {
};
updateAllSeriesPD = new ProgressDialog(this);
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
alertDialog.setTitle(R.string.messages_title_update_all_series);
String updateMessageAD = getString(R.string.dialog_update_all_series) + (lastSeasonOption == UPDATE_ALL_SEASONS ? getString(R.string.dialog_update_speedup) : "");
alertDialog.setTitle(R.string.messages_title_update_series);
String updateMessageAD = getString(R.string.dialog_update_series) + (lastSeasonOption == UPDATE_ALL_SEASONS ? getString(R.string.dialog_update_speedup) : "");
alertDialog.setMessage(updateMessageAD);
alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
alertDialog.setCancelable(false);
alertDialog.setPositiveButton(getString(R.string.dialog_OK), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
updateAllSeriesPD.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
updateAllSeriesPD.setTitle(R.string.messages_title_updating_all_series);
updateAllSeriesPD.setMessage(getString(R.string.messages_update_all_series));
updateAllSeriesPD.setTitle(R.string.messages_title_updating_series);
updateAllSeriesPD.setMessage(getString(R.string.messages_update_series));
updateAllSeriesPD.setCancelable(false);
updateAllSeriesPD.setMax(series.size());
updateAllSeriesPD.setProgress(0);
Expand Down Expand Up @@ -924,7 +913,7 @@ private void getSeries() {
}
listView.post(updateListView);
} catch (Exception e) {
Log.e(TAG, "Error populating TVShowItems or no shows added yet");
Log.e(SQLiteStore.TAG, "Error populating TVShowItems or no shows added yet");
e.printStackTrace();
}
}
Expand Down Expand Up @@ -1036,7 +1025,7 @@ protected Void doInBackground(Void... params) {
}
}
lastStatsUpdate = newAsync;
Log.d(TAG, "Updated show stats on "+ newAsync);
// Log.d(SQLiteStore.TAG, "Updated show stats on "+ newAsync);
}
return null;
}
Expand Down
4 changes: 1 addition & 3 deletions src/nl/asymmetrics/droidshows/thetvdb/model/Serie.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,7 @@ public boolean saveToDB(SQLiteStore SQLS) {
this.episodes.get(e).setSeriesId(this.id);
this.episodes.get(e).saveToDB(SQLS);
}

DroidShows.db.updateShowStats(this.id);

SQLS.updateShowStats(serieId);
} catch(SQLiteException e){
Log.e("DroidShows", e.getMessage());
return false;
Expand Down
Loading

0 comments on commit 9730009

Please sign in to comment.