Beginnings of an implementation for Swap.

The Fragments and an Activity which tie all of the swap views together
has begun. The first bit of implementation is to get the current
wifi network displayed, which worked out alright.

This commit contains a lot of theme related stuff, particularly
involving taking assets from carries mockups and making them suitable
to use as drawables. The process for doing this is a story for another
day, but I'll document it and put it on the wiki in the future. carrie
showed me a script that a mate of hers used on another project, and
I've adapted it a little to make it work nicely here (note - it isn't
in this commit).

The button is blue, and always shown with associated text in the
ActionBar. This required a custom drawable which was set as the
background in the styles.xml.
This commit is contained in:
Peter Serwylo 2014-08-19 15:37:44 +09:30
parent b14bffa1c5
commit ae9cb5b89b
59 changed files with 736 additions and 7 deletions

View File

@ -281,6 +281,15 @@
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".FDroid" /> android:value=".FDroid" />
</activity> </activity>
<activity
android:label="@string/menu_swap"
android:name=".views.swap.SwapActivity"
android:parentActivityName=".FDroid"
android:theme="@style/SwapTheme.Wizard">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".FDroid" />
</activity>
<activity <activity
android:name=".SearchResults" android:name=".SearchResults"
android:label="@string/search_results" android:label="@string/search_results"

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
res/drawable-hdpi/wifi.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
res/drawable-ldpi/wifi.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 718 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

BIN
res/drawable-mdpi/wifi.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 915 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 616 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 776 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
res/drawable-xhdpi/wifi.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
res/drawable/ic_swap.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
res/drawable/nfc_touch.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<solid android:color="@color/swap_light_blue_pressed" />
<padding
android:left="26.9dp"
android:top="17.9dp"
android:right="26.9dp"
android:bottom="17.9dp" />
<!--
Padding left/right = 48px * 90dpi / 160dpi = ~26.9dp
Padding top/bottom = 32px * 90dpi / 160dpi = ~17.9dp
-->
</shape>
</item>
<item>
<shape>
<solid android:color="@color/swap_light_blue" />
<padding
android:left="26.9dp"
android:top="17.9dp"
android:right="26.9dp"
android:bottom="17.9dp" />
</shape>
</item>
</selector>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="@color/white" />
<padding
android:top="1dp"/>
</shape>
</item>
<item>
<shape>
<solid android:color="@color/swap_blue" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
</layer-list>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="@color/white" />
<padding
android:top="1dp"/>
</shape>
</item>
<item>
<shape>
<solid android:color="@color/swap_blue_pressed" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
</layer-list>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/swap_button_pressed" />
<item android:drawable="@drawable/swap_button_normal" />
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="@color/swap_light_blue" />
</shape>
</item>
</selector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/swap_wifi_likely_to_work" />
<size android:width="88dp" android:height="7dp" />
</shape>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/swap_wifi_may_work"/>
<size android:width="88dp" android:height="7dp" />
</shape>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/swap_blue" />
</shape>

BIN
res/drawable/wifi.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -4,7 +4,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="10dp" android:padding="10dp"
android:baselineAligned="false" > android:baselineAligned="false"
xmlns:tools="http://schemas.android.com/tools" >
<!-- Actual icon size is dependent on preferences and set in <!-- Actual icon size is dependent on preferences and set in
AppListAdapater.java:layoutIcon() --> AppListAdapater.java:layoutIcon() -->
@ -14,7 +15,8 @@
android:layout_width="48dip" android:layout_width="48dip"
android:layout_height="48dip" android:layout_height="48dip"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:scaleType="fitCenter" /> android:scaleType="fitCenter"
tools:src="@drawable/ic_launcher" />
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
@ -44,7 +46,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:gravity="start" android:gravity="start"
android:textAlignment="viewStart" /> android:textAlignment="viewStart"
tools:text="F-Droid" />
<TextView android:id="@+id/status" <TextView android:id="@+id/status"
android:textSize="13sp" android:textSize="13sp"
@ -58,6 +61,7 @@
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:gravity="end" android:gravity="end"
android:textAlignment="viewEnd" android:textAlignment="viewEnd"
tools:text="Installed"
/> />
</LinearLayout> </LinearLayout>
@ -79,6 +83,7 @@
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:gravity="start" android:gravity="start"
android:textAlignment="viewStart" android:textAlignment="viewStart"
tools:text="Application manager"
/> />
<TextView android:id="@+id/license" <TextView android:id="@+id/license"
@ -93,6 +98,7 @@
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:gravity="end" android:gravity="end"
android:textAlignment="viewEnd" android:textAlignment="viewEnd"
tools:text="GPLv3"
/> />
</LinearLayout> </LinearLayout>

24
res/layout/swap_blank.xml Normal file
View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/text_description"
android:text="Your mobile device becomes an app store with Swap!"
style="@style/SwapTheme.AppList.MainText"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/checkbox_dont_show"
android:text="START A SWAP"
style="@style/SwapTheme.AppList.StartButton"
android:layout_width="match_parent"
android:layout_below="@+id/text_description"
android:layout_centerHorizontal="true"/>
</RelativeLayout>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools" tools:context=".views.swap.SwapActivity">
<ListView
android:id="@android:id/list"
android:layout_height="match_parent"
android:layout_width="match_parent"
tools:listitem="@layout/applistitem"
tools:listheader="@layout/swap_create_header"
/>
</RelativeLayout>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text_description"
android:text="Tap to select the apps you want to swap."
style="@style/SwapTheme.AppList.MainText"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

View File

@ -0,0 +1,169 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".views.swap.SwapActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/text_description"
android:layout_gravity="center_horizontal"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
style="@style/SwapTheme.Wizard.MainText"
android:text="@string/swap_join_same_wifi"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/wifi_icon"
android:src="@drawable/wifi"
android:layout_below="@+id/text_description"
android:layout_centerHorizontal="true"
android:layout_above="@+id/wifi_ssid"/>
<Button style="@style/SwapTheme.Wizard.OptionButton"
android:id="@+id/btn_bluetooth"
android:text="@string/swap_use_bluetooth"
android:layout_alignParentBottom="true" />
<Button style="@style/SwapTheme.Wizard.OptionButton"
android:text="@string/swap_wifi_help"
android:layout_above="@id/btn_bluetooth"
android:id="@+id/btn_learn_more_about_wifi"/>
<LinearLayout
android:id="@+id/wifi_type_descriptions"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/btn_learn_more_about_wifi"
android:layout_centerHorizontal="true"
android:gravity="bottom"
android:paddingBottom="20dp"
android:paddingTop="20dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginRight="10dp">
<ImageView
android:id="@+id/wifi_icon_public"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/wifi_ap_public"/>
<TextView
android:id="@+id/wifi_label_public"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Public"/>
<TextView
android:id="@+id/wifi_warning_public"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="May work"/>
<ImageView
android:id="@+id/wifi_status_public"
android:src="@drawable/swap_wifi_may_work"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp">
<ImageView
android:id="@+id/wifi_icon_private"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/wifi_ap_private" />
<TextView
android:id="@+id/wifi_label_private"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Private" />
<TextView
android:id="@+id/wifi_warning_private"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Promising" />
<ImageView
android:id="@+id/wifi_status_private"
android:src="@drawable/swap_wifi_likely_to_work"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginLeft="10dp">
<ImageView
android:id="@+id/wifi_icon_personal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/wifi_ap_personal" />
<TextView
android:id="@+id/wifi_label_personal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hotspot" />
<TextView
android:id="@+id/wifi_warning_personal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Best bet" />
<ImageView
android:id="@+id/wifi_status_personal"
android:src="@drawable/swap_wifi_likely_to_work"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/swap_view_available_networks"
android:id="@+id/wifi_available_networks_prompt"
android:layout_above="@id/wifi_type_descriptions"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="No network yet"
android:id="@+id/wifi_ssid"
style="@style/SwapTheme.Wizard.WifiSSID"
android:layout_above="@id/wifi_available_networks_prompt"
android:layout_centerHorizontal="true" />
</RelativeLayout>

