Commit 8d16af49 authored by M M Arif's avatar M M Arif

wip on issues and tabs

Signed-off-by: M M Arif's avatarM M Arif <mmarif@swatian.com>
parent ddd739d1
......@@ -40,4 +40,4 @@ dependencies {
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
}
\ No newline at end of file
}
......@@ -12,6 +12,10 @@
android:roundIcon="@mipmap/app_logo_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".activities.RepoDetailActivity"
android:label="@string/title_activity_repo_detail"
android:theme="@style/AppTheme.NoActionBar"></activity>
<activity android:name=".activities.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
......@@ -22,8 +26,8 @@
<activity
android:name=".activities.LoginActivity"
android:launchMode="singleTask" />
<activity android:name=".activities.NewRepoActivity"></activity>
<activity android:name=".activities.NewOrganizationActivity"></activity>
<activity android:name=".activities.NewRepoActivity" />
<activity android:name=".activities.NewOrganizationActivity" />
</application>
</manifest>
\ No newline at end of file
package org.mian.gitnex.activities;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.mian.gitnex.R;
import org.mian.gitnex.fragments.IssuesFragment;
public class RepoDetailActivity extends AppCompatActivity {
/**
* The {@link androidx.viewpager.widget.PagerAdapter} that will provide
* fragments for each of the sections. We use a
* {@link FragmentPagerAdapter} derivative, which will keep every
* loaded fragment in memory. If this becomes too memory intensive, it
* may be best to switch to a
* androidx.fragment.app.FragmentStatePagerAdapter.
*/
private SectionsPagerAdapter mSectionsPagerAdapter;
/**
* The {@link ViewPager} that will host the section contents.
*/
private ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_repo_detail);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.container);
mViewPager.setAdapter(mSectionsPagerAdapter);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_repo_detail, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
/**
* The fragment argument representing the section number for this
* fragment.
*/
private static final String ARG_SECTION_NUMBER = "section_number";
public PlaceholderFragment() {
}
/**
* Returns a new instance of this fragment for the given section
* number.
*/
public static PlaceholderFragment newInstance(int sectionNumber) {
PlaceholderFragment fragment = new PlaceholderFragment();
Bundle args = new Bundle();
args.putInt(ARG_SECTION_NUMBER, sectionNumber);
fragment.setArguments(args);
return fragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_repo_detail, container, false);
TextView textView = (TextView) rootView.findViewById(R.id.section_label);
textView.setText(getString(R.string.section_format, getArguments().getInt(ARG_SECTION_NUMBER)));
return rootView;
}
}
/**
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to
* one of the sections/tabs/pages.
*/
public class SectionsPagerAdapter extends FragmentPagerAdapter {
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
Fragment fragment = null;
switch (position) {
case 0:
fragment = new IssuesFragment();
break;
case 1:
fragment = new IssuesFragment();
break;
case 2:
fragment = new IssuesFragment();
break;
}
return fragment;
}
@Override
public int getCount() {
// Show 3 total pages.
return 3;
}
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "Info";
case 1:
return "Issues";
case 2:
return "Milestones";
}
return null;
}
}
}
package org.mian.gitnex.adaptors;
import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
......@@ -14,8 +15,9 @@ import android.widget.TextView;
import com.amulyakhare.textdrawable.TextDrawable;
import com.amulyakhare.textdrawable.util.ColorGenerator;
import org.mian.gitnex.R;
import org.mian.gitnex.activities.RepoDetailActivity;
import org.mian.gitnex.models.UserRepositories;
import org.mian.gitnex.util.TinyDB;
import java.util.ArrayList;
import java.util.List;
......@@ -48,6 +50,21 @@ public class ReposListAdaptor extends RecyclerView.Adapter<ReposListAdaptor.Repo
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
repoStars = itemView.findViewById(R.id.repoStars);
repoWatchers = itemView.findViewById(R.id.repoWatchers);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Context context = v.getContext();
TextView phoneName = (TextView) v.findViewById(R.id.repoName);
Intent intent = new Intent(context, RepoDetailActivity.class);
intent.putExtra("hello", phoneName.getText().toString());
TinyDB tinyDb = new TinyDB(context);
tinyDb.putString("hello", phoneName.getText().toString());
context.startActivity(intent);
}
});
}
}
......
......@@ -4,11 +4,15 @@ import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import org.mian.gitnex.R;
import org.mian.gitnex.activities.MainActivity;
import org.mian.gitnex.util.TinyDB;
import java.util.Objects;
/**
......@@ -21,7 +25,8 @@ public class IssuesFragment extends Fragment {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
((MainActivity) Objects.requireNonNull(getActivity())).setActionBarTitle(getResources().getString(R.string.pageTitleIssues));
TinyDB tinyDb = new TinyDB(getContext());
Log.i("tinyDB", tinyDb.getString("hello"));
return inflater.inflate(R.layout.fragment_issues, container, false);
}
}
<vector android:height="24dp" android:viewportHeight="1024"
android:viewportWidth="1024" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#CFCFCF" android:pathData="M704,316.03l-96,96L768,576l256,-256 -96,-96L769.25,382.78 704,316.03zM512,832c-176.78,0 -320,-143.25 -320,-320 0,-176.78 143.22,-320 320,-320 88.38,0 168.38,35.84 226.25,93.75l90.56,-90.5C747.75,114.13 635.75,64 512,64 264.56,64 64,264.56 64,512c0,247.44 200.56,448 448,448 247.44,0 448,-200.56 448,-448L759.75,712.25C768.69,701.25 684.75,832 512,832zM576,256H448v320h128V256zM448,768h128V640H448V768z"/>
</vector>
<vector android:height="24dp" android:viewportHeight="1024"
android:viewportWidth="896" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#CFCFCF" android:pathData="M448,64C200.56,64 0,264.56 0,512c0,247.44 200.56,448 448,448 247.44,0 448,-200.56 448,-448C896,264.56 695.44,64 448,64zM448,832c-176.78,0 -320,-143.25 -320,-320 0,-176.78 143.22,-320 320,-320 176.75,0 320,143.22 320,320C768,688.75 624.75,832 448,832zM384,768h128V640H384V768zM384,576h128V256H384V576z"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".activities.RepoDetailActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_weight="1"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:title="@string/app_name">
</androidx.appcompat.widget.Toolbar>
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.tabs.TabItem
android:id="@+id/tabItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tab_text_1" />
<com.google.android.material.tabs.TabItem
android:id="@+id/tabItem2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tab_text_2" />
<com.google.android.material.tabs.TabItem
android:id="@+id/tabItem3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tab_text_3" />
</com.google.android.material.tabs.TabLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@android:drawable/ic_dialog_email" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/backgroundColor">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/wip"
android:layout_centerInParent="true"
android:textColor="@color/colorWhite"
android:textSize="30sp" />
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearLayoutFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_marginTop="0dp"
android:fitsSystemWindows="true"
android:orientation="vertical"
android:padding="10dp"
android:theme="@style/AppTheme"
tools:context=".activities.MainActivity">
</RelativeLayout>
\ No newline at end of file
<ImageView
android:id="@+id/assigneeAvatar"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginEnd="15dp"
android:contentDescription="@string/repoContentAvatar"
android:src="@drawable/ic_android" />
<LinearLayout
android:id="@+id/infoSection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/assigneeAvatar"
android:orientation="vertical">
<LinearLayout
android:id="@+id/frameIssueNameStatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="10dp">
<TextView
android:id="@+id/issueTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".85"
android:text="Another one for api testing and long title to bring it to second line."
android:textColor="@color/white"
android:textSize="16sp" />
<ImageView
android:id="@+id/issueStatus"
android:layout_width="10dp"
android:layout_height="20dp"
android:layout_weight=".15"
android:layout_gravity="end"
android:contentDescription="@string/repoContentAvatar"
android:src="@drawable/ic_issue_closed" />
</LinearLayout>
<LinearLayout
android:id="@+id/frameAssignees"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="10dp">
<ImageView
android:id="@+id/assigneesAvatar"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginEnd="15dp"
android:contentDescription="@string/repoContentAvatar"
android:src="@drawable/ic_android" />
<ImageView
android:id="@+id/assigneesAvatar2"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginEnd="15dp"
android:contentDescription="@string/repoContentAvatar"
android:src="@drawable/ic_android" />
</LinearLayout>
<TextView
android:id="@+id/issueDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="If we wanted to send data between 2 or more fragments of the same activity in the past, we had to do the communication over the underlying activity using interfaces and public"
android:textColor="@color/colorWhite"
android:textSize="14sp"
android:visibility="visible" />
<LinearLayout
android:id="@+id/frameLabels"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="10dp">
<TextView
android:id="@+id/label1"
android:layout_width="wrap_content"
android:layout_height="18dp"
android:layout_marginEnd="15dp"
android:textSize="14sp"
android:text="help wanted"
android:textColor="@color/colorWhite"
android:contentDescription="@string/repoContentAvatar"
android:src="@drawable/ic_android" />
<TextView
android:id="@+id/label2"
android:layout_width="wrap_content"
android:layout_height="18dp"
android:layout_marginEnd="15dp"
android:textSize="14sp"
android:text="bug"
android:textColor="@color/colorWhite"
android:contentDescription="@string/repoContentAvatar"
android:src="@drawable/ic_android" />
</LinearLayout>
<LinearLayout
android:id="@+id/frameTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:orientation="horizontal">
<TextView
android:id="@+id/issueCreatedTime"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".50"
android:width="18dp"
android:height="18dp"
android:text="created at 2019-01-28"
android:textColor="@color/colorWhite"
android:textSize="14sp" />
<TextView
android:id="@+id/issueUpdatedTime"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".50"
android:width="18dp"
android:height="18dp"
android:layout_gravity="end"
android:gravity="end"
android:text="updated at 2019-01-28"
android:textColor="@color/colorWhite"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.RepoDetailActivity$PlaceholderFragment">
<TextView
android:id="@+id/section_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_marginBottom="@dimen/activity_vertical_margin"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="@+id/constraintLayout"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintTop_creator="1" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="org.mian.gitnex.activities.RepoDetailActivity">
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never" />
</menu>
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
......@@ -5,4 +5,6 @@
<dimen name="nav_header_height">176dp</dimen>
<dimen name="tooltipCornor">5dp</dimen>
<dimen name="fab_margin">16dp</dimen>
<dimen name="appbar_padding_top">8dp</dimen>
</resources>
......@@ -100,5 +100,11 @@
<string name="repoWatchers">98324</string>
<string name="genericApiStatusError">Instance has returned an error. Code\u0020</string>
<string name="title_activity_repo_detail">RepoDetailActivity</string>
<string name="tab_text_1">Tab 1</string>
<string name="tab_text_2">Tab 2</string>
<string name="tab_text_3">Tab 3</string>
<string name="action_settings">Settings</string>
<string name="section_format">Hello World from section: %1$d</string>
</resources>
......@@ -18,4 +18,13 @@
<item name="colorControlActivated">@color/colorWhite</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment