Skip to content

Commit

Permalink
Merge pull request #105 from Crazy-Marvin/development
Browse files Browse the repository at this point in the history
Vacation Days v9.0
  • Loading branch information
CrazyMarvin authored Oct 3, 2022
2 parents 743b190 + 10d56dc commit e4b39b6
Show file tree
Hide file tree
Showing 19 changed files with 194 additions and 91 deletions.
12 changes: 6 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'crea
}

android {
compileSdkVersion 31
compileSdkVersion 33
lintOptions {
checkReleaseBuilds false
}
defaultConfig {
applicationId "rocks.poopjournal.vacationdays"
minSdkVersion 21
targetSdkVersion 31
versionCode 8
versionName "8.0"
targetSdkVersion 33
versionCode 9
versionName "9.0"


testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -64,7 +64,7 @@ testOptions {

dependencies {

implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.+'
Expand All @@ -78,5 +78,5 @@ dependencies {
implementation 'com.savvi.datepicker:rangepicker:1.3.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'com.wdullaer:materialdatetimepicker:4.2.3'
implementation 'com.opencsv:opencsv:5.6'
implementation 'com.opencsv:opencsv:5.7.0'
}
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 8,
"versionName": "8.0",
"versionCode": 9,
"versionName": "9.0",
"outputFile": "app-release.apk"
}
],
Expand Down
45 changes: 28 additions & 17 deletions app/src/main/java/rocks/poopjournal/vacationdays/About.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package rocks.poopjournal.vacationdays;

import android.annotation.SuppressLint;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
Expand All @@ -11,20 +12,27 @@

import androidx.appcompat.app.AppCompatActivity;

import com.github.sundeepk.compactcalendarview.BuildConfig;
//import com.github.sundeepk.compactcalendarview.BuildConfig;

public class About extends AppCompatActivity {
TextView version;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
version=findViewById(R.id.versiontext);
version.setText(BuildConfig.VERSION_NAME+" "+this.getString(R.string.apache) );
}
TextView appVersion = findViewById(R.id.version);
//version.setText(BuildConfig.VERSION_NAME+" "+this.getString(R.string.apache) );

//@SuppressLint({"StringFormatInvalid", "LocalSuppress"}) String version =
@SuppressLint({"StringFormatInvalid", "LocalSuppress"}) String version =
String.format(getResources().getString(R.string.version),
BuildConfig.VERSION_NAME);
appVersion.setText(version);
}

public void contact_codeaquaria(View view) {
switch(view.getId()){
switch (view.getId()) {
case R.id.btnmail_codeaquaria:
String mailto = "mailto:codeaquaria20@gmail.com";
Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
Expand Down Expand Up @@ -54,7 +62,7 @@ public void contact_codeaquaria(View view) {
}

public void contact_marvin(View view) {
switch(view.getId()){
switch (view.getId()) {
case R.id.btnmail_crazymarvin:
String mailto = "mailto:marvin@poopjournal.rocks";
Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
Expand Down Expand Up @@ -145,19 +153,22 @@ public void Kotlin(View view) {
Intent i = new Intent(Intent.ACTION_VIEW, u);
startActivity(i);
}

public void Java(View view) {
Uri u = Uri.parse("http://openjdk.java.net/legal/gplv2+ce.html");
Intent i = new Intent(Intent.ACTION_VIEW, u);
startActivity(i);
}
public void nobobutton(View view) {
Uri u = Uri.parse("https://github.com/alex31n/NoboButton/blob/master/LICENSE");
Intent i = new Intent(Intent.ACTION_VIEW, u);
startActivity(i);
}
public void cImgButton(View view) {
Uri u = Uri.parse("https://github.com/hdodenhof/CircleImageView/blob/master/LICENSE.txt");
Intent i = new Intent(Intent.ACTION_VIEW, u);
startActivity(i);
}

public void nobobutton(View view) {
Uri u = Uri.parse("https://github.com/alex31n/NoboButton/blob/master/LICENSE");
Intent i = new Intent(Intent.ACTION_VIEW, u);
startActivity(i);
}

public void cImgButton(View view) {
Uri u = Uri.parse("https://github.com/hdodenhof/CircleImageView/blob/master/LICENSE.txt");
Intent i = new Intent(Intent.ACTION_VIEW, u);
startActivity(i);
}
}
117 changes: 106 additions & 11 deletions app/src/main/java/rocks/poopjournal/vacationdays/SettingsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,26 @@
import android.widget.TextView;
import android.widget.Toast;

import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

import com.opencsv.CSVReader;
import com.opencsv.exceptions.CsvValidationException;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;

import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
Expand All @@ -41,6 +49,89 @@ public class SettingsActivity extends AppCompatActivity {
private static final int STORAGE_REQUEST_CODE_EXPORT = 1;
private static final int STORAGE_REQUEST_CODE_IMPORT = 2;
private String[] storagepermission;
private final ActivityResultLauncher<String> importCSV = registerForActivityResult(new ActivityResultContracts.GetContent(), result -> {
if (result != null) {
try (CSVReader csvReader = new CSVReader(new InputStreamReader(getContentResolver().openInputStream(result)))) {
// List<String[]> restoreData = new ArrayList<>();

int k = Helper.data.size();
int counter;
if (k == 0) {
counter = 1;
} else {
counter = Helper.data.size();
}
for (int i = 0; i < counter; i++) {
Log.d("bakwaasinloop", "i am in" + counter);
String[] nextline;
while ((nextline = csvReader.readNext()) != null) {
String id = nextline[0];
String title = nextline[1];
String monthyear = nextline[2];
String dates = nextline[3];
String newdates = dates.replaceAll("geodholaz", ",");
int noOfHolidays = Integer.parseInt(nextline[4]);
db.insert_data(id, title, monthyear, newdates, noOfHolidays);
db.show_data();

Helper.holidayTitle = "";
k++;
}
}
Helper.whichTabSelected = 0;
Toast.makeText(this, Helper.whichTabSelected + "Restored...." + Helper.data.size(), Toast.LENGTH_SHORT).show();
Intent in = new Intent(SettingsActivity.this, MainActivity.class);
startActivity(in);
finish();
} catch (IOException | CsvValidationException e) {
e.printStackTrace();
}
}
});
private final ActivityResultLauncher<String> exportCSV = registerForActivityResult(new ActivityResultContracts.CreateDocument("text/plain"), result -> {
if (result != null) {
try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(getContentResolver().openOutputStream(result)))) {
for (int i = 0; i < Helper.data.size(); i++) {
bw.append(Helper.data.get(i)[0]);
bw.append(",");
bw.append(Helper.data.get(i)[1]);
bw.append(",");
bw.append(Helper.data.get(i)[2]);
bw.append(",");
String newdate = Helper.data.get(i)[3];
String new1 = newdate.replaceAll(",", "geodholaz");
Log.d("formatingdate", "" + new1);
bw.append(new1);
bw.append(",");
String noOfHolidays = Helper.data.get(i)[4];
bw.append(noOfHolidays);
bw.append(",");
bw.append("\n");
//Toast.makeText(this, "Backup Exported "+FileandPathname, Toast.LENGTH_LONG ).show();
}
Toast.makeText(this, "Backup Exported", Toast.LENGTH_LONG ).show();
/*final Dialog d = new Dialog(this);
d.requestWindowFeature(Window.FEATURE_NO_TITLE);
d.setContentView(R.layout.backup_dialogbox);
Button btnok = d.findViewById(R.id.btnok);
TextView path = d.findViewById(R.id.path);
path.setText("Backup Exported");
WindowManager.LayoutParams lp = d.getWindow().getAttributes();
lp.dimAmount = 0.9f;
d.getWindow().setAttributes(lp);
d.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
btnok.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
d.dismiss();
}
});
d.show();*/
} catch (IOException e) {

}
}
});


@Override
Expand All @@ -51,7 +142,7 @@ protected void onCreate(Bundle savedInstanceState) {
storagepermission = new String[]{WRITE_EXTERNAL_STORAGE};
modetitle = findViewById(R.id.modetitle);
noofvacations = findViewById(R.id.noOfvacations);
noofvacations.setText(""+Helper.totalHolidays);
noofvacations.setText("" + Helper.totalHolidays);
switch (rocks.poopjournal.vacationdays.Helper.isnightmodeon) {
case "followsys":
modetitle.setText("Follow System");
Expand Down Expand Up @@ -202,27 +293,28 @@ public void back(View view) {
Intent i = new Intent(this, MainActivity.class);
startActivity(i);
}

public void setnoofvacations(View view) {
final Dialog d = new Dialog(this);
d.requestWindowFeature(Window.FEATURE_NO_TITLE);
d.setContentView(R.layout.noofvacationsdialogbox);
Button btnsave = d.findViewById(R.id.savenoofvacations);
EditText noofvacations=d.findViewById(R.id.enterednoofvacations);
EditText noofvacations = d.findViewById(R.id.enterednoofvacations);
WindowManager.LayoutParams lp = d.getWindow().getAttributes();
lp.dimAmount = 0.9f;
d.getWindow().setAttributes(lp);
d.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
btnsave.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int setnoofvacations= Integer.parseInt(noofvacations.getText().toString());
int setnoofvacations = Integer.parseInt(noofvacations.getText().toString());
db.setnoofholidays(setnoofvacations);
noofvacations.setText(""+Helper.totalHolidays);
noofvacations.setText("" + Helper.totalHolidays);
d.dismiss();
Intent intennt = new Intent(SettingsActivity.this,SettingsActivity.class);
startActivity(intennt);
overridePendingTransition(0, 0);
finish();
Intent intennt = new Intent(SettingsActivity.this, SettingsActivity.class);
startActivity(intennt);
overridePendingTransition(0, 0);
finish();
}
});
d.show();
Expand Down Expand Up @@ -316,7 +408,8 @@ public void onRadioButtonClicked(View view) {


public void backup(View view) {
Toast.makeText(this, "This functionality will be available in next version", Toast.LENGTH_SHORT).show();
//Toast.makeText(this, "This functionality will be available in next version", Toast.LENGTH_SHORT).show();
exportCSV.launch("holidays_" + System.currentTimeMillis());

// if(checkStoragePermission()){
// Log.d("IntakePerExport","hello");
Expand All @@ -329,9 +422,11 @@ public void backup(View view) {
// requestStoragePermissionExport();
// }
}
//

//
public void restore(View view) {
Toast.makeText(this, "This functionality will be available in next version", Toast.LENGTH_SHORT).show();
//Toast.makeText(this, "This functionality will be available in next version", Toast.LENGTH_SHORT).show();
importCSV.launch("text/plain");

// String text="Bismillah di barkat";
//// savefile(file_name,text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,10 @@ public void onBindViewHolder(@NonNull SubItemViewHolder subItemViewHolder, int i
db.updateHabitsIdsForDeletion(subItem.getSubItemTitle(),subItem.getMonthyear(),updatedid);
db.show_data();
if(subItem.getStart().equals(subItem.getEnd())){
subItemViewHolder.startdate.setVisibility(View.INVISIBLE);
subItemViewHolder.to.setText(subItem.getStart());
subItemViewHolder.enddate.setVisibility(View.INVISIBLE);
subItemViewHolder.dateRange.setText(subItem.getStart());
}
else{
subItemViewHolder.startdate.setText(subItem.getStart());
subItemViewHolder.to.setBackgroundResource(R.drawable.arrow_down);
subItemViewHolder.enddate.setText(subItem.getEnd());
subItemViewHolder.dateRange.setText(con.getString(R.string.date_range, subItem.getStart(), subItem.getEnd()));
}

subItemViewHolder.img.setOnClickListener(new View.OnClickListener() {
Expand Down Expand Up @@ -98,16 +94,14 @@ public int getItemCount() {
return subItemList.size();
}

class SubItemViewHolder extends RecyclerView.ViewHolder {
TextView tvSubItemTitle, startdate, to, enddate;
static class SubItemViewHolder extends RecyclerView.ViewHolder {
TextView tvSubItemTitle, dateRange;
ImageView img;

SubItemViewHolder(View itemView) {
super(itemView);
tvSubItemTitle = itemView.findViewById(R.id.tv_sub_item_title);
startdate = itemView.findViewById(R.id.startdate);
to = itemView.findViewById(R.id.to);
enddate = itemView.findViewById(R.id.enddate);
dateRange = itemView.findViewById(R.id.date_range);
img=itemView.findViewById(R.id.btndel);
}
}
Expand Down
9 changes: 2 additions & 7 deletions app/src/main/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,13 @@
android:orientation="horizontal"
android:onClick="apacheee">

<TextView
android:id="@+id/versiontext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#776F6F"/>

<TextView
android:id="@+id/version"
android:text="@string/version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#776F6F"
/>
</LinearLayout>
</LinearLayout>
Expand Down
Loading

0 comments on commit e4b39b6

Please sign in to comment.