mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Add deletion button
This commit is contained in:
parent
89245a6d5b
commit
6c38b58a29
7 changed files with 76 additions and 0 deletions
|
|
@ -91,6 +91,10 @@
|
|||
android:name=".notification.NotificationActivity"
|
||||
android:label="@string/navigation_item_notification" />
|
||||
|
||||
<activity
|
||||
android:name=".delete.DeleteActivity"
|
||||
android:label="@string/title_activity_delete" />
|
||||
|
||||
<service android:name=".upload.UploadService" />
|
||||
|
||||
<service
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
package fr.free.nrw.commons.delete;
|
||||
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
|
||||
import fr.free.nrw.commons.R;
|
||||
|
||||
public class DeleteActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_delete);
|
||||
}
|
||||
}
|
||||
|
|
@ -6,11 +6,13 @@ import android.net.Uri;
|
|||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
|
@ -32,6 +34,8 @@ import fr.free.nrw.commons.MediaDataExtractor;
|
|||
import fr.free.nrw.commons.MediaWikiImageView;
|
||||
import fr.free.nrw.commons.PageTitle;
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.contributions.Contribution;
|
||||
import fr.free.nrw.commons.delete.DeleteActivity;
|
||||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
||||
import fr.free.nrw.commons.location.LatLng;
|
||||
import fr.free.nrw.commons.ui.widget.CompatTextView;
|
||||
|
|
@ -70,6 +74,7 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
|
|||
private TextView coordinates;
|
||||
private TextView uploadedDate;
|
||||
private LinearLayout categoryContainer;
|
||||
private Button delete;
|
||||
private ScrollView scrollView;
|
||||
private ArrayList<String> categoryNames;
|
||||
private boolean categoriesLoaded = false;
|
||||
|
|
@ -122,6 +127,7 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
|
|||
license = (TextView) view.findViewById(R.id.mediaDetailLicense);
|
||||
coordinates = (TextView) view.findViewById(R.id.mediaDetailCoordinates);
|
||||
uploadedDate = (TextView) view.findViewById(R.id.mediaDetailuploadeddate);
|
||||
delete = (Button) view.findViewById(R.id.nominateDeletion);
|
||||
categoryContainer = (LinearLayout) view.findViewById(R.id.mediaDetailCategoryContainer);
|
||||
|
||||
licenseList = new LicenseList(getActivity());
|
||||
|
|
@ -181,6 +187,12 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
|
|||
Timber.d("MediaDetailFragment ready to display details");
|
||||
displayMediaDetails(media);
|
||||
}
|
||||
if (media instanceof Contribution) {
|
||||
Contribution c = (Contribution) media;
|
||||
if (c.getState()!= Contribution.STATE_COMPLETED) {
|
||||
delete.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void displayMediaDetails(final Media media) {
|
||||
|
|
@ -283,6 +295,14 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
|
|||
if (media.getCoordinates() != null) {
|
||||
coordinates.setOnClickListener(v -> openMap(media.getCoordinates()));
|
||||
}
|
||||
if (delete.getVisibility()!=View.GONE){
|
||||
delete.setOnClickListener(v -> {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("media",media);
|
||||
Intent deleteIntent = new Intent(getActivity(), DeleteActivity.class);
|
||||
startActivity(deleteIntent);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void rebuildCatList() {
|
||||
|
|
|
|||
17
app/src/main/res/layout/activity_delete.xml
Normal file
17
app/src/main/res/layout/activity_delete.xml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<include
|
||||
android:id="@+id/toolbar"
|
||||
layout="@layout/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</RelativeLayout>
|
||||
</android.support.v4.widget.DrawerLayout>
|
||||
|
|
@ -247,6 +247,23 @@
|
|||
android:textSize="@dimen/description_text_size" />
|
||||
</LinearLayout>
|
||||
|
||||
<fr.free.nrw.commons.media.MediaDetailSpacer
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/small_gap" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/standard_gap">
|
||||
<Button
|
||||
android:id="@+id/nominateDeletion"
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:textColor="@color/deleteTextColor"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/nominate_deletion"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@
|
|||
<color name="primaryTextColor">#ffffff</color>
|
||||
<color name="secondaryTextColor">#000000</color>
|
||||
|
||||
<color name="deleteTextColor">#d50000</color>
|
||||
|
||||
<!-- Some colours are same for dark/light themes. They are written two times in case
|
||||
we want to change light ones later.
|
||||
-->
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@
|
|||
<string name="categories_activity_title">Categories</string>
|
||||
<string name="title_activity_settings">Settings</string>
|
||||
<string name="title_activity_signup">Sign Up</string>
|
||||
<string name="title_activity_delete">Request Deletion</string>
|
||||
<string name="menu_about">About</string>
|
||||
<string name="about_license">The Wikimedia Commons app is an open-source app created and maintained by grantees and volunteers of the Wikimedia community. The Wikimedia Foundation is not involved in the creation, development, or maintenance of the app. </string>
|
||||
<string name="trademarked_name" translatable="false">Wikimedia Commons</string>
|
||||
|
|
@ -225,6 +226,7 @@
|
|||
<string name="send_log_file">Send log file</string>
|
||||
<string name="send_log_file_description">Send log file to developers via email</string>
|
||||
<string name="null_url">Error! URL not found</string>
|
||||
<string name="nominate_deletion">Nominate for Deletion</string>
|
||||
|
||||
<string name="nearby_location_has_not_changed">Location has not changed.</string>
|
||||
<string name="nearby_location_not_available">Location not available.</string>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue