mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Merge pull request #292 from misaochan/copy-title-desc
Add button to copy previous title and desc
This commit is contained in:
commit
bfb7cae4c9
4 changed files with 79 additions and 36 deletions
|
|
@ -4,12 +4,14 @@ import android.app.Activity;
|
|||
import android.content.ContentProviderClient;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.os.RemoteException;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.Editable;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import android.preference.PreferenceManager;
|
|||
import android.support.v4.app.Fragment;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
|
@ -18,6 +19,7 @@ import android.view.MotionEvent;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
|
@ -37,6 +39,8 @@ public class SingleUploadFragment extends Fragment {
|
|||
|
||||
private OnUploadActionInitiated uploadActionInitiatedHandler;
|
||||
|
||||
private static final String TAG = "SingleUploadFragment";
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.activity_share, menu);
|
||||
|
|
@ -49,7 +53,18 @@ public class SingleUploadFragment extends Fragment {
|
|||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_upload_single:
|
||||
uploadActionInitiatedHandler.uploadActionInitiated(titleEdit.getText().toString(), descEdit.getText().toString());
|
||||
|
||||
String title = titleEdit.getText().toString();
|
||||
String desc = descEdit.getText().toString();
|
||||
|
||||
//Save the values of these fields in short-lived cache so next time this fragment is loaded, we can access these
|
||||
SharedPreferences titleDesc = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
SharedPreferences.Editor editor = titleDesc.edit();
|
||||
editor.putString("Title", title);
|
||||
editor.putString("Desc", desc);
|
||||
editor.apply();
|
||||
|
||||
uploadActionInitiatedHandler.uploadActionInitiated(title, desc);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
|
@ -62,6 +77,23 @@ public class SingleUploadFragment extends Fragment {
|
|||
|
||||
titleEdit = (EditText)rootView.findViewById(R.id.titleEdit);
|
||||
descEdit = (EditText)rootView.findViewById(R.id.descEdit);
|
||||
Button titleDescButton = (Button) rootView.findViewById(R.id.titleDescButton);
|
||||
|
||||
titleDescButton.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
public void onClick(View v)
|
||||
{
|
||||
//Retrieve last title and desc entered
|
||||
SharedPreferences titleDesc = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
String title = titleDesc.getString("Title", "");
|
||||
String desc = titleDesc.getString("Desc", "");
|
||||
Log.d(TAG, "Title: " + title + ", Desc: " + desc);
|
||||
|
||||
titleEdit.setText(title);
|
||||
descEdit.setText(desc);
|
||||
}
|
||||
});
|
||||
|
||||
licenseSummaryView = (TextView)rootView.findViewById(R.id.share_license_summary);
|
||||
|
||||
TextWatcher uploadEnabler = new TextWatcher() {
|
||||
|
|
|
|||
|
|
@ -32,11 +32,19 @@
|
|||
android:hint="@string/share_description_hint"
|
||||
android:imeOptions="flagNoExtractUi"
|
||||
/>
|
||||
|
||||
<Button
|
||||
android:text="@string/use_previous"
|
||||
android:background="@android:color/transparent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/titleDescButton" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/share_license_summary"
|
||||
android:id="@+id/share_license_summary"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:layout_marginTop="16dp"/>
|
||||
</LinearLayout>
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@
|
|||
|
||||
<string name="menu_download">Download</string>
|
||||
<string name="preference_license">License</string>
|
||||
<string name="use_previous">Use previous title/desc</string>
|
||||
|
||||
<string name="allow_gps">Automatically get current location</string>
|
||||
<string name="allow_gps_summary">Retrieve current location to offer category suggestions if image is not geotagged</string>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue