mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 13:53:54 +01:00
* Edited Project.xml to make indent size 4 * Changed files with 2 space indentation to use 4 space indentation * Edited Project.xml to make indent size 4 * changed files with 2 space indent to 4 space indent * fix :Back Pressed Event not work in Explore tab when user not login (#4404) * fix :Back Pressed Event not work in Explore tab * minor changes * fix :Upload count or number of contribution does not get updated when media is successful uploaded (#4399) * * fix:Number of Contributions not updated * Add javadocs * minor changes * made minor changes * String was nonsense and untranslatible, fixed (#4466) * Ability to show captions and descriptions in all entered languages (#4355) * implement Ability to show captions and descriptions in all entered languages *Add Javadoc * handle Back event of fragment(mediaDetailFragment) * fix minor bugs * add internationalization * revert previous changes * fix visibility bug * resolve conflict Co-authored-by: Prince kushwaha <65972015+Prince-kushwaha@users.noreply.github.com> Co-authored-by: neslihanturan <tur.neslihan@gmail.com>
This commit is contained in:
parent
b202f553f0
commit
ca9f6f5e47
36 changed files with 3047 additions and 2988 deletions
|
|
@ -16,82 +16,81 @@ import org.wikipedia.model.EnumCodeMap;
|
|||
import fr.free.nrw.commons.R;
|
||||
|
||||
|
||||
|
||||
public enum NavTab implements EnumCode {
|
||||
CONTRIBUTIONS(R.string.contributions_fragment, R.drawable.ic_baseline_person_24) {
|
||||
CONTRIBUTIONS(R.string.contributions_fragment, R.drawable.ic_baseline_person_24) {
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment newInstance() {
|
||||
return ContributionsFragment.newInstance();
|
||||
}
|
||||
},
|
||||
NEARBY(R.string.nearby_fragment, R.drawable.ic_location_on_black_24dp) {
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment newInstance() {
|
||||
return NearbyParentFragment.newInstance();
|
||||
}
|
||||
},
|
||||
EXPLORE(R.string.navigation_item_explore, R.drawable.ic_globe) {
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment newInstance() {
|
||||
return ExploreFragment.newInstance();
|
||||
}
|
||||
},
|
||||
FAVORITES(R.string.favorites, R.drawable.ic_round_star_border_24px) {
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment newInstance() {
|
||||
return BookmarkFragment.newInstance();
|
||||
}
|
||||
},
|
||||
MORE(R.string.more, R.drawable.ic_menu_black_24dp) {
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment newInstance() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
private static final EnumCodeMap<NavTab> MAP = new EnumCodeMap<>(NavTab.class);
|
||||
|
||||
@StringRes
|
||||
private final int text;
|
||||
@DrawableRes
|
||||
private final int icon;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment newInstance() {
|
||||
return ContributionsFragment.newInstance();
|
||||
public static NavTab of(int code) {
|
||||
return MAP.get(code);
|
||||
}
|
||||
},
|
||||
NEARBY(R.string.nearby_fragment, R.drawable.ic_location_on_black_24dp){
|
||||
|
||||
public static int size() {
|
||||
return MAP.size();
|
||||
}
|
||||
|
||||
@StringRes
|
||||
public int text() {
|
||||
return text;
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
public int icon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public abstract Fragment newInstance();
|
||||
|
||||
@Override
|
||||
public Fragment newInstance() {
|
||||
return NearbyParentFragment.newInstance();
|
||||
public int code() {
|
||||
// This enumeration is not marshalled so tying declaration order to presentation order is
|
||||
// convenient and consistent.
|
||||
return ordinal();
|
||||
}
|
||||
},
|
||||
EXPLORE(R.string.navigation_item_explore, R.drawable.ic_globe) {
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment newInstance() {
|
||||
return ExploreFragment.newInstance();
|
||||
|
||||
NavTab(@StringRes int text, @DrawableRes int icon) {
|
||||
this.text = text;
|
||||
this.icon = icon;
|
||||
}
|
||||
},
|
||||
FAVORITES(R.string.favorites, R.drawable.ic_round_star_border_24px) {
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment newInstance() {
|
||||
return BookmarkFragment.newInstance();
|
||||
}
|
||||
},
|
||||
MORE(R.string.more, R.drawable.ic_menu_black_24dp) {
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment newInstance() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
private static final EnumCodeMap<NavTab> MAP = new EnumCodeMap<>(NavTab.class);
|
||||
|
||||
@StringRes
|
||||
private final int text;
|
||||
@DrawableRes
|
||||
private final int icon;
|
||||
|
||||
@NonNull
|
||||
public static NavTab of(int code) {
|
||||
return MAP.get(code);
|
||||
}
|
||||
|
||||
public static int size() {
|
||||
return MAP.size();
|
||||
}
|
||||
|
||||
@StringRes
|
||||
public int text() {
|
||||
return text;
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
public int icon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public abstract Fragment newInstance();
|
||||
|
||||
@Override
|
||||
public int code() {
|
||||
// This enumeration is not marshalled so tying declaration order to presentation order is
|
||||
// convenient and consistent.
|
||||
return ordinal();
|
||||
}
|
||||
|
||||
NavTab(@StringRes int text, @DrawableRes int icon) {
|
||||
this.text = text;
|
||||
this.icon = icon;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,28 +8,31 @@ import androidx.fragment.app.FragmentManager;
|
|||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
|
||||
public class NavTabFragmentPagerAdapter extends FragmentPagerAdapter {
|
||||
private Fragment currentFragment;
|
||||
|
||||
public NavTabFragmentPagerAdapter(FragmentManager mgr) {
|
||||
super(mgr);
|
||||
}
|
||||
private Fragment currentFragment;
|
||||
|
||||
@Nullable
|
||||
public Fragment getCurrentFragment() {
|
||||
return currentFragment;
|
||||
}
|
||||
public NavTabFragmentPagerAdapter(FragmentManager mgr) {
|
||||
super(mgr);
|
||||
}
|
||||
|
||||
@Override public Fragment getItem(int pos) {
|
||||
return NavTab.of(pos).newInstance();
|
||||
}
|
||||
@Nullable
|
||||
public Fragment getCurrentFragment() {
|
||||
return currentFragment;
|
||||
}
|
||||
|
||||
@Override public int getCount() {
|
||||
return NavTab.size();
|
||||
}
|
||||
@Override
|
||||
public Fragment getItem(int pos) {
|
||||
return NavTab.of(pos).newInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrimaryItem(ViewGroup container, int position, Object object) {
|
||||
currentFragment = ((Fragment) object);
|
||||
super.setPrimaryItem(container, position, object);
|
||||
}
|
||||
@Override
|
||||
public int getCount() {
|
||||
return NavTab.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrimaryItem(ViewGroup container, int position, Object object) {
|
||||
currentFragment = ((Fragment) object);
|
||||
super.setPrimaryItem(container, position, object);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,32 +10,32 @@ import fr.free.nrw.commons.contributions.MainActivity;
|
|||
|
||||
public class NavTabLayout extends BottomNavigationView {
|
||||
|
||||
public NavTabLayout(Context context) {
|
||||
super(context);
|
||||
setTabViews();
|
||||
}
|
||||
|
||||
public NavTabLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setTabViews();
|
||||
}
|
||||
|
||||
public NavTabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
setTabViews();
|
||||
}
|
||||
|
||||
private void setTabViews() {
|
||||
if (((MainActivity)getContext()).applicationKvStore.getBoolean("login_skipped") == true) {
|
||||
for (int i = 0; i < NavTabLoggedOut.size(); i++) {
|
||||
NavTabLoggedOut navTab = NavTabLoggedOut.of(i);
|
||||
getMenu().add(Menu.NONE, i, i, navTab.text()).setIcon(navTab.icon());
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < NavTab.size(); i++) {
|
||||
NavTab navTab = NavTab.of(i);
|
||||
getMenu().add(Menu.NONE, i, i, navTab.text()).setIcon(navTab.icon());
|
||||
}
|
||||
public NavTabLayout(Context context) {
|
||||
super(context);
|
||||
setTabViews();
|
||||
}
|
||||
|
||||
public NavTabLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setTabViews();
|
||||
}
|
||||
|
||||
public NavTabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
setTabViews();
|
||||
}
|
||||
|
||||
private void setTabViews() {
|
||||
if (((MainActivity) getContext()).applicationKvStore.getBoolean("login_skipped") == true) {
|
||||
for (int i = 0; i < NavTabLoggedOut.size(); i++) {
|
||||
NavTabLoggedOut navTab = NavTabLoggedOut.of(i);
|
||||
getMenu().add(Menu.NONE, i, i, navTab.text()).setIcon(navTab.icon());
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < NavTab.size(); i++) {
|
||||
NavTab navTab = NavTab.of(i);
|
||||
getMenu().add(Menu.NONE, i, i, navTab.text()).setIcon(navTab.icon());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,66 +13,67 @@ import org.wikipedia.model.EnumCodeMap;
|
|||
|
||||
public enum NavTabLoggedOut implements EnumCode {
|
||||
|
||||
EXPLORE(R.string.navigation_item_explore, R.drawable.ic_globe) {
|
||||
EXPLORE(R.string.navigation_item_explore, R.drawable.ic_globe) {
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment newInstance() {
|
||||
return ExploreFragment.newInstance();
|
||||
}
|
||||
},
|
||||
FAVORITES(R.string.favorites, R.drawable.ic_round_star_border_24px) {
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment newInstance() {
|
||||
return BookmarkFragment.newInstance();
|
||||
}
|
||||
},
|
||||
MORE(R.string.more, R.drawable.ic_menu_black_24dp) {
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment newInstance() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
private static final EnumCodeMap<NavTabLoggedOut> MAP = new EnumCodeMap<>(
|
||||
NavTabLoggedOut.class);
|
||||
|
||||
@StringRes
|
||||
private final int text;
|
||||
@DrawableRes
|
||||
private final int icon;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment newInstance() {
|
||||
return ExploreFragment.newInstance();
|
||||
public static NavTabLoggedOut of(int code) {
|
||||
return MAP.get(code);
|
||||
}
|
||||
},
|
||||
FAVORITES(R.string.favorites, R.drawable.ic_round_star_border_24px) {
|
||||
|
||||
public static int size() {
|
||||
return MAP.size();
|
||||
}
|
||||
|
||||
@StringRes
|
||||
public int text() {
|
||||
return text;
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
public int icon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public abstract Fragment newInstance();
|
||||
|
||||
@Override
|
||||
public Fragment newInstance() {
|
||||
return BookmarkFragment.newInstance();
|
||||
public int code() {
|
||||
// This enumeration is not marshalled so tying declaration order to presentation order is
|
||||
// convenient and consistent.
|
||||
return ordinal();
|
||||
}
|
||||
},
|
||||
MORE(R.string.more, R.drawable.ic_menu_black_24dp) {
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment newInstance() {
|
||||
return null;
|
||||
|
||||
NavTabLoggedOut(@StringRes int text, @DrawableRes int icon) {
|
||||
this.text = text;
|
||||
this.icon = icon;
|
||||
}
|
||||
};
|
||||
|
||||
private static final EnumCodeMap<NavTabLoggedOut> MAP = new EnumCodeMap<>(NavTabLoggedOut.class);
|
||||
|
||||
@StringRes
|
||||
private final int text;
|
||||
@DrawableRes
|
||||
private final int icon;
|
||||
|
||||
@NonNull
|
||||
public static NavTabLoggedOut of(int code) {
|
||||
return MAP.get(code);
|
||||
}
|
||||
|
||||
public static int size() {
|
||||
return MAP.size();
|
||||
}
|
||||
|
||||
@StringRes
|
||||
public int text() {
|
||||
return text;
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
public int icon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public abstract Fragment newInstance();
|
||||
|
||||
@Override
|
||||
public int code() {
|
||||
// This enumeration is not marshalled so tying declaration order to presentation order is
|
||||
// convenient and consistent.
|
||||
return ordinal();
|
||||
}
|
||||
|
||||
NavTabLoggedOut(@StringRes int text, @DrawableRes int icon) {
|
||||
this.text = text;
|
||||
this.icon = icon;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue