diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4c0ed4e35..972079285 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -137,12 +137,6 @@ android:configChanges="layoutDirection|locale|keyboardHidden|orientation|screenSize" > - - - - - - @@ -506,6 +500,15 @@ + + + + + + + + + diff --git a/app/src/main/java/org/fdroid/fdroid/views/main/MainActivity.java b/app/src/main/java/org/fdroid/fdroid/views/main/MainActivity.java new file mode 100644 index 000000000..011cc2716 --- /dev/null +++ b/app/src/main/java/org/fdroid/fdroid/views/main/MainActivity.java @@ -0,0 +1,68 @@ +package org.fdroid.fdroid.views.main; + +import android.content.Context; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.design.widget.BottomNavigationView; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.LinearLayoutManager; +import android.view.MenuItem; +import android.support.v7.widget.RecyclerView; + +import org.fdroid.fdroid.R; + +/** + * Main view shown to users upon starting F-Droid. + * + * Shows a bottom navigation bar, with the following entries: + * + Whats new + * + Categories list + * + App swap + * + My apps + * + Settings + * + * Users navigate between items by using the bottom navigation bar, or by swiping left and right. + * When switching from one screen to the next, we stay within this activity. The new screen will + * get inflated (if required) + */ +public class MainActivity extends AppCompatActivity implements BottomNavigationView.OnNavigationItemSelectedListener { + + private RecyclerView pager; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.activity_main); + + pager = (RecyclerView) findViewById(R.id.main_view_pager); + pager.setHasFixedSize(true); + pager.setLayoutManager(new NonScrollingHorizontalLayoutManager(this)); + pager.setAdapter(new MainViewAdapter(this)); + + BottomNavigationView bottomNavigation = (BottomNavigationView) findViewById(R.id.bottom_navigation); + bottomNavigation.setOnNavigationItemSelectedListener(this); + } + + @Override + public boolean onNavigationItemSelected(@NonNull MenuItem item) { + return true; + } + + private static class NonScrollingHorizontalLayoutManager extends LinearLayoutManager { + NonScrollingHorizontalLayoutManager(Context context) { + super(context, LinearLayoutManager.HORIZONTAL, false); + } + + @Override + public boolean canScrollHorizontally() { + return false; + } + + @Override + public boolean canScrollVertically() { + return false; + } + } + +} \ No newline at end of file diff --git a/app/src/main/java/org/fdroid/fdroid/views/main/MainViewAdapter.java b/app/src/main/java/org/fdroid/fdroid/views/main/MainViewAdapter.java new file mode 100644 index 000000000..7d01442d8 --- /dev/null +++ b/app/src/main/java/org/fdroid/fdroid/views/main/MainViewAdapter.java @@ -0,0 +1,46 @@ +package org.fdroid.fdroid.views.main; + +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.RecyclerView; +import android.view.ViewGroup; +import android.widget.FrameLayout; + +/** + * Represents the five main views that are accessible from the main view. These are: + * + Whats new + * + Categories + * + Nearby + * + My Apps + * + Settings + * + * It is responsible for understanding the relationship between each main view that is reachable + * from the bottom navigation, and its position. + * + * It doesn't need to do very much other than redirect requests from the {@link MainActivity}s + * {@link RecyclerView} to the relevant "bind*()" method + * of the {@link MainViewController}. + */ +class MainViewAdapter extends RecyclerView.Adapter { + + private final AppCompatActivity activity; + + MainViewAdapter(AppCompatActivity activity) { + this.activity = activity; + } + + @Override + public MainViewController onCreateViewHolder(ViewGroup parent, int viewType) { + FrameLayout frame = new FrameLayout(activity); + frame.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); + return new MainViewController(activity, frame); + } + + @Override + public void onBindViewHolder(MainViewController holder, int position) { + } + + @Override + public int getItemCount() { + return 5; + } +} diff --git a/app/src/main/java/org/fdroid/fdroid/views/main/MainViewController.java b/app/src/main/java/org/fdroid/fdroid/views/main/MainViewController.java new file mode 100644 index 000000000..572c58d57 --- /dev/null +++ b/app/src/main/java/org/fdroid/fdroid/views/main/MainViewController.java @@ -0,0 +1,24 @@ +package org.fdroid.fdroid.views.main; + +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.RecyclerView; +import android.widget.FrameLayout; + +/** + * Decides which view on the main screen to attach to a given {@link FrameLayout}. This class + * doesn't know which view it will be rendering at the time it is constructed. Rather, at some + * point in the future the {@link MainViewAdapter} will have information about which view we + * are required to render, and will invoke the relevant "bind*()" method on this class. + */ +class MainViewController extends RecyclerView.ViewHolder { + + private final AppCompatActivity activity; + private final FrameLayout frame; + + MainViewController(AppCompatActivity activity, FrameLayout frame) { + super(frame); + this.activity = activity; + this.frame = frame; + } + +} diff --git a/app/src/main/res/drawable/ic_category.xml b/app/src/main/res/drawable/ic_category.xml new file mode 100644 index 000000000..b71523ac0 --- /dev/null +++ b/app/src/main/res/drawable/ic_category.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_my_apps.xml b/app/src/main/res/drawable/ic_my_apps.xml new file mode 100644 index 000000000..8bb1ec68b --- /dev/null +++ b/app/src/main/res/drawable/ic_my_apps.xml @@ -0,0 +1,6 @@ + + + diff --git a/app/src/main/res/drawable/ic_nearby.xml b/app/src/main/res/drawable/ic_nearby.xml new file mode 100644 index 000000000..c05402310 --- /dev/null +++ b/app/src/main/res/drawable/ic_nearby.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_overview.xml b/app/src/main/res/drawable/ic_overview.xml new file mode 100644 index 000000000..8aec73afc --- /dev/null +++ b/app/src/main/res/drawable/ic_overview.xml @@ -0,0 +1,6 @@ + + + diff --git a/app/src/main/res/drawable/ic_settings.xml b/app/src/main/res/drawable/ic_settings.xml new file mode 100644 index 000000000..7fb01b86a --- /dev/null +++ b/app/src/main/res/drawable/ic_settings.xml @@ -0,0 +1,6 @@ + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 000000000..c460ad897 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,26 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/main_activity_screens.xml b/app/src/main/res/menu/main_activity_screens.xml new file mode 100644 index 000000000..d2facc6ce --- /dev/null +++ b/app/src/main/res/menu/main_activity_screens.xml @@ -0,0 +1,29 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2976c7f7a..ea8e5e513 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -130,6 +130,11 @@ Litecoin Flattr + Latest + Categories + Nearby + My Apps + Version %s installed Not installed