mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
With more fragment (#2961)
This commit is contained in:
parent
9dd369e8ce
commit
85dfa0699b
7 changed files with 761 additions and 515 deletions
|
|
@ -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
|
||||
|
|
|
|||
150
app/src/main/java/fr/free/nrw/commons/MoreFragment.java
Normal file
150
app/src/main/java/fr/free/nrw/commons/MoreFragment.java
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
87
app/src/main/res/layout/fragment_more.xml
Normal file
87
app/src/main/res/layout/fragment_more.xml
Normal 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>
|
||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue