mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Fix Conflicts
This commit is contained in:
commit
235e2239c9
20 changed files with 187 additions and 86 deletions
|
|
@ -16,6 +16,8 @@ dependencies {
|
||||||
compile "com.android.support:appcompat-v7:${project.supportLibVersion}"
|
compile "com.android.support:appcompat-v7:${project.supportLibVersion}"
|
||||||
compile "com.android.support:design:${project.supportLibVersion}"
|
compile "com.android.support:design:${project.supportLibVersion}"
|
||||||
compile 'com.google.code.gson:gson:2.7'
|
compile 'com.google.code.gson:gson:2.7'
|
||||||
|
compile "com.jakewharton:butterknife:$BUTTERKNIFE_VERSION"
|
||||||
|
annotationProcessor "com.jakewharton:butterknife-compiler:$BUTTERKNIFE_VERSION"
|
||||||
|
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,23 +7,21 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import fr.free.nrw.commons.theme.BaseActivity;
|
import fr.free.nrw.commons.theme.BaseActivity;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
public class AboutActivity extends BaseActivity {
|
public class AboutActivity extends BaseActivity {
|
||||||
private TextView versionText;
|
@BindView(R.id.about_version) TextView versionText;
|
||||||
private TextView licenseText;
|
@BindView(R.id.about_license) TextView licenseText;
|
||||||
private TextView improveText;
|
@BindView(R.id.about_improve) TextView improveText;
|
||||||
private TextView privacyPolicyText;
|
@BindView(R.id.about_privacy_policy) TextView privacyPolicyText;
|
||||||
private TextView uploadsToText;
|
@BindView(R.id.about_uploads_to) TextView uploadsToText;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_about);
|
setContentView(R.layout.activity_about);
|
||||||
|
ButterKnife.bind(this);
|
||||||
versionText = (TextView) findViewById(R.id.about_version);
|
|
||||||
licenseText = (TextView) findViewById(R.id.about_license);
|
|
||||||
improveText = (TextView) findViewById(R.id.about_improve);
|
|
||||||
privacyPolicyText = (TextView) findViewById(R.id.about_privacy_policy);
|
|
||||||
uploadsToText = (TextView) findViewById(R.id.about_uploads_to);
|
|
||||||
|
|
||||||
uploadsToText.setText(CommonsApplication.EVENTLOG_WIKI);
|
uploadsToText.setText(CommonsApplication.EVENTLOG_WIKI);
|
||||||
versionText.setText(CommonsApplication.APPLICATION_VERSION);
|
versionText.setText(CommonsApplication.APPLICATION_VERSION);
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
|
||||||
getDelegate().installViewFactory();
|
getDelegate().installViewFactory();
|
||||||
getDelegate().onCreate(savedInstanceState);
|
getDelegate().onCreate(savedInstanceState);
|
||||||
// Check prefs on every activity starts
|
// Check prefs on every activity starts
|
||||||
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("theme",false)) {
|
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("theme",true)) {
|
||||||
setTheme(R.style.DarkAppTheme);
|
setTheme(R.style.DarkAppTheme);
|
||||||
}else {
|
}else {
|
||||||
setTheme(R.style.LightAppTheme); // default
|
setTheme(R.style.LightAppTheme); // default
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,12 @@
|
||||||
package fr.free.nrw.commons.auth;
|
package fr.free.nrw.commons.auth;
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
import android.accounts.AccountManager;
|
import android.accounts.AccountManager;
|
||||||
import android.accounts.AccountManagerFuture;
|
import android.accounts.AccountManagerFuture;
|
||||||
import android.accounts.AuthenticatorException;
|
import android.accounts.AuthenticatorException;
|
||||||
import android.accounts.OperationCanceledException;
|
import android.accounts.OperationCanceledException;
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.support.v4.app.ActivityCompat;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
@ -32,7 +28,6 @@ public abstract class AuthenticatedActivity extends BaseAppCompatActivity {
|
||||||
private class GetAuthCookieTask extends AsyncTask<Void, String, String> {
|
private class GetAuthCookieTask extends AsyncTask<Void, String, String> {
|
||||||
private Account account;
|
private Account account;
|
||||||
private AccountManager accountManager;
|
private AccountManager accountManager;
|
||||||
|
|
||||||
public GetAuthCookieTask(Account account, AccountManager accountManager) {
|
public GetAuthCookieTask(Account account, AccountManager accountManager) {
|
||||||
this.account = account;
|
this.account = account;
|
||||||
this.accountManager = accountManager;
|
this.accountManager = accountManager;
|
||||||
|
|
@ -68,7 +63,6 @@ public abstract class AuthenticatedActivity extends BaseAppCompatActivity {
|
||||||
|
|
||||||
private class AddAccountTask extends AsyncTask<Void, String, String> {
|
private class AddAccountTask extends AsyncTask<Void, String, String> {
|
||||||
private AccountManager accountManager;
|
private AccountManager accountManager;
|
||||||
|
|
||||||
public AddAccountTask(AccountManager accountManager) {
|
public AddAccountTask(AccountManager accountManager) {
|
||||||
this.accountManager = accountManager;
|
this.accountManager = accountManager;
|
||||||
}
|
}
|
||||||
|
|
@ -77,7 +71,8 @@ public abstract class AuthenticatedActivity extends BaseAppCompatActivity {
|
||||||
protected void onPostExecute(String result) {
|
protected void onPostExecute(String result) {
|
||||||
super.onPostExecute(result);
|
super.onPostExecute(result);
|
||||||
if(result != null) {
|
if(result != null) {
|
||||||
Account curAccount = getCurrentAccount();
|
Account[] allAccounts =accountManager.getAccountsByType(accountType);
|
||||||
|
Account curAccount = allAccounts[0];
|
||||||
GetAuthCookieTask getCookieTask = new GetAuthCookieTask(curAccount, accountManager);
|
GetAuthCookieTask getCookieTask = new GetAuthCookieTask(curAccount, accountManager);
|
||||||
getCookieTask.execute();
|
getCookieTask.execute();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -85,18 +80,6 @@ public abstract class AuthenticatedActivity extends BaseAppCompatActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private Account getCurrentAccount() {
|
|
||||||
if (ActivityCompat.checkSelfPermission(AuthenticatedActivity.this, Manifest.permission.GET_ACCOUNTS) != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Account[] allAccounts = accountManager.getAccountsByType(accountType);
|
|
||||||
if (allAccounts == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return allAccounts[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String doInBackground(Void... params) {
|
protected String doInBackground(Void... params) {
|
||||||
AccountManagerFuture<Bundle> resultFuture = accountManager.addAccount(accountType, null, null, null, AuthenticatedActivity.this, null, null);
|
AccountManagerFuture<Bundle> resultFuture = accountManager.addAccount(accountType, null, null, null, AuthenticatedActivity.this, null, null);
|
||||||
|
|
|
||||||
|
|
@ -50,11 +50,11 @@ public class LoginActivity extends AccountAuthenticatorActivity {
|
||||||
Button signupButton;
|
Button signupButton;
|
||||||
EditText usernameEdit;
|
EditText usernameEdit;
|
||||||
EditText passwordEdit;
|
EditText passwordEdit;
|
||||||
|
ProgressDialog dialog;
|
||||||
|
|
||||||
private class LoginTask extends AsyncTask<String, String, String> {
|
private class LoginTask extends AsyncTask<String, String, String> {
|
||||||
|
|
||||||
Activity context;
|
Activity context;
|
||||||
ProgressDialog dialog;
|
|
||||||
String username;
|
String username;
|
||||||
String password;
|
String password;
|
||||||
|
|
||||||
|
|
@ -69,7 +69,9 @@ public class LoginActivity extends AccountAuthenticatorActivity {
|
||||||
.log();
|
.log();
|
||||||
|
|
||||||
if (result.equals("Success")) {
|
if (result.equals("Success")) {
|
||||||
|
if (dialog != null && dialog.isShowing()) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
}
|
||||||
Toast successToast = Toast.makeText(context, R.string.login_success, Toast.LENGTH_SHORT);
|
Toast successToast = Toast.makeText(context, R.string.login_success, Toast.LENGTH_SHORT);
|
||||||
successToast.show();
|
successToast.show();
|
||||||
Account account = new Account(username, WikiAccountAuthenticator.COMMONS_ACCOUNT_TYPE);
|
Account account = new Account(username, WikiAccountAuthenticator.COMMONS_ACCOUNT_TYPE);
|
||||||
|
|
@ -219,6 +221,20 @@ public class LoginActivity extends AccountAuthenticatorActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
try {
|
||||||
|
// To prevent leaked window when finish() is called, see http://stackoverflow.com/questions/32065854/activity-has-leaked-window-at-alertdialog-show-method
|
||||||
|
if (dialog != null && dialog.isShowing()) {
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
private void performLogin() {
|
private void performLogin() {
|
||||||
String username = usernameEdit.getText().toString();
|
String username = usernameEdit.getText().toString();
|
||||||
// Because Mediawiki is upercase-first-char-then-case-sensitive :)
|
// Because Mediawiki is upercase-first-char-then-case-sensitive :)
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,16 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.util.TypedValue;
|
||||||
|
import android.view.Display;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
|
|
@ -25,6 +30,8 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
import fr.free.nrw.commons.AboutActivity;
|
import fr.free.nrw.commons.AboutActivity;
|
||||||
import fr.free.nrw.commons.CommonsApplication;
|
import fr.free.nrw.commons.CommonsApplication;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
|
|
@ -32,6 +39,7 @@ import fr.free.nrw.commons.SettingsActivity;
|
||||||
import fr.free.nrw.commons.nearby.NearbyActivity;
|
import fr.free.nrw.commons.nearby.NearbyActivity;
|
||||||
|
|
||||||
import static android.app.Activity.RESULT_OK;
|
import static android.app.Activity.RESULT_OK;
|
||||||
|
import static android.content.Context.LOCATION_SERVICE;
|
||||||
|
|
||||||
public class ContributionsListFragment extends Fragment {
|
public class ContributionsListFragment extends Fragment {
|
||||||
|
|
||||||
|
|
@ -39,9 +47,9 @@ public class ContributionsListFragment extends Fragment {
|
||||||
void refreshSource();
|
void refreshSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
private GridView contributionsList;
|
@BindView(R.id.contributionsList) GridView contributionsList;
|
||||||
private TextView waitingMessage;
|
@BindView(R.id.waitingMessage) TextView waitingMessage;
|
||||||
private TextView emptyMessage;
|
@BindView(R.id.emptyMessage) TextView emptyMessage;
|
||||||
|
|
||||||
private ContributionController controller;
|
private ContributionController controller;
|
||||||
private static final String TAG = "ContributionsList";
|
private static final String TAG = "ContributionsList";
|
||||||
|
|
@ -49,11 +57,7 @@ public class ContributionsListFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View v = inflater.inflate(R.layout.fragment_contributions, container, false);
|
View v = inflater.inflate(R.layout.fragment_contributions, container, false);
|
||||||
|
ButterKnife.bind(this, v);
|
||||||
|
|
||||||
contributionsList = (GridView) v.findViewById(R.id.contributionsList);
|
|
||||||
waitingMessage = (TextView) v.findViewById(R.id.waitingMessage);
|
|
||||||
emptyMessage = (TextView) v.findViewById(R.id.emptyMessage);
|
|
||||||
|
|
||||||
contributionsList.setOnItemClickListener((AdapterView.OnItemClickListener)getActivity());
|
contributionsList.setOnItemClickListener((AdapterView.OnItemClickListener)getActivity());
|
||||||
if(savedInstanceState != null) {
|
if(savedInstanceState != null) {
|
||||||
|
|
@ -229,6 +233,28 @@ public class ContributionsListFragment extends Fragment {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MenuItem galleryMenu = menu.findItem(R.id.menu_from_gallery);
|
||||||
|
|
||||||
|
// Get background resource id to recognize current themes
|
||||||
|
TypedArray typedArray = getActivity().getTheme().obtainStyledAttributes(new int[] {R.attr.mainBackground});
|
||||||
|
int galleryIconResourceId = typedArray.getResourceId(0, 0);
|
||||||
|
typedArray.recycle();
|
||||||
|
|
||||||
|
// Get width in dp http://stackoverflow.com/questions/11999260/check-if-menuitem-is-in-actionbar-overflow
|
||||||
|
DisplayMetrics metrics = new DisplayMetrics();
|
||||||
|
Display display = getActivity().getWindowManager().getDefaultDisplay();
|
||||||
|
display.getMetrics(metrics);
|
||||||
|
float logicalDensity = metrics.density;
|
||||||
|
int dp = (int) (metrics.widthPixels / logicalDensity + 0.5);
|
||||||
|
|
||||||
|
if(dp < 360) { // only two icons, there is no room
|
||||||
|
if(galleryIconResourceId==getActivity().obtainStyledAttributes(R.style.LightAppTheme, new int[] {R.attr.mainBackground}).getResourceId(0, 0)){
|
||||||
|
galleryMenu.setIcon(R.drawable.ic_photo_black_24dp); //If theme is light, display dark icon on overlay menu
|
||||||
|
}else{
|
||||||
|
galleryMenu.setIcon(R.drawable.ic_photo_white_24dp); //If theme is dark, display light icon on overlay menu
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
super.onPrepareOptionsMenu(menu);
|
super.onPrepareOptionsMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ public class BaseActivity extends Activity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("theme",false)) {
|
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("theme",true)) {
|
||||||
currentTheme = true;
|
currentTheme = true;
|
||||||
setTheme(R.style.DarkAppTheme);
|
setTheme(R.style.DarkAppTheme);
|
||||||
}else {
|
}else {
|
||||||
|
|
@ -26,7 +26,7 @@ public class BaseActivity extends Activity {
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
// Restart activity if theme is changed
|
// Restart activity if theme is changed
|
||||||
boolean newTheme = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("theme",false);
|
boolean newTheme = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("theme",true);
|
||||||
if(currentTheme!=newTheme){ // is activity theme changed
|
if(currentTheme!=newTheme){ // is activity theme changed
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
finish();
|
finish();
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ public class BaseAppCompatActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("theme",false)) {
|
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("theme",true)) {
|
||||||
currentTheme = true;
|
currentTheme = true;
|
||||||
setTheme(R.style.DarkAppTheme);
|
setTheme(R.style.DarkAppTheme);
|
||||||
}else {
|
}else {
|
||||||
|
|
@ -25,7 +25,7 @@ public class BaseAppCompatActivity extends AppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
// Restart activity if theme is changed
|
// Restart activity if theme is changed
|
||||||
boolean newTheme = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("theme",false);
|
boolean newTheme = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("theme",true);
|
||||||
if(currentTheme!=newTheme){ //is activity theme changed
|
if(currentTheme!=newTheme){ //is activity theme changed
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
finish();
|
finish();
|
||||||
|
|
|
||||||
|
|
@ -29,20 +29,28 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.OnClick;
|
||||||
|
import butterknife.OnItemSelected;
|
||||||
|
import butterknife.OnTouch;
|
||||||
import fr.free.nrw.commons.Prefs;
|
import fr.free.nrw.commons.Prefs;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.Utils;
|
import fr.free.nrw.commons.Utils;
|
||||||
|
|
||||||
public class SingleUploadFragment extends Fragment {
|
public class SingleUploadFragment extends Fragment {
|
||||||
|
private SharedPreferences prefs;
|
||||||
|
private String license;
|
||||||
|
|
||||||
public interface OnUploadActionInitiated {
|
public interface OnUploadActionInitiated {
|
||||||
void uploadActionInitiated(String title, String description);
|
void uploadActionInitiated(String title, String description);
|
||||||
}
|
}
|
||||||
|
|
||||||
private EditText titleEdit;
|
@BindView(R.id.titleEdit) EditText titleEdit;
|
||||||
private EditText descEdit;
|
@BindView(R.id.descEdit) EditText descEdit;
|
||||||
private TextView licenseSummaryView;
|
@BindView(R.id.titleDescButton) Button titleDescButton;
|
||||||
private Spinner licenseSpinner;
|
@BindView(R.id.share_license_summary) TextView licenseSummaryView;
|
||||||
|
@BindView(R.id.licenseSpinner) Spinner licenseSpinner;
|
||||||
|
|
||||||
private OnUploadActionInitiated uploadActionInitiatedHandler;
|
private OnUploadActionInitiated uploadActionInitiatedHandler;
|
||||||
|
|
||||||
|
|
@ -82,12 +90,7 @@ public class SingleUploadFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View rootView = inflater.inflate(R.layout.fragment_single_upload, null);
|
View rootView = inflater.inflate(R.layout.fragment_single_upload, null);
|
||||||
|
ButterKnife.bind(this, rootView);
|
||||||
titleEdit = (EditText)rootView.findViewById(R.id.titleEdit);
|
|
||||||
descEdit = (EditText)rootView.findViewById(R.id.descEdit);
|
|
||||||
Button titleDescButton = (Button) rootView.findViewById(R.id.titleDescButton);
|
|
||||||
licenseSpinner = (Spinner) rootView.findViewById(R.id.licenseSpinner);
|
|
||||||
licenseSummaryView = (TextView)rootView.findViewById(R.id.share_license_summary);
|
|
||||||
|
|
||||||
|
|
||||||
ArrayList<String> licenseItems = new ArrayList<>();
|
ArrayList<String> licenseItems = new ArrayList<>();
|
||||||
|
|
@ -97,8 +100,8 @@ public class SingleUploadFragment extends Fragment {
|
||||||
licenseItems.add(getString(R.string.license_name_cc_by_four));
|
licenseItems.add(getString(R.string.license_name_cc_by_four));
|
||||||
licenseItems.add(getString(R.string.license_name_cc_by_sa_four));
|
licenseItems.add(getString(R.string.license_name_cc_by_sa_four));
|
||||||
|
|
||||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||||
final String license = prefs.getString(Prefs.DEFAULT_LICENSE, Prefs.Licenses.CC_BY_SA_3);
|
license = prefs.getString(Prefs.DEFAULT_LICENSE, Prefs.Licenses.CC_BY_SA_3);
|
||||||
|
|
||||||
Log.d("Single Upload fragment", license);
|
Log.d("Single Upload fragment", license);
|
||||||
|
|
||||||
|
|
@ -190,10 +193,32 @@ public class SingleUploadFragment extends Fragment {
|
||||||
|
|
||||||
setLicenseSummary(license);
|
setLicenseSummary(license);
|
||||||
|
|
||||||
// Open license page on touch
|
return rootView;
|
||||||
licenseSummaryView.setOnTouchListener(new View.OnTouchListener() {
|
}
|
||||||
@Override
|
|
||||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
@OnItemSelected(R.id.licenseSpinner) void onLicenseSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
String licenseName = parent.getItemAtPosition(position).toString();
|
||||||
|
|
||||||
|
String license = Prefs.Licenses.CC_BY_SA_3; // default value
|
||||||
|
if(getString(R.string.license_name_cc0).equals(licenseName)) {
|
||||||
|
license = Prefs.Licenses.CC0;
|
||||||
|
} else if(getString(R.string.license_name_cc_by).equals(licenseName)) {
|
||||||
|
license = Prefs.Licenses.CC_BY_3;
|
||||||
|
} else if(getString(R.string.license_name_cc_by_sa).equals(licenseName)) {
|
||||||
|
license = Prefs.Licenses.CC_BY_SA_3;
|
||||||
|
} else if(getString(R.string.license_name_cc_by_four).equals(licenseName)) {
|
||||||
|
license = Prefs.Licenses.CC_BY_4;
|
||||||
|
} else if(getString(R.string.license_name_cc_by_sa_four).equals(licenseName)) {
|
||||||
|
license = Prefs.Licenses.CC_BY_SA_4;
|
||||||
|
}
|
||||||
|
|
||||||
|
setLicenseSummary(license);
|
||||||
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
|
editor.putString(Prefs.DEFAULT_LICENSE, license);
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnTouch(R.id.share_license_summary) boolean showLicence(View view, MotionEvent motionEvent) {
|
||||||
if (motionEvent.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
if (motionEvent.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setAction(Intent.ACTION_VIEW);
|
intent.setAction(Intent.ACTION_VIEW);
|
||||||
|
|
@ -204,9 +229,16 @@ public class SingleUploadFragment extends Fragment {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
return rootView;
|
@OnClick(R.id.titleDescButton) void setTitleDescButton() {
|
||||||
|
//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);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setLicenseSummary(String license) {
|
private void setLicenseSummary(String license) {
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,8 @@
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:textAlignment="textStart"
|
android:textAlignment="textStart"
|
||||||
android:paddingTop="16dp"
|
android:paddingTop="16dp"
|
||||||
android:gravity="start"/>
|
android:gravity="start"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,8 @@
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:textAlignment="textStart"
|
android:textAlignment="textStart"
|
||||||
android:paddingTop="16dp"
|
android:paddingTop="16dp"
|
||||||
android:gravity="start"/>
|
android:gravity="start"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:textAlignment="textStart"
|
android:textAlignment="textStart"
|
||||||
android:paddingTop="16dp"
|
android:paddingTop="16dp"
|
||||||
android:gravity="start"/>
|
android:gravity="start"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,8 @@
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:paddingTop="16dp"
|
android:paddingTop="16dp"
|
||||||
android:gravity="center_horizontal"/>
|
android:gravity="center_horizontal"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
||||||
|
|
@ -74,5 +74,6 @@
|
||||||
android:textAlignment="textStart"
|
android:textAlignment="textStart"
|
||||||
android:paddingTop="16dp"
|
android:paddingTop="16dp"
|
||||||
android:gravity="start"
|
android:gravity="start"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
/>
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
@ -53,5 +53,6 @@
|
||||||
android:textAlignment="textStart"
|
android:textAlignment="textStart"
|
||||||
android:paddingTop="16dp"
|
android:paddingTop="16dp"
|
||||||
android:gravity="start"
|
android:gravity="start"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
/>
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
@ -39,5 +39,6 @@
|
||||||
android:textAlignment="textStart"
|
android:textAlignment="textStart"
|
||||||
android:paddingTop="16dp"
|
android:paddingTop="16dp"
|
||||||
android:gravity="start"
|
android:gravity="start"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
/>
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
@ -37,5 +37,6 @@
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:paddingTop="16dp"
|
android:paddingTop="16dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
/>
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:title="@string/preference_theme"
|
android:title="@string/preference_theme"
|
||||||
android:defaultValue="false"
|
android:defaultValue="true"
|
||||||
android:summary="@string/preference_theme_summary"
|
android:summary="@string/preference_theme_summary"
|
||||||
android:key="theme" />
|
android:key="theme" />
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,3 +7,7 @@ buildToolsVersion = 25.0.1
|
||||||
|
|
||||||
minSdkVersion = 15
|
minSdkVersion = 15
|
||||||
targetSdkVersion = 25
|
targetSdkVersion = 25
|
||||||
|
android.useDeprecatedNdk=true
|
||||||
|
|
||||||
|
# Library dependencies
|
||||||
|
BUTTERKNIFE_VERSION=8.4.0
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,34 @@
|
||||||
<message key="ws.notPreceded"
|
<message key="ws.notPreceded"
|
||||||
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
|
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
|
<module name="VisibilityModifier">
|
||||||
|
<property name="packageAllowed" value="false"/>
|
||||||
|
|
||||||
|
<!-- Butter Knife -->
|
||||||
|
<property name="ignoreAnnotationCanonicalNames" value="BindArray" />
|
||||||
|
<property name="ignoreAnnotationCanonicalNames" value="BindBitmap" />
|
||||||
|
<property name="ignoreAnnotationCanonicalNames" value="BindBool" />
|
||||||
|
<property name="ignoreAnnotationCanonicalNames" value="BindColor" />
|
||||||
|
<property name="ignoreAnnotationCanonicalNames" value="BindDimen" />
|
||||||
|
<property name="ignoreAnnotationCanonicalNames" value="BindDrawable" />
|
||||||
|
<property name="ignoreAnnotationCanonicalNames" value="BindInt" />
|
||||||
|
<property name="ignoreAnnotationCanonicalNames" value="BindString" />
|
||||||
|
<property name="ignoreAnnotationCanonicalNames" value="BindView" />
|
||||||
|
<property name="ignoreAnnotationCanonicalNames" value="BindViews" />
|
||||||
|
<property name="ignoreAnnotationCanonicalNames" value="OnCheckedChanged" />
|
||||||
|
<property name="ignoreAnnotationCanonicalNames" value="OnClick" />
|
||||||
|
<property name="ignoreAnnotationCanonicalNames" value="OnEditorAction" />
|
||||||
|
<property name="ignoreAnnotationCanonicalNames" value="OnFocusChange" />
|
||||||
|
<property name="ignoreAnnotationCanonicalNames" value="OnItemClick" />
|
||||||
|
<property name="ignoreAnnotationCanonicalNames" value="OnItemLongClick" />
|
||||||
|
<property name="ignoreAnnotationCanonicalNames" value="OnItemSelected" />
|
||||||
|
<property name="ignoreAnnotationCanonicalNames" value="OnLongClick" />
|
||||||
|
<property name="ignoreAnnotationCanonicalNames" value="OnPageChange" />
|
||||||
|
<property name="ignoreAnnotationCanonicalNames" value="OnTextChanged" />
|
||||||
|
<property name="ignoreAnnotationCanonicalNames" value="OnTouch" />
|
||||||
|
</module>
|
||||||
|
|
||||||
<module name="OneStatementPerLine"/>
|
<module name="OneStatementPerLine"/>
|
||||||
<module name="MultipleVariableDeclarations"/>
|
<module name="MultipleVariableDeclarations"/>
|
||||||
<module name="ArrayTypeStyle"/>
|
<module name="ArrayTypeStyle"/>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue