Started swapping our ActionBar in favor of ActionBarSherlock

This commit is contained in:
Lennart Rosam 2012-02-05 22:47:25 +01:00
Родитель ae7af383fd
Коммит ca5455e88d
15 изменённых файлов: 144 добавлений и 174 удалений

Просмотреть файл

@ -7,11 +7,11 @@
<classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/commons-httpclient-3.0.1.jar"/>
<classpathentry kind="lib" path="lib/commons-io-2.0.1.jar"/>
<classpathentry kind="lib" path="lib/android-support-v4.jar"/>
<classpathentry kind="lib" path="lib/commons-httpclient-contrib-3.0.jar"/>
<classpathentry kind="lib" path="lib/httpclient-4.1.2.jar"/>
<classpathentry kind="lib" path="lib/httpcore-4.1.2.jar"/>
<classpathentry kind="lib" path="lib/httpmime-4.1.2.jar"/>
<classpathentry kind="lib" path="lib/httpclient-cache-4.1.2.jar"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

Просмотреть файл

@ -21,7 +21,7 @@
android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission
android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="10" />
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="13" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<application android:icon="@drawable/icon" android:label="@string/app_name">
@ -65,7 +65,7 @@
</service>
<activity android:name=".ui.activity.FileDetailActivity"></activity>
<activity android:name=".ui.activity.LandingActivity"
android:theme="@android:style/Theme.NoTitleBar"
android:theme="@style/Theme.ownCloud"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Двоичные данные
lib/android-support-v4.jar

Двоичный файл не отображается.

Просмотреть файл

@ -8,4 +8,5 @@
# project structure.
# Project target.
target=android-7
target=android-13
android.library.reference.1=actionbarsherlock/library

Просмотреть файл

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/gridImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="@drawable/action_item_btn" />
<TextView
android:id="@+id/gridText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/gridImage"
android:layout_centerHorizontal="true"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/setup_text_hint" />
</RelativeLayout>

22
res/layout-port/main.xml Normal file
Просмотреть файл

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<GridView
android:id="@+id/homeScreenGrid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:columnWidth="90dp"
android:gravity="center"
android:horizontalSpacing="10dp"
android:numColumns="2"
android:stretchMode="columnWidth"
android:verticalSpacing="10dp" >
</GridView>
</LinearLayout>

Просмотреть файл

@ -5,37 +5,13 @@
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="@+id/ocLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingTop="10dip"
android:src="@drawable/owncloud_logo" />
<TextView
android:id="@+id/textView0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="15dip"
android:layout_marginTop="15dip"
android:text="@string/main_welcome"
android:textColor="@android:color/black"
android:textSize="7pt"
android:textStyle="bold" />
<GridView
android:id="@+id/gridview"
<ListView
android:id="@+id/homeScreenList"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:columnWidth="90dp"
android:gravity="center"
android:horizontalSpacing="10dp"
android:numColumns="2"
android:stretchMode="columnWidth"
android:verticalSpacing="10dp" >
</GridView>
android:stretchMode="columnWidth"
android:divider="@android:color/black">
</ListView>
</LinearLayout>

Просмотреть файл

@ -1,25 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#F7F7F7"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
<ImageView
android:id="@+id/gridImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="@drawable/action_item_btn" />
android:layout_centerVertical="true"
android:src="@drawable/action_item_btn"
/>
<TextView
android:id="@+id/gridText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/gridImage"
android:layout_centerHorizontal="true"
android:layout_toRightOf="@+id/gridImage"
android:layout_centerVertical="true"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/setup_text_hint" />
</RelativeLayout>

Просмотреть файл

@ -1,26 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#F7F7F7"
android:orientation="vertical" >
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/actionBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
class="eu.alefzero.owncloud.ui.fragment.ActionBar" >
<!-- Preview: layout=@layout/action_bar -->
</fragment>
<fragment
android:id="@+id/landingPage"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
class="eu.alefzero.owncloud.ui.fragment.LandingPageFragment" >
<!-- Preview: layout=@layout/landing_page_fragment -->
</fragment>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<fragment
android:id="@+id/landingPage"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
class="eu.alefzero.owncloud.ui.fragment.LandingPageFragment" >
<!-- Preview: layout=@layout/landing_page_fragment -->
</fragment>
</LinearLayout>
</LinearLayout>

Просмотреть файл

@ -2,6 +2,18 @@
<resources>
<style name="Animations" />
<!-- Default ownCloud app style -->
<style name="Theme.ownCloud" parent="style/Theme.Sherlock.Light">
<item name="abBackground">@drawable/main_header_bg</item>
<item name="abTitleTextStyle">@style/ocActionBarTextStyle</item>
</style>
<style name="ocActionBarTextStyle">
<item name="android:textColor">#ffffff</item>
</style>
<!-- PopDownMenu -->
<style name="Animations.PopDownMenu" />

Просмотреть файл

@ -43,11 +43,11 @@ import android.os.Bundle;
import android.os.Environment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.Menu;
import android.support.v4.view.MenuItem;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;

Просмотреть файл

@ -22,19 +22,25 @@ import android.accounts.AccountManager;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.Toast;
import eu.alefzero.owncloud.R;
import eu.alefzero.owncloud.authenticator.AccountAuthenticator;
import eu.alefzero.owncloud.ui.adapter.LandingScreenAdapter;
/**
* This activity is used as a landing page when the user first opens this app.
* @author Lennart Rosam
*
*/
public class LandingActivity extends FragmentActivity implements OnClickListener {
public class LandingActivity extends FragmentActivity implements OnClickListener, OnItemClickListener {
public static final int DIALOG_SETUP_ACCOUNT = 1;
@ -43,6 +49,13 @@ public class LandingActivity extends FragmentActivity implements OnClickListener
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Fill the grid view that is only available in portrait mode
GridView landingScreenItems = (GridView) findViewById(R.id.homeScreenGrid);
if(landingScreenItems != null){
landingScreenItems.setAdapter(new LandingScreenAdapter(this));
landingScreenItems.setOnItemClickListener(this);
}
// Check, if there are ownCloud accounts
if(!accountsAreSetup()){
showDialog(DIALOG_SETUP_ACCOUNT);
@ -86,6 +99,22 @@ public class LandingActivity extends FragmentActivity implements OnClickListener
}
@Override
/**
* Start an activity based on the selection
* the user made
*/
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent;
intent = (Intent) parent.getAdapter().getItem(position);
if(intent != null ){
startActivity(intent);
} else {
Toast toast = Toast.makeText(this, "Not yet implemented!", Toast.LENGTH_SHORT);
toast.show();
}
}
/**
* Checks, whether or not there are any ownCloud accounts
* setup.
@ -98,6 +127,6 @@ public class LandingActivity extends FragmentActivity implements OnClickListener
.getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE);
return accounts.length > 0;
}
}

Просмотреть файл

@ -53,10 +53,12 @@ public class LandingScreenAdapter extends BaseAdapter {
mContext = context;
}
@Override
public int getCount() {
return mLandingScreenIcons.length;
}
@Override
/**
* Returns the Intent associated with this object
* or null if the functionality is not yet implemented
@ -76,10 +78,12 @@ public class LandingScreenAdapter extends BaseAdapter {
return intent;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater inflator = LayoutInflater.from(mContext);

Просмотреть файл

@ -17,13 +17,13 @@
*/
package eu.alefzero.owncloud.ui.fragment;
import eu.alefzero.owncloud.R;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.SupportActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import eu.alefzero.owncloud.R;
/**
* A custom ActionBar implementation used in the FileDisplayActivity
@ -45,7 +45,7 @@ public class ActionBar extends Fragment {
}
@Override
public void onAttach(Activity activity) {
public void onAttach(SupportActivity activity) {
super.onAttach(activity);
}

Просмотреть файл

@ -17,23 +17,15 @@
*/
package eu.alefzero.owncloud.ui.fragment;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import eu.alefzero.owncloud.R;
import eu.alefzero.owncloud.ui.activity.FileDisplayActivity;
import eu.alefzero.owncloud.ui.activity.Preferences;
import eu.alefzero.owncloud.ui.activity.LandingActivity;
import eu.alefzero.owncloud.ui.adapter.LandingScreenAdapter;
/**
* Used on the Landing page to display what Components of
@ -42,7 +34,7 @@ import eu.alefzero.owncloud.ui.activity.Preferences;
* @author Lennart Rosam
*
*/
public class LandingPageFragment extends Fragment implements OnItemClickListener {
public class LandingPageFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@ -55,99 +47,11 @@ public class LandingPageFragment extends Fragment implements OnItemClickListener
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
GridView grid = (GridView) getView().findViewById(R.id.gridview);
grid.setAdapter(new LandingScreenAdapter(getActivity()));
grid.setOnItemClickListener(this);
ListView landingScreenItems = (ListView) getView().findViewById(R.id.homeScreenList);
landingScreenItems.setAdapter(new LandingScreenAdapter(getActivity()));
landingScreenItems.setOnItemClickListener((LandingActivity) getActivity());
}
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
/*
* Start an activity based on the selection
* the user made
*/
Intent intent;
intent = (Intent) parent.getAdapter().getItem(position);
if(intent != null ){
startActivity(intent);
} else {
Toast toast = Toast.makeText(getActivity(), "Not yet implemented!", Toast.LENGTH_SHORT);
toast.show();
}
}
/**
* Used to populate the landing page grid.
* Defined this one right in here as private class
* as it is unlikely that this Adapter can be useful
* anywhere else.
*
* @author Lennart Rosam
*
*/
private class LandingScreenAdapter extends BaseAdapter {
private Context mContext;
private final Integer[] mLandingScreenIcons = { R.drawable.home,
R.drawable.music, R.drawable.contacts,
android.R.drawable.ic_menu_today,
android.R.drawable.ic_menu_agenda,
android.R.drawable.ic_menu_preferences };
private final Integer[] mLandingScreenTexts = { R.string.main_files,
R.string.main_music, R.string.main_contacts,
R.string.main_calendar, R.string.main_bookmarks,
R.string.main_settings };
public LandingScreenAdapter(Context context) {
mContext = context;
}
public int getCount() {
return mLandingScreenIcons.length;
}
/**
* Returns the Intent associated with this object
* or null if the functionality is not yet implemented
*/
public Object getItem(int position) {
Intent intent = new Intent();
switch (position) {
case 0:
intent.setClass(mContext, FileDisplayActivity.class);
break;
case 5:
intent.setClass(mContext, Preferences.class);
break;
default:
intent = null;
}
return intent;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater inflator = LayoutInflater.from(mContext);
convertView = inflator
.inflate(R.layout.landing_page_item, null);
ImageView icon = (ImageView) convertView
.findViewById(R.id.gridImage);
TextView iconText = (TextView) convertView
.findViewById(R.id.gridText);
icon.setImageResource(mLandingScreenIcons[position]);
iconText.setText(mLandingScreenTexts[position]);
}
return convertView;
}
}
}