mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-30 22:34:02 +01:00 
			
		
		
		
	Merge branch 'master' into rx_upload_count
# Conflicts: # app/src/main/java/fr/free/nrw/commons/concurrency/ThreadPoolExecutorService.java # app/src/main/java/fr/free/nrw/commons/contributions/ContributionsActivity.java
This commit is contained in:
		
						commit
						2b30924242
					
				
					 37 changed files with 191 additions and 45 deletions
				
			
		|  | @ -3,11 +3,13 @@ package fr.free.nrw.commons.contributions; | |||
| import android.content.ComponentName; | ||||
| import android.content.ContentResolver; | ||||
| import android.content.Context; | ||||
| import android.content.DialogInterface; | ||||
| import android.content.Intent; | ||||
| import android.content.ServiceConnection; | ||||
| import android.content.SharedPreferences; | ||||
| import android.database.Cursor; | ||||
| import android.database.DataSetObserver; | ||||
| import android.net.Uri; | ||||
| import android.os.Bundle; | ||||
| import android.os.IBinder; | ||||
| import android.preference.PreferenceManager; | ||||
|  | @ -16,13 +18,17 @@ import android.support.v4.app.LoaderManager; | |||
| import android.support.v4.content.CursorLoader; | ||||
| import android.support.v4.content.Loader; | ||||
| import android.support.v4.widget.CursorAdapter; | ||||
| import android.support.v7.app.AlertDialog; | ||||
| import android.view.Menu; | ||||
| import android.view.MenuItem; | ||||
| import android.view.View; | ||||
| import android.widget.Adapter; | ||||
| import android.widget.AdapterView; | ||||
| 
 | ||||
| import java.text.ParseException; | ||||
| import java.text.SimpleDateFormat; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Date; | ||||
| 
 | ||||
