Commit 071ceba1 authored by M M Arif's avatar M M Arif

Implement pretty time, layout updates and fixes

Signed-off-by: M M Arif's avatarM M Arif <mmarif@swatian.com>
parent cdd4daed
......@@ -34,10 +34,11 @@ Option 2 - Open terminal(Linux) and cd to the project dir. Run `./gradlew build`
2- Create new organization
3- Repositories list
4- Organizations list
5- Login/Logout
6- Search/filter repositories and organizations
7- Profile view
8- Repository stars and watchers
5- Search/filter repositories and organizations
6- Profile view
7- Repository stars, watchers, issues count
8- Repository information
9- Login/Logout
More to come...
## Screenshots:
......
......@@ -37,6 +37,7 @@ dependencies {
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.1'
implementation 'org.ocpsoft.prettytime:prettytime:4.0.1.Final'
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
......
......@@ -48,11 +48,18 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
protected void onCreate(Bundle savedInstanceState) {
TinyDB tinyDb = new TinyDB(getApplicationContext());
// ======================== These have to go to settings ==========================
tinyDb.putString("locale", "en"); // en, fr
tinyDb.putString("dateFormat", "pretty"); // pretty(1 week ago), normal(2019-01-30 at 12:23), normal1(30-01-2019 at 12:23)
// ======================== These have to go to settings ==========================
final String instanceUrl = tinyDb.getString("instanceUrl");
final String loginUid = tinyDb.getString("loginUid");
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
AppUtil.setAppLocale(getResources(), "en");
String appLocale = tinyDb.getString("locale");
AppUtil.setAppLocale(getResources(), appLocale);
boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
......
......@@ -17,6 +17,10 @@ import org.mian.gitnex.R;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.models.UserRepositories;
import org.mian.gitnex.util.TinyDB;
import org.ocpsoft.prettytime.PrettyTime;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Locale;
/**
* Author M M Arif
......@@ -42,7 +46,6 @@ public class RepoInfoFragment extends Fragment {
private TextView repoRepoUrlInfo;
private TextView repoForksCountInfo;
private TextView repoCreatedAtInfo;
private TextView repoUpdatedAtInfo;
private OnFragmentInteractionListener mListener;
......@@ -69,8 +72,7 @@ public class RepoInfoFragment extends Fragment {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_repo_info, container, false);
......@@ -78,6 +80,8 @@ public class RepoInfoFragment extends Fragment {
final String instanceUrl = tinyDb.getString("instanceUrl");
final String loginUid = tinyDb.getString("loginUid");
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
final String locale = tinyDb.getString("locale");
final String timeFormat = tinyDb.getString("dateFormat");
pageContent = v.findViewById(R.id.repoInfoLayout);
pageContent.setVisibility(View.GONE);
......@@ -94,9 +98,9 @@ public class RepoInfoFragment extends Fragment {
repoRepoUrlInfo = v.findViewById(R.id.repoRepoUrlInfo);
repoForksCountInfo = v.findViewById(R.id.repoForksCountInfo);
repoCreatedAtInfo = v.findViewById(R.id.repoCreatedAtInfo);
repoUpdatedAtInfo = v.findViewById(R.id.repoUpdatedAtInfo);
getRepoInfo(instanceUrl, instanceToken, repoOwner, repoName);
getRepoInfo(instanceUrl, instanceToken, repoOwner, repoName, locale, timeFormat);
Log.i("timeFormat", timeFormat);
return v;
}
......@@ -117,7 +121,7 @@ public class RepoInfoFragment extends Fragment {
void onFragmentInteraction(Uri uri);
}
private void getRepoInfo(String instanceUrl, String token, final String owner, String repo) {
private void getRepoInfo(String instanceUrl, String token, final String owner, String repo, final String locale, final String timeFormat) {
Call<UserRepositories> call = RetrofitClient
.getInstance(instanceUrl)
......@@ -145,8 +149,23 @@ public class RepoInfoFragment extends Fragment {
repoCloneUrlInfo.setText(repoInfo.getClone_url());
repoRepoUrlInfo.setText(repoInfo.getHtml_url());
repoForksCountInfo.setText(repoInfo.getForks_count());
repoCreatedAtInfo.setText(repoInfo.getCreated_at());
repoUpdatedAtInfo.setText(repoInfo.getUpdated_at());
if(timeFormat == "pretty") {
PrettyTime prettyTime = new PrettyTime(new Locale(locale));
String createdTime = prettyTime.format(repoInfo.getCreated_at());
repoCreatedAtInfo.setText(createdTime);
}
else if(timeFormat == "normal") {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd " + getResources().getString(R.string.timeAtText) + " HH:mm", new Locale(locale));
String createdTime = formatter.format(repoInfo.getCreated_at());
repoCreatedAtInfo.setText(createdTime);
}
else if(timeFormat == "normal1") {
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy " + getResources().getString(R.string.timeAtText) + " HH:mm", new Locale(locale));
String createdTime = formatter.format(repoInfo.getCreated_at());
repoCreatedAtInfo.setText(createdTime);
}
mProgressBar.setVisibility(View.GONE);
pageContent.setVisibility(View.VISIBLE);
......
package org.mian.gitnex.models;
import com.google.gson.annotations.SerializedName;
import java.util.Date;
/**
* Author M M Arif
......@@ -19,7 +20,7 @@ public class UserRepositories {
private String open_issues_count;
private String html_url;
private String default_branch;
private String created_at;
private Date created_at;
private String updated_at;
private String clone_url;
private String size;
......@@ -68,7 +69,7 @@ public class UserRepositories {
return default_branch;
}
public String getCreated_at() {
public Date getCreated_at() {
return created_at;
}
......
......@@ -207,23 +207,6 @@
android:paddingTop="5dp"
android:textColor="@color/colorWhite"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoUpdatedAt"
android:textSize="16sp"
android:textColor="@color/white"
android:layout_marginTop="15dp"/>
<TextView
android:id="@+id/repoUpdatedAtInfo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoDummyTime"
android:textSize="16sp"
android:paddingTop="5dp"
android:textColor="@color/colorWhite"/>
</LinearLayout>
</ScrollView>
......
......@@ -111,11 +111,13 @@
<string name="infoTabRepoCloneUrl">Clone URL</string>
<string name="infoTabRepoRepoUrl">Repo URL</string>
<string name="infoTabRepoForksCount">Forks Count</string>
<string name="infoTabRepoCreatedAt">Create at</string>
<string name="infoTabRepoUpdatedAt">Updated at</string>
<string name="infoTabRepoCreatedAt">Created</string>
<string name="infoTabRepoUpdatedAt">Last Updated</string>
<string name="infoTabRepoDummyTime">2018&#8211;10&#8211;30 08:25:25</string>
<string name="infoTabRepoBlank">&#8230;</string>
<string name="infoTabRepoZero">0</string>
<string name="infoTabRepoDefaultBranchText">master</string>
<string name="timeAtText">à</string>
</resources>
\ No newline at end of file
......@@ -121,11 +121,13 @@
<string name="infoTabRepoCloneUrl">Clone URL</string>
<string name="infoTabRepoRepoUrl">Repo URL</string>
<string name="infoTabRepoForksCount">Forks Count</string>
<string name="infoTabRepoCreatedAt">Create at</string>
<string name="infoTabRepoUpdatedAt">Updated at</string>
<string name="infoTabRepoCreatedAt">Created</string>
<string name="infoTabRepoUpdatedAt">Last Updated</string>
<string name="infoTabRepoDummyTime">2018&#8211;10&#8211;30 08:25:25</string>
<string name="infoTabRepoBlank">&#8230;</string>
<string name="infoTabRepoZero">0</string>
<string name="infoTabRepoDefaultBranchText">master</string>
<string name="timeAtText">at</string>
</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