|
|
@@ -8,6 +8,7 @@ import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
import android.content.ServiceConnection;
|
|
|
import android.content.res.ColorStateList;
|
|
|
+import android.content.res.Resources;
|
|
|
import android.graphics.drawable.BitmapDrawable;
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
import android.location.Location;
|
|
|
@@ -23,6 +24,7 @@ import android.support.v4.app.FragmentTransaction;
|
|
|
import android.support.v4.content.ContextCompat;
|
|
|
import android.support.v4.graphics.drawable.DrawableCompat;
|
|
|
import android.support.v7.app.AppCompatActivity;
|
|
|
+import android.support.v7.app.WindowDecorActionBar;
|
|
|
import android.util.Log;
|
|
|
import android.view.Menu;
|
|
|
import android.view.MenuItem;
|
|
|
@@ -117,28 +119,19 @@ public class MainActivity extends BasicActivity implements LoginFragment.LoginCa
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
+
|
|
|
+ if (ApexDriverApplication.sharedApplication().isLogin()) {
|
|
|
+ setTheme(R.style.ApexDriverTheme);
|
|
|
+ } else {
|
|
|
+ setTheme(R.style.ApexDriverThemeWhite);
|
|
|
+ autoSetupStatusBar = false;
|
|
|
+ }
|
|
|
+
|
|
|
super.onCreate(savedInstanceState);
|
|
|
setContentView(R.layout.activity_main);
|
|
|
|
|
|
mRootContainer = findViewById(R.id.root_container);
|
|
|
|
|
|
- android.support.v7.app.ActionBar actionBar = getSupportActionBar();
|
|
|
- if(actionBar != null){
|
|
|
- actionBar.setElevation(0); // 5.0以上隐藏分割线
|
|
|
-
|
|
|
- // 将图像渲染成白色
|
|
|
-// ColorStateList colorStateList = ColorStateList.valueOf(getResources().getColor(R.color.ApexDriverWhite));
|
|
|
- Drawable drawable = getResources().getDrawable(R.drawable.apexlogo_large);
|
|
|
-// DrawableCompat.setTintList(drawable, colorStateList);
|
|
|
- ImageUtil.renderingDrawable(drawable,getResources(),R.color.ApexDriverWhite);
|
|
|
-
|
|
|
- // 显示Home
|
|
|
- actionBar.setHomeAsUpIndicator(drawable);
|
|
|
- actionBar.setDisplayHomeAsUpEnabled(true);
|
|
|
-
|
|
|
- }
|
|
|
- setTitle(null);
|
|
|
-
|
|
|
initView();
|
|
|
|
|
|
// checkPowerManagement();
|
|
|
@@ -178,6 +171,59 @@ public class MainActivity extends BasicActivity implements LoginFragment.LoginCa
|
|
|
RAUtil.checkPermissions(this,permissions);
|
|
|
}
|
|
|
|
|
|
+ private void restart() {
|
|
|
+
|
|
|
+ finish();
|
|
|
+
|
|
|
+ startActivity(new Intent(this,MainActivity.class));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setupLoginAppearance() {
|
|
|
+
|
|
|
+ changeStatusBarGradient();
|
|
|
+
|
|
|
+ android.support.v7.app.ActionBar actionBar = getSupportActionBar();
|
|
|
+ if(actionBar != null){
|
|
|
+ actionBar.setElevation(0); // 5.0以上隐藏分割线
|
|
|
+
|
|
|
+ // 将图像渲染成白色
|
|
|
+ Drawable drawable = getResources().getDrawable(R.drawable.apexlogo_large);
|
|
|
+ ImageUtil.renderingDrawable(drawable,getResources(),R.color.ApexDriverWhite);
|
|
|
+
|
|
|
+ actionBar.setHomeAsUpIndicator(drawable);
|
|
|
+ actionBar.setDisplayHomeAsUpEnabled(true);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ setTitle(null);
|
|
|
+
|
|
|
+ invalidateOptionsMenu();
|
|
|
+
|
|
|
+ setTitle(ApexDriverApplication.sharedApplication().user);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setupLogoutAppearance() {
|
|
|
+
|
|
|
+ changeStatusBarNormal();
|
|
|
+
|
|
|
+ android.support.v7.app.ActionBar actionBar = getSupportActionBar();
|
|
|
+ if(actionBar != null){
|
|
|
+ actionBar.setElevation(1); // 5.0以上隐藏分割线
|
|
|
+
|
|
|
+ Drawable drawable = getResources().getDrawable(R.drawable.apexlogo_large);
|
|
|
+ ImageUtil.clearDrawableRendering(drawable);
|
|
|
+
|
|
|
+ actionBar.setHomeAsUpIndicator(drawable);
|
|
|
+ actionBar.setDisplayHomeAsUpEnabled(true);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ invalidateOptionsMenu();
|
|
|
+
|
|
|
+ setTitle("Login");
|
|
|
+ }
|
|
|
+
|
|
|
private void initView() {
|
|
|
|
|
|
FragmentManager manager = getSupportFragmentManager();
|
|
|
@@ -194,7 +240,7 @@ public class MainActivity extends BasicActivity implements LoginFragment.LoginCa
|
|
|
HomeFragment homeFragment = new HomeFragment();
|
|
|
transaction.add(R.id.root_container, homeFragment,FragmentTag);
|
|
|
|
|
|
- setTitle(ApexDriverApplication.sharedApplication().user);
|
|
|
+ setupLoginAppearance();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
@@ -202,13 +248,15 @@ public class MainActivity extends BasicActivity implements LoginFragment.LoginCa
|
|
|
loginFragment.setCallBack(this);
|
|
|
transaction.add(R.id.root_container, loginFragment,FragmentTag);
|
|
|
|
|
|
- setTitle("Login");
|
|
|
+ setupLogoutAppearance();
|
|
|
}
|
|
|
transaction.commit();
|
|
|
|
|
|
invalidateOptionsMenu();
|
|
|
}
|
|
|
|
|
|
+ // 登陆
|
|
|
+
|
|
|
@Override
|
|
|
public void onLogin() {
|
|
|
|
|
|
@@ -221,11 +269,13 @@ public class MainActivity extends BasicActivity implements LoginFragment.LoginCa
|
|
|
|
|
|
transaction.commit();
|
|
|
|
|
|
- invalidateOptionsMenu();
|
|
|
+ setupLoginAppearance();
|
|
|
|
|
|
- setTitle(ApexDriverApplication.sharedApplication().user);
|
|
|
+ restart();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ // d登出
|
|
|
private void showLogin() {
|
|
|
|
|
|
FragmentManager manager = getSupportFragmentManager();
|
|
|
@@ -237,9 +287,9 @@ public class MainActivity extends BasicActivity implements LoginFragment.LoginCa
|
|
|
|
|
|
transaction.commit();
|
|
|
|
|
|
- invalidateOptionsMenu();
|
|
|
+ setupLogoutAppearance();
|
|
|
|
|
|
- setTitle("Login");
|
|
|
+ restart();
|
|
|
}
|
|
|
|
|
|
@Override
|