This commit is contained in:
Jatin Rao 2018-03-03 19:55:23 +05:30
commit 6e9ea26023
7 changed files with 91 additions and 16 deletions

View file

@ -1,12 +1,15 @@
package fr.free.nrw.commons;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.support.customtabs.CustomTabsIntent;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import butterknife.BindView;
import butterknife.ButterKnife;
@ -14,6 +17,8 @@ import butterknife.OnClick;
import fr.free.nrw.commons.theme.NavigationBaseActivity;
import fr.free.nrw.commons.ui.widget.HtmlTextView;
import static android.widget.Toast.LENGTH_SHORT;
/**
* Represents about screen of this app
*/
@ -27,12 +32,12 @@ public class AboutActivity extends NavigationBaseActivity {
* @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);
@ -42,35 +47,66 @@ public class AboutActivity extends NavigationBaseActivity {
@OnClick(R.id.facebook_launch_icon)
public void launchFacebook(View view) {
Intent intent;
try {
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/" + "1921335171459985"));
intent.setPackage("com.facebook.katana");
startActivity(intent);
} catch (Exception e) {
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/" + "1921335171459985\\"));
if(intent.resolveActivity(this.getPackageManager()) != null){
Utils.handleWebUrl(this,Uri.parse("https://www.facebook.com/" + "1921335171459985"));
} else {
Toast toast = Toast.makeText(this, getString(R.string.no_web_browser), LENGTH_SHORT);
toast.show();
}
}
}
@OnClick(R.id.github_launch_icon)
public void launchGithub(View view) {
Utils.handleWebUrl(this,Uri.parse("https://commons-app.github.io/\\"));
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/commons-app/apps-android-commons\\"));
//check if web browser available
if (browserIntent.resolveActivity(this.getPackageManager()) != null) {
Utils.handleWebUrl(this,Uri.parse("https://github.com/commons-app/apps-android-commons\\"));
} else {
Toast toast = Toast.makeText(this, getString(R.string.no_web_browser), LENGTH_SHORT);
toast.show();
}
}
@OnClick(R.id.website_launch_icon)
public void launchWebsite(View view) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://commons-app.github.io/\\"));
if (browserIntent.resolveActivity(this.getPackageManager()) != null) {
Utils.handleWebUrl(this,Uri.parse("https://commons-app.github.io/\\"));
} else {
Toast toast = Toast.makeText(this, getString(R.string.no_web_browser), LENGTH_SHORT);
toast.show();
}
}
@OnClick(R.id.about_credits)
public void launchCredits(View view) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/commons-app/apps-android-commons/blob/master/CREDITS/\\"));
if (browserIntent.resolveActivity(this.getPackageManager()) != null) {
Utils.handleWebUrl(this,Uri.parse("https://github.com/commons-app/apps-android-commons/blob/master/CREDITS/\\"));
} else {
Toast toast = Toast.makeText(this, getString(R.string.no_web_browser), LENGTH_SHORT);
toast.show();
}
}
@OnClick(R.id.about_privacy_policy)
public void launchPrivacyPolicy(View view) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/commons-app/apps-android-commons/wiki/Privacy-policy\\"));
if (browserIntent.resolveActivity(this.getPackageManager()) != null) {
Utils.handleWebUrl(this,Uri.parse("https://github.com/commons-app/apps-android-commons/wiki/Privacy-policy\\"));
} else {
Toast toast = Toast.makeText(this, getString(R.string.no_web_browser), LENGTH_SHORT);
toast.show();
}
}
}

View file

@ -37,6 +37,8 @@ import fr.free.nrw.commons.location.LatLng;
import fr.free.nrw.commons.ui.widget.CompatTextView;
import timber.log.Timber;
import static android.widget.Toast.LENGTH_SHORT;
public class MediaDetailFragment extends CommonsDaggerSupportFragment {
private boolean editable;
@ -305,7 +307,13 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
Intent viewIntent = new Intent();
viewIntent.setAction(Intent.ACTION_VIEW);
viewIntent.setData(new PageTitle(selectedCategoryTitle).getCanonicalUri());
//check if web browser available
if(viewIntent.resolveActivity(getActivity().getPackageManager()) != null){
startActivity(viewIntent);
} else {
Toast toast = Toast.makeText(getContext(), getString(R.string.no_web_browser), LENGTH_SHORT);
toast.show();
}
});
}
return item;
@ -385,7 +393,14 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
private void openWebBrowser(String url) {
Intent browser = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
//check if web browser available
if (browser.resolveActivity(getActivity().getPackageManager()) != null) {
startActivity(browser);
} else {
Toast toast = Toast.makeText(getContext(), getString(R.string.no_web_browser), LENGTH_SHORT);
toast.show();
}
}
private void openMap(LatLng coordinates) {

View file

@ -24,6 +24,7 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import javax.inject.Inject;
import javax.inject.Named;
@ -40,6 +41,7 @@ import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
import static android.content.Context.DOWNLOAD_SERVICE;
import static android.content.Intent.ACTION_VIEW;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.widget.Toast.LENGTH_SHORT;
public class MediaDetailPagerFragment extends CommonsDaggerSupportFragment implements ViewPager.OnPageChangeListener {
@ -118,7 +120,14 @@ public class MediaDetailPagerFragment extends CommonsDaggerSupportFragment imple
Intent viewIntent = new Intent();
viewIntent.setAction(ACTION_VIEW);
viewIntent.setData(m.getFilePageTitle().getMobileUri());
//check if web browser available
if(viewIntent.resolveActivity(getActivity().getPackageManager()) != null){
startActivity(viewIntent);
} else {
Toast toast = Toast.makeText(getContext(), getString(R.string.no_web_browser), LENGTH_SHORT);
toast.show();
}
return true;
case R.id.menu_download_current_image:
// Download

View file

@ -8,6 +8,7 @@ import android.os.Bundle;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.Toast;
import com.pedrogomez.renderers.RVRendererAdapter;
@ -25,6 +26,8 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import timber.log.Timber;
import static android.widget.Toast.LENGTH_SHORT;
/**
* Created by root on 18.12.2017.
*/
@ -71,7 +74,14 @@ public class NotificationActivity extends NavigationBaseActivity {
if (url == null || url.equals("")) {
return;
}
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
Intent browser = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
//check if web browser available
if(browser.resolveActivity(this.getPackageManager()) != null){
startActivity(browser);
} else {
Toast toast = Toast.makeText(this, getString(R.string.no_web_browser), LENGTH_SHORT);
toast.show();
}
}
private void setAdapter(List<Notification> notificationList) {

View file

@ -28,6 +28,7 @@ import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
@ -65,9 +66,6 @@ public class SingleUploadFragment extends CommonsDaggerSupportFragment {
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.activity_share, menu);
if (titleEdit != null) {
menu.findItem(R.id.menu_upload_single).setEnabled(titleEdit.getText().length() != 0);
}
}
@Override
@ -76,6 +74,11 @@ public class SingleUploadFragment extends CommonsDaggerSupportFragment {
//What happens when the 'submit' icon is tapped
case R.id.menu_upload_single:
if (titleEdit.getText().toString().isEmpty()) {
Toast.makeText(getContext(), R.string.add_title_toast, Toast.LENGTH_LONG).show();
return false;
}
String title = titleEdit.getText().toString();
String desc = descEdit.getText().toString();

View file

@ -3,6 +3,6 @@
<item android:id="@+id/menu_upload_single"
android:title="@string/menu_upload_single"
android:icon="@drawable/ic_send_white_24dp"
android:enabled="false"
android:enabled="true"
app:showAsAction="always" />
</menu>

View file

@ -38,6 +38,7 @@
<string name="menu_share">Share</string>
<string name="menu_open_in_browser">View in Browser</string>
<string name="share_title_hint">Title</string>
<string name="add_title_toast">Please give a Title to proceed</string>
<string name="share_description_hint">Description</string>
<string name="login_failed_network">Unable to login - network failure</string>
<string name="login_failed_username">Unable to login - please check your username</string>
@ -224,6 +225,7 @@
<string name="login_to_your_account">Login to your account</string>
<string name="send_log_file">Send log file</string>
<string name="send_log_file_description">Send log file to developers via email</string>
<string name="no_web_browser">No web browser found to open URL</string>
<string name="null_url">Error! URL not found</string>
<string name="nearby_location_has_not_changed">Location has not changed.</string>