Browse Source

Added share button in TopicActivity

pull/24/head
Ezerous 7 years ago
parent
commit
701251df34
  1. 10
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
  2. BIN
      app/src/main/res/drawable-hdpi/ic_share.png
  3. BIN
      app/src/main/res/drawable-mdpi/ic_share.png
  4. BIN
      app/src/main/res/drawable-xhdpi/ic_share.png
  5. BIN
      app/src/main/res/drawable-xxhdpi/ic_share.png
  6. BIN
      app/src/main/res/drawable-xxxhdpi/ic_share.png
  7. 1
      app/src/main/res/layout/activity_topic.xml
  8. 6
      app/src/main/res/menu/topic_menu.xml
  9. 1
      app/src/main/res/values/strings.xml

10
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java

@ -15,7 +15,6 @@ import android.text.Html;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.text.method.ScrollingMovementMethod;
import android.text.style.ClickableSpan; import android.text.style.ClickableSpan;
import android.text.style.URLSpan; import android.text.style.URLSpan;
import android.util.SparseArray; import android.util.SparseArray;
@ -103,6 +102,7 @@ public class TopicActivity extends BaseActivity {
* bundle one and gets rendered in the toolbar. * bundle one and gets rendered in the toolbar.
*/ */
private String parsedTitle; private String parsedTitle;
private String topicPageUrl;
private RecyclerView recyclerView; private RecyclerView recyclerView;
/** /**
* Holds the url of this page * Holds the url of this page
@ -195,7 +195,7 @@ public class TopicActivity extends BaseActivity {
Bundle extras = getIntent().getExtras(); Bundle extras = getIntent().getExtras();
topicTitle = extras.getString(BUNDLE_TOPIC_TITLE); topicTitle = extras.getString(BUNDLE_TOPIC_TITLE);
String topicPageUrl = extras.getString(BUNDLE_TOPIC_URL); topicPageUrl = extras.getString(BUNDLE_TOPIC_URL);
ThmmyPage.PageCategory target = ThmmyPage.resolvePageCategory( ThmmyPage.PageCategory target = ThmmyPage.resolvePageCategory(
Uri.parse(topicPageUrl)); Uri.parse(topicPageUrl));
if (!target.is(ThmmyPage.PageCategory.TOPIC)) { if (!target.is(ThmmyPage.PageCategory.TOPIC)) {
@ -310,6 +310,12 @@ public class TopicActivity extends BaseActivity {
AlertDialog dialog = builder.create(); AlertDialog dialog = builder.create();
dialog.show(); dialog.show();
return true; return true;
case R.id.menu_share:
Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(android.content.Intent.EXTRA_TEXT, topicPageUrl);
startActivity(Intent.createChooser(sendIntent, "Share via"));
return true;
default: default:
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

BIN
app/src/main/res/drawable-hdpi/ic_share.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 541 B

BIN
app/src/main/res/drawable-mdpi/ic_share.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 B

BIN
app/src/main/res/drawable-xhdpi/ic_share.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 675 B

BIN
app/src/main/res/drawable-xxhdpi/ic_share.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
app/src/main/res/drawable-xxxhdpi/ic_share.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

1
app/src/main/res/layout/activity_topic.xml

@ -21,6 +21,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary" android:background="?attr/colorPrimary"
app:contentInsetStartWithNavigation="0dp"
app:popupTheme="@style/ToolbarTheme"> app:popupTheme="@style/ToolbarTheme">
<TextView <TextView

6
app/src/main/res/menu/topic_menu.xml

@ -7,6 +7,12 @@
app:showAsAction="ifRoom" app:showAsAction="ifRoom"
android:title="@string/bookmark"> android:title="@string/bookmark">
</item> </item>
<item
android:id="@+id/menu_share"
android:icon="@drawable/ic_share"
app:showAsAction="ifRoom"
android:title="@string/share">
</item>
<item <item
android:id="@+id/menu_info" android:id="@+id/menu_info"
android:icon="@drawable/ic_info" android:icon="@drawable/ic_info"

1
app/src/main/res/values/strings.xml

@ -31,6 +31,7 @@
<string name="topic_last_post">Last post on: %1$s</string> <string name="topic_last_post">Last post on: %1$s</string>
<!--Topic Activity--> <!--Topic Activity-->
<string name="share">Share</string>
<string name="post_author">Post author</string> <string name="post_author">Post author</string>
<string name="post_subject">Post subject</string> <string name="post_subject">Post subject</string>
<string name="post">Post</string> <string name="post">Post</string>

Loading…
Cancel
Save