Commits

Anonymous committed 3818bec

パッケージ名リファクタリング
メニュー追加

Comments (0)

Files changed (33)

AndroidManifest.xml

 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-      package="sheephead.homelinux.org.androizou"
-      android:versionCode="1"
-      android:versionName="1.0">
+      package="org.homelinux.sheephead.androizou" android:versionCode="1" android:versionName="preAlpha">
     <application android:icon="@drawable/icon" android:label="@string/app_name">
         <activity android:name=".MainAndroizou"
                   android:label="@string/app_name">
 
 
 
-<activity android:name="login">
+<activity android:name="Upload">
 <intent-filter>
 	<category android:name="android.intent.category.ALTERNATIVE"></category>
 	<category android:name="android.intent.category.DEFAULT"></category>

bin/androizou.apk

Binary file modified.

bin/classes.dex

Binary file modified.

bin/org/homelinux/sheephead/androizou/MainAndroizou.class

Binary file added.

bin/org/homelinux/sheephead/androizou/R$attr.class

Binary file added.

bin/org/homelinux/sheephead/androizou/R$drawable.class

Binary file added.

bin/org/homelinux/sheephead/androizou/R$id.class

Binary file added.

bin/org/homelinux/sheephead/androizou/R$layout.class

Binary file added.

bin/org/homelinux/sheephead/androizou/R$string.class

Binary file added.

bin/org/homelinux/sheephead/androizou/R.class

Binary file added.

bin/org/homelinux/sheephead/androizou/SetID$1.class

Binary file added.

bin/org/homelinux/sheephead/androizou/SetID.class

Binary file added.

bin/org/homelinux/sheephead/androizou/Upload.class

Binary file added.

bin/resources.ap_

Binary file modified.

bin/sheephead/homelinux/org/androizou/MainAndroizou.class

Binary file removed.

bin/sheephead/homelinux/org/androizou/R$attr.class

Binary file removed.

bin/sheephead/homelinux/org/androizou/R$drawable.class

Binary file removed.

bin/sheephead/homelinux/org/androizou/R$id.class

Binary file removed.

bin/sheephead/homelinux/org/androizou/R$layout.class

Binary file removed.

bin/sheephead/homelinux/org/androizou/R$string.class

Binary file removed.

bin/sheephead/homelinux/org/androizou/R.class

Binary file removed.

bin/sheephead/homelinux/org/androizou/SetID.class

Binary file removed.

bin/sheephead/homelinux/org/androizou/login.class

Binary file removed.

gen/org/homelinux/sheephead/androizou/R.java

+/* AUTO-GENERATED FILE.  DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found.  It
+ * should not be modified by hand.
+ */
+
+package org.homelinux.sheephead.androizou;
+
+public final class R {
+    public static final class attr {
+    }
+    public static final class drawable {
+        public static final int icon=0x7f020000;
+    }
+    public static final class id {
+        public static final int Button01=0x7f05000f;
+        public static final int EditText01=0x7f05000d;
+        public static final int EditText02=0x7f05000e;
+        public static final int TextView01=0x7f050003;
+        public static final int login_button=0x7f05000a;
+        public static final int pass_edit=0x7f05000c;
+        public static final int user_edit=0x7f05000b;
+        public static final int widget28=0x7f050002;
+        public static final int widget29=0x7f050000;
+        public static final int widget30=0x7f050004;
+        public static final int widget31=0x7f050007;
+        public static final int widget32=0x7f050005;
+        public static final int widget33=0x7f050008;
+        public static final int widget34=0x7f050006;
+        public static final int widget35=0x7f050009;
+        public static final int widget36=0x7f050001;
+    }
+    public static final class layout {
+        public static final int main=0x7f030000;
+        public static final int setid=0x7f030001;
+        public static final int upload=0x7f030002;
+    }
+    public static final class string {
+        public static final int app_name=0x7f040001;
+        public static final int button_login=0x7f040005;
+        public static final int button_name=0x7f040004;
+        public static final int hello=0x7f040000;
+        public static final int pass_name=0x7f040003;
+        public static final int preferences_id=0x7f040008;
+        public static final int preferences_name=0x7f040007;
+        public static final int preferences_pass=0x7f040009;
+        public static final int text_welcome=0x7f040006;
+        public static final int user_name=0x7f040002;
+    }
+}

gen/sheephead/homelinux/org/androizou/R.java

-/* AUTO-GENERATED FILE.  DO NOT MODIFY.
- *
- * This class was automatically generated by the
- * aapt tool from the resource data it found.  It
- * should not be modified by hand.
- */
-
-package sheephead.homelinux.org.androizou;
-
-public final class R {
-    public static final class attr {
-    }
-    public static final class drawable {
-        public static final int icon=0x7f020000;
-    }
-    public static final class id {
-        public static final int Button01=0x7f050002;
-        public static final int EditText01=0x7f050000;
-        public static final int EditText02=0x7f050001;
-        public static final int login_button=0x7f05000c;
-        public static final int pass_edit=0x7f05000e;
-        public static final int user_edit=0x7f05000d;
-        public static final int widget28=0x7f050005;
-        public static final int widget29=0x7f050003;
-        public static final int widget30=0x7f050006;
-        public static final int widget31=0x7f050009;
-        public static final int widget32=0x7f050007;
-        public static final int widget33=0x7f05000a;
-        public static final int widget34=0x7f050008;
-        public static final int widget35=0x7f05000b;
-        public static final int widget36=0x7f050004;
-    }
-    public static final class layout {
-        public static final int login=0x7f030000;
-        public static final int main=0x7f030001;
-        public static final int setid=0x7f030002;
-    }
-    public static final class string {
-        public static final int app_name=0x7f040001;
-        public static final int button_name=0x7f040004;
-        public static final int hello=0x7f040000;
-        public static final int pass_name=0x7f040003;
-        public static final int user_name=0x7f040002;
-    }
-}

res/layout/login.xml

-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout
-  xmlns:android="http://schemas.android.com/apk/res/android"
-  android:layout_width="wrap_content"
-  android:layout_height="wrap_content" android:orientation="vertical">
-
-<EditText android:text="@+id/EditText01" android:id="@+id/EditText01" android:layout_width="wrap_content" android:layout_height="wrap_content"></EditText>
-
-
-
-<EditText android:text="@+id/EditText02" android:id="@+id/EditText02" android:layout_width="wrap_content" android:layout_height="wrap_content"></EditText><Button android:text="@+id/Button01" android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
-</LinearLayout>

res/layout/main.xml

 android:stretchColumns="1"
 android:layout_alignParentTop="true"
 android:layout_alignParentLeft="true"
->
+><TextView android:layout_width="wrap_content" android:id="@+id/TextView01" android:layout_below="@+id/widget36" android:layout_height="wrap_content" android:text="@string/text_welcome"></TextView>
 <TableRow
 android:id="@+id/widget30"
 android:layout_width="fill_parent"
 </EditText>
 </TableRow>
 </TableLayout>
+
 </RelativeLayout>

res/layout/upload.xml

+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+  xmlns:android="http://schemas.android.com/apk/res/android"
+  android:layout_width="wrap_content"
+  android:layout_height="wrap_content" android:orientation="vertical">
+
+<EditText android:text="@+id/EditText01" android:id="@+id/EditText01" android:layout_width="wrap_content" android:layout_height="wrap_content"></EditText>
+
+
+
+<EditText android:text="@+id/EditText02" android:id="@+id/EditText02" android:layout_width="wrap_content" android:layout_height="wrap_content"></EditText><Button android:text="@+id/Button01" android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
+</LinearLayout>

res/values/strings.xml

     <string name="user_name">user</string>
     <string name="pass_name">pass</string>
 	<string name="button_name">login</string>
+<string name="button_login">login</string>
+<string name="text_welcome">アンドロイ蔵のメイン画面。一部機能が未実装です。</string>
+<string name="preferences_name">androizou_pref</string>
+<string name="preferences_id">androizou_id</string>
+<string name="preferences_pass">androizou_pass</string>
 </resources>

src/org/homelinux/sheephead/androizou/MainAndroizou.java

 package org.homelinux.sheephead.androizou;
 
-import sheephead.homelinux.org.androizou.R;
+import org.homelinux.sheephead.androizou.R;
 import android.app.Activity;
 import android.content.ActivityNotFoundException;
 import android.content.Intent;
+import android.content.SharedPreferences;
 import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
 import android.widget.Toast;
 
 public class MainAndroizou extends Activity {
+    private String strpass;
+	private String strid;
+
+	
+	@Override
+	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+//		super.onActivityResult(requestCode, resultCode, data);
+		if (resultCode == RESULT_OK) {
+			SetIDAndPass(false);
+		}
+	}
+
+    
+    
+    @Override    
+    public boolean onCreateOptionsMenu(Menu menu){
+        super.onCreateOptionsMenu(menu);
+        menu.add(0,0,0,"upload").setIcon(android.R.drawable.ic_menu_upload);
+        menu.add(0,1,0,"login").setIcon(android.R.drawable.ic_menu_agenda);
+        
+        return true;
+        
+    }
+    
+    @Override
+public boolean onMenuItemSelected(int featureId, MenuItem item) {
+        super.onMenuItemSelected(featureId, item);
+        switch( item.getItemId()){
+        case 0: //R.string.Set_id_pass
+            GoUploadActivity() ;
+            break;
+        case 1: //R.string.Set_id_pass
+            GoSetIDAndPassActivity();
+            break;
+		}
+        return true;
+	}
+    
     /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.main);
-        GoSetTwitterIDAndPassActivity();
+        //GoSetIDAndPassActivity();
     }
+     
+
     	/**
-	 * TwitterのIDとPassを設定する
+	 * IDとPassを設定する
 	 * @param bCreate
 	 * 初回起動時はtrueを指定
 	 */
-//	private void SetTwitterIDAndPass( boolean bCreate){
+	private void SetIDAndPass( boolean bCreate){
 //		updateButton.setClickable(false);
 //		reloadButton.setClickable(false);
-//		// プリファレンスからID/Passを取得
-//		SharedPreferences preferences = getSharedPreferences( getString(R.string.preferences_name), MODE_PRIVATE);
-//		strid = preferences.getString( getString(R.string.preferences_id), "");
-//		strpass = preferences.getString( getString(R.string.preferences_pass), "");
+		// プリファレンスからID/Passを取得
+		SharedPreferences preferences = getSharedPreferences( getString(R.string.preferences_name), MODE_PRIVATE);
+		strid = preferences.getString( getString(R.string.preferences_id), "");
+		strpass = preferences.getString( getString(R.string.preferences_pass), "");
 //		if(!chkid( bCreate)){
 //			return;
 //		}
 //		GetAndWriteHomeTimeLine();
 //		updateButton.setClickable(true);
 //		reloadButton.setClickable(true);
-//	}
+	}
     
 	/**
-	 * Twitter ID/pass が設定されているかを確認
+	 * ID/pass が設定されているかを確認
 	 * @param bCreate
 	 * 初回起動時はtrueを指定
 	 * @return
 	 * boolean値
 	 */
-//	private boolean chkid( boolean bCreate){
+	private boolean chkid( boolean bCreate){
 		
-//		if(strid.length() == 0 || strpass.length() == 0){
+		if(strid.length() == 0 || strpass.length() == 0){
 			// 初回起動時にid/passが未設定なら、設定画面を呼び出す
-//			if(bCreate){
-//				GoSetTwitterIDAndPassActivity();
-//			}
-//			return false;
-//		}
-//		return true;
-//				return bCreate;
-//	}
+			if(bCreate){
+				GoSetIDAndPassActivity();
+			}
+			return false;
+		}
+		return true;
+
+	}
 	/**
 	 *  Twitter ID/pass を設定するActivityへ移動
 	 */
-	private void GoSetTwitterIDAndPassActivity(){
+	private void GoSetIDAndPassActivity(){
 		try{
 			Intent intent = new Intent(MainAndroizou.this, SetID.class);
 			startActivityForResult(intent, 0);
 			Toast.makeText( MainAndroizou.this, "起動先のActivityが見つかりません", Toast.LENGTH_LONG).show();
 		}
 	}
+
+	private void GoUploadActivity(){
+		try{
+Intent intent = new Intent(MainAndroizou.this, Upload.class);
+			startActivityForResult(intent, 0);
+		} catch( ActivityNotFoundException e){
+			Toast.makeText( MainAndroizou.this, "起動先のActivityが見つかりません", Toast.LENGTH_LONG).show();
+		}
+	}
 }

src/org/homelinux/sheephead/androizou/SetID.java

 package org.homelinux.sheephead.androizou;
 
-import sheephead.homelinux.org.androizou.R;
+import org.homelinux.sheephead.androizou.R;
 import android.app.Activity;
+import android.content.SharedPreferences;
 import android.os.Bundle;
+import android.view.Menu;
+import android.view.View;
 import android.widget.Button;
 import android.widget.EditText;
+import android.widget.Toast;
 
 public class SetID extends Activity {
 	
-	public EditText idEdit;
+    public EditText idEdit;
 	public EditText passEdit;
 	public Button saveButton;
+	private String orgid;
+	private String orgpass;
+	private String tempid;
+	private String temppass;
+
 	
     /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        setContentView(R.layout.main);
+        setContentView(R.layout.setid);
         		idEdit = (EditText) findViewById(R.id.user_edit);
         		passEdit = (EditText) findViewById(R.id.pass_edit);
         		saveButton = (Button) findViewById(R.id.login_button);
+        		
+        				// プリファレンスからID/Passを取得
+		SharedPreferences preferences = getSharedPreferences( getString(R.string.preferences_name), MODE_PRIVATE);
+		orgid = preferences.getString( getString(R.string.preferences_id), "");
+		orgpass = preferences.getString( getString(R.string.preferences_pass), "");
+
+		// 初期値の設定
+		idEdit.setText(orgid);
+		passEdit.setText(orgpass);
+		tempid = "";
+		temppass = "";
+		
+		saveButton.setOnClickListener(new View.OnClickListener() {
+			public void onClick(View v) {
+				// TODO 自動生成されたメソッド・スタブ
+				tempid = idEdit.getEditableText().toString();
+				temppass = passEdit.getEditableText().toString();
+				// tempid == null とか tempid == "" だと引っかからなかったので
+				if( tempid.length() == 0 || temppass.length() == 0){
+					Toast.makeText( SetID.this, "ID / pass の設定がありません", Toast.LENGTH_LONG).show();
+					return;
+				}
+				// id/pass が正しいかを確認
+				//if( !chkid()){
+				//	Toast.makeText( SetID.this, "ID / pass を見直してください", Toast.LENGTH_LONG).show();
+				//	return;
+				//}
+				// 新しい ID/pass を設定して終了
+				SharedPreferences preferences = getSharedPreferences( getString(R.string.preferences_name), MODE_PRIVATE);
+				SharedPreferences.Editor editor = preferences.edit();
+				editor.putString( getString(R.string.preferences_id), tempid);
+				editor.putString( getString(R.string.preferences_pass), temppass);
+				editor.commit();
+				setResult(RESULT_OK);
+				finish();
+			}
+		});
+		
+				
+				
+				
+				
+        		
     }
-}
+    @Override
+     public boolean onCreateOptionsMenu(Menu menu){
+        super.onCreateOptionsMenu(menu);
+        menu.add(0,0,0,"upload").setIcon(android.R.drawable.ic_menu_upload);
+        menu.add(0,1,0,"login").setIcon(android.R.drawable.ic_menu_agenda);
+        
+        return true;
+     }   
+}

src/org/homelinux/sheephead/androizou/Upload.java

+package org.homelinux.sheephead.androizou;
+
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.DefaultHttpClient;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.util.Log;
+
+public class Upload extends Activity {
+    private static final String TAG = "Logact";
+
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.upload);
+        
+        final Uri uri =  this.getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
+        Log.d(TAG,uri.toString());
+        
+        HttpClient httpClient = new DefaultHttpClient();
+        HttpPost post = new HttpPost(URL);
+        MultipartEntity entity 
+        
+//        	private void SetIDAndPass( boolean bCreate){
+//		updateButton.setClickable(false);
+//		reloadButton.setClickable(false);
+		// プリファレンスからID/Passを取得
+//		SharedPreferences preferences = getSharedPreferences( getString(R.string.preferences_name), MODE_PRIVATE);
+//		strid = preferences.getString( getString(R.string.preferences_id), "");
+//		strpass = preferences.getString( getString(R.string.preferences_pass), "");
+//		if(!chkid( bCreate)){
+//			return;
+//		}
+//		httpClient = new DefaultHttpClient();
+//		Credentials cred = new UsernamePasswordCredentials( strid, strpass);
+//		httpClient.getCredentialsProvider().setCredentials( new AuthScope("twitter.com", 80), cred);
+//		GetAndWriteHomeTimeLine();
+//		updateButton.setClickable(true);
+//		reloadButton.setClickable(true);
+//	}
+
+        
+        
+    }
+    
+
+}

src/org/homelinux/sheephead/androizou/login.java

-package org.homelinux.sheephead.androizou;
-
-import android.app.Activity;
-
-public class login extends Activity {
-
-}