Skip to content

Commit

Permalink
Made minHeight of headline Row. ShareButton Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sahildave committed Oct 30, 2014
1 parent 5e92039 commit 345a33c
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 48 deletions.
27 changes: 11 additions & 16 deletions res/layout/headline_list_row.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/headline"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/list_singlepane_shadow"
android:paddingBottom="8dp"
android:paddingLeft="16dp"
android:paddingTop="8dp"
android:textAppearance="?android:attr/textAppearanceMedium"/>

</RelativeLayout>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/headline"
android:layout_width="match_parent"
android:minHeight="64dp"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:background="@drawable/list_singlepane_shadow"
android:paddingBottom="8dp"
android:paddingLeft="16dp"
android:paddingTop="8dp"
android:textAppearance="?android:attr/textAppearanceMedium"/>
29 changes: 12 additions & 17 deletions res/layout/headline_list_row_twopane.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/main_list_selector">

<TextView
android:id="@+id/headline"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="8dp"
android:paddingLeft="16dp"
android:paddingTop="8dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@drawable/main_list_text_selector"/>

</RelativeLayout>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/headline"
android:layout_width="match_parent"
android:minHeight="64dp"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:background="@drawable/main_list_selector"
android:paddingBottom="8dp"
android:paddingLeft="16dp"
android:paddingTop="8dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@drawable/main_list_text_selector"/>
4 changes: 3 additions & 1 deletion res/menu/detail_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
android:orderInCategory="99"
android:title="Share"
android:icon="@android:drawable/ic_menu_share"
app:showAsAction="always"/>
android:showAsAction="ifRoom"
app:showAsAction="ifRoom"/>

<item
android:id="@+id/action_view_in_browser"
android:orderInCategory="100"
android:title="View In Browser"
android:showAsAction="never"
app:showAsAction="never"/>

</menu>
32 changes: 18 additions & 14 deletions src/in/sahildave/gazetti/util/ShareButtonListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Build.VERSION;
import android.util.Log;
import com.crashlytics.android.Crashlytics;
import com.google.api.client.extensions.android.http.AndroidHttp;
Expand Down Expand Up @@ -49,17 +50,20 @@ private void shorten(String longUrl){
protected String doInBackground(String... params) {
String longUrl = params[0];

Urlshortener.Builder builder = new Urlshortener.Builder (AndroidHttp.newCompatibleTransport(), AndroidJsonFactory.getDefaultInstance(), null);
Urlshortener urlshortener = builder.build();

Url url = new Url();
url.setLongUrl(longUrl);
try {
url = urlshortener.url().insert(url).execute();
return url.getId();
} catch (IOException e) {
return null;
if(VERSION.SDK_INT >= 11 ){
Urlshortener.Builder builder = new Urlshortener.Builder(AndroidHttp.newCompatibleTransport(), AndroidJsonFactory.getDefaultInstance(), null);
Urlshortener urlshortener = builder.build();

Url url = new Url();
url.setLongUrl(longUrl);
try {
url = urlshortener.url().insert(url).execute();
return url.getId();
} catch (IOException e) {
return null;
}
}
return longUrl;
}

@Override
Expand All @@ -70,16 +74,16 @@ protected void onPostExecute(String s) {
mArticleURL = s;

String intentString = mArticleHeadLine + " - "+mArticleURL;
intentString = intentString.length() > MESSAGE_LENGTH ?
intentString.substring(0, MESSAGE_LENGTH)+"..." :
intentString;
// intentString = intentString.length() > MESSAGE_LENGTH ?
// intentString.substring(0, MESSAGE_LENGTH)+"..." :
// intentString;

Log.d(ShareButtonListener.class.getName(), "Sharing content - " + intentString);

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_TEXT, intentString);
sendIntent.setType("text/");
activity.startActivity(Intent.createChooser(sendIntent, "Share with"));
} catch (Exception e) {
Crashlytics.logException(e);
Expand Down

0 comments on commit 345a33c

Please sign in to comment.