android: redesign tab bar

android: redesign title bar
android: introduction of global layout theme
This commit is contained in:
Joachim Fritzsch 2013-05-19 18:45:16 +02:00
parent e350b8ef72
commit b9f8e4c62f
13 changed files with 298 additions and 59 deletions

View File

@ -35,6 +35,7 @@
<application
android:icon="@drawable/boinc"
android:label="@string/app_name"
android:theme="@style/Theme"
android:allowBackup="true"
android:debuggable="true" >

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is part of BOINC.
http://boinc.berkeley.edu
Copyright (C) 2012 University of California
BOINC is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation,
either version 3 of the License, or (at your option) any later version.
BOINC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with BOINC. If not, see <http://www.gnu.org/licenses/>.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Active tab -->
<item android:state_selected="true" android:state_focused="false"
android:state_pressed="false" android:drawable="@drawable/tab_background_selected" />
<!-- Inactive tab -->
<item android:state_selected="false" android:state_focused="false"
android:state_pressed="false" android:drawable="@drawable/tab_background_unselected" />
<!-- Pressed tab -->
<item android:state_pressed="true" android:drawable="@drawable/tab_background_selected" />
<!-- Selected tab (using d-pad) -->
<item android:state_focused="true" android:state_selected="true"
android:state_pressed="false" android:drawable="@drawable/tab_background_selected" />
</selector>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is part of BOINC.
http://boinc.berkeley.edu
Copyright (C) 2012 University of California
BOINC is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation,
either version 3 of the License, or (at your option) any later version.
BOINC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with BOINC. If not, see <http://www.gnu.org/licenses/>.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="@color/light_blue"
android:endColor="@color/white_smoke" android:angle="-90" />
</shape>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is part of BOINC.
http://boinc.berkeley.edu
Copyright (C) 2012 University of California
BOINC is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation,
either version 3 of the License, or (at your option) any later version.
BOINC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with BOINC. If not, see <http://www.gnu.org/licenses/>.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="@color/dark_blue_gradient" android:centerColor="@color/dark_blue"
android:endColor="@color/dark_blue_gradient" android:angle="-90" />
</shape>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is part of BOINC.
http://boinc.berkeley.edu
Copyright (C) 2012 University of California
BOINC is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation,
either version 3 of the License, or (at your option) any later version.
BOINC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with BOINC. If not, see <http://www.gnu.org/licenses/>.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:color="@android:color/black" />
<item android:state_focused="true" android:color="@android:color/black" />
<item android:state_pressed="true" android:color="@android:color/black" />
<item android:color="@android:color/white" />
</selector>

View File

@ -49,7 +49,8 @@
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
android:layout_height="wrap_content"
android:divider="@color/light_blue" >
</TabWidget>
<HorizontalScrollView

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is part of BOINC.
http://boinc.berkeley.edu
Copyright (C) 2012 University of California
BOINC is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation,
either version 3 of the License, or (at your option) any later version.
BOINC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with BOINC. If not, see <http://www.gnu.org/licenses/>.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabsLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp"
android:gravity="center"
android:orientation="vertical"
android:background="@drawable/tab_background">
<ImageView android:id="@+id/tabsIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent" />
<TextView android:id="@+id/tabsText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:background="@android:color/transparent"
android:textColor="@drawable/tab_text" />
</LinearLayout>

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is part of BOINC.
http://boinc.berkeley.edu
Copyright (C) 2012 University of California
BOINC is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation,
either version 3 of the License, or (at your option) any later version.
BOINC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with BOINC. If not, see <http://www.gnu.org/licenses/>.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/titleBar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp"
android:orientation="horizontal"
android:background="@color/black">
<ImageView android:id="@+id/titleIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:src="@drawable/boinc"
android:background="@android:color/transparent" />
<TextView android:id="@+id/titleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/titleIcon"
android:layout_marginLeft="5dp"
android:layout_centerVertical="true"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/app_name"
android:background="@android:color/transparent"
android:textColor="@color/light_blue" />
<TextView android:id="@+id/titleStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:textStyle="italic"
android:textAppearance="?android:attr/textAppearanceSmall"
android:background="@android:color/transparent"
android:textColor="@color/light_blue" />
</RelativeLayout>

View File

@ -18,6 +18,11 @@
along with BOINC. If not, see <http://www.gnu.org/licenses/>.
-->
<resources>
<!-- layout colors -->
<color name="white_smoke">#F5F5F5</color>
<color name="dark_blue">#003366</color>
<color name="dark_blue_gradient">#0C4175</color>
<color name="light_blue">#5DA0E3</color>
<!-- global colors -->
<color name="warning">#FCEC3D</color>
<color name="link">#05c5cf</color>

View File

@ -106,6 +106,7 @@
<string name="main_noproject_warning">No scientific project attached! tab here to enter account.</string>
<string name="main_error">Whooops</string>
<string name="main_error_long">&#8230;this should not happen!\nClick on the icon to try again.</string>
<string name="main_title_icon_desc">BOINC icon</string>
<!-- tab names -->
<string name="tab_status">Status</string>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is part of BOINC.
http://boinc.berkeley.edu
Copyright (C) 2012 University of California
BOINC is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation,
either version 3 of the License, or (at your option) any later version.
BOINC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with BOINC. If not, see <http://www.gnu.org/licenses/>.
-->
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme" parent="android:Theme">
<item name="android:background">@color/white_smoke</item>
<item name="android:textColor">@color/black</item>
<item name="android:windowTitleSize">35dp</item>
<item name="android:windowTitleStyle">@style/CustomWindowTitle</item>
<item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
</style>
<!-- title bar -->
<style name="CustomWindowTitle">
<item name="android:singleLine">true</item>
<item name="android:shadowDx">0</item>
<item name="android:shadowDy">0</item>
<item name="android:shadowRadius">5</item>
<item name="android:shadowColor">#1155CC</item>
</style>
<style name="CustomWindowTitleBackground">
<item name="android:background">@color/black</item>
</style>
</resources>

View File

@ -21,6 +21,7 @@ package edu.berkeley.boinc;
import edu.berkeley.boinc.client.ClientStatus;
import edu.berkeley.boinc.client.Monitor;
import edu.berkeley.boinc.utils.BOINCDefs;
import android.app.Activity;
import android.app.Service;
import android.app.TabActivity;
import android.content.BroadcastReceiver;
@ -34,11 +35,14 @@ import android.os.AsyncTask;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
@ -53,6 +57,8 @@ public class BOINCActivity extends TabActivity {
private Boolean intialStart = true;
private Boolean mIsBound;
private TabHost tabHost;
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
@ -84,12 +90,15 @@ public class BOINCActivity extends TabActivity {
public void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "onCreate()");
super.onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
//bind monitor service
doBindService();
// adapt to custom title bar
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar);
setupTabLayout();
}
@ -205,67 +214,45 @@ public class BOINCActivity extends TabActivity {
private void setupTabLayout() {
Resources res = getResources();
TabHost tabHost = getTabHost();
tabHost = getTabHost();
if(res.getBoolean(R.bool.tab_status)) {
TabSpec statusSpec = tabHost.newTabSpec(getResources().getString(R.string.tab_status));
statusSpec.setIndicator(getResources().getString(R.string.tab_status), getResources().getDrawable(R.drawable.icon_status_tab));
Intent statusIntent = new Intent(this, StatusActivity.class);
statusSpec.setContent(statusIntent);
tabHost.addTab(statusSpec);
}
if(res.getBoolean(R.bool.tab_projects)) {
TabSpec projectsSpec = tabHost.newTabSpec(getResources().getString(R.string.tab_projects));
projectsSpec.setIndicator(getResources().getString(R.string.tab_projects), getResources().getDrawable(R.drawable.icon_projects_tab));
Intent projectsIntent = new Intent(this, ProjectsActivity.class);
projectsSpec.setContent(projectsIntent);
tabHost.addTab(projectsSpec);
}
if(res.getBoolean(R.bool.tab_tasks)) {
TabSpec tasksSpec = tabHost.newTabSpec(getResources().getString(R.string.tab_tasks));
tasksSpec.setIndicator(getResources().getString(R.string.tab_tasks), getResources().getDrawable(R.drawable.icon_tasks_tab));
Intent tasksIntent = new Intent(this, TasksActivity.class);
tasksSpec.setContent(tasksIntent);
tabHost.addTab(tasksSpec);
}
if(res.getBoolean(R.bool.tab_transfers)) {
TabSpec transSpec = tabHost.newTabSpec(getResources().getString(R.string.tab_transfers));
transSpec.setIndicator(getResources().getString(R.string.tab_transfers), getResources().getDrawable(R.drawable.icon_trans_tab));
Intent transIntent = new Intent(this, TransActivity.class);
transSpec.setContent(transIntent);
tabHost.addTab(transSpec);
}
if(res.getBoolean(R.bool.tab_preferences)) {
TabSpec prefsSpec = tabHost.newTabSpec(getResources().getString(R.string.tab_preferences));
prefsSpec.setIndicator(getResources().getString(R.string.tab_preferences), getResources().getDrawable(R.drawable.icon_prefs_tab));
Intent prefsIntent = new Intent(this, PrefsActivity.class);
prefsSpec.setContent(prefsIntent);
tabHost.addTab(prefsSpec);
}
if(res.getBoolean(R.bool.tab_eventlog)) {
TabSpec msgsSpec = tabHost.newTabSpec(getResources().getString(R.string.tab_eventlog));
msgsSpec.setIndicator(getResources().getString(R.string.tab_eventlog), getResources().getDrawable(R.drawable.icon_msgs_tab));
Intent msgsIntent = new Intent(this, EventLogActivity.class);
msgsSpec.setContent(msgsIntent);
tabHost.addTab(msgsSpec);
}
Log.d(TAG, "tab layout setup done");
if(res.getBoolean(R.bool.tab_status))
setupTab(new TextView(this), getResources().getString(R.string.tab_status), R.drawable.icon_status_tab, StatusActivity.class);
if(res.getBoolean(R.bool.tab_projects))
setupTab(new TextView(this), getResources().getString(R.string.tab_projects), R.drawable.icon_projects_tab, ProjectsActivity.class);
if(res.getBoolean(R.bool.tab_tasks))
setupTab(new TextView(this), getResources().getString(R.string.tab_tasks), R.drawable.icon_tasks_tab, TasksActivity.class);
if(res.getBoolean(R.bool.tab_transfers))
setupTab(new TextView(this), getResources().getString(R.string.tab_transfers), R.drawable.icon_trans_tab, TransActivity.class);
if(res.getBoolean(R.bool.tab_preferences))
setupTab(new TextView(this), getResources().getString(R.string.tab_preferences), R.drawable.icon_prefs_tab, PrefsActivity.class);
if(res.getBoolean(R.bool.tab_eventlog))
setupTab(new TextView(this), getResources().getString(R.string.tab_eventlog), R.drawable.icon_msgs_tab, EventLogActivity.class);
//Log.d(TAG, "tab layout setup done");
}
private void setupTab(final View view, final String tag, int icon, Class<?> target) {
View tabview = createTabView(tabHost.getContext(), tag, icon);
TabSpec tabSpec = tabHost.newTabSpec(tag);
tabSpec.setIndicator(tabview);
tabSpec.setContent(new Intent(this, target));
tabHost.addTab(tabSpec);
}
private static View createTabView(final Context context, final String text, int icon) {
View view = LayoutInflater.from(context).inflate(R.layout.main_tab_layout, null);
TextView tv = (TextView) view.findViewById(R.id.tabsText);
tv.setText(text);
ImageView iv = (ImageView) view.findViewById(R.id.tabsIcon);
iv.setImageResource(icon);
return view;
}
// set app title to status string of ClientStatus
private void setAppTitle() {
String title = getString(R.string.app_name);
String status = Monitor.getClientStatus().getCurrentStatusString();
if (!status.isEmpty()) {
title += " - " + status;
}
this.setTitle(title);
TextView status = (TextView) findViewById(R.id.titleStatus);
status.setText(Monitor.getClientStatus().getCurrentStatusString());
}
// triggered by click on noproject_warning, starts login activity

View File

@ -67,7 +67,7 @@ public class CcState{
public Workunit lookup_wu(Project project, String wu_name) {
for(int i = 0; i < workunits.size(); i++) {
if(!workunits.get(i).project.compare(project)) {
Log.d("Workunit", "Projects Do not compare");
//Log.d("Workunit", "Projects Do not compare");
continue;
}
if(workunits.get(i).name.equalsIgnoreCase(wu_name)) {