Swap works on 2.3 devices.

* Cleaned up text alignment styles for API < 17.

API v17 has a textAlignment style, wherease previous verisons rely on
the "gravity" property. This change includes gravity="center" where there
was previously only textAlignment="center".

 * Fragments get added properly on 2.3 device.

For some reason, when adding the fragment to android.R.id.content, it
wouldn't work on my 2.3 device. This change includes a (almost) empty
activity layout with a single FrameLayout. The fragments are added to
this rather than "content", and it works better. It is not perfect - it
still adds the fargments behind the action bar, and so the action bar
appears blue. But at least they are there :)

 * Added translatable strings where constants were used before.

Not related to v2.3 support, but stil important for a stable release,
that is fully translated.
This commit is contained in:
Peter Serwylo 2014-12-30 11:48:20 +11:00
parent 7fb2de4bae
commit 4711b50836
5 changed files with 32 additions and 10 deletions

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</FrameLayout>
</RelativeLayout>

View File

@ -8,14 +8,14 @@
<TextView <TextView
android:id="@+id/text_description" android:id="@+id/text_description"
android:text="Your mobile device becomes an app store with Swap!" android:text="@string/swap_introduction"
style="@style/SwapTheme.StartSwap.MainText" style="@style/SwapTheme.StartSwap.MainText"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<Button <Button
android:id="@+id/button_start_swap" android:id="@+id/button_start_swap"
android:text="START A SWAP" android:text="@string/swap_start"
style="@style/SwapTheme.StartSwap.StartButton" style="@style/SwapTheme.StartSwap.StartButton"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_below="@+id/text_description" android:layout_below="@+id/text_description"

View File

@ -307,4 +307,6 @@
<string name="open_qr_code_scanner">Open QR Code Scanner</string> <string name="open_qr_code_scanner">Open QR Code Scanner</string>
<string name="swap_welcome">Welcome to F-Droid!</string> <string name="swap_welcome">Welcome to F-Droid!</string>
<string name="swap_confirm_connect">Do you want to get apps from %1$s now?</string> <string name="swap_confirm_connect">Do you want to get apps from %1$s now?</string>
<string name="swap_introduction">Your mobile device becomes an app store with Swap!</string>
<string name="swap_start">START A SWAP</string>
</resources> </resources>

View File

@ -12,14 +12,14 @@
<!-- backward-compatibility theme options go here --> <!-- backward-compatibility theme options go here -->
</style> </style>
<color name="black">#FF000000</color> <color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color> <color name="white">#FFFFFFFF</color>
<color name="red">#FFFF0000</color> <color name="red">#FFFF0000</color>
<style name="AboutDialogLight" parent="@android:style/Theme.Dialog"> <style name="AboutDialogLight" parent="@android:style/Theme.Dialog">
<item name="@android:windowBackground">@color/black</item> <item name="@android:windowBackground">@color/black</item>
<item name="@android:textColor">@color/white</item> <item name="@android:textColor">@color/white</item>
</style> </style>
<style name="AppThemeDark" parent="AppBaseThemeDark"> <style name="AppThemeDark" parent="AppBaseThemeDark">
<!-- customizations that are not API-level specific go here. --> <!-- customizations that are not API-level specific go here. -->
@ -65,6 +65,7 @@
<style name="SwapTheme.AppList.SwapSuccess"> <style name="SwapTheme.AppList.SwapSuccess">
<item name="android:textAlignment">center</item> <item name="android:textAlignment">center</item>
<item name="android:gravity">center</item>
<item name="android:textSize">25.7sp</item> <!-- 46px * 96dpi / 160dpi --> <item name="android:textSize">25.7sp</item> <!-- 46px * 96dpi / 160dpi -->
<item name="android:paddingTop">28dp</item> <!-- 50px * 96dpi / 160dpi --> <item name="android:paddingTop">28dp</item> <!-- 50px * 96dpi / 160dpi -->
<item name="android:paddingBottom">20.1dp</item> <!-- 36px * 96dpi / 160dpi --> <item name="android:paddingBottom">20.1dp</item> <!-- 36px * 96dpi / 160dpi -->
@ -73,6 +74,7 @@
<style name="SwapTheme.AppList.SwapSuccessDetails"> <style name="SwapTheme.AppList.SwapSuccessDetails">
<item name="android:textAlignment">center</item> <item name="android:textAlignment">center</item>
<item name="android:gravity">center</item>
<item name="android:textSize">20.1sp</item> <!-- 36px * 96dpi / 160dpi --> <item name="android:textSize">20.1sp</item> <!-- 36px * 96dpi / 160dpi -->
<item name="android:paddingTop">20.1dp</item> <!-- 36px * 96dpi / 160dpi --> <item name="android:paddingTop">20.1dp</item> <!-- 36px * 96dpi / 160dpi -->
<item name="android:paddingBottom">20.1dp</item> <!-- 36px * 96dpi / 160dpi --> <item name="android:paddingBottom">20.1dp</item> <!-- 36px * 96dpi / 160dpi -->
@ -81,6 +83,7 @@
<style name="SwapTheme.StartSwap.MainText"> <style name="SwapTheme.StartSwap.MainText">
<item name="android:textAlignment">center</item> <item name="android:textAlignment">center</item>
<item name="android:gravity">center</item>
<item name="android:textSize">20.1sp</item> <!-- 36px * 96dpi / 160dpi --> <item name="android:textSize">20.1sp</item> <!-- 36px * 96dpi / 160dpi -->
<item name="android:paddingLeft">28dp</item> <!-- 50px * 96dpi / 160dpi --> <item name="android:paddingLeft">28dp</item> <!-- 50px * 96dpi / 160dpi -->
<item name="android:paddingRight">28dp</item> <!-- 50px * 96dpi / 160dpi --> <item name="android:paddingRight">28dp</item> <!-- 50px * 96dpi / 160dpi -->
@ -90,6 +93,7 @@
<style name="SwapTheme.Wizard.Text"> <style name="SwapTheme.Wizard.Text">
<item name="android:textAlignment">center</item> <item name="android:textAlignment">center</item>
<item name="android:gravity">center</item>
<item name="android:textColor">#fff</item> <item name="android:textColor">#fff</item>
<item name="android:textColorPrimary">#fff</item> <item name="android:textColorPrimary">#fff</item>
<item name="android:textColorSecondary">#fff</item> <item name="android:textColorSecondary">#fff</item>

View File

@ -80,6 +80,8 @@ public class SwapActivity extends ActionBarActivity implements SwapProcessManage
if (savedInstanceState == null) { if (savedInstanceState == null) {
setContentView(R.layout.swap_activity);
showFragment(new StartSwapFragment(), STATE_START_SWAP); showFragment(new StartSwapFragment(), STATE_START_SWAP);
if (FDroidApp.isLocalRepoServiceRunning()) { if (FDroidApp.isLocalRepoServiceRunning()) {
@ -133,7 +135,7 @@ public class SwapActivity extends ActionBarActivity implements SwapProcessManage
private void showFragment(Fragment fragment, String name) { private void showFragment(Fragment fragment, String name) {
getSupportFragmentManager() getSupportFragmentManager()
.beginTransaction() .beginTransaction()
.replace(android.R.id.content, fragment, name) .replace(R.id.fragment_container, fragment, name)
.addToBackStack(name) .addToBackStack(name)
.commit(); .commit();
} }