With more fragment (#2961)

This commit is contained in:
Vivek Maskara 2019-05-19 09:35:32 +02:00 committed by Ashish Kumar
parent 9dd369e8ce
commit 85dfa0699b
7 changed files with 761 additions and 515 deletions

View file

@ -39,6 +39,7 @@ dependencies {
implementation 'com.dinuscxj:circleprogressbar:1.1.1'
implementation 'com.karumi:dexter:5.0.0'
implementation "com.jakewharton:butterknife:$BUTTERKNIFE_VERSION"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
kapt "com.jakewharton:butterknife-compiler:$BUTTERKNIFE_VERSION"
// Logging

View file

@ -0,0 +1,150 @@
package fr.free.nrw.commons;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import javax.inject.Inject;
import butterknife.ButterKnife;
import butterknife.OnClick;
import fr.free.nrw.commons.achievements.AchievementsActivity;
import fr.free.nrw.commons.auth.LoginActivity;
import fr.free.nrw.commons.category.CategoryImagesActivity;
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
import fr.free.nrw.commons.logging.CommonsLogSender;
import fr.free.nrw.commons.review.ReviewActivity;
import fr.free.nrw.commons.settings.SettingsActivity;
import timber.log.Timber;
/**
* A simple {@link Fragment} subclass.
* Use the {@link MoreFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class MoreFragment extends CommonsDaggerSupportFragment {
@Inject
CommonsLogSender commonsLogSender;
public MoreFragment() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @return A new instance of fragment MoreFragment.
*/
// TODO: Rename and change types and number of parameters
public static MoreFragment newInstance() {
MoreFragment fragment = new MoreFragment();
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_more, container, false);
ButterKnife.bind(this, view);
return view;
}
@Override
public void onDetach() {
super.onDetach();
}
@OnClick(R.id.more_logout)
public void onLogoutClicked() {
new AlertDialog.Builder(getActivity())
.setMessage(R.string.logout_verification)
.setCancelable(false)
.setPositiveButton(R.string.yes, (dialog, which) -> {
BaseLogoutListener logoutListener = new BaseLogoutListener();
CommonsApplication app = (CommonsApplication) getContext().getApplicationContext();
app.clearApplicationData(getContext(), logoutListener);
})
.setNegativeButton(R.string.no, (dialog, which) -> dialog.cancel())
.show();
}
@OnClick(R.id.more_feedback)
public void onFeedbackClicked() {
String technicalInfo = commonsLogSender.getExtraInfo();
Intent feedbackIntent = new Intent(Intent.ACTION_SENDTO);
feedbackIntent.setType("message/rfc822");
feedbackIntent.setData(Uri.parse("mailto:"));
feedbackIntent.putExtra(Intent.EXTRA_EMAIL,
new String[]{CommonsApplication.FEEDBACK_EMAIL});
feedbackIntent.putExtra(Intent.EXTRA_SUBJECT,
CommonsApplication.FEEDBACK_EMAIL_SUBJECT);
feedbackIntent.putExtra(Intent.EXTRA_TEXT, String.format(
"\n\n%s\n%s", CommonsApplication.FEEDBACK_EMAIL_TEMPLATE_HEADER, technicalInfo));
try {
startActivity(feedbackIntent);
} catch (ActivityNotFoundException e) {
Toast.makeText(getActivity(), R.string.no_email_client, Toast.LENGTH_SHORT).show();
}
}
@OnClick(R.id.more_about)
public void onAboutClicked() {
Intent intent = new Intent(getActivity(), CategoryImagesActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP);
getActivity().startActivity(intent);
}
@OnClick(R.id.more_tutorial)
public void onTutorialClicked() {
WelcomeActivity.startYourself(getActivity());
}
@OnClick(R.id.more_settings)
public void onSettingsClicked() {
Intent intent = new Intent(getActivity(), SettingsActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP);
getActivity().startActivity(intent);
}
@OnClick(R.id.more_achievements)
public void onAchievementsClicked() {
Intent intent = new Intent(getActivity(), AchievementsActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP);
getActivity().startActivity(intent);
}
@OnClick(R.id.more_peer_review)
public void onPeerReviewClicked() {
ReviewActivity.startYourself(getActivity(), getString(R.string.title_activity_review));
}
private class BaseLogoutListener implements CommonsApplication.LogoutListener {
@Override
public void onLogoutComplete() {
Timber.d("Logout complete callback received.");
Intent nearbyIntent = new Intent(
getContext(), LoginActivity.class);
nearbyIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
nearbyIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(nearbyIntent);
getActivity().finish();
}
}
}

View file

@ -2,6 +2,7 @@ package fr.free.nrw.commons.di;
import dagger.Module;
import dagger.android.ContributesAndroidInjector;
import fr.free.nrw.commons.MoreFragment;
import fr.free.nrw.commons.bookmarks.BookmarksFragment;
import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsFragment;
import fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesFragment;
@ -84,4 +85,7 @@ public abstract class FragmentBuilderModule {
@ContributesAndroidInjector
abstract BookmarksFragment bindBookmarksFragment();
@ContributesAndroidInjector
abstract MoreFragment bindMoreFragment();
}

View file

@ -8,6 +8,7 @@ import androidx.fragment.app.Fragment;
import org.wikipedia.model.EnumCode;
import org.wikipedia.model.EnumCodeMap;
import fr.free.nrw.commons.MoreFragment;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.bookmarks.BookmarksFragment;
import fr.free.nrw.commons.contributions.ContributionsMainFragment;
@ -39,7 +40,7 @@ public enum NavTab implements EnumCode {
@NonNull
@Override
public Fragment newInstance() {
return ContributionsMainFragment.newInstance();
return MoreFragment.newInstance();
}
};

View file

@ -27,22 +27,22 @@ public class SettingsActivity extends NavigationBaseActivity {
initDrawer();
}
// Get an action bar
/**
* takes care of actions taken after the creation has happened
* @param savedInstanceState the saved state
*/
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
if (settingsDelegate == null) {
settingsDelegate = AppCompatDelegate.create(this, null);
}
settingsDelegate.onPostCreate(savedInstanceState);
//Get an up button
//settingsDelegate.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
// // Get an action bar
// /**
// * takes care of actions taken after the creation has happened
// * @param savedInstanceState the saved state
// */
// @Override
// protected void onPostCreate(Bundle savedInstanceState) {
// super.onPostCreate(savedInstanceState);
// if (settingsDelegate == null) {
// settingsDelegate = AppCompatDelegate.create(this, null);
// }
// settingsDelegate.onPostCreate(savedInstanceState);
//
// //Get an up button
// //settingsDelegate.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
/**
* Handle action-bar clicks

View file

@ -0,0 +1,87 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginTop="?attr/actionBarSize"
tools:context="fr.free.nrw.commons.MoreFragment">
<TextView
android:id="@+id/more_achievements"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:drawableStart="@drawable/ic_feedback_black_24dp"
android:drawablePadding="12dp"
android:padding="8dp"
android:text="@string/Achievements"
android:textSize="18sp" />
<TextView
android:id="@+id/more_peer_review"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:drawableStart="@drawable/ic_check_black_24dp"
android:drawablePadding="12dp"
android:padding="8dp"
android:text="@string/navigation_item_review"
android:textSize="18sp" />
<TextView
android:id="@+id/more_settings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:drawableStart="@drawable/ic_settings_black_24dp"
android:drawablePadding="12dp"
android:padding="8dp"
android:text="@string/menu_settings"
android:textSize="18sp" />
<TextView
android:id="@+id/more_tutorial"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:drawableStart="@drawable/ic_help_black_24dp"
android:drawablePadding="12dp"
android:padding="8dp"
android:text="@string/navigation_item_info"
android:textSize="18sp" />
<TextView
android:id="@+id/more_feedback"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:drawableLeft="@drawable/ic_feedback_black_24dp"
android:drawablePadding="12dp"
android:padding="8dp"
android:text="@string/navigation_item_feedback"
android:textSize="18sp" />
<TextView
android:id="@+id/more_about"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:drawableStart="@drawable/ic_info_outline_24dp"
android:drawablePadding="12dp"
android:padding="8dp"
android:text="@string/navigation_item_about"
android:textSize="18sp" />
<TextView
android:id="@+id/more_logout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:drawableStart="@drawable/ic_exit_to_app_black_24dp"
android:drawablePadding="12dp"
android:padding="8dp"
android:text="@string/navigation_item_logout"
android:textSize="18sp" />
</LinearLayout>

View file

@ -280,7 +280,7 @@
<string name="get_directions">GET DIRECTIONS</string>
<string name="read_article">READ ARTICLE</string>
<string formatted="false" name="notifications_welcome">Welcome to Wikimedia Commons, %1$s! We\'re glad you\'re here.</string>
<string name="notifications_welcome" formatted="false">Welcome to Wikimedia Commons, %1$s! We\'re glad you\'re here.</string>
<string name="notifications_talk_page_message">%1$s left a message on your talk page</string>
<string name="notifications_thank_you_edit">Thank you for making an edit</string>
<string name="notifications_mention">%1$s mentioned you on %2$s.</string>
@ -530,7 +530,7 @@ Upload your first media by tapping on the add button.</string>
<string name="please_wait">Please wait…</string>
<string name="images_featured_explanation">Featured pictures are images from highly skilled photographers and illustrators that the Wikimedia Commons community has chosen as some of the highest quality on the site.</string>
<string name="images_via_nearby_explanation">Images Uploaded via Nearby places are the images which are uploaded by discovering places on the map.</string>
<string name="thanks_received_explanation" >This feature allows editors to send a Thank you notification to users who make useful edits by using a small thank link on the history page or diff page.</string>
<string name="thanks_received_explanation">This feature allows editors to send a Thank you notification to users who make useful edits by using a small thank link on the history page or diff page.</string>
<string name="previous_image_title_description">Copy previous title &amp; description</string>
<string name="previous_button_tooltip_message">Click to reuse the title and description you entered in your previous picture and modify it to fit your current one</string>
<string name="welcome_do_upload_content_description">Examples of good images to upload to Commons</string>
@ -541,9 +541,12 @@ Upload your first media by tapping on the add button.</string>
<string name="share_via">Share app via...</string>
<string name="image_info">Image Info</string>
<!-- Hackathon-->
<!-- Hackathon-->
<string name="favorites">Favorites</string>
<string name="more">More</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources>