android: redesing of project dialogs

This commit is contained in:
Joachim Fritzsch 2013-05-25 14:05:38 +02:00
parent 6822cc1323
commit 686688dcef
12 changed files with 301 additions and 45 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -17,25 +17,42 @@
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:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@color/white_smoke" >
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:layout_marginBottom="10dp"
android:singleLine="true"
android:textColor="@color/black"
android:textAppearance="?android:attr/textAppearanceMedium"
android:background="@drawable/shape_light_blue_background" />
<EditText
android:id="@+id/Input"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:inputType="textUri">
android:id="@+id/Input"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:inputType="textUri"
android:layout_margin="5dp">
<requestFocus />
</EditText>
<Button
android:id="@+id/buttonUrlSubmit"
android:layout_toRightOf="@+id/Input"
android:layout_width="50dp"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="@string/attachproject_list_manual__dialog_button"/>
</RelativeLayout>
android:background="@drawable/shape_button_blue"
android:textColor="@color/white_smoke"
android:textAppearance="?android:attr/textAppearanceMedium"
android:padding="5dp"
android:layout_gravity="center_horizontal"
android:clickable="true"
android:layout_margin="5dp"
android:text="@string/attachproject_list_manual_dialog_button"/>
</LinearLayout>

View File

@ -0,0 +1,94 @@
<?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:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@color/white_smoke" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp"
android:layout_marginBottom="10dp"
android:background="@drawable/shape_light_blue_background"
android:gravity="center_vertical" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/attentionb"
android:background="@android:color/transparent"
android:contentDescription="@string/confirm_image_desc"/>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:singleLine="true"
android:textColor="@color/black"
android:textAppearance="?android:attr/textAppearanceMedium"
android:background="@android:color/transparent" />
</LinearLayout>
<TextView
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:background="@android:color/transparent"
android:textColor="@color/black"
android:padding="10dp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/cancel"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:padding="5dp"
android:clickable="true"
android:layout_margin="5dp"
android:background="@drawable/shape_button_blue"
android:textColor="@color/white_smoke"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/confirm_cancel"
android:layout_weight="0.5"/>
<Button
android:id="@+id/confirm"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:padding="5dp"
android:clickable="true"
android:layout_margin="5dp"
android:background="@drawable/shape_button_red"
android:textColor="@color/white_smoke"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_weight="0.5" />
</LinearLayout>
</LinearLayout>

View File

@ -0,0 +1,55 @@
<?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:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@color/white_smoke" >
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:minWidth="180dp"
android:singleLine="true"
android:textColor="@color/black"
android:textAppearance="?android:attr/textAppearanceMedium"
android:background="@drawable/shape_light_blue_background" />
<ListView
android:id="@+id/options"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<Button
android:id="@+id/cancel"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:padding="5dp"
android:clickable="true"
android:layout_margin="5dp"
android:background="@drawable/shape_button_blue"
android:textColor="@color/white_smoke"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/confirm_cancel"
android:layout_gravity="center_horizontal"
android:layout_weight="0.5"/>
</LinearLayout>

View File

@ -0,0 +1,28 @@
<?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/>.
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/item"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:singleLine="true"
android:textColor="@color/black"
android:background="@color/white_smoke"
android:textAppearance="?android:attr/textAppearanceMedium" />

View File

@ -38,8 +38,8 @@
<string name="attachproject_list_loading">Loading supported projects&#8230;</string>
<string name="attachproject_list_header">Choose a project:</string>
<string name="attachproject_list_manual_button">Add project by URL</string>
<string name="attachproject_list_manual__dialog_title">Enter URL of scientific project:</string>
<string name="attachproject_list_manual__dialog_button">></string>
<string name="attachproject_list_manual_dialog_title">Enter project URL:</string>
<string name="attachproject_list_manual_dialog_button">Add project</string>
<string name="attachproject_list_manual_no_url">Please enter project URL!</string>
<string name="attachproject_list_no_internet">No internet connection!</string>
<!-- project login -->
@ -208,11 +208,10 @@
</string-array>
<!-- project dialogs -->
<string name="projects_confirm_detach_title">Remove project</string>
<string name="projects_confirm_detach_message">Remove project:</string>
<string name="projects_confirm_detach_message">Are you sure to remove</string>
<string name="projects_confirm_detach_message2">from BOINC?</string>
<string name="projects_confirm_detach_confirm">Remove</string>
<string name="projects_confirm_detach_cancel">Cancel</string>
<string name="projects_confirm_advanced_title">Project operation</string>
<string name="projects_confirm_advanced_message">Choose an operation to execute:</string>
<string name="projects_confirm_advanced_title">Project operations:</string>
<!-- tasks tab strings -->
<string name="tasks_loading">Reading tasks&#8230;</string>
@ -244,7 +243,8 @@
<string name="confirm_abort_task_title">Abort task</string>
<string name="confirm_abort_task_message">Abort task:</string>
<string name="confirm_abort_task_confirm">Abort</string>
<string name="confirm_abort_task_cancel">Cancel</string>
<string name="confirm_cancel">Cancel</string>
<string name="confirm_image_desc">Confirmation dialog</string>
<!-- transfers tab strings -->
<string name="trans_loading">Reading transfers&#8230;</string>

View File

@ -40,6 +40,7 @@ import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class AttachProjectListActivity extends Activity implements android.view.View.OnClickListener{
@ -135,10 +136,11 @@ public class AttachProjectListActivity extends Activity implements android.view.
@Override
protected Dialog onCreateDialog(int id) {
manualUrlInputDialog = new Dialog(this); //instance new dialog
manualUrlInputDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
manualUrlInputDialog.setContentView(R.layout.attach_project_list_layout_manual_dialog);
Button button = (Button) manualUrlInputDialog.findViewById(R.id.buttonUrlSubmit);
button.setOnClickListener(this);
manualUrlInputDialog.setTitle(R.string.attachproject_list_manual__dialog_title);
((TextView)manualUrlInputDialog.findViewById(R.id.title)).setText(R.string.attachproject_list_manual_dialog_title);
return manualUrlInputDialog;
}

View File

@ -20,16 +20,12 @@ package edu.berkeley.boinc;
import java.util.ArrayList;
import java.util.Iterator;
import edu.berkeley.boinc.adapter.ProjectsListAdapter;
import edu.berkeley.boinc.client.Monitor;
import edu.berkeley.boinc.rpc.Project;
import edu.berkeley.boinc.rpc.RpcClient;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
@ -43,8 +39,17 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import edu.berkeley.boinc.adapter.ProjectsListAdapter;
import edu.berkeley.boinc.client.Monitor;
import edu.berkeley.boinc.rpc.Project;
import edu.berkeley.boinc.rpc.RpcClient;
import android.widget.ArrayAdapter;
public class ProjectsActivity extends FragmentActivity {
@ -52,7 +57,7 @@ public class ProjectsActivity extends FragmentActivity {
private final String TAG = "BOINC ProjectsActivity";
private Monitor monitor;
private Boolean mIsBound;
private Boolean mIsBound = false;
private ListView lv;
private ProjectsListAdapter listAdapter;
@ -68,11 +73,13 @@ public class ProjectsActivity extends FragmentActivity {
// getService returns the Monitor object that is needed to call functions.
//
private ServiceConnection mConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName className, IBinder service) {
monitor = ((Monitor.LocalBinder)service).getService();
mIsBound = true;
Log.d(TAG,"service bound");
}
@Override
public void onServiceDisconnected(ComponentName className) {
monitor = null;
mIsBound = false;
@ -100,7 +107,7 @@ public class ProjectsActivity extends FragmentActivity {
// Establish a connection with the service, onServiceConnected gets called when
// (calling within Tab needs getApplicationContext() for bindService to work!)
getApplicationContext().bindService(new Intent(this, Monitor.class), mConnection, Service.START_STICKY_COMPATIBILITY);
getApplicationContext().bindService(new Intent(this, Monitor.class), mConnection, Service.START_STICKY_COMPATIBILITY);
}
@Override
@ -272,19 +279,72 @@ public class ProjectsActivity extends FragmentActivity {
new ProjectOperationAsync().execute(project.master_url, operation.toString());
break;
case RpcClient.PROJECT_DETACH:
ConfirmationDialog cd = ConfirmationDialog.newInstance(
getString(R.string.projects_confirm_detach_title) + "?",
getString(R.string.projects_confirm_detach_message) + " " + project.project_name,
getString(R.string.projects_confirm_detach_confirm));
cd.setConfirmationClicklistener(new DialogInterface.OnClickListener() {
final Dialog dialog = new Dialog(activity);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog_confirm);
((TextView)dialog.findViewById(R.id.title)).setText(R.string.projects_confirm_detach_title);
((TextView)dialog.findViewById(R.id.message)).setText(getString(R.string.projects_confirm_detach_message) + " "
+ project.project_name + " " + getString(R.string.projects_confirm_detach_message2));
Button confirm = (Button) dialog.findViewById(R.id.confirm);
confirm.setText(R.string.projects_confirm_detach_confirm);
confirm.setOnClickListener(new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
public void onClick(View v) {
new ProjectOperationAsync().execute(project.master_url, ""+RpcClient.PROJECT_DETACH);
dialog.dismiss();
}
});
cd.show(getSupportFragmentManager(), "");
Button cancel = (Button) dialog.findViewById(R.id.cancel);
cancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
break;
case RpcClient.PROJECT_ADVANCED:
final Dialog dialogAdvanced = new Dialog(activity);
dialogAdvanced.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialogAdvanced.setContentView(R.layout.dialog_list);
((TextView)dialogAdvanced.findViewById(R.id.title)).setText(R.string.projects_confirm_advanced_title);
ListView list = (ListView)dialogAdvanced.findViewById(R.id.options);
String[] controls = getResources().getStringArray(R.array.projects_advanced_controls);
list.setAdapter(new ArrayAdapter<String>(activity,R.layout.dialog_list_item,controls));
list.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View v, int position, long id) {
switch(position) {
case 0:
new ProjectOperationAsync().execute(project.master_url, ""+RpcClient.PROJECT_SUSPEND);
break;
case 1:
new ProjectOperationAsync().execute(project.master_url, ""+RpcClient.PROJECT_RESUME);
break;
case 2:
new ProjectOperationAsync().execute(project.master_url, ""+RpcClient.PROJECT_NNW);
break;
case 3:
new ProjectOperationAsync().execute(project.master_url, ""+RpcClient.PROJECT_ANW);
break;
case 4:
new ProjectOperationAsync().execute(project.master_url, ""+RpcClient.PROJECT_RESET);
break;
default:
break;
}
dialogAdvanced.dismiss();
}});
Button cancelButton = (Button) dialogAdvanced.findViewById(R.id.cancel);
cancelButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialogAdvanced.dismiss();
}
});
dialogAdvanced.show();
/*
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(R.string.projects_confirm_advanced_title);
builder.setItems(R.array.projects_advanced_controls, new DialogInterface.OnClickListener() {
@ -309,13 +369,13 @@ public class ProjectsActivity extends FragmentActivity {
break;
}
}});
builder.create().show();
builder.create().show(); */
break;
default:
Log.w(TAG,"could not map operation tag");
}
listAdapter.notifyDataSetChanged(); //force list adapter to refresh
} catch (Exception e) {Log.w(TAG,"failed parsing view tag");}
} catch (Exception e) {Log.w(TAG,"onclick failed",e);}
}
};
}
@ -329,7 +389,7 @@ public class ProjectsActivity extends FragmentActivity {
try{
String url = params[0];
Integer operation = Integer.parseInt(params[1]);
Log.d(TAG,"url: " + url + " operation: " + operation);
Log.d(TAG,"url: " + url + " operation: " + operation + " monitor bound: " + mIsBound);
if(mIsBound) return monitor.projectOperation(operation, url);
else return false;

View File

@ -51,7 +51,7 @@ public class ClientNotification {
public synchronized void update() {
// check whether notification is allowed in preferences
if (!Monitor.getAppPrefs().getShowNotification()) {
Log.d(TAG,"cancelling notification");
//Log.d(TAG,"cancelling notification");
nm.cancel(notificationId);
return;
}

View File

@ -759,11 +759,11 @@ public class RpcClient {
if(accountIn.email_addr == null || accountIn.email_addr.isEmpty()) id = accountIn.user_name;
else id = accountIn.email_addr;
mRequest.setLength(0);
mRequest.append("<lookup_account>\n <url>");
mRequest.append("<lookup_account>\n <url>");
mRequest.append(accountIn.url);
mRequest.append("</url>\n <email_addr>");
mRequest.append("</url>\n <email_addr>");
mRequest.append(id);
mRequest.append("</email_addr>\n <passwd_hash>");
mRequest.append("</email_addr>\n <passwd_hash>");
mRequest.append(getPasswdHash(accountIn.passwd, id));
mRequest.append("</passwd_hash>\n</lookup_account>\n");
sendRequest(mRequest.toString());