Skip to content
This repository was archived by the owner on Dec 8, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ dependencies {
compile 'com.google.code.gson:gson:2.1'
compile 'net.sf.opencsv:opencsv:2.3'
compile 'com.google.code.findbugs:jsr305:1.3.9'
compile 'com.android.support:recyclerview-v7:23.0.1'
}

android {
Expand Down
90 changes: 40 additions & 50 deletions res/layout/login.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,62 +3,52 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/andBackground"
android:orientation="vertical" >
android:orientation="vertical">

<ScrollView
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/login_ok_button" >
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="80dp">

<LinearLayout
android:layout_width="fill_parent"
<TextView
style="@style/MainTableText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="80dp" >

<TextView
style="@style/MainTableText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text="@string/account_required"
android:textStyle="bold" />

<TextView
style="@style/MainTableText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text="@string/account_choose" />
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text="@string/account_required"
android:textStyle="bold" />

<View
android:id="@+id/main_app_buttonbarSpacer"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:background="@color/andBorder"
android:paddingLeft="5dp"
android:paddingRight="5dp" />
<TextView
style="@style/MainTableText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text="@string/account_choose" />

<!-- TODO Replace this with a list view! -->
<View
android:id="@+id/main_app_buttonbarSpacer"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:background="@color/andBorder"
android:paddingLeft="5dp"
android:paddingRight="5dp" />

<LinearLayout
android:id="@+id/login_input"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</ScrollView>
<android.support.v7.widget.RecyclerView
android:id="@+id/login_input"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>

<RelativeLayout
android:id="@+id/login_ok_button"
Expand All @@ -70,7 +60,7 @@
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:background="@drawable/image_button"
android:padding="5dp" >
android:padding="5dp">

<TextView
style="@style/MainTableText"
Expand Down
2 changes: 1 addition & 1 deletion res/layout/login_list_item.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_height="fill_parent"
android:background="@drawable/button_background"
android:paddingBottom="10dp"
android:paddingTop="10dp" >
Expand Down
63 changes: 63 additions & 0 deletions src/com/github/andlyticsproject/AccountListAdapter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.github.andlyticsproject;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.TextView;

import com.github.andlyticsproject.model.DeveloperAccount;

import java.util.ArrayList;
import java.util.List;

public class AccountListAdapter extends RecyclerView.Adapter<AccountListAdapter.ViewHolder> {
private final AccountSelectedListener listener;
private List<DeveloperAccount> developerAccounts = new ArrayList<>();

public class ViewHolder extends RecyclerView.ViewHolder {
public TextView emailDeveloper;
public CheckBox checkBox;

public ViewHolder(View itemView) {
super(itemView);

emailDeveloper = (TextView) itemView.findViewById(R.id.login_list_item_text);
checkBox = (CheckBox) itemView.findViewById(R.id.login_list_item_enabled);
}
}

public AccountListAdapter(List<DeveloperAccount> developerAccounts, AccountSelectedListener listener) {
this.listener = listener;
this.developerAccounts.addAll(developerAccounts);
}

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.login_list_item, parent, false);

ViewHolder viewHolder = new ViewHolder(v);

return viewHolder;
}

@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
DeveloperAccount developerAccount = developerAccounts.get(position);
holder.emailDeveloper.setText(developerAccount.getName());
holder.checkBox.setChecked(!developerAccount.isHidden());
holder.checkBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.accountSelected(holder.checkBox.isChecked(), developerAccounts.get(position));
}
});

}

@Override
public int getItemCount() {
return developerAccounts.size();
}
}
8 changes: 8 additions & 0 deletions src/com/github/andlyticsproject/AccountSelectedListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.github.andlyticsproject;

import com.github.andlyticsproject.model.DeveloperAccount;


public interface AccountSelectedListener {
void accountSelected(boolean checked, DeveloperAccount account);
}
Loading