Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- HomeFragment: added shareViaSystem method
- HomeFragment.OnMenuItemClickListener: added handling of
menu_share_system click
- PhotoDetailsActivity.PhotoDetailsUiFragment: added handling of
menu_share_system to the onOptionsItemSelected method
- PhotoDetailsActivity.PhotoDetailsUiFragment: added new method
shareActivePhotoViaSystem
- PhotoDetailsActivity.PhotoDetailsUiFragment.PhotoDetailsPagerAdapter:
removed some unused overridden methods: finishUpdate, restoreState,
saveState, startUpdate
- ShareUtils: added shareViaSystem method
- res/menu/photo_details.xml: added system share menu item to share menu
- res/menu/share.xml: added system share menu and formatted file
- res/values/strings.xm res/values-ru/strings.xml: added strings
constants related to system share feature
  • Loading branch information
httpdispatch committed Jun 17, 2013
1 parent 7ef81e0 commit f84f795
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 25 deletions.
3 changes: 3 additions & 0 deletions app/res/menu/photo_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<item
android:id="@+id/menu_share_facebook"
android:title="@string/menu_share_facebook"/>
<item
android:id="@+id/menu_share_system"
android:title="@string/menu_share_system"/>
</group>
</menu>
</item>
Expand Down
12 changes: 6 additions & 6 deletions app/res/menu/share.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

<item
android:id="@+id/menu_share_email"
android:title="@string/menu_share_email"
/>
android:title="@string/menu_share_email"/>
<item
android:id="@+id/menu_share_twitter"
android:title="@string/menu_share_twitter"
/>
android:title="@string/menu_share_twitter"/>
<item
android:id="@+id/menu_share_facebook"
android:title="@string/menu_share_facebook"
/>
android:title="@string/menu_share_facebook"/>
<item
android:id="@+id/menu_share_system"
android:title="@string/menu_share_system"/>

</menu>
8 changes: 7 additions & 1 deletion app/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<string name="menu_share_email">Электронная почта</string>
<string name="menu_share_twitter">Twitter</string>
<string name="menu_share_facebook">Facebook</string>
<string name="menu_share_system">Другие системные приложения…</string>

<!-- Selection Menu -->
<string name="menu_select_all">Выбрать все</string>
Expand All @@ -28,9 +29,14 @@

<!-- Share E-Mail -->
<string name="share_email_default_title">Я использую Trovebox, чтобы поделиться мгновением</string>
<string name="share_email_default_body">Увидеть фотографию &lt;a href="%1$s">%1$s&lt;/a></string>
<string name="share_email_default_body">Посмотреть фотографию &lt;a href="%1$s">%1$s&lt;/a></string>
<string name="share_email_send_title">Отправить по электронной почте…</string>

<!-- Share System -->
<string name="share_system_default_title">@string/share_email_default_title</string>
<string name="share_system_default_body">Посмотреть фотографию %1$s</string>
<string name="share_system_send_title">Поделиться ссылкой на фото</string>

<!-- Share Twitter -->
<string name="share_twitter_requesting_authentication">Запрос аутентификации в twitter…</string>
<string name="share_twitter_verifying_authentication">Проверка аутентификации в twitter …</string>
Expand Down
6 changes: 6 additions & 0 deletions app/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<string name="menu_share_email">E-Mail</string>
<string name="menu_share_twitter">Twitter</string>
<string name="menu_share_facebook">Facebook</string>
<string name="menu_share_system">Other System Apps…</string>

<!-- Selection Menu -->
<string name="menu_select_all">Select All</string>
Expand All @@ -31,6 +32,11 @@
<string name="share_email_default_body">View the photo &lt;a href="%1$s">%1$s&lt;/a></string>
<string name="share_email_send_title">Send E-Mail…</string>

<!-- Share System -->
<string name="share_system_default_title">@string/share_email_default_title</string>
<string name="share_system_default_body">View the photo %1$s</string>
<string name="share_system_send_title">Share photo URL</string>

