0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 12:02:16 +02:00

Fixed all the crashes caused by starting the app without any selected deck and with the option 'Sample deck' deselected. It also has been implemented the DeckPicker's title change when sd card is unmounted and the correct display in both orientations of the message informing the user about the sd card being unavailable.

This commit is contained in:
edu-zamora 2009-11-05 14:10:52 +01:00
parent 6272c63c0d
commit fddf1f8683
3 changed files with 18 additions and 7 deletions

View File

@ -14,6 +14,7 @@
<string name="card_template">&lt;html&gt; &lt;head&gt; &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;file:///android_asset/flashcard_css&quot; /&gt; &lt;/head&gt; &lt;body&gt; &lt;span class=&quot;card&quot;&gt; ::content:: &lt;/span&gt; &lt;/body&gt; &lt;/html&gt;</string>
<string name="deckpicker_title">Select a deck you copied to your SD card</string>
<string name="deckpicker_title_nosdcard">SD card is unmounted</string>
<string name="deckpicker_due">%1$d of %2$d due</string>
<string name="deckpicker_new">%d new today</string>
<string name="deckpicker_loaddeck">Loading deck...</string>

View File

@ -520,6 +520,13 @@ public class Ankidroid extends Activity implements Runnable
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
LinearLayout sdLayout = (LinearLayout) findViewById(R.id.sd_layout);
if(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
sdLayout.setPadding(0, 50, 0, 0);
else if(newConfig.orientation == Configuration.ORIENTATION_PORTRAIT)
sdLayout.setPadding(0, 100, 0, 0);
//extra height that the Whiteboard should have to be able to write in all its surface either on the question or on the answer
int extraHeight = 0;
if(mSelectRemembered.isShown() && mSelectNotRemembered.isShown())
@ -644,6 +651,7 @@ public class Ankidroid extends Activity implements Runnable
public void updateCard(String content)
{
Log.i(TAG, "updateCard");
String card = cardTemplate.replace("::content::", content);
mCard.loadDataWithBaseURL("", card, "text/html", "utf-8", null);
}
@ -715,14 +723,14 @@ public class Ankidroid extends Activity implements Runnable
{
Log.i(TAG, "Ankidroid loader thread - run");
loadDeck(deckFilename);
//if(deckSelected)
//{
if(deckSelected)
{
handler.sendEmptyMessage(0);
//} else
//{
} else
{
//Dismiss dialog and show something to indicate to the user that a deck has not been loaded
//dialog.dismiss();
//}
dialog.dismiss();
}
}
private Handler handler = new Handler()

View File

@ -176,7 +176,8 @@ public class DeckPicker extends Activity implements Runnable
if(!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()))
{
Log.i(TAG, "populateDeckList - No sd card.");
setTitle(R.string.deckpicker_title_nosdcard);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("The SD card could not be read. Please, turn off USB storage.");
builder.setPositiveButton("OK", null);
@ -389,6 +390,7 @@ public class DeckPicker extends Activity implements Runnable
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
String deckPath = preferences.getString("deckPath", "/sdcard");
mDeckIsSelected = false;
setTitle(R.string.deckpicker_title);
populateDeckList(deckPath);
}
}