Skip to content

Commit 120130b

Browse files
Mansi449Vivek Maskara
authored andcommitted
Share feature (#1338)
* added share app feature in About * added share app feature in About * a small fix
1 parent c6679ed commit 120130b

File tree

5 files changed

+46
-0
lines changed

5 files changed

+46
-0
lines changed

app/src/main/java/fr/free/nrw/commons/AboutActivity.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
import android.util.Log;
1313
import android.support.customtabs.CustomTabsIntent;
1414
import android.support.v4.content.ContextCompat;
15+
import android.view.Menu;
16+
import android.view.MenuInflater;
17+
import android.view.MenuItem;
1518
import android.view.View;
1619
import android.widget.ArrayAdapter;
1720
import android.widget.LinearLayout;
@@ -121,6 +124,28 @@ public void launchFrequentlyAskedQuesions(View view) {
121124
Utils.handleWebUrl(this,Uri.parse("https://github.com/commons-app/apps-android-commons/wiki/Frequently-Asked-Questions\\"));
122125
}
123126

127+
@Override
128+
public boolean onCreateOptionsMenu(Menu menu) {
129+
MenuInflater inflater = getMenuInflater();
130+
inflater.inflate(R.menu.menu_about, menu);
131+
return super.onCreateOptionsMenu(menu);
132+
}
133+
134+
@Override
135+
public boolean onOptionsItemSelected(MenuItem item) {
136+
switch (item.getItemId()) {
137+
case R.id.share_app_icon:
138+
Intent sendIntent = new Intent();
139+
sendIntent.setAction(Intent.ACTION_SEND);
140+
sendIntent.putExtra(Intent.EXTRA_TEXT, "http://play.google.com/store/apps/details?id=fr.free.nrw.commons");
141+
sendIntent.setType("text/plain");
142+
startActivity(Intent.createChooser(sendIntent, "Share app via..."));
143+
return true;
144+
default:
145+
return super.onOptionsItemSelected(item);
146+
}
147+
}
148+
124149
@OnClick(R.id.about_translate)
125150
public void launchTranslate(View view) {
126151
final ArrayAdapter<String> languageAdapter = new ArrayAdapter<String>(AboutActivity.this,
9.35 KB
Loading
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:alpha="0.84" android:height="32dp"
2+
android:viewportHeight="24.0" android:viewportWidth="24.0"
3+
android:width="32dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="#ffffffff" android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>
5+
</vector>

app/src/main/res/layout/toolbar.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
android:minHeight="?attr/actionBarSize"
1010
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
1111
android:background="?attr/colorPrimaryDark">
12+
1213
</android.support.v7.widget.Toolbar>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<menu xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
tools:context=".MainActivity"
6+
>
7+
8+
<item
9+
android:id="@+id/share_app_icon"
10+
android:title="@string/refresh_button"
11+
android:icon="@drawable/ic_share_black_24dp"
12+
android:orderInCategory="1"
13+
app:showAsAction="ifRoom"
14+
/>
15+
</menu>

0 commit comments

Comments
 (0)