<!-- Share Twitter -->
<string name="share_twitter_requesting_authentication">Requesting twitter authentication…</string>
<string name="share_twitter_verifying_authentication">Veryfying twitter authentication…</string>
Expand Down
17 changes: 17 additions & 0 deletions app/src/com/trovebox/android/app/HomeFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ private void shareViaEMail(Photo photo)
ShareUtils.shareViaEMail(photo, getActivity(), loadingControl);
}

private void shareViaSystem(Photo photo)
{
ShareUtils.shareViaSystem(photo, getActivity(), loadingControl);
}

public void shareActivePhotoViaTwitter()
{
if (activePhoto != null)
Expand Down Expand Up @@ -639,8 +644,20 @@ public void run() {
}
});
break;
case R.id.menu_share_system:
TrackerUtils.trackPopupMenuClickEvent("menu_share_system",
getSupportActivity());
confirmPrivatePhotoSharingAndRun(new Runnable() {

@Override
public void run() {
shareViaSystem(activePhoto);
}
});
break;
}
return true;
}

};
}
40 changes: 22 additions & 18 deletions app/src/com/trovebox/android/app/PhotoDetailsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import android.database.DataSetObserver;
import android.net.Uri;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.text.TextUtils;
Expand Down Expand Up @@ -268,6 +267,17 @@ public void run() {
}
});
break;
case R.id.menu_share_system:
TrackerUtils.trackOptionsMenuClickEvent("menu_share_system",
getSupportActivity());
confirmPrivatePhotoSharingAndRun(new Runnable() {

@Override
public void run() {
shareActivePhotoViaSystem();
}
});
break;
case R.id.menu_share_twitter:
TrackerUtils.trackOptionsMenuClickEvent("menu_share_twitter",
getSupportActivity());
Expand Down Expand Up @@ -337,6 +347,17 @@ public void shareActivePhotoViaEMail() {
}
}

public void shareActivePhotoViaSystem() {
Photo photo = getActivePhoto();
if (photo != null)
{
ShareUtils.shareViaSystem(photo, getActivity(),
new ProgressDialogLoadingControl(
getSupportActivity(), true, false,
getString(R.string.loading)));
}
}

Photo getActivePhoto()
{
return mAdapter.currentPhoto;
Expand Down Expand Up @@ -803,23 +824,6 @@ public boolean isViewFromObject(View view, Object object) {
return view == ((View) object);
}

@Override
public void finishUpdate(View arg0) {
}

@Override
public void restoreState(Parcelable arg0, ClassLoader arg1) {
}

@Override
public Parcelable saveState() {
return null;
}

@Override
public void startUpdate(View arg0) {
}

@Override
public void setPrimaryItem(ViewGroup container, int position, Object object) {
super.setPrimaryItem(container, position, object);
Expand Down
43 changes: 43 additions & 0 deletions app/src/com/trovebox/android/app/share/ShareUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,49 @@ public void run(Photo photo) {

}

/**
* Shares the specified photo url via system share menu.
*
* @param photo
* @param context
* @param loadingControl the loading control for token retrieval operation
*/
public static void shareViaSystem(Photo photo, final Context context,
LoadingControl loadingControl)
{
RunnableWithParameter<Photo> runnable = new RunnableWithParameter<Photo>() {

@Override
public void run(Photo photo) {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
CommonUtils.getStringResource(R.string.share_system_default_title));
String url = PhotoUtils.getShareUrl(photo, photo.isPrivate());
String bodyText = CommonUtils.getStringResource(
R.string.share_system_default_body,
url, url);
shareIntent.putExtra(
Intent.EXTRA_TEXT,
bodyText
);
context.startActivity(Intent.createChooser(shareIntent,
CommonUtils.getStringResource(R.string.share_system_send_title)));
}
};
if (photo.isPrivate())
{
PhotoUtils.validateShareTokenExistsAsyncAndRunAsync(photo,
runnable,
null,
loadingControl);
} else
{
runnable.run(photo);
}

}

/**
* The runnable which opens twitter share dialog
*/
Expand Down

0 comments on commit f84f795

Please sign in to comment.