35
res/layout/swap_nfc.xml Normal file
View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:paddingTop="38.8dp"> <!-- 69px * 96dpi / 160dpi -->
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/icon_nfc"
android:src="@drawable/nfc_touch"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"/>
<TextView
android:id="@+id/text_description"
android:text="@string/swap_nfc_description"
style="@style/SwapTheme.Wizard.MainText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/icon_nfc" />
<CheckBox
android:id="@+id/checkbox_dont_show"
android:text="Don't show this again"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/text_description"
android:layout_centerHorizontal="true"/>
</RelativeLayout>

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView"
android:layout_gravity="center_horizontal"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
tools:text="One person needs to scan the code, or type the URL of the other swapper into a browser."
style="@style/SwapTheme.Wizard.MainText"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/wifi_qr_code"
tools:src="@drawable/swap_qr_example"
android:layout_below="@+id/textView" android:layout_above="@+id/device_ip_address"/>
<Button style="@style/SwapTheme.Wizard.OptionButton"
android:id="@+id/btn_not_working"
android:text="It's not working"
android:layout_alignParentBottom="true" />
<Button style="@style/SwapTheme.Wizard.OptionButton"
android:text="Open QR Code Scanner"
android:layout_above="@id/btn_not_working" android:layout_gravity="center" android:id="@+id/button"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="@+id/device_ip_address"
tools:text="192.168.1.1:8888"
android:layout_above="@+id/button" android:layout_centerHorizontal="true"
style="@style/SwapTheme.Wizard.LocalIpAddress"/>
</RelativeLayout>

View File

@ -13,8 +13,8 @@
android:title="@string/menu_update_repo" android:title="@string/menu_update_repo"
app:showAsAction="ifRoom"/> app:showAsAction="ifRoom"/>
<item <item
android:id="@+id/action_local_repo" android:id="@+id/action_swap"
android:title="@string/local_repo" android:title="@string/swap"
app:showAsAction="ifRoom"/> app:showAsAction="ifRoom"/>
<item <item
android:id="@+id/action_manage_repos" android:id="@+id/action_manage_repos"

11
res/menu/swap.xml Normal file
View File

@ -0,0 +1,11 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_next"
android:title="Next"
android:titleCondensed="Next"/>
<!-- Currently in a style, but that style probably wont work on 8 -> 11 devices -->
<!--android:drawable="@drawable/swap_action_button_skin"-->
</menu>

View File

@ -3,4 +3,12 @@
<color name="signed">#ffcccccc</color> <color name="signed">#ffcccccc</color>
<color name="unsigned">#ffCC0000</color> <color name="unsigned">#ffCC0000</color>
<color name="unverified">#ff999999</color> <color name="unverified">#ff999999</color>
<color name="swap_light_blue">#27aae1</color>
<color name="swap_light_blue_pressed">#ff98cce1</color>
<color name="swap_blue">#1c6bbc</color>
<color name="swap_blue_pressed">#ff6ca8d5</color>
<color name="swap_wifi_may_work">#fbb040</color>
<color name="swap_wifi_likely_to_work">#00a14b</color>
</resources> </resources>

View File

@ -295,4 +295,12 @@
<string name="system_permission_denied_body">This option is only available when F-Droid is installed as a system-app.</string> <string name="system_permission_denied_body">This option is only available when F-Droid is installed as a system-app.</string>
<string name="app_description">F-Droid is an installable catalogue of FOSS (Free and Open Source Software) applications for the Android platform. The client makes it easy to browse, install, and keep track of updates on your device.</string> <string name="app_description">F-Droid is an installable catalogue of FOSS (Free and Open Source Software) applications for the Android platform. The client makes it easy to browse, install, and keep track of updates on your device.</string>
<string name="swap_nfc_description">If your friend has <b>F-Droid and NFC turned on</b> touch your phones together.</string>
<string name="swap_join_same_wifi">Join the same Wifi as your friend</string>
<string name="swap_use_bluetooth">Use Bluetooth instead</string>
<string name="swap_wifi_help">Learn more about Wifi</string>
<string name="menu_swap">Swap apps</string>
<string name="swap">Swap apps</string>
<string name="swap_no_wifi_network">No network yet</string>
<string name="swap_view_available_networks">(Tap to open available networks)</string>
</resources> </resources>

View File

