View contact: layout changes, removed ShareActionProvider (for now)
This commit is contained in:
@@ -7,7 +7,6 @@ import android.nfc.NfcEvent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
|
||||
import i2p.bote.android.InitActivities;
|
||||
import i2p.bote.android.R;
|
||||
@@ -19,19 +18,11 @@ public class ViewContactActivity extends ActionBarActivity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_toolbar);
|
||||
|
||||
// Initialize I2P settings
|
||||
InitActivities init = new InitActivities(this);
|
||||
init.initialize();
|
||||
|
||||
// Set the action bar
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
// Enable ActionBar app icon to behave as action to go back
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
String destination = null;
|
||||
Bundle args = getIntent().getExtras();
|
||||
@@ -39,7 +30,7 @@ public class ViewContactActivity extends ActionBarActivity {
|
||||
destination = args.getString(ViewContactFragment.CONTACT_DESTINATION);
|
||||
ViewContactFragment f = ViewContactFragment.newInstance(destination);
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.add(R.id.container, f).commit();
|
||||
.add(android.R.id.content, f).commit();
|
||||
}
|
||||
|
||||
// NFC send only works on API 10+
|
||||
@@ -69,7 +60,7 @@ public class ViewContactActivity extends ActionBarActivity {
|
||||
|
||||
private NdefMessage getNdefMessage() {
|
||||
ViewContactFragment f = (ViewContactFragment) getSupportFragmentManager()
|
||||
.findFragmentById(R.id.container);
|
||||
.findFragmentById(android.R.id.content);
|
||||
return f.createNdefMessage();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,15 +12,14 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.widget.ShareActionProvider;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
@@ -38,6 +37,7 @@ public class ViewContactFragment extends Fragment {
|
||||
private String mDestination;
|
||||
private Contact mContact;
|
||||
|
||||
Toolbar mToolbar;
|
||||
ImageView mContactPicture;
|
||||
TextView mNameField;
|
||||
TextView mTextField;
|
||||
@@ -70,6 +70,7 @@ public class ViewContactFragment extends Fragment {
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
mToolbar = (Toolbar) view.findViewById(R.id.main_toolbar);
|
||||
mContactPicture = (ImageView) view.findViewById(R.id.contact_picture);
|
||||
mNameField = (TextView) view.findViewById(R.id.contact_name);
|
||||
mTextField = (TextView) view.findViewById(R.id.text);
|
||||
@@ -87,6 +88,18 @@ public class ViewContactFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
ActionBarActivity activity = ((ActionBarActivity)getActivity());
|
||||
|
||||
// Set the action bar
|
||||
activity.setSupportActionBar(mToolbar);
|
||||
|
||||
// Enable ActionBar app icon to behave as action to go back
|
||||
activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
@@ -101,7 +114,12 @@ public class ViewContactFragment extends Fragment {
|
||||
}
|
||||
|
||||
mNameField.setText(mContact.getName());
|
||||
mTextField.setText(mContact.getText());
|
||||
if (mContact.getText().isEmpty())
|
||||
mTextField.setVisibility(View.GONE);
|
||||
else {
|
||||
mTextField.setText(mContact.getText());
|
||||
mTextField.setVisibility(View.VISIBLE);
|
||||
}
|
||||
mCryptoField.setText(mContact.getDestination().getCryptoImpl().getName());
|
||||
mDestinationField.setText(mDestination);
|
||||
try {
|
||||
@@ -117,17 +135,6 @@ public class ViewContactFragment extends Fragment {
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.view_contact, menu);
|
||||
|
||||
MenuItem item = menu.findItem(R.id.menu_item_share);
|
||||
ShareActionProvider shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
|
||||
|
||||
if (mDestination != null) {
|
||||
Intent shareIntent = new Intent();
|
||||
shareIntent.setAction(Intent.ACTION_SEND);
|
||||
shareIntent.putExtra(Intent.EXTRA_TEXT, mDestination);
|
||||
shareIntent.setType("text/plain");
|
||||
shareActionProvider.setShareIntent(shareIntent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,101 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin">
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/main_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="@dimen/toolbar_height_with_picture"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
app:contentInsetEnd="0dp"
|
||||
app:contentInsetStart="0dp"
|
||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
|
||||
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/picture_layout"
|
||||
android:layout_width="96dp"
|
||||
android:layout_height="96dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:background="@drawable/picture_background">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|center_horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/contact_picture"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_width="@dimen/toolbar_picture_size"
|
||||
android:layout_height="@dimen/toolbar_picture_size"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:background="@color/background_material_light"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/ic_contact_picture" />
|
||||
android:src="@drawable/ic_contact_picture"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="@dimen/listitem_horizontal_margin"
|
||||
android:layout_marginStart="@dimen/listitem_horizontal_margin"
|
||||
android:layout_toEndOf="@id/contact_picture"
|
||||
android:layout_toRightOf="@id/contact_picture"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/contact_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/public_name"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Headline.Inverse"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/description"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Secondary.Inverse"/>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/contact_name"
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/picture_layout"
|
||||
android:layout_marginTop="8dp"
|
||||
android:ems="10"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/public_name"
|
||||
android:textSize="20dp" />
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/contact_name"
|
||||
android:layout_marginTop="5dp"
|
||||
android:ems="10"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/description" />
|
||||
<TextView
|
||||
android:id="@+id/title_key_info"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Address information"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Subject"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title_key_info"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_below="@id/text"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="Address information"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
<TextView
|
||||
android:id="@+id/crypto_impl"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/title_key_info"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Crypto implementation"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Primary"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/crypto_impl"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_below="@+id/title_key_info"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="Crypto implementation" />
|
||||
<TextView
|
||||
android:id="@+id/destination"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/crypto_impl"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Destination"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Secondary"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/destination"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/crypto_impl"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="Destination" />
|
||||
<TextView
|
||||
android:id="@+id/title_fingerprint"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/destination"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Fingerprint"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Subject"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title_fingerprint"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_below="@id/destination"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="Fingerprint"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:visibility="gone" />
|
||||
<TextView
|
||||
android:id="@+id/fingerprint"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/title_fingerprint"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Fingerprint"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Primary"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/fingerprint"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_below="@+id/title_fingerprint"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="Fingerprint"
|
||||
android:visibility="gone" />
|
||||
|
||||
</RelativeLayout>
|
||||
</ScrollView>
|
||||
</RelativeLayout>
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
||||
@@ -2,12 +2,6 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:i2pandroid="http://schemas.android.com/apk/res-auto" >
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_item_share"
|
||||
android:title="@string/share"
|
||||
i2pandroid:showAsAction="ifRoom"
|
||||
i2pandroid:actionProviderClass="android.support.v7.widget.ShareActionProvider"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_edit_contact"
|
||||
android:icon="@drawable/ic_create_white_24dp"
|
||||
|
||||
Reference in New Issue
Block a user