Profile details edit - work in progress
This commit is contained in:
parent
6bd8fda90a
commit
289e2e8679
8 changed files with 95 additions and 32 deletions
|
@ -1063,8 +1063,14 @@
|
||||||
<activity
|
<activity
|
||||||
android:configChanges="keyboardHidden|orientation"
|
android:configChanges="keyboardHidden|orientation"
|
||||||
android:label="Application profiles"
|
android:label="Application profiles"
|
||||||
android:name=".profiles.SettingsProfileActivity">
|
android:name=".profiles.SettingsProfileActivity"/>
|
||||||
</activity>
|
|
||||||
|
|
||||||
|
<activity android:name=".profiles.SelectedProfileActivity"
|
||||||
|
android:label="Application profiles"
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
|
@ -64,6 +64,7 @@
|
||||||
android:src="@drawable/ic_action_additional_option"
|
android:src="@drawable/ic_action_additional_option"
|
||||||
android:tint="?attr/primary_icon_color"
|
android:tint="?attr/primary_icon_color"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
|
android:clickable="true"
|
||||||
android:padding="@dimen/setting_profile_item_switch_margin"/>
|
android:padding="@dimen/setting_profile_item_switch_margin"/>
|
||||||
|
|
||||||
<android.support.v7.widget.SwitchCompat
|
<android.support.v7.widget.SwitchCompat
|
||||||
|
|
|
@ -17,38 +17,38 @@ public class OsmandActionBarActivity extends OsmandInAppPurchaseActivity {
|
||||||
|
|
||||||
protected boolean haveHomeButton = true;
|
protected boolean haveHomeButton = true;
|
||||||
|
|
||||||
//should be called after set content view
|
//should be called after set content view
|
||||||
protected void setupHomeButton(){
|
protected void setupHomeButton() {
|
||||||
Drawable back = ((OsmandApplication)getApplication()).getUIUtilities().getIcon(R.drawable.ic_arrow_back, R.color.color_white);
|
Drawable back = ((OsmandApplication) getApplication()).getUIUtilities().getIcon(R.drawable.ic_arrow_back, R.color.color_white);
|
||||||
final ActionBar supportActionBar = getSupportActionBar();
|
final ActionBar supportActionBar = getSupportActionBar();
|
||||||
if (supportActionBar != null) {
|
if (supportActionBar != null) {
|
||||||
supportActionBar.setHomeButtonEnabled(true);
|
supportActionBar.setHomeButtonEnabled(true);
|
||||||
supportActionBar.setDisplayHomeAsUpEnabled(true);
|
supportActionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
supportActionBar.setHomeAsUpIndicator(back);
|
supportActionBar.setHomeAsUpIndicator(back);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setContentView(int layoutResID) {
|
public void setContentView(int layoutResID) {
|
||||||
super.setContentView(layoutResID);
|
super.setContentView(layoutResID);
|
||||||
if (haveHomeButton) {
|
if (haveHomeButton) {
|
||||||
setupHomeButton();
|
setupHomeButton();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setContentView(View view) {
|
public void setContentView(View view) {
|
||||||
super.setContentView(view);
|
super.setContentView(view);
|
||||||
if (haveHomeButton) {
|
if (haveHomeButton) {
|
||||||
setupHomeButton();
|
setupHomeButton();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setContentView(View view, ViewGroup.LayoutParams params) {
|
public void setContentView(View view, ViewGroup.LayoutParams params) {
|
||||||
super.setContentView(view, params);
|
super.setContentView(view, params);
|
||||||
if (haveHomeButton) {
|
if (haveHomeButton) {
|
||||||
setupHomeButton();
|
setupHomeButton();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,6 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
listener.changeProfileStatus(item, holder.aSwitch.isChecked());
|
listener.changeProfileStatus(item, holder.aSwitch.isChecked());
|
||||||
PlatformUtil.getLog(ProfileMenuAdapter.class).debug("Is checked: " + holder.aSwitch.isChecked());
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
holder.profileOptions.setOnClickListener(new OnClickListener() {
|
holder.profileOptions.setOnClickListener(new OnClickListener() {
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package net.osmand.plus.profiles;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.OsmandActionBarActivity;
|
||||||
|
|
||||||
|
public class SelectedProfileActivity extends OsmandActionBarActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
getMyApplication().applyTheme(this);
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.single_fragment_layout);
|
||||||
|
|
||||||
|
Intent intent = getIntent();
|
||||||
|
if (intent.getExtras() != null) {
|
||||||
|
if (getSupportActionBar() != null) {
|
||||||
|
getSupportActionBar().setTitle(intent.getStringExtra("profile_name"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (savedInstanceState == null) {
|
||||||
|
// SettingsProfileFragment profileFragment = new SettingsProfileFragment();
|
||||||
|
// profileFragment.setArguments(getIntent().getExtras());
|
||||||
|
// getSupportFragmentManager().beginTransaction().add(android.R.id.content, profileFragment).commit();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package net.osmand.plus.profiles;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||||
|
|
||||||
|
public class SelectedProfileFragment extends BaseOsmAndFragment {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
return super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,14 +8,9 @@ import net.osmand.plus.activities.OsmandActionBarActivity;
|
||||||
|
|
||||||
public class SettingsProfileActivity extends OsmandActionBarActivity {
|
public class SettingsProfileActivity extends OsmandActionBarActivity {
|
||||||
|
|
||||||
private OsmandApplication app;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
app = getMyApplication();
|
getMyApplication().applyTheme(this);
|
||||||
app.applyTheme(this);
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.single_fragment_layout);
|
setContentView(R.layout.single_fragment_layout);
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.osmand.plus.profiles;
|
package net.osmand.plus.profiles;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
@ -42,6 +43,10 @@ public class SettingsProfileFragment extends BaseOsmAndFragment {
|
||||||
profilesList = new ArrayList<>();
|
profilesList = new ArrayList<>();
|
||||||
allDefaultModes = ApplicationMode.allPossibleValues();
|
allDefaultModes = ApplicationMode.allPossibleValues();
|
||||||
allDefaultModes.remove(ApplicationMode.DEFAULT);
|
allDefaultModes.remove(ApplicationMode.DEFAULT);
|
||||||
|
allDefaultModes.remove(ApplicationMode.AIRCRAFT);
|
||||||
|
allDefaultModes.remove(ApplicationMode.MOTORCYCLE);
|
||||||
|
allDefaultModes.remove(ApplicationMode.HIKING);
|
||||||
|
allDefaultModes.remove(ApplicationMode.TRAIN);
|
||||||
selectedDefaultModes = new LinkedHashSet<>(ApplicationMode.values(getMyApplication()));
|
selectedDefaultModes = new LinkedHashSet<>(ApplicationMode.values(getMyApplication()));
|
||||||
selectedDefaultModes.remove(ApplicationMode.DEFAULT);
|
selectedDefaultModes.remove(ApplicationMode.DEFAULT);
|
||||||
for (ApplicationMode am : allDefaultModes) {
|
for (ApplicationMode am : allDefaultModes) {
|
||||||
|
@ -99,7 +104,9 @@ public class SettingsProfileFragment extends BaseOsmAndFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void editProfile(ProfileItem item) {
|
public void editProfile(ProfileItem item) {
|
||||||
|
Intent intent = new Intent(getActivity(), SelectedProfileActivity.class);
|
||||||
|
intent.putExtra("profile_name", item.title);
|
||||||
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
adapter = new ProfileMenuAdapter(profilesList, getMyApplication(), listener);
|
adapter = new ProfileMenuAdapter(profilesList, getMyApplication(), listener);
|
||||||
|
|
Loading…
Reference in a new issue