Commit 5d116ce2 authored by idic's avatar idic

畫面 Fix

parent 9a0ab3b5
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
......@@ -26,17 +26,13 @@
<activity
android:name=".ReportActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme" />
<activity
android:name=".DialogPolicyDetailActivity"
android:theme="@style/AppTheme" />
android:label="Report Information"
android:parentActivityName=".MainActivity" />
<activity
android:name=".DialogDeviceInfoActivity"
android:label="@string/message_device_information"
android:theme="@style/AppTheme" />
android:theme="@style/AppDialogTheme"
android:label="Device Information" />
<provider
android:name=".storage.PrivacyPolicyProvider"
......
......@@ -16,13 +16,12 @@ import org.prlab.idic.privacypolicy.adapter.MessageRecyclerViewAdapter;
import org.prlab.idic.privacypolicy.ble.BLECustomScript;
import org.prlab.idic.privacypolicy.pojo.Message;
import org.prlab.idic.privacypolicy.schedule.Scheduled;
import org.prlab.idic.privacypolicy.storage.PrivacyPolicyContract;
import org.prlab.idic.privacypolicy.storage.PrivacyPolicyStorageImpl;
import org.prlab.idic.privacypolicy.tool.BaseUtils;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import static android.bluetooth.BluetoothGatt.GATT_SUCCESS;
......@@ -200,45 +199,12 @@ public class DeviceOperatorActivity extends AppCompatActivity {
actionCharacteristic = permissionService.getCharacteristic(PRIVACY_ACTION_UUID);
preferenceCharacteristic = permissionService.getCharacteristic(PRIVACY_PREFERENCE_UUID);
Set<Integer> acceptList = new HashSet<>();
List<List<Integer>> subAcceptList = new LinkedList<>();
setMessageBar("Enable privacy policy setting.");
for (BluetoothGattService service : gatt.getServices()) {
if (PRIVACY_NEGOTIATION_UUID.equals(service.getUuid()))
continue;
List<String> layerUUIDs = new LinkedList<>();
layerUUIDs.add(String.valueOf(service.getUuid()));
List<Integer> selections = mPolicyStorage.get(layerUUIDs);
for (int selection : selections) {
acceptList.add(selection);
}
for (BluetoothGattCharacteristic characteristic : service.getCharacteristics()) {
layerUUIDs.add(String.valueOf(characteristic.getUuid()));
selections = mPolicyStorage.get(layerUUIDs);
if (selections.size() > 0) {
List<Integer> list = new LinkedList<>();
for (int selection : selections) {
list.add(selection);
}
subAcceptList.add(list);
}
layerUUIDs.remove(layerUUIDs.size() - 1);
}
}
if (subAcceptList.size() > 0) {
acceptList.clear();
for (List<Integer> list : subAcceptList) {
acceptList.addAll(list);
}
}
for (int selection = SELECTION_LOWER_BOUND; selection < SELECTION_UPPER_BOUND; selection++) {
if (acceptList.contains(selection)) {
addPreference(selection);
for (int i = 0; i < 2; i++) {
if (PrivacyPolicyContract.ACCEPT.equals(mPolicyStorage.get(i + 1))) {
addPreference(i + 1);
} else {
removePreference(selection);
removePreference(i + 1);
}
}
continueNegotiating();
......@@ -500,7 +466,7 @@ public class DeviceOperatorActivity extends AppCompatActivity {
int connectionState = mBluetoothManager.getConnectionState(device, BluetoothProfile.GATT);
Log.i(TAG, "Device connection status is " + connectionState + ".");
if (device != null && connectionState == BluetoothProfile.STATE_DISCONNECTED) {
if (device != null) {
mBluetoothGatt = device.connectGatt(this, false, mBluetoothGattCallback);
return mBluetoothGatt != null;
} else {
......
package org.prlab.idic.privacypolicy;
import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.view.MenuItem;
import android.view.View;
import org.prlab.idic.privacypolicy.adapter.IconItemRecyclerViewAdapter;
import org.prlab.idic.privacypolicy.adapter.InfoItemRecyclerViewAdapter;
import org.prlab.idic.privacypolicy.pojo.report.InfoItem;
import org.prlab.idic.privacypolicy.pojo.report.device.Device;
......@@ -14,7 +17,7 @@ import java.util.List;
/**
* Created by IDIC on 2017/2/22.
*/
public class DialogDeviceInfoActivity extends Activity {
public class DialogDeviceInfoActivity extends AppCompatActivity {
private Device mDevice;
private List<InfoItem> items = new LinkedList<>();
......@@ -67,7 +70,10 @@ public class DialogDeviceInfoActivity extends Activity {
private void initView() {
RecyclerView mInfoRecyclerView = (RecyclerView) findViewById(R.id.layout_device_info);
RecyclerView.Adapter mInfoRecyclerViewAdapter = new InfoItemRecyclerViewAdapter(items, false);
RecyclerView.Adapter mInfoRecyclerViewAdapter = new InfoItemRecyclerViewAdapter(items,
R.layout.recycler_view_item_horizontally,
android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M ?
getColor(R.color.colorAnother) : getResources().getColor(R.color.colorAnother));
mInfoRecyclerView.setAdapter(mInfoRecyclerViewAdapter);
// RecyclerView mIconRecyclerView = (RecyclerView) findViewById(R.id.layout_device_icon);
......@@ -79,8 +85,4 @@ public class DialogDeviceInfoActivity extends Activity {
// }
}
public void onBackButtonClick(View view) {
finish();
}
}
package org.prlab.idic.privacypolicy;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import org.prlab.idic.privacypolicy.adapter.InfoItemRecyclerViewAdapter;
import org.prlab.idic.privacypolicy.adapter.StatementRecyclerViewAdapter;
import org.prlab.idic.privacypolicy.pojo.report.InfoItem;
import org.prlab.idic.privacypolicy.pojo.report.PrivacyPolicy;
import org.prlab.idic.privacypolicy.tool.BaseUtils;
import java.util.LinkedList;
import java.util.List;
/**
* Created by IDIC on 2017/2/17.
*/
public class DialogPolicyDetailActivity extends Activity {
private PrivacyPolicy mPrivacyPolicy;
private RecyclerView mCollectorRecyclerView;
private TextView mAccessTextView;
private RecyclerView mDisputeRecyclerView;
private RecyclerView mStatementsRecyclerView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dialog_policy);
mPrivacyPolicy = getIntent().getParcelableExtra(getString(R.string.intent_policy_info_key));
setTitle(getString(R.string.message_policy_title) + mPrivacyPolicy.getId());
initView();
}
private void initView() {
initCollector();
initAccess();
initDispute();
initStatements();
}
private void initCollector() {
mCollectorRecyclerView = (RecyclerView) findViewById(R.id.recycler_view_statement_collector);
List<InfoItem> collector = new LinkedList<>();
collector.add(new InfoItem()
.setKey(getString(R.string.policy_statement_collector_name))
.setValue(mPrivacyPolicy.getCollector().getName()));
collector.add(new InfoItem()
.setKey(getString(R.string.policy_statement_collector_email))
.setValue(mPrivacyPolicy.getCollector().getEmail()));
collector.add(new InfoItem()
.setKey(getString(R.string.policy_statement_collector_phone))
.setValue(mPrivacyPolicy.getCollector().getPhone()));
mCollectorRecyclerView.setAdapter(new InfoItemRecyclerViewAdapter(collector));
}
private void initAccess() {
mAccessTextView = (TextView) findViewById(R.id.recycler_view_statement_access);
mAccessTextView.setText(BaseUtils.fixTypeName(mPrivacyPolicy.getAccess().name()));
}
private void initDispute() {
mDisputeRecyclerView = (RecyclerView) findViewById(R.id.recycler_view_statement_dispute);
List<InfoItem> dispute = new LinkedList<>();
dispute.add(new InfoItem()
.setKey(getString(R.string.policy_statement_dispute_resolution_type))
.setValue(getString(R.string.policy_statement_dispute_related_organization)));
dispute.add(new InfoItem()
.setKey(BaseUtils.fixTypeName(mPrivacyPolicy.getDispute().getType().name()))
.setValue(mPrivacyPolicy.getDispute().getRelatedOrganization()));
mDisputeRecyclerView.setAdapter(new InfoItemRecyclerViewAdapter(dispute));
}
private void initStatements() {
mStatementsRecyclerView = (RecyclerView) findViewById(R.id.recycler_view_statement_content);
mStatementsRecyclerView.setAdapter(new StatementRecyclerViewAdapter(getResources(), mPrivacyPolicy.getStatements()));
}
public void onAgreeButtonClick(View view) {
Intent intent = new Intent();
intent.putExtra(getString(R.string.intent_policy_response_selection_key), mPrivacyPolicy.getId());
setResult(RESULT_OK, intent);
finish();
}
public void onDenyButtonClick(View view) {
finish();
}
}
......@@ -10,6 +10,7 @@ import android.widget.ImageView;
import org.prlab.idic.privacypolicy.R;
import org.prlab.idic.privacypolicy.pojo.report.device.Icon;
import java.util.Arrays;
import java.util.List;
/**
......
package org.prlab.idic.privacypolicy.adapter;
import android.content.res.Resources;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.prlab.idic.privacypolicy.R;
import org.prlab.idic.privacypolicy.pojo.report.InfoItem;
......@@ -17,27 +20,35 @@ import java.util.List;
public class InfoItemRecyclerViewAdapter extends RecyclerView.Adapter<InfoItemRecyclerViewAdapter.ViewHolder> {
private List<InfoItem> items;
private boolean isVertical;
private int layout;
private int separatedColor;
public InfoItemRecyclerViewAdapter(List<InfoItem> items) {
this.isVertical = true;
this.items = items;
public InfoItemRecyclerViewAdapter(List<InfoItem> items, int layout) {
this(items, layout, -1);
}
public InfoItemRecyclerViewAdapter(List<InfoItem> items, boolean isVertical) {
this.isVertical = isVertical;
public InfoItemRecyclerViewAdapter(List<InfoItem> items, int layout, int separatedColor) {
this.items = items;
this.layout = layout;
this.separatedColor = separatedColor;
}
@Override
public InfoItemRecyclerViewAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_view_item_horizontally, parent, false);
View view = LayoutInflater.from(parent.getContext()).inflate(layout, parent, false);
return new InfoItemRecyclerViewAdapter.ViewHolder(view);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.bind(position);
InfoItem item = items.get(position);
holder.mKeyTextView.setText(item.getKey());
holder.mValueTextView.setText(item.getValue());
if (separatedColor != -1) {
if (position % 2 == 0) {
holder.itemView.setBackgroundColor(separatedColor);
}
}
}
@Override
......@@ -52,19 +63,10 @@ public class InfoItemRecyclerViewAdapter extends RecyclerView.Adapter<InfoItemRe
ViewHolder(View itemView) {
super(itemView);
View view = itemView.findViewById(R.id.item_info);
mKeyTextView = (TextView) view.findViewById(R.id.text_key);
mValueTextView = (TextView) view.findViewById(R.id.text_value);
mKeyTextView = (TextView) itemView.findViewById(R.id.text_key);
mValueTextView = (TextView) itemView.findViewById(R.id.text_value);
}
void bind(int listIndex) {
InfoItem item = items.get(listIndex);
mKeyTextView.setText(item.getKey());
mValueTextView.setText(item.getValue());
if (isVertical && listIndex == 0) {
// title box
}
}
}
......
package org.prlab.idic.privacypolicy.adapter;
import android.content.res.Resources;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import org.prlab.idic.privacypolicy.R;
import java.util.LinkedList;
import java.util.List;
/**
* Created by IDIC on 2017/2/16.
*/
public class IntegerButtonRecyclerViewAdapter extends RecyclerView.Adapter<IntegerButtonRecyclerViewAdapter.ViewHolder> {
private final String PRIVACY_POLICY_TITLE;
private ListItemClickListener listItemClickListener;
private List<Integer> items;
private List<Integer> target = new LinkedList<>();
public IntegerButtonRecyclerViewAdapter(Resources resources, ListItemClickListener listItemClickListener) {
this.PRIVACY_POLICY_TITLE = resources.getString(R.string.message_policy_title);
this.listItemClickListener = listItemClickListener;
}
public void setItems(List<Integer> items) {
this.items = items;
notifyDataSetChanged();
}
public void addTarget(Integer target) {
this.target.add(target);
notifyDataSetChanged();
}
public void resetTarget() {
this.target.clear();
notifyDataSetChanged();
}
public interface ListItemClickListener {
void onListItemClick(int clickedItemIndex);
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_view_item, parent, false);
return new IntegerButtonRecyclerViewAdapter.ViewHolder(view);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.bind(position);
}
@Override
public int getItemCount() {
return null != items ? items.size() : 0;
}
class ViewHolder extends RecyclerView.ViewHolder {
private Button button;
ViewHolder(View itemView) {
super(itemView);
button = (Button) itemView.findViewById(R.id.button_item);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
IntegerButtonRecyclerViewAdapter.this.listItemClickListener.onListItemClick(getAdapterPosition());
}
});
}
void bind(int listIndex) {
int item = items.get(listIndex);
String message = IntegerButtonRecyclerViewAdapter.this.PRIVACY_POLICY_TITLE + String.valueOf(item);
button.setText(message);
button.setEnabled(!target.contains(item));
}
}
}
package org.prlab.idic.privacypolicy.adapter;
import android.content.res.Resources;
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.CompoundButton;
import android.widget.ImageView;
import android.widget.Switch;
import android.widget.TextView;
import org.prlab.idic.privacypolicy.R;
import org.prlab.idic.privacypolicy.pojo.report.InfoItem;
import org.prlab.idic.privacypolicy.pojo.report.PrivacyPolicy;
import org.prlab.idic.privacypolicy.pojo.report.p3p.Datum;
import org.prlab.idic.privacypolicy.pojo.report.p3p.Purpose;
import org.prlab.idic.privacypolicy.pojo.report.p3p.Recipient;
import org.prlab.idic.privacypolicy.pojo.report.p3p.Remedy;
import org.prlab.idic.privacypolicy.pojo.report.p3p.Statement;
import java.util.LinkedList;
import java.util.List;
public class PolicyRecyclerViewAdapter
extends RecyclerView.Adapter<PolicyRecyclerViewAdapter.ViewHolder> {
private static final String POLICY_PREFIX = "Policy ";
private List<PrivacyPolicy> policies;
private List<Integer> selections;
private ItemCheckedChangedListener itemCheckedChangedListener;
private int separatedColor;
private final String SEPARATOR;
//BASE
private final String COLLECTOR_NAME;
private final String COLLECTOR_PHONE;
private final String COLLECTOR_EMAIL;
private final String DISPUTE_RELATED_ORGANIZATION;
private final String DISPUTE_RESOLUTION_TYPE;
private final String ACCESS;
//Statement
private final String CONSEQUENCE;
private final String PURPOSE_TYPE;
private final String PURPOSE_DESCRIPTION;
private final String DATUM_TYPE;
private final String DATUM_DESCRIPTION;
private final String RECIPIENT_TYPE;
private final String RECIPIENT_DESCRIPTION;
private final String REMEDIES;
private final String RETENTION;
public PolicyRecyclerViewAdapter(Resources resources,
List<PrivacyPolicy> policies,
List<Integer> selections,
ItemCheckedChangedListener itemCheckedChangedListener){
this(resources, policies, selections, itemCheckedChangedListener, -1);
}
public PolicyRecyclerViewAdapter(Resources resources,
List<PrivacyPolicy> policies,
List<Integer> selections,
ItemCheckedChangedListener itemCheckedChangedListener,
int separatedColor) {
SEPARATOR = resources.getString(R.string.policy_separator);
//BASE
String COLLECTOR = resources.getString(R.string.policy_collector_title);
COLLECTOR_NAME = COLLECTOR + SEPARATOR + resources.getString(R.string.policy_collector_name);
COLLECTOR_PHONE = COLLECTOR + SEPARATOR + resources.getString(R.string.policy_collector_phone);
COLLECTOR_EMAIL = COLLECTOR + SEPARATOR + resources.getString(R.string.policy_collector_email);
String DISPUTES = resources.getString(R.string.policy_dispute_title);
DISPUTE_RESOLUTION_TYPE = DISPUTES + SEPARATOR + resources.getString(R.string.policy_dispute_resolution_type);
DISPUTE_RELATED_ORGANIZATION = DISPUTES + SEPARATOR + resources.getString(R.string.policy_dispute_related_organization);
ACCESS = resources.getString(R.string.policy_access_title);
//Statement
CONSEQUENCE = resources.getString(R.string.policy_statement_consequence_title);
String PURPOSES = resources.getString(R.string.policy_statement_purpose_title);
PURPOSE_TYPE = PURPOSES + SEPARATOR + resources.getString(R.string.policy_statement_purpose_type);
PURPOSE_DESCRIPTION = PURPOSES + SEPARATOR + resources.getString(R.string.policy_statement_purpose_description);
String DATA = resources.getString(R.string.policy_statement_data_title);
DATUM_TYPE = DATA + SEPARATOR + resources.getString(R.string.policy_statement_data_type);
DATUM_DESCRIPTION = DATA + SEPARATOR + resources.getString(R.string.policy_statement_data_description);
String RECIPIENTS = resources.getString(R.string.policy_statement_recipient_title);
RECIPIENT_TYPE = RECIPIENTS + SEPARATOR + resources.getString(R.string.policy_statement_recipient_type);
RECIPIENT_DESCRIPTION = RECIPIENTS + SEPARATOR + resources.getString(R.string.policy_statement_recipient_description);
REMEDIES = resources.getString(R.string.policy_statement_remedies);
RETENTION = resources.getString(R.string.policy_statement_retention);
this.policies = policies;
this.selections = selections;
this.itemCheckedChangedListener = itemCheckedChangedListener;
this.separatedColor = separatedColor;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new ViewHolder(LayoutInflater.from(parent.getContext())
.inflate(R.layout.recycler_view_policy, parent, false));
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
PrivacyPolicy policy = policies.get(position);
String title = POLICY_PREFIX + policy.getId();
holder.mPolicyTitleTextView.setText(title);
holder.mPolicyDescriptionTextView.setText(policy.getDescription());
holder.mPolicyCheckBox.setChecked(selections.contains(policy.getId()));
List<InfoItem> items = new LinkedList<>();
addItem(items, COLLECTOR_NAME, policy.getCollector().getName());
addItem(items, COLLECTOR_EMAIL, policy.getCollector().getEmail());
addItem(items, COLLECTOR_PHONE, policy.getCollector().getPhone());
addItem(items, DISPUTE_RESOLUTION_TYPE, policy.getDispute().getType().name());
addItem(items, DISPUTE_RELATED_ORGANIZATION, policy.getDispute().getRelatedOrganization());
addItem(items, ACCESS, policy.getAccess().name());
StringBuilder remedies = new StringBuilder();
for (Remedy remedy : policy.getRemedies()) {
remedies.append(remedy.getType()).append(SEPARATOR);
}
if (remedies.length() > 0)
addItem(items, REMEDIES, remedies.toString());
for (Statement statement : policy.getStatements()) {
// addItem(items, CONSEQUENCE, statement.getConsequence());
for (Purpose purpose : statement.getPurposes()) {
addItem(items, PURPOSE_TYPE, purpose.getType().name());
addItem(items, PURPOSE_DESCRIPTION, purpose.getDescription());
}
for (Datum datum : statement.getData()) {
addItem(items, DATUM_TYPE, datum.getType().name());
addItem(items, DATUM_DESCRIPTION, datum.getDescription());
}
for (Recipient recipient : statement.getRecipients()) {
addItem(items, RECIPIENT_TYPE, recipient.getType().name());
addItem(items, RECIPIENT_DESCRIPTION, recipient.getDescription());
}
addItem(items, RETENTION, statement.getRetention().name());
}
holder.mPolicyContentRecyclerView.setAdapter(new InfoItemRecyclerViewAdapter(items, R.layout.recycler_view_policy_content, separatedColor));
}
private void addItem(List<InfoItem> items, String key, String value) {
items.add(new InfoItem()
.setKey(key)
.setValue(value));
}
@Override
public int getItemCount() {
return policies != null ? policies.size() : 0;
}
class ViewHolder extends RecyclerView.ViewHolder {
private TextView mPolicyTitleTextView;
private TextView mPolicyDescriptionTextView;
private Switch mPolicyCheckBox;
private ImageView mPolicyScaledImageView;
private RecyclerView mPolicyContentRecyclerView;
ViewHolder(View itemView) {
super(itemView);
mPolicyTitleTextView = (TextView) itemView.findViewById(R.id.text_policy_title);
mPolicyDescriptionTextView = (TextView) itemView.findViewById(R.id.text_policy_description);
mPolicyCheckBox = (Switch) itemView.findViewById(R.id.switch_policy_accept);
mPolicyScaledImageView = (ImageView) itemView.findViewById(R.id.image_view_policy_scaled);
mPolicyContentRecyclerView = (RecyclerView) itemView.findViewById(R.id.recycler_view_policy_content);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mPolicyContentRecyclerView.getVisibility() == View.VISIBLE) {
mPolicyContentRecyclerView.setVisibility(View.GONE);
mPolicyScaledImageView.setImageResource(R.drawable.ic_arrow_drop_up_black_24dp);
} else {
mPolicyContentRecyclerView.setVisibility(View.VISIBLE);
mPolicyScaledImageView.setImageResource(R.drawable.ic_arrow_drop_down_black_24dp);
}
}
});
mPolicyCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
itemCheckedChangedListener.onItemCheckedChanged(policies.get(getAdapterPosition()), isChecked);
}
});
}
}
public interface ItemCheckedChangedListener {
void onItemCheckedChanged(PrivacyPolicy policy, boolean isChecked);
}
}
......@@ -16,7 +16,8 @@ import java.util.List;
/**
* Created by IDIC on 2017/1/20.
*/
public class ScanResultRecyclerViewAdapter extends RecyclerView.Adapter<ScanResultRecyclerViewAdapter.ViewHolder> {
public class ScanResultRecyclerViewAdapter
extends RecyclerView.Adapter<ScanResultRecyclerViewAdapter.ViewHolder> {
private static final String TAG = ScanResultRecyclerViewAdapter.class.getSimpleName();
......
package org.prlab.idic.privacypolicy.adapter;
import android.content.res.Resources;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.prlab.idic.privacypolicy.R;
import org.prlab.idic.privacypolicy.pojo.report.InfoItem;
import org.prlab.idic.privacypolicy.pojo.report.p3p.*;
import org.prlab.idic.privacypolicy.tool.BaseUtils;
import java.util.LinkedList;
import java.util.List;
/**
* Created by IDIC on 2017/2/23.
*/
public class StatementRecyclerViewAdapter extends RecyclerView.Adapter<StatementRecyclerViewAdapter.ViewHolder> {
private final String CONSEQUENCE_TITLE;
private final String PURPOSE_TYPE_TITLE;
private final String PURPOSE_DESCRIPTION_TITLE;
private final String DATUM_TYPE_TITLE;
private final String DATUM_DESCRIPTION_TITLE;
private final String REMEDIES_TITLE;
private final String RECIPIENT_TYPE_TITLE;
private final String RECIPIENT_DESCRIPTION_TITLE;
private final String RETENTION_TITLE;
private List<Statement> statements;
public StatementRecyclerViewAdapter(Resources resources, List<Statement> statements) {
CONSEQUENCE_TITLE = resources.getString(R.string.policy_statement_consequence_title);
PURPOSE_TYPE_TITLE = resources.getString(R.string.policy_statement_purpose_type);
PURPOSE_DESCRIPTION_TITLE = resources.getString(R.string.policy_statement_purpose_description);
DATUM_TYPE_TITLE = resources.getString(R.string.policy_statement_data_type);
DATUM_DESCRIPTION_TITLE = resources.getString(R.string.policy_statement_data_description);
REMEDIES_TITLE = resources.getString(R.string.policy_statement_remedies);
RECIPIENT_TYPE_TITLE = resources.getString(R.string.policy_statement_recipient_type);
RECIPIENT_DESCRIPTION_TITLE = resources.getString(R.string.policy_statement_recipient_description);
RETENTION_TITLE = resources.getString(R.string.policy_statement_retention);
this.statements = statements;
}
@Override
public StatementRecyclerViewAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_view_statement, parent, false);
return new StatementRecyclerViewAdapter.ViewHolder(view);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.bind(position);
}
@Override
public int getItemCount() {
return null == statements ? 0 : statements.size();
}
class ViewHolder extends RecyclerView.ViewHolder {
private TextView mConsequenceTextView;
private RecyclerView mPurposesRecyclerView;
private RecyclerView mDataRecyclerView;
private TextView mRemediesTextView;
private RecyclerView mRecipientsRecyclerView;
private TextView mRetentionTextView;
ViewHolder(View itemView) {
super(itemView);
mConsequenceTextView = (TextView) itemView.findViewById(R.id.recycler_view_statement_related_uuid);
mPurposesRecyclerView = (RecyclerView) itemView.findViewById(R.id.recycler_view_statement_purposes);
mDataRecyclerView = (RecyclerView) itemView.findViewById(R.id.recycler_view_statement_data);
mRemediesTextView = (TextView) itemView.findViewById(R.id.text_statement_remedies);
mRecipientsRecyclerView = (RecyclerView) itemView.findViewById(R.id.recycler_view_statement_recipients);
mRetentionTextView = (TextView) itemView.findViewById(R.id.text_statement_retention);
}
private void bindRelatedUUID(String consequence) {
mConsequenceTextView.setText(consequence);
}
private void bindPurposes(List<Purpose> purposes) {
List<InfoItem> infoItems = new LinkedList<>();
infoItems.add(new InfoItem()
.setKey(PURPOSE_TYPE_TITLE)
.setValue(PURPOSE_DESCRIPTION_TITLE));
for (Purpose purpose : purposes) {
infoItems.add(new InfoItem()
.setKey(BaseUtils.fixTypeName(purpose.getType().name()))
.setValue(purpose.getDescription()));
}
mPurposesRecyclerView.setAdapter(new InfoItemRecyclerViewAdapter(infoItems));
}
private void bindData(List<Datum> data) {
List<InfoItem> infoItems = new LinkedList<>();
infoItems.add(new InfoItem()
.setKey(DATUM_TYPE_TITLE)
.setValue(DATUM_DESCRIPTION_TITLE));
for (Datum datum : data) {
infoItems.add(new InfoItem()
.setKey(BaseUtils.fixTypeName(datum.getType().name()))
.setValue(datum.getDescription()));
}
mDataRecyclerView.setAdapter(new InfoItemRecyclerViewAdapter(infoItems));
}
private void bindRemedies(List<Remedy> remedies) {
StringBuilder builder = new StringBuilder();
for (Remedy remedy : remedies) {
builder.append(BaseUtils.fixTypeName(remedy.name())).append(", ");
}
builder.delete(builder.length() - 2, builder.length());
mRemediesTextView.setText(builder.toString());
}
private void bindRecipients(List<Recipient> recipients) {
List<InfoItem> infoItems = new LinkedList<>();
infoItems.add(new InfoItem()
.setKey(RECIPIENT_TYPE_TITLE)
.setValue(RECIPIENT_DESCRIPTION_TITLE));
for (Recipient recipient : recipients) {
infoItems.add(new InfoItem()
.setKey(BaseUtils.fixTypeName(recipient.getType().name()))
.setValue(recipient.getDescription()));
}
mRecipientsRecyclerView.setAdapter(new InfoItemRecyclerViewAdapter(infoItems));
}
private void bindRetention(Retention retention) {
mRetentionTextView.setText(BaseUtils.fixTypeName(retention.name()));
}
void bind(int listIndex) {
Statement statement = statements.get(listIndex);
bindRelatedUUID(statement.getConsequence());
bindPurposes(statement.getPurposes());
bindData(statement.getData());
bindRemedies(statement.getRemedies());
bindRecipients(statement.getRecipients());
bindRetention(statement.getRetention());
}
}
}
package org.prlab.idic.privacypolicy.adapter;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import org.prlab.idic.privacypolicy.R;
import java.util.List;
/**
* Created by IDIC on 2017/2/16.
*/
public class StringButtonRecyclerViewAdapter extends RecyclerView.Adapter<StringButtonRecyclerViewAdapter.ViewHolder> {
private ListItemClickListener listItemClickListener;
private List<String> items;
private String target;
public StringButtonRecyclerViewAdapter(ListItemClickListener listItemClickListener) {
this.listItemClickListener = listItemClickListener;
}
public void setItems(List<String> items) {
this.items = items;
notifyDataSetChanged();
}
public void setTarget(String target) {
this.target = target;
notifyItemChanged(items.indexOf(target));
}
public interface ListItemClickListener {
void onListItemClick(int clickedItemIndex);
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_view_item, parent, false);
return new StringButtonRecyclerViewAdapter.ViewHolder(view);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.bind(position);
}
@Override
public int getItemCount() {
return null != items ? items.size() : 0;
}
class ViewHolder extends RecyclerView.ViewHolder {
private Button button;
ViewHolder(View itemView) {
super(itemView);
button = (Button) itemView.findViewById(R.id.button_item);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
StringButtonRecyclerViewAdapter.this.listItemClickListener.onListItemClick(getAdapterPosition());
}
});
}
void bind(int listIndex) {
String item = items.get(listIndex);
button.setText(item);
button.setEnabled(!item.equals(target));
}
}
}
package org.prlab.idic.privacypolicy.pojo.report;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
/**
* Created by IDIC on 2017/2/22.
*/
public class Layer {
private String UUID;
private List<Integer> policies = new LinkedList<>();
private List<Layer> subLayers = new LinkedList<>();
public String getUUID() {
return UUID;
}
public Layer setUUID(String UUID) {
this.UUID = UUID;
return this;
}
public List<Integer> getPolicies() {
return policies;
}
public Layer setPolicies(List<Integer> policies) {
this.policies = policies;
return this;
}
public List<Layer> getSubLayers() {
return subLayers;
}
public Layer setSubLayers(List<Layer> subLayers) {
this.subLayers = subLayers;
return this;
}
public Layer addPrivacyPolicy(Integer policy) {
if (null != policies) this.policies.add(policy);
return this;
}
public Layer addSubLayer(Layer layer) {
if (null != subLayers) this.subLayers.add(layer);
return this;
}
public int getLayerLevel() {
if (null == subLayers || subLayers.isEmpty()) return 0;
List<Integer> counter = new LinkedList<>();
for (Layer layer : subLayers) {
counter.add(1 + layer.getLayerLevel());
}
return Collections.max(counter);
}
}
......@@ -18,6 +18,7 @@ public class PrivacyPolicy implements Parcelable {
private Collector collector;
private Dispute dispute;
private Access access;
private List<Remedy> remedies = new LinkedList<>();
private List<Statement> statements = new LinkedList<>();
public PrivacyPolicy() {
......@@ -29,6 +30,7 @@ public class PrivacyPolicy implements Parcelable {
collector = in.readParcelable(Collector.class.getClassLoader());
dispute = in.readParcelable(Dispute.class.getClassLoader());
access = in.readParcelable(Access.class.getClassLoader());
remedies = in.createTypedArrayList(Remedy.CREATOR);
statements = in.createTypedArrayList(Statement.CREATOR);
}
......@@ -56,6 +58,7 @@ public class PrivacyPolicy implements Parcelable {
dest.writeParcelable(collector, flags);
dest.writeParcelable(dispute, flags);
dest.writeParcelable(access, flags);
dest.writeTypedList(remedies);
dest.writeTypedList(statements);
}
......@@ -104,6 +107,20 @@ public class PrivacyPolicy implements Parcelable {
return this;
}
public List<Remedy> getRemedies() {
return remedies;
}
public PrivacyPolicy setRemedies(List<Remedy> remedies) {
this.remedies = remedies;
return this;
}
public PrivacyPolicy addRemedy(Remedy remedy) {
if (null != this.remedies) this.remedies.add(remedy);
return this;
}
public List<Statement> getStatements() {
return statements;
}
......@@ -117,4 +134,5 @@ public class PrivacyPolicy implements Parcelable {
if (null != this.statements) this.statements.add(statement);
return this;
}
}
......@@ -4,6 +4,8 @@ package org.prlab.idic.privacypolicy.pojo.report;
import org.prlab.idic.privacypolicy.pojo.report.device.Device;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
......@@ -11,11 +13,20 @@ import java.util.Map;
*/
public class PrivacyPolicyReport {
private String id;
private String version;
private String description;
private Device device;
private Map<Integer, PrivacyPolicy> policies = new HashMap<>();
private Layer root;
private List<PrivacyPolicy> policies = new LinkedList<>();
public String getId() {
return id;
}
public PrivacyPolicyReport setId(String id) {
this.id = id;
return this;
}
public String getVersion() {
return version;
......@@ -43,27 +54,18 @@ public class PrivacyPolicyReport {
this.device = device;
return this;
}
public Map<Integer, PrivacyPolicy> getPolicies() {
public List<PrivacyPolicy> getPolicies() {
return policies;
}
public PrivacyPolicyReport setPolicies(Map<Integer, PrivacyPolicy> policies) {
public PrivacyPolicyReport setPolicies(List<PrivacyPolicy> policies) {
this.policies = policies;
return this;
}
public PrivacyPolicyReport addPrivacyPolicy(PrivacyPolicy policy) {
if (null != policies) this.policies.put(policy.getId(), policy);
if (null != policies) this.policies.add(policy);
return this;
}
public Layer getRoot() {
return root;
}
public PrivacyPolicyReport setRoot(Layer root) {
this.root = root;
return this;
}
}
......@@ -8,6 +8,7 @@ import android.os.Parcelable;
*/
public class Manufacturer implements Parcelable {
private long id;
private String name;
private String url;
private String serialNumber;
......@@ -16,6 +17,7 @@ public class Manufacturer implements Parcelable {
}
private Manufacturer(Parcel in) {
id = in.readLong();
name = in.readString();
url = in.readString();
serialNumber = in.readString();
......@@ -28,6 +30,7 @@ public class Manufacturer implements Parcelable {
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(id);
dest.writeString(name);
dest.writeString(url);
dest.writeString(serialNumber);
......@@ -45,6 +48,15 @@ public class Manufacturer implements Parcelable {
}
};
public long getId() {
return id;
}
public Manufacturer setId(long id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
......@@ -79,16 +91,20 @@ public class Manufacturer implements Parcelable {
Manufacturer that = (Manufacturer) o;
if (id != that.id) return false;
if (name != null ? !name.equals(that.name) : that.name != null) return false;
if (url != null ? !url.equals(that.url) : that.url != null) return false;
return serialNumber != null ? serialNumber.equals(that.serialNumber) : that.serialNumber == null;
}
@Override
public int hashCode() {
int result = name != null ? name.hashCode() : 0;
int result = (int) (id ^ (id >>> 32));
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (url != null ? url.hashCode() : 0);
result = 31 * result + (serialNumber != null ? serialNumber.hashCode() : 0);
return result;
}
}
......@@ -8,6 +8,7 @@ import android.os.Parcelable;
*/
public class Model implements Parcelable{
private long id;
private String name;
private String url;
private String description;
......@@ -16,6 +17,7 @@ public class Model implements Parcelable{
}
private Model(Parcel in) {
id = in.readLong();
name = in.readString();
url = in.readString();
description = in.readString();
......@@ -28,6 +30,7 @@ public class Model implements Parcelable{
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(id);
dest.writeString(name);
dest.writeString(url);
dest.writeString(description);
......@@ -45,6 +48,15 @@ public class Model implements Parcelable{
}
};
public long getId() {
return id;
}
public Model setId(long id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
......@@ -79,16 +91,20 @@ public class Model implements Parcelable{
Model model = (Model) o;
if (id != model.id) return false;
if (name != null ? !name.equals(model.name) : model.name != null) return false;
if (url != null ? !url.equals(model.url) : model.url != null) return false;
return description != null ? description.equals(model.description) : model.description == null;
}
@Override
public int hashCode() {
int result = name != null ? name.hashCode() : 0;
int result = (int) (id ^ (id >>> 32));
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (url != null ? url.hashCode() : 0);
result = 31 * result + (description != null ? description.hashCode() : 0);
return result;
}
}
......@@ -8,6 +8,7 @@ import android.os.Parcelable;
*/
public class Collector implements Parcelable {
private long id;
private String name;
private String phone;
private String email;
......@@ -16,6 +17,7 @@ public class Collector implements Parcelable {
}
protected Collector(Parcel in) {
id = in.readLong();
name = in.readString();
phone = in.readString();
email = in.readString();
......@@ -33,6 +35,28 @@ public class Collector implements Parcelable {
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(id);
dest.writeString(name);
dest.writeString(phone);
dest.writeString(email);
}
public long getId() {
return id;
}
public Collector setId(long id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
......@@ -67,28 +91,19 @@ public class Collector implements Parcelable {
Collector collector = (Collector) o;
if (id != collector.id) return false;
if (name != null ? !name.equals(collector.name) : collector.name != null) return false;
if (phone != null ? !phone.equals(collector.phone) : collector.phone != null) return false;
return email != null ? email.equals(collector.email) : collector.email == null;
}
@Override
public int hashCode() {
int result = name != null ? name.hashCode() : 0;
int result = (int) (id ^ (id >>> 32));
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (phone != null ? phone.hashCode() : 0);
result = 31 * result + (email != null ? email.hashCode() : 0);
return result;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(name);
dest.writeString(phone);
dest.writeString(email);
}
}
......@@ -3,11 +3,14 @@ package org.prlab.idic.privacypolicy.pojo.report.p3p;
import android.os.Parcel;
import android.os.Parcelable;
import org.prlab.idic.privacypolicy.pojo.report.device.Model;
/**
* Created by IDIC on 2017/2/16.
*/
public class Datum implements Parcelable {
private long id;
private Type type;
private String description;
......@@ -15,6 +18,7 @@ public class Datum implements Parcelable {
}
private Datum(Parcel in) {
id = in.readLong();
description = in.readString();
type = Type.valueOf(in.readString());
}
......@@ -38,10 +42,20 @@ public class Datum implements Parcelable {
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(id);
dest.writeString(description);
dest.writeString(type.name());
}
public long getId() {
return id;
}
public Datum setId(long id) {
this.id = id;
return this;
}
public Type getType() {
return type;
}
......@@ -74,14 +88,18 @@ public class Datum implements Parcelable {
Datum datum = (Datum) o;
if (id != datum.id) return false;
if (type != datum.type) return false;
return description != null ? description.equals(datum.description) : datum.description == null;
}
@Override
public int hashCode() {
int result = type != null ? type.hashCode() : 0;
int result = (int) (id ^ (id >>> 32));
result = 31 * result + (type != null ? type.hashCode() : 0);
result = 31 * result + (description != null ? description.hashCode() : 0);
return result;
}
}
......@@ -8,6 +8,7 @@ import android.os.Parcelable;
*/
public class Dispute implements Parcelable {
private long id;
private String relatedOrganization;
private Type type;
......@@ -15,6 +16,7 @@ public class Dispute implements Parcelable {
}
protected Dispute(Parcel in) {
id = in.readLong();
relatedOrganization = in.readString();
type = Type.valueOf(in.readString());
}
......@@ -26,6 +28,7 @@ public class Dispute implements Parcelable {
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(id);
dest.writeString(relatedOrganization);
dest.writeString(type.name());
}
......@@ -42,6 +45,14 @@ public class Dispute implements Parcelable {
}
};
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getRelatedOrganization() {
return relatedOrganization;
}
......@@ -71,14 +82,17 @@ public class Dispute implements Parcelable {
Dispute dispute = (Dispute) o;
if (id != dispute.id) return false;
if (relatedOrganization != null ? !relatedOrganization.equals(dispute.relatedOrganization) : dispute.relatedOrganization != null)
return false;
return type == dispute.type;
}
@Override
public int hashCode() {
int result = relatedOrganization != null ? relatedOrganization.hashCode() : 0;
int result = (int) (id ^ (id >>> 32));
result = 31 * result + (relatedOrganization != null ? relatedOrganization.hashCode() : 0);
result = 31 * result + (type != null ? type.hashCode() : 0);
return result;
}
......
......@@ -8,6 +8,7 @@ import android.os.Parcelable;
*/
public class Purpose implements Parcelable {
private long id;
private Type type;
private String description;
......@@ -15,6 +16,7 @@ public class Purpose implements Parcelable {
}
protected Purpose(Parcel in) {
id = in.readLong();
description = in.readString();
type = Type.valueOf(in.readString());
}
......@@ -38,10 +40,19 @@ public class Purpose implements Parcelable {
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(id);
dest.writeString(description);
dest.writeString(type.name());
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public Type getType() {
return type;
}
......@@ -73,14 +84,18 @@ public class Purpose implements Parcelable {
Purpose purpose = (Purpose) o;
if (id != purpose.id) return false;
if (type != purpose.type) return false;
return description != null ? description.equals(purpose.description) : purpose.description == null;
}
@Override
public int hashCode() {
int result = type != null ? type.hashCode() : 0;
int result = (int) (id ^ (id >>> 32));
result = 31 * result + (type != null ? type.hashCode() : 0);
result = 31 * result + (description != null ? description.hashCode() : 0);
return result;
}
}
......@@ -3,11 +3,14 @@ package org.prlab.idic.privacypolicy.pojo.report.p3p;
import android.os.Parcel;
import android.os.Parcelable;
import org.prlab.idic.privacypolicy.pojo.report.device.Model;
/**
* Created by IDIC on 2017/2/16.
*/
public class Recipient implements Parcelable {
private long id;
private Type type;
private String description;
......@@ -15,6 +18,7 @@ public class Recipient implements Parcelable {
}
private Recipient(Parcel in) {
id = in.readLong();
description = in.readString();
type = Type.valueOf(in.readString());
}
......@@ -38,10 +42,20 @@ public class Recipient implements Parcelable {
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(id);
dest.writeString(description);
dest.writeString(type.name());
}
public long getId() {
return id;
}
public Recipient setId(long id) {
this.id = id;
return this;
}
public Type getType() {
return type;
}
......@@ -71,13 +85,16 @@ public class Recipient implements Parcelable {
Recipient recipient = (Recipient) o;
if (id != recipient.id) return false;
if (type != recipient.type) return false;
return description != null ? description.equals(recipient.description) : recipient.description == null;
}
@Override
public int hashCode() {
int result = type != null ? type.hashCode() : 0;
int result = (int) (id ^ (id >>> 32));
result = 31 * result + (type != null ? type.hashCode() : 0);
result = 31 * result + (description != null ? description.hashCode() : 0);
return result;
}
......
......@@ -6,15 +6,23 @@ import android.os.Parcelable;
/**
* Created by IDIC on 2017/2/16.
*/
public enum Remedy implements Parcelable {
CORRECT, MONEY, LAW;
public class Remedy implements Parcelable {
Remedy() {
private long id;
private Type type;
public Remedy() {
}
private Remedy(Parcel in) {
id = in.readLong();
type = Type.valueOf(in.readString());
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(name());
dest.writeLong(id);
dest.writeString(type.name());
}
@Override
......@@ -25,7 +33,7 @@ public enum Remedy implements Parcelable {
public static final Creator<Remedy> CREATOR = new Creator<Remedy>() {
@Override
public Remedy createFromParcel(Parcel in) {
return Remedy.valueOf(in.readString());
return new Remedy(in);
}
@Override
......@@ -33,4 +41,27 @@ public enum Remedy implements Parcelable {
return new Remedy[size];
}
};
public long getId() {
return id;
}
public Remedy setId(long id) {
this.id = id;
return this;
}
public Type getType() {
return type;
}
public Remedy setType(Type type) {
this.type = type;
return this;
}
public enum Type {
CORRECT, MONEY, LAW
}
}
......@@ -11,22 +11,20 @@ import java.util.List;
*/
public class Statement implements Parcelable {
private long id;
private String consequence;
private List<Purpose> purposes = new LinkedList<>();
private List<Datum> data = new LinkedList<>();
private List<Recipient> recipients = new LinkedList<>();
private List<Remedy> remedies = new LinkedList<>();
private Retention retention;
public Statement() {
}
private Statement(Parcel in) {
id = in.readLong();
consequence = in.readString();
purposes = in.createTypedArrayList(Purpose.CREATOR);
data = in.createTypedArrayList(Datum.CREATOR);
recipients = in.createTypedArrayList(Recipient.CREATOR);
remedies = in.createTypedArrayList(Remedy.CREATOR);
retention = in.readParcelable(Retention.class.getClassLoader());
}
......@@ -49,14 +47,23 @@ public class Statement implements Parcelable {
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(id);
dest.writeString(consequence);
dest.writeTypedList(purposes);
dest.writeTypedList(data);
dest.writeTypedList(recipients);
dest.writeTypedList(remedies);
dest.writeParcelable(retention, flags);
}
public long getId() {
return id;
}
public Statement setId(long id) {
this.id = id;
return this;
}
public String getConsequence() {
return consequence;
}
......@@ -108,20 +115,6 @@ public class Statement implements Parcelable {
return this;
}
public List<Remedy> getRemedies() {
return remedies;
}
public Statement setRemedies(List<Remedy> remedies) {
this.remedies = remedies;
return this;
}
public Statement addRemedy(Remedy remedy) {
if (null != this.remedies) this.remedies.add(remedy);
return this;
}
public Retention getRetention() {
return retention;
}
......@@ -143,7 +136,6 @@ public class Statement implements Parcelable {
if (purposes != null ? !purposes.equals(statement.purposes) : statement.purposes != null) return false;
if (data != null ? !data.equals(statement.data) : statement.data != null) return false;
if (recipients != null ? !recipients.equals(statement.recipients) : statement.recipients != null) return false;
if (remedies != null ? !remedies.equals(statement.remedies) : statement.remedies != null) return false;
return retention == statement.retention;
}
......@@ -153,7 +145,6 @@ public class Statement implements Parcelable {
result = 31 * result + (purposes != null ? purposes.hashCode() : 0);
result = 31 * result + (data != null ? data.hashCode() : 0);
result = 31 * result + (recipients != null ? recipients.hashCode() : 0);
result = 31 * result + (remedies != null ? remedies.hashCode() : 0);
result = 31 * result + (retention != null ? retention.hashCode() : 0);
return result;
}
......
......@@ -14,6 +14,9 @@ public class PrivacyPolicyContract {
public static final String PATH_PRIVACY_POLICY = "privacy_policy";
public static final String DECLINE = "decline";
public static final String ACCEPT = "accept";
public static final class PolicyEntry implements BaseColumns {
public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon()
......@@ -23,19 +26,9 @@ public class PrivacyPolicyContract {
public static final String TABLE_NAME = "policies";
public static final String COLUMN_MAC = "mac";
public static final String COLUMN_UUIDs = "uuid";
public static final String COLUMN_POLICY = "policy";
public static final String COLUMN_PREFERENCE = "preference";
}
public static String getSqlSelectForMACAndUUIDsOnwards() {
return PolicyEntry.COLUMN_MAC + " = ? " + " AND " +
PolicyEntry.COLUMN_UUIDs + " = ? ";
}
public static String getSqlSelectForMACAndRelatedUUIDsOnwards() {
return PolicyEntry.COLUMN_MAC + " = ? " + " AND " +
PolicyEntry.COLUMN_UUIDs + " LIKE ? ";
}
}
......@@ -20,8 +20,10 @@ class PrivacyPolicyDbHelper extends SQLiteOpenHelper {
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + PrivacyPolicyContract.PolicyEntry.TABLE_NAME + " (" +
PrivacyPolicyContract.PolicyEntry.COLUMN_MAC + " CHAR(12) NOT NULL, " +
PrivacyPolicyContract.PolicyEntry.COLUMN_UUIDs + " TEXT NOT NULL, " +
PrivacyPolicyContract.PolicyEntry.COLUMN_PREFERENCE + " TEXT);");
PrivacyPolicyContract.PolicyEntry.COLUMN_POLICY + " TEXT NOT NULL, " +
PrivacyPolicyContract.PolicyEntry.COLUMN_PREFERENCE + " INTEGER, " +
"PRIMARY KEY(" + PrivacyPolicyContract.PolicyEntry.COLUMN_MAC + ", " +
PrivacyPolicyContract.PolicyEntry.COLUMN_POLICY + "));");
}
@Override
......
......@@ -51,7 +51,8 @@ public class PrivacyPolicyProvider extends ContentProvider {
default:
throw new UnsupportedOperationException("Unknown uri: " + uri);
}
cursor.setNotificationUri(getContext().getContentResolver(), uri);
if (getContext() != null)
cursor.setNotificationUri(getContext().getContentResolver(), uri);
return cursor;
}
......@@ -72,7 +73,8 @@ public class PrivacyPolicyProvider extends ContentProvider {
db.setTransactionSuccessful();
Uri curr = ContentUris.withAppendedId(PrivacyPolicyContract.PolicyEntry.CONTENT_URI, _id);
//將新插入的資料uri進行通知,以便獲取最新的資料
getContext().getContentResolver().notifyChange(curr, null);
if (getContext() != null)
getContext().getContentResolver().notifyChange(curr, null);
return curr;
} finally {
db.endTransaction();
......@@ -112,7 +114,7 @@ public class PrivacyPolicyProvider extends ContentProvider {
db.endTransaction();
/* If we actually deleted any rows, notify that a change has occurred to this URI */
if (numRowsDeleted != 0) {
if (numRowsDeleted != 0 && getContext() != null) {
getContext().getContentResolver().notifyChange(uri, null);
}
......@@ -136,7 +138,8 @@ public class PrivacyPolicyProvider extends ContentProvider {
default:
throw new UnsupportedOperationException("Unknown uri: " + uri);
}
getContext().getContentResolver().notifyChange(uri, null);
if (getContext() != null)
getContext().getContentResolver().notifyChange(uri, null);
return count;
}
......
......@@ -13,6 +13,9 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import static org.prlab.idic.privacypolicy.storage.PrivacyPolicyContract.ACCEPT;
import static org.prlab.idic.privacypolicy.storage.PrivacyPolicyContract.DECLINE;
/**
* Created by IDIC on 2017/2/15.
*/
......@@ -25,12 +28,12 @@ public class PrivacyPolicyStorageImpl implements StorageInterface<Integer, Strin
private static final String[] PRIVACY_POLICY_PROJECTION = {
PrivacyPolicyContract.PolicyEntry.COLUMN_MAC,
PrivacyPolicyContract.PolicyEntry.COLUMN_UUIDs,
PrivacyPolicyContract.PolicyEntry.COLUMN_POLICY,
PrivacyPolicyContract.PolicyEntry.COLUMN_PREFERENCE
};
public static final int INDEX_POLICY_MAC = 0;
public static final int INDEX_POLICY_UUIDs = 1;
public static final int INDEX_POLICY_POLICY = 1;
public static final int INDEX_POLICY_PREFERENCE = 2;
public PrivacyPolicyStorageImpl(ContentResolver contentResolver, String targetDeviceMAC) {
......@@ -39,139 +42,60 @@ public class PrivacyPolicyStorageImpl implements StorageInterface<Integer, Strin
}
@Override
public StorageInterface remove(List<String> layerUUIDs) {
remove(BaseUtils.stringList2ArrayString(layerUUIDs));
public StorageInterface decline(Integer id) {
choose(id, DECLINE);
return this;
}
private void remove(String layerUUIDs) {
int impactRow = mContentResolver.delete(
PrivacyPolicyContract.PolicyEntry.CONTENT_URI,
PrivacyPolicyContract.getSqlSelectForMACAndUUIDsOnwards(),
new String[]{mTargetDeviceMAC, layerUUIDs}
);
removeChildLayerPolicies(layerUUIDs);
Log.i(TAG, "Remove [" + layerUUIDs + "] " + (impactRow == 1 ? "success" : "failure") + ".");
}
private void removeChildLayerPolicies(String layerUUIDs) {
List<String> subUUIDs = getRelatedUUIDs(true, layerUUIDs);
for (String subUUID : subUUIDs) {
remove(subUUID);
}
}
@Override
public StorageInterface put(List<Integer> selection, List<String> layerUUIDs) {
put(selection, BaseUtils.stringList2ArrayString(layerUUIDs));
public StorageInterface accept(Integer id) {
choose(id, ACCEPT);
return this;
}
private void put(List<Integer> selection, String layerUUIDs) {
for (int s : selection) {
private void choose(Integer id, String choice) {
ContentValues insertContentValues = new ContentValues();
insertContentValues.put(PrivacyPolicyContract.PolicyEntry.COLUMN_MAC, mTargetDeviceMAC);
insertContentValues.put(PrivacyPolicyContract.PolicyEntry.COLUMN_POLICY, id);
insertContentValues.put(PrivacyPolicyContract.PolicyEntry.COLUMN_PREFERENCE, choice);
Uri newUri = mContentResolver.insert(
PrivacyPolicyContract.PolicyEntry.CONTENT_URI,
insertContentValues
);
if (newUri == null) {
ContentValues updateContentValues = new ContentValues();
updateContentValues.put(PrivacyPolicyContract.PolicyEntry.COLUMN_PREFERENCE, s);
updateContentValues.put(PrivacyPolicyContract.PolicyEntry.COLUMN_PREFERENCE, choice);
ContentValues insertContentValues = new ContentValues(updateContentValues);
insertContentValues.put(PrivacyPolicyContract.PolicyEntry.COLUMN_MAC, mTargetDeviceMAC);
insertContentValues.put(PrivacyPolicyContract.PolicyEntry.COLUMN_UUIDs, layerUUIDs);
Uri mNewUri = mContentResolver.insert(
int count = mContentResolver.update(
PrivacyPolicyContract.PolicyEntry.CONTENT_URI,
insertContentValues
updateContentValues,
PrivacyPolicyContract.PolicyEntry.COLUMN_MAC + " = ? " + " AND " +
PrivacyPolicyContract.PolicyEntry.COLUMN_POLICY + " = ? " + " AND " +
PrivacyPolicyContract.PolicyEntry.COLUMN_PREFERENCE + " = ? ",
new String[]{mTargetDeviceMAC, String.valueOf(id), choice}
);
if (mNewUri == null) {
int count = mContentResolver.update(
PrivacyPolicyContract.PolicyEntry.CONTENT_URI,
updateContentValues,
PrivacyPolicyContract.getSqlSelectForMACAndUUIDsOnwards(),
new String[]{mTargetDeviceMAC, layerUUIDs}
);
Log.i(TAG, "Update " + String.valueOf(s) + " to [" + layerUUIDs + "] " + (count == 1 ? "success" : "failure") + ".");
} else {
Log.i(TAG, "Put " + String.valueOf(s) + " to [" + layerUUIDs + "] success.");
}
removeChildLayerPolicies(layerUUIDs);
Log.i(TAG, "Update " + String.valueOf(choice) + " to [" + id + "] " + (count == 1 ? "success" : "failure") + ".");
} else {
Log.i(TAG, "Put " + String.valueOf(choice) + " to [" + id + "] success.");
}
}
@Override
public List<Integer> get(List<String> layerUUIDs) {
return get(BaseUtils.stringList2ArrayString(layerUUIDs));
}
private List<Integer> get(String UUIDs) {
try (Cursor cursor = mContentResolver.query(
PrivacyPolicyContract.PolicyEntry.CONTENT_URI,
public String get(Integer id) {
String result = null;
try (Cursor cursor = mContentResolver.query(PrivacyPolicyContract.PolicyEntry.CONTENT_URI,
PRIVACY_POLICY_PROJECTION,
PrivacyPolicyContract.getSqlSelectForMACAndUUIDsOnwards(),
new String[]{mTargetDeviceMAC, UUIDs},
PrivacyPolicyContract.PolicyEntry.COLUMN_UUIDs + " ASC")) {
List<Integer> targets = new LinkedList<>();
Set<Integer> targetSet = new HashSet<>();
if (cursor != null && cursor.getCount() > 0) {
PrivacyPolicyContract.PolicyEntry.COLUMN_MAC + " = ? " + " AND " +
PrivacyPolicyContract.PolicyEntry.COLUMN_POLICY + " = ? ",
new String[]{mTargetDeviceMAC, String.valueOf(id)},
null)) {
if (cursor != null && cursor.getCount() == 1) {
cursor.moveToFirst();
do {
String target = cursor.getString(INDEX_POLICY_PREFERENCE);
Log.i(TAG, "Get [" + UUIDs + "] -> [" + String.valueOf(target) + "]");
if (target == null) return null;
targetSet.add(Integer.valueOf(target));
} while (cursor.moveToNext());
}
targetSet.addAll(getChildLayerPolicies(UUIDs));
targets.addAll(targetSet);
Log.i(TAG, "Get [" + UUIDs + "] -> null");
return targets;
}
}
private List<Integer> getChildLayerPolicies(String layerUUIDs) {
List<Integer> selections = new LinkedList<>();
List<Integer> selectionSet = new LinkedList<>();
List<String> subUUIDs = getRelatedUUIDs(true, layerUUIDs);
for (String subUUID : subUUIDs) {
List<Integer> subSelections = get(subUUID);
if (subSelections != null)
selectionSet.addAll(subSelections);
}
selections.addAll(selectionSet);
return selections;
}
private List<String> getRelatedUUIDs(boolean isLower, String UUIDs) {
List<String> UUIDList = new LinkedList<>();
if (isLower) {
try (Cursor cursor = mContentResolver.query(
PrivacyPolicyContract.PolicyEntry.CONTENT_URI,
PRIVACY_POLICY_PROJECTION,
PrivacyPolicyContract.getSqlSelectForMACAndRelatedUUIDsOnwards(),
new String[]{mTargetDeviceMAC, UUIDs + "_%"},
PrivacyPolicyContract.PolicyEntry.COLUMN_UUIDs + " ASC")) {
if (cursor != null)
while (cursor.moveToNext()) {
String targetUUIDs = cursor.getString(INDEX_POLICY_UUIDs);
UUIDList.add(targetUUIDs);
}
}
} else {
if (UUIDs.contains(", ")) {
UUIDs = UUIDs.substring(0, UUIDs.lastIndexOf(", "));
try (Cursor cursor = mContentResolver.query(
PrivacyPolicyContract.PolicyEntry.CONTENT_URI,
PRIVACY_POLICY_PROJECTION,
PrivacyPolicyContract.getSqlSelectForMACAndRelatedUUIDsOnwards(),
new String[]{mTargetDeviceMAC, "%" + UUIDs},
PrivacyPolicyContract.PolicyEntry.COLUMN_UUIDs + " ASC")) {
if (cursor != null)
while (cursor.moveToNext()) {
String targetUUIDs = cursor.getString(INDEX_POLICY_UUIDs);
UUIDList.add(targetUUIDs);
}
}
result = cursor.getString(INDEX_POLICY_PREFERENCE);
}
}
return UUIDList;
return result;
}
}
......@@ -5,12 +5,12 @@ import java.util.List;
/**
* Created by IDIC on 2017/2/15.
*/
interface StorageInterface<Result, Key> {
interface StorageInterface<Key, Result> {
StorageInterface remove(List<Key> layerUUIDs);
StorageInterface decline(Key id);
StorageInterface put(List<Result> choices, List<Key> layerUUIDs);
StorageInterface accept(Key id);
List<Result> get(List<Key> layerUUIDs);
Result get(Key id);
}
package org.prlab.idic.privacypolicy.tool;
import org.prlab.idic.privacypolicy.pojo.report.Layer;
import org.prlab.idic.privacypolicy.pojo.report.p3p.Remedy;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
/**
......@@ -41,18 +39,18 @@ public class BaseUtils {
return bite & 0xFF;
}
public static String convertRemedies2String(List<Remedy> enums) {
if (enums.size() <= 0) return "";
private static final String SPLIT_STRING = ", ";
public static String convertRemedies2String(List<Remedy> remedies) {
if (remedies.size() <= 0) return "";
StringBuilder builder = new StringBuilder();
for (Enum e : enums) {
builder.append(e.name()).append(", ");
for (Remedy remedy : remedies) {
builder.append(remedy.getType().name()).append(SPLIT_STRING);
}
builder.delete(builder.length() - 2, builder.length());
return builder.toString();
}
private static final String SPLIT_STRING = ", ";
public static List<String> arrayString2stringArray(String arrayString) {
return BaseUtils.arrayString2objectArray(arrayString, new BaseUtils.ObjectConverter<String>() {
@Override
......@@ -116,14 +114,6 @@ public class BaseUtils {
return builder.toString();
}
public static List<String> layer2UUID(List<Layer> layers) {
List<String> UUIDs = new LinkedList<>();
if (null == layers || layers.isEmpty()) return UUIDs;
for (Layer layer : layers)
UUIDs.add(layer.getUUID());
return UUIDs;
}
public static byte[] int2Bytes(int i) {
return ByteBuffer.allocate(4).putInt(i).array();
}
......
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="@color/colorPrimaryDark"
android:pathData="M7,10l5,5 5,-5z"/>
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="@color/colorPrimaryDark"
android:pathData="M7,14l5,-5 5,5z"/>
</vector>
......@@ -4,36 +4,21 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/activity_horizontal_margin"
android:orientation="vertical">
<Button
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:id="@+id/button_device_back"
android:layout_width="@dimen/button_width_size"
android:layout_height="@dimen/item_size"
android:layout_gravity="center"
android:layout_marginBottom="@dimen/median_size"
android:layout_marginTop="@dimen/median_size"
android:onClick="onBackButtonClick"
android:text="@string/message_back"
android:textSize="@dimen/font_bigger_size" />
<android.support.v7.widget.RecyclerView
android:layout_above="@id/button_device_back"
android:id="@+id/layout_device_info"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
tools:listitem="@layout/recycler_view_item_horizontally" />
<android.support.v7.widget.RecyclerView
android:layout_above="@id/button_device_back"
android:id="@+id/layout_device_icon"
android:layout_below="@+id/layout_device_info"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:layout_height="wrap_content"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
tools:listitem="@layout/recycler_view_icon" />
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_alignParentBottom="true"
android:id="@+id/layout_policy_choose_buttons"
android:gravity="center"
android:orientation="horizontal"
android:paddingTop="@dimen/small_size"
android:paddingBottom="@dimen/small_size"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:text="@string/message_agree"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:onClick="onAgreeButtonClick"
android:textSize="@dimen/font_bigger_size"
android:layout_width="@dimen/button_width_size"
android:layout_height="@dimen/item_size"/>
<Button
android:text="@string/message_deny"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:onClick="onDenyButtonClick"
android:textSize="@dimen/font_bigger_size"
android:layout_width="@dimen/button_width_size"
android:layout_height="@dimen/item_size"/>
</LinearLayout>
<ScrollView
android:layout_alignParentTop="true"
android:layout_above="@id/layout_policy_choose_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:text="@string/policy_statement_collector_title"
android:gravity="center_vertical"
android:textSize="@dimen/font_bigger_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view_statement_collector"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
tools:listitem="@layout/recycler_view_item_horizontally"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<View
android:background="@color/colorSeparator"
android:layout_width="match_parent"
android:layout_height="1dp"/>
<TextView
android:text="@string/policy_statement_access_title"
android:gravity="center_vertical"
android:textSize="@dimen/font_bigger_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_marginTop="@dimen/small_size"
android:id="@+id/recycler_view_statement_access"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<View
android:background="@color/colorSeparator"
android:layout_width="match_parent"
android:layout_height="1dp"/>
<TextView
android:text="@string/policy_statement_dispute_title"
android:gravity="center_vertical"
android:textSize="@dimen/font_bigger_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view_statement_dispute"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
tools:listitem="@layout/recycler_view_item_horizontally"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<View
android:background="@color/colorSeparator"
android:layout_width="match_parent"
android:layout_height="1dp"/>
<TextView
android:text="@string/policy_statement_title"
android:gravity="center_vertical"
android:textSize="@dimen/font_bigger_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.v7.widget.RecyclerView
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
tools:listitem="@layout/recycler_view_statement"
android:id="@+id/recycler_view_statement_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_margin="@dimen/activity_horizontal_margin"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/activity_horizontal_margin"
android:orientation="vertical">
<TextView
android:id="@+id/text_report_title"
android:text="@string/policy_information_title"
android:gravity="center_vertical"
android:textSize="@dimen/font_bigger_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_below="@id/text_report_title"
android:id="@+id/layout_report_info"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
android:id="@+id/item_report_version"
layout="@layout/item_key_value_horizontally"/>
<include
android:id="@+id/item_report_description"
layout="@layout/item_key_value_horizontally"/>
</LinearLayout>
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="@string/policy_information_title"
android:textSize="@dimen/font_bigger_size" />
<Button
android:id="@+id/button_report_device"
android:onClick="onDeviceInfoButtonClicked"
android:layout_below="@id/layout_report_info"
android:text="@string/policy_report_device_information"
android:textSize="@dimen/font_middle_size"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view_report_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
tools:listitem="@layout/recycler_view_item_horizontally" />
<Button
android:id="@+id/button_report_back"
android:onClick="onBackButtonClicked"
android:visibility="gone"
android:layout_alignParentBottom="true"
android:text="@string/message_back"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:textSize="@dimen/font_bigger_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:onClick="onDeviceInfoButtonClicked"
android:text="@string/policy_report_device_information"
android:textSize="@dimen/font_middle_size" />
<LinearLayout
android:orientation="vertical"
android:layout_below="@id/button_report_device"
android:layout_above="@id/button_report_back"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_marginTop="@dimen/median_size"
android:text="@string/message_collect_data"
android:id="@+id/text_report_policies_title"
android:gravity="center_vertical"
android:textSize="@dimen/font_bigger_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/button_report_reset"
android:text="@string/message_reset"
android:textSize="@dimen/font_middle_size"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.v7.widget.RecyclerView
tools:listitem="@layout/recycler_view_item"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
android:id="@+id/recycler_view_report_policies"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0dp"/>
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_marginTop="@dimen/median_size"
android:text="@string/message_more_detail"
android:id="@+id/text_report_child_layers_title"
android:gravity="center_vertical"
android:textSize="@dimen/font_bigger_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:id="@+id/text_report_policies_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/median_size"
android:gravity="center_vertical"
android:text="@string/message_collect_data"
android:textSize="@dimen/font_bigger_size" />
<android.support.v7.widget.RecyclerView
tools:listitem="@layout/recycler_view_item"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
android:id="@+id/recycler_view_report_child_layers"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"/>
android:id="@+id/recycler_view_report_policies"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
tools:listitem="@layout/recycler_view_policy" />
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
tools:text="key"
android:gravity="center"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:id="@+id/text_key"
android:textSize="@dimen/font_middle_size"
android:minHeight="@dimen/small_item_size"
android:layout_width="@dimen/text_key_size"
android:layout_height="wrap_content"/>
<TextView
tools:text="value"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:id="@+id/text_value"
android:layout_marginStart="@dimen/median_size"
android:layout_toEndOf="@id/text_key"
android:layout_alignParentEnd="true"
android:textSize="@dimen/font_middle_size"
android:minHeight="@dimen/small_item_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_marginStart="@dimen/activity_vertical_margin"
android:layout_marginEnd="@dimen/activity_vertical_margin"
tools:text="key"
android:gravity="center_vertical"
android:layout_alignParentStart="true"
android:id="@+id/text_key"
android:textSize="@dimen/font_normal_size"
android:minHeight="@dimen/small_item_size"
android:layout_width="@dimen/text_key_size"
android:layout_height="wrap_content"/>
<TextView
tools:text="value"
android:gravity="center_vertical"
android:id="@+id/text_value"
android:layout_marginStart="@dimen/median_size"
android:layout_toEndOf="@id/text_key"
android:layout_alignParentEnd="true"
android:textSize="@dimen/font_normal_size"
android:minHeight="@dimen/small_item_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
tools:text="12345678-1234-1234-1234-12345678"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:id="@+id/button_child_policy"
android:textSize="@dimen/font_normal_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
tools:text="111111111111-1111-1111-1111-111111111111111111"
android:gravity="center"
android:id="@+id/button_item"
android:textSize="@dimen/font_middle_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_marginTop="@dimen/small_size"
android:layout_width="match_parent"
android:layout_height="wrap_content">
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
android:id="@+id/item_info"
layout="@layout/item_key_value_horizontally"/>
<TextView
android:id="@+id/text_key"
android:layout_width="@dimen/text_key_size"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/activity_empty_margin"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:gravity="center_vertical|start"
android:minHeight="@dimen/small_item_size"
android:textSize="@dimen/font_middle_size"
tools:text="key" />
<TextView
android:id="@+id/text_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_toEndOf="@id/text_key"
android:gravity="center_vertical"
android:minHeight="@dimen/small_item_size"
android:textSize="@dimen/font_middle_size"
tools:text="value" />
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/median_size"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/median_size">
<Switch
android:id="@+id/switch_policy_accept"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:gravity="center" />
<ImageView
android:src="@drawable/ic_arrow_drop_up_black_24dp"
android:id="@+id/image_view_policy_scaled"
android:layout_width="@dimen/small_item_size"
android:layout_height="@dimen/small_item_size"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_below="@id/switch_policy_accept"/>
<TextView
android:id="@+id/text_policy_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_toStartOf="@id/switch_policy_accept"
android:textColor="@color/colorText"
android:textSize="@dimen/font_bigger_size"
android:textStyle="bold"
tools:text="Policy1" />
<TextView
android:id="@+id/text_policy_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/text_policy_title"
android:layout_toStartOf="@id/switch_policy_accept"
android:textSize="@dimen/font_middle_size"
tools:text="Description" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view_policy_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/median_size"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_empty_margin"
android:visibility="gone"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
tools:listitem="@layout/recycler_view_item_horizontally" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/line_size"
android:background="@color/colorSeparator" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_empty_margin">
<TextView
android:id="@+id/text_key"
android:layout_width="@dimen/text_key_size"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:gravity="center_vertical|start"
android:textSize="@dimen/font_normal_size"
tools:text="key" />
<TextView
android:id="@+id/text_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginStart="@dimen/median_size"
android:layout_marginEnd="@dimen/activity_empty_margin"
android:layout_toEndOf="@id/text_key"
android:gravity="center_vertical"
android:textSize="@dimen/font_normal_size"
tools:text="value" />
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:text="@string/policy_statement_consequence_title"
android:gravity="center_vertical"
android:textSize="@dimen/font_middle_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_marginTop="@dimen/small_size"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/recycler_view_statement_related_uuid"/>
<View
android:background="@color/colorSeparator"
android:layout_width="match_parent"
android:layout_height="1dp"/>
<TextView
android:text="@string/policy_statement_purpose_title"
android:gravity="center_vertical"
android:textSize="@dimen/font_middle_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view_statement_purposes"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
tools:listitem="@layout/recycler_view_item_horizontally"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<View
android:background="@color/colorSeparator"
android:layout_width="match_parent"
android:layout_height="1dp"/>
<TextView
android:text="@string/policy_statement_data_title"
android:gravity="center_vertical"
android:textSize="@dimen/font_middle_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view_statement_data"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
tools:listitem="@layout/recycler_view_item_horizontally"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<View
android:background="@color/colorSeparator"
android:layout_width="match_parent"
android:layout_height="1dp"/>
<TextView
android:text="@string/policy_statement_remedies"
android:gravity="center_vertical"
android:textSize="@dimen/font_middle_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
tools:text="123"
android:gravity="center"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/text_statement_remedies"/>
<View
android:background="@color/colorSeparator"
android:layout_width="match_parent"
android:layout_height="1dp"/>
<TextView
android:text="@string/policy_statement_recipient_title"
android:gravity="center_vertical"
android:textSize="@dimen/font_middle_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view_statement_recipients"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
tools:listitem="@layout/recycler_view_item_horizontally"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<View
android:background="@color/colorSeparator"
android:layout_width="match_parent"
android:layout_height="1dp"/>
<TextView
android:text="@string/policy_statement_retention"
android:gravity="center_vertical"
android:textSize="@dimen/font_middle_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_marginTop="@dimen/small_size"
android:gravity="center"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/text_statement_retention"/>
<View
android:background="@color/colorSeparator"
android:layout_width="match_parent"
android:layout_height="1dp"/>
</LinearLayout>
</ScrollView>
\ No newline at end of file
......@@ -5,6 +5,7 @@
<color name="colorPrimaryLight">#7484ea</color>
<color name="colorAccent">#FF4081</color>
<color name="colorSeparator">#898989</color>
<color name="colorAnother">#e5eaff</color>
<color name="colorImplicit">#4c9737</color>
<color name="colorObvious">#ffffff</color>
<color name="colorText">#000000</color>
......
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_empty_margin">0dp</dimen>
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="line_size">1dp</dimen>
<dimen name="small_size">5dp</dimen>
<dimen name="median_size">8dp</dimen>
<dimen name="item_size">50sp</dimen>
<dimen name="item_double_size">60sp</dimen>
<dimen name="middle_item_size">40sp</dimen>
<dimen name="small_item_size">30sp</dimen>
<dimen name="font_bigger_size">20sp</dimen>
<dimen name="font_middle_size">16sp</dimen>
......
......@@ -37,7 +37,7 @@
<string name="bluetooth_not_bonded">NOT BONDED</string>
<string name="get_policy_url"
translatable="false">http://192.168.0.157:4567/policy.json</string>
translatable="false">http://192.168.0.157:8080/policy.json</string>
<string name="get_policy_id_parameter_key"
translatable="false">id</string>
......@@ -71,15 +71,21 @@
<string name="device_upc_key"
translatable="false">UPC</string>
<string name="policy_statement_collector_title">Collector</string>
<string name="policy_statement_dispute_title">Dispute</string>
<string name="policy_separator">&#160;</string>
<string name="policy_collector_title">Collector</string>
<string name="policy_dispute_title">Dispute</string>
<string name="policy_statement_recipient_title">Recipient</string>
<string name="policy_statement_purpose_title">Purpose</string>
<string name="policy_statement_data_title">Data</string>
<string name="policy_statement_collector_name">Name</string>
<string name="policy_statement_collector_phone">Phone</string>
<string name="policy_statement_collector_email">Email</string>
<string name="policy_dispute_related_organization">Organization</string>
<string name="policy_dispute_resolution_type">Type</string>
<string name="policy_collector_name">Name</string>
<string name="policy_collector_phone">Phone</string>
<string name="policy_collector_email">Email</string>
<string name="policy_statement_data_type">Type</string>
<string name="policy_statement_data_description">Description</string>
......@@ -90,11 +96,8 @@
<string name="policy_statement_recipient_type">Type</string>
<string name="policy_statement_recipient_description">Description</string>
<string name="policy_statement_dispute_related_organization">Organization</string>
<string name="policy_statement_dispute_resolution_type">Type</string>
<string name="policy_statement_consequence_title">Consequence</string>
<string name="policy_statement_access_title">Access</string>
<string name="policy_access_title">Access</string>
<string name="policy_statement_remedies">Remedies</string>
<string name="policy_statement_title">Statement</string>
<string name="policy_statement_retention">Retention</string>
......
......@@ -8,4 +8,6 @@
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert"/>
</resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment