1
0
mirror of https://github.com/etesync/android synced 2024-11-16 04:49:06 +00:00

Import: Make account import activity prettier.

This commit is contained in:
Tom Hacohen 2017-04-03 12:52:07 +01:00
parent 0d848f0573
commit 7915a51f1f
7 changed files with 98 additions and 42 deletions

View File

@ -2,8 +2,6 @@ package com.etesync.syncadapter.ui.importlocal;
import android.accounts.Account;
import android.app.Activity;
import android.app.ProgressDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@ -15,6 +13,8 @@ import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.etesync.syncadapter.App;
import com.etesync.syncadapter.R;
@ -39,8 +39,6 @@ public class ImportActivity extends AppCompatActivity implements SelectImportMet
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_import);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setTitle(getString(R.string.import_dialog_title));
@ -50,7 +48,7 @@ public class ImportActivity extends AppCompatActivity implements SelectImportMet
if (savedInstanceState == null)
getSupportFragmentManager().beginTransaction()
.add(R.id.fragment_container, new ImportActivity.SelectImportFragment())
.add(android.R.id.content, new ImportActivity.SelectImportFragment())
.commit();
}
@ -66,13 +64,13 @@ public class ImportActivity extends AppCompatActivity implements SelectImportMet
public void importAccount() {
if (info.type == CollectionInfo.Type.CALENDAR) {
getSupportFragmentManager().beginTransaction()
.replace(R.id.fragment_container,
.replace(android.R.id.content,
LocalCalendarImportFragment.newInstance(account, info))
.addToBackStack(LocalCalendarImportFragment.class.getName())
.commit();
} else if (info.type == CollectionInfo.Type.ADDRESS_BOOK) {
getSupportFragmentManager().beginTransaction()
.replace(R.id.fragment_container,
.replace(android.R.id.content,
LocalContactImportFragment.newInstance(account, info))
.addToBackStack(LocalContactImportFragment.class.getName())
.commit();
@ -140,6 +138,7 @@ public class ImportActivity extends AppCompatActivity implements SelectImportMet
finish();
}
public static class SelectImportFragment extends Fragment {
private SelectImportMethod mSelectImportMethod;
@ -172,20 +171,32 @@ public class ImportActivity extends AppCompatActivity implements SelectImportMet
}
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_import, container, false);
v.findViewById(R.id.import_button_account).setOnClickListener(new View.OnClickListener() {
View v = inflater.inflate(R.layout.import_actions_list, container, false);
View card = v.findViewById(R.id.import_file);
ImageView img = (ImageView) card.findViewById(R.id.action_icon);
TextView text = (TextView) card.findViewById(R.id.action_text);
img.setImageResource(R.drawable.ic_file_white);
text.setText(R.string.import_button_file);
card.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View aView) {
mSelectImportMethod.importFile();
}
});
card = v.findViewById(R.id.import_account);
img = (ImageView) card.findViewById(R.id.action_icon);
text = (TextView) card.findViewById(R.id.action_text);
img.setImageResource(R.drawable.ic_account_circle_white);
text.setText(R.string.import_button_local);
card.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View aView) {
mSelectImportMethod.importAccount();
}
});
v.findViewById(R.id.import_button_file).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View aView) {
mSelectImportMethod.importFile();
}
});
return v;
}
}

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M13,9V3.5L18.5,9M6,2C4.89,2 4,2.89 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2H6Z" />
</vector>

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/activity_margin">
</FrameLayout>

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:id="@+id/import_button_file"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/import_button_file"/>
<Button
android:id="@+id/import_button_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/import_button_local"/>
</LinearLayout>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:orientation="vertical">
<include
android:id="@+id/import_file"
android:layout_height="wrap_content"
android:layout_width="match_parent"
layout="@layout/import_actions_list_item"/>
<include
android:id="@+id/import_account"
android:layout_height="wrap_content"
android:layout_width="match_parent"
layout="@layout/import_actions_list_item"/>
</LinearLayout>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
android:gravity="center_horizontal">
<android.support.v7.widget.CardView
style="@style/account_list_card"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:foreground="?android:attr/selectableItemBackground"
card_view:cardBackgroundColor="@color/orange400"
card_view:cardElevation="2dp"
card_view:contentPadding="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:id="@+id/action_icon"
android:layout_width="48dp"
android:layout_height="48dp"
tools:src="@drawable/ic_account_circle_white" />
<TextView
android:id="@+id/action_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:textAppearance="@style/TextAppearance.AppCompat.Title"
android:textColor="@android:color/white"
tools:text="Import Local" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>

View File

@ -250,8 +250,8 @@
<string name="loading_error_content">Refresh</string>
<!-- Import Activity -->
<string name="import_button_file">Import from file</string>
<string name="import_button_local">Import from local</string>
<string name="import_button_file">From File</string>
<string name="import_button_local">From Account</string>
<string name="import_select_account">Select Account</string>
</resources>