| import butterknife.ButterKnife; | ||||
| import fr.free.nrw.commons.CommonsApplication; | ||||
|  | @ -112,6 +118,12 @@ public  class       ContributionsActivity | |||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     @Override | ||||
|     protected void onStart() { | ||||
|         super.onStart(); | ||||
|         displayFeedbackPopup(); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     protected void onAuthCookieAcquired(String authCookie) { | ||||
|         // Do a sync everytime we get here! | ||||
|  | @ -342,4 +354,56 @@ public  class       ContributionsActivity | |||
|         Intent contributionsIntent = new Intent(context, ContributionsActivity.class); | ||||
|         context.startActivity(contributionsIntent); | ||||
|     } | ||||
| 
 | ||||
|     private void displayFeedbackPopup() { | ||||
| 
 | ||||
|         Date popupMessageEndDate = null; | ||||
|         try { | ||||
|             String validUntil = "23/08/2017"; | ||||
|             SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); | ||||
|             popupMessageEndDate = sdf.parse(validUntil); | ||||
|         } catch (ParseException e) { | ||||
|             e.printStackTrace(); | ||||
|         } | ||||
| 
 | ||||
|         final SharedPreferences prefs =  PreferenceManager.getDefaultSharedPreferences( | ||||
|                 CommonsApplication.getInstance()); | ||||
| 
 | ||||
|         // boolean to save users request about displaying popup | ||||
|         boolean displayFeedbackPopup = prefs.getBoolean("display_feedbak_popup", true); | ||||
| 
 | ||||
|         // boolean to recognize is application re-started. Will be used for "remind me later" option | ||||
|         int appStartCounter = prefs.getInt("app_start_counter" ,0); | ||||
| 
 | ||||
|         // if time is valid and shared pref says display | ||||
|         if (new Date().before(popupMessageEndDate) && displayFeedbackPopup && (appStartCounter == 4)) { | ||||
| 
 | ||||
|             new AlertDialog.Builder(this) | ||||
|             .setTitle(getResources().getString(R.string.feedback_popup_title)) | ||||
|             .setMessage(getResources().getString(R.string.feedback_popup_description)) | ||||
|             .setPositiveButton(getResources().getString(R.string.feedback_popup_accept), | ||||
|                     new DialogInterface.OnClickListener() { | ||||
|                         public void onClick(DialogInterface dialog, int which) { | ||||
|                             // Go to the page | ||||
|                             Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri | ||||
|                                     .parse(getResources() | ||||
|                                     .getString(R.string.feedback_page_url))); | ||||
|                             startActivity(browserIntent); | ||||
|                             // No need to dislay this window to the user again. | ||||
|                             prefs.edit().putBoolean("display_feedbak_popup" , false).commit(); | ||||
|                             dialog.dismiss(); | ||||
|                         } | ||||
|                     }) | ||||
|             .setNegativeButton(getResources().getString(R.string.feedback_popup_decline), | ||||
|                     new DialogInterface.OnClickListener() { | ||||
|                         @Override | ||||
|                         public void onClick(DialogInterface dialog, int which) { | ||||
|                             // Dismiss the dialog and not to show it later | ||||
|                             prefs.edit().putBoolean("display_feedbak_popup", false).commit(); | ||||
|                             dialog.dismiss(); | ||||
|                         } | ||||
|                     }) | ||||
|             .create().show(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -7,6 +7,7 @@ import android.database.Cursor; | |||
| import android.database.sqlite.SQLiteDatabase; | ||||
| import android.database.sqlite.SQLiteQueryBuilder; | ||||
| import android.net.Uri; | ||||
| import android.support.annotation.NonNull; | ||||
| import android.text.TextUtils; | ||||
| 
 | ||||
| import fr.free.nrw.commons.CommonsApplication; | ||||
|  | @ -38,7 +39,7 @@ public class ContributionsContentProvider extends ContentProvider{ | |||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { | ||||
|     public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { | ||||
|         SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder(); | ||||
|         queryBuilder.setTables(Contribution.Table.TABLE_NAME); | ||||
| 
 | ||||
|  | @ -71,12 +72,12 @@ public class ContributionsContentProvider extends ContentProvider{ | |||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public String getType(Uri uri) { | ||||
|     public String getType(@NonNull Uri uri) { | ||||
|         return null; | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public Uri insert(Uri uri, ContentValues contentValues) { | ||||
|     public Uri insert(@NonNull Uri uri, ContentValues contentValues) { | ||||
|         int uriType = uriMatcher.match(uri); | ||||
|         SQLiteDatabase sqlDB = CommonsApplication.getInstance().getDBOpenHelper().getWritableDatabase(); | ||||
|         long id = 0; | ||||
|  | @ -92,7 +93,7 @@ public class ContributionsContentProvider extends ContentProvider{ | |||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public int delete(Uri uri, String s, String[] strings) { | ||||
|     public int delete(@NonNull Uri uri, String s, String[] strings) { | ||||
|         int rows = 0; | ||||
|         int uriType = uriMatcher.match(uri); | ||||
| 
 | ||||
|  | @ -114,7 +115,7 @@ public class ContributionsContentProvider extends ContentProvider{ | |||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public int bulkInsert(Uri uri, ContentValues[] values) { | ||||
|     public int bulkInsert(@NonNull Uri uri, @NonNull ContentValues[] values) { | ||||
|         Timber.d("Hello, bulk insert! (ContributionsContentProvider)"); | ||||
|         int uriType = uriMatcher.match(uri); | ||||
|         SQLiteDatabase sqlDB = CommonsApplication.getInstance().getDBOpenHelper().getWritableDatabase(); | ||||
|  | @ -136,7 +137,7 @@ public class ContributionsContentProvider extends ContentProvider{ | |||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public int update(Uri uri, ContentValues contentValues, String selection, String[] selectionArgs) { | ||||
|     public int update(@NonNull Uri uri, ContentValues contentValues, String selection, String[] selectionArgs) { | ||||
|         /* | ||||
|         SQL Injection warnings: First, note that we're not exposing this to the outside world (exported="false") | ||||
|         Even then, we should make sure to sanitize all user input appropriately. Input that passes through ContentValues | ||||
|  |  | |||
|  | @ -8,6 +8,7 @@ import android.content.SharedPreferences; | |||
| import android.content.pm.PackageManager; | ||||
| import android.os.Build; | ||||
| import android.os.Bundle; | ||||
| import android.support.annotation.NonNull; | ||||
| import android.support.v4.app.Fragment; | ||||
| import android.support.v4.content.ContextCompat; | ||||
| import android.support.v7.app.AlertDialog; | ||||
|  | @ -162,7 +163,7 @@ public class ContributionsListFragment extends Fragment { | |||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { | ||||
|     public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | ||||
| 
 | ||||
|         Timber.d("onRequestPermissionsResult: req code = " + " perm = " + permissions + " grant =" + grantResults); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Mikel
						Mikel