first commit
|
@ -0,0 +1,15 @@
|
||||||
|
*.iml
|
||||||
|
.gradle
|
||||||
|
/local.properties
|
||||||
|
/.idea/caches
|
||||||
|
/.idea/libraries
|
||||||
|
/.idea/modules.xml
|
||||||
|
/.idea/workspace.xml
|
||||||
|
/.idea/navEditor.xml
|
||||||
|
/.idea/assetWizardSettings.xml
|
||||||
|
.DS_Store
|
||||||
|
/build
|
||||||
|
/captures
|
||||||
|
.externalNativeBuild
|
||||||
|
.cxx
|
||||||
|
local.properties
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
|
@ -0,0 +1 @@
|
||||||
|
Parent Apps
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel target="11" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="deploymentTargetDropDown">
|
||||||
|
<runningDeviceTargetSelectedWithDropDown>
|
||||||
|
<Target>
|
||||||
|
<type value="RUNNING_DEVICE_TARGET" />
|
||||||
|
<deviceKey>
|
||||||
|
<Key>
|
||||||
|
<type value="SERIAL_NUMBER" />
|
||||||
|
<value value="RRCT400HDSR" />
|
||||||
|
</Key>
|
||||||
|
</deviceKey>
|
||||||
|
</Target>
|
||||||
|
</runningDeviceTargetSelectedWithDropDown>
|
||||||
|
<timeTargetWasSelectedWithDropDown value="2023-08-20T13:12:58.472831800Z" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<option name="testRunner" value="GRADLE" />
|
||||||
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
<option value="$PROJECT_DIR$/app" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Embedded JDK" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectType">
|
||||||
|
<option name="id" value="Android" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1 @@
|
||||||
|
/build
|
|
@ -0,0 +1,44 @@
|
||||||
|
plugins {
|
||||||
|
id 'com.android.application'
|
||||||
|
id 'com.google.gms.google-services'
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace 'com.pkm.parentapps'
|
||||||
|
compileSdk 33
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "com.pkm.parentapps"
|
||||||
|
minSdk 21
|
||||||
|
targetSdk 33
|
||||||
|
versionCode 1
|
||||||
|
versionName "1.0"
|
||||||
|
|
||||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||||
|
implementation 'com.google.android.material:material:1.8.0'
|
||||||
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||||
|
implementation 'com.google.firebase:firebase-messaging:23.0.2'
|
||||||
|
testImplementation 'junit:junit:4.13.2'
|
||||||
|
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||||
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||||
|
implementation 'com.android.volley:volley:1.2.1'
|
||||||
|
implementation platform('com.google.firebase:firebase-bom:32.2.3')
|
||||||
|
implementation 'com.google.firebase:firebase-messaging:23.0.3'
|
||||||
|
implementation 'com.pierfrancescosoffritti.androidyoutubeplayer:core:12.1.0'
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
{
|
||||||
|
"project_info": {
|
||||||
|
"project_number": "515868072445",
|
||||||
|
"project_id": "pasty-bfda4",
|
||||||
|
"storage_bucket": "pasty-bfda4.appspot.com"
|
||||||
|
},
|
||||||
|
"client": [
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:515868072445:android:0a235699139cb18e1c2194",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "com.pkm.parentapps"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "515868072445-2jejf3nsh4al6qa3rma0q3sj55c350b2.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyBSvzUmCJkgjDOToipP2knPkTFnWPyws_E"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "515868072445-2jejf3nsh4al6qa3rma0q3sj55c350b2.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"configuration_version": "1"
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.pkm.parentapps;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry;
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instrumented test, which will execute on an Android device.
|
||||||
|
*
|
||||||
|
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||||
|
*/
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class ExampleInstrumentedTest {
|
||||||
|
@Test
|
||||||
|
public void useAppContext() {
|
||||||
|
// Context of the app under test.
|
||||||
|
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||||
|
assertEquals("com.pkm.parentapps", appContext.getPackageName());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,104 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
|
android:fullBackupContent="@xml/backup_rules"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/Theme.ParentApps"
|
||||||
|
android:usesCleartextTraffic="true"
|
||||||
|
tools:targetApi="31">
|
||||||
|
<activity
|
||||||
|
android:name=".KontenVideoActivity"
|
||||||
|
android:exported="false"
|
||||||
|
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
|
||||||
|
<activity
|
||||||
|
android:name=".Dasar5Activity"
|
||||||
|
android:exported="false"
|
||||||
|
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
|
||||||
|
<activity
|
||||||
|
android:name=".Dasar3Activity"
|
||||||
|
android:exported="false"
|
||||||
|
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
|
||||||
|
<activity
|
||||||
|
android:name=".Dasar2Activity"
|
||||||
|
android:exported="false"
|
||||||
|
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
|
||||||
|
<activity
|
||||||
|
android:name=".Dasar1Activity"
|
||||||
|
android:exported="false"
|
||||||
|
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
|
||||||
|
<activity
|
||||||
|
android:name=".AboutActivity"
|
||||||
|
android:exported="false"
|
||||||
|
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
|
||||||
|
<activity
|
||||||
|
android:name=".EditPasswordActivity"
|
||||||
|
android:exported="false"
|
||||||
|
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
|
||||||
|
<activity
|
||||||
|
android:name=".EditAkunActivity"
|
||||||
|
android:exported="false"
|
||||||
|
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
|
||||||
|
<activity
|
||||||
|
android:name=".DetailArtikelActivity"
|
||||||
|
android:exported="false"
|
||||||
|
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
|
||||||
|
<activity
|
||||||
|
android:name=".DetailBlogActivity"
|
||||||
|
android:exported="false"
|
||||||
|
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
|
||||||
|
<activity
|
||||||
|
android:name=".MulaiActivity"
|
||||||
|
android:exported="false"
|
||||||
|
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
|
||||||
|
<activity
|
||||||
|
android:name=".LanjutActivity"
|
||||||
|
android:exported="false"
|
||||||
|
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
|
||||||
|
<activity
|
||||||
|
android:name=".MenengahActivity"
|
||||||
|
android:exported="false"
|
||||||
|
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
|
||||||
|
<activity
|
||||||
|
android:name=".DasarActivity"
|
||||||
|
android:exported="false"
|
||||||
|
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
|
||||||
|
<activity
|
||||||
|
android:name=".RegisterActivity"
|
||||||
|
android:exported="false"
|
||||||
|
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
|
||||||
|
<activity
|
||||||
|
android:name=".LoginActivity"
|
||||||
|
android:exported="false"
|
||||||
|
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
|
||||||
|
<activity
|
||||||
|
android:name=".HomeActivity"
|
||||||
|
android:exported="false" />
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<service
|
||||||
|
android:name=".MyFirebaseMessagingService"
|
||||||
|
android:exported="false">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="com.google.firebase.MESSAGING_EVENT" />
|
||||||
|
</intent-filter>
|
||||||
|
</service>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
After Width: | Height: | Size: 36 KiB |
|
@ -0,0 +1,58 @@
|
||||||
|
package com.pkm.parentapps;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
|
||||||
|
public class AboutActivity extends AppCompatActivity {
|
||||||
|
Toolbar toolbar;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_about);
|
||||||
|
init();
|
||||||
|
setStatusBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
toolbar = findViewById(R.id.toolbar);
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
AboutActivity.super.onBackPressed();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setStatusBar() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false);
|
||||||
|
getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWindowFlag(Activity activity, final int bits, boolean on) {
|
||||||
|
Window window = activity.getWindow();
|
||||||
|
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||||
|
if (on) {
|
||||||
|
layoutParams.flags |= bits;
|
||||||
|
} else {
|
||||||
|
layoutParams.flags &= ~bits;
|
||||||
|
}
|
||||||
|
window.setAttributes(layoutParams);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,170 @@
|
||||||
|
package com.pkm.parentapps;
|
||||||
|
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.android.volley.Request;
|
||||||
|
import com.android.volley.RequestQueue;
|
||||||
|
import com.android.volley.toolbox.StringRequest;
|
||||||
|
import com.android.volley.toolbox.Volley;
|
||||||
|
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class AkunFragment extends Fragment {
|
||||||
|
LinearLayout btn_logout, profil, btnPassword, aboutapp;
|
||||||
|
TextView tvName;
|
||||||
|
SharedPreferences sharedPreferences;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.fragment_akun, container, false);
|
||||||
|
btn_logout = view.findViewById(R.id.btn_logout);
|
||||||
|
profil = view.findViewById(R.id.profil);
|
||||||
|
btnPassword = view.findViewById(R.id.btnPassword);
|
||||||
|
aboutapp = view.findViewById(R.id.aboutapp);
|
||||||
|
sharedPreferences = getActivity().getSharedPreferences("UserInfo", getActivity().MODE_PRIVATE);
|
||||||
|
tvName = view.findViewById(R.id.tvName);
|
||||||
|
tvName.setText(sharedPreferences.getString("name", ""));
|
||||||
|
|
||||||
|
btn_logout.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
builder.setCancelable(false);
|
||||||
|
builder.setMessage("Anda Yakin Ingin Logout ?");
|
||||||
|
builder.setPositiveButton("Ya", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
postData();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setNegativeButton("Tidak", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
dialog.cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
AlertDialog alert = builder.create();
|
||||||
|
alert.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
btnPassword.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(getActivity(), EditPasswordActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
profil.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(getActivity(), EditAkunActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
aboutapp.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(getActivity(), AboutActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void postData() {
|
||||||
|
String url = getResources().getString(R.string.api_server) + "/logout";
|
||||||
|
String token = sharedPreferences.getString("token", "");
|
||||||
|
StringRequest request = new StringRequest(Request.Method.POST, url, response -> {
|
||||||
|
try {
|
||||||
|
JSONObject object = new JSONObject(response);
|
||||||
|
if (object.getBoolean("success")) {
|
||||||
|
Toast.makeText(getActivity(), "Logout berhasil", Toast.LENGTH_SHORT).show();
|
||||||
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||||
|
editor.clear();
|
||||||
|
editor.apply();
|
||||||
|
Intent intent = new Intent(getActivity(), LoginActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
getActivity().finish();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}, error -> {
|
||||||
|
error.printStackTrace();
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
builder.setTitle("Pesan");
|
||||||
|
builder.setMessage("Logout gagal, silahkan coba lagi");
|
||||||
|
builder.setPositiveButton("Ok", null);
|
||||||
|
builder.show();
|
||||||
|
}) {
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getHeaders() {
|
||||||
|
Map<String, String> header = new HashMap<>();
|
||||||
|
header.put("Accept", "application/json");
|
||||||
|
header.put("Authorization", "Bearer " + token);
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Map<String, String> getParams() {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
RequestQueue queue = Volley.newRequestQueue(getActivity());
|
||||||
|
queue.add(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getData() {
|
||||||
|
String url = getResources().getString(R.string.api_server) + "/profile/" + sharedPreferences.getString("id", "");
|
||||||
|
String token = sharedPreferences.getString("token", "");
|
||||||
|
StringRequest request = new StringRequest(Request.Method.GET, url, response -> {
|
||||||
|
try {
|
||||||
|
JSONObject object = new JSONObject(response);
|
||||||
|
if (object.getBoolean("success")) {
|
||||||
|
JSONObject data = object.getJSONObject("data");
|
||||||
|
tvName.setText(data.getString("name"));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}, error -> {
|
||||||
|
error.printStackTrace();
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
builder.setTitle("Pesan");
|
||||||
|
builder.setMessage("Gagal mengambil data profile, silahkan coba lagi");
|
||||||
|
builder.setPositiveButton("Ok", null);
|
||||||
|
builder.show();
|
||||||
|
}) {
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getHeaders() {
|
||||||
|
Map<String, String> header = new HashMap<>();
|
||||||
|
header.put("Accept", "application/json");
|
||||||
|
header.put("Authorization", "Bearer " + token);
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
RequestQueue queue = Volley.newRequestQueue(getActivity());
|
||||||
|
queue.add(request);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,103 @@
|
||||||
|
package com.pkm.parentapps;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class BlogAdapter extends RecyclerView.Adapter<BlogAdapter.ViewHolder>{
|
||||||
|
private ArrayList<String> judul = new ArrayList<>();
|
||||||
|
private ArrayList<String> deskripsi = new ArrayList<>();
|
||||||
|
private ArrayList<String> link = new ArrayList<>();
|
||||||
|
private ArrayList<String> gambar = new ArrayList<>();
|
||||||
|
private Context context;
|
||||||
|
|
||||||
|
public BlogAdapter(ArrayList<String> judul, ArrayList<String> deskripsi, ArrayList<String> link, ArrayList<String> gambar, Context context) {
|
||||||
|
this.judul = judul;
|
||||||
|
this.deskripsi = deskripsi;
|
||||||
|
this.link = link;
|
||||||
|
this.gambar = gambar;
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlogAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
|
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.cardview_blog, parent, false);
|
||||||
|
BlogAdapter.ViewHolder holder = new BlogAdapter.ViewHolder(view);
|
||||||
|
return holder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(BlogAdapter.ViewHolder holder, @SuppressLint("RecyclerView") int position) {
|
||||||
|
holder.judul.setText(judul.get(position));
|
||||||
|
holder.deskripsi.setText(deskripsi.get(position));
|
||||||
|
String url = context.getResources().getString(R.string.img_server) + gambar.get(position);
|
||||||
|
new DownloadImageTask(holder.gambar).execute(url);
|
||||||
|
|
||||||
|
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(context, DetailArtikelActivity.class);
|
||||||
|
intent.putExtra("link", link.get(position));
|
||||||
|
context.startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
|
||||||
|
ImageView bmImage;
|
||||||
|
|
||||||
|
public DownloadImageTask(ImageView bmImage) {
|
||||||
|
this.bmImage = bmImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Bitmap doInBackground(String... urls) {
|
||||||
|
String urldisplay = urls[0];
|
||||||
|
Bitmap mIcon11 = null;
|
||||||
|
try {
|
||||||
|
InputStream in = new java.net.URL(urldisplay).openStream();
|
||||||
|
mIcon11 = BitmapFactory.decodeStream(in);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e("Error", e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return mIcon11;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onPostExecute(Bitmap result) {
|
||||||
|
bmImage.setImageBitmap(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return judul.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ViewHolder extends RecyclerView.ViewHolder{
|
||||||
|
TextView judul, deskripsi;
|
||||||
|
ImageView gambar;
|
||||||
|
|
||||||
|
public ViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
judul = itemView.findViewById(R.id.tvJudul);
|
||||||
|
deskripsi = itemView.findViewById(R.id.tvDeskripsi);
|
||||||
|
gambar = itemView.findViewById(R.id.tvGambar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,83 @@
|
||||||
|
package com.pkm.parentapps;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import com.android.volley.Request;
|
||||||
|
import com.android.volley.RequestQueue;
|
||||||
|
import com.android.volley.toolbox.StringRequest;
|
||||||
|
import com.android.volley.toolbox.Volley;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class BlogFragment extends Fragment {
|
||||||
|
SharedPreferences sharedPreferences;
|
||||||
|
ArrayList<String> judul = new ArrayList<>();
|
||||||
|
ArrayList<String> deskripsi = new ArrayList<>();
|
||||||
|
ArrayList<String> link = new ArrayList<>();
|
||||||
|
ArrayList<String> gambar = new ArrayList<>();
|
||||||
|
RecyclerView rvBlog;
|
||||||
|
BlogAdapter blogAdapter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.fragment_blog, container, false);
|
||||||
|
sharedPreferences = getActivity().getSharedPreferences("UserInfo", getActivity().MODE_PRIVATE);
|
||||||
|
rvBlog = view.findViewById(R.id.rvBlog);
|
||||||
|
rvBlog.setLayoutManager(new LinearLayoutManager(getActivity().getApplicationContext()));
|
||||||
|
getData();
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getData() {
|
||||||
|
String url = getResources().getString(R.string.api_server) + "/artikel";
|
||||||
|
String token = sharedPreferences.getString("token", "");
|
||||||
|
StringRequest request = new StringRequest(Request.Method.GET, url, response -> {
|
||||||
|
try {
|
||||||
|
JSONObject object = new JSONObject(response);
|
||||||
|
if (object.getBoolean("success")) {
|
||||||
|
JSONArray data = new JSONArray(object.getString("data"));
|
||||||
|
for (int i = 0; i < data.length(); i++) {
|
||||||
|
JSONObject item = data.getJSONObject(i);
|
||||||
|
judul.add(item.getString("judul"));
|
||||||
|
deskripsi.add(item.getString("deskripsi"));
|
||||||
|
link.add(item.getString("link"));
|
||||||
|
gambar.add(item.getString("gambar"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
blogAdapter = new BlogAdapter(judul, deskripsi, link, gambar, getActivity());
|
||||||
|
rvBlog.setAdapter(blogAdapter);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}, error -> {
|
||||||
|
error.printStackTrace();
|
||||||
|
}) {
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getHeaders() {
|
||||||
|
Map<String, String> header = new HashMap<>();
|
||||||
|
header.put("Accept", "application/json");
|
||||||
|
header.put("Authorization", "Bearer " + token);
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
RequestQueue queue = Volley.newRequestQueue(getActivity());
|
||||||
|
queue.add(request);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
package com.pkm.parentapps;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.CountDownTimer;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class Dasar1Activity extends AppCompatActivity {
|
||||||
|
private static final long START_TIME_IN_MILLIS = 100000;
|
||||||
|
TextView tvWaktu;
|
||||||
|
private CountDownTimer mCountDownTimer;
|
||||||
|
private boolean mTimerRunning;
|
||||||
|
private long mTimeLeftInMillis = START_TIME_IN_MILLIS;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_dasar1);
|
||||||
|
tvWaktu = findViewById(R.id.tvWaktu);
|
||||||
|
setStatusBar();
|
||||||
|
startTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startTimer() {
|
||||||
|
mCountDownTimer = new CountDownTimer(mTimeLeftInMillis, 1000) {
|
||||||
|
@Override
|
||||||
|
public void onTick(long millisUntilFinished) { // 1 detik
|
||||||
|
mTimeLeftInMillis = millisUntilFinished;
|
||||||
|
updateCountDownText();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFinish() { // selesai
|
||||||
|
mTimerRunning = false;
|
||||||
|
Toast.makeText(Dasar1Activity.this, "Tugas Selesai", Toast.LENGTH_SHORT).show();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
|
||||||
|
mTimerRunning = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCountDownText() {
|
||||||
|
int minutes = (int) (mTimeLeftInMillis / 1000) / 60; // 1 menit
|
||||||
|
int seconds = (int) (mTimeLeftInMillis / 1000) % 60; // 1 detik
|
||||||
|
|
||||||
|
String timeLeftFormatted = String.format("%02d:%02d", minutes, seconds);
|
||||||
|
tvWaktu.setText(timeLeftFormatted);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
Toast.makeText(this, "Tugas Belum Selesai", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setStatusBar() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false);
|
||||||
|
getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWindowFlag(Activity activity, final int bits, boolean on) {
|
||||||
|
Window window = activity.getWindow();
|
||||||
|
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||||
|
if (on) {
|
||||||
|
layoutParams.flags |= bits;
|
||||||
|
} else {
|
||||||
|
layoutParams.flags &= ~bits;
|
||||||
|
}
|
||||||
|
window.setAttributes(layoutParams);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
package com.pkm.parentapps;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.CountDownTimer;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
public class Dasar2Activity extends AppCompatActivity {
|
||||||
|
private static final long START_TIME_IN_MILLIS = 100000;
|
||||||
|
TextView tvWaktu;
|
||||||
|
private CountDownTimer mCountDownTimer;
|
||||||
|
private boolean mTimerRunning;
|
||||||
|
private long mTimeLeftInMillis = START_TIME_IN_MILLIS;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_dasar2);
|
||||||
|
tvWaktu = findViewById(R.id.tvWaktu);
|
||||||
|
setStatusBar();
|
||||||
|
startTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startTimer() {
|
||||||
|
mCountDownTimer = new CountDownTimer(mTimeLeftInMillis, 1000) {
|
||||||
|
@Override
|
||||||
|
public void onTick(long millisUntilFinished) { // 1 detik
|
||||||
|
mTimeLeftInMillis = millisUntilFinished;
|
||||||
|
updateCountDownText();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFinish() { // selesai
|
||||||
|
mTimerRunning = false;
|
||||||
|
Toast.makeText(Dasar2Activity.this, "Tugas Selesai", Toast.LENGTH_SHORT).show();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
|
||||||
|
mTimerRunning = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCountDownText() {
|
||||||
|
int minutes = (int) (mTimeLeftInMillis / 1000) / 60; // 1 menit
|
||||||
|
int seconds = (int) (mTimeLeftInMillis / 1000) % 60; // 1 detik
|
||||||
|
|
||||||
|
String timeLeftFormatted = String.format("%02d:%02d", minutes, seconds);
|
||||||
|
tvWaktu.setText(timeLeftFormatted);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
Toast.makeText(this, "Tugas Belum Selesai", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setStatusBar() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false);
|
||||||
|
getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWindowFlag(Activity activity, final int bits, boolean on) {
|
||||||
|
Window window = activity.getWindow();
|
||||||
|
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||||
|
if (on) {
|
||||||
|
layoutParams.flags |= bits;
|
||||||
|
} else {
|
||||||
|
layoutParams.flags &= ~bits;
|
||||||
|
}
|
||||||
|
window.setAttributes(layoutParams);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
package com.pkm.parentapps;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.CountDownTimer;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
public class Dasar3Activity extends AppCompatActivity {
|
||||||
|
private static final long START_TIME_IN_MILLIS = 100000;
|
||||||
|
TextView tvWaktu;
|
||||||
|
private CountDownTimer mCountDownTimer;
|
||||||
|
private boolean mTimerRunning;
|
||||||
|
private long mTimeLeftInMillis = START_TIME_IN_MILLIS;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_dasar3);
|
||||||
|
tvWaktu = findViewById(R.id.tvWaktu);
|
||||||
|
setStatusBar();
|
||||||
|
startTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startTimer() {
|
||||||
|
mCountDownTimer = new CountDownTimer(mTimeLeftInMillis, 1000) {
|
||||||
|
@Override
|
||||||
|
public void onTick(long millisUntilFinished) { // 1 detik
|
||||||
|
mTimeLeftInMillis = millisUntilFinished;
|
||||||
|
updateCountDownText();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFinish() { // selesai
|
||||||
|
mTimerRunning = false;
|
||||||
|
Toast.makeText(Dasar3Activity.this, "Tugas Selesai", Toast.LENGTH_SHORT).show();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
|
||||||
|
mTimerRunning = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCountDownText() {
|
||||||
|
int minutes = (int) (mTimeLeftInMillis / 1000) / 60; // 1 menit
|
||||||
|
int seconds = (int) (mTimeLeftInMillis / 1000) % 60; // 1 detik
|
||||||
|
|
||||||
|
String timeLeftFormatted = String.format("%02d:%02d", minutes, seconds);
|
||||||
|
tvWaktu.setText(timeLeftFormatted);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
Toast.makeText(this, "Tugas Belum Selesai", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setStatusBar() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false);
|
||||||
|
getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWindowFlag(Activity activity, final int bits, boolean on) {
|
||||||
|
Window window = activity.getWindow();
|
||||||
|
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||||
|
if (on) {
|
||||||
|
layoutParams.flags |= bits;
|
||||||
|
} else {
|
||||||
|
layoutParams.flags &= ~bits;
|
||||||
|
}
|
||||||
|
window.setAttributes(layoutParams);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
package com.pkm.parentapps;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.CountDownTimer;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
public class Dasar5Activity extends AppCompatActivity {
|
||||||
|
private static final long START_TIME_IN_MILLIS = 100000;
|
||||||
|
TextView tvWaktu;
|
||||||
|
private CountDownTimer mCountDownTimer;
|
||||||
|
private boolean mTimerRunning;
|
||||||
|
private long mTimeLeftInMillis = START_TIME_IN_MILLIS;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_dasar5);
|
||||||
|
tvWaktu = findViewById(R.id.tvWaktu);
|
||||||
|
setStatusBar();
|
||||||
|
startTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startTimer() {
|
||||||
|
mCountDownTimer = new CountDownTimer(mTimeLeftInMillis, 1000) {
|
||||||
|
@Override
|
||||||
|
public void onTick(long millisUntilFinished) { // 1 detik
|
||||||
|
mTimeLeftInMillis = millisUntilFinished;
|
||||||
|
updateCountDownText();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFinish() { // selesai
|
||||||
|
mTimerRunning = false;
|
||||||
|
Toast.makeText(Dasar5Activity.this, "Tugas Selesai", Toast.LENGTH_SHORT).show();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
|
||||||
|
mTimerRunning = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCountDownText() {
|
||||||
|
int minutes = (int) (mTimeLeftInMillis / 1000) / 60; // 1 menit
|
||||||
|
int seconds = (int) (mTimeLeftInMillis / 1000) % 60; // 1 detik
|
||||||
|
|
||||||
|
String timeLeftFormatted = String.format("%02d:%02d", minutes, seconds);
|
||||||
|
tvWaktu.setText(timeLeftFormatted);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
Toast.makeText(this, "Tugas Belum Selesai", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setStatusBar() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false);
|
||||||
|
getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWindowFlag(Activity activity, final int bits, boolean on) {
|
||||||
|
Window window = activity.getWindow();
|
||||||
|
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||||
|
if (on) {
|
||||||
|
layoutParams.flags |= bits;
|
||||||
|
} else {
|
||||||
|
layoutParams.flags &= ~bits;
|
||||||
|
}
|
||||||
|
window.setAttributes(layoutParams);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,188 @@
|
||||||
|
package com.pkm.parentapps;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.Button;
|
||||||
|
|
||||||
|
public class DasarActivity extends AppCompatActivity {
|
||||||
|
Toolbar toolbar;
|
||||||
|
SharedPreferences sharedPreferences;
|
||||||
|
Button button1, button2, button3, button4, button5, button6, button7, button8, button9;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_dasar);
|
||||||
|
|
||||||
|
init();
|
||||||
|
setStatusBar();
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
onBackPressed();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
for (int i=1; i<=9; i++) {
|
||||||
|
switch (i) {
|
||||||
|
case 1:
|
||||||
|
button1.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(DasarActivity.this, Dasar1Activity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
button2.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(DasarActivity.this, Dasar2Activity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
button3.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(DasarActivity.this, Dasar3Activity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
button4.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
getData(4);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
button5.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
KontenVideo(5);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
button6.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
getData(6);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
button7.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
getData(7);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
button8.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
getData(8);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
button9.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
getData(9);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
toolbar = findViewById(R.id.toolbar);
|
||||||
|
sharedPreferences = getSharedPreferences("UserInfo", MODE_PRIVATE);
|
||||||
|
for (int i = 1; i <= 9; i++) {
|
||||||
|
int id = getResources().getIdentifier("button" + i, "id", getPackageName());
|
||||||
|
switch (i) {
|
||||||
|
case 1:
|
||||||
|
button1 = findViewById(id);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
button2 = findViewById(id);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
button3 = findViewById(id);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
button4 = findViewById(id);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
button5 = findViewById(id);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
button6 = findViewById(id);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
button7 = findViewById(id);
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
button8 = findViewById(id);
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
button9 = findViewById(id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getData(int id) {
|
||||||
|
Intent intent = new Intent(DasarActivity.this, MulaiActivity.class);
|
||||||
|
intent.putExtra("idkonten", String.valueOf(id));
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void KontenVideo(int id) {
|
||||||
|
Intent intent = new Intent(DasarActivity.this, KontenVideoActivity.class);
|
||||||
|
intent.putExtra("idkonten", String.valueOf(id));
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setStatusBar() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false);
|
||||||
|
getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWindowFlag(Activity activity, final int bits, boolean on) {
|
||||||
|
Window window = activity.getWindow();
|
||||||
|
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||||
|
if (on) {
|
||||||
|
layoutParams.flags |= bits;
|
||||||
|
} else {
|
||||||
|
layoutParams.flags &= ~bits;
|
||||||
|
}
|
||||||
|
window.setAttributes(layoutParams);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.pkm.parentapps;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.webkit.WebSettings;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
|
||||||
|
public class DetailArtikelActivity extends AppCompatActivity {
|
||||||
|
WebView webView;
|
||||||
|
WebSettings webSettings;
|
||||||
|
Toolbar toolbar;
|
||||||
|
Intent intent;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_detail_artikel);
|
||||||
|
|
||||||
|
setStatusBar();
|
||||||
|
init();
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
onBackPressed();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
toolbar = findViewById(R.id.toolbar);
|
||||||
|
webView = findViewById(R.id.wvArtikel);
|
||||||
|
intent = getIntent();
|
||||||
|
webSettings = webView.getSettings();
|
||||||
|
webSettings.setJavaScriptEnabled(true);
|
||||||
|
webView.loadUrl(intent.getStringExtra("link"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setStatusBar() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false);
|
||||||
|
getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWindowFlag(Activity activity, final int bits, boolean on) {
|
||||||
|
Window window = activity.getWindow();
|
||||||
|
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||||
|
if (on) {
|
||||||
|
layoutParams.flags |= bits;
|
||||||
|
} else {
|
||||||
|
layoutParams.flags &= ~bits;
|
||||||
|
}
|
||||||
|
window.setAttributes(layoutParams);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
package com.pkm.parentapps;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
public class DetailBlogActivity extends AppCompatActivity {
|
||||||
|
Toolbar toolbar;
|
||||||
|
TextView tvJudul, tvDeskripsi;
|
||||||
|
Intent intent;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_detail_blog);
|
||||||
|
|
||||||
|
init();
|
||||||
|
setStatusBar();
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
onBackPressed();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
String judul = intent.getStringExtra("judul");
|
||||||
|
String deskripsi = intent.getStringExtra("deskripsi");
|
||||||
|
tvJudul.setText(judul);
|
||||||
|
tvDeskripsi.setText(deskripsi);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
toolbar = findViewById(R.id.toolbar);
|
||||||
|
tvJudul = findViewById(R.id.tvJudul);
|
||||||
|
tvDeskripsi = findViewById(R.id.tvDeskripsi);
|
||||||
|
intent = getIntent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setStatusBar() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false);
|
||||||
|
getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWindowFlag(Activity activity, final int bits, boolean on) {
|
||||||
|
Window window = activity.getWindow();
|
||||||
|
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||||
|
if (on) {
|
||||||
|
layoutParams.flags |= bits;
|
||||||
|
} else {
|
||||||
|
layoutParams.flags &= ~bits;
|
||||||
|
}
|
||||||
|
window.setAttributes(layoutParams);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,132 @@
|
||||||
|
package com.pkm.parentapps;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.AppCompatButton;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.android.volley.Request;
|
||||||
|
import com.android.volley.RequestQueue;
|
||||||
|
import com.android.volley.toolbox.StringRequest;
|
||||||
|
import com.android.volley.toolbox.Volley;
|
||||||
|
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class EditAkunActivity extends AppCompatActivity {
|
||||||
|
Toolbar toolbar;
|
||||||
|
EditText etName, etEmail;
|
||||||
|
AppCompatButton btnUbahAkun;
|
||||||
|
SharedPreferences sharedPreferences;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_edit_akun);
|
||||||
|
init();
|
||||||
|
btnUbahAkun.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
ubahData();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
toolbar = findViewById(R.id.toolbar);
|
||||||
|
btnUbahAkun = findViewById(R.id.btnUbahAkun);
|
||||||
|
sharedPreferences = getSharedPreferences("UserInfo", MODE_PRIVATE);
|
||||||
|
etName = findViewById(R.id.etName);
|
||||||
|
etEmail = findViewById(R.id.etEmail);
|
||||||
|
etName.setText(sharedPreferences.getString("name", ""));
|
||||||
|
etEmail.setText(sharedPreferences.getString("email", ""));
|
||||||
|
setStatusBar();
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
onBackPressed();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ubahData() {
|
||||||
|
String url = getResources().getString(R.string.api_server) + "/profile/akun/" + sharedPreferences.getString("id", "");
|
||||||
|
StringRequest request = new StringRequest(Request.Method.POST, url, response -> {
|
||||||
|
try {
|
||||||
|
JSONObject object = new JSONObject(response);
|
||||||
|
if (object.getBoolean("success")) {
|
||||||
|
JSONObject data = object.getJSONObject("data");
|
||||||
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||||
|
editor.putString("name", data.getString("name"));
|
||||||
|
editor.apply();
|
||||||
|
Toast.makeText(EditAkunActivity.this, "Berhasil mengubah data", Toast.LENGTH_SHORT).show();
|
||||||
|
Intent intent = new Intent(EditAkunActivity.this, HomeActivity.class);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}, error -> {
|
||||||
|
error.printStackTrace();
|
||||||
|
Toast.makeText(EditAkunActivity.this, "Gagal", Toast.LENGTH_SHORT).show();
|
||||||
|
}) {
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getHeaders() {
|
||||||
|
Map<String, String> header = new HashMap<>();
|
||||||
|
header.put("Accept", "application/json");
|
||||||
|
header.put("Authorization", "Bearer " + sharedPreferences.getString("token", ""));
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Map<String, String> getParams() {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("name", etName.getText().toString());
|
||||||
|
params.put("email", etEmail.getText().toString());
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
RequestQueue queue = Volley.newRequestQueue(EditAkunActivity.this);
|
||||||
|
queue.add(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setStatusBar() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false);
|
||||||
|
getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWindowFlag(Activity activity, final int bits, boolean on) {
|
||||||
|
Window window = activity.getWindow();
|
||||||
|
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||||
|
if (on) {
|
||||||
|
layoutParams.flags |= bits;
|
||||||
|
} else {
|
||||||
|
layoutParams.flags &= ~bits;
|
||||||
|
}
|
||||||
|
window.setAttributes(layoutParams);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,135 @@
|
||||||
|
package com.pkm.parentapps;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.AppCompatButton;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.android.volley.Request;
|
||||||
|
import com.android.volley.RequestQueue;
|
||||||
|
import com.android.volley.toolbox.StringRequest;
|
||||||
|
import com.android.volley.toolbox.Volley;
|
||||||
|
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class EditPasswordActivity extends AppCompatActivity {
|
||||||
|
Toolbar toolbar;
|
||||||
|
EditText etOldpassword, etPassword, etConfirmPassword;
|
||||||
|
AppCompatButton btnUbahPassword;
|
||||||
|
SharedPreferences sharedPreferences;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_edit_password);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
toolbar = findViewById(R.id.toolbar);
|
||||||
|
btnUbahPassword = findViewById(R.id.btnUbahPassword);
|
||||||
|
sharedPreferences = getSharedPreferences("UserInfo", MODE_PRIVATE);
|
||||||
|
etOldpassword = findViewById(R.id.etOldpassword);
|
||||||
|
etPassword = findViewById(R.id.etPassword);
|
||||||
|
etConfirmPassword = findViewById(R.id.etConfirmPassword);
|
||||||
|
setStatusBar();
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
btnUbahPassword.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
ubahPassword();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ubahPassword() {
|
||||||
|
String url = getResources().getString(R.string.api_server) + "/profile/password/" + sharedPreferences.getString("id", "");
|
||||||
|
StringRequest request = new StringRequest(Request.Method.POST, url, response -> {
|
||||||
|
try {
|
||||||
|
JSONObject object = new JSONObject(response);
|
||||||
|
if (object.getBoolean("success")) {
|
||||||
|
Toast.makeText(EditPasswordActivity.this, "Berhasil", Toast.LENGTH_SHORT).show();
|
||||||
|
Intent intent = new Intent(EditPasswordActivity.this, HomeActivity.class);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(EditPasswordActivity.this, "Gagal", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}, error -> {
|
||||||
|
error.printStackTrace();
|
||||||
|
Toast.makeText(EditPasswordActivity.this, "Gagal", Toast.LENGTH_SHORT).show();
|
||||||
|
}) {
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getHeaders() {
|
||||||
|
Map<String, String> header = new HashMap<>();
|
||||||
|
header.put("Accept", "application/json");
|
||||||
|
header.put("Authorization", "Bearer " + sharedPreferences.getString("token", ""));
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Map<String, String> getParams() {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
if (!etOldpassword.getText().toString().isEmpty()) {
|
||||||
|
params.put("password_lama", etOldpassword.getText().toString());
|
||||||
|
}
|
||||||
|
if (!etPassword.getText().toString().isEmpty()) {
|
||||||
|
params.put("password_baru", etPassword.getText().toString());
|
||||||
|
}
|
||||||
|
if (!etConfirmPassword.getText().toString().isEmpty()) {
|
||||||
|
params.put("c_password_baru", etConfirmPassword.getText().toString());
|
||||||
|
}
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
RequestQueue queue = Volley.newRequestQueue(EditPasswordActivity.this);
|
||||||
|
queue.add(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setStatusBar() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false);
|
||||||
|
getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWindowFlag(Activity activity, final int bits, boolean on) {
|
||||||
|
Window window = activity.getWindow();
|
||||||
|
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||||
|
if (on) {
|
||||||
|
layoutParams.flags |= bits;
|
||||||
|
} else {
|
||||||
|
layoutParams.flags &= ~bits;
|
||||||
|
}
|
||||||
|
window.setAttributes(layoutParams);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,97 @@
|
||||||
|
package com.pkm.parentapps;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||||
|
|
||||||
|
public class HomeActivity extends AppCompatActivity {
|
||||||
|
Intent intent;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
getSupportActionBar().hide();
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_home);
|
||||||
|
setStatusBar();
|
||||||
|
|
||||||
|
BottomNavigationView bottomNavigationView = findViewById(R.id.bottomNavigationView);
|
||||||
|
bottomNavigationView.setOnNavigationItemSelectedListener(item -> {
|
||||||
|
switch (item.getItemId()){
|
||||||
|
case R.id.home:
|
||||||
|
replaceFragment(new HomeFragment());
|
||||||
|
break;
|
||||||
|
case R.id.blog:
|
||||||
|
replaceFragment(new BlogFragment());
|
||||||
|
break;
|
||||||
|
case R.id.akun:
|
||||||
|
replaceFragment(new AkunFragment());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
bottomNavigationView.setSelectedItemId(R.id.home);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void replaceFragment(Fragment fragment) {
|
||||||
|
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||||
|
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
||||||
|
fragmentTransaction.replace(R.id.frameLayout,fragment);
|
||||||
|
fragmentTransaction.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setCancelable(false);
|
||||||
|
builder.setMessage("Anda Yakin Ingin Keluar ?");
|
||||||
|
builder.setPositiveButton("Ya", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setNegativeButton("Tidak", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
dialog.cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
AlertDialog alert = builder.create();
|
||||||
|
alert.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setStatusBar() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false);
|
||||||
|
getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWindowFlag(Activity activity, final int bits, boolean on) {
|
||||||
|
Window window = activity.getWindow();
|
||||||
|
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||||
|
if (on) {
|
||||||
|
layoutParams.flags |= bits;
|
||||||
|
} else {
|
||||||
|
layoutParams.flags &= ~bits;
|
||||||
|
}
|
||||||
|
window.setAttributes(layoutParams);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.pkm.parentapps;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
public class HomeFragment extends Fragment {
|
||||||
|
LinearLayout btnDasar, btnMenengah, btnLanjut;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.fragment_home, container, false);
|
||||||
|
btnDasar = view.findViewById(R.id.btnDasar);
|
||||||
|
btnMenengah = view.findViewById(R.id.btnMenengah);
|
||||||
|
btnLanjut = view.findViewById(R.id.btnLanjut);
|
||||||
|
|
||||||
|
btnDasar.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(getActivity(), DasarActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
btnMenengah.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(getActivity(), MenengahActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
btnLanjut.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
// Intent intent = new Intent(getActivity(), LanjutActivity.class);
|
||||||
|
// startActivity(intent);
|
||||||
|
Toast.makeText(getActivity(), "Dalam Pengembangan", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,214 @@
|
||||||
|
package com.pkm.parentapps;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.CountDownTimer;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.android.volley.Request;
|
||||||
|
import com.android.volley.RequestQueue;
|
||||||
|
import com.android.volley.toolbox.StringRequest;
|
||||||
|
import com.android.volley.toolbox.Volley;
|
||||||
|
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.YouTubePlayer;
|
||||||
|
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.listeners.AbstractYouTubePlayerListener;
|
||||||
|
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class KontenVideoActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
SharedPreferences sharedPreferences;
|
||||||
|
Intent intent;
|
||||||
|
Button btnLanjut;
|
||||||
|
private static final long START_TIME_IN_MILLIS = 100000;
|
||||||
|
TextView tvWaktu, tvDeskripsi, tvJudul, tvIsi;
|
||||||
|
YouTubePlayerView youTubePlayerView;
|
||||||
|
private CountDownTimer mCountDownTimer;
|
||||||
|
private boolean mTimerRunning;
|
||||||
|
private long mTimeLeftInMillis = START_TIME_IN_MILLIS;
|
||||||
|
ArrayList<String> judul = new ArrayList<>();
|
||||||
|
ArrayList<String> video = new ArrayList<>();
|
||||||
|
ArrayList<String> deskripsi = new ArrayList<>();
|
||||||
|
ArrayList<String> isi = new ArrayList<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_konten_video);
|
||||||
|
setStatusBar();
|
||||||
|
init();
|
||||||
|
getData();
|
||||||
|
startTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
tvWaktu = findViewById(R.id.tvWaktu);
|
||||||
|
tvDeskripsi = findViewById(R.id.tvDeskripsi);
|
||||||
|
tvJudul = findViewById(R.id.tvJudul);
|
||||||
|
tvIsi = findViewById(R.id.tvIsi);
|
||||||
|
youTubePlayerView = findViewById(R.id.youtube_player_view);
|
||||||
|
getLifecycle().addObserver(youTubePlayerView);
|
||||||
|
btnLanjut = findViewById(R.id.btnLanjut);
|
||||||
|
sharedPreferences = getSharedPreferences("UserInfo", MODE_PRIVATE);
|
||||||
|
intent = getIntent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getData() {
|
||||||
|
String url = getResources().getString(R.string.api_server) + "/konten/" + intent.getStringExtra("idkonten");
|
||||||
|
String token = sharedPreferences.getString("token", "");
|
||||||
|
StringRequest request = new StringRequest(Request.Method.GET, url, response -> {
|
||||||
|
try {
|
||||||
|
JSONObject object = new JSONObject(response);
|
||||||
|
if (object.getBoolean("success")) {
|
||||||
|
JSONArray data = new JSONArray(object.getString("data"));
|
||||||
|
for (int i = 0; i < data.length(); i++) {
|
||||||
|
JSONObject item = data.getJSONObject(i);
|
||||||
|
judul.add(item.getString("judul"));
|
||||||
|
video.add(item.getString("youtube"));
|
||||||
|
deskripsi.add(item.getString("deskripsi"));
|
||||||
|
isi.add(item.getString("isi"));
|
||||||
|
}
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}, error -> {
|
||||||
|
error.printStackTrace();
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setTitle("Pesan");
|
||||||
|
builder.setMessage("Terjadi Kesalahan");
|
||||||
|
builder.setPositiveButton("Ok", null);
|
||||||
|
builder.show();
|
||||||
|
}) {
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getHeaders() {
|
||||||
|
Map<String, String> header = new HashMap<>();
|
||||||
|
header.put("Accept", "application/json");
|
||||||
|
header.put("Authorization", "Bearer " + token);
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
RequestQueue queue = Volley.newRequestQueue(this);
|
||||||
|
queue.add(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int currentContentIndex = 0;
|
||||||
|
|
||||||
|
private void load() {
|
||||||
|
updateContent(currentContentIndex);
|
||||||
|
|
||||||
|
btnLanjut.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
currentContentIndex++;
|
||||||
|
if (currentContentIndex < judul.size()) {
|
||||||
|
updateContent(currentContentIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentContentIndex == judul.size() - 1) {
|
||||||
|
btnLanjut.setText("Selesai");
|
||||||
|
btnLanjut.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateContent(int index) {
|
||||||
|
tvJudul.setText(judul.get(index));
|
||||||
|
tvIsi.setText(isi.get(index));
|
||||||
|
tvDeskripsi.setText(deskripsi.get(index));
|
||||||
|
youTubePlayerView.addYouTubePlayerListener(new AbstractYouTubePlayerListener() {
|
||||||
|
@Override
|
||||||
|
public void onReady(@NonNull YouTubePlayer youTubePlayer) {
|
||||||
|
String videoId = video.get(index);
|
||||||
|
System.out.println("Video Id: " + video.get(index));
|
||||||
|
youTubePlayer.loadVideo(videoId, 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startTimer() {
|
||||||
|
mCountDownTimer = new CountDownTimer(mTimeLeftInMillis, 1000) {
|
||||||
|
@Override
|
||||||
|
public void onTick(long millisUntilFinished) { // 1 detik
|
||||||
|
mTimeLeftInMillis = millisUntilFinished;
|
||||||
|
updateCountDownText();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFinish() { // selesai
|
||||||
|
mTimerRunning = false;
|
||||||
|
Toast.makeText(KontenVideoActivity.this, "Tugas Selesai", Toast.LENGTH_SHORT).show();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
|
||||||
|
mTimerRunning = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCountDownText() {
|
||||||
|
int minutes = (int) (mTimeLeftInMillis / 1000) / 60; // 1 menit
|
||||||
|
int seconds = (int) (mTimeLeftInMillis / 1000) % 60; // 1 detik
|
||||||
|
|
||||||
|
String timeLeftFormatted = String.format("%02d:%02d", minutes, seconds);
|
||||||
|
tvWaktu.setText(timeLeftFormatted);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
Toast.makeText(this, "Tugas Belum Selesai", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setStatusBar() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false);
|
||||||
|
getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWindowFlag(Activity activity, final int bits, boolean on) {
|
||||||
|
Window window = activity.getWindow();
|
||||||
|
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||||
|
if (on) {
|
||||||
|
layoutParams.flags |= bits;
|
||||||
|
} else {
|
||||||
|
layoutParams.flags &= ~bits;
|
||||||
|
}
|
||||||
|
window.setAttributes(layoutParams);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,197 @@
|
||||||
|
package com.pkm.parentapps;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.Button;
|
||||||
|
|
||||||
|
import com.android.volley.Request;
|
||||||
|
import com.android.volley.RequestQueue;
|
||||||
|
import com.android.volley.toolbox.StringRequest;
|
||||||
|
import com.android.volley.toolbox.Volley;
|
||||||
|
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class LanjutActivity extends AppCompatActivity {
|
||||||
|
Toolbar toolbar;
|
||||||
|
SharedPreferences sharedPreferences;
|
||||||
|
Button button19, button20, button21, button22, button23, button24, button25, button26, button27;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_lanjut);
|
||||||
|
init();
|
||||||
|
setStatusBar();
|
||||||
|
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
onBackPressed();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
toolbar = findViewById(R.id.toolbar);
|
||||||
|
sharedPreferences = getSharedPreferences("UserInfo", MODE_PRIVATE);
|
||||||
|
for (int i=19; i<=27; i++) {
|
||||||
|
int id = getResources().getIdentifier("button"+i, "id", getPackageName());
|
||||||
|
switch (i) {
|
||||||
|
case 19:
|
||||||
|
button19 = findViewById(id);
|
||||||
|
button19.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
getData(19);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 20:
|
||||||
|
button20 = findViewById(id);
|
||||||
|
button20.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
getData(20);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 21:
|
||||||
|
button21 = findViewById(id);
|
||||||
|
button21.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
getData(21);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 22:
|
||||||
|
button22 = findViewById(id);
|
||||||
|
button22.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
getData(22);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 23:
|
||||||
|
button23 = findViewById(id);
|
||||||
|
button23.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
getData(23);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 24:
|
||||||
|
button24 = findViewById(id);
|
||||||
|
button24.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
getData(24);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 25:
|
||||||
|
button25 = findViewById(id);
|
||||||
|
button25.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
getData(25);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 26:
|
||||||
|
button26 = findViewById(id);
|
||||||
|
button26.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
getData(26);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 27:
|
||||||
|
button27 = findViewById(id);
|
||||||
|
button27.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
getData(27);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getData(int id) {
|
||||||
|
String url = getResources().getString(R.string.api_server) + "/konten/" + id;
|
||||||
|
String token = sharedPreferences.getString("token", "");
|
||||||
|
StringRequest request = new StringRequest(Request.Method.GET, url, response -> {
|
||||||
|
try {
|
||||||
|
JSONObject object = new JSONObject(response);
|
||||||
|
if (object.getBoolean("success")) {
|
||||||
|
JSONObject data = object.getJSONObject("data");
|
||||||
|
Intent intent = new Intent(LanjutActivity.this, MulaiActivity.class);
|
||||||
|
intent.putExtra("konten", data.getString("isi"));
|
||||||
|
intent.putExtra("idvideo", data.getString("idvideo"));
|
||||||
|
intent.putExtra("gambar", data.getString("gambar"));
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}, error -> {
|
||||||
|
error.printStackTrace();
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setTitle("Pesan");
|
||||||
|
builder.setMessage("Terjadi Kesalahan");
|
||||||
|
builder.setPositiveButton("Ok", null);
|
||||||
|
builder.show();
|
||||||
|
}) {
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getHeaders() {
|
||||||
|
Map<String, String> header = new HashMap<>();
|
||||||
|
header.put("Accept", "application/json");
|
||||||
|
header.put("Authorization", "Bearer " + token);
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
RequestQueue queue = Volley.newRequestQueue(this);
|
||||||
|
queue.add(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setStatusBar() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false);
|
||||||
|
getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWindowFlag(Activity activity, final int bits, boolean on) {
|
||||||
|
Window window = activity.getWindow();
|
||||||
|
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||||
|
if (on) {
|
||||||
|
layoutParams.flags |= bits;
|
||||||
|
} else {
|
||||||
|
layoutParams.flags &= ~bits;
|
||||||
|
}
|
||||||
|
window.setAttributes(layoutParams);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,211 @@
|
||||||
|
package com.pkm.parentapps;
|
||||||
|
|
||||||
|
import static android.content.ContentValues.TAG;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.AppCompatButton;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.android.volley.Request;
|
||||||
|
import com.android.volley.RequestQueue;
|
||||||
|
import com.android.volley.toolbox.StringRequest;
|
||||||
|
import com.android.volley.toolbox.Volley;
|
||||||
|
import com.google.android.gms.tasks.OnCompleteListener;
|
||||||
|
import com.google.android.gms.tasks.Task;
|
||||||
|
import com.google.firebase.messaging.FirebaseMessaging;
|
||||||
|
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class LoginActivity extends AppCompatActivity {
|
||||||
|
TextView tvRegister;
|
||||||
|
EditText etEmail, etPassword;
|
||||||
|
SharedPreferences sharedPreferences;
|
||||||
|
AppCompatButton btnLogin;
|
||||||
|
private String firebaseToken;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_login);
|
||||||
|
setStatusBar();
|
||||||
|
init();
|
||||||
|
FirebaseMessaging.getInstance().getToken()
|
||||||
|
.addOnCompleteListener(new OnCompleteListener<String>() {
|
||||||
|
@Override
|
||||||
|
public void onComplete(@NonNull Task<String> task) {
|
||||||
|
if (!task.isSuccessful()) {
|
||||||
|
Log.w(TAG, "Fetching FCM registration token failed", task.getException());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
firebaseToken = task.getResult();
|
||||||
|
Log.d(TAG, "Token: " + firebaseToken);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tvRegister.setOnClickListener(v -> {
|
||||||
|
Intent intent = new Intent(LoginActivity.this, RegisterActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
});
|
||||||
|
btnLogin.setOnClickListener(v -> {
|
||||||
|
postData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void postData() {
|
||||||
|
String url = getResources().getString(R.string.api_server) + "/login";
|
||||||
|
StringRequest request = new StringRequest(Request.Method.POST, url, response -> {
|
||||||
|
try {
|
||||||
|
JSONObject object = new JSONObject(response);
|
||||||
|
if (object.getBoolean("success")) {
|
||||||
|
JSONObject data = object.getJSONObject("data");
|
||||||
|
String id = data.getString("id");
|
||||||
|
String name = data.getString("name");
|
||||||
|
String email = data.getString("email");
|
||||||
|
String token = data.getString("token");
|
||||||
|
sharedPreferences = getSharedPreferences("UserInfo", MODE_PRIVATE);
|
||||||
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||||
|
editor.putString("token", token);
|
||||||
|
editor.putString("id", id);
|
||||||
|
editor.putString("name", name);
|
||||||
|
editor.putString("email", email);
|
||||||
|
editor.putBoolean("login", true);
|
||||||
|
editor.apply();
|
||||||
|
postToken();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}, error -> {
|
||||||
|
error.printStackTrace();
|
||||||
|
Toast.makeText(LoginActivity.this, "Login gagal", Toast.LENGTH_SHORT).show();
|
||||||
|
}) {
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getHeaders() {
|
||||||
|
Map<String, String> header = new HashMap<>();
|
||||||
|
header.put("Accept", "application/json");
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Map<String, String> getParams() {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("email", etEmail.getText().toString());
|
||||||
|
params.put("password", etPassword.getText().toString());
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
RequestQueue queue = Volley.newRequestQueue(LoginActivity.this);
|
||||||
|
queue.add(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void postToken() {
|
||||||
|
String url = getResources().getString(R.string.api_server) + "/firebase/create";
|
||||||
|
StringRequest request = new StringRequest(Request.Method.POST, url, response -> {
|
||||||
|
try {
|
||||||
|
JSONObject object = new JSONObject(response);
|
||||||
|
if (object.getBoolean("success")) {
|
||||||
|
Toast.makeText(LoginActivity.this, "Login berhasil", Toast.LENGTH_SHORT).show();
|
||||||
|
Intent intent = new Intent(LoginActivity.this, HomeActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}, error -> {
|
||||||
|
error.printStackTrace();
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
|
||||||
|
builder.setTitle("Pesan");
|
||||||
|
builder.setMessage("Token gagal disimpan, silahkan coba lagi");
|
||||||
|
builder.setPositiveButton("Ok", null);
|
||||||
|
builder.show();
|
||||||
|
}) {
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getHeaders() {
|
||||||
|
Map<String, String> header = new HashMap<>();
|
||||||
|
header.put("Accept", "application/json");
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Map<String, String> getParams() {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("token", firebaseToken);
|
||||||
|
params.put("user_id", sharedPreferences.getString("id", ""));
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
RequestQueue queue = Volley.newRequestQueue(LoginActivity.this);
|
||||||
|
queue.add(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
tvRegister = findViewById(R.id.tvRegister);
|
||||||
|
etEmail = findViewById(R.id.etEmail);
|
||||||
|
etPassword = findViewById(R.id.etPassword);
|
||||||
|
btnLogin = findViewById(R.id.btnLogin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setCancelable(false);
|
||||||
|
builder.setMessage("Anda Yakin Ingin Keluar ?");
|
||||||
|
builder.setPositiveButton("Ya", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setNegativeButton("Tidak", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
dialog.cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
AlertDialog alert = builder.create();
|
||||||
|
alert.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setStatusBar() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false);
|
||||||
|
getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWindowFlag(Activity activity, final int bits, boolean on) {
|
||||||
|
Window window = activity.getWindow();
|
||||||
|
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||||
|
if (on) {
|
||||||
|
layoutParams.flags |= bits;
|
||||||
|
} else {
|
||||||
|
layoutParams.flags &= ~bits;
|
||||||
|
}
|
||||||
|
window.setAttributes(layoutParams);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.pkm.parentapps;
|
||||||
|
|
||||||
|
import static android.content.ContentValues.TAG;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.google.android.gms.tasks.OnCompleteListener;
|
||||||
|
import com.google.android.gms.tasks.Task;
|
||||||
|
import com.google.firebase.FirebaseApp;
|
||||||
|
import com.google.firebase.messaging.FirebaseMessaging;
|
||||||
|
|
||||||
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
SharedPreferences sharedPreferences;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
getSupportActionBar().hide();
|
||||||
|
getWindow().setStatusBarColor(getResources().getColor(R.color.main));
|
||||||
|
sharedPreferences = getSharedPreferences("UserInfo", MODE_PRIVATE);
|
||||||
|
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
new Handler().postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (sharedPreferences.getBoolean("login", false)) {
|
||||||
|
Intent intent = new Intent(MainActivity.this, HomeActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
Intent intent = new Intent(MainActivity.this, LoginActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,185 @@
|
||||||
|
package com.pkm.parentapps;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.Button;
|
||||||
|
|
||||||
|
public class MenengahActivity extends AppCompatActivity {
|
||||||
|
Toolbar toolbar;
|
||||||
|
SharedPreferences sharedPreferences;
|
||||||
|
Button button10, button11, button12, button13, button14, button15, button16, button17, button18;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_menengah);
|
||||||
|
|
||||||
|
init();
|
||||||
|
setStatusBar();
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
onBackPressed();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
for (int i=10; i<=18; i++) {
|
||||||
|
switch (i) {
|
||||||
|
case 10:
|
||||||
|
button10.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
KontenVideo(10);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
button11.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
KontenVideo(11);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
button12.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
KontenVideo(12);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
button13.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
getData(13);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
button14.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
getData(14);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 15:
|
||||||
|
button15.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
KontenVideo(15);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
button16.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
KontenVideo(16);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 17:
|
||||||
|
button17.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
getData(17);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 18:
|
||||||
|
button18.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
getData(18);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
toolbar = findViewById(R.id.toolbar);
|
||||||
|
sharedPreferences = getSharedPreferences("UserInfo", MODE_PRIVATE);
|
||||||
|
for (int i=10; i<=18; i++) {
|
||||||
|
int id = getResources().getIdentifier("button" + i, "id", getPackageName());
|
||||||
|
switch (i) {
|
||||||
|
case 10:
|
||||||
|
button10 = findViewById(id);
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
button11 = findViewById(id);
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
button12 = findViewById(id);
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
button13 = findViewById(id);
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
button14 = findViewById(id);
|
||||||
|
break;
|
||||||
|
case 15:
|
||||||
|
button15 = findViewById(id);
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
button16 = findViewById(id);
|
||||||
|
break;
|
||||||
|
case 17:
|
||||||
|
button17 = findViewById(id);
|
||||||
|
break;
|
||||||
|
case 18:
|
||||||
|
button18 = findViewById(id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getData(int id) {
|
||||||
|
Intent intent = new Intent(MenengahActivity.this, MulaiActivity.class);
|
||||||
|
intent.putExtra("idkonten", String.valueOf(id));
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void KontenVideo(int id) {
|
||||||
|
Intent intent = new Intent(MenengahActivity.this, KontenVideoActivity.class);
|
||||||
|
intent.putExtra("idkonten", String.valueOf(id));
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setStatusBar() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false);
|
||||||
|
getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWindowFlag(Activity activity, final int bits, boolean on) {
|
||||||
|
Window window = activity.getWindow();
|
||||||
|
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||||
|
if (on) {
|
||||||
|
layoutParams.flags |= bits;
|
||||||
|
} else {
|
||||||
|
layoutParams.flags &= ~bits;
|
||||||
|
}
|
||||||
|
window.setAttributes(layoutParams);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,245 @@
|
||||||
|
package com.pkm.parentapps;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.CountDownTimer;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.MediaController;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
import android.widget.VideoView;
|
||||||
|
|
||||||
|
import com.android.volley.Request;
|
||||||
|
import com.android.volley.RequestQueue;
|
||||||
|
import com.android.volley.toolbox.StringRequest;
|
||||||
|
import com.android.volley.toolbox.Volley;
|
||||||
|
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.YouTubePlayer;
|
||||||
|
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.listeners.AbstractYouTubePlayerListener;
|
||||||
|
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.listeners.YouTubePlayerListener;
|
||||||
|
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.options.IFramePlayerOptions;
|
||||||
|
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class MulaiActivity extends AppCompatActivity {
|
||||||
|
SharedPreferences sharedPreferences;
|
||||||
|
Intent intent;
|
||||||
|
Button btnLanjut;
|
||||||
|
private static final long START_TIME_IN_MILLIS = 100000;
|
||||||
|
TextView tvWaktu, tvDeskripsi, tvJudul, tvIsi;
|
||||||
|
ImageView ivKonten;
|
||||||
|
private CountDownTimer mCountDownTimer;
|
||||||
|
private boolean mTimerRunning;
|
||||||
|
private long mTimeLeftInMillis = START_TIME_IN_MILLIS;
|
||||||
|
ArrayList<String> judul = new ArrayList<>();
|
||||||
|
ArrayList<String> gambar = new ArrayList<>();
|
||||||
|
ArrayList<String> deskripsi = new ArrayList<>();
|
||||||
|
ArrayList<String> isi = new ArrayList<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_mulai);
|
||||||
|
setStatusBar();
|
||||||
|
init();
|
||||||
|
getData();
|
||||||
|
startTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
tvWaktu = findViewById(R.id.tvWaktu);
|
||||||
|
tvDeskripsi = findViewById(R.id.tvDeskripsi);
|
||||||
|
tvJudul = findViewById(R.id.tvJudul);
|
||||||
|
tvIsi = findViewById(R.id.tvIsi);
|
||||||
|
ivKonten = findViewById(R.id.ivKonten);
|
||||||
|
btnLanjut = findViewById(R.id.btnLanjut);
|
||||||
|
sharedPreferences = getSharedPreferences("UserInfo", MODE_PRIVATE);
|
||||||
|
intent = getIntent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getData() {
|
||||||
|
String url = getResources().getString(R.string.api_server) + "/konten/" + intent.getStringExtra("idkonten");
|
||||||
|
String token = sharedPreferences.getString("token", "");
|
||||||
|
StringRequest request = new StringRequest(Request.Method.GET, url, response -> {
|
||||||
|
try {
|
||||||
|
JSONObject object = new JSONObject(response);
|
||||||
|
if (object.getBoolean("success")) {
|
||||||
|
JSONArray data = new JSONArray(object.getString("data"));
|
||||||
|
for (int i = 0; i < data.length(); i++) {
|
||||||
|
JSONObject item = data.getJSONObject(i);
|
||||||
|
judul.add(item.getString("judul"));
|
||||||
|
gambar.add(item.getString("gambar"));
|
||||||
|
deskripsi.add(item.getString("deskripsi"));
|
||||||
|
isi.add(item.getString("isi"));
|
||||||
|
}
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}, error -> {
|
||||||
|
error.printStackTrace();
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setTitle("Pesan");
|
||||||
|
builder.setMessage("Terjadi Kesalahan");
|
||||||
|
builder.setPositiveButton("Ok", null);
|
||||||
|
builder.show();
|
||||||
|
}) {
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getHeaders() {
|
||||||
|
Map<String, String> header = new HashMap<>();
|
||||||
|
header.put("Accept", "application/json");
|
||||||
|
header.put("Authorization", "Bearer " + token);
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
RequestQueue queue = Volley.newRequestQueue(this);
|
||||||
|
queue.add(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int currentContentIndex = 0;
|
||||||
|
|
||||||
|
private void load() {
|
||||||
|
updateContent(currentContentIndex);
|
||||||
|
|
||||||
|
btnLanjut.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
currentContentIndex++;
|
||||||
|
if (currentContentIndex < judul.size()) {
|
||||||
|
updateContent(currentContentIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentContentIndex == judul.size() - 1) {
|
||||||
|
btnLanjut.setText("Selesai");
|
||||||
|
btnLanjut.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateContent(int index) {
|
||||||
|
tvJudul.setText(judul.get(index));
|
||||||
|
tvIsi.setText(isi.get(index));
|
||||||
|
tvDeskripsi.setText(deskripsi.get(index));
|
||||||
|
String imageName = gambar.get(index);
|
||||||
|
int resID = getResources().getIdentifier(imageName, "drawable", getPackageName());
|
||||||
|
if (resID != 0) {
|
||||||
|
ivKonten.setImageResource(resID);
|
||||||
|
} else {
|
||||||
|
Toast.makeText(this, "Gambar tidak ditemukan", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
// String url = getResources().getString(R.string.img_server) + gambar.get(index);
|
||||||
|
// new DownloadImageTask(ivKonten).execute(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
|
||||||
|
ImageView bmImage;
|
||||||
|
|
||||||
|
public DownloadImageTask(ImageView bmImage) {
|
||||||
|
this.bmImage = bmImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Bitmap doInBackground(String... urls) {
|
||||||
|
String urldisplay = urls[0];
|
||||||
|
Bitmap mIcon11 = null;
|
||||||
|
try {
|
||||||
|
InputStream in = new java.net.URL(urldisplay).openStream();
|
||||||
|
mIcon11 = BitmapFactory.decodeStream(in);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e("Error", e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return mIcon11;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onPostExecute(Bitmap result) {
|
||||||
|
bmImage.setImageBitmap(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startTimer() {
|
||||||
|
mCountDownTimer = new CountDownTimer(mTimeLeftInMillis, 1000) {
|
||||||
|
@Override
|
||||||
|
public void onTick(long millisUntilFinished) { // 1 detik
|
||||||
|
mTimeLeftInMillis = millisUntilFinished;
|
||||||
|
updateCountDownText();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFinish() { // selesai
|
||||||
|
mTimerRunning = false;
|
||||||
|
Toast.makeText(MulaiActivity.this, "Tugas Selesai", Toast.LENGTH_SHORT).show();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
|
||||||
|
mTimerRunning = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCountDownText() {
|
||||||
|
int minutes = (int) (mTimeLeftInMillis / 1000) / 60; // 1 menit
|
||||||
|
int seconds = (int) (mTimeLeftInMillis / 1000) % 60; // 1 detik
|
||||||
|
|
||||||
|
String timeLeftFormatted = String.format("%02d:%02d", minutes, seconds);
|
||||||
|
tvWaktu.setText(timeLeftFormatted);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
Toast.makeText(this, "Tugas Belum Selesai", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setStatusBar() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false);
|
||||||
|
getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWindowFlag(Activity activity, final int bits, boolean on) {
|
||||||
|
Window window = activity.getWindow();
|
||||||
|
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||||
|
if (on) {
|
||||||
|
layoutParams.flags |= bits;
|
||||||
|
} else {
|
||||||
|
layoutParams.flags &= ~bits;
|
||||||
|
}
|
||||||
|
window.setAttributes(layoutParams);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,90 @@
|
||||||
|
package com.pkm.parentapps;
|
||||||
|
|
||||||
|
import android.app.NotificationChannel;
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.media.RingtoneManager;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.core.app.NotificationCompat;
|
||||||
|
|
||||||
|
import com.android.volley.Request;
|
||||||
|
import com.android.volley.RequestQueue;
|
||||||
|
import com.android.volley.toolbox.StringRequest;
|
||||||
|
import com.android.volley.toolbox.Volley;
|
||||||
|
import com.google.firebase.messaging.FirebaseMessaging;
|
||||||
|
import com.google.firebase.messaging.FirebaseMessagingService;
|
||||||
|
import com.google.firebase.messaging.RemoteMessage;
|
||||||
|
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class MyFirebaseMessagingService extends FirebaseMessagingService {
|
||||||
|
Intent intent;
|
||||||
|
private static final String TAG = "MyFirebaseMsgService";
|
||||||
|
@Override
|
||||||
|
public void onMessageReceived(RemoteMessage remoteMessage) {
|
||||||
|
System.out.println("From: " + remoteMessage.getFrom());
|
||||||
|
if (remoteMessage.getNotification() != null) {
|
||||||
|
System.out.println("Message Notification Body: " + remoteMessage.getNotification().getBody());
|
||||||
|
}
|
||||||
|
sendNotification(remoteMessage.getFrom(), remoteMessage.getNotification().getBody());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendNotification(String from, String body) {
|
||||||
|
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Toast.makeText(getApplicationContext(), "From: " + from + "\nBody: " + body, Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNewToken(@NonNull String token) {
|
||||||
|
Log.d(TAG, "Refreshed token: " + token);
|
||||||
|
sendRegistrationToServer(token);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendRegistrationToServer(String token) {
|
||||||
|
String url = getResources().getString(R.string.api_server) + "/firebase/update" + intent.getStringExtra("id");
|
||||||
|
StringRequest request = new StringRequest(Request.Method.POST, url, response -> {
|
||||||
|
try {
|
||||||
|
JSONObject object = new JSONObject(response);
|
||||||
|
if (object.getBoolean("success")) {
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}, error -> {
|
||||||
|
error.printStackTrace();
|
||||||
|
}) {
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getHeaders() {
|
||||||
|
Map<String, String> header = new HashMap<>();
|
||||||
|
header.put("Accept", "application/json");
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Map<String, String> getParams() {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("token", token);
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
RequestQueue queue = Volley.newRequestQueue(getApplicationContext());
|
||||||
|
queue.add(request);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,159 @@
|
||||||
|
package com.pkm.parentapps;
|
||||||
|
|
||||||
|
import static android.content.ContentValues.TAG;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.AppCompatButton;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.android.volley.Request;
|
||||||
|
import com.android.volley.RequestQueue;
|
||||||
|
import com.android.volley.Response;
|
||||||
|
import com.android.volley.VolleyError;
|
||||||
|
import com.android.volley.toolbox.JsonObjectRequest;
|
||||||
|
import com.android.volley.toolbox.StringRequest;
|
||||||
|
import com.android.volley.toolbox.Volley;
|
||||||
|
import com.google.android.gms.tasks.OnCompleteListener;
|
||||||
|
import com.google.android.gms.tasks.Task;
|
||||||
|
import com.google.firebase.messaging.FirebaseMessaging;
|
||||||
|
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class RegisterActivity extends AppCompatActivity {
|
||||||
|
TextView tvLogin;
|
||||||
|
EditText etName, etEmail, etPassword, etConfirmPassword;
|
||||||
|
AppCompatButton btnRegister;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_register);
|
||||||
|
setStatusBar();
|
||||||
|
init();
|
||||||
|
tvLogin.setOnClickListener(v -> {
|
||||||
|
Intent intent = new Intent(RegisterActivity.this, LoginActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
});
|
||||||
|
btnRegister.setOnClickListener(v -> {
|
||||||
|
if (etName.getText().toString().isEmpty()) {
|
||||||
|
etName.setError("Nama tidak boleh kosong");
|
||||||
|
etName.requestFocus();
|
||||||
|
} else if (etEmail.getText().toString().isEmpty()) {
|
||||||
|
etEmail.setError("Email tidak boleh kosong");
|
||||||
|
etEmail.requestFocus();
|
||||||
|
} else if (etPassword.getText().toString().isEmpty()) {
|
||||||
|
etPassword.setError("Password tidak boleh kosong");
|
||||||
|
etPassword.requestFocus();
|
||||||
|
} else if (etConfirmPassword.getText().toString().isEmpty()) {
|
||||||
|
etConfirmPassword.setError("Konfirmasi password tidak boleh kosong");
|
||||||
|
etConfirmPassword.requestFocus();
|
||||||
|
} else if (!etPassword.getText().toString().equals(etConfirmPassword.getText().toString())) {
|
||||||
|
etConfirmPassword.setError("Password tidak sama");
|
||||||
|
etConfirmPassword.requestFocus();
|
||||||
|
} else {
|
||||||
|
postData();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void postData () {
|
||||||
|
String url = getResources().getString(R.string.api_server) + "/register";
|
||||||
|
StringRequest request = new StringRequest(Request.Method.POST, url, response -> {
|
||||||
|
try {
|
||||||
|
JSONObject object = new JSONObject(response);
|
||||||
|
if (object.getBoolean("success")) {
|
||||||
|
Toast.makeText(RegisterActivity.this, "Registrasi berhasil", Toast.LENGTH_SHORT).show();
|
||||||
|
Intent intent = new Intent(RegisterActivity.this, LoginActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}, error -> {
|
||||||
|
error.printStackTrace();
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(RegisterActivity.this);
|
||||||
|
builder.setTitle("Pesan");
|
||||||
|
builder.setMessage("Registrasi gagal, silahkan coba lagi");
|
||||||
|
builder.setPositiveButton("Ok", null);
|
||||||
|
builder.show();
|
||||||
|
}) {
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getHeaders() {
|
||||||
|
Map<String, String> header = new HashMap<>();
|
||||||
|
header.put("Accept", "application/json");
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Map<String, String> getParams() {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("name", etName.getText().toString());
|
||||||
|
params.put("email", etEmail.getText().toString());
|
||||||
|
params.put("password", etPassword.getText().toString());
|
||||||
|
params.put("c_password", etConfirmPassword.getText().toString());
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
RequestQueue queue = Volley.newRequestQueue(RegisterActivity.this);
|
||||||
|
queue.add(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
tvLogin = findViewById(R.id.tvLogin);
|
||||||
|
etName = findViewById(R.id.etName);
|
||||||
|
etEmail = findViewById(R.id.etEmail);
|
||||||
|
etPassword = findViewById(R.id.etPassword);
|
||||||
|
etConfirmPassword = findViewById(R.id.etConfirmPassword);
|
||||||
|
btnRegister = findViewById(R.id.btnRegister);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
Intent intent = new Intent(RegisterActivity.this, LoginActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setStatusBar() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false);
|
||||||
|
getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWindowFlag(Activity activity, final int bits, boolean on) {
|
||||||
|
Window window = activity.getWindow();
|
||||||
|
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||||
|
if (on) {
|
||||||
|
layoutParams.flags |= bits;
|
||||||
|
} else {
|
||||||
|
layoutParams.flags &= ~bits;
|
||||||
|
}
|
||||||
|
window.setAttributes(layoutParams);
|
||||||
|
}
|
||||||
|
}
|
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 8.7 KiB |
After Width: | Height: | Size: 9.2 KiB |
After Width: | Height: | Size: 9.5 KiB |
After Width: | Height: | Size: 8.8 KiB |
After Width: | Height: | Size: 9.3 KiB |
After Width: | Height: | Size: 9.5 KiB |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 9.5 KiB |
After Width: | Height: | Size: 9.5 KiB |
After Width: | Height: | Size: 8.6 KiB |
After Width: | Height: | Size: 9.1 KiB |
After Width: | Height: | Size: 9.3 KiB |
After Width: | Height: | Size: 8.7 KiB |
After Width: | Height: | Size: 9.2 KiB |
After Width: | Height: | Size: 9.3 KiB |
After Width: | Height: | Size: 8.8 KiB |
After Width: | Height: | Size: 9.4 KiB |
After Width: | Height: | Size: 9.4 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 8.3 KiB |
After Width: | Height: | Size: 8.8 KiB |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 8.5 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 9.1 KiB |
After Width: | Height: | Size: 8.6 KiB |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 9.1 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 76 KiB |
After Width: | Height: | Size: 53 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 4.2 KiB |