Skip to content

Commit 9a3b6fc

Browse files
codepixelyneslihanturan
authored andcommitted
Deletion button being disabled (#1403)
* used CDATA * Improvements in Notification Activity (#1374) * Improvements in Notification Activity * Update NotificationActivity.java * Share feature (#1338) * added share app feature in About * added share app feature in About * a small fix * Use custom tabs for nearby web views (#1347) * Localisation updates from https://translatewiki.net. * Fix for issue #1380 Improved Notification UI (#1387) * Links added to TextView about_upload_to in aboutActivity (#1326) * Added the link in about_upload_to textfield * Merge conflicts resolved * Removed the extra textView * Fix re-enabling delete button if the action is canceled. * Keep delete button enabled until a reason is given.
1 parent 482b06c commit 9a3b6fc

File tree

50 files changed

+488
-76
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+488
-76
lines changed

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66
import android.content.Intent;
77
import android.net.Uri;
88
import android.os.Bundle;
9+
import android.text.Html;
910
import android.text.SpannableString;
1011
import android.text.style.UnderlineSpan;
1112
import android.util.Log;
1213
import android.support.customtabs.CustomTabsIntent;
1314
import android.support.v4.content.ContextCompat;
15+
import android.view.Menu;
16+
import android.view.MenuInflater;
17+
import android.view.MenuItem;
1418
import android.view.View;
1519
import android.widget.ArrayAdapter;
1620
import android.widget.LinearLayout;
@@ -62,6 +66,18 @@ public void onCreate(Bundle savedInstanceState) {
6266
content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
6367
faqText.setText(content);
6468
versionText.setText(BuildConfig.VERSION_NAME);
69+
TextView rate_us = findViewById(R.id.about_rate_us);
70+
TextView privacy_policy = findViewById(R.id.about_privacy_policy);
71+
TextView translate = findViewById(R.id.about_translate);
72+
TextView credits = findViewById(R.id.about_credits);
73+
TextView faq = findViewById(R.id.about_faq);
74+
75+
rate_us.setText(Html.fromHtml(getString(R.string.about_rate_us)));
76+
privacy_policy.setText(Html.fromHtml(getString(R.string.about_privacy_policy)));
77+
translate.setText(Html.fromHtml(getString(R.string.about_translate)));
78+
credits.setText(Html.fromHtml(getString(R.string.about_credits)));
79+
faq.setText(Html.fromHtml(getString(R.string.about_faq)));
80+
6581
initDrawer();
6682
}
6783

@@ -108,6 +124,28 @@ public void launchFrequentlyAskedQuesions(View view) {
108124
Utils.handleWebUrl(this,Uri.parse("https://github.com/commons-app/apps-android-commons/wiki/Frequently-Asked-Questions\\"));
109125
}
110126

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+
111149
@OnClick(R.id.about_translate)
112150
public void launchTranslate(View view) {
113151
final ArrayAdapter<String> languageAdapter = new ArrayAdapter<String>(AboutActivity.this,

app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,10 @@ private void setOnClickListeners(final Media media) {
304304
coordinates.setOnClickListener(v -> openMap(media.getCoordinates()));
305305
}
306306
if (delete.getVisibility() == View.VISIBLE) {
307+
enableDeleteButton(true);
308+
307309
delete.setOnClickListener(v -> {
308-
delete.setEnabled(false);
309-
delete.setTextColor(getResources().getColor(R.color.deleteButtonLight));
310+
310311
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
311312
alert.setMessage("Why should this file be deleted?");
312313
final EditText input = new EditText(getActivity());
@@ -317,6 +318,7 @@ public void onClick(DialogInterface dialog, int whichButton) {
317318
String reason = input.getText().toString();
318319
DeleteTask deleteTask = new DeleteTask(getActivity(), media, reason);
319320
deleteTask.execute();
321+
enableDeleteButton(false);
320322
}
321323
});
322324
alert.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@@ -358,6 +360,15 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
358360
}
359361
}
360362

363+
private void enableDeleteButton(boolean visibility) {
364+
delete.setEnabled(visibility);
365+
if(visibility) {
366+
delete.setTextColor(getResources().getColor(R.color.primaryTextColor));
367+
} else {
368+
delete.setTextColor(getResources().getColor(R.color.deleteButtonLight));
369+
}
370+
}
371+
361372
private void rebuildCatList() {
362373
categoryContainer.removeAllViews();
363374
// @fixme add the category items

app/src/main/java/fr/free/nrw/commons/nearby/NearbyMapFragment.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353

5454
import dagger.android.support.DaggerFragment;
5555
import fr.free.nrw.commons.R;
56+
import fr.free.nrw.commons.Utils;
5657
import fr.free.nrw.commons.contributions.ContributionController;
5758
import fr.free.nrw.commons.utils.UriDeserializer;
5859
import fr.free.nrw.commons.utils.ViewUtil;
@@ -747,8 +748,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
747748
}
748749

749750
private void openWebView(Uri link) {
750-
Intent browserIntent = new Intent(Intent.ACTION_VIEW, link);
751-
startActivity(browserIntent);
751+
Utils.handleWebUrl(getContext(), link);
752752
}
753753

754754
private void animateFAB(boolean isFabOpen) {

app/src/main/java/fr/free/nrw/commons/nearby/PlaceRenderer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import butterknife.ButterKnife;
2828
import fr.free.nrw.commons.CommonsApplication;
2929
import fr.free.nrw.commons.R;
30+
import fr.free.nrw.commons.Utils;
3031
import fr.free.nrw.commons.contributions.ContributionController;
3132
import fr.free.nrw.commons.di.ApplicationlessInjection;
3233
import timber.log.Timber;
@@ -200,8 +201,7 @@ private void popupMenuListener() {
200201
}
201202

202203
private void openWebView(Uri link) {
203-
Intent browserIntent = new Intent(Intent.ACTION_VIEW, link);
204-
view.getContext().startActivity(browserIntent);
204+
Utils.handleWebUrl(getContext(), link);
205205
}
206206

207207
private boolean showMenu() {

app/src/main/java/fr/free/nrw/commons/notification/NotificationActivity.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.content.Intent;
77
import android.net.Uri;
88
import android.os.Bundle;
9+
import android.support.design.widget.Snackbar;
910
import android.support.v7.widget.DividerItemDecoration;
1011
import android.support.v7.widget.LinearLayoutManager;
1112
import android.support.v7.widget.RecyclerView;
@@ -15,6 +16,7 @@
1516

1617
import com.pedrogomez.renderers.RVRendererAdapter;
1718

19+
import java.lang.ref.WeakReference;
1820
import java.util.Collections;
1921
import java.util.List;
2022

@@ -25,6 +27,7 @@
2527
import fr.free.nrw.commons.R;
2628
import fr.free.nrw.commons.Utils;
2729
import fr.free.nrw.commons.theme.NavigationBaseActivity;
30+
import fr.free.nrw.commons.utils.NetworkUtils;
2831
import fr.free.nrw.commons.utils.ViewUtil;
2932
import io.reactivex.Observable;
3033
import io.reactivex.android.schedulers.AndroidSchedulers;
@@ -62,9 +65,23 @@ private void initListView() {
6265
recyclerView.setLayoutManager(new LinearLayoutManager(this));
6366
DividerItemDecoration itemDecor = new DividerItemDecoration(recyclerView.getContext(), DividerItemDecoration.VERTICAL);
6467
recyclerView.addItemDecoration(itemDecor);
65-
addNotifications();
68+
refresh();
6669
}
6770

71+
private void refresh() {
72+
if (!NetworkUtils.isInternetConnectionEstablished(this)) {
73+
progressBar.setVisibility(View.GONE);
74+
Snackbar.make(relativeLayout , R.string.no_internet, Snackbar.LENGTH_INDEFINITE)
75+
.setAction(R.string.retry, view -> {
76+
refresh();
77+
}).show();
78+
}else {
79+
progressBar.setVisibility(View.VISIBLE);
80+
addNotifications();
81+
}
82+
}
83+
84+
6885
@SuppressLint("CheckResult")
6986
private void addNotifications() {
7087
Timber.d("Add notifications");
@@ -124,4 +141,4 @@ private void initializeAndSetNotificationList(List<Notification> notificationLis
124141
.commit();
125142
mNotificationWorkerFragment.setNotificationList(notificationList);
126143
}
127-
}
144+
}

app/src/main/java/fr/free/nrw/commons/notification/NotificationRenderer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ protected View inflate(LayoutInflater layoutInflater, ViewGroup viewGroup) {
4747
@Override
4848
public void render() {
4949
Notification notification = getContent();
50-
StringBuilder str = new StringBuilder(notification.notificationText.trim());
51-
str.append(" ");
50+
String str = notification.notificationText.trim();
51+
str = str.concat(" ");
5252
title.setText(str);
5353
time.setText(notification.date);
5454
switch (notification.notificationType) {
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/activity_about.xml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
android:layout_marginTop="@dimen/standard_gap"
112112
android:gravity="center"
113113
android:textColor="@color/primaryColor"
114-
android:text="@string/about_rate_us" />
114+
/>
115115

116116
<TextView
117117
android:id="@+id/about_privacy_policy"
@@ -121,7 +121,7 @@
121121
android:layout_marginTop="@dimen/standard_gap"
122122
android:textColor="@color/primaryColor"
123123
android:gravity="center"
124-
android:text="@string/about_privacy_policy" />
124+
/>
125125

126126
<TextView
127127
android:id="@+id/about_translate"
@@ -131,7 +131,7 @@
131131
android:textColor="@color/primaryColor"
132132
android:layout_marginTop="@dimen/standard_gap"
133133
android:gravity="center"
134-
android:text="@string/about_translate" />
134+
/>
135135

136136
<TextView
137137
android:id="@+id/about_credits"
@@ -141,7 +141,7 @@
141141
android:textColor="@color/primaryColor"
142142
android:layout_marginTop="@dimen/standard_gap"
143143
android:gravity="center"
144-
android:text="@string/about_credits" />
144+
/>
145145

146146
<TextView
147147
android:id="@+id/about_faq"
@@ -153,15 +153,6 @@
153153
android:gravity="center"
154154
/>
155155

156-
<TextView
157-
android:id="@+id/about_uploads_to"
158-
style="?android:textAppearanceSmall"
159-
android:layout_width="wrap_content"
160-
android:layout_height="wrap_content"
161-
android:layout_marginTop="@dimen/large_gap"
162-
android:alpha="0.2"
163-
android:gravity="center" />
164-
165156
</LinearLayout>
166157
</RelativeLayout>
167158
</ScrollView>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,6 @@
5151
app:colorClickableText="#969494"
5252
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
5353
tools:text="@string/placeholder_place_name"
54+
android:padding="12dp"
5455
/>
5556
</RelativeLayout>

0 commit comments

Comments
 (0)