Tab Navigation; SharedPreferences Storage;
This commit is contained in:
@@ -45,6 +45,11 @@
|
||||
android:configChanges="keyboardHidden|orientation"
|
||||
android:screenOrientation="portrait">
|
||||
</activity>
|
||||
<activity android:name=".Tabs"
|
||||
android:configChanges="orientation"
|
||||
android:label="FindMe"
|
||||
android:screenOrientation="portrait">
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -13,6 +13,9 @@ public final class R {
|
||||
}
|
||||
public static final class attr {
|
||||
}
|
||||
public static final class color {
|
||||
public static final int transparent=0x7f050000;
|
||||
}
|
||||
public static final class drawable {
|
||||
public static final int background=0x7f020000;
|
||||
public static final int background_dark=0x7f020001;
|
||||
@@ -23,53 +26,62 @@ public final class R {
|
||||
public static final int ic_tab_friends=0x7f020006;
|
||||
public static final int icon=0x7f020007;
|
||||
public static final int logo=0x7f020008;
|
||||
public static final int tab_bg_selected=0x7f020009;
|
||||
public static final int tab_bg_selector=0x7f02000a;
|
||||
public static final int tab_bg_unselected=0x7f02000b;
|
||||
public static final int tab_divider=0x7f02000c;
|
||||
public static final int tab_text_selector=0x7f02000d;
|
||||
}
|
||||
public static final class id {
|
||||
public static final int ButtonFriends=0x7f070008;
|
||||
public static final int ButtonLoginUser=0x7f070004;
|
||||
public static final int ButtonNearby=0x7f070007;
|
||||
public static final int ButtonRegisterUser=0x7f07000e;
|
||||
public static final int ButtonSearch=0x7f070009;
|
||||
public static final int ButtonUpdate=0x7f07000a;
|
||||
public static final int ButtonUserRegistration=0x7f070006;
|
||||
public static final int EditTextLoginMail=0x7f070000;
|
||||
public static final int EditTextLoginPassword=0x7f070001;
|
||||
public static final int EditTextRegistrationMail=0x7f07000c;
|
||||
public static final int EditTextRegistrationName=0x7f07000b;
|
||||
public static final int EditTextRegistrationPassword=0x7f07000d;
|
||||
public static final int SpinnerLoginUserStatus=0x7f070003;
|
||||
public static final int TextViewTitle=0x7f070002;
|
||||
public static final int icon=0x7f07000f;
|
||||
public static final int icontext=0x7f070011;
|
||||
public static final int test_image=0x7f070005;
|
||||
public static final int text=0x7f070010;
|
||||
public static final int ButtonFriends=0x7f080008;
|
||||
public static final int ButtonLoginUser=0x7f080004;
|
||||
public static final int ButtonNearby=0x7f080007;
|
||||
public static final int ButtonRegisterUser=0x7f08000e;
|
||||
public static final int ButtonSearch=0x7f080009;
|
||||
public static final int ButtonUpdate=0x7f08000a;
|
||||
public static final int ButtonUserRegistration=0x7f080006;
|
||||
public static final int EditTextLoginMail=0x7f080000;
|
||||
public static final int EditTextLoginPassword=0x7f080001;
|
||||
public static final int EditTextRegistrationMail=0x7f08000c;
|
||||
public static final int EditTextRegistrationName=0x7f08000b;
|
||||
public static final int EditTextRegistrationPassword=0x7f08000d;
|
||||
public static final int SpinnerLoginUserStatus=0x7f080003;
|
||||
public static final int TextViewTitle=0x7f080002;
|
||||
public static final int icon=0x7f080011;
|
||||
public static final int icontext=0x7f080013;
|
||||
public static final int tabsLayout=0x7f08000f;
|
||||
public static final int tabsText=0x7f080010;
|
||||
public static final int test_image=0x7f080005;
|
||||
public static final int text=0x7f080012;
|
||||
}
|
||||
public static final class layout {
|
||||
public static final int login=0x7f030000;
|
||||
public static final int main=0x7f030001;
|
||||
public static final int nearby=0x7f030002;
|
||||
public static final int nearby_list_item=0x7f030003;
|
||||
public static final int registration=0x7f030004;
|
||||
public static final int tabs=0x7f030005;
|
||||
public static final int colors=0x7f030000;
|
||||
public static final int login=0x7f030001;
|
||||
public static final int main=0x7f030002;
|
||||
public static final int nearby=0x7f030003;
|
||||
public static final int nearby_list_item=0x7f030004;
|
||||
public static final int registration=0x7f030005;
|
||||
public static final int tabs=0x7f030006;
|
||||
public static final int tabs_bg=0x7f030007;
|
||||
}
|
||||
public static final class menu {
|
||||
public static final int menu=0x7f060000;
|
||||
public static final int menu=0x7f070000;
|
||||
}
|
||||
public static final class string {
|
||||
public static final int app_name=0x7f050000;
|
||||
public static final int main_login=0x7f050001;
|
||||
public static final int main_register=0x7f050002;
|
||||
public static final int navigation_chat=0x7f05000a;
|
||||
public static final int navigation_friends=0x7f050008;
|
||||
public static final int app_name=0x7f060000;
|
||||
public static final int main_login=0x7f060001;
|
||||
public static final int main_register=0x7f060002;
|
||||
public static final int navigation_chat=0x7f06000a;
|
||||
public static final int navigation_friends=0x7f060008;
|
||||
/** Navigation
|
||||
*/
|
||||
public static final int navigation_nearby=0x7f050007;
|
||||
public static final int navigation_search=0x7f050009;
|
||||
public static final int navigation_nearby=0x7f060007;
|
||||
public static final int navigation_search=0x7f060009;
|
||||
/** Current User Status
|
||||
*/
|
||||
public static final int userStatus1=0x7f050003;
|
||||
public static final int userStatus2=0x7f050004;
|
||||
public static final int userStatus3=0x7f050005;
|
||||
public static final int userStatus4=0x7f050006;
|
||||
public static final int userStatus1=0x7f060003;
|
||||
public static final int userStatus2=0x7f060004;
|
||||
public static final int userStatus3=0x7f060005;
|
||||
public static final int userStatus4=0x7f060006;
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 83 B |
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (c) Josh Clemm 2010
|
||||
-->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<gradient android:startColor="#A8A8A8" android:centerColor="#7F7F7F"
|
||||
android:endColor="#696969" android:angle="-90" />
|
||||
</shape>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (c) Josh Clemm 2010
|
||||
-->
|
||||
<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_bg_selected" />
|
||||
<!-- Inactive tab -->
|
||||
<item android:state_selected="false" android:state_focused="false"
|
||||
android:state_pressed="false" android:drawable="@drawable/tab_bg_unselected" />
|
||||
<!-- Pressed tab -->
|
||||
<item android:state_pressed="true" android:drawable="@color/transparent" />
|
||||
<!-- Selected tab (using d-pad) -->
|
||||
<item android:state_focused="true" android:state_selected="true"
|
||||
android:state_pressed="false" android:drawable="@color/transparent" />
|
||||
</selector>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (c) Josh Clemm 2010
|
||||
-->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<gradient android:startColor="#5C5C5C" android:centerColor="#424242"
|
||||
android:endColor="#222222"
|
||||
android:angle="-90" />
|
||||
</shape>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (c) 2010 Josh Clemm
|
||||
-->
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_selected="true" android:color="@android:color/white" />
|
||||
<item android:state_focused="true" android:color="@android:color/white" />
|
||||
<item android:state_pressed="true" android:color="@android:color/white" />
|
||||
<item android:color="#f8f8f8" />
|
||||
</selector>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="transparent">#00000000</color>
|
||||
</resources>
|
||||
+24
-21
@@ -1,22 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/tabhost"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:padding="5dp">
|
||||
<TabWidget
|
||||
android:id="@android:id/tabs"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
</TabWidget>
|
||||
<FrameLayout
|
||||
android:id="@android:id/tabcontent"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:padding="5dp" />
|
||||
</LinearLayout>
|
||||
</TabHost>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/tabhost" android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<LinearLayout android:orientation="vertical"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent">
|
||||
<View android:layout_width="fill_parent" android:layout_height="0.5dip"
|
||||
android:background="#000" />
|
||||
<TabWidget android:id="@android:id/tabs"
|
||||
android:layout_width="fill_parent" android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="0dip" android:layout_marginRight="0dip" />
|
||||
<View android:layout_width="fill_parent" android:layout_height="2dip"
|
||||
android:background="#696969" />
|
||||
<View android:layout_width="fill_parent" android:layout_height="2dip"
|
||||
android:background="#000" />
|
||||
<FrameLayout android:id="@android:id/tabcontent"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent" />
|
||||
</LinearLayout>
|
||||
</TabHost>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (c) 2010 Josh Clemm
|
||||
-->
|
||||
|
||||
<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:background="@drawable/tab_bg_selector"
|
||||
android:padding="10dip" android:gravity="center" android:orientation="vertical">
|
||||
|
||||
<TextView android:id="@+id/tabsText" android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:text="Title"
|
||||
android:textSize="15dip" android:textColor="@drawable/tab_text_selector" />
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="transparent">#00000000</color>
|
||||
</resources>
|
||||
@@ -4,11 +4,15 @@ import com.architects.findme.R;
|
||||
import com.architects.findme.R.id;
|
||||
import com.architects.findme.R.layout;
|
||||
import com.architects.findme.R.menu;
|
||||
import com.architects.helper.AccountHelper;
|
||||
import com.architects.helper.StateHelper;
|
||||
import com.architects.findme.Login;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
@@ -18,7 +22,9 @@ import android.widget.Toast;
|
||||
|
||||
public class FindMe extends Activity
|
||||
{
|
||||
public static final String PREFS_NAME = "LoginCredentials";
|
||||
public StateHelper phoneState = new StateHelper();
|
||||
private static final String TAG = "test";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
@@ -27,6 +33,27 @@ public class FindMe extends Activity
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
setContentView(R.layout.main);
|
||||
|
||||
|
||||
String loginData[] = new String[3];
|
||||
|
||||
// save login credentials to storage
|
||||
SharedPreferences preferences = this.getSharedPreferences(PREFS_NAME, MODE_WORLD_READABLE);
|
||||
loginData[0] = preferences.getString("mail", "");
|
||||
loginData[1] = preferences.getString("password", "");
|
||||
loginData[2] = preferences.getString("status", "");
|
||||
|
||||
if (loginData[0].compareTo("") != 0)
|
||||
{
|
||||
String response = Login.login(loginData).trim();
|
||||
// check if login was successful
|
||||
Log.v(TAG, response);
|
||||
if(response.compareTo("01") == 0)
|
||||
{
|
||||
Intent myIntent = new Intent(this, Tabs.class);
|
||||
startActivity(myIntent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.architects.helper.AccountHelper;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@@ -18,18 +19,20 @@ import android.widget.Toast;
|
||||
|
||||
public class Login extends Activity
|
||||
{
|
||||
public static final String PREFS_NAME = "LoginCredentials";
|
||||
private static final String TAG = "test";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
setContentView(R.layout.login);
|
||||
}
|
||||
|
||||
public String login(String[] str)
|
||||
public static String login(String[] str)
|
||||
{
|
||||
JSONObject j = new JSONObject();
|
||||
try
|
||||
@@ -67,9 +70,19 @@ public class Login extends Activity
|
||||
String response = login(loginData).trim();
|
||||
Log.v(TAG, response);
|
||||
|
||||
|
||||
// check if login was successful
|
||||
if(response.compareTo("01") == 0)
|
||||
{
|
||||
Intent myIntent = new Intent(button.getContext(), Nearby.class);
|
||||
// save login credentials to storage
|
||||
SharedPreferences preferences = this.getSharedPreferences(PREFS_NAME, MODE_WORLD_READABLE);
|
||||
SharedPreferences.Editor prefsEditor = preferences.edit();
|
||||
prefsEditor.putString("mail", loginData[0]);
|
||||
prefsEditor.putString("password", loginData[1]);
|
||||
prefsEditor.putString("status", loginData[2]);
|
||||
prefsEditor.commit();
|
||||
|
||||
Intent myIntent = new Intent(button.getContext(), Tabs.class);
|
||||
startActivity(myIntent);
|
||||
}
|
||||
else Toast.makeText(this, response, Toast.LENGTH_LONG).show();
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.architects.findme;
|
||||
|
||||
import android.app.ActivityGroup;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
public class MainActivityGroup extends ActivityGroup{
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
//you van get the local activitymanager to start the new activity
|
||||
|
||||
View view = getLocalActivityManager().startActivity("Nearby", new Intent(this, Login.class)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
|
||||
.getDecorView();
|
||||
this.setContentView(view);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,50 +1,54 @@
|
||||
package com.architects.findme;
|
||||
|
||||
import android.app.TabActivity;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html.TagHandler;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.TabHost;
|
||||
import android.widget.TabWidget;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TabHost.TabContentFactory;
|
||||
import android.widget.TabHost.TabSpec;
|
||||
|
||||
public class Tabs extends TabActivity {
|
||||
private static final String TAG = "test";
|
||||
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
Log.v(TAG, "sicher");
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.tabs);
|
||||
Resources res = getResources(); // Resource object to get Drawables
|
||||
TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost); // The activity TabHost
|
||||
TabHost.TabSpec spec; // Resusable TabSpec for each tab
|
||||
Intent intent; // Reusable Intent for each tab
|
||||
|
||||
Log.v(TAG, "01");
|
||||
public class Tabs extends Activity {
|
||||
|
||||
// Create an Intent to launch an Activity for the tab (to be reused)
|
||||
intent = new Intent().setClass(this, Friends.class);
|
||||
private TabHost mTabHost;
|
||||
|
||||
// Initialize a TabSpec for each tab and add it to the TabHost
|
||||
spec = tabHost.newTabSpec("friends").setIndicator("Friends").setContent(intent);
|
||||
tabHost.addTab(spec);
|
||||
|
||||
Log.v(TAG, "01.5");
|
||||
|
||||
// Do the same for the other tabs
|
||||
intent = new Intent().setClass(this, Chat.class);
|
||||
spec = tabHost.newTabSpec("chat").setIndicator("Chat").setContent(intent);
|
||||
tabHost.addTab(spec);
|
||||
|
||||
intent = new Intent().setClass(this, Search.class);
|
||||
spec = tabHost.newTabSpec("search").setIndicator("Search").setContent(intent);
|
||||
tabHost.addTab(spec);
|
||||
|
||||
Log.v(TAG, "02");
|
||||
|
||||
tabHost.setCurrentTab(2);
|
||||
|
||||
Log.v(TAG, "03");
|
||||
private void setupTabHost() {
|
||||
mTabHost = (TabHost) findViewById(android.R.id.tabhost);
|
||||
mTabHost.setup();
|
||||
}
|
||||
}
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// construct the tabhost
|
||||
setContentView(R.layout.tabs);
|
||||
|
||||
setupTabHost();
|
||||
mTabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider);
|
||||
|
||||
setupTab(new TextView(this), "Nearby");
|
||||
setupTab(new TextView(this), "Friends");
|
||||
setupTab(new TextView(this), "Chat");
|
||||
}
|
||||
|
||||
private void setupTab(final View view, final String tag) {
|
||||
View tabview = createTabView(mTabHost.getContext(), tag);
|
||||
|
||||
TabSpec setContent = mTabHost.newTabSpec(tag).setIndicator(tabview).setContent(
|
||||
new Intent(this, MainActivityGroup.class)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
|
||||
mTabHost.addTab(setContent);
|
||||
|
||||
}
|
||||
|
||||
private static View createTabView(final Context context, final String text) {
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.tabs_bg, null);
|
||||
TextView tv = (TextView) view.findViewById(R.id.tabsText);
|
||||
tv.setText(text);
|
||||
return view;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user