@ -33,4 +33,93 @@
<!-- customizations that are not API-level specific go here. --> <!-- customizations that are not API-level specific go here. -->
</style> </style>
<style name="SwapTheme.Wizard" parent="AppThemeDark">
<item name="android:windowBackground">@drawable/swap_window_background</item>
<item name="android:actionBarStyle">@style/Widget.AppCompat.ActionBar.Solid</item>
<item name="android:actionButtonStyle">@style/SwapTheme.Wizard.ActionButton</item>
</style>
<style name="SwapTheme.AppList" parent="AppThemeLightWithDarkActionBar">
</style>
<style name="SwapTheme.AppList.StartButton">
<item name="android:layout_marginLeft">9dp</item> <!-- 16px * 96dpi / 160dpi -->
<item name="android:layout_marginRight">9dp</item> <!-- 16px * 96dpi / 160dpi -->
<item name="android:layout_height">63.3dp</item> <!-- 113px * 96dpi / 160dpi -->
<item name="android:layout_width">match_parent</item>
<item name="android:textSize">18.5sp</item> <!-- 33px * 96dpi / 160dpi -->
<item name="android:background">@drawable/swap_start_button_skin</item>
<item name="android:textColor">#fff</item>
<item name="android:drawableLeft">@drawable/ic_swap</item>
<item name="android:paddingLeft">10dp</item>
</style>
<style name="SwapTheme.AppList.MainText">
<item name="android:textAlignment">center</item>
<item name="android:textSize">20.1sp</item> <!-- 36px * 96dpi / 160dpi -->
<item name="android:paddingLeft">28dp</item> <!-- 50px * 96dpi / 160dpi -->
<item name="android:paddingRight">28dp</item> <!-- 50px * 96dpi / 160dpi -->
<item name="android:paddingTop">28dp</item> <!-- 50px * 96dpi / 160dpi -->
<item name="android:paddingBottom">16.8dp</item> <!-- 30px * 96dpi / 160dpi -->
</style>
<style name="SwapTheme.Wizard.Text">
<item name="android:textAlignment">center</item>
<item name="android:textColor">#fff</item>
<item name="android:textColorPrimary">#fff</item>
<item name="android:textColorSecondary">#fff</item>
</style>
<style name="SwapTheme.Wizard.ActionButton" parent="Widget.AppCompat.ActionButton">
<item name="android:textAppearance">@style/SwapTheme.Wizard.Text</item>
<item name="android:paddingLeft">10dp</item>
<item name="android:paddingRight">10dp</item>
<item name="android:paddingTop">5dp</item>
<item name="android:paddingBottom">5dp</item>
<item name="android:background">@drawable/swap_action_button_skin</item>
</style>
<style name="SwapTheme.Wizard.MainText" parent="@style/SwapTheme.Wizard.Text">
<item name="android:paddingLeft">40dp</item>
<item name="android:paddingRight">40dp</item>
<item name="android:paddingTop">39.3dp</item> <!-- 70px * 96dpi / 160dpi -->
<item name="android:paddingBottom">29.25dp</item> <!-- 52px * 96dpi / 160dpi -->
<item name="android:fontFamily">sans-serif-light</item>
</style>
<style name="SwapTheme.Wizard.LocalIpAddress" parent="@style/SwapTheme.Wizard.Text">
<item name="android:textSize">32.5sp</item> <!-- 58px * 96dpi / 160dpi -->
<item name="android:paddingLeft">40dp</item>
<item name="android:paddingRight">40dp</item>
<item name="android:paddingTop">22.5dp</item> <!-- 40px * 96dpi / 160dpi -->
<item name="android:paddingBottom">42.5dp</item> <!-- 75px * 96dpi / 160dpi -->
<item name="android:textStyle">bold</item>
</style>
<style name="SwapTheme.Wizard.WifiSSID" parent="@style/SwapTheme.Wizard.Text">
<item name="android:textSize">26sp</item> <!-- 46px * 96dpi / 160dpi -->
<item name="android:paddingLeft">40dp</item>
<item name="android:paddingRight">40dp</item>
<item name="android:paddingTop">20dp</item>
<item name="android:paddingBottom">5dp</item>
<item name="android:textStyle">bold</item>
</style>
<!--
Buttons down the bottom of the screen, which prompt the user for further
info, or to change the process somehow (e.g. Use Bluetooth instead of Wifi).
-->
<style name="SwapTheme.Wizard.OptionButton">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:padding">19dp</item> <!-- 34px * 96dpi / 160dpi -->
<item name="android:textSize">20.25sp</item> <!-- 36px * 96dpi / 160dpi -->
<item name="android:background">@drawable/swap_button_skin</item>
<item name="android:textColor">#fff</item>
<item name="android:fontFamily">sans-serif-light</item>
<item name="android:layout_margin">0dp</item>
</style>
</resources> </resources>

View File

