Skip to content
Snippets Groups Projects
Commit efb27372 authored by Jawnnypoo's avatar Jawnnypoo
Browse files

Add setting to set the app starting view

parent b9d4a374
No related branches found
No related tags found
No related merge requests found
Showing
with 125 additions and 31 deletions
Loading
Loading
@@ -51,6 +51,7 @@
<activity android:name=".activity.BuildActivity"/>
<activity android:name=".activity.LoadSomeInfoActivity"
android:theme="@style/Activity.Translucent"/>
<activity android:name=".activity.SettingsActivity"/>
 
<activity
android:name=".activity.RoutingActivity"
Loading
Loading
Loading
Loading
@@ -46,7 +46,7 @@ import timber.log.Timber;
public class AboutActivity extends BaseActivity {
private static final String REPO_ID = "473568";
 
public static Intent newInstance(Context context) {
public static Intent newIntent(Context context) {
Intent intent = new Intent(context, AboutActivity.class);
return intent;
}
Loading
Loading
Loading
Loading
@@ -4,7 +4,6 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.widget.Toolbar;
Loading
Loading
@@ -28,7 +27,7 @@ public class ActivityActivity extends BaseActivity {
 
private static final String TAG_FEED_FRAGMENT = "feed_fragment";
 
public static Intent newInstance(Context context) {
public static Intent newIntent(Context context) {
Intent intent = new Intent(context, ActivityActivity.class);
return intent;
}
Loading
Loading
Loading
Loading
@@ -41,11 +41,11 @@ public class AddMilestoneActivity extends MorphActivity {
private static final String KEY_PROJECT_ID = "project_id";
private static final String KEY_MILESTONE = "milestone";
 
public static Intent newInstance(Context context, long projectId) {
return newInstance(context, projectId, null);
public static Intent newIntent(Context context, long projectId) {
return newIntent(context, projectId, null);
}
 
public static Intent newInstance(Context context, long projectId, Milestone milestone) {
public static Intent newIntent(Context context, long projectId, Milestone milestone) {
Intent intent = new Intent(context, AddMilestoneActivity.class);
intent.putExtra(KEY_PROJECT_ID, projectId);
if (milestone != null) {
Loading
Loading
Loading
Loading
@@ -35,7 +35,7 @@ public class BuildActivity extends BaseActivity {
private static final String KEY_PROJECT = "key_project";
private static final String KEY_BUILD = "key_merge_request";
 
public static Intent newInstance(Context context, Project project, Build build) {
public static Intent newIntent(Context context, Project project, Build build) {
Intent intent = new Intent(context, BuildActivity.class);
intent.putExtra(KEY_PROJECT, Parcels.wrap(project));
intent.putExtra(KEY_BUILD, Parcels.wrap(build));
Loading
Loading
Loading
Loading
@@ -37,7 +37,7 @@ public class DiffActivity extends BaseActivity {
private static final String EXTRA_PROJECT = "extra_project";
private static final String EXTRA_COMMIT = "extra_commit";
 
public static Intent newInstance(Context context, Project project, RepositoryCommit commit) {
public static Intent newIntent(Context context, Project project, RepositoryCommit commit) {
Intent intent = new Intent(context, DiffActivity.class);
intent.putExtra(EXTRA_PROJECT, Parcels.wrap(project));
intent.putExtra(EXTRA_COMMIT, Parcels.wrap(commit));
Loading
Loading
Loading
Loading
@@ -41,13 +41,13 @@ public class GroupActivity extends BaseActivity {
private static final String KEY_GROUP = "key_group";
private static final String KEY_GROUP_ID = "key_group_id";
 
public static Intent newInstance(Context context, Group group) {
public static Intent newIntent(Context context, Group group) {
Intent intent = new Intent(context, GroupActivity.class);
intent.putExtra(KEY_GROUP, Parcels.wrap(group));
return intent;
}
 
public static Intent newInstance(Context context, long groupId) {
public static Intent newIntent(Context context, long groupId) {
Intent intent = new Intent(context, GroupActivity.class);
intent.putExtra(KEY_GROUP_ID, groupId);
return intent;
Loading
Loading
Loading
Loading
@@ -4,7 +4,6 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
Loading
Loading
@@ -40,7 +39,7 @@ import timber.log.Timber;
*/
public class GroupsActivity extends BaseActivity {
 
public static Intent newInstance(Context context) {
public static Intent newIntent(Context context) {
Intent intent = new Intent(context, GroupsActivity.class);
return intent;
}
Loading
Loading
Loading
Loading
@@ -62,14 +62,14 @@ public class IssueActivity extends BaseActivity {
 
private static final int REQUEST_IMAGE = 1;
 
public static Intent newInstance(Context context, Project project, Issue issue) {
public static Intent newIntent(Context context, Project project, Issue issue) {
Intent intent = new Intent(context, IssueActivity.class);
intent.putExtra(EXTRA_PROJECT, Parcels.wrap(project));
intent.putExtra(EXTRA_SELECTED_ISSUE, Parcels.wrap(issue));
return intent;
}
 
public static Intent newInstance(Context context, String namespace, String projectName, String issueIid) {
public static Intent newIntent(Context context, String namespace, String projectName, String issueIid) {
Intent intent = new Intent(context, IssueActivity.class);
intent.putExtra(EXTRA_PROJECT_NAMESPACE, namespace);
intent.putExtra(EXTRA_PROJECT_NAME, projectName);
Loading
Loading
Loading
Loading
@@ -46,7 +46,7 @@ public class LaunchActivity extends Activity {
runOnUiThread(new Runnable() {
@Override
public void run() {
NavigationManager.navigateToProjects(LaunchActivity.this);
NavigationManager.navigateToStartingActivity(LaunchActivity.this);
finish();
}
});
Loading
Loading
Loading
Loading
@@ -35,7 +35,7 @@ public class LoadSomeInfoActivity extends AppCompatActivity {
private static final int LOAD_TYPE_DIFF = 0;
private static final int LOAD_TYPE_MERGE_REQUEST = 1;
 
public static Intent newInstance(Context context, String namespace, String projectName, String commitSha) {
public static Intent newIntent(Context context, String namespace, String projectName, String commitSha) {
Intent intent = new Intent(context, LoadSomeInfoActivity.class);
intent.putExtra(EXTRA_PROJECT_NAMESPACE, namespace);
intent.putExtra(EXTRA_PROJECT_NAME, projectName);
Loading
Loading
@@ -44,7 +44,7 @@ public class LoadSomeInfoActivity extends AppCompatActivity {
return intent;
}
 
public static Intent newMergeRequestInstance(Context context, String namespace, String projectName, String mergeRequestId) {
public static Intent newMergeRequestIntent(Context context, String namespace, String projectName, String mergeRequestId) {
Intent intent = new Intent(context, LoadSomeInfoActivity.class);
intent.putExtra(EXTRA_PROJECT_NAMESPACE, namespace);
intent.putExtra(EXTRA_PROJECT_NAME, projectName);
Loading
Loading
Loading
Loading
@@ -73,11 +73,11 @@ public class LoginActivity extends BaseActivity {
private static final int PERMISSION_REQUEST_GET_ACCOUNTS = 1337;
private static Pattern sTokenPattern = Pattern.compile("^[A-Za-z0-9-_]*$");
 
public static Intent newInstance(Context context) {
return newInstance(context, false);
public static Intent newIntent(Context context) {
return newIntent(context, false);
}
 
public static Intent newInstance(Context context, boolean showClose) {
public static Intent newIntent(Context context, boolean showClose) {
Intent intent = new Intent(context, LoginActivity.class);
intent.putExtra(EXTRA_SHOW_CLOSE, showClose);
return intent;
Loading
Loading
@@ -294,7 +294,7 @@ public class LoginActivity extends BaseActivity {
LabCoatApp.bus().post(new LoginEvent(mAccount));
//This is mostly for if projects already exists, then we will reload the data
LabCoatApp.bus().post(new ReloadDataEvent());
NavigationManager.navigateToProjects(LoginActivity.this);
NavigationManager.navigateToStartingActivity(LoginActivity.this);
finish();
}
 
Loading
Loading
Loading
Loading
@@ -35,7 +35,7 @@ public class MergeRequestActivity extends BaseActivity {
private static final String KEY_PROJECT = "key_project";
private static final String KEY_MERGE_REQUEST = "key_merge_request";
 
public static Intent newInstance(Context context, Project project, MergeRequest mergeRequest) {
public static Intent newIntent(Context context, Project project, MergeRequest mergeRequest) {
Intent intent = new Intent(context, MergeRequestActivity.class);
intent.putExtra(KEY_PROJECT, Parcels.wrap(project));
intent.putExtra(KEY_MERGE_REQUEST, Parcels.wrap(mergeRequest));
Loading
Loading
Loading
Loading
@@ -44,7 +44,7 @@ public class MilestoneActivity extends BaseActivity {
private static final String EXTRA_PROJECT = "extra_project";
private static final String EXTRA_MILESTONE = "extra_milestone";
 
public static Intent newInstance(Context context, Project project, Milestone milestone) {
public static Intent newIntent(Context context, Project project, Milestone milestone) {
Intent intent = new Intent(context, MilestoneActivity.class);
intent.putExtra(EXTRA_PROJECT, Parcels.wrap(project));
intent.putExtra(EXTRA_MILESTONE, Parcels.wrap(milestone));
Loading
Loading
Loading
Loading
@@ -46,13 +46,13 @@ public class ProjectActivity extends BaseActivity {
private static final String EXTRA_PROJECT = "extra_project";
private static final String EXTRA_PROJECT_ID = "extra_project_id";
 
public static Intent newInstance(Context context, Project project) {
public static Intent newIntent(Context context, Project project) {
Intent intent = new Intent(context, ProjectActivity.class);
intent.putExtra(EXTRA_PROJECT, Parcels.wrap(project));
return intent;
}
 
public static Intent newInstance(Context context, String projectId) {
public static Intent newIntent(Context context, String projectId) {
Intent intent = new Intent(context, ProjectActivity.class);
intent.putExtra(EXTRA_PROJECT_ID, projectId);
return intent;
Loading
Loading
Loading
Loading
@@ -3,7 +3,6 @@ package com.commit451.gitlab.activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.design.widget.NavigationView;
import android.support.design.widget.TabLayout;
import android.support.v4.view.GravityCompat;
Loading
Loading
@@ -28,7 +27,7 @@ import butterknife.ButterKnife;
*/
public class ProjectsActivity extends BaseActivity {
 
public static Intent newInstance(Context context) {
public static Intent newIntent(Context context) {
Intent intent = new Intent(context, ProjectsActivity.class);
return intent;
}
Loading
Loading
Loading
Loading
@@ -75,7 +75,7 @@ public class RoutingActivity extends Activity {
String projectNamespace = link.getPathSegments().get(0);
String projectName = link.getPathSegments().get(1);
String commitSha = link.getPathSegments().get(3);
startActivity(LoadSomeInfoActivity.newInstance(this, projectNamespace, projectName, commitSha));
startActivity(LoadSomeInfoActivity.newIntent(this, projectNamespace, projectName, commitSha));
overridePendingTransition(R.anim.fade_in, R.anim.do_nothing);
handled = true;
}
Loading
Loading
@@ -93,7 +93,7 @@ public class RoutingActivity extends Activity {
String projectNamespace = link.getPathSegments().get(i-2);
String projectName = link.getPathSegments().get(i-1);
String mergeRequestId = link.getPathSegments().get(i+1);
startActivity(LoadSomeInfoActivity.newMergeRequestInstance(this, projectNamespace, projectName, mergeRequestId));
startActivity(LoadSomeInfoActivity.newMergeRequestIntent(this, projectNamespace, projectName, mergeRequestId));
overridePendingTransition(R.anim.fade_in, R.anim.do_nothing);
handled = true;
break;
Loading
Loading
Loading
Loading
@@ -29,7 +29,7 @@ import timber.log.Timber;
*/
public class SearchActivity extends BaseActivity {
 
public static Intent newInstance(Context context) {
public static Intent newIntent(Context context) {
Intent intent = new Intent(context, SearchActivity.class);
return intent;
}
Loading
Loading
package com.commit451.gitlab.activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;
import com.afollestad.materialdialogs.MaterialDialog;
import com.commit451.gitlab.R;
import com.commit451.gitlab.data.Prefs;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
/**
* Settings
*/
public class SettingsActivity extends BaseActivity {
private static final int REQUEST_COUNTRY = 1;
public static Intent newIntent(Context context) {
Intent intent = new Intent(context, SettingsActivity.class);
return intent;
}
@BindView(R.id.toolbar)
Toolbar mToolbar;
@BindView(R.id.text_launch_activity)
TextView mTextLaunchActivity;
@OnClick(R.id.root_launch_activity)
void onLaunchActivityClicked() {
new MaterialDialog.Builder(this)
.title(R.string.setting_starting_view)
.items(R.array.setting_starting_view_choices)
.itemsCallbackSingleChoice(getSelectedIndex(), new MaterialDialog.ListCallbackSingleChoice() {
@Override
public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
Prefs.setStartingView(SettingsActivity.this, which);
bindPrefs();
/**
* If you use alwaysCallSingleChoiceCallback(), which is discussed below,
* returning false here won't allow the newly selected radio button to actually be selected.
**/
return true;
}
})
.show();
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
ButterKnife.bind(this);
mToolbar.setTitle(R.string.settings);
mToolbar.setNavigationIcon(R.drawable.ic_back_24dp);
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
bindPrefs();
}
private void bindPrefs() {
setStartingViewSelection();
}
private void setStartingViewSelection() {
int startinView = Prefs.getStartingView(this);
switch (startinView) {
case Prefs.STARTING_VIEW_PROJECTS:
mTextLaunchActivity.setText(R.string.setting_starting_view_projects);
break;
case Prefs.STARTING_VIEW_GROUPS:
mTextLaunchActivity.setText(R.string.setting_starting_view_groups);
break;
case Prefs.STARTING_VIEW_ACTIVITY:
mTextLaunchActivity.setText(R.string.setting_starting_view_activity);
break;
}
}
private int getSelectedIndex() {
return Prefs.getStartingView(this);
}
}
Loading
Loading
@@ -35,7 +35,7 @@ public class UserActivity extends BaseActivity {
 
private static final String KEY_USER = "user";
 
public static Intent newInstance(Context context, UserBasic user) {
public static Intent newIntent(Context context, UserBasic user) {
Intent intent = new Intent(context, UserActivity.class);
intent.putExtra(KEY_USER, Parcels.wrap(user));
return intent;
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment