Skip to content

Commit c7c91f8

Browse files
committed
Initial commit
0 parents  commit c7c91f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1131
-0
lines changed

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures

.idea/.name

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/copyright/profiles_settings.xml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+62
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 25
5+
buildToolsVersion "25.0.2"
6+
7+
defaultConfig {
8+
applicationId "com.dynamictheme"
9+
minSdkVersion 16
10+
targetSdkVersion 25
11+
versionCode 1
12+
versionName "1.0"
13+
generatedDensities = []
14+
}
15+
16+
aaptOptions {
17+
additionalParameters "--no-version-vectors"
18+
}
19+
buildTypes {
20+
release {
21+
minifyEnabled false
22+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
23+
}
24+
}
25+
}
26+
27+
dependencies {
28+
compile fileTree(dir: 'libs', include: ['*.jar'])
29+
testCompile 'junit:junit:4.12'
30+
compile 'com.android.support:appcompat-v7:25.1.0'
31+
compile 'com.android.support:design:25.1.0'
32+
}

app/proguard-rules.pro

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in F:\Android\Android_soft\adt-bundle-windows-x86_64-20140702\sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.dynamictheme;
2+
3+
import android.app.Application;
4+
import android.test.ApplicationTestCase;
5+
6+
/**
7+
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
8+
*/
9+
public class ApplicationTest extends ApplicationTestCase<Application> {
10+
public ApplicationTest() {
11+
super(Application.class);
12+
}
13+
}

app/src/main/AndroidManifest.xml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.dynamictheme">
4+
5+
<application
6+
android:name=".MainController"
7+
android:allowBackup="true"
8+
android:icon="@mipmap/ic_launcher"
9+
android:label="@string/app_name"
10+
android:supportsRtl="true"
11+
android:theme="@style/ThemeApp.Green">
12+
<activity
13+
android:name=".MainActivity"
14+
android:label="@string/app_name">
15+
<intent-filter>
16+
<action android:name="android.intent.action.MAIN" />
17+
18+
<category android:name="android.intent.category.LAUNCHER" />
19+
</intent-filter>
20+
</activity>
21+
</application>
22+
23+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
package com.dynamictheme;
2+
3+
import android.content.Intent;
4+
import android.os.Build;
5+
import android.os.Bundle;
6+
import android.support.design.widget.FloatingActionButton;
7+
import android.support.v4.app.TaskStackBuilder;
8+
import android.support.v7.app.AppCompatActivity;
9+
import android.support.v7.widget.SwitchCompat;
10+
import android.support.v7.widget.Toolbar;
11+
import android.transition.Explode;
12+
import android.transition.Transition;
13+
import android.view.View;
14+
import android.view.Window;
15+
import android.widget.CompoundButton;
16+
import android.widget.LinearLayout;
17+
18+
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
19+
20+
private LinearLayout layout_green, layout_purple;
21+
private SwitchCompat switch_dark;
22+
private boolean isDarkTheme;
23+
private static final String Theme_Current = "ThemeCurrent";
24+
private static final String Dark_Theme = "DarkTheme";
25+
26+
@Override
27+
protected void onCreate(Bundle savedInstanceState) {
28+
29+
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
30+
getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
31+
32+
//set the transition
33+
Transition ts = new Explode();
34+
ts.setDuration(5000);
35+
getWindow().setEnterTransition(ts);
36+
getWindow().setExitTransition(ts);
37+
}
38+
39+
super.onCreate(savedInstanceState);
40+
41+
setAppTheme();
42+
setContentView(R.layout.activity_main);
43+
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
44+
setSupportActionBar(toolbar);
45+
46+
47+
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
48+
fab.setOnClickListener(new View.OnClickListener() {
49+
@Override
50+
public void onClick(View view) {
51+
TaskStackBuilder.create(MainActivity.this)
52+
.addNextIntent(new Intent(MainActivity.this, MainActivity.class))
53+
.addNextIntent(getIntent())
54+
.startActivities();
55+
56+
}
57+
});
58+
59+
60+
switch_dark = (SwitchCompat) findViewById(R.id.switch_darkTheme);
61+
layout_green = (LinearLayout) findViewById(R.id.Layout_green);
62+
layout_purple = (LinearLayout) findViewById(R.id.Layout_purple);
63+
64+
65+
switch_dark.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
66+
@Override
67+
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
68+
69+
if (isChecked) {
70+
isDarkTheme = true;
71+
MainController.preferencePutBoolean(Dark_Theme, true);
72+
} else {
73+
isDarkTheme = false;
74+
MainController.preferencePutBoolean(Dark_Theme, false);
75+
}
76+
77+
}
78+
});
79+
80+
if (MainController.preferenceGetBoolean(Dark_Theme, false)) {
81+
switch_dark.setChecked(true);
82+
}
83+
84+
85+
layout_green.setOnClickListener(this);
86+
layout_purple.setOnClickListener(this);
87+
88+
89+
}
90+
91+
92+
private void setAppTheme() {
93+
94+
if (!MainController.preferenceGetString(Theme_Current, "").equals("")) {
95+
if (MainController.preferenceGetString(Theme_Current, "").equals("Green")) {
96+
setTheme(R.style.ThemeApp_Green);
97+
} else if (MainController.preferenceGetString(Theme_Current, "").equals("Green_Dark")) {
98+
setTheme(R.style.ThemeApp_Green_Dark);
99+
} else if (MainController.preferenceGetString(Theme_Current, "").equals("Purple_Dark")) {
100+
setTheme(R.style.ThemeApp_Purple_Dark);
101+
} else if (MainController.preferenceGetString(Theme_Current, "").equals("Purple")) {
102+
setTheme(R.style.ThemeApp_Purple);
103+
}
104+
} else {
105+
setTheme(R.style.ThemeApp_Green);
106+
}
107+
}
108+
109+
@Override
110+
public void onClick(View v) {
111+
switch (v.getId()) {
112+
case R.id.Layout_green:
113+
if (isDarkTheme)
114+
MainController.preferencePutString(Theme_Current, "Green_Dark");
115+
else
116+
MainController.preferencePutString(Theme_Current, "Green");
117+
118+
119+
break;
120+
121+
case R.id.Layout_purple:
122+
123+
if (isDarkTheme)
124+
MainController.preferencePutString(Theme_Current, "Purple_Dark");
125+
else
126+
MainController.preferencePutString(Theme_Current, "Purple");
127+
128+
129+
/*TaskStackBuilder.create(this)
130+
.addNextIntent(new Intent(this, Listactivity.class))
131+
.addNextIntent(getIntent())
132+
.startActivities();*/
133+
break;
134+
}
135+
}
136+
}

0 commit comments

Comments
 (0)