@ -47,6 +47,7 @@ import org.fdroid.fdroid.data.AppProvider;
import org.fdroid.fdroid.views.AppListFragmentPagerAdapter; import org.fdroid.fdroid.views.AppListFragmentPagerAdapter;
import org.fdroid.fdroid.views.LocalRepoActivity; import org.fdroid.fdroid.views.LocalRepoActivity;
import org.fdroid.fdroid.views.ManageReposActivity; import org.fdroid.fdroid.views.ManageReposActivity;
import org.fdroid.fdroid.views.swap.SwapActivity;
public class FDroid extends ActionBarActivity { public class FDroid extends ActionBarActivity {
@ -145,8 +146,12 @@ public class FDroid extends ActionBarActivity {
startActivityForResult(prefs, REQUEST_PREFS); startActivityForResult(prefs, REQUEST_PREFS);
return true; return true;
case R.id.action_local_repo: case R.id.action_swap:
startActivity(new Intent(this, LocalRepoActivity.class)); startActivity(new Intent(this, SwapActivity.class));
return true;
case R.id.action_swap:
startActivity(new Intent(this, SwapActivity.class));
return true; return true;
case R.id.action_search: case R.id.action_search:

View File

@ -0,0 +1,64 @@
package org.fdroid.fdroid.views.swap;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.content.LocalBroadcastManager;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import org.fdroid.fdroid.FDroidApp;
import org.fdroid.fdroid.R;
import org.fdroid.fdroid.net.WifiStateChangeService;
public class JoinWifiFragment extends Fragment {
private BroadcastReceiver onWifiChange = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
refreshWifiState();
}
};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View joinWifiView = inflater.inflate(R.layout.swap_join_wifi, container, false);
joinWifiView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getActivity(), "Touched view", Toast.LENGTH_LONG);
}
});
return joinWifiView;
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
// TODO: Listen for "Connecting..." state and reflect that in the view too.
LocalBroadcastManager.getInstance(activity).registerReceiver(
onWifiChange,
new IntentFilter(WifiStateChangeService.BROADCAST));
}
@Override
public void onResume() {
super.onResume();
refreshWifiState();
}
private void refreshWifiState() {
if (getView() != null) {
TextView ssidView = (TextView) getView().findViewById(R.id.wifi_ssid);
String text = TextUtils.isEmpty(FDroidApp.ssid) ? getString(R.string.swap_no_wifi_network) : FDroidApp.ssid;
ssidView.setText(text);
}
}
}

View File

@ -0,0 +1,17 @@
package org.fdroid.fdroid.views.swap;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import org.fdroid.fdroid.R;
public class NfcSwapFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.swap_nfc, container, false);
}
}

View File

@ -0,0 +1,96 @@
package org.fdroid.fdroid.views.swap;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import org.fdroid.fdroid.R;
public class SwapActivity extends ActionBarActivity implements SwapProcessManager {
private static final String STATE_JOIN_WIFI = "joinWifi";
private static final String STATE_NFC = "nfc";
private static final String STATE_WIFI_QR = "wifiQr";
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.swap, menu);
MenuItem next = menu.getItem(0);
MenuItemCompat.setShowAsAction(next, MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
return true;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
return super.onPrepareOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_next) {
moveToNext();
return true;
}
return super.onOptionsItemSelected(item);
}
private void moveToNext() {
getSupportFragmentManager().popBackStack();
FragmentManager.BackStackEntry lastFragment = getSupportFragmentManager().getBackStackEntryAt(getSupportFragmentManager().getBackStackEntryCount() - 1);
String name = lastFragment.getName();
switch (name) {
case STATE_JOIN_WIFI:
onAttemptNfc();
break;
case STATE_NFC:
onWifiQr();
break;
case STATE_WIFI_QR:
break;
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
getSupportFragmentManager()
.beginTransaction()
.add(android.R.id.content, new JoinWifiFragment(), STATE_JOIN_WIFI)
.addToBackStack(STATE_JOIN_WIFI)
.commit();
}
}
@Override
public void onAttemptNfc() {
getSupportFragmentManager()
.beginTransaction()
.addToBackStack(STATE_NFC)
.replace(android.R.id.content, new NfcSwapFragment(), STATE_NFC)
.commit();
}
@Override
public void onBluetooth() {
}
@Override
public void onWifiQr() {
getSupportFragmentManager()
.beginTransaction()
.addToBackStack(STATE_WIFI_QR)
.replace(android.R.id.content, new WifiQrFragment(), STATE_WIFI_QR)
.commit();
}
}

View File

@ -0,0 +1,7 @@
package org.fdroid.fdroid.views.swap;
public interface SwapProcessManager {
public void onAttemptNfc();
public void onBluetooth();
public void onWifiQr();
}

View File

@ -0,0 +1,17 @@
package org.fdroid.fdroid.views.swap;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import org.fdroid.fdroid.R;
public class WifiQrFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.swap_nfc, container, false);
}
}