Skip to content

Commit

Permalink
droneshare account ui update.
Browse files Browse the repository at this point in the history
  • Loading branch information
m4gr3d committed Feb 9, 2015
1 parent 2a7f1a1 commit 98aba03
Show file tree
Hide file tree
Showing 13 changed files with 169 additions and 57 deletions.
4 changes: 2 additions & 2 deletions Android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies {
compile 'com.android.support:cardview-v7:21.0.2'
compile 'com.android.support:recyclerview-v7:21.0.2'

compile 'com.o3dr:3dr-services-lib:2.2.7'
compile 'com.o3dr:3dr-services-lib:2.2.8'

compile files('libs/droneapi-java-0.3-SNAPSHOT.jar')
compile files('libs/j2xx.jar')
Expand All @@ -28,7 +28,7 @@ android {
applicationId 'org.droidplanner.android'
minSdkVersion 14
targetSdkVersion 21
versionCode 30101
versionCode 30102
versionName getGitVersion()
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions Android/res/drawable/clickable_bg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/light_grey" android:state_pressed="true" />
</selector>
117 changes: 91 additions & 26 deletions Android/res/layout/fragment_droneshare_account.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,101 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:id="@+id/account_image"
android:layout_margin="10dp"
android:layout_height="100dp"
android:layout_width="100dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:visibility="invisible"
android:src="@drawable/ic_account_circle_grey600_48dp"/>

<TextView
<android.support.v7.widget.CardView
android:id="@+id/user_info_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/account_image"
android:layout_toEndOf="@+id/account_image"
android:layout_alignTop="@+id/account_image"
android:layout_alignBottom="@+id/account_image"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:gravity="center_vertical"
android:textSize="30sp"
android:id="@+id/dshare_username"
tools:text="ne0fhyk"/>

<android.support.v7.widget.RecyclerView
android:layout_below="@+id/account_image"
android:layout_marginRight="10dp"
android:layout_marginBottom="5dp">

<RelativeLayout
android:id="@+id/user_info_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:background="@drawable/clickable_bg"
>

<ImageView
android:id="@+id/account_image"
android:layout_margin="10dp"
android:layout_height="70dp"
android:layout_width="70dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:visibility="visible"
android:src="@drawable/ic_account_circle_grey600_48dp"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/account_image"
android:layout_toEndOf="@+id/account_image"
android:layout_marginTop="15dp"
android:gravity="center_vertical"
android:textSize="30sp"
android:id="@+id/dshare_username"
tools:text="ne0fhyk"/>

<TextView
android:id="@+id/dshare_user_url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/dshare_username"
android:layout_alignStart="@+id/dshare_username"
android:layout_alignLeft="@+id/dshare_username"
tools:text="http://www.droneshare.com/user/test"/>
</RelativeLayout>
</android.support.v7.widget.CardView>

<android.support.v7.widget.CardView
android:layout_below="@+id/user_info_card"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/user_vehicles_list"
android:fadeScrollbars="true"/>
android:layout_marginBottom="10dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<TextView
style="?android:attr/textAppearanceLarge"
android:text="@string/label_vehicle_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/dark_grey"
android:padding="15dp"/>

<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@color/light_grey"
android:layout_marginBottom="10dp"
/>

<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/user_vehicles_list"
android:scrollbars="vertical"
android:scrollbarStyle="insideInset"
/>
</LinearLayout>

<org.droidplanner.android.widgets.NiceProgressView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/vehicle_loading_progress"
android:visibility="gone"
style="?android:progressBarStyleLarge"/>
</android.support.v7.widget.CardView>

</RelativeLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
android:minWidth="250dp"
android:minHeight="56dp"
android:background="@drawable/signup_button_bg"
android:textColor="@android:color/white"
android:layout_marginTop="20dp"
android:text="@string/label_sign_up"
android:textAllCaps="true"/>
Expand Down Expand Up @@ -110,6 +111,7 @@
android:background="@drawable/login_button_bg"
android:layout_marginTop="20dp"
android:text="@string/label_login"
android:textColor="@android:color/white"
android:textAllCaps="true"/>

<TextView
Expand Down
26 changes: 17 additions & 9 deletions Android/res/layout/list_item_vehicle_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,23 @@
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="@+id/vehicle_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="15dp"
tools:text="quadcopter"
android:gravity="center"
android:textSize="20sp"
android:minHeight="64dp"/>

<TextView
android:id="@+id/vehicle_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?android:attr/borderlessButtonStyle"
android:padding="15dp"
tools:text="quadcopter"
android:layout_gravity="center"
android:gravity="center"
android:textSize="20sp"
android:textAllCaps="false"
android:textColor="@color/dark_grey"
android:drawableEnd="@drawable/ic_open_in_new_grey600_18dp"
android:drawableRight="@drawable/ic_open_in_new_grey600_18dp"
android:drawablePadding="10dp"
android:minHeight="64dp"/>

<View
android:layout_width="match_parent"
Expand Down
1 change: 1 addition & 0 deletions Android/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -536,5 +536,6 @@
<string name="label_mission_item_type_no_selection">No available option</string>
<string name="description_mission_item_type_selection">Click on the spinner to select a type for the selected waypoints.</string>
<string name="description_mission_item_type_no_selection">No type option is available for the selected items.</string>
<string name="label_vehicle_details">Vehicle details</string>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.Fragment;
Expand All @@ -22,6 +24,7 @@
import org.droidplanner.android.R;
import org.droidplanner.android.activities.interfaces.AccountLoginListener;
import org.droidplanner.android.utils.prefs.DroidPlannerPrefs;
import org.droidplanner.android.widgets.NiceProgressView;
import org.droidplanner.android.widgets.adapterViews.UserDataAdapter;
import org.json.JSONException;
import org.json.JSONObject;
Expand All @@ -37,6 +40,8 @@ public class DroneshareAccountFragment extends Fragment {

private final static String EXTRA_USER_DATA = "extra_user_data";

public final static String DRONESHARE_URL = "http://www.droneshare.com/";

private DroidPlannerPrefs dpPrefs;

private JSONObject userData;
Expand Down Expand Up @@ -79,6 +84,20 @@ public void onViewCreated(View view, Bundle savedInstanceState) {
final TextView usernameView = (TextView) view.findViewById(R.id.dshare_username);
usernameView.setText(username);

final String userProfileUrl = DRONESHARE_URL + "user/" + username;
final TextView userUrlView = (TextView) view.findViewById(R.id.dshare_user_url);
userUrlView.setText(userProfileUrl);

final View userInfoBox = view.findViewById(R.id.user_info_container);
userInfoBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Open the user profile on droneshare.
startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(userProfileUrl)));
}
});

final NiceProgressView progressView = (NiceProgressView) view.findViewById(R.id.vehicle_loading_progress);
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.user_vehicles_list);

//Use this setting to improve performance if you know that changes in content do not change the layout side
Expand All @@ -90,7 +109,7 @@ public void onViewCreated(View view, Bundle savedInstanceState) {
final RecyclerView.LayoutManager gridLayoutMgr = new GridLayoutManager(context, colCount);
recyclerView.setLayoutManager(gridLayoutMgr);

userDataAdapter = new UserDataAdapter();
userDataAdapter = new UserDataAdapter(context);

if (savedInstanceState != null) {
String userDataString = savedInstanceState.getString(EXTRA_USER_DATA);
Expand All @@ -106,7 +125,7 @@ public void onViewCreated(View view, Bundle savedInstanceState) {

recyclerView.setAdapter(userDataAdapter);

new LoadUserData(userData == null).execute(username, password);
new LoadUserData(progressView, userData == null).execute(username, password);
}

@Override
Expand Down Expand Up @@ -140,31 +159,24 @@ public boolean onOptionsItemSelected(MenuItem item) {

private class LoadUserData extends AsyncTask<String, Void, JSONObject> {

private final ProgressDialog progressDialog;
private final boolean forceUpdate;
private final NiceProgressView progressView;

LoadUserData(boolean forceUpdate) {
LoadUserData(NiceProgressView progressView, boolean forceUpdate) {
this.progressView = progressView;
this.forceUpdate = forceUpdate;
if (forceUpdate) {
progressDialog = new ProgressDialog(getActivity());
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setIndeterminate(true);
progressDialog.setTitle("Loading user data...");
} else {
progressDialog = null;
}
}

@Override
protected void onPreExecute() {
if (progressDialog != null)
progressDialog.show();
if(progressView != null && forceUpdate)
progressView.setVisibility(View.VISIBLE);
}

@Override
protected void onCancelled() {
if (progressDialog != null && progressDialog.isShowing())
progressDialog.dismiss();
if(progressView != null && forceUpdate)
progressView.setVisibility(View.GONE);
}

@Override
Expand All @@ -183,8 +195,8 @@ protected JSONObject doInBackground(String... params) {

@Override
protected void onPostExecute(JSONObject result) {
if (progressDialog != null && progressDialog.isShowing())
progressDialog.dismiss();
if(progressView != null && forceUpdate)
progressView.setVisibility(View.GONE);

if(loginListener == null)
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void onCreate(Bundle savedInstanceState) {

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.droneshare_account, container, false);
return inflater.inflate(R.layout.fragment_droneshare_login, container, false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package org.droidplanner.android.widgets.adapterViews;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import org.droidplanner.android.R;
import org.droidplanner.android.fragments.account.DroneshareAccountFragment;
import org.json.JSONArray;
import org.json.JSONObject;

Expand Down Expand Up @@ -34,9 +38,11 @@ public ViewHolder(View itemView, TextView vehicleName, TextView vehicleType, Tex
}
}

private final Context context;
private JSONArray userVehicleData;

public UserDataAdapter() {
public UserDataAdapter(Context context) {
this.context = context;
userVehicleData = new JSONArray();
}

Expand Down Expand Up @@ -75,6 +81,20 @@ public void onBindViewHolder(ViewHolder holder, int position) {
if(vehicleName.isEmpty())
vehicleName = vehicleType;
holder.vehicleName.setText(vehicleName);

final String vehicleId = vehicleData.optString("id", null);
if(vehicleId != null) {
holder.vehicleName.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final String vehicleInfoUrl = DroneshareAccountFragment.DRONESHARE_URL + "vehicle/" + vehicleId;
context.startActivity(new Intent(Intent.ACTION_VIEW)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.setData(Uri.parse(vehicleInfoUrl)));
}
});
}

holder.autopilot.setText("Autopilot: " + vehicleData.optString("autopilotType", ""));

JSONArray missions = vehicleData.optJSONArray("missions");
Expand Down

0 comments on commit 98aba03

Please sign in to comment.