mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Add button on image details to copy wikicode to clipboard (#1849)
* Add button on image details to copy wikicode to clipboard * Make copy wikicode button width the same as the nominate deletion button width by filling in background
This commit is contained in:
parent
e945d45558
commit
a059a3c2ef
3 changed files with 26 additions and 2 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
package fr.free.nrw.commons.media;
|
package fr.free.nrw.commons.media;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.content.ClipData;
|
||||||
|
import android.content.ClipboardManager;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.DataSetObserver;
|
import android.database.DataSetObserver;
|
||||||
|
|
@ -50,6 +52,7 @@ import fr.free.nrw.commons.mwapi.MediaWikiApi;
|
||||||
import fr.free.nrw.commons.ui.widget.CompatTextView;
|
import fr.free.nrw.commons.ui.widget.CompatTextView;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
|
import static android.content.Context.CLIPBOARD_SERVICE;
|
||||||
import static android.view.View.GONE;
|
import static android.view.View.GONE;
|
||||||
import static android.view.View.VISIBLE;
|
import static android.view.View.VISIBLE;
|
||||||
import static android.widget.Toast.LENGTH_SHORT;
|
import static android.widget.Toast.LENGTH_SHORT;
|
||||||
|
|
@ -351,6 +354,17 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnClick(R.id.copyWikicode)
|
||||||
|
public void onCopyWikicodeClicked(){
|
||||||
|
String data = "[[" + media.getFilename() + "|thumb|" + media.getDescription() + "]]";
|
||||||
|
ClipboardManager clipboard = (ClipboardManager) getContext().getApplicationContext().getSystemService(CLIPBOARD_SERVICE);
|
||||||
|
clipboard.setPrimaryClip(ClipData.newPlainText("wikiCode", data));
|
||||||
|
|
||||||
|
Timber.d("Generated wikidata copy code: %s", data);
|
||||||
|
|
||||||
|
Toast.makeText(getContext(), getString(R.string.wikicode_copied), Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
@OnClick(R.id.nominateDeletion)
|
@OnClick(R.id.nominateDeletion)
|
||||||
public void onDeleteButtonClicked(){
|
public void onDeleteButtonClicked(){
|
||||||
//Reviewer correct me if i have misunderstood something over here
|
//Reviewer correct me if i have misunderstood something over here
|
||||||
|
|
|
||||||
|
|
@ -312,6 +312,15 @@
|
||||||
android:textStyle="bold"/>
|
android:textStyle="bold"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/copyWikicode"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="@dimen/standard_gap"
|
||||||
|
android:background="@color/button_blue"
|
||||||
|
android:text="@string/copy_wikicode"
|
||||||
|
android:textColor="@color/primaryTextColor" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/nominateDeletion"
|
android:id="@+id/nominateDeletion"
|
||||||
android:background="@drawable/bg_delete_button"
|
android:background="@drawable/bg_delete_button"
|
||||||
|
|
@ -319,8 +328,7 @@
|
||||||
android:layout_margin="@dimen/standard_gap"
|
android:layout_margin="@dimen/standard_gap"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/nominate_deletion"
|
android:text="@string/nominate_deletion"/>
|
||||||
android:visibility="gone"/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
|
||||||
|
|
@ -252,6 +252,8 @@
|
||||||
<string name="skip_login_title">Do you really want to skip login?</string>
|
<string name="skip_login_title">Do you really want to skip login?</string>
|
||||||
<string name="skip_login_message">You will not be able to upload pictures.</string>
|
<string name="skip_login_message">You will not be able to upload pictures.</string>
|
||||||
<string name="login_alert_message">Please log in to use this feature</string>
|
<string name="login_alert_message">Please log in to use this feature</string>
|
||||||
|
<string name="copy_wikicode">Copy Wikicode to clipboard</string>
|
||||||
|
<string name="wikicode_copied">Wikicode copied to clipboard</string>
|
||||||
|
|
||||||
<string name="nearby_location_has_not_changed">Location has not changed.</string>
|
<string name="nearby_location_has_not_changed">Location has not changed.</string>
|
||||||
<string name="nearby_location_not_available">Location not available.</string>
|
<string name="nearby_location_not_available">Location not available.</string>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue