Skip to content

Commit

Permalink
Fixes commons-app#3405 Fix indentation in all java files
Browse files Browse the repository at this point in the history
  • Loading branch information
yashk2000 committed Feb 12, 2020
1 parent 69e7161 commit 88ce95d
Show file tree
Hide file tree
Showing 273 changed files with 27,052 additions and 26,492 deletions.
8 changes: 8 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'com.github.triplet.play' version '2.2.1' apply false
id "com.diffplug.gradle.spotless" version "3.27.1"
}
apply from: '../gitutils.gradle'
apply plugin: 'com.android.application'
Expand All @@ -14,6 +15,13 @@ if(isRunningOnTravisAndIsNotPRBuild) {
apply plugin: 'com.github.triplet.play'
}

spotless {
java {
googleJavaFormat()
target '**/*.java'
}
}

dependencies {

// Utils
Expand Down
288 changes: 150 additions & 138 deletions app/src/main/java/fr/free/nrw/commons/AboutActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,152 +15,164 @@
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;

import org.wikipedia.util.StringUtil;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import fr.free.nrw.commons.theme.NavigationBaseActivity;
import fr.free.nrw.commons.ui.widget.HtmlTextView;
import fr.free.nrw.commons.utils.ConfigUtils;
import org.wikipedia.util.StringUtil;

/**
* Represents about screen of this app
*/
/** Represents about screen of this app */
public class AboutActivity extends NavigationBaseActivity {
@BindView(R.id.about_version) TextView versionText;
@BindView(R.id.about_license) HtmlTextView aboutLicenseText;
@BindView(R.id.about_faq) TextView faqText;
@BindView(R.id.about_improve) HtmlTextView improve;

/**
* This method helps in the creation About screen
*
* @param savedInstanceState Data bundle
*/
@Override
@SuppressLint("StringFormatInvalid")
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);

ButterKnife.bind(this);

String aboutText = getString(R.string.about_license);
aboutLicenseText.setHtmlText(aboutText);

@SuppressLint("StringFormatMatches")
String improveText = String.format(getString(R.string.about_improve), Urls.NEW_ISSUE_URL);
improve.setHtmlText(improveText);

SpannableString content = new SpannableString(getString(R.string.about_faq));
content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
faqText.setText(content);

versionText.setText(ConfigUtils.getVersionNameWithSha(getApplicationContext()));

TextView rate_us = findViewById(R.id.about_rate_us);
TextView privacy_policy = findViewById(R.id.about_privacy_policy);
TextView translate = findViewById(R.id.about_translate);
TextView credits = findViewById(R.id.about_credits);
TextView faq = findViewById(R.id.about_faq);
rate_us.setText(StringUtil.fromHtml(getString(R.string.about_rate_us)));
privacy_policy.setText(StringUtil.fromHtml(getString(R.string.about_privacy_policy)));
translate.setText(StringUtil.fromHtml(getString(R.string.about_translate)));
credits.setText(StringUtil.fromHtml(getString(R.string.about_credits)));
faq.setText(StringUtil.fromHtml(getString(R.string.about_faq)));

initDrawer();
}

@OnClick(R.id.facebook_launch_icon)
public void launchFacebook(View view) {
Intent intent;
try {
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Urls.FACEBOOK_APP_URL));
intent.setPackage(Urls.FACEBOOK_PACKAGE_NAME);
startActivity(intent);
} catch (Exception e) {
Utils.handleWebUrl(this, Uri.parse(Urls.FACEBOOK_WEB_URL));
}
}

@OnClick(R.id.github_launch_icon)
public void launchGithub(View view) {
Utils.handleWebUrl(this, Uri.parse(Urls.GITHUB_REPO_URL));
}

@OnClick(R.id.website_launch_icon)
public void launchWebsite(View view) {
Utils.handleWebUrl(this, Uri.parse(Urls.WEBSITE_URL));
}

@OnClick(R.id.about_rate_us)
public void launchRatings(View view){
Utils.rateApp(this);
}

@OnClick(R.id.about_credits)
public void launchCredits(View view) {
Utils.handleWebUrl(this, Uri.parse(Urls.CREDITS_URL));
}

@OnClick(R.id.about_privacy_policy)
public void launchPrivacyPolicy(View view) {
Utils.handleWebUrl(this, Uri.parse(BuildConfig.PRIVACY_POLICY_URL));
@BindView(R.id.about_version)
TextView versionText;

@BindView(R.id.about_license)
HtmlTextView aboutLicenseText;

@BindView(R.id.about_faq)
TextView faqText;

@BindView(R.id.about_improve)
HtmlTextView improve;

/**
* This method helps in the creation About screen
*
* @param savedInstanceState Data bundle
*/
@Override
@SuppressLint("StringFormatInvalid")
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);

ButterKnife.bind(this);

String aboutText = getString(R.string.about_license);
aboutLicenseText.setHtmlText(aboutText);

@SuppressLint("StringFormatMatches")
String improveText = String.format(getString(R.string.about_improve), Urls.NEW_ISSUE_URL);
improve.setHtmlText(improveText);

SpannableString content = new SpannableString(getString(R.string.about_faq));
content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
faqText.setText(content);

versionText.setText(ConfigUtils.getVersionNameWithSha(getApplicationContext()));

TextView rate_us = findViewById(R.id.about_rate_us);
TextView privacy_policy = findViewById(R.id.about_privacy_policy);
TextView translate = findViewById(R.id.about_translate);
TextView credits = findViewById(R.id.about_credits);
TextView faq = findViewById(R.id.about_faq);
rate_us.setText(StringUtil.fromHtml(getString(R.string.about_rate_us)));
privacy_policy.setText(StringUtil.fromHtml(getString(R.string.about_privacy_policy)));
translate.setText(StringUtil.fromHtml(getString(R.string.about_translate)));
credits.setText(StringUtil.fromHtml(getString(R.string.about_credits)));
faq.setText(StringUtil.fromHtml(getString(R.string.about_faq)));

initDrawer();
}

@OnClick(R.id.facebook_launch_icon)
public void launchFacebook(View view) {
Intent intent;
try {
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Urls.FACEBOOK_APP_URL));
intent.setPackage(Urls.FACEBOOK_PACKAGE_NAME);
startActivity(intent);
} catch (Exception e) {
Utils.handleWebUrl(this, Uri.parse(Urls.FACEBOOK_WEB_URL));
}


@OnClick(R.id.about_faq)
public void launchFrequentlyAskedQuesions(View view) {
Utils.handleWebUrl(this, Uri.parse(Urls.FAQ_URL));
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_about, menu);
return super.onCreateOptionsMenu(menu);
}

@OnClick(R.id.github_launch_icon)
public void launchGithub(View view) {
Utils.handleWebUrl(this, Uri.parse(Urls.GITHUB_REPO_URL));
}

@OnClick(R.id.website_launch_icon)
public void launchWebsite(View view) {
Utils.handleWebUrl(this, Uri.parse(Urls.WEBSITE_URL));
}

@OnClick(R.id.about_rate_us)
public void launchRatings(View view) {
Utils.rateApp(this);
}

@OnClick(R.id.about_credits)
public void launchCredits(View view) {
Utils.handleWebUrl(this, Uri.parse(Urls.CREDITS_URL));
}

@OnClick(R.id.about_privacy_policy)
public void launchPrivacyPolicy(View view) {
Utils.handleWebUrl(this, Uri.parse(BuildConfig.PRIVACY_POLICY_URL));
}

@OnClick(R.id.about_faq)
public void launchFrequentlyAskedQuesions(View view) {
Utils.handleWebUrl(this, Uri.parse(Urls.FAQ_URL));
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_about, menu);
return super.onCreateOptionsMenu(menu);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.share_app_icon:
String shareText = String.format(getString(R.string.share_text), Urls.PLAY_STORE_URL);
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, shareText);
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, getString(R.string.share_via)));
return true;
default:
return super.onOptionsItemSelected(item);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.share_app_icon:
String shareText = String.format(getString(R.string.share_text), Urls.PLAY_STORE_URL);
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, shareText);
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, getString(R.string.share_via)));
return true;
default:
return super.onOptionsItemSelected(item);
}
}

@OnClick(R.id.about_translate)
public void launchTranslate(View view) {
final ArrayAdapter<String> languageAdapter = new ArrayAdapter<>(AboutActivity.this,
android.R.layout.simple_spinner_dropdown_item, CommonsApplication.getInstance().getLanguageLookUpTable().getLocalizedNames());
final Spinner spinner = new Spinner(AboutActivity.this);
spinner.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
spinner.setAdapter(languageAdapter);
spinner.setGravity(17);
spinner.setPadding(50,0,0,0);

AlertDialog.Builder builder = new AlertDialog.Builder(AboutActivity.this);
builder.setView(spinner);
builder.setTitle(R.string.about_translate_title)
.setMessage(R.string.about_translate_message)
.setPositiveButton(R.string.about_translate_proceed, (dialog, which) -> {
String langCode = CommonsApplication.getInstance().getLanguageLookUpTable().getCodes().get(spinner.getSelectedItemPosition());
Utils.handleWebUrl(AboutActivity.this, Uri.parse(Urls.TRANSLATE_WIKI_URL + langCode));
});
builder.setNegativeButton(R.string.about_translate_cancel, (dialog, which) -> finish());
builder.create().show();

}

}

@OnClick(R.id.about_translate)
public void launchTranslate(View view) {
final ArrayAdapter<String> languageAdapter =
new ArrayAdapter<>(
AboutActivity.this,
android.R.layout.simple_spinner_dropdown_item,
CommonsApplication.getInstance().getLanguageLookUpTable().getLocalizedNames());
final Spinner spinner = new Spinner(AboutActivity.this);
spinner.setLayoutParams(
new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
spinner.setAdapter(languageAdapter);
spinner.setGravity(17);
spinner.setPadding(50, 0, 0, 0);

AlertDialog.Builder builder = new AlertDialog.Builder(AboutActivity.this);
builder.setView(spinner);
builder
.setTitle(R.string.about_translate_title)
.setMessage(R.string.about_translate_message)
.setPositiveButton(
R.string.about_translate_proceed,
(dialog, which) -> {
String langCode =
CommonsApplication.getInstance()
.getLanguageLookUpTable()
.getCodes()
.get(spinner.getSelectedItemPosition());
Utils.handleWebUrl(AboutActivity.this, Uri.parse(Urls.TRANSLATE_WIKI_URL + langCode));
});
builder.setNegativeButton(R.string.about_translate_cancel, (dialog, which) -> finish());
builder.create().show();
}
}
16 changes: 5 additions & 11 deletions app/src/main/java/fr/free/nrw/commons/BasePresenter.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
package fr.free.nrw.commons;

/**
* Base presenter, enforcing contracts to atach and detach view
*/
/** Base presenter, enforcing contracts to atach and detach view */
public interface BasePresenter<T> {
/**
* Until a view is attached, it is open to listen events from the presenter
*/
void onAttachView(T view);
/** Until a view is attached, it is open to listen events from the presenter */
void onAttachView(T view);

/**
* Detaching a view makes sure that the view no more receives events from the presenter
*/
void onDetachView();
/** Detaching a view makes sure that the view no more receives events from the presenter */
void onDetachView();
}
Loading

0 comments on commit 88ce95d

Please sign in to comment.