Show a different list of apps after swap is ready, rather than the default.

Previously, we would redirect to the main list of apps. Now, the swap
thing will show the specific apps in the "LocalRepo" category. It also
shows the "Swap complete" message with a nice icon carrie designed.
This commit is contained in:
Peter Serwylo 2014-08-14 20:31:18 +09:30
parent bcb47c9490
commit a299340db7
48 changed files with 213 additions and 47 deletions

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 475 B

After

Width:  |  Height:  |  Size: 475 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 918 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 601 B

After

Width:  |  Height:  |  Size: 601 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 475 B

After

Width:  |  Height:  |  Size: 475 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 550 B

After

Width:  |  Height:  |  Size: 550 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 718 B

After

Width:  |  Height:  |  Size: 718 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 915 B

After

Width:  |  Height:  |  Size: 915 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 616 B

After

Width:  |  Height:  |  Size: 616 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 776 B

After

Width:  |  Height:  |  Size: 776 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

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

View File

@ -3,6 +3,6 @@
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"
style="@style/SwapTheme.StartSwap.MainText"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/text_title"
android:text="Swap success!"
style="@style/SwapTheme.AppList.SwapSuccess"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/swap_success"
android:layout_gravity="center_horizontal" />
<TextView
android:id="@+id/text_description"
android:text="Tap an app for details and to install."
style="@style/SwapTheme.AppList.SwapSuccessDetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
</LinearLayout>

View File

@ -39,14 +39,17 @@
<item name="android:actionButtonStyle">@style/SwapTheme.Wizard.ActionButton</item>
</style>
<style name="SwapTheme.AppList" parent="AppThemeLightWithDarkActionBar">
<style name="SwapTheme.StartSwap" parent="AppThemeLightWithDarkActionBar">
<item name="android:background">@color/white</item>
</style>
<style name="SwapTheme.AppList" parent="AppThemeLightWithDarkActionBar">
</style>
<style name="SwapTheme.AppList.ListItem" parent="AppThemeLightWithDarkActionBar">
</style>
<style name="SwapTheme.AppList.StartButton">
<style name="SwapTheme.StartSwap.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 -->
@ -60,7 +63,23 @@
</style>
<style name="SwapTheme.AppList.MainText">
<style name="SwapTheme.AppList.SwapSuccess">
<item name="android:textAlignment">center</item>
<item name="android:textSize">25.7sp</item> <!-- 46px * 96dpi / 160dpi -->
<item name="android:paddingTop">28dp</item> <!-- 50px * 96dpi / 160dpi -->
<item name="android:paddingBottom">20.1dp</item> <!-- 36px * 96dpi / 160dpi -->
<item name="android:fontFamily">sans-serif-light</item>
</style>
<style name="SwapTheme.AppList.SwapSuccessDetails">
<item name="android:textAlignment">center</item>
<item name="android:textSize">20.1sp</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:textStyle">bold</item>
</style>
<style name="SwapTheme.StartSwap.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 -->

View File

@ -6,22 +6,21 @@ import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.listener.PauseOnScrollListener;
import org.fdroid.fdroid.*;
import org.fdroid.fdroid.AppDetails;
import org.fdroid.fdroid.FDroid;
import org.fdroid.fdroid.Preferences;
import org.fdroid.fdroid.UpdateService;
import org.fdroid.fdroid.data.App;
import org.fdroid.fdroid.data.AppProvider;
import org.fdroid.fdroid.views.AppListAdapter;
abstract public class AppListFragment extends ListFragment implements
abstract public class AppListFragment extends ThemeableListFragment implements
AdapterView.OnItemClickListener,
Preferences.ChangeListener,
LoaderManager.LoaderCallbacks<Cursor> {

View File

@ -0,0 +1,65 @@
package org.fdroid.fdroid.views.fragments;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import org.fdroid.fdroid.R;
public abstract class ThemeableListFragment extends ListFragment {
protected int getThemeStyle() {
return 0;
}
protected int getHeaderLayout() {
return 0;
}
protected View getHeaderView(LayoutInflater inflater, ViewGroup container) {
if (getHeaderLayout() > 0) {
return inflater.inflate(getHeaderLayout(), null, false);
} else {
return null;
}
}
private LayoutInflater getThemedInflater(Context context)
{
Context c = (getThemeStyle() == 0) ? context : new ContextThemeWrapper(context, getThemeStyle());
return (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
/**
* Normally we'd just let the baseclass ListFrament.onCreateView() from the support library do its magic.
* However, it doesn't allow us to theme it. That is, it always passes getActivity() into the constructor
* of widgets. We are more interested in a ContextThemeWrapper, so that the widgets get appropriately
* themed. In order to get it working, we need to work around android bug 21742 as well
* (https://code.google.com/p/android/issues/detail?id=21742).
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
LayoutInflater themedInflater = getThemedInflater(inflater.getContext());
View view = themedInflater.inflate(R.layout.list_content, container, false);
View headerView = getHeaderView(themedInflater, container);
if (headerView != null) {
ListView listView = (ListView) view.findViewById(android.R.id.list);
listView.addHeaderView(headerView);
}
// Workaround for https://code.google.com/p/android/issues/detail?id=21742
view.findViewById(android.R.id.empty).setId(0x00ff0001);
view.findViewById(R.id.progressContainer).setId(0x00ff0002);
view.findViewById(android.R.id.progress).setId(0x00ff0003);
return view;
}
}

View File

@ -2,7 +2,6 @@ package org.fdroid.fdroid.views.swap;
import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
@ -94,10 +93,11 @@ public class ConfirmReceiveSwapFragment extends Fragment implements ProgressList
if (event.type.equals(UpdateService.EVENT_COMPLETE_AND_SAME) ||
event.type.equals(UpdateService.EVENT_COMPLETE_WITH_CHANGES)) {
Intent intent = new Intent();
intent.putExtra("category", parser.getHost()); // TODO: Load repo from database to get proper name. This is what the category we want to select will be called.
((ConnectSwapActivity)getActivity()).onRepoUpdated();
/*Intent intent = new Intent();
intent.putExtra("category", newRepoConfig.getHost()); // TODO: Load repo from database to get proper name. This is what the category we want to select will be called.
getActivity().setResult(Activity.RESULT_OK, intent);
finish();
finish();*/
} else if (event.type.equals(UpdateService.EVENT_ERROR)) {
// TODO: Show message on this screen (with a big "okay" button that goes back to F-Droid activity)
// rather than finishing directly.

View File

@ -1,5 +1,6 @@
package org.fdroid.fdroid.views.swap;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
@ -7,6 +8,7 @@ import android.support.v4.app.FragmentManager;
public class ConnectSwapActivity extends FragmentActivity {
private static final String STATE_CONFIRM = "startSwap";
private static final String STATE_APP_LIST = "swapAppList";
@Override
public void onCreate(Bundle savedInstanceState) {
@ -24,6 +26,7 @@ public class ConnectSwapActivity extends FragmentActivity {
}
}
@Override
public void onBackPressed() {
if (currentState().equals(STATE_CONFIRM)) {
@ -34,8 +37,15 @@ public class ConnectSwapActivity extends FragmentActivity {
}
private String currentState() {
FragmentManager.BackStackEntry lastFragment = getSupportFragmentManager().getBackStackEntryAt(getSupportFragmentManager().getBackStackEntryCount() - 1);
int index = getSupportFragmentManager().getBackStackEntryCount() - 1;
FragmentManager.BackStackEntry lastFragment = getSupportFragmentManager().getBackStackEntryAt(index);
return lastFragment.getName();
}
public void onRepoUpdated() {
Intent intent = new Intent(this, SwapAppListActivity.class);
startActivity(intent);
}
}

View File

@ -1,12 +1,10 @@
package org.fdroid.fdroid.views.swap;
import android.content.Context;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
@ -14,9 +12,7 @@ import android.support.v4.widget.SimpleCursorAdapter;
import android.text.TextUtils;
import android.view.ActionMode;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
@ -26,11 +22,12 @@ import org.fdroid.fdroid.FDroidApp;
import org.fdroid.fdroid.R;
import org.fdroid.fdroid.data.InstalledAppProvider;
import org.fdroid.fdroid.localrepo.LocalRepoManager;
import org.fdroid.fdroid.views.fragments.ThemeableListFragment;
import java.util.HashSet;
import java.util.Set;
public class SelectAppsFragment extends ListFragment
public class SelectAppsFragment extends ThemeableListFragment
implements LoaderManager.LoaderCallbacks<Cursor>, SearchView.OnQueryTextListener {
private PackageManager packageManager;
@ -75,30 +72,6 @@ public class SelectAppsFragment extends ListFragment
return false;
}
/**
* Normally we'd just let the baseclass ListFrament.onCreateView() from the support library do its magic.
* However, it doesn't allow us to theme it. That is, it always passes getActivity() into the constructor
* of widgets. We are more interested in a ContextThemeWrapper, so that the widgets get appropriately
* themed. In order to get it working, we need to work around android bug 21742 as well
* (https://code.google.com/p/android/issues/detail?id=21742).
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
LayoutInflater themedInflater = (LayoutInflater)new ContextThemeWrapper(inflater.getContext(), R.style.SwapTheme_AppList).getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = themedInflater.inflate(R.layout.swap_create, container, false);
ListView listView = (ListView)view.findViewById(android.R.id.list);
listView.addHeaderView(themedInflater.inflate(R.layout.swap_create_header, null, false));
// Workaround for https://code.google.com/p/android/issues/detail?id=21742
view.findViewById(android.R.id.empty).setId(0x00ff0001);
view.findViewById(R.id.progressContainer).setId(0x00ff0002);
view.findViewById(android.R.id.progress).setId(0x00ff0003);
return view;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
@ -246,4 +219,13 @@ public class SelectAppsFragment extends ListFragment
return mCurrentFilterString;
}
@Override
protected int getThemeStyle() {
return R.style.SwapTheme_StartSwap;
}
@Override
protected int getHeaderLayout() {
return R.layout.swap_create_header;
}
}

View File

@ -22,7 +22,7 @@ public class StartSwapFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
LayoutInflater themedInflater = (LayoutInflater)new ContextThemeWrapper(inflater.getContext(), R.style.SwapTheme_AppList).getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LayoutInflater themedInflater = (LayoutInflater)new ContextThemeWrapper(inflater.getContext(), R.style.SwapTheme_StartSwap).getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = themedInflater.inflate(R.layout.swap_blank, container, false);
view.findViewById(R.id.button_start_swap).setOnClickListener(new View.OnClickListener() {

View File

@ -0,0 +1,52 @@
package org.fdroid.fdroid.views.swap;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import org.fdroid.fdroid.R;
import org.fdroid.fdroid.data.AppProvider;
import org.fdroid.fdroid.views.AppListAdapter;
import org.fdroid.fdroid.views.AvailableAppListAdapter;
import org.fdroid.fdroid.views.fragments.AppListFragment;
public class SwapAppListActivity extends ActionBarActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
getSupportFragmentManager()
.beginTransaction()
.add(android.R.id.content, new SwapAppListFragment())
.commit();
}
}
private static class SwapAppListFragment extends AppListFragment {
@Override
protected int getHeaderLayout() {
return R.layout.swap_success_header;
}
@Override
protected AppListAdapter getAppListAdapter() {
return new AvailableAppListAdapter(getActivity(), null);
}
@Override
protected String getFromTitle() {
return getString(R.string.swap);
}
@Override
protected Uri getDataUri() {
return AppProvider.getCategoryUri("LocalRepo");
}
}
}